@7ots/cli 0.1.19 → 0.1.37
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/.env.example +14 -0
- package/brand/logos/base.svg +1 -0
- package/brand/logos/clawpump.png +0 -0
- package/brand/logos/conductors.svg +1 -0
- package/brand/logos/notlogin.svg +12 -0
- package/brand/logos/pumpfun.png +0 -0
- package/brand/logos/solana.png +0 -0
- package/brand/logos/spawnerbot.svg +1 -0
- package/brand/logos/virtuals.png +0 -0
- package/cli/7ots.mjs +59 -1
- package/cli/lib/account.mjs +23 -3
- package/cli/lib/assistant.mjs +88 -13
- package/cli/lib/brain.mjs +76 -8
- package/cli/lib/config.mjs +14 -3
- package/cli/lib/desktop-sync.mjs +177 -0
- package/cli/lib/i18n.mjs +9 -0
- package/cli/lib/inferences.mjs +19 -2
- package/cli/lib/integrations.mjs +61 -6
- package/cli/lib/pet-server.mjs +316 -41
- package/cli/lib/prompts.mjs +1 -1
- package/cli/lib/senses/gestures.mjs +121 -0
- package/cli/lib/senses/index.mjs +490 -0
- package/cli/lib/senses/rules.mjs +159 -0
- package/cli/lib/senses/sources/activity.mjs +95 -0
- package/cli/lib/senses/sources/calendar.mjs +75 -0
- package/cli/lib/senses/sources/index.mjs +17 -0
- package/cli/lib/senses/sources/mail.mjs +48 -0
- package/cli/lib/senses/sources/system.mjs +39 -0
- package/cli/lib/senses/util.mjs +41 -0
- package/cli/lib/senses/vendor.mjs +78 -0
- package/cli/lib/stt-local.py +16 -8
- package/cli/lib/stt.mjs +53 -6
- package/cli/lib/tooluse.mjs +56 -0
- package/cli/lib/vm.mjs +1 -1
- package/cli/lib/wake-local.py +109 -0
- package/cli/lib/wake.mjs +102 -0
- package/cli/pet/electron/main.cjs +145 -16
- package/cli/pet/pet.html +127 -27
- package/cli/pet/senses.html +342 -0
- package/cli/pet/settings.html +787 -86
- package/dist/7ots.esm.js +374 -146
- package/dist/7ots.esm.js.map +4 -4
- package/dist/7ots.iife.js +374 -146
- package/dist/7ots.iife.js.map +4 -4
- package/llms.txt +27 -0
- package/package.json +5 -2
- package/server/channels/apuchat.mjs +2 -0
- package/server/errors.mjs +90 -0
- package/server/notify.mjs +78 -0
- package/server/server.mjs +68 -12
- package/server/settings.mjs +3 -0
- package/server/site.mjs +401 -0
- package/server/tts.mjs +29 -5
- package/src/avatar/AvatarStage.js +2 -2
- package/src/avatar/three.js +3 -2
- package/src/character/AvatarEditor.js +2 -1
- package/src/character/Character.js +1 -1
- package/src/character/TradingCard.js +2 -0
- package/src/character/beat.js +64 -2
- package/src/character/mods/orc.js +8 -1
- package/src/character/mods.js +104 -10
- package/src/character/motion.js +162 -0
- package/src/character/parts.js +40 -38
- package/src/character/styles.js +40 -38
- package/src/character3d/Character3D.js +26 -5
- package/src/character3d/body.js +14 -12
- package/src/character3d/export.js +693 -0
- package/src/character3d/fx.js +13 -0
- package/src/character3d/index.js +2 -0
- package/src/character3d/materials.js +106 -10
- package/src/character3d/room-themes.js +1184 -0
- package/src/character3d/room.js +487 -0
- package/src/character3d/stage.js +9 -3
- package/src/creator/StepCreator.js +316 -0
- package/src/i18n/index.js +3 -3
- package/src/i18n/messages/character.js +352 -4
- package/src/i18n/messages/creator.js +138 -0
- package/src/i18n/messages/identity.js +89 -1
- package/src/i18n/messages/platform.js +255 -1
- package/src/i18n/messages/server.js +443 -1
- package/src/i18n/messages/widget.js +233 -0
- package/src/identity/random.js +14 -2
- package/src/identity/schema.js +2 -1
- package/src/index.js +10 -2
- package/src/voice/tags.js +22 -0
- package/server/platform/apuchat.mjs +0 -266
- package/server/platform/auth.mjs +0 -337
- package/server/platform/byte.mjs +0 -291
- package/server/platform/connect.mjs +0 -391
- package/server/platform/crypto.mjs +0 -80
- package/server/platform/db.mjs +0 -293
- package/server/platform/device.mjs +0 -247
- package/server/platform/integrations.mjs +0 -169
- package/server/platform/look.mjs +0 -20
- package/server/platform/mods.mjs +0 -222
- package/server/platform/orquesta.mjs +0 -611
- package/server/platform/profile.mjs +0 -182
- package/server/platform/routes.mjs +0 -589
- package/server/platform/runtime.mjs +0 -286
- package/server/platform/sites.mjs +0 -146
- package/server/platform/stage3d.mjs +0 -82
- package/server/platform/store.mjs +0 -469
- package/server/platform/vm.mjs +0 -1057
- package/server/platform/wallet.mjs +0 -255
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The ot's wallet: a managed subwallet in the owner's Notlogin account (agentId = the ot's id).
|
|
3
|
-
*
|
|
4
|
-
* Money never moves without the owner. The ot can only PROPOSE a payment (tool `request_payment`, owner
|
|
5
|
-
* chat only); the owner approves it in the dashboard's Wallet tab, which turns it into a Notlogin
|
|
6
|
-
* `withdraw` intent that they confirm on notlogin.com with a fresh sign-in. 7ots holds no keys.
|
|
7
|
-
*
|
|
8
|
-
* NOTLOGIN_SERVICE_TOKEN provisions/reads the agent wallets (GET /api/x402/wallet?userId&agentId)
|
|
9
|
-
* account integration 'notlogin' { access, refresh, exp } scopes wallet:read intents:create, from
|
|
10
|
-
* "Connect Notlogin" (/auth/notlogin?link=<otsId>, auth.mjs)
|
|
11
|
-
*
|
|
12
|
-
* Dashboard (connect.mjs-style, mounted from routes.mjs):
|
|
13
|
-
* GET …/ots/:id/wallet addresses, balances, payments
|
|
14
|
-
* POST …/ots/:id/wallet/payments/:pid/approve → { url } of the Notlogin confirm page
|
|
15
|
-
* POST …/ots/:id/wallet/payments/:pid/decline
|
|
16
|
-
* POST …/ots/:id/wallet/payments/:pid/refresh reads the intent's outcome
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import { randomBytes } from 'node:crypto';
|
|
20
|
-
import { reqT } from '../i18n.mjs';
|
|
21
|
-
import { getDb } from './db.mjs';
|
|
22
|
-
import { getIntegration, setIntegration } from './store.mjs';
|
|
23
|
-
|
|
24
|
-
const penv = process.env;
|
|
25
|
-
const notloginUrl = () => (penv.NOTLOGIN_URL || 'https://notlogin.com').replace(/\/+$/, '');
|
|
26
|
-
export const WALLET_SCOPE = 'openid profile email wallet:read intents:create';
|
|
27
|
-
export const walletConfigured = () => !!(penv.NOTLOGIN_CLIENT_ID && penv.NOTLOGIN_SERVICE_TOKEN);
|
|
28
|
-
|
|
29
|
-
const NETWORKS = ['base', 'solana'];
|
|
30
|
-
const ADDR = { base: /^0x[0-9a-fA-F]{40}$/, solana: /^[1-9A-HJ-NP-Za-km-z]{32,44}$/ };
|
|
31
|
-
const MAX_OPEN = 10;
|
|
32
|
-
|
|
33
|
-
// ───────────────────────────── Notlogin tokens ─────────────────────────────
|
|
34
|
-
|
|
35
|
-
/** Saves the tokens from the token endpoint (the link callback or a refresh). */
|
|
36
|
-
export function saveNotloginTokens(accountId, j) {
|
|
37
|
-
if (!j?.access_token) return;
|
|
38
|
-
const prev = getIntegration(accountId, 'notlogin') || {};
|
|
39
|
-
setIntegration(accountId, 'notlogin', {
|
|
40
|
-
access: j.access_token,
|
|
41
|
-
refresh: j.refresh_token || prev.refresh || null,
|
|
42
|
-
exp: Date.now() + (Number(j.expires_in) || 900) * 1000,
|
|
43
|
-
scope: j.scope || prev.scope || '',
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** A valid access token with the wallet scopes, refreshing it when needed. null = connect again. */
|
|
48
|
-
export async function accessToken(accountId) {
|
|
49
|
-
const it = getIntegration(accountId, 'notlogin');
|
|
50
|
-
if (!it) return null;
|
|
51
|
-
if (it.access && it.exp > Date.now() + 30_000) return it.access;
|
|
52
|
-
if (!it.refresh) return null;
|
|
53
|
-
const body = new URLSearchParams({ grant_type: 'refresh_token', refresh_token: it.refresh, client_id: penv.NOTLOGIN_CLIENT_ID });
|
|
54
|
-
if (penv.NOTLOGIN_CLIENT_SECRET) body.set('client_secret', penv.NOTLOGIN_CLIENT_SECRET);
|
|
55
|
-
const r = await fetch(`${notloginUrl()}/api/oauth/token`, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', Accept: 'application/json' }, body, signal: AbortSignal.timeout(10000) }).catch(() => null);
|
|
56
|
-
const j = r ? await r.json().catch(() => ({})) : {};
|
|
57
|
-
if (!r?.ok || !j.access_token) {
|
|
58
|
-
// single-use refresh: a rejected one is gone for good
|
|
59
|
-
if (r && r.status >= 400 && r.status < 500) setIntegration(accountId, 'notlogin', null);
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
saveNotloginTokens(accountId, j);
|
|
63
|
-
return j.access_token;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// ───────────────────────────── Notlogin calls ─────────────────────────────
|
|
67
|
-
|
|
68
|
-
/** The ot's wallets (created on first call) with balances. */
|
|
69
|
-
async function agentWallets(sub, otsId) {
|
|
70
|
-
const q = new URLSearchParams({ userId: sub, agentId: otsId, vendorSlug: penv.NOTLOGIN_CLIENT_ID });
|
|
71
|
-
const r = await fetch(`${notloginUrl()}/api/x402/wallet?${q}`, { headers: { Authorization: `Bearer ${penv.NOTLOGIN_SERVICE_TOKEN}`, Accept: 'application/json' }, signal: AbortSignal.timeout(15000) });
|
|
72
|
-
const j = await r.json().catch(() => ({}));
|
|
73
|
-
if (!r.ok) throw new Error(`notlogin wallet ${r.status}${j.error ? `: ${String(j.error).slice(0, 120)}` : ''}`);
|
|
74
|
-
return (j.wallets || [])
|
|
75
|
-
.filter((w) => w.namespace === 'evm' || w.namespace === 'solana')
|
|
76
|
-
.map((w) => ({ namespace: w.namespace, network: w.network, address: w.address, balances: w.balances || null, balanceError: w.balanceError || null }));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async function intentCall(accountId, path, init = {}) {
|
|
80
|
-
const tok = await accessToken(accountId);
|
|
81
|
-
if (!tok) throw Object.assign(new Error('relink'), { relink: true });
|
|
82
|
-
const r = await fetch(`${notloginUrl()}/api/v1/account/intents${path}`, {
|
|
83
|
-
...init,
|
|
84
|
-
headers: { Authorization: `Bearer ${tok}`, Accept: 'application/json', ...(init.body ? { 'Content-Type': 'application/json' } : {}) },
|
|
85
|
-
signal: AbortSignal.timeout(10000),
|
|
86
|
-
});
|
|
87
|
-
const j = await r.json().catch(() => ({}));
|
|
88
|
-
if (r.status === 401 || r.status === 403) throw Object.assign(new Error('relink'), { relink: true });
|
|
89
|
-
if (!r.ok) throw new Error(j.error || `notlogin ${r.status}`);
|
|
90
|
-
return j;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// ───────────────────────────── payments ─────────────────────────────
|
|
94
|
-
|
|
95
|
-
// public block explorers: an address page lists everything that came in and went out
|
|
96
|
-
const EXPLORER = { base: ['https://basescan.org/address/', 'https://basescan.org/tx/'], solana: ['https://solscan.io/account/', 'https://solscan.io/tx/'] };
|
|
97
|
-
const walletNetwork = (w) => (w.namespace === 'solana' ? 'solana' : w.network);
|
|
98
|
-
export const addressUrl = (network, address) => (EXPLORER[network] && address ? EXPLORER[network][0] + encodeURIComponent(address) : null);
|
|
99
|
-
const txUrl = (network, hash) => (EXPLORER[network] && hash ? EXPLORER[network][1] + encodeURIComponent(hash) : null);
|
|
100
|
-
|
|
101
|
-
const payOf = (r) =>
|
|
102
|
-
r && { id: r.id, network: r.network, to: r.to_addr, amount: r.amount, asset: r.asset, reason: r.reason, who: r.who, status: r.status, intentId: r.intent_id || null, txHash: r.tx_hash || null, txUrl: txUrl(r.network, r.tx_hash), error: r.error || null, createdAt: r.created_at, updatedAt: r.updated_at };
|
|
103
|
-
|
|
104
|
-
export function listPayments(otsId, limit = 30) {
|
|
105
|
-
return getDb().prepare('SELECT * FROM ots_payments WHERE ots_id = ? ORDER BY created_at DESC LIMIT ?').all(otsId, limit).map(payOf);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function getPayment(otsId, id) {
|
|
109
|
-
return payOf(getDb().prepare('SELECT * FROM ots_payments WHERE id = ? AND ots_id = ?').get(String(id || ''), otsId));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function setPayment(id, patch) {
|
|
113
|
-
const cols = { status: 'status', intentId: 'intent_id', txHash: 'tx_hash', error: 'error' };
|
|
114
|
-
const keys = Object.keys(patch).filter((k) => cols[k]);
|
|
115
|
-
if (!keys.length) return;
|
|
116
|
-
getDb()
|
|
117
|
-
.prepare(`UPDATE ots_payments SET ${keys.map((k) => `${cols[k]} = ?`).join(', ')}, updated_at = ? WHERE id = ?`)
|
|
118
|
-
.run(...keys.map((k) => (patch[k] == null ? null : String(patch[k]).slice(0, 300))), Date.now(), id);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/** A payment the ot proposes. It stays 'pending' until the owner approves it. */
|
|
122
|
-
export function requestPayment(ots, { network, to, amount, asset, reason }, who = 'owner') {
|
|
123
|
-
network = String(network || 'base').toLowerCase();
|
|
124
|
-
if (!NETWORKS.includes(network)) throw new Error(`network must be one of ${NETWORKS.join(', ')}`);
|
|
125
|
-
to = String(to || '').trim();
|
|
126
|
-
if (!ADDR[network].test(to)) throw new Error(`"to" is not a valid ${network} address`);
|
|
127
|
-
amount = String(amount ?? '').trim();
|
|
128
|
-
if (!/^\d+(\.\d{1,9})?$/.test(amount) || Number(amount) <= 0) throw new Error('amount must be a positive decimal, e.g. "2.5"');
|
|
129
|
-
asset = String(asset || 'USDC').trim().slice(0, 60) || 'USDC';
|
|
130
|
-
const open = getDb().prepare("SELECT COUNT(*) n FROM ots_payments WHERE ots_id = ? AND status IN ('pending', 'confirming')").get(ots.id).n;
|
|
131
|
-
if (open >= MAX_OPEN) throw new Error('Too many payments waiting for approval; ask your owner to review them first');
|
|
132
|
-
const id = `pay_${randomBytes(8).toString('hex')}`;
|
|
133
|
-
const now = Date.now();
|
|
134
|
-
getDb()
|
|
135
|
-
.prepare('INSERT INTO ots_payments (id, ots_id, account_id, network, to_addr, amount, asset, reason, who, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
136
|
-
.run(id, ots.id, ots.accountId, network, to, amount, asset, String(reason || '').slice(0, 300), String(who).slice(0, 120), 'pending', now, now);
|
|
137
|
-
return getPayment(ots.id, id);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/** Notlogin withdraw params: USDC is Notlogin's default stable; anything else goes as the asset ref. */
|
|
141
|
-
const withdrawParams = (otsId, p) => ({ network: p.network, to: p.to, amount: p.amount, agentId: otsId, ...(p.asset && p.asset.toUpperCase() !== 'USDC' ? { asset: p.asset } : {}) });
|
|
142
|
-
|
|
143
|
-
async function syncPayment(accountId, p) {
|
|
144
|
-
if (p.status !== 'confirming' || !p.intentId) return p;
|
|
145
|
-
const i = await intentCall(accountId, `/${encodeURIComponent(p.intentId)}`);
|
|
146
|
-
if (i.status === 'done') setPayment(p.id, { status: 'paid', txHash: i.result?.txHash || i.result?.hash || i.result?.signature || null });
|
|
147
|
-
else if (i.status === 'cancelled') setPayment(p.id, { status: 'cancelled' });
|
|
148
|
-
else if (i.expiresAt && Date.parse(i.expiresAt) < Date.now()) setPayment(p.id, { status: 'pending', intentId: null });
|
|
149
|
-
return { ...p, ...payOf(getDb().prepare('SELECT * FROM ots_payments WHERE id = ?').get(p.id)) };
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// ───────────────────────────── views ─────────────────────────────
|
|
153
|
-
|
|
154
|
-
export async function walletView(account, ots) {
|
|
155
|
-
const linked = !!account.notlogin_sub;
|
|
156
|
-
const scoped = linked && !!getIntegration(account.id, 'notlogin');
|
|
157
|
-
const v = { configured: walletConfigured(), linked, scoped, wallets: [], error: null, payments: listPayments(ots.id), connectUrl: `/auth/notlogin?link=${encodeURIComponent(ots.id)}`, notloginUrl: notloginUrl() };
|
|
158
|
-
if (!v.configured || !linked) return v;
|
|
159
|
-
try {
|
|
160
|
-
v.wallets = (await agentWallets(account.notlogin_sub, ots.id)).map((w) => ({ ...w, explorerUrl: addressUrl(walletNetwork(w), w.address) }));
|
|
161
|
-
} catch (e) {
|
|
162
|
-
v.error = e.message;
|
|
163
|
-
}
|
|
164
|
-
return v;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// ───────────────────────────── dashboard routes ─────────────────────────────
|
|
168
|
-
|
|
169
|
-
export function createWallet({ send, readJson }) {
|
|
170
|
-
/** @returns {Promise<boolean>} */
|
|
171
|
-
return async function dashboard(req, res, account, ots, sub) {
|
|
172
|
-
if (sub !== '/wallet' && !sub.startsWith('/wallet/')) return false;
|
|
173
|
-
const t = reqT(req);
|
|
174
|
-
if (sub === '/wallet' && req.method === 'GET') {
|
|
175
|
-
const v = await walletView(account, ots);
|
|
176
|
-
// payments waiting on Notlogin: pick up their outcome while the tab is open
|
|
177
|
-
if (v.scoped) for (const p of v.payments.filter((x) => x.status === 'confirming').slice(0, 3)) await syncPayment(account.id, p).catch(() => null);
|
|
178
|
-
return send(res, 200, { ...v, payments: listPayments(ots.id) }), true;
|
|
179
|
-
}
|
|
180
|
-
const m = sub.match(/^\/wallet\/payments\/(pay_[a-f0-9]{16})\/(approve|decline|refresh)$/);
|
|
181
|
-
if (!m || req.method !== 'POST') return send(res, 404, { error: t('server.http.unknownRoute') }), true;
|
|
182
|
-
const p = getPayment(ots.id, m[1]);
|
|
183
|
-
if (!p) return send(res, 404, { error: t('server.http.notFound') }), true;
|
|
184
|
-
try {
|
|
185
|
-
if (m[2] === 'decline') {
|
|
186
|
-
if (!['pending', 'confirming'].includes(p.status)) return send(res, 409, { error: t('platform.wallet.notPending') }), true;
|
|
187
|
-
setPayment(p.id, { status: 'declined' });
|
|
188
|
-
return send(res, 200, { payment: getPayment(ots.id, p.id) }), true;
|
|
189
|
-
}
|
|
190
|
-
if (m[2] === 'refresh') return send(res, 200, { payment: await syncPayment(account.id, p) }), true;
|
|
191
|
-
// approve → a Notlogin withdraw intent, confirmed by the owner on notlogin.com
|
|
192
|
-
if (!['pending', 'confirming'].includes(p.status)) return send(res, 409, { error: t('platform.wallet.notPending') }), true;
|
|
193
|
-
if (!account.notlogin_sub) return send(res, 409, { error: t('platform.wallet.relink'), relink: true }), true;
|
|
194
|
-
const base = (penv.PLATFORM_URL || '').replace(/\/+$/, '');
|
|
195
|
-
const intent = await intentCall(account.id, '', {
|
|
196
|
-
method: 'POST',
|
|
197
|
-
body: JSON.stringify({ type: 'withdraw', params: withdrawParams(ots.id, p), ...(base ? { returnTo: `${base}/app/#ots/${ots.id}/wallet` } : {}) }),
|
|
198
|
-
});
|
|
199
|
-
setPayment(p.id, { status: 'confirming', intentId: intent.id, error: null });
|
|
200
|
-
return send(res, 200, { url: intent.url, payment: getPayment(ots.id, p.id) }), true;
|
|
201
|
-
} catch (e) {
|
|
202
|
-
if (e.relink) return send(res, 409, { error: t('platform.wallet.relink'), relink: true }), true;
|
|
203
|
-
console.warn('[7ots] wallet:', e.message);
|
|
204
|
-
return send(res, 502, { error: String(e.message).slice(0, 200) }), true;
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// ───────────────────────────── the ot's tools (owner chat) ─────────────────────────────
|
|
210
|
-
|
|
211
|
-
const TOOLS = [
|
|
212
|
-
{
|
|
213
|
-
name: 'wallet_info',
|
|
214
|
-
description: 'Shows your own wallet: your addresses (Base and Solana) and balances, and the payments you proposed with their status.',
|
|
215
|
-
parameters: { type: 'object', properties: {} },
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
name: 'request_payment',
|
|
219
|
-
description:
|
|
220
|
-
'Proposes a payment from your wallet. It does NOT pay by itself: your owner must approve it in the Wallet tab and confirm it on Notlogin. ' +
|
|
221
|
-
'Only use it when your owner asked you to pay something, with the exact address and amount.',
|
|
222
|
-
parameters: {
|
|
223
|
-
type: 'object',
|
|
224
|
-
properties: {
|
|
225
|
-
network: { type: 'string', enum: NETWORKS, description: 'base (default) or solana' },
|
|
226
|
-
to: { type: 'string', description: 'Destination address' },
|
|
227
|
-
amount: { type: 'string', description: 'Decimal amount, e.g. "2.5"' },
|
|
228
|
-
asset: { type: 'string', description: 'USDC (default) or a token address' },
|
|
229
|
-
reason: { type: 'string', description: 'What it is for, in a few words' },
|
|
230
|
-
},
|
|
231
|
-
required: ['to', 'amount'],
|
|
232
|
-
},
|
|
233
|
-
},
|
|
234
|
-
];
|
|
235
|
-
|
|
236
|
-
/** Wallet tools for the owner chat, or null when the account has no Notlogin wallet. */
|
|
237
|
-
export function walletTools(ots, account) {
|
|
238
|
-
if (!walletConfigured() || !account?.notlogin_sub) return null;
|
|
239
|
-
return {
|
|
240
|
-
tools: TOOLS,
|
|
241
|
-
names: TOOLS.map((x) => x.name),
|
|
242
|
-
prompt: 'You have your own crypto wallet (Notlogin). You can check it with wallet_info and propose payments with request_payment; your owner approves every payment in the Wallet tab, so say so after proposing one.',
|
|
243
|
-
run: async (name, args = {}) => {
|
|
244
|
-
if (name === 'wallet_info') {
|
|
245
|
-
const wallets = await agentWallets(account.notlogin_sub, ots.id).catch((e) => ({ error: e.message }));
|
|
246
|
-
return { ok: true, wallets, payments: listPayments(ots.id, 10).map(({ id, network, to, amount, asset, reason, status, txHash }) => ({ id, network, to, amount, asset, reason, status, txHash })) };
|
|
247
|
-
}
|
|
248
|
-
if (name === 'request_payment') {
|
|
249
|
-
const p = requestPayment(ots, args, 'owner chat');
|
|
250
|
-
return { ok: true, id: p.id, status: p.status, note: 'Waiting for your owner to approve it in the Wallet tab.' };
|
|
251
|
-
}
|
|
252
|
-
throw new Error(`Unknown tool: ${name}`);
|
|
253
|
-
},
|
|
254
|
-
};
|
|
255
|
-
}
|