@ch4p/cli 0.2.3 → 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.
Files changed (40) hide show
  1. package/dist/agent-5OVBABE3.js +765 -0
  2. package/dist/agent-EQWU6KSU.js +765 -0
  3. package/dist/agent-FJPYQ6XV.js +765 -0
  4. package/dist/agent-WYITNAJU.js +765 -0
  5. package/dist/agent-XZVKJIJ5.js +765 -0
  6. package/dist/canvas-2JNS7CMC.js +324 -0
  7. package/dist/canvas-4LGESGLM.js +324 -0
  8. package/dist/canvas-BW7CYPN3.js +324 -0
  9. package/dist/canvas-FTJBNVCM.js +324 -0
  10. package/dist/canvas-MWPE2PQK.js +324 -0
  11. package/dist/canvas-NXLWNI43.js +324 -0
  12. package/dist/canvas-PC5NYJDT.js +324 -0
  13. package/dist/canvas-TGYQHRYN.js +324 -0
  14. package/dist/chunk-2JQRW4PJ.js +2411 -0
  15. package/dist/chunk-34NIJXVM.js +2415 -0
  16. package/dist/chunk-4WUPNLKF.js +7747 -0
  17. package/dist/chunk-AVGUMMZG.js +4455 -0
  18. package/dist/chunk-AW4NG3S5.js +3413 -0
  19. package/dist/chunk-KFUI3QZ2.js +2415 -0
  20. package/dist/chunk-MQKGGZAB.js +7736 -0
  21. package/dist/chunk-N743BUPD.js +2415 -0
  22. package/dist/chunk-ODOKLIJK.js +2415 -0
  23. package/dist/chunk-OUSWJVVJ.js +2415 -0
  24. package/dist/chunk-Y6WYS576.js +2415 -0
  25. package/dist/chunk-YTUBP6WQ.js +2410 -0
  26. package/dist/chunk-ZOCVQFO4.js +7739 -0
  27. package/dist/chunk-ZR7T5BT6.js +7752 -0
  28. package/dist/gateway-4JZYQLZF.js +19 -0
  29. package/dist/gateway-BS2IUIQT.js +19 -0
  30. package/dist/gateway-HIRX2D3Q.js +19 -0
  31. package/dist/gateway-ILVICOGD.js +19 -0
  32. package/dist/gateway-J7WHUIK3.js +19 -0
  33. package/dist/gateway-JAGHGXCR.js +19 -0
  34. package/dist/gateway-JTQ2FYQZ.js +19 -0
  35. package/dist/gateway-N7MJSTAD.js +19 -0
  36. package/dist/index.js +6 -6
  37. package/dist/install-4JYHJURZ.js +378 -0
  38. package/dist/message-IQ4WVCHZ.js +189 -0
  39. package/dist/tools-A7GRNRGL.js +50 -0
  40. package/package.json +18 -18
@@ -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.2.3",
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/agent": "0.2.3",
57
- "@ch4p/core": "0.2.3",
58
- "@ch4p/security": "0.2.3",
59
- "@ch4p/providers": "0.2.3",
60
- "@ch4p/memory": "0.2.3",
61
- "@ch4p/tools": "0.2.3",
62
- "@ch4p/observability": "0.2.3",
63
- "@ch4p/channels": "0.2.3",
64
- "@ch4p/engines": "0.2.3",
65
- "@ch4p/supervisor": "0.2.3",
66
- "@ch4p/gateway": "0.2.3",
67
- "@ch4p/skills": "0.2.3",
68
- "@ch4p/tunnels": "0.2.3",
69
- "@ch4p/voice": "0.2.3",
70
- "@ch4p/canvas": "0.2.3",
71
- "@ch4p/plugin-x402": "0.2.3"
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",