hmcp-web 0.1.0 → 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.
- package/README.md +3 -2
- package/dist/api.d.ts +11 -0
- package/dist/api.js +64 -10
- package/dist/model/app-servers.d.ts +85 -0
- package/dist/model/app-servers.js +109 -0
- package/dist/model/import-record.d.ts +80 -0
- package/dist/model/import-record.js +179 -0
- package/dist/model/metrics.js +16 -1
- package/dist/routes/connect-import.d.ts +9 -0
- package/dist/routes/connect-import.js +594 -0
- package/dist/routes/connect.d.ts +36 -0
- package/dist/routes/connect.js +71 -13
- package/dist/routes/github.d.ts +97 -0
- package/dist/routes/github.js +587 -0
- package/dist/routes/guard.d.ts +3 -0
- package/dist/routes/guard.js +166 -0
- package/dist/routes/runtime.d.ts +6 -0
- package/dist/routes/runtime.js +1 -1
- package/dist/routes/servers-add.d.ts +8 -0
- package/dist/routes/servers-add.js +2 -2
- package/dist-ui/assets/{Activity-BqKGpXMN.js → Activity-CZ78RyRO.js} +1 -1
- package/dist-ui/assets/Approvals-DPIlNZsv.js +1 -0
- package/dist-ui/assets/AttachApp-DjSeWCbS.js +5 -0
- package/dist-ui/assets/Connections-qcA96lXh.js +2 -0
- package/dist-ui/assets/{Gallery-B39L2Yma.js → Gallery-DB_OO7Vw.js} +1 -1
- package/dist-ui/assets/{PreApprovals-BsIhjMqb.js → PreApprovals-C4cKajcK.js} +1 -1
- package/dist-ui/assets/{Protection-DlB09ABa.js → Protection-B8h-5YAb.js} +1 -1
- package/dist-ui/assets/{Safety-CN-oHO2h.js → Safety-BQqHyYdo.js} +1 -1
- package/dist-ui/assets/{Settings-BLD7G1Ag.js → Settings-Cx50zZSt.js} +1 -1
- package/dist-ui/assets/StartPage-CdX-v7ej.js +1 -0
- package/dist-ui/assets/{Suggestions-Dp7pofcs.js → Suggestions-CRo5UOTT.js} +1 -1
- package/dist-ui/assets/Tools-xo39lPKB.js +4 -0
- package/dist-ui/assets/index-DttDjRpu.js +16 -0
- package/dist-ui/assets/index-QeJyD5z2.css +2 -0
- package/dist-ui/assets/{kit-DQ7Oxf5n.js → kit-DRVm92_t.js} +1 -1
- package/dist-ui/index.html +3 -3
- package/package.json +4 -4
- package/dist-ui/assets/Approvals-Qo7bCcli.js +0 -1
- package/dist-ui/assets/AttachApp-0zRSPgSY.js +0 -5
- package/dist-ui/assets/Connections-CE0JGe8c.js +0 -2
- package/dist-ui/assets/StartPage-HuZSnmSr.js +0 -1
- package/dist-ui/assets/Tools-Bfot3bx5.js +0 -4
- package/dist-ui/assets/index-Khp0l1zp.js +0 -16
- package/dist-ui/assets/index-Ylyt4DEr.css +0 -2
package/dist/routes/connect.d.ts
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AuditLog } from "hmcp-core";
|
|
3
|
+
import { type Scope } from "hmcp-gateway";
|
|
1
4
|
import type { ApiOptions } from "../api.js";
|
|
2
5
|
import { type Route } from "../http.js";
|
|
6
|
+
export declare const ScopeSchema: z.ZodEnum<{
|
|
7
|
+
project: "project";
|
|
8
|
+
local: "local";
|
|
9
|
+
user: "user";
|
|
10
|
+
"claude-desktop": "claude-desktop";
|
|
11
|
+
"cursor-project": "cursor-project";
|
|
12
|
+
"cursor-user": "cursor-user";
|
|
13
|
+
"vscode-project": "vscode-project";
|
|
14
|
+
"vscode-user": "vscode-user";
|
|
15
|
+
windsurf: "windsurf";
|
|
16
|
+
"copilot-cli": "copilot-cli";
|
|
17
|
+
antigravity: "antigravity";
|
|
18
|
+
"antigravity-project": "antigravity-project";
|
|
19
|
+
devin: "devin";
|
|
20
|
+
"devin-project": "devin-project";
|
|
21
|
+
junie: "junie";
|
|
22
|
+
"junie-project": "junie-project";
|
|
23
|
+
"roo-project": "roo-project";
|
|
24
|
+
codex: "codex";
|
|
25
|
+
"codex-project": "codex-project";
|
|
26
|
+
}>;
|
|
27
|
+
export declare const LABELS: Record<Scope, string>;
|
|
3
28
|
/**
|
|
4
29
|
* Where the folders for an app's PATH come from. The machine check supplies
|
|
5
30
|
* them once it is wired in; until then, and when it finds nothing, the
|
|
@@ -11,4 +36,15 @@ export interface ConnectDeps {
|
|
|
11
36
|
readonly pathDirs?: () => string[] | Promise<string[]>;
|
|
12
37
|
}
|
|
13
38
|
export declare function pathDirsFromEnv(path?: string | undefined): string[];
|
|
39
|
+
export declare function parse<T>(schema: z.ZodType<T>, body: unknown): T;
|
|
40
|
+
/**
|
|
41
|
+
* The project folder, defaulting to the console's own working directory --
|
|
42
|
+
* which is what the CLI does with its own, and the folder the console was
|
|
43
|
+
* started from is the likeliest project.
|
|
44
|
+
*/
|
|
45
|
+
export declare function projectDirOf(raw: string | null | undefined): string;
|
|
46
|
+
/** The gateway's own audit log, or null when its config does not load or keeps none. */
|
|
47
|
+
export declare function gatewayAudit(configPath: string, actor: string): AuditLog | null;
|
|
48
|
+
/** Appends one record, and turns a failure into a warning: the change itself already happened. */
|
|
49
|
+
export declare function record(log: AuditLog | null, entry: Parameters<AuditLog["appendStrict"]>[0]): string | null;
|
|
14
50
|
export declare function connectRoutes(options: ApiOptions, deps?: ConnectDeps): Route[];
|
package/dist/routes/connect.js
CHANGED
|
@@ -4,7 +4,9 @@ import { delimiter, dirname, isAbsolute, join, resolve } from "node:path";
|
|
|
4
4
|
import { stringify } from "yaml";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { AuditLog, readRegistry, writeRegistry } from "hmcp-core";
|
|
7
|
-
import { AdoptCommandError, AdoptRefusedError, ClientConfigError, UpstreamSchema, adoptApply, adoptPlan, adoptRevert, connectClient, detectClients, emitPolicyYaml, isLocalTarget, loadGatewayConfig, readBackup, resolveScope } from "hmcp-gateway";
|
|
7
|
+
import { AdoptCommandError, AdoptRefusedError, ClientConfigError, codexHomeNote, UpstreamSchema, adoptApply, adoptPlan, adoptRevert, connectClient, detectClients, emitPolicyYaml, isLocalTarget, loadGatewayConfig, readBackup, resolveScope } from "hmcp-gateway";
|
|
8
|
+
import { appServersFor } from "../model/app-servers.js";
|
|
9
|
+
import { deleteImportRecord, readImportRecord } from "../model/import-record.js";
|
|
8
10
|
import { badRequest, conflict, HttpError, route, unprocessable } from "../http.js";
|
|
9
11
|
/**
|
|
10
12
|
* Connecting the AI apps a person already uses: `hmcp-gateway adopt`, from
|
|
@@ -29,14 +31,34 @@ const SCOPES = [
|
|
|
29
31
|
"cursor-user",
|
|
30
32
|
"vscode-project",
|
|
31
33
|
"vscode-user",
|
|
32
|
-
"windsurf"
|
|
34
|
+
"windsurf",
|
|
35
|
+
"copilot-cli",
|
|
36
|
+
"antigravity",
|
|
37
|
+
"antigravity-project",
|
|
38
|
+
"devin",
|
|
39
|
+
"devin-project",
|
|
40
|
+
"junie",
|
|
41
|
+
"junie-project",
|
|
42
|
+
"roo-project",
|
|
43
|
+
"codex",
|
|
44
|
+
"codex-project"
|
|
33
45
|
];
|
|
34
|
-
const ScopeSchema = z.enum(SCOPES);
|
|
46
|
+
export const ScopeSchema = z.enum(SCOPES);
|
|
35
47
|
/** The scopes whose file lives in a project, so need a project folder to find it. */
|
|
36
|
-
const PROJECT_SCOPES = new Set([
|
|
48
|
+
const PROJECT_SCOPES = new Set([
|
|
49
|
+
"project",
|
|
50
|
+
"local",
|
|
51
|
+
"cursor-project",
|
|
52
|
+
"vscode-project",
|
|
53
|
+
"antigravity-project",
|
|
54
|
+
"devin-project",
|
|
55
|
+
"junie-project",
|
|
56
|
+
"roo-project",
|
|
57
|
+
"codex-project"
|
|
58
|
+
]);
|
|
37
59
|
/** The client allow rule is a Claude Code permission; the other apps never read it. */
|
|
38
60
|
const CLAUDE_CODE_SCOPES = new Set(["project", "local", "user"]);
|
|
39
|
-
const LABELS = {
|
|
61
|
+
export const LABELS = {
|
|
40
62
|
project: "Claude Code — this project",
|
|
41
63
|
local: "Claude Code — this project, only you",
|
|
42
64
|
user: "Claude Code — all projects",
|
|
@@ -45,7 +67,18 @@ const LABELS = {
|
|
|
45
67
|
"cursor-user": "Cursor — all projects",
|
|
46
68
|
"vscode-project": "VS Code — this project",
|
|
47
69
|
"vscode-user": "VS Code — all projects",
|
|
48
|
-
windsurf: "Windsurf"
|
|
70
|
+
windsurf: "Windsurf (now Devin Desktop; older settings file)",
|
|
71
|
+
// The research notes list ~/.copilot/mcp-config.json as Copilot's portable file, which VS Code's Copilot reads too.
|
|
72
|
+
"copilot-cli": "GitHub Copilot CLI (also used by Copilot in VS Code)",
|
|
73
|
+
antigravity: "Antigravity CLI (formerly Gemini CLI) — all projects",
|
|
74
|
+
"antigravity-project": "Antigravity CLI (formerly Gemini CLI) — this project",
|
|
75
|
+
devin: "Devin Desktop — all projects",
|
|
76
|
+
"devin-project": "Devin Desktop — this project",
|
|
77
|
+
junie: "Junie — all projects",
|
|
78
|
+
"junie-project": "Junie — this project",
|
|
79
|
+
"roo-project": "Roo Code — this project",
|
|
80
|
+
codex: "Codex and the ChatGPT desktop app",
|
|
81
|
+
"codex-project": "Codex — this project (trusted projects only)"
|
|
49
82
|
};
|
|
50
83
|
const REGISTRY_ID = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
51
84
|
const AdoptBody = z
|
|
@@ -107,7 +140,7 @@ export function pathDirsFromEnv(path = process.env["PATH"]) {
|
|
|
107
140
|
.filter((d) => d.length > 0 && isAbsolute(d) && !/[\\/](node_modules|_npx)([\\/]|$)/.test(d) && existsSync(d)))
|
|
108
141
|
];
|
|
109
142
|
}
|
|
110
|
-
function parse(schema, body) {
|
|
143
|
+
export function parse(schema, body) {
|
|
111
144
|
const result = schema.safeParse(body ?? {});
|
|
112
145
|
if (!result.success) {
|
|
113
146
|
throw badRequest("the request body is not valid", result.error.issues.map((i) => ({ path: i.path.join(".") || "(root)", message: i.message })));
|
|
@@ -141,7 +174,7 @@ function plainDirectory(raw, field, mustExist) {
|
|
|
141
174
|
* which is what the CLI does with its own, and the folder the console was
|
|
142
175
|
* started from is the likeliest project.
|
|
143
176
|
*/
|
|
144
|
-
function projectDirOf(raw) {
|
|
177
|
+
export function projectDirOf(raw) {
|
|
145
178
|
return raw ? plainDirectory(raw, "projectDir", true) : process.cwd();
|
|
146
179
|
}
|
|
147
180
|
function libraryOptions(body, options) {
|
|
@@ -269,7 +302,7 @@ function asHttp(err) {
|
|
|
269
302
|
throw err;
|
|
270
303
|
}
|
|
271
304
|
/** The gateway's own audit log, or null when its config does not load or keeps none. */
|
|
272
|
-
function gatewayAudit(configPath, actor) {
|
|
305
|
+
export function gatewayAudit(configPath, actor) {
|
|
273
306
|
try {
|
|
274
307
|
const { policy } = loadGatewayConfig(configPath);
|
|
275
308
|
if (!policy.audit.enabled)
|
|
@@ -281,7 +314,7 @@ function gatewayAudit(configPath, actor) {
|
|
|
281
314
|
}
|
|
282
315
|
}
|
|
283
316
|
/** Appends one record, and turns a failure into a warning: the change itself already happened. */
|
|
284
|
-
function record(log, entry) {
|
|
317
|
+
export function record(log, entry) {
|
|
285
318
|
if (!log)
|
|
286
319
|
return "this gateway keeps no activity log, so the change was not recorded there";
|
|
287
320
|
try {
|
|
@@ -350,14 +383,21 @@ export function connectRoutes(options, deps = {}) {
|
|
|
350
383
|
projectDir,
|
|
351
384
|
clients: withoutSameFile(detectClients({ cwd: projectDir })).map((c) => ({
|
|
352
385
|
...c,
|
|
353
|
-
|
|
386
|
+
// Codex's folder moved by CODEX_HOME, which the ChatGPT desktop app may not follow: said on the card.
|
|
387
|
+
label: codexHomeNote(c) ? `${LABELS[c.scope]} (${codexHomeNote(c)})` : LABELS[c.scope],
|
|
354
388
|
projectScoped: PROJECT_SCOPES.has(c.scope),
|
|
355
389
|
/*
|
|
356
390
|
* An app with no servers yet can still be connected to a toolbox
|
|
357
391
|
* made here: that is the whole of `attach`. Only a config file that
|
|
358
392
|
* cannot be read stops it, and then `error` says why.
|
|
359
393
|
*/
|
|
360
|
-
canAttach: c.error === null
|
|
394
|
+
canAttach: c.error === null,
|
|
395
|
+
/*
|
|
396
|
+
* The app's own servers, and what "Bring in servers" can do with
|
|
397
|
+
* them. Names only; `serverCount` stays the raw count of entries in
|
|
398
|
+
* the file (the toolbox's own included), as older pages read it.
|
|
399
|
+
*/
|
|
400
|
+
...appServersFor(c.scope, projectDir, options.registryPath)
|
|
361
401
|
}))
|
|
362
402
|
};
|
|
363
403
|
}),
|
|
@@ -426,6 +466,8 @@ export function connectRoutes(options, deps = {}) {
|
|
|
426
466
|
? readRegistry(options.registryPath).servers.find((s) => s.id === backup.registry_id)?.config_path
|
|
427
467
|
: undefined);
|
|
428
468
|
const log = generatedConfig ? gatewayAudit(generatedConfig, ctx.actor) : null;
|
|
469
|
+
const target = resolveScope(body.scope, { cwd });
|
|
470
|
+
const imported = readImportRecord(options.registryPath, target);
|
|
429
471
|
let result;
|
|
430
472
|
try {
|
|
431
473
|
result = await adoptRevert({ scope: body.scope, cwd, purge: body.purge, registry: options.registryPath });
|
|
@@ -433,6 +475,15 @@ export function connectRoutes(options, deps = {}) {
|
|
|
433
475
|
catch (err) {
|
|
434
476
|
asHttp(err);
|
|
435
477
|
}
|
|
478
|
+
/*
|
|
479
|
+
* Servers brought in from the app were in the undo record's `replaced`
|
|
480
|
+
* map, so they are back in the app now. Their copies in the toolbox
|
|
481
|
+
* stay -- the toolbox is the console's, and other apps may use them --
|
|
482
|
+
* and the record of the import goes, since there is nothing left in the
|
|
483
|
+
* app for its Undo to put back.
|
|
484
|
+
*/
|
|
485
|
+
deleteImportRecord(options.registryPath, target);
|
|
486
|
+
const importedKept = (imported?.items ?? []).filter((i) => i.added).map((i) => i.upstream);
|
|
436
487
|
const warning = record(log, {
|
|
437
488
|
tool: "(connect)",
|
|
438
489
|
effect: null,
|
|
@@ -450,7 +501,14 @@ export function connectRoutes(options, deps = {}) {
|
|
|
450
501
|
registry_removed: result.registryRemoved
|
|
451
502
|
}
|
|
452
503
|
});
|
|
453
|
-
return {
|
|
504
|
+
return {
|
|
505
|
+
...result,
|
|
506
|
+
importedKept,
|
|
507
|
+
...(importedKept.length > 0
|
|
508
|
+
? { importedNote: `The servers you brought in stay in your toolbox too (${importedKept.join(", ")}). Remove them there if the app should be the only one running them.` }
|
|
509
|
+
: {}),
|
|
510
|
+
warning
|
|
511
|
+
};
|
|
454
512
|
}),
|
|
455
513
|
/**
|
|
456
514
|
* Put a toolbox made here into an AI app: one entry added beside the
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { type Effect, type Policy } from "hmcp-core";
|
|
2
|
+
import { type ProbeOutcome, type Upstream } from "hmcp-gateway";
|
|
3
|
+
import type { ApiOptions } from "../api.js";
|
|
4
|
+
import { type Route } from "../http.js";
|
|
5
|
+
import { type LoadedServer } from "../model/server.js";
|
|
6
|
+
/**
|
|
7
|
+
* Making hmcp the only way an AI app changes GitHub.
|
|
8
|
+
*
|
|
9
|
+
* Three parts. The doors: every other way a change could reach GitHub from
|
|
10
|
+
* this computer, which are only ever read here and reported without a
|
|
11
|
+
* value. Claude Code's own block, which writes three deny rules into its
|
|
12
|
+
* settings and can be undone. And the toolbox's GitHub server itself: one
|
|
13
|
+
* switch from GitHub's read-only address to the one that can make changes,
|
|
14
|
+
* which writes the GitHub pack's rules first so every change still waits for
|
|
15
|
+
* the person, and a self-check that says whether it works.
|
|
16
|
+
*/
|
|
17
|
+
/** A probe of one server, overridable so a test needs no GitHub. */
|
|
18
|
+
export type GithubProbe = (spec: Upstream, server: LoadedServer) => Promise<ProbeOutcome>;
|
|
19
|
+
export interface GithubRouteDeps {
|
|
20
|
+
readonly probe?: GithubProbe;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* What a change to GitHub would actually meet in this toolbox, from
|
|
24
|
+
* `decide()` over the GitHub pack's change tools -- so the card says "waits
|
|
25
|
+
* for you" only when it does. Computed whether or not changes are switched
|
|
26
|
+
* on yet: on the read-only address, it is what switching would lead to.
|
|
27
|
+
*/
|
|
28
|
+
export interface GithubChangeState {
|
|
29
|
+
/**
|
|
30
|
+
* waits: every change asks first. refused: every change is blocked.
|
|
31
|
+
* partly-refused: some are. runs: some run unasked. observe: nothing is
|
|
32
|
+
* enforced. unchecked: the server's tools aren't known yet. no-changes: it
|
|
33
|
+
* lists none that change anything.
|
|
34
|
+
*/
|
|
35
|
+
readonly kind: "waits" | "refused" | "partly-refused" | "runs" | "observe" | "unchecked" | "no-changes";
|
|
36
|
+
/** The toolbox's stance (read-only / approve-writes / locked), for the words. */
|
|
37
|
+
readonly posture: string;
|
|
38
|
+
/** An active pre-approval covers one of the change tools. */
|
|
39
|
+
readonly preApproved: boolean;
|
|
40
|
+
/** The tools that run unasked or are refused, for "runs" and "partly-refused". */
|
|
41
|
+
readonly tools?: readonly string[];
|
|
42
|
+
}
|
|
43
|
+
/** Each toolbox's GitHub servers, and which of GitHub's two hosted addresses each uses. */
|
|
44
|
+
export interface GithubServerView {
|
|
45
|
+
readonly gatewayId: string;
|
|
46
|
+
readonly gatewayLabel: string;
|
|
47
|
+
readonly configPath: string;
|
|
48
|
+
readonly upstream: string;
|
|
49
|
+
/** "readonly" / "changes" for GitHub's hosted server, null for any other GitHub server. */
|
|
50
|
+
readonly access: "readonly" | "changes" | null;
|
|
51
|
+
/** The gateway.yaml digest, for the switch's lost-update check. */
|
|
52
|
+
readonly digest: string;
|
|
53
|
+
/** Null when the toolbox's policy can't be loaded. */
|
|
54
|
+
readonly changes: GithubChangeState | null;
|
|
55
|
+
}
|
|
56
|
+
/** One tool as the server really lists it. */
|
|
57
|
+
export interface KnownTool {
|
|
58
|
+
/** The server's own name for it. */
|
|
59
|
+
readonly name: string;
|
|
60
|
+
/** As the AI app sees it, `<upstream>__<tool>`. */
|
|
61
|
+
readonly exposedName: string;
|
|
62
|
+
/** The gateway's own reading of it; undefined when nothing classified it. */
|
|
63
|
+
readonly effect: Effect | undefined;
|
|
64
|
+
}
|
|
65
|
+
export declare function rememberListed(gatewayId: string, upstream: string, outcome: ProbeOutcome | null): void;
|
|
66
|
+
/**
|
|
67
|
+
* What a change would meet, graded over the tools the server really lists:
|
|
68
|
+
* every one that isn't a read is a change tool. With no list yet, it says
|
|
69
|
+
* so ("unchecked") rather than guess from the pack's names, most of which
|
|
70
|
+
* a given release of GitHub's server doesn't use.
|
|
71
|
+
*/
|
|
72
|
+
export declare function changeState(server: LoadedServer, gatewayId: string, upstream: string): GithubChangeState;
|
|
73
|
+
/**
|
|
74
|
+
* The tools whose decision is less strict under `after` than under `before`
|
|
75
|
+
* (deny → approve or allow, approve → allow). The same posture, enforcement
|
|
76
|
+
* and tenant hold in both, since only rules are added, so any difference is
|
|
77
|
+
* the rules'. A pack rule placed above a rule the person wrote would show
|
|
78
|
+
* here, which is the case this exists for.
|
|
79
|
+
*/
|
|
80
|
+
export declare function loosenedTools(before: Policy, after: Policy, tools: readonly (string | {
|
|
81
|
+
readonly name: string;
|
|
82
|
+
readonly effect?: Effect | undefined;
|
|
83
|
+
})[]): string[];
|
|
84
|
+
export interface CheckLine {
|
|
85
|
+
readonly ok: boolean;
|
|
86
|
+
readonly text: string;
|
|
87
|
+
}
|
|
88
|
+
export declare const KEY_NOTE: string;
|
|
89
|
+
/**
|
|
90
|
+
* Whether the toolbox side works: the server connects, it offers tools that
|
|
91
|
+
* make changes, and how every tool it lists is decided under the policy as it
|
|
92
|
+
* is now. Green only when every tool that isn't a read waits for the person
|
|
93
|
+
* (or is refused, which is said in so many words). Whether the key itself may
|
|
94
|
+
* write can only be known from a call.
|
|
95
|
+
*/
|
|
96
|
+
export declare function checkLines(outcome: ProbeOutcome, upstream: Upstream, policy: Policy): CheckLine[];
|
|
97
|
+
export declare function githubRoutes(options: ApiOptions, deps?: GithubRouteDeps): Route[];
|