@tacitai/mcp-server 0.7.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.
Files changed (73) hide show
  1. package/dist/api-errors.d.ts +102 -0
  2. package/dist/api-errors.js +165 -0
  3. package/dist/autonomy.d.ts +46 -0
  4. package/dist/autonomy.js +118 -0
  5. package/dist/claude-config.d.ts +139 -0
  6. package/dist/claude-config.js +339 -0
  7. package/dist/cli-launch.d.ts +33 -0
  8. package/dist/cli-launch.js +178 -0
  9. package/dist/cli-login.d.ts +34 -0
  10. package/dist/cli-login.js +200 -0
  11. package/dist/cli-mode.d.ts +47 -0
  12. package/dist/cli-mode.js +170 -0
  13. package/dist/cli-profiles.d.ts +37 -0
  14. package/dist/cli-profiles.js +344 -0
  15. package/dist/cli.d.ts +9 -0
  16. package/dist/cli.js +59 -458
  17. package/dist/client.d.ts +90 -52
  18. package/dist/client.js +198 -296
  19. package/dist/credentials.d.ts +81 -0
  20. package/dist/credentials.js +291 -0
  21. package/dist/index.d.ts +3 -3
  22. package/dist/index.js +37 -89
  23. package/dist/oauth.d.ts +1 -1
  24. package/dist/oauth.js +5 -5
  25. package/dist/profile-store.d.ts +96 -0
  26. package/dist/profile-store.js +382 -0
  27. package/dist/prompt.d.ts +32 -0
  28. package/dist/prompt.js +99 -0
  29. package/dist/prompts.d.ts +2 -2
  30. package/dist/prompts.js +3 -3
  31. package/dist/server-mode.d.ts +65 -0
  32. package/dist/server-mode.js +99 -0
  33. package/dist/setup-migrate.d.ts +35 -0
  34. package/dist/setup-migrate.js +204 -0
  35. package/dist/setup.d.ts +41 -66
  36. package/dist/setup.js +361 -531
  37. package/dist/signin.d.ts +108 -0
  38. package/dist/signin.js +595 -0
  39. package/dist/tools/agents.d.ts +6 -4
  40. package/dist/tools/agents.js +15 -4
  41. package/dist/tools/artifacts.d.ts +2 -0
  42. package/dist/tools/artifacts.js +8 -1
  43. package/dist/tools/capture.js +2 -2
  44. package/dist/tools/career.js +2 -2
  45. package/dist/tools/chronicle.js +7 -7
  46. package/dist/tools/crews.js +8 -8
  47. package/dist/tools/errors.d.ts +18 -0
  48. package/dist/tools/errors.js +73 -1
  49. package/dist/tools/exec-route.d.ts +34 -0
  50. package/dist/tools/exec-route.js +101 -27
  51. package/dist/tools/github.js +2 -2
  52. package/dist/tools/gm.js +2 -2
  53. package/dist/tools/iam.js +2 -3
  54. package/dist/tools/kb.js +2 -2
  55. package/dist/tools/lake-structure.js +8 -8
  56. package/dist/tools/lake.js +2 -2
  57. package/dist/tools/onboarding.js +2 -2
  58. package/dist/tools/people.js +7 -7
  59. package/dist/tools/pyramid.js +2 -2
  60. package/dist/tools/recall.js +2 -2
  61. package/dist/tools/secretary.d.ts +1 -0
  62. package/dist/tools/secretary.js +2 -1
  63. package/dist/tools/synthesize.d.ts +37 -0
  64. package/dist/tools/synthesize.js +128 -9
  65. package/dist/tools/voice.d.ts +3 -2
  66. package/dist/tools/voice.js +70 -18
  67. package/dist/tools/wiki.js +2 -2
  68. package/dist/tools/workspaces.js +20 -6
  69. package/dist/version.d.ts +6 -0
  70. package/dist/version.js +18 -0
  71. package/dist/workflow-registry.d.ts +1 -0
  72. package/dist/workflow-registry.js +21 -0
  73. package/package.json +4 -1
