Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat(platform): ship the last pending changes picked up since the previous push, with their docs and tests

nirholasd93b25d5b443
diff --git a/robinhood/robinhood-chain-examples/examples/11-mcp-agent-session/package-lock.json b/robinhood/robinhood-chain-examples/examples/11-mcp-agent-session/package-lock.json
index eaff91011..1e4161f32 100644
--- a/robinhood/robinhood-chain-examples/examples/11-mcp-agent-session/package-lock.json
+++ b/robinhood/robinhood-chain-examples/examples/11-mcp-agent-session/package-lock.json
@@ -557,9 +557,9 @@
"license": "MIT"
},
"node_modules/fast-uri": {
- "version": "3.1.4",
- "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.4.tgz",
- "integrity": "sha512-8JnbkQ4juDyvYs4mgFGQqg4yCYtFDtUtmp2QIQq11ZZe5CFQ5wcqm1rqDgAh/QdMySuBnPzMUiJUNZG5N/AiQw==",
+ "version": "3.1.9",
+ "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz",
+ "integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==",
"funding": [
{
"type": "github",
diff --git a/tests/agent-guard-endpoint.test.js b/tests/agent-guard-endpoint.test.js
index 53e6a5634..83f8016ad 100644
--- a/tests/agent-guard-endpoint.test.js
+++ b/tests/agent-guard-endpoint.test.js
@@ -70,6 +70,13 @@ vi.mock('../api/_lib/db.js', () => ({
},
}));
+// The on-chain allowance ceiling reads the chain; its own logic is covered in
+// tests/onchain-allowance.test.js. Here only the endpoint wiring is exercised.
+const checkAgentAllowanceSpend = vi.fn();
+vi.mock('../api/_lib/onchain-allowance-store.js', () => ({
+ checkAgentAllowanceSpend: (...a) => checkAgentAllowanceSpend(...a),
+}));
+
const { default: guardHandler } = await import('../api/agent/guard.js');
const { delegationMessage } = await import('../packages/agent-guards/src/delegation.js');
@@ -437,3 +444,45 @@ describe('POST /api/agent/guard - signed spend delegation', () => {
expect(verdicts[0].verdict.blockedBy).toBe('spend_delegation');
});
});
+
+describe('POST /api/agent/guard - on-chain allowance ceiling', () => {
+ const agentId = '22222222-2222-4222-8222-222222222222';
+ const mint = 'So11111111111111111111111111111111111111112';
+ const pull = (amountRaw) => ({ calls: [{ identifier: 'allowance_pull', apiName: 'allowance_pull', arguments: { mint, amountRaw } }], agentId, network: 'devnet' });
+
+ beforeEach(() => checkAgentAllowanceSpend.mockReset());
+
+ it('blocks a pull above the remaining allowance', async () => {
+ checkAgentAllowanceSpend.mockResolvedValue({ gated: true, allow: false, code: 'allowance_exceeded', reason: 'requested 80 exceeds the remaining on-chain allowance of 60', detail: { remaining: '60', requested: '80' }, allowance: { id: 'a1' }, live: { remaining: '60' } });
+ const res = mkRes();
+ await guardHandler(mkReq({ body: pull('80') }), res);
+ const { verdicts } = parse(res);
+ expect(checkAgentAllowanceSpend).toHaveBeenCalledWith({ agentId, network: 'devnet', mint, amount: '80' });
+ expect(verdicts[0].verdict.decision).toBe('block');
+ expect(verdicts[0].verdict.blockedBy).toBe('onchain_allowance');
+ expect(verdicts[0].allowance).toMatchObject({ allow: false, code: 'allowance_exceeded', remaining: '60' });
+ });
+
+ it('leaves a pull within the allowance to the other layers', async () => {
+ checkAgentAllowanceSpend.mockResolvedValue({ gated: true, allow: true, code: 'ok', reason: 'within the on-chain allowance', allowance: { id: 'a1' }, live: { remaining: '60' } });
+ const res = mkRes();
+ await guardHandler(mkReq({ body: pull('40') }), res);
+ const { verdicts } = parse(res);
+ expect(verdicts[0].verdict.blockedBy).not.toBe('onchain_allowance');
+ expect(verdicts[0].allowance).toMatchObject({ allow: true, code: 'ok' });
+ });
+
+ it('reports a blind spot instead of failing when the chain is unreadable', async () => {
+ checkAgentAllowanceSpend.mockImplementation(async () => { throw new Error('rpc down'); });
+ const res = mkRes();
+ await guardHandler(mkReq({ body: pull('1') }), res);
+ expect(res.statusCode).toBe(200);
+ expect(JSON.stringify(parse(res).verdicts[0].verdict.blindSpots)).toContain('onchain allowance unreadable');
+ });
+
+ it('never consults the allowance for other tools', async () => {
+ const res = mkRes();
+ await guardHandler(mkReq({ body: { calls: [{ identifier: 'solana_transfer', valueUsd: 5 }], agentId } }), res);
+ expect(checkAgentAllowanceSpend).not.toHaveBeenCalled();
+ });
+});
diff --git a/tests/skill-candidates.test.js b/tests/skill-candidates.test.js
index ffb27f818..79b4f77a6 100644
--- a/tests/skill-candidates.test.js
+++ b/tests/skill-candidates.test.js
@@ -11,6 +11,8 @@ const holder = vi.hoisted(() => ({ db: null }));
vi.mock('../api/_lib/db.js', async (importActual) => {
const actual = await importActual();
+ // Modules build sql fragments at import time, before beforeEach runs.
+ holder.db = createPgliteSql();
return { ...actual, sql: (...args) => holder.db.sql(...args) };
});
vi.mock('../api/_lib/agent-learning/settings.js', () => ({