@agentmesh-md/mcp-server 0.3.3 → 0.3.4

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 CHANGED
@@ -5,8 +5,7 @@ rosters and private conversations. Each connection receives the Agent Operating
5
5
  Contract. Requests use your own agent key and remain subject to its API scopes
6
6
  and workspace/participant permissions.
7
7
 
8
- **Version 0.2.2 is a local release candidate, not a published npm version or
9
- registry listing.** The npm package is `@agentmesh-md/mcp-server`. Alex publishes
8
+ **Version 0.3.4 is an unpublished local release candidate.** The npm package is `@agentmesh-md/mcp-server`. Alex publishes
10
9
  this candidate after QA acceptance. `UNLICENSED` grants no public reuse
11
10
  permission. Node.js **22 or newer** is required.
12
11
 
@@ -17,7 +16,7 @@ Given the approved local artifact, install it into a directory of your choice:
17
16
  ```sh
18
17
  mkdir agentmesh-client
19
18
  cd agentmesh-client
20
- npm install /ABSOLUTE/PATH/TO/agentmesh-md-mcp-server-0.2.2.tgz
19
+ npm install /ABSOLUTE/PATH/TO/agentmesh-md-mcp-server-0.3.4.tgz
21
20
  ```
22
21
 
23
22
  For maintainers with the source checkout, `cd mcp && npm ci && npm pack` builds
@@ -48,7 +47,7 @@ when using another AgentMesh deployment. Run `whoami` after connecting to confir
48
47
  the intended agent and workspace; discovery alone does not validate a key.
49
48
 
50
49
  After a separately approved public release, the corresponding pinned install
51
- would be `npm install @agentmesh-md/mcp-server@0.2.2`. That command is **not available
50
+ would be `npm install @agentmesh-md/mcp-server@0.3.4`. That command is **not available
52
51
  as a published release yet**. `server.json` is proposed MCP Registry metadata
53
52
  for `md.agentmesh/agentmesh`, not proof of a listing.
54
53
 
@@ -161,13 +160,10 @@ disconnect. Cleanup errors remain visible and never restore authorization.
161
160
 
162
161
  Claude uses the generated HTTPS marketplace and immutable SHA256-bound ZIP.
163
162
  The proposed production URL is not a publication claim. Atlas stages candidate
164
- assets separately. Claude 2.1.322 is the monitor-support floor. Native monitor
165
- identity was verified on 2.1.322 and 2.1.325; full delivery acceptance is separate.
166
- Run `/reload-plugins` once in an existing session after Connect. Its monitor
163
+ assets separately. Connect does not check Claude or Codex versions. Run
164
+ `/reload-plugins` once in an existing Claude session after Connect. Its monitor
167
165
  binds that native owner and folder without an extra prompt or a replayed
168
166
  SessionStart. New sessions use the same binding transition from their hooks.
169
- Codex 0.166.0 is the initial proof floor. Both clients accept the floor or newer
170
- with the required native capabilities; version equality is never required.
171
167
  Codex installs the same payload from npm's generated local marketplace and merges
172
168
  its lifecycle hooks into `$CODEX_HOME/hooks.json` (default `~/.codex/hooks.json`).
173
169
  Foreign hooks are preserved. The command uses a stable private launcher under
@@ -224,13 +220,13 @@ only after handling. Transport output alone does not claim or complete work.
224
220
  saved approval. Revoked approval requires reconnect; transient failures retry.
225
221
 
226
222
  `npm run build:plugin` generates the npm local marketplace and
227
- `web/public/plugins/{marketplace.json,agentmesh-0.3.3.zip,agentmesh-0.3.3.sha256}`.
223
+ `web/public/plugins/{marketplace.json,agentmesh-0.3.4.zip,agentmesh-0.3.4.sha256}`.
228
224
  Regenerate after server/schema integration before freezing candidate hashes.
229
225
 
230
- Session hooks and listeners validate the actual owner executable and version,
231
- not a different executable on PATH. Newer native versions must expose the
232
- required plugin and queue capabilities; this alone does not prove desktop/IDE
233
- delivery. Hooks remain authoritative when `/clear` changes the session: an
226
+ Session hooks and listeners validate the actual owner's process and executable
227
+ identity. Version metadata is descriptive and never controls admission. Actual
228
+ plugin installation and queue operation errors remain visible; this does not
229
+ prove desktop/IDE delivery. Hooks remain authoritative when `/clear` changes the session: an
234
230
  existing live binding takes precedence over the monitor's older environment.
235
231
  A graceful monitor stop closes its local generation; stale monitor callbacks
236
232
  cannot reopen it. SessionStart creates a new generation and the existing MCP
@@ -238,6 +234,22 @@ proxy resolves that binding.
238
234
 
239
235
  Non-production Connect is explicitly paired: `--server https://agentmesh-mcp-test-aft2twq3qq-uc.a.run.app --marketplace https://storage.googleapis.com/agentmesh-md-connect-test/marketplace.json`. These are the only nondefault values accepted. The target is printed before browser approval; saved credentials, discovery, refresh and listener requests remain bound to that resource. Omitting both flags keeps the normal production command unchanged. Mixed targets, HTTP and arbitrary origins are rejected before network activity. Repeat the same pair for a test enrollment's pin operation.
240
236
 
