@tacitai/mcp-server 0.1.1 → 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/dist/auth.d.ts +32 -0
- package/dist/auth.js +64 -0
- package/dist/client.d.ts +60 -5
- package/dist/client.js +234 -53
- package/dist/index.js +130 -106
- package/dist/oauth.d.ts +115 -0
- package/dist/oauth.js +619 -0
- package/dist/prompts.d.ts +2 -0
- package/dist/prompts.js +12 -0
- package/dist/setup.d.ts +28 -5
- package/dist/setup.js +266 -59
- package/dist/tools/agents.d.ts +277 -0
- package/dist/tools/agents.js +335 -0
- package/dist/tools/annotations.d.ts +117 -0
- package/dist/tools/annotations.js +130 -0
- package/dist/tools/artifacts.d.ts +178 -8
- package/dist/tools/artifacts.js +372 -81
- package/dist/tools/chronicle.d.ts +3 -0
- package/dist/tools/chronicle.js +165 -0
- package/dist/tools/connector_write_back.d.ts +3 -0
- package/dist/tools/connector_write_back.js +27 -0
- package/dist/tools/converse.d.ts +10 -0
- package/dist/tools/converse.js +88 -0
- package/dist/tools/crews.d.ts +3 -0
- package/dist/tools/crews.js +115 -0
- package/dist/tools/drafts.d.ts +83 -0
- package/dist/tools/drafts.js +86 -0
- package/dist/tools/errors.d.ts +15 -0
- package/dist/tools/errors.js +21 -0
- package/dist/tools/export.d.ts +54 -0
- package/dist/tools/export.js +55 -0
- package/dist/tools/gm.d.ts +214 -0
- package/dist/tools/gm.js +198 -0
- package/dist/tools/ingest.d.ts +58 -4
- package/dist/tools/ingest.js +109 -76
- package/dist/tools/kb.d.ts +544 -0
- package/dist/tools/kb.js +687 -0
- package/dist/tools/lake-structure.d.ts +3 -0
- package/dist/tools/lake-structure.js +126 -0
- package/dist/tools/lake.d.ts +932 -0
- package/dist/tools/lake.js +1017 -0
- package/dist/tools/move.d.ts +200 -0
- package/dist/tools/move.js +96 -0
- package/dist/tools/outbox.d.ts +274 -0
- package/dist/tools/outbox.js +223 -0
- package/dist/tools/people.d.ts +3 -0
- package/dist/tools/people.js +59 -0
- package/dist/tools/pyramid.d.ts +554 -0
- package/dist/tools/pyramid.js +758 -0
- package/dist/tools/recall.d.ts +2 -0
- package/dist/tools/recall.js +28 -17
- package/dist/tools/registry.d.ts +17 -0
- package/dist/tools/registry.js +199 -0
- package/dist/tools/research.d.ts +47 -0
- package/dist/tools/research.js +575 -0
- package/dist/tools/search.d.ts +9 -0
- package/dist/tools/search.js +86 -25
- package/dist/tools/sharing.d.ts +63 -0
- package/dist/tools/sharing.js +157 -0
- package/dist/tools/skills.d.ts +9 -0
- package/dist/tools/skills.js +98 -0
- package/dist/tools/synthesize.d.ts +54 -2
- package/dist/tools/synthesize.js +80 -23
- package/dist/tools/web-url.d.ts +57 -0
- package/dist/tools/web-url.js +74 -0
- package/dist/tools/workspaces.d.ts +3 -0
- package/dist/tools/workspaces.js +47 -0
- package/dist/transport.d.ts +9 -0
- package/dist/transport.js +209 -0
- package/package.json +5 -4
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent tools — Claude CLI wrappers around the Agent Factory MCP surface.
|
|
3
|
+
*
|
|
4
|
+
* All 6 tools dispatch through POST /agents/mcp/tools/call on the Axum API,
|
|
5
|
+
* which provides governance parity (feature gate, fingerprint dedup, hash-bound
|
|
6
|
+
* approval checks) with the web UI.
|
|
7
|
+
*
|
|
8
|
+
* Routes (Axum):
|
|
9
|
+
* GET /agents/mcp/tools — tool discovery (not used here; we define our own defs)
|
|
10
|
+
* POST /agents/mcp/tools/call — authenticated dispatch by tool name
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
14
|
+
import { TacitClient } from '../client.js';
|
|
15
|
+
export interface ToolRequest {
|
|
16
|
+
execute(): Promise<{
|
|
17
|
+
content: Array<{
|
|
18
|
+
type: 'text';
|
|
19
|
+
text: string;
|
|
20
|
+
}>;
|
|
21
|
+
isError?: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
export declare const agentListInputSchema: z.ZodObject<{
|
|
25
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
limit?: number | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
limit?: number | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
export type AgentListInput = z.infer<typeof agentListInputSchema>;
|
|
32
|
+
export declare const AGENT_LIST_TOOL_DEF: {
|
|
33
|
+
name: "tacit_agent_list";
|
|
34
|
+
description: string;
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: "object";
|
|
37
|
+
properties: {
|
|
38
|
+
limit: {
|
|
39
|
+
type: string;
|
|
40
|
+
description: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
required: string[];
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export declare function buildAgentListRequest(client: TacitClient, input: AgentListInput): ToolRequest;
|
|
47
|
+
export declare function handleAgentList(args: unknown): Promise<{
|
|
48
|
+
content: Array<{
|
|
49
|
+
type: 'text';
|
|
50
|
+
text: string;
|
|
51
|
+
}>;
|
|
52
|
+
isError?: boolean;
|
|
53
|
+
}>;
|
|
54
|
+
export declare const agentDelegateInputSchema: z.ZodObject<{
|
|
55
|
+
agent_id: z.ZodString;
|
|
56
|
+
task: z.ZodString;
|
|
57
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
58
|
+
target_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
59
|
+
program_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
60
|
+
dossier_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
agent_id: string;
|
|
63
|
+
task: string;
|
|
64
|
+
program_ids?: string[] | undefined;
|
|
65
|
+
kind?: string | undefined;
|
|
66
|
+
target_ids?: string[] | undefined;
|
|
67
|
+
dossier_ids?: string[] | undefined;
|
|
68
|
+
}, {
|
|
69
|
+
agent_id: string;
|
|
70
|
+
task: string;
|
|
71
|
+
program_ids?: string[] | undefined;
|
|
72
|
+
kind?: string | undefined;
|
|
73
|
+
target_ids?: string[] | undefined;
|
|
74
|
+
dossier_ids?: string[] | undefined;
|
|
75
|
+
}>;
|
|
76
|
+
export type AgentDelegateInput = z.infer<typeof agentDelegateInputSchema>;
|
|
77
|
+
export declare const AGENT_DELEGATE_TOOL_DEF: {
|
|
78
|
+
name: "tacit_agent_delegate";
|
|
79
|
+
description: string;
|
|
80
|
+
inputSchema: {
|
|
81
|
+
type: "object";
|
|
82
|
+
properties: {
|
|
83
|
+
agent_id: {
|
|
84
|
+
type: string;
|
|
85
|
+
description: string;
|
|
86
|
+
};
|
|
87
|
+
task: {
|
|
88
|
+
type: string;
|
|
89
|
+
description: string;
|
|
90
|
+
};
|
|
91
|
+
kind: {
|
|
92
|
+
type: string;
|
|
93
|
+
description: string;
|
|
94
|
+
};
|
|
95
|
+
target_ids: {
|
|
96
|
+
type: string;
|
|
97
|
+
items: {
|
|
98
|
+
type: string;
|
|
99
|
+
};
|
|
100
|
+
description: string;
|
|
101
|
+
};
|
|
102
|
+
program_ids: {
|
|
103
|
+
type: string;
|
|
104
|
+
items: {
|
|
105
|
+
type: string;
|
|
106
|
+
};
|
|
107
|
+
description: string;
|
|
108
|
+
};
|
|
109
|
+
dossier_ids: {
|
|
110
|
+
type: string;
|
|
111
|
+
items: {
|
|
112
|
+
type: string;
|
|
113
|
+
};
|
|
114
|
+
description: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
required: string[];
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
export declare function buildAgentDelegateRequest(client: TacitClient, input: AgentDelegateInput): ToolRequest;
|
|
121
|
+
export declare function handleAgentDelegate(args: unknown): Promise<{
|
|
122
|
+
content: Array<{
|
|
123
|
+
type: 'text';
|
|
124
|
+
text: string;
|
|
125
|
+
}>;
|
|
126
|
+
isError?: boolean;
|
|
127
|
+
}>;
|
|
128
|
+
export declare const agentThreadInputSchema: z.ZodObject<{
|
|
129
|
+
agent_id: z.ZodString;
|
|
130
|
+
}, "strip", z.ZodTypeAny, {
|
|
131
|
+
agent_id: string;
|
|
132
|
+
}, {
|
|
133
|
+
agent_id: string;
|
|
134
|
+
}>;
|
|
135
|
+
export type AgentThreadInput = z.infer<typeof agentThreadInputSchema>;
|
|
136
|
+
export declare const AGENT_THREAD_TOOL_DEF: {
|
|
137
|
+
name: "tacit_agent_thread";
|
|
138
|
+
description: string;
|
|
139
|
+
inputSchema: {
|
|
140
|
+
type: "object";
|
|
141
|
+
properties: {
|
|
142
|
+
agent_id: {
|
|
143
|
+
type: string;
|
|
144
|
+
description: string;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
required: string[];
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
export declare function buildAgentThreadRequest(client: TacitClient, input: AgentThreadInput): ToolRequest;
|
|
151
|
+
export declare function handleAgentThread(args: unknown): Promise<{
|
|
152
|
+
content: Array<{
|
|
153
|
+
type: 'text';
|
|
154
|
+
text: string;
|
|
155
|
+
}>;
|
|
156
|
+
isError?: boolean;
|
|
157
|
+
}>;
|
|
158
|
+
export declare const agentApprovalsInputSchema: z.ZodObject<{
|
|
159
|
+
status: z.ZodOptional<z.ZodString>;
|
|
160
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
161
|
+
}, "strip", z.ZodTypeAny, {
|
|
162
|
+
limit?: number | undefined;
|
|
163
|
+
status?: string | undefined;
|
|
164
|
+
}, {
|
|
165
|
+
limit?: number | undefined;
|
|
166
|
+
status?: string | undefined;
|
|
167
|
+
}>;
|
|
168
|
+
export type AgentApprovalsInput = z.infer<typeof agentApprovalsInputSchema>;
|
|
169
|
+
export declare const AGENT_APPROVALS_TOOL_DEF: {
|
|
170
|
+
name: "tacit_agent_approvals";
|
|
171
|
+
description: string;
|
|
172
|
+
inputSchema: {
|
|
173
|
+
type: "object";
|
|
174
|
+
properties: {
|
|
175
|
+
status: {
|
|
176
|
+
type: string;
|
|
177
|
+
description: string;
|
|
178
|
+
};
|
|
179
|
+
limit: {
|
|
180
|
+
type: string;
|
|
181
|
+
description: string;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
required: string[];
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
export declare function buildAgentApprovalsRequest(client: TacitClient, input: AgentApprovalsInput): ToolRequest;
|
|
188
|
+
export declare function handleAgentApprovals(args: unknown): Promise<{
|
|
189
|
+
content: Array<{
|
|
190
|
+
type: 'text';
|
|
191
|
+
text: string;
|
|
192
|
+
}>;
|
|
193
|
+
isError?: boolean;
|
|
194
|
+
}>;
|
|
195
|
+
export declare const agentDecideInputSchema: z.ZodObject<{
|
|
196
|
+
approval_id: z.ZodString;
|
|
197
|
+
decision: z.ZodEnum<["approve", "deny"]>;
|
|
198
|
+
note: z.ZodOptional<z.ZodString>;
|
|
199
|
+
}, "strip", z.ZodTypeAny, {
|
|
200
|
+
approval_id: string;
|
|
201
|
+
decision: "approve" | "deny";
|
|
202
|
+
note?: string | undefined;
|
|
203
|
+
}, {
|
|
204
|
+
approval_id: string;
|
|
205
|
+
decision: "approve" | "deny";
|
|
206
|
+
note?: string | undefined;
|
|
207
|
+
}>;
|
|
208
|
+
export type AgentDecideInput = z.infer<typeof agentDecideInputSchema>;
|
|
209
|
+
export declare const AGENT_DECIDE_TOOL_DEF: {
|
|
210
|
+
name: "tacit_agent_decide";
|
|
211
|
+
description: string;
|
|
212
|
+
inputSchema: {
|
|
213
|
+
type: "object";
|
|
214
|
+
properties: {
|
|
215
|
+
approval_id: {
|
|
216
|
+
type: string;
|
|
217
|
+
description: string;
|
|
218
|
+
};
|
|
219
|
+
decision: {
|
|
220
|
+
type: string;
|
|
221
|
+
enum: string[];
|
|
222
|
+
description: string;
|
|
223
|
+
};
|
|
224
|
+
note: {
|
|
225
|
+
type: string;
|
|
226
|
+
description: string;
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
required: string[];
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
export declare function buildAgentDecideRequest(client: TacitClient, input: AgentDecideInput): ToolRequest;
|
|
233
|
+
export declare function handleAgentDecide(args: unknown): Promise<{
|
|
234
|
+
content: Array<{
|
|
235
|
+
type: 'text';
|
|
236
|
+
text: string;
|
|
237
|
+
}>;
|
|
238
|
+
isError?: boolean;
|
|
239
|
+
}>;
|
|
240
|
+
export declare const agentTimelineInputSchema: z.ZodObject<{
|
|
241
|
+
agent_id: z.ZodString;
|
|
242
|
+
run_id: z.ZodString;
|
|
243
|
+
}, "strip", z.ZodTypeAny, {
|
|
244
|
+
agent_id: string;
|
|
245
|
+
run_id: string;
|
|
246
|
+
}, {
|
|
247
|
+
agent_id: string;
|
|
248
|
+
run_id: string;
|
|
249
|
+
}>;
|
|
250
|
+
export type AgentTimelineInput = z.infer<typeof agentTimelineInputSchema>;
|
|
251
|
+
export declare const AGENT_TIMELINE_TOOL_DEF: {
|
|
252
|
+
name: "tacit_agent_timeline";
|
|
253
|
+
description: string;
|
|
254
|
+
inputSchema: {
|
|
255
|
+
type: "object";
|
|
256
|
+
properties: {
|
|
257
|
+
agent_id: {
|
|
258
|
+
type: string;
|
|
259
|
+
description: string;
|
|
260
|
+
};
|
|
261
|
+
run_id: {
|
|
262
|
+
type: string;
|
|
263
|
+
description: string;
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
required: string[];
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
export declare function buildAgentTimelineRequest(client: TacitClient, input: AgentTimelineInput): ToolRequest;
|
|
270
|
+
export declare function handleAgentTimeline(args: unknown): Promise<{
|
|
271
|
+
content: Array<{
|
|
272
|
+
type: 'text';
|
|
273
|
+
text: string;
|
|
274
|
+
}>;
|
|
275
|
+
isError?: boolean;
|
|
276
|
+
}>;
|
|
277
|
+
export declare function registerAgentTools(server: McpServer, getClientFn: () => Promise<TacitClient>): void;
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
/**
|
|
3
|
+
* Agent tools — Claude CLI wrappers around the Agent Factory MCP surface.
|
|
4
|
+
*
|
|
5
|
+
* All 6 tools dispatch through POST /agents/mcp/tools/call on the Axum API,
|
|
6
|
+
* which provides governance parity (feature gate, fingerprint dedup, hash-bound
|
|
7
|
+
* approval checks) with the web UI.
|
|
8
|
+
*
|
|
9
|
+
* Routes (Axum):
|
|
10
|
+
* GET /agents/mcp/tools — tool discovery (not used here; we define our own defs)
|
|
11
|
+
* POST /agents/mcp/tools/call — authenticated dispatch by tool name
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import { getClient, TacitApiError, TokenExpiredError } from '../client.js';
|
|
15
|
+
function apiErrorResult(err, toolName) {
|
|
16
|
+
if (err instanceof TokenExpiredError) {
|
|
17
|
+
return {
|
|
18
|
+
content: [{ type: 'text', text: err.message }],
|
|
19
|
+
isError: true,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (err instanceof TacitApiError) {
|
|
23
|
+
return { content: [{ type: 'text', text: `API error ${err.statusCode} on ${toolName}: ${err.body}` }], isError: true };
|
|
24
|
+
}
|
|
25
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
26
|
+
return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
|
|
27
|
+
}
|
|
28
|
+
async function callAgentTool(client, name, args) {
|
|
29
|
+
return client.post('/api/v1/agents/mcp/tools/call', { name, arguments: args });
|
|
30
|
+
}
|
|
31
|
+
// ─── tacit_agent_list ────────────────────────────────────────────────────────
|
|
32
|
+
export const agentListInputSchema = z.object({
|
|
33
|
+
limit: z.number().int().positive().optional().describe('Maximum agents to return (default 25, max 100)'),
|
|
34
|
+
});
|
|
35
|
+
export const AGENT_LIST_TOOL_DEF = {
|
|
36
|
+
name: 'tacit_agent_list',
|
|
37
|
+
description: 'List business agents in the workspace. Returns agent id, name, archetype, status, and policy summary.',
|
|
38
|
+
inputSchema: {
|
|
39
|
+
type: 'object',
|
|
40
|
+
properties: {
|
|
41
|
+
limit: { type: 'number', description: 'Maximum agents to return (default 25, max 100)' },
|
|
42
|
+
},
|
|
43
|
+
required: [],
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
export function buildAgentListRequest(client, input) {
|
|
47
|
+
return {
|
|
48
|
+
async execute() {
|
|
49
|
+
try {
|
|
50
|
+
const args = {};
|
|
51
|
+
if (input.limit !== undefined)
|
|
52
|
+
args['limit'] = input.limit;
|
|
53
|
+
const result = await callAgentTool(client, 'tacit.agents.list', args);
|
|
54
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
return apiErrorResult(err, 'tacit_agent_list');
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export async function handleAgentList(args) {
|
|
63
|
+
const parsed = agentListInputSchema.safeParse(args);
|
|
64
|
+
if (!parsed.success) {
|
|
65
|
+
return { content: [{ type: 'text', text: `Invalid input: ${parsed.error.message}` }], isError: true };
|
|
66
|
+
}
|
|
67
|
+
return buildAgentListRequest(getClient(), parsed.data).execute();
|
|
68
|
+
}
|
|
69
|
+
// ─── tacit_agent_delegate ────────────────────────────────────────────────────
|
|
70
|
+
export const agentDelegateInputSchema = z.object({
|
|
71
|
+
agent_id: z.string().min(1).describe('UUID of the agent to delegate to'),
|
|
72
|
+
task: z.string().min(1).describe('Task description to delegate'),
|
|
73
|
+
kind: z.string().optional().describe('Task kind (default: "task")'),
|
|
74
|
+
target_ids: z.array(z.string()).optional().describe('Target entity UUIDs for the task'),
|
|
75
|
+
program_ids: z.array(z.string()).optional().describe('Program UUIDs to scope the task'),
|
|
76
|
+
dossier_ids: z.array(z.string()).optional().describe('Dossier UUIDs to scope the task'),
|
|
77
|
+
});
|
|
78
|
+
export const AGENT_DELEGATE_TOOL_DEF = {
|
|
79
|
+
name: 'tacit_agent_delegate',
|
|
80
|
+
description: 'Delegate a task to a business agent. The task is fingerprint-deduped and dispatched to the run engine. ' +
|
|
81
|
+
'Returns assignment_id, run_id, and status. Duplicate tasks return status "duplicate" with the existing assignment.',
|
|
82
|
+
inputSchema: {
|
|
83
|
+
type: 'object',
|
|
84
|
+
properties: {
|
|
85
|
+
agent_id: { type: 'string', description: 'UUID of the agent to delegate to' },
|
|
86
|
+
task: { type: 'string', description: 'Task description to delegate' },
|
|
87
|
+
kind: { type: 'string', description: 'Task kind (default: "task")' },
|
|
88
|
+
target_ids: { type: 'array', items: { type: 'string' }, description: 'Target entity UUIDs' },
|
|
89
|
+
program_ids: { type: 'array', items: { type: 'string' }, description: 'Program UUIDs to scope the task' },
|
|
90
|
+
dossier_ids: { type: 'array', items: { type: 'string' }, description: 'Dossier UUIDs to scope the task' },
|
|
91
|
+
},
|
|
92
|
+
required: ['agent_id', 'task'],
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
export function buildAgentDelegateRequest(client, input) {
|
|
96
|
+
return {
|
|
97
|
+
async execute() {
|
|
98
|
+
try {
|
|
99
|
+
const spec = { task: input.task };
|
|
100
|
+
if (input.kind)
|
|
101
|
+
spec['kind'] = input.kind;
|
|
102
|
+
if (input.target_ids)
|
|
103
|
+
spec['target_ids'] = input.target_ids;
|
|
104
|
+
if (input.program_ids)
|
|
105
|
+
spec['program_ids'] = input.program_ids;
|
|
106
|
+
if (input.dossier_ids)
|
|
107
|
+
spec['dossier_ids'] = input.dossier_ids;
|
|
108
|
+
const result = await callAgentTool(client, 'tacit.agents.delegate', {
|
|
109
|
+
agent_id: input.agent_id,
|
|
110
|
+
spec,
|
|
111
|
+
});
|
|
112
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
return apiErrorResult(err, 'tacit_agent_delegate');
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
export async function handleAgentDelegate(args) {
|
|
121
|
+
const parsed = agentDelegateInputSchema.safeParse(args);
|
|
122
|
+
if (!parsed.success) {
|
|
123
|
+
return { content: [{ type: 'text', text: `Invalid input: ${parsed.error.message}` }], isError: true };
|
|
124
|
+
}
|
|
125
|
+
return buildAgentDelegateRequest(getClient(), parsed.data).execute();
|
|
126
|
+
}
|
|
127
|
+
// ─── tacit_agent_thread ──────────────────────────────────────────────────────
|
|
128
|
+
export const agentThreadInputSchema = z.object({
|
|
129
|
+
agent_id: z.string().min(1).describe('UUID of the agent whose thread to retrieve'),
|
|
130
|
+
});
|
|
131
|
+
export const AGENT_THREAD_TOOL_DEF = {
|
|
132
|
+
name: 'tacit_agent_thread',
|
|
133
|
+
description: 'Get the workspace-scope conversation thread and recent messages for an agent. Creates the thread lazily if it does not exist.',
|
|
134
|
+
inputSchema: {
|
|
135
|
+
type: 'object',
|
|
136
|
+
properties: {
|
|
137
|
+
agent_id: { type: 'string', description: 'UUID of the agent' },
|
|
138
|
+
},
|
|
139
|
+
required: ['agent_id'],
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
export function buildAgentThreadRequest(client, input) {
|
|
143
|
+
return {
|
|
144
|
+
async execute() {
|
|
145
|
+
try {
|
|
146
|
+
const result = await callAgentTool(client, 'tacit.agents.thread', { agent_id: input.agent_id });
|
|
147
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
return apiErrorResult(err, 'tacit_agent_thread');
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
export async function handleAgentThread(args) {
|
|
156
|
+
const parsed = agentThreadInputSchema.safeParse(args);
|
|
157
|
+
if (!parsed.success) {
|
|
158
|
+
return { content: [{ type: 'text', text: `Invalid input: ${parsed.error.message}` }], isError: true };
|
|
159
|
+
}
|
|
160
|
+
return buildAgentThreadRequest(getClient(), parsed.data).execute();
|
|
161
|
+
}
|
|
162
|
+
// ─── tacit_agent_approvals ───────────────────────────────────────────────────
|
|
163
|
+
export const agentApprovalsInputSchema = z.object({
|
|
164
|
+
status: z.string().optional().describe('Filter by status (e.g. "pending", "approved", "denied")'),
|
|
165
|
+
limit: z.number().int().positive().optional().describe('Maximum approvals to return (default 25, max 100)'),
|
|
166
|
+
});
|
|
167
|
+
export const AGENT_APPROVALS_TOOL_DEF = {
|
|
168
|
+
name: 'tacit_agent_approvals',
|
|
169
|
+
description: 'List pending or decided approvals in the workspace. Use status "pending" to see items awaiting human decision.',
|
|
170
|
+
inputSchema: {
|
|
171
|
+
type: 'object',
|
|
172
|
+
properties: {
|
|
173
|
+
status: { type: 'string', description: 'Filter by status (e.g. "pending", "approved", "denied")' },
|
|
174
|
+
limit: { type: 'number', description: 'Maximum approvals to return (default 25, max 100)' },
|
|
175
|
+
},
|
|
176
|
+
required: [],
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
export function buildAgentApprovalsRequest(client, input) {
|
|
180
|
+
return {
|
|
181
|
+
async execute() {
|
|
182
|
+
try {
|
|
183
|
+
const args = {};
|
|
184
|
+
if (input.status)
|
|
185
|
+
args['status'] = input.status;
|
|
186
|
+
if (input.limit !== undefined)
|
|
187
|
+
args['limit'] = input.limit;
|
|
188
|
+
const result = await callAgentTool(client, 'tacit.agents.approvals', args);
|
|
189
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
190
|
+
}
|
|
191
|
+
catch (err) {
|
|
192
|
+
return apiErrorResult(err, 'tacit_agent_approvals');
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export async function handleAgentApprovals(args) {
|
|
198
|
+
const parsed = agentApprovalsInputSchema.safeParse(args);
|
|
199
|
+
if (!parsed.success) {
|
|
200
|
+
return { content: [{ type: 'text', text: `Invalid input: ${parsed.error.message}` }], isError: true };
|
|
201
|
+
}
|
|
202
|
+
return buildAgentApprovalsRequest(getClient(), parsed.data).execute();
|
|
203
|
+
}
|
|
204
|
+
// ─── tacit_agent_decide ──────────────────────────────────────────────────────
|
|
205
|
+
export const agentDecideInputSchema = z.object({
|
|
206
|
+
approval_id: z.string().min(1).describe('UUID of the approval to decide'),
|
|
207
|
+
decision: z.enum(['approve', 'deny']).describe('Decision: "approve" or "deny"'),
|
|
208
|
+
note: z.string().optional().describe('Optional note explaining the decision'),
|
|
209
|
+
});
|
|
210
|
+
export const AGENT_DECIDE_TOOL_DEF = {
|
|
211
|
+
name: 'tacit_agent_decide',
|
|
212
|
+
description: 'Approve or deny a pending approval. The decision is hash-bound to the approval\'s action payload for integrity.',
|
|
213
|
+
inputSchema: {
|
|
214
|
+
type: 'object',
|
|
215
|
+
properties: {
|
|
216
|
+
approval_id: { type: 'string', description: 'UUID of the approval to decide' },
|
|
217
|
+
decision: { type: 'string', enum: ['approve', 'deny'], description: 'Decision: "approve" or "deny"' },
|
|
218
|
+
note: { type: 'string', description: 'Optional note explaining the decision' },
|
|
219
|
+
},
|
|
220
|
+
required: ['approval_id', 'decision'],
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
export function buildAgentDecideRequest(client, input) {
|
|
224
|
+
return {
|
|
225
|
+
async execute() {
|
|
226
|
+
try {
|
|
227
|
+
const args = {
|
|
228
|
+
approval_id: input.approval_id,
|
|
229
|
+
decision: input.decision,
|
|
230
|
+
};
|
|
231
|
+
if (input.note)
|
|
232
|
+
args['note'] = input.note;
|
|
233
|
+
const result = await callAgentTool(client, 'tacit.agents.decide', args);
|
|
234
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
235
|
+
}
|
|
236
|
+
catch (err) {
|
|
237
|
+
return apiErrorResult(err, 'tacit_agent_decide');
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
export async function handleAgentDecide(args) {
|
|
243
|
+
const parsed = agentDecideInputSchema.safeParse(args);
|
|
244
|
+
if (!parsed.success) {
|
|
245
|
+
return { content: [{ type: 'text', text: `Invalid input: ${parsed.error.message}` }], isError: true };
|
|
246
|
+
}
|
|
247
|
+
return buildAgentDecideRequest(getClient(), parsed.data).execute();
|
|
248
|
+
}
|
|
249
|
+
// ─── tacit_agent_timeline ────────────────────────────────────────────────────
|
|
250
|
+
export const agentTimelineInputSchema = z.object({
|
|
251
|
+
agent_id: z.string().min(1).describe('UUID of the agent'),
|
|
252
|
+
run_id: z.string().min(1).describe('UUID of the agent run to get the timeline for'),
|
|
253
|
+
});
|
|
254
|
+
export const AGENT_TIMELINE_TOOL_DEF = {
|
|
255
|
+
name: 'tacit_agent_timeline',
|
|
256
|
+
description: 'Get the Chronicle-backed provenance event timeline for an agent run. Shows all events (assignment, tool calls, approvals, completions) in chronological order.',
|
|
257
|
+
inputSchema: {
|
|
258
|
+
type: 'object',
|
|
259
|
+
properties: {
|
|
260
|
+
agent_id: { type: 'string', description: 'UUID of the agent' },
|
|
261
|
+
run_id: { type: 'string', description: 'UUID of the agent run' },
|
|
262
|
+
},
|
|
263
|
+
required: ['agent_id', 'run_id'],
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
export function buildAgentTimelineRequest(client, input) {
|
|
267
|
+
return {
|
|
268
|
+
async execute() {
|
|
269
|
+
try {
|
|
270
|
+
const result = await callAgentTool(client, 'tacit.agents.timeline', {
|
|
271
|
+
agent_id: input.agent_id,
|
|
272
|
+
run_id: input.run_id,
|
|
273
|
+
});
|
|
274
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
275
|
+
}
|
|
276
|
+
catch (err) {
|
|
277
|
+
return apiErrorResult(err, 'tacit_agent_timeline');
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
export async function handleAgentTimeline(args) {
|
|
283
|
+
const parsed = agentTimelineInputSchema.safeParse(args);
|
|
284
|
+
if (!parsed.success) {
|
|
285
|
+
return { content: [{ type: 'text', text: `Invalid input: ${parsed.error.message}` }], isError: true };
|
|
286
|
+
}
|
|
287
|
+
return buildAgentTimelineRequest(getClient(), parsed.data).execute();
|
|
288
|
+
}
|
|
289
|
+
export function registerAgentTools(server, getClientFn) {
|
|
290
|
+
server.tool('tacit_agent_list', 'List business agents in the workspace.', {
|
|
291
|
+
limit: z.number().int().positive().optional().describe('Maximum agents to return'),
|
|
292
|
+
}, async (args) => {
|
|
293
|
+
const client = await getClientFn();
|
|
294
|
+
return buildAgentListRequest(client, args).execute();
|
|
295
|
+
});
|
|
296
|
+
server.tool('tacit_agent_delegate', 'Delegate a task to a business agent.', {
|
|
297
|
+
agent_id: z.string().min(1).describe('UUID of the agent to delegate to'),
|
|
298
|
+
task: z.string().min(1).describe('Task description to delegate'),
|
|
299
|
+
kind: z.string().optional().describe('Task kind'),
|
|
300
|
+
target_ids: z.array(z.string()).optional().describe('Target entity UUIDs'),
|
|
301
|
+
program_ids: z.array(z.string()).optional().describe('Program UUIDs'),
|
|
302
|
+
dossier_ids: z.array(z.string()).optional().describe('Dossier UUIDs'),
|
|
303
|
+
}, async (args) => {
|
|
304
|
+
const client = await getClientFn();
|
|
305
|
+
return buildAgentDelegateRequest(client, args).execute();
|
|
306
|
+
});
|
|
307
|
+
server.tool('tacit_agent_thread', 'Get the conversation thread for an agent.', {
|
|
308
|
+
agent_id: z.string().min(1).describe('UUID of the agent'),
|
|
309
|
+
}, async (args) => {
|
|
310
|
+
const client = await getClientFn();
|
|
311
|
+
return buildAgentThreadRequest(client, args).execute();
|
|
312
|
+
});
|
|
313
|
+
server.tool('tacit_agent_approvals', 'List pending or decided approvals in the workspace.', {
|
|
314
|
+
status: z.string().optional().describe('Filter by status'),
|
|
315
|
+
limit: z.number().int().positive().optional().describe('Maximum approvals to return'),
|
|
316
|
+
}, async (args) => {
|
|
317
|
+
const client = await getClientFn();
|
|
318
|
+
return buildAgentApprovalsRequest(client, args).execute();
|
|
319
|
+
});
|
|
320
|
+
server.tool('tacit_agent_decide', 'Approve or deny a pending approval.', {
|
|
321
|
+
approval_id: z.string().min(1).describe('UUID of the approval to decide'),
|
|
322
|
+
decision: z.enum(['approve', 'deny']).describe('Decision'),
|
|
323
|
+
note: z.string().optional().describe('Optional note'),
|
|
324
|
+
}, async (args) => {
|
|
325
|
+
const client = await getClientFn();
|
|
326
|
+
return buildAgentDecideRequest(client, args).execute();
|
|
327
|
+
});
|
|
328
|
+
server.tool('tacit_agent_timeline', 'Get Chronicle-backed provenance timeline for an agent run.', {
|
|
329
|
+
agent_id: z.string().min(1).describe('UUID of the agent'),
|
|
330
|
+
run_id: z.string().min(1).describe('UUID of the agent run'),
|
|
331
|
+
}, async (args) => {
|
|
332
|
+
const client = await getClientFn();
|
|
333
|
+
return buildAgentTimelineRequest(client, args).execute();
|
|
334
|
+
});
|
|
335
|
+
}
|