package/dist/client.d.ts CHANGED
@@ -1,17 +1,43 @@
1
1
  /**
2
- * TacitClient — REST/SSE client over TACIT_API_URL.
2
+ * TacitClient — REST/SSE client over an API URL it is GIVEN.
3
3
  *
4
4
  * Security invariants (enforced here and NEVER relaxed):
5
- * - TACIT_TOKEN is NEVER written to any output stream (stdout, stderr, logs).
5
+ * - The token is NEVER written to any output stream (stdout, stderr, logs).
6
6
  * - The Authorization header value is NEVER logged at any level.
7
7
  * - No anthropic/openai SDK import.
8
- * - Token sourced from process.env.TACIT_TOKEN or v2 profile files (~/.tacit/profiles/).
8
+ * - This module reads no credential from the environment. Credentials arrive as
9
+ * constructor options from credentials.ts (levels 0/1/2/4/5), the only
10
+ * module that reads them (MV-1542c step 1.4).
9
11
  */
12
+ export { type AutonomyLevel, parseAutonomyLevel, autonomyAtLeast, getCachedAutonomy, ensureAutonomy, } from './autonomy.js';
13
+ /** GET /api/v1/auth/whoami (every authenticated credential kind). */
14
+ export interface WhoAmI {
15
+ credential_type: 'jwt' | 'iam_token' | 'dev_token' | 'api_key' | 'hmac_session';
16
+ workspace_id: string;
17
+ workspace_name: string;
18
+ user_id?: string | null;
19
+ person_id?: string | null;
20
+ identity_email?: string | null;
21
+ is_owner: boolean;
22
+ autonomy_level?: string | null;
23
+ expires_at?: string | null;
24
+ token_id?: string | null;
25
+ device_label?: string | null;
26
+ used_owner_fallback?: boolean;
27
+ cli_login_ttl_days?: number;
28
+ }
10
29
  export interface TacitClientOptions {
11
30
  apiUrl?: string;
12
31
  appUrl?: string;
13
32
  token?: string;
33
+ /** HMAC X-Tacit-Session credential (eval/oracle harness); wins over `token` when set. */
34
+ sessionToken?: string;
14
35
  workspaceId?: string;
36
+ workspaceName?: string;
37
+ /** Where the credential came from, for the 401 message (profile or environment). Default: profile. */
38
+ credentialSource?: 'profile' | 'env';
39
+ /** Name of the environment variable that held an env credential (for the 401 message). */
40
+ envVar?: string;
15
41
  /** Override the root directory used to locate .tacit/sync.json (default: process.cwd()). */
16
42
  rootDir?: string;
17
43
  }
