clawntenna 0.12.0 → 0.12.2

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,59 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ CONFIG_DIR
4
+ } from "./chunk-XGIPK7SQ.js";
5
+
6
+ // src/cli/skill.ts
7
+ import { readFileSync, existsSync, copyFileSync, mkdirSync } from "fs";
8
+ import { join, dirname } from "path";
9
+ import { fileURLToPath } from "url";
10
+ var __dirname = dirname(fileURLToPath(import.meta.url));
11
+ var PKG_ROOT = join(__dirname, "..", "..");
12
+ var SKILL_FILES = ["skill.md", "heartbeat.md", "skill.json"];
13
+ function copySkillFiles() {
14
+ mkdirSync(CONFIG_DIR, { recursive: true, mode: 448 });
15
+ const files = {};
16
+ let anyCreated = false;
17
+ for (const file of SKILL_FILES) {
18
+ const dest = join(CONFIG_DIR, file);
19
+ if (existsSync(dest)) {
20
+ files[file] = "exists";
21
+ } else {
22
+ copyFileSync(join(PKG_ROOT, file), dest);
23
+ files[file] = "created";
24
+ anyCreated = true;
25
+ }
26
+ }
27
+ return {
28
+ status: anyCreated ? "created" : "exists",
29
+ path: CONFIG_DIR,
30
+ files
31
+ };
32
+ }
33
+ function showSkill(json) {
34
+ const content = readFileSync(join(PKG_ROOT, "skill.md"), "utf-8");
35
+ if (json) {
36
+ console.log(JSON.stringify({ content }));
37
+ } else {
38
+ console.log(content);
39
+ }
40
+ }
41
+ function showHeartbeat(json) {
42
+ const content = readFileSync(join(PKG_ROOT, "heartbeat.md"), "utf-8");
43
+ if (json) {
44
+ console.log(JSON.stringify({ content }));
45
+ } else {
46
+ console.log(content);
47
+ }
48
+ }
49
+ function showSkillJson() {
50
+ const content = readFileSync(join(PKG_ROOT, "skill.json"), "utf-8");
51
+ console.log(content);
52
+ }
53
+
54
+ export {
55
+ copySkillFiles,
56
+ showSkill,
57
+ showHeartbeat,
58
+ showSkillJson
59
+ };
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ CONFIG_DIR,
4
+ loadCredentials,
5
+ output
6
+ } from "./chunk-XGIPK7SQ.js";
7
+
8
+ // src/cli/state.ts
9
+ import { existsSync, mkdirSync, writeFileSync } from "fs";
10
+ import { join } from "path";
11
+ var STATE_PATH = join(CONFIG_DIR, "state.json");
12
+ function initState(address) {
13
+ if (existsSync(STATE_PATH)) {
14
+ return "exists";
15
+ }
16
+ const now = (/* @__PURE__ */ new Date()).toISOString();
17
+ const state = {
18
+ version: 2,
19
+ agent: {
20
+ address,
21
+ startedAt: now,
22
+ lastScanAt: now,
23
+ mode: "active",
24
+ skillVersion: "0.12.2",
25
+ lastSkillCheck: now
26
+ },
27
+ chains: {
28
+ base: {
29
+ lastScanAt: null,
30
+ gasBalance: "0",
31
+ gasCheckedAt: null,
32
+ apps: {}
33
+ },
34
+ avalanche: {
35
+ lastScanAt: null,
36
+ gasBalance: "0",
37
+ gasCheckedAt: null,
38
+ apps: {}
39
+ }
40
+ },
41
+ escrow: {
42
+ base: {
43
+ watching: {},
44
+ history: [],
45
+ stats: {
46
+ totalEarned: "0",
47
+ totalRefunded: "0",
48
+ depositsResponded: 0,
49
+ depositsReleased: 0,
50
+ depositsRefunded: 0,
51
+ depositsExpired: 0
52
+ }
53
+ },
54
+ avalanche: {
55
+ watching: {},
56
+ history: [],
57
+ stats: {
58
+ totalEarned: "0",
59
+ totalRefunded: "0",
60
+ depositsResponded: 0,
61
+ depositsReleased: 0,
62
+ depositsRefunded: 0,
63
+ depositsExpired: 0
64
+ }
65
+ }
66
+ },
67
+ people: {},
68
+ messages: {
69
+ sent: [],
70
+ repliedTo: []
71
+ },
72
+ rateLimits: {
73
+ windowStart: now,
74
+ messagesInWindow: 0,
75
+ perTopic: {}
76
+ }
77
+ };
78
+ mkdirSync(CONFIG_DIR, { recursive: true, mode: 448 });
79
+ writeFileSync(STATE_PATH, JSON.stringify(state, null, 2) + "\n", { mode: 384 });
80
+ return "created";
81
+ }
82
+ function stateInit(json) {
83
+ const creds = loadCredentials();
84
+ const address = creds?.wallet?.address ?? "";
85
+ const status = initState(address);
86
+ if (status === "exists") {
87
+ output(
88
+ json ? { status: "exists", path: STATE_PATH } : `State file already exists: ${STATE_PATH}`,
89
+ json
90
+ );
91
+ } else {
92
+ output(
93
+ json ? { status: "created", path: STATE_PATH, address } : `State file created: ${STATE_PATH}`,
94
+ json
95
+ );
96
+ }
97
+ }
98
+
99
+ export {
100
+ initState,
101
+ stateInit
102
+ };