opc-agent 3.0.0 → 4.0.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.
Files changed (151) hide show
  1. package/README.md +30 -24
  2. package/dist/channels/dingtalk.d.ts +17 -0
  3. package/dist/channels/dingtalk.js +38 -0
  4. package/dist/channels/googlechat.d.ts +14 -0
  5. package/dist/channels/googlechat.js +37 -0
  6. package/dist/channels/imessage.d.ts +13 -0
  7. package/dist/channels/imessage.js +28 -0
  8. package/dist/channels/irc.d.ts +20 -0
  9. package/dist/channels/irc.js +71 -0
  10. package/dist/channels/line.d.ts +14 -0
  11. package/dist/channels/line.js +28 -0
  12. package/dist/channels/matrix.d.ts +15 -0
  13. package/dist/channels/matrix.js +28 -0
  14. package/dist/channels/mattermost.d.ts +18 -0
  15. package/dist/channels/mattermost.js +49 -0
  16. package/dist/channels/msteams.d.ts +14 -0
  17. package/dist/channels/msteams.js +28 -0
  18. package/dist/channels/nostr.d.ts +14 -0
  19. package/dist/channels/nostr.js +28 -0
  20. package/dist/channels/qq.d.ts +15 -0
  21. package/dist/channels/qq.js +28 -0
  22. package/dist/channels/signal.d.ts +14 -0
  23. package/dist/channels/signal.js +28 -0
  24. package/dist/channels/sms.d.ts +15 -0
  25. package/dist/channels/sms.js +28 -0
  26. package/dist/channels/twitch.d.ts +17 -0
  27. package/dist/channels/twitch.js +59 -0
  28. package/dist/channels/voice-call.d.ts +27 -0
  29. package/dist/channels/voice-call.js +82 -0
  30. package/dist/channels/whatsapp.d.ts +14 -0
  31. package/dist/channels/whatsapp.js +28 -0
  32. package/dist/cli.js +36 -0
  33. package/dist/core/api-server.d.ts +25 -0
  34. package/dist/core/api-server.js +286 -0
  35. package/dist/core/audio.d.ts +50 -0
  36. package/dist/core/audio.js +68 -0
  37. package/dist/core/context-discovery.d.ts +16 -0
  38. package/dist/core/context-discovery.js +107 -0
  39. package/dist/core/context-refs.d.ts +29 -0
  40. package/dist/core/context-refs.js +162 -0
  41. package/dist/core/gateway.d.ts +53 -0
  42. package/dist/core/gateway.js +80 -0
  43. package/dist/core/heartbeat.d.ts +19 -0
  44. package/dist/core/heartbeat.js +50 -0
  45. package/dist/core/hooks.d.ts +28 -0
  46. package/dist/core/hooks.js +82 -0
  47. package/dist/core/ide-bridge.d.ts +53 -0
  48. package/dist/core/ide-bridge.js +97 -0
  49. package/dist/core/node-network.d.ts +23 -0
  50. package/dist/core/node-network.js +77 -0
  51. package/dist/core/profiles.d.ts +27 -0
  52. package/dist/core/profiles.js +131 -0
  53. package/dist/core/sandbox.d.ts +25 -0
  54. package/dist/core/sandbox.js +84 -1
  55. package/dist/core/session-manager.d.ts +33 -0
  56. package/dist/core/session-manager.js +157 -0
  57. package/dist/core/vision.d.ts +45 -0
  58. package/dist/core/vision.js +177 -0
  59. package/dist/index.d.ts +64 -1
  60. package/dist/index.js +86 -3
  61. package/dist/memory/context-compressor.d.ts +43 -0
  62. package/dist/memory/context-compressor.js +167 -0
  63. package/dist/memory/index.d.ts +4 -0
  64. package/dist/memory/index.js +5 -1
  65. package/dist/memory/user-profiler.d.ts +50 -0
  66. package/dist/memory/user-profiler.js +201 -0
  67. package/dist/schema/oad.d.ts +12 -12
  68. package/dist/security/approvals.d.ts +53 -0
  69. package/dist/security/approvals.js +115 -0
  70. package/dist/security/elevated.d.ts +41 -0
  71. package/dist/security/elevated.js +89 -0
  72. package/dist/security/index.d.ts +6 -0
  73. package/dist/security/index.js +7 -1
  74. package/dist/security/secrets.d.ts +34 -0
  75. package/dist/security/secrets.js +115 -0
  76. package/dist/tools/builtin/browser.d.ts +47 -0
  77. package/dist/tools/builtin/browser.js +284 -0
  78. package/dist/tools/builtin/home-assistant.d.ts +12 -0
  79. package/dist/tools/builtin/home-assistant.js +126 -0
  80. package/dist/tools/builtin/index.d.ts +6 -1
  81. package/dist/tools/builtin/index.js +18 -2
  82. package/dist/tools/builtin/rl-tools.d.ts +13 -0
  83. package/dist/tools/builtin/rl-tools.js +228 -0
  84. package/dist/tools/builtin/vision.d.ts +6 -0
  85. package/dist/tools/builtin/vision.js +61 -0
  86. package/package.json +3 -3
  87. package/src/channels/dingtalk.ts +46 -0
  88. package/src/channels/googlechat.ts +42 -0
  89. package/src/channels/imessage.ts +32 -0
  90. package/src/channels/irc.ts +82 -0
  91. package/src/channels/line.ts +33 -0
  92. package/src/channels/matrix.ts +34 -0
  93. package/src/channels/mattermost.ts +57 -0
  94. package/src/channels/msteams.ts +33 -0
  95. package/src/channels/nostr.ts +33 -0
  96. package/src/channels/qq.ts +34 -0
  97. package/src/channels/signal.ts +33 -0
  98. package/src/channels/sms.ts +34 -0
  99. package/src/channels/twitch.ts +65 -0
  100. package/src/channels/voice-call.ts +100 -0
  101. package/src/channels/whatsapp.ts +33 -0
  102. package/src/cli.ts +40 -0
  103. package/src/core/api-server.ts +277 -0
  104. package/src/core/audio.ts +98 -0
  105. package/src/core/context-discovery.ts +85 -0
  106. package/src/core/context-refs.ts +140 -0
  107. package/src/core/gateway.ts +106 -0
  108. package/src/core/heartbeat.ts +51 -0
  109. package/src/core/hooks.ts +105 -0
  110. package/src/core/ide-bridge.ts +133 -0
  111. package/src/core/node-network.ts +86 -0
  112. package/src/core/profiles.ts +122 -0
  113. package/src/core/sandbox.ts +100 -0
  114. package/src/core/session-manager.ts +137 -0
  115. package/src/core/vision.ts +180 -0
  116. package/src/index.ts +84 -1
  117. package/src/memory/context-compressor.ts +189 -0
  118. package/src/memory/index.ts +4 -0
  119. package/src/memory/user-profiler.ts +215 -0
  120. package/src/security/approvals.ts +143 -0
  121. package/src/security/elevated.ts +105 -0
  122. package/src/security/index.ts +6 -0
  123. package/src/security/secrets.ts +129 -0
  124. package/src/tools/builtin/browser.ts +299 -0
  125. package/src/tools/builtin/home-assistant.ts +116 -0
  126. package/src/tools/builtin/index.ts +9 -2
  127. package/src/tools/builtin/rl-tools.ts +243 -0
  128. package/src/tools/builtin/vision.ts +64 -0
  129. package/tests/api-server.test.ts +148 -0
  130. package/tests/approvals.test.ts +89 -0
  131. package/tests/audio.test.ts +40 -0
  132. package/tests/browser.test.ts +179 -0
  133. package/tests/builtin-tools.test.ts +83 -83
  134. package/tests/channels-extra.test.ts +45 -0
  135. package/tests/context-compressor.test.ts +172 -0
  136. package/tests/context-refs.test.ts +121 -0
  137. package/tests/elevated.test.ts +69 -0
  138. package/tests/gateway.test.ts +63 -71
  139. package/tests/home-assistant.test.ts +40 -0
  140. package/tests/hooks.test.ts +79 -0
  141. package/tests/ide-bridge.test.ts +38 -0
  142. package/tests/node-network.test.ts +74 -0
  143. package/tests/profiles.test.ts +61 -0
  144. package/tests/rl-tools.test.ts +93 -0
  145. package/tests/sandbox-manager.test.ts +46 -0
  146. package/tests/secrets.test.ts +107 -0
  147. package/tests/tools/builtin-extended.test.ts +138 -138
  148. package/tests/user-profiler.test.ts +169 -0
  149. package/tests/v090-features.test.ts +254 -0
  150. package/tests/vision.test.ts +61 -0
  151. package/tests/voice-call.test.ts +47 -0
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # ⚡ OPC Agent
4
4
 
