@tacitai/mcp-server 0.6.29 → 0.6.30
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/tools/agents.d.ts +18 -0
- package/dist/tools/agents.js +73 -5
- package/package.json +1 -2
package/dist/tools/agents.d.ts
CHANGED
|
@@ -59,8 +59,12 @@ export declare const agentDelegateInputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
59
59
|
target_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
60
60
|
program_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
61
61
|
dossier_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
62
|
+
wait: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
63
|
+
wait_timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
62
64
|
}, "strip", z.ZodTypeAny, {
|
|
63
65
|
task: string;
|
|
66
|
+
wait: boolean;
|
|
67
|
+
wait_timeout: number;
|
|
64
68
|
program_ids?: string[] | undefined;
|
|
65
69
|
role_slug?: string | undefined;
|
|
66
70
|
agent_id?: string | undefined;
|
|
@@ -75,8 +79,12 @@ export declare const agentDelegateInputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
75
79
|
kind?: string | undefined;
|
|
76
80
|
target_ids?: string[] | undefined;
|
|
77
81
|
dossier_ids?: string[] | undefined;
|
|
82
|
+
wait?: boolean | undefined;
|
|
83
|
+
wait_timeout?: number | undefined;
|
|
78
84
|
}>, {
|
|
79
85
|
task: string;
|
|
86
|
+
wait: boolean;
|
|
87
|
+
wait_timeout: number;
|
|
80
88
|
program_ids?: string[] | undefined;
|
|
81
89
|
role_slug?: string | undefined;
|
|
82
90
|
agent_id?: string | undefined;
|
|
@@ -91,6 +99,8 @@ export declare const agentDelegateInputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
91
99
|
kind?: string | undefined;
|
|
92
100
|
target_ids?: string[] | undefined;
|
|
93
101
|
dossier_ids?: string[] | undefined;
|
|
102
|
+
wait?: boolean | undefined;
|
|
103
|
+
wait_timeout?: number | undefined;
|
|
94
104
|
}>;
|
|
95
105
|
export type AgentDelegateInput = z.infer<typeof agentDelegateInputSchema>;
|
|
96
106
|
export declare const AGENT_DELEGATE_TOOL_DEF: {
|
|
@@ -136,6 +146,14 @@ export declare const AGENT_DELEGATE_TOOL_DEF: {
|
|
|
136
146
|
};
|
|
137
147
|
description: string;
|
|
138
148
|
};
|
|
149
|
+
wait: {
|
|
150
|
+
type: string;
|
|
151
|
+
description: string;
|
|
152
|
+
};
|
|
153
|
+
wait_timeout: {
|
|
154
|
+
type: string;
|
|
155
|
+
description: string;
|
|
156
|
+
};
|
|
139
157
|
};
|
|
140
158
|
required: string[];
|
|
141
159
|
};
|
package/dist/tools/agents.js
CHANGED
|
@@ -104,13 +104,15 @@ export const agentDelegateInputSchema = z.object({
|
|
|
104
104
|
target_ids: z.array(z.string()).optional().describe('Target entity UUIDs for the task'),
|
|
105
105
|
program_ids: z.array(z.string()).optional().describe('Program UUIDs to scope the task'),
|
|
106
106
|
dossier_ids: z.array(z.string()).optional().describe('Dossier UUIDs to scope the task'),
|
|
107
|
+
wait: z.boolean().optional().default(true).describe('Wait for the run to complete and return results inline (default: true)'),
|
|
108
|
+
wait_timeout: z.number().int().positive().optional().default(120).describe('Max seconds to wait for completion (default: 120)'),
|
|
107
109
|
}).refine((d) => d.agent_id || d.role_slug, { message: 'Either agent_id or role_slug is required' });
|
|
108
110
|
export const AGENT_DELEGATE_TOOL_DEF = {
|
|
109
111
|
name: 'tacit_agent_delegate',
|
|
110
|
-
description: 'Delegate a task to a business agent. Accepts agent_id (UUID) or role_slug (template name). ' +
|
|
112
|
+
description: 'Delegate a task to a business agent and wait for results. Accepts agent_id (UUID) or role_slug (template name). ' +
|
|
111
113
|
'When role_slug is used and no instance exists, the agent is created on first delegation. ' +
|
|
112
|
-
'
|
|
113
|
-
'
|
|
114
|
+
'By default, waits for the run to complete and returns the agent\'s output messages inline. ' +
|
|
115
|
+
'Set wait=false to return immediately with just the assignment_id and run_id.',
|
|
114
116
|
inputSchema: {
|
|
115
117
|
type: 'object',
|
|
116
118
|
properties: {
|
|
@@ -121,6 +123,8 @@ export const AGENT_DELEGATE_TOOL_DEF = {
|
|
|
121
123
|
target_ids: { type: 'array', items: { type: 'string' }, description: 'Target entity UUIDs' },
|
|
122
124
|
program_ids: { type: 'array', items: { type: 'string' }, description: 'Program UUIDs to scope the task' },
|
|
123
125
|
dossier_ids: { type: 'array', items: { type: 'string' }, description: 'Dossier UUIDs to scope the task' },
|
|
126
|
+
wait: { type: 'boolean', description: 'Wait for run completion and return results inline (default: true)' },
|
|
127
|
+
wait_timeout: { type: 'number', description: 'Max seconds to wait for completion (default: 120)' },
|
|
124
128
|
},
|
|
125
129
|
required: ['task'],
|
|
126
130
|
},
|
|
@@ -190,6 +194,49 @@ async function resolveAgentId(client, input) {
|
|
|
190
194
|
return { error: `Failed to create agent instance for ${slug}: ${msg}` };
|
|
191
195
|
}
|
|
192
196
|
}
|
|
197
|
+
function sleep(ms) {
|
|
198
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
199
|
+
}
|
|
200
|
+
async function pollForCompletion(client, agentId, runId, timeoutSec) {
|
|
201
|
+
const POLL_INTERVAL_MS = 3000;
|
|
202
|
+
const deadline = Date.now() + timeoutSec * 1000;
|
|
203
|
+
while (Date.now() < deadline) {
|
|
204
|
+
try {
|
|
205
|
+
const timeline = await callAgentTool(client, 'tacit.agents.timeline', {
|
|
206
|
+
agent_id: agentId,
|
|
207
|
+
run_id: runId,
|
|
208
|
+
});
|
|
209
|
+
const events = timeline?.events;
|
|
210
|
+
if (Array.isArray(events)) {
|
|
211
|
+
for (const evt of events) {
|
|
212
|
+
const e = evt;
|
|
213
|
+
const evtType = (e['event_type'] ?? e['type'] ?? '');
|
|
214
|
+
if (evtType.includes('completed') || evtType.includes('succeeded')) {
|
|
215
|
+
return { completed: true, failed: false, events };
|
|
216
|
+
}
|
|
217
|
+
if (evtType.includes('failed') || evtType.includes('error')) {
|
|
218
|
+
return { completed: false, failed: true, events };
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
// timeline call failed — keep polling
|
|
225
|
+
}
|
|
226
|
+
await sleep(POLL_INTERVAL_MS);
|
|
227
|
+
}
|
|
228
|
+
return { completed: false, failed: false, events: [] };
|
|
229
|
+
}
|
|
230
|
+
async function fetchRunMessages(client, agentId) {
|
|
231
|
+
try {
|
|
232
|
+
const threadResult = await callAgentTool(client, 'tacit.agents.thread', { agent_id: agentId });
|
|
233
|
+
const tr = threadResult;
|
|
234
|
+
return tr?.messages ?? [];
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
return [];
|
|
238
|
+
}
|
|
239
|
+
}
|
|
193
240
|
export function buildAgentDelegateRequest(client, input) {
|
|
194
241
|
return {
|
|
195
242
|
async execute() {
|
|
@@ -211,7 +258,26 @@ export function buildAgentDelegateRequest(client, input) {
|
|
|
211
258
|
agent_id: resolved.agent_id,
|
|
212
259
|
spec,
|
|
213
260
|
});
|
|
214
|
-
|
|
261
|
+
const shouldWait = input.wait !== false;
|
|
262
|
+
const runId = result['run_id'];
|
|
263
|
+
const status = result['status'] ?? '';
|
|
264
|
+
if (!shouldWait || !runId || status === 'duplicate') {
|
|
265
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
266
|
+
}
|
|
267
|
+
// Poll for completion, then fetch output messages
|
|
268
|
+
const timeoutSec = input.wait_timeout ?? 120;
|
|
269
|
+
const poll = await pollForCompletion(client, resolved.agent_id, runId, timeoutSec);
|
|
270
|
+
const messages = await fetchRunMessages(client, resolved.agent_id);
|
|
271
|
+
const combined = {
|
|
272
|
+
...result,
|
|
273
|
+
wait_result: poll.completed
|
|
274
|
+
? 'completed'
|
|
275
|
+
: poll.failed
|
|
276
|
+
? 'failed'
|
|
277
|
+
: 'timeout',
|
|
278
|
+
messages,
|
|
279
|
+
};
|
|
280
|
+
return { content: [{ type: 'text', text: JSON.stringify(combined) }] };
|
|
215
281
|
}
|
|
216
282
|
catch (err) {
|
|
217
283
|
return apiErrorResult(err, 'tacit_agent_delegate');
|
|
@@ -395,7 +461,7 @@ export function registerAgentTools(server, getClientFn) {
|
|
|
395
461
|
const client = await getClientFn();
|
|
396
462
|
return buildAgentListRequest(client, args).execute();
|
|
397
463
|
});
|
|
398
|
-
server.tool('tacit_agent_delegate', 'Delegate a task to a business agent. Accepts agent_id
|
|
464
|
+
server.tool('tacit_agent_delegate', 'Delegate a task to a business agent and wait for results. Accepts agent_id or role_slug. Returns the agent\'s output inline by default.', {
|
|
399
465
|
agent_id: z.string().min(1).optional().describe('UUID of the agent to delegate to (provide this OR role_slug)'),
|
|
400
466
|
role_slug: z.string().min(1).optional().describe('Role template slug (e.g. "wiki_editor"). Creates instance on first use'),
|
|
401
467
|
task: z.string().min(1).describe('Task description to delegate'),
|
|
@@ -403,6 +469,8 @@ export function registerAgentTools(server, getClientFn) {
|
|
|
403
469
|
target_ids: z.array(z.string()).optional().describe('Target entity UUIDs'),
|
|
404
470
|
program_ids: z.array(z.string()).optional().describe('Program UUIDs'),
|
|
405
471
|
dossier_ids: z.array(z.string()).optional().describe('Dossier UUIDs'),
|
|
472
|
+
wait: z.boolean().optional().default(true).describe('Wait for completion and return results (default: true)'),
|
|
473
|
+
wait_timeout: z.number().int().positive().optional().default(120).describe('Max seconds to wait (default: 120)'),
|
|
406
474
|
}, async (args) => {
|
|
407
475
|
const client = await getClientFn();
|
|
408
476
|
return buildAgentDelegateRequest(client, args).execute();
|