@analytix402/openclaw-skill 0.1.6 → 0.2.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/SKILL.md +11 -1
- package/dist/index.js +3 -2
- package/dist/index.mjs +3 -2
- package/dist/setup.js +105 -0
- package/package.json +9 -3
package/SKILL.md
CHANGED
|
@@ -14,9 +14,19 @@ Analytix402 gives your OpenClaw agent financial visibility and guardrails. Track
|
|
|
14
14
|
- Sends heartbeats so you know your agent is alive and healthy
|
|
15
15
|
- Provides a real-time dashboard at analytix402.com
|
|
16
16
|
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
After installing, run the setup wizard:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx @analytix402/openclaw-skill init
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
It will ask for your API key, validate it, and write your `.env` file.
|
|
26
|
+
|
|
17
27
|
## Configuration
|
|
18
28
|
|
|
19
|
-
|
|
29
|
+
Or add these to your OpenClaw agent's `.env` file manually:
|
|
20
30
|
|
|
21
31
|
```yaml
|
|
22
32
|
# Required
|
package/dist/index.js
CHANGED
|
@@ -47,7 +47,7 @@ function getClient() {
|
|
|
47
47
|
if (!client) {
|
|
48
48
|
if (!API_KEY) {
|
|
49
49
|
throw new Error(
|
|
50
|
-
|
|
50
|
+
'ANALYTIX402_API_KEY is not set. Run "npx @analytix402/openclaw-skill init" to configure.'
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
53
|
client = (0, import_sdk.createClient)({
|
|
@@ -67,12 +67,13 @@ if (API_KEY) {
|
|
|
67
67
|
} catch (err) {
|
|
68
68
|
console.warn("[Analytix402] Failed to connect on startup:", err instanceof Error ? err.message : err);
|
|
69
69
|
}
|
|
70
|
+
} else {
|
|
71
|
+
console.warn('[Analytix402] No API key found. Run "npx @analytix402/openclaw-skill init" to set up.');
|
|
70
72
|
}
|
|
71
73
|
async function apiRequest(method, path, body) {
|
|
72
74
|
const url = `${BASE_URL}/api${path}`;
|
|
73
75
|
const headers = {
|
|
74
76
|
"Content-Type": "application/json",
|
|
75
|
-
"Authorization": `Bearer ${API_KEY}`,
|
|
76
77
|
"X-API-Key": API_KEY
|
|
77
78
|
};
|
|
78
79
|
const opts = { method, headers };
|
package/dist/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ function getClient() {
|
|
|
16
16
|
if (!client) {
|
|
17
17
|
if (!API_KEY) {
|
|
18
18
|
throw new Error(
|
|
19
|
-
|
|
19
|
+
'ANALYTIX402_API_KEY is not set. Run "npx @analytix402/openclaw-skill init" to configure.'
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
22
|
client = createClient({
|
|
@@ -36,12 +36,13 @@ if (API_KEY) {
|
|
|
36
36
|
} catch (err) {
|
|
37
37
|
console.warn("[Analytix402] Failed to connect on startup:", err instanceof Error ? err.message : err);
|
|
38
38
|
}
|
|
39
|
+
} else {
|
|
40
|
+
console.warn('[Analytix402] No API key found. Run "npx @analytix402/openclaw-skill init" to set up.');
|
|
39
41
|
}
|
|
40
42
|
async function apiRequest(method, path, body) {
|
|
41
43
|
const url = `${BASE_URL}/api${path}`;
|
|
42
44
|
const headers = {
|
|
43
45
|
"Content-Type": "application/json",
|
|
44
|
-
"Authorization": `Bearer ${API_KEY}`,
|
|
45
46
|
"X-API-Key": API_KEY
|
|
46
47
|
};
|
|
47
48
|
const opts = { method, headers };
|
package/dist/setup.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/setup.ts
|
|
27
|
+
var readline = __toESM(require("readline"));
|
|
28
|
+
var fs = __toESM(require("fs"));
|
|
29
|
+
var path = __toESM(require("path"));
|
|
30
|
+
var rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
31
|
+
function ask(question, fallback = "") {
|
|
32
|
+
return new Promise((resolve2) => {
|
|
33
|
+
rl.question(question, (answer) => {
|
|
34
|
+
resolve2(answer.trim() || fallback);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async function validateKey(apiKey, baseUrl) {
|
|
39
|
+
try {
|
|
40
|
+
const res = await fetch(`${baseUrl}/api/agents/overview`, {
|
|
41
|
+
headers: { "X-API-Key": apiKey }
|
|
42
|
+
});
|
|
43
|
+
return res.ok;
|
|
44
|
+
} catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function main() {
|
|
49
|
+
console.log("\n Analytix402 \u2014 Setup\n");
|
|
50
|
+
const apiKey = await ask(" API key (ax_live_... or ax_test_...): ");
|
|
51
|
+
if (!apiKey) {
|
|
52
|
+
console.log("\n No API key provided. Exiting.\n");
|
|
53
|
+
rl.close();
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
if (!apiKey.startsWith("ax_live_") && !apiKey.startsWith("ax_test_")) {
|
|
57
|
+
console.log(" Warning: key should start with ax_live_ or ax_test_\n");
|
|
58
|
+
}
|
|
59
|
+
const agentName = await ask(" Agent display name [OpenClaw Agent]: ", "OpenClaw Agent");
|
|
60
|
+
const dailyBudget = await ask(" Daily budget in USD (0 = unlimited) [0]: ", "0");
|
|
61
|
+
const baseUrl = await ask(" API endpoint [https://analytix402.com]: ", "https://analytix402.com");
|
|
62
|
+
rl.close();
|
|
63
|
+
console.log("\n Validating API key...");
|
|
64
|
+
const valid = await validateKey(apiKey, baseUrl.replace(/\/$/, ""));
|
|
65
|
+
if (valid) {
|
|
66
|
+
console.log(" Connected successfully.\n");
|
|
67
|
+
} else {
|
|
68
|
+
console.log(" Could not reach the dashboard \u2014 the key may still be correct.");
|
|
69
|
+
console.log(" (The server might be starting up or unreachable right now.)\n");
|
|
70
|
+
}
|
|
71
|
+
const envPath = path.resolve(process.cwd(), ".env");
|
|
72
|
+
const lines = [];
|
|
73
|
+
if (fs.existsSync(envPath)) {
|
|
74
|
+
const existing = fs.readFileSync(envPath, "utf-8");
|
|
75
|
+
for (const line of existing.split("\n")) {
|
|
76
|
+
if (!line.startsWith("ANALYTIX402_")) {
|
|
77
|
+
lines.push(line);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
while (lines.length > 0 && lines[lines.length - 1].trim() === "") {
|
|
81
|
+
lines.pop();
|
|
82
|
+
}
|
|
83
|
+
if (lines.length > 0) {
|
|
84
|
+
lines.push("");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
lines.push(`ANALYTIX402_API_KEY=${apiKey}`);
|
|
88
|
+
if (agentName !== "OpenClaw Agent") {
|
|
89
|
+
lines.push(`ANALYTIX402_AGENT_NAME=${agentName}`);
|
|
90
|
+
}
|
|
91
|
+
if (dailyBudget !== "0") {
|
|
92
|
+
lines.push(`ANALYTIX402_DAILY_BUDGET=${dailyBudget}`);
|
|
93
|
+
}
|
|
94
|
+
if (baseUrl !== "https://analytix402.com") {
|
|
95
|
+
lines.push(`ANALYTIX402_BASE_URL=${baseUrl}`);
|
|
96
|
+
}
|
|
97
|
+
lines.push("");
|
|
98
|
+
fs.writeFileSync(envPath, lines.join("\n"), "utf-8");
|
|
99
|
+
console.log(` Wrote config to ${envPath}`);
|
|
100
|
+
console.log(" You're all set. The skill will connect automatically on next start.\n");
|
|
101
|
+
}
|
|
102
|
+
main().catch((err) => {
|
|
103
|
+
console.error("Setup failed:", err);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@analytix402/openclaw-skill",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Analytix402 skill for OpenClaw — monitor, control, and optimize your AI agent's spend",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"openclaw-skill": "./dist/setup.js"
|
|
10
|
+
},
|
|
8
11
|
"exports": {
|
|
9
12
|
".": {
|
|
10
13
|
"types": "./dist/index.d.ts",
|
|
@@ -13,10 +16,13 @@
|
|
|
13
16
|
}
|
|
14
17
|
},
|
|
15
18
|
"scripts": {
|
|
16
|
-
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
19
|
+
"build": "tsup src/index.ts --format cjs,esm --dts && tsup src/setup.ts --format cjs --no-dts --outDir dist",
|
|
20
|
+
"build:index": "tsup src/index.ts --format cjs,esm --dts",
|
|
21
|
+
"build:setup": "tsup src/setup.ts --format cjs --no-dts --outDir dist",
|
|
17
22
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
18
23
|
"typecheck": "tsc --noEmit",
|
|
19
|
-
"
|
|
24
|
+
"postinstall": "echo \"\n Run 'npx @analytix402/openclaw-skill init' to configure your API key.\n\"",
|
|
25
|
+
"prepublishOnly": "npm run build:index && npm run build:setup"
|
|
20
26
|
},
|
|
21
27
|
"openclaw": {
|
|
22
28
|
"tools": {
|