@openscout/protocol 0.2.63 → 0.2.82
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/LICENSE +202 -0
- package/README.md +103 -52
- package/dist/a2a.d.ts +224 -0
- package/dist/a2a.d.ts.map +1 -0
- package/dist/a2a.js +225 -0
- package/dist/activity.d.ts +70 -0
- package/dist/activity.d.ts.map +1 -0
- package/dist/activity.js +1 -0
- package/dist/actors.d.ts +7 -3
- package/dist/actors.d.ts.map +1 -0
- package/dist/actors.js +15 -1
- package/dist/agent-broker-feed.d.ts +84 -0
- package/dist/agent-broker-feed.d.ts.map +1 -0
- package/dist/agent-broker-feed.js +1 -0
- package/dist/agent-identity.d.ts +23 -0
- package/dist/agent-identity.d.ts.map +1 -0
- package/dist/agent-identity.js +122 -8
- package/dist/agent-runs.d.ts +191 -0
- package/dist/agent-runs.d.ts.map +1 -0
- package/dist/agent-runs.js +365 -0
- package/dist/assigned-roles.d.ts +205 -0
- package/dist/assigned-roles.d.ts.map +1 -0
- package/dist/assigned-roles.js +228 -0
- package/dist/broker-routes.d.ts +40 -0
- package/dist/broker-routes.d.ts.map +1 -0
- package/dist/broker-routes.js +56 -0
- package/dist/budget.d.ts +65 -0
- package/dist/budget.d.ts.map +1 -0
- package/dist/budget.js +19 -0
- package/dist/capability-matrix.d.ts +230 -0
- package/dist/capability-matrix.d.ts.map +1 -0
- package/dist/capability-matrix.js +304 -0
- package/dist/channel-identity.d.ts +40 -0
- package/dist/channel-identity.d.ts.map +1 -0
- package/dist/channel-identity.js +108 -0
- package/dist/collaboration.d.ts +45 -16
- package/dist/collaboration.d.ts.map +1 -0
- package/dist/collaboration.js +39 -23
- package/dist/common.d.ts +4 -3
- package/dist/common.d.ts.map +1 -0
- package/dist/conversations.d.ts +1 -0
- package/dist/conversations.d.ts.map +1 -0
- package/dist/cursor-transport.d.ts +22 -0
- package/dist/cursor-transport.d.ts.map +1 -0
- package/dist/cursor-transport.js +10 -0
- package/dist/debug-attach.d.ts +29 -0
- package/dist/debug-attach.d.ts.map +1 -0
- package/dist/debug-attach.js +6 -0
- package/dist/deliveries.d.ts +16 -2
- package/dist/deliveries.d.ts.map +1 -0
- package/dist/durable-actions.d.ts +94 -0
- package/dist/durable-actions.d.ts.map +1 -0
- package/dist/durable-actions.js +1 -0
- package/dist/events.d.ts +27 -1
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +14 -1
- package/dist/harness-feature-support.d.ts +76 -0
- package/dist/harness-feature-support.d.ts.map +1 -0
- package/dist/harness-feature-support.js +29 -0
- package/dist/host-integrations.d.ts +22 -0
- package/dist/host-integrations.d.ts.map +1 -0
- package/dist/host-integrations.js +64 -0
- package/dist/inbox.d.ts +50 -0
- package/dist/inbox.d.ts.map +1 -0
- package/dist/inbox.js +9 -0
- package/dist/index.d.ts +36 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -2
- package/dist/invocations.d.ts +121 -0
- package/dist/invocations.d.ts.map +1 -0
- package/dist/invocations.js +201 -1
- package/dist/mesh.d.ts +98 -0
- package/dist/mesh.d.ts.map +1 -0
- package/dist/mesh.js +18 -1
- package/dist/messages.d.ts +3 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/native-interactions.d.ts +30 -0
- package/dist/native-interactions.d.ts.map +1 -0
- package/dist/native-interactions.js +51 -0
- package/dist/observed-status.d.ts +33 -0
- package/dist/observed-status.d.ts.map +1 -0
- package/dist/observed-status.js +6 -0
- package/dist/orchestrator-prompt.d.ts +10 -0
- package/dist/orchestrator-prompt.d.ts.map +1 -0
- package/dist/orchestrator-prompt.js +36 -0
- package/dist/permission-policy.d.ts +5 -0
- package/dist/permission-policy.d.ts.map +1 -0
- package/dist/permission-policy.js +15 -0
- package/dist/provisional-agent-names.d.ts +30 -0
- package/dist/provisional-agent-names.d.ts.map +1 -0
- package/dist/provisional-agent-names.js +224 -0
- package/dist/read-receipts.d.ts +12 -0
- package/dist/read-receipts.d.ts.map +1 -0
- package/dist/read-receipts.js +1 -0
- package/dist/relay-agent-card.d.ts +10 -0
- package/dist/relay-agent-card.d.ts.map +1 -0
- package/dist/rendezvous.d.ts +97 -0
- package/dist/rendezvous.d.ts.map +1 -0
- package/dist/rendezvous.js +35 -0
- package/dist/reserved-vocabulary.d.ts +21 -0
- package/dist/reserved-vocabulary.d.ts.map +1 -0
- package/dist/reserved-vocabulary.js +101 -0
- package/dist/route-aliases.d.ts +112 -0
- package/dist/route-aliases.d.ts.map +1 -0
- package/dist/route-aliases.js +1 -0
- package/dist/runtime-catalog-contract.d.ts +39 -0
- package/dist/runtime-catalog-contract.d.ts.map +1 -0
- package/dist/runtime-catalog-contract.js +17 -0
- package/dist/runtime-catalog.d.ts +11 -0
- package/dist/runtime-catalog.d.ts.map +1 -0
- package/dist/runtime-catalog.generated.d.ts +230 -0
- package/dist/runtime-catalog.generated.d.ts.map +1 -0
- package/dist/runtime-catalog.generated.js +299 -0
- package/dist/runtime-catalog.js +192 -0
- package/dist/runtime-execution.d.ts +161 -0
- package/dist/runtime-execution.d.ts.map +1 -0
- package/dist/runtime-execution.js +327 -0
- package/dist/runtime-profiles.d.ts +12 -0
- package/dist/runtime-profiles.d.ts.map +1 -0
- package/dist/runtime-profiles.js +20 -0
- package/dist/scout-agent-card.d.ts +10 -0
- package/dist/scout-agent-card.d.ts.map +1 -0
- package/dist/scout-composer.d.ts +27 -0
- package/dist/scout-composer.d.ts.map +1 -0
- package/dist/scout-composer.js +192 -0
- package/dist/scout-delivery.d.ts +101 -4
- package/dist/scout-delivery.d.ts.map +1 -0
- package/dist/scout-dispatch.d.ts +44 -3
- package/dist/scout-dispatch.d.ts.map +1 -0
- package/dist/scout-reply-context.d.ts +14 -0
- package/dist/scout-reply-context.d.ts.map +1 -0
- package/dist/scout-reply-context.js +1 -0
- package/dist/session-display-state.d.ts +132 -0
- package/dist/session-display-state.d.ts.map +1 -0
- package/dist/session-display-state.js +94 -0
- package/dist/terminal-host-topology.d.ts +119 -0
- package/dist/terminal-host-topology.d.ts.map +1 -0
- package/dist/terminal-host-topology.js +21 -0
- package/dist/terminal-sessions.d.ts +142 -0
- package/dist/terminal-sessions.d.ts.map +1 -0
- package/dist/terminal-sessions.js +81 -0
- package/dist/terminal-surface-id.d.ts +73 -0
- package/dist/terminal-surface-id.d.ts.map +1 -0
- package/dist/terminal-surface-id.js +162 -0
- package/dist/terminal-workspaces.d.ts +199 -0
- package/dist/terminal-workspaces.d.ts.map +1 -0
- package/dist/terminal-workspaces.js +287 -0
- package/dist/thread-events.d.ts +1 -0
- package/dist/thread-events.d.ts.map +1 -0
- package/dist/time.d.ts +16 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/time.js +33 -0
- package/dist/transports.d.ts +1 -0
- package/dist/transports.d.ts.map +1 -0
- package/package.json +37 -9
- package/src/a2a.ts +471 -0
- package/src/activity.ts +113 -0
- package/src/actors.ts +42 -8
- package/src/agent-broker-feed.ts +102 -0
- package/src/agent-identity.ts +143 -8
- package/src/agent-runs.ts +675 -0
- package/src/assigned-roles.ts +437 -0
- package/src/broker-routes.ts +62 -0
- package/src/budget.ts +88 -0
- package/src/capability-matrix.ts +648 -0
- package/src/channel-identity.ts +147 -0
- package/src/collaboration.ts +78 -48
- package/src/common.ts +24 -5
- package/src/cursor-transport.ts +34 -0
- package/src/debug-attach.ts +38 -0
- package/src/deliveries.ts +16 -1
- package/src/durable-actions.ts +125 -0
- package/src/events.ts +31 -0
- package/src/harness-feature-support.ts +116 -0
- package/src/host-integrations.ts +104 -0
- package/src/inbox.ts +68 -0
- package/src/index.ts +35 -2
- package/src/invocations.ts +353 -0
- package/src/mesh.ts +130 -0
- package/src/messages.ts +2 -0
- package/src/native-interactions.ts +100 -0
- package/src/observed-status.ts +90 -0
- package/src/orchestrator-prompt.ts +47 -0
- package/src/permission-policy.ts +21 -0
- package/src/provisional-agent-names.ts +272 -0
- package/src/read-receipts.ts +12 -0
- package/src/relay-agent-card.ts +73 -63
- package/src/rendezvous.ts +154 -0
- package/src/reserved-vocabulary.ts +135 -0
- package/src/route-aliases.ts +130 -0
- package/src/runtime-catalog-contract.ts +60 -0
- package/src/runtime-catalog.generated.ts +300 -0
- package/src/runtime-catalog.md +21 -0
- package/src/runtime-catalog.ts +193 -0
- package/src/runtime-catalog.v1.json +81 -0
- package/src/runtime-execution.ts +545 -0
- package/src/runtime-profiles.ts +37 -0
- package/src/scout-agent-card.ts +10 -0
- package/src/scout-composer.ts +249 -0
- package/src/scout-delivery.ts +117 -4
- package/src/scout-dispatch.ts +34 -2
- package/src/scout-reply-context.ts +15 -0
- package/src/session-display-state.ts +202 -0
- package/src/terminal-host-topology.ts +132 -0
- package/src/terminal-sessions.ts +187 -0
- package/src/terminal-surface-id.ts +189 -0
- package/src/terminal-workspaces.ts +455 -0
- package/src/time.ts +49 -0
- package/dist/agent-address.d.ts +0 -1
- package/dist/agent-address.js +0 -1
- package/dist/agent-selectors.d.ts +0 -1
- package/dist/agent-selectors.js +0 -1
- package/src/agent-address.ts +0 -1
- package/src/agent-identity.test.ts +0 -435
- package/src/agent-selectors.ts +0 -1
- package/src/scout-agent-card.test.ts +0 -54
|
@@ -0,0 +1,648 @@
|
|
|
1
|
+
import type { AgentHarness } from "./actors.js";
|
|
2
|
+
import type { MetadataMap, ScoutId } from "./common.js";
|
|
3
|
+
import type { HarnessFeatureSupportMap } from "./harness-feature-support.js";
|
|
4
|
+
|
|
5
|
+
export type ScoutCapabilityProviderKind =
|
|
6
|
+
| "broker"
|
|
7
|
+
| "mcp"
|
|
8
|
+
| "harness"
|
|
9
|
+
| "shell"
|
|
10
|
+
| "app_connector"
|
|
11
|
+
| "extension_pack"
|
|
12
|
+
| "remote_peer"
|
|
13
|
+
| "provider"
|
|
14
|
+
| "model"
|
|
15
|
+
| "runtime_probe";
|
|
16
|
+
|
|
17
|
+
export type ScoutCapabilitySourceKind =
|
|
18
|
+
| "broker"
|
|
19
|
+
| "mcp_server"
|
|
20
|
+
| "harness_adapter"
|
|
21
|
+
| "provider_catalog"
|
|
22
|
+
| "model_catalog"
|
|
23
|
+
| "project_manifest"
|
|
24
|
+
| "extension_pack"
|
|
25
|
+
| "runtime_probe"
|
|
26
|
+
| "observed_execution"
|
|
27
|
+
| "human_annotation";
|
|
28
|
+
|
|
29
|
+
export type ScoutCapabilityEvidenceKind =
|
|
30
|
+
| "protocol_discovery"
|
|
31
|
+
| "adapter_report"
|
|
32
|
+
| "catalog"
|
|
33
|
+
| "project_manifest"
|
|
34
|
+
| "extension_pack"
|
|
35
|
+
| "runtime_probe"
|
|
36
|
+
| "observed_execution"
|
|
37
|
+
| "human_annotation"
|
|
38
|
+
| "upstream";
|
|
39
|
+
|
|
40
|
+
export type ScoutCapabilityEvidenceTrust =
|
|
41
|
+
| "verified"
|
|
42
|
+
| "observed"
|
|
43
|
+
| "declared"
|
|
44
|
+
| "advisory"
|
|
45
|
+
| "unknown";
|
|
46
|
+
|
|
47
|
+
export interface ScoutCapabilityEvidence {
|
|
48
|
+
kind: ScoutCapabilityEvidenceKind;
|
|
49
|
+
ref: string;
|
|
50
|
+
sourceId?: string;
|
|
51
|
+
observedAt?: number;
|
|
52
|
+
protocol?: string;
|
|
53
|
+
protocolVersion?: string;
|
|
54
|
+
trust?: ScoutCapabilityEvidenceTrust;
|
|
55
|
+
metadata?: MetadataMap;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface ScoutCapabilityScope {
|
|
59
|
+
projectRoot?: string;
|
|
60
|
+
workspaceRoot?: string;
|
|
61
|
+
agentId?: ScoutId;
|
|
62
|
+
sessionId?: ScoutId;
|
|
63
|
+
harness?: AgentHarness | (string & {});
|
|
64
|
+
machineId?: ScoutId;
|
|
65
|
+
permissionProfile?: string;
|
|
66
|
+
channelId?: ScoutId;
|
|
67
|
+
environmentId?: ScoutId;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type ScoutCapabilityEffect =
|
|
71
|
+
| "read"
|
|
72
|
+
| "write"
|
|
73
|
+
| "execute"
|
|
74
|
+
| "network"
|
|
75
|
+
| "notify"
|
|
76
|
+
| "admin"
|
|
77
|
+
| "unknown";
|
|
78
|
+
|
|
79
|
+
export interface ScoutCapabilityMethodHints {
|
|
80
|
+
readOnly?: boolean;
|
|
81
|
+
destructive?: boolean;
|
|
82
|
+
idempotent?: boolean;
|
|
83
|
+
openWorld?: boolean;
|
|
84
|
+
annotationsTrusted?: boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface ScoutCapabilityMethod {
|
|
88
|
+
name: string;
|
|
89
|
+
displayName?: string;
|
|
90
|
+
description?: string;
|
|
91
|
+
inputSchema?: unknown;
|
|
92
|
+
outputSchema?: unknown;
|
|
93
|
+
effects: ScoutCapabilityEffect[];
|
|
94
|
+
idempotent?: boolean;
|
|
95
|
+
requiresApproval?: boolean;
|
|
96
|
+
hints?: ScoutCapabilityMethodHints;
|
|
97
|
+
metadata?: MetadataMap;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export type ScoutCapabilityReadinessState =
|
|
101
|
+
| "ready"
|
|
102
|
+
| "degraded"
|
|
103
|
+
| "missing"
|
|
104
|
+
| "disabled"
|
|
105
|
+
| "unknown";
|
|
106
|
+
|
|
107
|
+
export interface ScoutCapabilityReadiness {
|
|
108
|
+
state: ScoutCapabilityReadinessState;
|
|
109
|
+
detail?: string;
|
|
110
|
+
checkedAt?: number;
|
|
111
|
+
missing?: string[];
|
|
112
|
+
evidence?: ScoutCapabilityEvidence[];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export type ScoutCapabilityEnforcementLevel =
|
|
116
|
+
| "broker_native"
|
|
117
|
+
| "mcp_server"
|
|
118
|
+
| "harness_native"
|
|
119
|
+
| "sandbox_native"
|
|
120
|
+
| "container"
|
|
121
|
+
| "remote_authority"
|
|
122
|
+
| "advisory"
|
|
123
|
+
| "unknown";
|
|
124
|
+
|
|
125
|
+
export type ScoutCapabilityPolicyTrust =
|
|
126
|
+
| "enforced"
|
|
127
|
+
| "declared"
|
|
128
|
+
| "advisory"
|
|
129
|
+
| "unknown";
|
|
130
|
+
|
|
131
|
+
export interface ScoutCapabilityEnforcement {
|
|
132
|
+
level: ScoutCapabilityEnforcementLevel;
|
|
133
|
+
trust: ScoutCapabilityPolicyTrust;
|
|
134
|
+
reason?: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface ScoutCapabilityProvenance {
|
|
138
|
+
sourceKind: ScoutCapabilitySourceKind;
|
|
139
|
+
sourceId: string;
|
|
140
|
+
sourceName?: string;
|
|
141
|
+
capturedAt: number;
|
|
142
|
+
protocol?: string;
|
|
143
|
+
protocolVersion?: string;
|
|
144
|
+
evidence?: ScoutCapabilityEvidence[];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface ScoutCapabilityDefinition {
|
|
148
|
+
id: ScoutId;
|
|
149
|
+
name: string;
|
|
150
|
+
displayName: string;
|
|
151
|
+
description?: string;
|
|
152
|
+
provider: ScoutCapabilityProviderKind;
|
|
153
|
+
providerId?: string;
|
|
154
|
+
methods: ScoutCapabilityMethod[];
|
|
155
|
+
scope?: ScoutCapabilityScope;
|
|
156
|
+
readiness: ScoutCapabilityReadiness;
|
|
157
|
+
enforcement: ScoutCapabilityEnforcement;
|
|
158
|
+
provenance: ScoutCapabilityProvenance;
|
|
159
|
+
enabled: boolean;
|
|
160
|
+
version?: string;
|
|
161
|
+
metadata?: MetadataMap;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface ScoutCapabilityMatrixSource {
|
|
165
|
+
kind: ScoutCapabilitySourceKind;
|
|
166
|
+
id: string;
|
|
167
|
+
name?: string;
|
|
168
|
+
capturedAt: number;
|
|
169
|
+
protocol?: string;
|
|
170
|
+
protocolVersion?: string;
|
|
171
|
+
raw?: unknown;
|
|
172
|
+
metadata?: MetadataMap;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export interface ScoutCapabilityMatrixSnapshot {
|
|
176
|
+
generatedAt: number;
|
|
177
|
+
scope?: ScoutCapabilityScope;
|
|
178
|
+
sources: ScoutCapabilityMatrixSource[];
|
|
179
|
+
capabilities: ScoutCapabilityDefinition[];
|
|
180
|
+
harnessSupport?: Record<string, HarnessFeatureSupportMap>;
|
|
181
|
+
warnings: string[];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface McpServerCapabilities {
|
|
185
|
+
tools?: { listChanged?: boolean; [key: string]: unknown } | boolean;
|
|
186
|
+
resources?: { subscribe?: boolean; listChanged?: boolean; [key: string]: unknown } | boolean;
|
|
187
|
+
prompts?: { listChanged?: boolean; [key: string]: unknown } | boolean;
|
|
188
|
+
logging?: Record<string, unknown> | boolean;
|
|
189
|
+
completions?: Record<string, unknown> | boolean;
|
|
190
|
+
tasks?: Record<string, unknown> | boolean;
|
|
191
|
+
[key: string]: unknown;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface McpToolAnnotations {
|
|
195
|
+
title?: string;
|
|
196
|
+
readOnlyHint?: boolean;
|
|
197
|
+
destructiveHint?: boolean;
|
|
198
|
+
idempotentHint?: boolean;
|
|
199
|
+
openWorldHint?: boolean;
|
|
200
|
+
[key: string]: unknown;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface McpToolDefinition {
|
|
204
|
+
name: string;
|
|
205
|
+
title?: string;
|
|
206
|
+
description?: string;
|
|
207
|
+
inputSchema?: unknown;
|
|
208
|
+
outputSchema?: unknown;
|
|
209
|
+
annotations?: McpToolAnnotations;
|
|
210
|
+
icons?: unknown[];
|
|
211
|
+
_meta?: MetadataMap;
|
|
212
|
+
[key: string]: unknown;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export interface McpToolsListResult {
|
|
216
|
+
tools?: readonly McpToolDefinition[];
|
|
217
|
+
nextCursor?: string;
|
|
218
|
+
[key: string]: unknown;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export interface NormalizeMcpToolsOptions {
|
|
222
|
+
serverId: string;
|
|
223
|
+
serverName?: string;
|
|
224
|
+
protocolVersion?: string;
|
|
225
|
+
capturedAt?: number;
|
|
226
|
+
scope?: ScoutCapabilityScope;
|
|
227
|
+
serverCapabilities?: McpServerCapabilities;
|
|
228
|
+
tools: readonly McpToolDefinition[] | McpToolsListResult;
|
|
229
|
+
enabled?: boolean;
|
|
230
|
+
readiness?: Partial<ScoutCapabilityReadiness>;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export type ScoutModelModality =
|
|
234
|
+
| "text"
|
|
235
|
+
| "image"
|
|
236
|
+
| "audio"
|
|
237
|
+
| "video"
|
|
238
|
+
| "file"
|
|
239
|
+
| "embedding"
|
|
240
|
+
| "unknown";
|
|
241
|
+
|
|
242
|
+
export interface ScoutModelFeatureSupport {
|
|
243
|
+
streaming?: boolean;
|
|
244
|
+
toolCalling?: boolean;
|
|
245
|
+
structuredOutput?: boolean;
|
|
246
|
+
embeddings?: boolean;
|
|
247
|
+
usageTelemetry?: boolean;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export interface ScoutModelCatalogEntry {
|
|
251
|
+
providerId: string;
|
|
252
|
+
modelId: string;
|
|
253
|
+
displayName?: string;
|
|
254
|
+
inputModalities?: ScoutModelModality[];
|
|
255
|
+
outputModalities?: ScoutModelModality[];
|
|
256
|
+
features?: ScoutModelFeatureSupport;
|
|
257
|
+
contextWindowTokens?: number;
|
|
258
|
+
maxOutputTokens?: number;
|
|
259
|
+
metadata?: MetadataMap;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface NormalizeModelCatalogOptions {
|
|
263
|
+
sourceId: string;
|
|
264
|
+
sourceName?: string;
|
|
265
|
+
capturedAt?: number;
|
|
266
|
+
scope?: ScoutCapabilityScope;
|
|
267
|
+
models: readonly ScoutModelCatalogEntry[];
|
|
268
|
+
enabled?: boolean;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export type ScoutCapabilityAvailabilityDecision =
|
|
272
|
+
| {
|
|
273
|
+
decision: "allow";
|
|
274
|
+
capabilityId: ScoutId;
|
|
275
|
+
methodName: string;
|
|
276
|
+
reason: string;
|
|
277
|
+
}
|
|
278
|
+
| {
|
|
279
|
+
decision: "deny";
|
|
280
|
+
capabilityId?: ScoutId;
|
|
281
|
+
methodName?: string;
|
|
282
|
+
reason:
|
|
283
|
+
| "capability_missing"
|
|
284
|
+
| "capability_disabled"
|
|
285
|
+
| "method_missing"
|
|
286
|
+
| "readiness_missing"
|
|
287
|
+
| "readiness_disabled";
|
|
288
|
+
detail: string;
|
|
289
|
+
}
|
|
290
|
+
| {
|
|
291
|
+
decision: "require_approval";
|
|
292
|
+
capabilityId: ScoutId;
|
|
293
|
+
methodName: string;
|
|
294
|
+
reason: "method_requires_approval";
|
|
295
|
+
detail: string;
|
|
296
|
+
}
|
|
297
|
+
| {
|
|
298
|
+
decision: "downgrade";
|
|
299
|
+
capabilityId: ScoutId;
|
|
300
|
+
methodName: string;
|
|
301
|
+
reason: "readiness_degraded";
|
|
302
|
+
detail: string;
|
|
303
|
+
}
|
|
304
|
+
| {
|
|
305
|
+
decision: "unknown";
|
|
306
|
+
capabilityId: ScoutId;
|
|
307
|
+
methodName: string;
|
|
308
|
+
reason: "readiness_unknown";
|
|
309
|
+
detail: string;
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
export interface EvaluateScoutCapabilityAvailabilityOptions {
|
|
313
|
+
capabilityId: ScoutId;
|
|
314
|
+
methodName?: string;
|
|
315
|
+
requireReady?: boolean;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export function makeMcpToolCapabilityId(serverId: string, toolName: string): ScoutId {
|
|
319
|
+
return `cap:mcp:${encodeURIComponent(serverId)}:tool:${encodeURIComponent(toolName)}`;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export function makeModelCapabilityId(providerId: string, modelId: string): ScoutId {
|
|
323
|
+
return `cap:model:${encodeURIComponent(providerId)}:${encodeURIComponent(modelId)}`;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export function inferMcpToolEffects(annotations: McpToolAnnotations | undefined): ScoutCapabilityEffect[] {
|
|
327
|
+
const effects: ScoutCapabilityEffect[] = [];
|
|
328
|
+
if (annotations?.readOnlyHint === true) {
|
|
329
|
+
effects.push("read");
|
|
330
|
+
}
|
|
331
|
+
if (annotations?.destructiveHint === true) {
|
|
332
|
+
effects.push("write");
|
|
333
|
+
}
|
|
334
|
+
if (annotations?.openWorldHint === true) {
|
|
335
|
+
effects.push("network");
|
|
336
|
+
}
|
|
337
|
+
return effects.length > 0 ? effects : ["unknown"];
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export function normalizeMcpToolsToScoutCapabilities(options: NormalizeMcpToolsOptions): ScoutCapabilityDefinition[] {
|
|
341
|
+
const capturedAt = options.capturedAt ?? Date.now();
|
|
342
|
+
const tools = getMcpToolDefinitions(options.tools);
|
|
343
|
+
const evidence = buildMcpDiscoveryEvidence(options, capturedAt);
|
|
344
|
+
|
|
345
|
+
return tools
|
|
346
|
+
.filter((tool) => typeof tool.name === "string" && tool.name.trim().length > 0)
|
|
347
|
+
.map((tool) => {
|
|
348
|
+
const toolName = tool.name.trim();
|
|
349
|
+
const annotations = tool.annotations;
|
|
350
|
+
const effects = inferMcpToolEffects(annotations);
|
|
351
|
+
const methodHints = buildMcpMethodHints(annotations);
|
|
352
|
+
const readinessEvidence = [
|
|
353
|
+
evidence,
|
|
354
|
+
...(options.readiness?.evidence ?? []),
|
|
355
|
+
];
|
|
356
|
+
|
|
357
|
+
return {
|
|
358
|
+
id: makeMcpToolCapabilityId(options.serverId, toolName),
|
|
359
|
+
name: `mcp.${options.serverId}.${toolName}`,
|
|
360
|
+
displayName: tool.title ?? annotations?.title ?? toolName,
|
|
361
|
+
description: tool.description,
|
|
362
|
+
provider: "mcp",
|
|
363
|
+
providerId: options.serverId,
|
|
364
|
+
methods: [{
|
|
365
|
+
name: "call",
|
|
366
|
+
displayName: tool.title ?? annotations?.title ?? toolName,
|
|
367
|
+
description: tool.description,
|
|
368
|
+
inputSchema: tool.inputSchema,
|
|
369
|
+
outputSchema: tool.outputSchema,
|
|
370
|
+
effects,
|
|
371
|
+
idempotent: inferMcpIdempotence(annotations),
|
|
372
|
+
requiresApproval: annotations?.destructiveHint === true ? true : undefined,
|
|
373
|
+
hints: methodHints,
|
|
374
|
+
metadata: {
|
|
375
|
+
mcpToolName: toolName,
|
|
376
|
+
},
|
|
377
|
+
}],
|
|
378
|
+
scope: options.scope,
|
|
379
|
+
readiness: {
|
|
380
|
+
state: "unknown",
|
|
381
|
+
detail: "Discovered from MCP tools/list; runtime readiness has not been probed.",
|
|
382
|
+
checkedAt: capturedAt,
|
|
383
|
+
...options.readiness,
|
|
384
|
+
evidence: readinessEvidence,
|
|
385
|
+
},
|
|
386
|
+
enforcement: {
|
|
387
|
+
level: "mcp_server",
|
|
388
|
+
trust: "advisory",
|
|
389
|
+
reason: "MCP tool metadata and annotations are advisory; Scout policy still decides availability.",
|
|
390
|
+
},
|
|
391
|
+
provenance: {
|
|
392
|
+
sourceKind: "mcp_server",
|
|
393
|
+
sourceId: options.serverId,
|
|
394
|
+
sourceName: options.serverName,
|
|
395
|
+
capturedAt,
|
|
396
|
+
protocol: "mcp",
|
|
397
|
+
protocolVersion: options.protocolVersion,
|
|
398
|
+
evidence: [evidence],
|
|
399
|
+
},
|
|
400
|
+
enabled: options.enabled ?? true,
|
|
401
|
+
metadata: {
|
|
402
|
+
mcpServerCapabilities: options.serverCapabilities,
|
|
403
|
+
mcpTool: {
|
|
404
|
+
name: toolName,
|
|
405
|
+
icons: tool.icons,
|
|
406
|
+
meta: tool._meta,
|
|
407
|
+
},
|
|
408
|
+
},
|
|
409
|
+
} satisfies ScoutCapabilityDefinition;
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
export function buildMcpCapabilityMatrixSnapshot(options: NormalizeMcpToolsOptions): ScoutCapabilityMatrixSnapshot {
|
|
414
|
+
const generatedAt = options.capturedAt ?? Date.now();
|
|
415
|
+
const capabilities = normalizeMcpToolsToScoutCapabilities({
|
|
416
|
+
...options,
|
|
417
|
+
capturedAt: generatedAt,
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
return {
|
|
421
|
+
generatedAt,
|
|
422
|
+
scope: options.scope,
|
|
423
|
+
sources: [{
|
|
424
|
+
kind: "mcp_server",
|
|
425
|
+
id: options.serverId,
|
|
426
|
+
name: options.serverName,
|
|
427
|
+
capturedAt: generatedAt,
|
|
428
|
+
protocol: "mcp",
|
|
429
|
+
protocolVersion: options.protocolVersion,
|
|
430
|
+
raw: {
|
|
431
|
+
capabilities: options.serverCapabilities,
|
|
432
|
+
tools: options.tools,
|
|
433
|
+
},
|
|
434
|
+
}],
|
|
435
|
+
capabilities,
|
|
436
|
+
warnings: [],
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
export function normalizeModelCatalogToScoutCapabilities(
|
|
441
|
+
options: NormalizeModelCatalogOptions,
|
|
442
|
+
): ScoutCapabilityDefinition[] {
|
|
443
|
+
const capturedAt = options.capturedAt ?? Date.now();
|
|
444
|
+
const evidence = {
|
|
445
|
+
kind: "catalog" as const,
|
|
446
|
+
ref: `model-catalog:${options.sourceId}`,
|
|
447
|
+
sourceId: options.sourceId,
|
|
448
|
+
observedAt: capturedAt,
|
|
449
|
+
trust: "declared" as const,
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
return options.models
|
|
453
|
+
.filter((model) => model.providerId.trim() && model.modelId.trim())
|
|
454
|
+
.map((model) => {
|
|
455
|
+
const providerId = model.providerId.trim();
|
|
456
|
+
const modelId = model.modelId.trim();
|
|
457
|
+
return {
|
|
458
|
+
id: makeModelCapabilityId(providerId, modelId),
|
|
459
|
+
name: `model.${providerId}.${modelId}`,
|
|
460
|
+
displayName: model.displayName ?? modelId,
|
|
461
|
+
provider: "model",
|
|
462
|
+
providerId,
|
|
463
|
+
methods: [{
|
|
464
|
+
name: "invoke",
|
|
465
|
+
displayName: "Invoke model",
|
|
466
|
+
effects: ["execute"],
|
|
467
|
+
metadata: {
|
|
468
|
+
inputModalities: model.inputModalities ?? ["unknown"],
|
|
469
|
+
outputModalities: model.outputModalities ?? ["unknown"],
|
|
470
|
+
features: model.features ?? {},
|
|
471
|
+
contextWindowTokens: model.contextWindowTokens,
|
|
472
|
+
maxOutputTokens: model.maxOutputTokens,
|
|
473
|
+
},
|
|
474
|
+
}],
|
|
475
|
+
scope: options.scope,
|
|
476
|
+
readiness: {
|
|
477
|
+
state: "unknown",
|
|
478
|
+
detail: "Declared by model catalog; provider readiness has not been probed.",
|
|
479
|
+
checkedAt: capturedAt,
|
|
480
|
+
evidence: [evidence],
|
|
481
|
+
},
|
|
482
|
+
enforcement: {
|
|
483
|
+
level: "remote_authority",
|
|
484
|
+
trust: "declared",
|
|
485
|
+
reason: "Model metadata is catalog-declared; Scout must still verify provider readiness and policy.",
|
|
486
|
+
},
|
|
487
|
+
provenance: {
|
|
488
|
+
sourceKind: "model_catalog",
|
|
489
|
+
sourceId: options.sourceId,
|
|
490
|
+
sourceName: options.sourceName,
|
|
491
|
+
capturedAt,
|
|
492
|
+
evidence: [evidence],
|
|
493
|
+
},
|
|
494
|
+
enabled: options.enabled ?? true,
|
|
495
|
+
metadata: {
|
|
496
|
+
model: {
|
|
497
|
+
providerId,
|
|
498
|
+
modelId,
|
|
499
|
+
inputModalities: model.inputModalities ?? ["unknown"],
|
|
500
|
+
outputModalities: model.outputModalities ?? ["unknown"],
|
|
501
|
+
features: model.features ?? {},
|
|
502
|
+
contextWindowTokens: model.contextWindowTokens,
|
|
503
|
+
maxOutputTokens: model.maxOutputTokens,
|
|
504
|
+
metadata: model.metadata,
|
|
505
|
+
},
|
|
506
|
+
},
|
|
507
|
+
} satisfies ScoutCapabilityDefinition;
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
export function evaluateScoutCapabilityAvailability(
|
|
512
|
+
snapshot: ScoutCapabilityMatrixSnapshot,
|
|
513
|
+
options: EvaluateScoutCapabilityAvailabilityOptions,
|
|
514
|
+
): ScoutCapabilityAvailabilityDecision {
|
|
515
|
+
const capability = snapshot.capabilities.find((candidate) => candidate.id === options.capabilityId);
|
|
516
|
+
if (!capability) {
|
|
517
|
+
return {
|
|
518
|
+
decision: "deny",
|
|
519
|
+
capabilityId: options.capabilityId,
|
|
520
|
+
reason: "capability_missing",
|
|
521
|
+
detail: "Capability is not present in the current matrix snapshot.",
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
if (!capability.enabled) {
|
|
525
|
+
return {
|
|
526
|
+
decision: "deny",
|
|
527
|
+
capabilityId: capability.id,
|
|
528
|
+
reason: "capability_disabled",
|
|
529
|
+
detail: "Capability is disabled in the current matrix snapshot.",
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
const methodName = options.methodName ?? capability.methods[0]?.name;
|
|
534
|
+
const method = methodName ? capability.methods.find((candidate) => candidate.name === methodName) : undefined;
|
|
535
|
+
if (!methodName || !method) {
|
|
536
|
+
return {
|
|
537
|
+
decision: "deny",
|
|
538
|
+
capabilityId: capability.id,
|
|
539
|
+
methodName,
|
|
540
|
+
reason: "method_missing",
|
|
541
|
+
detail: "Requested method is not present on the capability.",
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
if (method.requiresApproval) {
|
|
545
|
+
return {
|
|
546
|
+
decision: "require_approval",
|
|
547
|
+
capabilityId: capability.id,
|
|
548
|
+
methodName,
|
|
549
|
+
reason: "method_requires_approval",
|
|
550
|
+
detail: "Capability method requires operator approval before execution.",
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
switch (capability.readiness.state) {
|
|
555
|
+
case "ready":
|
|
556
|
+
return {
|
|
557
|
+
decision: "allow",
|
|
558
|
+
capabilityId: capability.id,
|
|
559
|
+
methodName,
|
|
560
|
+
reason: "Capability is ready.",
|
|
561
|
+
};
|
|
562
|
+
case "degraded":
|
|
563
|
+
return {
|
|
564
|
+
decision: "downgrade",
|
|
565
|
+
capabilityId: capability.id,
|
|
566
|
+
methodName,
|
|
567
|
+
reason: "readiness_degraded",
|
|
568
|
+
detail: capability.readiness.detail ?? "Capability readiness is degraded.",
|
|
569
|
+
};
|
|
570
|
+
case "missing":
|
|
571
|
+
return {
|
|
572
|
+
decision: "deny",
|
|
573
|
+
capabilityId: capability.id,
|
|
574
|
+
methodName,
|
|
575
|
+
reason: "readiness_missing",
|
|
576
|
+
detail: capability.readiness.detail ?? "Capability readiness is missing.",
|
|
577
|
+
};
|
|
578
|
+
case "disabled":
|
|
579
|
+
return {
|
|
580
|
+
decision: "deny",
|
|
581
|
+
capabilityId: capability.id,
|
|
582
|
+
methodName,
|
|
583
|
+
reason: "readiness_disabled",
|
|
584
|
+
detail: capability.readiness.detail ?? "Capability readiness is disabled.",
|
|
585
|
+
};
|
|
586
|
+
case "unknown":
|
|
587
|
+
if (options.requireReady === false) {
|
|
588
|
+
return {
|
|
589
|
+
decision: "allow",
|
|
590
|
+
capabilityId: capability.id,
|
|
591
|
+
methodName,
|
|
592
|
+
reason: "Capability readiness is unknown but this check does not require ready state.",
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
return {
|
|
596
|
+
decision: "unknown",
|
|
597
|
+
capabilityId: capability.id,
|
|
598
|
+
methodName,
|
|
599
|
+
reason: "readiness_unknown",
|
|
600
|
+
detail: capability.readiness.detail ?? "Capability readiness is unknown.",
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
function getMcpToolDefinitions(tools: NormalizeMcpToolsOptions["tools"]): readonly McpToolDefinition[] {
|
|
606
|
+
return isMcpToolDefinitionArray(tools) ? tools : tools.tools ?? [];
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
function isMcpToolDefinitionArray(
|
|
610
|
+
value: NormalizeMcpToolsOptions["tools"],
|
|
611
|
+
): value is readonly McpToolDefinition[] {
|
|
612
|
+
return Array.isArray(value);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
function buildMcpDiscoveryEvidence(
|
|
616
|
+
options: Pick<NormalizeMcpToolsOptions, "serverId" | "protocolVersion">,
|
|
617
|
+
observedAt: number,
|
|
618
|
+
): ScoutCapabilityEvidence {
|
|
619
|
+
return {
|
|
620
|
+
kind: "protocol_discovery",
|
|
621
|
+
ref: `mcp:${options.serverId}:tools/list`,
|
|
622
|
+
sourceId: options.serverId,
|
|
623
|
+
observedAt,
|
|
624
|
+
protocol: "mcp",
|
|
625
|
+
protocolVersion: options.protocolVersion,
|
|
626
|
+
trust: "declared",
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
function buildMcpMethodHints(annotations: McpToolAnnotations | undefined): ScoutCapabilityMethodHints | undefined {
|
|
631
|
+
if (!annotations) {
|
|
632
|
+
return undefined;
|
|
633
|
+
}
|
|
634
|
+
return {
|
|
635
|
+
readOnly: annotations.readOnlyHint,
|
|
636
|
+
destructive: annotations.destructiveHint,
|
|
637
|
+
idempotent: annotations.idempotentHint,
|
|
638
|
+
openWorld: annotations.openWorldHint,
|
|
639
|
+
annotationsTrusted: false,
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
function inferMcpIdempotence(annotations: McpToolAnnotations | undefined): boolean | undefined {
|
|
644
|
+
if (annotations?.idempotentHint !== undefined) {
|
|
645
|
+
return annotations.idempotentHint;
|
|
646
|
+
}
|
|
647
|
+
return annotations?.readOnlyHint === true ? true : undefined;
|
|
648
|
+
}
|