visionclaw 0.1.111 → 0.1.113
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/CHANGELOG.md +34 -0
- package/dist/agent/backup.d.ts.map +1 -1
- package/dist/agent/backup.js +41 -0
- package/dist/agent/backup.js.map +1 -1
- package/dist/agent/client-factory.js +1 -74
- package/dist/agent/command-handlers.d.ts.map +1 -1
- package/dist/agent/command-handlers.js +7 -3
- package/dist/agent/command-handlers.js.map +1 -1
- package/dist/agent/loop.d.ts.map +1 -1
- package/dist/agent/loop.js +16 -1
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/openai-file-session.js +1 -78
- package/dist/agent/openai-session.js +1 -413
- package/dist/agent/openai-tools.js +1 -167
- package/dist/agent/providers/claude/session.d.ts.map +1 -1
- package/dist/agent/providers/claude/session.js +17 -0
- package/dist/agent/providers/claude/session.js.map +1 -1
- package/dist/agent/runtime-surface.d.ts.map +1 -1
- package/dist/agent/runtime-surface.js +17 -3
- package/dist/agent/runtime-surface.js.map +1 -1
- package/dist/agent/session-trimmer.d.ts +34 -0
- package/dist/agent/session-trimmer.d.ts.map +1 -0
- package/dist/agent/session-trimmer.js +101 -0
- package/dist/agent/session-trimmer.js.map +1 -0
- package/dist/agent/session-types.js +1 -2
- package/dist/agent/session.js +1 -500
- package/dist/agent/state.d.ts +2 -0
- package/dist/agent/state.d.ts.map +1 -1
- package/dist/agent/state.js +14 -0
- package/dist/agent/state.js.map +1 -1
- package/dist/agent/system-prompt.d.ts.map +1 -1
- package/dist/agent/system-prompt.js +5 -3
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/builtin-skills/visionclaw-manual/SKILL.md +29 -5
- package/dist/channels/slack.js +1 -142
- package/dist/channels/sms.js +1 -111
- package/dist/channels/whatsapp.js +1 -292
- package/dist/config/types.d.ts +3 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +3 -0
- package/dist/config/types.js.map +1 -1
- package/dist/files.js +1 -82
- package/dist/google/default-oauth-app.js +1 -7
- package/dist/index.js +36 -1
- package/dist/index.js.map +1 -1
- package/dist/memory/store.js +1 -71
- package/dist/onboarding/index.d.ts.map +1 -1
- package/dist/onboarding/index.js +55 -6
- package/dist/onboarding/index.js.map +1 -1
- package/dist/onboarding/macos-permissions.d.ts +4 -8
- package/dist/onboarding/macos-permissions.d.ts.map +1 -1
- package/dist/onboarding/macos-permissions.js +79 -28
- package/dist/onboarding/macos-permissions.js.map +1 -1
- package/dist/onboarding/prepare-mac.d.ts.map +1 -1
- package/dist/onboarding/prepare-mac.js +206 -70
- package/dist/onboarding/prepare-mac.js.map +1 -1
- package/dist/onboarding/provisioning-spec.d.ts +5 -0
- package/dist/onboarding/provisioning-spec.d.ts.map +1 -1
- package/dist/onboarding/provisioning-spec.js +6 -0
- package/dist/onboarding/provisioning-spec.js.map +1 -1
- package/dist/onboarding/setup-state.d.ts +1 -0
- package/dist/onboarding/setup-state.d.ts.map +1 -1
- package/dist/onboarding/setup-state.js +1 -0
- package/dist/onboarding/setup-state.js.map +1 -1
- package/dist/restore.d.ts.map +1 -1
- package/dist/restore.js +26 -0
- package/dist/restore.js.map +1 -1
- package/dist/service/launchd.d.ts +11 -0
- package/dist/service/launchd.d.ts.map +1 -0
- package/dist/service/launchd.js +344 -0
- package/dist/service/launchd.js.map +1 -0
- package/dist/tools/browser.js +1 -108
- package/dist/tools/helpers/macos-screenshot.swift +74 -0
- package/dist/tools/screenshot.d.ts.map +1 -1
- package/dist/tools/screenshot.js +55 -2
- package/dist/tools/screenshot.js.map +1 -1
- package/dist/tools/sleep-interval.js +1 -25
- package/dist/tools/upgrade.d.ts.map +1 -1
- package/dist/tools/upgrade.js +2 -1
- package/dist/tools/upgrade.js.map +1 -1
- package/dist/tools/version-check.js +1 -164
- package/dist/tools/web-search.js +1 -2
- package/dist/utils/backup-paths.js +1 -14
- package/dist/utils/restart.d.ts +3 -1
- package/dist/utils/restart.d.ts.map +1 -1
- package/dist/utils/restart.js +43 -26
- package/dist/utils/restart.js.map +1 -1
- package/package.json +5 -3
|
@@ -48,7 +48,7 @@ When a new Telegram DM or group that has not been approved yet contacts the agen
|
|
|
48
48
|
|
|
49
49
|
- **Gmail** — Always enabled. This is the agent's email identity. The agent can send and receive emails as itself.
|
|
50
50
|
- **Discord** — Optional. Can be enabled in the configuration.
|
|
51
|
-
- **WeChat, GitHub, etc.** — The agent has accounts on these platforms and can interact with them via browser automation or desktop control, but they are not direct messaging channels. Messages or notifications from these apps are observed during wake cycles (e.g., via desktop screenshots) rather than being pushed in real time.
|
|
51
|
+
- **WeChat, GitHub, etc.** — The agent has accounts on these platforms and can interact with them via browser automation or desktop control, but they are not direct messaging channels. Messages or notifications from these apps are observed during wake cycles (e.g., via desktop screenshots) rather than being pushed in real time. The agent is expected to regularly check these chat apps for new messages during wake cycles.
|
|
52
52
|
|
|
53
53
|
### Message Priority
|
|
54
54
|
|
|
@@ -82,28 +82,45 @@ VisionClaw operates on an infinite **wake/sleep loop**:
|
|
|
82
82
|
|
|
83
83
|
The agent can only do one thing at a time. If it is working on a long task and a new command arrives, the fast responder sends a quick acknowledgement, and the primary agent decides how to handle it when it finishes the current step.
|
|
84
84
|
|
|
85
|
+
### Dual-Session Architecture (Optional)
|
|
86
|
+
|
|
87
|
+
When enabled by the owner, VisionClaw operates with two separate conversation sessions, each with its own context history:
|
|
88
|
+
|
|
89
|
+
- **General session** — Handles conversations, quick tasks, questions, scheduling, status checks, and anything that doesn't require sustained multi-step coding work. This is the default session.
|
|
90
|
+
- **Coding session** — Handles complex coding tasks (refactoring, debugging, multi-file feature implementation). This session preserves focused coding context without interruption from unrelated messages.
|
|
91
|
+
|
|
92
|
+
Only one session is active at a time. The agent uses the `switch_session` tool to hand off between sessions:
|
|
93
|
+
- General → Coding: when a complex coding task arrives
|
|
94
|
+
- Coding → General (handoff): when an unrelated message needs attention — the coding session stays active for later
|
|
95
|
+
- Coding → General (complete): when the coding task is finished
|
|
96
|
+
|
|
97
|
+
The `memo` field on `switch_session` is the communication channel between sessions — it carries context, progress, and decisions so the target session can pick up seamlessly.
|
|
98
|
+
|
|
85
99
|
## Available Tools
|
|
86
100
|
|
|
87
101
|
### Communication
|
|
88
102
|
- **notify_user** — Send messages back to the owner through any channel (Telegram, Gmail, Discord). Supports text, images, files, and screenshots.
|
|
89
103
|
|
|
90
104
|
### Desktop & Browser
|
|
91
|
-
- **computer_use_click / scroll / drag / type / key** — Control the mouse and keyboard for desktop applications using AI-powered coordinate resolution.
|
|
92
|
-
- **
|
|
93
|
-
- **Playwright MCP tools** — Full browser automation: navigate, click, fill forms, take snapshots, execute JavaScript, etc.
|
|
105
|
+
- **computer_use_click / move / scroll / drag / type / key / screenshot** — Control the mouse and keyboard for desktop applications using AI-powered coordinate resolution. `computer_use_screenshot` captures the current screen, and `computer_use_move` positions the cursor without clicking.
|
|
106
|
+
- **Playwright MCP tools** — Full browser automation: navigate, click, fill forms, take snapshots, execute JavaScript, etc. A Chrome browser is launched automatically before the first Playwright tool call and relaunched if closed. Prefer Playwright for all in-browser work; use computer_use tools only for desktop apps or as a fallback.
|
|
94
107
|
|
|
95
108
|
### Productivity
|
|
96
109
|
- **manage_calendar** — Create, update, delete, and list Google Calendar events.
|
|
97
110
|
- **manage_email** — Send, read, search, and manage emails via Gmail.
|
|
98
111
|
- **manage_drive** — Upload, download, list, and manage files on Google Drive.
|
|
112
|
+
- **web_fetch** — Fetch content from a URL and return it in a readable format.
|
|
99
113
|
|
|
100
114
|
### Memory & Knowledge
|
|
101
115
|
- **memory** — Persistent storage that survives context compaction. The agent proactively saves important information here. Operations: view, create, edit, delete, rename.
|
|
102
116
|
|
|
103
117
|
### Skills
|
|
104
|
-
- **manage_skills** — Create, update, delete, and
|
|
118
|
+
- **manage_skills** — Create, update, delete, list, browse catalog, and install catalog skills. Skills are reusable instruction sets (SKILL.md files) that the agent can invoke for specialized tasks. Use `manage_skills(action="list_catalog")` to browse available domain-specific skills and `manage_skills(action="install_catalog", name="skill-name")` to install one permanently.
|
|
105
119
|
- **Skill** (SDK built-in) — Invoke a skill by name when its task pattern matches.
|
|
106
120
|
|
|
121
|
+
### MCP Server Management
|
|
122
|
+
- **manage_mcp_servers** — Dynamically add, remove, or list external MCP (Model Context Protocol) servers at runtime. This lets the agent connect to new tool providers (GitHub, Slack, databases, etc.) on demand. Supported transport types: stdio, http, sse. Added servers persist across restarts and are hot-loaded into the current session immediately.
|
|
123
|
+
|
|
107
124
|
### System
|
|
108
125
|
- **screenshot** — Capture the current desktop screen.
|
|
109
126
|
- **wait** — Pause execution for a specified duration.
|
|
@@ -133,6 +150,13 @@ VisionClaw typically runs under pm2 as a managed process. The agent can read its
|
|
|
133
150
|
|
|
134
151
|
These logs contain everything printed during execution: system startup, channel events, tool calls, errors, and more. This is useful for diagnosing crashes, reviewing what happened across restarts, or answering the owner's question "what went wrong?"
|
|
135
152
|
|
|
153
|
+
### Pre-Installed System Utilities
|
|
154
|
+
|
|
155
|
+
The following tools are pre-installed on the system and available for the agent to use:
|
|
156
|
+
|
|
157
|
+
- **pm2** — Process manager for Node.js. Beyond managing VisionClaw itself, the agent can use pm2 to start, stop, and monitor any long-running processes (e.g., web servers, background scripts, automation daemons).
|
|
158
|
+
- **cloudflared** — Cloudflare Tunnel client. The agent can use cloudflared to expose local services (web apps, APIs, dashboards) to the internet via secure Cloudflare tunnels without opening firewall ports or configuring port forwarding.
|
|
159
|
+
|
|
136
160
|
## Memory System
|
|
137
161
|
|
|
138
162
|
The agent maintains a persistent memory directory (`/memories`). Since the agent's context window is finite and gets compacted over time, important information is proactively saved to memory files.
|
package/dist/channels/slack.js
CHANGED
|
@@ -1,142 +1 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import { EventEmitter } from "node:events";
|
|
3
|
-
import { App } from "@slack/bolt";
|
|
4
|
-
import { logger } from "../logger.js";
|
|
5
|
-
import { uploadMedia } from "../files.js";
|
|
6
|
-
/**
|
|
7
|
-
* Slack channel adapter using Bolt framework with Socket Mode.
|
|
8
|
-
* Supports multimodal inbound (file attachments) and outbound (images, files).
|
|
9
|
-
*/
|
|
10
|
-
export class SlackAdapter extends EventEmitter {
|
|
11
|
-
name = "slack";
|
|
12
|
-
config;
|
|
13
|
-
app = null;
|
|
14
|
-
constructor(config) {
|
|
15
|
-
super();
|
|
16
|
-
this.config = config;
|
|
17
|
-
}
|
|
18
|
-
async start() {
|
|
19
|
-
const slackConfig = this.config.channels.slack;
|
|
20
|
-
if (!slackConfig)
|
|
21
|
-
throw new Error("Slack channel not configured");
|
|
22
|
-
if (!slackConfig.appToken || !slackConfig.botToken) {
|
|
23
|
-
throw new Error("Slack app token and bot token are required");
|
|
24
|
-
}
|
|
25
|
-
this.app = new App({
|
|
26
|
-
token: slackConfig.botToken,
|
|
27
|
-
appToken: slackConfig.appToken,
|
|
28
|
-
socketMode: true,
|
|
29
|
-
});
|
|
30
|
-
const botToken = slackConfig.botToken;
|
|
31
|
-
// Listen for messages mentioning the bot or DMs
|
|
32
|
-
this.app.message(async ({ message }) => {
|
|
33
|
-
// Type narrowing for message events with text
|
|
34
|
-
if (!("text" in message) || !message.text)
|
|
35
|
-
return;
|
|
36
|
-
if (!("user" in message) || !message.user)
|
|
37
|
-
return;
|
|
38
|
-
const commandMessage = {
|
|
39
|
-
id: `slack-${message.ts}-${message.channel}`,
|
|
40
|
-
channel: "slack",
|
|
41
|
-
sender: message.user,
|
|
42
|
-
text: message.text,
|
|
43
|
-
attachments: [],
|
|
44
|
-
timestamp: new Date(Number(message.ts) * 1000).toISOString(),
|
|
45
|
-
meta: {
|
|
46
|
-
ts: message.ts,
|
|
47
|
-
channelId: message.channel,
|
|
48
|
-
threadTs: "thread_ts" in message ? message.thread_ts : undefined,
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
// Handle file attachments -- download and upload to S3
|
|
52
|
-
if ("files" in message && Array.isArray(message.files)) {
|
|
53
|
-
for (const file of message.files) {
|
|
54
|
-
const mimeType = file.mimetype;
|
|
55
|
-
const filename = file.name ?? "attachment";
|
|
56
|
-
const privateUrl = file.url_private;
|
|
57
|
-
let publicUrl;
|
|
58
|
-
if (privateUrl) {
|
|
59
|
-
try {
|
|
60
|
-
// Download from Slack (requires bot token for auth)
|
|
61
|
-
const response = await fetch(privateUrl, {
|
|
62
|
-
headers: { Authorization: `Bearer ${botToken}` },
|
|
63
|
-
});
|
|
64
|
-
if (response.ok) {
|
|
65
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
66
|
-
const buffer = Buffer.from(arrayBuffer);
|
|
67
|
-
const s3Url = await uploadMedia(buffer, filename, mimeType);
|
|
68
|
-
publicUrl = s3Url ?? undefined;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
catch (err) {
|
|
72
|
-
logger.warn(`Slack: Failed to download file ${filename}: ${err instanceof Error ? err.message : String(err)}`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const type = mimeType.startsWith("image/")
|
|
76
|
-
? "image"
|
|
77
|
-
: mimeType.startsWith("audio/")
|
|
78
|
-
? "audio"
|
|
79
|
-
: mimeType.startsWith("video/")
|
|
80
|
-
? "video"
|
|
81
|
-
: "file";
|
|
82
|
-
commandMessage.attachments.push({
|
|
83
|
-
type,
|
|
84
|
-
url: publicUrl ?? privateUrl,
|
|
85
|
-
filename,
|
|
86
|
-
mimeType,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
this.emit("message", commandMessage);
|
|
91
|
-
});
|
|
92
|
-
this.app.error(async (error) => {
|
|
93
|
-
await Promise.resolve();
|
|
94
|
-
this.emit("error", new Error(`Slack error: ${error.message}`));
|
|
95
|
-
});
|
|
96
|
-
await this.app.start();
|
|
97
|
-
}
|
|
98
|
-
async stop() {
|
|
99
|
-
if (this.app) {
|
|
100
|
-
await this.app.stop();
|
|
101
|
-
this.app = null;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
async sendMessage(to, message, attachments) {
|
|
105
|
-
if (!this.app) {
|
|
106
|
-
throw new Error("Slack app not started");
|
|
107
|
-
}
|
|
108
|
-
// Send text message
|
|
109
|
-
if (message.trim()) {
|
|
110
|
-
await this.app.client.chat.postMessage({
|
|
111
|
-
channel: to,
|
|
112
|
-
text: message,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
// Send attachments
|
|
116
|
-
if (attachments && attachments.length > 0) {
|
|
117
|
-
for (const att of attachments) {
|
|
118
|
-
try {
|
|
119
|
-
if (att.localPath && fs.existsSync(att.localPath)) {
|
|
120
|
-
// Upload local file to Slack
|
|
121
|
-
await this.app.client.files.uploadV2({
|
|
122
|
-
channel_id: to,
|
|
123
|
-
file: fs.createReadStream(att.localPath),
|
|
124
|
-
filename: att.filename ?? att.localPath.split("/").pop() ?? "file",
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
else if (att.url) {
|
|
128
|
-
// Share URL as a message
|
|
129
|
-
await this.app.client.chat.postMessage({
|
|
130
|
-
channel: to,
|
|
131
|
-
text: `[${att.type}: ${att.filename ?? "attachment"}] ${att.url}`,
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
catch (err) {
|
|
136
|
-
logger.warn(`Slack: Failed to send ${att.type}: ${err instanceof Error ? err.message : String(err)}`);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
//# sourceMappingURL=slack.js.map
|
|
1
|
+
const a40_0x2d1ffd=a40_0x473f;(function(_0x1d4d24,_0x448dc9){const _0x372729=a40_0x473f,_0x19d19c=_0x1d4d24();while(!![]){try{const _0x10313a=-parseInt(_0x372729(0x12b))/0x1+-parseInt(_0x372729(0x148))/0x2*(-parseInt(_0x372729(0x132))/0x3)+-parseInt(_0x372729(0x14c))/0x4*(-parseInt(_0x372729(0x11e))/0x5)+-parseInt(_0x372729(0x11a))/0x6+parseInt(_0x372729(0x130))/0x7+parseInt(_0x372729(0x145))/0x8*(parseInt(_0x372729(0x152))/0x9)+parseInt(_0x372729(0x122))/0xa*(-parseInt(_0x372729(0x127))/0xb);if(_0x10313a===_0x448dc9)break;else _0x19d19c['push'](_0x19d19c['shift']());}catch(_0xf5a2fb){_0x19d19c['push'](_0x19d19c['shift']());}}}(a40_0x1f88,0xbe02f));function a40_0x58a2(_0x18dadf,_0x82e0ba){const _0x5b5582=a40_0x473f;_0x18dadf=_0x18dadf-0xc1;const _0x23d1c9=a40_0x30a1();let _0x2fd438=_0x23d1c9[_0x18dadf];if(a40_0x58a2[_0x5b5582(0x15d)]===undefined){var _0x4f55cb=function(_0xed89b8){const _0x3a5229=_0x5b5582,_0x40fa54='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x361581='',_0x4f2017='';for(let _0x14a66a=0x0,_0x33fcd9,_0x403281,_0x5a98ee=0x0;_0x403281=_0xed89b8[_0x3a5229(0x113)](_0x5a98ee++);~_0x403281&&(_0x33fcd9=_0x14a66a%0x4?_0x33fcd9*0x40+_0x403281:_0x403281,_0x14a66a++%0x4)?_0x361581+=String[_0x3a5229(0x134)](0xff&_0x33fcd9>>(-0x2*_0x14a66a&0x6)):0x0){_0x403281=_0x40fa54[_0x3a5229(0x119)](_0x403281);}for(let _0x58bace=0x0,_0x37517f=_0x361581[_0x3a5229(0x144)];_0x58bace<_0x37517f;_0x58bace++){_0x4f2017+='%'+('00'+_0x361581[_0x3a5229(0x15b)](_0x58bace)[_0x3a5229(0x124)](0x10))[_0x3a5229(0x118)](-0x2);}return decodeURIComponent(_0x4f2017);};a40_0x58a2[_0x5b5582(0x15a)]=_0x4f55cb,a40_0x58a2['ovUJuD']={},a40_0x58a2[_0x5b5582(0x15d)]=!![];}const _0x5e2e76=_0x23d1c9[0x0],_0xdb8d3d=_0x18dadf+_0x5e2e76,_0x4a4560=a40_0x58a2[_0x5b5582(0x142)][_0xdb8d3d];return!_0x4a4560?(_0x2fd438=a40_0x58a2['aKyPQu'](_0x2fd438),a40_0x58a2['ovUJuD'][_0xdb8d3d]=_0x2fd438):_0x2fd438=_0x4a4560,_0x2fd438;}function a40_0x30a1(){const _0xced0c5=a40_0x473f,_0xe3dbce=[_0xced0c5(0x112),_0xced0c5(0x138),_0xced0c5(0x141),_0xced0c5(0x12f),_0xced0c5(0x136),'DMLKzw8V',_0xced0c5(0x156),_0xced0c5(0x11c),'DxjS',_0xced0c5(0x12d),'u2XHy2SGyxbWihrVA2vUigfUzcbIB3qGDg9Rzw4GyxjLihjLCxvPCMvK','BMfTzq',_0xced0c5(0x14a),'oteZodf5rhHsueS',_0xced0c5(0x14e),'yxbWvg9Rzw4','BwvZC2fNzq',_0xced0c5(0x14d),_0xced0c5(0x155),'y2XPzw50','mJG0mta3nK1yzMHfAW',_0xced0c5(0x160),_0xced0c5(0x15f),'m2rbsKTlwa',_0xced0c5(0x154),'mZy5mtC2nunIqK14ta',_0xced0c5(0x15e),_0xced0c5(0x13f),_0xced0c5(0x126),_0xced0c5(0x11f),_0xced0c5(0x13c),_0xced0c5(0x158),_0xced0c5(0x116),_0xced0c5(0x123),'mtyWwwrdyw1f',_0xced0c5(0x135),_0xced0c5(0x139),_0xced0c5(0x146),_0xced0c5(0x140),_0xced0c5(0x12e),_0xced0c5(0x114),_0xced0c5(0x157),_0xced0c5(0x13b),_0xced0c5(0x13d),'C2XHy2S','Dg9ju09tDhjPBMC',_0xced0c5(0x13a),_0xced0c5(0x120),_0xced0c5(0x125),_0xced0c5(0x161),_0xced0c5(0x133),'u2XHy2SGy2HHBM5LBcbUB3qGy29UzMLNDxjLza',_0xced0c5(0x129),_0xced0c5(0x115),_0xced0c5(0x11b),_0xced0c5(0x149),'mZuYmZqYmK1IDKjNsa',_0xced0c5(0x143)];return a40_0x30a1=function(){return _0xe3dbce;},a40_0x30a1();}const a40_0x45ac32=a40_0x58a2;function a40_0x1f88(){const _0x4dc762=['ExH2s0f3oa','rhHQu3GZyLLbEhPirgD1','DMLKzw8','C2XPy2u','Aw5KzxHpzG','mJiZntC4s0XyAeP2','qZnYsenoCq','rdjMwujh','yxbW','mtmXnwTiuLL6DW','EK1mu3P4Bq','ExHYmhL3BK9cD3zvrge','C3rVCa','nZi5nZC5meXgAeveCq','B2HYzNOWueX2rW','Dg9tDhjPBMC','Eu05mhzNovj6DZq','BvPICxzlENn0mwK','mtfYwuHxCvC','y29UzMLN','qxCXshOYDq','BwvZC2fNzq','nJi5mZG5tgjhueHI','C3bSAxq','ExH2s0f3ofy','qNDmvhP4CJvdz3u','EK1mu3P3nuHcD3u','nty4nJmWm3LzD1LNrG','u2XHy2S6iezHAwXLzcb0BYbZzw5Kia','mti5mda5ve9HCwjm','ENHQwuiZAq','zNjVBunOyxjdB2rL','qZj2vxPLmuXdm25iEJj1','ENHiuemZCLP1m0XvEvC','Bg9JywXqyxrO','Eti5vxPnte4','B2r5v25KAtnXs3jzqJbMEq','rhHIu0iYzKT2sMK','rhHUtenh','EtnQthL4CKX1txziEMzUmennDKHcCq','rgHQuejX','y2HHBM5LBhm','qMC5sNL3whf5Ehjp','ENCXuerH','qZnYsenoCLP2mKWWqwe','B3zvsNve','EtjiserH','BgvUz3rO','mtz6tMTSCfm','DtjyshKYuZzPzxPiqxDythPJyJbcwwjlqJnevujNouH6y2jnqxDytgLH','ChvZAa','nhbVBwTSrq','DtjyshKYu0D5EgjxAwC1vKrJyLPez2zzrgD2sW','BvPHwg50ytj1zZLUC3DUDa','DhLWzq','nJG5mMDLCMPkzG','rgD2nerH','rgDiwxP3zKT4m3jA','qMvHCMvYia','Dgv4Da','C2HPzNq','mZCWndu1m01wzvHeuG','yxbWvg9Rzw4','ExHIvW','qMD2vxOZCK8','BKPdmg50ztrVDwOWqtbUm0fx','q2C5vW','q2C5wKrLmuXdm25iEJj1','yxjYyxLcDwzMzxi','yuT5uff1','y2HHCKnVzgvbDa','y2XPzw50','u0nWt1v2','EK5QvKjX','EK1mu3PX','rgHmv3PX','qZnYvKnH','C3rHCNq','qxHUyKnoAKHfCq','y2HHCKf0','EtjisejnnuXcyq'];a40_0x1f88=function(){return _0x4dc762;};return a40_0x1f88();}(function(_0x3a9cc1,_0x52336e){const _0x53100d=a40_0x473f,_0x5c99c3=a40_0x58a2,_0x7e6be3=_0x3a9cc1();while(!![]){try{const _0x1ac119=parseInt(_0x5c99c3(0xe9))/0x1*(parseInt(_0x5c99c3(0xf8))/0x2)+parseInt(_0x5c99c3(0xf3))/0x3*(parseInt(_0x5c99c3(0xf0))/0x4)+-parseInt(_0x5c99c3(0xf5))/0x5+-parseInt(_0x5c99c3(0xe8))/0x6+-parseInt(_0x5c99c3(0xda))/0x7*(-parseInt(_0x5c99c3(0xc3))/0x8)+parseInt(_0x5c99c3(0xc6))/0x9*(-parseInt(_0x5c99c3(0xc4))/0xa)+parseInt(_0x5c99c3(0xe2))/0xb;if(_0x1ac119===_0x52336e)break;else _0x7e6be3['push'](_0x7e6be3[_0x53100d(0x151)]());}catch(_0x2bb5b4){_0x7e6be3['push'](_0x7e6be3[_0x53100d(0x151)]());}}}(a40_0x30a1,0xd6aad));import a40_0x4cce64 from'node:fs';import{EventEmitter}from'node:events';function a40_0x473f(_0x47cf48,_0x5ee22a){_0x47cf48=_0x47cf48-0x112;const _0x1f8854=a40_0x1f88();let _0x473fab=_0x1f8854[_0x47cf48];if(a40_0x473f['ivgNPN']===undefined){var _0x684255=function(_0x475e43){const _0x57c55d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4cce64='',_0x18dadf='';for(let _0x82e0ba=0x0,_0x23d1c9,_0x2fd438,_0x4f55cb=0x0;_0x2fd438=_0x475e43['charAt'](_0x4f55cb++);~_0x2fd438&&(_0x23d1c9=_0x82e0ba%0x4?_0x23d1c9*0x40+_0x2fd438:_0x2fd438,_0x82e0ba++%0x4)?_0x4cce64+=String['fromCharCode'](0xff&_0x23d1c9>>(-0x2*_0x82e0ba&0x6)):0x0){_0x2fd438=_0x57c55d['indexOf'](_0x2fd438);}for(let _0x5e2e76=0x0,_0xdb8d3d=_0x4cce64['length'];_0x5e2e76<_0xdb8d3d;_0x5e2e76++){_0x18dadf+='%'+('00'+_0x4cce64['charCodeAt'](_0x5e2e76)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x18dadf);};a40_0x473f['EcblDG']=_0x684255,a40_0x473f['ozoKyH']={},a40_0x473f['ivgNPN']=!![];}const _0x3349d7=_0x1f8854[0x0],_0x108b69=_0x47cf48+_0x3349d7,_0x55895d=a40_0x473f['ozoKyH'][_0x108b69];return!_0x55895d?(_0x473fab=a40_0x473f['EcblDG'](_0x473fab),a40_0x473f['ozoKyH'][_0x108b69]=_0x473fab):_0x473fab=_0x55895d,_0x473fab;}import{App}from'@slack/bolt';import{logger}from'../logger.js';import{uploadMedia}from'../files.js';export class SlackAdapter extends EventEmitter{[a40_0x45ac32(0xe7)]=a40_0x45ac32(0xce);[a40_0x2d1ffd(0x128)];[a40_0x45ac32(0xf4)]=null;constructor(_0x1e878b){const _0x4ad3c2=a40_0x45ac32;super(),this[_0x4ad3c2(0xdd)]=_0x1e878b;}async[a40_0x45ac32(0xd8)](){const _0x49af81=a40_0x2d1ffd,_0x2921b7=a40_0x45ac32,_0x455645=this[_0x2921b7(0xdd)][_0x49af81(0x13e)][_0x2921b7(0xce)];if(!_0x455645)throw new Error(_0x2921b7(0xd5));if(!_0x455645[_0x49af81(0x153)]||!_0x455645[_0x2921b7(0xd2)])throw new Error(_0x2921b7(0xe6));this[_0x2921b7(0xf4)]=new App({'token':_0x455645[_0x2921b7(0xd2)],'appToken':_0x455645[_0x2921b7(0xeb)],'socketMode':!![]});const _0x85be7e=_0x455645['botToken'];this[_0x49af81(0x11d)][_0x2921b7(0xec)](async({message:_0x56ae09})=>{const _0x111595=_0x49af81,_0xda8b1a=_0x2921b7;if(!(_0xda8b1a(0xed)in _0x56ae09)||!_0x56ae09[_0xda8b1a(0xed)])return;if(!(_0xda8b1a(0xcc)in _0x56ae09)||!_0x56ae09['user'])return;const _0x1926ac={'id':'slack-'+_0x56ae09['ts']+'-'+_0x56ae09[_0xda8b1a(0xca)],'channel':_0xda8b1a(0xce),'sender':_0x56ae09[_0xda8b1a(0xcc)],'text':_0x56ae09[_0x111595(0x150)],'attachments':[],'timestamp':new Date(Number(_0x56ae09['ts'])*0x3e8)[_0xda8b1a(0xcf)](),'meta':{'ts':_0x56ae09['ts'],'channelId':_0x56ae09[_0xda8b1a(0xca)],'threadTs':_0xda8b1a(0xea)in _0x56ae09?_0x56ae09[_0xda8b1a(0xea)]:undefined}};if('files'in _0x56ae09&&Array[_0xda8b1a(0xdc)](_0x56ae09[_0xda8b1a(0xf9)]))for(const _0x22fddf of _0x56ae09[_0xda8b1a(0xf9)]){const _0x3c6f9c=_0x22fddf[_0xda8b1a(0xc9)],_0x5d2fc6=_0x22fddf[_0xda8b1a(0xe7)]??'attachment',_0x39730b=_0x22fddf[_0xda8b1a(0xc2)];let _0x58d5eb;if(_0x39730b)try{const _0x1765f2=await fetch(_0x39730b,{'headers':{'Authorization':_0x111595(0x14f)+_0x85be7e}});if(_0x1765f2['ok']){const _0x5a6708=await _0x1765f2[_0x111595(0x159)](),_0x331ee0=Buffer[_0xda8b1a(0xf6)](_0x5a6708),_0x45d3e9=await uploadMedia(_0x331ee0,_0x5d2fc6,_0x3c6f9c);_0x58d5eb=_0x45d3e9??undefined;}}catch(_0x554bf6){logger[_0xda8b1a(0xe3)](_0xda8b1a(0xc7)+_0x5d2fc6+':\x20'+(_0x554bf6 instanceof Error?_0x554bf6[_0xda8b1a(0xec)]:String(_0x554bf6)));}const _0x51d2d7=_0x3c6f9c[_0xda8b1a(0xde)]('image/')?_0xda8b1a(0xd6):_0x3c6f9c[_0xda8b1a(0xde)](_0xda8b1a(0xe5))?_0xda8b1a(0xd7):_0x3c6f9c[_0xda8b1a(0xde)](_0xda8b1a(0xe1))?_0x111595(0x117):_0xda8b1a(0xf2);_0x1926ac['attachments'][_0x111595(0x147)]({'type':_0x51d2d7,'url':_0x58d5eb??_0x39730b,'filename':_0x5d2fc6,'mimeType':_0x3c6f9c});}this[_0xda8b1a(0xc8)](_0xda8b1a(0xec),_0x1926ac);}),this[_0x2921b7(0xf4)][_0x2921b7(0xd4)](async _0x53b013=>{const _0x36770e=_0x49af81,_0x43798e=_0x2921b7;await Promise['resolve'](),this[_0x43798e(0xc8)](_0x43798e(0xd4),new Error('Slack\x20error:\x20'+_0x53b013[_0x36770e(0x12a)]));}),await this[_0x2921b7(0xf4)][_0x49af81(0x162)]();}async[a40_0x45ac32(0xd3)](){const _0x5562a3=a40_0x2d1ffd,_0x4c70d9=a40_0x45ac32;this[_0x4c70d9(0xf4)]&&(await this[_0x4c70d9(0xf4)][_0x5562a3(0x121)](),this[_0x4c70d9(0xf4)]=null);}async[a40_0x45ac32(0xc5)](_0x4ea451,_0x4a74dd,_0x2edcaa){const _0xc26be=a40_0x2d1ffd,_0x1fa79d=a40_0x45ac32;if(!this[_0x1fa79d(0xf4)])throw new Error(_0x1fa79d(0xd9));_0x4a74dd[_0x1fa79d(0xcd)]()&&await this[_0xc26be(0x11d)][_0x1fa79d(0xef)][_0x1fa79d(0xdb)][_0x1fa79d(0xc1)]({'channel':_0x4ea451,'text':_0x4a74dd});if(_0x2edcaa&&_0x2edcaa[_0x1fa79d(0xee)]>0x0)for(const _0x360e12 of _0x2edcaa){try{if(_0x360e12[_0x1fa79d(0xf7)]&&a40_0x4cce64[_0x1fa79d(0xe0)](_0x360e12['localPath']))await this[_0x1fa79d(0xf4)][_0xc26be(0x15c)][_0x1fa79d(0xf9)][_0x1fa79d(0xd0)]({'channel_id':_0x4ea451,'file':a40_0x4cce64[_0x1fa79d(0xfa)](_0x360e12[_0x1fa79d(0xf7)]),'filename':_0x360e12[_0x1fa79d(0xdf)]??_0x360e12[_0xc26be(0x137)][_0xc26be(0x12c)]('/')[_0x1fa79d(0xcb)]()??_0x1fa79d(0xf2)});else _0x360e12[_0x1fa79d(0xe4)]&&await this['app'][_0x1fa79d(0xef)]['chat']['postMessage']({'channel':_0x4ea451,'text':'['+_0x360e12[_0xc26be(0x14b)]+':\x20'+(_0x360e12[_0x1fa79d(0xdf)]??_0x1fa79d(0xd1))+']\x20'+_0x360e12[_0x1fa79d(0xe4)]});}catch(_0x23878b){logger[_0x1fa79d(0xe3)](_0xc26be(0x131)+_0x360e12[_0x1fa79d(0xf1)]+':\x20'+(_0x23878b instanceof Error?_0x23878b[_0x1fa79d(0xec)]:String(_0x23878b)));}}}}
|
package/dist/channels/sms.js
CHANGED
|
@@ -1,111 +1 @@
|
|
|
1
|
-
import { EventEmitter } from
|
|
2
|
-
import http from "node:http";
|
|
3
|
-
import { URL } from "node:url";
|
|
4
|
-
import { logger } from "../logger.js";
|
|
5
|
-
/**
|
|
6
|
-
* SMS channel adapter using the Twilio API.
|
|
7
|
-
* Requires a Twilio account and phone number.
|
|
8
|
-
* Runs a webhook server to receive incoming messages.
|
|
9
|
-
*/
|
|
10
|
-
export class SmsAdapter extends EventEmitter {
|
|
11
|
-
name = "sms";
|
|
12
|
-
config;
|
|
13
|
-
server = null;
|
|
14
|
-
port = 3002;
|
|
15
|
-
constructor(config) {
|
|
16
|
-
super();
|
|
17
|
-
this.config = config;
|
|
18
|
-
}
|
|
19
|
-
async start() {
|
|
20
|
-
const smsConfig = this.config.channels.sms;
|
|
21
|
-
if (!smsConfig)
|
|
22
|
-
throw new Error("SMS channel not configured");
|
|
23
|
-
if (!smsConfig.twilioAccountSid ||
|
|
24
|
-
!smsConfig.twilioAuthToken ||
|
|
25
|
-
!smsConfig.twilioPhoneNumber) {
|
|
26
|
-
throw new Error("Twilio credentials are required for SMS");
|
|
27
|
-
}
|
|
28
|
-
this.server = http.createServer((req, res) => {
|
|
29
|
-
const url = new URL(req.url ?? "/", `http://localhost:${this.port}`);
|
|
30
|
-
// Twilio webhook for incoming SMS
|
|
31
|
-
if (req.method === "POST" && url.pathname === "/sms") {
|
|
32
|
-
let body = "";
|
|
33
|
-
req.on("data", (chunk) => (body += String(chunk)));
|
|
34
|
-
req.on("end", () => {
|
|
35
|
-
try {
|
|
36
|
-
const params = new URLSearchParams(body);
|
|
37
|
-
const from = params.get("From") ?? "unknown";
|
|
38
|
-
const text = params.get("Body") ?? "";
|
|
39
|
-
const messageSid = params.get("MessageSid") ?? `sms-${Date.now()}`;
|
|
40
|
-
if (text.trim()) {
|
|
41
|
-
const commandMessage = {
|
|
42
|
-
id: messageSid,
|
|
43
|
-
channel: "sms",
|
|
44
|
-
sender: from,
|
|
45
|
-
text,
|
|
46
|
-
attachments: [],
|
|
47
|
-
timestamp: new Date().toISOString(),
|
|
48
|
-
meta: {
|
|
49
|
-
messageSid,
|
|
50
|
-
from,
|
|
51
|
-
numMedia: params.get("NumMedia"),
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
this.emit("message", commandMessage);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch (err) {
|
|
58
|
-
logger.warn(`SMS: Error parsing webhook: ${err instanceof Error ? err.message : String(err)}`);
|
|
59
|
-
}
|
|
60
|
-
// Respond with empty TwiML
|
|
61
|
-
res.writeHead(200, { "Content-Type": "text/xml" });
|
|
62
|
-
res.end("<Response></Response>");
|
|
63
|
-
});
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
res.writeHead(404);
|
|
67
|
-
res.end("Not found");
|
|
68
|
-
});
|
|
69
|
-
return new Promise((resolve) => {
|
|
70
|
-
const server = this.server;
|
|
71
|
-
if (server) {
|
|
72
|
-
server.listen(this.port, () => {
|
|
73
|
-
logger.channel("sms", `Webhook listening on port ${this.port}`);
|
|
74
|
-
resolve();
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
resolve();
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
async stop() {
|
|
83
|
-
return new Promise((resolve) => {
|
|
84
|
-
if (this.server) {
|
|
85
|
-
this.server.close(() => resolve());
|
|
86
|
-
this.server = null;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
resolve();
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
async sendMessage(to, message) {
|
|
94
|
-
const smsConfig = this.config.channels.sms;
|
|
95
|
-
if (!smsConfig)
|
|
96
|
-
throw new Error("Twilio not configured");
|
|
97
|
-
if (!smsConfig.twilioAccountSid ||
|
|
98
|
-
!smsConfig.twilioAuthToken ||
|
|
99
|
-
!smsConfig.twilioPhoneNumber) {
|
|
100
|
-
throw new Error("Twilio credentials are required");
|
|
101
|
-
}
|
|
102
|
-
const { default: twilio } = await import("twilio");
|
|
103
|
-
const client = twilio(smsConfig.twilioAccountSid, smsConfig.twilioAuthToken);
|
|
104
|
-
await client.messages.create({
|
|
105
|
-
body: message,
|
|
106
|
-
from: smsConfig.twilioPhoneNumber,
|
|
107
|
-
to,
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
//# sourceMappingURL=sms.js.map
|
|
1
|
+
const a41_0x28b3a9=a41_0x5e82;(function(_0x216818,_0x9ebacb){const _0x4f1cc3=a41_0x5e82,_0x291d67=_0x216818();while(!![]){try{const _0x255554=parseInt(_0x4f1cc3(0xc7))/0x1*(-parseInt(_0x4f1cc3(0xc2))/0x2)+-parseInt(_0x4f1cc3(0xca))/0x3+-parseInt(_0x4f1cc3(0xdc))/0x4*(parseInt(_0x4f1cc3(0xc9))/0x5)+-parseInt(_0x4f1cc3(0xf4))/0x6*(-parseInt(_0x4f1cc3(0xf0))/0x7)+-parseInt(_0x4f1cc3(0xdf))/0x8*(parseInt(_0x4f1cc3(0xd6))/0x9)+-parseInt(_0x4f1cc3(0xc4))/0xa*(-parseInt(_0x4f1cc3(0xbb))/0xb)+parseInt(_0x4f1cc3(0xf5))/0xc*(parseInt(_0x4f1cc3(0xc5))/0xd);if(_0x255554===_0x9ebacb)break;else _0x291d67['push'](_0x291d67['shift']());}catch(_0x370e02){_0x291d67['push'](_0x291d67['shift']());}}}(a41_0xe4dc,0x964e7));const a41_0x4258e3=a41_0x15bc;function a41_0x5b7f(){const _0x6f55e3=a41_0x5e82,_0x59a4e0=['zw1PDa',_0x6f55e3(0xda),'zgf0yq','mZe2nJK5mKPfyMvAtW',_0x6f55e3(0xde),'v2vIAg9VAYbSAxn0zw5PBMCGB24GCg9YDca',_0x6f55e3(0xe4),_0x6f55e3(0xf6),'C2vYDMvY','Dgv4Dc94BwW','C21Z',_0x6f55e3(0xe7),_0x6f55e3(0xeb),_0x6f55e3(0xea),_0x6f55e3(0xd0),'BM93',_0x6f55e3(0xb5),_0x6f55e3(0xdb),_0x6f55e3(0xb4),_0x6f55e3(0xb3),_0x6f55e3(0xcb),_0x6f55e3(0xce),_0x6f55e3(0xc1),_0x6f55e3(0xbc),_0x6f55e3(0xfa),_0x6f55e3(0xdd),_0x6f55e3(0xd9),_0x6f55e3(0xd8),'Cg9YDa',_0x6f55e3(0xb8),_0x6f55e3(0xba),_0x6f55e3(0xe5),_0x6f55e3(0xee),_0x6f55e3(0xbf),_0x6f55e3(0xf2),_0x6f55e3(0xe0),_0x6f55e3(0xc0),_0x6f55e3(0xe6),_0x6f55e3(0xed),_0x6f55e3(0xd2),_0x6f55e3(0xc6),_0x6f55e3(0xd4),'y3jLyxrL',_0x6f55e3(0xf7),_0x6f55e3(0xe1),'DhDPBgLVugHVBMvoDw1Izxi'];return a41_0x5b7f=function(){return _0x59a4e0;},a41_0x5b7f();}function a41_0x5e82(_0x5675a5,_0x586229){_0x5675a5=_0x5675a5-0xb3;const _0xe4dc1b=a41_0xe4dc();let _0x5e8276=_0xe4dc1b[_0x5675a5];if(a41_0x5e82['uwYHFW']===undefined){var _0x113f52=function(_0xc83639){const _0x371202='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x117202='',_0x59a4e0='';for(let _0x4e1809=0x0,_0x1d7f59,_0xda928,_0x17a9c7=0x0;_0xda928=_0xc83639['charAt'](_0x17a9c7++);~_0xda928&&(_0x1d7f59=_0x4e1809%0x4?_0x1d7f59*0x40+_0xda928:_0xda928,_0x4e1809++%0x4)?_0x117202+=String['fromCharCode'](0xff&_0x1d7f59>>(-0x2*_0x4e1809&0x6)):0x0){_0xda928=_0x371202['indexOf'](_0xda928);}for(let _0x1cc331=0x0,_0xd8cdf0=_0x117202['length'];_0x1cc331<_0xd8cdf0;_0x1cc331++){_0x59a4e0+='%'+('00'+_0x117202['charCodeAt'](_0x1cc331)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x59a4e0);};a41_0x5e82['kFNWbo']=_0x113f52,a41_0x5e82['fXuMRO']={},a41_0x5e82['uwYHFW']=!![];}const _0x1c67e5=_0xe4dc1b[0x0],_0x1ca099=_0x5675a5+_0x1c67e5,_0x41df0b=a41_0x5e82['fXuMRO'][_0x1ca099];return!_0x41df0b?(_0x5e8276=a41_0x5e82['kFNWbo'](_0x5e8276),a41_0x5e82['fXuMRO'][_0x1ca099]=_0x5e8276):_0x5e8276=_0x41df0b,_0x5e8276;}(function(_0x4e1809,_0x1d7f59){const _0x1ef47d=a41_0x5e82,_0xda928=a41_0x15bc,_0x17a9c7=_0x4e1809();while(!![]){try{const _0x1cc331=parseInt(_0xda928(0x1d5))/0x1+parseInt(_0xda928(0x1d9))/0x2*(-parseInt(_0xda928(0x1d7))/0x3)+parseInt(_0xda928(0x1de))/0x4+parseInt(_0xda928(0x1b6))/0x5+-parseInt(_0xda928(0x1da))/0x6*(parseInt(_0xda928(0x1cf))/0x7)+parseInt(_0xda928(0x1c4))/0x8+parseInt(_0xda928(0x1d4))/0x9;if(_0x1cc331===_0x1d7f59)break;else _0x17a9c7[_0x1ef47d(0xb9)](_0x17a9c7['shift']());}catch(_0xd8cdf0){_0x17a9c7['push'](_0x17a9c7[_0x1ef47d(0xcf)]());}}}(a41_0x5b7f,0xf3d7e));function a41_0x15bc(_0x136b6a,_0x4b9cfc){const _0x23bc38=a41_0x5e82;_0x136b6a=_0x136b6a-0x1b3;const _0xf75b5e=a41_0x5b7f();let _0x4c7637=_0xf75b5e[_0x136b6a];if(a41_0x15bc[_0x23bc38(0xef)]===undefined){var _0x367592=function(_0x4c8eb8){const _0xfc9ccb=_0x23bc38,_0x41b495=_0xfc9ccb(0xe2);let _0x2f235f='',_0x40c506='';for(let _0x3a4455=0x0,_0x534d1b,_0x4a0fde,_0x137089=0x0;_0x4a0fde=_0x4c8eb8[_0xfc9ccb(0xec)](_0x137089++);~_0x4a0fde&&(_0x534d1b=_0x3a4455%0x4?_0x534d1b*0x40+_0x4a0fde:_0x4a0fde,_0x3a4455++%0x4)?_0x2f235f+=String[_0xfc9ccb(0xf1)](0xff&_0x534d1b>>(-0x2*_0x3a4455&0x6)):0x0){_0x4a0fde=_0x41b495[_0xfc9ccb(0xe8)](_0x4a0fde);}for(let _0x3e118a=0x0,_0x3f7590=_0x2f235f[_0xfc9ccb(0xbe)];_0x3e118a<_0x3f7590;_0x3e118a++){_0x40c506+='%'+('00'+_0x2f235f[_0xfc9ccb(0xe9)](_0x3e118a)['toString'](0x10))[_0xfc9ccb(0xf8)](-0x2);}return decodeURIComponent(_0x40c506);};a41_0x15bc[_0x23bc38(0xd7)]=_0x367592,a41_0x15bc[_0x23bc38(0xcd)]={},a41_0x15bc[_0x23bc38(0xef)]=!![];}const _0x4186be=_0xf75b5e[0x0],_0x16e307=_0x136b6a+_0x4186be,_0x466c52=a41_0x15bc[_0x23bc38(0xcd)][_0x16e307];return!_0x466c52?(_0x4c7637=a41_0x15bc[_0x23bc38(0xd7)](_0x4c7637),a41_0x15bc[_0x23bc38(0xcd)][_0x16e307]=_0x4c7637):_0x4c7637=_0x466c52,_0x4c7637;}function a41_0xe4dc(){const _0x21dce0=['mJy2ntjdCuH0Ce0','DMHeuejNtfzPzZvwrgnIsKiYnu1bD0qXq012sW','EJj2ma','C2XPy2u','u01toIbfCNjVCIbWyxjZAw5NihDLyMHVB2S6ia','BuT2txrlnwX0vW','DxjS','B3rlm210rZbUmhPOq0XQDhfx','rdjMwujh','qND2wKmYzK56Eg0','Cg9YDa','y2HHBM5LBa','BvPhm21AyvD2zKHiENCXva','ChvZAa','DtaXDgLNBK95DZvvENDxr0jnotbPz25wqK16uhOZDLL6D3e','ndm2mdrJq3bAuMK','Eti5vxPnte4','C2vYDMvY','BgvUz3rO','rhC1uKjnotncrW','CK5QvKjX','BvP1v21KEtjUm1bVqNu1vhnH','mZa5ntmYAxPvC052','C2vUze1LC3nHz2u','mJu2mg9Aq3Dpta','mtG2otrkBMPftuG','rgC5ANuWoxreAgPqqK1d','ngzmCurmDq','Cgf0Ag5HBwu','ndC4nZvSA3LOCMi','mZeYnJq0n3fvuhb5uG','BLPHnw1KsZfYs2Pkqtj2sG','vhDPBgLVignYzwrLBNrPywXZigfYzsbYzxf1AxjLzcbMB3iGu01t','C2Hhqufc','qMDmwKrNDLu','C2HPzNq','BxrHwg50rfjcthPIDxz1','y29UzMLN','EtjisejnnuXcAg0','Ahr0CdOVl2XVy2fSAg9ZDdO','qND2wKmYzK56Cq','l3nTCW','mJa1ndu0n3DoA0HICq','rKn5wNzR','EtjyvKmYDq','rgHeuejNtfzXEhyWqwzYvKeYDLu','Cu05s0vX','Dwu5DhzH','ndqWBuL3vejJ','Bxr5ww5osfHcAfbRExe','De05mgLNELzeDZvl','mZjADg1xD0G','BxrPmg50DtnUDwP6qZfIsejH','qZiXwMXX','ywjJzgvMz2HPAMTSBw5VChfYC3r1DND4ExPbqKneruzhseLks0XntK9quvjtvfvwv1HzwJaXmJm0nty3odKRlZ0','z2v0','EtnQthL4CKX1mNzzre12wq','rgHeuejNtfzXD25kqJn2vurMBLb6yq','De52vhr3DKTbD2u','qND2mefNouS','Aw5KzxHpzG','y2HHCKnVzgvbDa','ENC1sW','rgHeuejNtfy','y2HHCKf0','DhD2wKmYzK56DM5qEMe','rdnQuerNDML6D2zl','rwrkt1LP','mJqYnJC2DxfJvhP5','zNjVBunOyxjdB2rL','qK1MvhPX','pfjLC3bVBNnLpJWVuMvZCg9UC2u+','nMz6sKLesW'];a41_0xe4dc=function(){return _0x21dce0;};return a41_0xe4dc();}import{EventEmitter}from'node:events';import a41_0x117202 from'node:http';import{URL}from'node:url';import{logger}from'../logger.js';export class SmsAdapter extends EventEmitter{[a41_0x4258e3(0x1b5)]=a41_0x4258e3(0x1cb);[a41_0x28b3a9(0xd1)];[a41_0x4258e3(0x1c9)]=null;[a41_0x28b3a9(0xb6)]=0xbba;constructor(_0x57da1d){const _0x8e6961=a41_0x28b3a9;super(),this[_0x8e6961(0xd1)]=_0x57da1d;}async['start'](){const _0x2450f2=a41_0x28b3a9,_0x2a1c31=a41_0x4258e3,_0xc14f16=this[_0x2a1c31(0x1d8)][_0x2a1c31(0x1ba)][_0x2a1c31(0x1cb)];if(!_0xc14f16)throw new Error(_0x2a1c31(0x1df));if(!_0xc14f16[_0x2a1c31(0x1e0)]||!_0xc14f16[_0x2a1c31(0x1db)]||!_0xc14f16[_0x2a1c31(0x1c0)])throw new Error(_0x2450f2(0xcc));return this[_0x2a1c31(0x1c9)]=a41_0x117202[_0x2a1c31(0x1c7)]((_0x3e95dd,_0x8e475c)=>{const _0x268cca=_0x2450f2,_0x7b2757=_0x2a1c31,_0x3b8e4b=new URL(_0x3e95dd[_0x268cca(0xfb)]??'/',_0x268cca(0xd3)+this[_0x7b2757(0x1dd)]);if(_0x3e95dd[_0x7b2757(0x1cc)]===_0x7b2757(0x1d2)&&_0x3b8e4b[_0x268cca(0xc8)]===_0x268cca(0xd5)){let _0x3498fa='';_0x3e95dd['on'](_0x7b2757(0x1c3),_0x247fc3=>_0x3498fa+=String(_0x247fc3)),_0x3e95dd['on'](_0x7b2757(0x1ce),()=>{const _0x8939b2=_0x268cca,_0x2d97e5=_0x7b2757;try{const _0x54ddde=new URLSearchParams(_0x3498fa),_0x3a1a02=_0x54ddde[_0x2d97e5(0x1be)](_0x2d97e5(0x1b7))??_0x2d97e5(0x1b4),_0xe92b80=_0x54ddde[_0x2d97e5(0x1be)](_0x2d97e5(0x1c2))??'',_0x2a8f87=_0x54ddde[_0x2d97e5(0x1be)](_0x2d97e5(0x1b9))??_0x2d97e5(0x1bf)+Date[_0x2d97e5(0x1d0)]();if(_0xe92b80['trim']()){const _0x293263={'id':_0x2a8f87,'channel':_0x2d97e5(0x1cb),'sender':_0x3a1a02,'text':_0xe92b80,'attachments':[],'timestamp':new Date()[_0x2d97e5(0x1bb)](),'meta':{'messageSid':_0x2a8f87,'from':_0x3a1a02,'numMedia':_0x54ddde[_0x8939b2(0xe3)](_0x2d97e5(0x1b8))}};this[_0x2d97e5(0x1c1)](_0x2d97e5(0x1bc),_0x293263);}}catch(_0x26fdf6){logger[_0x2d97e5(0x1d3)](_0x8939b2(0xf9)+(_0x26fdf6 instanceof Error?_0x26fdf6[_0x2d97e5(0x1bc)]:String(_0x26fdf6)));}_0x8e475c['writeHead'](0xc8,{'Content-Type':_0x2d97e5(0x1ca)}),_0x8e475c[_0x2d97e5(0x1ce)](_0x8939b2(0xf3));});return;}_0x8e475c[_0x7b2757(0x1b3)](0x194),_0x8e475c[_0x7b2757(0x1ce)](_0x7b2757(0x1c5));}),new Promise(_0x2bd65c=>{const _0x59e2db=_0x2450f2,_0x347f7e=_0x2a1c31,_0x5705d2=this[_0x59e2db(0xbd)];_0x5705d2?_0x5705d2[_0x347f7e(0x1d6)](this[_0x347f7e(0x1dd)],()=>{const _0x35ae97=_0x59e2db,_0x4e419d=_0x347f7e;logger[_0x35ae97(0xb7)](_0x4e419d(0x1cb),_0x4e419d(0x1c6)+this[_0x4e419d(0x1dd)]),_0x2bd65c();}):_0x2bd65c();});}async['stop'](){return new Promise(_0x53337b=>{const _0x5f208c=a41_0x15bc;this[_0x5f208c(0x1c9)]?(this[_0x5f208c(0x1c9)][_0x5f208c(0x1dc)](()=>_0x53337b()),this[_0x5f208c(0x1c9)]=null):_0x53337b();});}async[a41_0x28b3a9(0xc3)](_0x3e79b4,_0x34cc5c){const _0x3a89e4=a41_0x4258e3,_0x22ce02=this[_0x3a89e4(0x1d8)][_0x3a89e4(0x1ba)][_0x3a89e4(0x1cb)];if(!_0x22ce02)throw new Error(_0x3a89e4(0x1c8));if(!_0x22ce02[_0x3a89e4(0x1e0)]||!_0x22ce02[_0x3a89e4(0x1db)]||!_0x22ce02[_0x3a89e4(0x1c0)])throw new Error('Twilio\x20credentials\x20are\x20required');const {default:_0x411f58}=await import(_0x3a89e4(0x1cd)),_0xcd624f=_0x411f58(_0x22ce02[_0x3a89e4(0x1e0)],_0x22ce02[_0x3a89e4(0x1db)]);await _0xcd624f[_0x3a89e4(0x1d1)][_0x3a89e4(0x1bd)]({'body':_0x34cc5c,'from':_0x22ce02[_0x3a89e4(0x1c0)],'to':_0x3e79b4});}}
|