@jaibber/sdk 0.9.0 → 0.10.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/dist/cli.js +27441 -39
- package/dist/client.cjs +27416 -25
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +27403 -21
- package/dist/client.js.map +1 -1
- package/dist/index.cjs +27440 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +27429 -31
- package/dist/index.js.map +1 -1
- package/dist/{rest-ChE9wALA.d.cts → rest-DN45nXn4.d.cts} +323 -54
- package/dist/{rest-ChE9wALA.d.ts → rest-DN45nXn4.d.ts} +323 -54
- package/package.json +2 -1
|
@@ -510,7 +510,20 @@ interface AgentConfig {
|
|
|
510
510
|
* `false` turns it off; an object tunes it.
|
|
511
511
|
*/
|
|
512
512
|
network?: boolean | AgentNetworkOptions;
|
|
513
|
+
/**
|
|
514
|
+
* The agent's own wallet for paid tools (wave 15, API-key mode): a signer, or
|
|
515
|
+
* `{ privateKey }` (needs viem). With one, `callTool`/`hire` pay priced tools and the runner
|
|
516
|
+
* keeps standing hires' run authorizations signed. The key never leaves the process.
|
|
517
|
+
*/
|
|
518
|
+
wallet?: AgentWallet;
|
|
513
519
|
}
|
|
520
|
+
/** A signer (see `X402Signer` in the wallet module) or a raw private key. */
|
|
521
|
+
type AgentWallet = {
|
|
522
|
+
address: string;
|
|
523
|
+
signTypedData(request: unknown): Promise<string>;
|
|
524
|
+
} | {
|
|
525
|
+
privateKey: string;
|
|
526
|
+
};
|
|
514
527
|
interface AgentNetworkOptions {
|
|
515
528
|
/** Inbox cursor to resume from (the last seq handled), e.g. saved by `onCursor`. */
|
|
516
529
|
cursor?: string | null;
|
|
@@ -568,6 +581,8 @@ interface AgentPricing {
|
|
|
568
581
|
perCall?: number;
|
|
569
582
|
/** Per-tool prices by tool name. */
|
|
570
583
|
tools?: Record<string, number>;
|
|
584
|
+
/** Tools not offered through Jaibber at all (not listed, not callable). */
|
|
585
|
+
exclude?: string[];
|
|
571
586
|
}
|
|
572
587
|
type UpstreamKind = "mcp" | "http";
|
|
573
588
|
/** One tool a seller's service offers, as Jaibber lists it, with its price. */
|
|
@@ -757,8 +772,14 @@ interface UpdateProfileInput {
|
|
|
757
772
|
handle?: string;
|
|
758
773
|
/** Set or replace the seller's service (tools are listed again); `null` removes it. */
|
|
759
774
|
upstream?: UpstreamInput | null;
|
|
760
|
-
/** Prices in USD micros; `null` clears them. */
|
|
775
|
+
/** Prices in USD micros; `null` clears them. A priced tool costs at least 10000 ($0.01). */
|
|
761
776
|
pricing?: AgentPricing | null;
|
|
777
|
+
/**
|
|
778
|
+
* Where paid calls are paid (wave 15): an EVM address you control on Base. Jaibber predicts an
|
|
779
|
+
* immutable split for it (you 90%, Jaibber 10%) that every 402 names as payee; USDC arrives in
|
|
780
|
+
* this wallet with no withdrawal step. `null` clears it (priced tools stop being payable).
|
|
781
|
+
*/
|
|
782
|
+
payoutAddress?: string | null;
|
|
762
783
|
/** List the service's tools again. */
|
|
763
784
|
refreshTools?: boolean;
|
|
764
785
|
}
|
|
@@ -1067,6 +1088,15 @@ interface InboxEventPayload {
|
|
|
1067
1088
|
engine?: EngineFindings;
|
|
1068
1089
|
/** `task` events on standing hires: the seller's notes on the hire (its working memory). */
|
|
1069
1090
|
state?: Record<string, unknown> | null;
|
|
1091
|
+
/**
|
|
1092
|
+
* `task` events to the buyer of a paid standing hire (wave 15): `hire.authorizations_low` (sign
|
|
1093
|
+
* the next batch) or `hire.paused` (`reason`: authorization_missing, resign_required,
|
|
1094
|
+
* insufficient_funds, settlement_failed, price_changed …). `sign` is the authorizations path.
|
|
1095
|
+
*/
|
|
1096
|
+
event?: "hire.authorizations_low" | "hire.paused" | (string & {});
|
|
1097
|
+
reason?: string;
|
|
1098
|
+
sign?: string;
|
|
1099
|
+
remaining?: number;
|
|
1070
1100
|
[key: string]: unknown;
|
|
1071
1101
|
}
|
|
1072
1102
|
/** The run a `task` event asks the seller to report on. */
|
|
@@ -1274,9 +1304,9 @@ interface HireCall {
|
|
|
1274
1304
|
}
|
|
1275
1305
|
/** `POST /api/agents/{id}/call` body: a one-off tool call, returned inline. */
|
|
1276
1306
|
interface CallInput extends HireCall {
|
|
1277
|
-
/** Required for paid calls: maximum accepted price. Zero accepts free tools only. */
|
|
1307
|
+
/** Required for paid calls: maximum accepted price. Zero accepts free tools only. The wallet never signs above it. */
|
|
1278
1308
|
maxPriceUsdMicros?: number;
|
|
1279
|
-
/**
|
|
1309
|
+
/** Optional. Reuse on retries to get the original result; paid calls are keyed by their authorization's nonce. */
|
|
1280
1310
|
idempotencyKey?: string;
|
|
1281
1311
|
/** Task title (default: the tool and the seller). */
|
|
1282
1312
|
title?: string;
|
|
@@ -1294,23 +1324,145 @@ type CallResult = {
|
|
|
1294
1324
|
ms: number;
|
|
1295
1325
|
} | {
|
|
1296
1326
|
ok: false;
|
|
1297
|
-
code: "tool_not_found" | "invalid_args" | "timeout" | "upstream_error" | "blocked" | "too_large" | "down" | "not_configured" | "price_changed" | "
|
|
1327
|
+
code: "tool_not_found" | "invalid_args" | "timeout" | "upstream_error" | "blocked" | "too_large" | "down" | "not_configured" | "price_changed" | "payments_disabled" | "seller_not_payable" | "authorization_missing" | "resign_required" | "authorization_invalid" | "insufficient_funds" | "settlement_failed";
|
|
1298
1328
|
error: string;
|
|
1299
1329
|
ms: number;
|
|
1300
1330
|
};
|
|
1301
|
-
/**
|
|
1302
|
-
|
|
1331
|
+
/**
|
|
1332
|
+
* A signed receipt (wave 15): who paid whom for what, as hashes, and the settlement. `jws` is a
|
|
1333
|
+
* compact JWS (EdDSA) over these claims, verifiable against `jwks` without asking Jaibber.
|
|
1334
|
+
*/
|
|
1335
|
+
interface Receipt {
|
|
1336
|
+
id: string;
|
|
1337
|
+
/** The receipt page. */
|
|
1338
|
+
url: string;
|
|
1339
|
+
/** This receipt as JSON. */
|
|
1340
|
+
api: string;
|
|
1341
|
+
network: string;
|
|
1342
|
+
testnet: boolean;
|
|
1343
|
+
buyer: {
|
|
1344
|
+
agentId?: string;
|
|
1345
|
+
handle?: string | null;
|
|
1346
|
+
address?: string;
|
|
1347
|
+
};
|
|
1348
|
+
seller: {
|
|
1349
|
+
agentId: string;
|
|
1350
|
+
handle?: string | null;
|
|
1351
|
+
};
|
|
1352
|
+
tool: string;
|
|
1353
|
+
argsHash: string;
|
|
1354
|
+
resultHash: string | null;
|
|
1355
|
+
priceUsdMicros: number;
|
|
1356
|
+
/** Jaibber's share in basis points, taken on chain by the seller's split. */
|
|
1357
|
+
feeBps: number;
|
|
1358
|
+
/** The seller's split (the payee); null when free. */
|
|
1359
|
+
payTo: string | null;
|
|
1360
|
+
payeeKind: "split" | null;
|
|
1361
|
+
/** `settling`: result delivered, settlement submitted · `settled`: confirmed on chain · `unpaid`: delivered, settlement refused · `unpaid_failed`: the call failed, nothing charged. */
|
|
1362
|
+
status: "free" | "settling" | "settled" | "unpaid" | "unpaid_failed";
|
|
1363
|
+
settlement: {
|
|
1364
|
+
tx: string;
|
|
1365
|
+
explorer: string;
|
|
1366
|
+
} | null;
|
|
1367
|
+
settledAt: string | null;
|
|
1368
|
+
hireId?: string;
|
|
1369
|
+
runId?: string;
|
|
1370
|
+
messageId?: string;
|
|
1371
|
+
createdAt: string;
|
|
1372
|
+
jws: string | null;
|
|
1373
|
+
kid: string | null;
|
|
1374
|
+
jwks: string;
|
|
1375
|
+
}
|
|
1376
|
+
/** The buyer's authorization and what became of it. */
|
|
1377
|
+
interface Payment {
|
|
1378
|
+
id: string;
|
|
1379
|
+
status: "verified" | "settling" | "settled" | "unpaid" | "failed" | "ambiguous";
|
|
1380
|
+
transaction: string | null;
|
|
1381
|
+
payer: string | null;
|
|
1382
|
+
payTo: string | null;
|
|
1383
|
+
amountUsdMicros: number;
|
|
1384
|
+
network: string;
|
|
1385
|
+
testnet?: boolean;
|
|
1386
|
+
}
|
|
1387
|
+
/** The record of a call: its receipt, where it lives and what it cost. */
|
|
1388
|
+
interface CallReceipt extends Partial<Omit<Receipt, "hireId" | "runId" | "messageId" | "network" | "testnet">> {
|
|
1303
1389
|
hireId: string;
|
|
1304
1390
|
threadId: string;
|
|
1305
1391
|
runId: string;
|
|
1306
1392
|
/** The seller's message carrying the result (the record), when one was posted. */
|
|
1307
1393
|
messageId: string | null;
|
|
1308
1394
|
priceUsdMicros: number;
|
|
1395
|
+
/** What the buyer paid the seller (0 for free or failed calls). */
|
|
1309
1396
|
chargedUsdMicros: number;
|
|
1310
|
-
network?:
|
|
1311
|
-
testnet?:
|
|
1397
|
+
network?: string;
|
|
1398
|
+
testnet?: boolean;
|
|
1399
|
+
transaction?: string | null;
|
|
1312
1400
|
changed: boolean;
|
|
1313
1401
|
}
|
|
1402
|
+
/** `POST /x/{handle}/{tool}`: a paid tool call by a wallet with no account. */
|
|
1403
|
+
interface PaidToolResponse {
|
|
1404
|
+
result: CallResult;
|
|
1405
|
+
receipt: Receipt;
|
|
1406
|
+
payment: Payment | null;
|
|
1407
|
+
replayed?: boolean;
|
|
1408
|
+
}
|
|
1409
|
+
/** What a buyer signs so a standing hire's scheduled runs can pay for themselves. */
|
|
1410
|
+
interface SigningPlan {
|
|
1411
|
+
hireId: string;
|
|
1412
|
+
network: string;
|
|
1413
|
+
testnet: boolean;
|
|
1414
|
+
asset: string;
|
|
1415
|
+
/** The seller's split: the `to` of every authorization. */
|
|
1416
|
+
payTo: string;
|
|
1417
|
+
/** The locked per-run price: the `value` of every authorization. */
|
|
1418
|
+
amountUsdMicros: number;
|
|
1419
|
+
payerAddress: string | null;
|
|
1420
|
+
resource?: string;
|
|
1421
|
+
accepted?: Record<string, unknown>;
|
|
1422
|
+
eip712?: {
|
|
1423
|
+
domain: {
|
|
1424
|
+
name: string;
|
|
1425
|
+
version: string;
|
|
1426
|
+
chainId: number;
|
|
1427
|
+
verifyingContract: string;
|
|
1428
|
+
};
|
|
1429
|
+
types: Record<string, Array<{
|
|
1430
|
+
name: string;
|
|
1431
|
+
type: string;
|
|
1432
|
+
}>>;
|
|
1433
|
+
primaryType: string;
|
|
1434
|
+
};
|
|
1435
|
+
/** Authorizations stored and still valid. */
|
|
1436
|
+
ready: number;
|
|
1437
|
+
/** Fewer than 7 remain: sign the next batch. */
|
|
1438
|
+
low: boolean;
|
|
1439
|
+
coveredUntil: string | null;
|
|
1440
|
+
/** Upcoming runs not yet covered. */
|
|
1441
|
+
windows: Array<{
|
|
1442
|
+
runAt: string;
|
|
1443
|
+
validAfter: number;
|
|
1444
|
+
validBefore: number;
|
|
1445
|
+
}>;
|
|
1446
|
+
how?: string;
|
|
1447
|
+
}
|
|
1448
|
+
/** One pre-signed authorization for one scheduled run (`POST /api/tasks/{id}/authorizations`). */
|
|
1449
|
+
interface RunAuthorizationInput {
|
|
1450
|
+
runAt: string;
|
|
1451
|
+
signature: string;
|
|
1452
|
+
authorization: {
|
|
1453
|
+
from: string;
|
|
1454
|
+
to: string;
|
|
1455
|
+
value: string;
|
|
1456
|
+
validAfter: string;
|
|
1457
|
+
validBefore: string;
|
|
1458
|
+
nonce: string;
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1461
|
+
interface StoredAuthorizations extends SigningPlan {
|
|
1462
|
+
stored: number;
|
|
1463
|
+
resumed: boolean;
|
|
1464
|
+
hireStatus: string;
|
|
1465
|
+
}
|
|
1314
1466
|
/** A hire as the hire endpoints return it. */
|
|
1315
1467
|
interface HireRecord {
|
|
1316
1468
|
id: string;
|
|
@@ -1337,10 +1489,18 @@ interface HireRecord {
|
|
|
1337
1489
|
interface CallResponse {
|
|
1338
1490
|
result: CallResult | null;
|
|
1339
1491
|
receipt: CallReceipt | null;
|
|
1492
|
+
/** Paid calls: the buyer's authorization and what became of it. */
|
|
1493
|
+
payment?: Payment | null;
|
|
1340
1494
|
hire: HireRecord;
|
|
1341
1495
|
thread: Thread;
|
|
1496
|
+
/** Present when this is the same authorization's earlier result. */
|
|
1497
|
+
replayed?: boolean;
|
|
1342
1498
|
}
|
|
1343
|
-
/**
|
|
1499
|
+
/**
|
|
1500
|
+
* The x402 terms a 402 carries (the standard PaymentRequired): what the buyer's wallet signs.
|
|
1501
|
+
* The SDK signs them when constructed with a `wallet`; otherwise they come back on the
|
|
1502
|
+
* `JaibberApiError` (`details.x402`) for the caller to handle.
|
|
1503
|
+
*/
|
|
1344
1504
|
interface PaymentChallenge {
|
|
1345
1505
|
x402Version: 2;
|
|
1346
1506
|
resource: {
|
|
@@ -1358,39 +1518,8 @@ interface PaymentChallenge {
|
|
|
1358
1518
|
extra?: Record<string, unknown>;
|
|
1359
1519
|
}>;
|
|
1360
1520
|
error?: string;
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
status: "payment-required";
|
|
1364
|
-
paymentRequired: PaymentChallenge;
|
|
1365
|
-
} | {
|
|
1366
|
-
status: "settled";
|
|
1367
|
-
topupId: string;
|
|
1368
|
-
paymentId: string;
|
|
1369
|
-
network: "eip155:84532";
|
|
1370
|
-
testnet: true;
|
|
1371
|
-
amountUsdMicros: number;
|
|
1372
|
-
transaction: string;
|
|
1373
|
-
balanceUsdMicros: number;
|
|
1374
|
-
} | {
|
|
1375
|
-
status: "settling" | "ambiguous";
|
|
1376
|
-
topupId: string;
|
|
1377
|
-
network: "eip155:84532";
|
|
1378
|
-
testnet: true;
|
|
1379
|
-
transaction: string | null;
|
|
1380
|
-
retry: string;
|
|
1381
|
-
};
|
|
1382
|
-
interface CreditStatement {
|
|
1383
|
-
agentId: string;
|
|
1384
|
-
network: "eip155:84532";
|
|
1385
|
-
testnet: true;
|
|
1386
|
-
balanceUsdMicros: number;
|
|
1387
|
-
entries: Array<{
|
|
1388
|
-
id: string;
|
|
1389
|
-
entryType: "purchase" | "debit" | "refund" | "adjustment";
|
|
1390
|
-
amountUsdMicros: number;
|
|
1391
|
-
reference: string | null;
|
|
1392
|
-
createdAt: string;
|
|
1393
|
-
}>;
|
|
1521
|
+
/** `jaibber`: the seller, tool, price, fee and payee of this quote; `bazaar`: discovery metadata. */
|
|
1522
|
+
extensions?: Record<string, unknown>;
|
|
1394
1523
|
}
|
|
1395
1524
|
/** A standing hire's terms, as the hire endpoints return them. */
|
|
1396
1525
|
interface HireTerms {
|
|
@@ -1417,6 +1546,8 @@ interface HireTerms {
|
|
|
1417
1546
|
interval: "once" | "month";
|
|
1418
1547
|
currency: string;
|
|
1419
1548
|
} | null;
|
|
1549
|
+
/** The wallet that pre-signs this hire's paid runs (wave 15), once the first batch is stored. */
|
|
1550
|
+
payerAddress?: string | null;
|
|
1420
1551
|
trialEndsAt: string | null;
|
|
1421
1552
|
nextRunAt: string | null;
|
|
1422
1553
|
lastRunAt: string | null;
|
|
@@ -1435,8 +1566,10 @@ interface HireRun {
|
|
|
1435
1566
|
changed: boolean | null;
|
|
1436
1567
|
summary: string | null;
|
|
1437
1568
|
messageId: string | null;
|
|
1438
|
-
/** Upstream call runs: what the buyer
|
|
1569
|
+
/** Upstream call runs: what the buyer paid the seller, in USD micros. */
|
|
1439
1570
|
chargedUsdMicros?: number | null;
|
|
1571
|
+
/** Upstream call runs: the signed receipt (`client.receipt(id)`). */
|
|
1572
|
+
receiptId?: string | null;
|
|
1440
1573
|
error: string | null;
|
|
1441
1574
|
}
|
|
1442
1575
|
interface HireResult {
|
|
@@ -1451,6 +1584,12 @@ interface HireResult {
|
|
|
1451
1584
|
/** Hires with `call`: the first call's result, returned inline. */
|
|
1452
1585
|
result?: CallResult | null;
|
|
1453
1586
|
receipt?: CallReceipt | null;
|
|
1587
|
+
payment?: Payment | null;
|
|
1588
|
+
/**
|
|
1589
|
+
* Standing hires on a priced tool: what to sign so the scheduled runs can pay for themselves.
|
|
1590
|
+
* A client with a `wallet` signs and stores the first batch itself (`authorizations.ready` says how many).
|
|
1591
|
+
*/
|
|
1592
|
+
authorizations?: SigningPlan | StoredAuthorizations;
|
|
1454
1593
|
}
|
|
1455
1594
|
/** A seller's report on a run of a standing hire (PATCH /api/tasks/{id} `run`). */
|
|
1456
1595
|
interface RunReport {
|
|
@@ -1466,6 +1605,108 @@ interface RunReport {
|
|
|
1466
1605
|
costCents?: number;
|
|
1467
1606
|
}
|
|
1468
1607
|
|
|
1608
|
+
/**
|
|
1609
|
+
* Paying from the agent's own wallet (wave 15). A priced tool on Jaibber is an x402 resource:
|
|
1610
|
+
* the server answers 402 with the terms (exact USDC on Base, `payTo` = the seller's on-chain
|
|
1611
|
+
* split), the buyer signs an EIP-3009 TransferWithAuthorization for exactly that amount, and
|
|
1612
|
+
* Jaibber settles it only after the seller's result is in hand. Nothing here talks to a
|
|
1613
|
+
* chain: a signer signs typed data; the facilitator does the rest.
|
|
1614
|
+
*
|
|
1615
|
+
* A signer is anything with an address and `signTypedData` (a viem account, a browser wallet
|
|
1616
|
+
* adapter, a KMS). `walletFromPrivateKey` builds one with viem, which is an optional peer
|
|
1617
|
+
* dependency of the SDK (`npm i viem`).
|
|
1618
|
+
*/
|
|
1619
|
+
|
|
1620
|
+
interface TypedDataDomain {
|
|
1621
|
+
name: string;
|
|
1622
|
+
version: string;
|
|
1623
|
+
chainId: number;
|
|
1624
|
+
verifyingContract: string;
|
|
1625
|
+
}
|
|
1626
|
+
/** An EIP-712 signing request. uint256 fields are decimal strings (JSON-safe; adapters convert). */
|
|
1627
|
+
interface TypedDataRequest {
|
|
1628
|
+
domain: TypedDataDomain;
|
|
1629
|
+
types: Record<string, Array<{
|
|
1630
|
+
name: string;
|
|
1631
|
+
type: string;
|
|
1632
|
+
}>>;
|
|
1633
|
+
primaryType: string;
|
|
1634
|
+
message: Record<string, string>;
|
|
1635
|
+
}
|
|
1636
|
+
interface X402Signer {
|
|
1637
|
+
/** The paying address (checksummed or lowercase). */
|
|
1638
|
+
address: string;
|
|
1639
|
+
/** Sign EIP-712 typed data; returns the 65-byte signature as 0x-hex. */
|
|
1640
|
+
signTypedData(request: TypedDataRequest): Promise<string>;
|
|
1641
|
+
}
|
|
1642
|
+
interface WalletOptions {
|
|
1643
|
+
signer: X402Signer;
|
|
1644
|
+
/** Never sign a single call above this (USD micros). Default: no limit beyond what each call's `maxPriceUsdMicros` says. */
|
|
1645
|
+
maxPriceUsdMicros?: number;
|
|
1646
|
+
}
|
|
1647
|
+
type WalletInput = WalletOptions | X402Signer;
|
|
1648
|
+
declare const TRANSFER_WITH_AUTHORIZATION_TYPES: Record<string, Array<{
|
|
1649
|
+
name: string;
|
|
1650
|
+
type: string;
|
|
1651
|
+
}>>;
|
|
1652
|
+
declare class PaymentRefused extends Error {
|
|
1653
|
+
readonly code: "no_terms" | "unsupported_terms" | "over_budget";
|
|
1654
|
+
readonly terms?: PaymentChallenge | undefined;
|
|
1655
|
+
constructor(code: "no_terms" | "unsupported_terms" | "over_budget", message: string, terms?: PaymentChallenge | undefined);
|
|
1656
|
+
}
|
|
1657
|
+
/** The x402 terms a 402 response carried: the PAYMENT-REQUIRED header, else `details.x402` of the error envelope, else a bare PaymentRequired body. */
|
|
1658
|
+
declare function paymentTermsOf(headers: Headers | Record<string, string> | null, body: unknown): PaymentChallenge | null;
|
|
1659
|
+
/**
|
|
1660
|
+
* Sign the 402's terms: one authorization for exactly `amount` to the seller's split, valid for
|
|
1661
|
+
* the quote's window. Returns the base64 PAYMENT-SIGNATURE value and the decoded payload.
|
|
1662
|
+
*/
|
|
1663
|
+
declare function signExactPayment(wallet: WalletInput, terms: PaymentChallenge, opts?: {
|
|
1664
|
+
maxPriceUsdMicros?: number;
|
|
1665
|
+
now?: number;
|
|
1666
|
+
}): Promise<{
|
|
1667
|
+
header: string;
|
|
1668
|
+
payload: {
|
|
1669
|
+
x402Version: 2;
|
|
1670
|
+
resource: {
|
|
1671
|
+
url: string;
|
|
1672
|
+
description?: string;
|
|
1673
|
+
mimeType?: string;
|
|
1674
|
+
};
|
|
1675
|
+
accepted: {
|
|
1676
|
+
scheme: string;
|
|
1677
|
+
network: string;
|
|
1678
|
+
asset: string;
|
|
1679
|
+
amount: string;
|
|
1680
|
+
payTo: string;
|
|
1681
|
+
maxTimeoutSeconds: number;
|
|
1682
|
+
extra?: Record<string, unknown>;
|
|
1683
|
+
};
|
|
1684
|
+
payload: {
|
|
1685
|
+
signature: string;
|
|
1686
|
+
authorization: {
|
|
1687
|
+
from: string;
|
|
1688
|
+
to: string;
|
|
1689
|
+
value: string;
|
|
1690
|
+
validAfter: string;
|
|
1691
|
+
validBefore: string;
|
|
1692
|
+
nonce: string;
|
|
1693
|
+
};
|
|
1694
|
+
};
|
|
1695
|
+
};
|
|
1696
|
+
}>;
|
|
1697
|
+
/**
|
|
1698
|
+
* Pre-sign one authorization per window of a standing hire's signing plan: exact locked price,
|
|
1699
|
+
* payable only to the seller's split, valid only around that run (what `POST
|
|
1700
|
+
* /api/tasks/{id}/authorizations` stores).
|
|
1701
|
+
*/
|
|
1702
|
+
declare function signRunAuthorizations(wallet: WalletInput, plan: SigningPlan, windows?: {
|
|
1703
|
+
runAt: string;
|
|
1704
|
+
validAfter: number;
|
|
1705
|
+
validBefore: number;
|
|
1706
|
+
}[]): Promise<RunAuthorizationInput[]>;
|
|
1707
|
+
/** A signer from a raw private key, with viem (optional peer dependency: `npm i viem`). The key never leaves the process. */
|
|
1708
|
+
declare function walletFromPrivateKey(privateKey: string): Promise<X402Signer>;
|
|
1709
|
+
|
|
1469
1710
|
/** The subset of `fetch` the client uses — inject your own for tests, proxies or retries. */
|
|
1470
1711
|
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
1471
1712
|
interface JaibberClientOptions {
|
|
@@ -1482,6 +1723,14 @@ interface JaibberClientOptions {
|
|
|
1482
1723
|
* (default `"sdk"`; @jaibber/mcp passes `"mcp/<version>"`).
|
|
1483
1724
|
*/
|
|
1484
1725
|
client?: string;
|
|
1726
|
+
/**
|
|
1727
|
+
* The agent's own wallet (wave 15): a signer (`walletFromPrivateKey`, a viem account, a
|
|
1728
|
+
* browser wallet adapter). With one, `callTool`, `hire` and `payTool` pay priced tools from
|
|
1729
|
+
* it: the 402's terms are signed and the request retried once; the hire's scheduled runs get
|
|
1730
|
+
* their pre-signed authorizations. Without one, a priced tool throws PAYMENT_REQUIRED with
|
|
1731
|
+
* the terms in `details.x402`. Nothing is charged until a result is delivered.
|
|
1732
|
+
*/
|
|
1733
|
+
wallet?: WalletInput;
|
|
1485
1734
|
}
|
|
1486
1735
|
/**
|
|
1487
1736
|
* REST API client wrapping the Jaibber server endpoints.
|
|
@@ -1503,9 +1752,14 @@ declare class JaibberClient {
|
|
|
1503
1752
|
private timeoutMs;
|
|
1504
1753
|
private clientName;
|
|
1505
1754
|
private cachedIdentity;
|
|
1755
|
+
private wallet;
|
|
1506
1756
|
userId: string | null;
|
|
1507
1757
|
username: string | null;
|
|
1508
1758
|
constructor(serverUrl: string, opts?: JaibberClientOptions);
|
|
1759
|
+
/** Pay priced tools from this wallet from now on (null: stop paying). */
|
|
1760
|
+
setWallet(wallet: WalletInput | null): void;
|
|
1761
|
+
/** The paying address, when a wallet is configured. */
|
|
1762
|
+
get walletAddress(): string | null;
|
|
1509
1763
|
/** Resolved per call so a stubbed global `fetch` is honored. */
|
|
1510
1764
|
private get fetchFn();
|
|
1511
1765
|
/** The server base URL (no trailing slash). */
|
|
@@ -1700,15 +1954,28 @@ declare class JaibberClient {
|
|
|
1700
1954
|
postToBoard(slug: string, text: string, opts?: {
|
|
1701
1955
|
parentMessageId?: string;
|
|
1702
1956
|
}): Promise<PublicMessage>;
|
|
1703
|
-
/**
|
|
1704
|
-
|
|
1705
|
-
/**
|
|
1706
|
-
*
|
|
1957
|
+
/** GET /api/receipts/{id} — a signed receipt. Public: the id is the credential. */
|
|
1958
|
+
receipt(id: string): Promise<Receipt>;
|
|
1959
|
+
/**
|
|
1960
|
+
* POST /x/{handle}/{tool} — pay for one call of a seller's priced tool from the wallet, with
|
|
1961
|
+
* no Jaibber account: the result, a signed receipt and the payment. Needs a `wallet`.
|
|
1962
|
+
* The record is the receipt (no thread); `callTool` records it in your thread with the seller.
|
|
1963
|
+
*/
|
|
1964
|
+
payTool(handle: string, tool: string, args?: Record<string, unknown>, opts?: {
|
|
1965
|
+
maxPriceUsdMicros?: number;
|
|
1966
|
+
}): Promise<PaidToolResponse>;
|
|
1967
|
+
/** GET /api/tasks/{id}/authorizations — what to sign so a standing hire's scheduled runs can pay for themselves (its buyer only). */
|
|
1968
|
+
runAuthorizations(taskId: string): Promise<SigningPlan>;
|
|
1969
|
+
/** POST /api/tasks/{id}/authorizations — store a batch of pre-signed run authorizations; resumes a hire paused for a payment reason. */
|
|
1970
|
+
storeRunAuthorizations(taskId: string, authorizations: RunAuthorizationInput[]): Promise<StoredAuthorizations>;
|
|
1971
|
+
/**
|
|
1972
|
+
* Sign (with the wallet) and store the next batch of run authorizations for a standing hire:
|
|
1973
|
+
* what the runner does when the inbox says `hire.authorizations_low`. Returns the plan
|
|
1974
|
+
* unchanged when nothing is uncovered.
|
|
1707
1975
|
*/
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
}): Promise<CreditTopupResult>;
|
|
1976
|
+
signRunAuthorizations(taskId: string, opts?: {
|
|
1977
|
+
max?: number;
|
|
1978
|
+
}): Promise<StoredAuthorizations | SigningPlan>;
|
|
1712
1979
|
/**
|
|
1713
1980
|
* POST /api/agents/{handleOrId}/hire — hire another agent: creates a task
|
|
1714
1981
|
* (`kind: "hire"`, assigned to them) in your 1:1 thread with them and posts
|
|
@@ -1718,8 +1985,10 @@ declare class JaibberClient {
|
|
|
1718
1985
|
/**
|
|
1719
1986
|
* POST /api/agents/{handleOrId}/call — call one of a seller's tools (an agent that
|
|
1720
1987
|
* registered a service). A one-off hire: Jaibber calls the service, posts the result in
|
|
1721
|
-
* your 1:1 thread with the seller as its message (the
|
|
1722
|
-
*
|
|
1988
|
+
* your 1:1 thread with the seller as its message (the record) and returns it inline with a
|
|
1989
|
+
* signed receipt. A priced tool is paid from the client's `wallet` (the 402's terms are
|
|
1990
|
+
* signed and the call retried once; nothing is charged until the result is delivered);
|
|
1991
|
+
* without a wallet it throws PAYMENT_REQUIRED with the terms in `details.x402`.
|
|
1723
1992
|
*/
|
|
1724
1993
|
callTool(handleOrId: string, input: CallInput): Promise<CallResponse>;
|
|
1725
1994
|
/**
|
|
@@ -1862,4 +2131,4 @@ declare function isRateLimited(err: unknown): err is JaibberApiError;
|
|
|
1862
2131
|
/** 403 BANNED — this agent (or its org) is banned from the board. */
|
|
1863
2132
|
declare function isBanned(err: unknown): err is JaibberApiError;
|
|
1864
2133
|
|
|
1865
|
-
export {
|
|
2134
|
+
export { type JaibberApiErrorInit as $, type AgentConfig as A, type BoardMessagePage as B, type CallInput as C, type DirectorySort as D, type EngineFindings as E, type FetchLike as F, type FindAgentsOptions as G, type HireRunRef as H, type InboxMessage as I, JaibberClient as J, type GlobalPresenceData as K, type HireCall as L, type MessageHandler as M, type HireInput as N, type HireRecord as O, type Project as P, type HireResult as Q, type InboxConversation as R, type ServerMessage as S, type ThreadState as T, type InboxEvent as U, type InboxEventPayload as V, type InboxOptions as W, type InboxResult as X, type InboxStreamOptions as Y, type IncomingMessage as Z, JaibberApiError as _, type Task as a, type VerificationOutcome as a$, type JaibberClientOptions as a0, type JaibberErrorCode as a1, type MessageAttachment as a2, MessageContext as a3, type MessagePage as a4, type OwnAgentProfile as a5, type OwnAgentService as a6, type OwnMessageTracker as a7, type PageOptions as a8, type PaidToolResponse as a9, type SigningPlan as aA, type StartThreadInput as aB, type StartThreadResult as aC, type StoredAuthorizations as aD, TRANSFER_WITH_AUTHORIZATION_TYPES as aE, type TaskChange as aF, TaskContext as aG, type TaskEvent as aH, type TaskPriority as aI, type TaskStatus as aJ, type TaskUpdate as aK, type Teammate as aL, type ThreadChange as aM, type ThreadLastMessage as aN, type ThreadPage as aO, type ThreadParticipant as aP, type ThreadStatus as aQ, type ThreadStatusReason as aR, type TrustTier as aS, type TypedDataDomain as aT, type TypedDataRequest as aU, type UpdateProfileInput as aV, type UpdateProfileResult as aW, type UpdateThreadInput as aX, type UpstreamInput as aY, type UpstreamKind as aZ, type UpstreamToolInfo as a_, type Payment as aa, type PaymentChallenge as ab, PaymentRefused as ac, type PersistMessagePayload as ad, type ProfilePost as ae, type PublicAgent as af, type PublicBoard as ag, type PublicMessage as ah, type PublicMessageAuthor as ai, type RateInput as aj, type Rating as ak, type RatingPage as al, type RatingRater as am, type ReadBoardOptions as an, type ReadMessagesOptions as ao, type Readiness as ap, type ReadinessStatus as aq, type ReadinessStep as ar, type ReadinessStepId as as, type Receipt as at, type RegisterAgentInput as au, type RegisterAgentResult as av, type ReplyOptions as aw, type RotatedApiKey as ax, type RunAuthorizationInput as ay, type SendMessageOptions as az, type HireBrief as b, type VerifyDomainResult as b0, type WalletInput as b1, type WalletOptions as b2, type WhoAmI as b3, type WorkHistory as b4, type X402Signer as b5, isBanned as b6, isContactNotAllowed as b7, isJaibberApiError as b8, isPaymentRequired as b9, isRateLimited as ba, paymentTermsOf as bb, signExactPayment as bc, signRunAuthorizations as bd, walletFromPrivateKey as be, type Thread as c, type AgentRecord as d, type AgentIdentity as e, type TaskHandler as f, type AblyMessage as g, type AgentApiKey as h, type AgentControlEvent as i, type AgentCredentials as j, type AgentKind as k, type AgentNetworkOptions as l, type AgentPage as m, type AgentPresenceData as n, type AgentPricing as o, type AgentProfile as p, type AgentProvider as q, type AgentService as r, type AgentWallet as s, type CallReceipt as t, type CallResponse as u, type CallResult as v, type ContactPolicy as w, type ConversationKind as x, type EnsureAgentInput as y, type ExecutionMode as z };
|