@agentxv2/sdk 0.3.0
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 +195 -0
- package/dist/a2a/a2a.d.ts +37 -0
- package/dist/a2a/a2a.d.ts.map +1 -0
- package/dist/a2a/a2a.js +252 -0
- package/dist/a2a/a2a.js.map +1 -0
- package/dist/a2a/index.d.ts +4 -0
- package/dist/a2a/index.d.ts.map +1 -0
- package/dist/a2a/index.js +4 -0
- package/dist/a2a/index.js.map +1 -0
- package/dist/agent/agent-runner.d.ts +124 -0
- package/dist/agent/agent-runner.d.ts.map +1 -0
- package/dist/agent/agent-runner.js +249 -0
- package/dist/agent/agent-runner.js.map +1 -0
- package/dist/agent/index.d.ts +3 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +3 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/config/config.d.ts +31 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +95 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +4 -0
- package/dist/config/index.js.map +1 -0
- package/dist/core/crypto.d.ts +62 -0
- package/dist/core/crypto.d.ts.map +1 -0
- package/dist/core/crypto.js +291 -0
- package/dist/core/crypto.js.map +1 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +4 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/types.d.ts +296 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +30 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/connector.d.ts +43 -0
- package/dist/mcp/connector.d.ts.map +1 -0
- package/dist/mcp/connector.js +79 -0
- package/dist/mcp/connector.js.map +1 -0
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +4 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +3 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/useAgentRunner.d.ts +16 -0
- package/dist/react/useAgentRunner.d.ts.map +1 -0
- package/dist/react/useAgentRunner.js +204 -0
- package/dist/react/useAgentRunner.js.map +1 -0
- package/dist/registry/agent-registry.d.ts +52 -0
- package/dist/registry/agent-registry.d.ts.map +1 -0
- package/dist/registry/agent-registry.js +221 -0
- package/dist/registry/agent-registry.js.map +1 -0
- package/dist/registry/index.d.ts +7 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +6 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/ipfs-fetcher.d.ts +39 -0
- package/dist/registry/ipfs-fetcher.d.ts.map +1 -0
- package/dist/registry/ipfs-fetcher.js +139 -0
- package/dist/registry/ipfs-fetcher.js.map +1 -0
- package/dist/reputation/index.d.ts +4 -0
- package/dist/reputation/index.d.ts.map +1 -0
- package/dist/reputation/index.js +4 -0
- package/dist/reputation/index.js.map +1 -0
- package/dist/reputation/reputation.d.ts +26 -0
- package/dist/reputation/reputation.d.ts.map +1 -0
- package/dist/reputation/reputation.js +113 -0
- package/dist/reputation/reputation.js.map +1 -0
- package/dist/subscription/agent-x402.d.ts +33 -0
- package/dist/subscription/agent-x402.d.ts.map +1 -0
- package/dist/subscription/agent-x402.js +144 -0
- package/dist/subscription/agent-x402.js.map +1 -0
- package/dist/subscription/index.d.ts +6 -0
- package/dist/subscription/index.d.ts.map +1 -0
- package/dist/subscription/index.js +5 -0
- package/dist/subscription/index.js.map +1 -0
- package/dist/subscription/subscription.d.ts +67 -0
- package/dist/subscription/subscription.d.ts.map +1 -0
- package/dist/subscription/subscription.js +346 -0
- package/dist/subscription/subscription.js.map +1 -0
- package/package.json +69 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './core';
|
|
2
|
+
export * from './agent';
|
|
3
|
+
export * from './registry';
|
|
4
|
+
export * from './subscription';
|
|
5
|
+
export * from './a2a';
|
|
6
|
+
export * from './mcp';
|
|
7
|
+
export * from './reputation';
|
|
8
|
+
export * from './config';
|
|
9
|
+
export * from './react';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,OAAO,CAAA;AACrB,cAAc,OAAO,CAAA;AACrB,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// agentx-protocol — Main Entry
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// AgentX: Decentralized AI Agent Platform SDK
|
|
5
|
+
//
|
|
6
|
+
// Agent = Prompt + Skills[] + MCP
|
|
7
|
+
//
|
|
8
|
+
// Quick start:
|
|
9
|
+
// import { AgentRunner } from 'agentx-protocol'
|
|
10
|
+
//
|
|
11
|
+
// const runner = new AgentRunner({ reader, wallet })
|
|
12
|
+
// const ctx = await runner.useAgent(42)
|
|
13
|
+
// // ctx.prompt → inject as LLM system prompt
|
|
14
|
+
// // ctx.skills → inject as LLM tools
|
|
15
|
+
//
|
|
16
|
+
// Modules:
|
|
17
|
+
// agentx-protocol/core — Types, AES-256-GCM + ECIES crypto
|
|
18
|
+
// agentx-protocol/registry — Agent registration & discovery
|
|
19
|
+
// agentx-protocol/subscription — Subscription purchase + AgentX402 gate
|
|
20
|
+
// agentx-protocol/a2a — Agent-to-Agent protocol
|
|
21
|
+
// agentx-protocol/react — React hooks (useAgent, etc.)
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
export * from './core';
|
|
24
|
+
export * from './agent';
|
|
25
|
+
export * from './registry';
|
|
26
|
+
export * from './subscription';
|
|
27
|
+
export * from './a2a';
|
|
28
|
+
export * from './mcp';
|
|
29
|
+
export * from './reputation';
|
|
30
|
+
export * from './config';
|
|
31
|
+
export * from './react';
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,+BAA+B;AAC/B,8EAA8E;AAC9E,8CAA8C;AAC9C,EAAE;AACF,oCAAoC;AACpC,EAAE;AACF,eAAe;AACf,kDAAkD;AAClD,EAAE;AACF,uDAAuD;AACvD,0CAA0C;AAC1C,gDAAgD;AAChD,wCAAwC;AACxC,EAAE;AACF,WAAW;AACX,qEAAqE;AACrE,kEAAkE;AAClE,2EAA2E;AAC3E,2DAA2D;AAC3D,gEAAgE;AAChE,8EAA8E;AAE9E,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,OAAO,CAAA;AACrB,cAAc,OAAO,CAAA;AACrB,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { McpConnection } from '../core/types';
|
|
2
|
+
export interface MCPTool {
|
|
3
|
+
name: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
inputSchema: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export interface MCPCallResult {
|
|
8
|
+
content: {
|
|
9
|
+
type: string;
|
|
10
|
+
text?: string;
|
|
11
|
+
data?: string;
|
|
12
|
+
}[];
|
|
13
|
+
isError?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface MCPConnectorConfig {
|
|
16
|
+
/** MCP server base URL */
|
|
17
|
+
url: string;
|
|
18
|
+
/** Transport type */
|
|
19
|
+
transport?: 'http' | 'sse';
|
|
20
|
+
/** Auth header value (e.g. "Bearer xxx") */
|
|
21
|
+
authHeader?: string;
|
|
22
|
+
/** Request timeout in ms (default: 30_000) */
|
|
23
|
+
timeoutMs?: number;
|
|
24
|
+
/** Optional: subscriber address for subscription-gated MCP servers */
|
|
25
|
+
subscriberAddress?: string;
|
|
26
|
+
/** Optional: wallet signature for authentication */
|
|
27
|
+
signature?: string;
|
|
28
|
+
timestamp?: number;
|
|
29
|
+
}
|
|
30
|
+
export declare class MCPConnector {
|
|
31
|
+
private config;
|
|
32
|
+
constructor(config: MCPConnectorConfig);
|
|
33
|
+
/** Create from an Agent's McpConnection. */
|
|
34
|
+
static fromAgent(mcp: McpConnection, opts?: Partial<MCPConnectorConfig>): MCPConnector;
|
|
35
|
+
/** List available tools from the MCP server. */
|
|
36
|
+
listTools(): Promise<MCPTool[]>;
|
|
37
|
+
/** Call a tool on the MCP server. */
|
|
38
|
+
callTool(name: string, args?: Record<string, unknown>): Promise<MCPCallResult>;
|
|
39
|
+
listResources(): Promise<unknown[]>;
|
|
40
|
+
readResource(uri: string): Promise<unknown>;
|
|
41
|
+
private _request;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=connector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../src/mcp/connector.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAIlD,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAA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k — MCP Connector
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Minimal MCP (Model Context Protocol) client for HTTP/SSE transports.
|
|
5
|
+
// Used by AgentRunner for Closed Skill remote execution.
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// ── MCP Connector ──────────────────────────────────────────────────────────
|
|
8
|
+
export class MCPConnector {
|
|
9
|
+
config;
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.config = { timeoutMs: 30_000, transport: 'http', ...config };
|
|
12
|
+
}
|
|
13
|
+
/** Create from an Agent's McpConnection. */
|
|
14
|
+
static fromAgent(mcp, opts) {
|
|
15
|
+
return new MCPConnector({
|
|
16
|
+
url: mcp.url ?? '',
|
|
17
|
+
transport: mcp.type === 'sse' ? 'sse' : 'http',
|
|
18
|
+
authHeader: mcp.authHeader,
|
|
19
|
+
...opts,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
// ── Tool Discovery ───────────────────────────────────────────────────────
|
|
23
|
+
/** List available tools from the MCP server. */
|
|
24
|
+
async listTools() {
|
|
25
|
+
const res = await this._request('tools/list', {});
|
|
26
|
+
return (res.tools ?? []);
|
|
27
|
+
}
|
|
28
|
+
// ── Tool Execution ───────────────────────────────────────────────────────
|
|
29
|
+
/** Call a tool on the MCP server. */
|
|
30
|
+
async callTool(name, args = {}) {
|
|
31
|
+
return this._request('tools/call', { name, arguments: args });
|
|
32
|
+
}
|
|
33
|
+
// ── Resources (optional) ─────────────────────────────────────────────────
|
|
34
|
+
async listResources() {
|
|
35
|
+
const res = await this._request('resources/list', {});
|
|
36
|
+
return (res.resources ?? []);
|
|
37
|
+
}
|
|
38
|
+
async readResource(uri) {
|
|
39
|
+
return this._request('resources/read', { uri });
|
|
40
|
+
}
|
|
41
|
+
// ── Internal ─────────────────────────────────────────────────────────────
|
|
42
|
+
async _request(method, params) {
|
|
43
|
+
const headers = {
|
|
44
|
+
'Content-Type': 'application/json',
|
|
45
|
+
};
|
|
46
|
+
if (this.config.authHeader) {
|
|
47
|
+
headers['Authorization'] = this.config.authHeader;
|
|
48
|
+
}
|
|
49
|
+
if (this.config.subscriberAddress) {
|
|
50
|
+
headers['X-Subscriber-Address'] = this.config.subscriberAddress;
|
|
51
|
+
}
|
|
52
|
+
if (this.config.signature) {
|
|
53
|
+
headers['X-Signature'] = this.config.signature;
|
|
54
|
+
}
|
|
55
|
+
if (this.config.timestamp) {
|
|
56
|
+
headers['X-Timestamp'] = String(this.config.timestamp);
|
|
57
|
+
}
|
|
58
|
+
const res = await fetch(this.config.url, {
|
|
59
|
+
method: 'POST',
|
|
60
|
+
headers,
|
|
61
|
+
body: JSON.stringify({
|
|
62
|
+
jsonrpc: '2.0',
|
|
63
|
+
id: Date.now(),
|
|
64
|
+
method,
|
|
65
|
+
params,
|
|
66
|
+
}),
|
|
67
|
+
signal: AbortSignal.timeout(this.config.timeoutMs ?? 30_000),
|
|
68
|
+
});
|
|
69
|
+
if (!res.ok) {
|
|
70
|
+
throw new Error(`MCP request failed: HTTP ${res.status}`);
|
|
71
|
+
}
|
|
72
|
+
const data = await res.json();
|
|
73
|
+
if (data.error) {
|
|
74
|
+
throw new Error(`MCP error: ${data.error.message}`);
|
|
75
|
+
}
|
|
76
|
+
return data.result ?? {};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=connector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.js","sourceRoot":"","sources":["../../src/mcp/connector.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,8BAA8B;AAC9B,8EAA8E;AAC9E,uEAAuE;AACvE,yDAAyD;AACzD,8EAA8E;AAiC9E,8EAA8E;AAE9E,MAAM,OAAO,YAAY;IACf,MAAM,CAAoB;IAElC,YAAY,MAA0B;QACpC,IAAI,CAAC,MAAM,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAA;IACnE,CAAC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,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,IAAI,EAAE,CAAA;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,YAAY,EAAE,kBAAkB,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC7E,eAAO,MAAM,WAAW,UAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { useAgentRunner } from './useAgentRunner';
|
|
2
|
+
export type { UseAgentRunnerConfig, UseAgentRunnerResult } from './useAgentRunner';
|
|
3
|
+
export type { AgentRunContext, RunnableSkill, OnChainReader, WalletSigner } from '../agent/agent-runner';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAClF,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AgentRunContext } from '../agent/agent-runner';
|
|
2
|
+
import type { ChainConfig } from '../config/config';
|
|
3
|
+
export interface UseAgentRunnerConfig {
|
|
4
|
+
agentId: number;
|
|
5
|
+
chainConfig?: ChainConfig;
|
|
6
|
+
ipfsGateways?: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface UseAgentRunnerResult {
|
|
9
|
+
ctx: AgentRunContext | null;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
error: Error | null;
|
|
12
|
+
/** Re-trigger the load (e.g. after connecting wallet or subscribing) */
|
|
13
|
+
refetch: () => void;
|
|
14
|
+
}
|
|
15
|
+
export declare function useAgentRunner(config: UseAgentRunnerConfig): UseAgentRunnerResult;
|
|
16
|
+
//# sourceMappingURL=useAgentRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAgentRunner.d.ts","sourceRoot":"","sources":["../../src/react/useAgentRunner.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,uBAAuB,CAAA;AAG3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAyCnD,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,eAAe,GAAG,IAAI,CAAA;IAC3B,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;IACnB,wEAAwE;IACxE,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB;AA0ED,wBAAgB,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,CAoGjF"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// @agentx/sdk — useAgentRunner React Hook
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Wraps AgentRunner.useAgent() for React + wagmi integration.
|
|
5
|
+
//
|
|
6
|
+
// const { ctx, isLoading, error } = useAgentRunner(agentId)
|
|
7
|
+
// // ctx.prompt → inject into LLM
|
|
8
|
+
// // ctx.skills → RunnableSkill[] with execute()
|
|
9
|
+
// // ctx.mcp → MCP connection info
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
'use client';
|
|
12
|
+
import { useState, useEffect, useRef } from 'react';
|
|
13
|
+
import { usePublicClient, useWalletClient } from 'wagmi';
|
|
14
|
+
import { AgentRunner } from '../agent/agent-runner';
|
|
15
|
+
import { IPFSFetcher } from '../registry/ipfs-fetcher';
|
|
16
|
+
import { KNOWN_CHAINS } from '../config/config';
|
|
17
|
+
// ── IdentityRegistry ABI (minimal — only what useAgent needs) ──────────────
|
|
18
|
+
const IDENTITY_REGISTRY_ABI = [
|
|
19
|
+
// getAgentMetadata returns MetadataEntry[] with key+value strings
|
|
20
|
+
{
|
|
21
|
+
name: 'getAgentMetadata',
|
|
22
|
+
type: 'function',
|
|
23
|
+
stateMutability: 'view',
|
|
24
|
+
inputs: [{ name: 'agentId', type: 'uint256' }],
|
|
25
|
+
outputs: [
|
|
26
|
+
{
|
|
27
|
+
name: '',
|
|
28
|
+
type: 'tuple[]',
|
|
29
|
+
components: [
|
|
30
|
+
{ name: 'key', type: 'string' },
|
|
31
|
+
{ name: 'value', type: 'bytes' },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
// ── SubscriptionManager ABI (minimal) ─────────────────────────────────────
|
|
38
|
+
const SUBSCRIPTION_MANAGER_ABI = [
|
|
39
|
+
{
|
|
40
|
+
name: 'hasActiveSubscription',
|
|
41
|
+
type: 'function',
|
|
42
|
+
stateMutability: 'view',
|
|
43
|
+
inputs: [
|
|
44
|
+
{ name: 'subscriber', type: 'address' },
|
|
45
|
+
{ name: 'agentId', type: 'uint256' },
|
|
46
|
+
],
|
|
47
|
+
outputs: [{ name: '', type: 'bool' }],
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
// ── OnChainReader Implementation (viem) ────────────────────────────────────
|
|
51
|
+
class ViemOnChainReader {
|
|
52
|
+
publicClient;
|
|
53
|
+
chainConfig;
|
|
54
|
+
constructor(publicClient, chainConfig) {
|
|
55
|
+
this.publicClient = publicClient;
|
|
56
|
+
this.chainConfig = chainConfig;
|
|
57
|
+
}
|
|
58
|
+
async getTokenURI(_agentId) {
|
|
59
|
+
// tokenURI is standard ERC-721 metadata — not needed for our flow
|
|
60
|
+
// Metadata is fetched via getAgentMetadata
|
|
61
|
+
return '';
|
|
62
|
+
}
|
|
63
|
+
async getAttributes(agentId) {
|
|
64
|
+
if (!this.publicClient)
|
|
65
|
+
throw new Error('Public client not available');
|
|
66
|
+
const entries = (await this.publicClient.readContract({
|
|
67
|
+
address: this.chainConfig.contracts.identityRegistry,
|
|
68
|
+
abi: IDENTITY_REGISTRY_ABI,
|
|
69
|
+
functionName: 'getAgentMetadata',
|
|
70
|
+
args: [BigInt(agentId)],
|
|
71
|
+
}));
|
|
72
|
+
const attrs = {};
|
|
73
|
+
for (const entry of entries) {
|
|
74
|
+
// value is bytes — convert to string
|
|
75
|
+
const hexStr = entry.value;
|
|
76
|
+
if (hexStr && hexStr !== '0x') {
|
|
77
|
+
attrs[entry.key] = hexToStringUTF8(hexStr);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
attrs[entry.key] = '';
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return attrs;
|
|
84
|
+
}
|
|
85
|
+
async hasActiveSubscription(address, agentId) {
|
|
86
|
+
if (!this.publicClient)
|
|
87
|
+
return false;
|
|
88
|
+
try {
|
|
89
|
+
return (await this.publicClient.readContract({
|
|
90
|
+
address: this.chainConfig.contracts.subscriptionManager,
|
|
91
|
+
abi: SUBSCRIPTION_MANAGER_ABI,
|
|
92
|
+
functionName: 'hasActiveSubscription',
|
|
93
|
+
args: [address, BigInt(agentId)],
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// ── Helpers ────────────────────────────────────────────────────────────────
|
|
102
|
+
function hexToStringUTF8(hex) {
|
|
103
|
+
if (!hex.startsWith('0x'))
|
|
104
|
+
return hex;
|
|
105
|
+
const hexClean = hex.slice(2);
|
|
106
|
+
if (hexClean.length === 0)
|
|
107
|
+
return '';
|
|
108
|
+
try {
|
|
109
|
+
const bytes = new Uint8Array(hexClean.length / 2);
|
|
110
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
111
|
+
bytes[i] = parseInt(hexClean.substring(i * 2, i * 2 + 2), 16);
|
|
112
|
+
}
|
|
113
|
+
return new TextDecoder().decode(bytes);
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return hex;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// ── Hook ───────────────────────────────────────────────────────────────────
|
|
120
|
+
export function useAgentRunner(config) {
|
|
121
|
+
const { agentId, chainConfig: chainConfigOverride, ipfsGateways } = config;
|
|
122
|
+
const publicClient = usePublicClient();
|
|
123
|
+
const { data: walletClient } = useWalletClient();
|
|
124
|
+
const [ctx, setCtx] = useState(null);
|
|
125
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
126
|
+
const [error, setError] = useState(null);
|
|
127
|
+
const [refetchKey, setRefetchKey] = useState(0);
|
|
128
|
+
const runnerRef = useRef(null);
|
|
129
|
+
const mountedRef = useRef(true);
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
mountedRef.current = true;
|
|
132
|
+
return () => {
|
|
133
|
+
mountedRef.current = false;
|
|
134
|
+
};
|
|
135
|
+
}, []);
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
if (!publicClient || !walletClient) {
|
|
138
|
+
setError(new Error('Wallet not connected'));
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const chainConfig = chainConfigOverride ?? (publicClient.chain?.id ? KNOWN_CHAINS[publicClient.chain.id] : undefined);
|
|
142
|
+
if (!chainConfig) {
|
|
143
|
+
setError(new Error(`Chain ${publicClient.chain?.id} not supported`));
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
// Create OnChainReader
|
|
147
|
+
const reader = new ViemOnChainReader(publicClient, chainConfig);
|
|
148
|
+
// WalletSigner from wagmi
|
|
149
|
+
const signer = {
|
|
150
|
+
async signMessage(message) {
|
|
151
|
+
if (!walletClient.account)
|
|
152
|
+
throw new Error('Wallet not connected');
|
|
153
|
+
return walletClient.signMessage({ account: walletClient.account, message });
|
|
154
|
+
},
|
|
155
|
+
async getAddress() {
|
|
156
|
+
if (!walletClient.account)
|
|
157
|
+
throw new Error('Wallet not connected');
|
|
158
|
+
return walletClient.account.address;
|
|
159
|
+
},
|
|
160
|
+
async getPrivateKey() {
|
|
161
|
+
// wagmi walletClient doesn't expose private key
|
|
162
|
+
// ECIES decryption requires private key — must be injected from wallet provider
|
|
163
|
+
throw new Error('Private key not available via wagmi. ' +
|
|
164
|
+
'Use window.ethereum.request({ method: "eth_private_key" }) or inject getPrivateKey via custom WalletSigner.');
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
// IPFS Fetcher
|
|
168
|
+
const ipfsFetcher = new IPFSFetcher({
|
|
169
|
+
fallbackGateways: ipfsGateways ?? chainConfig.ipfsGateways ?? [
|
|
170
|
+
'gateway.pinata.cloud',
|
|
171
|
+
'dweb.link',
|
|
172
|
+
'cf-ipfs.com',
|
|
173
|
+
],
|
|
174
|
+
});
|
|
175
|
+
runnerRef.current = new AgentRunner({
|
|
176
|
+
reader,
|
|
177
|
+
wallet: signer,
|
|
178
|
+
ipfsFetcher,
|
|
179
|
+
});
|
|
180
|
+
setIsLoading(true);
|
|
181
|
+
setError(null);
|
|
182
|
+
runnerRef.current
|
|
183
|
+
.useAgent(agentId)
|
|
184
|
+
.then(result => {
|
|
185
|
+
if (mountedRef.current) {
|
|
186
|
+
setCtx(result);
|
|
187
|
+
setIsLoading(false);
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
.catch(err => {
|
|
191
|
+
if (mountedRef.current) {
|
|
192
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
193
|
+
setIsLoading(false);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
return () => {
|
|
197
|
+
mountedRef.current = false;
|
|
198
|
+
};
|
|
199
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
200
|
+
}, [agentId, publicClient?.chain?.id, publicClient, walletClient, refetchKey]);
|
|
201
|
+
const refetch = () => setRefetchKey(k => k + 1);
|
|
202
|
+
return { ctx, isLoading, error, refetch };
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=useAgentRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAgentRunner.js","sourceRoot":"","sources":["../../src/react/useAgentRunner.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,0CAA0C;AAC1C,8EAA8E;AAC9E,8DAA8D;AAC9D,EAAE;AACF,8DAA8D;AAC9D,oCAAoC;AACpC,mDAAmD;AACnD,wCAAwC;AACxC,8EAA8E;AAE9E,YAAY,CAAA;AAEZ,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAG/C,8EAA8E;AAE9E,MAAM,qBAAqB,GAAG;IAC5B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D,uDAAuD;IACzD,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC,CAAA;IAE9E,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IAE/C,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;AAC3C,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { PublicClient, WalletClient, Address, Hash } from 'viem';
|
|
2
|
+
export interface AgentRegistryConfig {
|
|
3
|
+
/** IdentityRegistry contract address */
|
|
4
|
+
contractAddress: Address;
|
|
5
|
+
/** viem PublicClient for read calls */
|
|
6
|
+
publicClient: PublicClient;
|
|
7
|
+
/** viem WalletClient for write calls */
|
|
8
|
+
walletClient: WalletClient;
|
|
9
|
+
}
|
|
10
|
+
export declare class AgentRegistry {
|
|
11
|
+
private address;
|
|
12
|
+
private publicClient;
|
|
13
|
+
private walletClient;
|
|
14
|
+
constructor(config: AgentRegistryConfig);
|
|
15
|
+
/**
|
|
16
|
+
* Register a new Agent NFT on-chain.
|
|
17
|
+
*
|
|
18
|
+
* @param tokenURI IPFS URI of the public metadata (ipfs://...)
|
|
19
|
+
* @param metadata Key-value metadata (encryptedPayloadCid, eciesEncryptedKey, etc.)
|
|
20
|
+
* @param valueWei Optional: native currency to send with registration
|
|
21
|
+
* @returns { agentId: number, txHash: Hash }
|
|
22
|
+
*/
|
|
23
|
+
register(tokenURI: string, metadata: {
|
|
24
|
+
key: string;
|
|
25
|
+
value: string;
|
|
26
|
+
}[], valueWei?: bigint): Promise<{
|
|
27
|
+
agentId: number;
|
|
28
|
+
txHash: Hash;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Simple register — just a tokenURI, no extra metadata.
|
|
32
|
+
*/
|
|
33
|
+
registerSimple(tokenURI: string, valueWei?: bigint): Promise<{
|
|
34
|
+
agentId: number;
|
|
35
|
+
txHash: Hash;
|
|
36
|
+
}>;
|
|
37
|
+
/** Get all agent IDs owned by an address. */
|
|
38
|
+
getAgentsByOwner(owner: Address): Promise<number[]>;
|
|
39
|
+
/** Get the current total agent count. */
|
|
40
|
+
getCurrentAgentId(): Promise<number>;
|
|
41
|
+
/** Check if an agent exists. */
|
|
42
|
+
agentExists(agentId: number): Promise<boolean>;
|
|
43
|
+
/** Get the tokenURI for an agent. */
|
|
44
|
+
tokenURI(agentId: number): Promise<string>;
|
|
45
|
+
/** Get all metadata attributes for an agent as key-value pairs. */
|
|
46
|
+
getAttributes(agentId: number): Promise<Record<string, string>>;
|
|
47
|
+
/** Extract tokenId from the Transfer event in the receipt. */
|
|
48
|
+
private _parseAgentIdFromReceipt;
|
|
49
|
+
}
|
|
50
|
+
/** Extract IPFS CID from an ipfs:// URI. */
|
|
51
|
+
export declare function cidFromURI(uri: string): string;
|
|
52
|
+
//# sourceMappingURL=agent-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-registry.d.ts","sourceRoot":"","sources":["../../src/registry/agent-registry.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AA8ErE,MAAM,WAAW,mBAAmB;IAClC,wCAAwC;IACxC,eAAe,EAAE,OAAO,CAAA;IACxB,uCAAuC;IACvC,YAAY,EAAE,YAAY,CAAA;IAC1B,wCAAwC;IACxC,YAAY,EAAE,YAAY,CAAA;CAC3B;AAID,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,YAAY,CAAc;gBAEtB,MAAM,EAAE,mBAAmB;IAQvC;;;;;;;OAOG;IACG,QAAQ,CACZ,QAAQ,EAAE,MAAM,E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