@enhance-eng/enhance 0.1.21 → 0.1.25
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/{cli-output-identity.lib-a1wTreJ6.mjs → cli-output-identity.lib-DpON8As5.mjs} +4751 -899
- package/dist/{file-credential.adapter-rI5HpMEo.mjs → file-credential.adapter-C78gc9OK.mjs} +1 -1
- package/dist/main.mjs +251 -95
- package/dist/mcp-invocation.adapter-FuxI6KsE.mjs +1336 -0
- package/dist/mcp-main.mjs +38 -21
- package/dist/{mcp-server.adapter-Cgp05gfi.mjs → mcp-server.adapter-D7XwVD-o.mjs} +395 -260
- package/dist/mcp.mjs +2 -2
- package/dist/mutation-key.adapter-CXQ08HQY.mjs +4531 -0
- package/dist/remote-mcp-main.mjs +629 -27
- package/package.json +9 -4
- package/dist/mcp-invocation.adapter-NrVhm7y8.mjs +0 -119
- package/dist/mutation-key.adapter-x3QOYrKY.mjs +0 -2046
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enhance-eng/enhance",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Agent-first command-line interface for Enhance.",
|
|
6
6
|
"keywords": [
|
|
@@ -32,10 +32,12 @@
|
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsdown",
|
|
35
|
+
"build:desktop": "ENHANCE3_DESKTOP_RUNTIME=1 tsdown",
|
|
35
36
|
"prepack": "pnpm run build",
|
|
36
|
-
"test": "pnpm run test:e2e",
|
|
37
|
+
"test": "pnpm run test:unit && pnpm run test:e2e",
|
|
37
38
|
"test:e2e": "pnpm run build && node e2e/e2e-runner.ts",
|
|
38
39
|
"test:e2e:browser": "pnpm run build && playwright test",
|
|
40
|
+
"test:unit": "vitest run --config vitest.config.ts",
|
|
39
41
|
"typecheck": "tsc --noEmit"
|
|
40
42
|
},
|
|
41
43
|
"dependencies": {
|
|
@@ -45,8 +47,11 @@
|
|
|
45
47
|
"@trpc/client": "11.18.0",
|
|
46
48
|
"@trpc/server": "11.18.0",
|
|
47
49
|
"commander": "^14.0.0",
|
|
50
|
+
"css-tree": "3.2.1",
|
|
48
51
|
"fractional-indexing": "^4.0.0",
|
|
52
|
+
"parse5": "8.0.1",
|
|
49
53
|
"trpc-cli": "0.16.0",
|
|
54
|
+
"yauzl": "3.4.0",
|
|
50
55
|
"yazl": "3.3.1",
|
|
51
56
|
"zod": "^4.4.3"
|
|
52
57
|
},
|
|
@@ -57,6 +62,7 @@
|
|
|
57
62
|
"@enhance3/tsconfig": "workspace:*",
|
|
58
63
|
"@modelcontextprotocol/client": "2.0.0",
|
|
59
64
|
"@playwright/test": "^1.62.0",
|
|
65
|
+
"@types/css-tree": "2.3.11",
|
|
60
66
|
"@types/yauzl": "3.4.0",
|
|
61
67
|
"@types/yazl": "3.3.1",
|
|
62
68
|
"@vitest/coverage-v8": "catalog:",
|
|
@@ -65,8 +71,7 @@
|
|
|
65
71
|
"istanbul-lib-coverage": "3.2.2",
|
|
66
72
|
"tsdown": "^0.22.14",
|
|
67
73
|
"tsx": "^4.23.1",
|
|
68
|
-
"vitest": "catalog:"
|
|
69
|
-
"yauzl": "3.4.0"
|
|
74
|
+
"vitest": "catalog:"
|
|
70
75
|
},
|
|
71
76
|
"engines": {
|
|
72
77
|
"node": ">=24"
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { o as toFailurePayload } from "./cli-output-identity.lib-a1wTreJ6.mjs";
|
|
3
|
-
import { a as createOauthLoopbackAdapter, m as createAuthUseCase, n as createHttpRemoteAdapter, o as createCapabilityInvocationAdapter, t as createMutationKeyAdapter } from "./mutation-key.adapter-x3QOYrKY.mjs";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
|
|
6
|
-
//#region src/infrastructure/mcp-auth.adapter.ts
|
|
7
|
-
const loginInputSchema = z.object({ openBrowser: z.boolean() });
|
|
8
|
-
const createMcpAuthAdapter = (credentials, remote) => {
|
|
9
|
-
const auth = createAuthUseCase(credentials, remote, createOauthLoopbackAdapter(remote));
|
|
10
|
-
let active = null;
|
|
11
|
-
let state = null;
|
|
12
|
-
return {
|
|
13
|
-
login: async (offered) => {
|
|
14
|
-
if (active !== null) return active.ready;
|
|
15
|
-
const input = loginInputSchema.parse(offered);
|
|
16
|
-
const controller = new AbortController();
|
|
17
|
-
const ready = Promise.withResolvers();
|
|
18
|
-
state = null;
|
|
19
|
-
const complete = async () => {
|
|
20
|
-
try {
|
|
21
|
-
await auth.loginWithBrowser({
|
|
22
|
-
label: "Agent plugin",
|
|
23
|
-
openBrowser: input.openBrowser,
|
|
24
|
-
signal: controller.signal,
|
|
25
|
-
onReady: (url) => {
|
|
26
|
-
state = {
|
|
27
|
-
authenticated: false,
|
|
28
|
-
status: "waiting_for_browser",
|
|
29
|
-
url
|
|
30
|
-
};
|
|
31
|
-
ready.resolve(state);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
state = null;
|
|
35
|
-
} catch (error) {
|
|
36
|
-
state = {
|
|
37
|
-
authenticated: false,
|
|
38
|
-
status: "failed",
|
|
39
|
-
error: toFailurePayload(error, null)
|
|
40
|
-
};
|
|
41
|
-
ready.reject(error);
|
|
42
|
-
} finally {
|
|
43
|
-
active = null;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
const completion = complete();
|
|
47
|
-
active = {
|
|
48
|
-
controller,
|
|
49
|
-
ready: ready.promise,
|
|
50
|
-
completion
|
|
51
|
-
};
|
|
52
|
-
return ready.promise;
|
|
53
|
-
},
|
|
54
|
-
status: async () => {
|
|
55
|
-
if (state !== null) return state;
|
|
56
|
-
if (await credentials.read() === null) return { authenticated: false };
|
|
57
|
-
return auth.status();
|
|
58
|
-
},
|
|
59
|
-
logout: async () => {
|
|
60
|
-
active?.controller.abort();
|
|
61
|
-
await active?.completion;
|
|
62
|
-
state = null;
|
|
63
|
-
return auth.logout();
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/infrastructure/mcp-invocation.adapter.ts
|
|
70
|
-
const TRANSPORT_CAPABILITIES = /* @__PURE__ */ new Set([
|
|
71
|
-
"auth.login",
|
|
72
|
-
"auth.logout",
|
|
73
|
-
"auth.status",
|
|
74
|
-
"doctor"
|
|
75
|
-
]);
|
|
76
|
-
const invokeTransport = async (input) => {
|
|
77
|
-
switch (input.capability) {
|
|
78
|
-
case "auth.login": return input.auth.login(input.arguments);
|
|
79
|
-
case "auth.logout": return input.auth.logout();
|
|
80
|
-
case "auth.status": return input.auth.status();
|
|
81
|
-
case "doctor": {
|
|
82
|
-
const [api, credential] = await Promise.all([input.remote.health(), input.credentials.read()]);
|
|
83
|
-
return {
|
|
84
|
-
status: credential !== null && api.reachable ? "ok" : "degraded",
|
|
85
|
-
runtimeVersion: input.version,
|
|
86
|
-
api: {
|
|
87
|
-
reachable: api.reachable,
|
|
88
|
-
status: api.status,
|
|
89
|
-
...api.error !== void 0 && { error: api.error }
|
|
90
|
-
},
|
|
91
|
-
credential: { present: credential !== null }
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
default: throw new TypeError(`${input.capability} has no MCP transport execution`);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
const createMcpInvocationAdapter = (apiUrl, credentials, configDirectory, version) => {
|
|
98
|
-
const transportRemote = createHttpRemoteAdapter(apiUrl, credentials, createMutationKeyAdapter());
|
|
99
|
-
const auth = createMcpAuthAdapter(credentials, transportRemote);
|
|
100
|
-
return { invoke: async (request) => {
|
|
101
|
-
if (TRANSPORT_CAPABILITIES.has(request.capability.id)) return invokeTransport({
|
|
102
|
-
capability: request.capability.id,
|
|
103
|
-
arguments: request.arguments,
|
|
104
|
-
credentials,
|
|
105
|
-
remote: transportRemote,
|
|
106
|
-
version,
|
|
107
|
-
auth
|
|
108
|
-
});
|
|
109
|
-
const mutationKey = createMutationKeyAdapter();
|
|
110
|
-
return createCapabilityInvocationAdapter({
|
|
111
|
-
remote: createHttpRemoteAdapter(apiUrl, credentials, mutationKey),
|
|
112
|
-
mutationKey,
|
|
113
|
-
configDirectory
|
|
114
|
-
}).invoke(request);
|
|
115
|
-
} };
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
//#endregion
|
|
119
|
-
export { createMcpInvocationAdapter as t };
|