@mysten-incubation/sui-agent-pass 0.1.18 → 0.1.20
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 +20 -7
- package/dist/cli.js +101 -47
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -59,12 +59,12 @@ client ships the per-network deployment IDs (`deployments/<network>.json`):
|
|
|
59
59
|
|
|
60
60
|
```sh
|
|
61
61
|
npm install -g @mysten-incubation/sui-agent-pass
|
|
62
|
-
agent-pass connect #
|
|
62
|
+
agent-pass connect # connect all detected agents, or choose specific ones
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
That is the only command. For each agent you pick it registers the MCP server and links the
|
|
66
66
|
`agent-pass` skill, the playbook built into the package, into the agent's skills folder (Claude
|
|
67
|
-
Code, Codex, Cursor and
|
|
67
|
+
Code, Codex, Cursor, Hermes and OpenClaw), so the agent has the tools and the guidance for them. A link
|
|
68
68
|
follows upgrades; rerun `connect` if you installed through `npx`. Then open the agent and tell
|
|
69
69
|
it what to do with your money. It
|
|
70
70
|
proposes a pass (`propose_authorization`) and opens the review page with the proposal in its URL.
|
|
@@ -94,8 +94,9 @@ writes or prints the entry in the right place:
|
|
|
94
94
|
| `claude-code` | `claude mcp add` in user scope |
|
|
95
95
|
| `claude-desktop` | Writes into `claude_desktop_config.json` |
|
|
96
96
|
| `cursor` | Writes into `~/.cursor/mcp.json` |
|
|
97
|
-
| `hermes` |
|
|
98
|
-
| `codex` |
|
|
97
|
+
| `hermes` | Uses `hermes mcp add`; prints configuration for `--session` |
|
|
98
|
+
| `codex` | Uses `codex mcp add`; prints configuration for `--session` |
|
|
99
|
+
| `openclaw` | Uses `openclaw mcp set` in the active OpenClaw profile |
|
|
99
100
|
| `json` | Prints a generic `mcpServers` entry |
|
|
100
101
|
|
|
101
102
|
The entry is `agent-pass mcp`, a stdio server the client starts when it needs it and stops with
|
|
@@ -105,6 +106,16 @@ also set a pass up. While it runs it also serves each pass's HTTP signer, which
|
|
|
105
106
|
`connect --session <directory>` instead points a client at one session's foreground signer
|
|
106
107
|
(`agent-pass serve`), for agents that cannot start a process themselves.
|
|
107
108
|
|
|
109
|
+
OpenClaw needs a release with native `openclaw mcp set` support. Stop its gateway before
|
|
110
|
+
connecting (`openclaw gateway stop` when running as a service), then run
|
|
111
|
+
`agent-pass connect --client openclaw`. Restart OpenClaw and start a new chat session afterward.
|
|
112
|
+
Registration uses OpenClaw's own CLI and its reported managed skills directory, so custom
|
|
113
|
+
state directories and profiles stay aligned. For a named profile, use
|
|
114
|
+
`OPENCLAW_PROFILE=<name> agent-pass connect --client openclaw`; `OPENCLAW_HOME` and
|
|
115
|
+
`OPENCLAW_STATE_DIR` are passed through to OpenClaw. OpenClaw must run on the machine where
|
|
116
|
+
Agent Pass is installed and have access to a local Node runtime for SDK scripts; remote
|
|
117
|
+
gateways need their own installation.
|
|
118
|
+
|
|
108
119
|
Acting is a Node script against the SDK. `session_info.sdk.install` is the install command
|
|
109
120
|
(`npm install <this checkout>` after `npm run build` while the package is unpublished), then:
|
|
110
121
|
|
|
@@ -203,9 +214,11 @@ account when lending is allowed, and sends SUI to the session's **address balanc
|
|
|
203
214
|
service re-reads everything that landed on chain and compares it with what you reviewed before
|
|
204
215
|
the signer serves the key.
|
|
205
216
|
|
|
206
|
-
Register the agents that may use your passes once with `connect`.
|
|
207
|
-
|
|
208
|
-
|
|
217
|
+
Register the agents that may use your passes once with `connect`. It shows the detected agents
|
|
218
|
+
and offers to connect them all, or choose specific ones. **Other / manual setup** offers
|
|
219
|
+
undetected clients, Cursor and a generic MCP configuration; Cursor is excluded from detection
|
|
220
|
+
and bulk setup. You can also select a client directly with `--client <name>`. After connecting,
|
|
221
|
+
restart each connected agent and start a new chat session. Then start Claude anywhere:
|
|
209
222
|
|
|
210
223
|
```sh
|
|
211
224
|
claude
|
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Copyright (c) Mysten Labs, Inc.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
import { spawn } from 'node:child_process';
|
|
4
|
+
import { execFile, spawn } from 'node:child_process';
|
|
5
5
|
import { realpathSync } from 'node:fs';
|
|
6
6
|
import { access, cp, lstat, mkdir, readFile, rm, symlink, writeFile } from 'node:fs/promises';
|
|
7
7
|
import { homedir } from 'node:os';
|
|
8
|
-
import { dirname, join, resolve, sep } from 'node:path';
|
|
8
|
+
import { dirname, isAbsolute, join, resolve, sep } from 'node:path';
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
10
|
-
import {
|
|
10
|
+
import { promisify } from 'node:util';
|
|
11
|
+
import { checkbox, select } from '@inquirer/prompts';
|
|
11
12
|
import { Command } from 'commander';
|
|
12
13
|
import { clientFor, readStatus } from './chain.js';
|
|
13
14
|
import { cliInvocation, defaultRoot, forgetSession, openBrowser, servePlugin, servePluginHttp, } from './plugin.js';
|
|
@@ -17,7 +18,7 @@ const quote = (s) => `'${s.replaceAll("'", "'\\''")}'`;
|
|
|
17
18
|
export async function serve(store, port = 0, open = true) {
|
|
18
19
|
const server = await startServer(store, port);
|
|
19
20
|
console.log(`\nOwner page: ${server.ownerUrl}\nSession address: ${store.state.sessionAddress}\nSession directory: ${store.directory}`);
|
|
20
|
-
console.log(`\nAfter authorization, register the signer with your agent (from the agent's working directory for Claude Code):\n${cliInvocation().map(quote).join(' ')} connect --session ${quote(store.directory)} --client claude-code\nOther clients: --client claude-desktop | cursor | hermes | codex | json\n\nKeep this process running. Ctrl-C stops signing; use the owner page to revoke on chain.`);
|
|
21
|
+
console.log(`\nAfter authorization, register the signer with your agent (from the agent's working directory for Claude Code):\n${cliInvocation().map(quote).join(' ')} connect --session ${quote(store.directory)} --client claude-code\nOther clients: --client claude-desktop | cursor | hermes | codex | openclaw | json\n\nKeep this process running. Ctrl-C stops signing; use the owner page to revoke on chain.`);
|
|
21
22
|
if (open)
|
|
22
23
|
openBrowser(server.ownerUrl);
|
|
23
24
|
const stop = () => {
|
|
@@ -76,7 +77,29 @@ program
|
|
|
76
77
|
const { url } = await servePluginHttp(options, Number(o.http));
|
|
77
78
|
console.error(`agent-pass MCP at ${url}; bearer token in ${join(options.root, 'mcp-http.json')}`);
|
|
78
79
|
});
|
|
79
|
-
const CLIENTS = [
|
|
80
|
+
const CLIENTS = [
|
|
81
|
+
'claude-code',
|
|
82
|
+
'claude-desktop',
|
|
83
|
+
'cursor',
|
|
84
|
+
'hermes',
|
|
85
|
+
'codex',
|
|
86
|
+
'openclaw',
|
|
87
|
+
'json',
|
|
88
|
+
];
|
|
89
|
+
const CLIENT_NAMES = {
|
|
90
|
+
'claude-code': 'Claude Code',
|
|
91
|
+
'claude-desktop': 'Claude Desktop',
|
|
92
|
+
cursor: 'Cursor',
|
|
93
|
+
hermes: 'Hermes',
|
|
94
|
+
codex: 'Codex',
|
|
95
|
+
openclaw: 'OpenClaw',
|
|
96
|
+
json: 'Generic MCP configuration',
|
|
97
|
+
};
|
|
98
|
+
/** OpenClaw's CLI selects named profiles through a root option, not the environment alone. */
|
|
99
|
+
function openclawArgs(args) {
|
|
100
|
+
const profile = process.env.OPENCLAW_PROFILE?.trim();
|
|
101
|
+
return profile ? ['--profile', profile, ...args] : args;
|
|
102
|
+
}
|
|
80
103
|
/** Merges one server entry into a JSON MCP config file, creating it if needed. */
|
|
81
104
|
async function mergeJsonConfig(path, entry) {
|
|
82
105
|
const current = await readFile(path, 'utf8')
|
|
@@ -85,7 +108,7 @@ async function mergeJsonConfig(path, entry) {
|
|
|
85
108
|
current.mcpServers = { ...(current.mcpServers ?? {}), 'agent-pass': entry };
|
|
86
109
|
await mkdir(dirname(path), { recursive: true });
|
|
87
110
|
await writeFile(path, JSON.stringify(current, null, 2) + '\n', { mode: 0o600 });
|
|
88
|
-
console.log(`Wrote agent-pass into ${path}
|
|
111
|
+
console.log(`Wrote agent-pass into ${path}.`);
|
|
89
112
|
}
|
|
90
113
|
/** Registers agent-pass with Claude Code, replacing an earlier entry in the same scope. */
|
|
91
114
|
/** Runs a client's own CLI; the client is not on this machine when the command cannot start. */
|
|
@@ -161,7 +184,7 @@ async function registerClient(client, http) {
|
|
|
161
184
|
// `hermes mcp add` writes ~/.hermes/config.yaml itself; an HTTP signer's bearer header
|
|
162
185
|
// has no plain flag there, so that form is printed to paste.
|
|
163
186
|
if (http) {
|
|
164
|
-
console.log(`Add to ~/.hermes/config.yaml under mcp_servers:\n\n agent-pass:\n url: "${http.url}"\n headers:\n Authorization: "${http.headers.Authorization}"\n
|
|
187
|
+
console.log(`Add to ~/.hermes/config.yaml under mcp_servers:\n\n agent-pass:\n url: "${http.url}"\n headers:\n Authorization: "${http.headers.Authorization}"\n`);
|
|
165
188
|
return;
|
|
166
189
|
}
|
|
167
190
|
await cli('hermes', ['mcp', 'remove', 'agent-pass'], true).catch(() => { });
|
|
@@ -174,7 +197,7 @@ async function registerClient(client, http) {
|
|
|
174
197
|
'--args',
|
|
175
198
|
...stdio.args,
|
|
176
199
|
]);
|
|
177
|
-
console.log('Registered agent-pass with Hermes (hermes mcp add).
|
|
200
|
+
console.log('Registered agent-pass with Hermes (hermes mcp add).');
|
|
178
201
|
return;
|
|
179
202
|
}
|
|
180
203
|
case 'codex': {
|
|
@@ -186,9 +209,22 @@ async function registerClient(client, http) {
|
|
|
186
209
|
}
|
|
187
210
|
await cli('codex', ['mcp', 'remove', 'agent-pass'], true).catch(() => { });
|
|
188
211
|
await cli('codex', ['mcp', 'add', 'agent-pass', '--', stdio.command, ...stdio.args]);
|
|
189
|
-
console.log('Registered agent-pass with Codex (codex mcp add).
|
|
212
|
+
console.log('Registered agent-pass with Codex (codex mcp add).');
|
|
190
213
|
return;
|
|
191
214
|
}
|
|
215
|
+
case 'openclaw':
|
|
216
|
+
// Let OpenClaw validate and update its own registry, including profile/state overrides.
|
|
217
|
+
// `set` replaces only our entry and refuses to write while its gateway owns the state.
|
|
218
|
+
await cli('openclaw', openclawArgs([
|
|
219
|
+
'mcp',
|
|
220
|
+
'set',
|
|
221
|
+
'agent-pass',
|
|
222
|
+
JSON.stringify({
|
|
223
|
+
...(http ? { ...http, transport: 'streamable-http' } : stdio),
|
|
224
|
+
requestTimeoutMs: 180_000, // session_info can wait 120 seconds for wallet consent.
|
|
225
|
+
}),
|
|
226
|
+
]));
|
|
227
|
+
return;
|
|
192
228
|
case 'json':
|
|
193
229
|
console.log(JSON.stringify({ mcpServers: { 'agent-pass': http ?? stdio } }, null, 2));
|
|
194
230
|
}
|
|
@@ -208,14 +244,22 @@ async function installSkill(client) {
|
|
|
208
244
|
const source = fileURLToPath(new URL('../skills/agent-pass', import.meta.url));
|
|
209
245
|
if (!(await access(join(source, 'SKILL.md')).then(() => true, () => false)))
|
|
210
246
|
throw new Error(`The skill is missing from ${source}; run npm run build`);
|
|
211
|
-
|
|
247
|
+
let dir = SKILL_DIRS[client];
|
|
248
|
+
if (client === 'openclaw') {
|
|
249
|
+
// Ask the client for its managed directory so profiles and custom state roots stay aligned.
|
|
250
|
+
const { stdout } = await promisify(execFile)('openclaw', openclawArgs(['skills', 'list', '--json']));
|
|
251
|
+
const report = JSON.parse(stdout);
|
|
252
|
+
if (typeof report.managedSkillsDir !== 'string' || !isAbsolute(report.managedSkillsDir))
|
|
253
|
+
throw new Error('OpenClaw did not report an absolute managed skills directory');
|
|
254
|
+
dir = report.managedSkillsDir;
|
|
255
|
+
}
|
|
212
256
|
if (!dir) {
|
|
213
257
|
console.log(client === 'claude-desktop'
|
|
214
258
|
? `Claude Desktop takes skills from its own settings; add ${join(source, 'SKILL.md')} there to give it the playbook.`
|
|
215
259
|
: `If the agent loads SKILL.md skills, link ${source} into its skills folder to give it the playbook.`);
|
|
216
260
|
return;
|
|
217
261
|
}
|
|
218
|
-
const target = join(homedir(), dir, 'agent-pass');
|
|
262
|
+
const target = join(isAbsolute(dir) ? dir : join(homedir(), dir), 'agent-pass');
|
|
219
263
|
const existing = await lstat(target).catch(() => null);
|
|
220
264
|
if (existing && !existing.isSymbolicLink()) {
|
|
221
265
|
const ours = await readFile(join(target, 'SKILL.md'), 'utf8').then((t) => /^name: agent-pass$/m.test(t), () => false);
|
|
@@ -232,8 +276,8 @@ async function installSkill(client) {
|
|
|
232
276
|
await symlink(source, target, 'dir');
|
|
233
277
|
console.log(`${temporary ? 'Copied' : 'Linked'} the agent-pass skill into ${target}.`);
|
|
234
278
|
}
|
|
235
|
-
/**
|
|
236
|
-
async function chooseClients() {
|
|
279
|
+
/** Connect detected agents together; Cursor and undetected clients stay in manual setup. */
|
|
280
|
+
async function chooseClients(http = false) {
|
|
237
281
|
const home = homedir();
|
|
238
282
|
const found = async (path) => access(path).then(() => true, () => false);
|
|
239
283
|
const onPath = (bin) => new Promise((done) => {
|
|
@@ -246,38 +290,59 @@ async function chooseClients() {
|
|
|
246
290
|
: process.platform === 'win32'
|
|
247
291
|
? join(process.env.APPDATA ?? join(home, 'AppData/Roaming'), 'Claude')
|
|
248
292
|
: join(home, '.config/Claude');
|
|
249
|
-
const [claude, desktop,
|
|
293
|
+
const [claude, desktop, hermes, codex, openclaw] = await Promise.all([
|
|
250
294
|
onPath('claude'),
|
|
251
295
|
found(desktopConfig),
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
296
|
+
onPath('hermes'),
|
|
297
|
+
onPath('codex'),
|
|
298
|
+
onPath('openclaw'),
|
|
255
299
|
]);
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
];
|
|
264
|
-
|
|
300
|
+
const detected = {
|
|
301
|
+
'claude-code': claude,
|
|
302
|
+
'claude-desktop': desktop,
|
|
303
|
+
hermes,
|
|
304
|
+
codex,
|
|
305
|
+
openclaw,
|
|
306
|
+
};
|
|
307
|
+
const choices = CLIENTS.filter((client) => !http || client !== 'claude-desktop').map((client) => ({ name: CLIENT_NAMES[client], value: client, found: !!detected[client] }));
|
|
308
|
+
const available = choices.filter((c) => c.found);
|
|
309
|
+
if (available.length)
|
|
310
|
+
console.log(`Detected: ${available.map((c) => c.name).join(', ')}.`);
|
|
311
|
+
else
|
|
265
312
|
console.log('No supported agents detected. Choose Other / manual setup to configure one.');
|
|
266
|
-
console.log('Pick one at a time with the arrow keys and enter; add more after.');
|
|
267
313
|
const picked = [];
|
|
268
314
|
while (picked.length < choices.length) {
|
|
269
315
|
const remaining = choices.filter((c) => !picked.includes(c.value));
|
|
316
|
+
const detected = remaining.filter((c) => c.found);
|
|
270
317
|
const manual = remaining.filter((c) => !c.found);
|
|
271
318
|
const pick = await select({
|
|
272
|
-
message: `
|
|
319
|
+
message: `Connect Agent Pass${picked.length ? ` (${picked.map((c) => CLIENT_NAMES[c]).join(', ')} selected)` : ''}`,
|
|
273
320
|
choices: [
|
|
274
|
-
...
|
|
321
|
+
...(detected.length
|
|
322
|
+
? [
|
|
323
|
+
{
|
|
324
|
+
name: `Connect ${detected.length === 1 ? detected[0].name : `all ${detected.length} detected agents`}`,
|
|
325
|
+
value: 'all',
|
|
326
|
+
},
|
|
327
|
+
{ name: 'Choose specific agents', value: 'choose' },
|
|
328
|
+
]
|
|
329
|
+
: []),
|
|
275
330
|
...(manual.length ? [{ name: 'Other / manual setup', value: 'manual' }] : []),
|
|
276
|
-
{ name:
|
|
331
|
+
{ name: picked.length ? 'Connect selected agents' : 'Cancel', value: null },
|
|
277
332
|
],
|
|
278
333
|
});
|
|
279
334
|
if (pick === null)
|
|
280
335
|
break;
|
|
336
|
+
if (pick === 'all')
|
|
337
|
+
return [...picked, ...detected.map((c) => c.value)];
|
|
338
|
+
if (pick === 'choose') {
|
|
339
|
+
const selected = await checkbox({
|
|
340
|
+
message: 'Select agents with space, then enter to connect (none to go back)',
|
|
341
|
+
choices: detected,
|
|
342
|
+
});
|
|
343
|
+
if (selected.length)
|
|
344
|
+
return [...picked, ...selected];
|
|
345
|
+
}
|
|
281
346
|
if (pick === 'manual') {
|
|
282
347
|
const client = await select({
|
|
283
348
|
message: 'Choose a client to configure manually',
|
|
@@ -286,20 +351,6 @@ async function chooseClients() {
|
|
|
286
351
|
if (client !== null)
|
|
287
352
|
picked.push(client);
|
|
288
353
|
}
|
|
289
|
-
else {
|
|
290
|
-
picked.push(pick);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
if (picked.length === 0) {
|
|
294
|
-
const finish = await select({
|
|
295
|
-
message: 'No agent picked. Finish without registering any?',
|
|
296
|
-
choices: [
|
|
297
|
-
{ name: 'Go back and pick one', value: false },
|
|
298
|
-
{ name: 'Finish; I will run connect later', value: true },
|
|
299
|
-
],
|
|
300
|
-
});
|
|
301
|
-
if (!finish)
|
|
302
|
-
return chooseClients();
|
|
303
354
|
}
|
|
304
355
|
return picked;
|
|
305
356
|
}
|
|
@@ -319,13 +370,16 @@ program
|
|
|
319
370
|
const { mcpUrl } = JSON.parse(await readFile(join(store.directory, 'runtime.json'), 'utf8'));
|
|
320
371
|
http = { url: mcpUrl, headers: { Authorization: `Bearer ${await store.mcpToken()}` } };
|
|
321
372
|
}
|
|
322
|
-
const clients = o.client ? [o.client] : await chooseClients();
|
|
373
|
+
const clients = o.client ? [o.client] : await chooseClients(!!http);
|
|
323
374
|
for (const client of clients) {
|
|
324
375
|
await registerClient(client, http);
|
|
325
376
|
await installSkill(client);
|
|
326
377
|
}
|
|
327
|
-
if (
|
|
328
|
-
|
|
378
|
+
if (clients.length) {
|
|
379
|
+
const manual = clients.some((client) => client === 'json' || (http && (client === 'codex' || client === 'hermes')));
|
|
380
|
+
const names = clients.map((client) => client === 'json' ? 'your agent' : CLIENT_NAMES[client]);
|
|
381
|
+
console.log(`\n${manual ? 'After adding the configuration above:' : 'Connected.'}\n1. Restart ${names.join(', ')}.\n2. Start a new chat session${clients.length > 1 ? ' in each' : ''}.`);
|
|
382
|
+
}
|
|
329
383
|
});
|
|
330
384
|
// Run only when this file is the entry: directly, through tsx in development, or through the
|
|
331
385
|
// package's `agent-pass` bin, which is a symlink to it.
|