@tacitai/mcp-server 0.8.0 → 0.8.1
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 +3 -1
- package/dist/client.js +5 -3
- package/dist/tools/agents.d.ts +2 -0
- package/dist/tools/agents.js +15 -4
- package/dist/tools/capture.js +2 -2
- package/dist/tools/career.js +2 -2
- package/dist/tools/chronicle.js +7 -7
- package/dist/tools/crews.js +8 -8
- package/dist/tools/errors.d.ts +6 -0
- package/dist/tools/errors.js +17 -10
- package/dist/tools/github.js +2 -2
- package/dist/tools/gm.js +2 -2
- package/dist/tools/kb.js +2 -2
- package/dist/tools/lake-structure.js +8 -8
- package/dist/tools/lake.js +2 -2
- package/dist/tools/onboarding.js +2 -2
- package/dist/tools/people.js +7 -7
- package/dist/tools/pyramid.js +2 -2
- package/dist/tools/recall.js +2 -2
- package/dist/tools/synthesize.js +2 -2
- package/dist/tools/wiki.js +2 -2
- package/dist/tools/workspaces.js +13 -2
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -144,7 +144,9 @@ export declare class TacitApiError extends Error {
|
|
|
144
144
|
readonly workspace: string | null;
|
|
145
145
|
constructor(statusCode: number, body: string, endpoint: string,
|
|
146
146
|
/** Workspace name when the client knew it, for the <workspace> slot of api-errors.ts messages. */
|
|
147
|
-
workspace?: string | null
|
|
147
|
+
workspace?: string | null,
|
|
148
|
+
/** The api-errors.ts message for this status + code, when the table has one. */
|
|
149
|
+
message?: string);
|
|
148
150
|
}
|
|
149
151
|
/**
|
|
150
152
|
* Thrown when the API returns 401 — the credential has expired or been revoked.
|
package/dist/client.js
CHANGED
|
@@ -426,8 +426,10 @@ export class TacitApiError extends Error {
|
|
|
426
426
|
workspace;
|
|
427
427
|
constructor(statusCode, body, endpoint,
|
|
428
428
|
/** Workspace name when the client knew it, for the <workspace> slot of api-errors.ts messages. */
|
|
429
|
-
workspace = null
|
|
430
|
-
|
|
429
|
+
workspace = null,
|
|
430
|
+
/** The api-errors.ts message for this status + code, when the table has one. */
|
|
431
|
+
message) {
|
|
432
|
+
super(message ?? `Tacit API error ${statusCode} on ${endpoint}`);
|
|
431
433
|
this.statusCode = statusCode;
|
|
432
434
|
this.body = body;
|
|
433
435
|
this.endpoint = endpoint;
|
|
@@ -506,7 +508,7 @@ async function throwForStatus(res, endpoint, apiUrl, ctx = {}) {
|
|
|
506
508
|
const message = messageForResponse(401, code, ctx) ?? messageForResponse(401, null, ctx) ?? undefined;
|
|
507
509
|
throw new TokenExpiredError(`${apiUrl}/settings`, `npx @tacitai/mcp-server setup --api-url ${apiUrl}`, code, message, workspace);
|
|
508
510
|
}
|
|
509
|
-
throw new TacitApiError(res.status, text, endpoint, workspace);
|
|
511
|
+
throw new TacitApiError(res.status, text, endpoint, workspace, messageForResponse(res.status, code, ctx) ?? undefined);
|
|
510
512
|
}
|
|
511
513
|
const requestStore = new AsyncLocalStorage();
|
|
512
514
|
/** HTTPS mode: bind the caller's token/apiUrl/principal to everything run inside fn. */
|
package/dist/tools/agents.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface ToolRequest {
|
|
|
21
21
|
isError?: boolean;
|
|
22
22
|
}>;
|
|
23
23
|
}
|
|
24
|
+
/** True for the "agents table does not exist" failure: a 404, or a 5xx whose body says the table/relation is missing. */
|
|
25
|
+
export declare function isMissingAgentsTable(err: unknown): boolean;
|
|
24
26
|
export declare const agentListInputSchema: z.ZodObject<{
|
|
25
27
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
26
28
|
}, "strip", z.ZodTypeAny, {
|
package/dist/tools/agents.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { z } from 'zod';
|
|
13
13
|
import { getClient, TacitApiError, TokenExpiredError } from '../client.js';
|
|
14
|
-
import { featureDisabledResult } from './errors.js';
|
|
14
|
+
import { featureDisabledResult, apiErrorText } from './errors.js';
|
|
15
15
|
import { loadRoleTemplates } from '../templates/role-loader.js';
|
|
16
16
|
function apiErrorResult(err, toolName) {
|
|
17
17
|
if (err instanceof TokenExpiredError) {
|
|
@@ -24,11 +24,19 @@ function apiErrorResult(err, toolName) {
|
|
|
24
24
|
const disabled = featureDisabledResult(err);
|
|
25
25
|
if (disabled)
|
|
26
26
|
return disabled;
|
|
27
|
-
return { content: [{ type: 'text', text:
|
|
27
|
+
return { content: [{ type: 'text', text: apiErrorText(err, toolName) }], isError: true };
|
|
28
28
|
}
|
|
29
29
|
const msg = err instanceof Error ? err.message : String(err);
|
|
30
30
|
return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
|
|
31
31
|
}
|
|
32
|
+
/** True for the "agents table does not exist" failure: a 404, or a 5xx whose body says the table/relation is missing. */
|
|
33
|
+
export function isMissingAgentsTable(err) {
|
|
34
|
+
if (!(err instanceof TacitApiError))
|
|
35
|
+
return false;
|
|
36
|
+
if (err.statusCode === 404)
|
|
37
|
+
return true;
|
|
38
|
+
return err.statusCode >= 500 && /business_agents|relation .* does not exist|table .* (does not exist|missing)/i.test(err.body);
|
|
39
|
+
}
|
|
32
40
|
async function callAgentTool(client, name, args) {
|
|
33
41
|
return client.post('/api/v1/agents/mcp/tools/call', { name, arguments: args });
|
|
34
42
|
}
|
|
@@ -65,8 +73,11 @@ export function buildAgentListRequest(client, input) {
|
|
|
65
73
|
if (Array.isArray(list))
|
|
66
74
|
instances = list;
|
|
67
75
|
}
|
|
68
|
-
catch {
|
|
69
|
-
//
|
|
76
|
+
catch (e) {
|
|
77
|
+
// Only a missing business_agents table (migration 349 RESERVED) falls back to templates.
|
|
78
|
+
// Membership and auth errors (401/403, removed member) must reach the caller.
|
|
79
|
+
if (!isMissingAgentsTable(e))
|
|
80
|
+
throw e;
|
|
70
81
|
}
|
|
71
82
|
const merged = templates.map((t) => {
|
|
72
83
|
const inst = instances.find((i) => i['role_slug'] === t.slug);
|
package/dist/tools/capture.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { z } from 'zod';
|
|
13
13
|
import { TacitApiError, TokenExpiredError } from '../client.js';
|
|
14
|
-
import { featureDisabledResult } from './errors.js';
|
|
14
|
+
import { apiErrorText, featureDisabledResult } from './errors.js';
|
|
15
15
|
function apiErrorResult(err, toolName) {
|
|
16
16
|
if (err instanceof TokenExpiredError) {
|
|
17
17
|
return { content: [{ type: 'text', text: err.message }], isError: true };
|
|
@@ -20,7 +20,7 @@ function apiErrorResult(err, toolName) {
|
|
|
20
20
|
const disabled = featureDisabledResult(err);
|
|
21
21
|
if (disabled)
|
|
22
22
|
return disabled;
|
|
23
|
-
return { content: [{ type: 'text', text:
|
|
23
|
+
return { content: [{ type: 'text', text: apiErrorText(err, toolName) }], isError: true };
|
|
24
24
|
}
|
|
25
25
|
const msg = err instanceof Error ? err.message : String(err);
|
|
26
26
|
return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
|
package/dist/tools/career.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { z } from 'zod';
|
|
19
19
|
import dns from 'node:dns/promises';
|
|
20
20
|
import { TacitApiError, TokenExpiredError } from '../client.js';
|
|
21
|
-
import { featureDisabledResult } from './errors.js';
|
|
21
|
+
import { apiErrorText, featureDisabledResult } from './errors.js';
|
|
22
22
|
function flagGuard() {
|
|
23
23
|
if (process.env['FEATURE_CAREER_EXEC'] === 'true')
|
|
24
24
|
return null;
|
|
@@ -38,7 +38,7 @@ function apiErrorResult(err, toolName) {
|
|
|
38
38
|
const disabled = featureDisabledResult(err);
|
|
39
39
|
if (disabled)
|
|
40
40
|
return disabled;
|
|
41
|
-
return { content: [{ type: 'text', text:
|
|
41
|
+
return { content: [{ type: 'text', text: apiErrorText(err, toolName) }], isError: true };
|
|
42
42
|
}
|
|
43
43
|
const msg = err instanceof Error ? err.message : String(err);
|
|
44
44
|
return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
|
package/dist/tools/chronicle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { TacitApiError } from '../client.js';
|
|
2
|
+
import { TacitApiError, TokenExpiredError } from '../client.js';
|
|
3
3
|
import { success, error, featureDisabledResult } from './errors.js';
|
|
4
4
|
export function registerChronicleTools(server, getClient) {
|
|
5
5
|
server.tool('tacit_chronicle_timeline', 'Query the Chronicle timeline with date range, scope, and text filters.', {
|
|
@@ -39,7 +39,7 @@ export function registerChronicleTools(server, getClient) {
|
|
|
39
39
|
return success(data);
|
|
40
40
|
}
|
|
41
41
|
catch (e) {
|
|
42
|
-
if (e instanceof TacitApiError)
|
|
42
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
43
43
|
return featureDisabledResult(e) ?? error(e.message);
|
|
44
44
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
45
45
|
}
|
|
@@ -72,7 +72,7 @@ export function registerChronicleTools(server, getClient) {
|
|
|
72
72
|
return success(data);
|
|
73
73
|
}
|
|
74
74
|
catch (e) {
|
|
75
|
-
if (e instanceof TacitApiError)
|
|
75
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
76
76
|
return featureDisabledResult(e) ?? error(e.message);
|
|
77
77
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
78
78
|
}
|
|
@@ -98,7 +98,7 @@ export function registerChronicleTools(server, getClient) {
|
|
|
98
98
|
return success(data);
|
|
99
99
|
}
|
|
100
100
|
catch (e) {
|
|
101
|
-
if (e instanceof TacitApiError)
|
|
101
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
102
102
|
return featureDisabledResult(e) ?? error(e.message);
|
|
103
103
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
104
104
|
}
|
|
@@ -120,7 +120,7 @@ export function registerChronicleTools(server, getClient) {
|
|
|
120
120
|
return success(data);
|
|
121
121
|
}
|
|
122
122
|
catch (e) {
|
|
123
|
-
if (e instanceof TacitApiError)
|
|
123
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
124
124
|
return featureDisabledResult(e) ?? error(e.message);
|
|
125
125
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
126
126
|
}
|
|
@@ -143,7 +143,7 @@ export function registerChronicleTools(server, getClient) {
|
|
|
143
143
|
return success(data);
|
|
144
144
|
}
|
|
145
145
|
catch (e) {
|
|
146
|
-
if (e instanceof TacitApiError)
|
|
146
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
147
147
|
return featureDisabledResult(e) ?? error(e.message);
|
|
148
148
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
149
149
|
}
|
|
@@ -157,7 +157,7 @@ export function registerChronicleTools(server, getClient) {
|
|
|
157
157
|
return success(data);
|
|
158
158
|
}
|
|
159
159
|
catch (e) {
|
|
160
|
-
if (e instanceof TacitApiError)
|
|
160
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
161
161
|
return featureDisabledResult(e) ?? error(e.message);
|
|
162
162
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
163
163
|
}
|
package/dist/tools/crews.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { TacitApiError } from '../client.js';
|
|
2
|
+
import { TacitApiError, TokenExpiredError } from '../client.js';
|
|
3
3
|
import { success, error, featureDisabledResult } from './errors.js';
|
|
4
4
|
export function registerCrewTools(server, getClient) {
|
|
5
5
|
server.tool('tacit_dispatch_crew', 'Dispatch a crew for autonomous task execution.', {
|
|
@@ -11,7 +11,7 @@ export function registerCrewTools(server, getClient) {
|
|
|
11
11
|
return success(data);
|
|
12
12
|
}
|
|
13
13
|
catch (e) {
|
|
14
|
-
if (e instanceof TacitApiError)
|
|
14
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
15
15
|
return featureDisabledResult(e) ?? error(e.message);
|
|
16
16
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
17
17
|
}
|
|
@@ -25,7 +25,7 @@ export function registerCrewTools(server, getClient) {
|
|
|
25
25
|
return success(data);
|
|
26
26
|
}
|
|
27
27
|
catch (e) {
|
|
28
|
-
if (e instanceof TacitApiError)
|
|
28
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
29
29
|
return featureDisabledResult(e) ?? error(e.message);
|
|
30
30
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
31
31
|
}
|
|
@@ -40,7 +40,7 @@ export function registerCrewTools(server, getClient) {
|
|
|
40
40
|
return success(data);
|
|
41
41
|
}
|
|
42
42
|
catch (e) {
|
|
43
|
-
if (e instanceof TacitApiError)
|
|
43
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
44
44
|
return featureDisabledResult(e) ?? error(e.message);
|
|
45
45
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
46
46
|
}
|
|
@@ -58,7 +58,7 @@ export function registerCrewTools(server, getClient) {
|
|
|
58
58
|
return success(data);
|
|
59
59
|
}
|
|
60
60
|
catch (e) {
|
|
61
|
-
if (e instanceof TacitApiError)
|
|
61
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
62
62
|
return featureDisabledResult(e) ?? error(e.message);
|
|
63
63
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
64
64
|
}
|
|
@@ -76,7 +76,7 @@ export function registerCrewTools(server, getClient) {
|
|
|
76
76
|
return success(data);
|
|
77
77
|
}
|
|
78
78
|
catch (e) {
|
|
79
|
-
if (e instanceof TacitApiError)
|
|
79
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
80
80
|
return featureDisabledResult(e) ?? error(e.message);
|
|
81
81
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
82
82
|
}
|
|
@@ -90,7 +90,7 @@ export function registerCrewTools(server, getClient) {
|
|
|
90
90
|
return success(data);
|
|
91
91
|
}
|
|
92
92
|
catch (e) {
|
|
93
|
-
if (e instanceof TacitApiError)
|
|
93
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
94
94
|
return featureDisabledResult(e) ?? error(e.message);
|
|
95
95
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
96
96
|
}
|
|
@@ -107,7 +107,7 @@ export function registerCrewTools(server, getClient) {
|
|
|
107
107
|
return success(data);
|
|
108
108
|
}
|
|
109
109
|
catch (e) {
|
|
110
|
-
if (e instanceof TacitApiError)
|
|
110
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
111
111
|
return featureDisabledResult(e) ?? error(e.message);
|
|
112
112
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
113
113
|
}
|
package/dist/tools/errors.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TacitApiError } from '../client.js';
|
|
1
2
|
type ToolResult = {
|
|
2
3
|
content: Array<{
|
|
3
4
|
type: 'text';
|
|
@@ -24,6 +25,11 @@ export declare function errorCodeOfBody(body: string): string | null;
|
|
|
24
25
|
* removal code; a 401 MEMBERSHIP_NOT_FOUND reaches tools as TokenExpiredError with the same code.
|
|
25
26
|
*/
|
|
26
27
|
export declare function accessRemovedFrom(err: unknown): AccessRemovedError | null;
|
|
28
|
+
/**
|
|
29
|
+
* Text for a failed API call: the access-removed / api-errors.ts message when the table has one,
|
|
30
|
+
* otherwise "API error <status> [on <endpoint>]: <body>". Shared by every tool's error handler.
|
|
31
|
+
*/
|
|
32
|
+
export declare function apiErrorText(err: TacitApiError, endpoint?: string): string;
|
|
27
33
|
export declare function apiErrorResult(err: unknown, endpoint: string): ToolResult & {
|
|
28
34
|
isError: boolean;
|
|
29
35
|
};
|
package/dist/tools/errors.js
CHANGED
|
@@ -79,6 +79,22 @@ export function accessRemovedFrom(err) {
|
|
|
79
79
|
}
|
|
80
80
|
return null;
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Text for a failed API call: the access-removed / api-errors.ts message when the table has one,
|
|
84
|
+
* otherwise "API error <status> [on <endpoint>]: <body>". Shared by every tool's error handler.
|
|
85
|
+
*/
|
|
86
|
+
export function apiErrorText(err, endpoint) {
|
|
87
|
+
const removed = accessRemovedFrom(err);
|
|
88
|
+
if (removed)
|
|
89
|
+
return removed.message;
|
|
90
|
+
const mapped = messageForResponse(err.statusCode, errorCodeOfBody(err.body), {
|
|
91
|
+
workspace: err.workspace,
|
|
92
|
+
reason: reasonOfBody(err.body),
|
|
93
|
+
});
|
|
94
|
+
if (mapped)
|
|
95
|
+
return mapped;
|
|
96
|
+
return `API error ${err.statusCode}${endpoint ? ` on ${endpoint}` : ''}: ${err.body}`;
|
|
97
|
+
}
|
|
82
98
|
export function apiErrorResult(err, endpoint) {
|
|
83
99
|
if (err instanceof TokenExpiredError) {
|
|
84
100
|
return {
|
|
@@ -90,16 +106,7 @@ export function apiErrorResult(err, endpoint) {
|
|
|
90
106
|
const disabled = featureDisabledResult(err);
|
|
91
107
|
if (disabled)
|
|
92
108
|
return disabled;
|
|
93
|
-
|
|
94
|
-
if (removed)
|
|
95
|
-
return { content: [{ type: 'text', text: removed.message }], isError: true };
|
|
96
|
-
const mapped = messageForResponse(err.statusCode, errorCodeOfBody(err.body), {
|
|
97
|
-
workspace: err.workspace,
|
|
98
|
-
reason: reasonOfBody(err.body),
|
|
99
|
-
});
|
|
100
|
-
if (mapped)
|
|
101
|
-
return { content: [{ type: 'text', text: mapped }], isError: true };
|
|
102
|
-
return { content: [{ type: 'text', text: `API error ${err.statusCode} on ${endpoint}: ${err.body}` }], isError: true };
|
|
109
|
+
return { content: [{ type: 'text', text: apiErrorText(err, endpoint) }], isError: true };
|
|
103
110
|
}
|
|
104
111
|
const msg = err instanceof Error ? err.message : String(err);
|
|
105
112
|
return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
|
package/dist/tools/github.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { z } from 'zod';
|
|
11
11
|
import { TacitApiError, TokenExpiredError } from '../client.js';
|
|
12
|
-
import { featureDisabledResult } from './errors.js';
|
|
12
|
+
import { apiErrorText, featureDisabledResult } from './errors.js';
|
|
13
13
|
function apiErrorResult(err, toolName) {
|
|
14
14
|
if (err instanceof TokenExpiredError) {
|
|
15
15
|
return { content: [{ type: 'text', text: err.message }], isError: true };
|
|
@@ -18,7 +18,7 @@ function apiErrorResult(err, toolName) {
|
|
|
18
18
|
const disabled = featureDisabledResult(err);
|
|
19
19
|
if (disabled)
|
|
20
20
|
return disabled;
|
|
21
|
-
return { content: [{ type: 'text', text:
|
|
21
|
+
return { content: [{ type: 'text', text: apiErrorText(err, toolName) }], isError: true };
|
|
22
22
|
}
|
|
23
23
|
const msg = err instanceof Error ? err.message : String(err);
|
|
24
24
|
return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
|
package/dist/tools/gm.js
CHANGED
|
@@ -10,7 +10,7 @@ import * as fs from 'fs';
|
|
|
10
10
|
import * as path from 'path';
|
|
11
11
|
import { z } from 'zod';
|
|
12
12
|
import { TacitClient, TacitApiError, TokenExpiredError, getRequestPrincipal } from '../client.js';
|
|
13
|
-
import { featureDisabledResult } from './errors.js';
|
|
13
|
+
import { apiErrorText, featureDisabledResult } from './errors.js';
|
|
14
14
|
import { GM_APPROVE_NEXT_STEP } from '../workflow-gate.js';
|
|
15
15
|
function apiErrorResult(err, toolName) {
|
|
16
16
|
if (err instanceof TokenExpiredError) {
|
|
@@ -23,7 +23,7 @@ function apiErrorResult(err, toolName) {
|
|
|
23
23
|
const disabled = featureDisabledResult(err);
|
|
24
24
|
if (disabled)
|
|
25
25
|
return disabled;
|
|
26
|
-
return { content: [{ type: 'text', text:
|
|
26
|
+
return { content: [{ type: 'text', text: apiErrorText(err, toolName) }], isError: true };
|
|
27
27
|
}
|
|
28
28
|
const msg = err instanceof Error ? err.message : String(err);
|
|
29
29
|
return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
|
package/dist/tools/kb.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { z } from 'zod';
|
|
15
15
|
import { getClient, getRequestPrincipal, TacitApiError, TokenExpiredError } from '../client.js';
|
|
16
|
-
import { apiErrorResult as sharedApiErrorResult, featureDisabledResult } from './errors.js';
|
|
16
|
+
import { apiErrorResult as sharedApiErrorResult, featureDisabledResult, apiErrorText } from './errors.js';
|
|
17
17
|
import { GM_LIST_TOOL_NEXT_STEP } from '../workflow-gate.js';
|
|
18
18
|
function apiErrorResult(err, toolName) {
|
|
19
19
|
if (err instanceof TokenExpiredError) {
|
|
@@ -26,7 +26,7 @@ function apiErrorResult(err, toolName) {
|
|
|
26
26
|
const disabled = featureDisabledResult(err);
|
|
27
27
|
if (disabled)
|
|
28
28
|
return disabled;
|
|
29
|
-
return { content: [{ type: 'text', text:
|
|
29
|
+
return { content: [{ type: 'text', text: apiErrorText(err, toolName) }], isError: true };
|
|
30
30
|
}
|
|
31
31
|
const msg = err instanceof Error ? err.message : String(err);
|
|
32
32
|
return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { TacitApiError } from '../client.js';
|
|
2
|
+
import { TacitApiError, TokenExpiredError } from '../client.js';
|
|
3
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.', {
|
|
@@ -11,7 +11,7 @@ export function registerLakeStructureTools(server, getClient) {
|
|
|
11
11
|
return success(data);
|
|
12
12
|
}
|
|
13
13
|
catch (e) {
|
|
14
|
-
if (e instanceof TacitApiError)
|
|
14
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
15
15
|
return featureDisabledResult(e) ?? error(e.message);
|
|
16
16
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
17
17
|
}
|
|
@@ -33,7 +33,7 @@ export function registerLakeStructureTools(server, getClient) {
|
|
|
33
33
|
return success(data);
|
|
34
34
|
}
|
|
35
35
|
catch (e) {
|
|
36
|
-
if (e instanceof TacitApiError)
|
|
36
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
37
37
|
return featureDisabledResult(e) ?? error(e.message);
|
|
38
38
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
39
39
|
}
|
|
@@ -47,7 +47,7 @@ export function registerLakeStructureTools(server, getClient) {
|
|
|
47
47
|
return success(data);
|
|
48
48
|
}
|
|
49
49
|
catch (e) {
|
|
50
|
-
if (e instanceof TacitApiError)
|
|
50
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
51
51
|
return featureDisabledResult(e) ?? error(e.message);
|
|
52
52
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
53
53
|
}
|
|
@@ -70,7 +70,7 @@ export function registerLakeStructureTools(server, getClient) {
|
|
|
70
70
|
return success(data);
|
|
71
71
|
}
|
|
72
72
|
catch (e) {
|
|
73
|
-
if (e instanceof TacitApiError)
|
|
73
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
74
74
|
return featureDisabledResult(e) ?? error(e.message);
|
|
75
75
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
76
76
|
}
|
|
@@ -86,7 +86,7 @@ export function registerLakeStructureTools(server, getClient) {
|
|
|
86
86
|
return success(data);
|
|
87
87
|
}
|
|
88
88
|
catch (e) {
|
|
89
|
-
if (e instanceof TacitApiError)
|
|
89
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
90
90
|
return featureDisabledResult(e) ?? error(e.message);
|
|
91
91
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
92
92
|
}
|
|
@@ -102,7 +102,7 @@ export function registerLakeStructureTools(server, getClient) {
|
|
|
102
102
|
return success(data);
|
|
103
103
|
}
|
|
104
104
|
catch (e) {
|
|
105
|
-
if (e instanceof TacitApiError)
|
|
105
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
106
106
|
return featureDisabledResult(e) ?? error(e.message);
|
|
107
107
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
108
108
|
}
|
|
@@ -118,7 +118,7 @@ export function registerLakeStructureTools(server, getClient) {
|
|
|
118
118
|
return success(data);
|
|
119
119
|
}
|
|
120
120
|
catch (e) {
|
|
121
|
-
if (e instanceof TacitApiError)
|
|
121
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
122
122
|
return featureDisabledResult(e) ?? error(e.message);
|
|
123
123
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
124
124
|
}
|
package/dist/tools/lake.js
CHANGED
|
@@ -26,7 +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
|
+
import { featureDisabledResult, apiErrorText } from './errors.js';
|
|
30
30
|
function apiErrorResult(err, toolName) {
|
|
31
31
|
if (err instanceof TokenExpiredError) {
|
|
32
32
|
return {
|
|
@@ -38,7 +38,7 @@ function apiErrorResult(err, toolName) {
|
|
|
38
38
|
const disabled = featureDisabledResult(err);
|
|
39
39
|
if (disabled)
|
|
40
40
|
return disabled;
|
|
41
|
-
return { content: [{ type: 'text', text:
|
|
41
|
+
return { content: [{ type: 'text', text: apiErrorText(err, toolName) }], isError: true };
|
|
42
42
|
}
|
|
43
43
|
const msg = err instanceof Error ? err.message : String(err);
|
|
44
44
|
return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
|
package/dist/tools/onboarding.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { TacitApiError } from '../client.js';
|
|
2
|
+
import { TacitApiError, TokenExpiredError } from '../client.js';
|
|
3
3
|
import { success, error, featureDisabledResult } from './errors.js';
|
|
4
4
|
import { EXPERIENCES, fetchWorkspaceState, normalizeCompleted } from '../prompts.js';
|
|
5
5
|
export function registerOnboardingTools(server, getClient) {
|
|
@@ -104,7 +104,7 @@ export function registerOnboardingTools(server, getClient) {
|
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
106
|
catch (e) {
|
|
107
|
-
if (e instanceof TacitApiError)
|
|
107
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
108
108
|
return featureDisabledResult(e) ?? error(e.message);
|
|
109
109
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
110
110
|
}
|
package/dist/tools/people.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { TacitApiError } from '../client.js';
|
|
2
|
+
import { TacitApiError, TokenExpiredError } from '../client.js';
|
|
3
3
|
import { success, error, featureDisabledResult } from './errors.js';
|
|
4
4
|
export function registerPeopleTools(server, getClient) {
|
|
5
5
|
server.tool('tacit_list_people', 'List all people in the current workspace.', {}, async () => {
|
|
@@ -9,7 +9,7 @@ export function registerPeopleTools(server, getClient) {
|
|
|
9
9
|
return success(data);
|
|
10
10
|
}
|
|
11
11
|
catch (e) {
|
|
12
|
-
if (e instanceof TacitApiError)
|
|
12
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
13
13
|
return featureDisabledResult(e) ?? error(e.message);
|
|
14
14
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
15
15
|
}
|
|
@@ -23,7 +23,7 @@ export function registerPeopleTools(server, getClient) {
|
|
|
23
23
|
return success(data);
|
|
24
24
|
}
|
|
25
25
|
catch (e) {
|
|
26
|
-
if (e instanceof TacitApiError)
|
|
26
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
27
27
|
return featureDisabledResult(e) ?? error(e.message);
|
|
28
28
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
29
29
|
}
|
|
@@ -39,7 +39,7 @@ export function registerPeopleTools(server, getClient) {
|
|
|
39
39
|
return success(data);
|
|
40
40
|
}
|
|
41
41
|
catch (e) {
|
|
42
|
-
if (e instanceof TacitApiError)
|
|
42
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
43
43
|
return featureDisabledResult(e) ?? error(e.message);
|
|
44
44
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
45
45
|
}
|
|
@@ -61,7 +61,7 @@ export function registerPeopleTools(server, getClient) {
|
|
|
61
61
|
return success(data);
|
|
62
62
|
}
|
|
63
63
|
catch (e) {
|
|
64
|
-
if (e instanceof TacitApiError)
|
|
64
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
65
65
|
return featureDisabledResult(e) ?? error(e.message);
|
|
66
66
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
67
67
|
}
|
|
@@ -80,7 +80,7 @@ export function registerPeopleTools(server, getClient) {
|
|
|
80
80
|
return success(data);
|
|
81
81
|
}
|
|
82
82
|
catch (e) {
|
|
83
|
-
if (e instanceof TacitApiError)
|
|
83
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
84
84
|
return featureDisabledResult(e) ?? error(e.message);
|
|
85
85
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
86
86
|
}
|
|
@@ -92,7 +92,7 @@ export function registerPeopleTools(server, getClient) {
|
|
|
92
92
|
return success(data);
|
|
93
93
|
}
|
|
94
94
|
catch (e) {
|
|
95
|
-
if (e instanceof TacitApiError)
|
|
95
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError)
|
|
96
96
|
return featureDisabledResult(e) ?? error(e.message);
|
|
97
97
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
98
98
|
}
|
package/dist/tools/pyramid.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { z } from 'zod';
|
|
13
13
|
import { getClient, getRequestPrincipal, TacitApiError, TokenExpiredError } from '../client.js';
|
|
14
|
-
import { apiErrorResult as sharedApiErrorResult, featureDisabledResult } from './errors.js';
|
|
14
|
+
import { apiErrorResult as sharedApiErrorResult, featureDisabledResult, apiErrorText } from './errors.js';
|
|
15
15
|
import { GM_LIST_TOOL_NEXT_STEP } from '../workflow-gate.js';
|
|
16
16
|
function apiErrorResult(err, toolName) {
|
|
17
17
|
if (err instanceof TokenExpiredError) {
|
|
@@ -24,7 +24,7 @@ function apiErrorResult(err, toolName) {
|
|
|
24
24
|
const disabled = featureDisabledResult(err);
|
|
25
25
|
if (disabled)
|
|
26
26
|
return disabled;
|
|
27
|
-
return { content: [{ type: 'text', text:
|
|
27
|
+
return { content: [{ type: 'text', text: apiErrorText(err, toolName) }], isError: true };
|
|
28
28
|
}
|
|
29
29
|
const msg = err instanceof Error ? err.message : String(err);
|
|
30
30
|
return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
|
package/dist/tools/recall.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { getClient, TacitApiError, TokenExpiredError } from '../client.js';
|
|
7
|
-
import { featureDisabledResult } from './errors.js';
|
|
7
|
+
import { apiErrorText, featureDisabledResult } from './errors.js';
|
|
8
8
|
export const recallInputSchema = z.object({
|
|
9
9
|
query: z.string().min(1).describe('Recall query'),
|
|
10
10
|
portfolio_id: z.string().min(1).describe('Portfolio UUID to scope the recall'),
|
|
@@ -50,7 +50,7 @@ export function buildRecallRequest(client, input) {
|
|
|
50
50
|
const disabled = featureDisabledResult(err);
|
|
51
51
|
if (disabled)
|
|
52
52
|
return disabled;
|
|
53
|
-
return { content: [{ type: 'text', text:
|
|
53
|
+
return { content: [{ type: 'text', text: apiErrorText(err) }], isError: true };
|
|
54
54
|
}
|
|
55
55
|
const msg = err instanceof Error ? err.message : String(err);
|
|
56
56
|
return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
|
package/dist/tools/synthesize.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { z } from 'zod';
|
|
16
16
|
import { getClient, TacitApiError, TokenExpiredError } from '../client.js';
|
|
17
|
-
import { featureDisabledResult } from './errors.js';
|
|
17
|
+
import { apiErrorText, featureDisabledResult } from './errors.js';
|
|
18
18
|
export const synthesizeInputSchema = z.object({
|
|
19
19
|
query: z.string().min(1).describe('Question or synthesis prompt'),
|
|
20
20
|
stream: z.boolean().optional().describe('If true, use SSE stream variant (/mind/synthesize/stream)'),
|
|
@@ -279,7 +279,7 @@ export function buildSynthesizeRequest(client, input) {
|
|
|
279
279
|
const disabled = featureDisabledResult(err);
|
|
280
280
|
if (disabled)
|
|
281
281
|
return disabled;
|
|
282
|
-
return { content: [{ type: 'text', text:
|
|
282
|
+
return { content: [{ type: 'text', text: apiErrorText(err) }], isError: true };
|
|
283
283
|
}
|
|
284
284
|
const msg = err instanceof Error ? err.message : String(err);
|
|
285
285
|
return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
|
package/dist/tools/wiki.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { z } from 'zod';
|
|
12
12
|
import { TacitApiError, TokenExpiredError } from '../client.js';
|
|
13
|
-
import { featureDisabledResult } from './errors.js';
|
|
13
|
+
import { apiErrorText, featureDisabledResult } from './errors.js';
|
|
14
14
|
function apiErrorResult(err, toolName) {
|
|
15
15
|
if (err instanceof TokenExpiredError) {
|
|
16
16
|
return { content: [{ type: 'text', text: err.message }], isError: true };
|
|
@@ -19,7 +19,7 @@ function apiErrorResult(err, toolName) {
|
|
|
19
19
|
const disabled = featureDisabledResult(err);
|
|
20
20
|
if (disabled)
|
|
21
21
|
return disabled;
|
|
22
|
-
return { content: [{ type: 'text', text:
|
|
22
|
+
return { content: [{ type: 'text', text: apiErrorText(err, toolName) }], isError: true };
|
|
23
23
|
}
|
|
24
24
|
const msg = err instanceof Error ? err.message : String(err);
|
|
25
25
|
return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
|
package/dist/tools/workspaces.js
CHANGED
|
@@ -9,8 +9,9 @@ export function registerWorkspaceTools(server, getClient) {
|
|
|
9
9
|
return success(data);
|
|
10
10
|
}
|
|
11
11
|
catch (e) {
|
|
12
|
-
if (e instanceof TacitApiError)
|
|
13
|
-
return featureDisabledResult(e) ??
|
|
12
|
+
if (e instanceof TacitApiError || e instanceof TokenExpiredError) {
|
|
13
|
+
return featureDisabledResult(e) ?? apiErrorResult(e, '/api/v1/workspaces/mine');
|
|
14
|
+
}
|
|
14
15
|
return error(`Unexpected error: ${e instanceof Error ? e.message : String(e)}`);
|
|
15
16
|
}
|
|
16
17
|
});
|
|
@@ -38,6 +39,16 @@ export function registerWorkspaceTools(server, getClient) {
|
|
|
38
39
|
server.tool('tacit_current_workspace', 'Get the currently active workspace ID and name.', {}, async () => {
|
|
39
40
|
try {
|
|
40
41
|
const client = await getClient();
|
|
42
|
+
// One whoami call confirms the login still works (a removed member must not get a cached answer).
|
|
43
|
+
try {
|
|
44
|
+
await client.whoami();
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
if (e instanceof TokenExpiredError || (e instanceof TacitApiError && (e.statusCode === 401 || e.statusCode === 403))) {
|
|
48
|
+
return apiErrorResult(e, '/api/v1/auth/whoami');
|
|
49
|
+
}
|
|
50
|
+
// Old server (404/405), network trouble or 5xx: answer from local state.
|
|
51
|
+
}
|
|
41
52
|
return success({
|
|
42
53
|
workspace_id: client.workspaceId,
|
|
43
54
|
name: client.workspaceName,
|