5
- ### 全球首个内置记忆进化的 TypeScript Agent 框架
5
+ ### 内置记忆进化的 TypeScript Agent 框架
6
6
 
7
7
  [![npm version](https://img.shields.io/badge/npm-v3.0.0-blue)](https://www.npmjs.com/package/opc-agent)
8
8
  [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/Deepleaper/opc-agent/blob/main/LICENSE)
@@ -48,7 +48,7 @@ Agent: 您上次查询的订单 #12300 已签收,签收时间是 4 月 15 日
48
48
 
49
49
  | | 特性 | 说明 |
50
50
  |---|---|---|
51
- | 🧠 | **记忆进化** | learn → recall → evolve,全球唯一内置知识自动沉淀 |
51
+ | 🧠 | **记忆进化** | learn → recall → evolve,内置知识自动沉淀 |
52
52
  | 🔧 | **20+ CLI 命令** | init / chat / run / start / studio / doctor / eval / traces / publish |
53
53
  | 📡 | **11 种 Channel** | Telegram / Discord / Slack / WeChat / Feishu / Email / Web / WebSocket / Voice / Webhook / API |
54
54
  | 🔌 | **三大协议** | Google A2A + AG-UI + MCP(Server & Client) |
@@ -185,20 +185,23 @@ opc brain status # 查看 brain 统计信息
185
185
  | 特性 | OPC Agent | Mastra | CrewAI | LangGraph |
186
186
  |------|:---------:|:------:|:------:|:---------:|
187
187
  | 语言 | TypeScript | TypeScript | Python | Python |
188
- | 记忆进化 | ✅ 内置 | ❌ | | |
189
- | CLI 全生命周期 | ✅ 20+ 命令 | ⚠️ 部分 | | ❌ |
190
- | 渠道数量 | 11 | 自己接 | 自己接 | 自己接 |
188
+ | 记忆进化 | ✅ 内置 | ❌ | ⚠️ 有记忆模块 | ⚠️ 可通过 checkpointer 实现 |
189
+ | CLI 全生命周期 | ✅ 20+ 命令 | ⚠️ 部分 | ⚠️ CLI 有限 | ❌ |
190
+ | 渠道集成 | 11 内置 | ⚠️ 需自行接入 | ⚠️ 需自行接入 | ⚠️ 需自行接入 |
191
191
  | A2A 协议 | ✅ | ⚠️ | ❌ | ❌ |
192
192
  | AG-UI 协议 | ✅ | ❌ | ❌ | ❌ |
193
- | MCP (Server+Client) | ✅ | ⚠️ Client | | ⚠️ Client |
194
- | 可视化 Studio | ✅ | ⚠️ | | ⚠️ |
195
- | 内置评估 | ✅ `opc eval` | ❌ | ❌ | |
196
- | OpenTelemetry | ✅ | | ❌ | ⚠️ |
197
- | Agent | ✅ spawn/parallel | | ✅ | ✅ |
198
- | 打包发布 | ✅ `opc publish` | ❌ | ❌ | ❌ |
193
+ | MCP (Server+Client) | ✅ | ⚠️ Client | ⚠️ 有集成 | ⚠️ Client |
194
+ | 可视化管理 | ✅ OPC Studio | ⚠️ Dashboard | ⚠️ 有 Dashboard | ✅ LangGraph Studio |
195
+ | 内置评估 | ✅ `opc eval` | ❌ | ❌ | ⚠️ LangSmith 集成 |
196
+ | OpenTelemetry | ✅ | ⚠️ 有 Observability | ❌ | ⚠️ LangSmith |
197
+ | Agent 协作 | ✅ spawn/parallel | ⚠️ 有 Agent Network | ✅ Crew 编排 | ✅ 图编排 |
199
198
  | YAML 声明式 | ✅ | ⚠️ | ❌ | ❌ |
199
+ | 社区与生态 | 早期项目 | ✅ 活跃社区 | ✅ 大型社区 | ✅ LangChain 大生态 |
200
+ | 文档完善度 | 🚧 持续完善中 | ✅ | ✅ | ✅ |
200
201
 
201
- > 其他框架各有所长——OPC 的差异化在于**记忆进化 + 全生命周期 CLI + 11 渠道开箱即用**的完整闭环。
202
+ OPC Agent 的特色是**记忆进化 + 全生命周期 CLI + 多渠道开箱即用**。各框架各有侧重,建议根据技术栈和场景选择。
203
+
204
+ > 对比基于各项目公开文档(截至 2026 年 4 月),如有偏差欢迎 [Issue 指正](https://github.com/Deepleaper/opc-agent/issues)。
202
205
 
203
206
  ---
204
207
 
@@ -307,7 +310,7 @@ npm test
307
310
 
308
311
  # ⚡ OPC Agent
309
312
 
310
- ### The World's First TypeScript Agent Framework with Built-in Memory Evolution
313
+ ### TypeScript Agent Framework with Built-in Memory Evolution
311
314
 
312
315
  [![npm version](https://img.shields.io/badge/npm-v3.0.0-blue)](https://www.npmjs.com/package/opc-agent)
313
316
  [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/Deepleaper/opc-agent/blob/main/LICENSE)
@@ -353,7 +356,7 @@ Agent: Your previous order #12300 was delivered on April 15th at 2 PM.
353
356
 
354
357
  | | Feature | Description |
355
358
  |---|---|---|
356
- | 🧠 | **Memory Evolution** | learn → recall → evolve — the only framework with built-in automatic knowledge distillation |
359
+ | 🧠 | **Memory Evolution** | learn → recall → evolve — built-in automatic knowledge distillation |
357
360
  | 🔧 | **20+ CLI Commands** | init / chat / run / start / studio / doctor / eval / traces / publish |
358
361
  | 📡 | **11 Channels** | Telegram / Discord / Slack / WeChat / Feishu / Email / Web / WebSocket / Voice / Webhook / API |
359
362
  | 🔌 | **3 Protocols** | Google A2A + AG-UI + MCP (Server & Client) |
@@ -490,20 +493,23 @@ opc brain status # View brain statistics
490
493
  | Feature | OPC Agent | Mastra | CrewAI | LangGraph |
491
494
  |---------|:---------:|:------:|:------:|:---------:|
492
495
  | Language | TypeScript | TypeScript | Python | Python |
493
- | Memory Evolution | ✅ Built-in | ❌ | | |
494
- | Full-lifecycle CLI | ✅ 20+ cmds | ⚠️ Partial | | ❌ |
495
- | Channels | 11 | DIY | DIY | DIY |
496
+ | Memory Evolution | ✅ Built-in | ❌ | ⚠️ Has memory module | ⚠️ Via checkpointer |
497
+ | Full-lifecycle CLI | ✅ 20+ cmds | ⚠️ Partial | ⚠️ Limited CLI | ❌ |
498
+ | Channel integrations | 11 built-in | ⚠️ DIY | ⚠️ DIY | ⚠️ DIY |
496
499
  | A2A Protocol | ✅ | ⚠️ | ❌ | ❌ |
497
500
  | AG-UI Protocol | ✅ | ❌ | ❌ | ❌ |
498
- | MCP (Server+Client) | ✅ | ⚠️ Client | | ⚠️ Client |
499
- | Visual Studio | ✅ | ⚠️ | | ⚠️ |
500
- | Built-in Eval | ✅ `opc eval` | ❌ | ❌ | |
501
- | OpenTelemetry | ✅ | | ❌ | ⚠️ |
502
- | Sub-Agents | ✅ spawn/parallel | | ✅ | ✅ |
503
- | Publish to npm | ✅ `opc publish` | ❌ | ❌ | ❌ |
501
+ | MCP (Server+Client) | ✅ | ⚠️ Client | ⚠️ Has integration | ⚠️ Client |
502
+ | Visual Studio | ✅ OPC Studio | ⚠️ Dashboard | ⚠️ Dashboard | LangGraph Studio |
503
+ | Built-in Eval | ✅ `opc eval` | ❌ | ❌ | ⚠️ LangSmith integration |
504
+ | OpenTelemetry | ✅ | ⚠️ Observability | ❌ | ⚠️ LangSmith |
505
+ | Multi-Agent | ✅ spawn/parallel | ⚠️ Agent Network | ✅ Crew orchestration | ✅ Graph orchestration |
504
506
  | YAML Declarative | ✅ | ⚠️ | ❌ | ❌ |
507
+ | Community & ecosystem | Early-stage project | ✅ Active community | ✅ Large community | ✅ LangChain ecosystem |
508
+ | Documentation | 🚧 Improving | ✅ | ✅ | ✅ |
509
+
510
+ OPC Agent's differentiator is **Memory Evolution + Full-lifecycle CLI + multi-channel out of the box**. Each framework has different strengths — choose based on your tech stack and use case.
505
511
 
506
- > Each framework has its strengths — OPC's differentiation is the **Memory Evolution + Full-lifecycle CLI + 11 Channels** complete loop.
512
+ > Comparison based on each project's public documentation as of April 2026. Corrections welcome via [Issues](https://github.com/Deepleaper/opc-agent/issues).
507
513
 
508
514
  ---
509
515
 
@@ -0,0 +1,17 @@
1
+ import { BaseChannel } from './index';
2
+ export interface DingTalkChannelConfig {
3
+ webhookUrl: string;
4
+ secret?: string;
5
+ appKey?: string;
6
+ appSecret?: string;
7
+ }
8
+ export declare class DingTalkChannel extends BaseChannel {
9
+ readonly type = "dingtalk";
10
+ private config;
11
+ private running;
12
+ constructor(config: DingTalkChannelConfig);
13
+ start(): Promise<void>;
14
+ stop(): Promise<void>;
15
+ send(chatId: string, text: string): Promise<void>;
16
+ }
17
+ //# sourceMappingURL=dingtalk.d.ts.map
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DingTalkChannel = void 0;
4
+ const index_1 = require("./index");
5
+ class DingTalkChannel extends index_1.BaseChannel {
6
+ type = 'dingtalk';
7
+ config;
8
+ running = false;
9
+ constructor(config) {
10
+ super();
11
+ if (!config.webhookUrl) {
12
+ throw new Error('DingTalkChannel requires webhookUrl in config');
13
+ }
14
+ this.config = config;
15
+ }
16
+ async start() {
17
+ this.running = true;
18
+ }
19
+ async stop() {
20
+ this.running = false;
21
+ }
22
+ async send(chatId, text) {
23
+ if (!this.running) {
24
+ throw new Error('DingTalkChannel: not started. Call start() first.');
25
+ }
26
+ const body = JSON.stringify({ msgtype: 'text', text: { content: text } });
27
+ const res = await fetch(this.config.webhookUrl, {
28
+ method: 'POST',
29
+ headers: { 'Content-Type': 'application/json' },
30
+ body,
31
+ });
32
+ if (!res.ok) {
33
+ throw new Error(`DingTalk webhook failed: ${res.status}`);
34
+ }
35
+ }
36
+ }
37
+ exports.DingTalkChannel = DingTalkChannel;
38
+ //# sourceMappingURL=dingtalk.js.map
@@ -0,0 +1,14 @@
1
+ import { BaseChannel } from './index';
2
+ export interface GoogleChatChannelConfig {
3
+ webhookUrl: string;
4
+ }
5
+ export declare class GoogleChatChannel extends BaseChannel {
6
+ readonly type = "googlechat";
7
+ private config;
8
+ private running;
9
+ constructor(config: GoogleChatChannelConfig);
10
+ start(): Promise<void>;
11
+ stop(): Promise<void>;
12
+ send(spaceId: string, text: string): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=googlechat.d.ts.map
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GoogleChatChannel = void 0;
4
+ const index_1 = require("./index");
5
+ class GoogleChatChannel extends index_1.BaseChannel {
6
+ type = 'googlechat';
7
+ config;
8
+ running = false;
9
+ constructor(config) {
10
+ super();
11
+ if (!config.webhookUrl) {
12
+ throw new Error('GoogleChatChannel requires webhookUrl in config');
13
+ }
14
+ this.config = config;
15
+ }
16
+ async start() {
17
+ this.running = true;
18
+ }
19
+ async stop() {
20
+ this.running = false;
21
+ }
22
+ async send(spaceId, text) {
23
+ if (!this.running) {
24
+ throw new Error('GoogleChatChannel: not started. Call start() first.');
25
+ }
26
+ const res = await fetch(this.config.webhookUrl, {
27
+ method: 'POST',
28
+ headers: { 'Content-Type': 'application/json' },
29
+ body: JSON.stringify({ text }),
30
+ });
31
+ if (!res.ok) {
32
+ throw new Error(`Google Chat webhook failed: ${res.status}`);
33
+ }
34
+ }
35
+ }
36
+ exports.GoogleChatChannel = GoogleChatChannel;
37
+ //# sourceMappingURL=googlechat.js.map
@@ -0,0 +1,13 @@
1
+ import { BaseChannel } from './index';
2
+ export interface IMessageChannelConfig {
3
+ applescriptPath?: string;
4
+ }
5
+ export declare class IMessageChannel extends BaseChannel {
6
+ readonly type = "imessage";
7
+ private config;
8
+ constructor(config?: IMessageChannelConfig);
9
+ start(): Promise<void>;
10
+ stop(): Promise<void>;
11
+ send(chatId: string, text: string): Promise<void>;
12
+ }
13
+ //# sourceMappingURL=imessage.d.ts.map
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IMessageChannel = void 0;
4
+ const index_1 = require("./index");
5
+ class IMessageChannel extends index_1.BaseChannel {
6
+ type = 'imessage';
7
+ config;
8
+ constructor(config = {}) {
9
+ super();
10
+ this.config = config;
11
+ }
12
+ async start() {
13
+ try {
14
+ require('macOS iMessage CLI');
15
+ }
16
+ catch {
17
+ throw new Error('Install macOS iMessage CLI to use the IMessageChannel. Run: npm install macOS iMessage CLI');
18
+ }
19
+ }
20
+ async stop() {
21
+ // cleanup
22
+ }
23
+ async send(chatId, text) {
24
+ throw new Error('IMessageChannel: not yet connected. Call start() first.');
25
+ }
26
+ }
27
+ exports.IMessageChannel = IMessageChannel;
28
+ //# sourceMappingURL=imessage.js.map
@@ -0,0 +1,20 @@
1
+ import { BaseChannel } from './index';
2
+ export interface IRCChannelConfig {
3
+ host: string;
4
+ port?: number;
5
+ nick: string;
6
+ channels: string[];
7
+ tls?: boolean;
8
+ password?: string;
9
+ }
10
+ export declare class IRCChannel extends BaseChannel {
11
+ readonly type = "irc";
12
+ private config;
13
+ private client;
14
+ private running;
15
+ constructor(config: IRCChannelConfig);
16
+ start(): Promise<void>;
17
+ stop(): Promise<void>;
18
+ send(target: string, text: string): Promise<void>;
19
+ }
20
+ //# sourceMappingURL=irc.d.ts.map
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IRCChannel = void 0;
4
+ const index_1 = require("./index");
5
+ class IRCChannel extends index_1.BaseChannel {
6
+ type = 'irc';
7
+ config;
8
+ client = null;
9
+ running = false;
10
+ constructor(config) {
11
+ super();
12
+ if (!config.host || !config.nick || !config.channels?.length) {
13
+ throw new Error('IRCChannel requires host, nick, and channels in config');
14
+ }
15
+ this.config = config;
16
+ }
17
+ async start() {
18
+ let IRC;
19
+ try {
20
+ IRC = require('irc-framework');
21
+ }
22
+ catch {
23
+ throw new Error('Install irc-framework to use the IRCChannel. Run: npm install irc-framework');
24
+ }
25
+ this.client = new IRC.Client();
26
+ this.client.connect({
27
+ host: this.config.host,
28
+ port: this.config.port ?? (this.config.tls ? 6697 : 6667),
29
+ nick: this.config.nick,
30
+ tls: this.config.tls ?? false,
31
+ password: this.config.password,
32
+ });
33
+ await new Promise((resolve, reject) => {
34
+ this.client.on('registered', () => {
35
+ for (const ch of this.config.channels) {
36
+ this.client.join(ch);
37
+ }
38
+ resolve();
39
+ });
40
+ this.client.on('error', (err) => reject(new Error(`IRC connection error: ${err.message || err}`)));
41
+ });
42
+ this.running = true;
43
+ this.client.on('privmsg', async (event) => {
44
+ if (!this.handler)
45
+ return;
46
+ const msg = {
47
+ id: Date.now().toString(),
48
+ role: 'user',
49
+ content: event.message,
50
+ timestamp: Date.now(),
51
+ metadata: { channel: event.target, nick: event.nick },
52
+ };
53
+ await this.handler(msg);
54
+ });
55
+ }
56
+ async stop() {
57
+ if (this.client) {
58
+ this.client.quit('Goodbye');
59
+ this.client = null;
60
+ }
61
+ this.running = false;
62
+ }
63
+ async send(target, text) {
64
+ if (!this.running || !this.client) {
65
+ throw new Error('IRCChannel: not started. Call start() first.');
66
+ }
67
+ this.client.say(target, text);
68
+ }
69
+ }
70
+ exports.IRCChannel = IRCChannel;
71
+ //# sourceMappingURL=irc.js.map
@@ -0,0 +1,14 @@
1
+ import { BaseChannel } from './index';
2
+ export interface LINEChannelConfig {
3
+ channelAccessToken?: string;
4
+ channelSecret?: string;
5
+ }
6
+ export declare class LINEChannel extends BaseChannel {
7
+ readonly type = "line";
8
+ private config;
9
+ constructor(config?: LINEChannelConfig);
10
+ start(): Promise<void>;
11
+ stop(): Promise<void>;
12
+ send(chatId: string, text: string): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=line.d.ts.map
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LINEChannel = void 0;
4
+ const index_1 = require("./index");
5
+ class LINEChannel extends index_1.BaseChannel {
6
+ type = 'line';
7
+ config;
8
+ constructor(config = {}) {
9
+ super();
10
+ this.config = config;
11
+ }
12
+ async start() {
13
+ try {
14
+ require('@line/bot-sdk');
15
+ }
16
+ catch {
17
+ throw new Error('Install @line/bot-sdk to use the LINEChannel. Run: npm install @line/bot-sdk');
18
+ }
19
+ }
20
+ async stop() {
21
+ // cleanup
22
+ }
23
+ async send(chatId, text) {
24
+ throw new Error('LINEChannel: not yet connected. Call start() first.');
25
+ }
26
+ }
27
+ exports.LINEChannel = LINEChannel;
28
+ //# sourceMappingURL=line.js.map
@@ -0,0 +1,15 @@
1
+ import { BaseChannel } from './index';
2
+ export interface MatrixChannelConfig {
3
+ homeserverUrl?: string;
4
+ accessToken?: string;
5
+ userId?: string;
6
+ }
7
+ export declare class MatrixChannel extends BaseChannel {
8
+ readonly type = "matrix";
9
+ private config;
10
+ constructor(config?: MatrixChannelConfig);
11
+ start(): Promise<void>;
12
+ stop(): Promise<void>;
13
+ send(chatId: string, text: string): Promise<void>;
14
+ }
15
+ //# sourceMappingURL=matrix.d.ts.map
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MatrixChannel = void 0;
4
+ const index_1 = require("./index");
5
+ class MatrixChannel extends index_1.BaseChannel {
6
+ type = 'matrix';
7
+ config;
8
+ constructor(config = {}) {
9
+ super();
10
+ this.config = config;
11
+ }
12
+ async start() {
13
+ try {
14
+ require('matrix-js-sdk');
15
+ }
16
+ catch {
17
+ throw new Error('Install matrix-js-sdk to use the MatrixChannel. Run: npm install matrix-js-sdk');
18
+ }
19
+ }
20
+ async stop() {
21
+ // cleanup
22
+ }
23
+ async send(chatId, text) {
24
+ throw new Error('MatrixChannel: not yet connected. Call start() first.');
25
+ }
26
+ }
27
+ exports.MatrixChannel = MatrixChannel;
28
+ //# sourceMappingURL=matrix.js.map
@@ -0,0 +1,18 @@
1
+ import { BaseChannel } from './index';
2
+ export interface MattermostChannelConfig {
3
+ serverUrl: string;
4
+ token: string;
5
+ teamId?: string;
6
+ defaultChannelId?: string;
7
+ }
8
+ export declare class MattermostChannel extends BaseChannel {
9
+ readonly type = "mattermost";
10
+ private config;
11
+ private running;
12
+ private ws;
13
+ constructor(config: MattermostChannelConfig);
14
+ start(): Promise<void>;
15
+ stop(): Promise<void>;
16
+ send(channelId: string, text: string): Promise<void>;
17
+ }
18
+ //# sourceMappingURL=mattermost.d.ts.map
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MattermostChannel = void 0;
4
+ const index_1 = require("./index");
5
+ class MattermostChannel extends index_1.BaseChannel {
6
+ type = 'mattermost';
7
+ config;
8
+ running = false;
9
+ ws = null;
10
+ constructor(config) {
11
+ super();
12
+ if (!config.serverUrl || !config.token) {
13
+ throw new Error('MattermostChannel requires serverUrl and token in config');
14
+ }
15
+ this.config = config;
16
+ }
17
+ async start() {
18
+ // Verify connection by hitting the API
19
+ const res = await fetch(`${this.config.serverUrl}/api/v4/users/me`, {
20
+ headers: { Authorization: `Bearer ${this.config.token}` },
21
+ }).catch(() => null);
22
+ this.running = true;
23
+ }
24
+ async stop() {
25
+ if (this.ws) {
26
+ this.ws.close();
27
+ this.ws = null;
28
+ }
29
+ this.running = false;
30
+ }
31
+ async send(channelId, text) {
32
+ if (!this.running) {
33
+ throw new Error('MattermostChannel: not started. Call start() first.');
34
+ }
35
+ const res = await fetch(`${this.config.serverUrl}/api/v4/posts`, {
36
+ method: 'POST',
37
+ headers: {
38
+ Authorization: `Bearer ${this.config.token}`,
39
+ 'Content-Type': 'application/json',
40
+ },
41
+ body: JSON.stringify({ channel_id: channelId, message: text }),
42
+ });
43
+ if (!res.ok) {
44
+ throw new Error(`Mattermost API failed: ${res.status}`);
45
+ }
46
+ }
47
+ }
48
+ exports.MattermostChannel = MattermostChannel;
49
+ //# sourceMappingURL=mattermost.js.map
@@ -0,0 +1,14 @@
1
+ import { BaseChannel } from './index';
2
+ export interface MSTeamsChannelConfig {
3
+ appId?: string;
4
+ appPassword?: string;
5
+ }
6
+ export declare class MSTeamsChannel extends BaseChannel {
7
+ readonly type = "msteams";
8
+ private config;
9
+ constructor(config?: MSTeamsChannelConfig);
10
+ start(): Promise<void>;
11
+ stop(): Promise<void>;
12
+ send(chatId: string, text: string): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=msteams.d.ts.map
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MSTeamsChannel = void 0;
4
+ const index_1 = require("./index");
5
+ class MSTeamsChannel extends index_1.BaseChannel {
6
+ type = 'msteams';
7
+ config;
8
+ constructor(config = {}) {
9
+ super();
10
+ this.config = config;
11
+ }
12
+ async start() {
13
+ try {
14
+ require('botframework-connector');
15
+ }
16
+ catch {
17
+ throw new Error('Install botframework-connector to use the MSTeamsChannel. Run: npm install botframework-connector');
18
+ }
19
+ }
20
+ async stop() {
21
+ // cleanup
22
+ }
23
+ async send(chatId, text) {
24
+ throw new Error('MSTeamsChannel: not yet connected. Call start() first.');
25
+ }
26
+ }
27
+ exports.MSTeamsChannel = MSTeamsChannel;
28
+ //# sourceMappingURL=msteams.js.map
@@ -0,0 +1,14 @@
1
+ import { BaseChannel } from './index';
2
+ export interface NostrChannelConfig {
3
+ privateKey?: string;
4
+ relays?: string[];
5
+ }
6
+ export declare class NostrChannel extends BaseChannel {
7
+ readonly type = "nostr";
8
+ private config;
9
+ constructor(config?: NostrChannelConfig);
10
+ start(): Promise<void>;
11
+ stop(): Promise<void>;
12
+ send(chatId: string, text: string): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=nostr.d.ts.map
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NostrChannel = void 0;
4
+ const index_1 = require("./index");
5
+ class NostrChannel extends index_1.BaseChannel {
6
+ type = 'nostr';
7
+ config;
8
+ constructor(config = {}) {
9
+ super();
10
+ this.config = config;
11
+ }
12
+ async start() {
13
+ try {
14
+ require('nostr-tools');
15
+ }
16
+ catch {
17
+ throw new Error('Install nostr-tools to use the NostrChannel. Run: npm install nostr-tools');
18
+ }
19
+ }
20
+ async stop() {
21
+ // cleanup
22
+ }
23
+ async send(chatId, text) {
24
+ throw new Error('NostrChannel: not yet connected. Call start() first.');
25
+ }
26
+ }
27
+ exports.NostrChannel = NostrChannel;
28
+ //# sourceMappingURL=nostr.js.map
@@ -0,0 +1,15 @@
1
+ import { BaseChannel } from './index';
2
+ export interface QQChannelConfig {
3
+ appId?: string;
4
+ token?: string;
5
+ sandbox?: boolean;
6
+ }
7
+ export declare class QQChannel extends BaseChannel {
8
+ readonly type = "qq";
9
+ private config;
10
+ constructor(config?: QQChannelConfig);
11
+ start(): Promise<void>;
12
+ stop(): Promise<void>;
13
+ send(chatId: string, text: string): Promise<void>;
14
+ }
15
+ //# sourceMappingURL=qq.d.ts.map
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QQChannel = void 0;
4
+ const index_1 = require("./index");
5
+ class QQChannel extends index_1.BaseChannel {
6
+ type = 'qq';
7
+ config;
8
+ constructor(config = {}) {
9
+ super();
10
+ this.config = config;
11
+ }
12
+ async start() {
13
+ try {
14
+ require('qq-bot-sdk');
15
+ }
16
+ catch {
17
+ throw new Error('Install qq-bot-sdk to use the QQChannel. Run: npm install qq-bot-sdk');
18
+ }
19
+ }
20
+ async stop() {
21
+ // cleanup
22
+ }
23
+ async send(chatId, text) {
24
+ throw new Error('QQChannel: not yet connected. Call start() first.');
25
+ }
26
+ }
27
+ exports.QQChannel = QQChannel;
28
+ //# sourceMappingURL=qq.js.map
@@ -0,0 +1,14 @@
1
+ import { BaseChannel } from './index';
2
+ export interface SignalChannelConfig {
3
+ signalCliPath?: string;
4
+ phoneNumber?: string;
5
+ }
6
+ export declare class SignalChannel extends BaseChannel {
7
+ readonly type = "signal";
8
+ private config;
9
+ constructor(config?: SignalChannelConfig);
10
+ start(): Promise<void>;
11
+ stop(): Promise<void>;
12
+ send(chatId: string, text: string): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=signal.d.ts.map