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

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.
@@ -4,7 +4,7 @@
4
4
  "graphqlUrl": "https://graphql.mainnet.sui.io/graphql",
5
5
  "chainIdentifier": "4btiuiMPvEENsttpZC7CZ53DruC3MAgfznDbASZ7DR6S",
6
6
  "packageId": "0x389b58171d057852dd4b071d47474a2a97a6e4489cc2094a527a57d57d58063f",
7
- "publishedAt": "0x389b58171d057852dd4b071d47474a2a97a6e4489cc2094a527a57d57d58063f",
7
+ "publishedAt": "0x21eff2fccc83a6c5ec789a0a44a73b7b7884eb50c418abb41796ac14a1fe4683",
8
8
  "configId": "0xd300382e608b07f96796e707ab92253597fc4c199172cc35627aad6c2d243f2c",
9
9
  "coins": [
10
10
  {
@@ -3,9 +3,9 @@
3
3
  "grpcUrl": "https://fullnode.testnet.sui.io:443",
4
4
  "graphqlUrl": "https://graphql.testnet.sui.io/graphql",
5
5
  "chainIdentifier": "69WiPg3DAQiwdxfncX6wYQ2siKwAe6L9BZthQea3JNMD",
6
- "packageId": "0xb6e9d01e6718cf1ccc33598efc892e1891f564f82824cd4af5b7d40160e21bf0",
7
- "publishedAt": "0xb6e9d01e6718cf1ccc33598efc892e1891f564f82824cd4af5b7d40160e21bf0",
8
- "configId": "0xe465c9fc3225454f16f2212136f6b2ccea2dc5d4168502b42bbdff548dbca7c8",
6
+ "packageId": "0x00ab15079b220610fc6b22c44c0d1d9de5e614bf3249aac06c966f4f60903293",
7
+ "publishedAt": "0x00ab15079b220610fc6b22c44c0d1d9de5e614bf3249aac06c966f4f60903293",
8
+ "configId": "0x742f3b1ffd770d06308a72bb31265d85b2bfdfbeff82742788960f07830af35d",
9
9
  "coins": [
10
10
  {
11
11
  "type": "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
@@ -13,37 +13,59 @@
13
13
  "decimals": 9
14
14
  },
15
15
  {
16
- "type": "0x6829a10a5340763ad78735fea97f9e26c02cd774bb20cb1d12615b1e54e8deeb::usdc::USDC",
16
+ "type": "0x6547c10c36c29651d59686f3b5017eafd5ac8bce26e6e500368f8ec650188a72::usdc::USDC",
17
17
  "symbol": "USDC",
18
18
  "decimals": 6
19
19
  }
20
20
  ],
21
- "pools": [],
21
+ "pools": [
22
+ {
23
+ "venue": "deepbook",
24
+ "poolId": "0xfdadb096936979e624522b70f90234ad11bca114f658d2c7127bbcb98b193a69",
25
+ "coinA": "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
26
+ "coinB": "0x6547c10c36c29651d59686f3b5017eafd5ac8bce26e6e500368f8ec650188a72::usdc::USDC"
27
+ },
28
+ {
29
+ "venue": "cetus",
30
+ "poolId": "0x925f8ac4fdda84240133b447e575170a037be2e639d29647048a9b2df2d8d4d8",
31
+ "coinA": "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
32
+ "coinB": "0x6547c10c36c29651d59686f3b5017eafd5ac8bce26e6e500368f8ec650188a72::usdc::USDC"
33
+ }
34
+ ],
22
35
  "maxTermDays": 365,
23
36
  "demoFaucet": {
24
- "packageId": "0x6829a10a5340763ad78735fea97f9e26c02cd774bb20cb1d12615b1e54e8deeb",
25
- "faucetId": "0xc93883668a3e6b44e8333936ea9e2817805be1f0d673a6887a78b3156e2e9ed4",
26
- "coin": "0x6829a10a5340763ad78735fea97f9e26c02cd774bb20cb1d12615b1e54e8deeb::usdc::USDC"
37
+ "packageId": "0x6547c10c36c29651d59686f3b5017eafd5ac8bce26e6e500368f8ec650188a72",
38
+ "faucetId": "0x371cc8f33cdbad58441aba8d828d29a341285136bc6a67bb9dc4344527ae8728",
39
+ "coin": "0x6547c10c36c29651d59686f3b5017eafd5ac8bce26e6e500368f8ec650188a72::usdc::USDC"
27
40
  },
28
41
  "protocols": {
29
42
  "deepbook": {
30
- "packageId": "0x5151e1122073b79c9aafeff11a10420d6c9c0d2d03a7428fa908ace0d368ebcb",
31
- "publishedAt": "0x5151e1122073b79c9aafeff11a10420d6c9c0d2d03a7428fa908ace0d368ebcb"
43
+ "packageId": "0xde09a6a70f6247b6bd843fa6c58d985c5fbde193ce1fc451210f213dea5fb805",
44
+ "publishedAt": "0xde09a6a70f6247b6bd843fa6c58d985c5fbde193ce1fc451210f213dea5fb805"
32
45
  },
33
46
  "cetus": {
34
- "packageId": "0x62618216842046496e2dfc46400a116558d474a595ccb1bfffbea0ba6e032885",
35
- "publishedAt": "0x62618216842046496e2dfc46400a116558d474a595ccb1bfffbea0ba6e032885",
36
- "configId": "0x1ba07f13168a8ce9016d4c11cf3c9e82b5750904d5ebd065b802d04e4497386c"
47
+ "packageId": "0x6389949994451e382b6e3f71ff60c8aeb7991c22626c64a9c0704c751ae3e762",
48
+ "publishedAt": "0x6389949994451e382b6e3f71ff60c8aeb7991c22626c64a9c0704c751ae3e762",
49
+ "configId": "0xca499c91f302284d5a71b85f2fda768ca58ff88e95ec73c69fb64d96dec7d809"
37
50
  },
38
51
  "navi": {
39
- "packageId": "0xac15f2796ef5484dc66e0ffe17464c9858f0b5d8cd199a05f0346dda0e0f6ab2",
40
- "publishedAt": "0xac15f2796ef5484dc66e0ffe17464c9858f0b5d8cd199a05f0346dda0e0f6ab2",
41
- "oraclePackageId": "0xf817a7885d31650680d4eeb2e55220316f57f902a23a1648f3d469876463a45d",
42
- "storageId": "0x073f220b58dd691ffa01505274677784472450ca845c813b3ee77fa8fc8654e3",
43
- "oracleId": "0x8c9198b2eca4e9b08b456a23ba2c9862df34e06b350f3912320250dfd1cc235f",
44
- "incentiveV2Id": "0xcc1b64820185219fe7554ea223a238aecece52733f772c76adcc94b2b68df60f",
45
- "incentiveV3Id": "0x24c969a0d6006b7b5e9cb0920b9ade50ba8acbfb30f5d5d5928538feb1984a4e",
46
- "reserves": {}
52
+ "packageId": "0xdaa41ff6a374d2e73f1750fbc707919e7cce491b4d0c3ef8ff7d8bbc880798e9",
53
+ "publishedAt": "0xdaa41ff6a374d2e73f1750fbc707919e7cce491b4d0c3ef8ff7d8bbc880798e9",
54
+ "oraclePackageId": "0xdcb7679d0bbc6577471f0d8e1f827f8c32f239fc1b5a993b3b5e0c7f5ab415ed",
55
+ "storageId": "0xe61937792bad26e06ae8a8238a42ff29c581ebb48167f54ef58b1d351e886b81",
56
+ "oracleId": "0xc56207ad573d9ccdddf9e8fe5f56f28b284504d836014ce31964cad70acbd0f2",
57
+ "incentiveV2Id": "0x9bc5bf093fef467da7c9830a180d0a2407074d401f8d15a50a289888b2747c6f",
58
+ "incentiveV3Id": "0x5af68707c38587a0a2a82ebdd147d3d6db8f0ab154e9e1564eab8717652ce48b",
59
+ "reserves": {
60
+ "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI": {
61
+ "poolId": "0xb1f1ef1f05c7236b3f0709bfd84200381a7fe2804531411ecb1b2ffb5ba001f2",
62
+ "assetId": 0
63
+ },
64
+ "0x6547c10c36c29651d59686f3b5017eafd5ac8bce26e6e500368f8ec650188a72::usdc::USDC": {
65
+ "poolId": "0xdc1b1f1e94654adfc08af5457e4f23c2375ad465bd1295b88dcb1c55b38eecfa",
66
+ "assetId": 1
67
+ }
68
+ }
47
69
  }
48
70
  }
49
71
  }
package/dist/agent.js CHANGED
@@ -13,7 +13,7 @@ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
13
13
  import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
14
14
  import { Inputs, Transaction } from '@mysten/sui/transactions';
15
15
  import { fromBase64, normalizeStructTag, normalizeSuiAddress, toBase64 } from '@mysten/sui/utils';
16
- import { activeValidators, clientFor, quoteSwap, readAllowance, readControl } from './chain.js';
16
+ import { activeValidators, buildResignation, clientFor, quoteSwap, readAllowance, readControl, } from './chain.js';
17
17
  import { describeRefusal } from './describe.js';
18
18
  import { poolsFor, sameCoin, SUI, } from './domain.js';
19
19
  import { refreshNaviPrices } from './navi.js';
@@ -498,6 +498,13 @@ export function stake(i, amount, validator) {
498
498
  });