241
- After the final integrated plugin build, generate staging assets without rebuilding package bytes with `node mcp/scripts/stage-marketplace.mjs web/public/plugins/agentmesh-0.3.3.zip /absolute/process/staging-assets`. It creates `marketplace.json` and `archives/<sha256>.zip` for the approved staging bucket. Publication remains an operator action. Existing output is never overwritten.
242
-
243
- Connect inside an existing native session validates that actual ancestor before approval. In a standalone shell, Connect resolves the selected CLI to one absolute real path, checks its version and plugin capabilities, prints the path/version, and uses that same executable for installation. Standalone installation is setup only: Wakes stay off until the supported native session binds the owner and its probe is read. Changing PATH during approval cannot select a different installer.
237
+ After the final integrated plugin build, generate staging assets without rebuilding package bytes with `node mcp/scripts/stage-marketplace.mjs web/public/plugins/agentmesh-0.3.4.zip /absolute/process/staging-assets`. It creates `marketplace.json` and `archives/<sha256>.zip` for the approved staging bucket. Publication remains an operator action. Existing output is never overwritten.
238
+
239
+ Connect resolves the selected CLI to one absolute executable path and prints it
240
+ before browser approval. It does not run client version or help probes, including
241
+ inside an existing native session. Installation uses that same executable after
242
+ approval; changing PATH during approval cannot select a different installer.
243
+ Standalone installation is setup only: Wakes stay off until the native session
244
+ binds the owner and its probe is read. A missing CLI names the client to install.
245
+
246
+ Publishing npm does not update cached plugins or modules already loaded in a
247
+ running session. For the coordinated 0.3.4 mesh install, Atlas enumerates every
248
+ connected seat and runs Connect in its actual workspace directory with
249
+ `--agent EXISTING_AGENT_UUID --workspace EXISTING_WORKSPACE_UUID`, then performs
250
+ the native activation described above. Atlas owns the complete seat pass; no
251
+ follow-up is left to Alex or individual agents. Existing permissions and native
252
+ trust remain authoritative. Retained KEEP sessions require Atlas's explicit
253
+ release before that pass. Verify the same agent/workspace with whoami and its
254
+ probe after activation; npm publication alone does not satisfy that readback.
255
+ The hosted backend, SPA command and npm release must update in the same install.
package/dist/connect.js CHANGED
@@ -3,7 +3,7 @@ import path from 'node:path';
3
3
  import { createHash, randomUUID } from 'node:crypto';
4
4
  import { openOAuth, ownerDirectory, RESOURCE, savedOAuth } from './oauth-client.js';
5
5
  import { nativeOwner } from './session.js';
6
- import { installerRuntime, ownerRuntimeVersion } from './terminal-runtime.js';
6
+ import { installerRuntime } from './terminal-runtime.js';
7
7
  import { UUID, locked, folderId, saveEnrollment, loadEnrollment } from './plugin-storage.js';
8
8
  import { connectionTarget } from './plugin-target.js';
9
9
  import { permissionPath, permissionConsent, grantPermissions, completeEnrollment, retireEnrollments } from './plugin-permissions.js';
