-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
53 lines (44 loc) · 1.68 KB
/
__init__.py
File metadata and controls
53 lines (44 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""nwc plugin for Hermes Agent — Nostr Wallet Connect (NIP-47).
Vendors both the ``nostrwalletconnect`` and ``nostrkey`` libraries
(NWC depends on nostrkey for crypto + signing). Adds the plugin
directory to ``sys.path`` so the bundled packages' internal absolute
imports resolve.
All tools are async — registered with ``is_async=True`` so the
dispatcher bridges them via ``_run_async()``.
"""
from __future__ import annotations
import sys
from pathlib import Path
_HERE = Path(__file__).resolve().parent
if str(_HERE) not in sys.path:
sys.path.insert(0, str(_HERE))
from .tools import ( # noqa: E402
NWC_BALANCE_SCHEMA,
NWC_GET_INFO_SCHEMA,
NWC_LIST_TRANSACTIONS_SCHEMA,
NWC_MAKE_INVOICE_SCHEMA,
NWC_PAY_INVOICE_SCHEMA,
handle_nwc_balance,
handle_nwc_get_info,
handle_nwc_list_transactions,
handle_nwc_make_invoice,
handle_nwc_pay_invoice,
)
_TOOLS = (
("nwc_get_info", NWC_GET_INFO_SCHEMA, handle_nwc_get_info, "ℹ️"),
("nwc_balance", NWC_BALANCE_SCHEMA, handle_nwc_balance, "⚡"),
("nwc_pay_invoice", NWC_PAY_INVOICE_SCHEMA, handle_nwc_pay_invoice, "💸"),
("nwc_make_invoice", NWC_MAKE_INVOICE_SCHEMA, handle_nwc_make_invoice, "🧾"),
("nwc_list_transactions", NWC_LIST_TRANSACTIONS_SCHEMA, handle_nwc_list_transactions, "📜"),
)
def register(ctx) -> None:
for name, schema, handler, emoji in _TOOLS:
ctx.register_tool(
name=name,
toolset="nwc",
schema=schema,
handler=handler,
is_async=True,
requires_env=["NWC_URI"],
emoji=emoji,
)