@cmdoss/agent-pass-plugin 0.1.2-dev.19.1 → 0.1.2-dev.21.1

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 CHANGED
@@ -60,7 +60,8 @@ See the [trading skill](skills/agent-pass-plugin-trading/SKILL.md) for tool sequ
60
60
 
61
61
  - Keep the machine and local service running. Closing chat/browser or logging out
62
62
  does not stop an active plan. Restarted plans pause and require explicit Resume.
63
- - Pause/Stop prevent new trades. Revoke requires owner review and chain confirmation.
63
+ - Pause/Stop prevent new trades. Revoke requires the owner to choose **Stop the agent now**
64
+ (or **Close the pass**) on the official Agent Pass page, approve in the wallet, and chain confirmation.
64
65
  Holdings are not automatically sold; submitted transactions still reconcile.
65
66
  - Delegated keys stay in the official local SDK's `agent-pass/` data directory.
66
67
  Never commit runtime data or signer sessions. No owner seed is requested.
package/dist/mcp.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DEFAULT_APP_PORT, SERVICE_ID } from "./shared/constants.js";
1
+ import { DEFAULT_APP_PORT, REVOCATION_CLOSE_BUTTON, REVOCATION_STOP_BUTTON, SERVICE_ID, } from "./shared/constants.js";
2
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
4
  import { randomUUID } from "node:crypto";
@@ -245,7 +245,7 @@ server.registerTool("list_transactions", {
245
245
  }, ({ planId }) => api(`/api/transactions${planId ? `?planId=${encodeURIComponent(planId)}` : ""}`));