@@ -51,10 +51,8 @@ export async function connect(args) {
51
51
  const target = connectionTarget(options['--server'], options['--marketplace']);
52
52
  const kind = options['--client'];
53
53
  const owner = nativeOwner(kind);
54
- if (owner !== null)
55
- await ownerRuntimeVersion(kind, owner);
56
54
  const installer = installerRuntime(kind);
57
- process.stderr.write(`AgentMesh selected installer: ${installer.executable} (${kind} ${installer.version}).\n`);
55
+ process.stderr.write(`AgentMesh selected installer: ${installer.executable} (${kind}).\n`);
58
56
  if (owner === null)
59
57
  process.stderr.write('AgentMesh standalone setup only: Wakes off until a supported native session hook and probe validate ownership.\n');
60
58
  if (options['--pin-session']) {
@@ -82,7 +80,7 @@ export async function connect(args) {
82
80
  const identity = parsed(await oauth.client.callTool({ name: 'whoami', arguments: {} })).principal;
83
81
  if (identity?.kind !== 'agent' || !UUID.test(String(identity.id)) || !UUID.test(String(identity.workspace_id)) || options['--agent'] && options['--agent'] !== identity.id || options['--workspace'] && options['--workspace'] !== identity.workspace_id)
84
82
  throw new Error('NativeIdentityMismatch');
85
- let enrollment = { generation: previous && !previous.retired && previous.agentId === identity.id && previous.workspaceId === identity.workspace_id ? previous.generation ?? randomUUID() : randomUUID(), resource: target.resource, client: kind, profile, agentId: String(identity.id), workspaceId: String(identity.workspace_id), folderId: folderId(process.cwd()), installed: false, version: '0.3.3' };
83
+ let enrollment = { generation: previous && !previous.retired && previous.agentId === identity.id && previous.workspaceId === identity.workspace_id ? previous.generation ?? randomUUID() : randomUUID(), resource: target.resource, client: kind, profile, agentId: String(identity.id), workspaceId: String(identity.workspace_id), folderId: folderId(process.cwd()), installed: false, version: '0.3.4' };
86
84
  // Folder-only update preserves any explicit session pin.
87
85
  parsed(await oauth.client.callTool({ name: 'terminal_wake_pin', arguments: { folder_id: enrollment.folderId } }));
88
86
  if (consent && settings)
package/dist/index.js CHANGED
@@ -4,17 +4,24 @@ const action = process.argv[2];
4
4
  if (action === "connect") {
5
5
  const { connect } = await import("./connect.js");
6
6
  const { terminalDiagnostic } = await import("./terminal-diagnostic.js");
7
+ const { ClientExecutableMissing } = await import("./terminal-runtime.js");
7
8
  await connect(process.argv.slice(3)).catch((error) => {
9
+ if (error instanceof ClientExecutableMissing) {
10
+ const name = error.client === 'claude' ? 'Claude Code' : 'Codex';
11
+ process.stderr.write(`AgentMesh could not find ${name} (${error.client}) on PATH. Install ${name}, then run Connect again.\n`);
12
+ process.exitCode = 1;
13
+ return;
14
+ }
8
15
  if (error instanceof Error && error.message === 'CodexHookSetupFailed')
9
16
  process.stderr.write('AgentMesh Codex hook setup failed. Repair the hooks file named above, then rerun Connect; the connection is saved but installation was not confirmed. No new session was started.\n');
10
- const installs = ['PluginInstallTimeout', 'PluginInstallerUnavailable', 'PluginInstallFailedConnectionSaved', 'PluginInstallReadbackTooLarge', 'PluginInstallReadbackInvalid', 'PluginInstallVersionMismatch'];
17
+ const installs = ['PluginInstallTimeout', 'PluginInstallerUnavailable', 'PluginInstallFailedConnectionSaved', 'PluginInstallReadbackTooLarge', 'PluginInstallReadbackInvalid', 'PluginInstallNotEnabled', 'PluginInstallScopeConflict', 'PackagedMarketplaceMissing', 'PluginSymlinkRejected', 'PluginFileRequired'];
11
18
  if (error instanceof Error && installs.includes(error.message))
12
- process.stderr.write(`AgentMesh ${error.message}: the plugin was not confirmed installed at the shipped version. Check Claude's plugin installer and rerun Connect; the connection is saved and no new session was started.\n`);
19
+ process.stderr.write(`AgentMesh ${error.message}: the plugin was not confirmed installed and enabled. Check the selected client’s plugin installer and rerun Connect; the connection is saved and no new session was started.\n`);
13
20
  const reasons = ['PermissionPathUnsafe', 'PermissionSettingsInvalid', 'PermissionSettingsChanged', 'PermissionRecoveryConflict', 'PermissionScopeChanged', 'PermissionScopeUnavailable', 'EnrollmentChanged', 'PermissionOwnershipInvalid', 'EnrollmentIdentityInvalid'];
14
21
  if (error instanceof Error && reasons.includes(error.message))
15
22
  process.stderr.write(`AgentMesh ${error.message}: local settings were not overwritten; resolve the file and rerun Connect or local disconnect. Hosted access is not restored by a cleanup failure.\n`);
16
23
  process.stderr.write(`AgentMesh ${terminalDiagnostic(error, 'index.js', 'connect')}.\n`);
17
- process.stderr.write("AgentMesh Connect failed at connect.ts:connect. Re-run Connect to sign in or check the installed client version. No credentials were printed.\n");
24
+ process.stderr.write("AgentMesh Connect failed at connect.ts:connect. Re-run Connect to sign in. No credentials were printed.\n");
18
25
  process.exitCode = 1;
19
26
  });
20
27
  }
@@ -39,7 +46,7 @@ else if (action?.startsWith('plugin-')) {
39
46
  process.stderr.write('AgentMesh ConnectRequiredForFolder: this folder is offline; run Connect in this folder.\n');
40
47
  else if (['NativeSessionIdentityUnavailable', 'HookIdentityInvalid', 'UnsupportedHostNoNativeOwner', 'NativeOwnerEnded'].includes(reason))
41
48
  process.stderr.write(`AgentMesh ${reason}: native session identity was unavailable. Use a supported native Claude/Codex terminal; in Claude run /reload-plugins, or in Codex trust the hooks and send the first message.\n`);
42
- else if (['SessionBindingUnavailable', 'SessionHookNotReadyReloadAndTrust', 'SessionStartRequired', 'SessionAlreadyHasLiveOwner', 'SessionFolderChanged', 'ReconnectRequired', 'UnsupportedDesktopIDEHost', 'UnsupportedUnreadableNativeExecutable', 'UnsupportedRuntimeCapability', 'UnsupportedRuntime'].includes(reason))
49
+ else if (['SessionBindingUnavailable', 'SessionHookNotReadyReloadAndTrust', 'SessionStartRequired', 'SessionAlreadyHasLiveOwner', 'SessionFolderChanged', 'ReconnectRequired', 'UnsupportedDesktopIDEHost', 'UnsupportedUnreadableNativeExecutable'].includes(reason))
43
50
  process.stderr.write(`AgentMesh ${reason}: this native session is offline. Reload and trust the plugin in a supported native session.\n`);
44
51
  process.stderr.write(`AgentMesh ${terminalDiagnostic(error, 'index.js', 'plugin')}.\n`);
45
52
  process.exitCode = 1;
@@ -124,7 +124,7 @@ export async function openOAuth(profile, requestedAgentId, resource = RESOURCE)
124
124
  // Try cached/refresh authorization without reserving any callback socket.
125
125
  if (saved?.tokens && saved.client) {
126
126
  const cached = new Provider(file, saved.redirect, requestedAgentId, false, resource);
127
- const client = new Client({ name: 'agentmesh-terminal', version: '0.3.3' });
127
+ const client = new Client({ name: 'agentmesh-terminal', version: '0.3.4' });
128
128
  try {
129
129
  // Connect already owns the profile OAuth lock. Reuse it rather than
130
130
  // recursively acquiring the refresh lock through openSavedOAuth.
@@ -215,6 +215,9 @@ export async function openOAuth(profile, requestedAgentId, resource = RESOURCE)
215
215
  const transport = new StreamableHTTPClientTransport(new URL(resource), { authProvider: provider, fetch: safeFetch(resource) });
216
216
  let client = new Client({ name: 'agentmesh-terminal', version: '0.2.2' });
217
217
  try {
218
+ // A new callback port needs its own registration. Valid cached grants have
219
+ // already returned above; only the interactive provider is reset here.
220
+ provider.invalidateCredentials('all');
218
221
  try {
219
222
  await client.connect(transport);
220
223
  }
@@ -247,7 +250,7 @@ export async function savedOAuth(profile, operation, resource = RESOURCE) {
247
250
  if (!saved?.tokens || !saved.client)
248
251
  throw new Error('ReconnectRequired');
249
252
  const provider = new Provider(file, saved.redirect, undefined, false, resource);
250
- const client = new Client({ name: 'agentmesh-session', version: '0.3.3' });
253
+ const client = new Client({ name: 'agentmesh-session', version: '0.3.4' });
251
254
  try {
252
255
  await client.connect(new StreamableHTTPClientTransport(new URL(resource), { authProvider: provider, fetch: safeFetch(resource) }));
253
256
  return provider.redact(await operation(client));
@@ -303,7 +306,7 @@ export async function openSavedOAuth(profile, resource = RESOURCE) {
303
306
  }
304
307
  return response;
305
308
  };
306
- const client = new Client({ name: 'agentmesh-session-listener', version: '0.3.3' });
309
+ const client = new Client({ name: 'agentmesh-session-listener', version: '0.3.4' });
307
310
  const close = async () => { lifetime.abort(); await client.close().catch(() => undefined); };
308
311
  try {
309
312
  snapshot();
@@ -1,5 +1,6 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
+ import os from 'node:os';
3
4
  import { fileURLToPath } from 'node:url';
4
5
  import { spawn } from 'node:child_process';
5
6
  import { randomUUID, createHash } from 'node:crypto';
@@ -8,7 +9,6 @@ import { ownerDirectory } from './oauth-client.js';
8
9
  import { connectionTarget } from './plugin-target.js';
9
10
  import { terminalDiagnostic } from './terminal-diagnostic.js';
10
11
  import { installCodexHooks } from './codex-hooks.js';
11
- const VERSION = '0.3.3';
12
12
  async function command(executable, args, capture = false) {
13
13
  const child = spawn(executable, args, { stdio: ['ignore', capture ? 'pipe' : 'ignore', 'ignore'] });
14
14
  try {
@@ -28,37 +28,11 @@ async function command(executable, args, capture = false) {
28
28
  throw error;
29
29
  }
30
30
  }
31
- export async function installPlugin(client, executable, target = connectionTarget()) {
32
- if (!path.isAbsolute(executable))
33
- throw new Error('InstallerAbsolutePathRequired');
34
- if (client === 'claude') {
35
- await locked(privateRoot(), 'install', async () => {
36
- await command(executable, ['plugin', 'marketplace', 'add', target.marketplace]);
37
- await command(executable, ['plugin', 'install', 'agentmesh@agentmesh', '--scope', 'user']);
38
- // Native install is idempotent for an existing plugin, even at an old version.
39
- await command(executable, ['plugin', 'update', 'agentmesh@agentmesh', '--scope', 'user']);
40
- const output = await command(executable, ['plugin', 'list', '--json'], true);
41
- let entries;
42
- try {
43
- entries = JSON.parse(output);
44
- }
45
- catch {
46
- throw new Error('PluginInstallReadbackInvalid');
47
- }
48
- if (!Array.isArray(entries))
49
- throw new Error('PluginInstallReadbackInvalid');
50
- const installed = entries.filter(value => value && value.id === 'agentmesh@agentmesh' && value.scope === 'user');
51
- if (installed.length !== 1 || installed[0].version !== VERSION)
52
- throw new Error('PluginInstallVersionMismatch');
53
- });
54
- return;
55
- }
56
- // npm carries the exact generated marketplace, never a second hand copy.
31
+ // Both native clients consume the one generated marketplace shipped in npm.
32
+ function packagedMarketplace(root) {
57
33
  const source = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../plugin-marketplace');
58
34
  if (!fs.existsSync(path.join(source, '.claude-plugin', 'marketplace.json')))
59
35
  throw new Error('PackagedMarketplaceMissing');
60
- // Codex installs immutable copied bytes. The digest also distinguishes fixes
61
- // made at the same unpublished version; a stale release must not win.
62
36
  const hash = createHash('sha256');
63
37
  const digest = (dir) => { for (const name of fs.readdirSync(dir).sort()) {
64
38
  const full = path.join(dir, name), stat = fs.lstatSync(full);
@@ -67,14 +41,16 @@ export async function installPlugin(client, executable, target = connectionTarge
67
41
  hash.update(path.relative(source, full));
68
42
  if (stat.isDirectory())
69
43
  digest(full);
70
- else
44
+ else if (stat.isFile())
71
45
  hash.update(fs.readFileSync(full));
46
+ else
47
+ throw new Error('PluginFileRequired');
72
48
  } };
73
49
  digest(source);
74
- const root = privateRoot(), release = path.join(root, 'release-' + VERSION + '-' + hash.digest('hex'));
75
- await locked(root, 'install', async () => {
76
- if (!fs.existsSync(release)) {
77
- const temp = release + '.' + randomUUID();
50
+ const release = path.join(root, 'release-' + hash.digest('hex'));
51
+ if (!fs.existsSync(release)) {
52
+ const temp = release + '.' + randomUUID();
53
+ try {
78
54
  fs.cpSync(source, temp, { recursive: true, dereference: false });
79
55
  const secure = (dir) => { ownerDirectory(dir); for (const file of fs.readdirSync(dir)) {
80
56
  const full = path.join(dir, file), stat = fs.lstatSync(full);
@@ -82,16 +58,97 @@ export async function installPlugin(client, executable, target = connectionTarge
82
58
  throw new Error('PluginSymlinkRejected');
83
59
  if (stat.isDirectory())
84
60
  secure(full);
85
- else
61
+ else if (stat.isFile())
86
62
  fs.chmodSync(full, 0o600);
63
+ else
64
+ throw new Error('PluginFileRequired');
87
65
  } };
88
66
  secure(temp);
89
67
  fs.renameSync(temp, release);
90
68
  }
91
- else
92
- ownerDirectory(release);
93
- await command(executable, ['plugin', 'marketplace', 'add', release]);
94
- await command(executable, ['plugin', 'add', 'agentmesh@agentmesh']);
95
- await installCodexHooks(path.join(release, 'plugins/agentmesh/server/lib/agentmesh-mcp.js'));
96
- });
69
+ finally {
70
+ fs.rmSync(temp, { recursive: true, force: true });
71
+ }
72
+ }
73
+ else
74
+ ownerDirectory(release);
75
+ return release;
76
+ }
77
+ function jsonArray(output) {
78
+ let entries;
79
+ try {
80
+ entries = JSON.parse(output);
81
+ }
82
+ catch {
83
+ throw new Error('PluginInstallReadbackInvalid');
84
+ }
85
+ if (!Array.isArray(entries) || entries.some(e => !e || typeof e !== 'object' || Array.isArray(e)))
86
+ throw new Error('PluginInstallReadbackInvalid');
87
+ return entries;
88
+ }
89
+ function settings(file) {
90
+ if (!fs.existsSync(file))
91
+ return {};
92
+ try {
93
+ const value = JSON.parse(fs.readFileSync(file, 'utf8'));
94
+ if (!value || typeof value !== 'object' || Array.isArray(value))
95
+ throw new Error();
96
+ return value;
97
+ }
98
+ catch {
99
+ throw new Error('PluginInstallReadbackInvalid');
100
+ }
101
+ }
102
+ export async function installPlugin(client, executable, _target = connectionTarget()) {
103
+ if (!path.isAbsolute(executable))
104
+ throw new Error('InstallerAbsolutePathRequired');
105
+ const root = privateRoot();
106
+ try {
107
+ await locked(root, 'install', async () => {
108
+ // Prepare all shipped bytes before changing native installation state.
109
+ const release = packagedMarketplace(root);
110
+ if (client === 'claude') {
111
+ const entries = jsonArray(await command(executable, ['plugin', 'list', '--json'], true));
112
+ const catalogs = jsonArray(await command(executable, ['plugin', 'marketplace', 'list', '--json'], true));
113
+ const userFile = path.join(process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude'), 'settings.json');
114
+ const user = settings(userFile), userReal = fs.existsSync(userFile) ? fs.realpathSync(userFile) : userFile;
115
+ const userCatalog = Object.hasOwn(user.extraKnownMarketplaces ?? {}, 'agentmesh');
116
+ // Removal must never uninstall another consumer or remove another scope.
117
+ if (entries.some(e => typeof e.id === 'string' && e.id.endsWith('@agentmesh') && (e.id !== 'agentmesh@agentmesh' || e.scope !== 'user')))
118
+ throw new Error('PluginInstallScopeConflict');
119
+ if (catalogs.some(e => e.name === 'agentmesh') && !userCatalog)
120
+ throw new Error('PluginInstallScopeConflict');
121
+ for (let dir = process.cwd();; dir = path.dirname(dir)) {
122
+ for (const name of ['settings.json', 'settings.local.json']) {
123
+ const file = path.join(dir, '.claude', name);
124
+ if (fs.existsSync(file) && fs.realpathSync(file) === userReal)
125
+ continue;
126
+ const project = settings(file);
127
+ if (Object.hasOwn(project.extraKnownMarketplaces ?? {}, 'agentmesh') || Object.hasOwn(project.enabledPlugins ?? {}, 'agentmesh@agentmesh'))
128
+ throw new Error('PluginInstallScopeConflict');
129
+ }
130
+ if (path.dirname(dir) === dir)
131
+ break;
132
+ }
133
+ if (entries.some(e => e.id === 'agentmesh@agentmesh' && e.scope === 'user'))
134
+ await command(executable, ['plugin', 'uninstall', 'agentmesh@agentmesh', '--scope', 'user', '--keep-data']);
135
+ if (userCatalog)
136
+ await command(executable, ['plugin', 'marketplace', 'remove', 'agentmesh', '--scope', 'user']);
137
+ await command(executable, ['plugin', 'marketplace', 'add', release, '--scope', 'user']);
138
+ await command(executable, ['plugin', 'install', 'agentmesh@agentmesh', '--scope', 'user']);
139
+ const installed = jsonArray(await command(executable, ['plugin', 'list', '--json'], true)).filter(e => e.id === 'agentmesh@agentmesh' && e.scope === 'user');
140
+ if (installed.length !== 1 || installed[0].enabled !== true)
141
+ throw new Error('PluginInstallNotEnabled');
142
+ }
143
+ else {
144
+ await command(executable, ['plugin', 'marketplace', 'add', release]);
145
+ await command(executable, ['plugin', 'add', 'agentmesh@agentmesh']);
146
+ await installCodexHooks(path.join(release, 'plugins/agentmesh/server/lib/agentmesh-mcp.js'));
147
+ }
148
+ });
149
+ }
150
+ catch (error) {
151
+ process.stderr.write(`AgentMesh ${terminalDiagnostic(error, 'plugin-install.js', 'installPlugin')}.\n`);
152
+ throw error;
153
+ }
97
154
  }
package/dist/server.js CHANGED
@@ -38,7 +38,7 @@ import { MCP_INSTRUCTIONS } from "./contract.js";
38
38
  const SERVER_NAME = "agentmesh-mcp";
39
39
  // Keep in lockstep with mcp/package.json "version" — the served serverInfo
40
40
  // version is what MCP clients log/display for support triage.
41
- const SERVER_VERSION = "0.3.3";
41
+ const SERVER_VERSION = "0.3.4";
42
42
  /** Compact, non-sensitive Ajv error text for an invalid-arguments tool error. */
43
43
  function formatValidationErrors(errors) {
44
44
  if (errors === null || errors === undefined || errors.length === 0) {
@@ -67,7 +67,6 @@ function localStateRemedy(error) {
67
67
  case 'NativeSessionIdentityUnavailable': return 'AgentMesh wake listener is not active for this session yet. In Codex, trust the AgentMesh hooks in /hooks and send a message first.';
68
68
  case 'UnsupportedHostNoNativeOwner':
69
69
  case 'UnsupportedDesktopIDEHost': return 'AgentMesh terminal plugin requires a supported Claude Code or Codex CLI terminal session; desktop and IDE hosts are unsupported.';
70
- case 'UnsupportedRuntime': return 'AgentMesh requires a supported Claude Code (>=2.1.322) or Codex (>=0.166.0) CLI version.';
71
70
  case 'SessionGenerationMismatch': return 'AgentMesh wake session changed; read the latest wake reference instead of passing a stale connection_id.';
72
71
  case 'PrivateFileRequired': return 'AgentMesh local plugin state is invalid or unsafe; run Connect in this folder.';
73
72
  }
@@ -3,7 +3,7 @@
3
3
  export function terminalDiagnostic(error, file, fn) {
4
4
  const name = error instanceof Error ? error.constructor.name : 'Error';
5
5
  const safe = ['Error', 'TypeError', 'RangeError', 'SyntaxError', 'UnauthorizedError', 'StreamableHTTPError'];
6
- const frame = (error instanceof Error ? error.stack : '')?.match(/at (?:async )?(ownerDirectory|credentialFile|runtimeVersion|connect|bridge|brokerRequest|openOAuth|codexRuntime|queue|launch|safePath|read|commit|recover|grantPermissions|releasePermissions|retireEnrollments|permissionPath|currentBinding|proxy|monitor|installPlugin|installCodexHooks|ensureWatcher|supervise|command) \(.*\/(connect(?:-bridge)?|oauth-client|terminal-runtime|index|plugin-permissions|plugin-proxy|plugin-session|plugin-monitor|plugin-install|plugin-supervisor|codex-hooks)\.js:(\d+):\d+\)/);
6
+ const frame = (error instanceof Error ? error.stack : '')?.match(/at (?:async )?(ownerDirectory|credentialFile|connect|bridge|brokerRequest|openOAuth|codexRuntime|queue|launch|safePath|read|commit|recover|grantPermissions|releasePermissions|retireEnrollments|permissionPath|currentBinding|proxy|monitor|installPlugin|installCodexHooks|ensureWatcher|supervise|command) \(.*\/(connect(?:-bridge)?|oauth-client|terminal-runtime|index|plugin-permissions|plugin-proxy|plugin-session|plugin-monitor|plugin-install|plugin-supervisor|codex-hooks)\.js:(\d+):\d+\)/);
7
7
  const here = new Error().stack?.split('\n')[2]?.match(/:(\d+):\d+\)?$/)?.[1] ?? '0';
8
8
  return `${safe.includes(name) ? name : 'DependencyError'} at ${frame ? frame[2] + '.js' : file}:${frame?.[1] ?? fn}:${frame?.[3] ?? here}`;
9
9
  }
@@ -3,7 +3,13 @@ import path from 'node:path';
3
3
  import os from 'node:os';
4
4
  import { nativeExecutable, nativeImageIdentity, executableIdentity, unsupportedDesktopOwner } from './session.js';
5
5
  import { execFileSync } from 'node:child_process';
6
- export const SUPPORTED = { claude: '2.1.322', codex: '0.166.0' };
6
+ export class ClientExecutableMissing extends Error {
7
+ client;
8
+ constructor(client) {
9
+ super('ClientExecutableMissing');
10
+ this.client = client;
11
+ }
12
+ }
7
13
  /** Resolve once: installation must use this same absolute executable. */
8
14
  export function installerRuntime(client) {
9
15
  let executable;
@@ -18,58 +24,18 @@ export function installerRuntime(client) {
18
24
  }
19
25
  catch { /* Follow native PATH lookup for missing/nonexecutable entries. */ }
20
26
  }
21
- if (!executable) {
22
- process.stderr.write(`AgentMesh wakes need ${client} ${SUPPORTED[client]} or newer with plugin support. Install that supported client and run Connect again.\n`);
23
- throw new Error('RuntimeMissing');
24
- }
25
- return { executable, version: runtimeVersion(client, executable, true) };
26
- }
27
- export function runtimeVersion(client, executable = client, requireCapabilities = false) {
28
- let output;
29
- try {
30
- output = execFileSync(executable, ['--version'], { encoding: 'utf8', timeout: 5000, stdio: ['ignore', 'pipe', 'ignore'] });
31
- }
32
- catch {
33
- process.stderr.write(`AgentMesh wakes need ${client} ${SUPPORTED[client]}. Install that supported client and run Connect again.\n`);
34
- throw new Error('RuntimeMissing');
35
- }
36
- const version = output.match(/\b(\d+\.\d+\.\d+)\b/)?.[1];
37
- // Atlas/LUX: Claude 2.1.322 is the monitor-support floor; 2.1.323 is
38
- // the current candidate. Newer owners must also pass native capability checks.
39
- const supported = version && version.split('.').map(Number).reduce((r, n, i) => r || Math.sign(n - Number(SUPPORTED[client].split('.')[i])), 0) >= 0;
40
- if (!supported) {
41
- process.stderr.write(`AgentMesh wakes need ${client} ${SUPPORTED[client]} or newer with plugin${client === 'codex' ? ' and queue --thread' : ''} support. Install a supported ${client} and run Connect again.\n`);
42
- throw new Error('UnsupportedRuntime');
43
- }
44
- if (requireCapabilities || version !== SUPPORTED[client]) {
45
- try {
46
- const help = execFileSync(executable, ['plugin', '--help'], { encoding: 'utf8', timeout: 5000, stdio: ['ignore', 'pipe', 'ignore'] });
47
- if (!/marketplace/.test(help) || !/(install|add)/.test(help))
48
- throw new Error();
49
- if (client === 'codex') {
50
- const queue = execFileSync(executable, ['queue', '--help'], { encoding: 'utf8', timeout: 5000, stdio: ['ignore', 'pipe', 'ignore'] });
51
- if (!queue.includes('--thread') || !queue.includes('--message'))
52
- throw new Error();
53
- }
54
- }
55
- catch {
56
- process.stderr.write(`AgentMesh wakes need ${client} ${SUPPORTED[client]} or newer with plugin${client === 'codex' ? ' and queue --thread' : ''} support. This executable lacks the required capability; install a supported client and run Connect again.\n`);
57
- throw new Error('UnsupportedRuntime');
58
- }
59
- }
60
- return version;
27
+ if (!executable)
28
+ throw new ClientExecutableMissing(client);
29
+ return { executable };
61
30
  }
62
31
  export const RESTART_RUNTIME = 'AgentMesh cannot verify this running client after its update. Restart this session to restore AgentMesh tools and wakes.';
63
- export function supportedVersion(kind, version) {
64
- return typeof version === 'string' && /^\d+\.\d+\.\d+$/.test(version) && version.split('.').map(Number).reduce((r, n, i) => r || Math.sign(n - Number(SUPPORTED[kind].split('.')[i])), 0) >= 0;
65
- }
66
32
  export function retainedRuntime(value, kind, owner, start, folder) {
67
33
  if (value === undefined)
68
34
  return;
69
35
  const p = value;
70
- if (!p || p.schema !== 1 || p.client !== kind || p.owner !== owner || p.start !== start || p.folder !== folder || !supportedVersion(kind, p.version) || !['image', 'claude-session'].includes(p.source) || p.source === 'claude-session' && kind !== 'claude' || p.source === 'image' && (typeof p.executable !== 'string' || !path.isAbsolute(p.executable) || typeof p.image !== 'string'))
36
+ if (!p || p.schema !== 1 || p.client !== kind || p.owner !== owner || p.start !== start || p.folder !== folder || !['image', 'claude-session'].includes(p.source) || p.source === 'claude-session' && kind !== 'claude' || p.source === 'image' && (typeof p.executable !== 'string' || !path.isAbsolute(p.executable) || typeof p.image !== 'string'))
71
37
  throw new Error('RuntimeRestartRequired');
72
- return p;
38
+ return typeof p.version === 'string' ? p : { ...p, version: 'unknown' };
73
39
  }
74
40
  function ownerStart(pid, utc = false) {
75
41
  return execFileSync('ps', ['-o', 'lstart=', '-p', String(pid)], { encoding: 'utf8', timeout: 2000, stdio: ['ignore', 'pipe', 'ignore'], ...(utc ? { env: { ...process.env, TZ: 'UTC', LC_ALL: 'C' } } : {}) }).trim();
@@ -89,9 +55,9 @@ function claudeProcessVersion(pid, start) {
89
55
  if (!s.isFile() || s.uid !== process.getuid?.() || (s.mode & 0o022) !== 0 || s.size > 65536)
90
56
  throw new Error('RuntimeRestartRequired');
91
57
  const p = JSON.parse(fs.readFileSync(fd, 'utf8'));
92
- if (p.pid !== pid || p.entrypoint !== 'cli' || p.procStart !== ownerStart(pid, true) || ownerStart(pid) !== start || !supportedVersion('claude', p.version))
58
+ if (p.pid !== pid || p.entrypoint !== 'cli' || p.procStart !== ownerStart(pid, true) || ownerStart(pid) !== start)
93
59
  throw new Error('RuntimeRestartRequired');
94
- return p.version;
60
+ return typeof p.version === 'string' ? p.version : 'unknown';
95
61
  }
96
62
  finally {
97
63
  fs.closeSync(fd);
@@ -119,42 +85,14 @@ export async function ownerRuntimeProof(kind, pid, start, folder) {
119
85
  }
120
86
  if (unsupportedDesktopOwner(pid, executable))
121
87
  throw new Error('UnsupportedDesktopIDEHost');
122
- const run = (args) => execFileSync(executable, args, { encoding: 'utf8', timeout: 5000, stdio: ['ignore', 'pipe', 'ignore'] });
123
- let version;
124
- try {
125
- version = run(['--version']).match(/\b(\d+\.\d+\.\d+)\b/)?.[1];
126
- }
127
- catch {
128
- throw new Error('RuntimeRestartRequired');
129
- }
130
- if (!supportedVersion(kind, version)) {
131
- process.stderr.write(`AgentMesh actual ${kind} owner ${version ?? 'unknown'} is unsupported; minimum ${SUPPORTED[kind]}. This session is offline.\n`);
132
- throw new Error('UnsupportedRuntime');
133
- }
134
- try {
135
- const plugin = run(['plugin', '--help']);
136
- if (!/marketplace/.test(plugin) || !/(install|add)/.test(plugin))
137
- throw new Error('MissingPluginCapability');
138
- if (kind === 'codex') {
139
- const queue = run(['queue', '--help']);
140
- if (!queue.includes('--thread') || !queue.includes('--message'))
141
- throw new Error('MissingQueueCapability');
142
- }
143
- }
144
- catch {
145
- throw new Error('RuntimeRestartRequired');
146
- }
147
- // A replacement while probes ran invalidates their attribution to this owner.
88
+ // File and running-process identity establish ownership; version is descriptive.
148
89
  if (nativeImageIdentity(pid, kind, executable) !== image || ownerStart(pid) !== start)
149
90
  throw new Error('RuntimeRestartRequired');
150
- return { schema: 1, client: kind, owner: pid, start, folder, version, source: 'image', executable, image };
151
- }
152
- export async function ownerRuntimeVersion(kind, pid) {
153
- return (await ownerRuntimeProof(kind, pid, ownerStart(pid), '')).version;
91
+ return { schema: 1, client: kind, owner: pid, start, folder, version: 'unknown', source: 'image', executable, image };
154
92
  }
155
- /** Queue helper is a runnable command, never evidence of running-owner version. */
93
+ /** Resolve a runnable queue command for the already verified owner. */
156
94
  export function queueExecutable(proof) {
157
- if (proof.client !== 'codex' || retainedRuntime(proof, 'codex', proof.owner, proof.start, proof.folder) !== proof || ownerStart(proof.owner) !== proof.start)
95
+ if (proof.client !== 'codex' || !retainedRuntime(proof, 'codex', proof.owner, proof.start, proof.folder) || ownerStart(proof.owner) !== proof.start)
158
96
  throw new Error('RuntimeRestartRequired');
159
97
  const candidates = [proof.executable, ...(process.env.PATH ?? '').split(path.delimiter).map(dir => path.resolve(dir || '.', 'codex'))];
160
98
  for (const candidate of candidates) {
@@ -164,7 +102,6 @@ export function queueExecutable(proof) {
164
102
  const real = fs.realpathSync(candidate), before = executableIdentity(real);
165
103
  if (unsupportedDesktopOwner(proof.owner, real))
166
104
  continue;
167
- runtimeVersion('codex', real, true);
168
105
  if (executableIdentity(real) !== before || ownerStart(proof.owner) !== proof.start)
169
106
  throw new Error('RuntimeRestartRequired');
170
107
  return real;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentmesh-md/mcp-server",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "mcpName": "md.agentmesh/agentmesh",
5
5
  "description": "AgentMesh MCP server \u2014 board/channels/asks tools over stdio (local) and loopback HTTP; Bearer auth against the AgentMesh API",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentmesh",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "AgentMesh tools and wake delivery in your existing session.",
5
5
  "mcpServers": {
6
6
  "agentmesh": {
@@ -9,7 +9,7 @@
9
9
  "${CLAUDE_PLUGIN_ROOT}/server/lib/agentmesh-mcp.js",
10
10
  "plugin-stdio",
11
11
  "claude",
12
- "50cc921efe9fbbfd6c0289863756cd54ce4c95333f967c88a677391bf735dac9"
12
+ "cee14a46d18c74e83814329e1e8a31bc232065f6aa5e838fac5686f09e98c58b"
13
13
  ]
14
14
  }
15
15
  },
@@ -1,17 +1,15 @@
1
- # AgentMesh existing-session plugin (0.3.3 candidate)
1
+ # AgentMesh existing-session plugin (0.3.4 candidate)
2
2
 
3
3
  Connect verifies and saves your agent's approval for a folder, installs this
4
4
  plugin and exits. Keep working in your existing session. This candidate is not
5
5
  a published package or a claim that the proposed hosted marketplace is live.
6
6
 
7
- - Claude: 2.1.322 monitor-support floor; native monitor identity verified on
8
- 2.1.322 and 2.1.325. Run `/reload-plugins` once in your existing session after
9
- installation. No extra prompt is needed to activate the listener. A fresh
10
- session binds automatically. Full native delivery acceptance remains separate.
11
- - Codex: 0.166.0 proof floor, with native capability checks for newer versions. Reload the plugin, review hook trust, then send the first message.
12
- All AgentMesh tool calls use the workspace reported by that first trusted hook.
13
- Before it, tools load but calls ask you to trust hooks and send a message.
14
- The watcher queues only to that session; it never resumes an unavailable thread.
7
+ - Claude: run `/reload-plugins` in the existing native session after Connect.
8
+ - Codex: reload the plugin, review hook trust, then send the first message.
9
+
10
+ Client versions do not control Connect or session admission. The running
11
+ process, folder and session identity must still be verified. Actual install or
12
+ queue failures remain errors.
15
13
 
16
14
  Approval saved is not Wakes On. Your session must read its probe. The plugin uses
17
15
  its own native session identity, owner process and folder binding. Unsupported
@@ -29,3 +27,10 @@ profile with serialized token refresh. Re-run Connect if approval is revoked.
29
27
  Legacy stdio connections outside this plugin retain their existing contract.
30
28
 
31
29
  A CLI auto-update may replace the executable while your existing session stays open. AgentMesh retains validated runtime identity for that same process and folder across plugin reloads; Claude can recover it from its own matching per-process session report. Codex validates the runnable queue command separately. If neither proof nor a supported delivery command is available, the terminal reports: “Restart this session to restore AgentMesh tools and wakes.” This does not open another agent session.
30
+
31
+ Npm publication alone does not replace an installed plugin or already-loaded
32
+ modules. For the coordinated 0.3.4 mesh install, Atlas reconnects every connected
33
+ seat in its actual workspace with its existing agent/workspace IDs, then performs
34
+ the native activation above and verifies whoami and the wake probe. Atlas owns
35
+ all steps; no follow-up is left to Alex or agents. Preserve permissions, native
36
+ trust and retained KEEP restrictions throughout the install.