@tacitai/mcp-server 0.6.10 → 0.6.12
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/prompts.d.ts +37 -19
- package/dist/prompts.js +21 -11
- package/dist/tools/agents.js +4 -0
- package/dist/tools/artifacts.js +8 -2
- package/dist/tools/chronicle.js +7 -7
- package/dist/tools/crews.js +8 -8
- package/dist/tools/errors.d.ts +3 -0
- package/dist/tools/errors.js +19 -0
- package/dist/tools/github.js +4 -0
- package/dist/tools/gm.d.ts +44 -16
- package/dist/tools/gm.js +194 -39
- package/dist/tools/kb.js +4 -1
- package/dist/tools/lake-structure.js +8 -8
- package/dist/tools/lake.d.ts +44 -0
- package/dist/tools/lake.js +66 -2
- package/dist/tools/onboarding.js +8 -8
- package/dist/tools/people.js +5 -5
- package/dist/tools/pyramid.js +4 -1
- package/dist/tools/registry.d.ts +1 -1
- package/dist/tools/registry.js +7 -3
- package/dist/tools/research.js +14 -8
- package/dist/tools/wiki.js +4 -0
- package/dist/tools/workspaces.js +3 -3
- package/package.json +1 -2
package/dist/tools/gm.js
CHANGED
|
@@ -6,8 +6,11 @@
|
|
|
6
6
|
* POST /ingest — ingest content, classify, propose placement
|
|
7
7
|
* POST /approve — approve placement targets for a catalog entry
|
|
8
8
|
*/
|
|
9
|
+
import * as fs from 'fs';
|
|
10
|
+
import * as path from 'path';
|
|
9
11
|
import { z } from 'zod';
|
|
10
12
|
import { TacitClient, TacitApiError, TokenExpiredError } from '../client.js';
|
|
13
|
+
import { featureDisabledResult } from './errors.js';
|
|
11
14
|
function apiErrorResult(err, toolName) {
|
|
12
15
|
if (err instanceof TokenExpiredError) {
|
|
13
16
|
return {
|
|
@@ -16,14 +19,154 @@ function apiErrorResult(err, toolName) {
|
|
|
16
19
|
};
|
|
17
20
|
}
|
|
18
21
|
if (err instanceof TacitApiError) {
|
|
22
|
+
const disabled = featureDisabledResult(err);
|
|
23
|
+
if (disabled)
|
|
24
|
+
return disabled;
|
|
19
25
|
return { content: [{ type: 'text', text: `API error ${err.statusCode} on ${toolName}: ${err.body}` }], isError: true };
|
|
20
26
|
}
|
|
21
27
|
const msg = err instanceof Error ? err.message : String(err);
|
|
22
28
|
return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
|
|
23
29
|
}
|
|
24
30
|
// ─── tacit_gm_ingest ────────────────────────────────────────────────────────
|
|
31
|
+
/** Largest file `file_path` will read (10 MiB). */
|
|
32
|
+
export const GM_INGEST_MAX_FILE_BYTES = 10 * 1024 * 1024;
|
|
33
|
+
/** Text formats `file_path` may read. Anything else (binaries, keys, .env) is refused. */
|
|
34
|
+
const GM_INGEST_TEXT_EXTENSIONS = new Set([
|
|
35
|
+
'.html', '.htm', '.md', '.markdown', '.mdx', '.txt', '.text',
|
|
36
|
+
'.json', '.csv', '.tsv', '.yaml', '.yml', '.xml', '.rst', '.adoc',
|
|
37
|
+
]);
|
|
38
|
+
/**
|
|
39
|
+
* Roots `file_path` may read from: TACIT_MCP_FILE_ROOTS (path.delimiter-separated),
|
|
40
|
+
* else the process cwd. Each root is realpath'd so symlinked roots compare correctly.
|
|
41
|
+
*/
|
|
42
|
+
function gmIngestAllowedRoots() {
|
|
43
|
+
const raw = process.env['TACIT_MCP_FILE_ROOTS'];
|
|
44
|
+
const configured = raw && raw.trim()
|
|
45
|
+
? raw.split(path.delimiter).map((r) => r.trim()).filter(Boolean)
|
|
46
|
+
: [process.cwd()];
|
|
47
|
+
const roots = [];
|
|
48
|
+
for (const r of configured) {
|
|
49
|
+
try {
|
|
50
|
+
roots.push(fs.realpathSync(path.resolve(r)));
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// A root that does not exist cannot contain anything; skip it.
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return roots;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Credential-store names (client_secret.json, aws-credentials.json, github_token.txt,
|
|
60
|
+
* secrets.prod.yaml, api-key.json, aws_access_key_id.json…). Applied only to data formats, where secret stores live; document
|
|
61
|
+
* formats (.md, .html, .rst…) skip it so ADRs and briefs about tokens stay ingestible.
|
|
62
|
+
*/
|
|
63
|
+
const GM_INGEST_SECRET_NAME = /(^|[._-])(credentials?|secrets?|tokens?|passwords?|keys?)([._-]|$)/i;
|
|
64
|
+
const GM_INGEST_DATA_EXTENSIONS = new Set(['.json', '.yaml', '.yml', '.txt', '.text', '.xml', '.csv', '.tsv']);
|
|
65
|
+
function isInsideRoot(root, target) {
|
|
66
|
+
const rel = path.relative(root, target);
|
|
67
|
+
if (rel === '' || path.isAbsolute(rel))
|
|
68
|
+
return false;
|
|
69
|
+
return rel.split(path.sep)[0] !== '..';
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Read a local file for tacit_gm_ingest (BUG-333). Only on the stdio transport, only
|
|
73
|
+
* inside the allowed roots (after resolving symlinks), only text formats, size-capped.
|
|
74
|
+
* A missing file is an error — never ingest the path string itself.
|
|
75
|
+
*/
|
|
76
|
+
export function readGmIngestFile(filePath) {
|
|
77
|
+
if (process.env['MCP_TRANSPORT'] === 'http') {
|
|
78
|
+
return { ok: false, reason: 'file_path is only available on the stdio transport; send content instead' };
|
|
79
|
+
}
|
|
80
|
+
const roots = gmIngestAllowedRoots();
|
|
81
|
+
if (roots.length === 0) {
|
|
82
|
+
return { ok: false, reason: 'no readable file roots configured (TACIT_MCP_FILE_ROOTS)' };
|
|
83
|
+
}
|
|
84
|
+
const candidate = path.isAbsolute(filePath) ? filePath : path.resolve(roots[0], filePath);
|
|
85
|
+
let real;
|
|
86
|
+
try {
|
|
87
|
+
real = fs.realpathSync(candidate);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return { ok: false, reason: `file not found: ${filePath}` };
|
|
91
|
+
}
|
|
92
|
+
// Deepest matching root wins, so a nested root (e.g. <repo>/.claude/skills) listed after
|
|
93
|
+
// <repo> still governs the hidden-path check for files beneath it.
|
|
94
|
+
const root = roots.filter((r) => isInsideRoot(r, real)).sort((x, y) => y.length - x.length)[0];
|
|
95
|
+
if (root === undefined) {
|
|
96
|
+
return { ok: false, reason: `file_path is outside the allowed roots (set TACIT_MCP_FILE_ROOTS to widen): ${filePath}` };
|
|
97
|
+
}
|
|
98
|
+
// Hidden files/dirs (.mcp.json, .env, .claude/settings.json, .git/…) and credential-store
|
|
99
|
+
// files often hold tokens; never ship them to the classifier or a shared catalog. Checked
|
|
100
|
+
// relative to the matched root, so a root that is itself hidden (e.g. .claude/skills) works.
|
|
101
|
+
if (path.relative(root, real).split(path.sep).some((seg) => seg.startsWith('.'))) {
|
|
102
|
+
return { ok: false, reason: `hidden files and directories cannot be ingested: ${filePath}` };
|
|
103
|
+
}
|
|
104
|
+
if (GM_INGEST_DATA_EXTENSIONS.has(path.extname(real).toLowerCase()) && GM_INGEST_SECRET_NAME.test(path.basename(real))) {
|
|
105
|
+
return { ok: false, reason: `file name looks credential-bearing and cannot be ingested: ${filePath}` };
|
|
106
|
+
}
|
|
107
|
+
const ext = path.extname(real).toLowerCase();
|
|
108
|
+
if (!GM_INGEST_TEXT_EXTENSIONS.has(ext)) {
|
|
109
|
+
return { ok: false, reason: `unsupported file type "${ext || '(none)'}"; allowed: ${[...GM_INGEST_TEXT_EXTENSIONS].join(' ')}` };
|
|
110
|
+
}
|
|
111
|
+
// Check the type before opening: open() on a FIFO blocks and would hang the stdio server.
|
|
112
|
+
let pre;
|
|
113
|
+
try {
|
|
114
|
+
pre = fs.statSync(real);
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return { ok: false, reason: `file not found: ${filePath}` };
|
|
118
|
+
}
|
|
119
|
+
if (!pre.isFile())
|
|
120
|
+
return { ok: false, reason: `not a regular file: ${filePath}` };
|
|
121
|
+
let fd;
|
|
122
|
+
try {
|
|
123
|
+
fd = fs.openSync(real, fs.constants.O_RDONLY | fs.constants.O_NONBLOCK);
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
return { ok: false, reason: `cannot open file: ${err instanceof Error ? err.message : String(err)}` };
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
const stat = fs.fstatSync(fd);
|
|
130
|
+
if (!stat.isFile())
|
|
131
|
+
return { ok: false, reason: `not a regular file: ${filePath}` };
|
|
132
|
+
// The opened file must be the one that passed the root check (no swap in between).
|
|
133
|
+
if (stat.dev !== pre.dev || stat.ino !== pre.ino) {
|
|
134
|
+
return { ok: false, reason: `file changed while being read; retry: ${filePath}` };
|
|
135
|
+
}
|
|
136
|
+
// Re-resolve after opening: if a parent directory was swapped for a symlink between the
|
|
137
|
+
// root check and the open, the path no longer resolves to the checked file. (Node has no
|
|
138
|
+
// openat/O_NOFOLLOW per component, so this narrows rather than eliminates the window; only
|
|
139
|
+
// a local process with write access to the root can race it.)
|
|
140
|
+
let again;
|
|
141
|
+
try {
|
|
142
|
+
again = fs.realpathSync(candidate);
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return { ok: false, reason: `file changed while being read; retry: ${filePath}` };
|
|
146
|
+
}
|
|
147
|
+
if (again !== real || !isInsideRoot(root, again)) {
|
|
148
|
+
return { ok: false, reason: `file changed while being read; retry: ${filePath}` };
|
|
149
|
+
}
|
|
150
|
+
if (stat.size > GM_INGEST_MAX_FILE_BYTES) {
|
|
151
|
+
return { ok: false, reason: `file size ${stat.size} bytes exceeds the ${GM_INGEST_MAX_FILE_BYTES}-byte limit` };
|
|
152
|
+
}
|
|
153
|
+
const content = fs.readFileSync(fd, 'utf8');
|
|
154
|
+
if (content.length === 0)
|
|
155
|
+
return { ok: false, reason: `file is empty: ${filePath}` };
|
|
156
|
+
return { ok: true, content };
|
|
157
|
+
}
|
|
158
|
+
catch (err) {
|
|
159
|
+
return { ok: false, reason: `cannot read file: ${err instanceof Error ? err.message : String(err)}` };
|
|
160
|
+
}
|
|
161
|
+
finally {
|
|
162
|
+
fs.closeSync(fd);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
25
165
|
export const gmIngestInputSchema = z.object({
|
|
26
|
-
content: z.string().min(1).describe('The content to ingest'),
|
|
166
|
+
content: z.string().min(1).optional().describe('The content to ingest inline. Provide exactly one of content or file_path.'),
|
|
167
|
+
file_path: z.string().min(1).optional().describe('Local text file to ingest (html, md, txt, json, csv, yaml, xml…). Read by the MCP server so the content is never pasted. ' +
|
|
168
|
+
'Relative paths resolve against the first allowed root (TACIT_MCP_FILE_ROOTS, default cwd). stdio transport only. ' +
|
|
169
|
+
'Provide exactly one of content or file_path.'),
|
|
27
170
|
title: z.string().min(1).describe('Title for the catalog entry'),
|
|
28
171
|
source_uri: z.string().optional().describe('Source URI (defaults to tacit://adhoc/<uuid>)'),
|
|
29
172
|
content_type: z.string().optional().describe('Content type (auto-detected if omitted)'),
|
|
@@ -36,11 +179,16 @@ export const GM_INGEST_TOOL_DEF = {
|
|
|
36
179
|
name: 'tacit_gm_ingest',
|
|
37
180
|
description: 'Ingest content through the unified gateway manager. Classifies the content, creates a catalog entry and artifact, ' +
|
|
38
181
|
'and returns a placement proposal with suggested targets (KB, pyramid, or lake-only). ' +
|
|
182
|
+
'Pass either inline content or a local file_path (preferred for HTML/MD files — never paste a file). ' +
|
|
39
183
|
'Route: POST /api/v1/gm/ingest.',
|
|
40
184
|
inputSchema: {
|
|
41
185
|
type: 'object',
|
|
42
186
|
properties: {
|
|
43
|
-
content: { type: 'string', description: 'The content to ingest' },
|
|
187
|
+
content: { type: 'string', description: 'The content to ingest inline. Provide exactly one of content or file_path.' },
|
|
188
|
+
file_path: {
|
|
189
|
+
type: 'string',
|
|
190
|
+
description: 'Local text file to ingest, read by the MCP server (stdio only, within TACIT_MCP_FILE_ROOTS / cwd). Provide exactly one of content or file_path.',
|
|
191
|
+
},
|
|
44
192
|
title: { type: 'string', description: 'Title for the catalog entry' },
|
|
45
193
|
source_uri: { type: 'string', description: 'Source URI (defaults to tacit://adhoc/<uuid>)' },
|
|
46
194
|
content_type: { type: 'string', description: 'Content type (auto-detected if omitted)' },
|
|
@@ -53,15 +201,34 @@ export const GM_INGEST_TOOL_DEF = {
|
|
|
53
201
|
description: 'Optional hints for the classifier',
|
|
54
202
|
},
|
|
55
203
|
},
|
|
56
|
-
required: ['
|
|
204
|
+
required: ['title'],
|
|
57
205
|
},
|
|
58
206
|
};
|
|
59
207
|
export function buildGmIngestRequest(client, input) {
|
|
60
208
|
return {
|
|
61
209
|
async execute() {
|
|
210
|
+
const hasContent = input.content !== undefined;
|
|
211
|
+
const hasFile = input.file_path !== undefined;
|
|
212
|
+
if (hasContent === hasFile) {
|
|
213
|
+
return {
|
|
214
|
+
content: [{ type: 'text', text: 'Invalid input: provide exactly one of content or file_path' }],
|
|
215
|
+
isError: true,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
let content;
|
|
219
|
+
if (hasFile) {
|
|
220
|
+
const read = readGmIngestFile(input.file_path);
|
|
221
|
+
if (!read.ok) {
|
|
222
|
+
return { content: [{ type: 'text', text: `Error: ${read.reason}` }], isError: true };
|
|
223
|
+
}
|
|
224
|
+
content = read.content;
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
content = input.content;
|
|
228
|
+
}
|
|
62
229
|
try {
|
|
63
230
|
const body = {
|
|
64
|
-
content
|
|
231
|
+
content,
|
|
65
232
|
title: input.title,
|
|
66
233
|
};
|
|
67
234
|
if (input.source_uri !== undefined)
|
|
@@ -90,41 +257,49 @@ export async function handleGmIngest(args) {
|
|
|
90
257
|
export const gmApproveInputSchema = z.object({
|
|
91
258
|
catalog_id: z.string().uuid().describe('The catalog entry to approve placement for'),
|
|
92
259
|
approved_targets: z.array(z.object({
|
|
93
|
-
surface: z.
|
|
94
|
-
collection_or_program: z.string().
|
|
95
|
-
dossier_id: z.string().uuid().optional(),
|
|
96
|
-
})).describe('
|
|
260
|
+
surface: z.literal('pyramid'),
|
|
261
|
+
collection_or_program: z.string().uuid().describe('Program UUID (the pyramid home)'),
|
|
262
|
+
dossier_id: z.string().uuid().optional().describe('Dossier UUID to add the artifact to'),
|
|
263
|
+
}).strict()).length(1).describe('Exactly one pyramid target'),
|
|
97
264
|
rejected_targets: z.array(z.object({
|
|
98
265
|
surface: z.string(),
|
|
99
266
|
reason: z.string().optional(),
|
|
100
|
-
})).optional().default([]).describe('Targets to explicitly reject'),
|
|
101
|
-
});
|
|
267
|
+
}).strict()).optional().default([]).describe('Targets to explicitly reject'),
|
|
268
|
+
}).strict();
|
|
102
269
|
export const GM_APPROVE_TOOL_DEF = {
|
|
103
270
|
name: 'tacit_gm_approve',
|
|
104
|
-
description: '
|
|
105
|
-
'
|
|
271
|
+
description: 'Place an artifact created by tacit_gm_ingest in the pyramid: sets its program (and portfolio) home and, ' +
|
|
272
|
+
'if dossier_id is given, adds it to that dossier, in one transaction. Exactly one pyramid target per call. ' +
|
|
273
|
+
'Does NOT place KB content; use tacit_kb_promote_from_artifact (SOP-03). ' +
|
|
274
|
+
'Refuses catalog entries that are not ACTIVE and deleted artifacts. ' +
|
|
275
|
+
'Repeat calls are idempotent for placement and record one PlacementApproved event each. ' +
|
|
106
276
|
'Route: POST /api/v1/gm/approve.',
|
|
107
277
|
inputSchema: {
|
|
108
278
|
type: 'object',
|
|
279
|
+
additionalProperties: false,
|
|
109
280
|
properties: {
|
|
110
281
|
catalog_id: { type: 'string', description: 'The catalog entry to approve placement for' },
|
|
111
282
|
approved_targets: {
|
|
112
283
|
type: 'array',
|
|
284
|
+
minItems: 1,
|
|
285
|
+
maxItems: 1,
|
|
113
286
|
items: {
|
|
114
287
|
type: 'object',
|
|
288
|
+
additionalProperties: false,
|
|
115
289
|
properties: {
|
|
116
|
-
surface: { type: 'string', enum: ['
|
|
117
|
-
collection_or_program: { type: 'string', description: '
|
|
118
|
-
dossier_id: { type: 'string', description: 'Dossier UUID
|
|
290
|
+
surface: { type: 'string', enum: ['pyramid'], description: 'Target surface' },
|
|
291
|
+
collection_or_program: { type: 'string', description: 'Program UUID (the pyramid home)' },
|
|
292
|
+
dossier_id: { type: 'string', description: 'Dossier UUID to add the artifact to' },
|
|
119
293
|
},
|
|
120
|
-
required: ['surface'],
|
|
294
|
+
required: ['surface', 'collection_or_program'],
|
|
121
295
|
},
|
|
122
|
-
description: '
|
|
296
|
+
description: 'Exactly one pyramid target',
|
|
123
297
|
},
|
|
124
298
|
rejected_targets: {
|
|
125
299
|
type: 'array',
|
|
126
300
|
items: {
|
|
127
301
|
type: 'object',
|
|
302
|
+
additionalProperties: false,
|
|
128
303
|
properties: {
|
|
129
304
|
surface: { type: 'string', description: 'Surface being rejected' },
|
|
130
305
|
reason: { type: 'string', description: 'Reason for rejection' },
|
|
@@ -166,31 +341,11 @@ export async function handleGmApprove(args) {
|
|
|
166
341
|
}
|
|
167
342
|
// ─── Registration ───────────────────────────────────────────────────────────
|
|
168
343
|
export function registerGmTools(server, getClientFn) {
|
|
169
|
-
server.tool('tacit_gm_ingest', GM_INGEST_TOOL_DEF.description, {
|
|
170
|
-
content: z.string().min(1).describe('The content to ingest'),
|
|
171
|
-
title: z.string().min(1).describe('Title for the catalog entry'),
|
|
172
|
-
source_uri: z.string().optional().describe('Source URI (defaults to tacit://adhoc/<uuid>)'),
|
|
173
|
-
content_type: z.string().optional().describe('Content type (auto-detected if omitted)'),
|
|
174
|
-
classification_hints: z.object({
|
|
175
|
-
domain: z.string().optional(),
|
|
176
|
-
content_type: z.string().optional(),
|
|
177
|
-
}).optional().describe('Optional hints for the classifier'),
|
|
178
|
-
}, async (args) => {
|
|
344
|
+
server.tool('tacit_gm_ingest', GM_INGEST_TOOL_DEF.description, gmIngestInputSchema.shape, async (args) => {
|
|
179
345
|
const client = await getClientFn();
|
|
180
346
|
return buildGmIngestRequest(client, args).execute();
|
|
181
347
|
});
|
|
182
|
-
server.tool('tacit_gm_approve', GM_APPROVE_TOOL_DEF.description, {
|
|
183
|
-
catalog_id: z.string().uuid().describe('The catalog entry to approve placement for'),
|
|
184
|
-
approved_targets: z.array(z.object({
|
|
185
|
-
surface: z.enum(['kb', 'pyramid']),
|
|
186
|
-
collection_or_program: z.string().optional(),
|
|
187
|
-
dossier_id: z.string().uuid().optional(),
|
|
188
|
-
})).describe('Targets to approve for placement'),
|
|
189
|
-
rejected_targets: z.array(z.object({
|
|
190
|
-
surface: z.string(),
|
|
191
|
-
reason: z.string().optional(),
|
|
192
|
-
})).optional().default([]).describe('Targets to explicitly reject'),
|
|
193
|
-
}, async (args) => {
|
|
348
|
+
server.tool('tacit_gm_approve', GM_APPROVE_TOOL_DEF.description, gmApproveInputSchema.shape, async (args) => {
|
|
194
349
|
const client = await getClientFn();
|
|
195
350
|
return buildGmApproveRequest(client, args).execute();
|
|
196
351
|
});
|
package/dist/tools/kb.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { z } from 'zod';
|
|
15
15
|
import { getClient, TacitApiError, TokenExpiredError } from '../client.js';
|
|
16
|
-
import { apiErrorResult as sharedApiErrorResult } from './errors.js';
|
|
16
|
+
import { apiErrorResult as sharedApiErrorResult, featureDisabledResult } from './errors.js';
|
|
17
17
|
function apiErrorResult(err, toolName) {
|
|
18
18
|
if (err instanceof TokenExpiredError) {
|
|
19
19
|
return {
|
|
@@ -22,6 +22,9 @@ function apiErrorResult(err, toolName) {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
if (err instanceof TacitApiError) {
|
|
25
|
+
const disabled = featureDisabledResult(err);
|
|
26
|
+
if (disabled)
|
|
27
|
+
return disabled;
|
|
25
28
|
return { content: [{ type: 'text', text: `API error ${err.statusCode} on ${toolName}: ${err.body}` }], isError: true };
|
|
26
29
|
}
|
|
27
30
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { TacitApiError } from '../client.js';
|
|
3
|
-
import { success, error } from './errors.js';
|
|
3
|
+
import { success, error, featureDisabledResult } from './errors.js';
|
|
4
4
|
export function registerLakeStructureTools(server, getClient) {
|
|
5
5
|
server.tool('tacit_lake_propose_structure', 'Generate a v7 structure proposal for a registered source. Does NOT modify the repo.', {
|
|
6
6
|
source_id: z.string().uuid().describe('Source ID to generate proposal for'),
|
|
@@ -12,7 +12,7 @@ export function registerLakeStructureTools(server, getClient) {
|
|
|
12
12
|
}
|
|
13
13
|
catch (e) {
|
|
14
14
|
if (e instanceof TacitApiError)
|
|
15
|
-
return error(e.message);
|
|
15
|
+
return featureDisabledResult(e) ?? error(e.message);
|
|
16
16
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
17
17
|
}
|
|
18
18
|
});
|
|
@@ -34,7 +34,7 @@ export function registerLakeStructureTools(server, getClient) {
|
|
|
34
34
|
}
|
|
35
35
|
catch (e) {
|
|
36
36
|
if (e instanceof TacitApiError)
|
|
37
|
-
return error(e.message);
|
|
37
|
+
return featureDisabledResult(e) ?? error(e.message);
|
|
38
38
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
39
39
|
}
|
|
40
40
|
});
|
|
@@ -48,7 +48,7 @@ export function registerLakeStructureTools(server, getClient) {
|
|
|
48
48
|
}
|
|
49
49
|
catch (e) {
|
|
50
50
|
if (e instanceof TacitApiError)
|
|
51
|
-
return error(e.message);
|
|
51
|
+
return featureDisabledResult(e) ?? error(e.message);
|
|
52
52
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
53
53
|
}
|
|
54
54
|
});
|
|
@@ -71,7 +71,7 @@ export function registerLakeStructureTools(server, getClient) {
|
|
|
71
71
|
}
|
|
72
72
|
catch (e) {
|
|
73
73
|
if (e instanceof TacitApiError)
|
|
74
|
-
return error(e.message);
|
|
74
|
+
return featureDisabledResult(e) ?? error(e.message);
|
|
75
75
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
76
76
|
}
|
|
77
77
|
});
|
|
@@ -87,7 +87,7 @@ export function registerLakeStructureTools(server, getClient) {
|
|
|
87
87
|
}
|
|
88
88
|
catch (e) {
|
|
89
89
|
if (e instanceof TacitApiError)
|
|
90
|
-
return error(e.message);
|
|
90
|
+
return featureDisabledResult(e) ?? error(e.message);
|
|
91
91
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
92
92
|
}
|
|
93
93
|
});
|
|
@@ -103,7 +103,7 @@ export function registerLakeStructureTools(server, getClient) {
|
|
|
103
103
|
}
|
|
104
104
|
catch (e) {
|
|
105
105
|
if (e instanceof TacitApiError)
|
|
106
|
-
return error(e.message);
|
|
106
|
+
return featureDisabledResult(e) ?? error(e.message);
|
|
107
107
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
108
108
|
}
|
|
109
109
|
});
|
|
@@ -119,7 +119,7 @@ export function registerLakeStructureTools(server, getClient) {
|
|
|
119
119
|
}
|
|
120
120
|
catch (e) {
|
|
121
121
|
if (e instanceof TacitApiError)
|
|
122
|
-
return error(e.message);
|
|
122
|
+
return featureDisabledResult(e) ?? error(e.message);
|
|
123
123
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
124
124
|
}
|
|
125
125
|
});
|
package/dist/tools/lake.d.ts
CHANGED
|
@@ -197,12 +197,18 @@ export declare function handleSyncStatus(args: unknown): Promise<{
|
|
|
197
197
|
export declare const triggerSyncInputSchema: z.ZodObject<{
|
|
198
198
|
source_id: z.ZodString;
|
|
199
199
|
confirm_deletions: z.ZodOptional<z.ZodBoolean>;
|
|
200
|
+
full_rescan: z.ZodOptional<z.ZodBoolean>;
|
|
201
|
+
allow_empty_enumeration: z.ZodOptional<z.ZodBoolean>;
|
|
200
202
|
}, "strip", z.ZodTypeAny, {
|
|
201
203
|
source_id: string;
|
|
202
204
|
confirm_deletions?: boolean | undefined;
|
|
205
|
+
full_rescan?: boolean | undefined;
|
|
206
|
+
allow_empty_enumeration?: boolean | undefined;
|
|
203
207
|
}, {
|
|
204
208
|
source_id: string;
|
|
205
209
|
confirm_deletions?: boolean | undefined;
|
|
210
|
+
full_rescan?: boolean | undefined;
|
|
211
|
+
allow_empty_enumeration?: boolean | undefined;
|
|
206
212
|
}>;
|
|
207
213
|
export type TriggerSyncInput = z.infer<typeof triggerSyncInputSchema>;
|
|
208
214
|
export declare const TRIGGER_SYNC_TOOL_DEF: {
|
|
@@ -219,6 +225,14 @@ export declare const TRIGGER_SYNC_TOOL_DEF: {
|
|
|
219
225
|
type: string;
|
|
220
226
|
description: string;
|
|
221
227
|
};
|
|
228
|
+
full_rescan: {
|
|
229
|
+
type: string;
|
|
230
|
+
description: string;
|
|
231
|
+
};
|
|
232
|
+
allow_empty_enumeration: {
|
|
233
|
+
type: string;
|
|
234
|
+
description: string;
|
|
235
|
+
};
|
|
222
236
|
};
|
|
223
237
|
required: string[];
|
|
224
238
|
};
|
|
@@ -609,6 +623,36 @@ export declare function handleDeleteCatalogItem(args: unknown): Promise<{
|
|
|
609
623
|
}>;
|
|
610
624
|
isError?: boolean;
|
|
611
625
|
}>;
|
|
626
|
+
export declare const restoreCatalogItemInputSchema: z.ZodObject<{
|
|
627
|
+
catalog_id: z.ZodString;
|
|
628
|
+
}, "strip", z.ZodTypeAny, {
|
|
629
|
+
catalog_id: string;
|
|
630
|
+
}, {
|
|
631
|
+
catalog_id: string;
|
|
632
|
+
}>;
|
|
633
|
+
export type RestoreCatalogItemInput = z.infer<typeof restoreCatalogItemInputSchema>;
|
|
634
|
+
export declare const RESTORE_CATALOG_ITEM_TOOL_DEF: {
|
|
635
|
+
name: "tacit_lake_restore_catalog_item";
|
|
636
|
+
description: string;
|
|
637
|
+
inputSchema: {
|
|
638
|
+
type: "object";
|
|
639
|
+
properties: {
|
|
640
|
+
catalog_id: {
|
|
641
|
+
type: string;
|
|
642
|
+
description: string;
|
|
643
|
+
};
|
|
644
|
+
};
|
|
645
|
+
required: string[];
|
|
646
|
+
};
|
|
647
|
+
};
|
|
648
|
+
export declare function buildRestoreCatalogItemRequest(client: TacitClient, input: RestoreCatalogItemInput): ToolRequest;
|
|
649
|
+
export declare function handleRestoreCatalogItem(args: unknown): Promise<{
|
|
650
|
+
content: Array<{
|
|
651
|
+
type: 'text';
|
|
652
|
+
text: string;
|
|
653
|
+
}>;
|
|
654
|
+
isError?: boolean;
|
|
655
|
+
}>;
|
|
612
656
|
export declare const ingestInputSchema: z.ZodObject<{
|
|
613
657
|
source_uri: z.ZodString;
|
|
614
658
|
content: z.ZodString;
|
package/dist/tools/lake.js
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
*/
|
|
27
27
|
import { z } from 'zod';
|
|
28
28
|
import { getClient, TacitApiError, TokenExpiredError } from '../client.js';
|
|
29
|
+
import { featureDisabledResult } from './errors.js';
|
|
29
30
|
function apiErrorResult(err, toolName) {
|
|
30
31
|
if (err instanceof TokenExpiredError) {
|
|
31
32
|
return {
|
|
@@ -34,6 +35,9 @@ function apiErrorResult(err, toolName) {
|
|
|
34
35
|
};
|
|
35
36
|
}
|
|
36
37
|
if (err instanceof TacitApiError) {
|
|
38
|
+
const disabled = featureDisabledResult(err);
|
|
39
|
+
if (disabled)
|
|
40
|
+
return disabled;
|
|
37
41
|
return { content: [{ type: 'text', text: `API error ${err.statusCode} on ${toolName}: ${err.body}` }], isError: true };
|
|
38
42
|
}
|
|
39
43
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -175,7 +179,7 @@ export const syncStatusInputSchema = z.object({
|
|
|
175
179
|
});
|
|
176
180
|
export const SYNC_STATUS_TOOL_DEF = {
|
|
177
181
|
name: 'tacit_lake_sync_status',
|
|
178
|
-
description: 'Check data lake sync status — running runs, active catalog rows, latest run status. Route: GET /api/v1/org/lake/status.',
|
|
182
|
+
description: 'Check data lake sync status — running runs, active catalog rows, latest run status, latest_gate_skipped_reason, and alerts (recent runs matching a mass-tombstone signature: NO_WORK_ONLY_DELETES, HIGH_DELETE_RATIO, GATE_SKIPPED). Route: GET /api/v1/org/lake/status.',
|
|
179
183
|
inputSchema: {
|
|
180
184
|
type: 'object',
|
|
181
185
|
properties: {
|
|
@@ -211,15 +215,31 @@ export async function handleSyncStatus(args) {
|
|
|
211
215
|
export const triggerSyncInputSchema = z.object({
|
|
212
216
|
source_id: z.string().uuid().describe('Source to sync'),
|
|
213
217
|
confirm_deletions: z.boolean().optional().describe('Confirm deletion of removed source files'),
|
|
218
|
+
full_rescan: z
|
|
219
|
+
.boolean()
|
|
220
|
+
.optional()
|
|
221
|
+
.describe('Enumerate the whole source instead of the delta since the last sync (GIT only; default false)'),
|
|
222
|
+
allow_empty_enumeration: z
|
|
223
|
+
.boolean()
|
|
224
|
+
.optional()
|
|
225
|
+
.describe('Confirm that an empty full-scan enumeration is intended, so every live row is tombstoned (default false)'),
|
|
214
226
|
});
|
|
215
227
|
export const TRIGGER_SYNC_TOOL_DEF = {
|
|
216
228
|
name: 'tacit_lake_trigger_sync',
|
|
217
|
-
description: 'Trigger an incremental sync from a registered data lake source. Route: POST /api/v1/org/lake/sync.',
|
|
229
|
+
description: 'Trigger an incremental sync from a registered data lake source. Pass full_rescan=true for a full enumeration (the supported GIT removal path is full_rescan + confirm_deletions). Route: POST /api/v1/org/lake/sync.',
|
|
218
230
|
inputSchema: {
|
|
219
231
|
type: 'object',
|
|
220
232
|
properties: {
|
|
221
233
|
source_id: { type: 'string', description: 'Source to sync' },
|
|
222
234
|
confirm_deletions: { type: 'boolean', description: 'Confirm deletion of removed source files' },
|
|
235
|
+
full_rescan: {
|
|
236
|
+
type: 'boolean',
|
|
237
|
+
description: 'Enumerate the whole source instead of the delta since the last sync (GIT only; default false)',
|
|
238
|
+
},
|
|
239
|
+
allow_empty_enumeration: {
|
|
240
|
+
type: 'boolean',
|
|
241
|
+
description: 'Confirm that an empty full-scan enumeration is intended, so every live row is tombstoned (default false)',
|
|
242
|
+
},
|
|
223
243
|
},
|
|
224
244
|
required: ['source_id'],
|
|
225
245
|
},
|
|
@@ -231,6 +251,11 @@ export function buildTriggerSyncRequest(client, input) {
|
|
|
231
251
|
const body = { source_id: input.source_id };
|
|
232
252
|
if (input.confirm_deletions !== undefined)
|
|
233
253
|
body['confirm_deletions'] = input.confirm_deletions;
|
|
254
|
+
// BUG-332 Fix 6: forward both flags, or the backend runs a plain delta sync.
|
|
255
|
+
if (input.full_rescan !== undefined)
|
|
256
|
+
body['full_rescan'] = input.full_rescan;
|
|
257
|
+
if (input.allow_empty_enumeration !== undefined)
|
|
258
|
+
body['allow_empty_enumeration'] = input.allow_empty_enumeration;
|
|
234
259
|
const result = await client.post('/api/v1/org/lake/sync', body);
|
|
235
260
|
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
236
261
|
}
|
|
@@ -604,6 +629,41 @@ export async function handleDeleteCatalogItem(args) {
|
|
|
604
629
|
}
|
|
605
630
|
return buildDeleteCatalogItemRequest(getClient(), parsed.data).execute();
|
|
606
631
|
}
|
|
632
|
+
// ─── tacit_lake_restore_catalog_item ─────────────────────────────────────────
|
|
633
|
+
export const restoreCatalogItemInputSchema = z.object({
|
|
634
|
+
catalog_id: z.string().uuid().describe('Catalog item to restore (must be OPERATOR_DELETED)'),
|
|
635
|
+
});
|
|
636
|
+
export const RESTORE_CATALOG_ITEM_TOOL_DEF = {
|
|
637
|
+
name: 'tacit_lake_restore_catalog_item',
|
|
638
|
+
description: 'Restore a soft-deleted catalog item (OPERATOR_DELETED → ACTIVE) and re-include its search projections. Route: POST /api/v1/org/lake/catalog/{catalog_id}/restore.',
|
|
639
|
+
inputSchema: {
|
|
640
|
+
type: 'object',
|
|
641
|
+
properties: {
|
|
642
|
+
catalog_id: { type: 'string', description: 'Catalog item to restore' },
|
|
643
|
+
},
|
|
644
|
+
required: ['catalog_id'],
|
|
645
|
+
},
|
|
646
|
+
};
|
|
647
|
+
export function buildRestoreCatalogItemRequest(client, input) {
|
|
648
|
+
return {
|
|
649
|
+
async execute() {
|
|
650
|
+
try {
|
|
651
|
+
const result = await client.post(`/api/v1/org/lake/catalog/${input.catalog_id}/restore`, {});
|
|
652
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
653
|
+
}
|
|
654
|
+
catch (err) {
|
|
655
|
+
return apiErrorResult(err, 'tacit_lake_restore_catalog_item');
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
export async function handleRestoreCatalogItem(args) {
|
|
661
|
+
const parsed = restoreCatalogItemInputSchema.safeParse(args);
|
|
662
|
+
if (!parsed.success) {
|
|
663
|
+
return { content: [{ type: 'text', text: `Invalid input: ${parsed.error.message}` }], isError: true };
|
|
664
|
+
}
|
|
665
|
+
return buildRestoreCatalogItemRequest(getClient(), parsed.data).execute();
|
|
666
|
+
}
|
|
607
667
|
// ─── tacit_lake_ingest ───────────────────────────────────────────────────────
|
|
608
668
|
export const ingestInputSchema = z.object({
|
|
609
669
|
source_uri: z.string().min(1).describe('URI identifying the document'),
|
|
@@ -981,6 +1041,10 @@ export function registerLakeTools(server, getClientFn) {
|
|
|
981
1041
|
const client = await getClientFn();
|
|
982
1042
|
return buildDeleteCatalogItemRequest(client, args).execute();
|
|
983
1043
|
});
|
|
1044
|
+
server.tool('tacit_lake_restore_catalog_item', RESTORE_CATALOG_ITEM_TOOL_DEF.description, restoreCatalogItemInputSchema.shape, async (args) => {
|
|
1045
|
+
const client = await getClientFn();
|
|
1046
|
+
return buildRestoreCatalogItemRequest(client, args).execute();
|
|
1047
|
+
});
|
|
984
1048
|
server.tool('tacit_lake_ingest', INGEST_TOOL_DEF.description, ingestInputSchema.shape, async (args) => {
|
|
985
1049
|
const client = await getClientFn();
|
|
986
1050
|
return buildIngestRequest(client, args).execute();
|
package/dist/tools/onboarding.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { TacitApiError } from '../client.js';
|
|
3
|
-
import { success, error } from './errors.js';
|
|
3
|
+
import { success, error, featureDisabledResult } from './errors.js';
|
|
4
4
|
import { EXPERIENCES, fetchWorkspaceState } from '../prompts.js';
|
|
5
5
|
export function registerOnboardingTools(server, getClient) {
|
|
6
|
-
server.tool('tacit_onboarding', 'Guide the user through the TACIT onboarding journey — the
|
|
7
|
-
'
|
|
8
|
-
'"
|
|
9
|
-
'
|
|
6
|
+
server.tool('tacit_onboarding', 'Guide the user through the TACIT onboarding journey — the Eleven Experiences. ' +
|
|
7
|
+
'ONLY call this when the user explicitly asks for onboarding: "onboard me", "take me through onboarding", ' +
|
|
8
|
+
'"walk me through the experiences", "what are the experiences", "show me the onboarding path". ' +
|
|
9
|
+
'Do NOT call this for general questions, daily use, or when the user is just working normally.', {
|
|
10
10
|
completed: z
|
|
11
11
|
.string()
|
|
12
12
|
.optional()
|
|
@@ -40,7 +40,7 @@ export function registerOnboardingTools(server, getClient) {
|
|
|
40
40
|
lines.push(`Progress: ${completedIds.length} of ${EXPERIENCES.length} experiences complete.`);
|
|
41
41
|
lines.push('');
|
|
42
42
|
if (!next) {
|
|
43
|
-
lines.push('All
|
|
43
|
+
lines.push('All eleven experiences complete — you are a TACIT power user.');
|
|
44
44
|
lines.push('');
|
|
45
45
|
lines.push('From here, build your own operating rhythm: set up recurring briefs, delegate complex tasks to crews, and let the system learn your patterns.');
|
|
46
46
|
return success({ onboarding: lines.join('\n'), status: 'complete', completed: completedIds.length, total: EXPERIENCES.length });
|
|
@@ -63,7 +63,7 @@ export function registerOnboardingTools(server, getClient) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
lines.push('');
|
|
66
|
-
lines.push('### All
|
|
66
|
+
lines.push('### All Eleven Experiences');
|
|
67
67
|
lines.push('');
|
|
68
68
|
for (const exp of EXPERIENCES) {
|
|
69
69
|
const done = completedSet.has(exp.id);
|
|
@@ -81,7 +81,7 @@ export function registerOnboardingTools(server, getClient) {
|
|
|
81
81
|
}
|
|
82
82
|
catch (e) {
|
|
83
83
|
if (e instanceof TacitApiError)
|
|
84
|
-
return error(e.message);
|
|
84
|
+
return featureDisabledResult(e) ?? error(e.message);
|
|
85
85
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
86
86
|
}
|
|
87
87
|
});
|