@enhance-eng/enhance 0.1.7 → 0.1.14

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.
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env node
2
+ import { i as toFailurePayload } from "./cli-output-identity.lib-bX6NwZjd.mjs";
3
+ import { a as createOauthLoopbackAdapter, f as createAuthUseCase, n as createHttpRemoteAdapter, o as createCapabilityInvocationAdapter, t as createMutationKeyAdapter } from "./mutation-key.adapter-p1odGHfg.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 };
package/dist/mcp-main.mjs CHANGED
@@ -1,15 +1,29 @@
1
1
  #!/usr/bin/env node
2
- import { f as toCapabilityDefinition, l as createCapabilityCatalogAdapter } from "./cli-output-identity.lib-BSUBcRJm.mjs";
3
- import { r as CLI_CONFIG } from "./mutation-key.adapter-EvvklGSw.mjs";
2
+ import { f as toCapabilityDefinition, l as createCapabilityCatalogAdapter } from "./cli-output-identity.lib-bX6NwZjd.mjs";
3
+ import { r as CLI_CONFIG } from "./mutation-key.adapter-p1odGHfg.mjs";
4
4
  import { t as createFileCredentialAdapter } from "./file-credential.adapter-rI5HpMEo.mjs";
5
- import { t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-Bn41hcLB.mjs";
6
- import { t as createMcpServerAdapter } from "./mcp-server.adapter-lxpsuDlU.mjs";
5
+ import { t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-BdZ-LpPW.mjs";
6
+ import { t as createMcpServerAdapter } from "./mcp-server.adapter-DBlOw4BM.mjs";
7
7
  import { z } from "zod";
8
8
  import process from "node:process";
9
9
  import { serveStdio } from "@modelcontextprotocol/server/stdio";
10
10
 
11
11
  //#region src/infrastructure/mcp-transport-capability.adapter.ts
12
12
  const unauthenticatedSchema = z.object({ authenticated: z.literal(false) });
13
+ const pendingLoginSchema = z.object({
14
+ authenticated: z.literal(false),
15
+ status: z.literal("waiting_for_browser"),
16
+ url: z.url()
17
+ });
18
+ const failedLoginSchema = z.object({
19
+ authenticated: z.literal(false),
20
+ status: z.literal("failed"),
21
+ error: z.object({
22
+ code: z.string(),
23
+ message: z.string(),
24
+ remediation: z.string()
25
+ })
26
+ });
13
27
  const authenticatedSchema = z.object({
14
28
  authenticated: z.literal(true),
15
29
  personId: z.uuid(),
@@ -18,9 +32,14 @@ const authenticatedSchema = z.object({
18
32
  tokenLabel: z.string().min(1),
19
33
  expiresAt: z.iso.datetime().nullable()
20
34
  });
21
- const loginInputSchema = z.object({ openBrowser: z.boolean().default(true).describe("Open the system browser for the human sign-in and wait for completion.") });
35
+ const loginInputSchema = z.object({ openBrowser: z.boolean().default(true).describe("Open the system browser for human sign-in; return its URL immediately.") });
22
36
  const statusInputSchema = z.strictObject({});
23
- const statusOutputSchema = z.union([unauthenticatedSchema, authenticatedSchema]);
37
+ const statusOutputSchema = z.union([
38
+ pendingLoginSchema,
39
+ failedLoginSchema,
40
+ unauthenticatedSchema,
41
+ authenticatedSchema
42
+ ]);
24
43
  const logoutOutputSchema = z.object({ loggedOut: z.boolean() });
25
44
  const doctorOutputSchema = z.object({
26
45
  status: z.enum(["ok", "degraded"]),
@@ -75,20 +94,17 @@ const capabilities = [
75
94
  operation: "mutation",
76
95
  effect: "external",
77
96
  inputSchema: loginInputSchema,
78
- outputSchema: authenticatedSchema,
97
+ outputSchema: pendingLoginSchema,
79
98
  guide: guideFor({
80
99
  summary: "Open browser sign-in and store a revocable user-scoped Enhance credential.",
81
100
  useWhen: "Use when Enhance is not authenticated or its credential was revoked.",
82
- result: "Waits for browser consent, stores the credential locally, and returns safe identity metadata.",
83
- next: ["Call auth.status, then read the target canvas."],
101
+ result: "Returns waiting_for_browser and the exact sign-in URL immediately. Show this URL to the person if their browser restores another page. Consent continues in the background; auth.status reports completion or a failure.",
102
+ next: ["Show the sign-in URL, then check auth.status after the person finishes. Only report success after authenticated is true and a canvas read succeeds."],
84
103
  exampleInput: { openBrowser: true },
85
104
  exampleOutput: {
86
- authenticated: true,
87
- personId: "00000000-0000-4000-8000-000000000001",
88
- displayName: "Ada",
89
- tokenId: "00000000-0000-4000-8000-000000000002",
90
- tokenLabel: "Agent plugin",
91
- expiresAt: null
105
+ authenticated: false,
106
+ status: "waiting_for_browser",
107
+ url: "https://app.example.test/oauth/authorize?client_id=client_enhance_cli"
92
108
  }
93
109
  })
94
110
  }),
@@ -116,8 +132,8 @@ const capabilities = [
116
132
  guide: guideFor({
117
133
  summary: "Check whether the local Enhance MCP runtime is authenticated.",
118
134
  useWhen: "Use before a workflow or after login, logout, expiry, or an authorization failure.",
119
- result: "Returns safe identity metadata or authenticated false, never a credential value.",
120
- next: ["When unauthenticated, call auth.login; otherwise continue with the requested workflow."],
135
+ result: "Returns safe identity metadata, a pending sign-in URL, a sign-in failure, or authenticated false; never a credential value.",
136
+ next: ["While waiting_for_browser, show the URL and let the person finish. After failure, report the error before retrying auth.login. Continue the workflow only when authenticated is true."],
121
137
  exampleInput: {},
122
138
  exampleOutput: { authenticated: false }
123
139
  })
@@ -136,7 +152,7 @@ const capabilities = [
136
152
  exampleInput: {},
137
153
  exampleOutput: {
138
154
  status: "ok",
139
- runtimeVersion: "0.1.7",
155
+ runtimeVersion: "0.1.14",
140
156
  api: {
141
157
  reachable: true,
142
158
  status: 200
@@ -151,10 +167,10 @@ const createMcpTransportCapabilityAdapter = () => capabilities;
151
167
  //#endregion
152
168
  //#region src/mcp-main.ts
153
169
  const credentials = createFileCredentialAdapter(CLI_CONFIG.configDirectory);
154
- const invocation = createMcpInvocationAdapter(CLI_CONFIG.apiUrl, credentials, CLI_CONFIG.configDirectory, "0.1.7");
170
+ const invocation = createMcpInvocationAdapter(CLI_CONFIG.apiUrl, credentials, CLI_CONFIG.configDirectory, "0.1.14");
155
171
  const catalog = [...createCapabilityCatalogAdapter(), ...createMcpTransportCapabilityAdapter()];
156
172
  serveStdio(() => createMcpServerAdapter({
157
- version: "0.1.7",
173
+ version: "0.1.14",
158
174
  name: CLI_CONFIG.mcpServiceName,
159
175
  commandName: CLI_CONFIG.commandName,
160
176
  invocation,
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { C as CliError, a as toPresentedCapabilities, i as toFailurePayload, l as createCapabilityCatalogAdapter, n as withCommandName, s as createMcpCapabilityDiscoveryAdapter, t as withCommandInFailure } from "./cli-output-identity.lib-BSUBcRJm.mjs";
2
+ import { C as CliError, a as toPresentedCapabilities, i as toFailurePayload, l as createCapabilityCatalogAdapter, n as withCommandName, s as createMcpCapabilityDiscoveryAdapter, t as withCommandInFailure } from "./cli-output-identity.lib-bX6NwZjd.mjs";
3
3
  import { z } from "zod";
4
4
  import { createHash, randomUUID } from "node:crypto";
5
5
  import { readFile, rm } from "node:fs/promises";
@@ -196,14 +196,25 @@ const localArtifactResult = async (server, result, delivery) => {
196
196
  }
197
197
  };
198
198
  return {
199
- content: [{
200
- type: "text",
201
- text: textFor(structuredContent)
202
- }, {
203
- type: "image",
204
- data: body.toString("base64"),
205
- mimeType
206
- }],
199
+ content: [
200
+ {
201
+ type: "text",
202
+ text: textFor(structuredContent)
203
+ },
204
+ {
205
+ type: "image",
206
+ data: body.toString("base64"),
207
+ mimeType
208
+ },
209
+ {
210
+ type: "resource",
211
+ resource: {
212
+ uri,
213
+ mimeType,
214
+ blob: body.toString("base64")
215
+ }
216
+ }
217
+ ],
207
218
  structuredContent
208
219
  };
209
220
  }
@@ -351,8 +362,8 @@ const createMcpResultAdapter = (authenticationRemediation, commandName = "enhanc
351
362
  const MAX_SEARCH_QUERY_CHARACTERS = 200;
352
363
  const MAX_SEARCH_RESULTS = 10;
353
364
  const DEFAULT_SEARCH_RESULTS = 5;
354
- const AUTHENTICATION_INSTRUCTIONS = "Transport attachment is not Enhance sign-in, even when the host reports mcp_auth success. Use capability_query with capability auth.status to check the person. If authenticated is false or a read returns UNAUTHORIZED, use capability_mutate with capability auth.login and input {\"openBrowser\":true}, then let the person complete browser sign-in. Verify auth.status and a read such as canvas.list before reporting setup complete.";
355
- const LOCAL_AUTHENTICATION_REMEDY = "Call capability_mutate with capability auth.login and input {\"openBrowser\":true}. Complete browser sign-in, then verify auth.status and a read such as canvas.list.";
365
+ const AUTHENTICATION_INSTRUCTIONS = "Transport attachment is not Enhance sign-in, even when the host reports mcp_auth success. Use capability_query with capability auth.status to check the person. If authenticated is false or a read returns UNAUTHORIZED, use capability_mutate with capability auth.login and input {\"openBrowser\":true}, then show the returned sign-in URL and let the person complete browser sign-in. If their browser restores a canvas or another page, direct them to this exact URL. A waiting_for_browser result is pending, not authenticated. Verify auth.status and a read such as canvas.list before reporting setup complete.";
366
+ const LOCAL_AUTHENTICATION_REMEDY = "Call capability_mutate with capability auth.login and input {\"openBrowser\":true}. Show the returned sign-in URL, complete browser sign-in, then verify auth.status and a read such as canvas.list.";
356
367
  const HOSTED_AUTHENTICATION_REMEDY = "Reconnect this hosted MCP server through your host’s browser OAuth sign-in. Then verify person.me and a read such as canvas.list.";
357
368
  const searchInputSchema = z.object({
358
369
  query: z.string().trim().min(1).max(MAX_SEARCH_QUERY_CHARACTERS).describe("Plain-language task, domain, or exact capability id to discover."),
@@ -443,7 +454,7 @@ const registerMutation = (server, catalog, invocation, execution) => {
443
454
  readOnlyHint: false,
444
455
  destructiveHint: true,
445
456
  idempotentHint: false,
446
- openWorldHint: false
457
+ openWorldHint: true
447
458
  },
448
459
  _meta: {
449
460
  "ai.enhancelabs/disclosure": "progressive",
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { l as createCapabilityCatalogAdapter, o as toSharedCapabilities } from "./cli-output-identity.lib-BSUBcRJm.mjs";
2
+ import { l as createCapabilityCatalogAdapter, o as toSharedCapabilities } from "./cli-output-identity.lib-bX6NwZjd.mjs";
3
3
  import { t as toCapabilityInventory } from "./capability-inventory.mapper-DyYXyVBJ.mjs";
4
- import { t as createMcpServerAdapter } from "./mcp-server.adapter-lxpsuDlU.mjs";
4
+ import { t as createMcpServerAdapter } from "./mcp-server.adapter-DBlOw4BM.mjs";
5
5
 
6
6
  export { createCapabilityCatalogAdapter, createMcpServerAdapter as createEnhanceMcpServer, toCapabilityInventory, toSharedCapabilities };
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { $ as createCanvasConversionOutputSchema, B as getMeOutputSchema, C as CliError, F as getPrototypeArtifactCapabilitiesOutputSchema, G as beginCanvasActivityOutputSchema, H as cliAuthConfigurationSchema, I as getPrototypePublishStatusOutputSchema, J as applyCanvasOperationsOutputSchema, L as prototypeArtifactManifestSchema, M as attachPrototypeArtifactOutputSchema, N as createPrototypeArtifactOutputSchema, P as foldPrototypeArtifactPath, R as prototypeArtifactPathSchema, S as PartialBatchError, U as createAgentTokenOutputSchema, Z as getCanvasDocumentOutputSchema, _ as canvasWriteHtmlCapabilityInputSchema, at as downloadCanvasRenderOutputSchema, b as recordingSnapshotCapabilityInputSchema, et as getCanvasConversionOutputSchema, g as canvasRenderCapabilityInputSchema, h as canvasApplyCapabilityInputSchema, it as createRecordingSnapshotOutputSchema, j as PROTOTYPE_ARTIFACT_MANIFEST_PATH, ot as getCanvasRenderOutputSchema, rt as createCanvasRenderOutputSchema, st as canvasSceneDocumentSchema, v as commentAttentionCapabilityInputSchema, w as transcriptOutputSchema, x as transcriptReadCapabilityInputSchema, y as prototypePublishCapabilityInputSchema, z as submitPrototypeArtifactOutputSchema } from "./cli-output-identity.lib-BSUBcRJm.mjs";
2
+ import { B as getMeOutputSchema, C as CliError, F as getPrototypeArtifactCapabilitiesOutputSchema, H as cliAuthConfigurationSchema, I as getPrototypePublishStatusOutputSchema, L as prototypeArtifactManifestSchema, M as attachPrototypeArtifactOutputSchema, N as createPrototypeArtifactOutputSchema, P as foldPrototypeArtifactPath, R as prototypeArtifactPathSchema, S as PartialBatchError, U as createAgentTokenOutputSchema, X as applyCanvasOperationsOutputSchema, _ as canvasWriteHtmlCapabilityInputSchema, b as recordingSnapshotCapabilityInputSchema, ct as downloadCanvasRenderOutputSchema, et as getCanvasDocumentOutputSchema, g as canvasRenderCapabilityInputSchema, h as canvasApplyCapabilityInputSchema, j as PROTOTYPE_ARTIFACT_MANIFEST_PATH, lt as getCanvasRenderOutputSchema, nt as createCanvasConversionOutputSchema, ot as createCanvasRenderOutputSchema, q as beginCanvasActivityOutputSchema, rt as getCanvasConversionOutputSchema, st as createRecordingSnapshotOutputSchema, ut as canvasReadableSceneDocumentSchema, v as commentAttentionCapabilityInputSchema, w as transcriptOutputSchema, x as transcriptReadCapabilityInputSchema, y as prototypePublishCapabilityInputSchema, z as submitPrototypeArtifactOutputSchema } from "./cli-output-identity.lib-bX6NwZjd.mjs";
3
3
  import { z } from "zod";
4
4
  import { homedir, tmpdir } from "node:os";
5
5
  import process from "node:process";
@@ -44,13 +44,16 @@ const createAuthUseCase = (credentials, remote, browser) => ({
44
44
  clientId: configuration.clientId,
45
45
  scope: configuration.scope,
46
46
  openBrowser: input.openBrowser,
47
- onReady: input.onReady
47
+ onReady: input.onReady,
48
+ ...input.signal !== void 0 && { signal: input.signal }
48
49
  });
50
+ input.signal?.throwIfAborted();
49
51
  const created = createAgentTokenOutputSchema.parse(await remote.mutateWithToken("person.createAgentToken", {
50
52
  label: input.label,
51
53
  expiresAt: null
52
54
  }, accessToken));
53
55
  const status = authenticated(await remote.queryWithToken("person.me", {}, created.token));
56
+ input.signal?.throwIfAborted();
54
57
  await credentials.write(created.token);
55
58
  return status;
56
59
  },
@@ -296,7 +299,7 @@ const activityNodeIds = (input) => [...new Set(input.operations.flatMap((operati
296
299
  const operationBox = (operation) => {
297
300
  if (operation.op === "insertConvertedSubtree") return operation.nodes[operation.rootNodeId]?.box ?? null;
298
301
  if (operation.op === "insertNode") return operation.node.box ?? null;
299
- if (hasOperationBox(operation)) return operation.box;
302
+ if (hasOperationBox(operation)) return operation.box === "default" ? null : operation.box;
300
303
  return null;
301
304
  };
302
305
  const union = (boxes) => {
@@ -320,7 +323,10 @@ const union = (boxes) => {
320
323
  };
321
324
  };
322
325
  const apply = async (remote, input) => {
323
- const response = await remote.mutate(APPLY_PROCEDURE, input);
326
+ const response = await remote.mutate(APPLY_PROCEDURE, {
327
+ ...input,
328
+ documentFormatVersion: 3
329
+ });
324
330
  const parsed = applyCanvasOperationsOutputSchema.safeParse(response);
325
331
  if (!parsed.success) throw new CliError("INTERNAL", "The API returned an invalid canvas apply response.", "Run `enhance doctor`; report the API and CLI versions if they differ.");
326
332
  return parsed.data;
@@ -444,7 +450,7 @@ const renderReview = async (render, input, imported) => {
444
450
  const createdNodes = async (remote, imported) => {
445
451
  const held = getCanvasDocumentOutputSchema.safeParse(await remote.query(READ_DOCUMENT_PROCEDURE, { canvasId: imported.canvasId }));
446
452
  if (!held.success) throw invalidResponse$1("canvas document");
447
- const scene = canvasSceneDocumentSchema.safeParse(held.data.document);
453
+ const scene = canvasReadableSceneDocumentSchema.safeParse(held.data.document);
448
454
  if (!scene.success) throw invalidResponse$1("editable canvas document");
449
455
  return imported.result.insertedNodeIds.map((nodeId) => {
450
456
  const node = scene.data.nodes[nodeId];
@@ -1066,6 +1072,7 @@ const authorizeUrl = (input) => {
1066
1072
  return authorize.href;
1067
1073
  };
1068
1074
  const authorizationCode = async (input) => {
1075
+ input.signal?.throwIfAborted();
1069
1076
  const completion = Promise.withResolvers();
1070
1077
  const server = createServer((request, response) => {
1071
1078
  handleCallback({
@@ -1087,18 +1094,24 @@ const authorizationCode = async (input) => {
1087
1094
  ...input,
1088
1095
  redirectUri
1089
1096
  });
1090
- input.onReady(url);
1091
- if (input.openBrowser) launchBrowser(url);
1097
+ const abort = () => {
1098
+ completion.reject(/* @__PURE__ */ new Error("browser authorization cancelled"));
1099
+ };
1100
+ input.signal?.addEventListener("abort", abort, { once: true });
1092
1101
  const timeout = setTimeout(() => {
1093
1102
  completion.reject(/* @__PURE__ */ new Error("browser authorization timed out"));
1094
1103
  }, AUTHORIZATION_TIMEOUT_MS);
1095
1104
  try {
1105
+ input.signal?.throwIfAborted();
1106
+ input.onReady(url);
1107
+ if (input.openBrowser) launchBrowser(url);
1096
1108
  return {
1097
1109
  code: await completion.promise,
1098
1110
  redirectUri
1099
1111
  };
1100
1112
  } finally {
1101
1113
  clearTimeout(timeout);
1114
+ input.signal?.removeEventListener("abort", abort);
1102
1115
  await new Promise((resolve) => {
1103
1116
  server.close(() => {
1104
1117
  resolve();
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { B as getMeOutputSchema, V as MCP_AUTH_SCOPE, l as createCapabilityCatalogAdapter } from "./cli-output-identity.lib-BSUBcRJm.mjs";
3
- import { i as readRemoteMcpEnvironment, n as createHttpRemoteAdapter, t as createMutationKeyAdapter } from "./mutation-key.adapter-EvvklGSw.mjs";
4
- import { t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-Bn41hcLB.mjs";
5
- import { t as createMcpServerAdapter } from "./mcp-server.adapter-lxpsuDlU.mjs";
2
+ import { B as getMeOutputSchema, V as MCP_AUTH_SCOPE, l as createCapabilityCatalogAdapter } from "./cli-output-identity.lib-bX6NwZjd.mjs";
3
+ import { i as readRemoteMcpEnvironment, n as createHttpRemoteAdapter, t as createMutationKeyAdapter } from "./mutation-key.adapter-p1odGHfg.mjs";
4
+ import { t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-BdZ-LpPW.mjs";
5
+ import { t as createMcpServerAdapter } from "./mcp-server.adapter-DBlOw4BM.mjs";
6
6
  import os from "node:os";
7
7
  import process from "node:process";
8
8
  import path from "node:path";
@@ -145,7 +145,7 @@ const server = await createRemoteMcpHttpAdapter({
145
145
  configDirectory: path.join(os.tmpdir(), "enhance-remote-mcp"),
146
146
  allowedHosts: config.MCP_ALLOWED_HOSTS.split(",").map((value) => value.trim()),
147
147
  allowedOrigins: config.MCP_ALLOWED_ORIGINS.split(",").map((value) => value.trim()),
148
- version: "0.1.7",
148
+ version: "0.1.14",
149
149
  onerror: (error) => process.stderr.write(`${error.message}\n`)
150
150
  });
151
151
  await server.listen(config.PORT, config.MCP_HOST);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enhance-eng/enhance",
3
- "version": "0.1.7",
3
+ "version": "0.1.14",
4
4
  "private": false,
5
5
  "description": "Agent-first command-line interface for Enhance.",
6
6
  "keywords": [
@@ -1,64 +0,0 @@
1
- #!/usr/bin/env node
2
- import { a as createOauthLoopbackAdapter, f as createAuthUseCase, n as createHttpRemoteAdapter, o as createCapabilityInvocationAdapter, t as createMutationKeyAdapter } from "./mutation-key.adapter-EvvklGSw.mjs";
3
- import { z } from "zod";
4
-
5
- //#region src/infrastructure/mcp-invocation.adapter.ts
6
- const TRANSPORT_CAPABILITIES = /* @__PURE__ */ new Set([
7
- "auth.login",
8
- "auth.logout",
9
- "auth.status",
10
- "doctor"
11
- ]);
12
- const loginInputSchema = z.object({ openBrowser: z.boolean() });
13
- const invokeTransport = async (input) => {
14
- const auth = createAuthUseCase(input.credentials, input.remote, createOauthLoopbackAdapter(input.remote));
15
- switch (input.capability) {
16
- case "auth.login": {
17
- const offered = loginInputSchema.parse(input.arguments);
18
- return auth.loginWithBrowser({
19
- label: "Agent plugin",
20
- openBrowser: offered.openBrowser,
21
- onReady: () => null
22
- });
23
- }
24
- case "auth.logout": return auth.logout();
25
- case "auth.status":
26
- if (await input.credentials.read() === null) return { authenticated: false };
27
- return auth.status();
28
- case "doctor": {
29
- const [api, credential] = await Promise.all([input.remote.health(), input.credentials.read()]);
30
- return {
31
- status: credential !== null && api.reachable ? "ok" : "degraded",
32
- runtimeVersion: input.version,
33
- api: {
34
- reachable: api.reachable,
35
- status: api.status,
36
- ...api.error !== void 0 && { error: api.error }
37
- },
38
- credential: { present: credential !== null }
39
- };
40
- }
41
- default: throw new TypeError(`${input.capability} has no MCP transport execution`);
42
- }
43
- };
44
- const createMcpInvocationAdapter = (apiUrl, credentials, configDirectory, version) => {
45
- const transportRemote = createHttpRemoteAdapter(apiUrl, credentials, createMutationKeyAdapter());
46
- return { invoke: async (request) => {
47
- if (TRANSPORT_CAPABILITIES.has(request.capability.id)) return invokeTransport({
48
- capability: request.capability.id,
49
- arguments: request.arguments,
50
- credentials,
51
- remote: transportRemote,
52
- version
53
- });
54
- const mutationKey = createMutationKeyAdapter();
55
- return createCapabilityInvocationAdapter({
56
- remote: createHttpRemoteAdapter(apiUrl, credentials, mutationKey),
57
- mutationKey,
58
- configDirectory
59
- }).invoke(request);
60
- } };
61
- };
62
-
63
- //#endregion
64
- export { createMcpInvocationAdapter as t };