@mysten-incubation/sui-agent-pass 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -111,7 +111,16 @@ async function mergeJsonConfig(path, entry) {
111
111
  await writeFile(path, JSON.stringify(current, null, 2) + '\n', { mode: 0o600 });
112
112
  console.log(`Wrote agent-pass into ${path}. Restart the client to load it.`);
113
113
  }
114
+ /** Registers agent-pass with Claude Code, replacing an earlier entry in the same scope. */
114
115
  async function claudeMcpAdd(args) {
116
+ const scope = args[args.indexOf('--scope') + 1];
117
+ await new Promise((done) => {
118
+ const remove = spawn('claude', ['mcp', 'remove', '--scope', scope, 'agent-pass'], {
119
+ stdio: 'ignore',
120
+ });
121
+ remove.once('error', () => done());
122
+ remove.once('exit', () => done());
123
+ });
115
124
  const child = spawn('claude', ['mcp', 'add', ...args], { stdio: 'inherit' });
116
125
  await new Promise((resolve, reject) => {
117
126
  child.once('error', reject);
package/dist/mcp.js CHANGED
@@ -6,7 +6,7 @@ import { fileURLToPath } from 'node:url';
6
6
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
7
7
  import { z } from 'zod';
8
8
  import { clientFor, deepbookSizes, readAllHoldings, readStatus } from './chain.js';
9
- import { coinInfo } from './domain.js';
9
+ import { coinInfo, DAY_MS } from './domain.js';
10
10
  export const result = (value) => ({
11
11
  content: [{ type: 'text', text: JSON.stringify(value) }],
12
12
  });
@@ -45,14 +45,51 @@ async function sdkInfo(directory) {
45
45
  note: published ? null : `${root} must be built (npm run build) before installing from it`,
46
46
  };
47
47
  }
48
- /** Which code answers: the package version and when it was built, so a stale server shows. */
49
- async function serverInfo() {
48
+ let latest = null;
49
+ /** The newest version on npm, asked at most once a day per process; null when npm is unreachable. */
50
+ async function latestVersion(name) {
51
+ if (latest && Date.now() - latest.at < DAY_MS)
52
+ return latest.version;
53
+ const version = await fetch(`https://registry.npmjs.org/${name.replace('/', '%2F')}/latest`, {
54
+ signal: AbortSignal.timeout(2_000),
55
+ })
56
+ .then((r) => (r.ok ? r.json() : null))
57
+ .then((j) => j?.version ?? null)
58
+ .catch(() => null);
59
+ latest = { at: Date.now(), version };
60
+ return version;
61
+ }
62
+ const newer = (a, b) => {
63
+ const [x, y] = [a, b].map((v) => v.split('-')[0].split('.').map(Number));
64
+ for (let i = 0; i < 3; i++)
65
+ if (x[i] !== y[i])
66
+ return (x[i] ?? 0) > (y[i] ?? 0);
67
+ return false;
68
+ };
69
+ /**
70
+ * Which code answers: the package version and when it was built, so a stale server shows, and
71
+ * for an installed package a newer release on npm with the command that takes it.
72
+ */
73
+ export async function serverInfo() {
50
74
  const pkg = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
51
75
  const built = await stat(fileURLToPath(import.meta.url)).then((s) => s.mtime.toISOString());
76
+ const installed = fileURLToPath(import.meta.url)
77
+ .split(sep)
78
+ .includes('node_modules');
79
+ const available = installed ? await latestVersion(pkg.name) : null;
52
80
  return {
53
81
  version: pkg.version,
54
82
  builtAt: built,
55
83
  note: 'This process keeps the code it started with. After this package is rebuilt or upgraded, restart the agent client so it starts a new server; compare builtAt.',
84
+ ...(available && newer(available, pkg.version)
85
+ ? {
86
+ update: {
87
+ latest: available,
88
+ command: `npm install -g ${pkg.name}@latest`,
89
+ then: 'Restart the agent client so it starts the new server; the agent-pass skill is linked to the package and follows it.',
90
+ },
91
+ }
92
+ : {}),
56
93
  };
57
94
  }
58
95
  /**
package/dist/plugin.js CHANGED
@@ -25,7 +25,7 @@ import { describePolicy, describeSetup, renderRows } from './describe.js';
25
25
  import { address, coinBySymbol, coinInfo, DAY_MS, defaultGasDaily, DeploymentSchema, display, isStable, limitUnits, poolsFor, recipientName, sameCoin, SetupSchema, showCoin, units, VenueSchema, } from './domain.js';
26
26
  import { passesByAgent } from './explorer.js';
27
27
  import { passEnded, returnGasFloat } from './float.js';
28
- import { failure, INSTRUCTIONS, registerDocs, result, sessionInfo, SIGN_ANNOTATIONS, SIGN_DESCRIPTION, } from './mcp.js';
28
+ import { failure, INSTRUCTIONS, registerDocs, result, serverInfo, sessionInfo, SIGN_ANNOTATIONS, SIGN_DESCRIPTION, } from './mcp.js';
29
29
  import { authenticated, body, ownerPageUrl, startServer } from './server.js';
30
30
  import { SessionSigner } from './signer.js';
31
31
  import { SessionStore, token } from './storage.js';
@@ -465,6 +465,7 @@ export function createPluginMcp(registry) {
465
465
  }
466
466
  : {}),
467
467
  deployment: { path, exists: own.length > 0 },
468
+ server: await serverInfo(),
468
469
  networks: [...own, ...bundled.filter((b) => !own.some((o) => o.network === b.network))],
469
470
  });
470
471
  });
package/docs/PLAYBOOK.md CHANGED
@@ -122,6 +122,10 @@ Start with `session_info`. It returns:
122
122
  - `directory`, `sdk` and `server`: the session directory, how to install and import the SDK,
123
123
  and this server's version (after an upgrade the client must restart the server).
124
124
 
125
+ **Updates.** When `server.update` is present in `list_passes` or `session_info`, a newer release
126
+ is out. Tell the owner once per conversation, with `server.update.command` and the reminder to
127
+ restart the agent afterwards, then carry on with the task; never run the command yourself.
128
+
125
129
  Act by writing a Node script against the SDK. Run `sdk.install` once in your working directory,
126
130
  then:
127
131
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mysten-incubation/sui-agent-pass",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "description": "AI builds transactions. A session signer signs. Your pass enforces the rules.",
6
6
  "repository": {
@@ -127,6 +127,10 @@ Start with `session_info`. It returns:
127
127
  - `directory`, `sdk` and `server`: the session directory, how to install and import the SDK,
128
128
  and this server's version (after an upgrade the client must restart the server).
129
129
 
130
+ **Updates.** When `server.update` is present in `list_passes` or `session_info`, a newer release
131
+ is out. Tell the owner once per conversation, with `server.update.command` and the reminder to
132
+ restart the agent afterwards, then carry on with the task; never run the command yourself.
133
+
130
134
  Act by writing a Node script against the SDK. Run `sdk.install` once in your working directory,
131
135
  then:
132
136