@tacitai/mcp-server 0.6.28 → 0.6.29
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/client.d.ts +10 -0
- package/dist/client.js +71 -0
- package/dist/flags.d.ts +11 -0
- package/dist/flags.js +33 -0
- package/dist/index.js +75 -4
- package/dist/prompts.d.ts +55 -0
- package/dist/prompts.js +26 -0
- package/dist/templates/role-loader.d.ts +9 -0
- package/dist/templates/role-loader.js +93 -0
- package/dist/tools/agents.d.ts +27 -4
- package/dist/tools/agents.js +110 -10
- package/dist/tools/cmo.d.ts +14 -0
- package/dist/tools/cmo.js +125 -0
- package/dist/tools/errors.js +4 -2
- package/dist/tools/outbox.d.ts +2 -2
- package/dist/tools/registry.d.ts +1 -1
- package/dist/tools/registry.js +14 -3
- package/dist/tools/workflow-prereqs.d.ts +16 -0
- package/dist/tools/workflow-prereqs.js +29 -0
- package/dist/tools/workflow-types.d.ts +11 -0
- package/dist/tools/workflow-types.js +179 -0
- package/dist/tools/workflow.d.ts +9 -0
- package/dist/tools/workflow.js +134 -0
- package/dist/workflow-gate.d.ts +173 -78
- package/dist/workflow-gate.js +741 -156
- package/dist/workflow-persistence.d.ts +25 -0
- package/dist/workflow-persistence.js +127 -0
- package/dist/workflow-registry.d.ts +80 -0
- package/dist/workflow-registry.js +375 -0
- package/dist/workflow-type-schema.d.ts +11 -0
- package/dist/workflow-type-schema.js +92 -0
- package/package.json +2 -1
package/dist/tools/agents.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { z } from 'zod';
|
|
13
13
|
import { getClient, TacitApiError, TokenExpiredError } from '../client.js';
|
|
14
14
|
import { featureDisabledResult } from './errors.js';
|
|
15
|
+
import { loadRoleTemplates } from '../templates/role-loader.js';
|
|
15
16
|
function apiErrorResult(err, toolName) {
|
|
16
17
|
if (err instanceof TokenExpiredError) {
|
|
17
18
|
return {
|
|
@@ -53,8 +54,33 @@ export function buildAgentListRequest(client, input) {
|
|
|
53
54
|
const args = {};
|
|
54
55
|
if (input.limit !== undefined)
|
|
55
56
|
args['limit'] = input.limit;
|
|
56
|
-
const
|
|
57
|
-
|
|
57
|
+
const templates = loadRoleTemplates();
|
|
58
|
+
let instances = [];
|
|
59
|
+
try {
|
|
60
|
+
const result = await callAgentTool(client, 'tacit.agents.list', args);
|
|
61
|
+
const r = result;
|
|
62
|
+
const list = Array.isArray(r) ? r : r?.agents;
|
|
63
|
+
if (Array.isArray(list))
|
|
64
|
+
instances = list;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// business_agents table may not exist (migration 349 RESERVED)
|
|
68
|
+
}
|
|
69
|
+
const merged = templates.map((t) => {
|
|
70
|
+
const inst = instances.find((i) => i['role_slug'] === t.slug);
|
|
71
|
+
return {
|
|
72
|
+
role_slug: t.slug,
|
|
73
|
+
display_name: inst?.['name'] ?? t.display_name,
|
|
74
|
+
description: t.description,
|
|
75
|
+
icon: t.icon,
|
|
76
|
+
default_capabilities: t.default_capabilities,
|
|
77
|
+
workflow_types: t.workflow_types,
|
|
78
|
+
instance: inst
|
|
79
|
+
? { agent_id: inst['agent_id'] ?? inst['id'], status: inst['status'], health: inst['health'] }
|
|
80
|
+
: null,
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
return { content: [{ type: 'text', text: JSON.stringify({ agents: merged }) }] };
|
|
58
84
|
}
|
|
59
85
|
catch (err) {
|
|
60
86
|
return apiErrorResult(err, 'tacit_agent_list');
|
|
@@ -71,34 +97,107 @@ export async function handleAgentList(args) {
|
|
|
71
97
|
}
|
|
72
98
|
// ─── tacit_agent_delegate ────────────────────────────────────────────────────
|
|
73
99
|
export const agentDelegateInputSchema = z.object({
|
|
74
|
-
agent_id: z.string().min(1).describe('UUID of the agent to delegate to'),
|
|
100
|
+
agent_id: z.string().min(1).optional().describe('UUID of the agent to delegate to (provide this OR role_slug)'),
|
|
101
|
+
role_slug: z.string().min(1).optional().describe('Role template slug (e.g. "wiki_editor"). Resolves to agent_id; creates instance on first use'),
|
|
75
102
|
task: z.string().min(1).describe('Task description to delegate'),
|
|
76
103
|
kind: z.string().optional().describe('Task kind (default: "task")'),
|
|
77
104
|
target_ids: z.array(z.string()).optional().describe('Target entity UUIDs for the task'),
|
|
78
105
|
program_ids: z.array(z.string()).optional().describe('Program UUIDs to scope the task'),
|
|
79
106
|
dossier_ids: z.array(z.string()).optional().describe('Dossier UUIDs to scope the task'),
|
|
80
|
-
});
|
|
107
|
+
}).refine((d) => d.agent_id || d.role_slug, { message: 'Either agent_id or role_slug is required' });
|
|
81
108
|
export const AGENT_DELEGATE_TOOL_DEF = {
|
|
82
109
|
name: 'tacit_agent_delegate',
|
|
83
|
-
description: 'Delegate a task to a business agent.
|
|
110
|
+
description: 'Delegate a task to a business agent. Accepts agent_id (UUID) or role_slug (template name). ' +
|
|
111
|
+
'When role_slug is used and no instance exists, the agent is created on first delegation. ' +
|
|
112
|
+
'The task is fingerprint-deduped and dispatched to the run engine. ' +
|
|
84
113
|
'Returns assignment_id, run_id, and status. Duplicate tasks return status "duplicate" with the existing assignment.',
|
|
85
114
|
inputSchema: {
|
|
86
115
|
type: 'object',
|
|
87
116
|
properties: {
|
|
88
|
-
agent_id: { type: 'string', description: 'UUID of the agent to delegate to' },
|
|
117
|
+
agent_id: { type: 'string', description: 'UUID of the agent to delegate to (provide this OR role_slug)' },
|
|
118
|
+
role_slug: { type: 'string', description: 'Role template slug (e.g. "wiki_editor"). Creates instance on first use' },
|
|
89
119
|
task: { type: 'string', description: 'Task description to delegate' },
|
|
90
120
|
kind: { type: 'string', description: 'Task kind (default: "task")' },
|
|
91
121
|
target_ids: { type: 'array', items: { type: 'string' }, description: 'Target entity UUIDs' },
|
|
92
122
|
program_ids: { type: 'array', items: { type: 'string' }, description: 'Program UUIDs to scope the task' },
|
|
93
123
|
dossier_ids: { type: 'array', items: { type: 'string' }, description: 'Dossier UUIDs to scope the task' },
|
|
94
124
|
},
|
|
95
|
-
required: ['
|
|
125
|
+
required: ['task'],
|
|
96
126
|
},
|
|
97
127
|
};
|
|
128
|
+
async function resolveAgentId(client, input) {
|
|
129
|
+
if (input.agent_id)
|
|
130
|
+
return { agent_id: input.agent_id };
|
|
131
|
+
const slug = input.role_slug;
|
|
132
|
+
if (!slug)
|
|
133
|
+
return { error: 'Either agent_id or role_slug is required' };
|
|
134
|
+
const template = loadRoleTemplates().find((t) => t.slug === slug);
|
|
135
|
+
if (!template)
|
|
136
|
+
return { error: `Unknown role_slug: ${slug}` };
|
|
137
|
+
try {
|
|
138
|
+
const result = await callAgentTool(client, 'tacit.agents.list', {});
|
|
139
|
+
const r = result;
|
|
140
|
+
const list = Array.isArray(r)
|
|
141
|
+
? r
|
|
142
|
+
: (r?.items ??
|
|
143
|
+
r?.agents);
|
|
144
|
+
if (Array.isArray(list)) {
|
|
145
|
+
const existing = list.find((i) => i['role_slug'] === slug);
|
|
146
|
+
if (existing) {
|
|
147
|
+
const id = (existing['agent_id'] ?? existing['id']);
|
|
148
|
+
if (id)
|
|
149
|
+
return { agent_id: id };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
// list failed — fall through to create
|
|
155
|
+
}
|
|
156
|
+
// No instance exists — create one (lazy materialization)
|
|
157
|
+
try {
|
|
158
|
+
const created = await callAgentTool(client, 'tacit.agents.create', {
|
|
159
|
+
name: template.display_name,
|
|
160
|
+
role_slug: slug,
|
|
161
|
+
archetype: 'executive',
|
|
162
|
+
});
|
|
163
|
+
const id = (created['agent_id'] ?? created['id']);
|
|
164
|
+
if (id)
|
|
165
|
+
return { agent_id: id };
|
|
166
|
+
return { error: 'Agent creation returned no id' };
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
170
|
+
// Unique constraint collision — agent was created concurrently; re-list
|
|
171
|
+
if (msg.includes('duplicate key') || msg.includes('unique constraint')) {
|
|
172
|
+
try {
|
|
173
|
+
const retry = await callAgentTool(client, 'tacit.agents.list', {});
|
|
174
|
+
const rr = retry;
|
|
175
|
+
const rlist = Array.isArray(rr)
|
|
176
|
+
? rr
|
|
177
|
+
: (rr?.items ??
|
|
178
|
+
rr?.agents);
|
|
179
|
+
if (Array.isArray(rlist)) {
|
|
180
|
+
const found = rlist.find((i) => i['role_slug'] === slug);
|
|
181
|
+
if (found) {
|
|
182
|
+
const fid = (found['agent_id'] ?? found['id']);
|
|
183
|
+
if (fid)
|
|
184
|
+
return { agent_id: fid };
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
catch { /* re-list also failed */ }
|
|
189
|
+
}
|
|
190
|
+
return { error: `Failed to create agent instance for ${slug}: ${msg}` };
|
|
191
|
+
}
|
|
192
|
+
}
|
|
98
193
|
export function buildAgentDelegateRequest(client, input) {
|
|
99
194
|
return {
|
|
100
195
|
async execute() {
|
|
101
196
|
try {
|
|
197
|
+
const resolved = await resolveAgentId(client, input);
|
|
198
|
+
if ('error' in resolved) {
|
|
199
|
+
return { content: [{ type: 'text', text: resolved.error }], isError: true };
|
|
200
|
+
}
|
|
102
201
|
const spec = { task: input.task };
|
|
103
202
|
if (input.kind)
|
|
104
203
|
spec['kind'] = input.kind;
|
|
@@ -109,7 +208,7 @@ export function buildAgentDelegateRequest(client, input) {
|
|
|
109
208
|
if (input.dossier_ids)
|
|
110
209
|
spec['dossier_ids'] = input.dossier_ids;
|
|
111
210
|
const result = await callAgentTool(client, 'tacit.agents.delegate', {
|
|
112
|
-
agent_id:
|
|
211
|
+
agent_id: resolved.agent_id,
|
|
113
212
|
spec,
|
|
114
213
|
});
|
|
115
214
|
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
@@ -296,8 +395,9 @@ export function registerAgentTools(server, getClientFn) {
|
|
|
296
395
|
const client = await getClientFn();
|
|
297
396
|
return buildAgentListRequest(client, args).execute();
|
|
298
397
|
});
|
|
299
|
-
server.tool('tacit_agent_delegate', 'Delegate a task to a business agent.', {
|
|
300
|
-
agent_id: z.string().min(1).describe('UUID of the agent to delegate to'),
|
|
398
|
+
server.tool('tacit_agent_delegate', 'Delegate a task to a business agent. Accepts agent_id (UUID) or role_slug (template name like "wiki_editor"). Creates instance on first use.', {
|
|
399
|
+
agent_id: z.string().min(1).optional().describe('UUID of the agent to delegate to (provide this OR role_slug)'),
|
|
400
|
+
role_slug: z.string().min(1).optional().describe('Role template slug (e.g. "wiki_editor"). Creates instance on first use'),
|
|
301
401
|
task: z.string().min(1).describe('Task description to delegate'),
|
|
302
402
|
kind: z.string().optional().describe('Task kind'),
|
|
303
403
|
target_ids: z.array(z.string()).optional().describe('Target entity UUIDs'),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tacit_cmo_lint — deterministic D-rule checks (MV-1539 W3 Step 12b).
|
|
3
|
+
*
|
|
4
|
+
* Applies MR-D01..D08 from MARKETING-RULES.json. H-rules and J-rules
|
|
5
|
+
* (model-dependent) are skill-layer only. Stateless, preCall-exempt.
|
|
6
|
+
*/
|
|
7
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
8
|
+
export interface LintViolation {
|
|
9
|
+
ruleId: string;
|
|
10
|
+
title: string;
|
|
11
|
+
detail: string;
|
|
12
|
+
severity: 'FAIL' | 'WARN';
|
|
13
|
+
}
|
|
14
|
+
export declare function registerCmoTools(server: McpServer): void;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tacit_cmo_lint — deterministic D-rule checks (MV-1539 W3 Step 12b).
|
|
3
|
+
*
|
|
4
|
+
* Applies MR-D01..D08 from MARKETING-RULES.json. H-rules and J-rules
|
|
5
|
+
* (model-dependent) are skill-layer only. Stateless, preCall-exempt.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import * as fs from 'fs';
|
|
9
|
+
import * as path from 'path';
|
|
10
|
+
const lintSchema = z.object({
|
|
11
|
+
content: z.string().describe('The HTML content to lint'),
|
|
12
|
+
assetType: z.string().optional().describe('Asset type (e.g. report, deck, short-story)'),
|
|
13
|
+
});
|
|
14
|
+
function loadRules() {
|
|
15
|
+
const primary = path.join(process.cwd(), '.claude/skills/cmo/assets/MARKETING-RULES.json');
|
|
16
|
+
const fallback = process.env['MARKETING_RULES_PATH'];
|
|
17
|
+
const filePath = fs.existsSync(primary) ? primary : fallback;
|
|
18
|
+
if (!filePath || !fs.existsSync(filePath))
|
|
19
|
+
return null;
|
|
20
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
21
|
+
}
|
|
22
|
+
function isChannelNative(rulesFile, assetType) {
|
|
23
|
+
if (!assetType)
|
|
24
|
+
return false;
|
|
25
|
+
return rulesFile.asset_type_classes?.channel_native?.types?.includes(assetType) ?? false;
|
|
26
|
+
}
|
|
27
|
+
function checkD02(content) {
|
|
28
|
+
if (!/Quarterback\s+AI\s+Inc\./i.test(content)) {
|
|
29
|
+
return { ruleId: 'MR-D02', title: 'Legal footer present', detail: 'Missing "Quarterback AI Inc." text', severity: 'FAIL' };
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
function checkD03(content) {
|
|
34
|
+
const violations = [];
|
|
35
|
+
if (!/\d{4}-\d{2}-\d{2}/.test(content)) {
|
|
36
|
+
violations.push({ ruleId: 'MR-D03a', title: 'ISO date missing', detail: 'No ISO 8601 date (YYYY-MM-DD) found', severity: 'FAIL' });
|
|
37
|
+
}
|
|
38
|
+
if (!/v\d+\.\d+/i.test(content)) {
|
|
39
|
+
violations.push({ ruleId: 'MR-D03b', title: 'Version number missing', detail: 'No version number (vN.N) found', severity: 'FAIL' });
|
|
40
|
+
}
|
|
41
|
+
if (!/version\s+history|changelog/i.test(content)) {
|
|
42
|
+
violations.push({ ruleId: 'MR-D03c', title: 'Version history heading missing', detail: 'No "Version History" or "Changelog" heading found', severity: 'FAIL' });
|
|
43
|
+
}
|
|
44
|
+
return violations;
|
|
45
|
+
}
|
|
46
|
+
function checkD04(content) {
|
|
47
|
+
if (!/missions\/|results\/|docs\//i.test(content)) {
|
|
48
|
+
return { ruleId: 'MR-D04', title: 'Deliverable path', detail: 'No deliverable file path reference found', severity: 'WARN' };
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
function checkD07(content) {
|
|
53
|
+
const hasStoryMarkers = /fiction|fictional|story|narrative|imagin/i.test(content);
|
|
54
|
+
if (hasStoryMarkers && !/this\s+(is\s+)?(a\s+)?fiction|fictional|work\s+of\s+fiction|disclosure/i.test(content)) {
|
|
55
|
+
return { ruleId: 'MR-D07', title: 'Fiction disclosure present', detail: 'Content appears fictional but lacks explicit fiction disclosure', severity: 'FAIL' };
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
function checkD08(content, allowedDomains) {
|
|
60
|
+
const violations = [];
|
|
61
|
+
const urlRegex = /https?:\/\/([a-zA-Z0-9.-]+)/g;
|
|
62
|
+
let match;
|
|
63
|
+
const seen = new Set();
|
|
64
|
+
while ((match = urlRegex.exec(content)) !== null) {
|
|
65
|
+
const domain = match[1].toLowerCase();
|
|
66
|
+
if (seen.has(domain))
|
|
67
|
+
continue;
|
|
68
|
+
seen.add(domain);
|
|
69
|
+
const allowed = allowedDomains.some((d) => domain === d || domain.endsWith('.' + d));
|
|
70
|
+
if (!allowed) {
|
|
71
|
+
violations.push({ ruleId: 'MR-D08', title: 'Link domain allowlist', detail: `Domain not in allowlist: ${domain}`, severity: 'FAIL' });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return violations;
|
|
75
|
+
}
|
|
76
|
+
function checkD01(content) {
|
|
77
|
+
const violations = [];
|
|
78
|
+
const hexWhites = /#(?:fff(?:fff)?|fefefe|fdfdfd|fcfcfc|fbfbfb|fafafa|f9f9f9|f8f8f8|f7f7f7|f6f6f6|f5f5f5|f4f4f4|f3f3f3|f2f2f2|f1f1f1|f0f0f0)\b/gi;
|
|
79
|
+
const matches = content.match(hexWhites);
|
|
80
|
+
if (matches && matches.length > 0) {
|
|
81
|
+
const unique = [...new Set(matches.map((m) => m.toLowerCase()))];
|
|
82
|
+
violations.push({ ruleId: 'MR-D01', title: 'No near-white backgrounds', detail: `Near-white hex values found: ${unique.join(', ')}`, severity: 'FAIL' });
|
|
83
|
+
}
|
|
84
|
+
if (/background[^;]*:\s*white\b/i.test(content)) {
|
|
85
|
+
violations.push({ ruleId: 'MR-D01', title: 'No near-white backgrounds', detail: 'CSS "white" keyword used for background', severity: 'FAIL' });
|
|
86
|
+
}
|
|
87
|
+
return violations;
|
|
88
|
+
}
|
|
89
|
+
export function registerCmoTools(server) {
|
|
90
|
+
const rulesFile = loadRules();
|
|
91
|
+
const allowedDomains = rulesFile?.allowed_link_domains.map((d) => d.domain) ?? [];
|
|
92
|
+
server.tool('tacit_cmo_lint', 'Run deterministic D-rule checks (MR-D01..D08) on marketing content. Returns structured violations.', lintSchema.shape, async (args) => {
|
|
93
|
+
const parsed = lintSchema.safeParse(args);
|
|
94
|
+
if (!parsed.success) {
|
|
95
|
+
return { content: [{ type: 'text', text: JSON.stringify({ error: 'invalid_input', detail: parsed.error.message }) }], isError: true };
|
|
96
|
+
}
|
|
97
|
+
const { content, assetType } = parsed.data;
|
|
98
|
+
const violations = [];
|
|
99
|
+
const channelNative = rulesFile ? isChannelNative(rulesFile, assetType) : false;
|
|
100
|
+
// D01: near-white backgrounds
|
|
101
|
+
violations.push(...checkD01(content));
|
|
102
|
+
// D02: legal footer (skip for channel-native per spec)
|
|
103
|
+
if (!channelNative) {
|
|
104
|
+
const v = checkD02(content);
|
|
105
|
+
if (v)
|
|
106
|
+
violations.push(v);
|
|
107
|
+
}
|
|
108
|
+
// D03: date, version, history (skip for channel-native)
|
|
109
|
+
if (!channelNative)
|
|
110
|
+
violations.push(...checkD03(content));
|
|
111
|
+
// D04: deliverable path
|
|
112
|
+
const d04 = checkD04(content);
|
|
113
|
+
if (d04)
|
|
114
|
+
violations.push(d04);
|
|
115
|
+
// D07: fiction disclosure
|
|
116
|
+
const d07 = checkD07(content);
|
|
117
|
+
if (d07)
|
|
118
|
+
violations.push(d07);
|
|
119
|
+
// D08: link domain allowlist
|
|
120
|
+
violations.push(...checkD08(content, allowedDomains));
|
|
121
|
+
return {
|
|
122
|
+
content: [{ type: 'text', text: JSON.stringify({ violations, count: violations.length, rulesChecked: 6, rulesVersion: rulesFile?.rules?.length ?? 0 }) }],
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
}
|
package/dist/tools/errors.js
CHANGED
|
@@ -18,8 +18,10 @@ export function featureDisabledResult(err) {
|
|
|
18
18
|
if (parsed?.error?.code !== 'FEATURE_DISABLED')
|
|
19
19
|
return null;
|
|
20
20
|
const flagMatch = parsed.error.message?.match(/feature flag ([A-Z][A-Z0-9_]*) is off/);
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
if (flagMatch) {
|
|
22
|
+
return error(`Feature flag ${flagMatch[1]} is disabled on this cell. Enable it in the flag registry and restart.`);
|
|
23
|
+
}
|
|
24
|
+
return error(`Feature disabled: ${parsed.error.message || 'unknown reason'}`);
|
|
23
25
|
}
|
|
24
26
|
export function apiErrorResult(err, endpoint) {
|
|
25
27
|
if (err instanceof TokenExpiredError) {
|
package/dist/tools/outbox.d.ts
CHANGED
|
@@ -110,8 +110,8 @@ export declare const outboxWriteInputSchema: z.ZodObject<{
|
|
|
110
110
|
};
|
|
111
111
|
content_origin: "agent" | "human" | "git_sync";
|
|
112
112
|
content_format: "MARKDOWN" | "HTML" | "PLAIN_TEXT";
|
|
113
|
-
source_agent_id?: string | undefined;
|
|
114
113
|
autonomy_level?: "MENTAT" | "TWIN" | undefined;
|
|
114
|
+
source_agent_id?: string | undefined;
|
|
115
115
|
idempotency_key?: string | undefined;
|
|
116
116
|
replaces_object_id?: string | undefined;
|
|
117
117
|
}, {
|
|
@@ -132,9 +132,9 @@ export declare const outboxWriteInputSchema: z.ZodObject<{
|
|
|
132
132
|
})[] | undefined;
|
|
133
133
|
} | undefined;
|
|
134
134
|
};
|
|
135
|
+
autonomy_level?: "MENTAT" | "TWIN" | undefined;
|
|
135
136
|
content_origin?: "agent" | "human" | "git_sync" | undefined;
|
|
136
137
|
source_agent_id?: string | undefined;
|
|
137
|
-
autonomy_level?: "MENTAT" | "TWIN" | undefined;
|
|
138
138
|
idempotency_key?: string | undefined;
|
|
139
139
|
replaces_object_id?: string | undefined;
|
|
140
140
|
content_format?: "MARKDOWN" | "HTML" | "PLAIN_TEXT" | undefined;
|
package/dist/tools/registry.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compile-time tool classification. Governs which tools may be called over HTTPS.
|
|
3
|
-
* Partition: 6 stdio_only + 18 admin_only + 2 gate_only +
|
|
3
|
+
* Partition: 6 stdio_only + 18 admin_only + 2 gate_only + 142 https = 168.
|
|
4
4
|
*/
|
|
5
5
|
export type ToolTransport = 'https' | 'stdio_only' | 'admin_only' | 'gate_only';
|
|
6
6
|
export type ToolClass = 'read' | 'write' | 'admin' | 'dispatch';
|
package/dist/tools/registry.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compile-time tool classification. Governs which tools may be called over HTTPS.
|
|
3
|
-
* Partition: 6 stdio_only + 18 admin_only + 2 gate_only +
|
|
3
|
+
* Partition: 6 stdio_only + 18 admin_only + 2 gate_only + 142 https = 168.
|
|
4
4
|
*/
|
|
5
5
|
const STDIO_ONLY = [
|
|
6
6
|
'tacit_ingest_file',
|
|
@@ -32,6 +32,7 @@ const ADMIN_ONLY = [
|
|
|
32
32
|
];
|
|
33
33
|
const GATE_ONLY = ['tacit_approve_gate', 'tacit_reject_gate'];
|
|
34
34
|
const READ_TOOLS = [
|
|
35
|
+
'tacit_workflow_prereqs',
|
|
35
36
|
'tacit_agent_approvals',
|
|
36
37
|
'tacit_agent_list',
|
|
37
38
|
'tacit_agent_thread',
|
|
@@ -46,6 +47,7 @@ const READ_TOOLS = [
|
|
|
46
47
|
'tacit_chronicle_graph',
|
|
47
48
|
'tacit_chronicle_search',
|
|
48
49
|
'tacit_chronicle_timeline',
|
|
50
|
+
'tacit_cmo_lint',
|
|
49
51
|
'tacit_converse_messages',
|
|
50
52
|
'tacit_converse_sessions',
|
|
51
53
|
'tacit_crew_history',
|
|
@@ -170,6 +172,15 @@ const WRITE_TOOLS = [
|
|
|
170
172
|
'tacit_wiki_author',
|
|
171
173
|
'tacit_wiki_override',
|
|
172
174
|
'tacit_wiki_write',
|
|
175
|
+
'tacit_workflow_advance',
|
|
176
|
+
'tacit_workflow_deactivate',
|
|
177
|
+
'tacit_workflow_handoff',
|
|
178
|
+
'tacit_workflow_resume',
|
|
179
|
+
'tacit_workflow_set_metadata',
|
|
180
|
+
'tacit_workflow_start',
|
|
181
|
+
'tacit_workflow_type_create',
|
|
182
|
+
'tacit_workflow_type_list',
|
|
183
|
+
'tacit_workflow_type_update',
|
|
173
184
|
];
|
|
174
185
|
function build() {
|
|
175
186
|
const map = new Map();
|
|
@@ -196,8 +207,8 @@ function build() {
|
|
|
196
207
|
if (!exclusive.has(n))
|
|
197
208
|
add(n, classOf(n), 'https', false);
|
|
198
209
|
}
|
|
199
|
-
if (map.size !==
|
|
200
|
-
throw new Error(`tool registry expected
|
|
210
|
+
if (map.size !== 163)
|
|
211
|
+
throw new Error(`tool registry expected 163 tools, got ${map.size}`);
|
|
201
212
|
return map;
|
|
202
213
|
}
|
|
203
214
|
export const TOOL_REGISTRY = build();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { WorkflowRegistry } from '../workflow-registry.js';
|
|
3
|
+
export interface PrereqsResult {
|
|
4
|
+
tool: string;
|
|
5
|
+
workflowType: string | null;
|
|
6
|
+
chain: string[];
|
|
7
|
+
phases: Array<{
|
|
8
|
+
name: string;
|
|
9
|
+
requiredTools: readonly string[];
|
|
10
|
+
gatedTools: readonly string[];
|
|
11
|
+
approvalGate: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
flagActive: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function handleWorkflowPrereqs(registry: WorkflowRegistry, isTypeActive: (name: string) => boolean, toolName: string): PrereqsResult;
|
|
16
|
+
export declare function registerWorkflowPrereqsTool(server: McpServer, registry: WorkflowRegistry): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export function handleWorkflowPrereqs(registry, isTypeActive, toolName) {
|
|
3
|
+
const typeDef = registry
|
|
4
|
+
.findByTool(toolName)
|
|
5
|
+
.find((d) => d.prereqs.kind === 'phased');
|
|
6
|
+
if (!typeDef || typeDef.prereqs.kind !== 'phased') {
|
|
7
|
+
return { tool: toolName, workflowType: null, chain: [], phases: [], flagActive: true };
|
|
8
|
+
}
|
|
9
|
+
const phases = typeDef.prereqs.phases;
|
|
10
|
+
const chain = [...new Set(phases.flatMap((p) => [...p.requiredTools, ...p.gatedTools]))];
|
|
11
|
+
return {
|
|
12
|
+
tool: toolName,
|
|
13
|
+
workflowType: typeDef.name,
|
|
14
|
+
chain,
|
|
15
|
+
phases: phases.map((p) => ({
|
|
16
|
+
name: p.name,
|
|
17
|
+
requiredTools: p.requiredTools,
|
|
18
|
+
gatedTools: p.gatedTools,
|
|
19
|
+
approvalGate: p.approvalGate ?? false,
|
|
20
|
+
})),
|
|
21
|
+
flagActive: isTypeActive(typeDef.name),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function registerWorkflowPrereqsTool(server, registry) {
|
|
25
|
+
server.tool('tacit_workflow_prereqs', 'Discover the workflow prerequisite chain for a tool before calling it. Read-only.', { tool_name: z.string().describe('Name of the tool to look up, e.g. tacit_dispatch_crew') }, async (args) => {
|
|
26
|
+
const result = handleWorkflowPrereqs(registry, () => true, args.tool_name);
|
|
27
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tools for user-authored workflow types (MV-1539 W7 Step 30).
|
|
3
|
+
*
|
|
4
|
+
* tacit_workflow_type_list — list system + user types for current workspace
|
|
5
|
+
* tacit_workflow_type_create — create a user-authored type (T2 approval gate)
|
|
6
|
+
* tacit_workflow_type_update — update an existing user type definition
|
|
7
|
+
*/
|
|
8
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
9
|
+
import type { TacitClient } from '../client.js';
|
|
10
|
+
import type { WorkflowRegistry } from '../workflow-registry.js';
|
|
11
|
+
export declare function registerWorkflowTypeTools(server: McpServer, getClient: () => Promise<TacitClient>, registry: WorkflowRegistry): void;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tools for user-authored workflow types (MV-1539 W7 Step 30).
|
|
3
|
+
*
|
|
4
|
+
* tacit_workflow_type_list — list system + user types for current workspace
|
|
5
|
+
* tacit_workflow_type_create — create a user-authored type (T2 approval gate)
|
|
6
|
+
* tacit_workflow_type_update — update an existing user type definition
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import { isUserWorkflowTypesActive } from '../flags.js';
|
|
10
|
+
import { validateUserTypeDef, SYSTEM_RESERVED_TYPE_NAMES } from '../workflow-type-schema.js';
|
|
11
|
+
const listSchema = z.object({});
|
|
12
|
+
const createSchema = z.object({
|
|
13
|
+
name: z.string().describe('Type name (lowercase, 3-64 chars, a-z0-9_)'),
|
|
14
|
+
definition: z.record(z.unknown()).describe('Full workflow type definition (prereqs, failDirection, etc.)'),
|
|
15
|
+
base_type: z.string().optional().describe('System type name to fork from (merges base with overrides)'),
|
|
16
|
+
});
|
|
17
|
+
const updateSchema = z.object({
|
|
18
|
+
id: z.string().uuid().describe('UUID of the user type to update'),
|
|
19
|
+
definition: z.record(z.unknown()).describe('Updated workflow type definition'),
|
|
20
|
+
});
|
|
21
|
+
function jsonResult(data, isError = false) {
|
|
22
|
+
return {
|
|
23
|
+
content: [{ type: 'text', text: JSON.stringify(data) }],
|
|
24
|
+
isError,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function rowToTypeDef(row) {
|
|
28
|
+
const def = row.definition;
|
|
29
|
+
return {
|
|
30
|
+
...def,
|
|
31
|
+
name: row.name,
|
|
32
|
+
entryTool: def.entryTool ?? null,
|
|
33
|
+
failDirection: def.failDirection ?? 'open',
|
|
34
|
+
sharedToolPolicy: def.sharedToolPolicy ?? 'passthrough',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function registerWorkflowTypeTools(server, getClient, registry) {
|
|
38
|
+
server.tool('tacit_workflow_type_list', 'List all workflow types (system + user-authored) for the current workspace.', listSchema.shape, async () => {
|
|
39
|
+
const client = await getClient();
|
|
40
|
+
const workspaceId = client.workspaceId;
|
|
41
|
+
if (!workspaceId) {
|
|
42
|
+
return jsonResult({ error: 'no_workspace', detail: 'No workspace context available' }, true);
|
|
43
|
+
}
|
|
44
|
+
const systemTypes = registry.list().map((t) => ({
|
|
45
|
+
name: t.name,
|
|
46
|
+
is_system: true,
|
|
47
|
+
guidance: t.guidance ?? null,
|
|
48
|
+
persistent: t.persistent ?? false,
|
|
49
|
+
maxInstances: t.maxInstances ?? 1,
|
|
50
|
+
}));
|
|
51
|
+
if (!isUserWorkflowTypesActive()) {
|
|
52
|
+
return jsonResult({ types: systemTypes });
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const result = await client.get('/api/v1/workflow-types', {
|
|
56
|
+
workspace_id: workspaceId,
|
|
57
|
+
});
|
|
58
|
+
const userTypes = (result.types ?? []).map((row) => ({
|
|
59
|
+
id: row.id,
|
|
60
|
+
name: row.name,
|
|
61
|
+
is_system: false,
|
|
62
|
+
base_type: row.base_type,
|
|
63
|
+
version: row.version,
|
|
64
|
+
created_at: row.created_at,
|
|
65
|
+
updated_at: row.updated_at,
|
|
66
|
+
}));
|
|
67
|
+
return jsonResult({ types: [...systemTypes, ...userTypes] });
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return jsonResult({ types: systemTypes, _note: 'user types unavailable (backend unreachable)' });
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
server.tool('tacit_workflow_type_create', 'Create a user-authored workflow type for the current workspace.', createSchema.shape, async (args) => {
|
|
74
|
+
if (!isUserWorkflowTypesActive()) {
|
|
75
|
+
return jsonResult({ error: 'feature_disabled', detail: 'FEATURE_WORKFLOW_USER_TYPES is not enabled' }, true);
|
|
76
|
+
}
|
|
77
|
+
const parsed = createSchema.safeParse(args);
|
|
78
|
+
if (!parsed.success) {
|
|
79
|
+
return jsonResult({ error: 'invalid_input', detail: parsed.error.message }, true);
|
|
80
|
+
}
|
|
81
|
+
const { name, definition, base_type } = parsed.data;
|
|
82
|
+
const client = await getClient();
|
|
83
|
+
const workspaceId = client.workspaceId;
|
|
84
|
+
if (!workspaceId) {
|
|
85
|
+
return jsonResult({ error: 'no_workspace', detail: 'No workspace context available' }, true);
|
|
86
|
+
}
|
|
87
|
+
let mergedDef = { ...definition, name };
|
|
88
|
+
if (base_type) {
|
|
89
|
+
if (!SYSTEM_RESERVED_TYPE_NAMES.includes(base_type)) {
|
|
90
|
+
return jsonResult({ error: 'invalid_base_type', detail: `Base type '${base_type}' is not a system type` }, true);
|
|
91
|
+
}
|
|
92
|
+
const baseDef = registry.get(base_type);
|
|
93
|
+
if (!baseDef) {
|
|
94
|
+
return jsonResult({ error: 'base_type_not_found', detail: `System type '${base_type}' not found in registry` }, true);
|
|
95
|
+
}
|
|
96
|
+
const baseObj = JSON.parse(JSON.stringify(baseDef));
|
|
97
|
+
mergedDef = { ...baseObj, ...definition, name };
|
|
98
|
+
}
|
|
99
|
+
const validation = validateUserTypeDef(mergedDef);
|
|
100
|
+
if (!validation.valid) {
|
|
101
|
+
return jsonResult({ error: 'validation_failed', errors: validation.errors }, true);
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
const result = await client.post('/api/v1/workflow-types', {
|
|
105
|
+
workspace_id: workspaceId,
|
|
106
|
+
name,
|
|
107
|
+
definition: mergedDef,
|
|
108
|
+
base_type: base_type ?? null,
|
|
109
|
+
});
|
|
110
|
+
registry.registerUserType(rowToTypeDef(result), workspaceId);
|
|
111
|
+
return jsonResult({
|
|
112
|
+
id: result.id,
|
|
113
|
+
name: result.name,
|
|
114
|
+
version: result.version,
|
|
115
|
+
created_at: result.created_at,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
120
|
+
if (msg.includes('reserved_type_name')) {
|
|
121
|
+
return jsonResult({ error: 'reserved_type_name', name }, true);
|
|
122
|
+
}
|
|
123
|
+
if (msg.includes('reserved_tool')) {
|
|
124
|
+
return jsonResult({ error: 'reserved_tool', detail: msg }, true);
|
|
125
|
+
}
|
|
126
|
+
if (msg.includes('DUPLICATE_TYPE_NAME') || msg.includes('duplicate key')) {
|
|
127
|
+
return jsonResult({ error: 'duplicate_type_name', detail: `Type '${name}' already exists in this workspace` }, true);
|
|
128
|
+
}
|
|
129
|
+
return jsonResult({ error: 'backend_unreachable', detail: msg }, true);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
server.tool('tacit_workflow_type_update', 'Update the definition of a user-authored workflow type.', updateSchema.shape, async (args) => {
|
|
133
|
+
if (!isUserWorkflowTypesActive()) {
|
|
134
|
+
return jsonResult({ error: 'feature_disabled', detail: 'FEATURE_WORKFLOW_USER_TYPES is not enabled' }, true);
|
|
135
|
+
}
|
|
136
|
+
const parsed = updateSchema.safeParse(args);
|
|
137
|
+
if (!parsed.success) {
|
|
138
|
+
return jsonResult({ error: 'invalid_input', detail: parsed.error.message }, true);
|
|
139
|
+
}
|
|
140
|
+
const { id, definition } = parsed.data;
|
|
141
|
+
const client = await getClient();
|
|
142
|
+
const workspaceId = client.workspaceId;
|
|
143
|
+
if (!workspaceId) {
|
|
144
|
+
return jsonResult({ error: 'no_workspace', detail: 'No workspace context available' }, true);
|
|
145
|
+
}
|
|
146
|
+
const defWithPolicy = {
|
|
147
|
+
...definition,
|
|
148
|
+
failDirection: definition['failDirection'] ?? 'open',
|
|
149
|
+
sharedToolPolicy: definition['sharedToolPolicy'] ?? 'passthrough',
|
|
150
|
+
name: definition['name'] ?? 'placeholder_name',
|
|
151
|
+
};
|
|
152
|
+
const validation = validateUserTypeDef(defWithPolicy);
|
|
153
|
+
if (!validation.valid) {
|
|
154
|
+
const relevantErrors = validation.errors.filter((e) => !e.includes('placeholder_name'));
|
|
155
|
+
if (relevantErrors.length > 0) {
|
|
156
|
+
return jsonResult({ error: 'validation_failed', errors: relevantErrors }, true);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
try {
|
|
160
|
+
const result = await client.put(`/api/v1/workflow-types/${id}`, {
|
|
161
|
+
definition: defWithPolicy,
|
|
162
|
+
});
|
|
163
|
+
registry.registerUserType(rowToTypeDef(result), workspaceId);
|
|
164
|
+
return jsonResult({
|
|
165
|
+
id: result.id,
|
|
166
|
+
name: result.name,
|
|
167
|
+
version: result.version,
|
|
168
|
+
updated_at: result.updated_at,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
173
|
+
if (msg.includes('TYPE_NOT_FOUND')) {
|
|
174
|
+
return jsonResult({ error: 'type_not_found', detail: `Type ${id} not found or is a system type` }, true);
|
|
175
|
+
}
|
|
176
|
+
return jsonResult({ error: 'backend_unreachable', detail: msg }, true);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow lifecycle MCP tools (MV-1539 W2 Step 6, W3 Step 11).
|
|
3
|
+
*
|
|
4
|
+
* W2: tacit_workflow_start, tacit_workflow_handoff, tacit_workflow_deactivate.
|
|
5
|
+
* W3: tacit_workflow_advance, tacit_workflow_resume, tacit_workflow_set_metadata.
|
|
6
|
+
*/
|
|
7
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
8
|
+
import { WorkflowGate } from '../workflow-gate.js';
|
|
9
|
+
export declare function registerWorkflowTools(server: McpServer, gate: WorkflowGate): void;
|