@ch4p/cli 0.3.0 → 0.3.3

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,19 @@
1
+ import {
2
+ applySafeUpdates,
3
+ buildSafeConfig,
4
+ gateway
5
+ } from "./chunk-N743BUPD.js";
6
+ import "./chunk-WYXCGS55.js";
7
+ import "./chunk-AVGUMMZG.js";
8
+ import "./chunk-ZR7T5BT6.js";
9
+ import "./chunk-MABLWEGE.js";
10
+ import "./chunk-6BURGD2Y.js";
11
+ import "./chunk-UNF4S4CA.js";
12
+ import "./chunk-YSCX2QQQ.js";
13
+ import "./chunk-AORLXQHZ.js";
14
+ import "./chunk-NMGPBPNU.js";
15
+ export {
16
+ applySafeUpdates,
17
+ buildSafeConfig,
18
+ gateway
19
+ };
@@ -0,0 +1,19 @@
1
+ import {
2
+ applySafeUpdates,
3
+ buildSafeConfig,
4
+ gateway
5
+ } from "./chunk-34NIJXVM.js";
6
+ import "./chunk-WYXCGS55.js";
7
+ import "./chunk-3CYOOHMM.js";
8
+ import "./chunk-ZOCVQFO4.js";
9
+ import "./chunk-MABLWEGE.js";
10
+ import "./chunk-6BURGD2Y.js";
11
+ import "./chunk-UNF4S4CA.js";
12
+ import "./chunk-YSCX2QQQ.js";
13
+ import "./chunk-AORLXQHZ.js";
14
+ import "./chunk-NMGPBPNU.js";
15
+ export {
16
+ applySafeUpdates,
17
+ buildSafeConfig,
18
+ gateway
19
+ };
@@ -0,0 +1,19 @@
1
+ import {
2
+ applySafeUpdates,
3
+ buildSafeConfig,
4
+ gateway
5
+ } from "./chunk-KFUI3QZ2.js";
6
+ import "./chunk-WYXCGS55.js";
7
+ import "./chunk-AVGUMMZG.js";
8
+ import "./chunk-4WUPNLKF.js";
9
+ import "./chunk-MABLWEGE.js";
10
+ import "./chunk-6BURGD2Y.js";
11
+ import "./chunk-UNF4S4CA.js";
12
+ import "./chunk-YSCX2QQQ.js";
13
+ import "./chunk-AORLXQHZ.js";
14
+ import "./chunk-NMGPBPNU.js";
15
+ export {
16
+ applySafeUpdates,
17
+ buildSafeConfig,
18
+ gateway
19
+ };
@@ -0,0 +1,19 @@
1
+ import {
2
+ applySafeUpdates,
3
+ buildSafeConfig,
4
+ gateway
5
+ } from "./chunk-OUSWJVVJ.js";
6
+ import "./chunk-WYXCGS55.js";
7
+ import "./chunk-AVGUMMZG.js";
8
+ import "./chunk-ZOCVQFO4.js";
9
+ import "./chunk-MABLWEGE.js";
10
+ import "./chunk-6BURGD2Y.js";
11
+ import "./chunk-UNF4S4CA.js";
12
+ import "./chunk-YSCX2QQQ.js";
13
+ import "./chunk-AORLXQHZ.js";
14
+ import "./chunk-NMGPBPNU.js";
15
+ export {
16
+ applySafeUpdates,
17
+ buildSafeConfig,
18
+ gateway
19
+ };
@@ -0,0 +1,19 @@
1
+ import {
2
+ applySafeUpdates,
3
+ buildSafeConfig,
4
+ gateway
5
+ } from "./chunk-Y6WYS576.js";
6
+ import "./chunk-WYXCGS55.js";
7
+ import "./chunk-AVGUMMZG.js";
8
+ import "./chunk-ZR7T5BT6.js";
9
+ import "./chunk-AW4NG3S5.js";
10
+ import "./chunk-6BURGD2Y.js";
11
+ import "./chunk-UNF4S4CA.js";
12
+ import "./chunk-YSCX2QQQ.js";
13
+ import "./chunk-AORLXQHZ.js";
14
+ import "./chunk-NMGPBPNU.js";
15
+ export {
16
+ applySafeUpdates,
17
+ buildSafeConfig,
18
+ gateway
19
+ };
package/dist/index.js CHANGED
@@ -106,12 +106,12 @@ async function main() {
106
106
  const { command, rest } = parseArgs(process.argv);
107
107
  switch (command) {
108
108
  case "agent": {
109
- const { agent } = await import("./agent-FJPYQ6XV.js");
109
+ const { agent } = await import("./agent-EQWU6KSU.js");
110
110
  await agent(rest);
111
111
  break;
112
112
  }
113
113
  case "gateway": {
114
- const { gateway } = await import("./gateway-BS2IUIQT.js");
114
+ const { gateway } = await import("./gateway-N7MJSTAD.js");
115
115
  await gateway(rest);
116
116
  break;
117
117
  }
@@ -136,7 +136,7 @@ async function main() {
136
136
  break;
137
137
  }
138
138
  case "tools": {
139
- const { tools } = await import("./tools-ORNZA5W6.js");
139
+ const { tools } = await import("./tools-A7GRNRGL.js");
140
140
  await tools();
141
141
  break;
142
142
  }
@@ -146,7 +146,7 @@ async function main() {
146
146
  break;
147
147
  }
148
148
  case "message": {
149
- const { message } = await import("./message-LTVKYQKB.js");
149
+ const { message } = await import("./message-IQ4WVCHZ.js");
150
150
  await message(rest);
151
151
  break;
152
152
  }
@@ -156,7 +156,7 @@ async function main() {
156
156
  break;
157
157
  }
158
158
  case "canvas": {
159
- const { canvas } = await import("./canvas-FTJBNVCM.js");
159
+ const { canvas } = await import("./canvas-NXLWNI43.js");
160
160
  await canvas(rest);
161
161
  break;
162
162
  }
@@ -0,0 +1,189 @@
1
+ import {
2
+ CliChannel,
3
+ DiscordChannel,
4
+ IMessageChannel,
5
+ MatrixChannel,
6
+ SignalChannel,
7
+ SlackChannel,
8
+ TelegramChannel,
9
+ WhatsAppChannel
10
+ } from "./chunk-AVGUMMZG.js";
11
+ import "./chunk-YSCX2QQQ.js";
12
+ import {
13
+ loadConfig
14
+ } from "./chunk-AORLXQHZ.js";
15
+ import {
16
+ BOLD,
17
+ DIM,
18
+ GREEN,
19
+ RED,
20
+ RESET,
21
+ TEAL,
22
+ separator
23
+ } from "./chunk-NMGPBPNU.js";
24
+
25
+ // src/commands/message.ts
26
+ function createChannelInstance(channelName) {
27
+ switch (channelName) {
28
+ case "telegram":
29
+ return new TelegramChannel();
30
+ case "discord":
31
+ return new DiscordChannel();
32
+ case "slack":
33
+ return new SlackChannel();
34
+ case "cli":
35
+ return new CliChannel();
36
+ case "matrix":
37
+ return new MatrixChannel();
38
+ case "whatsapp":
39
+ return new WhatsAppChannel();
40
+ case "signal":
41
+ return new SignalChannel();
42
+ case "imessage":
43
+ return new IMessageChannel();
44
+ default:
45
+ return null;
46
+ }
47
+ }
48
+ function parseMessageArgs(args) {
49
+ let channel = null;
50
+ let threadId = null;
51
+ let text = null;
52
+ const textParts = [];
53
+ for (let i = 0; i < args.length; i++) {
54
+ const arg = args[i];
55
+ if (arg === "-c" || arg === "--channel") {
56
+ channel = args[i + 1] ?? null;
57
+ i++;
58
+ continue;
59
+ }
60
+ if (arg === "-t" || arg === "--thread") {
61
+ threadId = args[i + 1] ?? null;
62
+ i++;
63
+ continue;
64
+ }
65
+ textParts.push(arg);
66
+ }
67
+ if (textParts.length > 0) {
68
+ text = textParts.join(" ");
69
+ }
70
+ return { channel, threadId, text };
71
+ }
72
+ async function message(args) {
73
+ const parsed = parseMessageArgs(args);
74
+ if (!parsed.channel) {
75
+ console.error(`
76
+ ${RED}Error:${RESET} Channel is required.`);
77
+ console.error(` ${DIM}Usage: ch4p message -c <channel> "message text"${RESET}`);
78
+ console.error(` ${DIM}Example: ch4p message -c telegram "Hello!"${RESET}
79
+ `);
80
+ process.exitCode = 1;
81
+ return;
82
+ }
83
+ if (!parsed.text) {
84
+ console.error(`
85
+ ${RED}Error:${RESET} Message text is required.`);
86
+ console.error(` ${DIM}Usage: ch4p message -c ${parsed.channel} "message text"${RESET}
87
+ `);
88
+ process.exitCode = 1;
89
+ return;
90
+ }
91
+ let config;
92
+ try {
93
+ config = loadConfig();
94
+ } catch (err) {
95
+ const errMessage = err instanceof Error ? err.message : String(err);
96
+ console.error(`
97
+ ${RED}Failed to load config:${RESET} ${errMessage}`);
98
+ console.error(` ${DIM}Run ${TEAL}ch4p onboard${DIM} to set up ch4p.${RESET}
99
+ `);
100
+ process.exitCode = 1;
101
+ return;
102
+ }
103
+ const channelConfig = config.channels[parsed.channel];
104
+ if (!channelConfig) {
105
+ const availableChannels = Object.keys(config.channels);
106
+ console.error(`
107
+ ${RED}Error:${RESET} Channel "${parsed.channel}" is not configured.`);
108
+ if (availableChannels.length > 0) {
109
+ console.error(` ${DIM}Available channels: ${availableChannels.join(", ")}${RESET}`);
110
+ } else {
111
+ console.error(` ${DIM}No channels configured. Add channels to ~/.ch4p/config.json.${RESET}`);
112
+ console.error(` ${DIM}Example for Telegram:${RESET}`);
113
+ console.error(` ${DIM} "channels": { "telegram": { "token": "BOT_TOKEN" } }${RESET}`);
114
+ }
115
+ console.error("");
116
+ process.exitCode = 1;
117
+ return;
118
+ }
119
+ const channel = createChannelInstance(parsed.channel);
120
+ if (!channel) {
121
+ console.error(`
122
+ ${RED}Error:${RESET} Unknown channel type "${parsed.channel}".`);
123
+ console.error(` ${DIM}Supported channels: telegram, discord, slack, cli${RESET}
124
+ `);
125
+ process.exitCode = 1;
126
+ return;
127
+ }
128
+ console.log(`
129
+ ${TEAL}${BOLD}ch4p Message${RESET}`);
130
+ console.log(separator());
131
+ console.log("");
132
+ console.log(` ${BOLD}Channel${RESET} ${parsed.channel}`);
133
+ if (parsed.threadId) {
134
+ console.log(` ${BOLD}Thread${RESET} ${parsed.threadId}`);
135
+ }
136
+ console.log(` ${BOLD}Message${RESET} ${parsed.text}`);
137
+ console.log("");
138
+ try {
139
+ console.log(` ${DIM}Starting ${parsed.channel} channel...${RESET}`);
140
+ await channel.start(channelConfig);
141
+ } catch (err) {
142
+ const errMessage = err instanceof Error ? err.message : String(err);
143
+ console.error(` ${RED}Failed to start channel:${RESET} ${errMessage}
144
+ `);
145
+ process.exitCode = 1;
146
+ return;
147
+ }
148
+ const outbound = {
149
+ text: parsed.text,
150
+ format: "text"
151
+ };
152
+ const recipient = {
153
+ channelId: parsed.channel,
154
+ userId: channelConfig["chatId"] ?? channelConfig["defaultChatId"] ?? void 0,
155
+ groupId: channelConfig["channelId"] ?? channelConfig["defaultChannelId"] ?? void 0,
156
+ threadId: parsed.threadId ?? void 0
157
+ };
158
+ if (!recipient.userId && !recipient.groupId) {
159
+ console.error(` ${RED}Error:${RESET} No recipient specified.`);
160
+ console.error(` ${DIM}Add "chatId" or "defaultChatId" to your ${parsed.channel} channel config.${RESET}`);
161
+ console.error(` ${DIM}Example: "channels": { "${parsed.channel}": { "token": "...", "chatId": "123" } }${RESET}
162
+ `);
163
+ await channel.stop();
164
+ process.exitCode = 1;
165
+ return;
166
+ }
167
+ try {
168
+ const result = await channel.send(recipient, outbound);
169
+ if (result.success) {
170
+ console.log(` ${GREEN}${BOLD}Sent!${RESET}`);
171
+ if (result.messageId) {
172
+ console.log(` ${DIM}Message ID: ${result.messageId}${RESET}`);
173
+ }
174
+ } else {
175
+ console.error(` ${RED}Failed to send:${RESET} ${result.error ?? "Unknown error"}`);
176
+ process.exitCode = 1;
177
+ }
178
+ } catch (err) {
179
+ const errMessage = err instanceof Error ? err.message : String(err);
180
+ console.error(` ${RED}Send error:${RESET} ${errMessage}`);
181
+ process.exitCode = 1;
182
+ } finally {
183
+ await channel.stop();
184
+ }
185
+ console.log("");
186
+ }
187
+ export {
188
+ message
189
+ };
@@ -0,0 +1,50 @@
1
+ import {
2
+ ToolRegistry
3
+ } from "./chunk-AW4NG3S5.js";
4
+ import "./chunk-YSCX2QQQ.js";
5
+ import {
6
+ BOLD,
7
+ DIM,
8
+ GREEN,
9
+ MAGENTA,
10
+ RESET,
11
+ TEAL,
12
+ YELLOW,
13
+ separator
14
+ } from "./chunk-NMGPBPNU.js";
15
+
16
+ // src/commands/tools.ts
17
+ function weightLabel(weight) {
18
+ return weight === "lightweight" ? `${GREEN}lightweight${RESET}` : `${YELLOW}heavyweight${RESET}`;
19
+ }
20
+ async function tools() {
21
+ const registry = ToolRegistry.createDefault();
22
+ const allTools = registry.list();
23
+ console.log(`
24
+ ${TEAL}${BOLD}ch4p Tools${RESET}`);
25
+ console.log(separator());
26
+ console.log("");
27
+ const maxNameLen = Math.max(...allTools.map((t) => t.name.length));
28
+ for (const tool of allTools) {
29
+ const paddedName = tool.name.padEnd(maxNameLen + 2, " ");
30
+ console.log(
31
+ ` ${MAGENTA}${BOLD}${paddedName}${RESET}${tool.description}`
32
+ );
33
+ console.log(
34
+ ` ${"".padEnd(maxNameLen + 2, " ")}${DIM}weight: ${RESET}${weightLabel(tool.weight)}`
35
+ );
36
+ }
37
+ const lwCount = allTools.filter((t) => t.weight === "lightweight").length;
38
+ const hwCount = allTools.filter((t) => t.weight === "heavyweight").length;
39
+ console.log(`
40
+ ${separator()}`);
41
+ console.log(
42
+ ` ${allTools.length} tools (${GREEN}${lwCount} lightweight${RESET}, ${YELLOW}${hwCount} heavyweight${RESET})`
43
+ );
44
+ console.log(` ${DIM}Lightweight tools run on the main thread.${RESET}`);
45
+ console.log(` ${DIM}Heavyweight tools run in worker threads for isolation.${RESET}
46
+ `);
47
+ }
48
+ export {
49
+ tools
50
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ch4p/cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.3",
4
4
  "description": "Personal AI assistant platform — security-first, multi-channel, programmable",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -32,7 +32,7 @@
32
32
  "url": "https://github.com/ch4p-labs/ch4p/issues"
33
33
  },
34
34
  "engines": {
35
- "node": ">=22.0.0"
35
+ "node": ">=20.0.0"
36
36
  },
37
37
  "keywords": [
38
38
  "ai",
@@ -53,22 +53,22 @@
53
53
  "playwright-core": "^1.50.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@ch4p/core": "0.3.0",
57
- "@ch4p/agent": "0.3.0",
58
- "@ch4p/channels": "0.3.0",
59
- "@ch4p/security": "0.3.0",
60
- "@ch4p/providers": "0.3.0",
61
- "@ch4p/memory": "0.3.0",
62
- "@ch4p/tools": "0.3.0",
63
- "@ch4p/observability": "0.3.0",
64
- "@ch4p/engines": "0.3.0",
65
- "@ch4p/gateway": "0.3.0",
66
- "@ch4p/supervisor": "0.3.0",
67
- "@ch4p/skills": "0.3.0",
68
- "@ch4p/tunnels": "0.3.0",
69
- "@ch4p/voice": "0.3.0",
70
- "@ch4p/canvas": "0.3.0",
71
- "@ch4p/plugin-x402": "0.3.0"
56
+ "@ch4p/core": "0.3.3",
57
+ "@ch4p/security": "0.3.3",
58
+ "@ch4p/agent": "0.3.3",
59
+ "@ch4p/tools": "0.3.3",
60
+ "@ch4p/providers": "0.3.3",
61
+ "@ch4p/engines": "0.3.3",
62
+ "@ch4p/memory": "0.3.3",
63
+ "@ch4p/supervisor": "0.3.3",
64
+ "@ch4p/observability": "0.3.3",
65
+ "@ch4p/skills": "0.3.3",
66
+ "@ch4p/canvas": "0.3.3",
67
+ "@ch4p/channels": "0.3.3",
68
+ "@ch4p/tunnels": "0.3.3",
69
+ "@ch4p/gateway": "0.3.3",
70
+ "@ch4p/voice": "0.3.3",
71
+ "@ch4p/plugin-x402": "0.3.3"
72
72
  },
73
73
  "scripts": {
74
74
  "build": "tsup",