@priors/mcp 0.18.0 → 0.18.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/CHANGELOG.md +17 -0
- package/README.md +7 -7
- package/package.json +2 -2
- package/src/market-plan.mjs +28 -12
- package/src/market-tools.mjs +7 -5
- package/src/server.mjs +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @priors/mcp changelog
|
|
2
2
|
|
|
3
|
+
## 0.18.1 (2026-11-05)
|
|
4
|
+
|
|
5
|
+
On @priors/x402 0.8.8 (a plan whose AutoRepay epoch could not be read, below).
|
|
6
|
+
|
|
7
|
+
- **A bid made while Priors' hub does not answer never sets the bids' approval down, and counts it** (GHSA-mc89-r73h-33vv,
|
|
8
|
+
reported by @sonson0910; only with `PRIORS_MARKET` on). With the hub's list of this wallet's bids unread, `market_bid`
|
|
9
|
+
and `market_bid_any` planned from this server's own record alone: an approval standing above `PRIORS_MAX_BIDS_USD`
|
|
10
|
+
(bids made in Go mode, on the board or on another machine) was set down to the new bid's price, leaving those bids
|
|
11
|
+
unfunded (0.16.0 had fixed the same in `market_cancel_bid`), and an approval under it was neither counted against
|
|
12
|
+
`PRIORS_MAX_BIDS_USD` nor kept back from the agent's open loans. With the hub down, the approval standing now counts
|
|
13
|
+
with the new bid: it is only ever raised, a bid that would pass `PRIORS_MAX_BIDS_USD` with it is refused before
|
|
14
|
+
anything is signed (try again once the hub answers), and keep back counts it.
|
|
15
|
+
- **Auto-borrow never borrows on a plan whose AutoRepay epoch could not be read** (GHSA-mc89-r73h-33vv): with
|
|
16
|
+
`@priors/x402` 0.8.7, a failed `epochOf` read made a plan set before the agent's key or owner changed, which
|
|
17
|
+
AutoRepayV2 never pays, read as current. The borrow is refused now ("AutoRepay's epoch ... could not be read just
|
|
18
|
+
now"), and `credit_status` says the same.
|
|
19
|
+
|
|
3
20
|
## 0.18.0 (2026-11-04)
|
|
4
21
|
|
|
5
22
|
- `line_key_status` and `line_key_spend` (only with `PRIORS_LINE_KEY=on`, off by default; docs/LINE-KEY.md in the
|
package/README.md
CHANGED
|
@@ -134,7 +134,7 @@ nothing changes: no tool, no sentence in the instructions, and none of the setti
|
|
|
134
134
|
| `market_list` | the cancel of its own listing while the market isn't approved (approving would bring it back at its old price; on V2 also its own listing on the older market), InviteBondV2's bond when the treasury line lends with none (an approval of exactly the bond, then the deposit), the registry's approval of this one agent, then `list` |
|
|
135
135
|
| `market_cancel` | `cancel`, here and on the older market; any agent, always: it only stops a sale |
|
|
136
136
|
| `market_buy` | an approval of exactly the price when the USDG approved is short, then `buy`, pinned to the listing read (its nonce, the agent's file, its record) |
|
|
137
|
-
| `market_bid` | an approval to the bids' spender of exactly what all of this wallet's open bids take, when it is short or above `PRIORS_MAX_BIDS_USD
|
|
137
|
+
| `market_bid` | an approval to the bids' spender of exactly what all of this wallet's open bids take, when it is short or above `PRIORS_MAX_BIDS_USD` (while Priors' hub doesn't answer, the approval standing plus the bid, only ever raised: bids made elsewhere can't be counted then), then `bid` |
|
|
138
138
|
| `market_bid_any` | the same approval, then `bidAny` on the origin's list from Priors' hub, its ids checked against its root first. The root proves only that the list is the hub's: any agent on it can be sold to this wallet, so the answer names the list and its first ids, and the bid asks at least 1 repaid loan unless `min_repaid` says otherwise |
|
|
139
139
|
| `market_cancel_bid` | `cancelBid` for one bid, or `all` (at most 10 a call), then the approval set down to what the bids left take (left as it is while Priors' hub doesn't answer, since bids made elsewhere can't be counted then; with `all` and no open bid, an approval left standing is set to 0) |
|
|
140
140
|
| `market_accept` | the cancels and the bond as `market_list` (the bond stays on the agent after the sale until its new owner bonds), the registry's approval, then `acceptBid` with what this wallet gets pinned exactly; a bid made before the agent's builder share was set, which the market refuses, is refused before anything is sent |
|
|
@@ -388,7 +388,7 @@ Settings → Developer → Edit Config (`claude_desktop_config.json`), then rest
|
|
|
388
388
|
"mcpServers": {
|
|
389
389
|
"priors": {
|
|
390
390
|
"command": "npx",
|
|
391
|
-
"args": ["-y", "@priors/mcp@0.18.
|
|
391
|
+
"args": ["-y", "@priors/mcp@0.18.1"],
|
|
392
392
|
"env": {
|
|
393
393
|
"PRIORS_KEY": "0xYOUR_AGENT_WALLET_KEY",
|
|
394
394
|
"PRIORS_AGENT_ID": "1234"
|
|
@@ -410,7 +410,7 @@ A project `.mcp.json` that reads the key from your shell's environment, so the f
|
|
|
410
410
|
"mcpServers": {
|
|
411
411
|
"priors": {
|
|
412
412
|
"command": "npx",
|
|
413
|
-
"args": ["-y", "@priors/mcp@0.18.
|
|
413
|
+
"args": ["-y", "@priors/mcp@0.18.1"],
|
|
414
414
|
"env": {
|
|
415
415
|
"PRIORS_KEY": "${PRIORS_KEY}",
|
|
416
416
|
"PRIORS_AGENT_ID": "${PRIORS_AGENT_ID:-}"
|
|
@@ -423,7 +423,7 @@ A project `.mcp.json` that reads the key from your shell's environment, so the f
|
|
|
423
423
|
or, for your user only, from a macOS or Linux terminal:
|
|
424
424
|
|
|
425
425
|
```sh
|
|
426
|
-
(read -rs PRIORS_KEY && umask 077 && mkdir -p ~/.config/priors && rm -f ~/.config/priors/agent.key && printf '%s\n' "$PRIORS_KEY" > ~/.config/priors/agent.key) && claude mcp add priors --scope user -- sh -c 'read -r PRIORS_KEY < "$1" && export PRIORS_KEY && exec npx -y @priors/mcp@0.18.
|
|
426
|
+
(read -rs PRIORS_KEY && umask 077 && mkdir -p ~/.config/priors && rm -f ~/.config/priors/agent.key && printf '%s\n' "$PRIORS_KEY" > ~/.config/priors/agent.key) && claude mcp add priors --scope user -- sh -c 'read -r PRIORS_KEY < "$1" && export PRIORS_KEY && exec npx -y @priors/mcp@0.18.1' priors-mcp ~/.config/priors/agent.key
|
|
427
427
|
```
|
|
428
428
|
|
|
429
429
|
It waits for the key without showing it (paste it, then Enter), saves it in a file only you can read, and gives Claude
|
|
@@ -504,7 +504,7 @@ to approve a borrow; this package, with the key, pays for APIs. With borrowing o
|
|
|
504
504
|
approves each loan in Priors' Go mode. ElizaOS (`@elizaos/plugin-mcp`):
|
|
505
505
|
|
|
506
506
|
```ts
|
|
507
|
-
"priors-wallet": { type: "stdio", command: "npx", args: ["-y", "@priors/mcp@0.18.
|
|
507
|
+
"priors-wallet": { type: "stdio", command: "npx", args: ["-y", "@priors/mcp@0.18.1"],
|
|
508
508
|
env: { PRIORS_KEY_FILE: "/home/agent/.config/priors/agent-7311.key", PRIORS_AGENT_ID: "7311",
|
|
509
509
|
PRIORS_MAX_BORROW_USD: "0", PRIORS_MAX_BORROW_DAY_USD: "0", PRIORS_MAX_SPEND_DAY_USD: "1", PRIORS_MAX_PRICE_USD: "0.10",
|
|
510
510
|
PRIORS_PAY_HOSTS: "api.example.com" } }
|
|
@@ -516,7 +516,7 @@ OpenClaw (`mcp.servers`, JSON5) takes the same `command`, `args` and `env`; Herm
|
|
|
516
516
|
mcp_servers:
|
|
517
517
|
priors-wallet:
|
|
518
518
|
command: npx
|
|
519
|
-
args: ["-y", "@priors/mcp@0.18.
|
|
519
|
+
args: ["-y", "@priors/mcp@0.18.1"]
|
|
520
520
|
env:
|
|
521
521
|
PRIORS_KEY_FILE: /home/agent/.config/priors/agent-7311.key
|
|
522
522
|
PRIORS_AGENT_ID: "7311"
|
|
@@ -543,7 +543,7 @@ key proves it is there: it signs the ERC-8004 identity registry's `AgentWalletSe
|
|
|
543
543
|
agent's).
|
|
544
544
|
|
|
545
545
|
```sh
|
|
546
|
-
PRIORS_KEY_FILE=~/.config/priors/agent-7311.key npx -y @priors/mcp@0.18.
|
|
546
|
+
PRIORS_KEY_FILE=~/.config/priors/agent-7311.key npx -y @priors/mcp@0.18.1 link-wallet --agent 7311
|
|
547
547
|
```
|
|
548
548
|
|
|
549
549
|
It reads the registry's EIP-712 domain and refuses to sign for any other, takes the owner from the chain (`--owner`
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@priors/mcp",
|
|
3
3
|
"mcpName": "io.github.priors-agents/priors",
|
|
4
|
-
"version": "0.18.
|
|
4
|
+
"version": "0.18.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "MCP server for Priors on Robinhood Chain: pay x402 URLs in USDG, read balances, credit lines and scores, borrow and repay, and buy, sell and redeem PT-USDG. Key from PRIORS_KEY_FILE (a file only you can read) or PRIORS_KEY, never the command line.",
|
|
7
7
|
"type": "module",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@modelcontextprotocol/sdk": "^1.30.1",
|
|
48
|
-
"@priors/x402": "0.8.
|
|
48
|
+
"@priors/x402": "0.8.8",
|
|
49
49
|
"ethers": "^6.13.4",
|
|
50
50
|
"undici": "6.29.1",
|
|
51
51
|
"viem": "^2.56.9",
|
package/src/market-plan.mjs
CHANGED
|
@@ -556,6 +556,18 @@ function reserveOf(c, { ids, me, now, except = [], extra = 0n }) {
|
|
|
556
556
|
}
|
|
557
557
|
return sum;
|
|
558
558
|
}
|
|
559
|
+
/** A new bid's reserve (`extra` on top of the open bids in `ids`), and what an over-limit refusal says. With Priors' hub
|
|
560
|
+
* down (`hubDown`), the bids this wallet made elsewhere (Go mode, the board, another machine) are unknown, and the
|
|
561
|
+
* approval standing (c.reserve) may fund them: the bid counts on top of it, so it is never set down (P-55's rule) and
|
|
562
|
+
* the limit and keep back see it (P-54's) (GHSA-mc89-r73h-33vv). `standing`: the approval as the call first read it,
|
|
563
|
+
* when it plans again after its own approval (which then stands for this bid too). */
|
|
564
|
+
function newReserve(c, { ids, me, now, extra, hubDown, maxReserve, standing: first = null }) {
|
|
565
|
+
const known = reserveOf(c, { ids, me, now, extra });
|
|
566
|
+
if (known == null) return { error: "unread" };
|
|
567
|
+
const standing = first ?? big(c.reserve), reserve = hubDown && standing + extra > known ? standing + extra : known;
|
|
568
|
+
if (reserve > big(maxReserve)) return { error: "over", reserve, max: big(maxReserve), ...(hubDown ? { down: true, standing } : {}) };
|
|
569
|
+
return { reserve, ...(hubDown ? { standing } : {}) };
|
|
570
|
+
}
|
|
559
571
|
/** The terms both bids check first, in the contract's order: the pause, the wallet's standing, the price, the days. */
|
|
560
572
|
function bidTerms(c, { me, now, price, days, expiry }) {
|
|
561
573
|
if (unread(c.paused, c.custodian, c.refused, c.marked, c.cash, c.reserve, c.feeBps, c.minFee)) return { error: "unread" };
|
|
@@ -576,9 +588,12 @@ function bidTerms(c, { me, now, price, days, expiry }) {
|
|
|
576
588
|
* market stops doesn't count, as bid() takes the bid then), "short" (`short`, `cash`), "over" (`reserve`, `max`)), or
|
|
577
589
|
* { steps ("approveReserve": the reserve set to exactly what all its open bids and this one take, when the allowance
|
|
578
590
|
* is under it or above `maxReserve`; "bid"), reserve, price, expiry, uriHash (only as its file is now: the URI's bytes
|
|
579
|
-
* hashed here, with `sameFile`), minRepaid, minLine, fee, share, net (what the owner gets now), pins }.
|
|
591
|
+
* hashed here, with `sameFile`), minRepaid, minLine, fee, share, net (what the owner gets now), pins }. `hubDown`:
|
|
592
|
+
* Priors' hub didn't answer, so `myBids` lacks the bids made elsewhere: the reserve is at least the approval standing
|
|
593
|
+
* plus this bid ("over" then carries `down` and `standing`), and the approval is never set down (newReserve); the plan
|
|
594
|
+
* keeps that `standing`, which its call passes back when it plans again after its own approval.
|
|
580
595
|
*/
|
|
581
|
-
export function bidPlan(c, { addr, me, id, now, price, days, expiry = null, sameFile = true, minRepaid = 0n, minLine = 0n, myBids = [], maxReserve, minRecord = 0n, adapters = [], shares = false }) {
|
|
596
|
+
export function bidPlan(c, { addr, me, id, now, price, days, expiry = null, sameFile = true, minRepaid = 0n, minLine = 0n, myBids = [], maxReserve, minRecord = 0n, adapters = [], shares = false, hubDown = false, standing = null }) {
|
|
582
597
|
c = c || {};
|
|
583
598
|
const t = bidTerms(c, { me, now, price, days, expiry });
|
|
584
599
|
if (t.error) return t;
|
|
@@ -597,15 +612,15 @@ export function bidPlan(c, { addr, me, id, now, price, days, expiry = null, same
|
|
|
597
612
|
if (!k.error) return { error: "listed", price: l.price };
|
|
598
613
|
}
|
|
599
614
|
if (big(c.cash) < t.p) return { error: "short", short: t.p - big(c.cash), cash: big(c.cash) };
|
|
600
|
-
const
|
|
601
|
-
if (
|
|
602
|
-
|
|
615
|
+
const nr = newReserve(c, { ids: myBids, me, now, extra: t.p, hubDown, maxReserve, standing });
|
|
616
|
+
if (nr.error) return nr;
|
|
617
|
+
const { reserve } = nr;
|
|
603
618
|
const bi = builderIn(c, shares);
|
|
604
619
|
if (bi.error) return bi;
|
|
605
620
|
const { fee, share, net } = netOf(t.p, { ...feesOf(c), builder: bi.builder, seller: c.owner });
|
|
606
621
|
const uriHash = sameFile ? lc(ethers.keccak256(ethers.toUtf8Bytes(c.uri))) : ZERO32;
|
|
607
622
|
const r = big(c.reserve), mr = big(minRepaid), ml = big(minLine);
|
|
608
|
-
return { steps: [...(r < reserve || r > big(maxReserve) ? ["approveReserve"] : []), "bid"], reserve, price: t.p, expiry: t.e, uriHash, minRepaid: mr, minLine: ml, fee, share, net,
|
|
623
|
+
return { steps: [...(r < reserve || r > big(maxReserve) ? ["approveReserve"] : []), "bid"], reserve, ...(nr.standing != null ? { standing: nr.standing } : {}), price: t.p, expiry: t.e, uriHash, minRepaid: mr, minLine: ml, fee, share, net,
|
|
609
624
|
pins: { id: big(id), price: t.p, expiry: t.e, uriHash, minRepaid: mr, minLine: ml } };
|
|
610
625
|
}
|
|
611
626
|
/**
|
|
@@ -613,9 +628,9 @@ export function bidPlan(c, { addr, me, id, now, price, days, expiry = null, same
|
|
|
613
628
|
* first (its ids don't make its root: the index's answer is refused), "count" (1 to 20, at most the list's size: `max`),
|
|
614
629
|
* then bidPlan's terms, "short" (price × count), "over"; else { steps ("approveReserve", "bidAny"), reserve, price,
|
|
615
630
|
* total, count, root, expiry, minRepaid, minLine, fee, net (what an owner gets now; no share is known before an agent
|
|
616
|
-
* is), pins }.
|
|
631
|
+
* is), pins }. `hubDown` as bidPlan's.
|
|
617
632
|
*/
|
|
618
|
-
export function bidAnyPlan(c, { me, now, set, count, price, days, expiry = null, minRepaid = 0n, minLine = 0n, myBids = [], maxReserve }) {
|
|
633
|
+
export function bidAnyPlan(c, { me, now, set, count, price, days, expiry = null, minRepaid = 0n, minLine = 0n, myBids = [], maxReserve, hubDown = false, standing = null }) {
|
|
619
634
|
c = c || {};
|
|
620
635
|
let root;
|
|
621
636
|
try { root = set && Array.isArray(set.ids) && set.ids.length ? idsRootOf(set.ids) : null; } catch (_) { root = null; }
|
|
@@ -626,12 +641,12 @@ export function bidAnyPlan(c, { me, now, set, count, price, days, expiry = null,
|
|
|
626
641
|
if (t.error) return t;
|
|
627
642
|
const total = t.p * BigInt(count);
|
|
628
643
|
if (big(c.cash) < total) return { error: "short", short: total - big(c.cash), cash: big(c.cash) };
|
|
629
|
-
const
|
|
630
|
-
if (
|
|
631
|
-
|
|
644
|
+
const nr = newReserve(c, { ids: myBids, me, now, extra: total, hubDown, maxReserve, standing });
|
|
645
|
+
if (nr.error) return nr;
|
|
646
|
+
const { reserve } = nr;
|
|
632
647
|
const { fee, net } = netOf(t.p, feesOf(c));
|
|
633
648
|
const r = big(c.reserve), mr = big(minRepaid), ml = big(minLine);
|
|
634
|
-
return { steps: [...(r < reserve || r > big(maxReserve) ? ["approveReserve"] : []), "bidAny"], reserve, price: t.p, total, count, root, expiry: t.e, minRepaid: mr, minLine: ml, fee, net,
|
|
649
|
+
return { steps: [...(r < reserve || r > big(maxReserve) ? ["approveReserve"] : []), "bidAny"], reserve, ...(nr.standing != null ? { standing: nr.standing } : {}), price: t.p, total, count, root, expiry: t.e, minRepaid: mr, minLine: ml, fee, net,
|
|
635
650
|
pins: { root, count, price: t.p, expiry: t.e, minRepaid: mr, minLine: ml } };
|
|
636
651
|
}
|
|
637
652
|
/**
|
|
@@ -816,6 +831,7 @@ export const PLAN_WORDS = Object.freeze({
|
|
|
816
831
|
ceiling: "This could take {amount} USDG, above this server's limit of {max} USDG for one buy or bid. The user can raise PRIORS_MAX_MARKET_USD.",
|
|
817
832
|
day: "This would bring today's buys and bids for agent #{self} and this wallet to {total} USDG, above {cap} USDG a day. {used} USDG was counted today, and the limit starts again at 00:00 UTC.",
|
|
818
833
|
bidsOver: "Your open bids would take up to {reserve} USDG, above this server's limit of {max} USDG. Cancel a bid, then bid.",
|
|
834
|
+
bidsOverDown: "Priors' hub didn't answer, so bids this wallet made elsewhere can't be counted, and the bids' approval, which may fund them, stands at {standing} USDG: with this bid, all open bids could take up to {reserve} USDG, above this server's limit of {max} USDG. Try again once the hub answers.",
|
|
819
835
|
dupBid: "This wallet made bid #{bidId} on the same terms in the last 10 minutes, and it is still open. To bid again, cancel it with market_cancel_bid, then bid.",
|
|
820
836
|
record: "#{id} has {m} repaid loan{s}. This server buys and bids only on agents with {n} or more.",
|
|
821
837
|
// money
|
package/src/market-tools.mjs
CHANGED
|
@@ -912,6 +912,7 @@ export function registerMarketTools(ctx) {
|
|
|
912
912
|
return { ids: [...new Set([...myBidIds(rec), ...(fromHub || [])])], hubDown: fromHub === null };
|
|
913
913
|
}
|
|
914
914
|
const reserveLine = (x) => `Your bids can take up to ${amt(x)} USDG from this wallet.`;
|
|
915
|
+
const downLine = " Priors' hub didn't answer, so bids this wallet made elsewhere can't be listed: the approval standing, which may fund them, is counted in it with this bid, and never set down.";
|
|
915
916
|
tool("market_bid", {
|
|
916
917
|
title: "Bid on an agent",
|
|
917
918
|
description: `Bid price_usd on one agent on Priors' agent market (AgentMarketV2): the agent's owner can accept it at any time until it ends, and the agent then comes to this wallet at once. The USDG stays in this wallet until then: one approval to the bids' spender, set to exactly what all of this wallet's open bids take, covers every bid. Its pins, Go mode's defaults: same_file (default true: only as its file is now), min_repaid (default its repaid loans now, never under PRIORS_MARKET_MIN_REPAID), min_line_usd (default its treasury line when it lends). Held to PRIORS_MAX_MARKET_USD (${amt(S.maxMarket)} USDG) a bid, PRIORS_MAX_BIDS_USD (${amt(S.maxBids)} USDG) for all open bids, PRIORS_MAX_MARKET_DAY_USD a day, and agent #${S.agentId}'s open loans. Refused when it is listed at or below the bid (buy it instead). Commits real money: state the agent, the price, the fee and what the owner gets to the user and get their go-ahead first; dry_run: true lists the transactions without sending. Needs ETH for gas.`,
|
|
@@ -932,8 +933,9 @@ export function registerMarketTools(ctx) {
|
|
|
932
933
|
const follows = BigInt(a.sponsor) !== 0n && s.c.followed === true, lent = BigInt(a.delegatedIn);
|
|
933
934
|
const minRepaid = first ? first.minRepaid : (() => { const r = min_repaid != null ? BigInt(min_repaid) : BigInt(a.loansRepaid); return r < S.minRepaid ? S.minRepaid : r; })();
|
|
934
935
|
const minLine = first ? first.minLine : min_line_usd != null ? units(min_line_usd, "min_line_usd") : follows && lent > 0n ? lent : 0n;
|
|
935
|
-
|
|
936
|
-
|
|
936
|
+
// the hub down: the approval standing counts with this bid, and is never set down (GHSA-mc89-r73h-33vv)
|
|
937
|
+
const p = M.bidPlan(s.c, { addr: k.addr, me, id, now: s.now, price, days, expiry: first ? first.expiry : null, sameFile: same_file, minRepaid, minLine, myBids: [...s.c.bids.keys()], maxReserve: S.maxBids, minRecord: S.minRepaid, adapters: REC.adapters, shares: k.shares, hubDown, standing: first ? first.standing : null });
|
|
938
|
+
return p.error === "over" ? { ...p, error: p.down ? "bidsOverDown" : "bidsOver" } : p;
|
|
937
939
|
},
|
|
938
940
|
// a retry whose terms differ only in days (or whose answer was lost and its settling is past the replay) is a
|
|
939
941
|
// second bid on chain: refused while the record's stands
|
|
@@ -943,7 +945,7 @@ export function registerMarketTools(ctx) {
|
|
|
943
945
|
},
|
|
944
946
|
changed: (p, f) => (p.pins.uriHash !== f.pins.uriHash ? M.planWords("fileMoved", { id }) : "Its terms changed since the first read."),
|
|
945
947
|
keep: (p) => p.reserve, day: (p) => p.price, counted: (step, p) => (step === "bid" ? p.price : 0n),
|
|
946
|
-
facts: (p) => [`Bids on #${id}: ${amt(p.price)} USDG. Fee ${amt(p.fee)}.${p.share > 0n ? ` Builder share ${amt(p.share)}.` : ""} The owner gets ${amt(p.net)}. Until ${M.dayText(p.expiry)}.`, `${reserveLine(p.reserve)}${hubDown ?
|
|
948
|
+
facts: (p) => [`Bids on #${id}: ${amt(p.price)} USDG. Fee ${amt(p.fee)}.${p.share > 0n ? ` Builder share ${amt(p.share)}.` : ""} The owner gets ${amt(p.net)}. Until ${M.dayText(p.expiry)}.`, `${reserveLine(p.reserve)}${hubDown ? downLine : ""}`],
|
|
947
949
|
done: async ({ k, sent, plan, events, T }) => {
|
|
948
950
|
const txs = sent.map((x) => x.hash), ev = events.find((e) => e.name === "BidMade" && same(e.args.maker, me) && BigInt(e.args.agentId) === id);
|
|
949
951
|
if (!ev) return { text: `${cap1(stageWords("bid", id))} was mined (tx ${txs[txs.length - 1]}), but its receipt carries no BidMade event for #${id} from this wallet. ${NOTHING_MORE} market_agent shows its bids.`, structured: { tool: "market_bid", agentId: String(id), txs, bid: null } };
|
|
@@ -985,13 +987,13 @@ export function registerMarketTools(ctx) {
|
|
|
985
987
|
return execute({
|
|
986
988
|
name: "market_bid_any", role: "bid", args: { origin, count, price_usd, days, min_repaid, min_line_usd }, id: null, me, dry: dry_run, vars: { price, max: S.maxBids },
|
|
987
989
|
read: async (rec, k, T) => { const b = await myBids(rec, T); hubDown = b.hubDown; return { me, self: S.agentId, bidIds: b.ids }; },
|
|
988
|
-
plan: (s, k, first) => { const p = M.bidAnyPlan(s.c, { me, now: s.now, set, count, price, days, expiry: first ? first.expiry : null, minRepaid, minLine, myBids: [...s.c.bids.keys()], maxReserve: S.maxBids }); return p.error === "over" ? { ...p, error: "bidsOver" } : p; },
|
|
990
|
+
plan: (s, k, first) => { const p = M.bidAnyPlan(s.c, { me, now: s.now, set, count, price, days, expiry: first ? first.expiry : null, minRepaid, minLine, myBids: [...s.c.bids.keys()], maxReserve: S.maxBids, hubDown, standing: first ? first.standing : null }); return p.error === "over" ? { ...p, error: p.down ? "bidsOverDown" : "bidsOver" } : p; },
|
|
989
991
|
check: (p, s, rec) => {
|
|
990
992
|
const dup = recentBid(rec, s.c, s.now, (x) => x.any && lc(x.target) === lc(p.root) && BigInt(x.price) === p.price && BigInt(x.minRepaid) === p.minRepaid && BigInt(x.minLine) === p.minLine);
|
|
991
993
|
if (dup) throw refuse("dupBid", { bidId: BigInt(dup) }, "bid");
|
|
992
994
|
},
|
|
993
995
|
keep: (p) => p.reserve, day: (p) => p.total, counted: (step, p) => (step === "bidAny" ? p.total : 0n),
|
|
994
|
-
facts: (p) => [`Bids on any of ${listWords}: ${amt(p.price)} USDG each, up to ${count}. Fee ${amt(p.fee)}. An owner gets ${amt(p.net)}, less any builder share on its agent. Until ${M.dayText(p.expiry)}.${recordWords}`, `${reserveLine(p.reserve)}${hubDown ?
|
|
996
|
+
facts: (p) => [`Bids on any of ${listWords}: ${amt(p.price)} USDG each, up to ${count}. Fee ${amt(p.fee)}. An owner gets ${amt(p.net)}, less any builder share on its agent. Until ${M.dayText(p.expiry)}.${recordWords}`, `${reserveLine(p.reserve)}${hubDown ? downLine : ""}`],
|
|
995
997
|
done: async ({ sent, plan, events }) => {
|
|
996
998
|
const txs = sent.map((x) => x.hash), ev = events.find((e) => e.name === "BidAnyMade" && same(e.args.maker, me) && lc(e.args.root) === set.root);
|
|
997
999
|
if (!ev) return { text: `${cap1(stageWords("bidAny", null))} was mined (tx ${txs[txs.length - 1]}), but its receipt carries no BidAnyMade event from this wallet. ${NOTHING_MORE}`, structured: { tool: "market_bid_any", txs, bid: null } };
|
package/src/server.mjs
CHANGED
|
@@ -1125,6 +1125,8 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
|
|
|
1125
1125
|
throw no(`agent #${id}'s declared wallet is its owner's own address (this wallet), and AutoRepay never repays from that address under a wallet plan, so no plan covers the loan. Declare a key of the agent's own as its wallet (the registry's setAgentWallet) and turn Autopay on from that key`);
|
|
1126
1126
|
}
|
|
1127
1127
|
if (!st.plan.on) throw no("Autopay is off for this wallet");
|
|
1128
|
+
// null: AutoRepay's epoch unread, so a plan set before the agent's key or owner changed can't be told apart (GHSA-mc89)
|
|
1129
|
+
if (st.plan.current === null) throw no(`AutoRepay's epoch for agent #${id} could not be read just now, so whether this wallet's plan still pays can't be told (one set before the agent's key or owner changed pays nothing); try again in a moment`);
|
|
1128
1130
|
if (!st.plan.current) throw no("this wallet's Autopay plan was set under an earlier owner or key of the agent, so it pays nothing now");
|
|
1129
1131
|
if (st.held) throw no("Autopay is on hold for this wallet");
|
|
1130
1132
|
if (st.paused) throw no(`Autopay is paused by the Safe until ${when(st.paused.until)}`);
|
|
@@ -1141,6 +1143,7 @@ export async function createPriorsMcpServer({ env = process.env, fetchImpl = glo
|
|
|
1141
1143
|
if (!st.declared) return ["Autopay: off. This wallet is not the agent's declared wallet, so it can't repay the agent's loans through AutoRepay."];
|
|
1142
1144
|
if (st.ownerIsWallet) return [`Autopay: off. The agent's declared wallet is its owner's own address (this wallet), and AutoRepay never repays from that address under a wallet plan${st.plan.on ? ", so the plan this wallet set pays nothing" : ""}. Declare a key of the agent's own as its wallet (setAgentWallet) and turn Autopay on from that key, or repay by hand before the due date.`];
|
|
1143
1145
|
if (!st.plan.on) return ["Autopay: off. autopay_on turns it on: this wallet then repays each loan a few hours before it is due, if it holds enough."];
|
|
1146
|
+
if (st.plan.current === null) return ["Autopay: on, but AutoRepay's epoch for the agent couldn't be read just now, so whether the plan still pays can't be told (one set before the agent's key or owner changed pays nothing). Ask again in a moment."];
|
|
1144
1147
|
if (!st.plan.current) return [st.plan.stale ? "Autopay: the plan was set before the agent's key or owner changed, so it pays nothing now. Call autopay_on again." : "Autopay: the plan was set under an earlier owner of the agent, so it pays nothing now. Call autopay_on again."];
|
|
1145
1148
|
const out = [`Autopay: on, from this wallet${st.plan.useSavings ? " (then its savings)" : ""}; limit ${usd(st.plan.cap)} per loan, budget left ${usd(st.budget)}${st.plan.late ? "; also in the grace period" : ""}.${st.held ? " On hold: it pays nothing until resumed." : ""}${st.paused ? ` Paused by the Safe until ${when(st.paused.until)}: repay by hand before the due date.` : ""}`];
|
|
1146
1149
|
if (st.next) out.push(`Next autopay: loan #${st.next.loanId}, ${usd(st.next.due)}, from ${when(st.next.opens)} (due ${when(st.next.dueAt)}).`);
|