@agenticprimitives/treasury-service-agent
v0.0.0-alpha.4
Published
Intent-native DeFi Treasury Agent (spec 284): a domain composition over service-agent — skill catalog + profiles + treasury authority-scope/receipt helpers, evolving toward intent resolution, solver brokering, and DAG execution. Catalog = definitions + pl
Downloads
80
Maintainers
Readme
@agenticprimitives/treasury-service-agent
Status: experimental (spec 284 PR-A — relocated from
packages/treasury).
The intent-native DeFi Treasury Agent: an intent compiler + DeFi skill fabric + solver broker +
settlement coordinator (see spec 284). A domain
composition over @agenticprimitives/service-agent, not a generic
packages/* primitive.
PR-A ships the catalog/profiles baseline — the wallet-operation surface as vendor-neutral skill
definitions, plans, and profiles (this is the payments profile of the larger agent). Intent resolution,
solver brokering, DAG execution, autonomous strategies, and risk land in later phases. Catalog =
definitions + plans only — no provider implementations. Concrete providers (EVM transfer/sign,
swap/perp/prediction venues, market data, RPC) live in external repos (ADR-0037) and register into the host;
the demo apps ship fakes.
What's inside
TREASURY_CAPABILITIES— the logical capability vocabulary skills require (account.read,transfer.execute,signing.sign,swap.execute, …).- Catalog — ~26 skills across service / network / account / market-data / signing / transaction /
transfer / swap / perp / prediction / delegation / entitlement. Each declares an
effect(read|sign|spend|trade|admin), a defaultexposure, required capabilities, and acompile()→ plan. - Profiles —
readonly,payments,markets,administration,full. TreasuryAuthorityScope+treasuryScopeToCaveatTerms— the neutral input to the connect-treasury ceremony; the ceremony maps the abstract caveat terms onto realdelegationcaveats.summarizeTreasuryReceipt— projects the genericExecutionReceiptinto a treasury audit summary.
Gating
| skill kind | exposure | gates | | --- | --- | --- | | service / network / market-data | public | none | | account / quote / positions / simulate / entitlement.check | authenticated | entitlement | | transfer / swap.execute / perp / prediction.bet | authenticated | entitlement ∩ delegation ∩ policy (+ ledger reserve/finalize) | | signing / transaction.send / delegation.* / entitlement.issue/consume | private | entitlement ∩ delegation ∩ policy |
Gates are fail-closed and monotonic — the first denial throws and nothing further runs. Asserting a skill proves the host can run it; per-call authority is still decided fresh at invoke.
Example
import { ServiceAgent, createPrimitiveRegistry } from '@agenticprimitives/service-agent';
import { paymentsProfile, ASSET_TYPE } from '@agenticprimitives/treasury';
const registry = createPrimitiveRegistry();
registry.register(myTransferProvider); // advertises 'transfer.execute' (external / fake)
// …register account/network/market-data providers…
const agent = new ServiceAgent({
descriptor: { id: treasurySaAddress, name: 'Treasury', version: '1.0.0' },
primitives: registry,
entitlements, delegations, policies, ledger, // injected: tool-policy / delegation / entitlements / ledger
});
agent.defineProfile(paymentsProfile);
await agent.assert(); // asserts the skills whose providers are present
const receipt = await agent.invoke({
skillId: 'treasury.transfer.native',
input: { account: treasurySaAddress, network: 'eip155:84532', to, asset: { type: ASSET_TYPE.native }, amount: '100' },
idempotencyKey: 'transfer-0001',
});What lives elsewhere
- The framework (registry, plan runner,
ServiceAgent, assertion) →@agenticprimitives/service-agent. - Providers → external repos (ADR-0037); fakes → the demo apps (PR3) + this package's tests.
- The connect-treasury ceremony + a treasury UI → demo-sso-next / demo-web-payment (PR4).
