@mysten-incubation/sui-agent-pass 0.1.29 → 0.1.30

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.
Files changed (2) hide show
  1. package/dist/plugin.js +15 -6
  2. package/package.json +1 -1
package/dist/plugin.js CHANGED
@@ -25,7 +25,7 @@ import { buildResignation, clientFor, deepbookSizes, findPools, quoteSwap, readA
25
25
  import { Deployments } from './deployments.js';
26
26
  import { describePolicy, describeSetup, renderRows } from './describe.js';
27
27
  import { address, coinBySymbol, coinInfo, connects, DAY_MS, defaultGasDaily, display, isStable, limitUnits, MAX_TERM_DAYS, poolsFor, recipientName, requiredSui, sameCoin, SetupSchema, showCoin, SUI, uncovered, units, VenueSchema, } from './domain.js';
28
- import { passIdOf } from './explorer.js';
28
+ import { findPassByAgent, passIdOf } from './explorer.js';
29
29
  import { passEnded, returnGasFloat } from './float.js';
30
30
  import { failure, INSTRUCTIONS, keyAlert, MAX_TOOL_INPUT_ELEMENTS, registerDocs, result, serverInfo, sessionInfo, SIGN_ANNOTATIONS, SIGN_DESCRIPTION, } from './mcp.js';
31
31
  import { authenticated, body, ownerPageUrl, startServer } from './server.js';
@@ -748,12 +748,20 @@ export function createPluginMcp(registry) {
748
748
  }, async ({ pass }) => {
749
749
  try {
750
750
  const session = await registry.find(pass);
751
- const { store } = session, { deployment: d, active } = store.state;
752
- if (!active)
753
- throw new Error('This pass was never authorized; nothing to resign from');
751
+ const { store } = session, { deployment: d0, sessionAddress } = store.state;
752
+ // A pass this session never adopted (a mismatch) still exists on chain for its key,
753
+ // and an upgrade keeps the package id while calls go to the newest code, which a
754
+ // session proposed earlier does not know.
755
+ const bundled = await registry.deployments.bundled(d0.network).catch(() => null);
756
+ const d = bundled && bundled.packageId === d0.packageId
757
+ ? { ...d0, publishedAt: bundled.publishedAt }
758
+ : d0;
754
759
  const client = clientFor(d);
755
- const tx = buildResignation(d, active.passId);
756
- tx.setSender(store.state.sessionAddress);
760
+ const hit = await findPassByAgent(client, d, sessionAddress);
761
+ if (!hit)
762
+ throw new Error('No pass for this key is on chain; nothing to resign from');
763
+ const tx = buildResignation(d, hit.id);
764
+ tx.setSender(sessionAddress);
757
765
  const bytes = await tx.build({ client });
758
766
  await SessionStore.recordSigned(store.directory, await Transaction.from(bytes).getDigest());
759
767
  const outcome = await client.signAndExecuteTransaction({
@@ -765,6 +773,7 @@ export function createPluginMcp(registry) {
765
773
  await client.waitForTransaction({ result: outcome });
766
774
  return result({
767
775
  pass: session.id,
776
+ passId: hit.id,
768
777
  digest: outcome.Transaction.digest,
769
778
  status: 'revoked',
770
779
  next: 'The key can no longer act. Tell the owner the pass is stopped and that closing it from its page refunds the storage deposit; then call forget_pass once it is closed.',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mysten-incubation/sui-agent-pass",
3
- "version": "0.1.29",
3
+ "version": "0.1.30",
4
4
  "type": "module",
5
5
  "description": "AI builds transactions. A session signer signs. Your pass enforces the rules.",
6
6
  "repository": {