@cmdoss/agent-pass-plugin 0.1.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 +3 -2
- package/dist/http.js +1 -1
- package/dist/mcp.js +3 -3
- package/dist/shared/constants.js +7 -0
- package/dist/testnet/authorization.js +78 -0
- package/dist/testnet/engine.js +14 -3
- package/dist/testnet/read-model.js +19 -8
- package/dist/testnet/runner.js +5 -4
- package/docs/agent-pass-integration.md +8 -2
- package/docs/npm-release.md +11 -9
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/public/assets/agent-pass-plugin-client.js +4 -4
- package/public/assets/agent-pass-plugin-sdk.js +1 -1
- package/public/styles/plans.css +4 -0
- package/skills/agent-pass-plugin-trading/SKILL.md +42 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
var l="Agent Pass Plugin";var d=Object.freeze({decimals:3}),
|
|
1
|
+
var l="Agent Pass Plugin";var d="Stop the agent now",u="Close the pass",y=`Open the Agent Pass page, choose "${d}" (revokes the agent key and deletes its allowances; the pass stays) or "${u}" (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.`;var p=Object.freeze({decimals:3}),m=Object.freeze({leading:3,trailing:3,ellipsis:"\u2026",addressPrefix:"0x"}),N=Object.freeze({codex:"Codex",claude:"Claude Code",fallback:"your agent"});function h(n,o=p.decimals){return new Intl.NumberFormat("en-US",{minimumFractionDigits:0,maximumFractionDigits:Math.min(o,p.decimals)}).format(Number(n)||0)}function c(n){let o=String(n??""),{leading:r,trailing:i,ellipsis:e,addressPrefix:t}=m,s=o.startsWith(t)?t:"",a=o.slice(s.length);return a.length>r+i+e.length?`${s}${a.slice(0,r)}${e}${a.slice(-i)}`:o||"\u2014"}var O="https://agent-pass-plugin.commandoss.com",g=new WeakMap;function S(){for(let n of document.querySelectorAll("aside .panel > h2")){if(n.textContent.trim()!=="Held by the pass")continue;let o=n.parentElement;if(o.classList.add("sdk-split-cards"),n.classList.add("sdk-held-title"),g.has(o))continue;let r=()=>{let e=n.getBoundingClientRect().top-o.getBoundingClientRect().top-24;o.style.setProperty("--held-card-start",`${e}px`),o.style.setProperty("--balance-card-end",`${e-24}px`)},i=new ResizeObserver(r);i.observe(o),i.observe(n),g.set(o,i),r()}}function b(){document.documentElement.dataset.sdkPage=location.hash.startsWith("#/authorize/")?"authorization":"pass",document.title=`${l} \xB7 Agent Pass`;let n=document.querySelector("main > header");if(n&&!n.dataset.pluginTheme){n.dataset.pluginTheme="true",n.classList.add("app-header");let e=n.querySelector(".brand");e&&(e.textContent=l,e.classList.add("wordmark"),e.href=`${O}/#home`);let t=n.querySelector(".nav");t&&(t.className="sdk-subnav",n.after(t))}if(S(),document.querySelectorAll("p.fine").forEach(e=>{e.textContent.startsWith("Deletes the pass, its policies, its receipt and any remaining allowances,")&&e.classList.add("sdk-omit")}),document.querySelectorAll("button, a.primary, a.revoke").forEach(e=>{if(e.classList.add("button"),(e.classList.contains("primary")||e.classList.contains("revoke"))&&!e.querySelector(".action-arrow")){let t=document.createElement("span");t.className="action-arrow",t.setAttribute("aria-hidden","true"),t.textContent="\u2197",e.append(t)}}),document.querySelectorAll('a[href*="/object/"], a[href*="/tx/"], a[href*="/account/"], a[href*="#/owner/"]').forEach(e=>{let t=e.getAttribute("href").match(/(?:object|tx|owner|account)\/([^/?#]+)/);if(!t||e.dataset.pluginShort)return;let s=decodeURIComponent(t[1]);e.title=s,e.textContent=e.textContent.startsWith("Owner ")?`Owner ${c(s)}`:c(s),e.dataset.pluginShort="true"}),location.hash.startsWith("#/authorize/")){let e=document.querySelector(".hero h1");e&&e.textContent!=="Authorize plan"&&(e.textContent="Authorize plan")}let o=location.hash.match(/^#\/pass\/(0x[a-f\d]+)/i)?.[1],r=document.querySelector(".hero h1");o&&r&&!r.dataset.pluginTitle&&(r.title=r.textContent,r.textContent=`Agent Pass ${c(o)}`,r.dataset.pluginTitle="true");let i=document.querySelector(".crumbs");if(o&&i){let e=i.lastChild,t=`Agent Pass ${c(o)}`;e?.nodeType===Node.TEXT_NODE&&e.textContent!==t&&(e.textContent=t)}document.querySelectorAll(".attempt strong, .attempt .moved").forEach(e=>{for(let t of e.childNodes){if(t.nodeType!==Node.TEXT_NODE)continue;let s=t.textContent.replace(/0x([a-f\d]{3})[a-f\d]*…[a-f\d]*([a-f\d]{3})/gi,"0x$1\u2026$2").replace(/\b(\d+\.\d{4,})\b/g,a=>h(a));s!==t.textContent&&(e.title||=t.textContent,t.textContent=s)}}),document.querySelectorAll(".balance").forEach(e=>{for(let t of e.childNodes){if(t.nodeType!==Node.TEXT_NODE)continue;let s=t.textContent.trim();if(!/^\d+(\.\d+)?$/.test(s))continue;let a=h(s);s!==a&&(e.title=s,t.textContent=`${a} `)}})}var v=new MutationObserver(b);v.observe(document.body,{childList:!0,subtree:!0});b();var A=await fetch("/plugin/styles/sdk-wallet.css").then(n=>n.text()),x=new WeakSet;function f(n){if(n.host?.tagName==="CONNECTED-ACCOUNT-MENU"){let o=n.host.connection?.account?.address,r=n.querySelector(".trigger-content");if(o&&r){for(let i of r.childNodes)i.nodeType===Node.TEXT_NODE&&i.textContent.trim()&&i.textContent!==c(o)&&(i.textContent=c(o));r.title=o}}for(let o of n.querySelectorAll("*")){let r=o.shadowRoot;if(r){if(!x.has(r)){x.add(r);let i=document.createElement("style");i.textContent=A,r.append(i),new MutationObserver(()=>f(r)).observe(r,{childList:!0,subtree:!0})}f(r)}}}function w(){for(let n of document.querySelectorAll("mysten-dapp-kit-connect-button"))f(n.parentElement)}new MutationObserver(w).observe(document.body,{childList:!0,subtree:!0});w();
|
package/public/styles/plans.css
CHANGED
|
@@ -18,20 +18,40 @@ Agent Pass Plugin defaults to **Sui Testnet**, using test SUI and the installed
|
|
|
18
18
|
|
|
19
19
|
Public setup metadata lives under `AGENT_PASS_PLUGIN_DATA_DIR` (default `.data` in a source checkout; `~/.agent-pass-plugin/data` for npm installs). The durable executable and assets live separately under `~/.agent-pass-plugin/runtimes`, overridable with `AGENT_PASS_PLUGIN_INSTALL_DIR`; do not move signer data into the npm/npx cache. Testnet and Paper use separate `testnet.sqlite` and `paper.sqlite` files. The SDK manages private local session/signing files under `agent-pass` within that directory. Do not place those files in a public document, browser payload or Git commit.
|
|
20
20
|
|
|
21
|
+
## Conversation
|
|
22
|
+
|
|
23
|
+
Keep the agent-led flow short and in this order: **user intent → missing parameters → proposal → confirmed configuration → owner wallet authorization → return to the agent → explicit Start**. This section changes wording and sequencing only; strategy rules, limits and tool behavior are unchanged.
|
|
24
|
+
|
|
25
|
+
- **Ask once.** After `testnet_capabilities` and the strategy are known, list every missing `create_testnet_plan` field in a single message, grouped as trade (strategy, direction), sizing (per-order amount, lifetime budget, daily cap), price and time (limit price, interval, duration) and gas (stipend, lifetime and daily refill caps). Do not ask one field per turn.
|
|
26
|
+
- **Keep answers.** Carry every value the user already gave through later turns, client restarts and setup resumes. When one value changes, restate only that change and keep the rest. Re-ask a value only when it is invalid, naming the rule it breaks (for example "duration must be a whole 1–7 days").
|
|
27
|
+
- **Never invent price or spending limits.** `limitPrice`, `amountIn`, `budgetIn`, `dailyLimitIn`, `durationDays` and gas caps come from the user. A current quote may be shown as context with its source and time, never pre-filled as their bound. If a value is missing, ask for it; do not create a draft with a guess.
|
|
28
|
+
- **Label the four stages** and never merge two of them in one question or action:
|
|
29
|
+
1. **Proposal** — values under discussion; nothing is created.
|
|
30
|
+
2. **Confirmed configuration** — the user agreed to the exact values; create the draft and show `review_plan`.
|
|
31
|
+
3. **Wallet authorization** — the owner reviews and signs in the official review page; you only show the link and poll.
|
|
32
|
+
4. **Start** — a separate explicit instruction after verified authorization. Never ask "authorize and start?" together.
|
|
33
|
+
- **Units.** Attach a unit to every number: amounts, budgets and daily caps in the **input asset** (`demo USDC` or `test SUI`); `limitPrice` in `demo USDC per SUI`; gas in `test SUI`; interval in seconds; duration in days. Never write `$` or plain "USDC dollars"; Testnet assets have no dollar value. Echo the decimal strings the user gave rather than rounded display values.
|
|
34
|
+
- **Concise summary.** Before creating the draft, show one compact list: owner (shortened), strategy and direction, per-order / lifetime / daily amounts with unit, limit price, interval, duration, slippage and venue, gas stipend / lifetime / daily caps. Add only what the user must decide; leave rules text for the authorization step.
|
|
35
|
+
- **Name the actual client in handoffs.** You are either Codex or Claude Code; say that name, not "your agent", in every browser handoff and return instruction: "I opened the wallet page in your browser. Connect there, then come back to Claude Code." The wallet page uses the MCP client name for its return button.
|
|
36
|
+
- **Recover without duplicates.** For a returning user, or after an interrupted turn, first read state: `marketplace_status`, `onboarding_status` or `account_status`, `list_plans`, then `get_review_request` for a known review ID and `list_transactions` for submitted work. Summarize what exists before proposing anything.
|
|
37
|
+
- An existing draft, approved, paused or blocked plan is continued or explicitly stopped by the user; never create a second plan to "start over". Plan creation is not idempotent.
|
|
38
|
+
- A pending authorization is re-shown with its existing `reviewUrl`. Retry `request_plan_authorization` with the **same `requestId` and payload**; the runtime also returns the existing request for the same plan fingerprint. Use a new `requestId` only for a genuinely new request.
|
|
39
|
+
- Never treat reconnection, restart or a returning conversation as permission to authorize, Start or Resume.
|
|
40
|
+
|
|
21
41
|
## Testnet: MCP → official owner review → MCP
|
|
22
42
|
|
|
23
43
|
1. Read `testnet_capabilities` for the actual coin types/decimals, supported pools/venues and gas defaults. Do not hardcode a remembered deployment, substitute mainnet, or treat an SDK quote as permission.
|
|
24
44
|
2. Use `onboard` to automatically open the local connection screen and existing wallet chooser when needed. The user selects/connects their intended wallet; never auto-select, sign or grant permissions. Repeated calls reuse the same request and do not open extra tabs; `retryBrowser:true` explicitly retries a failed/dismissed launch. If the OS cannot open the browser, report `browser_open_failed` and the returned manual URL; never report success. Keep waiting for `onboarding_status.onboardingComplete:true`; rejection, dismissal, stale persisted hints, page launch, disconnect or expiry are not completion. Read the explicit owner address from the fresh connection and confirm the intended strategy/direction. If the connected address and plan owner differ, stop approval-changing work and resolve the mismatch; never silently reassign the plan.
|
|
25
45
|
3. Use `list_strategies` / `get_strategy`. Explain the version, deterministic rules and cadence. Thirty-day PnL stays unavailable without adequate verified history; do not invent rankings.
|
|
26
|
-
4. Collect the exact parameters for `create_testnet_plan
|
|
46
|
+
4. Collect the exact parameters for `create_testnet_plan` in one grouped question (see Conversation): `expectedOwner`, `botId`, `direction`, decimal-string `amountIn`, `budgetIn`, `dailyLimitIn`, owner-chosen `limitPrice`, `intervalSeconds`, whole `durationDays` (1–7), `slippageBps`, `venue`, decimal-string `gasSui`, `gasCapSui`, `gasDailySui`.
|
|
27
47
|
- Direction is `sui_to_usdc` or `usdc_to_sui`. Amounts/budgets use the **input asset**, with its supported decimals; preserve strings rather than rounding through floating-point display values.
|
|
28
48
|
- `limitPrice` is **demo USDC per one SUI**: most paid when buying SUI, least accepted when selling SUI. It is mandatory and chosen by the owner. Never invent a permissive price to make a plan start.
|
|
29
49
|
- `gasSui` is the initial agent stipend. `gasCapSui` / `gasDailySui` are lifetime/day gas refill allowance caps, separate from that stipend; they are not total execution-cost ceilings. Agent Pass Plugin does not automatically refill gas.
|
|
30
50
|
- Per-order amount, daily cap, lifetime cap, current funds and agent gas are different quantities. A spending cap is not a portfolio-loss limit.
|
|
31
|
-
5.
|
|
51
|
+
5. After the user confirms the summarized configuration, create the draft and read it with `review_plan`. Inspect `list_plans` after an uncertain creation response before retrying: plan creation is not idempotent.
|
|
32
52
|
6. Call `request_plan_authorization({planId,requestId:newUUID})`. Show the exact official `rules`, `warnings` and `reviewUrl`. Only the user opens the owner review, checks Testnet/owner/funding/gas/policy and signs personally. Never confirm through HTTP, browser automation, another MCP or a signing tool on their behalf.
|
|
33
53
|
7. Poll `get_review_request({reviewId: returned.id})`; use the returned review ID, not the client retry UUID. The runtime checks actual owner, network/chain, pass/session, deployment, immutable policy and gas/allowance binding. A closed review tab, wallet connection, submitted signature or unverified RPC result is not confirmation. Mismatch/expiry/unknown state blocks progress.
|
|
34
|
-
8. Only after a matching verified authorization **and the user's separate explicit instruction to run**, call `start_plan({planId})`. Authorizing the pass does not start the loop. The independent local service checks conditions, balances, gas, fresh quote/slippage and permissions on repeated cycles without new model prompts.
|
|
54
|
+
8. Only after a matching verified authorization **and the user's separate explicit instruction to run**, call `start_plan({planId})`. After verification, tell the user authorization is confirmed and ask whether to Start; do not Start in the same turn as the confirmation unless they already gave that separate instruction after verification. Authorizing the pass does not start the loop. The independent local service checks conditions, balances, gas, fresh quote/slippage and permissions on repeated cycles without new model prompts.
|
|
35
55
|
|
|
36
56
|
Retain the same `requestId` and exact original payload for retries of a single authorization request. Use a new UUID only for a new action. An uncertain SDK proposal/session must be reconciled rather than creating another delegated key blindly. Do not bypass a policy mismatch by broadening rules automatically.
|
|
37
57
|
|
|
@@ -43,12 +63,30 @@ Use `list_plans` and `list_transactions({planId?})`. Report actual digests and c
|
|
|
43
63
|
|
|
44
64
|
`pause_plan` prevents new local execution; `resume_plan` requires explicit user intent and rechecks the same bound plan. `stop_plan` ends local scheduling. These operations do not liquidate holdings or revoke an onchain pass.
|
|
45
65
|
|
|
46
|
-
`revoke_plan` first blocks new local submissions and returns the official owner
|
|
66
|
+
`revoke_plan` first blocks new local submissions and returns the official Agent Pass page URL with `revocationSteps`. That page has no "Revoke" button, so name the exact buttons: open the pass page, choose **Stop the agent now** (revokes the agent key and deletes its allowances; the pass stays) or **Close the pass** (same, and also returns everything the pass holds to the owner wallet), then approve in the wallet. The owner must sign; never press either button yourself. Once confirmed, the `revoked` history entry carries the owner's revocation digest when it could be verified from chain; if it is absent, say the digest was not recorded rather than inventing one. While status is `revoking`, do not claim it is revoked or offer Start/resume. Report confirmed onchain revocation only after fresh verified state. Transactions submitted before pause/stop/revocation still need reconciliation.
|
|
47
67
|
|
|
48
68
|
The computer/runtime must remain online. Browser/chat closure and Logout do not stop jobs or revoke a pass. If the user's intent is to stop trading, perform the appropriate local control within their authorization and explain the remaining owner-signature step for onchain revoke.
|
|
49
69
|
|
|
50
70
|
PnL is denominated in **demo USDC**, with the valuation source/time disclosed and gas separately recorded in SUI. Unknown/stale valuation or missing cost basis stays unavailable. Selling SUI without acquisition basis is proceeds, not proven profit. Do not combine Testnet records with Paper fills or count funding as trading profit.
|
|
51
71
|
|
|
72
|
+
## Errors and recovery
|
|
73
|
+
|
|
74
|
+
Explain the current state in one line, then one next step. Never fix a problem by authorizing, Starting, Resuming or broadening a plan yourself.
|
|
75
|
+
|
|
76
|
+
| Situation | State | Next step to offer |
|
|
77
|
+
| ------------------------------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
78
|
+
| Owner input balance below one order | blocked | Owner adds the input asset (`demo USDC` or `test SUI`) to the owner wallet, then asks to Resume. Nothing was submitted. |
|
|
79
|
+
| Agent gas below 0.01 test SUI | blocked | Owner tops up agent gas through the official Agent Pass page; Agent Pass Plugin never refills gas. Then Resume on request. |
|
|
80
|
+
| Wallet rejected or review page closed | pending | Re-show the same `reviewUrl`; retry with the same `requestId`. No new plan or request. |
|
|
81
|
+
| Local runtime unreachable (MCP returns "Local runtime unavailable") | unknown | Ask the user to start it (`agent-pass-plugin start` for npm installs, `npm run dev` in a checkout), then retry the exact same call. After restart, running plans are paused. |
|
|
82
|
+
| Network or RPC interruption | blocked | No new order was sent in that cycle. Check the connection, then Resume on request; submitted digests reconcile automatically. |
|
|
83
|
+
| Submitted transaction not yet confirmed (`pendingSubmissions` > 0) | pending | Wait; the runtime looks up the saved digest. Resume and new plans stay unavailable until it settles. |
|
|
84
|
+
| Transaction failed onchain | failed | Gas was recorded and no fill counted. Report the reason; Resume only on request. |
|
|
85
|
+
| Pass or plan term ended | expired | Stop the plan; a new reviewed plan is needed. |
|
|
86
|
+
| Pass revoked | revoked | No new orders. Holdings stay with the owner. A new plan and authorization are needed to trade again. |
|
|
87
|
+
|
|
88
|
+
Keep these five states distinct: **pending** (waiting for a signature or a digest), **failed** (a transaction failed), **blocked** (a guard stopped new orders until fixed and resumed), **expired** and **revoked** (terminal). When PnL is unavailable or uses a mark older than 60 seconds, say so and quote `pnlReason`; never report it as zero or as a live valuation.
|
|
89
|
+
|
|
52
90
|
## Explicit Paper branch
|
|
53
91
|
|
|
54
92
|
Use Paper only when `AGENT_PASS_PLUGIN_MODE=paper` is deliberately selected. A separate example is `AGENT_PASS_PLUGIN_MODE=paper AGENT_PASS_PLUGIN_DATA_DIR=.data/paper-demo PORT=4318 npm run dev`; pass matching variables when registering that service through setup. Do not silently switch an existing runtime or reuse its live session as a simulated account.
|