hmcp-web 0.0.1 → 0.2.0

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 (94) hide show
  1. package/LICENSE +77 -0
  2. package/README.md +49 -2
  3. package/THIRD-PARTY-NOTICES.md +110 -0
  4. package/bin/hmcp-web.js +20 -0
  5. package/dist/api.d.ts +22 -0
  6. package/dist/api.js +1458 -0
  7. package/dist/cli.d.ts +2 -0
  8. package/dist/cli.js +40 -0
  9. package/dist/contracts/onboarding.d.ts +233 -0
  10. package/dist/contracts/onboarding.js +1 -0
  11. package/dist/http.d.ts +72 -0
  12. package/dist/http.js +319 -0
  13. package/dist/index.d.ts +7 -0
  14. package/dist/index.js +7 -0
  15. package/dist/model/app-servers.d.ts +85 -0
  16. package/dist/model/app-servers.js +109 -0
  17. package/dist/model/console-settings.d.ts +37 -0
  18. package/dist/model/console-settings.js +74 -0
  19. package/dist/model/doctor.d.ts +68 -0
  20. package/dist/model/doctor.js +254 -0
  21. package/dist/model/fs-browse.d.ts +9 -0
  22. package/dist/model/fs-browse.js +184 -0
  23. package/dist/model/gateway-config.d.ts +287 -0
  24. package/dist/model/gateway-config.js +760 -0
  25. package/dist/model/import-record.d.ts +80 -0
  26. package/dist/model/import-record.js +179 -0
  27. package/dist/model/metrics.d.ts +65 -0
  28. package/dist/model/metrics.js +213 -0
  29. package/dist/model/oauth-flows.d.ts +60 -0
  30. package/dist/model/oauth-flows.js +79 -0
  31. package/dist/model/pipeline.d.ts +58 -0
  32. package/dist/model/pipeline.js +84 -0
  33. package/dist/model/probe.d.ts +155 -0
  34. package/dist/model/probe.js +385 -0
  35. package/dist/model/process.d.ts +100 -0
  36. package/dist/model/process.js +278 -0
  37. package/dist/model/protection.d.ts +378 -0
  38. package/dist/model/protection.js +470 -0
  39. package/dist/model/registry-cache.d.ts +59 -0
  40. package/dist/model/registry-cache.js +238 -0
  41. package/dist/model/scan.d.ts +48 -0
  42. package/dist/model/scan.js +59 -0
  43. package/dist/model/server.d.ts +127 -0
  44. package/dist/model/server.js +243 -0
  45. package/dist/model/tools.d.ts +61 -0
  46. package/dist/model/tools.js +72 -0
  47. package/dist/routes/catalog.d.ts +8 -0
  48. package/dist/routes/catalog.js +47 -0
  49. package/dist/routes/connect-import.d.ts +9 -0
  50. package/dist/routes/connect-import.js +594 -0
  51. package/dist/routes/connect.d.ts +50 -0
  52. package/dist/routes/connect.js +691 -0
  53. package/dist/routes/github.d.ts +97 -0
  54. package/dist/routes/github.js +587 -0
  55. package/dist/routes/guard.d.ts +3 -0
  56. package/dist/routes/guard.js +166 -0
  57. package/dist/routes/oauth.d.ts +55 -0
  58. package/dist/routes/oauth.js +406 -0
  59. package/dist/routes/policy.d.ts +34 -0
  60. package/dist/routes/policy.js +513 -0
  61. package/dist/routes/runtime.d.ts +12 -0
  62. package/dist/routes/runtime.js +921 -0
  63. package/dist/routes/servers-add.d.ts +32 -0
  64. package/dist/routes/servers-add.js +1091 -0
  65. package/dist/routes/system.d.ts +4 -0
  66. package/dist/routes/system.js +13 -0
  67. package/dist/start.d.ts +56 -0
  68. package/dist/start.js +164 -0
  69. package/dist-ui/assets/Activity-CZ78RyRO.js +1 -0
  70. package/dist-ui/assets/Approvals-DPIlNZsv.js +1 -0
  71. package/dist-ui/assets/AttachApp-DjSeWCbS.js +5 -0
  72. package/dist-ui/assets/Connections-qcA96lXh.js +2 -0
  73. package/dist-ui/assets/Gallery-DB_OO7Vw.js +17 -0
  74. package/dist-ui/assets/PreApprovals-C4cKajcK.js +1 -0
  75. package/dist-ui/assets/Protection-B8h-5YAb.js +1 -0
  76. package/dist-ui/assets/Safety-BQqHyYdo.js +1 -0
  77. package/dist-ui/assets/Settings-Cx50zZSt.js +1 -0
  78. package/dist-ui/assets/StartPage-CdX-v7ej.js +1 -0
  79. package/dist-ui/assets/Suggestions-CRo5UOTT.js +1 -0
  80. package/dist-ui/assets/Tools-xo39lPKB.js +4 -0
  81. package/dist-ui/assets/index-DttDjRpu.js +16 -0
  82. package/dist-ui/assets/index-QeJyD5z2.css +2 -0
  83. package/dist-ui/assets/kit-DRVm92_t.js +4 -0
  84. package/dist-ui/brand/logo-256.png +0 -0
  85. package/dist-ui/brand/logo-512.png +0 -0
  86. package/dist-ui/brand/logo.svg +6 -0
  87. package/dist-ui/brand/mark.svg +5 -0
  88. package/dist-ui/fonts/OFL.txt +99 -0
  89. package/dist-ui/fonts/README.md +21 -0
  90. package/dist-ui/fonts/jetbrainsmono-latin.woff2 +0 -0
  91. package/dist-ui/fonts/manrope-latin.woff2 +0 -0
  92. package/dist-ui/index.html +51 -0
  93. package/package.json +69 -6
  94. package/bin/notice.js +0 -7
