@nookplot/runtime 0.5.147 → 0.5.148
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/dist/__tests__/apiMarketplace.test.js +189 -2
- package/dist/__tests__/apiMarketplace.test.js.map +1 -1
- package/dist/__tests__/autonomous.dedup.test.js +11 -0
- package/dist/__tests__/autonomous.dedup.test.js.map +1 -1
- package/dist/__tests__/autonomous.getAvailableActions.test.js +13 -1
- package/dist/__tests__/autonomous.getAvailableActions.test.js.map +1 -1
- package/dist/__tests__/autonomous.goalBootstrap.test.d.ts +2 -0
- package/dist/__tests__/autonomous.goalBootstrap.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.goalBootstrap.test.js +148 -0
- package/dist/__tests__/autonomous.goalBootstrap.test.js.map +1 -0
- package/dist/__tests__/autonomous.miningTrack.test.d.ts +2 -0
- package/dist/__tests__/autonomous.miningTrack.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.miningTrack.test.js +38 -0
- package/dist/__tests__/autonomous.miningTrack.test.js.map +1 -0
- package/dist/__tests__/autonomous.payApi.test.d.ts +2 -0
- package/dist/__tests__/autonomous.payApi.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.payApi.test.js +73 -0
- package/dist/__tests__/autonomous.payApi.test.js.map +1 -0
- package/dist/__tests__/autonomous.workspaceOpportunity.test.d.ts +2 -0
- package/dist/__tests__/autonomous.workspaceOpportunity.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.workspaceOpportunity.test.js +212 -0
- package/dist/__tests__/autonomous.workspaceOpportunity.test.js.map +1 -0
- package/dist/__tests__/bdAgentPack.test.js +1 -1
- package/dist/__tests__/bdAgentPack.test.js.map +1 -1
- package/dist/__tests__/bounties.test.js +12 -0
- package/dist/__tests__/bounties.test.js.map +1 -1
- package/dist/__tests__/codegen-drift.test.js +3 -1
- package/dist/__tests__/codegen-drift.test.js.map +1 -1
- package/dist/__tests__/conversation/modelThresholdsParity.test.js +19 -14
- package/dist/__tests__/conversation/modelThresholdsParity.test.js.map +1 -1
- package/dist/__tests__/economy.surplusBranch.test.js +64 -0
- package/dist/__tests__/economy.surplusBranch.test.js.map +1 -1
- package/dist/__tests__/goalLoop.test.d.ts +2 -0
- package/dist/__tests__/goalLoop.test.d.ts.map +1 -0
- package/dist/__tests__/goalLoop.test.js +358 -0
- package/dist/__tests__/goalLoop.test.js.map +1 -0
- package/dist/__tests__/helpers/mockRuntime.d.ts.map +1 -1
- package/dist/__tests__/helpers/mockRuntime.js +7 -0
- package/dist/__tests__/helpers/mockRuntime.js.map +1 -1
- package/dist/__tests__/loadProfile.test.d.ts +8 -0
- package/dist/__tests__/loadProfile.test.d.ts.map +1 -0
- package/dist/__tests__/loadProfile.test.js +134 -0
- package/dist/__tests__/loadProfile.test.js.map +1 -0
- package/dist/__tests__/mining.test.d.ts +2 -0
- package/dist/__tests__/mining.test.d.ts.map +1 -0
- package/dist/__tests__/mining.test.js +306 -0
- package/dist/__tests__/mining.test.js.map +1 -0
- package/dist/__tests__/signalActionMap.test.d.ts +17 -0
- package/dist/__tests__/signalActionMap.test.d.ts.map +1 -0
- package/dist/__tests__/signalActionMap.test.js +165 -0
- package/dist/__tests__/signalActionMap.test.js.map +1 -0
- package/dist/__tests__/usdcBudget.test.d.ts +2 -0
- package/dist/__tests__/usdcBudget.test.d.ts.map +1 -0
- package/dist/__tests__/usdcBudget.test.js +128 -0
- package/dist/__tests__/usdcBudget.test.js.map +1 -0
- package/dist/__tests__/x402.test.d.ts +2 -0
- package/dist/__tests__/x402.test.d.ts.map +1 -0
- package/dist/__tests__/x402.test.js +117 -0
- package/dist/__tests__/x402.test.js.map +1 -0
- package/dist/actionCatalog.d.ts.map +1 -1
- package/dist/actionCatalog.generated.d.ts +1 -1
- package/dist/actionCatalog.generated.d.ts.map +1 -1
- package/dist/actionCatalog.generated.js +151 -26
- package/dist/actionCatalog.generated.js.map +1 -1
- package/dist/actionCatalog.js +0 -10
- package/dist/actionCatalog.js.map +1 -1
- package/dist/api-marketplace.d.ts +146 -0
- package/dist/api-marketplace.d.ts.map +1 -1
- package/dist/api-marketplace.js +218 -0
- package/dist/api-marketplace.js.map +1 -1
- package/dist/autonomous.d.ts +16 -9
- package/dist/autonomous.d.ts.map +1 -1
- package/dist/autonomous.js +276 -59
- package/dist/autonomous.js.map +1 -1
- package/dist/bounties.d.ts +8 -0
- package/dist/bounties.d.ts.map +1 -1
- package/dist/bounties.js +2 -0
- package/dist/bounties.js.map +1 -1
- package/dist/contentSafety.d.ts +1 -1
- package/dist/contentSafety.d.ts.map +1 -1
- package/dist/contentSafety.js +6 -2
- package/dist/contentSafety.js.map +1 -1
- package/dist/discovery.js +1 -1
- package/dist/discovery.js.map +1 -1
- package/dist/economy.d.ts +10 -15
- package/dist/economy.d.ts.map +1 -1
- package/dist/economy.js +16 -29
- package/dist/economy.js.map +1 -1
- package/dist/goal/goalLoop.d.ts +78 -0
- package/dist/goal/goalLoop.d.ts.map +1 -0
- package/dist/goal/goalLoop.js +388 -0
- package/dist/goal/goalLoop.js.map +1 -0
- package/dist/goal/goalPrompts.d.ts +20 -0
- package/dist/goal/goalPrompts.d.ts.map +1 -0
- package/dist/goal/goalPrompts.js +54 -0
- package/dist/goal/goalPrompts.js.map +1 -0
- package/dist/goal/types.d.ts +102 -0
- package/dist/goal/types.d.ts.map +1 -0
- package/dist/goal/types.js +7 -0
- package/dist/goal/types.js.map +1 -0
- package/dist/identity.d.ts +51 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +50 -0
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +18 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/dist/loadProfile.d.ts +100 -0
- package/dist/loadProfile.d.ts.map +1 -0
- package/dist/loadProfile.js +221 -0
- package/dist/loadProfile.js.map +1 -0
- package/dist/signalActionMap.d.ts.map +1 -1
- package/dist/signalActionMap.js +15 -5
- package/dist/signalActionMap.js.map +1 -1
- package/dist/swarms.d.ts +13 -0
- package/dist/swarms.d.ts.map +1 -1
- package/dist/swarms.js +4 -0
- package/dist/swarms.js.map +1 -1
- package/dist/tools.js +1 -1
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +21 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/usdcBudget.d.ts +90 -0
- package/dist/usdcBudget.d.ts.map +1 -0
- package/dist/usdcBudget.js +155 -0
- package/dist/usdcBudget.js.map +1 -0
- package/dist/x402.d.ts +69 -0
- package/dist/x402.d.ts.map +1 -0
- package/dist/x402.js +139 -0
- package/dist/x402.js.map +1 -0
- package/package.json +1 -1
- package/dist/__tests__/economy.frontierInference.test.d.ts +0 -2
- package/dist/__tests__/economy.frontierInference.test.d.ts.map +0 -1
- package/dist/__tests__/economy.frontierInference.test.js +0 -61
- package/dist/__tests__/economy.frontierInference.test.js.map +0 -1
- package/dist/frontierPass.d.ts +0 -30
- package/dist/frontierPass.d.ts.map +0 -1
- package/dist/frontierPass.js +0 -42
- package/dist/frontierPass.js.map +0 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for the UsdcBudget primitive (the hard-stop x402 spend cap).
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it, expect } from "vitest";
|
|
5
|
+
import { UsdcBudget, createUsdcBudget, parseUsdcToBaseUnits, formatUsdc, DEFAULT_DAILY_USDC_CAP_BASE_UNITS, } from "../usdcBudget.js";
|
|
6
|
+
const USDC = 1000000n; // 1 USDC in base units
|
|
7
|
+
describe("parseUsdcToBaseUnits", () => {
|
|
8
|
+
it("parses whole and fractional USDC", () => {
|
|
9
|
+
expect(parseUsdcToBaseUnits("10")).toBe(10n * USDC);
|
|
10
|
+
expect(parseUsdcToBaseUnits("0.5")).toBe(500000n);
|
|
11
|
+
expect(parseUsdcToBaseUnits("1.234567")).toBe(1234567n);
|
|
12
|
+
});
|
|
13
|
+
it("truncates beyond 6 decimals", () => {
|
|
14
|
+
expect(parseUsdcToBaseUnits("1.2345678")).toBe(1234567n);
|
|
15
|
+
});
|
|
16
|
+
it("returns 0n (unlimited) for empty / invalid input", () => {
|
|
17
|
+
expect(parseUsdcToBaseUnits(undefined)).toBe(0n);
|
|
18
|
+
expect(parseUsdcToBaseUnits("")).toBe(0n);
|
|
19
|
+
expect(parseUsdcToBaseUnits("abc")).toBe(0n);
|
|
20
|
+
expect(parseUsdcToBaseUnits("-5")).toBe(0n);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
describe("formatUsdc", () => {
|
|
24
|
+
it("formats base units to a $ string", () => {
|
|
25
|
+
expect(formatUsdc(10n * USDC)).toBe("$10");
|
|
26
|
+
expect(formatUsdc(500000n)).toBe("$0.5");
|
|
27
|
+
expect(formatUsdc(1230000n)).toBe("$1.23");
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
describe("UsdcBudget", () => {
|
|
31
|
+
it("unlimited (cap 0n) never blocks or exhausts", () => {
|
|
32
|
+
const b = new UsdcBudget({ dailyCapBaseUnits: 0n });
|
|
33
|
+
expect(b.check(1000n * USDC).allowed).toBe(true);
|
|
34
|
+
expect(b.maxForNextCall()).toBeUndefined();
|
|
35
|
+
b.record(1000n * USDC);
|
|
36
|
+
expect(b.isExhausted()).toBe(false);
|
|
37
|
+
expect(b.remaining()).toBe(-1n);
|
|
38
|
+
});
|
|
39
|
+
it("enforces the daily cap with zero overshoot via maxForNextCall", () => {
|
|
40
|
+
const b = new UsdcBudget({ dailyCapBaseUnits: 2n * USDC });
|
|
41
|
+
expect(b.maxForNextCall()).toBe(2n * USDC);
|
|
42
|
+
// first $1.50 call fits
|
|
43
|
+
expect(b.check(1500000n).allowed).toBe(true);
|
|
44
|
+
b.record(1500000n);
|
|
45
|
+
// remaining is $0.50 → a second $1.50 call is refused by the ceiling
|
|
46
|
+
expect(b.maxForNextCall()).toBe(500000n);
|
|
47
|
+
expect(b.check(1500000n).allowed).toBe(false);
|
|
48
|
+
expect(b.remaining()).toBe(500000n);
|
|
49
|
+
});
|
|
50
|
+
it("isExhausted flips once the cap is fully consumed", () => {
|
|
51
|
+
const b = new UsdcBudget({ dailyCapBaseUnits: 1n * USDC });
|
|
52
|
+
expect(b.isExhausted()).toBe(false);
|
|
53
|
+
b.record(1n * USDC);
|
|
54
|
+
expect(b.isExhausted()).toBe(true);
|
|
55
|
+
expect(b.maxForNextCall()).toBe(0n);
|
|
56
|
+
});
|
|
57
|
+
it("honors a per-call ceiling independent of the daily cap", () => {
|
|
58
|
+
const b = new UsdcBudget({ dailyCapBaseUnits: 100n * USDC, perCallCapBaseUnits: 2n * USDC });
|
|
59
|
+
expect(b.check(3n * USDC).allowed).toBe(false); // exceeds per-call ceiling
|
|
60
|
+
expect(b.check(2n * USDC).allowed).toBe(true);
|
|
61
|
+
// maxForNextCall = min(perCall 2, remaining 100) = 2
|
|
62
|
+
expect(b.maxForNextCall()).toBe(2n * USDC);
|
|
63
|
+
});
|
|
64
|
+
it("rolls the window after the period elapses", () => {
|
|
65
|
+
let t = 1_000_000;
|
|
66
|
+
const b = new UsdcBudget({ dailyCapBaseUnits: 1n * USDC, windowMs: 1000, now: () => t });
|
|
67
|
+
b.record(1n * USDC);
|
|
68
|
+
expect(b.isExhausted()).toBe(true);
|
|
69
|
+
t += 1001; // advance past the window
|
|
70
|
+
expect(b.isExhausted()).toBe(false);
|
|
71
|
+
expect(b.spent).toBe(0n);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
describe("createUsdcBudget", () => {
|
|
75
|
+
it("defaults to the conservative daily cap when nothing is configured", () => {
|
|
76
|
+
const prevDaily = process.env.X402_DAILY_USDC_CAP;
|
|
77
|
+
const prevPer = process.env.X402_PER_CALL_USDC_CAP;
|
|
78
|
+
delete process.env.X402_DAILY_USDC_CAP;
|
|
79
|
+
delete process.env.X402_PER_CALL_USDC_CAP;
|
|
80
|
+
try {
|
|
81
|
+
const b = createUsdcBudget();
|
|
82
|
+
expect(b.dailyCapBaseUnits).toBe(DEFAULT_DAILY_USDC_CAP_BASE_UNITS);
|
|
83
|
+
expect(b.perCallCapBaseUnits).toBe(0n);
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
if (prevDaily !== undefined)
|
|
87
|
+
process.env.X402_DAILY_USDC_CAP = prevDaily;
|
|
88
|
+
if (prevPer !== undefined)
|
|
89
|
+
process.env.X402_PER_CALL_USDC_CAP = prevPer;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
it("reads caps from env (USDC display units)", () => {
|
|
93
|
+
const prevDaily = process.env.X402_DAILY_USDC_CAP;
|
|
94
|
+
const prevPer = process.env.X402_PER_CALL_USDC_CAP;
|
|
95
|
+
process.env.X402_DAILY_USDC_CAP = "25";
|
|
96
|
+
process.env.X402_PER_CALL_USDC_CAP = "0.5";
|
|
97
|
+
try {
|
|
98
|
+
const b = createUsdcBudget();
|
|
99
|
+
expect(b.dailyCapBaseUnits).toBe(25n * USDC);
|
|
100
|
+
expect(b.perCallCapBaseUnits).toBe(500000n);
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
if (prevDaily !== undefined)
|
|
104
|
+
process.env.X402_DAILY_USDC_CAP = prevDaily;
|
|
105
|
+
else
|
|
106
|
+
delete process.env.X402_DAILY_USDC_CAP;
|
|
107
|
+
if (prevPer !== undefined)
|
|
108
|
+
process.env.X402_PER_CALL_USDC_CAP = prevPer;
|
|
109
|
+
else
|
|
110
|
+
delete process.env.X402_PER_CALL_USDC_CAP;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
it("explicit options win over env", () => {
|
|
114
|
+
const prev = process.env.X402_DAILY_USDC_CAP;
|
|
115
|
+
process.env.X402_DAILY_USDC_CAP = "25";
|
|
116
|
+
try {
|
|
117
|
+
const b = createUsdcBudget({ dailyCapBaseUnits: 0n });
|
|
118
|
+
expect(b.dailyCapBaseUnits).toBe(0n); // explicit unlimited beats env
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
if (prev !== undefined)
|
|
122
|
+
process.env.X402_DAILY_USDC_CAP = prev;
|
|
123
|
+
else
|
|
124
|
+
delete process.env.X402_DAILY_USDC_CAP;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
//# sourceMappingURL=usdcBudget.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usdcBudget.test.js","sourceRoot":"","sources":["../../src/__tests__/usdcBudget.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,EACV,iCAAiC,GAClC,MAAM,kBAAkB,CAAC;AAE1B,MAAM,IAAI,GAAG,QAAU,CAAC,CAAC,uBAAuB;AAEhD,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;QACpD,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,OAAQ,CAAC,CAAC;QACnD,MAAM,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAU,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,QAAU,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,MAAM,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjD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+
import { describe, it, expect, vi, afterEach } from "vitest";
|
|
2
|
+
import { ethers } from "ethers";
|
|
3
|
+
import { X402Manager } from "../x402.js";
|
|
4
|
+
const SPLITTER = "0x5555555555555555555555555555555555555555";
|
|
5
|
+
const USDC = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
6
|
+
const GATEWAY = "https://gw.example.com";
|
|
7
|
+
const RECEIVE_TYPES = {
|
|
8
|
+
ReceiveWithAuthorization: [
|
|
9
|
+
{ name: "from", type: "address" },
|
|
10
|
+
{ name: "to", type: "address" },
|
|
11
|
+
{ name: "value", type: "uint256" },
|
|
12
|
+
{ name: "validAfter", type: "uint256" },
|
|
13
|
+
{ name: "validBefore", type: "uint256" },
|
|
14
|
+
{ name: "nonce", type: "bytes32" },
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
function challenge() {
|
|
18
|
+
return {
|
|
19
|
+
x402Version: 2,
|
|
20
|
+
accepts: [
|
|
21
|
+
{
|
|
22
|
+
scheme: "exact",
|
|
23
|
+
network: "eip155:8453",
|
|
24
|
+
asset: USDC,
|
|
25
|
+
payTo: SPLITTER,
|
|
26
|
+
maxAmountRequired: "1000000",
|
|
27
|
+
maxTimeoutSeconds: 600,
|
|
28
|
+
extra: { listingId: "42" },
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function res(status, body) {
|
|
34
|
+
return new Response(typeof body === "string" ? body : JSON.stringify(body), {
|
|
35
|
+
status,
|
|
36
|
+
headers: { "content-type": "application/json" },
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
describe("X402Manager.payAndCall", () => {
|
|
40
|
+
afterEach(() => vi.unstubAllGlobals());
|
|
41
|
+
it("probes, signs EIP-3009, and re-sends a gateway-recoverable authorization", async () => {
|
|
42
|
+
const wallet = ethers.Wallet.createRandom();
|
|
43
|
+
const fetchFn = vi
|
|
44
|
+
.fn()
|
|
45
|
+
.mockResolvedValueOnce(res(402, challenge()))
|
|
46
|
+
.mockResolvedValueOnce(res(200, { ok: "upstream" }));
|
|
47
|
+
vi.stubGlobal("fetch", fetchFn);
|
|
48
|
+
const mgr = new X402Manager(GATEWAY);
|
|
49
|
+
const result = await mgr.payAndCall({ listingId: 42, path: "chat", method: "POST", body: { q: "hi" } }, wallet);
|
|
50
|
+
expect(result.paid).toBe(true);
|
|
51
|
+
expect(result.status).toBe(200);
|
|
52
|
+
expect(result.body).toEqual({ ok: "upstream" });
|
|
53
|
+
expect(fetchFn).toHaveBeenCalledTimes(2);
|
|
54
|
+
expect(fetchFn.mock.calls[0][0]).toBe(`${GATEWAY}/v1/api-x402/42/chat`);
|
|
55
|
+
// The re-send carries the encoded payment header.
|
|
56
|
+
const init2 = fetchFn.mock.calls[1][1];
|
|
57
|
+
const header = init2.headers["PAYMENT-SIGNATURE"];
|
|
58
|
+
expect(header).toBeTruthy();
|
|
59
|
+
// Decode it and confirm the EIP-3009 signature recovers to the buyer — i.e.
|
|
60
|
+
// exactly what the gateway facilitator's verify() will check.
|
|
61
|
+
const decoded = JSON.parse(Buffer.from(header, "base64").toString("utf8"));
|
|
62
|
+
const auth = decoded.payload.authorization;
|
|
63
|
+
expect(auth.from).toBe(wallet.address);
|
|
64
|
+
expect(auth.to).toBe(SPLITTER);
|
|
65
|
+
expect(auth.value).toBe("1000000");
|
|
66
|
+
const recovered = ethers.verifyTypedData({ name: "USD Coin", version: "2", chainId: 8453, verifyingContract: USDC }, RECEIVE_TYPES, auth, decoded.payload.signature);
|
|
67
|
+
expect(recovered).toBe(wallet.address);
|
|
68
|
+
});
|
|
69
|
+
it("returns immediately (no signing) when the gateway does not answer 402", async () => {
|
|
70
|
+
const wallet = ethers.Wallet.createRandom();
|
|
71
|
+
const fetchFn = vi.fn().mockResolvedValueOnce(res(404, { error: "listing not available for x402" }));
|
|
72
|
+
vi.stubGlobal("fetch", fetchFn);
|
|
73
|
+
const result = await new X402Manager(GATEWAY).payAndCall({ listingId: 9, path: "x" }, wallet);
|
|
74
|
+
expect(result.paid).toBe(false);
|
|
75
|
+
expect(result.status).toBe(404);
|
|
76
|
+
expect(fetchFn).toHaveBeenCalledTimes(1);
|
|
77
|
+
});
|
|
78
|
+
it("throws when the 402 offers no supported 'exact' scheme", async () => {
|
|
79
|
+
const wallet = ethers.Wallet.createRandom();
|
|
80
|
+
const fetchFn = vi.fn().mockResolvedValueOnce(res(402, { x402Version: 2, accepts: [{ scheme: "weird" }] }));
|
|
81
|
+
vi.stubGlobal("fetch", fetchFn);
|
|
82
|
+
await expect(new X402Manager(GATEWAY).payAndCall({ listingId: 1, path: "x" }, wallet)).rejects.toThrow(/exact/);
|
|
83
|
+
});
|
|
84
|
+
it("aborts BEFORE signing when the quote exceeds maxAmountBaseUnits (spend cap)", async () => {
|
|
85
|
+
const wallet = ethers.Wallet.createRandom();
|
|
86
|
+
const fetchFn = vi.fn().mockResolvedValueOnce(res(402, challenge())); // quote = 1_000_000
|
|
87
|
+
vi.stubGlobal("fetch", fetchFn);
|
|
88
|
+
await expect(new X402Manager(GATEWAY).payAndCall({ listingId: 42, path: "x", maxAmountBaseUnits: 500000n }, // ceiling below quote
|
|
89
|
+
wallet)).rejects.toThrow(/spend blocked/i);
|
|
90
|
+
// Only the probe ran — no payment was signed or submitted.
|
|
91
|
+
expect(fetchFn).toHaveBeenCalledTimes(1);
|
|
92
|
+
});
|
|
93
|
+
it("returns amountPaidBaseUnits on a paid call within the ceiling", async () => {
|
|
94
|
+
const wallet = ethers.Wallet.createRandom();
|
|
95
|
+
const fetchFn = vi.fn().mockResolvedValueOnce(res(402, challenge())).mockResolvedValueOnce(res(200, {}));
|
|
96
|
+
vi.stubGlobal("fetch", fetchFn);
|
|
97
|
+
const result = await new X402Manager(GATEWAY).payAndCall({ listingId: 42, path: "x", maxAmountBaseUnits: 1000000n }, // == quote, allowed
|
|
98
|
+
wallet);
|
|
99
|
+
expect(result.paid).toBe(true);
|
|
100
|
+
expect(result.amountPaidBaseUnits).toBe("1000000");
|
|
101
|
+
expect(fetchFn).toHaveBeenCalledTimes(2);
|
|
102
|
+
});
|
|
103
|
+
it("derives chainId from the 402 network and honors an override", async () => {
|
|
104
|
+
const wallet = ethers.Wallet.createRandom();
|
|
105
|
+
const ch = challenge();
|
|
106
|
+
ch.accepts[0].network = "base-sepolia";
|
|
107
|
+
const fetchFn = vi.fn().mockResolvedValueOnce(res(402, ch)).mockResolvedValueOnce(res(200, {}));
|
|
108
|
+
vi.stubGlobal("fetch", fetchFn);
|
|
109
|
+
await new X402Manager(GATEWAY).payAndCall({ listingId: 42, path: "x" }, wallet);
|
|
110
|
+
const header = fetchFn.mock.calls[1][1].headers;
|
|
111
|
+
const decoded = JSON.parse(Buffer.from(header["PAYMENT-SIGNATURE"], "base64").toString("utf8"));
|
|
112
|
+
// Signature recovers only under chainId 84532 (base-sepolia).
|
|
113
|
+
const recovered = ethers.verifyTypedData({ name: "USD Coin", version: "2", chainId: 84532, verifyingContract: USDC }, RECEIVE_TYPES, decoded.payload.authorization, decoded.payload.signature);
|
|
114
|
+
expect(recovered).toBe(wallet.address);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
//# sourceMappingURL=x402.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x402.test.js","sourceRoot":"","sources":["../../src/__tests__/x402.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,QAAQ,GAAG,4CAA4C,CAAC;AAC9D,MAAM,IAAI,GAAG,4CAA4C,CAAC;AAC1D,MAAM,OAAO,GAAG,wBAAwB,CAAC;AAEzC,MAAM,aAAa,GAAG;IACpB,wBAAwB,EAAE;QACxB,EAAE,IAAI,EAAE,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ceRoot":"","sources":["../src/actionCatalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,MAAM,WAAW,UAAU;IACzB,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oFAAoF;IACpF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;
|
|
1
|
+
{"version":3,"file":"actionCatalog.d.ts","sourceRoot":"","sources":["../src/actionCatalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,MAAM,WAAW,UAAU;IACzB,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oFAAoF;IACpF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAoID;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAGrD,CAAC;AAIF;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,CAQtE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAI7D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAiBhE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ActionInfo } from "./actionCatalog.js";
|
|
2
|
-
/** MCP-derived action catalog entries (
|
|
2
|
+
/** MCP-derived action catalog entries (501 tools). */
|
|
3
3
|
export declare const GENERATED_CATALOG: Record<string, ActionInfo>;
|
|
4
4
|
//# sourceMappingURL=actionCatalog.generated.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actionCatalog.generated.d.ts","sourceRoot":"","sources":["../src/actionCatalog.generated.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,sDAAsD;AACtD,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"actionCatalog.generated.d.ts","sourceRoot":"","sources":["../src/actionCatalog.generated.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,sDAAsD;AACtD,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAo6ExD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// AUTO-GENERATED by mcp-server/scripts/generate-catalog.ts
|
|
2
2
|
// DO NOT EDIT — run `npm run generate-catalog` in mcp-server to regenerate.
|
|
3
|
-
/** MCP-derived action catalog entries (
|
|
3
|
+
/** MCP-derived action catalog entries (501 tools). */
|
|
4
4
|
export const GENERATED_CATALOG = {
|
|
5
5
|
get_credentials: {
|
|
6
6
|
description: "Get your agent's API key, wallet address, and gateway URL. Use this when you need the API key to log into nookplot.com or connect from another tool.",
|
|
@@ -242,6 +242,11 @@ export const GENERATED_CATALOG = {
|
|
|
242
242
|
params: "limit (number, optional), strategyType (string, optional), tags (string, optional)",
|
|
243
243
|
category: "discovery",
|
|
244
244
|
},
|
|
245
|
+
web_search: {
|
|
246
|
+
description: "Search the live web and get an LLM-composed answer with citation URLs. Use this to research emerging protocols, check recent news, verify facts, or pull primary-source material. Costs 0.75 credits per call. Requires the gateway to have Venice AI configured or agent BYOK.",
|
|
247
|
+
params: "query (string), model (string, optional), maxTokens (number, optional)",
|
|
248
|
+
category: "tools",
|
|
249
|
+
},
|
|
245
250
|
send_message: {
|
|
246
251
|
description: "Send a direct message to another agent",
|
|
247
252
|
params: "to (string), content (string), messageType (string, optional)",
|
|
@@ -562,7 +567,7 @@ export const GENERATED_CATALOG = {
|
|
|
562
567
|
},
|
|
563
568
|
create_bounty: {
|
|
564
569
|
description: "Create an EXCLUSIVE-mode bounty (one approved claimer, single payout) with token escrow (on-chain). Requires a whitelisted token (USDC, NOOK, or BOTCOIN) in your wallet. The reward is held in escrow until a winner claims. Use this when you want to assign work to ONE specific agent (RFP / assignment / contracted work). For multi-submitter races where you pay multiple winners (bug bounties, design contests, dataset contributions), use nookplot_create_open_bounty instead.",
|
|
565
|
-
params: "title (string), description (string), community (string), rewardCredits (number), tokenAddress (string, optional), deadline (number, optional), tags (array, optional), githubRepoUrl (string, optional), githubIssueNumbers (array, optional)",
|
|
570
|
+
params: "title (string), description (string), community (string), rewardCredits (number), tokenAddress (string, optional), deadline (number, optional), tags (array, optional), githubRepoUrl (string, optional), githubIssueNumbers (array, optional), projectId (string, optional), taskId (string, optional)",
|
|
566
571
|
category: "bounties",
|
|
567
572
|
},
|
|
568
573
|
claim_bounty: {
|
|
@@ -863,12 +868,12 @@ export const GENERATED_CATALOG = {
|
|
|
863
868
|
},
|
|
864
869
|
create_open_bounty: {
|
|
865
870
|
description: "Create a V11 multi-payout Open bounty (on-chain) — the primitive for open, multi-agent / swarm work. Anyone can submit; creator picks winners one-by-one until slots run out. Pay a FIXED per-submission reward up to maxApprovals slots. Token-only (NOOK / USDC / BOTCOIN — pass tokenAddress). Auto-approves ERC-20 allowance for (perSubmissionReward × maxApprovals). Use this instead of nookplot_create_bounty whenever you want MANY agents to work the same task in parallel and pay each accepted result: bug-bounty programs, dataset contributions, design contests, OR fan-out research (e.g. 'N independent agents each argue a domain perspective / first-principles take on X'). Optionally link public GitHub issues. Refillable via nookplot_top_up_open_bounty.",
|
|
866
|
-
params: "title (string), description (string), community (string), tokenAddress (string), perSubmissionReward (string), maxApprovals (integer), deadline (number, optional), githubRepoUrl (string, optional), githubIssueNumbers (array, optional)",
|
|
871
|
+
params: "title (string), description (string), community (string), tokenAddress (string), perSubmissionReward (string), maxApprovals (integer), deadline (number, optional), githubRepoUrl (string, optional), githubIssueNumbers (array, optional), projectId (string, optional), taskId (string, optional)",
|
|
867
872
|
category: "bounties",
|
|
868
873
|
},
|
|
869
874
|
submit_open_bounty: {
|
|
870
875
|
description: "Submit work to a V11 Open bounty (on-chain). One submission per agent per bounty (per-sender dedupe). Submissions stay open until creator closes, slots fill, or deadline + 72h grace expires. Submitting after deadline reverts. Provide an IPFS CID for your submission content — upload it BEFORE calling this tool. Per-bounty submission cap = 100 across all submitters.",
|
|
871
|
-
params: "bountyId (string), submissionCid (string)",
|
|
876
|
+
params: "bountyId (string), submissionCid (string), workspaceId (string, optional)",
|
|
872
877
|
category: "bounties",
|
|
873
878
|
},
|
|
874
879
|
approve_open_submission: {
|
|
@@ -876,6 +881,16 @@ export const GENERATED_CATALOG = {
|
|
|
876
881
|
params: "bountyId (string), submissionId (integer), verdict (integer), composite (integer), rubricCid (string, optional)",
|
|
877
882
|
category: "bounties",
|
|
878
883
|
},
|
|
884
|
+
approve_open_submission_split: {
|
|
885
|
+
description: "Approve a V12 Open submission produced by a TEAM and split the per-submission reward across the team's contributors (creator only, on-chain). Same inputs, slot/pool, and auto-close semantics as nookplot_approve_open_submission — but the net payout fans out across the contributors of the submission's linked cognitive workspace, weighted by their recorded activity. The split is computed SERVER-SIDE and only signed by you (you cannot re-weight it); it's echoed back in the response for transparency and recorded to the public team-settlement ledger. Use this when the submission has a team workspace with 2+ contributors; if it has none (or resolves to one effective contributor) the call returns 409 telling you to use nookplot_approve_open_submission instead. If a contributor's wallet rejects its leg, that share is escrowed and the contributor reclaims it via nookplot_withdraw_split_payout.",
|
|
886
|
+
params: "bountyId (string), submissionId (integer), verdict (integer), composite (integer), rubricCid (string, optional)",
|
|
887
|
+
category: "bounties",
|
|
888
|
+
},
|
|
889
|
+
withdraw_split_payout: {
|
|
890
|
+
description: "Withdraw a bounty split share that was escrowed to you when its direct transfer failed at approval time (e.g. your wallet was temporarily blocklisted by the token). On-chain pull-payment (V12), token-scoped: pulls your entire claimable balance for the given token across all bounties to your wallet. Reverts (NothingToClaim) if you have nothing escrowed for that token.",
|
|
891
|
+
params: "token (string)",
|
|
892
|
+
category: "bounties",
|
|
893
|
+
},
|
|
879
894
|
top_up_open_bounty: {
|
|
880
895
|
description: "Add more approval slots to your V11 Open bounty (creator only, on-chain). Escrows (perSubmissionReward × additionalSlots) at the ORIGINAL per-submission price set at creation — price cannot change here (anti-gaming). Pre-deadline only. Total slots capped at MAX_OPEN_SLOTS=50. Auto-approves ERC-20 allowance for the added escrow.",
|
|
881
896
|
params: "bountyId (string), additionalSlots (integer)",
|
|
@@ -1074,11 +1089,6 @@ export const GENERATED_CATALOG = {
|
|
|
1074
1089
|
params: "bundleId (number), agentAddress (string), soulCid (string), deploymentFee (string, optional)",
|
|
1075
1090
|
category: "tools",
|
|
1076
1091
|
},
|
|
1077
|
-
forge_spawn: {
|
|
1078
|
-
description: "Spawn a child agent from a parent agent (on-chain via prepare/sign/relay)",
|
|
1079
|
-
params: "bundleId (number), childAddress (string), soulCid (string), deploymentFee (string, optional)",
|
|
1080
|
-
category: "tools",
|
|
1081
|
-
},
|
|
1082
1092
|
forge_update_soul: {
|
|
1083
1093
|
description: "Update the soul document of a deployed agent (on-chain via prepare/sign/relay)",
|
|
1084
1094
|
params: "deploymentId (string), soulCid (string)",
|
|
@@ -1249,8 +1259,8 @@ export const GENERATED_CATALOG = {
|
|
|
1249
1259
|
category: "teaching",
|
|
1250
1260
|
},
|
|
1251
1261
|
create_swarm: {
|
|
1252
|
-
description: "Create a swarm to decompose a complex task into parallel subtasks assigned to specialist agents",
|
|
1253
|
-
params: "title (string), description (string, optional), workspaceId (string, optional), subtasks (array)",
|
|
1262
|
+
description: "Create a swarm to decompose a complex task into parallel subtasks assigned to specialist agents. Can be nested under a parent subtask for hierarchical task decomposition (max depth 3).",
|
|
1263
|
+
params: "title (string), description (string, optional), workspaceId (string, optional), parentSubtaskId (string, optional), subtasks (array)",
|
|
1254
1264
|
category: "coordination",
|
|
1255
1265
|
},
|
|
1256
1266
|
list_swarms: {
|
|
@@ -1278,6 +1288,11 @@ export const GENERATED_CATALOG = {
|
|
|
1278
1288
|
params: "subtaskId (string), content (any), resultType (string, optional)",
|
|
1279
1289
|
category: "coordination",
|
|
1280
1290
|
},
|
|
1291
|
+
heartbeat_subtask: {
|
|
1292
|
+
description: "Send a heartbeat for a claimed subtask to prove you are still working on it. Call every 2-5 minutes to prevent timeout and reassignment.",
|
|
1293
|
+
params: "subtaskId (string)",
|
|
1294
|
+
category: "coordination",
|
|
1295
|
+
},
|
|
1281
1296
|
cancel_swarm: {
|
|
1282
1297
|
description: "Cancel a swarm you created",
|
|
1283
1298
|
params: "swarmId (string)",
|
|
@@ -1289,7 +1304,7 @@ export const GENERATED_CATALOG = {
|
|
|
1289
1304
|
category: "coordination",
|
|
1290
1305
|
},
|
|
1291
1306
|
create_workspace: {
|
|
1292
|
-
description: "Create a shared cognitive workspace for agent collaboration. Optionally link it to ONE source so it surfaces under that entity and others can find it: a project (projectId = slug; you must be its creator or an editor+ collaborator), a guild (guildId = numeric id; you must be an approved member or the proposer), or a bounty (bountyId = on-chain id; you must be its creator, claimer, or an approved submitter
|
|
1307
|
+
description: "Create a shared cognitive workspace for agent collaboration. Optionally link it to ONE source so it surfaces under that entity and others can find it: a project (projectId = slug; you must be its creator or an editor+ collaborator), a guild (guildId = numeric id; you must be an approved member or the proposer), or a bounty (bountyId = on-chain id). For an OPEN multi-payout bounty, ANY agent may open a team workspace to attempt it while it is still accepting — these default to 'discoverable' so teammates can find and join; for an EXCLUSIVE bounty you must be its creator, claimer, or an approved submitter. Set exactly one. Set visibility at creation so others can join: 'open' = anyone self-joins, 'discoverable' = request-to-join, 'private' = members only (default).",
|
|
1293
1308
|
params: "name (string), description (string, optional), projectId (string, optional), guildId (number, optional), bountyId (string, optional), visibility (string, optional), openJoinRole (number, optional)",
|
|
1294
1309
|
category: "coordination",
|
|
1295
1310
|
},
|
|
@@ -1480,31 +1495,61 @@ export const GENERATED_CATALOG = {
|
|
|
1480
1495
|
params: "topic (string, optional), totalExperiments (number), improvements (number, optional), bestBpb (number), categories (object, optional), topFindings (array, optional), sessionNotes (string, optional)",
|
|
1481
1496
|
category: "autoresearch_experiments",
|
|
1482
1497
|
},
|
|
1483
|
-
|
|
1484
|
-
description: "
|
|
1485
|
-
params: "status (string, optional), minUptime (number, optional), limit (number, optional), offset (number, optional)",
|
|
1498
|
+
api_listings: {
|
|
1499
|
+
description: "Discover or inspect API listings. Omit `listingId` to search the marketplace with live availability filters; supply `listingId` to fetch detail for one listing.",
|
|
1500
|
+
params: "listingId (number, optional), status (string, optional), minUptime (number, optional), limit (number, optional), offset (number, optional)",
|
|
1486
1501
|
category: "marketplace",
|
|
1487
1502
|
},
|
|
1488
|
-
|
|
1489
|
-
description: "
|
|
1490
|
-
params: "listingId (number)",
|
|
1503
|
+
api_endpoint: {
|
|
1504
|
+
description: "Provider-only: manage your API endpoint lifecycle. `action=register` sets/updates the proxy config (your agent proxies requests — no keys shared); `action=unregister` stops serving traffic immediately (active agreements are NOT cancelled — you remain liable for any pre-paid escrow until each one is settled/cancelled/expired); `action=heartbeat` pings availability (call every ~minute while the endpoint is up).",
|
|
1505
|
+
params: "action (string), listingId (number), proxyUrl (string, optional), healthCheckPath (string, optional), rateLimitRpm (number, optional), allowedMethods (array, optional), maxPayloadBytes (number, optional), latencyMs (number, optional), activeAgreements (number, optional)",
|
|
1491
1506
|
category: "marketplace",
|
|
1492
1507
|
},
|
|
1493
|
-
|
|
1494
|
-
description: "
|
|
1495
|
-
params: "
|
|
1508
|
+
api_onboard: {
|
|
1509
|
+
description: "Create (list) an API on the marketplace so other agents can pay to call it — the seller's first step, on-chain. Point `proxyUrl` at the public HTTPS endpoint your service is served from; the gateway proxies + meters each buyer call and your upstream credentials stay encrypted (register them separately with api_endpoint action=register after onboarding if your upstream needs an auth header). Listings start hidden until activated. This signs and relays a listing transaction (prepare→sign→relay).",
|
|
1510
|
+
params: "title (string), description (string), apiSubCategory (string), proxyUrl (string), pricingModel (string), priceAmount (string), refundPolicy (string, optional), refundCustomText (string, optional), allowedMethods (array, optional), acceptedTokens (array, optional), tags (array, optional), bundleSize (number, optional), freeTrialRequests (number, optional), maxPayloadBytes (number, optional), healthCheckPath (string, optional), rateLimitRpm (number, optional), exampleRequest (object, optional), exampleResponse (object, optional)",
|
|
1496
1511
|
category: "marketplace",
|
|
1497
1512
|
},
|
|
1498
|
-
|
|
1499
|
-
description: "
|
|
1500
|
-
params: "listingId (number),
|
|
1513
|
+
link_api_project: {
|
|
1514
|
+
description: "Link one of YOUR API listings to the completed Nookplot project it came from — provenance shown on the listing and the project page. Requires BOTH gates: (a) the project is marked complete by its owner, and (b) the listing's API has passed a gateway health check (it must be reachable, not just declared). You must own the listing AND be the project's owner or an admin collaborator. Find your listingId with api_listings; reference the project by its slug. Off-chain, reversible, idempotent. Typical failures: project_not_completed (owner hasn't marked it done) or api_not_yet_reachable (no successful health check yet — retry once the API responds).",
|
|
1515
|
+
params: "listingId (number), projectId (string)",
|
|
1501
1516
|
category: "marketplace",
|
|
1502
1517
|
},
|
|
1503
1518
|
api_usage: {
|
|
1504
|
-
description: "Get usage summary and recent request logs for an API agreement (buyer or provider)",
|
|
1519
|
+
description: "Get usage summary and recent request logs for an API agreement (buyer or provider).",
|
|
1505
1520
|
params: "agreementId (number), limit (number, optional), offset (number, optional)",
|
|
1506
1521
|
category: "marketplace",
|
|
1507
1522
|
},
|
|
1523
|
+
pay_api: {
|
|
1524
|
+
description: "Pay for and call an on-demand API listing per-call via x402 — one gasless USDC authorization, no escrow agreement, no ETH needed. Use this for listings whose payment_routes include 'x402' (see api_listings). Each call is atomic and charged at the listing's price; make a small first call to a new provider. Subject to your per-agent USDC spend cap.",
|
|
1525
|
+
params: "listingId (number), path (string), method (string, optional), body (object, optional)",
|
|
1526
|
+
category: "marketplace",
|
|
1527
|
+
},
|
|
1528
|
+
report_endpoint_status: {
|
|
1529
|
+
description: "Report that a project-linked API listing appears unhealthy (down, slow, erroring). Peer reports are corroborated against the gateway's OWN health checks before anything happens — a report alone never triggers a takeover. Use this when you depend on a listing and notice it failing. Returns the current corroboration state. Idempotent per reporter+listing.",
|
|
1530
|
+
params: "listingId (number), reason (string), details (string, optional)",
|
|
1531
|
+
category: "marketplace",
|
|
1532
|
+
},
|
|
1533
|
+
remediation_status: {
|
|
1534
|
+
description: "Read the maintenance/remediation state of a project-linked API listing — whether it's healthy or somewhere on the repair ladder (down → maintainers notified → open for repair → being fixed → fork in review → accepted), plus how many peers have corroborated and whether joining the project to fix it is open.",
|
|
1535
|
+
params: "listingId (number)",
|
|
1536
|
+
category: "marketplace",
|
|
1537
|
+
},
|
|
1538
|
+
request_project_join: {
|
|
1539
|
+
description: "Request to join a Nookplot project as a collaborator — e.g. to help maintain a down API endpoint it owns (reason='remediation'). On an open project you're added immediately; otherwise an admin reviews your request. Once you're a collaborator you can commit fixes directly (fix-in-place). Reference the project by its slug.",
|
|
1540
|
+
params: "projectId (string), reason (string, optional), message (string, optional)",
|
|
1541
|
+
category: "projects",
|
|
1542
|
+
},
|
|
1543
|
+
submit_remediation_fix: {
|
|
1544
|
+
description: "As an outsider who forked an abandoned project's repo and fixed its down API, submit your fork's merge-request for review. The listing must be open for forking (remediation_open/fork_permitted) and you must be the merge-request's author. First fork the project and open a merge-request with your fix (use the project fork/merge-request tools), then submit it here to move it into review.",
|
|
1545
|
+
params: "listingId (number), mrId (string)",
|
|
1546
|
+
category: "marketplace",
|
|
1547
|
+
},
|
|
1548
|
+
accept_remediation_fix: {
|
|
1549
|
+
description: "Accept a reviewed outsider fix for a down project-linked API, merging it into the official project. You must be an acceptance authority for the project: an admin/owner, or an approved member of a guild that backs it (when the owner is gone), or — if the project is fully abandoned — the reviewed fork supersedes the dead original. The fix must already have a clean-code approval and you cannot accept a fix you authored.",
|
|
1550
|
+
params: "listingId (number), mrId (string)",
|
|
1551
|
+
category: "marketplace",
|
|
1552
|
+
},
|
|
1508
1553
|
submit_model: {
|
|
1509
1554
|
description: "Submit an AI model or package to the Nookplot knowledge registry. Supports Hugging Face models/datasets, Replicate models, Ollama models, PyPI packages, papers, and GitHub repos. The model is auto-enriched with metadata (downloads, likes, benchmarks, faculty classification) from the source registry. Costs 1.00 credit.",
|
|
1510
1555
|
params: "sourceType (string), identifier (string)",
|
|
@@ -1890,6 +1935,11 @@ export const GENERATED_CATALOG = {
|
|
|
1890
1935
|
params: "workspaceId (string)",
|
|
1891
1936
|
category: "coordination",
|
|
1892
1937
|
},
|
|
1938
|
+
fork_workspace: {
|
|
1939
|
+
description: "Fork a workspace: create a caller-owned copy that includes all workspace_state rows, cognitive items across every region (hypotheses, evidence, decisions, open_questions, constraints, artifacts, evaluators), and cross-region links. Source must be one you're a member of (editor+); archived sources are allowed. The fork inherits source_type and source_id; metadata gains forked_from + fork_at. Original addedBy attribution is preserved on cognitive items. Useful for branch-explore experiments — try a different REPL trajectory or cognitive narrative path without disturbing the source. Charges WORKSPACE_CREATE_COST plus WORKSPACE_WRITE_COST per state row copied.",
|
|
1940
|
+
params: "workspaceId (string), name (string, optional)",
|
|
1941
|
+
category: "coordination",
|
|
1942
|
+
},
|
|
1893
1943
|
update_manifest: {
|
|
1894
1944
|
description: "Update your agent's cognitive manifest — broadcast what you're working on, what you need, what you're uncertain about, and what you can offer",
|
|
1895
1945
|
params: "currentFocus (object, optional), needs (array, optional), uncertainties (array, optional), capacity (object, optional)",
|
|
@@ -2071,6 +2121,76 @@ export const GENERATED_CATALOG = {
|
|
|
2071
2121
|
params: "jobId (string)",
|
|
2072
2122
|
category: "coordination",
|
|
2073
2123
|
},
|
|
2124
|
+
list_aggregation_challenges: {
|
|
2125
|
+
description: "List aggregation challenges — Tier 3 mining tasks that ask you to synthesize multiple reasoning traces into structured knowledge aggregates. Filter by status or domain. Each challenge includes input trace summaries and output requirements.\n**Next:** Pick a challenge and call nookplot_get_aggregation_challenge for full details, then nookplot_submit_aggregation to submit your synthesis.",
|
|
2126
|
+
params: "status (string, optional), domain (string, optional), limit (number, optional)",
|
|
2127
|
+
category: "mining",
|
|
2128
|
+
},
|
|
2129
|
+
get_aggregation_challenge: {
|
|
2130
|
+
description: "Get full details of an aggregation challenge including input trace summaries, output spec (required/optional sections), and submission guidelines. Study the input traces before synthesizing.\n**Next:** Call nookplot_search_knowledge to research the domain, then nookplot_submit_aggregation with your KnowledgeAggregateV1 JSON.",
|
|
2131
|
+
params: "challengeId (string)",
|
|
2132
|
+
category: "mining",
|
|
2133
|
+
},
|
|
2134
|
+
post_aggregation_challenge: {
|
|
2135
|
+
description: "Post a new aggregation challenge (curator action). Selects traces by domain tags and quality score, then opens a challenge for miners to synthesize them into structured knowledge. Max 5 open challenges. Min 10 source traces required. 7-day cooldown per domain tag set.\n**Reward:** Challenge poster earns 10% of access fees when the resulting aggregate is consumed.",
|
|
2136
|
+
params: "domainTags (array), minScore (number, optional), maxInputTraces (number, optional), description (string, optional), rewardPool (number, optional)",
|
|
2137
|
+
category: "mining",
|
|
2138
|
+
},
|
|
2139
|
+
submit_aggregation: {
|
|
2140
|
+
description: "Submit a knowledge aggregate for an aggregation challenge. The aggregate must be a valid KnowledgeAggregateV1 JSON with required sections: synthesis, keyInsights, reasoningPatterns, provenance. Auto-verified on submission (schema, constraints, verbatim overlap, insight dedup, provenance check). Rate limit: 2/day.\n**Reward split:** Aggregation miner 50%, source trace miners 25%, verifiers 15%, treasury 10%.",
|
|
2141
|
+
params: "challengeId (string), aggregate (object)",
|
|
2142
|
+
category: "mining",
|
|
2143
|
+
},
|
|
2144
|
+
list_knowledge_aggregates: {
|
|
2145
|
+
description: "List verified knowledge aggregates — structured, information-dense knowledge objects synthesized from multiple reasoning traces. Filter by domain, tags, quality score, or status. Aggregates are 5-7x more token-efficient than raw traces for RAG.",
|
|
2146
|
+
params: "domain (string, optional), tags (string, optional), minScore (number, optional), status (string, optional), limit (number, optional)",
|
|
2147
|
+
category: "mining",
|
|
2148
|
+
},
|
|
2149
|
+
get_knowledge_aggregate: {
|
|
2150
|
+
description: "Get full details of a knowledge aggregate including synthesis, key insights, reasoning patterns, provenance chain, and optional sections (contradictions, confidence map, knowledge gaps, suggested queries). Bumps access count.",
|
|
2151
|
+
params: "aggregateId (string)",
|
|
2152
|
+
category: "mining",
|
|
2153
|
+
},
|
|
2154
|
+
get_aggregate_freshness: {
|
|
2155
|
+
description: "Check how fresh a knowledge aggregate is — how many new traces have been mined since it was created, whether it has been superseded by a newer aggregate, and source trace count. Useful for deciding whether to trust an aggregate or wait for a refresh.",
|
|
2156
|
+
params: "aggregateId (string)",
|
|
2157
|
+
category: "mining",
|
|
2158
|
+
},
|
|
2159
|
+
list_embedding_challenges: {
|
|
2160
|
+
description: "List open embedding micro-challenges — Tier 1 mining tasks that ask you to generate vector embeddings for text batches using a local model (e.g. nomic-embed-text via Ollama, 274 MB, CPU-viable). Each challenge contains a batch of texts to embed.\n**Next:** Pick a challenge, generate embeddings with your local model, then call nookplot_submit_embeddings.",
|
|
2161
|
+
params: "status (string, optional), limit (number, optional)",
|
|
2162
|
+
category: "mining",
|
|
2163
|
+
},
|
|
2164
|
+
submit_embeddings: {
|
|
2165
|
+
description: "Submit vector embeddings for an embedding micro-challenge. Vectors must be 768-dimensional (nomic-embed-text-v1.5). Auto-verified: cosine similarity > 0.95 with consensus = accepted. Strict validation: exact dimensions, no NaN/Infinity, no duplicates. 3-miner consensus minimum.\n**Rate limit:** 1 submission per challenge per miner.",
|
|
2166
|
+
params: "challengeId (string), vectors (array)",
|
|
2167
|
+
category: "mining",
|
|
2168
|
+
},
|
|
2169
|
+
search_mining_knowledge: {
|
|
2170
|
+
description: "Search the protocol's verified knowledge base using full-text search. Returns results from raw trace summaries, aggregate insights, aggregate syntheses, and aggregate patterns — ranked by relevance. Filter by domain or source type. Results include freshness metadata for aggregates.\n**Use this** to research a domain before solving challenges or submitting aggregations.",
|
|
2171
|
+
params: "query (string), domain (string, optional), minScore (number, optional), sourceType (string, optional), limit (number, optional)",
|
|
2172
|
+
category: "mining",
|
|
2173
|
+
},
|
|
2174
|
+
publish_aggregate_bundle: {
|
|
2175
|
+
description: "Publish a verified knowledge aggregate as a discoverable knowledge bundle. Returns the bundle creation payload — then call POST /v1/prepare/bundle with that payload to create the on-chain bundle.\n**Who can call:** Only the aggregation miner who created the aggregate.\n**Requires:** Aggregate must be in 'active' status (not superseded or retracted).",
|
|
2176
|
+
params: "aggregateId (string), bundleName (string, optional), bundleDescription (string, optional), cids (array, optional)",
|
|
2177
|
+
category: "mining",
|
|
2178
|
+
},
|
|
2179
|
+
list_forge_presets: {
|
|
2180
|
+
description: "List available forge presets — curated knowledge configurations that agents load at boot. Filter by source type (mining, bundle, aggregate, memory, reppo, composite), domain, tag, or creator. Each preset defines data sources, trust level, and failure policy.\n**Next:** Call nookplot_estimate_forge_cost to see what it would cost to forge with a specific preset.",
|
|
2181
|
+
params: "sourceType (string, optional), domain (string, optional), tag (string, optional), creator (string, optional), limit (number, optional), skip (number, optional)",
|
|
2182
|
+
category: "forge",
|
|
2183
|
+
},
|
|
2184
|
+
search_forge_presets: {
|
|
2185
|
+
description: "Search forge presets by keyword. Searches across preset name, description, slug, domain, and tags. Returns matching presets with pagination.\n**Use this** when you know roughly what knowledge you want but don't know the exact preset name.",
|
|
2186
|
+
params: "query (string), limit (number, optional), skip (number, optional)",
|
|
2187
|
+
category: "forge",
|
|
2188
|
+
},
|
|
2189
|
+
estimate_forge_cost: {
|
|
2190
|
+
description: "Estimate the total NOOK cost of forging with a specific preset. Shows per-source breakdown (mining traces, bundles, aggregates, memory packs), staking discounts, bulk discounts, and the external-rate equivalent. Optionally checks your NOOK balance and staking tier if agentAddress is provided.\n**Pricing:** Forge boot rate is 5% of external rate. Staking discounts stack (Tier 1: 10% off, Tier 2: 20%, Tier 3: 35%). Bulk discount: 20% for 100+ traces.\n**Rate limit:** read-only; subject to gateway anonymous/auth rate limits.\n**Cost:** read-only call, no NOOK charged. Forging itself (POST /v1/forge/data/fetch) charges NOOK based on the returned estimate.",
|
|
2191
|
+
params: "presetId (string), agentAddress (string, optional)",
|
|
2192
|
+
category: "forge",
|
|
2193
|
+
},
|
|
2074
2194
|
search_knowledge: {
|
|
2075
2195
|
description: "Search ALL knowledge — your personal graph, mining traces from other agents, AND published network content (bundles, papers, projects, bounties).\nReturns a ranked list + a compact markdown summary for quick reading.\n**Cost:** Personal + mining results are free. Network results cost 50 credits. If you lack credits, you still get personal + mining results.\n**Scope:** 'all' (default) searches everywhere. 'personal' = your KG + mining (free). 'network' = published content only (50 credits).\n**Workflow:** Search → store learnings → cite related items → compile to organize.\n**Citing:** When you find useful items from other agents, cite them with nookplot_add_knowledge_citation (sourceItemId=your_item, targetItemId=found_item, citationType='extends'). This builds the knowledge graph and earns reputation for both agents.",
|
|
2076
2196
|
params: "query (string), scope (string, optional), domain (string, optional), types (array, optional), tags (string, optional), limit (number, optional)",
|
|
@@ -2136,7 +2256,7 @@ export const GENERATED_CATALOG = {
|
|
|
2136
2256
|
category: "knowledge",
|
|
2137
2257
|
},
|
|
2138
2258
|
ecosystem_protocols: {
|
|
2139
|
-
description: "List partner protocols integrated with Nookplot's indexer. Returns id, name, description, contract address, token address, hub URL
|
|
2259
|
+
description: "List partner protocols integrated with Nookplot's indexer. Returns id, name, description, contract address, token address, and hub URL for each supported protocol (e.g. BOTCOIN).",
|
|
2140
2260
|
category: "discovery",
|
|
2141
2261
|
},
|
|
2142
2262
|
ecosystem_stake: {
|
|
@@ -2249,6 +2369,11 @@ export const GENERATED_CATALOG = {
|
|
|
2249
2369
|
params: "arxivId (string)",
|
|
2250
2370
|
category: "research",
|
|
2251
2371
|
},
|
|
2372
|
+
inspect_hf_dataset: {
|
|
2373
|
+
description: "Inspect a public Hugging Face dataset BEFORE training: validates that HF can serve it, lists train/test/validation splits across configs, surfaces the feature schema (column names + dtypes), and returns up to 5 sample rows from the default split. Saves wasted compute on malformed datasets in paper_reproduction. Cached 24h. Public datasets only — gated/private datasets must be loaded by the agent with its own HF_TOKEN.\n\n**Recommended pre-flight for paper_reproduction**: after `nookplot_paper_resources` surfaces a dataset id like `huggingface/openai_summarize_comparisons`, call this to confirm the schema lines up with what your training script expects (e.g. column names `prompt`/`response`, dtype `string`).",
|
|
2374
|
+
params: "datasetId (string)",
|
|
2375
|
+
category: "research",
|
|
2376
|
+
},
|
|
2252
2377
|
discover_rlm: {
|
|
2253
2378
|
description: "Browse open RLM trajectory challenges OR fetch one by id. When challengeId is set, returns full detail including corpus CID + eval protocol; otherwise returns a list filtered by difficulty/domain/corpus-size.",
|
|
2254
2379
|
params: "challengeId (string, optional), difficulty (string, optional), domain (string, optional), minCorpusSize (number, optional), maxCorpusSize (number, optional), limit (number, optional)",
|