499
499
  return tx;
500
500
  }
501
+ /**
502
+ * Give up this key's authority for good: the chain refuses every later action under the pass.
503
+ * The owner closes the pass from its page when they want the storage deposit back.
504
+ */
505
+ export function resign(i) {
506
+ return buildResignation(i.deployment, i.active.passId);
507
+ }
501
508
  /** Withdraw one held stake, principal and rewards, into the owner's balance. No allowance is drawn. */
502
509
  export function unstake(i, stakeId) {
503
510
  const d = i.deployment, tx = new Transaction();
package/dist/chain.js CHANGED
@@ -153,6 +153,12 @@ export const allowanceType = (coin) => `0x2::allowance::Allowance<0x2::balance::
153
153
  export const allowanceCapType = (coin) => `0x2::allowance::AllowanceCap<0x2::balance::Balance<${coin}>>`;
154
154
  export const policyType = (d, module, name, typeArguments) => normalizeStructTag(`${d.packageId}::${module}::${name}${typeArguments.length ? `<${typeArguments.join(',')}>` : ''}`);
155
155
  const typeNameTag = (name) => normalizeStructTag(`0x${name}`);
156
+ /** The agent's own ending: `pass::resign`, signed by the session key; see `agent.resign`. */
157
+ export function buildResignation(d, passId) {
158
+ const tx = new Transaction();
159
+ tx.moveCall({ target: `${d.publishedAt}::pass::resign`, arguments: [tx.object(passId)] });
160
+ return tx;
161
+ }
156
162
  export async function readAuthorization(client, d, digest) {
157
163
  const result = await client.waitForTransaction({
158
164
  digest,
package/dist/describe.js CHANGED
@@ -252,6 +252,9 @@ export function describeAttempt(d, sessionAddress, recipients, tx) {
252
252
  what = `Unstake ${stake ? short(stake) : 'a stake'} back to your balance`;
253
253
  break;
254
254
  }
255
+ case 'resign':
256
+ what = 'Give up the agent key: the pass refuses it from now on';
257
+ break;
255
258
  default:
256
259
  what = OWNER_ONLY.has(main.function)
257
260
  ? `Call the owner-only ${main.module}::${main.function}`
package/dist/plugin.js CHANGED
@@ -21,7 +21,7 @@ import { Transaction } from '@mysten/sui/transactions';
21
21
  import { fromBase64, normalizeSuiAddress } from '@mysten/sui/utils';
22
22
  import { z } from 'zod';
23
23
  import { adoptAuthorization, applyPendingChange, RulesMismatch } from './activation.js';
24
- import { clientFor, deepbookSizes, findPools, quoteSwap, readAllHoldings, readHoldings, readStatus, withMarketFacts, } from './chain.js';
24
+ import { buildResignation, clientFor, deepbookSizes, findPools, quoteSwap, readAllHoldings, readHoldings, readStatus, withMarketFacts, } from './chain.js';
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';
@@ -736,6 +736,44 @@ export function createPluginMcp(registry) {
736
736
  return failure(error, 'Cannot propose the change');
737
737
  }
738
738
  });
739
+ server.registerTool('resign_pass', {
740
+ description: "End this key's authority yourself, with no owner signature: one transaction from the agent key, after which the chain refuses every action under the pass. Use it when the work is done and nothing recurring remains, when the owner says stop, after a keyAlert, or on a mismatch. The pass and its allowances stay on chain, inert, until the owner closes the pass from its page and gets the storage deposit back; tell them so. Irreversible: a new pass needs a new proposal.",
741
+ inputSchema: {
742
+ pass: z
743
+ .string()
744
+ .optional()
745
+ .describe('pass id prefix from list_passes; omit if there is one'),
746
+ },
747
+ annotations: { readOnlyHint: false, destructiveHint: true },
748
+ }, async ({ pass }) => {
749
+ try {
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');
754
+ const client = clientFor(d);
755
+ const tx = buildResignation(d, active.passId);
756
+ tx.setSender(store.state.sessionAddress);
757
+ const bytes = await tx.build({ client });
758
+ await SessionStore.recordSigned(store.directory, await Transaction.from(bytes).getDigest());
759
+ const outcome = await client.signAndExecuteTransaction({
760
+ transaction: bytes,
761
+ signer: await store.key(),
762
+ });
763
+ if (outcome.$kind !== 'Transaction')
764
+ throw new Error(`The chain refused the resignation: ${outcome.FailedTransaction.status.error?.message}`);
765
+ await client.waitForTransaction({ result: outcome });
766
+ return result({
767
+ pass: session.id,
768
+ digest: outcome.Transaction.digest,
769
+ status: 'revoked',
770
+ 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.',
771
+ });
772
+ }
773
+ catch (error) {
774
+ return failure(error, 'Resignation failed');
775
+ }
776
+ });
739
777
  server.registerTool('forget_pass', {
740
778
  description: "Retire a session whose pass is over: refuses while the pass is live, returns the key's unspent gas float to the owner, then deletes the session directory and its key. Works on sessions an earlier version wrote (list_passes shows them as unreadable). Offer this for every pass list_passes reports as closed or stopped, and for proposals the owner never signed.",
741
779
  inputSchema: {
package/docs/AGENT.md CHANGED
@@ -50,7 +50,8 @@ on one listed pool for the pair (the first when none is named), or along `route`
50
50
  pool ids in order, when the pair trades only through other coins, `supply(i, coin, amount)`, `await withdraw(i, coin, amount)`,
51
51
  `await borrow(i, coin, amount)`, `await repay(i, coin, amount)` (the three that check health first
52
52
  refresh NAVI's oracle prices, which on mainnet must be newer than its update interval), `stake(i, amount, validator)` in SUI with
53
- `await pickValidator(i)` for the validator, `unstake(i, stakeId)` and `refillGas(i, amount)`. Each
53
+ `await pickValidator(i)` for the validator, `unstake(i, stakeId)`, `refillGas(i, amount)` and
54
+ `resign(i)`, which ends this key's authority for good. Each
54
55
  returns a `Transaction`; `submit` tops up your gas from the gas allowance when your own balance
55
56
  is below 0.01 SUI (by what the allowance can still give, up to 0.05 SUI), builds with a dry run
56
57
  that sizes the gas budget, signs through the signer, executes and waits.
@@ -179,6 +180,7 @@ window; `0x3::validator_set` 10 below the 1 SUI minimum stake.
179
180
  | `pass::navi_repay` | `[coin]` | pass, config, allowance, withdrawal, oracle, storage, pool, asset, incentiveV2, incentiveV3, clock |
180
181
  | `pass::stake` | | pass, config, SUI allowance, withdrawal, `0x5`, validator address, clock; returns the stake's ID |
181
182
  | `pass::unstake` | | pass, config, `0x5`, stake ID, clock |
183
+ | `pass::resign` | | pass |
182
184
  | `pass::add_policy`, `remove_policy`, `set_term`, `revoke_agent`, `deposit_object`, `withdraw_object`, `navi_open`, `destroy` | | **owner sender only**; installs take `config` after the pass, exits do not |
183
185
 
184
186
  A swap is a route in one transaction: `begin_swap` charges the allowance and the `SwapPolicy<in,
package/docs/PLAYBOOK.md CHANGED
@@ -105,8 +105,8 @@ ask for a yes, unless they already stated every rule explicitly.
105
105
 
106
106
  ## 2. Propose the pass and wait for the signature
107
107
 
108
- `propose_authorization`, `propose_change`, `list_passes`, `find_pools`, `revoke_pass` and
109
- `forget_pass` live on the stdio server (`agent-pass mcp`), which keeps every session on the
108
+ `propose_authorization`, `propose_change`, `list_passes`, `find_pools`, `revoke_pass`,
109
+ `resign_pass` and `forget_pass` live on the stdio server (`agent-pass mcp`), which keeps every session on the
110
110
  machine. A per-session HTTP signer has only `session_info` and `sign_transaction`.
111
111
 
112
112
  The pass goes on the network the owner names (`network`, one of `list_passes.networks`), else on
@@ -130,8 +130,8 @@ Then call `session_info` with the pass and `wait: 120`, again while the status i
130
130
  policies back from chain and checked them against the proposal. Report the pass id, the
131
131
  authorization digest, the owner's balances and what the key may still withdraw. A status of
132
132
  `mismatch` means the owner signed something other than the reviewed rules: quote
133
- `authorizationError`, do not act, and ask the owner to close the pass from its page before you
134
- propose again. A `chainError` means the signer could not read the chain; the status is unknown
133
+ `authorizationError`, call `resign_pass` so the key cannot act under rules nobody reviewed, and
134
+ ask the owner to close the pass from its page before you propose again. A `chainError` means the signer could not read the chain; the status is unknown
135
135
  until a read succeeds, so fix the connection and call again.
136
136
 
137
137
  ## 3. Act within the rules
@@ -151,8 +151,8 @@ Start with `session_info`. It returns:
151
151
 
152
152
  **Key alert.** When `list_passes` or `session_info` carries `keyAlert`, the chain shows
153
153
  transactions from the agent key that this machine never signed: a copy of the key is in use
154
- elsewhere. Stop acting, tell the owner at once with the digests, and offer `revoke_pass` so they
155
- can stop the agent from the pass page.
154
+ elsewhere. Call `resign_pass` at once, so the chain refuses the key from then on, then tell the
155
+ owner with the digests; they close the pass from its page.
156
156
 
157
157
  **Updates.** When `server.update` is present in `list_passes` or `session_info`, a newer release
158
158
  is out. Tell the owner once per conversation, with `server.update.command` and the reminder to
@@ -239,8 +239,13 @@ Until the owner signs, the old rules apply and `session_info` reports `changing`
239
239
 
240
240
  ## 6. End it
241
241
 
242
- There are two endings, both on the pass page, which `revoke_pass` opens for the pass the owner
243
- names. Without a pass it opens the owner page, which lists all of the owner's passes and ends any
242
+ When the work is done and nothing recurring remains, or the owner tells you to stop, call
243
+ `resign_pass`: one transaction from your own key, no owner signature, after which the chain
244
+ refuses every action under the pass. Tell the owner, and that closing the pass from its page
245
+ refunds its storage deposit. It is irreversible; a new pass needs a new proposal.
246
+
247
+ The owner has two endings of their own, both on the pass page, which `revoke_pass` opens for the
248
+ pass the owner names. Without a pass it opens the owner page, which lists all of the owner's passes and ends any
244
249
  number of them with one signature; use that when several are to go.
245
250
 
246
251
  - **Stop the agent now** revokes the key and deletes the allowances, and keeps the pass and its
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mysten-incubation/sui-agent-pass",
3
- "version": "0.1.28",
3
+ "version": "0.1.29",
4
4
  "type": "module",
5
5
  "description": "AI builds transactions. A session signer signs. Your pass enforces the rules.",
6
6
  "repository": {
@@ -110,8 +110,8 @@ ask for a yes, unless they already stated every rule explicitly.
110
110
 
111
111
  ## 2. Propose the pass and wait for the signature
112
112
 
113
- `propose_authorization`, `propose_change`, `list_passes`, `find_pools`, `revoke_pass` and
114
- `forget_pass` live on the stdio server (`agent-pass mcp`), which keeps every session on the
113
+ `propose_authorization`, `propose_change`, `list_passes`, `find_pools`, `revoke_pass`,
114
+ `resign_pass` and `forget_pass` live on the stdio server (`agent-pass mcp`), which keeps every session on the
115
115
  machine. A per-session HTTP signer has only `session_info` and `sign_transaction`.
116
116
 
117
117
  The pass goes on the network the owner names (`network`, one of `list_passes.networks`), else on
@@ -135,8 +135,8 @@ Then call `session_info` with the pass and `wait: 120`, again while the status i
135
135
  policies back from chain and checked them against the proposal. Report the pass id, the
136
136
  authorization digest, the owner's balances and what the key may still withdraw. A status of
137
137
  `mismatch` means the owner signed something other than the reviewed rules: quote
138
- `authorizationError`, do not act, and ask the owner to close the pass from its page before you
139
- propose again. A `chainError` means the signer could not read the chain; the status is unknown
138
+ `authorizationError`, call `resign_pass` so the key cannot act under rules nobody reviewed, and
139
+ ask the owner to close the pass from its page before you propose again. A `chainError` means the signer could not read the chain; the status is unknown
140
140
  until a read succeeds, so fix the connection and call again.
141
141
 
142
142
  ## 3. Act within the rules
@@ -156,8 +156,8 @@ Start with `session_info`. It returns:
156
156
 
157
157
  **Key alert.** When `list_passes` or `session_info` carries `keyAlert`, the chain shows
158
158
  transactions from the agent key that this machine never signed: a copy of the key is in use
159
- elsewhere. Stop acting, tell the owner at once with the digests, and offer `revoke_pass` so they
160
- can stop the agent from the pass page.
159
+ elsewhere. Call `resign_pass` at once, so the chain refuses the key from then on, then tell the
160
+ owner with the digests; they close the pass from its page.
161
161
 
162
162
  **Updates.** When `server.update` is present in `list_passes` or `session_info`, a newer release
163
163
  is out. Tell the owner once per conversation, with `server.update.command` and the reminder to
@@ -244,8 +244,13 @@ Until the owner signs, the old rules apply and `session_info` reports `changing`
244
244
 
245
245
  ## 6. End it
246
246
 
247
- There are two endings, both on the pass page, which `revoke_pass` opens for the pass the owner
248
- names. Without a pass it opens the owner page, which lists all of the owner's passes and ends any
247
+ When the work is done and nothing recurring remains, or the owner tells you to stop, call
248
+ `resign_pass`: one transaction from your own key, no owner signature, after which the chain
249
+ refuses every action under the pass. Tell the owner, and that closing the pass from its page
250
+ refunds its storage deposit. It is irreversible; a new pass needs a new proposal.
251
+
252
+ The owner has two endings of their own, both on the pass page, which `revoke_pass` opens for the
253
+ pass the owner names. Without a pass it opens the owner page, which lists all of the owner's passes and ends any
249
254
  number of them with one signature; use that when several are to go.
250
255
 
251
256
  - **Stop the agent now** revokes the key and deletes the allowances, and keeps the pass and its