@company-semantics/contracts 87.0.0 → 88.0.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/package.json +7 -3
- package/src/guards/README.md +0 -1
- package/src/guards/config.ts +0 -9
- package/src/guards/evolution-config.ts +1 -18
- package/src/guards/index.ts +0 -1
- package/src/index.ts +15 -1277
- package/src/mcp/README.md +12 -12
- package/src/mcp/capability-graph.ts +1 -1
- package/src/mcp/index.ts +16 -244
- package/src/mcp/tool-descriptor.ts +244 -0
- package/src/org/authority-schemas.ts +242 -0
- package/src/org/index.ts +26 -249
- package/src/org/invite-schemas.ts +596 -0
- package/src/org/org-governance-schemas.ts +198 -0
- package/src/org/org-unit-api-schemas.ts +226 -0
- package/src/org/org-unit-schemas.ts +223 -0
- package/src/org/ownership-transfer-types.ts +51 -0
- package/src/org/schemas.ts +18 -1658
- package/src/org/sso-stepper-types.ts +81 -0
- package/src/org/types.ts +15 -115
- package/src/org/workspace-admin-schemas.ts +240 -0
- package/src/root-exports/README.md +91 -0
- package/src/root-exports/agent-runtime.ts +213 -0
- package/src/root-exports/collaboration.ts +247 -0
- package/src/root-exports/delivery.ts +218 -0
- package/src/root-exports/org-structure.ts +214 -0
- package/src/root-exports/org-workspace.ts +254 -0
- package/src/root-exports/platform.ts +205 -0
- package/src/system/README.md +1 -1
- package/src/system/capabilities.ts +1 -1
- package/src/system/diagram.ts +1 -1
- package/src/system/feature-status.ts +4 -0
- package/src/system/index.ts +3 -4
package/src/mcp/README.md
CHANGED
|
@@ -19,25 +19,25 @@ Type vocabulary for MCP (Model Context Protocol) tool discovery, invocation meta
|
|
|
19
19
|
|
|
20
20
|
## Public API
|
|
21
21
|
|
|
22
|
-
- `CapabilityGraph` _(type)_
|
|
23
|
-
- `CapabilityGraphEdge` _(type)_
|
|
22
|
+
- `CapabilityGraph` _(type)_ — Capability graph derived from tool resource flow metadata.
|
|
23
|
+
- `CapabilityGraphEdge` _(type)_ — Edge in the capability graph connecting two tools via a resource.
|
|
24
24
|
- `FailureContext` _(type)_ — Structured recovery context emitted when an MCP tool call fails.
|
|
25
|
-
- `MCPToolDescriptor` _(type)_
|
|
25
|
+
- `MCPToolDescriptor` _(type)_ — Complete tool descriptor for discovery and invocation.
|
|
26
26
|
- `RecoveryAction` _(type)_ — A recovery action the agent may take.
|
|
27
27
|
- `ResourceType` _(type)_ — Resource type vocabulary for MCP tool resource flow.
|
|
28
28
|
- `ToolCategory` _(type)_
|
|
29
|
-
- `ToolComplexity` _(type)_
|
|
29
|
+
- `ToolComplexity` _(type)_ — Tool computational complexity classification.
|
|
30
30
|
- `ToolDiscoveryResponse` _(type)_
|
|
31
|
-
- `ToolDomain` _(type)_
|
|
32
|
-
- `ToolEffectClass` _(type)_
|
|
33
|
-
- `ToolIntegration` _(type)_
|
|
34
|
-
- `ToolIntent` _(type)_
|
|
35
|
-
- `ToolInvocationMode` _(type)_
|
|
31
|
+
- `ToolDomain` _(type)_ — Tool domain taxonomy.
|
|
32
|
+
- `ToolEffectClass` _(type)_ — Tool effect classification.
|
|
33
|
+
- `ToolIntegration` _(type)_ — Integration provider tag for tools.
|
|
34
|
+
- `ToolIntent` _(type)_ — Tool intent classification.
|
|
35
|
+
- `ToolInvocationMode` _(type)_ — How the tool can be invoked. - manual: User must explicitly request - assistant: AI can invoke proactively -…
|
|
36
36
|
- `ToolListDataPart` _(type)_
|
|
37
37
|
- `ToolListMessagePart` _(type)_
|
|
38
|
-
- `ToolStability` _(type)_
|
|
39
|
-
- `ToolVisibility` _(type)_
|
|
40
|
-
- `ToolWorkflow` _(type)_
|
|
38
|
+
- `ToolStability` _(type)_ — Tool lifecycle stability classification. - experimental: May change or be removed without notice - stable…
|
|
39
|
+
- `ToolVisibility` _(type)_ — Tool visibility levels.
|
|
40
|
+
- `ToolWorkflow` _(type)_ — Named workflow derived from capability graph paths.
|
|
41
41
|
- `buildCapabilityGraph` — Build a capability graph from tool resource flow metadata.
|
|
42
42
|
|
|
43
43
|
<!-- END GENERATED: readme-public-api -->
|
package/src/mcp/index.ts
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CapabilityGraph, MCPToolDescriptor } from "./tool-descriptor";
|
|
2
2
|
export type { ResourceType } from "./resources";
|
|
3
3
|
export { buildCapabilityGraph } from "./capability-graph";
|
|
4
4
|
export type { FailureContext, RecoveryAction } from "./failure-context";
|
|
5
|
+
export type {
|
|
6
|
+
ToolCategory,
|
|
7
|
+
ToolDomain,
|
|
8
|
+
ToolVisibility,
|
|
9
|
+
ToolInvocationMode,
|
|
10
|
+
ToolEffectClass,
|
|
11
|
+
ToolIntent,
|
|
12
|
+
ToolStability,
|
|
13
|
+
ToolComplexity,
|
|
14
|
+
ToolIntegration,
|
|
15
|
+
MCPToolDescriptor,
|
|
16
|
+
CapabilityGraphEdge,
|
|
17
|
+
ToolWorkflow,
|
|
18
|
+
CapabilityGraph,
|
|
19
|
+
} from "./tool-descriptor";
|
|
5
20
|
|
|
6
21
|
/**
|
|
7
22
|
* MCP Tool Discovery Types
|
|
@@ -22,249 +37,6 @@ export type { FailureContext, RecoveryAction } from "./failure-context";
|
|
|
22
37
|
* @see company-semantics-backend/src/interfaces/mcp/ for implementation
|
|
23
38
|
*/
|
|
24
39
|
|
|
25
|
-
/**
|
|
26
|
-
* @deprecated Use ToolDomain instead. ToolCategory is too coarse —
|
|
27
|
-
* 'data' conflates discovery, ingestion, and coverage.
|
|
28
|
-
*/
|
|
29
|
-
export type ToolCategory =
|
|
30
|
-
"system" | "data" | "connections" | "automation" | "developer";
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Tool domain taxonomy.
|
|
34
|
-
*
|
|
35
|
-
* Each value maps to a distinct domain boundary in the system architecture.
|
|
36
|
-
* Replaces ToolCategory which was too coarse for resource flow reasoning.
|
|
37
|
-
*
|
|
38
|
-
* - organization: Org settings, membership, billing queries
|
|
39
|
-
* - identity: User profile, auth state, preferences
|
|
40
|
-
* - integrations: OAuth connections, provider management
|
|
41
|
-
* - ingestion: Data import, sync jobs, source configuration
|
|
42
|
-
* - discovery: Search, exploration, content queries
|
|
43
|
-
* - knowledge: Fingerprints, embeddings, knowledge graph
|
|
44
|
-
* - system: Health, status, runtime diagnostics
|
|
45
|
-
*/
|
|
46
|
-
export type ToolDomain =
|
|
47
|
-
| "organization"
|
|
48
|
-
| "identity"
|
|
49
|
-
| "integrations"
|
|
50
|
-
| "ingestion"
|
|
51
|
-
| "discovery"
|
|
52
|
-
| "knowledge"
|
|
53
|
-
| "system";
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Tool visibility levels.
|
|
57
|
-
* Controls who can see the tool in discovery.
|
|
58
|
-
*/
|
|
59
|
-
export type ToolVisibility = "user" | "admin";
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* How the tool can be invoked.
|
|
63
|
-
* - manual: User must explicitly request
|
|
64
|
-
* - assistant: AI can invoke proactively
|
|
65
|
-
* - hybrid: Both manual and assistant invocation
|
|
66
|
-
*/
|
|
67
|
-
export type ToolInvocationMode = "manual" | "assistant" | "hybrid";
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Tool effect classification.
|
|
71
|
-
* Effect classification is orthogonal to requiresConfirmation and requiresApproval.
|
|
72
|
-
* - effectClass: "Does this tool mutate state?"
|
|
73
|
-
* - requiresConfirmation: "Does the user need to approve before execution?"
|
|
74
|
-
* - requiresApproval: "Does this need cross-principal authorization?"
|
|
75
|
-
* An effectful tool may auto-execute (requiresConfirmation: false) for low-risk operations.
|
|
76
|
-
* An effectful tool may require approval without confirmation.
|
|
77
|
-
*/
|
|
78
|
-
export type ToolEffectClass = "pure" | "effectful";
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Tool intent classification.
|
|
82
|
-
*
|
|
83
|
-
* Classifies what the tool does to the system:
|
|
84
|
-
* - read: Pure data retrieval (no side effects)
|
|
85
|
-
* - mutate: State change (creates, updates, deletes)
|
|
86
|
-
* - analysis: Computation over data without mutation (aggregation, scoring)
|
|
87
|
-
*
|
|
88
|
-
* Note: 'control' was removed — system-level operations (health, status,
|
|
89
|
-
* runtime) use 'read' intent in the 'system' domain. Control is a domain
|
|
90
|
-
* classification, not an intent.
|
|
91
|
-
*
|
|
92
|
-
* INVARIANT: intent 'mutate' + risk 'high' → requiresConfirmation must be true.
|
|
93
|
-
* Enforced in backend tool registration, typed here for documentation.
|
|
94
|
-
*/
|
|
95
|
-
export type ToolIntent = "read" | "mutate" | "analysis";
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Tool lifecycle stability classification.
|
|
99
|
-
*
|
|
100
|
-
* - experimental: May change or be removed without notice
|
|
101
|
-
* - stable: Production-ready with backward compatibility guarantees
|
|
102
|
-
* - deprecated: Scheduled for removal, consumers should migrate
|
|
103
|
-
*/
|
|
104
|
-
export type ToolStability = "experimental" | "stable" | "deprecated";
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Tool computational complexity classification.
|
|
108
|
-
*
|
|
109
|
-
* Classifies the cost and latency profile of a tool invocation:
|
|
110
|
-
* - trivial: Sub-100ms, in-memory or single DB lookup
|
|
111
|
-
* - moderate: 100ms-5s, may involve external API calls
|
|
112
|
-
* - heavy: 5s+, batch processing, large data transfers, long-running ops
|
|
113
|
-
*/
|
|
114
|
-
export type ToolComplexity = "trivial" | "moderate" | "heavy";
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Integration provider tag for tools.
|
|
118
|
-
*
|
|
119
|
-
* Known values correspond to registered OAuth providers.
|
|
120
|
-
* Extensible via (string & {}) — new integrations do not require
|
|
121
|
-
* a contracts release, but known values get autocomplete.
|
|
122
|
-
*/
|
|
123
|
-
export type ToolIntegration = "slack" | "google" | "zoom" | (string & {});
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Complete tool descriptor for discovery and invocation.
|
|
127
|
-
*
|
|
128
|
-
* Discovery uses: id, name, description, category
|
|
129
|
-
* Invocation uses: id, requiresConfirmation, invocationMode, effectClass
|
|
130
|
-
*/
|
|
131
|
-
// @vocabulary-exempt reason: MCPToolDescriptor is a single cohesive descriptor consumed by multiple repos; splitting would break consumers
|
|
132
|
-
export interface MCPToolDescriptor {
|
|
133
|
-
/** Unique identifier (matches MCP tool name, e.g., 'cs_help') */
|
|
134
|
-
id: string;
|
|
135
|
-
/** Human-readable name for display */
|
|
136
|
-
name: string;
|
|
137
|
-
/** User-facing description (what it does, not how) */
|
|
138
|
-
description: string;
|
|
139
|
-
/** Grouping category for UI organization */
|
|
140
|
-
category: ToolCategory;
|
|
141
|
-
/** Whether user confirmation is required before execution */
|
|
142
|
-
requiresConfirmation: boolean;
|
|
143
|
-
/**
|
|
144
|
-
* Whether this tool causes durable state change.
|
|
145
|
-
* Effectful = any tool that can cause durable state change (DB writes, external API calls, background job enqueue).
|
|
146
|
-
* Pure = read-only operations, URL generation, status queries.
|
|
147
|
-
*
|
|
148
|
-
* Orthogonal to requiresConfirmation — an effectful tool may auto-execute
|
|
149
|
-
* for low-risk operations, and a pure tool never needs confirmation.
|
|
150
|
-
* The bridge enforces: effectful tools must return previewResponse()
|
|
151
|
-
* with ExecutionIntent, never direct side effects.
|
|
152
|
-
*/
|
|
153
|
-
effectClass: ToolEffectClass;
|
|
154
|
-
/** How the tool can be triggered */
|
|
155
|
-
invocationMode: ToolInvocationMode;
|
|
156
|
-
/** Who can see this tool */
|
|
157
|
-
visibility: ToolVisibility;
|
|
158
|
-
|
|
159
|
-
// --- New fields (PRD-00265) ---
|
|
160
|
-
|
|
161
|
-
/** Domain taxonomy classification. Replaces category for routing and grouping. */
|
|
162
|
-
domain: ToolDomain;
|
|
163
|
-
/**
|
|
164
|
-
* Integration providers this tool interacts with.
|
|
165
|
-
* Empty or omitted for tools that don't touch external integrations.
|
|
166
|
-
*/
|
|
167
|
-
integrations?: ToolIntegration[];
|
|
168
|
-
/**
|
|
169
|
-
* User-impact risk classification.
|
|
170
|
-
* - none: Read-only, no side effects
|
|
171
|
-
* - low: Reversible mutation (can be undone)
|
|
172
|
-
* - moderate: User-visible side effect (notification sent, state changed)
|
|
173
|
-
* - high: Destructive or irreversible (data deletion, external action)
|
|
174
|
-
*
|
|
175
|
-
* INVARIANT: intent 'mutate' + risk 'high' → requiresConfirmation must be true.
|
|
176
|
-
*/
|
|
177
|
-
risk: "none" | "low" | "moderate" | "high";
|
|
178
|
-
/** What the tool does to the system (read, mutate, analysis). */
|
|
179
|
-
intent: ToolIntent;
|
|
180
|
-
/** Lifecycle stability classification. */
|
|
181
|
-
stability: ToolStability;
|
|
182
|
-
/** Computational complexity and latency profile. */
|
|
183
|
-
complexity: ToolComplexity;
|
|
184
|
-
/**
|
|
185
|
-
* Input schema version number.
|
|
186
|
-
* Disambiguates input schema versioning from tool behavior versioning.
|
|
187
|
-
* Increment when the tool's input schema changes shape.
|
|
188
|
-
*/
|
|
189
|
-
schemaVersion: number;
|
|
190
|
-
/**
|
|
191
|
-
* Authorization scopes required to invoke this tool.
|
|
192
|
-
* References scope strings from trust/scopes.ts.
|
|
193
|
-
* Omit for tools with no specific scope requirements.
|
|
194
|
-
*/
|
|
195
|
-
scopes?: string[];
|
|
196
|
-
/**
|
|
197
|
-
* Resource types this tool produces (creates or outputs).
|
|
198
|
-
* Used for capability graph derivation — enables workflow ordering
|
|
199
|
-
* via resource flow instead of explicit `requires` fields.
|
|
200
|
-
*/
|
|
201
|
-
produces?: ResourceType[];
|
|
202
|
-
/**
|
|
203
|
-
* Resource types this tool consumes (requires as input).
|
|
204
|
-
* Used for capability graph derivation — a tool that consumes
|
|
205
|
-
* 'integration.connection' can only run after a tool that produces it.
|
|
206
|
-
*/
|
|
207
|
-
consumes?: ResourceType[];
|
|
208
|
-
/**
|
|
209
|
-
* Mutation-capability gate (ADR-BE-241). When present, the tool is locked
|
|
210
|
-
* unless the viewer's resolved capabilities permit it — the SINGLE source of
|
|
211
|
-
* truth consumed by BOTH the backend execution gate and the frontend tool-lock
|
|
212
|
-
* UI (replacing the previously triplicated ACTION_TOOL_GATES / FIELD_GATES /
|
|
213
|
-
* ACTION_GATES maps).
|
|
214
|
-
* - kind 'field': `path` addresses a FieldCapability in CapabilitiesResponse
|
|
215
|
-
* (e.g. 'org.name', 'profile.fullName'); locked unless state === 'editable'.
|
|
216
|
-
* - kind 'action': `path` addresses an ActionCapability under `.actions`
|
|
217
|
-
* (e.g. 'members.invite', 'orgAdmins.manage'); locked unless 'allowed'.
|
|
218
|
-
* Absent ⇒ ungated (gating is additive).
|
|
219
|
-
*/
|
|
220
|
-
capabilityGate?: { kind: "field" | "action"; path: string };
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Edge in the capability graph connecting two tools via a resource.
|
|
225
|
-
* A tool that produces a resource connects to tools that consume it.
|
|
226
|
-
*
|
|
227
|
-
* @see capability-graph.ts for buildCapabilityGraph() implementation
|
|
228
|
-
*/
|
|
229
|
-
export interface CapabilityGraphEdge {
|
|
230
|
-
/** Tool ID that produces the resource */
|
|
231
|
-
from: string;
|
|
232
|
-
/** Tool ID that consumes the resource */
|
|
233
|
-
to: string;
|
|
234
|
-
/** Resource type flowing between tools */
|
|
235
|
-
resource: ResourceType;
|
|
236
|
-
/** Resource domain (extracted from resource namespace prefix, e.g., 'slack' from 'slack.channel') */
|
|
237
|
-
domain?: string;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Named workflow derived from capability graph paths.
|
|
242
|
-
* Represents a common multi-tool sequence (e.g., "Connect Slack → Ingest → Query").
|
|
243
|
-
*
|
|
244
|
-
* @see capability-graph.ts for buildCapabilityGraph() implementation
|
|
245
|
-
*/
|
|
246
|
-
export interface ToolWorkflow {
|
|
247
|
-
/** Workflow name (e.g., "Slack Onboarding") */
|
|
248
|
-
name: string;
|
|
249
|
-
/** Human-readable description of the workflow */
|
|
250
|
-
description: string;
|
|
251
|
-
/** Ordered list of tool IDs in this workflow */
|
|
252
|
-
steps: string[];
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Capability graph derived from tool resource flow metadata.
|
|
257
|
-
* Built from produces/consumes fields on MCPToolDescriptor.
|
|
258
|
-
*
|
|
259
|
-
* @see capability-graph.ts for buildCapabilityGraph() implementation
|
|
260
|
-
*/
|
|
261
|
-
export interface CapabilityGraph {
|
|
262
|
-
/** Resource flow edges between tools */
|
|
263
|
-
edges: CapabilityGraphEdge[];
|
|
264
|
-
/** Named workflows derived from graph paths */
|
|
265
|
-
workflows: ToolWorkflow[];
|
|
266
|
-
}
|
|
267
|
-
|
|
268
40
|
/**
|
|
269
41
|
* Response shape for tool discovery endpoint.
|
|
270
42
|
* Used by GET /api/capabilities/tools
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import type { ResourceType } from "./resources";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use ToolDomain instead. ToolCategory is too coarse —
|
|
5
|
+
* 'data' conflates discovery, ingestion, and coverage.
|
|
6
|
+
*/
|
|
7
|
+
export type ToolCategory =
|
|
8
|
+
"system" | "data" | "connections" | "automation" | "developer";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Tool domain taxonomy.
|
|
12
|
+
*
|
|
13
|
+
* Each value maps to a distinct domain boundary in the system architecture.
|
|
14
|
+
* Replaces ToolCategory which was too coarse for resource flow reasoning.
|
|
15
|
+
*
|
|
16
|
+
* - organization: Org settings, membership, billing queries
|
|
17
|
+
* - identity: User profile, auth state, preferences
|
|
18
|
+
* - integrations: OAuth connections, provider management
|
|
19
|
+
* - ingestion: Data import, sync jobs, source configuration
|
|
20
|
+
* - discovery: Search, exploration, content queries
|
|
21
|
+
* - knowledge: Fingerprints, embeddings, knowledge graph
|
|
22
|
+
* - system: Health, status, runtime diagnostics
|
|
23
|
+
*/
|
|
24
|
+
export type ToolDomain =
|
|
25
|
+
| "organization"
|
|
26
|
+
| "identity"
|
|
27
|
+
| "integrations"
|
|
28
|
+
| "ingestion"
|
|
29
|
+
| "discovery"
|
|
30
|
+
| "knowledge"
|
|
31
|
+
| "system";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Tool visibility levels.
|
|
35
|
+
* Controls who can see the tool in discovery.
|
|
36
|
+
*/
|
|
37
|
+
export type ToolVisibility = "user" | "admin";
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* How the tool can be invoked.
|
|
41
|
+
* - manual: User must explicitly request
|
|
42
|
+
* - assistant: AI can invoke proactively
|
|
43
|
+
* - hybrid: Both manual and assistant invocation
|
|
44
|
+
*/
|
|
45
|
+
export type ToolInvocationMode = "manual" | "assistant" | "hybrid";
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Tool effect classification.
|
|
49
|
+
* Effect classification is orthogonal to requiresConfirmation and requiresApproval.
|
|
50
|
+
* - effectClass: "Does this tool mutate state?"
|
|
51
|
+
* - requiresConfirmation: "Does the user need to approve before execution?"
|
|
52
|
+
* - requiresApproval: "Does this need cross-principal authorization?"
|
|
53
|
+
* An effectful tool may auto-execute (requiresConfirmation: false) for low-risk operations.
|
|
54
|
+
* An effectful tool may require approval without confirmation.
|
|
55
|
+
*/
|
|
56
|
+
export type ToolEffectClass = "pure" | "effectful";
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Tool intent classification.
|
|
60
|
+
*
|
|
61
|
+
* Classifies what the tool does to the system:
|
|
62
|
+
* - read: Pure data retrieval (no side effects)
|
|
63
|
+
* - mutate: State change (creates, updates, deletes)
|
|
64
|
+
* - analysis: Computation over data without mutation (aggregation, scoring)
|
|
65
|
+
*
|
|
66
|
+
* Note: 'control' was removed — system-level operations (health, status,
|
|
67
|
+
* runtime) use 'read' intent in the 'system' domain. Control is a domain
|
|
68
|
+
* classification, not an intent.
|
|
69
|
+
*
|
|
70
|
+
* INVARIANT: intent 'mutate' + risk 'high' → requiresConfirmation must be true.
|
|
71
|
+
* Enforced in backend tool registration, typed here for documentation.
|
|
72
|
+
*/
|
|
73
|
+
export type ToolIntent = "read" | "mutate" | "analysis";
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Tool lifecycle stability classification.
|
|
77
|
+
*
|
|
78
|
+
* - experimental: May change or be removed without notice
|
|
79
|
+
* - stable: Production-ready with backward compatibility guarantees
|
|
80
|
+
* - deprecated: Scheduled for removal, consumers should migrate
|
|
81
|
+
*/
|
|
82
|
+
export type ToolStability = "experimental" | "stable" | "deprecated";
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Tool computational complexity classification.
|
|
86
|
+
*
|
|
87
|
+
* Classifies the cost and latency profile of a tool invocation:
|
|
88
|
+
* - trivial: Sub-100ms, in-memory or single DB lookup
|
|
89
|
+
* - moderate: 100ms-5s, may involve external API calls
|
|
90
|
+
* - heavy: 5s+, batch processing, large data transfers, long-running ops
|
|
91
|
+
*/
|
|
92
|
+
export type ToolComplexity = "trivial" | "moderate" | "heavy";
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Integration provider tag for tools.
|
|
96
|
+
*
|
|
97
|
+
* Known values correspond to registered OAuth providers.
|
|
98
|
+
* Extensible via (string & {}) — new integrations do not require
|
|
99
|
+
* a contracts release, but known values get autocomplete.
|
|
100
|
+
*/
|
|
101
|
+
export type ToolIntegration = "slack" | "google" | "zoom" | (string & {});
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Complete tool descriptor for discovery and invocation.
|
|
105
|
+
*
|
|
106
|
+
* Discovery uses: id, name, description, category
|
|
107
|
+
* Invocation uses: id, requiresConfirmation, invocationMode, effectClass
|
|
108
|
+
*/
|
|
109
|
+
// @vocabulary-exempt reason: MCPToolDescriptor is a single cohesive descriptor consumed by multiple repos; splitting would break consumers
|
|
110
|
+
export interface MCPToolDescriptor {
|
|
111
|
+
/** Unique identifier (matches MCP tool name, e.g., 'cs_help') */
|
|
112
|
+
id: string;
|
|
113
|
+
/** Human-readable name for display */
|
|
114
|
+
name: string;
|
|
115
|
+
/** User-facing description (what it does, not how) */
|
|
116
|
+
description: string;
|
|
117
|
+
/** Grouping category for UI organization */
|
|
118
|
+
category: ToolCategory;
|
|
119
|
+
/** Whether user confirmation is required before execution */
|
|
120
|
+
requiresConfirmation: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Whether this tool causes durable state change.
|
|
123
|
+
* Effectful = any tool that can cause durable state change (DB writes, external API calls, background job enqueue).
|
|
124
|
+
* Pure = read-only operations, URL generation, status queries.
|
|
125
|
+
*
|
|
126
|
+
* Orthogonal to requiresConfirmation — an effectful tool may auto-execute
|
|
127
|
+
* for low-risk operations, and a pure tool never needs confirmation.
|
|
128
|
+
* The bridge enforces: effectful tools must return previewResponse()
|
|
129
|
+
* with ExecutionIntent, never direct side effects.
|
|
130
|
+
*/
|
|
131
|
+
effectClass: ToolEffectClass;
|
|
132
|
+
/** How the tool can be triggered */
|
|
133
|
+
invocationMode: ToolInvocationMode;
|
|
134
|
+
/** Who can see this tool */
|
|
135
|
+
visibility: ToolVisibility;
|
|
136
|
+
|
|
137
|
+
// --- New fields (PRD-00265) ---
|
|
138
|
+
|
|
139
|
+
/** Domain taxonomy classification. Replaces category for routing and grouping. */
|
|
140
|
+
domain: ToolDomain;
|
|
141
|
+
/**
|
|
142
|
+
* Integration providers this tool interacts with.
|
|
143
|
+
* Empty or omitted for tools that don't touch external integrations.
|
|
144
|
+
*/
|
|
145
|
+
integrations?: ToolIntegration[];
|
|
146
|
+
/**
|
|
147
|
+
* User-impact risk classification.
|
|
148
|
+
* - none: Read-only, no side effects
|
|
149
|
+
* - low: Reversible mutation (can be undone)
|
|
150
|
+
* - moderate: User-visible side effect (notification sent, state changed)
|
|
151
|
+
* - high: Destructive or irreversible (data deletion, external action)
|
|
152
|
+
*
|
|
153
|
+
* INVARIANT: intent 'mutate' + risk 'high' → requiresConfirmation must be true.
|
|
154
|
+
*/
|
|
155
|
+
risk: "none" | "low" | "moderate" | "high";
|
|
156
|
+
/** What the tool does to the system (read, mutate, analysis). */
|
|
157
|
+
intent: ToolIntent;
|
|
158
|
+
/** Lifecycle stability classification. */
|
|
159
|
+
stability: ToolStability;
|
|
160
|
+
/** Computational complexity and latency profile. */
|
|
161
|
+
complexity: ToolComplexity;
|
|
162
|
+
/**
|
|
163
|
+
* Input schema version number.
|
|
164
|
+
* Disambiguates input schema versioning from tool behavior versioning.
|
|
165
|
+
* Increment when the tool's input schema changes shape.
|
|
166
|
+
*/
|
|
167
|
+
schemaVersion: number;
|
|
168
|
+
/**
|
|
169
|
+
* Authorization scopes required to invoke this tool.
|
|
170
|
+
* References scope strings from trust/scopes.ts.
|
|
171
|
+
* Omit for tools with no specific scope requirements.
|
|
172
|
+
*/
|
|
173
|
+
scopes?: string[];
|
|
174
|
+
/**
|
|
175
|
+
* Resource types this tool produces (creates or outputs).
|
|
176
|
+
* Used for capability graph derivation — enables workflow ordering
|
|
177
|
+
* via resource flow instead of explicit `requires` fields.
|
|
178
|
+
*/
|
|
179
|
+
produces?: ResourceType[];
|
|
180
|
+
/**
|
|
181
|
+
* Resource types this tool consumes (requires as input).
|
|
182
|
+
* Used for capability graph derivation — a tool that consumes
|
|
183
|
+
* 'integration.connection' can only run after a tool that produces it.
|
|
184
|
+
*/
|
|
185
|
+
consumes?: ResourceType[];
|
|
186
|
+
/**
|
|
187
|
+
* Mutation-capability gate (ADR-BE-241). When present, the tool is locked
|
|
188
|
+
* unless the viewer's resolved capabilities permit it — the SINGLE source of
|
|
189
|
+
* truth consumed by BOTH the backend execution gate and the frontend tool-lock
|
|
190
|
+
* UI (replacing the previously triplicated ACTION_TOOL_GATES / FIELD_GATES /
|
|
191
|
+
* ACTION_GATES maps).
|
|
192
|
+
* - kind 'field': `path` addresses a FieldCapability in CapabilitiesResponse
|
|
193
|
+
* (e.g. 'org.name', 'profile.fullName'); locked unless state === 'editable'.
|
|
194
|
+
* - kind 'action': `path` addresses an ActionCapability under `.actions`
|
|
195
|
+
* (e.g. 'members.invite', 'orgAdmins.manage'); locked unless 'allowed'.
|
|
196
|
+
* Absent ⇒ ungated (gating is additive).
|
|
197
|
+
*/
|
|
198
|
+
capabilityGate?: { kind: "field" | "action"; path: string };
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Edge in the capability graph connecting two tools via a resource.
|
|
203
|
+
* A tool that produces a resource connects to tools that consume it.
|
|
204
|
+
*
|
|
205
|
+
* @see capability-graph.ts for buildCapabilityGraph() implementation
|
|
206
|
+
*/
|
|
207
|
+
export interface CapabilityGraphEdge {
|
|
208
|
+
/** Tool ID that produces the resource */
|
|
209
|
+
from: string;
|
|
210
|
+
/** Tool ID that consumes the resource */
|
|
211
|
+
to: string;
|
|
212
|
+
/** Resource type flowing between tools */
|
|
213
|
+
resource: ResourceType;
|
|
214
|
+
/** Resource domain (extracted from resource namespace prefix, e.g., 'slack' from 'slack.channel') */
|
|
215
|
+
domain?: string;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Named workflow derived from capability graph paths.
|
|
220
|
+
* Represents a common multi-tool sequence (e.g., "Connect Slack → Ingest → Query").
|
|
221
|
+
*
|
|
222
|
+
* @see capability-graph.ts for buildCapabilityGraph() implementation
|
|
223
|
+
*/
|
|
224
|
+
export interface ToolWorkflow {
|
|
225
|
+
/** Workflow name (e.g., "Slack Onboarding") */
|
|
226
|
+
name: string;
|
|
227
|
+
/** Human-readable description of the workflow */
|
|
228
|
+
description: string;
|
|
229
|
+
/** Ordered list of tool IDs in this workflow */
|
|
230
|
+
steps: string[];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Capability graph derived from tool resource flow metadata.
|
|
235
|
+
* Built from produces/consumes fields on MCPToolDescriptor.
|
|
236
|
+
*
|
|
237
|
+
* @see capability-graph.ts for buildCapabilityGraph() implementation
|
|
238
|
+
*/
|
|
239
|
+
export interface CapabilityGraph {
|
|
240
|
+
/** Resource flow edges between tools */
|
|
241
|
+
edges: CapabilityGraphEdge[];
|
|
242
|
+
/** Named workflows derived from graph paths */
|
|
243
|
+
workflows: ToolWorkflow[];
|
|
244
|
+
}
|