@@ -19,37 +45,56 @@ export declare class TacitClient {
19
45
  private readonly apiUrl;
20
46
  private readonly _appUrl;
21
47
  private token;
48
+ private readonly sessionToken;
22
49
  private readonly _fetch;
23
50
  private readonly _rootDir;
24
51
  private _workspaceId;
25
52
  private _workspaceName;
53
+ private readonly _credentialSource;
54
+ private readonly _envVar;
26
55
  private _initialized;
27
56
  /**
28
- * @param fetchOrOpts - Optional: a custom fetch implementation (for testing),
29
- * or a TacitClientOptions object. If a function is provided it overrides
30
- * global fetch. Configuration falls back to environment variables.
31
- * @param opts - Additional options (apiUrl, token, workspaceId, rootDir).
32
- * Only used when fetchOrOpts is a fetch function.
57
+ * @param fetchOrOpts - A custom fetch implementation (for testing) or a
58
+ * TacitClientOptions object.
59
+ * @param opts - Options when the first argument is a fetch function.
33
60
  */
34
61
  constructor(fetchOrOpts?: typeof globalThis.fetch | TacitClientOptions, opts?: TacitClientOptions);
62
+ /** Values that fill the `<workspace>` / credential slots of api-errors.ts messages. */
63
+ private errorContext;
35
64
  get workspaceId(): string;
36
65
  get workspaceName(): string | null;
66
+ /** GET /api/v1/auth/whoami. Throws TokenExpiredError (401) or TacitApiError. */
67
+ whoami(timeoutMs?: number): Promise<WhoAmI>;
68
+ /** Adopt a verified identity: fills a missing workspace id and the name; skips the /workspaces/mine lookup. */
69
+ applyIdentity(who: Pick<WhoAmI, 'workspace_id' | 'workspace_name'>): void;
70
+ /**
71
+ * Decoded payload of an HMAC session credential (carries the autonomy claim), or null
72
+ * when the client does not hold one. Never returns the token itself.
73
+ */
74
+ hmacSessionClaims(): Record<string, unknown> | null;
75
+ /**
76
+ * Fill in the workspace name for a client built without one (level-2 env credentials on an
77
+ * old server). Never replaces a workspace id that is already set.
78
+ */
37
79
  initialize(): Promise<void>;
80
+ /**
81
+ * Switch workspace. Session JWT credentials only (G4, D-45): any other credential kind
82
+ * switches by choosing another saved login, so it gets a named error instead of a 401.
83
+ */
38
84
  switchWorkspace(workspaceId: string): Promise<{
39
85
  workspace_id: string;
40
86
  name: string;
41
87
  }>;
42
88
  /**
43
89
  * Resolve the workspace ID:
44
- * 1. Return this._workspaceId if already set (from constructor opts/profile).
45
- * 2. TACIT_WORKSPACE_ID env var (BUG-369: takes priority over sync.json).
46
- * 3. Fall back to <rootDir>/.tacit/sync.json.
47
- * 4. Return null if no source is available.
90
+ * 1. Return this._workspaceId if already set (constructor options / profile / whoami).
91
+ * 2. Fall back to <rootDir>/.tacit/sync.json.
92
+ * 3. Return null if no source is available.
48
93
  */
49
94
  resolveWorkspaceId(): Promise<string | null>;
50
95
  /**
51
96
  * Build a user-facing URL for an entity in the TACIT web app.
52
- * Returns null when TACIT_APP_URL is not configured.
97
+ * Returns null when no app URL is configured.
53
98
  *
54
99
  * Route patterns (TanStack file-based routing in tacitai.app.beta):
55
100
  * artifact → /view/:id
@@ -63,15 +108,17 @@ export declare class TacitClient {
63
108
  /**
64
109
  * Build auth headers. Value is NEVER written to logs.
65
110
  *
66
- * MV-1515n (W5 harness): when TACIT_SESSION_TOKEN is set (an HMAC
67
- * X-Tacit-Session token, per tacit-internal-token-auth §HMAC session token
68
- * format), it takes precedence and is sent as X-Tacit-Session instead of
69
- * Authorization — this is additive and does not change default behavior
70
- * (Bearer via TACIT_TOKEN) when TACIT_SESSION_TOKEN is unset.
111
+ * An HMAC session credential (explicit `sessionToken`, MV-1515n harness, or an HMAC-shaped
112
+ * token) is sent as X-Tacit-Session; everything else as a Bearer token.
71
113
  */
72
114
  private authHeaders;
115
+ /**
116
+ * Every request carries a credential, so none may follow a redirect (L-7): a 307/308 would re-send
117
+ * the Authorization / X-Tacit-Session header and body to another origin. A 3xx is an error.
118
+ */
119
+ private send;
73
120
  /** GET request returning parsed JSON. */
74
- get<T = unknown>(endpoint: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
121
+ get<T = unknown>(endpoint: string, params?: Record<string, string | number | boolean | undefined>, timeoutMs?: number): Promise<T>;
75
122
  /** POST request returning parsed JSON. `extraHeaders` merges on top of auth headers (e.g. If-Match). */
76
123
  post<T = unknown>(endpoint: string, body: unknown, extraHeaders?: Record<string, string>, timeoutMs?: number): Promise<T>;
77
124
  /** PUT request returning parsed JSON. */
@@ -93,51 +140,42 @@ export declare class TacitApiError extends Error {
93
140
  readonly statusCode: number;
94
141
  readonly body: string;
95
142
  readonly endpoint: string;
96
- constructor(statusCode: number, body: string, endpoint: string);
143
+ /** Workspace name when the client knew it, for the <workspace> slot of api-errors.ts messages. */
144
+ readonly workspace: string | null;
145
+ constructor(statusCode: number, body: string, endpoint: string,
146
+ /** Workspace name when the client knew it, for the <workspace> slot of api-errors.ts messages. */
147
+ workspace?: string | null,
148
+ /** The api-errors.ts message for this status + code, when the table has one. */
149
+ message?: string);
97
150
  }
98
151
  /**
99
- * Thrown when the API returns 401 — indicates the developer token has expired
100
- * or been revoked. Tools catch this and surface a user-actionable message.
152
+ * Thrown when the API returns 401 — the credential has expired or been revoked.
153
+ * Tools catch this and surface a user-actionable message.
101
154
  *
102
- * FEAT-193: The server grants a 7-day grace window after expiry — during that
103
- * window, `POST /api/v1/developer-tokens/refresh` still works (no browser
104
- * re-auth needed). After 7 days, full device-auth is required.
155
+ * `code` is the server's named error code when the 401 body carried one
156
+ * (e.g. MEMBERSHIP_NOT_FOUND, CREDENTIAL_BINDING_MISMATCH); null for an old server.
105
157
  *
106
158
  * Security invariant: token plaintext is NEVER included in this error.
107
159
  */
108
160
  export declare class TokenExpiredError extends Error {
109
161
  readonly renewalUrl: string;
110
162
  readonly setupCommand: string;
111
- constructor(renewalUrl: string, setupCommand: string);
163
+ readonly code: string | null;
164
+ /** Workspace name when the client knew it. */
165
+ readonly workspace: string | null;
166
+ readonly statusCode = 401;
167
+ constructor(renewalUrl: string, setupCommand: string, code?: string | null,
168
+ /** The api-errors.ts message for this 401. When absent, the generic renewal text is used. */
169
+ message?: string,
170
+ /** Workspace name when the client knew it. */
171
+ workspace?: string | null);
112
172
  }
113
- export interface ProfileData {
114
- version: number;
115
- workspace_id: string;
116
- workspace_name?: string;
117
- api_url: string;
118
- app_url?: string;
119
- token: string;
120
- created_at?: string;
121
- expires_at?: string;
173
+ /** `tacit_switch_workspace` with a credential that is not a session JWT (D-45). */
174
+ export declare class SwitchNotSupportedError extends Error {
175
+ constructor();
122
176
  }
123
- export declare function loadProfile(name: string): ProfileData;
124
- /**
125
- * 5-level resolution chain (FEAT-255 §2.1). Empty-string-as-unset rule applies.
126
- * Returns TacitClientOptions from the first matching level.
127
- * Throws on set-but-invalid states (profile missing, WORKSPACE_ID without TOKEN).
128
- */
129
- export declare function resolveProfileOptions(): TacitClientOptions;
130
177
  /** HTTPS mode: bind the caller's token/apiUrl/principal to everything run inside fn. */
131
178
  export declare function runWithRequestContext<T>(token: string, apiUrl: string, fn: () => Promise<T>, principal?: string): Promise<T>;
132
179
  export declare function getRequestPrincipal(): string | null;
133
- export type AutonomyLevel = 'GUEST' | 'SCRIBE' | 'MENTAT' | 'TWIN';
134
- export declare function parseAutonomyLevel(raw: unknown): AutonomyLevel;
135
- export declare function autonomyAtLeast(current: AutonomyLevel, required: AutonomyLevel): boolean;
136
- export declare function getRequestAutonomy(principal: string): Promise<AutonomyLevel | {
137
- error: 'token_expired';
138
- }>;
139
- export declare function ensureAutonomy(principal: string): Promise<AutonomyLevel | {
140
- error: 'token_expired';
141
- }>;
142
- export declare function getCachedAutonomy(principal: string): AutonomyLevel | null;
180
+ export declare function setDefaultClient(client: TacitClient | null): void;
143
181
  export declare function getClient(): TacitClient;