@rine-network/cli 0.14.0 → 0.15.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 +2 -0
- package/dist/main.js +287 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -55,6 +55,8 @@ npx @rine-network/cli onboard --email you@example.com --name "My Org" --slug my-
|
|
|
55
55
|
| `rine agent profile / describe / add-skill / set-categories / set-languages / set-pricing / accept-types` | Agent card management |
|
|
56
56
|
| `rine keys ...` | Status, generate, rotate, export, import E2EE key pairs |
|
|
57
57
|
| `rine send / read / inbox / reply` | Messaging (with `--payload-file` for file/stdin input) |
|
|
58
|
+
| `rine wallet create / address / policy [set]` | Payment wallet and spend policy for x402 agent payments |
|
|
59
|
+
| `rine pay <message-id>` | Pay a received in-thread x402 quote (`--auto-pay`, `--no-marker`, `--force`) |
|
|
58
60
|
| `rine group ...` | Group CRUD, join, invite, vote, members |
|
|
59
61
|
| `rine webhook ...` | Outbound webhook management (rine → a URL you host) |
|
|
60
62
|
| `rine hook ... / rine relay` | Inbound webhook Funnel — hook CRUD + the relay daemon (`--tier zero-trust\|shared-edge`) |
|
package/dist/main.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { Command, Option } from "commander";
|
|
3
|
-
import { FUNNEL_TIERS, HttpClient, IdempotencyStore, RineApiError, UUID_RE, addMlsGroupMember, agentKeysExist, agentLabel, buildIssueCertDeps, cacheToken, connectTunnel, decryptGroupMessage, decryptMessage, decryptThreadRow, deleteHookSecret, encryptGroupMessage, encryptMessage, encryptMlsGroupMessage, ensureCert, externalJoinMlsGroup, fetchAgents, fetchAndIngestPendingSKDistributions, fetchOAuthToken, fetchRecipientKeys, formatError, fromBase64Url, generateAgentKeys, generateHookSecret, generatePqKeyPair, getAgentPublicKeys, getCredentialEntry, getOrCreateSenderKey, getOrRefreshToken, handleWebhookRequest, hasSpiffeEndpoint, hookNameError, ingestSenderKeyDistribution, initMlsGroup, isBareAgentName, jitteredRefreshMargin, listMyInvites, loadAgentKeys, loadCredentials, loadHookSecret, loadMeta, loadMlsState, loadTokenCache, makeEdgePipeFactory, normalizeHandle, performAgentCreation, performRegistration, processMlsWelcomes, renewalDueWithJitter, resolveAgent, resolveApiUrl, resolveConfigDir, resolveHandleViaWebFinger, resolveToUuid, saveAgentKeys, saveCredentials, saveHookSecret, savePqEncryptionKey, saveTokenCache, sendGroupInviteNotification, startTlsListener, syncMlsGroup, toBase64Url, validateEncryptionKey, validateSigningKey, validateSlug, verifyIdentitySpiffe } from "@rine-network/core";
|
|
4
|
-
import readline from "node:readline";
|
|
5
3
|
import * as fs from "node:fs";
|
|
6
4
|
import { readFileSync } from "node:fs";
|
|
5
|
+
import { FUNNEL_TIERS, HttpClient, IdempotencyStore, RineApiError, UUID_RE, X402Error, X402_MESSAGE_TYPE, addMlsGroupMember, agentKeysExist, agentLabel, buildIssueCertDeps, buildPaymentMessage, buildPaymentPayload, buildPaymentRequiredMessage, buildReceiptMessage, cacheToken, connectTunnel, createWallet, decryptGroupMessage, decryptMessage, decryptThreadRow, deleteHookSecret, encryptGroupMessage, encryptMessage, encryptMlsGroupMessage, ensureCert, externalJoinMlsGroup, fetchAgents, fetchAndIngestPendingSKDistributions, fetchOAuthToken, fetchRecipientKeys, formatError, fromBase64Url, generateAgentKeys, generateHookSecret, generatePqKeyPair, getAgentPublicKeys, getCredentialEntry, getOrCreateSenderKey, getOrRefreshToken, getWalletAddress, handleWebhookRequest, hasSpiffeEndpoint, hookNameError, ingestSenderKeyDistribution, initMlsGroup, isAutoPayable, isBareAgentName, isX402MessageType, jitteredRefreshMargin, listMyInvites, loadAgentKeys, loadCredentials, loadHookSecret, loadMeta, loadMlsState, loadPolicy, loadTokenCache, loadWalletKey, makeEdgePipeFactory, normalizeHandle, parseX402Payload, performAgentCreation, performRegistration, processMlsWelcomes, readDailySpent, renewalDueWithJitter, reserveSpend, resolveAgent, resolveApiUrl, resolveConfigDir, resolveHandleViaWebFinger, resolveToUuid, saveAgentKeys, saveCredentials, saveHookSecret, savePolicy, savePqEncryptionKey, saveTokenCache, selectRequirement, sendGroupInviteNotification, startTlsListener, syncMlsGroup, toBase64Url, validateEncryptionKey, validateSigningKey, validateSlug, verifyIdentitySpiffe, walletKeyExists } from "@rine-network/core";
|
|
6
|
+
import readline from "node:readline";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { resolve4 } from "node:dns/promises";
|
|
9
9
|
import { createEventSource } from "eventsource-client";
|
|
@@ -116,6 +116,30 @@ const VALID_PRICING = [
|
|
|
116
116
|
"subscription",
|
|
117
117
|
"negotiated"
|
|
118
118
|
];
|
|
119
|
+
/**
|
|
120
|
+
* Read the x402 card terms from a JSON string or a file (`-` = stdin). The
|
|
121
|
+
* authoritative field shape (rail/schemes/networks/assets/mode/...) is validated
|
|
122
|
+
* server-side on PUT; here we only enforce it is a JSON array so a malformed
|
|
123
|
+
* value fails client-side before a needless round-trip.
|
|
124
|
+
*/
|
|
125
|
+
function readTerms(inline, file) {
|
|
126
|
+
if (inline !== void 0 && file !== void 0) return { error: "--x402-terms and --x402-terms-file are mutually exclusive" };
|
|
127
|
+
let raw;
|
|
128
|
+
if (file !== void 0) try {
|
|
129
|
+
raw = file === "-" ? fs.readFileSync(0, "utf-8") : fs.readFileSync(file, "utf-8");
|
|
130
|
+
} catch (err) {
|
|
131
|
+
return { error: `Cannot read terms file: ${err instanceof Error ? err.message : String(err)}` };
|
|
132
|
+
}
|
|
133
|
+
else raw = inline;
|
|
134
|
+
let parsed;
|
|
135
|
+
try {
|
|
136
|
+
parsed = JSON.parse(raw);
|
|
137
|
+
} catch {
|
|
138
|
+
return { error: "x402 terms must be valid JSON" };
|
|
139
|
+
}
|
|
140
|
+
if (!Array.isArray(parsed)) return { error: "x402 terms must be a JSON array (rail-keyed entries)" };
|
|
141
|
+
return { value: parsed };
|
|
142
|
+
}
|
|
119
143
|
function stripReadOnly(card) {
|
|
120
144
|
const result = { ...card };
|
|
121
145
|
for (const key of READ_ONLY_KEYS) delete result[key];
|
|
@@ -212,13 +236,33 @@ function registerAgentProfile(program) {
|
|
|
212
236
|
});
|
|
213
237
|
printMutationOk("Skill added", gOpts.json);
|
|
214
238
|
}));
|
|
215
|
-
agent.command("set-pricing").description("Set agent pricing model").argument("<agent-id>", "Agent ID").
|
|
216
|
-
if (
|
|
239
|
+
agent.command("set-pricing").description("Set agent pricing model and/or x402 payment terms (rine.x402.terms)").argument("<agent-id>", "Agent ID").option("--model <model>", `Pricing model (${VALID_PRICING.join("|")})`).option("--x402-terms <json>", "x402 card terms as a JSON array (REQ-P03 shape); advisory only").option("--x402-terms-file <path>", "Read the x402 terms JSON array from a file (use - for stdin)").action(withClient(program, async ({ client, gOpts }, agentId, opts) => {
|
|
240
|
+
if (opts.model === void 0 && opts.x402Terms === void 0 && opts.x402TermsFile === void 0) {
|
|
241
|
+
printError("Nothing to set. Provide --model and/or --x402-terms/--x402-terms-file.");
|
|
242
|
+
process.exitCode = 2;
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
if (opts.model !== void 0 && !VALID_PRICING.includes(opts.model)) {
|
|
217
246
|
printError(`Invalid pricing model '${opts.model}'. Valid: ${VALID_PRICING.join(", ")}`);
|
|
218
247
|
process.exitCode = 2;
|
|
219
248
|
return;
|
|
220
249
|
}
|
|
221
|
-
|
|
250
|
+
let terms;
|
|
251
|
+
if (opts.x402Terms !== void 0 || opts.x402TermsFile !== void 0) {
|
|
252
|
+
const parsed = readTerms(opts.x402Terms, opts.x402TermsFile);
|
|
253
|
+
if ("error" in parsed) {
|
|
254
|
+
printError(parsed.error);
|
|
255
|
+
process.exitCode = 2;
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
terms = parsed.value;
|
|
259
|
+
}
|
|
260
|
+
await updateCard(client, agentId, (card) => {
|
|
261
|
+
let next = card;
|
|
262
|
+
if (opts.model !== void 0) next = setRineField(next, "pricing_model", opts.model);
|
|
263
|
+
if (terms !== void 0) next = setRineField(next, "x402", { terms });
|
|
264
|
+
return next;
|
|
265
|
+
});
|
|
222
266
|
printMutationOk("Pricing updated", gOpts.json);
|
|
223
267
|
}));
|
|
224
268
|
for (const def of CSV_FIELD_CMDS) agent.command(def.name).description(def.desc).argument("<agent-id>", "Agent ID").requiredOption(def.flag, def.flagDesc).action(withClient(program, async ({ client, gOpts }, agentId, opts) => {
|
|
@@ -1259,6 +1303,29 @@ function registerKeys(program) {
|
|
|
1259
1303
|
}));
|
|
1260
1304
|
}
|
|
1261
1305
|
//#endregion
|
|
1306
|
+
//#region src/x402.ts
|
|
1307
|
+
/**
|
|
1308
|
+
* Build the x402 send extras for a `type`/`payload` pair, or `null` when `type`
|
|
1309
|
+
* is not one of the three x402 message types (the caller then sends normally).
|
|
1310
|
+
* Validates + normalizes the payload through the core parse layer first, so a
|
|
1311
|
+
* malformed x402 quote/payment/receipt fails loudly before the encrypt/send.
|
|
1312
|
+
*/
|
|
1313
|
+
function x402SendExtras(type, payload, emitMarker) {
|
|
1314
|
+
if (!isX402MessageType(type)) return null;
|
|
1315
|
+
const parsed = parseX402Payload(type, JSON.stringify(payload));
|
|
1316
|
+
const opts = { emitMarker };
|
|
1317
|
+
let built;
|
|
1318
|
+
if (type === X402_MESSAGE_TYPE.PAYMENT_REQUIRED) built = buildPaymentRequiredMessage(parsed, opts);
|
|
1319
|
+
else if (type === X402_MESSAGE_TYPE.PAYMENT) built = buildPaymentMessage(parsed, opts);
|
|
1320
|
+
else built = buildReceiptMessage(parsed, opts);
|
|
1321
|
+
const extras = {
|
|
1322
|
+
content_type: built.content_type,
|
|
1323
|
+
payload_schema: built.payload_schema
|
|
1324
|
+
};
|
|
1325
|
+
if (built.metadata) extras.metadata = built.metadata;
|
|
1326
|
+
return extras;
|
|
1327
|
+
}
|
|
1328
|
+
//#endregion
|
|
1262
1329
|
//#region src/commands/messages.ts
|
|
1263
1330
|
function msgFrom(m) {
|
|
1264
1331
|
return m.sender_handle ?? m.from_agent_id ?? "";
|
|
@@ -1339,7 +1406,7 @@ async function encryptMlsWithRecovery(client, configDir, senderAgentId, groupId,
|
|
|
1339
1406
|
}
|
|
1340
1407
|
}
|
|
1341
1408
|
function addMessageCommands(parent, program) {
|
|
1342
|
-
parent.command("send").description("Send an encrypted message").requiredOption("--to <address>", "Recipient: agent handle (agent@org), agent ID, or group handle (#group@org)").option("--type <type>", "Message type (default: rine.v1.dm)").option("--payload <json>", "Message payload as JSON string").option("--payload-file <path>", "Read payload JSON from file (use - for stdin)").option("--from <address>", "Sender: agent handle (agent@org) or agent ID").option("--idempotency-key <key>", "Idempotency key header").action(withClient(program, async ({ client, gOpts, configDir, apiUrl }, opts) => {
|
|
1409
|
+
parent.command("send").description("Send an encrypted message").requiredOption("--to <address>", "Recipient: agent handle (agent@org), agent ID, or group handle (#group@org)").option("--type <type>", "Message type (default: rine.v1.dm)").option("--payload <json>", "Message payload as JSON string").option("--payload-file <path>", "Read payload JSON from file (use - for stdin)").option("--from <address>", "Sender: agent handle (agent@org) or agent ID").option("--idempotency-key <key>", "Idempotency key header").option("--no-marker", "For x402 message types: omit the cleartext status marker").action(withClient(program, async ({ client, gOpts, configDir, apiUrl }, opts) => {
|
|
1343
1410
|
const result = resolvePayload(opts.payload, opts.payloadFile);
|
|
1344
1411
|
if ("error" in result) {
|
|
1345
1412
|
printError(result.error);
|
|
@@ -1362,7 +1429,14 @@ function addMessageCommands(parent, program) {
|
|
|
1362
1429
|
let recipientAgentId;
|
|
1363
1430
|
if (!to.includes("@")) recipientAgentId = to;
|
|
1364
1431
|
else if (!to.startsWith("#")) recipientAgentId = await resolveToUuid(apiUrl, to);
|
|
1365
|
-
const
|
|
1432
|
+
const resolvedType = opts.type ?? "rine.v1.dm";
|
|
1433
|
+
const body = { type: resolvedType };
|
|
1434
|
+
const x402 = x402SendExtras(resolvedType, parsedPayload, opts.marker !== false);
|
|
1435
|
+
if (x402) {
|
|
1436
|
+
body.content_type = x402.content_type;
|
|
1437
|
+
body.payload_schema = x402.payload_schema;
|
|
1438
|
+
if (x402.metadata) body.metadata = x402.metadata;
|
|
1439
|
+
}
|
|
1366
1440
|
if (to.includes("@")) body.to_handle = to;
|
|
1367
1441
|
else body.to_agent_id = to;
|
|
1368
1442
|
if (from?.includes("@")) body.from_handle = from;
|
|
@@ -1619,6 +1693,111 @@ function registerOrg(program) {
|
|
|
1619
1693
|
}));
|
|
1620
1694
|
}
|
|
1621
1695
|
//#endregion
|
|
1696
|
+
//#region src/commands/pay.ts
|
|
1697
|
+
function registerPay(program) {
|
|
1698
|
+
program.command("pay").description("Pay an in-thread x402 payment_required (sign + reply with x402_payment)").argument("<message-id>", "ID of the received rine.v1.x402_payment_required").option("--agent <id>", "Payer agent ID (defaults to your agent)").option("--auto-pay", "Only pay when the quote is at/below the wallet autoPayThreshold").option("--force", "Re-pay a quote already paid today (bypasses the once-per-message guard)").option("--no-marker", "Omit the cleartext status marker (fully sealed)").action(withClient(program, async ({ client, gOpts, configDir, apiUrl }, messageId, opts) => {
|
|
1699
|
+
const message = await client.get(`/messages/${messageId}`);
|
|
1700
|
+
if (message.type !== X402_MESSAGE_TYPE.PAYMENT_REQUIRED) {
|
|
1701
|
+
printError(`Message ${messageId} is '${message.type}', not ${X402_MESSAGE_TYPE.PAYMENT_REQUIRED}. Nothing to pay.`);
|
|
1702
|
+
process.exitCode = 2;
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1705
|
+
const payeeAgentId = message.from_agent_id;
|
|
1706
|
+
if (!payeeAgentId) {
|
|
1707
|
+
printError("Cannot pay: the quote has no resolvable sender agent.");
|
|
1708
|
+
process.exitCode = 1;
|
|
1709
|
+
return;
|
|
1710
|
+
}
|
|
1711
|
+
const payerAgentId = await resolveAgent(apiUrl, await fetchAgents(client), opts.agent, gOpts.as);
|
|
1712
|
+
if (payeeAgentId === payerAgentId) {
|
|
1713
|
+
printError("Cannot pay your own quote.");
|
|
1714
|
+
process.exitCode = 1;
|
|
1715
|
+
return;
|
|
1716
|
+
}
|
|
1717
|
+
if (!agentKeysExist(configDir, payerAgentId)) {
|
|
1718
|
+
printError(`No E2EE keys for agent ${payerAgentId}. Run 'rine keys generate' first.`);
|
|
1719
|
+
process.exitCode = 1;
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
if (!walletKeyExists(configDir, payerAgentId)) {
|
|
1723
|
+
printError(`No payment wallet for agent ${payerAgentId}. Run 'rine wallet create' first.`);
|
|
1724
|
+
process.exitCode = 1;
|
|
1725
|
+
return;
|
|
1726
|
+
}
|
|
1727
|
+
const decrypted = await decryptMessage(configDir, payerAgentId, message.encrypted_payload, client);
|
|
1728
|
+
const pr = parseX402Payload(message.type, decrypted.plaintext);
|
|
1729
|
+
const policy = loadPolicy(configDir, payerAgentId);
|
|
1730
|
+
const dailySpent = readDailySpent(configDir, payerAgentId);
|
|
1731
|
+
try {
|
|
1732
|
+
const requirement = selectRequirement(pr, policy, dailySpent);
|
|
1733
|
+
if (opts.autoPay) {
|
|
1734
|
+
if (!policy || !isAutoPayable(policy, requirement)) {
|
|
1735
|
+
printError("Quote exceeds the auto-pay threshold. Run 'rine pay' without --auto-pay to approve it manually.");
|
|
1736
|
+
process.exitCode = 1;
|
|
1737
|
+
return;
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
const built = buildPaymentMessage(buildPaymentPayload(pr, requirement, loadWalletKey(configDir, payerAgentId)), { emitMarker: opts.marker !== false });
|
|
1741
|
+
const recipientKeys = await fetchRecipientKeys(client, payeeAgentId);
|
|
1742
|
+
const encrypted = await encryptMessage(configDir, payerAgentId, recipientKeys.encryption, built.payload, recipientKeys.pqEncryption);
|
|
1743
|
+
const body = {
|
|
1744
|
+
type: built.type,
|
|
1745
|
+
content_type: built.content_type,
|
|
1746
|
+
payload_schema: built.payload_schema,
|
|
1747
|
+
...encrypted
|
|
1748
|
+
};
|
|
1749
|
+
if (built.metadata) body.metadata = built.metadata;
|
|
1750
|
+
await reserveSpend(configDir, payerAgentId, policy, requirement, {
|
|
1751
|
+
messageId,
|
|
1752
|
+
force: opts.force
|
|
1753
|
+
});
|
|
1754
|
+
const sent = await client.post(`/messages/${messageId}/reply`, body, { "X-Rine-Agent": payerAgentId });
|
|
1755
|
+
if (gOpts.json) printJson({
|
|
1756
|
+
ok: true,
|
|
1757
|
+
payment_message_id: sent.id,
|
|
1758
|
+
conversation_id: sent.conversation_id,
|
|
1759
|
+
paid_to: requirement.payTo,
|
|
1760
|
+
amount: requirement.amount,
|
|
1761
|
+
asset: requirement.asset,
|
|
1762
|
+
network: requirement.network
|
|
1763
|
+
});
|
|
1764
|
+
else printTable([
|
|
1765
|
+
{
|
|
1766
|
+
Field: "Payment sent",
|
|
1767
|
+
Value: sent.id
|
|
1768
|
+
},
|
|
1769
|
+
{
|
|
1770
|
+
Field: "Conversation",
|
|
1771
|
+
Value: sent.conversation_id
|
|
1772
|
+
},
|
|
1773
|
+
{
|
|
1774
|
+
Field: "Pay to",
|
|
1775
|
+
Value: requirement.payTo
|
|
1776
|
+
},
|
|
1777
|
+
{
|
|
1778
|
+
Field: "Amount",
|
|
1779
|
+
Value: requirement.amount
|
|
1780
|
+
},
|
|
1781
|
+
{
|
|
1782
|
+
Field: "Asset",
|
|
1783
|
+
Value: requirement.asset
|
|
1784
|
+
},
|
|
1785
|
+
{
|
|
1786
|
+
Field: "Network",
|
|
1787
|
+
Value: requirement.network
|
|
1788
|
+
}
|
|
1789
|
+
]);
|
|
1790
|
+
} catch (err) {
|
|
1791
|
+
if (err instanceof X402Error) {
|
|
1792
|
+
printError(`Payment refused: ${err.message}`);
|
|
1793
|
+
process.exitCode = 1;
|
|
1794
|
+
return;
|
|
1795
|
+
}
|
|
1796
|
+
throw err;
|
|
1797
|
+
}
|
|
1798
|
+
}));
|
|
1799
|
+
}
|
|
1800
|
+
//#endregion
|
|
1622
1801
|
//#region src/commands/poll-token.ts
|
|
1623
1802
|
function registerPollToken(program) {
|
|
1624
1803
|
program.command("poll-token").description("Generate or revoke a poll token for inbox monitoring").option("--agent <id>", "Agent ID (auto-resolved for single-agent orgs)").option("--revoke", "Revoke the poll token").action(withClient(program, async ({ client, gOpts, profileName, configDir, apiUrl }, opts) => {
|
|
@@ -2276,6 +2455,105 @@ function registerVerifyIdentity(program) {
|
|
|
2276
2455
|
}));
|
|
2277
2456
|
}
|
|
2278
2457
|
//#endregion
|
|
2458
|
+
//#region src/commands/wallet.ts
|
|
2459
|
+
function csv(raw) {
|
|
2460
|
+
return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
2461
|
+
}
|
|
2462
|
+
function registerWallet(program) {
|
|
2463
|
+
const wallet = program.command("wallet").description("Manage the agent payment wallet and spend policy (x402)");
|
|
2464
|
+
wallet.command("create").description("Create a payment wallet for an agent (refuses to overwrite)").option("--agent <id>", "Agent ID (defaults to your agent)").action(withClient(program, async ({ client, gOpts, apiUrl, configDir }, opts) => {
|
|
2465
|
+
const agentId = await resolveAgent(apiUrl, await fetchAgents(client), opts.agent, gOpts.as);
|
|
2466
|
+
if (walletKeyExists(configDir, agentId)) {
|
|
2467
|
+
printError(`Wallet already exists for agent ${agentId}. The private key is never overwritten.`);
|
|
2468
|
+
process.exitCode = 1;
|
|
2469
|
+
return;
|
|
2470
|
+
}
|
|
2471
|
+
const { address } = createWallet(configDir, agentId);
|
|
2472
|
+
if (gOpts.json) printJson({
|
|
2473
|
+
agent_id: agentId,
|
|
2474
|
+
address
|
|
2475
|
+
});
|
|
2476
|
+
else printTable([{
|
|
2477
|
+
Field: "Agent ID",
|
|
2478
|
+
Value: agentId
|
|
2479
|
+
}, {
|
|
2480
|
+
Field: "Wallet address",
|
|
2481
|
+
Value: address
|
|
2482
|
+
}]);
|
|
2483
|
+
}));
|
|
2484
|
+
wallet.command("address").description("Print an agent's payment wallet address").option("--agent <id>", "Agent ID (defaults to your agent)").action(withClient(program, async ({ client, gOpts, apiUrl, configDir }, opts) => {
|
|
2485
|
+
const agentId = await resolveAgent(apiUrl, await fetchAgents(client), opts.agent, gOpts.as);
|
|
2486
|
+
if (!walletKeyExists(configDir, agentId)) {
|
|
2487
|
+
printError(`No wallet for agent ${agentId}. Run 'rine wallet create' first.`);
|
|
2488
|
+
process.exitCode = 1;
|
|
2489
|
+
return;
|
|
2490
|
+
}
|
|
2491
|
+
const address = getWalletAddress(configDir, agentId);
|
|
2492
|
+
if (gOpts.json) printJson({
|
|
2493
|
+
agent_id: agentId,
|
|
2494
|
+
address
|
|
2495
|
+
});
|
|
2496
|
+
else printTable([{ "Wallet address": address }]);
|
|
2497
|
+
}));
|
|
2498
|
+
wallet.command("policy").description("Show the effective spend policy (deny-by-default when unset)").option("--agent <id>", "Agent ID (defaults to your agent)").action(withClient(program, async ({ client, gOpts, apiUrl, configDir }, opts) => {
|
|
2499
|
+
const agentId = await resolveAgent(apiUrl, await fetchAgents(client), opts.agent, gOpts.as);
|
|
2500
|
+
const p = loadPolicy(configDir, agentId);
|
|
2501
|
+
if (gOpts.json) {
|
|
2502
|
+
printJson({
|
|
2503
|
+
agent_id: agentId,
|
|
2504
|
+
policy: p,
|
|
2505
|
+
effective: p ? "configured" : "deny-by-default"
|
|
2506
|
+
});
|
|
2507
|
+
return;
|
|
2508
|
+
}
|
|
2509
|
+
if (!p) {
|
|
2510
|
+
printTable([{
|
|
2511
|
+
Field: "Effective policy",
|
|
2512
|
+
Value: "DENY (no policy set)"
|
|
2513
|
+
}, {
|
|
2514
|
+
Field: "Note",
|
|
2515
|
+
Value: "Payments are denied by default. Configure with 'rine wallet policy set'."
|
|
2516
|
+
}]);
|
|
2517
|
+
return;
|
|
2518
|
+
}
|
|
2519
|
+
printTable([
|
|
2520
|
+
{
|
|
2521
|
+
Field: "Effective policy",
|
|
2522
|
+
Value: "configured"
|
|
2523
|
+
},
|
|
2524
|
+
{
|
|
2525
|
+
Field: "Per-tx cap",
|
|
2526
|
+
Value: p.perTxCap
|
|
2527
|
+
},
|
|
2528
|
+
{
|
|
2529
|
+
Field: "Daily cap",
|
|
2530
|
+
Value: p.dailyCap
|
|
2531
|
+
},
|
|
2532
|
+
{
|
|
2533
|
+
Field: "Auto-pay threshold",
|
|
2534
|
+
Value: p.autoPayThreshold
|
|
2535
|
+
},
|
|
2536
|
+
{
|
|
2537
|
+
Field: "Allowed assets",
|
|
2538
|
+
Value: p.allowedAssets.join(", ") || "—"
|
|
2539
|
+
},
|
|
2540
|
+
{
|
|
2541
|
+
Field: "Allowed networks",
|
|
2542
|
+
Value: p.allowedNetworks.join(", ") || "—"
|
|
2543
|
+
}
|
|
2544
|
+
]);
|
|
2545
|
+
})).command("set").description("Set the spend policy (all caps are decimal major-unit strings)").option("--agent <id>", "Agent ID (defaults to your agent)").requiredOption("--per-tx-cap <amount>", "Max per-transaction spend, e.g. 5.00").requiredOption("--daily-cap <amount>", "Max total spend per UTC day, e.g. 50.00").requiredOption("--allowed-assets <list>", "Comma-separated assets (symbols e.g. EURC or 0x contract addresses)").requiredOption("--allowed-networks <list>", "Comma-separated CAIP-2 networks, e.g. eip155:8453").option("--auto-pay-threshold <amount>", "Auto-pay ceiling for 'rine pay --auto-pay' (default 0 = never auto-pay)", "0").action(withClient(program, async ({ client, gOpts, apiUrl, configDir }, opts) => {
|
|
2546
|
+
savePolicy(configDir, await resolveAgent(apiUrl, await fetchAgents(client), opts.agent, gOpts.as), {
|
|
2547
|
+
perTxCap: opts.perTxCap,
|
|
2548
|
+
dailyCap: opts.dailyCap,
|
|
2549
|
+
allowedAssets: csv(opts.allowedAssets),
|
|
2550
|
+
allowedNetworks: csv(opts.allowedNetworks),
|
|
2551
|
+
autoPayThreshold: opts.autoPayThreshold
|
|
2552
|
+
});
|
|
2553
|
+
printMutationOk("Spend policy updated", gOpts.json);
|
|
2554
|
+
}));
|
|
2555
|
+
}
|
|
2556
|
+
//#endregion
|
|
2279
2557
|
//#region src/commands/webhook.ts
|
|
2280
2558
|
function registerWebhook(program) {
|
|
2281
2559
|
const webhook = program.command("webhook").description("Manage webhooks");
|
|
@@ -2360,6 +2638,8 @@ registerGroup(program);
|
|
|
2360
2638
|
registerDiscover(program);
|
|
2361
2639
|
registerWebhook(program);
|
|
2362
2640
|
registerHook(program);
|
|
2641
|
+
registerWallet(program);
|
|
2642
|
+
registerPay(program);
|
|
2363
2643
|
registerKeys(program);
|
|
2364
2644
|
registerStream(program);
|
|
2365
2645
|
registerRelay(program);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rine-network/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"description": "CLI client for rine.network \u2014 EU-first messaging infrastructure for AI agents",
|
|
5
5
|
"author": "mmmbs <mmmbs@proton.me>",
|
|
6
6
|
"license": "EUPL-1.2",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dev": "tsx src/main.ts"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@rine-network/core": "^0.
|
|
31
|
+
"@rine-network/core": "^0.10.1",
|
|
32
32
|
"commander": "^12.0.0",
|
|
33
33
|
"eventsource-client": "^1.1.0"
|
|
34
34
|
},
|