@@ -0,0 +1,378 @@
1
+ import { type Decision, type StandingGrantRow, type ArgConstraint, type ToolSurfaceEntry } from "hmcp-core";
2
+ import { type LoadedServer } from "./server.js";
3
+ import { ENFORCEMENT_PIPELINE } from "./pipeline.js";
4
+ import { type ToolSurfaceView } from "./tools.js";
5
+ /**
6
+ * The protection view model.
7
+ *
8
+ * Every statement here is derived from this gateway's own configuration and the
9
+ * surface it published. The one exception is `ENFORCEMENT_PIPELINE`, which
10
+ * describes the gateway's code rather than the user's settings and is therefore
11
+ * the only thing that can honestly be written ahead of time.
12
+ */
13
+ export interface ToolProtection {
14
+ readonly name: string;
15
+ /** What the model is told, after any rewriting of the upstream's own text. */
16
+ readonly description: string;
17
+ /** The upstream's own text. Differs from `description` when it was rewritten. */
18
+ readonly rawDescription: string;
19
+ /** Which upstream server advertises this tool. */
20
+ readonly upstream: string;
21
+ /** Null when the gateway could not classify it, in which case it is refused. */
22
+ readonly effect: string | null;
23
+ /** How the effect was decided: policy, annotation, name, or unclassified. */
24
+ readonly effectSource: string;
25
+ /**
26
+ * Hidden from every tenant by gateway policy — `on_injection: deny` found
27
+ * injected instructions in the upstream's text. Distinct from `exposure`,
28
+ * which is one tenant's switch and is theirs to reverse.
29
+ */
30
+ readonly hiddenByPolicy: boolean;
31
+ /** Injection pattern ids found in the upstream's advertised text. */
32
+ readonly injection: readonly string[] | null;
33
+ /**
34
+ * What `decide()` says about this tool with no particular call in mind.
35
+ *
36
+ * Asked with `argsUnknown`, because "what would happen to a call carrying no
37
+ * arguments" is a different question: a rule bounding `amount` refuses a
38
+ * call that omits it, and reporting a bounded tool as refused in a listing
39
+ * where no call exists would describe a tool nobody can call. `bounds` below
40
+ * is the other half of the answer.
41
+ */
42
+ readonly verdict: {
43
+ kind: Decision["kind"];
44
+ ruleId: string;
45
+ reason: string;
46
+ };
47
+ /**
48
+ * The argument bounds standing between this verdict and a real call, when
49
+ * the matched rule sets any. Null when the rule bounds nothing, in which
50
+ * case `verdict` is the whole story.
51
+ */
52
+ readonly bounds: {
53
+ readonly ruleId: string;
54
+ /** The argument paths the rule bounds, as written in the policy. */
55
+ readonly paths: readonly string[];
56
+ /**
57
+ * The bounds themselves, not only which arguments carry one.
58
+ *
59
+ * Without the values the console can say a tool is bounded on `body` and
60
+ * not that the bound is 120 characters — which is the thing a reviewer is
61
+ * deciding about, and what an editor must pre-fill so that opening it and
62
+ * saving does not silently change it.
63
+ */
64
+ readonly constraints: Readonly<Record<string, ArgConstraint>>;
65
+ /** What an out-of-bounds call gets: refused, or held for a human. */
66
+ readonly onViolation: "deny" | "approve";
67
+ /** What an argument no bound claims gets. */
68
+ readonly unknownArgs: "allow" | "deny" | "approve";
69
+ } | null;
70
+ /** Which stage of `decide()` produced the verdict. */
71
+ readonly verdictStage: string;
72
+ /** Set when a policy rule reclassifies the effect the tool was built with. */
73
+ readonly reclassifiedTo: string | null;
74
+ /**
75
+ * The rule deciding this tool was written from the console or the CLI rather
76
+ * than by hand, so it can be changed and reverted from here.
77
+ *
78
+ * Follows the page's existing convention of tagging the non-default: a tool
79
+ * nobody has touched shows nothing.
80
+ */
81
+ readonly consoleRule: {
82
+ readonly ruleId: string;
83
+ } | null;
84
+ /**
85
+ * The rule this console's own rule displaced now bounds the tool differently
86
+ * from the copy that was taken of it.
87
+ *
88
+ * A console rule carries a *copy* of the bounds it displaced, because
89
+ * `decide()` reads the decision and the bounds from one rule and a rule
90
+ * placed above a bounding one would otherwise unbound the tool. A copy does
91
+ * not follow the original, so this is the one way the two can drift apart —
92
+ * and nothing else would say so.
93
+ *
94
+ * Derived from the policy each time rather than stored, so it cannot itself
95
+ * go stale. It is a statement about two rules, not a verdict: someone may
96
+ * have chosen different bounds here deliberately, which is why the console
97
+ * offers to take the newer ones rather than doing it.
98
+ */
99
+ readonly boundsDrift: {
100
+ readonly ruleId: string;
101
+ readonly differences: readonly string[];
102
+ } | null;
103
+ /** Advertised but unrunnable: approval required, approvals disabled. */
104
+ readonly unreachable: boolean;
105
+ readonly requiresApproval: boolean;
106
+ /**
107
+ * The console's exposure switch for this tool.
108
+ *
109
+ * `verdict` above deliberately stays the *policy* verdict even while a tool
110
+ * is switched off, so the console can still say what policy would do and a
111
+ * reviewer can see what turning the switch back on would restore.
112
+ */
113
+ readonly exposure: {
114
+ readonly disabled: boolean;
115
+ readonly setBy: string | null;
116
+ readonly setAt: number | null;
117
+ readonly reason: string | null;
118
+ /**
119
+ * Whether clearing the override would actually expose the tool. False when
120
+ * policy refuses it anyway, in which case the switch has nothing to turn
121
+ * on and the console says so rather than offering a no-op.
122
+ */
123
+ readonly policyWouldExpose: boolean;
124
+ };
125
+ readonly args: readonly {
126
+ readonly name: string;
127
+ readonly type: string | undefined;
128
+ readonly required: boolean;
129
+ readonly description: string | undefined;
130
+ readonly constrainedByRule: string | null;
131
+ /** The values the upstream said it accepts, or null where it named none. */
132
+ readonly enumValues: readonly string[] | null;
133
+ /** `format`, verbatim. `uri` is the one that says this argument is dialled. */
134
+ readonly format: string | undefined;
135
+ /**
136
+ * The value the upstream fills in when the model supplies none, rendered
137
+ * for display. Carried because an argument with a default is an argument
138
+ * the model can leave out and still cause something to happen.
139
+ */
140
+ readonly defaultValue: string | null;
141
+ /**
142
+ * Whether that default is an absolute `http(s)` URL.
143
+ *
144
+ * Worth its own field rather than left for the reader to spot. A default
145
+ * URL is a network destination chosen by the upstream, reachable by a
146
+ * call that names no arguments at all, and `policy.egress` does not bound
147
+ * it: the egress guard governs what *this* gateway dials, so a stdio
148
+ * upstream fetching it is outside the allowlist entirely.
149
+ */
150
+ readonly defaultIsUrl: boolean;
151
+ }[];
152
+ /**
153
+ * Whether the upstream declared its argument object closed.
154
+ *
155
+ * Three states, because `additionalProperties` absent is not the same claim
156
+ * as `additionalProperties: false`, and almost no MCP server emits either:
157
+ * the schemas most servers generate simply leave it out. Reading absent as
158
+ * "open" meant every tool on every gateway carried the same warning, which
159
+ * is no signal at all — the scanner has always flagged only an explicit
160
+ * `true`, and this is now consistent with it.
161
+ *
162
+ * `true` closed, `false` explicitly open, `null` the upstream did not say.
163
+ */
164
+ readonly schemaClosed: boolean | null;
165
+ readonly standingGrants: readonly {
166
+ readonly grantId: string;
167
+ readonly reason: string;
168
+ /**
169
+ * Whether the grant reaches this tool at all. About the tool and its
170
+ * effect, because a grant is weighed against a call and there is no call
171
+ * here: `heldBounds` carries what its bounds leave behind.
172
+ */
173
+ readonly covers: boolean;
174
+ readonly why: string;
175
+ /**
176
+ * The governing rule's bounds this grant does not bound, so a call held
177
+ * over one of them still waits for a person however well the grant
178
+ * matches.
179
+ */
180
+ readonly heldBounds: readonly string[];
181
+ readonly uses: number;
182
+ readonly maxUses: number | null;
183
+ readonly expiresAt: number;
184
+ }[];
185
+ }
186
+ export interface ServerProtection {
187
+ readonly id: string;
188
+ readonly label: string;
189
+ readonly kind: string;
190
+ /**
191
+ * Which tenant every scoped number below describes.
192
+ *
193
+ * Carried so the page cannot present one tenant's exposure, queue and reach
194
+ * as the gateway's. `explicitTenant` says whether the request named it or the
195
+ * console read it from the deployment's own configuration.
196
+ */
197
+ readonly tenant_scope: string;
198
+ readonly explicitTenant: boolean;
199
+ /** `defaults.mode` as written in the policy: the fallback, not the surface. */
200
+ readonly posture: string;
201
+ /** What is actually reachable, or null when the surface is unknown. */
202
+ readonly reach: Reach | null;
203
+ /**
204
+ * Where the tool list came from and whether it can be believed.
205
+ *
206
+ * A gateway's surface is published by a running process, so "no tools" has
207
+ * two very different meanings — a gateway serving nothing, and a gateway that
208
+ * has not told us anything. Every consumer needs to tell those apart, so the
209
+ * provenance travels with the numbers rather than being inferred from them.
210
+ */
211
+ readonly surface: {
212
+ readonly live: boolean;
213
+ readonly stale: boolean;
214
+ readonly neverPublished: boolean;
215
+ readonly publishedAt: number | null;
216
+ readonly toolCount: number;
217
+ /** Tools whose upstream text carried injected instructions. */
218
+ readonly injectionCount: number;
219
+ /** Tools gateway policy hides from every tenant. */
220
+ readonly hiddenCount: number;
221
+ /** Tools the gateway could not classify, which it refuses. */
222
+ readonly unclassifiedCount: number;
223
+ };
224
+ readonly onUnclassified: string;
225
+ /**
226
+ * The settings the Protection settings page edits that had no field here:
227
+ * whether policy is applied or only recorded, what a changed tool gets,
228
+ * what result scanning does, and both defaults together.
229
+ */
230
+ readonly enforcement: "enforce" | "observe";
231
+ readonly onToolChange: "warn" | "deny";
232
+ readonly results: {
233
+ readonly onInjection: string;
234
+ readonly onSecret: string;
235
+ };
236
+ readonly defaults: {
237
+ readonly mode: string;
238
+ readonly onUnclassified: string;
239
+ };
240
+ /** Whether a classification can be written here, and the digest to write against. */
241
+ readonly policyWrite: {
242
+ readonly ok: boolean;
243
+ readonly why: string | null;
244
+ readonly path: string | null;
245
+ readonly digest: string;
246
+ readonly overrides: boolean;
247
+ };
248
+ readonly toolBudget: {
249
+ budget: number;
250
+ enabled: number;
251
+ ok: boolean;
252
+ };
253
+ readonly rules: readonly {
254
+ readonly id: string;
255
+ readonly match: string;
256
+ readonly decision: string;
257
+ readonly effect: string | null;
258
+ readonly reason: string | null;
259
+ /** The argument paths this rule bounds, as written in the policy. */
260
+ readonly argConstraints: readonly string[];
261
+ /**
262
+ * What an out-of-bounds call gets, and what an argument no bound claims
263
+ * gets. Carried because "this rule bounds `amount`" does not say whether
264
+ * exceeding it is refused or held, and because a rule that bounds one
265
+ * argument while leaving `unknown_args: allow` protects less than the list
266
+ * of bounds suggests.
267
+ */
268
+ readonly onViolation: string;
269
+ readonly unknownArgs: string;
270
+ readonly matchedTools: readonly string[];
271
+ /** An earlier rule already claims every tool this one matches. */
272
+ readonly shadowedBy: string | null;
273
+ }[];
274
+ readonly tenant: {
275
+ readonly field: string;
276
+ readonly aliases: readonly string[];
277
+ readonly sourceKind: string;
278
+ readonly sourceName: string | null;
279
+ readonly sourceProse: string;
280
+ readonly inject: readonly string[];
281
+ readonly onMismatch: string;
282
+ readonly required: boolean;
283
+ readonly resolved: boolean;
284
+ readonly error: string | null;
285
+ } | null;
286
+ readonly egress: {
287
+ readonly allow: readonly string[];
288
+ readonly methods: readonly string[];
289
+ readonly maxBodyBytes: number;
290
+ readonly maxRequestBodyBytes: number;
291
+ readonly timeoutMs: number;
292
+ readonly maxRedirects: number;
293
+ readonly blockPrivateIps: boolean;
294
+ readonly allowHttp: boolean;
295
+ readonly allowIpLiterals: boolean;
296
+ };
297
+ readonly approvals: {
298
+ readonly mode: string;
299
+ readonly ttlSeconds: number;
300
+ readonly singleUse: boolean;
301
+ readonly storePath: string;
302
+ readonly pendingCount: number;
303
+ readonly activeGrantCount: number;
304
+ /** Requests in the same store that belong to some other server. */
305
+ readonly pendingElsewhere: number;
306
+ };
307
+ readonly audit: {
308
+ readonly enabled: boolean;
309
+ readonly path: string;
310
+ readonly hashChain: boolean;
311
+ readonly recordArgs: boolean;
312
+ readonly redact: readonly string[];
313
+ /** What happens to a permitted call when its record cannot be written. */
314
+ readonly onFailure: "refuse" | "continue";
315
+ /**
316
+ * `written: false` means the log does not exist yet, which is the normal
317
+ * state of a server that has not run. Without it a brand-new server looks
318
+ * like one whose chain has been tampered with.
319
+ */
320
+ readonly verify: {
321
+ ok: boolean;
322
+ written: boolean;
323
+ count: number;
324
+ problemCount: number;
325
+ };
326
+ };
327
+ /**
328
+ * Whether what is shown here is what a running server is enforcing.
329
+ *
330
+ * Everything else on this object is read from disk on every request, so it
331
+ * is always current as to the files. A running server is not: it parsed its
332
+ * policy at startup and holds that copy. `applied: false` means those two
333
+ * have diverged and the page is describing a configuration that is not in
334
+ * force — the one state in which these numbers can be confidently wrong.
335
+ */
336
+ readonly runtime: {
337
+ /** A live server has announced itself and refreshed within the TTL. */
338
+ readonly running: boolean;
339
+ /** Epoch ms, as every other timestamp the UI formats. */
340
+ readonly startedAt: number | null;
341
+ /**
342
+ * `null` when nothing is running: not knowing whether the on-disk policy
343
+ * is in force is a different claim from knowing that it is not.
344
+ */
345
+ readonly policyApplied: boolean | null;
346
+ readonly policyPath: string | null;
347
+ };
348
+ readonly pipeline: typeof ENFORCEMENT_PIPELINE;
349
+ readonly tools: readonly ToolProtection[];
350
+ }
351
+ /**
352
+ * What the model can actually do on this server right now.
353
+ *
354
+ * Not to be confused with `posture`, which is `defaults.mode` from the policy
355
+ * file: that is only the fallback for a call no rule matched. A server can
356
+ * declare `read-only` and still hand the model a dozen writes through explicit
357
+ * rules, which is precisely what the console used to misreport — it printed the
358
+ * declared default and let the reader assume it described the surface.
359
+ *
360
+ * This asks the narrower question a reader is actually asking when they glance
361
+ * at the chrome: of everything advertised, what can run? It is taken from the
362
+ * same `decide()` the runtime uses, with the console's own switches subtracted,
363
+ * so it cannot drift from what the server would really do.
364
+ */
365
+ export type Reach = "read-only" | "approve-writes" | "locked";
366
+ /**
367
+ * `null` when the surface is unknown, which is not the same as `"locked"`.
368
+ *
369
+ * A gateway that has never published, or whose process is gone, tells us
370
+ * nothing about what is reachable. Reporting `"locked"` for that case — which
371
+ * is what deriving reach from an empty tool list used to do — states that
372
+ * nothing can run, about a gateway that may be serving every tool it has.
373
+ */
374
+ export declare function effectiveReach(server: LoadedServer, tenant: string, surface?: ToolSurfaceView): Reach | null;
375
+ export declare function toolProtection(server: LoadedServer, tool: ToolSurfaceEntry, grants: readonly StandingGrantRow[]): ToolProtection;
376
+ export declare function buildProtection(server: LoadedServer, tenant: string, explicit?: boolean): ServerProtection;
377
+ /** The last few decisions recorded for one tool. */
378
+ export declare function recentActivity(server: LoadedServer, tool: string, limit?: number, otherComponents?: readonly string[]): import("hmcp-core").AuditRecord[];