@agentmesh-md/mcp-server 0.3.6 → 0.3.7
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 +47 -36
- package/dist/agy-config.js +90 -2
- package/dist/agy-connect.js +136 -83
- package/dist/agy-proxy.js +66 -3
- package/dist/agy-storage.js +146 -1
- package/dist/connect.js +2 -2
- package/dist/index.js +8 -4
- package/dist/oauth-client.js +27 -8
- package/dist/server.js +1 -1
- package/package.json +1 -1
- package/plugin-marketplace/plugins/agentmesh/.claude-plugin/plugin.json +2 -2
- package/plugin-marketplace/plugins/agentmesh/README.md +2 -2
- package/plugin-marketplace/plugins/agentmesh/mcp.json +1 -1
- package/plugin-marketplace/plugins/agentmesh/monitors/monitors.json +2 -2
- package/plugin-marketplace/plugins/agentmesh/plugin.json +1 -1
- package/plugin-marketplace/plugins/agentmesh/release.json +1 -1
- package/plugin-marketplace/plugins/agentmesh/server/lib/agentmesh-mcp.js +615 -254
package/dist/agy-storage.js
CHANGED
|
@@ -31,7 +31,13 @@ export function directory(parts, create, privateMode = true) {
|
|
|
31
31
|
if (!s) {
|
|
32
32
|
if (!create)
|
|
33
33
|
throw new Error('AgyNotConnected');
|
|
34
|
-
|
|
34
|
+
try {
|
|
35
|
+
fs.mkdirSync(dir, { mode: 0o700 });
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error.code !== 'EEXIST')
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
35
41
|
s = fs.lstatSync(dir);
|
|
36
42
|
}
|
|
37
43
|
if (!s.isDirectory() || s.isSymbolicLink() || s.uid !== process.getuid?.() || (s.mode & (privateMode && part !== '.agentmesh' ? 0o077 : 0o022)))
|
|
@@ -63,6 +69,22 @@ export function credentials(dir, resource) {
|
|
|
63
69
|
throw new Error('AgyUnsafeState');
|
|
64
70
|
return value;
|
|
65
71
|
}
|
|
72
|
+
// Exchange can leave the client registration but no returned grant. Treat only
|
|
73
|
+
// that well-formed partial profile as unknown; corrupt/private-mode failures stop.
|
|
74
|
+
export function receivedCredentials(dir, resource) {
|
|
75
|
+
const file = path.join(dir, 'credentials.json');
|
|
76
|
+
readPrivate(file);
|
|
77
|
+
const value = credentialFile(file, resource);
|
|
78
|
+
if (!value)
|
|
79
|
+
return false;
|
|
80
|
+
if (!value.tokens) {
|
|
81
|
+
if (typeof value.client?.client_id !== 'string' || !value.client.client_id || typeof value.redirect !== 'string')
|
|
82
|
+
throw new Error('AgyUnsafeState');
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
credentials(dir, resource);
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
66
88
|
export function install() {
|
|
67
89
|
const value = readPrivate(path.join(root(), 'install.json'));
|
|
68
90
|
if (value && (value.schema !== 1 || !UUID.test(value.generation) || !['pending', 'active', 'retired', 'removed'].includes(value.status) ||
|
|
@@ -90,3 +112,126 @@ export function saveEnrollment(value) {
|
|
|
90
112
|
}
|
|
91
113
|
export async function lifecycle(fn) { return locked(root(true), 'lifecycle', fn); }
|
|
92
114
|
export function freshInstall() { return { schema: 1, generation: randomUUID(), status: 'pending' }; }
|
|
115
|
+
export function canonicalFolder(folder = process.cwd()) {
|
|
116
|
+
const canonical = fs.realpathSync(folder), s = fs.lstatSync(canonical);
|
|
117
|
+
if (!s.isDirectory() || s.uid !== process.getuid?.() || (s.mode & 0o022))
|
|
118
|
+
throw new Error('AgyUnsafeState');
|
|
119
|
+
return canonical;
|
|
120
|
+
}
|
|
121
|
+
export function folderRoot(folder, create = false) {
|
|
122
|
+
if (!path.isAbsolute(folder) || canonicalFolder(folder) !== folder)
|
|
123
|
+
throw new Error('AgyNotConnected');
|
|
124
|
+
return directory(['.agentmesh', 'agy', 'folders', digest(folder)], create);
|
|
125
|
+
}
|
|
126
|
+
export function folderProfile(folder, generation, create = false) {
|
|
127
|
+
if (!UUID.test(generation))
|
|
128
|
+
throw new Error('AgyUnsafeState');
|
|
129
|
+
return directory(['.agentmesh', 'agy', 'folders', digest(folder), 'approvals', generation], create);
|
|
130
|
+
}
|
|
131
|
+
export function folderState(folder) {
|
|
132
|
+
const value = readPrivate(path.join(folderRoot(folder), 'state.json'));
|
|
133
|
+
if (!value)
|
|
134
|
+
return;
|
|
135
|
+
if (value.schema !== 1 || value.folder !== folder || !UUID.test(value.generation) || !['pending', 'active', 'retired', 'removed'].includes(value.status))
|
|
136
|
+
throw new Error('AgyUnsafeState');
|
|
137
|
+
if (value.agentId !== undefined)
|
|
138
|
+
agentUUID(value.agentId);
|
|
139
|
+
if (value.resource !== undefined)
|
|
140
|
+
resourceTarget(value.resource);
|
|
141
|
+
if (value.status === 'active' && (!value.agentId || !value.resource || !value.originals || !value.installed || !value.installedModes))
|
|
142
|
+
throw new Error('AgyUnsafeState');
|
|
143
|
+
const images = (items) => {
|
|
144
|
+
if (!Array.isArray(items) || items.length !== 2 || items[0]?.name !== 'plugin.json' || items[1]?.name !== 'mcp_config.json')
|
|
145
|
+
throw new Error('AgyUnsafeState');
|
|
146
|
+
for (const i of items)
|
|
147
|
+
if (typeof i.bytes !== 'string' || Buffer.from(i.bytes, 'base64').toString('base64') !== i.bytes || typeof i.absent !== 'boolean' || !Number.isInteger(i.mode) || i.mode < 0 || i.mode > 0o777 || i.mode & 0o022)
|
|
148
|
+
throw new Error('AgyUnsafeState');
|
|
149
|
+
};
|
|
150
|
+
const hashes = (items) => { if (!Array.isArray(items) || items.length !== 2 || items.some(v => typeof v !== 'string' || !/^[a-f0-9]{64}$/.test(v)))
|
|
151
|
+
throw new Error('AgyUnsafeState'); };
|
|
152
|
+
const modes = (items) => { if (!Array.isArray(items) || items.length !== 2 || items.some(v => !Number.isInteger(v) || v < 0 || v > 0o777 || (v & 0o022)))
|
|
153
|
+
throw new Error('AgyUnsafeState'); };
|
|
154
|
+
if (value.installedModes)
|
|
155
|
+
modes(value.installedModes);
|
|
156
|
+
if (value.originals)
|
|
157
|
+
images(value.originals);
|
|
158
|
+
if (value.installed)
|
|
159
|
+
hashes(value.installed);
|
|
160
|
+
if (value.transaction) {
|
|
161
|
+
images(value.transaction.before);
|
|
162
|
+
hashes(value.transaction.after);
|
|
163
|
+
modes(value.transaction.modes);
|
|
164
|
+
}
|
|
165
|
+
if (value.pending) {
|
|
166
|
+
const p = value.pending;
|
|
167
|
+
if (!UUID.test(p.generation) || !['approval', 'exchange', 'received'].includes(p.phase))
|
|
168
|
+
throw new Error('AgyUnsafeState');
|
|
169
|
+
resourceTarget(p.resource);
|
|
170
|
+
if (p.requestedAgent !== undefined)
|
|
171
|
+
agentUUID(p.requestedAgent);
|
|
172
|
+
}
|
|
173
|
+
return value;
|
|
174
|
+
}
|
|
175
|
+
export function saveFolder(value) {
|
|
176
|
+
const file = path.join(folderRoot(value.folder, true), 'state.json');
|
|
177
|
+
readPrivate(file);
|
|
178
|
+
writeAtomic(file, value);
|
|
179
|
+
}
|
|
180
|
+
export async function folderLifecycle(folder, fn) { return locked(folderRoot(folder, true), 'lifecycle', fn); }
|
|
181
|
+
export function pluginDirectory(folder, create = false) {
|
|
182
|
+
if (canonicalFolder(folder) !== folder)
|
|
183
|
+
throw new Error('AgyNotConnected');
|
|
184
|
+
let dir = folder;
|
|
185
|
+
for (const part of ['.agents', 'plugins', 'agentmesh']) {
|
|
186
|
+
dir = path.join(dir, part);
|
|
187
|
+
let s = lstat(dir);
|
|
188
|
+
if (!s) {
|
|
189
|
+
if (!create)
|
|
190
|
+
throw new Error('AgyNotConnected');
|
|
191
|
+
try {
|
|
192
|
+
fs.mkdirSync(dir, { mode: 0o700 });
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
if (error.code !== 'EEXIST')
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
s = fs.lstatSync(dir);
|
|
199
|
+
}
|
|
200
|
+
if (!s.isDirectory() || s.isSymbolicLink() || s.uid !== process.getuid?.() || (s.mode & 0o022))
|
|
201
|
+
throw new Error('AgyUnsafeState');
|
|
202
|
+
}
|
|
203
|
+
return dir;
|
|
204
|
+
}
|
|
205
|
+
export const agyMessages = {
|
|
206
|
+
AgyArgumentsInvalid: 'Invalid agy Connect arguments. Use connect --client agy [--agent <UUID>] [--server <approved-resource-URL>], or connect --client agy --remove.',
|
|
207
|
+
AgyWorkspace: 'agy Connect does not take --workspace. Choose the initial membership on the approval page. Run connect --client agy in this folder.',
|
|
208
|
+
AgyNotConnected: 'AgentMesh is not connected in this folder. Run connect --client agy in this folder.',
|
|
209
|
+
AgyGenerationChanged: 'This AgentMesh connection was removed or replaced. Run connect --client agy in this folder.',
|
|
210
|
+
ApprovalDenied: 'AgentMesh approval was denied. No connection was saved. Run connect --client agy in this folder to retry.',
|
|
211
|
+
ApprovalCancelled: 'AgentMesh approval was cancelled. No connection was saved. Run connect --client agy in this folder to retry.',
|
|
212
|
+
ApprovalTimeout: 'AgentMesh approval timed out. No connection was saved. Run connect --client agy in this folder to retry.',
|
|
213
|
+
AgyApprovalFailed: 'AgentMesh approval could not be completed. Check your connection and sign-in, then run connect --client agy in this folder to retry.',
|
|
214
|
+
AgyIdentityMismatch: 'AgentMesh returned a different identity. No connection was saved. Run connect --client agy in this folder to retry.',
|
|
215
|
+
AgyUnsafeState: 'AgentMesh local files are unsafe or invalid. Restore owner-only files and directories, then run connect --client agy in this folder.',
|
|
216
|
+
AgyConfigInvalid: 'AgentMesh plugin files are invalid or already owned by another entry. Resolve the conflict, then run connect --client agy in this folder.',
|
|
217
|
+
AgyConfigChanged: 'AgentMesh plugin files changed during Connect or removal. Your edits were preserved. Resolve the conflict, then run connect --client agy in this folder.',
|
|
218
|
+
ReconnectRequired: 'AgentMesh approval expired or was revoked. Run connect --client agy --agent <UUID> in this folder.',
|
|
219
|
+
AgyUnavailable: 'AgentMesh is unavailable. Check your connection and retry the tool call.',
|
|
220
|
+
AgyRuntimeIdentity: 'AgentMesh identity did not match this folder. Run connect --client agy in this folder.',
|
|
221
|
+
AgyApprovalReceived: 'AgentMesh approval completed; the agent was created if you chose New agent. This folder is not connected yet. Run connect --client agy in this folder to finish the saved approval.',
|
|
222
|
+
AgyApprovalUnknown: 'AgentMesh approval may have completed, but its result was not received. Check the agentmesh.md roster before retrying. Use connect --client agy --agent <existing-agent-UUID> in this folder; do not create another agent.',
|
|
223
|
+
};
|
|
224
|
+
export function agyReason(error, fallback = 'AgyUnsafeState') {
|
|
225
|
+
const code = error instanceof Error ? error.message : '';
|
|
226
|
+
if (agyMessages[code])
|
|
227
|
+
return code;
|
|
228
|
+
if (['AgyInvalidSelection', 'UnapprovedResource'].includes(code))
|
|
229
|
+
return 'AgyArgumentsInvalid';
|
|
230
|
+
if (['AgyConfigDuplicate', 'AgyConfigCollision'].includes(code))
|
|
231
|
+
return 'AgyConfigInvalid';
|
|
232
|
+
if (code === 'AgyRecoveryConflict')
|
|
233
|
+
return 'AgyConfigChanged';
|
|
234
|
+
if (['AgyUnsafeConfig', 'OwnerCredentialsRequired', 'OwnerDirectoryRequired', 'PrivateFileRequired', 'ResourceMismatch'].includes(code) || error instanceof SyntaxError)
|
|
235
|
+
return 'AgyUnsafeState';
|
|
236
|
+
return fallback;
|
|
237
|
+
}
|
package/dist/connect.js
CHANGED
|
@@ -23,13 +23,13 @@ export function parsed(result) { if (result.isError)
|
|
|
23
23
|
throw new Error('RemoteResultMissing'); return JSON.parse(text.text); }
|
|
24
24
|
export async function connect(args) {
|
|
25
25
|
if (args.includes('--help') && args.some((value, index) => value === '--client' && args[index + 1] === 'agy')) {
|
|
26
|
-
process.stdout.write('Usage: agentmesh-mcp connect --client agy --agent UUID
|
|
26
|
+
process.stdout.write('Usage: agentmesh-mcp connect --client agy [--agent UUID] [--server MCP_URL]\n agentmesh-mcp connect --client agy --remove\nConnect in the folder where you will start agy. Choose New or Existing agent in the browser; the folder remembers its identity. Remove restores this folder’s original plugin files.\n');
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
if (args.some((value, index) => value === '--client' && args[index + 1] === 'agy'))
|
|
30
30
|
return (await import('./agy-connect.js')).agyConnect(args);
|
|
31
31
|
if (args.includes('--help')) {
|
|
32
|
-
process.stdout.write('Usage: agentmesh-mcp connect --client claude|codex [--agent UUID] [--workspace UUID]\n agentmesh-mcp connect --client claude|codex --disconnect\n agentmesh-mcp connect --client agy --agent UUID
|
|
32
|
+
process.stdout.write('Usage: agentmesh-mcp connect --client claude|codex [--agent UUID] [--workspace UUID]\n agentmesh-mcp connect --client claude|codex --disconnect\n agentmesh-mcp connect --client agy [--agent UUID]\n agentmesh-mcp connect --client agy --remove\nClaude asks once before browser approval to allow five exact wake/read/reply tools in Git-root .claude/settings.local.json (main checkout for worktrees). Only interactive yes adds rules. No/EOF keeps native approval each time. Explicit ask/deny or managed policy still wins. Disconnect removes only Connect-added entries. Remote revoke stops hosted access immediately; offline local cleanup waits for the next native auth check or local disconnect.\n');
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
const disconnect = args.includes('--disconnect');
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,14 @@ if (action === "connect") {
|
|
|
5
5
|
const { connect } = await import("./connect.js");
|
|
6
6
|
const { terminalDiagnostic } = await import("./terminal-diagnostic.js");
|
|
7
7
|
const { ClientExecutableMissing } = await import("./terminal-runtime.js");
|
|
8
|
-
await connect(process.argv.slice(3)).catch((error) => {
|
|
8
|
+
await connect(process.argv.slice(3)).catch(async (error) => {
|
|
9
|
+
if (process.argv.some((value, index) => value === '--client' && process.argv[index + 1] === 'agy')) {
|
|
10
|
+
const { agyMessages, agyReason } = await import('./agy-storage.js');
|
|
11
|
+
process.stderr.write(agyMessages[agyReason(error, 'AgyApprovalFailed')] + '\n');
|
|
12
|
+
process.stderr.write(`AgentMesh ${terminalDiagnostic(error, 'index.js', 'connect')}.\n`);
|
|
13
|
+
process.exitCode = 1;
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
9
16
|
if (error instanceof ClientExecutableMissing) {
|
|
10
17
|
const name = error.client === 'claude' ? 'Claude Code' : 'Codex';
|
|
11
18
|
process.stderr.write(`AgentMesh could not find ${name} (${error.client}) on PATH. Install ${name}, then run Connect again.\n`);
|
|
@@ -14,9 +21,6 @@ if (action === "connect") {
|
|
|
14
21
|
}
|
|
15
22
|
if (error instanceof Error && error.message === 'CodexHookSetupFailed')
|
|
16
23
|
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');
|
|
17
|
-
const agyReasons = ['AgyArgumentsInvalid', 'AgyInvalidSelection', 'AgyIdentityMismatch', 'AgyUnsafeState', 'AgyUnsafeConfig', 'AgyConfigChanged', 'AgyConfigInvalid', 'AgyConfigDuplicate', 'AgyConfigCollision', 'AgyBackupInvalid', 'AgyBackupCollision', 'AgyRecoveryConflict', 'AgyGenerationChanged'];
|
|
18
|
-
if (error instanceof Error && agyReasons.includes(error.message))
|
|
19
|
-
process.stderr.write(`AgentMesh ${error.message}: verify the agy agent UUID and owner-only files, resolve any shared-config conflict, then rerun Connect. The original backup is retained on a removal conflict.\n`);
|
|
20
24
|
const installs = ['PluginInstallTimeout', 'PluginInstallerUnavailable', 'PluginInstallFailedConnectionSaved', 'PluginInstallReadbackTooLarge', 'PluginInstallReadbackInvalid', 'PluginInstallNotEnabled', 'PluginInstallScopeConflict', 'PackagedMarketplaceMissing', 'PluginSymlinkRejected', 'PluginFileRequired'];
|
|
21
25
|
if (error instanceof Error && installs.includes(error.message))
|
|
22
26
|
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`);
|
package/dist/oauth-client.js
CHANGED
|
@@ -35,6 +35,7 @@ class Provider {
|
|
|
35
35
|
requestedAgentId;
|
|
36
36
|
interactive;
|
|
37
37
|
resource;
|
|
38
|
+
onTokens;
|
|
38
39
|
verifier = '';
|
|
39
40
|
secrets = new Set();
|
|
40
41
|
redact(value) {
|
|
@@ -52,11 +53,12 @@ class Provider {
|
|
|
52
53
|
saved;
|
|
53
54
|
redirectUrl;
|
|
54
55
|
authorizationStarted = false;
|
|
55
|
-
constructor(file, redirect, requestedAgentId, interactive = true, resource = RESOURCE) {
|
|
56
|
+
constructor(file, redirect, requestedAgentId, interactive = true, resource = RESOURCE, onTokens) {
|
|
56
57
|
this.file = file;
|
|
57
58
|
this.requestedAgentId = requestedAgentId;
|
|
58
59
|
this.interactive = interactive;
|
|
59
60
|
this.resource = resource;
|
|
61
|
+
this.onTokens = onTokens;
|
|
60
62
|
this.saved = credentialFile(file, resource) ?? { resource, redirect };
|
|
61
63
|
this.redirectUrl = redirect;
|
|
62
64
|
this.saved.redirect = redirect;
|
|
@@ -72,7 +74,7 @@ class Provider {
|
|
|
72
74
|
clientInformation() { return this.saved.client; }
|
|
73
75
|
saveClientInformation(value) { this.saved.client = value; this.save(); }
|
|
74
76
|
tokens() { return this.saved.tokens; }
|
|
75
|
-
saveTokens(value) { this.remember(value); this.saved.tokens = value; this.save(); }
|
|
77
|
+
async saveTokens(value) { this.remember(value); this.saved.tokens = value; this.save(); await this.onTokens?.(); }
|
|
76
78
|
saveCodeVerifier(value) { this.verifier = value; }
|
|
77
79
|
codeVerifier() { return this.verifier; }
|
|
78
80
|
async validateResourceURL(server, resource) {
|
|
@@ -114,7 +116,7 @@ const safeFetch = (resource, timeout = 15_000) => async (input, init) => {
|
|
|
114
116
|
throw new Error('OAuthOriginMismatch');
|
|
115
117
|
return fetch(input, { ...init, redirect: 'error', signal: init?.signal ? AbortSignal.any([init.signal, AbortSignal.timeout(timeout)]) : AbortSignal.timeout(timeout) });
|
|
116
118
|
};
|
|
117
|
-
export async function openOAuth(profile, requestedAgentId, resource = RESOURCE, freshApproval = false) {
|
|
119
|
+
export async function openOAuth(profile, requestedAgentId, resource = RESOURCE, freshApproval = false, options = {}) {
|
|
118
120
|
const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
119
121
|
if (requestedAgentId !== undefined && !uuid.test(requestedAgentId))
|
|
120
122
|
throw new Error('IdentityArgument');
|
|
@@ -147,12 +149,14 @@ export async function openOAuth(profile, requestedAgentId, resource = RESOURCE,
|
|
|
147
149
|
const address = server.address();
|
|
148
150
|
if (!address || typeof address === 'string')
|
|
149
151
|
throw new Error('CallbackUnavailable');
|
|
150
|
-
const provider = new Provider(file, `http://127.0.0.1:${address.port}/callback`, requestedAgentId, true, resource);
|
|
152
|
+
const provider = new Provider(file, `http://127.0.0.1:${address.port}/callback`, requestedAgentId, true, resource, options.onTokens);
|
|
151
153
|
let timer;
|
|
152
154
|
let callback;
|
|
153
155
|
let accepted = false, finished = false;
|
|
154
156
|
const failure = 'Approval was not accepted. Return to your terminal and retry Connect.';
|
|
155
|
-
const cleanup = () => { clearTimeout(timer); server.close(); };
|
|
157
|
+
const cleanup = () => { clearTimeout(timer); options.signal?.removeEventListener('abort', cancel); server.close(); };
|
|
158
|
+
let rejectCode = () => undefined;
|
|
159
|
+
const cancel = () => { fail(); rejectCode(new Error('ApprovalCancelled')); };
|
|
156
160
|
const fail = () => {
|
|
157
161
|
finished = true;
|
|
158
162
|
if (callback && !callback.writableEnded) {
|
|
@@ -162,6 +166,7 @@ export async function openOAuth(profile, requestedAgentId, resource = RESOURCE,
|
|
|
162
166
|
cleanup();
|
|
163
167
|
};
|
|
164
168
|
const code = new Promise((resolve, reject) => {
|
|
169
|
+
rejectCode = reject;
|
|
165
170
|
timer = setTimeout(() => {
|
|
166
171
|
console.error({ error_class: 'Error', cause: 'ApprovalTimeout', location: 'mcp/src/oauth-client.ts:openOAuth:approvalTimeout' });
|
|
167
172
|
fail();
|
|
@@ -180,6 +185,14 @@ export async function openOAuth(profile, requestedAgentId, resource = RESOURCE,
|
|
|
180
185
|
res.end(failure);
|
|
181
186
|
return;
|
|
182
187
|
}
|
|
188
|
+
const validEnvelope = !finished && !accepted && req.method === 'GET' && req.headers.host === `127.0.0.1:${address.port}` && url.pathname === '/callback' && url.searchParams.getAll('state').length === 1 && provider.validState(url.searchParams.get('state'));
|
|
189
|
+
if (validEnvelope && url.searchParams.getAll('error').length === 1 && url.searchParams.get('error') === 'access_denied' && !url.searchParams.has('code')) {
|
|
190
|
+
res.writeHead(400);
|
|
191
|
+
res.end(failure);
|
|
192
|
+
fail();
|
|
193
|
+
reject(new Error('ApprovalDenied'));
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
183
196
|
const value = url.searchParams.get('code');
|
|
184
197
|
if (finished || accepted || req.method !== 'GET' || req.headers.host !== `127.0.0.1:${address.port}` || url.pathname !== '/callback'
|
|
185
198
|
|| url.searchParams.getAll('state').length !== 1 || url.searchParams.getAll('code').length !== 1
|
|
@@ -195,6 +208,9 @@ export async function openOAuth(profile, requestedAgentId, resource = RESOURCE,
|
|
|
195
208
|
resolve(value);
|
|
196
209
|
});
|
|
197
210
|
});
|
|
211
|
+
options.signal?.addEventListener('abort', cancel, { once: true });
|
|
212
|
+
if (options.signal?.aborted)
|
|
213
|
+
cancel();
|
|
198
214
|
const complete = ({ agentId, workspaceId }) => {
|
|
199
215
|
if (!accepted)
|
|
200
216
|
return; // Cached-token launch has no browser response.
|
|
@@ -212,7 +228,7 @@ export async function openOAuth(profile, requestedAgentId, resource = RESOURCE,
|
|
|
212
228
|
// A cached-token success never awaits the callback; prevent an unhandled
|
|
213
229
|
// rejection while its timer is being cancelled in finally.
|
|
214
230
|
void code.catch(() => undefined);
|
|
215
|
-
const transport = new StreamableHTTPClientTransport(new URL(resource), { authProvider: provider, fetch: safeFetch(resource) });
|
|
231
|
+
const transport = new StreamableHTTPClientTransport(new URL(resource), { authProvider: provider, fetch: async (input, init) => safeFetch(resource)(input, { ...init, signal: options.signal ? AbortSignal.any([options.signal, ...init?.signal ? [init.signal] : []]) : init?.signal }) });
|
|
216
232
|
let client = new Client({ name: 'agentmesh-terminal', version: '0.2.2' });
|
|
217
233
|
try {
|
|
218
234
|
// A new callback port needs its own registration. Valid cached grants have
|
|
@@ -224,10 +240,13 @@ export async function openOAuth(profile, requestedAgentId, resource = RESOURCE,
|
|
|
224
240
|
catch (error) {
|
|
225
241
|
if (!(error instanceof UnauthorizedError) || !provider.authorizationStarted)
|
|
226
242
|
throw error;
|
|
227
|
-
|
|
243
|
+
const authorizationCode = await code;
|
|
244
|
+
options.signal?.throwIfAborted();
|
|
245
|
+
await options.onExchange?.();
|
|
246
|
+
await transport.finishAuth(authorizationCode);
|
|
228
247
|
await client.close();
|
|
229
248
|
client = new Client({ name: 'agentmesh-terminal', version: '0.2.2' });
|
|
230
|
-
await client.connect(new StreamableHTTPClientTransport(new URL(resource), { authProvider: provider, fetch: safeFetch(resource) }));
|
|
249
|
+
await client.connect(new StreamableHTTPClientTransport(new URL(resource), { authProvider: provider, fetch: async (input, init) => safeFetch(resource)(input, { ...init, signal: options.signal ? AbortSignal.any([options.signal, ...init?.signal ? [init.signal] : []]) : init?.signal }) }));
|
|
231
250
|
}
|
|
232
251
|
if (!accepted)
|
|
233
252
|
cleanup();
|
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.
|
|
41
|
+
const SERVER_VERSION = "0.3.7";
|
|
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) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentmesh-md/mcp-server",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"mcpName": "md.agentmesh/agentmesh",
|
|
5
5
|
"description": "AgentMesh MCP server — 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
|
+
"version": "0.3.7",
|
|
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
|
-
"
|
|
12
|
+
"50a75cee7dce2b4c39080e77a777193142995f904709d6252e3249cc16b2cee3"
|
|
13
13
|
]
|
|
14
14
|
}
|
|
15
15
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# AgentMesh existing-session plugin (0.3.
|
|
1
|
+
# AgentMesh existing-session plugin (0.3.7 candidate)
|
|
2
2
|
|
|
3
3
|
Connect verifies and saves your agent's approval for a folder, installs this
|
|
4
4
|
plugin and exits. The activation steps below load AgentMesh tools and wakes.
|
|
@@ -33,7 +33,7 @@ Legacy stdio connections outside this plugin retain their existing contract.
|
|
|
33
33
|
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.
|
|
34
34
|
|
|
35
35
|
Npm publication alone does not replace an installed plugin or already-loaded
|
|
36
|
-
modules. For the coordinated 0.3.
|
|
36
|
+
modules. For the coordinated 0.3.7 mesh install, Atlas reconnects every connected
|
|
37
37
|
seat in its actual workspace with its existing agent/workspace IDs, then performs
|
|
38
38
|
the native activation above and verifies whoami and the wake probe. Atlas owns
|
|
39
39
|
all steps; no follow-up is left to Alex or agents. Preserve permissions, native
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"name": "agentmesh-wake-
|
|
4
|
-
"command": "node \"${CLAUDE_PLUGIN_ROOT}/server/lib/agentmesh-mcp.js\" plugin-monitor claude
|
|
3
|
+
"name": "agentmesh-wake-50a75cee7dce2b4c3908",
|
|
4
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/server/lib/agentmesh-mcp.js\" plugin-monitor claude 50a75cee7dce2b4c39080e77a777193142995f904709d6252e3249cc16b2cee3",
|
|
5
5
|
"description": "AgentMesh offers for this existing session"
|
|
6
6
|
}
|
|
7
7
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"digest":"
|
|
1
|
+
{"digest":"50a75cee7dce2b4c39080e77a777193142995f904709d6252e3249cc16b2cee3"}
|