@cann4n/actions-smart-account 0.1.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.
@@ -0,0 +1,2 @@
1
+ export { SmartAccountProvider, smartAccountActions } from "./smartAccountActionProvider";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { SmartAccountProvider, smartAccountActions } from "./smartAccountActionProvider";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { z } from "zod";
2
+ import type { WalletProvider } from "@cann4n/core";
3
+ import { ActionProvider } from "@cann4n/core";
4
+ declare const AddContextRuleSchema: z.ZodObject<{
5
+ contractId: z.ZodString;
6
+ functionName: z.ZodString;
7
+ maxAmount: z.ZodOptional<z.ZodString>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ contractId: string;
10
+ functionName: string;
11
+ maxAmount?: string | undefined;
12
+ }, {
13
+ contractId: string;
14
+ functionName: string;
15
+ maxAmount?: string | undefined;
16
+ }>;
17
+ declare const AddSignerSchema: z.ZodObject<{
18
+ signerAddress: z.ZodString;
19
+ weight: z.ZodOptional<z.ZodNumber>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ signerAddress: string;
22
+ weight?: number | undefined;
23
+ }, {
24
+ signerAddress: string;
25
+ weight?: number | undefined;
26
+ }>;
27
+ declare const AddPolicySchema: z.ZodObject<{
28
+ ruleId: z.ZodNumber;
29
+ policyType: z.ZodEnum<["spending_limit", "threshold", "weighted"]>;
30
+ params: z.ZodRecord<z.ZodString, z.ZodUnknown>;
31
+ }, "strip", z.ZodTypeAny, {
32
+ params: Record<string, unknown>;
33
+ ruleId: number;
34
+ policyType: "spending_limit" | "threshold" | "weighted";
35
+ }, {
36
+ params: Record<string, unknown>;
37
+ ruleId: number;
38
+ policyType: "spending_limit" | "threshold" | "weighted";
39
+ }>;
40
+ declare const GetRulesSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
41
+ export declare class SmartAccountProvider extends ActionProvider {
42
+ private rules;
43
+ private signers;
44
+ private policies;
45
+ private nextRuleId;
46
+ constructor();
47
+ addContextRule(_wallet: WalletProvider, args: z.infer<typeof AddContextRuleSchema>): Promise<string>;
48
+ addSigner(_wallet: WalletProvider, args: z.infer<typeof AddSignerSchema>): Promise<string>;
49
+ addPolicy(_wallet: WalletProvider, args: z.infer<typeof AddPolicySchema>): Promise<string>;
50
+ getRules(_wallet: WalletProvider, _args: z.infer<typeof GetRulesSchema>): Promise<string>;
51
+ }
52
+ /** Create a smart account action provider for context rule and signer management. */
53
+ export declare const smartAccountActions: () => SmartAccountProvider;
54
+ export {};
55
+ //# sourceMappingURL=smartAccountActionProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smartAccountActionProvider.d.ts","sourceRoot":"","sources":["../src/smartAccountActionProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAU,cAAc,EAAE,MAAM,cAAc,CAAC;AAEtD,QAAA,MAAM,oBAAoB;;;;;;;;;;;;EAIxB,CAAC;AAEH,QAAA,MAAM,eAAe;;;;;;;;;EAGnB,CAAC;AAEH,QAAA,MAAM,eAAe;;;;;;;;;;;;EAInB,CAAC;AAEH,QAAA,MAAM,cAAc,gDAAe,CAAC;AAEpC,qBAAa,oBAAqB,SAAQ,cAAc;IACtD,OAAO,CAAC,KAAK,CAA4F;IACzG,OAAO,CAAC,OAAO,CAAmD;IAClE,OAAO,CAAC,QAAQ,CAA6E;IAC7F,OAAO,CAAC,UAAU,CAAa;;IAczB,cAAc,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAmBpG,SAAS,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAc1F,SAAS,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAe1F,QAAQ,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CAgBhG;AAED,qFAAqF;AACrF,eAAO,MAAM,mBAAmB,4BAAmC,CAAC"}
@@ -0,0 +1,124 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { z } from "zod";
11
+ import { Action, ActionProvider } from "@cann4n/core";
12
+ const AddContextRuleSchema = z.object({
13
+ contractId: z.string().describe("Contract address to authorize (C...)"),
14
+ functionName: z.string().describe("Function name to authorize (e.g., 'transfer')"),
15
+ maxAmount: z.string().optional().describe("Maximum spend amount per transaction"),
16
+ });
17
+ const AddSignerSchema = z.object({
18
+ signerAddress: z.string().describe("Signer address to add"),
19
+ weight: z.number().optional().describe("Signer weight for weighted policies"),
20
+ });
21
+ const AddPolicySchema = z.object({
22
+ ruleId: z.number().describe("Context rule ID"),
23
+ policyType: z.enum(["spending_limit", "threshold", "weighted"]).describe("Type of policy"),
24
+ params: z.record(z.unknown()).describe("Policy parameters"),
25
+ });
26
+ const GetRulesSchema = z.object({});
27
+ export class SmartAccountProvider extends ActionProvider {
28
+ rules = new Map();
29
+ signers = [];
30
+ policies = new Map();
31
+ nextRuleId = 1;
32
+ constructor() {
33
+ super("smart_account", []);
34
+ }
35
+ async addContextRule(_wallet, args) {
36
+ const id = this.nextRuleId++;
37
+ this.rules.set(id, {
38
+ contractId: args.contractId,
39
+ functionName: args.functionName,
40
+ maxAmount: args.maxAmount,
41
+ });
42
+ return `Added context rule #${id}: Call ${args.functionName} on ${args.contractId}` +
43
+ (args.maxAmount ? ` (max ${args.maxAmount})` : "");
44
+ }
45
+ async addSigner(_wallet, args) {
46
+ this.signers.push({ address: args.signerAddress, weight: args.weight });
47
+ return `Added signer ${args.signerAddress} to smart account` +
48
+ (args.weight ? ` with weight ${args.weight}` : "");
49
+ }
50
+ async addPolicy(_wallet, args) {
51
+ this.policies.set(args.ruleId, {
52
+ type: args.policyType,
53
+ params: args.params,
54
+ });
55
+ return `Added ${args.policyType} policy to rule #${args.ruleId}`;
56
+ }
57
+ async getRules(_wallet, _args) {
58
+ if (this.rules.size === 0)
59
+ return "No context rules configured";
60
+ const rulesList = Array.from(this.rules.entries()).map(([id, rule]) => `Rule #${id}: ${rule.functionName} on ${rule.contractId}` +
61
+ (rule.maxAmount ? ` (max ${rule.maxAmount})` : "") +
62
+ (this.policies.has(id) ? ` [Policy: ${this.policies.get(id).type}]` : ""));
63
+ const signersList = this.signers.map((s) => ` Signer: ${s.address}${s.weight ? ` (weight: ${s.weight})` : ""}`);
64
+ return [
65
+ "Smart Account Configuration:",
66
+ ...rulesList,
67
+ ...(signersList.length > 0 ? ["Signers:", ...signersList] : []),
68
+ ].join("\n");
69
+ }
70
+ }
71
+ __decorate([
72
+ Action({
73
+ name: "add_context_rule",
74
+ description: "Add a context rule to a smart account, authorizing specific contract calls",
75
+ similes: ["add permission", "authorize action", "context rule"],
76
+ schema: AddContextRuleSchema,
77
+ returnDirect: true,
78
+ needsWallet: true,
79
+ }),
80
+ __metadata("design:type", Function),
81
+ __metadata("design:paramtypes", [Function, void 0]),
82
+ __metadata("design:returntype", Promise)
83
+ ], SmartAccountProvider.prototype, "addContextRule", null);
84
+ __decorate([
85
+ Action({
86
+ name: "add_signer",
87
+ description: "Add a signer to the smart account",
88
+ similes: ["add signer", "authorize signer"],
89
+ schema: AddSignerSchema,
90
+ returnDirect: true,
91
+ needsWallet: true,
92
+ }),
93
+ __metadata("design:type", Function),
94
+ __metadata("design:paramtypes", [Function, void 0]),
95
+ __metadata("design:returntype", Promise)
96
+ ], SmartAccountProvider.prototype, "addSigner", null);
97
+ __decorate([
98
+ Action({
99
+ name: "add_policy",
100
+ description: "Add a policy to a context rule (e.g., spending limit, multisig threshold)",
101
+ similes: ["add policy", "enforce limit", "add constraint"],
102
+ schema: AddPolicySchema,
103
+ returnDirect: true,
104
+ needsWallet: true,
105
+ }),
106
+ __metadata("design:type", Function),
107
+ __metadata("design:paramtypes", [Function, void 0]),
108
+ __metadata("design:returntype", Promise)
109
+ ], SmartAccountProvider.prototype, "addPolicy", null);
110
+ __decorate([
111
+ Action({
112
+ name: "get_rules",
113
+ description: "List all context rules on the smart account",
114
+ similes: ["my permissions", "list rules"],
115
+ schema: GetRulesSchema,
116
+ needsWallet: true,
117
+ }),
118
+ __metadata("design:type", Function),
119
+ __metadata("design:paramtypes", [Function, void 0]),
120
+ __metadata("design:returntype", Promise)
121
+ ], SmartAccountProvider.prototype, "getRules", null);
122
+ /** Create a smart account action provider for context rule and signer management. */
123
+ export const smartAccountActions = () => new SmartAccountProvider();
124
+ //# sourceMappingURL=smartAccountActionProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smartAccountActionProvider.js","sourceRoot":"","sources":["../src/smartAccountActionProvider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sCAAsC,CAAC;IACvE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+CAA+C,CAAC;IAClF,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,sCAAsC,CAAC;CAClF,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;IAC3D,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;CAC9E,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC;IAC9C,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC;IAC1F,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,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+ export {};
2
+ //# sourceMappingURL=smartAccountActionProvider.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smartAccountActionProvider.test.d.ts","sourceRoot":"","sources":["../src/smartAccountActionProvider.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,59 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { MockWalletProvider } from "@cann4n/core";
3
+ import { SmartAccountProvider } from "./smartAccountActionProvider";
4
+ describe("SmartAccountProvider", () => {
5
+ const wallet = new MockWalletProvider();
6
+ const provider = new SmartAccountProvider();
7
+ it("should provide smart account actions", () => {
8
+ const actions = provider.getActions(wallet);
9
+ const names = actions.map((a) => a.name);
10
+ expect(names).toContain("smart_account_add_context_rule");
11
+ expect(names).toContain("smart_account_add_signer");
12
+ expect(names).toContain("smart_account_add_policy");
13
+ expect(names).toContain("smart_account_get_rules");
14
+ });
15
+ it("should describe actions for LLM", () => {
16
+ const actions = provider.getActions(wallet);
17
+ const rule = actions.find((a) => a.name === "smart_account_add_context_rule");
18
+ expect(rule.description).toContain("context rule");
19
+ expect(rule.similes.length).toBeGreaterThan(0);
20
+ });
21
+ it("should add a context rule", async () => {
22
+ const actions = provider.getActions(wallet);
23
+ const addRule = actions.find((a) => a.name === "smart_account_add_context_rule");
24
+ const result = await addRule.invoke({
25
+ contractId: "CAZ7T3Y5XJ5Y6XJ5Y6XJ5Y6XJ5Y6XJ5Y6XJ5Y6XJ5Y6XJ5Y6XJ5Y6XJ5",
26
+ functionName: "transfer",
27
+ maxAmount: "1000000",
28
+ });
29
+ expect(result).toContain("Added context rule");
30
+ expect(result).toContain("transfer");
31
+ });
32
+ it("should add a signer", async () => {
33
+ const actions = provider.getActions(wallet);
34
+ const addSigner = actions.find((a) => a.name === "smart_account_add_signer");
35
+ const result = await addSigner.invoke({
36
+ signerAddress: "GC4B7Y6XJ5Y6XJ5Y6XJ5Y6XJ5Y6XJ5Y6XJ5Y6XJ5Y6XJ5Y6XJ5Y6XJ5",
37
+ weight: 1,
38
+ });
39
+ expect(result).toContain("Added signer");
40
+ });
41
+ it("should add a policy", async () => {
42
+ const actions = provider.getActions(wallet);
43
+ const addPolicy = actions.find((a) => a.name === "smart_account_add_policy");
44
+ const result = await addPolicy.invoke({
45
+ ruleId: 1,
46
+ policyType: "spending_limit",
47
+ params: { maxAmount: "5000000" },
48
+ });
49
+ expect(result).toContain("spending_limit policy");
50
+ });
51
+ it("should get rules", async () => {
52
+ const actions = provider.getActions(wallet);
53
+ const getRules = actions.find((a) => a.name === "smart_account_get_rules");
54
+ const result = await getRules.invoke({});
55
+ expect(result).toContain("Smart Account Configuration");
56
+ expect(result).toContain("transfer");
57
+ });
58
+ });
59
+ //# sourceMappingURL=smartAccountActionProvider.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smartAccountActionProvider.test.js","sourceRoot":"","sources":["../src/smartAccountActionProvider.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,MAAM,MAAM,GAAG,IAAI,kBAAkB,EAAE,CAAC;IACxC,MAAM,QAAQ,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAE5C,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,gCAAgC,CAAC,CAAC;QAC1D,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,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C,CAAC,SAAS,CAAC,6BAA6B,CAAC,CAAC;QACxD,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@cann4n/actions-smart-account",
3
+ "version": "0.1.0",
4
+ "description": "Smart Account management actions for AgentKit Stellar",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "dependencies": {
20
+ "@cann4n/core": "^0.1.0",
21
+ "zod": "^3.24.0"
22
+ },
23
+ "devDependencies": {
24
+ "typescript": "^5.7.0",
25
+ "vitest": "^3.0.0"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "license": "MIT",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/anomalyco/agentkit-stellar.git",
34
+ "directory": "packages/actions-smart-account"
35
+ },
36
+ "scripts": {
37
+ "build": "tsc",
38
+ "test": "vitest run",
39
+ "lint": "eslint src/",
40
+ "typecheck": "tsc --noEmit",
41
+ "clean": "rm -rf dist"
42
+ }
43
+ }