@tacitai/mcp-server 0.6.29 → 0.6.31

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.
@@ -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
  };
@@ -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
- 'The task is fingerprint-deduped and dispatched to the run engine. ' +
113
- 'Returns assignment_id, run_id, and status. Duplicate tasks return status "duplicate" with the existing assignment.',
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,56 @@ 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 runStatus = (timeline?.['status'] ?? '');
210
+ if (runStatus === 'succeeded' || runStatus === 'completed') {
211
+ return { completed: true, failed: false, events: timeline?.['events'] ?? [] };
212
+ }
213
+ if (runStatus === 'failed' || runStatus === 'infra_failed' || runStatus === 'error') {
214
+ return { completed: false, failed: true, events: timeline?.['events'] ?? [] };
215
+ }
216
+ const events = timeline?.['events'];
217
+ if (Array.isArray(events)) {
218
+ for (const evt of events) {
219
+ const e = evt;
220
+ const evtType = (e['event_type'] ?? e['type'] ?? '');
221
+ if (evtType.includes('completed') || evtType.includes('succeeded')) {
222
+ return { completed: true, failed: false, events };
223
+ }
224
+ if (evtType.includes('failed') || evtType.includes('error')) {
225
+ return { completed: false, failed: true, events };
226
+ }
227
+ }
228
+ }
229
+ }
230
+ catch {
231
+ // timeline call failed — keep polling
232
+ }
233
+ await sleep(POLL_INTERVAL_MS);
234
+ }
235
+ return { completed: false, failed: false, events: [] };
236
+ }
237
+ async function fetchRunMessages(client, agentId) {
238
+ try {
239
+ const threadResult = await callAgentTool(client, 'tacit.agents.thread', { agent_id: agentId });
240
+ const tr = threadResult;
241
+ return tr?.messages ?? [];
242
+ }
243
+ catch {
244
+ return [];
245
+ }
246
+ }
193
247
  export function buildAgentDelegateRequest(client, input) {
194
248
  return {
195
249
  async execute() {
@@ -211,7 +265,26 @@ export function buildAgentDelegateRequest(client, input) {
211
265
  agent_id: resolved.agent_id,
212
266
  spec,
213
267
  });
214
- return { content: [{ type: 'text', text: JSON.stringify(result) }] };
268
+ const shouldWait = input.wait !== false;
269
+ const runId = result['run_id'];
270
+ const status = result['status'] ?? '';
271
+ if (!shouldWait || !runId || status === 'duplicate') {
272
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
273
+ }
274
+ // Poll for completion, then fetch output messages
275
+ const timeoutSec = input.wait_timeout ?? 120;
276
+ const poll = await pollForCompletion(client, resolved.agent_id, runId, timeoutSec);
277
+ const messages = await fetchRunMessages(client, resolved.agent_id);
278
+ const combined = {
279
+ ...result,
280
+ wait_result: poll.completed
281
+ ? 'completed'
282
+ : poll.failed
283
+ ? 'failed'
284
+ : 'timeout',
285
+ messages,
286
+ };
287
+ return { content: [{ type: 'text', text: JSON.stringify(combined) }] };
215
288
  }
216
289
  catch (err) {
217
290
  return apiErrorResult(err, 'tacit_agent_delegate');
@@ -395,7 +468,7 @@ export function registerAgentTools(server, getClientFn) {
395
468
  const client = await getClientFn();
396
469
  return buildAgentListRequest(client, args).execute();
397
470
  });
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.', {
471
+ 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
472
  agent_id: z.string().min(1).optional().describe('UUID of the agent to delegate to (provide this OR role_slug)'),
400
473
  role_slug: z.string().min(1).optional().describe('Role template slug (e.g. "wiki_editor"). Creates instance on first use'),
401
474
  task: z.string().min(1).describe('Task description to delegate'),
@@ -403,6 +476,8 @@ export function registerAgentTools(server, getClientFn) {
403
476
  target_ids: z.array(z.string()).optional().describe('Target entity UUIDs'),
404
477
  program_ids: z.array(z.string()).optional().describe('Program UUIDs'),
405
478
  dossier_ids: z.array(z.string()).optional().describe('Dossier UUIDs'),
479
+ wait: z.boolean().optional().default(true).describe('Wait for completion and return results (default: true)'),
480
+ wait_timeout: z.number().int().positive().optional().default(120).describe('Max seconds to wait (default: 120)'),
406
481
  }, async (args) => {
407
482
  const client = await getClientFn();
408
483
  return buildAgentDelegateRequest(client, args).execute();
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@tacitai/mcp-server",
3
- "version": "0.6.29",
4
- "private": false,
3
+ "version": "0.6.31",
5
4
  "description": "stdio MCP server wrapping Tacit /api/v1 REST/SSE API",
6
5
  "license": "UNLICENSED",
7
6
  "repository": {
@@ -39,5 +38,6 @@
39
38
  "@types/semver": "^7.5.0",
40
39
  "typescript": "^5.4.0",
41
40
  "vitest": "^4.1.7"
42
- }
41
+ },
42
+ "private": false
43
43
  }