hmcp-web 0.2.2 → 0.2.3
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/dist/api.d.ts +6 -0
- package/dist/api.js +36 -8
- package/dist/model/app-connect-note.d.ts +114 -0
- package/dist/model/app-connect-note.js +199 -0
- package/dist/model/app-servers.d.ts +24 -1
- package/dist/model/app-servers.js +54 -6
- package/dist/model/apps.d.ts +24 -0
- package/dist/model/apps.js +18 -0
- package/dist/model/bring-in.d.ts +185 -0
- package/dist/model/bring-in.js +755 -0
- package/dist/model/console-settings.d.ts +2 -2
- package/dist/model/import-record.d.ts +4 -0
- package/dist/model/import-record.js +22 -1
- package/dist/model/new-toolbox.d.ts +84 -0
- package/dist/model/new-toolbox.js +209 -0
- package/dist/model/protection.d.ts +4 -1
- package/dist/model/protection.js +12 -9
- package/dist/model/provisional-tools.d.ts +56 -0
- package/dist/model/provisional-tools.js +145 -0
- package/dist/model/server-names.d.ts +25 -0
- package/dist/model/server-names.js +158 -0
- package/dist/model/toolbox-label.d.ts +22 -0
- package/dist/model/toolbox-label.js +42 -0
- package/dist/model/tools.d.ts +20 -5
- package/dist/model/tools.js +22 -11
- package/dist/routes/connect-app.d.ts +54 -0
- package/dist/routes/connect-app.js +1018 -0
- package/dist/routes/connect-import.d.ts +21 -6
- package/dist/routes/connect-import.js +162 -546
- package/dist/routes/connect.d.ts +11 -0
- package/dist/routes/connect.js +28 -116
- package/dist/routes/github.js +2 -1
- package/dist/routes/guard.js +4 -0
- package/dist/routes/runtime.js +21 -22
- package/dist/routes/servers-add.d.ts +1 -0
- package/dist/routes/servers-add.js +6 -5
- package/dist-ui/assets/Activity-BSf4lBm-.js +1 -0
- package/dist-ui/assets/Approvals-CDz3zYpl.js +1 -0
- package/dist-ui/assets/AttachApp-COr1547c.js +5 -0
- package/dist-ui/assets/Connections-ClW5R6ea.js +2 -0
- package/dist-ui/assets/{Gallery-DB_OO7Vw.js → Gallery-0iiv1H9e.js} +3 -3
- package/dist-ui/assets/{PreApprovals-C-2ZGYfc.js → PreApprovals-DYDKgSpr.js} +1 -1
- package/dist-ui/assets/Protection-DMtABpM7.js +1 -0
- package/dist-ui/assets/Safety-BLTF2fqV.js +1 -0
- package/dist-ui/assets/{Settings-CSyTOe8X.js → Settings-DZ4P3Us6.js} +1 -1
- package/dist-ui/assets/StartPage-Bke6mrv5.js +1 -0
- package/dist-ui/assets/{Suggestions-CaQ_ifWR.js → Suggestions-kAWUILyw.js} +1 -1
- package/dist-ui/assets/Tools-BdXSeKeL.js +4 -0
- package/dist-ui/assets/connect-app-words-CT8Fytzv.js +1 -0
- package/dist-ui/assets/index-Cm4wG2zz.js +16 -0
- package/dist-ui/assets/{kit-DRVm92_t.js → kit-BHB_ha4i.js} +1 -1
- package/dist-ui/assets/server-name-D9u6r07i.js +1 -0
- package/dist-ui/index.html +3 -2
- package/package.json +4 -4
- package/dist-ui/assets/Activity-CoVSFaRd.js +0 -1
- package/dist-ui/assets/Approvals-BSEDgiNu.js +0 -1
- package/dist-ui/assets/AttachApp-Cpm6DOaX.js +0 -5
- package/dist-ui/assets/Connections-D5Xd9vH8.js +0 -2
- package/dist-ui/assets/Protection-B4Ltb5iP.js +0 -1
- package/dist-ui/assets/Safety-CSQhoL9D.js +0 -1
- package/dist-ui/assets/StartPage-JBVzYXce.js +0 -1
- package/dist-ui/assets/Tools-CDl6irG1.js +0 -4
- package/dist-ui/assets/index-CTvq_isK.js +0 -16
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { type RegistryEntry } from "hmcp-core";
|
|
2
|
+
import { type ProbeTool, type Scope, type ScopeTarget, type Upstream } from "hmcp-gateway";
|
|
3
|
+
import type { ApiOptions } from "../api.js";
|
|
4
|
+
import { type LoadedServer } from "./server.js";
|
|
5
|
+
import { type NewToolbox } from "./new-toolbox.js";
|
|
6
|
+
/**
|
|
7
|
+
* "Bring in servers": moving the servers an AI app runs by itself into a
|
|
8
|
+
* toolbox, so every call they make is checked. Into the toolbox the app is
|
|
9
|
+
* connected to, or into a new one made for it in the same step.
|
|
10
|
+
*
|
|
11
|
+
* The same rules as adding a server by hand hold, with one more file in play:
|
|
12
|
+
*
|
|
13
|
+
* - Every server is tested first, the way "Test it" tests one, against a
|
|
14
|
+
* scratch copy of the keys and the policy. Only servers that connected are
|
|
15
|
+
* brought in; the rest stay in the app, untouched, and the reply says why.
|
|
16
|
+
* - Writes go keys, then policy, then gateway.yaml, then the app's settings
|
|
17
|
+
* -- each one put back if a later one is refused. The app's file is last so
|
|
18
|
+
* that at every moment a server is in the app, the toolbox, or both; never
|
|
19
|
+
* in neither.
|
|
20
|
+
* - A server leaves the app only after its entry is kept in the connection's
|
|
21
|
+
* undo record, so "Undo connection" gives it back too.
|
|
22
|
+
*
|
|
23
|
+
* A new toolbox can't be empty, so it is made only once the servers have
|
|
24
|
+
* been tested, with the ones that connected: keys, then the toolbox's files
|
|
25
|
+
* and its row in the console, then the app connected to it, then the
|
|
26
|
+
* servers taken out of the app. If none connected, nothing is written.
|
|
27
|
+
*
|
|
28
|
+
* Nothing about a server but its name goes back to the browser: no command
|
|
29
|
+
* line, address, setting value or key. A failure's message has every one of
|
|
30
|
+
* those taken out before it is sent.
|
|
31
|
+
*/
|
|
32
|
+
/** The toolbox an app was connected to from the console, as `connectedToolbox` finds it. */
|
|
33
|
+
export interface Connected {
|
|
34
|
+
readonly target: ScopeTarget;
|
|
35
|
+
readonly entry: RegistryEntry;
|
|
36
|
+
readonly server: LoadedServer;
|
|
37
|
+
readonly configPath: string;
|
|
38
|
+
readonly entryName: string;
|
|
39
|
+
readonly home: string;
|
|
40
|
+
/**
|
|
41
|
+
* Set when the app's undo record names this toolbox by an id the console
|
|
42
|
+
* no longer has (it was found by what the app runs): that old id and the
|
|
43
|
+
* record's `created_at`, for `adoptToolboxId`.
|
|
44
|
+
*/
|
|
45
|
+
readonly staleId?: {
|
|
46
|
+
readonly id: string;
|
|
47
|
+
readonly createdAt: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** A toolbox made for the app in the same step: its name (also its folder) and what the console calls it. */
|
|
51
|
+
export interface NewToolboxChoice {
|
|
52
|
+
readonly new: {
|
|
53
|
+
readonly name: string;
|
|
54
|
+
readonly label?: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export interface BringInOptions {
|
|
58
|
+
readonly options: ApiOptions;
|
|
59
|
+
readonly scope: Scope;
|
|
60
|
+
/** The project folder, already checked. */
|
|
61
|
+
readonly cwd: string;
|
|
62
|
+
/** Entry names in the app's settings. */
|
|
63
|
+
readonly names: readonly string[];
|
|
64
|
+
/** Claude Desktop extension ids. */
|
|
65
|
+
readonly extensions: readonly string[];
|
|
66
|
+
readonly acknowledged?: {
|
|
67
|
+
readonly loosens: true;
|
|
68
|
+
} | undefined;
|
|
69
|
+
readonly toolbox: Connected | NewToolboxChoice;
|
|
70
|
+
/** Who did it, for the activity log. */
|
|
71
|
+
readonly actor: string;
|
|
72
|
+
/** New toolbox only: the folders for the app's PATH. Default: the console's own PATH (`pathDirsFromEnv`). */
|
|
73
|
+
readonly pathDirs?: readonly string[];
|
|
74
|
+
/**
|
|
75
|
+
* One-click connect only. Instead of refusing the whole batch when it
|
|
76
|
+
* would let more through, each server is weighed on its own: one whose
|
|
77
|
+
* every loosening line `accept` takes goes on, and any other is left in
|
|
78
|
+
* the app, untouched, and listed in `held` with what it would loosen.
|
|
79
|
+
* What was accepted is still recorded in the activity log.
|
|
80
|
+
*/
|
|
81
|
+
readonly hold?: {
|
|
82
|
+
readonly accept: (line: string, upstream: Upstream, server: {
|
|
83
|
+
readonly needsLocalHttp: boolean;
|
|
84
|
+
}) => boolean;
|
|
85
|
+
/** Said for a server held for lines `accept` refused, in place of the usual words. */
|
|
86
|
+
readonly why?: string;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* With `hold`: stop once each server has been weighed, before anything is
|
|
90
|
+
* started or written, and return only `held`. What a one-click preview
|
|
91
|
+
* shows, so it says what the click would decide.
|
|
92
|
+
*/
|
|
93
|
+
readonly dryRun?: boolean;
|
|
94
|
+
}
|
|
95
|
+
export interface BringInResult {
|
|
96
|
+
readonly imported: {
|
|
97
|
+
name: string;
|
|
98
|
+
source: string;
|
|
99
|
+
upstream: string;
|
|
100
|
+
tools: number;
|
|
101
|
+
keysLocked: string[];
|
|
102
|
+
}[];
|
|
103
|
+
readonly takenOut: {
|
|
104
|
+
name: string;
|
|
105
|
+
source: string;
|
|
106
|
+
upstream: string;
|
|
107
|
+
}[];
|
|
108
|
+
readonly failures: {
|
|
109
|
+
name: string;
|
|
110
|
+
source: string;
|
|
111
|
+
code: string;
|
|
112
|
+
message: string;
|
|
113
|
+
}[];
|
|
114
|
+
/** With `hold` only: the servers left in the app because they need a person's OK. */
|
|
115
|
+
readonly held: {
|
|
116
|
+
name: string;
|
|
117
|
+
source: string;
|
|
118
|
+
key: string;
|
|
119
|
+
loosens: string[];
|
|
120
|
+
why: string;
|
|
121
|
+
}[];
|
|
122
|
+
/** What each server brought in offered when tested, for a list shown before the toolbox first runs. */
|
|
123
|
+
readonly probed: {
|
|
124
|
+
upstream: string;
|
|
125
|
+
digest: string;
|
|
126
|
+
tools: ProbeTool[];
|
|
127
|
+
}[];
|
|
128
|
+
readonly restartHint: string;
|
|
129
|
+
readonly extensionsToSwitchOff: {
|
|
130
|
+
id: string;
|
|
131
|
+
name: string;
|
|
132
|
+
enabled: boolean;
|
|
133
|
+
}[];
|
|
134
|
+
readonly otherApps: string[];
|
|
135
|
+
readonly warning: string | null;
|
|
136
|
+
/**
|
|
137
|
+
* The toolbox the servers went into, and whether this made it. Null when a
|
|
138
|
+
* new toolbox was asked for and no server connected, so none was made.
|
|
139
|
+
*/
|
|
140
|
+
readonly toolbox: {
|
|
141
|
+
id: string;
|
|
142
|
+
label: string;
|
|
143
|
+
configPath: string;
|
|
144
|
+
created: boolean;
|
|
145
|
+
entryName: string;
|
|
146
|
+
} | null;
|
|
147
|
+
/** The toolbox this made, file by file, so a later Undo removes exactly that. Null when none was made. */
|
|
148
|
+
readonly made: Omit<NewToolbox, "entry"> | null;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The toolbox this app was connected to from the console. An app that is
|
|
152
|
+
* not connected, or was connected with adopt (which already moved its
|
|
153
|
+
* servers in, and owns its files), has nothing to bring servers into.
|
|
154
|
+
*/
|
|
155
|
+
export declare function connectedToolbox(options: ApiOptions, scope: ScopeTarget["scope"], cwd: string): Connected;
|
|
156
|
+
/**
|
|
157
|
+
* Points the app's records at its toolbox's id now, when `connectedToolbox`
|
|
158
|
+
* found the toolbox by what the app runs because the id it was connected
|
|
159
|
+
* under is gone. Called once a request has passed its own checks, so a
|
|
160
|
+
* refused request writes nothing.
|
|
161
|
+
*
|
|
162
|
+
* The import record goes first, then the app's undo record. A step that
|
|
163
|
+
* fails part-way loses nothing: `readLiveImportRecord` keeps a record while
|
|
164
|
+
* either id is one the console doesn't have, and the next call finds the
|
|
165
|
+
* undo record still naming the old id and finishes the job. The undo record
|
|
166
|
+
* is read again just before: one undone, or made again (a new `created_at`),
|
|
167
|
+
* since `connectedToolbox` read it is left alone.
|
|
168
|
+
*/
|
|
169
|
+
export declare function adoptToolboxId(registryPath: string, connected: Connected): void;
|
|
170
|
+
/**
|
|
171
|
+
* Puts back what a refused import wrote, every step tried even when one
|
|
172
|
+
* before it fails: a gateway.yaml that can't be restored must not also leave
|
|
173
|
+
* the new keys behind. Returns what could not be put back, without keys.
|
|
174
|
+
*/
|
|
175
|
+
export declare function rollBack(steps: readonly (readonly [string, () => void])[], values: readonly string[]): string[];
|
|
176
|
+
/** The other apps whose settings run this toolbox, so the person knows what else now runs these servers. */
|
|
177
|
+
export declare function otherAppsUsing(configPath: string, except: ScopeTarget, cwd: string, home: string): string[];
|
|
178
|
+
/** The gateway engine's refusals as the console's error shape. */
|
|
179
|
+
export declare function asHttp(err: unknown, values?: readonly string[]): never;
|
|
180
|
+
/**
|
|
181
|
+
* Brings the chosen servers of one app into a toolbox. Throws the console's
|
|
182
|
+
* refusals (`HttpError`); a refusal after anything was written puts every
|
|
183
|
+
* write back first, newest first.
|
|
184
|
+
*/
|
|
185
|
+
export declare function bringIn(args: BringInOptions): Promise<BringInResult>;
|