@hblues419/agent-dashboard-daemon 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
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import { homedir } from "node:os";
4
+ import { join } from "node:path";
5
+ import { existsSync } from "node:fs";
6
+ import { handlers, OnchainosClient, OpenClawClient, SkillsScanner } from "@hblues419/agent-dashboard-core";
7
+ import { DaemonConnection } from "../src/connection.js";
8
+ const VERSION = "0.1.0";
9
+ const program = new Command()
10
+ .name("agent-dashboard-daemon")
11
+ .description("Local daemon for Agent Dashboard — connects to relay via WebSocket")
12
+ .version(VERSION)
13
+ .option("--server-url <url>", "WebSocket URL of the relay server", process.env.AGENT_DASHBOARD_RELAY_URL)
14
+ .option("--api-key <key>", "Machine API key for authentication", process.env.AGENT_DASHBOARD_DAEMON_API_KEY)
15
+ .option("--name <name>", "Human-readable machine name", `${homedir().split("/").pop()}_machine`)
16
+ .option("--onchainos-path <path>", "Path to onchainos binary", join(homedir(), ".local/bin/onchainos"))
17
+ .option("--openclaw-path <path>", "Path to openclaw binary", process.env.OPENCLAW_PATH ?? "openclaw")
18
+ .option("--openclaw-agent <agent>", "Default OpenClaw agent id for agent.message RPCs")
19
+ .option("--openclaw-session-id <sessionId>", "Default OpenClaw session id for agent.message RPCs")
20
+ .option("--openclaw-to <target>", "Default OpenClaw target for agent.message RPCs")
21
+ .option("--openclaw-local", "Run OpenClaw agent messages with --local by default", false)
22
+ .option("--skills-lock <path>", "Path to skills-lock.json")
23
+ .option("--default-chain <chain>", "Default chain for operations", "ethereum");
24
+ program.parse();
25
+ const opts = program.opts();
26
+ async function main() {
27
+ if (!opts.serverUrl || !opts.apiKey) {
28
+ console.error("--server-url and --api-key are required (or set AGENT_DASHBOARD_RELAY_URL and AGENT_DASHBOARD_DAEMON_API_KEY)");
29
+ process.exit(1);
30
+ }
31
+ validateServerUrl(opts.serverUrl);
32
+ // Verify onchainos binary
33
+ if (!existsSync(opts.onchainosPath)) {
34
+ console.error(`onchainos not found at ${opts.onchainosPath}`);
35
+ console.error("Install it or pass --onchainos-path");
36
+ process.exit(1);
37
+ }
38
+ const oc = new OnchainosClient(opts.onchainosPath);
39
+ const openclaw = new OpenClawClient(opts.openclawPath, {
40
+ agent: opts.openclawAgent,
41
+ sessionId: opts.openclawSessionId,
42
+ to: opts.openclawTo,
43
+ local: opts.openclawLocal,
44
+ });
45
+ const skills = new SkillsScanner(opts.skillsLock);
46
+ // Check wallet status
47
+ const status = await oc.run(["wallet", "status"]);
48
+ if (status.ok && status.data?.loggedIn) {
49
+ console.log(`Wallet: ${status.data.email} (${status.data.currentAccountName})`);
50
+ }
51
+ else {
52
+ console.warn("Wallet not logged in — some methods will be unavailable");
53
+ }
54
+ // Scan skills
55
+ const skillsInfo = skills.scan();
56
+ console.log(`Skills: ${skillsInfo.installedCount} installed, ${skillsInfo.lockedCount} locked`);
57
+ console.log(`Platform: ${skillsInfo.platform}`);
58
+ console.log(`OpenClaw: ${opts.openclawPath}`);
59
+ // Connect
60
+ console.log(`\nConnecting to ${opts.serverUrl}...`);
61
+ console.log(`Machine: ${opts.name}`);
62
+ const conn = new DaemonConnection({
63
+ serverUrl: opts.serverUrl,
64
+ apiKey: opts.apiKey,
65
+ ctx: { oc, openclaw, skills, defaultChain: opts.defaultChain },
66
+ version: VERSION,
67
+ skillsCount: skillsInfo.installedCount,
68
+ onConnect: () => {
69
+ console.log("Connected to relay");
70
+ console.log(`Methods available: ${Object.keys(handlers).length}`);
71
+ },
72
+ onDisconnect: () => {
73
+ console.log("Disconnected from relay");
74
+ },
75
+ });
76
+ conn.connect();
77
+ // Graceful shutdown
78
+ const shutdown = () => {
79
+ console.log("\nShutting down...");
80
+ conn.close();
81
+ setTimeout(() => process.exit(0), 100);
82
+ };
83
+ process.on("SIGINT", shutdown);
84
+ process.on("SIGTERM", shutdown);
85
+ }
86
+ main().catch((e) => {
87
+ console.error(e);
88
+ process.exit(1);
89
+ });
90
+ function validateServerUrl(raw) {
91
+ const url = new URL(raw);
92
+ const isLocalhost = url.hostname === "localhost" || url.hostname === "127.0.0.1" || url.hostname === "::1";
93
+ if (url.protocol !== "wss:" && !(url.protocol === "ws:" && isLocalhost)) {
94
+ throw new Error("server-url must use wss:// unless connecting to localhost");
95
+ }
96
+ }
97
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../bin/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAC3G,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE;KAC1B,IAAI,CAAC,wBAAwB,CAAC;KAC9B,WAAW,CAAC,oEAAoE,CAAC;KACjF,OAAO,CAAC,OAAO,CAAC;KAChB,MAAM,CAAC,oBAAoB,EAAE,mCAAmC,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC;KACxG,MAAM,CAAC,iBAAiB,EAAE,oCAAoC,EAAE,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC;KAC3G,MAAM,CAAC,eAAe,EAAE,6BAA6B,EAAE,GAAG,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,UAAU,CAAC;KAC/F,MAAM,CAAC,yBAAyB,EAAE,0BAA0B,E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AW,IAAI,GAAG,CAAC,QAAQ,KAAK,KAAK,CAAC;IAC3G,IAAI,GAAG,CAAC,QAAQ,KAAK,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,KAAK,KAAK,IAAI,WAAW,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC/E,CAAC;AACH,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { type HandlerContext } from "@hblues419/agent-dashboard-core";
2
+ export interface ConnectionOptions {
3
+ serverUrl: string;
4
+ apiKey: string;
5
+ ctx: HandlerContext;
6
+ version: string;
7
+ skillsCount: number;
8
+ onConnect?: () => void;
9
+ onDisconnect?: () => void;
10
+ }
11
+ export declare class DaemonConnection {
12
+ private opts;
13
+ private ws;
14
+ private pingTimer;
15
+ private pongTimer;
16
+ private reconnectAttempts;
17
+ private closed;
18
+ constructor(opts: ConnectionOptions);
19
+ connect(): void;
20
+ private handleRpc;
21
+ private sendPresence;
22
+ private send;
23
+ private startHeartbeat;
24
+ private resetPongTimeout;
25
+ private stopHeartbeat;
26
+ private cleanup;
27
+ private scheduleReconnect;
28
+ close(): void;
29
+ }
@@ -0,0 +1,147 @@
1
+ import WebSocket from "ws";
2
+ import { InboundMessage } from "./protocol.js";
3
+ import { dispatch } from "@hblues419/agent-dashboard-core";
4
+ const PING_INTERVAL = 30_000;
5
+ const PONG_TIMEOUT = 60_000;
6
+ const RECONNECT_BASE = 1_000;
7
+ const RECONNECT_CAP = 30_000;
8
+ export class DaemonConnection {
9
+ opts;
10
+ ws = null;
11
+ pingTimer = null;
12
+ pongTimer = null;
13
+ reconnectAttempts = 0;
14
+ closed = false;
15
+ constructor(opts) {
16
+ this.opts = opts;
17
+ }
18
+ connect() {
19
+ if (this.closed)
20
+ return;
21
+ const ws = new WebSocket(this.opts.serverUrl, {
22
+ headers: { Authorization: `Bearer ${this.opts.apiKey}` },
23
+ });
24
+ ws.on("open", () => {
25
+ this.reconnectAttempts = 0;
26
+ this.ws = ws;
27
+ this.startHeartbeat();
28
+ this.sendPresence("online");
29
+ this.opts.onConnect?.();
30
+ });
31
+ ws.on("message", (raw) => {
32
+ const text = raw.toString();
33
+ let msg;
34
+ try {
35
+ msg = JSON.parse(text);
36
+ }
37
+ catch {
38
+ return;
39
+ }
40
+ const parsed = InboundMessage.safeParse(msg);
41
+ if (!parsed.success)
42
+ return;
43
+ const m = parsed.data;
44
+ this.resetPongTimeout();
45
+ if (m.type === "ping") {
46
+ this.send({ type: "pong" });
47
+ return;
48
+ }
49
+ if (m.type === "pong")
50
+ return;
51
+ if (m.type === "rpc.request") {
52
+ void this.handleRpc(m);
53
+ }
54
+ });
55
+ ws.on("pong", () => {
56
+ this.resetPongTimeout();
57
+ });
58
+ ws.on("close", () => {
59
+ this.cleanup();
60
+ this.opts.onDisconnect?.();
61
+ this.scheduleReconnect();
62
+ });
63
+ ws.on("error", () => {
64
+ // close event will follow
65
+ });
66
+ }
67
+ async handleRpc(req) {
68
+ try {
69
+ const result = await dispatch(this.opts.ctx, req.method, req.params);
70
+ this.send({
71
+ type: "rpc.response",
72
+ id: req.id,
73
+ ok: result.ok,
74
+ ...(result.ok ? { data: result.data, notifications: result.notifications } : { error: result.error }),
75
+ });
76
+ }
77
+ catch (e) {
78
+ this.send({
79
+ type: "rpc.response",
80
+ id: req.id,
81
+ ok: false,
82
+ error: { message: e.message },
83
+ });
84
+ }
85
+ }
86
+ sendPresence(status) {
87
+ this.send({
88
+ type: "presence",
89
+ status,
90
+ version: this.opts.version,
91
+ skills: this.opts.skillsCount,
92
+ });
93
+ }
94
+ send(msg) {
95
+ if (this.ws?.readyState === WebSocket.OPEN) {
96
+ this.ws.send(JSON.stringify(msg));
97
+ }
98
+ }
99
+ startHeartbeat() {
100
+ this.stopHeartbeat();
101
+ this.pingTimer = setInterval(() => {
102
+ if (this.ws?.readyState === WebSocket.OPEN) {
103
+ this.send({ type: "ping" });
104
+ this.resetPongTimeout();
105
+ }
106
+ }, PING_INTERVAL);
107
+ }
108
+ resetPongTimeout() {
109
+ if (this.pongTimer)
110
+ clearTimeout(this.pongTimer);
111
+ this.pongTimer = setTimeout(() => {
112
+ this.ws?.terminate();
113
+ }, PONG_TIMEOUT);
114
+ }
115
+ stopHeartbeat() {
116
+ if (this.pingTimer) {
117
+ clearInterval(this.pingTimer);
118
+ this.pingTimer = null;
119
+ }
120
+ if (this.pongTimer) {
121
+ clearTimeout(this.pongTimer);
122
+ this.pongTimer = null;
123
+ }
124
+ }
125
+ cleanup() {
126
+ this.stopHeartbeat();
127
+ this.ws = null;
128
+ }
129
+ scheduleReconnect() {
130
+ if (this.closed)
131
+ return;
132
+ this.reconnectAttempts++;
133
+ const base = Math.min(RECONNECT_BASE * Math.pow(2, this.reconnectAttempts - 1), RECONNECT_CAP);
134
+ const jitter = base * (0.8 + Math.random() * 0.4);
135
+ const delay = Math.round(jitter);
136
+ console.log(`Reconnecting in ${(delay / 1000).toFixed(1)}s (attempt ${this.reconnectAttempts})...`);
137
+ setTimeout(() => this.connect(), delay);
138
+ }
139
+ close() {
140
+ this.closed = true;
141
+ this.sendPresence("offline");
142
+ const ws = this.ws;
143
+ this.cleanup();
144
+ ws?.close(1000, "daemon shutting down");
145
+ }
146
+ }
147
+ //# sourceMappingURL=connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/connection.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,IAAI,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAmB,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAuB,MAAM,iCAAiC,CAAC;AAYhF,MAAM,aAAa,GAAG,MAAM,CAAC;AAC7B,MAAM,YAAY,GAAG,MAAM,CAAC;AAC5B,MAAM,cAAc,GAAG,KAAK,CAAC;AAC7B,MAAM,aAAa,GAAG,MAAM,CAAC;AAE7B,MAAM,OAAO,gBAAgB;IAOP;IANZ,EAAE,GAAqB,IAAI,CAAC;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CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAC7B,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QACnB,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,EAAE,EAAE,KAAK,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;IAC1C,CAAC;CACF"}
@@ -0,0 +1,173 @@
1
+ import { z } from "zod";
2
+ export declare const RpcRequest: z.ZodObject<{
3
+ type: z.ZodLiteral<"rpc.request">;
4
+ id: z.ZodString;
5
+ method: z.ZodString;
6
+ params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ type: "rpc.request";
9
+ params: Record<string, unknown>;
10
+ id: string;
11
+ method: string;
12
+ }, {
13
+ type: "rpc.request";
14
+ id: string;
15
+ method: string;
16
+ params?: Record<string, unknown> | undefined;
17
+ }>;
18
+ export declare const RpcResponse: z.ZodObject<{
19
+ type: z.ZodLiteral<"rpc.response">;
20
+ id: z.ZodString;
21
+ ok: z.ZodBoolean;
22
+ data: z.ZodOptional<z.ZodUnknown>;
23
+ error: z.ZodOptional<z.ZodObject<{
24
+ code: z.ZodOptional<z.ZodString>;
25
+ message: z.ZodString;
26
+ }, "strip", z.ZodTypeAny, {
27
+ message: string;
28
+ code?: string | undefined;
29
+ }, {
30
+ message: string;
31
+ code?: string | undefined;
32
+ }>>;
33
+ notifications: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
34
+ }, "strip", z.ZodTypeAny, {
35
+ type: "rpc.response";
36
+ id: string;
37
+ ok: boolean;
38
+ data?: unknown;
39
+ error?: {
40
+ message: string;
41
+ code?: string | undefined;
42
+ } | undefined;
43
+ notifications?: unknown[] | undefined;
44
+ }, {
45
+ type: "rpc.response";
46
+ id: string;
47
+ ok: boolean;
48
+ data?: unknown;
49
+ error?: {
50
+ message: string;
51
+ code?: string | undefined;
52
+ } | undefined;
53
+ notifications?: unknown[] | undefined;
54
+ }>;
55
+ export declare const Ping: z.ZodObject<{
56
+ type: z.ZodLiteral<"ping">;
57
+ }, "strip", z.ZodTypeAny, {
58
+ type: "ping";
59
+ }, {
60
+ type: "ping";
61
+ }>;
62
+ export declare const Pong: z.ZodObject<{
63
+ type: z.ZodLiteral<"pong">;
64
+ }, "strip", z.ZodTypeAny, {
65
+ type: "pong";
66
+ }, {
67
+ type: "pong";
68
+ }>;
69
+ export declare const Presence: z.ZodObject<{
70
+ type: z.ZodLiteral<"presence">;
71
+ status: z.ZodEnum<["online", "offline"]>;
72
+ version: z.ZodString;
73
+ skills: z.ZodOptional<z.ZodNumber>;
74
+ }, "strip", z.ZodTypeAny, {
75
+ type: "presence";
76
+ status: "online" | "offline";
77
+ version: string;
78
+ skills?: number | undefined;
79
+ }, {
80
+ type: "presence";
81
+ status: "online" | "offline";
82
+ version: string;
83
+ skills?: number | undefined;
84
+ }>;
85
+ export declare const InboundMessage: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
86
+ type: z.ZodLiteral<"rpc.request">;
87
+ id: z.ZodString;
88
+ method: z.ZodString;
89
+ params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
90
+ }, "strip", z.ZodTypeAny, {
91
+ type: "rpc.request";
92
+ params: Record<string, unknown>;
93
+ id: string;
94
+ method: string;
95
+ }, {
96
+ type: "rpc.request";
97
+ id: string;
98
+ method: string;
99
+ params?: Record<string, unknown> | undefined;
100
+ }>, z.ZodObject<{
101
+ type: z.ZodLiteral<"ping">;
102
+ }, "strip", z.ZodTypeAny, {
103
+ type: "ping";
104
+ }, {
105
+ type: "ping";
106
+ }>, z.ZodObject<{
107
+ type: z.ZodLiteral<"pong">;
108
+ }, "strip", z.ZodTypeAny, {
109
+ type: "pong";
110
+ }, {
111
+ type: "pong";
112
+ }>]>;
113
+ export declare const OutboundMessage: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
114
+ type: z.ZodLiteral<"rpc.response">;
115
+ id: z.ZodString;
116
+ ok: z.ZodBoolean;
117
+ data: z.ZodOptional<z.ZodUnknown>;
118
+ error: z.ZodOptional<z.ZodObject<{
119
+ code: z.ZodOptional<z.ZodString>;
120
+ message: z.ZodString;
121
+ }, "strip", z.ZodTypeAny, {
122
+ message: string;
123
+ code?: string | undefined;
124
+ }, {
125
+ message: string;
126
+ code?: string | undefined;
127
+ }>>;
128
+ notifications: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
129
+ }, "strip", z.ZodTypeAny, {
130
+ type: "rpc.response";
131
+ id: string;
132
+ ok: boolean;
133
+ data?: unknown;
134
+ error?: {
135
+ message: string;
136
+ code?: string | undefined;
137
+ } | undefined;
138
+ notifications?: unknown[] | undefined;
139
+ }, {
140
+ type: "rpc.response";
141
+ id: string;
142
+ ok: boolean;
143
+ data?: unknown;
144
+ error?: {
145
+ message: string;
146
+ code?: string | undefined;
147
+ } | undefined;
148
+ notifications?: unknown[] | undefined;
149
+ }>, z.ZodObject<{
150
+ type: z.ZodLiteral<"pong">;
151
+ }, "strip", z.ZodTypeAny, {
152
+ type: "pong";
153
+ }, {
154
+ type: "pong";
155
+ }>, z.ZodObject<{
156
+ type: z.ZodLiteral<"presence">;
157
+ status: z.ZodEnum<["online", "offline"]>;
158
+ version: z.ZodString;
159
+ skills: z.ZodOptional<z.ZodNumber>;
160
+ }, "strip", z.ZodTypeAny, {
161
+ type: "presence";
162
+ status: "online" | "offline";
163
+ version: string;
164
+ skills?: number | undefined;
165
+ }, {
166
+ type: "presence";
167
+ status: "online" | "offline";
168
+ version: string;
169
+ skills?: number | undefined;
170
+ }>]>;
171
+ export type RpcRequest = z.infer<typeof RpcRequest>;
172
+ export type RpcResponse = z.infer<typeof RpcResponse>;
173
+ export type Presence = z.infer<typeof Presence>;
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ export const RpcRequest = z.object({
3
+ type: z.literal("rpc.request"),
4
+ id: z.string(),
5
+ method: z.string(),
6
+ params: z.record(z.unknown()).default({}),
7
+ });
8
+ export const RpcResponse = z.object({
9
+ type: z.literal("rpc.response"),
10
+ id: z.string(),
11
+ ok: z.boolean(),
12
+ data: z.unknown().optional(),
13
+ error: z.object({ code: z.string().optional(), message: z.string() }).optional(),
14
+ notifications: z.array(z.unknown()).optional(),
15
+ });
16
+ export const Ping = z.object({ type: z.literal("ping") });
17
+ export const Pong = z.object({ type: z.literal("pong") });
18
+ export const Presence = z.object({
19
+ type: z.literal("presence"),
20
+ status: z.enum(["online", "offline"]),
21
+ version: z.string(),
22
+ skills: z.number().optional(),
23
+ });
24
+ export const InboundMessage = z.discriminatedUnion("type", [RpcRequest, Ping, Pong]);
25
+ export const OutboundMessage = z.discriminatedUnion("type", [RpcResponse, Pong, Presence]);
26
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;IAC9B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CAC1C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;IAC/B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE;IACf,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC5B,KAA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Agent Dashboard — connects to relay via WebSocket, executes onchainos CLI commands locally.",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "type": "module",
9
+ "bin": {
10
+ "agent-dashboard-daemon": "./dist/bin/cli.js"
11
+ },
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "dev": "tsx watch bin/cli.ts"
18
+ },
19
+ "dependencies": {
20
+ "@hblues419/agent-dashboard-core": "^0.1.0",
21
+ "commander": "^12.1.0",
22
+ "ws": "^8.18.0",
23
+ "zod": "^3.24.0"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^22.10.1",
27
+ "@types/ws": "^8.5.13",
28
+ "tsx": "^4.19.2",
29
+ "typescript": "^5.7.2"
30
+ },
31
+ "engines": {
32
+ "node": ">=18"
33
+ }
34
+ }