@terminal3/t3n-sdk 5.15.2 → 5.16.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/index.js +1 -1
- package/dist/index.d.ts +63 -2
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3460,22 +3460,37 @@ declare class T3nClient {
|
|
|
3460
3460
|
* already exists from creation). All-or-nothing: any refusal creates
|
|
3461
3461
|
* no agent, no record, no card.
|
|
3462
3462
|
*
|
|
3463
|
+
* `options.initialCredits` pre-funds the new agent, in the SAME
|
|
3464
|
+
* transaction as creation, from the owning organisation's own T3N
|
|
3465
|
+
* balance — a freshly created agent otherwise starts with zero credit
|
|
3466
|
+
* and every metered action it takes fails, since metered actions bill
|
|
3467
|
+
* the acting DID's own balance. Internally dispatches into
|
|
3468
|
+
* `tee:admin.agent-credit-transfer` over contracts-call; the caller must
|
|
3469
|
+
* still be an admin of `organisationDid` (already required for
|
|
3470
|
+
* `create-agent` itself) and the org's own balance must cover the
|
|
3471
|
+
* amount, or the whole call refuses and nothing is created. To instead
|
|
3472
|
+
* fund an agent from your own personal balance, or any time after
|
|
3473
|
+
* creation, use {@link fundAgent}.
|
|
3474
|
+
*
|
|
3463
3475
|
* @param organisationDid - the owning organisation's DID
|
|
3464
3476
|
* (`did:t3n:<40-hex>`); the caller must be one of its admins
|
|
3465
3477
|
* @param name - human-readable agent name (1..=128 bytes)
|
|
3466
|
-
* @param options - optional atomic registration + card hosting
|
|
3478
|
+
* @param options - optional atomic registration + card hosting +
|
|
3479
|
+
* initial credit funding (`initialCredits`, in base units)
|
|
3467
3480
|
* @returns the new agent's DID and its one-time opaque `apiKey` + `keyId`,
|
|
3468
3481
|
* plus `agentUri` / `cardEntryId` (the hosted PRIVATE card's entry id)
|
|
3469
3482
|
* when the atomic path ran
|
|
3470
3483
|
* @throws if the session is not authenticated, or if the contract
|
|
3471
3484
|
* refuses (e.g. the caller is not an admin of `organisationDid`, the
|
|
3472
|
-
* name is empty / too long,
|
|
3485
|
+
* name is empty / too long, the card fails validation, or
|
|
3486
|
+
* `initialCredits` exceeds the org's available balance — in which
|
|
3473
3487
|
* case NOTHING was created)
|
|
3474
3488
|
*/
|
|
3475
3489
|
createAgent(organisationDid: string, name: string, options?: {
|
|
3476
3490
|
agentUri?: string;
|
|
3477
3491
|
card?: object | string;
|
|
3478
3492
|
defaultCard?: boolean;
|
|
3493
|
+
initialCredits?: number;
|
|
3479
3494
|
}): Promise<{
|
|
3480
3495
|
agentDid: Did;
|
|
3481
3496
|
apiKey: string;
|
|
@@ -3483,6 +3498,52 @@ declare class T3nClient {
|
|
|
3483
3498
|
agentUri?: string;
|
|
3484
3499
|
cardEntryId?: string;
|
|
3485
3500
|
}>;
|
|
3501
|
+
/**
|
|
3502
|
+
* Fund an agent DID's T3N credit balance so it can act. A freshly
|
|
3503
|
+
* created agent starts with zero credit (unless `createAgent` was called
|
|
3504
|
+
* with `initialCredits`), and every metered action is billed to the
|
|
3505
|
+
* agent's own DID — so an unfunded agent's first call fails.
|
|
3506
|
+
* Use this to fund an agent any time after it was created (not just at
|
|
3507
|
+
* creation).
|
|
3508
|
+
*
|
|
3509
|
+
* Dispatches `fund-agent` on `tee:organisation/contracts`, which forwards
|
|
3510
|
+
* into `tee:admin.agent-credit-transfer` over contracts-call. By default
|
|
3511
|
+
* the transfer comes from the CALLER'S OWN balance (self-funding) —
|
|
3512
|
+
* `tee:admin` requires the caller to administer at least one organisation
|
|
3513
|
+
* `agentDid` belongs to. Pass `options.fromOrg` to instead fund from an
|
|
3514
|
+
* organisation's own balance — `tee:admin` then requires the caller to
|
|
3515
|
+
* administer `fromOrg` AND `agentDid` to actually be a member of it.
|
|
3516
|
+
*
|
|
3517
|
+
* Authorisation is organisation MEMBERSHIP, not a check that `agentDid`
|
|
3518
|
+
* is specifically an agent: a human member of the same organisation is
|
|
3519
|
+
* an equally valid recipient (deliberate — see the WIT doc on
|
|
3520
|
+
* `agent-credit-transfer` in the contracts repo). `tee:admin`
|
|
3521
|
+
* independently re-verifies this before moving any credit, regardless of
|
|
3522
|
+
* what this SDK call or `tee:organisation` checked — this call can never
|
|
3523
|
+
* reach a DID with no membership row under an organisation the caller
|
|
3524
|
+
* administers, or move more than the source's real available balance.
|
|
3525
|
+
*
|
|
3526
|
+
* @param agentDid - the agent to fund (`did:t3n:<40-hex>` or bare hex)
|
|
3527
|
+
* @param amount - credit to transfer, in base units (see
|
|
3528
|
+
* {@link formatTokens} / {@link toBaseUnits} in `src/token/`). u128 on
|
|
3529
|
+
* the wire as a JSON number, same convention as {@link BalanceRow} —
|
|
3530
|
+
* values above `Number.MAX_SAFE_INTEGER` are not currently
|
|
3531
|
+
* representable; split into multiple calls if you need to move more.
|
|
3532
|
+
* @param options - `note` (recorded on the ledger's tx log — never put
|
|
3533
|
+
* secrets or PII in it, it's visible in both parties' usage feeds) and
|
|
3534
|
+
* `fromOrg` (fund from an org's balance instead of the caller's own)
|
|
3535
|
+
* @returns the ledger transaction's sequence number for this transfer
|
|
3536
|
+
* @throws if the session is not authenticated, if the caller does not
|
|
3537
|
+
* administer any organisation `agentDid` belongs to (or isn't an admin
|
|
3538
|
+
* of `options.fromOrg`, or `agentDid` isn't a member of `fromOrg`), or
|
|
3539
|
+
* if the source balance is insufficient
|
|
3540
|
+
*/
|
|
3541
|
+
fundAgent(agentDid: string, amount: number, options?: {
|
|
3542
|
+
note?: string;
|
|
3543
|
+
fromOrg?: string;
|
|
3544
|
+
}): Promise<{
|
|
3545
|
+
seqNo: number;
|
|
3546
|
+
}>;
|
|
3486
3547
|
/**
|
|
3487
3548
|
* Normalise an organisation / user DID to the bare 40-hex form the
|
|
3488
3549
|
* `tee:organisation` contract's organisation-lifecycle exports
|