246
246
  for (const action of ["start", "pause", "resume", "stop", "revoke"]) {
247
247
  server.registerTool(`${action}_plan`, {
248
- description: `${action} a plan in the runtime mode. Testnet Start/resume requires matching verified onchain authorization and explicit user intent. Pause/Stop block new submissions; submitted digests still reconcile. Testnet Revoke stops local submissions and returns the official owner wallet review URL; only report onchain revoked after fresh confirmation. Paper revoke is simulation. Holdings are not sold.`,
248
+ description: `${action} a plan in the runtime mode. Testnet Start/resume requires matching verified onchain authorization and explicit user intent. Pause/Stop block new submissions; submitted digests still reconcile. Testnet Revoke stops local submissions and returns the official Agent Pass page URL (reviewUrl/revocationUrl) plus revocationSteps. That page has no "Revoke" button: tell the owner to open it, choose "${REVOCATION_STOP_BUTTON}" (revokes the agent key and deletes its allowances; the pass stays) or "${REVOCATION_CLOSE_BUTTON}" (same, and also returns everything the pass holds to the owner wallet), then approve in their wallet. Never press either button yourself. Only report onchain revoked after fresh confirmation. Paper revoke is simulation. Holdings are not sold.`,
249
249
  inputSchema: { planId: z.string().uuid() },
250
250
  outputSchema: QuoteDataSchema,
251
251
  annotations: {
@@ -7,3 +7,10 @@ export const SDK_UI_ORIGIN = `http://127.0.0.1:${SDK_UI_PORT}`;
7
7
  export const STRATEGY_VERSION = "1.1.0";
8
8
  export const LOOP_INTERVAL_MS = 1_000;
9
9
  export const VALUATION_MAX_AGE_MS = 60_000;
10
+ /**
11
+ * Owner-only Testnet revocation steps. SDK 0.1.35's pass page has no "Revoke" button;
12
+ * it offers exactly these two endings. The agent opens the page but never presses either.
13
+ */
14
+ export const REVOCATION_STOP_BUTTON = "Stop the agent now";
15
+ export const REVOCATION_CLOSE_BUTTON = "Close the pass";
16
+ export const REVOCATION_OWNER_STEPS = `Open the Agent Pass page, choose "${REVOCATION_STOP_BUTTON}" (revokes the agent key and deletes its allowances; the pass stays) or "${REVOCATION_CLOSE_BUTTON}" (does the same and also returns everything the pass holds to the owner wallet), then approve in the owner wallet. Only the owner presses these buttons; the agent never does.`;
@@ -237,6 +237,46 @@ export function assertBindingPolicy(binding, input) {
237
237
  equal(binding.expected, expected(input, setup.name, Number(setup.expiresMs)), "bound plan rules");
238
238
  equal(binding.policyHash, digest(binding.expected), "bound policy hash");
239
239
  }
240
+ /**
241
+ * The owner's revocation digest, only when the transaction read back from chain proves it:
242
+ * it succeeded, the plan owner sent it, it called the bundled package's pass::revoke_agent and
243
+ * it wrote this pass. Anything else (a later owner edit, a closed pass) yields undefined.
244
+ */
245
+ export function verifiedRevocationDigest(deployment, binding, digest, value) {
246
+ try {
247
+ if (typeof digest !== "string" ||
248
+ !/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(digest))
249
+ return undefined;
250
+ const result = obj(value, "revocation transaction");
251
+ if (result.$kind !== "Transaction")
252
+ return undefined;
253
+ const tx = obj(result.Transaction, "revocation transaction");
254
+ if (tx.digest !== undefined && tx.digest !== digest)
255
+ return undefined;
256
+ if (obj(obj(tx.effects, "effects").status, "status").success !== true)
257
+ return undefined;
258
+ const data = obj(tx.transaction, "transaction data");
259
+ if (address(data.sender) !== address(binding.owner))
260
+ return undefined;
261
+ const packages = [
262
+ deployment.packageId,
263
+ deployment.publishedAt,
264
+ ]
265
+ .filter((id) => typeof id === "string")
266
+ .map(address);
267
+ const revokes = (Array.isArray(data.commands) ? data.commands : []).some((command) => command?.$kind === "MoveCall" &&
268
+ command.MoveCall?.module === "pass" &&
269
+ command.MoveCall?.function === "revoke_agent" &&
270
+ packages.includes(address(command.MoveCall?.package)));
271
+ const changed = obj(tx.effects, "effects").changedObjects;
272
+ const wrotePass = (Array.isArray(changed) ? changed : []).some((o) => typeof o?.objectId === "string" &&
273
+ address(o.objectId) === address(binding.passId));
274
+ return revokes && wrotePass ? digest : undefined;
275
+ }
276
+ catch {
277
+ return undefined;
278
+ }
279
+ }
240
280
  export class OfficialAuthorization {
241
281
  options;
242
282
  root;
@@ -603,6 +643,44 @@ export class OfficialAuthorization {
603
643
  alreadyRevoked: result.alreadyRevoked === true,
604
644
  };
605
645
  }
646
+ async revocationDigest(binding) {
647
+ const d = await this.deployment();
648
+ if (binding.network !== "testnet" ||
649
+ binding.chainIdentifier !== d.chainIdentifier ||
650
+ address(binding.packageId) !== address(d.packageId))
651
+ return undefined;
652
+ try {
653
+ const read = this.options.readPassTransaction
654
+ ? await this.options.readPassTransaction(d, address(binding.passId))
655
+ : await this.readPassTransaction(d, address(binding.passId));
656
+ return verifiedRevocationDigest(d, binding, read.digest, read.transaction);
657
+ }
658
+ catch {
659
+ return undefined;
660
+ }
661
+ }
662
+ async readPassTransaction(deployment, passId) {
663
+ const moduleName = "@mysten-incubation/sui-agent-pass/chain";
664
+ const chain = (await import(moduleName));
665
+ const client = chain.clientFor(deployment);
666
+ await chain.assertChain(client, deployment);
667
+ const found = await client.getObject({
668
+ objectId: passId,
669
+ include: { previousTransaction: true },
670
+ signal: AbortSignal.timeout(12_000),
671
+ });
672
+ const digest = found.object?.previousTransaction;
673
+ if (typeof digest !== "string")
674
+ return { digest, transaction: null };
675
+ return {
676
+ digest,
677
+ transaction: await client.getTransaction({
678
+ digest,
679
+ include: { transaction: true, effects: true },
680
+ signal: AbortSignal.timeout(12_000),
681
+ }),
682
+ };
683
+ }
606
684
  themedUrl(url) {
607
685
  if (this.options.reviewOrigin) {
608
686
  const origin = new URL(this.options.reviewOrigin);
@@ -1,4 +1,4 @@
1
- import { STRATEGY_VERSION } from "../shared/constants.js";
1
+ import { REVOCATION_OWNER_STEPS, STRATEGY_VERSION, } from "../shared/constants.js";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { fingerprint, testnetInput, units, } from "./model.js";
4
4
  import { validatePlan } from "./policy.js";
@@ -223,6 +223,15 @@ export class TestnetEngine {
223
223
  if (request.payloadHash !== plan.reviewHash)
224
224
  throw new Error("The reviewed plan changed");
225
225
  const authorization = await this.authorization.inspect(plan.policy, request.authorization);
226
+ // Best effort, read-only and before the fresh re-read: a digest is recorded only when the
227
+ // chain shows the owner's revoke_agent transaction. Otherwise it stays absent, never guessed.
228
+ const revocationDigest = ["revoked", "closed"].includes(authorization.status) &&
229
+ plan.status !== "revoked" &&
230
+ plan.binding
231
+ ? await this.authorization
232
+ .revocationDigest?.(plan.binding)
233
+ .catch(() => undefined)
234
+ : undefined;
226
235
  const fresh = this.repository.get(plan.id);
227
236
  validatePlan(fresh);
228
237
  if (fresh.reviewHash !== request.payloadHash)
@@ -256,9 +265,11 @@ export class TestnetEngine {
256
265
  else if (["revoked", "closed"].includes(authorization.status)) {
257
266
  request.status = request.kind === "revocation" ? "confirmed" : "revoked";
258
267
  if (fresh.status !== "revoked") {
268
+ if (revocationDigest)
269
+ authorization.revocationDigest = revocationDigest;
259
270
  fresh.status = "revoked";
260
271
  fresh.epoch++;
261
- this.repository.event(fresh, "revoked", "Onchain revocation confirmed; no new transactions will be submitted");
272
+ this.repository.event(fresh, "revoked", "Onchain revocation confirmed; no new transactions will be submitted", revocationDigest ? { digest: revocationDigest } : {});
262
273
  }
263
274
  }
264
275
  else if (["mismatch", "expired"].includes(authorization.status)) {
@@ -291,7 +302,7 @@ export class TestnetEngine {
291
302
  : "revoking";
292
303
  plan.epoch++;
293
304
  this.repository.event(plan, action === "revoke" ? "revocation_requested" : action, action === "revoke"
294
- ? "New submissions stopped locally. Owner must sign onchain revocation"
305
+ ? `New submissions stopped locally. Owner must sign onchain revocation: ${REVOCATION_OWNER_STEPS}`
295
306
  : "New submissions stopped; holdings remain with the owner");
296
307
  this.repository.save(plan);
297
308
  if (action === "revoke") {
@@ -1,3 +1,4 @@
1
+ import { REVOCATION_OWNER_STEPS } from "../shared/constants.js";
1
2
  import { STRATEGY_VERSION, VALUATION_MAX_AGE_MS } from "../shared/constants.js";
2
3
  import { testnetCatalog, testnetStrategy } from "../public/catalog.js";
3
4
  import { display, fingerprint } from "./model.js";
@@ -26,6 +27,7 @@ export class TestnetReadModel {
26
27
  sessionAddress: a.sessionAddress,
27
28
  passId: plan.binding?.passId,
28
29
  owner: plan.binding?.owner,
30
+ revocationDigest: a.revocationDigest,
29
31
  }
30
32
  : null;
31
33
  }
@@ -90,6 +92,7 @@ export class TestnetReadModel {
90
92
  valuation,
91
93
  authorization: this.publicAuthorization(plan),
92
94
  revocationUrl: plan.status === "revoking" ? plan.revocationUrl : undefined,
95
+ revocationSteps: plan.status === "revoking" ? REVOCATION_OWNER_STEPS : undefined,
93
96
  history: plan.history
94
97
  .slice(-200)
95
98
  .reverse()
@@ -14,8 +14,14 @@ liquidity. Test SUI and demo USDC have no real-dollar value. Mainnet is disabled
14
14
  Review the returned rules and official SDK URL; authorize with the owner wallet.
15
15
  4. Poll `get_review_request`. Only a verified matching pass enables **Start**.
16
16
  5. Explicitly Start; inspect receipts, digests and remaining budget in My plans.
17
- 6. Pause/Resume/Stop locally as needed. Revoke opens the official owner review;
18
- wait for chain confirmation. Already submitted transactions still reconcile.
17
+ 6. Pause/Resume/Stop locally as needed. Revoke blocks new submissions locally and
18
+ returns the official Agent Pass page. That page has no "Revoke" button: the owner
19
+ chooses **Stop the agent now** (revokes the agent key and deletes its allowances;
20
+ the pass stays) or **Close the pass** (same, and also returns everything the pass
21
+ holds to the owner wallet), then approves in the wallet. The agent never presses
22
+ either button. Wait for chain confirmation; the plan's `revoked` history entry
23
+ records the owner's `revoke_agent` digest when it can be read back from chain.
24
+ Already submitted transactions still reconcile.
19
25
 
20
26
  No MCP tool grants owner approval. Paper confirmation routes cannot authorize
21
27
  Testnet. The browser, persisted JSON and a closed review tab prove no permission.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@cmdoss/agent-pass-plugin",
3
- "version": "0.1.2-dev.19.1",
3
+ "version": "0.1.2-dev.21.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@cmdoss/agent-pass-plugin",
9
- "version": "0.1.2-dev.19.1",
9
+ "version": "0.1.2-dev.21.1",
10
10
  "dependencies": {
11
11
  "@fastify/static": "10.1.10",
12
12
  "@modelcontextprotocol/sdk": "1.32.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmdoss/agent-pass-plugin",
3
- "version": "0.1.2-dev.19.1",
3
+ "version": "0.1.2-dev.21.1",
4
4
  "type": "module",
5
5
  "description": "Agent Pass Plugin — local trading strategies, explicit permissions and an independent execution loop",
6
6
  "engines": {