hmcp-web 0.0.0-stage → 0.1.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.
- package/LICENSE +77 -0
- package/README.md +50 -2
- package/THIRD-PARTY-NOTICES.md +110 -0
- package/bin/hmcp-web.js +20 -0
- package/dist/api.d.ts +11 -0
- package/dist/api.js +1404 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +40 -0
- package/dist/contracts/onboarding.d.ts +233 -0
- package/dist/contracts/onboarding.js +1 -0
- package/dist/http.d.ts +72 -0
- package/dist/http.js +319 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/model/console-settings.d.ts +37 -0
- package/dist/model/console-settings.js +74 -0
- package/dist/model/doctor.d.ts +68 -0
- package/dist/model/doctor.js +254 -0
- package/dist/model/fs-browse.d.ts +9 -0
- package/dist/model/fs-browse.js +184 -0
- package/dist/model/gateway-config.d.ts +287 -0
- package/dist/model/gateway-config.js +760 -0
- package/dist/model/metrics.d.ts +65 -0
- package/dist/model/metrics.js +198 -0
- package/dist/model/oauth-flows.d.ts +60 -0
- package/dist/model/oauth-flows.js +79 -0
- package/dist/model/pipeline.d.ts +58 -0
- package/dist/model/pipeline.js +84 -0
- package/dist/model/probe.d.ts +155 -0
- package/dist/model/probe.js +385 -0
- package/dist/model/process.d.ts +100 -0
- package/dist/model/process.js +278 -0
- package/dist/model/protection.d.ts +378 -0
- package/dist/model/protection.js +470 -0
- package/dist/model/registry-cache.d.ts +59 -0
- package/dist/model/registry-cache.js +238 -0
- package/dist/model/scan.d.ts +48 -0
- package/dist/model/scan.js +59 -0
- package/dist/model/server.d.ts +127 -0
- package/dist/model/server.js +243 -0
- package/dist/model/tools.d.ts +61 -0
- package/dist/model/tools.js +72 -0
- package/dist/routes/catalog.d.ts +8 -0
- package/dist/routes/catalog.js +47 -0
- package/dist/routes/connect.d.ts +14 -0
- package/dist/routes/connect.js +633 -0
- package/dist/routes/oauth.d.ts +55 -0
- package/dist/routes/oauth.js +406 -0
- package/dist/routes/policy.d.ts +34 -0
- package/dist/routes/policy.js +513 -0
- package/dist/routes/runtime.d.ts +6 -0
- package/dist/routes/runtime.js +921 -0
- package/dist/routes/servers-add.d.ts +24 -0
- package/dist/routes/servers-add.js +1091 -0
- package/dist/routes/system.d.ts +4 -0
- package/dist/routes/system.js +13 -0
- package/dist/start.d.ts +56 -0
- package/dist/start.js +164 -0
- package/dist-ui/assets/Activity-BqKGpXMN.js +1 -0
- package/dist-ui/assets/Approvals-Qo7bCcli.js +1 -0
- package/dist-ui/assets/AttachApp-0zRSPgSY.js +5 -0
- package/dist-ui/assets/Connections-CE0JGe8c.js +2 -0
- package/dist-ui/assets/Gallery-B39L2Yma.js +17 -0
- package/dist-ui/assets/PreApprovals-BsIhjMqb.js +1 -0
- package/dist-ui/assets/Protection-DlB09ABa.js +1 -0
- package/dist-ui/assets/Safety-CN-oHO2h.js +1 -0
- package/dist-ui/assets/Settings-BLD7G1Ag.js +1 -0
- package/dist-ui/assets/StartPage-HuZSnmSr.js +1 -0
- package/dist-ui/assets/Suggestions-Dp7pofcs.js +1 -0
- package/dist-ui/assets/Tools-Bfot3bx5.js +4 -0
- package/dist-ui/assets/index-Khp0l1zp.js +16 -0
- package/dist-ui/assets/index-Ylyt4DEr.css +2 -0
- package/dist-ui/assets/kit-DQ7Oxf5n.js +4 -0
- package/dist-ui/brand/logo-256.png +0 -0
- package/dist-ui/brand/logo-512.png +0 -0
- package/dist-ui/brand/logo.svg +6 -0
- package/dist-ui/brand/mark.svg +5 -0
- package/dist-ui/fonts/OFL.txt +99 -0
- package/dist-ui/fonts/README.md +21 -0
- package/dist-ui/fonts/jetbrainsmono-latin.woff2 +0 -0
- package/dist-ui/fonts/manrope-latin.woff2 +0 -0
- package/dist-ui/index.html +51 -0
- package/package.json +71 -4
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { type ApprovalStore, type LiveConfigStateRow } from "hmcp-core";
|
|
2
|
+
import { type GatewayConfig, type Upstream } from "hmcp-gateway";
|
|
3
|
+
/**
|
|
4
|
+
* Editing `gateway.yaml` from the console.
|
|
5
|
+
*
|
|
6
|
+
* Every write here goes through `commitGatewayText`, which is the whole of the
|
|
7
|
+
* boundary: a digest lock, YAML that parses, a config the gateway's own schema
|
|
8
|
+
* accepts, the two settings that decide whether the console may write policy
|
|
9
|
+
* at all left exactly as they were, the policy itself left alone, and an
|
|
10
|
+
* acknowledgement for any change that widens what reaches the model. Edits are
|
|
11
|
+
* made through the `yaml` Document API, so comments and layout around the
|
|
12
|
+
* edited node survive.
|
|
13
|
+
*
|
|
14
|
+
* A running gateway with `upstream_reload` (the default) applies a change to
|
|
15
|
+
* `upstreams` live; any other change still waits for its next start. Which of
|
|
16
|
+
* the two happened is read from what the running processes report -- see
|
|
17
|
+
* `applyState` in routes/runtime.ts.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* What the console shows in place of an upstream header or env value.
|
|
21
|
+
*
|
|
22
|
+
* Those two maps are where credentials live in this file, and the console does
|
|
23
|
+
* not echo a credential back over its API. A value left as this marker on a
|
|
24
|
+
* save keeps whatever is on disk for the same upstream and key.
|
|
25
|
+
*/
|
|
26
|
+
export declare const KEPT_SECRET = "[kept secret]";
|
|
27
|
+
/** The two settings no console write may change. See `assertGuardsUnchanged`. */
|
|
28
|
+
export declare const GUARDED_SETTINGS: readonly ["policy_writes", "policy_overrides"];
|
|
29
|
+
export interface GatewayFile {
|
|
30
|
+
readonly path: string;
|
|
31
|
+
readonly text: string;
|
|
32
|
+
readonly digest: string;
|
|
33
|
+
readonly config: GatewayConfig;
|
|
34
|
+
}
|
|
35
|
+
export declare function digestText(text: string): string;
|
|
36
|
+
export declare function readGatewayFile(path: string): GatewayFile;
|
|
37
|
+
/**
|
|
38
|
+
* A gateway.yaml the schema rejects, read so it can be repaired.
|
|
39
|
+
*
|
|
40
|
+
* `text` is null when the file is not even YAML: the credential markers are
|
|
41
|
+
* found by walking the YAML document, so text that does not parse cannot be
|
|
42
|
+
* redacted, and is never sent to the browser.
|
|
43
|
+
*/
|
|
44
|
+
export interface BrokenGatewayFile {
|
|
45
|
+
readonly path: string;
|
|
46
|
+
readonly text: string | null;
|
|
47
|
+
readonly digest: string;
|
|
48
|
+
readonly error: string;
|
|
49
|
+
}
|
|
50
|
+
/** The file when it is valid, or what is wrong with it when it is not. */
|
|
51
|
+
export declare function readGatewayFileOrBroken(path: string): GatewayFile | BrokenGatewayFile;
|
|
52
|
+
export declare function isBroken(file: GatewayFile | BrokenGatewayFile): file is BrokenGatewayFile;
|
|
53
|
+
/**
|
|
54
|
+
* Repairs a gateway.yaml the schema rejects.
|
|
55
|
+
*
|
|
56
|
+
* The usual checks compare against the parsed config before the edit, and a
|
|
57
|
+
* broken file has none, so this path holds the line differently:
|
|
58
|
+
* - the broken text must still be YAML, so the guards' values on disk can be
|
|
59
|
+
* read from it (a file that is not even YAML is refused: there is nothing
|
|
60
|
+
* to compare the guards against);
|
|
61
|
+
* - `policy_writes`, `policy_overrides` and `policy:` must come out exactly as
|
|
62
|
+
* the broken file has them, reading an absent guard as its schema default;
|
|
63
|
+
* - the save always counts as loosening, because what it widens cannot be
|
|
64
|
+
* computed against a file the gateway could not load.
|
|
65
|
+
*/
|
|
66
|
+
export declare function repairGatewayText(args: {
|
|
67
|
+
file: BrokenGatewayFile;
|
|
68
|
+
text: string;
|
|
69
|
+
expectedDigest: string;
|
|
70
|
+
acknowledgedLoosens: boolean;
|
|
71
|
+
}): {
|
|
72
|
+
after: GatewayConfig;
|
|
73
|
+
previousDigest: string;
|
|
74
|
+
digest: string;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* The file as the console shows it: byte for byte, except that each credential
|
|
78
|
+
* value is replaced in place by the marker. Done on source ranges rather than
|
|
79
|
+
* by re-serialising, so what the editor shows is the file's own layout.
|
|
80
|
+
*/
|
|
81
|
+
export declare function redactText(text: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* The redaction for a file the schema rejects: everything `conservativeSites`
|
|
84
|
+
* finds, as well as everything `redactText` would.
|
|
85
|
+
*/
|
|
86
|
+
export declare function redactBrokenText(text: string): string;
|
|
87
|
+
export declare function redactUpstream(upstream: Upstream): Upstream;
|
|
88
|
+
export declare function redactConfig(config: GatewayConfig): GatewayConfig;
|
|
89
|
+
/**
|
|
90
|
+
* Puts the real values back wherever the marker was left in a submitted text.
|
|
91
|
+
*
|
|
92
|
+
* Copied from the current file's own source, so a credential never passes
|
|
93
|
+
* through the browser in either direction. A marker with nothing to keep -- an
|
|
94
|
+
* upstream or key that does not exist on disk -- is refused, rather than
|
|
95
|
+
* written as the literal word.
|
|
96
|
+
*/
|
|
97
|
+
export declare function restoreSecretsInText(submitted: string, current: string): string;
|
|
98
|
+
/** The same, for an upstream submitted as an object. */
|
|
99
|
+
export declare function restoreSecretsInUpstream(submitted: Upstream, current: Upstream | undefined): Upstream;
|
|
100
|
+
/**
|
|
101
|
+
* Every way a change widens what this gateway lets through, in plain words.
|
|
102
|
+
*
|
|
103
|
+
* Each one needs `acknowledged.loosens`. They are the changes where a person
|
|
104
|
+
* clicking through a form could make the gateway quietly protect less: a
|
|
105
|
+
* weaker answer to a poisoned description, a renamed gateway or tool set that
|
|
106
|
+
* strands every switch and pin stored under the old names, and credentials or
|
|
107
|
+
* environment handed to a server that did not have them.
|
|
108
|
+
*/
|
|
109
|
+
export declare function gatewayLoosens(before: GatewayConfig, after: GatewayConfig): string[];
|
|
110
|
+
export interface CommitResult {
|
|
111
|
+
readonly before: GatewayConfig;
|
|
112
|
+
readonly after: GatewayConfig;
|
|
113
|
+
readonly previousDigest: string;
|
|
114
|
+
readonly digest: string;
|
|
115
|
+
readonly loosens: string[];
|
|
116
|
+
}
|
|
117
|
+
/** Parses and validates text as a gateway config, or says why it is not one. */
|
|
118
|
+
export declare function parseGatewayText(text: string): GatewayConfig;
|
|
119
|
+
/**
|
|
120
|
+
* The guard on the guard.
|
|
121
|
+
*
|
|
122
|
+
* `policy_writes` and `policy_overrides` decide whether this console may write
|
|
123
|
+
* policy at all. A console that could change them would be granting itself
|
|
124
|
+
* permission, so no write from here may, in either direction -- tightening
|
|
125
|
+
* them is a reviewed edit to the file too.
|
|
126
|
+
*/
|
|
127
|
+
export declare function assertGuardsUnchanged(before: GatewayConfig, after: GatewayConfig): void;
|
|
128
|
+
/**
|
|
129
|
+
* The one place a gateway.yaml is written from the console.
|
|
130
|
+
*
|
|
131
|
+
* `intended` is the caller's own assertion that nothing outside the part it
|
|
132
|
+
* meant to change has changed: a check on the parsed result rather than on the
|
|
133
|
+
* edit, so a Document API surprise cannot widen a write.
|
|
134
|
+
*/
|
|
135
|
+
export declare function commitGatewayText(args: {
|
|
136
|
+
file: GatewayFile;
|
|
137
|
+
text: string;
|
|
138
|
+
expectedDigest: string;
|
|
139
|
+
acknowledgedLoosens: boolean;
|
|
140
|
+
intended?: (before: GatewayConfig, after: GatewayConfig) => string | null;
|
|
141
|
+
}): CommitResult;
|
|
142
|
+
/** Every top-level key but these, canonicalised, for an "only this changed" check. */
|
|
143
|
+
export declare function sameExcept(before: GatewayConfig, after: GatewayConfig, keys: readonly string[]): boolean;
|
|
144
|
+
export interface DiffLine {
|
|
145
|
+
readonly op: " " | "+" | "-";
|
|
146
|
+
readonly line: string;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* A line diff, for a preview, as a flat op/line list: the gateway editor's
|
|
150
|
+
* shape. The policy editor's diff is hunked instead -- see `lineDiff` in
|
|
151
|
+
* routes/policy.ts. Longest common subsequence, which is quadratic,
|
|
152
|
+
* so a pair of files too large for it falls back to "all removed, all added" --
|
|
153
|
+
* still correct, just less helpful.
|
|
154
|
+
*/
|
|
155
|
+
export declare function lineDiff(a: string, b: string): DiffLine[];
|
|
156
|
+
/**
|
|
157
|
+
* What adding a server needs from the policy beside it: its address allowed,
|
|
158
|
+
* POST allowed (opening a Streamable HTTP session is a POST), private
|
|
159
|
+
* addresses allowed for a server on this computer, and the ready-made rules
|
|
160
|
+
* for it.
|
|
161
|
+
*/
|
|
162
|
+
export type PolicyChange = {
|
|
163
|
+
readonly kind: "egress-allow";
|
|
164
|
+
readonly host: string;
|
|
165
|
+
} | {
|
|
166
|
+
readonly kind: "egress-method";
|
|
167
|
+
readonly method: string;
|
|
168
|
+
} | {
|
|
169
|
+
readonly kind: "egress-local-network";
|
|
170
|
+
}
|
|
171
|
+
/** Plain http:// to a public host: only `allow_http`, private addresses stay refused. */
|
|
172
|
+
| {
|
|
173
|
+
readonly kind: "egress-plain-http";
|
|
174
|
+
} | {
|
|
175
|
+
readonly kind: "rule";
|
|
176
|
+
readonly rule: {
|
|
177
|
+
readonly id: string;
|
|
178
|
+
readonly match: string;
|
|
179
|
+
readonly effect?: string;
|
|
180
|
+
readonly decision: string;
|
|
181
|
+
} & Record<string, unknown>;
|
|
182
|
+
};
|
|
183
|
+
export interface PolicyBatchResult {
|
|
184
|
+
readonly text: string;
|
|
185
|
+
/** Plain words, one per change that lets more through. */
|
|
186
|
+
readonly loosens: string[];
|
|
187
|
+
/** False when every change was already in the file. */
|
|
188
|
+
readonly changed: boolean;
|
|
189
|
+
/** Rule ids written new, written over an older copy, and left out (with why). */
|
|
190
|
+
readonly rulesAdded: readonly string[];
|
|
191
|
+
readonly rulesReplaced: readonly string[];
|
|
192
|
+
readonly rulesSkipped: readonly {
|
|
193
|
+
readonly id: string;
|
|
194
|
+
readonly why: string;
|
|
195
|
+
}[];
|
|
196
|
+
}
|
|
197
|
+
/** A batch that changed nothing, for a policy that was not edited at all. */
|
|
198
|
+
export declare function unchangedBatch(text: string): PolicyBatchResult;
|
|
199
|
+
/**
|
|
200
|
+
* ADAPTER for core's `applyPolicyBatch(policyText, changes)` (workstream A,
|
|
201
|
+
* core/src/policy-batch.ts). Until that lands this applies the changes itself
|
|
202
|
+
* through the yaml Document API, so comments and layout around them survive;
|
|
203
|
+
* at merge this body becomes a one-line call (translating `PolicyChange` if
|
|
204
|
+
* A's shape differs).
|
|
205
|
+
*/
|
|
206
|
+
export declare function applyPolicyChanges(policyText: string, changes: readonly PolicyChange[], source?: string): PolicyBatchResult;
|
|
207
|
+
/**
|
|
208
|
+
* The refusal for a toolbox with `policy_overrides: false`, which lets the
|
|
209
|
+
* console tighten its policy but never loosen it -- the same line core's
|
|
210
|
+
* `writePolicyBatch` holds. Acknowledging would not change the answer, so
|
|
211
|
+
* this carries no `needs: "loosens"`: the page must not offer a confirm
|
|
212
|
+
* button that can only fail. Throws when `loosens` is not empty.
|
|
213
|
+
*/
|
|
214
|
+
export declare function refuseIfOverridesOff(config: GatewayConfig, loosens: readonly string[]): void;
|
|
215
|
+
/**
|
|
216
|
+
* policy.yaml without the rules the console or a pack wrote for one server:
|
|
217
|
+
* ids starting `pack-` or `console-` whose `match` names a tool of that
|
|
218
|
+
* server (`<upstream>__...`). Removing a server otherwise leaves them behind,
|
|
219
|
+
* deciding tools that no longer exist -- and deciding them again, unseen, for
|
|
220
|
+
* a different server later added under the same name.
|
|
221
|
+
*
|
|
222
|
+
* A rule a person wrote is never touched, and neither is `egress`: another
|
|
223
|
+
* server may share an address. Edited through the Document API so comments
|
|
224
|
+
* survive, and checked to have removed exactly those rules.
|
|
225
|
+
*/
|
|
226
|
+
export declare function removeRulesWrittenFor(policyText: string, upstream: string): {
|
|
227
|
+
text: string;
|
|
228
|
+
removed: string[];
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Whether the egress guard refuses this host unless private addresses are
|
|
232
|
+
* allowed: `localhost`, and any literal in loopback, link-local or private
|
|
233
|
+
* space. The same test adopt-plan.ts makes.
|
|
234
|
+
*/
|
|
235
|
+
export declare function isLocalHost(hostname: string): boolean;
|
|
236
|
+
/**
|
|
237
|
+
* The changes an upstream needs for its own address, before any rule pack.
|
|
238
|
+
*
|
|
239
|
+
* The one place this is worked out: Test it's scratch policy and install both
|
|
240
|
+
* call it, so what is saved is what was tested. A server on this computer or
|
|
241
|
+
* the local network needs the guard's private-address, bare-IP and plain-http
|
|
242
|
+
* protections off; one on a public host reached over plain http needs only
|
|
243
|
+
* plain http. `localNetwork` is what the draft found (a private address);
|
|
244
|
+
* it can only add to what the address itself says, never take it away.
|
|
245
|
+
*/
|
|
246
|
+
export declare function egressChangesFor(upstream: Upstream, options?: {
|
|
247
|
+
localNetwork?: boolean;
|
|
248
|
+
}): PolicyChange[];
|
|
249
|
+
/** The rows of gateway processes still beating, newest heartbeat first. */
|
|
250
|
+
export declare function liveRows(store: ApprovalStore, component: string, now?: number): LiveConfigStateRow[];
|
|
251
|
+
/** Asks running gateways to retry one server now. False when the store cannot take requests. */
|
|
252
|
+
export declare function requestRetry(store: ApprovalStore, component: string, upstream: string): boolean;
|
|
253
|
+
export type ApplyState = "live" | "pending" | "not-running" | "needs-restart";
|
|
254
|
+
/**
|
|
255
|
+
* A gateway's refusal in words a person can act on. The gateway writes for a
|
|
256
|
+
* log ("gateway.yaml changed connect_timeout_ms, which a running gateway cannot
|
|
257
|
+
* pick up..."); the console shows this instead, with the setting's own name
|
|
258
|
+
* kept in brackets for whoever wants to look it up.
|
|
259
|
+
*/
|
|
260
|
+
export declare function plainRefusal(refusal: string): string;
|
|
261
|
+
/**
|
|
262
|
+
* Whether a gateway's published refusal can only be cleared by a restart.
|
|
263
|
+
* A file that did not parse ("could not be used") is cleared by the next good
|
|
264
|
+
* write, so it does not count; a change outside `upstreams` does.
|
|
265
|
+
*/
|
|
266
|
+
export declare function refusalNeedsRestart(refusal: string | null | undefined): boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Whether that refusal also holds back changes to the servers. A gateway that
|
|
269
|
+
* carries server changes past a standing refusal says so ("The servers were
|
|
270
|
+
* updated"); one that does not refuses the whole file.
|
|
271
|
+
*/
|
|
272
|
+
export declare function refusalBlocksServers(refusal: string | null | undefined): boolean;
|
|
273
|
+
/**
|
|
274
|
+
* What a write to gateway.yaml means for what is running.
|
|
275
|
+
*
|
|
276
|
+
* Only `upstreams` changes are applied live, and only by a gateway with
|
|
277
|
+
* `upstream_reload` on; anything else waits for its next start. `running`
|
|
278
|
+
* covers a gateway from before live state existed, which announces itself but
|
|
279
|
+
* writes no live rows: it can only pick the change up by restarting.
|
|
280
|
+
*/
|
|
281
|
+
export declare function applyStateFor(args: {
|
|
282
|
+
rows: readonly LiveConfigStateRow[];
|
|
283
|
+
running: boolean;
|
|
284
|
+
upstreamsOnly: boolean;
|
|
285
|
+
upstreamReload: boolean;
|
|
286
|
+
digest: string;
|
|
287
|
+
}): ApplyState;
|