@fiber-pay/agent 0.1.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,145 @@
1
+ # @fiber-pay/agent
2
+
3
+ AI-agent orchestration layer for Fiber Network (targeting Fiber `v0.6.1`).
4
+
5
+ This package provides:
6
+
7
+ - `FiberPay`: high-level, agent-friendly API on top of `@fiber-pay/sdk` + `@fiber-pay/node`
8
+ - `MCP_TOOLS`: MCP tool schema definitions for model/tool integration
9
+
10
+ ## What this package is (and is not)
11
+
12
+ `@fiber-pay/agent` is an orchestration layer, not a separate protocol implementation.
13
+ It composes existing SDK and node lifecycle capabilities into one API designed for autonomous agents.
14
+
15
+ It currently exports MCP tool **definitions/schemas**; host-side tool execution wiring is still your responsibility.
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ pnpm add @fiber-pay/agent
21
+ ```
22
+
23
+ ## Quick start
24
+
25
+ ```ts
26
+ import { createFiberPay } from '@fiber-pay/agent';
27
+
28
+ const fiber = createFiberPay({
29
+ dataDir: `${process.env.HOME}/.fiber-pay`,
30
+ network: 'testnet',
31
+ });
32
+
33
+ const init = await fiber.initialize();
34
+ if (!init.success) throw new Error(init.error?.message ?? 'init failed');
35
+
36
+ const balance = await fiber.getBalance();
37
+ console.log(balance.data);
38
+
39
+ await fiber.shutdown();
40
+ ```
41
+
42
+ ## Runtime job orchestration
43
+
44
+ By default, `FiberPay` enables runtime-backed job orchestration for:
45
+
46
+ - `pay()`
47
+ - `createInvoice()`
48
+ - `createHoldInvoice()`
49
+ - `settleInvoice()`
50
+ - `openChannel()`
51
+ - `closeChannel()`
52
+
53
+ This uses an internal SQLite job store and waits for terminal job states before returning.
54
+
55
+ Config knobs:
56
+
57
+ - `useRuntimeJobs` (default: `true`)
58
+ - `runtimeJobsDbPath` (default: `${dataDir}/runtime-jobs.db`)
59
+
60
+ Disable orchestration to force direct RPC calls:
61
+
62
+ ```ts
63
+ const fiber = createFiberPay({
64
+ dataDir: `${process.env.HOME}/.fiber-pay`,
65
+ useRuntimeJobs: false,
66
+ });
67
+ ```
68
+
69
+ ## API surface summary
70
+
71
+ ### Lifecycle
72
+
73
+ - `initialize()`
74
+ - `shutdown()`
75
+
76
+ ### Payments and invoices
77
+
78
+ - `pay()`
79
+ - `createInvoice()`
80
+ - `getPaymentStatus()`
81
+ - `getInvoiceStatus()`
82
+ - `createHoldInvoice()`
83
+ - `settleInvoice()`
84
+ - `waitForPayment()`
85
+
86
+ ### Channels and node state
87
+
88
+ - `listChannels()`
89
+ - `openChannel()`
90
+ - `closeChannel()`
91
+ - `waitForChannelReady()`
92
+ - `getNodeInfo()`
93
+ - `getBalance()`
94
+
95
+ ### Safety, verification, and observability
96
+
97
+ - `validateInvoice()`
98
+ - `analyzeLiquidity()`
99
+ - `canSend()`
100
+ - `getPaymentProof()`
101
+ - `getPaymentProofSummary()`
102
+ - `getPaymentAuditReport()`
103
+ - `getSpendingAllowance()`
104
+ - `getAuditLog()`
105
+
106
+ All async operations return `AgentResult<T>`:
107
+
108
+ ```ts
109
+ type AgentResult<T> = {
110
+ success: boolean;
111
+ data?: T;
112
+ error?: {
113
+ code: string;
114
+ message: string;
115
+ recoverable: boolean;
116
+ suggestion?: string;
117
+ };
118
+ metadata?: {
119
+ timestamp: number;
120
+ };
121
+ };
122
+ ```
123
+
124
+ ## MCP integration
125
+
126
+ ```ts
127
+ import { MCP_TOOLS } from '@fiber-pay/agent/mcp';
128
+
129
+ for (const tool of Object.values(MCP_TOOLS)) {
130
+ // register with your MCP host runtime
131
+ // mcpServer.registerTool(tool)
132
+ }
133
+ ```
134
+
135
+ See `src/mcp-tools.ts` for complete tool names and JSON schemas.
136
+
137
+ ## Compatibility
138
+
139
+ - Node.js: `>=20`
140
+ - Fiber RPC semantics: aligned with Fiber `v0.6.1`
141
+
142
+ ## Known gaps
143
+
144
+ - No dedicated `@fiber-pay/agent` test suite yet
145
+ - MCP runtime execution adapter is not bundled in this package
@@ -0,0 +1,3 @@
1
+ export { A as AgentResult, B as BalanceInfo, C as ChannelSummary, F as FiberPay, a as FiberPayConfig, H as HoldInvoiceResult, I as InvoiceResult, MCP_TOOLS, McpToolInput, McpToolName, McpToolResult, P as PaymentResult, c as createFiberPay } from './mcp-tools.js';
2
+ import '@fiber-pay/sdk';
3
+ import '@fiber-pay/node';