@agenticprimitives/treasury-service-agent 0.0.0-alpha.4
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/LICENSE +21 -0
- package/README.md +70 -0
- package/dist/benchmarks/benchmark.d.ts +28 -0
- package/dist/benchmarks/benchmark.d.ts.map +1 -0
- package/dist/benchmarks/benchmark.js +26 -0
- package/dist/benchmarks/benchmark.js.map +1 -0
- package/dist/benchmarks/suite.d.ts +11 -0
- package/dist/benchmarks/suite.d.ts.map +1 -0
- package/dist/benchmarks/suite.js +166 -0
- package/dist/benchmarks/suite.js.map +1 -0
- package/dist/capabilities.d.ts +68 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +68 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/catalog-defi.d.ts +29 -0
- package/dist/catalog-defi.d.ts.map +1 -0
- package/dist/catalog-defi.js +79 -0
- package/dist/catalog-defi.js.map +1 -0
- package/dist/catalog.d.ts +86 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +199 -0
- package/dist/catalog.js.map +1 -0
- package/dist/dispatch/delegation-authority.d.ts +58 -0
- package/dist/dispatch/delegation-authority.d.ts.map +1 -0
- package/dist/dispatch/delegation-authority.js +62 -0
- package/dist/dispatch/delegation-authority.js.map +1 -0
- package/dist/grant.d.ts +34 -0
- package/dist/grant.d.ts.map +1 -0
- package/dist/grant.js +40 -0
- package/dist/grant.js.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/intents/intent-types.d.ts +65 -0
- package/dist/intents/intent-types.d.ts.map +1 -0
- package/dist/intents/intent-types.js +44 -0
- package/dist/intents/intent-types.js.map +1 -0
- package/dist/intents/resolved-treasury-order.d.ts +38 -0
- package/dist/intents/resolved-treasury-order.d.ts.map +1 -0
- package/dist/intents/resolved-treasury-order.js +2 -0
- package/dist/intents/resolved-treasury-order.js.map +1 -0
- package/dist/intents/treasury-intent-resolver.d.ts +30 -0
- package/dist/intents/treasury-intent-resolver.d.ts.map +1 -0
- package/dist/intents/treasury-intent-resolver.js +113 -0
- package/dist/intents/treasury-intent-resolver.js.map +1 -0
- package/dist/payments/order-to-mandate.d.ts +31 -0
- package/dist/payments/order-to-mandate.d.ts.map +1 -0
- package/dist/payments/order-to-mandate.js +46 -0
- package/dist/payments/order-to-mandate.js.map +1 -0
- package/dist/plans.d.ts +27 -0
- package/dist/plans.d.ts.map +1 -0
- package/dist/plans.js +47 -0
- package/dist/plans.js.map +1 -0
- package/dist/plugins/defi-plugin.d.ts +54 -0
- package/dist/plugins/defi-plugin.d.ts.map +1 -0
- package/dist/plugins/defi-plugin.js +30 -0
- package/dist/plugins/defi-plugin.js.map +1 -0
- package/dist/profiles.d.ts +92 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +60 -0
- package/dist/profiles.js.map +1 -0
- package/dist/receipt.d.ts +16 -0
- package/dist/receipt.d.ts.map +1 -0
- package/dist/receipt.js +16 -0
- package/dist/receipt.js.map +1 -0
- package/dist/risk/risk-policy.d.ts +44 -0
- package/dist/risk/risk-policy.d.ts.map +1 -0
- package/dist/risk/risk-policy.js +50 -0
- package/dist/risk/risk-policy.js.map +1 -0
- package/dist/schemas.d.ts +68 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +24 -0
- package/dist/schemas.js.map +1 -0
- package/dist/solvers/broker.d.ts +24 -0
- package/dist/solvers/broker.d.ts.map +1 -0
- package/dist/solvers/broker.js +43 -0
- package/dist/solvers/broker.js.map +1 -0
- package/dist/solvers/digest.d.ts +5 -0
- package/dist/solvers/digest.d.ts.map +1 -0
- package/dist/solvers/digest.js +27 -0
- package/dist/solvers/digest.js.map +1 -0
- package/dist/solvers/plan-validation.d.ts +40 -0
- package/dist/solvers/plan-validation.d.ts.map +1 -0
- package/dist/solvers/plan-validation.js +66 -0
- package/dist/solvers/plan-validation.js.map +1 -0
- package/dist/solvers/quote-ranking.d.ts +47 -0
- package/dist/solvers/quote-ranking.d.ts.map +1 -0
- package/dist/solvers/quote-ranking.js +48 -0
- package/dist/solvers/quote-ranking.js.map +1 -0
- package/dist/solvers/solver-port.d.ts +104 -0
- package/dist/solvers/solver-port.d.ts.map +1 -0
- package/dist/solvers/solver-port.js +2 -0
- package/dist/solvers/solver-port.js.map +1 -0
- package/dist/strategy/strategy-controller.d.ts +36 -0
- package/dist/strategy/strategy-controller.d.ts.map +1 -0
- package/dist/strategy/strategy-controller.js +66 -0
- package/dist/strategy/strategy-controller.js.map +1 -0
- package/dist/strategy/strategy-definition.d.ts +55 -0
- package/dist/strategy/strategy-definition.d.ts.map +1 -0
- package/dist/strategy/strategy-definition.js +39 -0
- package/dist/strategy/strategy-definition.js.map +1 -0
- package/dist/strategy/triggers.d.ts +27 -0
- package/dist/strategy/triggers.d.ts.map +1 -0
- package/dist/strategy/triggers.js +22 -0
- package/dist/strategy/triggers.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// DeFi family catalog (spec 284 PR-E) — lending / staking / liquidity / vaults / bridge / portfolio, as
|
|
2
|
+
// vendor-neutral skill DEFINITIONS. These are DEFERRED-ASSERTED: they require capabilities no provider
|
|
3
|
+
// advertises by default, so a host asserts them only once a DeFiPrimitivePlugin advertising the capability
|
|
4
|
+
// is installed (gate honesty, spec 284). Same gating discipline as the wallet baseline: reads are
|
|
5
|
+
// entitlement-gated; value-movers gate entitlement ∩ delegation ∩ policy (+ ledger via spendPlan);
|
|
6
|
+
// recover/migrate are `private` admin. Providers are external (ADR-0037); tests/demos ship fakes.
|
|
7
|
+
import { defineSkill } from '@agenticprimitives/service-agent';
|
|
8
|
+
import { ASSET_TYPE, TREASURY_CAPABILITIES as CAP } from './capabilities.js';
|
|
9
|
+
import { adminPlan, authedReadPlan, spendPlan } from './plans.js';
|
|
10
|
+
import { objectSchema } from './schemas.js';
|
|
11
|
+
import { SKILL_VERSION } from './catalog.js';
|
|
12
|
+
const idem = (k) => k ?? '';
|
|
13
|
+
/** A read skill: caller-entitlement gate, then a provider read. */
|
|
14
|
+
function readSkill(id, name, capability, exposure = 'authenticated') {
|
|
15
|
+
return defineSkill({
|
|
16
|
+
id, version: SKILL_VERSION, name, effect: 'read', defaultExposure: exposure, requires: [{ capability }],
|
|
17
|
+
compile: ({ input }) => authedReadPlan(id, capability, { ...input }, id, input.account),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/** A value-moving skill: full gating + ledger reserve/finalize around execution. */
|
|
21
|
+
function spendSkill(id, name, capability) {
|
|
22
|
+
return defineSkill({
|
|
23
|
+
id, version: SKILL_VERSION, name, effect: 'spend', defaultExposure: 'authenticated', requires: [{ capability }],
|
|
24
|
+
inputSchema: objectSchema(`${id}Input`, { account: 'string', network: 'string', amount: 'string' }),
|
|
25
|
+
compile: ({ input, context }) => spendPlan({
|
|
26
|
+
id, capability, action: id, resource: input.account, stepArgs: { ...input },
|
|
27
|
+
ledger: { accountId: input.account, asset: input.asset?.address ?? ASSET_TYPE.erc20, amount: input.amount, idempotencyKey: idem(context.idempotencyKey) },
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** A gated skill with no ledger reserve (value-in / position change): full gating, single step. */
|
|
32
|
+
function gatedSkill(id, name, capability, effect = 'trade', exposure = 'authenticated') {
|
|
33
|
+
return defineSkill({
|
|
34
|
+
id, version: SKILL_VERSION, name, effect, defaultExposure: exposure, requires: [{ capability }],
|
|
35
|
+
inputSchema: objectSchema(`${id}Input`, { account: 'string' }),
|
|
36
|
+
compile: ({ input }) => adminPlan(id, capability, { ...input }, id, input.account),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
// ── portfolio ──────────────────────────────────────────────────────────────────
|
|
40
|
+
export const portfolioSnapshot = readSkill('treasury.portfolio.snapshot', 'Portfolio snapshot', CAP.portfolioRead);
|
|
41
|
+
export const portfolioValue = readSkill('treasury.portfolio.value', 'Portfolio value', CAP.portfolioRead);
|
|
42
|
+
export const portfolioExposure = readSkill('treasury.portfolio.exposure', 'Portfolio exposure', CAP.portfolioRead);
|
|
43
|
+
export const portfolioRebalance = gatedSkill('treasury.portfolio.rebalance', 'Rebalance portfolio', CAP.portfolioRebalance, 'trade');
|
|
44
|
+
// ── lending ──────────────────────────────────────────────────────────────────
|
|
45
|
+
export const lendingPosition = readSkill('treasury.lending.position', 'Lending position', CAP.lendingRead);
|
|
46
|
+
export const lendingSupply = spendSkill('treasury.lending.supply', 'Supply to lending market', CAP.lendingExecute);
|
|
47
|
+
export const lendingRepay = spendSkill('treasury.lending.repay', 'Repay loan', CAP.lendingExecute);
|
|
48
|
+
export const lendingWithdraw = gatedSkill('treasury.lending.withdraw', 'Withdraw supply', CAP.lendingExecute, 'trade');
|
|
49
|
+
export const lendingBorrow = gatedSkill('treasury.lending.borrow', 'Borrow', CAP.lendingExecute, 'trade');
|
|
50
|
+
// ── staking ────────────────────────────────────────────────────────────────────
|
|
51
|
+
export const stakingPosition = readSkill('treasury.staking.position', 'Staking position', CAP.stakingRead);
|
|
52
|
+
export const stakingStake = spendSkill('treasury.staking.stake', 'Stake', CAP.stakingExecute);
|
|
53
|
+
export const stakingUnstake = gatedSkill('treasury.staking.unstake', 'Unstake', CAP.stakingExecute, 'trade');
|
|
54
|
+
export const stakingClaim = gatedSkill('treasury.staking.claim', 'Claim staking rewards', CAP.stakingExecute, 'trade');
|
|
55
|
+
// ── liquidity ──────────────────────────────────────────────────────────────────
|
|
56
|
+
export const liquidityPosition = readSkill('treasury.liquidity.position', 'Liquidity position', CAP.liquidityRead);
|
|
57
|
+
export const liquidityAdd = spendSkill('treasury.liquidity.add', 'Add liquidity', CAP.liquidityExecute);
|
|
58
|
+
export const liquidityRemove = gatedSkill('treasury.liquidity.remove', 'Remove liquidity', CAP.liquidityExecute, 'trade');
|
|
59
|
+
export const liquidityCollectFees = gatedSkill('treasury.liquidity.collect-fees', 'Collect LP fees', CAP.liquidityExecute, 'trade');
|
|
60
|
+
// ── vaults ─────────────────────────────────────────────────────────────────────
|
|
61
|
+
export const vaultPosition = readSkill('treasury.vault.position', 'Vault position', CAP.vaultRead);
|
|
62
|
+
export const vaultDeposit = spendSkill('treasury.vault.deposit', 'Deposit to vault', CAP.vaultExecute);
|
|
63
|
+
export const vaultWithdraw = gatedSkill('treasury.vault.withdraw', 'Withdraw from vault', CAP.vaultExecute, 'trade');
|
|
64
|
+
export const vaultMigrate = gatedSkill('treasury.vault.migrate', 'Migrate vault position', CAP.vaultExecute, 'admin', 'private');
|
|
65
|
+
// ── cross-chain bridge ──────────────────────────────────────────────────────────
|
|
66
|
+
export const bridgeQuote = readSkill('treasury.bridge.quote', 'Bridge quote', CAP.bridgeQuote);
|
|
67
|
+
export const bridgeStatus = readSkill('treasury.bridge.status', 'Bridge status', CAP.bridgeRead);
|
|
68
|
+
export const bridgeExecute = spendSkill('treasury.bridge.execute', 'Execute bridge transfer', CAP.bridgeExecute);
|
|
69
|
+
export const bridgeRecover = gatedSkill('treasury.bridge.recover', 'Recover stuck bridge transfer', CAP.bridgeExecute, 'admin', 'private');
|
|
70
|
+
/** Every DeFi-family skill, in catalog order. */
|
|
71
|
+
export const DEFI_SKILLS = [
|
|
72
|
+
portfolioSnapshot, portfolioValue, portfolioExposure, portfolioRebalance,
|
|
73
|
+
lendingPosition, lendingSupply, lendingRepay, lendingWithdraw, lendingBorrow,
|
|
74
|
+
stakingPosition, stakingStake, stakingUnstake, stakingClaim,
|
|
75
|
+
liquidityPosition, liquidityAdd, liquidityRemove, liquidityCollectFees,
|
|
76
|
+
vaultPosition, vaultDeposit, vaultWithdraw, vaultMigrate,
|
|
77
|
+
bridgeQuote, bridgeStatus, bridgeExecute, bridgeRecover,
|
|
78
|
+
];
|
|
79
|
+
//# sourceMappingURL=catalog-defi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-defi.js","sourceRoot":"","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,CAAC,WAAW,CAAC,CAAC;AAC/F,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC,wBAAwB,EAAE,eAAe,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;AACjG,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC,yBAAyB,EAAE,yBAAyB,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;AACjH,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC,yBAAyB,EAAE,+BAA+B,EAAE,GAAG,CAAC,aAAa,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AAE3I,iDAAiD;AACjD,MAAM,CAAC,MAAM,WAAW,GAAyB;IAC/C,iBAAiB,EAAE,cAAc,EAAE,iBAAiB,EAAE,kBAAkB;IACxE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa;IAC5E,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY;IAC3D,iBAAiB,EAAE,YAAY,EAAE,eAAe,EAAE,oBAAoB;IACtE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY;IACxD,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa;CACxD,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type AnySkillDefinition } from '@agenticprimitives/service-agent';
|
|
2
|
+
import { type SignInput, type SwapExecuteInput, type RawTxInput, type TransferInput } from './schemas.js';
|
|
3
|
+
export declare const SKILL_VERSION = "1.0.0";
|
|
4
|
+
export declare const serviceInfo: import("@agenticprimitives/service-agent").SkillDefinition<unknown, unknown>;
|
|
5
|
+
export declare const networkList: import("@agenticprimitives/service-agent").SkillDefinition<unknown, unknown>;
|
|
6
|
+
export declare const networkStatus: import("@agenticprimitives/service-agent").SkillDefinition<{
|
|
7
|
+
network: string;
|
|
8
|
+
}, unknown>;
|
|
9
|
+
export declare const accountList: import("@agenticprimitives/service-agent").SkillDefinition<unknown, unknown>;
|
|
10
|
+
export declare const accountBalance: import("@agenticprimitives/service-agent").SkillDefinition<{
|
|
11
|
+
account: string;
|
|
12
|
+
network?: string;
|
|
13
|
+
}, unknown>;
|
|
14
|
+
export declare const accountActivity: import("@agenticprimitives/service-agent").SkillDefinition<{
|
|
15
|
+
account: string;
|
|
16
|
+
network?: string;
|
|
17
|
+
}, unknown>;
|
|
18
|
+
export declare const marketDataPrice: import("@agenticprimitives/service-agent").SkillDefinition<{
|
|
19
|
+
network: string;
|
|
20
|
+
asset: string;
|
|
21
|
+
}, unknown>;
|
|
22
|
+
export declare const marketDataOhlcv: import("@agenticprimitives/service-agent").SkillDefinition<{
|
|
23
|
+
network: string;
|
|
24
|
+
asset: string;
|
|
25
|
+
interval: string;
|
|
26
|
+
}, unknown>;
|
|
27
|
+
export declare const signMessage: import("@agenticprimitives/service-agent").SkillDefinition<SignInput, unknown>;
|
|
28
|
+
export declare const signTypedData: import("@agenticprimitives/service-agent").SkillDefinition<SignInput, unknown>;
|
|
29
|
+
export declare const txSimulate: import("@agenticprimitives/service-agent").SkillDefinition<RawTxInput, unknown>;
|
|
30
|
+
export declare const txSend: import("@agenticprimitives/service-agent").SkillDefinition<RawTxInput, unknown>;
|
|
31
|
+
export declare const transferNative: import("@agenticprimitives/service-agent").SkillDefinition<TransferInput, unknown>;
|
|
32
|
+
export declare const transferToken: import("@agenticprimitives/service-agent").SkillDefinition<TransferInput, unknown>;
|
|
33
|
+
export declare const swapQuote: import("@agenticprimitives/service-agent").SkillDefinition<{
|
|
34
|
+
network: string;
|
|
35
|
+
sell: unknown;
|
|
36
|
+
buy: unknown;
|
|
37
|
+
amount: string;
|
|
38
|
+
}, unknown>;
|
|
39
|
+
export declare const swapExecute: import("@agenticprimitives/service-agent").SkillDefinition<SwapExecuteInput, unknown>;
|
|
40
|
+
export declare const perpPositions: import("@agenticprimitives/service-agent").SkillDefinition<{
|
|
41
|
+
account: string;
|
|
42
|
+
}, unknown>;
|
|
43
|
+
export declare const perpOpen: import("@agenticprimitives/service-agent").SkillDefinition<{
|
|
44
|
+
account: string;
|
|
45
|
+
market: string;
|
|
46
|
+
side: string;
|
|
47
|
+
margin: string;
|
|
48
|
+
}, unknown>;
|
|
49
|
+
export declare const perpClose: import("@agenticprimitives/service-agent").SkillDefinition<{
|
|
50
|
+
account: string;
|
|
51
|
+
market: string;
|
|
52
|
+
}, unknown>;
|
|
53
|
+
export declare const predictionMarkets: import("@agenticprimitives/service-agent").SkillDefinition<{
|
|
54
|
+
query?: string;
|
|
55
|
+
}, unknown>;
|
|
56
|
+
export declare const predictionBet: import("@agenticprimitives/service-agent").SkillDefinition<{
|
|
57
|
+
account: string;
|
|
58
|
+
market: string;
|
|
59
|
+
outcome: string;
|
|
60
|
+
stake: string;
|
|
61
|
+
}, unknown>;
|
|
62
|
+
export declare const delegationGrant: import("@agenticprimitives/service-agent").SkillDefinition<{
|
|
63
|
+
account: string;
|
|
64
|
+
delegate: string;
|
|
65
|
+
caveats: unknown;
|
|
66
|
+
}, unknown>;
|
|
67
|
+
export declare const delegationRevoke: import("@agenticprimitives/service-agent").SkillDefinition<{
|
|
68
|
+
account: string;
|
|
69
|
+
delegationId: string;
|
|
70
|
+
}, unknown>;
|
|
71
|
+
export declare const entitlementCheck: import("@agenticprimitives/service-agent").SkillDefinition<{
|
|
72
|
+
account: string;
|
|
73
|
+
entitlementId: string;
|
|
74
|
+
}, unknown>;
|
|
75
|
+
export declare const entitlementIssue: import("@agenticprimitives/service-agent").SkillDefinition<{
|
|
76
|
+
account: string;
|
|
77
|
+
subject: string;
|
|
78
|
+
scope: unknown;
|
|
79
|
+
}, unknown>;
|
|
80
|
+
export declare const entitlementConsume: import("@agenticprimitives/service-agent").SkillDefinition<{
|
|
81
|
+
account: string;
|
|
82
|
+
entitlementId: string;
|
|
83
|
+
}, unknown>;
|
|
84
|
+
/** Every catalog skill, in catalog order. */
|
|
85
|
+
export declare const ALL_TREASURY_SKILLS: AnySkillDefinition[];
|
|
86
|
+
//# sourceMappingURL=catalog.d.ts.map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MAAM,SAAS;aAA0B,MAAM;YAAU,MAAM;WAKpE,CAAC;AAGH,eAAO,MAAM,iBAAiB;YAAyB,MAAM;WAI3D,CAAC;AACH,eAAO,MAAM,aAAa;aAA0B,MAAM;YAAU,MAAM;aAAW,MAAM;WAAS,MAAM;WAQxG,CAAC;AAGH,eAAO,MAAM,eAAe;aAA0B,MAAM;cAAY,MAAM;aAAW,OAAO;WAK9F,CAAC;AACH,eAAO,MAAM,gBAAgB;aAA0B,MAAM;kBAAgB,MAAM;WAKjF,CAAC;AAGH,eAAO,MAAM,gBAAgB;aAA0B,MAAM;mBAAiB,MAAM;WAIlF,CAAC;AACH,eAAO,MAAM,gBAAgB;aAA0B,MAAM;aAAW,MAAM;WAAS,OAAO;WAK5F,CAAC;AACH,eAAO,MAAM,kBAAkB;aAA0B,MAAM;mBAAiB,MAAM;WAKpF,CAAC;AAEH,6CAA6C;AAC7C,eAAO,MAAM,mBAAmB,EAAE,kBAAkB,EAYnD,CAAC"}
|
package/dist/catalog.js
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// Treasury skill catalog (spec 283) — the wallet/exchange feature-parity surface as vendor-neutral skill
|
|
2
|
+
// DEFINITIONS (the source vendor is a parity checklist only; no vendor branding or SDK enters this code).
|
|
3
|
+
// Each skill states its meaning (effect, exposure, required capability, plan); none implements a provider.
|
|
4
|
+
// Read/public skills carry no authority gates; spend/trade/sign/admin skills gate
|
|
5
|
+
// entitlement ∩ delegation ∩ policy, and value-movers reserve/finalize the ledger around execution.
|
|
6
|
+
// Admin / signing / raw-tx skills are `private` (asserted but never projected to a remote card).
|
|
7
|
+
import { defineSkill } from '@agenticprimitives/service-agent';
|
|
8
|
+
import { ASSET_TYPE, TREASURY_CAPABILITIES as CAP } from './capabilities.js';
|
|
9
|
+
import { adminPlan, authedReadPlan, readPlan, signPlan, spendPlan } from './plans.js';
|
|
10
|
+
import { objectSchema, } from './schemas.js';
|
|
11
|
+
export const SKILL_VERSION = '1.0.0';
|
|
12
|
+
const idem = (k) => k ?? '';
|
|
13
|
+
// ── service / network ──────────────────────────────────────────────────────
|
|
14
|
+
export const serviceInfo = defineSkill({
|
|
15
|
+
id: 'treasury.service.info', version: SKILL_VERSION, name: 'Service info', effect: 'read', defaultExposure: 'public',
|
|
16
|
+
requires: [],
|
|
17
|
+
compile: () => ({ id: 'treasury.service.info', steps: [], outputSpec: { service: 'treasury', version: SKILL_VERSION } }),
|
|
18
|
+
});
|
|
19
|
+
export const networkList = defineSkill({
|
|
20
|
+
id: 'treasury.network.list', version: SKILL_VERSION, name: 'List networks', effect: 'read', defaultExposure: 'public',
|
|
21
|
+
requires: [{ capability: CAP.networkRead }],
|
|
22
|
+
compile: () => readPlan('treasury.network.list', CAP.networkRead, {}),
|
|
23
|
+
});
|
|
24
|
+
export const networkStatus = defineSkill({
|
|
25
|
+
id: 'treasury.network.status', version: SKILL_VERSION, name: 'Network status', effect: 'read', defaultExposure: 'public',
|
|
26
|
+
requires: [{ capability: CAP.networkRead }],
|
|
27
|
+
compile: ({ input }) => readPlan('treasury.network.status', CAP.networkRead, { network: input.network }),
|
|
28
|
+
});
|
|
29
|
+
// ── account ──────────────────────────────────────────────────────────────────
|
|
30
|
+
export const accountList = defineSkill({
|
|
31
|
+
id: 'treasury.account.list', version: SKILL_VERSION, name: 'List accounts', effect: 'read', defaultExposure: 'authenticated',
|
|
32
|
+
requires: [{ capability: CAP.accountRead }],
|
|
33
|
+
compile: () => authedReadPlan('treasury.account.list', CAP.accountRead, {}, 'treasury.account.list', undefined),
|
|
34
|
+
});
|
|
35
|
+
export const accountBalance = defineSkill({
|
|
36
|
+
id: 'treasury.account.balance', version: SKILL_VERSION, name: 'Account balance', effect: 'read', defaultExposure: 'authenticated',
|
|
37
|
+
requires: [{ capability: CAP.accountRead }],
|
|
38
|
+
compile: ({ input }) => authedReadPlan('treasury.account.balance', CAP.accountRead, { account: input.account, network: input.network }, 'treasury.account.balance', input.account),
|
|
39
|
+
});
|
|
40
|
+
export const accountActivity = defineSkill({
|
|
41
|
+
id: 'treasury.account.activity', version: SKILL_VERSION, name: 'Account activity', effect: 'read', defaultExposure: 'authenticated',
|
|
42
|
+
requires: [{ capability: CAP.accountRead }],
|
|
43
|
+
compile: ({ input }) => authedReadPlan('treasury.account.activity', CAP.accountRead, { account: input.account, network: input.network }, 'treasury.account.activity', input.account),
|
|
44
|
+
});
|
|
45
|
+
// ── market data ────────────────────────────────────────────────────────────────
|
|
46
|
+
export const marketDataPrice = defineSkill({
|
|
47
|
+
id: 'treasury.market-data.price', version: SKILL_VERSION, name: 'Asset price', effect: 'read', defaultExposure: 'public',
|
|
48
|
+
requires: [{ capability: CAP.marketDataRead }],
|
|
49
|
+
compile: ({ input }) => readPlan('treasury.market-data.price', CAP.marketDataRead, { network: input.network, asset: input.asset }),
|
|
50
|
+
});
|
|
51
|
+
export const marketDataOhlcv = defineSkill({
|
|
52
|
+
id: 'treasury.market-data.ohlcv', version: SKILL_VERSION, name: 'Price history', effect: 'read', defaultExposure: 'public',
|
|
53
|
+
requires: [{ capability: CAP.marketDataRead }],
|
|
54
|
+
compile: ({ input }) => readPlan('treasury.market-data.ohlcv', CAP.marketDataRead, { network: input.network, asset: input.asset, interval: input.interval }),
|
|
55
|
+
});
|
|
56
|
+
// ── signing (private) ─────────────────────────────────────────────────────────
|
|
57
|
+
const signSchema = objectSchema('SignInput', { account: 'string', payload: 'string', kind: 'string' });
|
|
58
|
+
export const signMessage = defineSkill({
|
|
59
|
+
id: 'treasury.signing.message', version: SKILL_VERSION, name: 'Sign message', effect: 'sign', defaultExposure: 'private',
|
|
60
|
+
requires: [{ capability: CAP.sign }], inputSchema: signSchema,
|
|
61
|
+
compile: ({ input }) => signPlan('treasury.signing.message', { account: input.account, payload: input.payload, kind: 'message' }, 'treasury.signing.message', input.account),
|
|
62
|
+
});
|
|
63
|
+
export const signTypedData = defineSkill({
|
|
64
|
+
id: 'treasury.signing.typed-data', version: SKILL_VERSION, name: 'Sign typed data', effect: 'sign', defaultExposure: 'private',
|
|
65
|
+
requires: [{ capability: CAP.sign }], inputSchema: signSchema,
|
|
66
|
+
compile: ({ input }) => signPlan('treasury.signing.typed-data', { account: input.account, payload: input.payload, kind: 'typed-data' }, 'treasury.signing.typed-data', input.account),
|
|
67
|
+
});
|
|
68
|
+
// ── transaction ────────────────────────────────────────────────────────────────
|
|
69
|
+
export const txSimulate = defineSkill({
|
|
70
|
+
id: 'treasury.transaction.simulate', version: SKILL_VERSION, name: 'Simulate transaction', effect: 'read', defaultExposure: 'authenticated',
|
|
71
|
+
requires: [{ capability: CAP.txSimulate }],
|
|
72
|
+
compile: ({ input }) => authedReadPlan('treasury.transaction.simulate', CAP.txSimulate, { ...input }, 'treasury.transaction.simulate', input.account),
|
|
73
|
+
});
|
|
74
|
+
export const txSend = defineSkill({
|
|
75
|
+
id: 'treasury.transaction.send', version: SKILL_VERSION, name: 'Send raw transaction', effect: 'admin', defaultExposure: 'private',
|
|
76
|
+
requires: [{ capability: CAP.txSend }],
|
|
77
|
+
inputSchema: objectSchema('RawTxInput', { account: 'string', network: 'string', to: 'string' }),
|
|
78
|
+
compile: ({ input, context }) => spendPlan({
|
|
79
|
+
id: 'treasury.transaction.send', capability: CAP.txSend, action: 'treasury.transaction.send', resource: input.account,
|
|
80
|
+
stepArgs: { ...input }, ledger: { accountId: input.account, asset: ASSET_TYPE.native, amount: input.value ?? '0', idempotencyKey: idem(context.idempotencyKey) },
|
|
81
|
+
}),
|
|
82
|
+
});
|
|
83
|
+
// ── transfer (payments profile — REAL via the host's payments/x402 rail) ────────
|
|
84
|
+
const transferSchema = objectSchema('TransferInput', { account: 'string', network: 'string', to: 'string', amount: 'string', asset: 'object' });
|
|
85
|
+
export const transferNative = defineSkill({
|
|
86
|
+
id: 'treasury.transfer.native', version: SKILL_VERSION, name: 'Transfer native', effect: 'spend', defaultExposure: 'authenticated',
|
|
87
|
+
requires: [{ capability: CAP.transferExecute, constraints: { assetTypes: [ASSET_TYPE.native] } }], inputSchema: transferSchema,
|
|
88
|
+
compile: ({ input, context }) => spendPlan({
|
|
89
|
+
id: 'treasury.transfer.native', capability: CAP.transferExecute, action: 'treasury.transfer.native', resource: input.account,
|
|
90
|
+
stepArgs: { account: input.account, network: input.network, to: input.to, asset: input.asset, amount: input.amount, memo: input.memo },
|
|
91
|
+
ledger: { accountId: input.account, asset: ASSET_TYPE.native, amount: input.amount, idempotencyKey: idem(context.idempotencyKey) },
|
|
92
|
+
}),
|
|
93
|
+
});
|
|
94
|
+
export const transferToken = defineSkill({
|
|
95
|
+
id: 'treasury.transfer.token', version: SKILL_VERSION, name: 'Transfer token', effect: 'spend', defaultExposure: 'authenticated',
|
|
96
|
+
requires: [{ capability: CAP.transferExecute, constraints: { assetTypes: [ASSET_TYPE.erc20] } }], inputSchema: transferSchema,
|
|
97
|
+
compile: ({ input, context }) => spendPlan({
|
|
98
|
+
id: 'treasury.transfer.token', capability: CAP.transferExecute, action: 'treasury.transfer.token', resource: input.account,
|
|
99
|
+
stepArgs: { account: input.account, network: input.network, to: input.to, asset: input.asset, amount: input.amount, memo: input.memo },
|
|
100
|
+
ledger: { accountId: input.account, asset: input.asset.address ?? ASSET_TYPE.erc20, amount: input.amount, idempotencyKey: idem(context.idempotencyKey) },
|
|
101
|
+
}),
|
|
102
|
+
});
|
|
103
|
+
// ── swap (markets) ─────────────────────────────────────────────────────────────
|
|
104
|
+
export const swapQuote = defineSkill({
|
|
105
|
+
id: 'treasury.swap.quote', version: SKILL_VERSION, name: 'Swap quote', effect: 'read', defaultExposure: 'authenticated',
|
|
106
|
+
requires: [{ capability: CAP.swapQuote }],
|
|
107
|
+
compile: ({ input }) => authedReadPlan('treasury.swap.quote', CAP.swapQuote, { ...input }, 'treasury.swap.quote', undefined),
|
|
108
|
+
});
|
|
109
|
+
export const swapExecute = defineSkill({
|
|
110
|
+
id: 'treasury.swap.execute', version: SKILL_VERSION, name: 'Swap', effect: 'trade', defaultExposure: 'authenticated',
|
|
111
|
+
requires: [{ capability: CAP.swapExecute }],
|
|
112
|
+
inputSchema: objectSchema('SwapExecuteInput', { account: 'string', network: 'string', sell: 'object', buy: 'object', amount: 'string' }),
|
|
113
|
+
compile: ({ input, context }) => spendPlan({
|
|
114
|
+
id: 'treasury.swap.execute', capability: CAP.swapExecute, action: 'treasury.swap.execute', resource: input.account,
|
|
115
|
+
stepArgs: { ...input }, ledger: { accountId: input.account, asset: input.sell.address ?? input.sell.type, amount: input.amount, idempotencyKey: idem(context.idempotencyKey) },
|
|
116
|
+
}),
|
|
117
|
+
});
|
|
118
|
+
// ── perp (markets) ─────────────────────────────────────────────────────────────
|
|
119
|
+
export const perpPositions = defineSkill({
|
|
120
|
+
id: 'treasury.perp.positions', version: SKILL_VERSION, name: 'Perp positions', effect: 'read', defaultExposure: 'authenticated',
|
|
121
|
+
requires: [{ capability: CAP.perpRead }],
|
|
122
|
+
compile: ({ input }) => authedReadPlan('treasury.perp.positions', CAP.perpRead, { account: input.account }, 'treasury.perp.positions', input.account),
|
|
123
|
+
});
|
|
124
|
+
export const perpOpen = defineSkill({
|
|
125
|
+
id: 'treasury.perp.open', version: SKILL_VERSION, name: 'Open perp', effect: 'trade', defaultExposure: 'authenticated',
|
|
126
|
+
requires: [{ capability: CAP.perpExecute }],
|
|
127
|
+
inputSchema: objectSchema('PerpOpenInput', { account: 'string', market: 'string', side: 'string', margin: 'string' }),
|
|
128
|
+
compile: ({ input, context }) => spendPlan({
|
|
129
|
+
id: 'treasury.perp.open', capability: CAP.perpExecute, action: 'treasury.perp.open', resource: input.account,
|
|
130
|
+
stepArgs: { ...input }, ledger: { accountId: input.account, asset: ASSET_TYPE.erc20, amount: input.margin, idempotencyKey: idem(context.idempotencyKey) },
|
|
131
|
+
}),
|
|
132
|
+
});
|
|
133
|
+
export const perpClose = defineSkill({
|
|
134
|
+
id: 'treasury.perp.close', version: SKILL_VERSION, name: 'Close perp', effect: 'trade', defaultExposure: 'authenticated',
|
|
135
|
+
requires: [{ capability: CAP.perpExecute }],
|
|
136
|
+
inputSchema: objectSchema('PerpCloseInput', { account: 'string', market: 'string' }),
|
|
137
|
+
compile: ({ input }) => adminPlan('treasury.perp.close', CAP.perpExecute, { ...input, op: 'close' }, 'treasury.perp.close', input.account),
|
|
138
|
+
});
|
|
139
|
+
// ── prediction (markets) ──────────────────────────────────────────────────────
|
|
140
|
+
export const predictionMarkets = defineSkill({
|
|
141
|
+
id: 'treasury.prediction.markets', version: SKILL_VERSION, name: 'Prediction markets', effect: 'read', defaultExposure: 'authenticated',
|
|
142
|
+
requires: [{ capability: CAP.predictionRead }],
|
|
143
|
+
compile: ({ input }) => authedReadPlan('treasury.prediction.markets', CAP.predictionRead, { query: input.query }, 'treasury.prediction.markets', undefined),
|
|
144
|
+
});
|
|
145
|
+
export const predictionBet = defineSkill({
|
|
146
|
+
id: 'treasury.prediction.bet', version: SKILL_VERSION, name: 'Place prediction bet', effect: 'trade', defaultExposure: 'authenticated',
|
|
147
|
+
requires: [{ capability: CAP.predictionExecute }],
|
|
148
|
+
inputSchema: objectSchema('PredictionBetInput', { account: 'string', market: 'string', outcome: 'string', stake: 'string' }),
|
|
149
|
+
compile: ({ input, context }) => spendPlan({
|
|
150
|
+
id: 'treasury.prediction.bet', capability: CAP.predictionExecute, action: 'treasury.prediction.bet', resource: input.account,
|
|
151
|
+
stepArgs: { ...input }, ledger: { accountId: input.account, asset: ASSET_TYPE.erc20, amount: input.stake, idempotencyKey: idem(context.idempotencyKey) },
|
|
152
|
+
}),
|
|
153
|
+
});
|
|
154
|
+
// ── delegation management (administration, private) ─────────────────────────────
|
|
155
|
+
export const delegationGrant = defineSkill({
|
|
156
|
+
id: 'treasury.delegation.grant', version: SKILL_VERSION, name: 'Grant delegation', effect: 'admin', defaultExposure: 'private',
|
|
157
|
+
requires: [{ capability: CAP.delegationManage }],
|
|
158
|
+
inputSchema: objectSchema('DelegationGrantInput', { account: 'string', delegate: 'string' }),
|
|
159
|
+
compile: ({ input }) => adminPlan('treasury.delegation.grant', CAP.delegationManage, { ...input, op: 'grant' }, 'treasury.delegation.grant', input.account),
|
|
160
|
+
});
|
|
161
|
+
export const delegationRevoke = defineSkill({
|
|
162
|
+
id: 'treasury.delegation.revoke', version: SKILL_VERSION, name: 'Revoke delegation', effect: 'admin', defaultExposure: 'private',
|
|
163
|
+
requires: [{ capability: CAP.delegationManage }],
|
|
164
|
+
inputSchema: objectSchema('DelegationRevokeInput', { account: 'string', delegationId: 'string' }),
|
|
165
|
+
compile: ({ input }) => adminPlan('treasury.delegation.revoke', CAP.delegationManage, { ...input, op: 'revoke' }, 'treasury.delegation.revoke', input.account),
|
|
166
|
+
});
|
|
167
|
+
// ── entitlement (administration) ────────────────────────────────────────────────
|
|
168
|
+
export const entitlementCheck = defineSkill({
|
|
169
|
+
id: 'treasury.entitlement.check', version: SKILL_VERSION, name: 'Check entitlement', effect: 'read', defaultExposure: 'authenticated',
|
|
170
|
+
requires: [{ capability: CAP.entitlementRead }],
|
|
171
|
+
compile: ({ input }) => authedReadPlan('treasury.entitlement.check', CAP.entitlementRead, { ...input }, 'treasury.entitlement.check', input.account),
|
|
172
|
+
});
|
|
173
|
+
export const entitlementIssue = defineSkill({
|
|
174
|
+
id: 'treasury.entitlement.issue', version: SKILL_VERSION, name: 'Issue entitlement', effect: 'admin', defaultExposure: 'private',
|
|
175
|
+
requires: [{ capability: CAP.entitlementManage }],
|
|
176
|
+
inputSchema: objectSchema('EntitlementIssueInput', { account: 'string', subject: 'string' }),
|
|
177
|
+
compile: ({ input }) => adminPlan('treasury.entitlement.issue', CAP.entitlementManage, { ...input, op: 'issue' }, 'treasury.entitlement.issue', input.account),
|
|
178
|
+
});
|
|
179
|
+
export const entitlementConsume = defineSkill({
|
|
180
|
+
id: 'treasury.entitlement.consume', version: SKILL_VERSION, name: 'Consume entitlement', effect: 'admin', defaultExposure: 'private',
|
|
181
|
+
requires: [{ capability: CAP.entitlementManage }],
|
|
182
|
+
inputSchema: objectSchema('EntitlementConsumeInput', { account: 'string', entitlementId: 'string' }),
|
|
183
|
+
compile: ({ input }) => adminPlan('treasury.entitlement.consume', CAP.entitlementManage, { ...input, op: 'consume' }, 'treasury.entitlement.consume', input.account),
|
|
184
|
+
});
|
|
185
|
+
/** Every catalog skill, in catalog order. */
|
|
186
|
+
export const ALL_TREASURY_SKILLS = [
|
|
187
|
+
serviceInfo, networkList, networkStatus,
|
|
188
|
+
accountList, accountBalance, accountActivity,
|
|
189
|
+
marketDataPrice, marketDataOhlcv,
|
|
190
|
+
signMessage, signTypedData,
|
|
191
|
+
txSimulate, txSend,
|
|
192
|
+
transferNative, transferToken,
|
|
193
|
+
swapQuote, swapExecute,
|
|
194
|
+
perpPositions, perpOpen, perpClose,
|
|
195
|
+
predictionMarkets, predictionBet,
|
|
196
|
+
delegationGrant, delegationRevoke,
|
|
197
|
+
entitlementCheck, entitlementIssue, entitlementConsume,
|
|
198
|
+
];
|
|
199
|
+
//# sourceMappingURL=catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,0GAA0G;AAC1G,2GAA2G;AAC3G,kFAAkF;AAClF,oGAAoG;AACpG,iGAAiG;AACjG,OAAO,EAAE,WAAW,EAA2B,MAAM,kCAAkC,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,qBAAqB,IAAI,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,EACL,YAAY,GAEb,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC;AACrC,MAAM,IAAI,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAErC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC;IACrC,EA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IAClB,cAAc,EAAE,aAAa;IAC7B,SAAS,EAAE,WAAW;IACtB,aAAa,EAAE,QAAQ,EAAE,SAAS;IAClC,iBAAiB,EAAE,aAAa;IAChC,eAAe,EAAE,gBAAgB;IACjC,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB;CACvD,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Address, CaveatContext, Delegation, EnforcerAddressMap } from '@agenticprimitives/delegation';
|
|
2
|
+
import type { AuthorityRequest, DelegationEvaluator, ExecutionReceipt, ServiceAgent, SkillInvocation } from '@agenticprimitives/service-agent';
|
|
3
|
+
import { type TreasuryAuthorityScope } from '../grant.js';
|
|
4
|
+
/** Inputs the host supplies to map a treasury skill invocation onto the caveat engine. */
|
|
5
|
+
export interface DelegationAuthorityDeps {
|
|
6
|
+
/** On-chain enforcer addresses (from the contracts deployment) the caveats dispatch against. */
|
|
7
|
+
enforcerMap: EnforcerAddressMap;
|
|
8
|
+
/** Monotonic clock in UNIX **seconds** (the timestamp caveat compares against this). Injected. */
|
|
9
|
+
now: () => number;
|
|
10
|
+
/** Map an `AuthorityRequest` → the call context the on-chain caveats are checked against
|
|
11
|
+
* (`target`/`value`/`selector`). The host owns this because pulling the recipient/amount/skill-selector
|
|
12
|
+
* out of a skill's input is provider-shaped. Anything not supplied is treated per `enforceOnChain`. */
|
|
13
|
+
contextOf?: (req: AuthorityRequest) => Partial<CaveatContext>;
|
|
14
|
+
/** Permissive mode for on-chain-only caveats (Value/AllowedTargets/AllowedMethods/inert) — set ONLY when an
|
|
15
|
+
* on-chain redeem WILL follow (where those enforcers actually fire). Default `false` = strict (a missing
|
|
16
|
+
* context field DENIES). The off-chain gates (MCP/A2A sentinels) stay strict regardless. */
|
|
17
|
+
enforceOnChain?: boolean;
|
|
18
|
+
/** Stamp the decision id with the delegation's EIP-712 hash (for the receipt's authority trail). */
|
|
19
|
+
chainId?: number;
|
|
20
|
+
delegationManager?: Address;
|
|
21
|
+
}
|
|
22
|
+
/** Build a `DelegationEvaluator` bound to ONE signed delegation. Inject it as a `ServiceAgent`'s `delegations`
|
|
23
|
+
* evaluator: every `.authorize(..,'delegation',..)` plan step then evaluates the delegation's caveats against
|
|
24
|
+
* the per-call context. Fail-closed — a single denied caveat denies the step (and `runPlan` throws). */
|
|
25
|
+
export declare function createDelegationAuthority(delegation: Delegation, deps: DelegationAuthorityDeps): DelegationEvaluator;
|
|
26
|
+
/** On-chain validity of a delegation — INJECTED so the domain stays viem-free (fakes in the demo, real
|
|
27
|
+
* ERC-1271 + `isRevoked` at the host). Both fail-closed: a throw or `false` denies. */
|
|
28
|
+
export interface DelegationVerifier {
|
|
29
|
+
/** Has the delegation been revoked on-chain (`DelegationManager._revoked[hash]`)? */
|
|
30
|
+
isRevoked(delegation: Delegation): Promise<boolean>;
|
|
31
|
+
/** Does the delegator SA accept the delegation hash (ERC-1271 `isValidSignature` over `hashDelegation`)? */
|
|
32
|
+
verifyDelegationSignature(delegation: Delegation): Promise<boolean>;
|
|
33
|
+
}
|
|
34
|
+
export declare class DelegationDispatchError extends Error {
|
|
35
|
+
}
|
|
36
|
+
export interface DispatchUnderDelegationArgs<Input = unknown> {
|
|
37
|
+
/** The verified, signed delegation (treasury SA → host) authorizing this dispatch. */
|
|
38
|
+
delegation: Delegation;
|
|
39
|
+
/** Build + ASSERT the service agent with the supplied delegation authority injected as its `delegations`
|
|
40
|
+
* evaluator. Async so the host can `await agent.assert()` before returning it. Receiving the evaluator
|
|
41
|
+
* here (rather than a pre-built agent) guarantees the agent's per-step delegation gate is bound to the
|
|
42
|
+
* SAME delegation we validate on-chain — no chance of a mismatch. */
|
|
43
|
+
buildAgent: (delegations: DelegationEvaluator) => ServiceAgent | Promise<ServiceAgent>;
|
|
44
|
+
invocation: SkillInvocation<Input>;
|
|
45
|
+
verify: DelegationVerifier;
|
|
46
|
+
authority: DelegationAuthorityDeps;
|
|
47
|
+
/** NEW-TSA-1 (2026-07-05): the treasury authority scope this dispatch runs under. REQUIRED — the skill
|
|
48
|
+
* allowlist is the PRIMARY treasury scope axis, but `allowedSkillIds` has no on-chain enforcer (the
|
|
49
|
+
* ceremony can't mint it as a caveat), so it MUST be enforced here as an off-chain gate. Without it a
|
|
50
|
+
* read-scoped grant could dispatch a spend/swap skill. */
|
|
51
|
+
scope: TreasuryAuthorityScope;
|
|
52
|
+
}
|
|
53
|
+
/** Dispatch a skill under a treasury→host delegation: validate the delegation on-chain (revocation +
|
|
54
|
+
* delegator signature, fail-closed, validity BEFORE authorization), then invoke with the delegation's
|
|
55
|
+
* caveats enforced per-step. Returns the standard `ExecutionReceipt` (whose `authority` trail records the
|
|
56
|
+
* delegation decision). A revoked / badly-signed / out-of-caveat call never moves value. */
|
|
57
|
+
export declare function dispatchUnderDelegation<Input = unknown>(args: DispatchUnderDelegationArgs<Input>): Promise<ExecutionReceipt>;
|
|
58
|
+
//# sourceMappingURL=delegation-authority.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegation-authority.d.ts","sourceRoot":"","sources":["../../src/dispatch/delegation-authority.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAC5G,OAAO,KAAK,EACS,gBAAgB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,YAAY,EAAE,eAAe,EAC1G,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAgB,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAExE,0FAA0F;AAC1F,MAAM,WAAW,uBAAuB;IACtC,gGAAgG;IAChG,WAAW,EAAE,kBAAkB,CAAC;IAChC,kGAAkG;IAClG,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB;;4GAEwG;IACxG,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IAC9D;;iGAE6F;IAC7F,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oGAAoG;IACpG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;yGAEyG;AACzG,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,uBAAuB,GAAG,mBAAmB,CAapH;AAED;wFACwF;AACxF,MAAM,WAAW,kBAAkB;IACjC,qFAAqF;IACrF,SAAS,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACpD,4GAA4G;IAC5G,yBAAyB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACrE;AAED,qBAAa,uBAAwB,SAAQ,KAAK;CAAG;AAErD,MAAM,WAAW,2BAA2B,CAAC,KAAK,GAAG,OAAO;IAC1D,sFAAsF;IACtF,UAAU,EAAE,UAAU,CAAC;IACvB;;;0EAGsE;IACtE,UAAU,EAAE,CAAC,WAAW,EAAE,mBAAmB,KAAK,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACvF,UAAU,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,SAAS,EAAE,uBAAuB,CAAC;IACnC;;;+DAG2D;IAC3D,KAAK,EAAE,sBAAsB,CAAC;CAC/B;AAED;;;6FAG6F;AAC7F,wBAAsB,uBAAuB,CAAC,KAAK,GAAG,OAAO,EAC3D,IAAI,EAAE,2BAA2B,CAAC,KAAK,CAAC,GACvC,OAAO,CAAC,gBAAgB,CAAC,CAa3B"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Delegation-backed dispatch (spec 284 host wiring + spec 285 T2T). The connect-treasury ceremony mints a
|
|
2
|
+
// scoped `Delegation` treasury-SA → host (demo-sso-next AUTHORIZE step). This module turns that signed
|
|
3
|
+
// delegation into the authority the host enforces at invoke time — REPLACING the demo's permissive
|
|
4
|
+
// `{ allow: true }` delegation evaluator with REAL caveat evaluation.
|
|
5
|
+
//
|
|
6
|
+
// Two seams, deliberately split:
|
|
7
|
+
// 1. `createDelegationAuthority` — a PURE `DelegationEvaluator` over `delegation.evaluateCaveats`. Maps each
|
|
8
|
+
// `service-agent` `AuthorityRequest` (raised by the plan's `.authorize(..,'delegation',..)` step) into a
|
|
9
|
+
// `CaveatContext` and returns the AND of every caveat verdict. Off-chain, deterministic, no chain reads.
|
|
10
|
+
// 2. `dispatchUnderDelegation` — sequences the on-chain VALIDITY check (is-revoked + delegator signature, an
|
|
11
|
+
// INJECTED seam: fakes in the demo, real ERC-1271 over Base Sepolia at the host) BEFORE building the
|
|
12
|
+
// agent with the bound authority and invoking. Validity (signature/revocation) and authorization
|
|
13
|
+
// (caveats) are separate concerns (delegation map note + verifyAuthorization danger note) — we enforce
|
|
14
|
+
// BOTH, fail-closed, validity first.
|
|
15
|
+
//
|
|
16
|
+
// Why this lives in `domains/treasury-service-agent`, not `service-agent`: the framework is Ring-0 and must
|
|
17
|
+
// not import `@agenticprimitives/delegation` (its manifest forbids it). The domain is the composition layer
|
|
18
|
+
// where the generic `DelegationEvaluator` seam is wired to the real caveat engine; the manifest was widened
|
|
19
|
+
// (deliberately, per the domain CLAUDE.md "widen allowedImports per phase") to allow `delegation` here.
|
|
20
|
+
import { evaluateCaveats, hashDelegation } from '@agenticprimitives/delegation';
|
|
21
|
+
import { skillInScope } from '../grant.js';
|
|
22
|
+
/** Build a `DelegationEvaluator` bound to ONE signed delegation. Inject it as a `ServiceAgent`'s `delegations`
|
|
23
|
+
* evaluator: every `.authorize(..,'delegation',..)` plan step then evaluates the delegation's caveats against
|
|
24
|
+
* the per-call context. Fail-closed — a single denied caveat denies the step (and `runPlan` throws). */
|
|
25
|
+
export function createDelegationAuthority(delegation, deps) {
|
|
26
|
+
const decisionId = deps.chainId !== undefined && deps.delegationManager
|
|
27
|
+
? hashDelegation(delegation, deps.chainId, deps.delegationManager)
|
|
28
|
+
: undefined;
|
|
29
|
+
return {
|
|
30
|
+
async evaluate(req) {
|
|
31
|
+
const ctx = { timestamp: deps.now(), ...deps.contextOf?.(req) };
|
|
32
|
+
const verdicts = evaluateCaveats(delegation.caveats, ctx, deps.enforcerMap, { enforceOnChain: deps.enforceOnChain });
|
|
33
|
+
const denied = verdicts.find((v) => !v.allowed);
|
|
34
|
+
if (denied)
|
|
35
|
+
return { allow: false, decisionId, reason: `delegation caveat ${denied.enforcer}: ${denied.reason}` };
|
|
36
|
+
return { allow: true, decisionId };
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export class DelegationDispatchError extends Error {
|
|
41
|
+
}
|
|
42
|
+
/** Dispatch a skill under a treasury→host delegation: validate the delegation on-chain (revocation +
|
|
43
|
+
* delegator signature, fail-closed, validity BEFORE authorization), then invoke with the delegation's
|
|
44
|
+
* caveats enforced per-step. Returns the standard `ExecutionReceipt` (whose `authority` trail records the
|
|
45
|
+
* delegation decision). A revoked / badly-signed / out-of-caveat call never moves value. */
|
|
46
|
+
export async function dispatchUnderDelegation(args) {
|
|
47
|
+
const { delegation, verify } = args;
|
|
48
|
+
if (await verify.isRevoked(delegation))
|
|
49
|
+
throw new DelegationDispatchError('delegation revoked');
|
|
50
|
+
if (!(await verify.verifyDelegationSignature(delegation)))
|
|
51
|
+
throw new DelegationDispatchError('delegation signature invalid');
|
|
52
|
+
// NEW-TSA-1: enforce the skill allowlist BEFORE authorization/invoke — the PRIMARY treasury scope axis has
|
|
53
|
+
// no on-chain enforcer, so the per-step caveat eval never covers it. Fail-closed: an out-of-scope skill
|
|
54
|
+
// never reaches the agent (so a read-scoped grant can't move value via a spend/swap skill).
|
|
55
|
+
if (!skillInScope(args.scope, args.invocation.skillId)) {
|
|
56
|
+
throw new DelegationDispatchError(`skill not in treasury authority scope: ${args.invocation.skillId}`);
|
|
57
|
+
}
|
|
58
|
+
const delegations = createDelegationAuthority(delegation, args.authority);
|
|
59
|
+
const agent = await args.buildAgent(delegations);
|
|
60
|
+
return agent.invoke(args.invocation);
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=delegation-authority.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegation-authority.js","sourceRoot":"","sources":["../../src/dispatch/delegation-authority.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,uGAAuG;AACvG,mGAAmG;AACnG,sEAAsE;AACtE,EAAE;AACF,iCAAiC;AACjC,8GAA8G;AAC9G,6GAA6G;AAC7G,6GAA6G;AAC7G,8GAA8G;AAC9G,yGAAyG;AACzG,qGAAqG;AACrG,2GAA2G;AAC3G,yCAAyC;AACzC,EAAE;AACF,4GAA4G;AAC5G,4GAA4G;AAC5G,4GAA4G;AAC5G,wGAAwG;AACxG,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAKhF,OAAO,EAAE,YAAY,EAA+B,MAAM,aAAa,CAAC;AAqBxE;;yGAEyG;AACzG,MAAM,UAAU,yBAAyB,CAAC,UAAsB,EAAE,IAA6B;IAC7F,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,IAAI,CAAC,iBAAiB;QACrE,CAAC,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC;QAClE,CAAC,CAAC,SAAS,CAAC;IACd,OAAO;QACL,KAAK,CAAC,QAAQ,CAAC,GAAqB;YAClC,MAAM,GAAG,GAAkB,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/E,MAAM,QAAQ,GAAG,eAAe,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;YACrH,MAAM,MAAM,GAA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,CAAC"}
|
package/dist/grant.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AssetType } from './capabilities.js';
|
|
2
|
+
export interface TreasuryAuthorityScope {
|
|
3
|
+
/** Exactly the skills the host may execute — an allowlist (never a denylist). */
|
|
4
|
+
allowedSkillIds: string[];
|
|
5
|
+
/** Networks the host may act on. Empty/omitted = the ceremony must supply one (fail-closed). */
|
|
6
|
+
networks?: string[];
|
|
7
|
+
/** Per-transaction value ceiling (decimal string, smallest unit). */
|
|
8
|
+
maxValuePerTx?: string;
|
|
9
|
+
/** Cumulative value ceiling over the grant's life. */
|
|
10
|
+
maxTotalValue?: string;
|
|
11
|
+
/** Asset classes the host may move. */
|
|
12
|
+
allowedAssetTypes?: AssetType[];
|
|
13
|
+
/** Recipient allowlist for transfers/sends. */
|
|
14
|
+
allowedTargets?: string[];
|
|
15
|
+
/** Validity window (unix seconds). */
|
|
16
|
+
notBefore?: number;
|
|
17
|
+
notAfter?: number;
|
|
18
|
+
}
|
|
19
|
+
/** An abstract caveat descriptor. `kind` is mapped to a concrete `delegation` enforcer by the ceremony. */
|
|
20
|
+
export interface CaveatTerm {
|
|
21
|
+
kind: 'allowed-skills' | 'allowed-networks' | 'value-per-tx' | 'value-total' | 'allowed-asset-types' | 'allowed-targets' | 'time-window';
|
|
22
|
+
value: unknown;
|
|
23
|
+
}
|
|
24
|
+
export declare class TreasuryScopeError extends Error {
|
|
25
|
+
}
|
|
26
|
+
/** Validate + normalize a scope. Fail-closed: an empty skill allowlist is rejected (a grant that lets a
|
|
27
|
+
* host do nothing is almost certainly a mistake; the caller must be explicit). */
|
|
28
|
+
export declare function buildTreasuryScope(scope: TreasuryAuthorityScope): TreasuryAuthorityScope;
|
|
29
|
+
/** Lower a scope into abstract caveat terms (only the constraints that are set). The ceremony maps each
|
|
30
|
+
* `kind` to a `delegation` enforcer; the resulting grant is monotonic (it can only narrow these). */
|
|
31
|
+
export declare function treasuryScopeToCaveatTerms(scope: TreasuryAuthorityScope): CaveatTerm[];
|
|
32
|
+
/** Is a skill within the scope's allowlist? (Pure check the host can use before invoking.) */
|
|
33
|
+
export declare function skillInScope(scope: TreasuryAuthorityScope, skillId: string): boolean;
|
|
34
|
+
//# sourceMappingURL=grant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grant.d.ts","sourceRoot":"","sources":["../src/grant.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,WAAW,sBAAsB;IACrC,iFAAiF;IACjF,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,gGAAgG;IAChG,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,iBAAiB,CAAC,EAAE,SAAS,EAAE,CAAC;IAChC,+CAA+C;IAC/C,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,2GAA2G;AAC3G,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,gBAAgB,GAAG,kBAAkB,GAAG,cAAc,GAAG,aAAa,GAAG,qBAAqB,GAAG,iBAAiB,GAAG,aAAa,CAAC;IACzI,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,qBAAa,kBAAmB,SAAQ,KAAK;CAAG;AAEhD;mFACmF;AACnF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,sBAAsB,GAAG,sBAAsB,CAWxF;AAED;sGACsG;AACtG,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,sBAAsB,GAAG,UAAU,EAAE,CAWtF;AAED,8FAA8F;AAC9F,wBAAgB,YAAY,CAAC,KAAK,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAEpF"}
|