alvin-bot 5.7.0 → 5.8.1

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 (137) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +25 -31
  3. package/dist/claude.js +1 -102
  4. package/dist/config.js +1 -96
  5. package/dist/engine.js +1 -90
  6. package/dist/find-claude-binary.js +1 -98
  7. package/dist/handlers/async-agent-chunk-handler.js +1 -50
  8. package/dist/handlers/background-bypass.js +1 -75
  9. package/dist/handlers/commands.js +1 -2336
  10. package/dist/handlers/cron-progress.js +1 -52
  11. package/dist/handlers/document.js +1 -194
  12. package/dist/handlers/message.js +1 -959
  13. package/dist/handlers/photo.js +1 -154
  14. package/dist/handlers/platform-message.js +1 -360
  15. package/dist/handlers/stuck-timer.js +1 -54
  16. package/dist/handlers/video.js +1 -237
  17. package/dist/handlers/voice.js +1 -148
  18. package/dist/i18n.js +1 -805
  19. package/dist/index.js +1 -697
  20. package/dist/init-data-dir.js +1 -98
  21. package/dist/middleware/auth.js +1 -233
  22. package/dist/migrate.js +1 -162
  23. package/dist/paths.js +1 -146
  24. package/dist/platforms/discord.js +1 -175
  25. package/dist/platforms/index.js +1 -130
  26. package/dist/platforms/signal.js +1 -205
  27. package/dist/platforms/slack-slash-parser.js +1 -32
  28. package/dist/platforms/slack.js +1 -501
  29. package/dist/platforms/telegram.js +1 -111
  30. package/dist/platforms/types.js +1 -8
  31. package/dist/platforms/whatsapp-auth-helpers.js +1 -53
  32. package/dist/platforms/whatsapp.js +1 -707
  33. package/dist/providers/claude-sdk-provider.js +1 -565
  34. package/dist/providers/codex-cli-provider.js +1 -134
  35. package/dist/providers/index.js +1 -7
  36. package/dist/providers/ollama-provider.js +1 -32
  37. package/dist/providers/openai-compatible.js +1 -406
  38. package/dist/providers/registry.js +1 -352
  39. package/dist/providers/runtime-header.js +1 -45
  40. package/dist/providers/tool-executor.js +1 -475
  41. package/dist/providers/types.js +1 -227
  42. package/dist/services/access.js +1 -144
  43. package/dist/services/allowed-users-gate.js +1 -56
  44. package/dist/services/alvin-dispatch.js +1 -174
  45. package/dist/services/alvin-mcp-tools.js +1 -104
  46. package/dist/services/asset-index.js +1 -224
  47. package/dist/services/async-agent-parser.js +1 -418
  48. package/dist/services/async-agent-watcher.js +1 -583
  49. package/dist/services/auto-diagnostic.js +1 -228
  50. package/dist/services/broadcast.js +1 -52
  51. package/dist/services/browser-manager.js +1 -562
  52. package/dist/services/browser-webfetch.js +1 -127
  53. package/dist/services/browser.js +1 -121
  54. package/dist/services/cdp-bootstrap.js +1 -357
  55. package/dist/services/compaction.js +1 -144
  56. package/dist/services/critical-notify.js +1 -203
  57. package/dist/services/cron-resolver.js +1 -58
  58. package/dist/services/cron-scheduling.js +1 -310
  59. package/dist/services/cron.js +1 -861
  60. package/dist/services/custom-tools.js +1 -317
  61. package/dist/services/delivery-queue.js +1 -173
  62. package/dist/services/delivery-registry.js +1 -21
  63. package/dist/services/disk-cleanup.js +1 -203
  64. package/dist/services/elevenlabs.js +1 -58
  65. package/dist/services/embeddings/auto-detect.js +1 -74
  66. package/dist/services/embeddings/fts5.js +1 -108
  67. package/dist/services/embeddings/gemini.js +1 -65
  68. package/dist/services/embeddings/index.js +1 -496
  69. package/dist/services/embeddings/ollama.js +1 -78
  70. package/dist/services/embeddings/openai.js +1 -49
  71. package/dist/services/embeddings/provider.js +1 -22
  72. package/dist/services/embeddings/vector-base.js +1 -113
  73. package/dist/services/embeddings-migration.js +1 -193
  74. package/dist/services/embeddings.js +1 -9
  75. package/dist/services/env-file.js +1 -50
  76. package/dist/services/exec-guard.js +1 -71
  77. package/dist/services/fallback-order.js +1 -154
  78. package/dist/services/file-permissions.js +1 -93
  79. package/dist/services/heartbeat-file.js +1 -65
  80. package/dist/services/heartbeat.js +1 -313
  81. package/dist/services/hooks.js +1 -44
  82. package/dist/services/imagegen.js +1 -72
  83. package/dist/services/language-detect.js +1 -154
  84. package/dist/services/markdown.js +1 -63
  85. package/dist/services/mcp.js +1 -263
  86. package/dist/services/memory-extractor.js +1 -178
  87. package/dist/services/memory-inject-mode.js +1 -43
  88. package/dist/services/memory-layers.js +1 -156
  89. package/dist/services/memory.js +1 -146
  90. package/dist/services/ollama-manager.js +1 -339
  91. package/dist/services/permissions-wizard.js +1 -291
  92. package/dist/services/personality.js +1 -376
  93. package/dist/services/plugins.js +1 -171
  94. package/dist/services/preflight.js +1 -292
  95. package/dist/services/process-manager.js +1 -291
  96. package/dist/services/release-highlights.js +1 -79
  97. package/dist/services/reminders.js +1 -97
  98. package/dist/services/restart.js +1 -48
  99. package/dist/services/security-audit.js +1 -74
  100. package/dist/services/self-diagnosis.js +1 -272
  101. package/dist/services/self-search.js +1 -129
  102. package/dist/services/session-persistence.js +1 -237
  103. package/dist/services/session.js +1 -282
  104. package/dist/services/skills.js +1 -290
  105. package/dist/services/ssrf-guard.js +1 -162
  106. package/dist/services/standing-orders.js +1 -29
  107. package/dist/services/steer-channel.js +1 -46
  108. package/dist/services/stop-controller.js +1 -52
  109. package/dist/services/subagent-dedup.js +1 -86
  110. package/dist/services/subagent-delivery.js +1 -452
  111. package/dist/services/subagent-stats.js +1 -123
  112. package/dist/services/subagents.js +1 -814
  113. package/dist/services/sudo.js +1 -329
  114. package/dist/services/telegram.js +1 -158
  115. package/dist/services/timing-safe-bearer.js +1 -51
  116. package/dist/services/tool-discovery.js +1 -214
  117. package/dist/services/trends.js +1 -580
  118. package/dist/services/updater.js +1 -291
  119. package/dist/services/usage-tracker.js +1 -144
  120. package/dist/services/users.js +1 -271
  121. package/dist/services/voice.js +1 -104
  122. package/dist/services/watchdog-brake.js +1 -154
  123. package/dist/services/watchdog.js +1 -311
  124. package/dist/services/workspaces.js +1 -276
  125. package/dist/tui/index.js +1 -667
  126. package/dist/util/console-formatter.js +1 -109
  127. package/dist/util/debounce.js +1 -24
  128. package/dist/util/telegram-error-filter.js +1 -62
  129. package/dist/version.js +1 -24
  130. package/dist/web/bind-strategy.js +1 -42
  131. package/dist/web/canvas.js +1 -30
  132. package/dist/web/doctor-api.js +1 -604
  133. package/dist/web/openai-compat.js +1 -252
  134. package/dist/web/server.js +1 -1902
  135. package/dist/web/setup-api.js +1 -1101
  136. package/package.json +5 -2
  137. package/dist/.metadata_never_index +0 -0
@@ -1,290 +1 @@
1
- /**
2
- * Skill System — Specialized knowledge for complex tasks.
3
- *
4
- * Skills are SKILL.md files in the skills/ directory that provide
5
- * domain-specific instructions, workflows, and best practices.
6
- *
7
- * When a user message matches a skill's triggers, the skill's content
8
- * is injected into the system prompt — giving the agent deep expertise
9
- * for that specific task type.
10
- *
11
- * Philosophy: A generalist agent with specialist knowledge on demand.
12
- *
13
- * Features:
14
- * - Bundled skills (skills/ in repo) + User skills (~/.alvin-bot/skills/)
15
- * - User skills override bundled skills with the same ID
16
- * - Hot-reload via fs.watch() on both directories
17
- * - Self-modification via createSkill()
18
- */
19
- import { existsSync, readFileSync, readdirSync, mkdirSync, writeFileSync, watch } from "fs";
20
- import { resolve } from "path";
21
- import { SKILLS_DIR } from "../paths.js";
22
- import { USER_SKILLS_DIR } from "../paths.js";
23
- import { loadAssetIndex } from "./asset-index.js";
24
- import { debounce } from "../util/debounce.js";
25
- // ── Skill Registry ──────────────────────────────────────
26
- let cachedSkills = [];
27
- let lastScanAt = 0;
28
- /**
29
- * Parse SKILL.md frontmatter (simple YAML-like header).
30
- *
31
- * Format:
32
- * ---
33
- * name: Video Creation
34
- * description: Create videos with Remotion
35
- * triggers: video, remotion, animation, render
36
- * priority: 5
37
- * category: media
38
- * ---
39
- * (rest is the skill content)
40
- */
41
- function parseSkillFile(id, content, source) {
42
- const fmMatch = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
43
- if (!fmMatch) {
44
- // No frontmatter — treat entire file as content with defaults
45
- return {
46
- id,
47
- name: id.replace(/-/g, " ").replace(/\b\w/g, c => c.toUpperCase()),
48
- description: "",
49
- triggers: [id.replace(/-/g, " ")],
50
- content: content.trim(),
51
- priority: 1,
52
- category: "general",
53
- source,
54
- };
55
- }
56
- const frontmatter = fmMatch[1];
57
- const body = fmMatch[2].trim();
58
- function getField(key) {
59
- const match = frontmatter.match(new RegExp(`^${key}:\\s*(.+)$`, "m"));
60
- return match ? match[1].trim() : "";
61
- }
62
- const name = getField("name") || id;
63
- const description = getField("description") || "";
64
- const triggersRaw = getField("triggers") || id;
65
- const priority = parseInt(getField("priority")) || 1;
66
- const category = getField("category") || "general";
67
- const assetCategoriesRaw = getField("assetCategories");
68
- const assetCategories = assetCategoriesRaw
69
- ? assetCategoriesRaw.replace(/[\[\]]/g, "").split(",").map(s => s.trim()).filter(Boolean)
70
- : undefined;
71
- const triggers = triggersRaw
72
- .split(",")
73
- .map(t => t.trim().toLowerCase())
74
- .filter(Boolean);
75
- return { id, name, description, triggers, content: body, priority, category, source, assetCategories };
76
- }
77
- /**
78
- * Scan a single skills directory and return all parsed skills.
79
- */
80
- function scanDirectory(dir, source) {
81
- if (!existsSync(dir))
82
- return [];
83
- const skills = [];
84
- const entries = readdirSync(dir, { withFileTypes: true });
85
- for (const entry of entries) {
86
- if (entry.isDirectory()) {
87
- const skillFile = resolve(dir, entry.name, "SKILL.md");
88
- if (existsSync(skillFile)) {
89
- try {
90
- const content = readFileSync(skillFile, "utf-8");
91
- const skill = parseSkillFile(entry.name, content, source);
92
- if (skill)
93
- skills.push(skill);
94
- }
95
- catch (err) {
96
- console.warn(`\u26a0\ufe0f Failed to load skill ${entry.name}:`, err);
97
- }
98
- }
99
- }
100
- // Also support flat .md files in skills/
101
- if (entry.isFile() && entry.name.endsWith(".md")) {
102
- const id = entry.name.replace(/\.md$/, "");
103
- try {
104
- const content = readFileSync(resolve(dir, entry.name), "utf-8");
105
- const skill = parseSkillFile(id, content, source);
106
- if (skill)
107
- skills.push(skill);
108
- }
109
- catch (err) {
110
- console.warn(`\u26a0\ufe0f Failed to load skill ${id}:`, err);
111
- }
112
- }
113
- }
114
- return skills;
115
- }
116
- /**
117
- * Reload all skills from both directories.
118
- * User skills override bundled skills with the same ID.
119
- */
120
- function reloadAllSkills() {
121
- // Ensure bundled directory exists
122
- if (!existsSync(SKILLS_DIR)) {
123
- mkdirSync(SKILLS_DIR, { recursive: true });
124
- }
125
- const bundled = scanDirectory(SKILLS_DIR, "bundled");
126
- const user = scanDirectory(USER_SKILLS_DIR, "user");
127
- // Merge: user skills override bundled skills with same ID
128
- const skillMap = new Map();
129
- for (const s of bundled)
130
- skillMap.set(s.id, s);
131
- for (const s of user)
132
- skillMap.set(s.id, s); // override
133
- cachedSkills = [...skillMap.values()];
134
- lastScanAt = Date.now();
135
- if (cachedSkills.length > 0) {
136
- const bundledCount = cachedSkills.filter(s => s.source === "bundled").length;
137
- const userCount = cachedSkills.filter(s => s.source === "user").length;
138
- console.log(`\ud83c\udfaf Skills loaded: ${cachedSkills.length} (${bundledCount} bundled, ${userCount} user) — ${cachedSkills.map(s => s.name).join(", ")}`);
139
- }
140
- }
141
- /**
142
- * Scan both skills directories and load all SKILL.md files.
143
- * Sets up fs.watch() for hot-reload on both directories.
144
- */
145
- export function loadSkills() {
146
- reloadAllSkills();
147
- // Hot-reload watchers — macOS FSEvents delivers many duplicate events
148
- // for a single logical change, so we coalesce bursts into one reload.
149
- const bundledReload = debounce(() => {
150
- console.log("Skills changed (bundled) \u2014 reloading");
151
- reloadAllSkills();
152
- }, 300);
153
- const userReload = debounce(() => {
154
- console.log("Skills changed (user) \u2014 reloading");
155
- reloadAllSkills();
156
- }, 300);
157
- try {
158
- watch(SKILLS_DIR, { recursive: true }, () => bundledReload());
159
- }
160
- catch { /* ignore — watcher failures fall back to manual reload */ }
161
- try {
162
- if (existsSync(USER_SKILLS_DIR)) {
163
- watch(USER_SKILLS_DIR, { recursive: true }, () => userReload());
164
- }
165
- }
166
- catch { /* ignore */ }
167
- return cachedSkills;
168
- }
169
- /**
170
- * Get all loaded skills. Cached after the first loadSkills() call; hot-reload
171
- * happens via fs.watch when files change on disk. We only force a scan here if
172
- * the cache is empty (init-order edge case).
173
- */
174
- export function getSkills() {
175
- if (cachedSkills.length === 0) {
176
- reloadAllSkills();
177
- }
178
- return cachedSkills;
179
- }
180
- /**
181
- * Find a skill by its ID.
182
- */
183
- export function getSkillById(id) {
184
- return cachedSkills.find(s => s.id === id);
185
- }
186
- /**
187
- * Create or update a user skill (self-modification).
188
- * Writes to USER_SKILLS_DIR and triggers reload.
189
- */
190
- export function createSkill(id, content) {
191
- const dir = resolve(USER_SKILLS_DIR, id);
192
- if (!existsSync(dir))
193
- mkdirSync(dir, { recursive: true });
194
- writeFileSync(resolve(dir, "SKILL.md"), content);
195
- // Trigger reload
196
- reloadAllSkills();
197
- return true;
198
- }
199
- /**
200
- * Find skills that match a user message.
201
- * Returns matched skills sorted by priority (highest first).
202
- */
203
- export function matchSkills(userMessage, maxResults = 2) {
204
- const skills = getSkills();
205
- if (skills.length === 0)
206
- return [];
207
- const msgLower = userMessage.toLowerCase();
208
- const words = msgLower.split(/[\s,.!?;:()[\]{}'"]+/).filter(w => w.length >= 2);
209
- const wordSet = new Set(words);
210
- const scored = [];
211
- for (const skill of skills) {
212
- let score = 0;
213
- for (const trigger of skill.triggers) {
214
- // Exact phrase match (strongest signal)
215
- if (msgLower.includes(trigger)) {
216
- score += trigger.split(" ").length * 3; // multi-word triggers score higher
217
- }
218
- // Single-word trigger match
219
- else if (trigger.split(" ").length === 1 && wordSet.has(trigger)) {
220
- score += 1;
221
- }
222
- }
223
- if (score > 0) {
224
- scored.push({ skill, score: score * skill.priority });
225
- }
226
- }
227
- return scored
228
- .sort((a, b) => b.score - a.score)
229
- .slice(0, maxResults)
230
- .map(s => s.skill);
231
- }
232
- // ── Skill-Asset Mapping ────────────────────────────────
233
- /** Default mapping for skills that don't declare assetCategories in frontmatter.
234
- * Skills can override this by declaring `assetCategories:` in their SKILL.md
235
- * frontmatter. This map is only the fallback. */
236
- const SKILL_ASSET_MAP = {};
237
- /**
238
- * Find assets relevant to a skill.
239
- * Uses frontmatter assetCategories if declared, otherwise falls back to static map.
240
- */
241
- function findAssetsForSkill(skill) {
242
- const categories = skill.assetCategories || SKILL_ASSET_MAP[skill.id];
243
- if (!categories || categories.length === 0)
244
- return [];
245
- const index = loadAssetIndex();
246
- return index.assets.filter(a => categories.includes(a.category));
247
- }
248
- /**
249
- * Build a skill injection block for the system prompt.
250
- * Includes matched skill content + relevant asset references.
251
- */
252
- export function buildSkillContext(userMessage) {
253
- const matched = matchSkills(userMessage, 1); // inject top 1 skill only
254
- if (matched.length === 0)
255
- return "";
256
- const skill = matched[0];
257
- let context = `\n\n## 🎯 Active Skill: ${skill.name}\n\n${skill.content}`;
258
- // Inject relevant assets for this skill
259
- const assets = findAssetsForSkill(skill);
260
- if (assets.length > 0) {
261
- context += `\n\n### 📂 Relevant Assets\n`;
262
- for (const a of assets) {
263
- context += `- ${a.category}/${a.filename} → \`${a.absolutePath}\`\n`;
264
- }
265
- }
266
- return context;
267
- }
268
- /**
269
- * Get a summary of all available skills (for /skills command or status).
270
- */
271
- export function getSkillsSummary() {
272
- const skills = getSkills();
273
- if (skills.length === 0)
274
- return "No skills installed.";
275
- const byCategory = new Map();
276
- for (const s of skills) {
277
- const list = byCategory.get(s.category) || [];
278
- list.push(s);
279
- byCategory.set(s.category, list);
280
- }
281
- const lines = [`\ud83c\udfaf **Skills (${skills.length}):**\n`];
282
- for (const [cat, list] of byCategory) {
283
- lines.push(`**${cat}:**`);
284
- for (const s of list) {
285
- const badge = s.source === "user" ? " \ud83d\udc64" : "";
286
- lines.push(` \u2022 ${s.name}${badge} \u2014 ${s.description || "(no description)"}`);
287
- }
288
- }
289
- return lines.join("\n");
290
- }
1
+ (function(_0x3e7cfa,_0x3d90e0){const _0x2fa329=_0xa5ba,_0x1d4487=_0xa5ba,_0xa00572=_0x3e7cfa();while(!![]){try{const _0x442c3a=-parseInt(_0x2fa329(0xe8))/(0x8a8+0x13a+0x9e1*-0x1)+-parseInt(_0x2fa329(0x101))/(0x435*0x7+-0x2d*0x4f+-0xf8e*0x1)+-parseInt(_0x2fa329(0xd4))/(0xdec+0x385+0x17*-0xc2)+-parseInt(_0x2fa329(0xd2))/(-0xc31+0xd60+-0x1*0x12b)+-parseInt(_0x2fa329(0xe5))/(-0x2485+0xe56+0x3a*0x62)*(parseInt(_0x2fa329(0xe7))/(-0xeb2+-0x1c4f*-0x1+-0xd97))+-parseInt(_0x1d4487(0xed))/(0x11aa+0x329*-0x5+-0x1d6)*(-parseInt(_0x1d4487(0xd9))/(-0x814+-0x2*0x71f+0x165a))+parseInt(_0x1d4487(0xfe))/(-0xd11+0xcec+0x2e);if(_0x442c3a===_0x3d90e0)break;else _0xa00572['push'](_0xa00572['shift']());}catch(_0x495cd7){_0xa00572['push'](_0xa00572['shift']());}}}(_0x3b42,0xae750+0xc5d9c+-0x89a17*0x1));const _0xe98a56=(function(){let _0x49295d=!![];return function(_0x38be02,_0x211b9b){const _0x19a599=_0x49295d?function(){const _0x1999f8=_0xa5ba;if(_0x211b9b){const _0x47eb5c=_0x211b9b[_0x1999f8(0xca)](_0x38be02,arguments);return _0x211b9b=null,_0x47eb5c;}}:function(){};return _0x49295d=![],_0x19a599;};}()),_0x38218e=_0xe98a56(this,function(){const _0xd2f64f=_0xa5ba;return _0x38218e['toString']()['search']('(((.+)+)+)'+'+$')['toString']()['constructo'+'r'](_0x38218e)[_0xd2f64f(0xcc)]('(((.+)+)+)'+'+$');});_0x38218e();import{existsSync,readFileSync,readdirSync,mkdirSync,writeFileSync,watch}from'fs';import{resolve}from'path';import{SKILLS_DIR}from'../paths.js';import{USER_SKILLS_DIR}from'../paths.js';import{loadAssetIndex}from'./asset-index.js';import{debounce}from'../util/debounce.js';let cachedSkills=[],lastScanAt=-0x133e+0x138+0x602*0x3;function _0x3b42(){const _0x4f60cf=['C2TPBgW','DMfSDwvZ','C2v0','mJK5nZK5mKnVsersqW','BgvUz3rO','ndGXnZaYnvPhBxLtBa','AxngAwXL','Dg9mB3DLCKnHCW','C3bSAxq','zMLSDgvY','ndG0mJuYmhzPqwn4Ba','u2TPBgXZignOyq','C2nVCMu','ChrPB24P','AM9PBG','icdIGkiG','B2fKAw5N','4PQG77IpiezHAwXLzcb0','8j+oRYbtA2LSBhmGBa','BMfTzq','Aw5JBhvKzxm','oLXZkIGUkYKK','mJe4mJe1D0jMCfnx','ChvZAa','mJrPq21kA3G','mtqXodm1m1HXEhz6Ba','BYbSB2fKihnRAq','yxnZzxrZ','BMDLzcaOyNvUza','DhjPBq','mJfNzxvvrhC','yxnZzxrdyxrLzW','BwfW','zMLSzw5HBwu','y29UDgvUDa','DxnLCG','C291CMnL','Aw5ZDgfSBgvKlG','yNvUzgXLza','B3jPzxm','DxrMltG','Aw5N','AxneAxjLy3rVCG','Bg9N','lM1K','zMLUza','DhjPz2DLCNm','ndqXmZi0odfMCwH6CLC','AxzLifnRAwXSoG','BMDLzcaODxnLCG','mZyYmdqZoezxwNDHsG','zw5KC1DPDgG','Bwf0y2G','ihvZzxiPiokaLca','AgfZ','y2f0zwDVCNK','ChjPB3jPDhK','BM93','cGOJiYdWN46ViefJDa','BgvKksdIGjqGCMvS','tM8GC2TPBgXZia','CMvWBgfJzq','zgvZy3jPChrPBW','z2v0','igj1BMrSzwqSia','D2fYBG','ywjZB2X1Dgvqyq','BgWG','iokgKIbG','yxbWBhK','cGOJiYmG8j+tGIbszq','C2vHCMnO','ipcFKAq','z2vUzxjHBa'];_0x3b42=function(){return _0x4f60cf;};return _0x3b42();}function parseSkillFile(_0x169b00,_0x1ff3e2,_0x1103ef){const _0x3bbac0=_0xa5ba,_0x5af3c0=_0xa5ba,_0x3ca852=_0x1ff3e2[_0x3bbac0(0x103)](/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!_0x3ca852)return{'id':_0x169b00,'name':_0x169b00[_0x5af3c0(0xc2)](/-/g,'\x20')[_0x5af3c0(0xc2)](/\b\w/g,_0x4d18ee=>_0x4d18ee['toUpperCas'+'e']()),'description':'','triggers':[_0x169b00[_0x3bbac0(0xc2)](/-/g,'\x20')],'content':_0x1ff3e2[_0x5af3c0(0xec)](),'priority':0x1,'category':_0x3bbac0(0xce),'source':_0x1103ef};const _0x3471a3=_0x3ca852[-0x2*0xa1f+-0x29*0x88+0x2a07],_0x109352=_0x3ca852[-0x1a44+0x1957*0x1+0xef][_0x5af3c0(0xec)]();function _0x355fa1(_0x3c410c){const _0x40e6c7=_0x3bbac0,_0x208863=_0x3bbac0,_0x34d03b=_0x3471a3[_0x40e6c7(0x103)](new RegExp('^'+_0x3c410c+_0x208863(0xe4),'m'));return _0x34d03b?_0x34d03b[0xb5b+-0x17e1+-0x42d*-0x3][_0x40e6c7(0xec)]():'';}const _0x272c13=_0x355fa1('name')||_0x169b00,_0x2c052d=_0x355fa1(_0x5af3c0(0xc3)+'n')||'',_0x4f5884=_0x355fa1(_0x3bbac0(0xfd))||_0x169b00,_0x4a1a82=parseInt(_0x355fa1(_0x5af3c0(0x107)))||-0x461*-0x5+0x1dd2+-0x33b6,_0x14e826=_0x355fa1('category')||_0x5af3c0(0xce),_0x2fc699=_0x355fa1(_0x5af3c0(0xee)+_0x3bbac0(0xf6)),_0x4e336a=_0x2fc699?_0x2fc699[_0x3bbac0(0xc2)](/[\[\]]/g,'')[_0x3bbac0(0xd7)](',')['map'](_0x1e7e6f=>_0x1e7e6f[_0x3bbac0(0xec)]())[_0x3bbac0(0xd8)](Boolean):undefined,_0x3b8e66=_0x4f5884['split'](',')['map'](_0x2967d=>_0x2967d[_0x5af3c0(0xec)]()[_0x5af3c0(0xd6)+'e']())[_0x3bbac0(0xd8)](Boolean);return{'id':_0x169b00,'name':_0x272c13,'description':_0x2c052d,'triggers':_0x3b8e66,'content':_0x109352,'priority':_0x4a1a82,'category':_0x14e826,'source':_0x1103ef,'assetCategories':_0x4e336a};}function scanDirectory(_0x1aafe8,_0x442e49){const _0x3be1ee=_0xa5ba,_0x5d182a=_0xa5ba;if(!existsSync(_0x1aafe8))return[];const _0x240de9=[],_0x353eb0=readdirSync(_0x1aafe8,{'withFileTypes':!![]});for(const _0x1d9941 of _0x353eb0){if(_0x1d9941[_0x3be1ee(0xf9)+'y']()){const _0x24e0e0=resolve(_0x1aafe8,_0x1d9941[_0x5d182a(0xe2)],'SKILL.md');if(existsSync(_0x24e0e0))try{const _0x4a84d5=readFileSync(_0x24e0e0,_0x5d182a(0xf7)),_0x25615f=parseSkillFile(_0x1d9941[_0x3be1ee(0xe2)],_0x4a84d5,_0x442e49);if(_0x25615f)_0x240de9[_0x3be1ee(0xe6)](_0x25615f);}catch(_0xe033dd){console['warn'](_0x3be1ee(0xe0)+_0x5d182a(0xe9)+_0x3be1ee(0xc8)+_0x1d9941[_0x5d182a(0xe2)]+':',_0xe033dd);}}if(_0x1d9941[_0x5d182a(0xd5)]()&&_0x1d9941[_0x5d182a(0xe2)][_0x5d182a(0x102)](_0x5d182a(0xfb))){const _0x25a327=_0x1d9941[_0x3be1ee(0xe2)][_0x5d182a(0xc2)](/\.md$/,'');try{const _0x4ea848=readFileSync(resolve(_0x1aafe8,_0x1d9941[_0x5d182a(0xe2)]),'utf-8'),_0x17efcb=parseSkillFile(_0x25a327,_0x4ea848,_0x442e49);if(_0x17efcb)_0x240de9['push'](_0x17efcb);}catch(_0x5bbe61){console[_0x3be1ee(0xc6)](_0x3be1ee(0xe0)+_0x5d182a(0xe9)+_0x5d182a(0xc8)+_0x25a327+':',_0x5bbe61);}}}return _0x240de9;}function reloadAllSkills(){const _0x37d151=_0xa5ba,_0x282c1d=_0xa5ba;!existsSync(SKILLS_DIR)&&mkdirSync(SKILLS_DIR,{'recursive':!![]});const _0x15d310=scanDirectory(SKILLS_DIR,_0x37d151(0xf5)),_0x51f054=scanDirectory(USER_SKILLS_DIR,'user'),_0x9850f7=new Map();for(const _0x4047e2 of _0x15d310)_0x9850f7[_0x37d151(0xd1)](_0x4047e2['id'],_0x4047e2);for(const _0x317e3c of _0x51f054)_0x9850f7[_0x282c1d(0xd1)](_0x317e3c['id'],_0x317e3c);cachedSkills=[..._0x9850f7[_0x282c1d(0xd0)]()],lastScanAt=Date[_0x282c1d(0x108)]();if(cachedSkills[_0x37d151(0xd3)]>0x2593+-0x19b*-0xb+-0x373c){const _0x511fd8=cachedSkills['filter'](_0x13a6e7=>_0x13a6e7[_0x37d151(0xf3)]==='bundled')[_0x282c1d(0xd3)],_0x1c4fb9=cachedSkills[_0x282c1d(0xd8)](_0xa4c482=>_0xa4c482[_0x37d151(0xf3)]==='user')[_0x282c1d(0xd3)];console[_0x282c1d(0xfa)](_0x282c1d(0xe1)+'oaded:\x20'+cachedSkills['length']+'\x20('+_0x511fd8+_0x282c1d(0xc5)+_0x1c4fb9+_0x37d151(0x104)+cachedSkills['map'](_0x280021=>_0x280021[_0x282c1d(0xe2)])[_0x37d151(0xdd)](',\x20'));}}export function loadSkills(){reloadAllSkills();const _0x5b6877=debounce(()=>{const _0x147a9c=_0xa5ba,_0x2aef07=_0xa5ba;console[_0x147a9c(0xfa)](_0x147a9c(0xda)+_0x2aef07(0xeb)+_0x147a9c(0x10a)+_0x2aef07(0xdf)),reloadAllSkills();},-0x3e9*0x1+0x2613+-0x52*0x67),_0x18453b=debounce(()=>{const _0x5b9908=_0xa5ba,_0xd91151=_0xa5ba;console['log'](_0x5b9908(0xda)+_0xd91151(0x100)+')\x20—\x20reload'+_0x5b9908(0xf8)),reloadAllSkills();},-0x1b19*0x1+-0x2e8+0x1f2d);try{watch(SKILLS_DIR,{'recursive':!![]},()=>_0x5b6877());}catch{}try{existsSync(USER_SKILLS_DIR)&&watch(USER_SKILLS_DIR,{'recursive':!![]},()=>_0x18453b());}catch{}return cachedSkills;}export function getSkills(){return cachedSkills['length']===-0x2*0x11c7+0x2697+-0x309&&reloadAllSkills(),cachedSkills;}export function getSkillById(_0x290af3){const _0x16b418=_0xa5ba;return cachedSkills[_0x16b418(0xfc)](_0x942d2a=>_0x942d2a['id']===_0x290af3);}export function createSkill(_0x212272,_0x18207f){const _0x253d64=resolve(USER_SKILLS_DIR,_0x212272);if(!existsSync(_0x253d64))mkdirSync(_0x253d64,{'recursive':!![]});return writeFileSync(resolve(_0x253d64,'SKILL.md'),_0x18207f),reloadAllSkills(),!![];}export function matchSkills(_0x7e3923,_0x259b84=0x13bb+-0x28*-0xa1+-0x2ce1){const _0x346ab6=_0xa5ba,_0x1503b7=_0xa5ba,_0x447241=getSkills();if(_0x447241[_0x346ab6(0xd3)]===0x1*-0x1b56+-0x1*-0x59b+-0x15bb*-0x1)return[];const _0x5c08c6=_0x7e3923[_0x346ab6(0xd6)+'e'](),_0x520509=_0x5c08c6['split'](/[\s,.!?;:()[\]{}'"]+/)['filter'](_0x1ef36b=>_0x1ef36b[_0x1503b7(0xd3)]>=0x1*-0xb9b+0x194a*-0x1+0x24e7),_0x594250=new Set(_0x520509),_0x35a42c=[];for(const _0x1482c3 of _0x447241){let _0xd5b707=0xd87+0x3*0x652+0x207d*-0x1;for(const _0x8cdc5f of _0x1482c3[_0x346ab6(0xfd)]){if(_0x5c08c6[_0x1503b7(0xe3)](_0x8cdc5f))_0xd5b707+=_0x8cdc5f['split']('\x20')[_0x346ab6(0xd3)]*(0x2080*0x1+-0x2285*-0x1+-0x4302);else _0x8cdc5f['split']('\x20')['length']===0xe48*-0x2+-0x100e*0x1+0x2c9f&&_0x594250[_0x346ab6(0x105)](_0x8cdc5f)&&(_0xd5b707+=-0x70e*-0x4+-0x1419+-0x81e*0x1);}_0xd5b707>-0x1711*0x1+0x20c0*0x1+0x25*-0x43&&_0x35a42c[_0x346ab6(0xe6)]({'skill':_0x1482c3,'score':_0xd5b707*_0x1482c3[_0x1503b7(0x107)]});}return _0x35a42c['sort']((_0x3d606c,_0x56a55b)=>_0x56a55b[_0x346ab6(0xdb)]-_0x3d606c[_0x1503b7(0xdb)])['slice'](0xc13*0x1+0x6*0xce+0x10e7*-0x1,_0x259b84)[_0x346ab6(0xef)](_0x159f0b=>_0x159f0b[_0x1503b7(0xcf)]);}const SKILL_ASSET_MAP={};function findAssetsForSkill(_0x4182dc){const _0x25778a=_0xa5ba,_0x46a4bd=_0xa5ba,_0x2cf260=_0x4182dc[_0x25778a(0xee)+_0x46a4bd(0xf6)]||SKILL_ASSET_MAP[_0x4182dc['id']];if(!_0x2cf260||_0x2cf260['length']===-0x403+0x1*-0x443+0x846)return[];const _0x12c97b=loadAssetIndex();return _0x12c97b[_0x25778a(0xea)]['filter'](_0x5cf778=>_0x2cf260['includes'](_0x5cf778[_0x25778a(0x106)]));}function _0xa5ba(_0xcafb55,_0x372aea){_0xcafb55=_0xcafb55-(-0x453+-0x772*-0x3+-0x1141*0x1);const _0x2b267e=_0x3b42();let _0x498975=_0x2b267e[_0xcafb55];if(_0xa5ba['kLpmOa']===undefined){var _0x2cac11=function(_0x5e440a){const _0x126393='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x49295d='',_0x38be02='',_0x211b9b=_0x49295d+_0x2cac11;for(let _0x19a599=-0x2c*-0x11+-0x83f*-0x1+-0xb2b,_0x47eb5c,_0x169b00,_0x1ff3e2=0x138+0x95*-0x3b+0x211f;_0x169b00=_0x5e440a['charAt'](_0x1ff3e2++);~_0x169b00&&(_0x47eb5c=_0x19a599%(-0x15c8+-0xb*-0x301+-0xb3f)?_0x47eb5c*(-0x1a44+0x1957*0x1+0x12d)+_0x169b00:_0x169b00,_0x19a599++%(0xb5b+-0x17e1+-0x141*-0xa))?_0x49295d+=_0x211b9b['charCodeAt'](_0x1ff3e2+(-0x461*-0x5+0x1dd2+-0x33ad))-(0x2593+-0x19b*-0xb+-0x3732)!==-0x3e9*0x1+0x2613+-0x2*0x1115?String['fromCharCode'](-0x1b19*0x1+-0x2e8+0x1f00&_0x47eb5c>>(-(-0x2*0x11c7+0x2697+-0x307)*_0x19a599&0x13bb+-0x28*-0xa1+-0x2cdd)):_0x19a599:0x1*-0x1b56+-0x1*-0x59b+-0x15bb*-0x1){_0x169b00=_0x126393['indexOf'](_0x169b00);}for(let _0x1103ef=0x1*-0xb9b+0x194a*-0x1+0x24e5,_0x3ca852=_0x49295d['length'];_0x1103ef<_0x3ca852;_0x1103ef++){_0x38be02+='%'+('00'+_0x49295d['charCodeAt'](_0x1103ef)['toString'](0xd87+0x3*0x652+0x206d*-0x1))['slice'](-(0x2080*0x1+-0x2285*-0x1+-0x4303));}return decodeURIComponent(_0x38be02);};_0xa5ba['EcHQZi']=_0x2cac11,_0xa5ba['wcMgvP']={},_0xa5ba['kLpmOa']=!![];}const _0x4d1cc1=_0x2b267e[0xe48*-0x2+-0x100e*0x1+0x2c9e],_0x1ea0d7=_0xcafb55+_0x4d1cc1,_0x868fa5=_0xa5ba['wcMgvP'][_0x1ea0d7];if(!_0x868fa5){const _0x3471a3=function(_0x109352){this['wvYzMl']=_0x109352,this['AfuJPQ']=[-0x70e*-0x4+-0x1419+-0x81e*0x1,-0x1711*0x1+0x20c0*0x1+0x25*-0x43,0xc13*0x1+0x6*0xce+0x10e7*-0x1],this['koUFTO']=function(){return'newState';},this['fpTZKH']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['pLSHlL']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x3471a3['prototype']['gvhTPP']=function(){const _0x355fa1=new RegExp(this['fpTZKH']+this['pLSHlL']),_0x272c13=_0x355fa1['test'](this['koUFTO']['toString']())?--this['AfuJPQ'][-0x403+0x1*-0x443+0x847]:--this['AfuJPQ'][0x26f6+0x21f3+0x1*-0x48e9];return this['UZUhfp'](_0x272c13);},_0x3471a3['prototype']['UZUhfp']=function(_0x2c052d){if(!Boolean(~_0x2c052d))return _0x2c052d;return this['YvJOry'](this['wvYzMl']);},_0x3471a3['prototype']['YvJOry']=function(_0x4f5884){for(let _0x4a1a82=-0x10*0x20e+-0x229*0x11+0x4599*0x1,_0x14e826=this['AfuJPQ']['length'];_0x4a1a82<_0x14e826;_0x4a1a82++){this['AfuJPQ']['push'](Math['round'](Math['random']())),_0x14e826=this['AfuJPQ']['length'];}return _0x4f5884(this['AfuJPQ'][-0x90e*-0x1+0x2ad*0x2+-0xe68]);},new _0x3471a3(_0xa5ba)['gvhTPP'](),_0x498975=_0xa5ba['EcHQZi'](_0x498975),_0xa5ba['wcMgvP'][_0x1ea0d7]=_0x498975;}else _0x498975=_0x868fa5;return _0x498975;}export function buildSkillContext(_0x16cf2c){const _0x44a4be=_0xa5ba,_0x4ee468=_0xa5ba,_0xb432fc=matchSkills(_0x16cf2c,0x26f6+0x21f3+0x1*-0x48e8);if(_0xb432fc[_0x44a4be(0xd3)]===-0x10*0x20e+-0x229*0x11+0x4599*0x1)return'';const _0x46b40c=_0xb432fc[-0x90e*-0x1+0x2ad*0x2+-0xe68];let _0x5df53e=_0x44a4be(0x109)+_0x4ee468(0xff)+'\x20'+_0x46b40c[_0x44a4be(0xe2)]+'\x0a\x0a'+_0x46b40c[_0x4ee468(0xf1)];const _0xee6e3=findAssetsForSkill(_0x46b40c);if(_0xee6e3[_0x44a4be(0xd3)]>-0x1cae+0x621+0x168d){_0x5df53e+=_0x44a4be(0xcb)+'levant\x20Ass'+'ets\x0a';for(const _0x523dc3 of _0xee6e3){_0x5df53e+='-\x20'+_0x523dc3['category']+'/'+_0x523dc3[_0x44a4be(0xf0)]+_0x44a4be(0xc9)+_0x523dc3[_0x4ee468(0xc7)+'th']+'`\x0a';}}return _0x5df53e;}export function getSkillsSummary(){const _0x414993=_0xa5ba,_0x3af0ca=_0xa5ba,_0x302b5d=getSkills();if(_0x302b5d['length']===-0x2320+-0xdfa+0x311a)return _0x414993(0x10b)+_0x3af0ca(0xf4);const _0x3ea11f=new Map();for(const _0x145071 of _0x302b5d){const _0x31e624=_0x3ea11f[_0x414993(0xc4)](_0x145071[_0x414993(0x106)])||[];_0x31e624[_0x3af0ca(0xe6)](_0x145071),_0x3ea11f[_0x3af0ca(0xd1)](_0x145071[_0x3af0ca(0x106)],_0x31e624);}const _0x860018=['🎯\x20**Skills'+'\x20('+_0x302b5d[_0x3af0ca(0xd3)]+'):**\x0a'];for(const [_0x57242b,_0x14d397]of _0x3ea11f){_0x860018[_0x414993(0xe6)]('**'+_0x57242b+':**');for(const _0x5861b0 of _0x14d397){const _0x17bd35=_0x5861b0[_0x3af0ca(0xf3)]===_0x414993(0xf2)?_0x414993(0xcd):'';_0x860018['push'](_0x3af0ca(0xde)+_0x5861b0['name']+_0x17bd35+'\x20—\x20'+(_0x5861b0['descriptio'+'n']||'(no\x20descri'+_0x3af0ca(0xdc)));}}return _0x860018[_0x414993(0xdd)]('\x0a');}
@@ -1,162 +1 @@
1
- /**
2
- * SSRF Guard — rejects requests to private/internal network destinations.
3
- *
4
- * Blocks:
5
- * - Non-http(s) schemes (file://, ftp://, etc.)
6
- * - IPv4 loopback (127.0.0.0/8), link-local (169.254.0.0/16 — incl. cloud
7
- * metadata endpoint 169.254.169.254), RFC-1918 private ranges
8
- * (10/8, 172.16/12, 192.168/16), and the catch-all 0.0.0.0
9
- * - IPv6 loopback (::1), ULA (fc00::/7), link-local (fe80::/10)
10
- *
11
- * Opt-out: set ALLOW_PRIVATE_FETCH=1 to disable blocking (for local dev /
12
- * self-hosted setups). Default = blocked.
13
- *
14
- * No new runtime dependencies — uses Node's built-in `dns` and `net` modules.
15
- */
16
- import dns from "dns";
17
- import net from "net";
18
- export class SsrfBlockedError extends Error {
19
- url;
20
- constructor(url, reason) {
21
- super(`SSRF blocked: ${reason} (url: ${url})`);
22
- this.name = "SsrfBlockedError";
23
- this.url = url;
24
- }
25
- }
26
- /**
27
- * Return true if the given IPv4 address string falls into a private/reserved
28
- * range (RFC-1918, loopback, link-local, unspecified).
29
- *
30
- * Ranges blocked:
31
- * 0.0.0.0/8 — "this" network
32
- * 10.0.0.0/8 — RFC-1918 class A
33
- * 127.0.0.0/8 — loopback
34
- * 169.254.0.0/16 — link-local (incl. IMDS 169.254.169.254)
35
- * 172.16.0.0/12 — RFC-1918 class B (172.16–172.31)
36
- * 192.168.0.0/16 — RFC-1918 class C
37
- */
38
- function isPrivateIPv4(ip) {
39
- const parts = ip.split(".").map(Number);
40
- if (parts.length !== 4 || parts.some(p => isNaN(p) || p < 0 || p > 255)) {
41
- return false; // not a valid IPv4 — let DNS resolve decide
42
- }
43
- const [a, b] = parts;
44
- if (a === 0)
45
- return true; // 0.0.0.0/8
46
- if (a === 10)
47
- return true; // 10.0.0.0/8
48
- if (a === 127)
49
- return true; // 127.0.0.0/8 loopback
50
- if (a === 169 && b === 254)
51
- return true; // 169.254.0.0/16 link-local
52
- if (a === 172 && b >= 16 && b <= 31)
53
- return true; // 172.16.0.0/12
54
- if (a === 192 && b === 168)
55
- return true; // 192.168.0.0/16
56
- return false;
57
- }
58
- /**
59
- * Return true if the given IPv6 address string falls into a blocked range.
60
- *
61
- * Ranges blocked:
62
- * ::1 — loopback
63
- * fc00::/7 — ULA (fc00:: – fdff::)
64
- * fe80::/10 — link-local
65
- */
66
- function isPrivateIPv6(ip) {
67
- // Node net.isIPv6 normalises the address but we need the raw string
68
- // for prefix checks. Use the compressed form from net.
69
- const normalized = ip.toLowerCase().replace(/^\[|\]$/g, "");
70
- // Loopback
71
- if (normalized === "::1")
72
- return true;
73
- // For prefix checks, expand just the first 16-bit group
74
- const firstGroup = normalized.split(":")[0];
75
- const value = parseInt(firstGroup || "0", 16);
76
- // fc00::/7 — fc00 to fdff (bit 7 of first byte = 1, bit 6 = 1, bit 5 doesn't matter… easier: 0xfc00–0xfdff range for the first 16 bits)
77
- // The /7 prefix means: binary prefix 1111110x — so 0xfc00 to 0xfdff
78
- if (value >= 0xfc00 && value <= 0xfdff)
79
- return true;
80
- // fe80::/10 — fe80 to febf
81
- if (value >= 0xfe80 && value <= 0xfebf)
82
- return true;
83
- return false;
84
- }
85
- /**
86
- * Check whether a raw IP string (v4 or v6) is a private/internal address.
87
- */
88
- function isPrivateIP(ip) {
89
- const stripped = ip.replace(/^\[|\]$/g, ""); // strip IPv6 brackets
90
- if (net.isIPv4(stripped))
91
- return isPrivateIPv4(stripped);
92
- if (net.isIPv6(stripped))
93
- return isPrivateIPv6(stripped);
94
- return false;
95
- }
96
- /**
97
- * Check the hostname from a URL — if it's a literal IP, classify immediately.
98
- * If it's a hostname, resolve it via DNS and check every returned address.
99
- *
100
- * Throws SsrfBlockedError if any resolved address is private.
101
- * Resolves void if all addresses are public (or DNS fails — fail-open on DNS
102
- * errors so a temporary resolver blip doesn't DoS the bot; the risk is low
103
- * because the per-host literal-IP checks run before DNS).
104
- */
105
- async function checkHost(hostname, url) {
106
- const bare = hostname.replace(/^\[|\]$/g, ""); // strip IPv6 brackets for net.isIP
107
- // Literal IP — no DNS needed
108
- if (net.isIP(bare)) {
109
- if (isPrivateIP(bare)) {
110
- throw new SsrfBlockedError(url, `destination ${bare} is a private/loopback/link-local address`);
111
- }
112
- return;
113
- }
114
- // Named hostname — also catch obvious loopback hostnames without DNS
115
- const lower = bare.toLowerCase();
116
- if (lower === "localhost" || lower.endsWith(".localhost") || lower === "::1") {
117
- throw new SsrfBlockedError(url, `destination hostname '${bare}' resolves to loopback`);
118
- }
119
- // DNS resolution — check every returned address
120
- try {
121
- const { promises: dnsPromises } = dns;
122
- const addresses = await dnsPromises.resolve(bare);
123
- for (const addr of addresses) {
124
- if (isPrivateIP(addr)) {
125
- throw new SsrfBlockedError(url, `destination hostname '${bare}' resolves to private address ${addr}`);
126
- }
127
- }
128
- }
129
- catch (err) {
130
- // Re-throw our own error; swallow DNS failures (fail-open)
131
- if (err instanceof SsrfBlockedError)
132
- throw err;
133
- // DNS error (ENOTFOUND, etc.) — let the actual fetch fail naturally
134
- }
135
- }
136
- /**
137
- * Assert that `url` is safe to fetch (not SSRF-risky).
138
- *
139
- * - Rejects non-http(s) schemes immediately (synchronous check).
140
- * - Resolves hostnames to detect private IP destinations.
141
- * - Respects ALLOW_PRIVATE_FETCH=1 for operator opt-out.
142
- *
143
- * Throws SsrfBlockedError when blocked.
144
- * Resolves void when safe.
145
- */
146
- export async function assertSsrfSafe(url) {
147
- // Opt-out for trusted local / self-hosted environments
148
- if (process.env.ALLOW_PRIVATE_FETCH === "1")
149
- return;
150
- let parsed;
151
- try {
152
- parsed = new URL(url);
153
- }
154
- catch {
155
- throw new SsrfBlockedError(url, "invalid URL");
156
- }
157
- const scheme = parsed.protocol; // includes trailing ':'
158
- if (scheme !== "http:" && scheme !== "https:") {
159
- throw new SsrfBlockedError(url, `scheme '${parsed.protocol}' is not allowed (only http/https)`);
160
- }
161
- await checkHost(parsed.hostname, url);
162
- }
1
+ const _0x268f44=_0x3e58;(function(_0x2cb50b,_0x8dd7b4){const _0x1a416c=_0x3e58,_0xc91528=_0x3e58,_0x47f5f9=_0x2cb50b();while(!![]){try{const _0xd77eaa=-parseInt(_0x1a416c(0x1f0))/(0x1be+-0x177f+0x15c2)+-parseInt(_0xc91528(0x1fe))/(0x28*0x76+-0x1bda+0x96c)+-parseInt(_0x1a416c(0x1ed))/(-0x2433+-0x79*0x7+0x2785)+parseInt(_0xc91528(0x1fb))/(-0x1*0x643+0x21d6+-0x1b8f)+-parseInt(_0x1a416c(0x212))/(0x5*-0x35b+-0x2055+0x3121)+parseInt(_0xc91528(0x1ea))/(-0x1a3d*0x1+0x129d+0x59*0x16)+parseInt(_0xc91528(0x203))/(-0xb58+-0x309+0xe68);if(_0xd77eaa===_0x8dd7b4)break;else _0x47f5f9['push'](_0x47f5f9['shift']());}catch(_0x245ceb){_0x47f5f9['push'](_0x47f5f9['shift']());}}}(_0x4ecb,0x69753+0x6cc91+-0x888df));function _0x3e58(_0x393604,_0x334557){_0x393604=_0x393604-(-0x1c8f+0x4*0x95d+0x4*-0x1bf);const _0x24f59e=_0x4ecb();let _0x43f820=_0x24f59e[_0x393604];if(_0x3e58['pyAcZq']===undefined){var _0x341cee=function(_0x257898){const _0x4a4790='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x172144='',_0x5c141c='',_0x1a6a77=_0x172144+_0x341cee;for(let _0x189f0d=0x780+-0x6e3+-0x1*0x9d,_0x34312e,_0x233ffe,_0x591c05=0x2021+0x2100+-0x1*0x4121;_0x233ffe=_0x257898['charAt'](_0x591c05++);~_0x233ffe&&(_0x34312e=_0x189f0d%(-0x5*0x35b+0x1060*-0x2+0xb*0x481)?_0x34312e*(-0x21e5*0x1+0x1b21+0x704)+_0x233ffe:_0x233ffe,_0x189f0d++%(0x1*0x1238+-0x1c4d+0x205*0x5))?_0x172144+=_0x1a6a77['charCodeAt'](_0x591c05+(-0x7*0x3d1+0x39b+0x1726))-(0xf1*-0x8+0x2*0xdff+-0x146c)!==0x1a6b*-0x1+0x2*0x2ee+-0x115*-0x13?String['fromCharCode'](-0x16f5+0x1f*0x127+0xbc5*-0x1&_0x34312e>>(-(0xa5*-0x19+-0x2e2*0x3+0x18c5*0x1)*_0x189f0d&0x1472+0x3*0xd6+-0x2*0xb77)):_0x189f0d:0x1d13+-0xe*0x3+-0x1ce9){_0x233ffe=_0x4a4790['indexOf'](_0x233ffe);}for(let _0x955a71=-0x2f5*0x8+0x44b*0x1+-0x135d*-0x1,_0x1e9879=_0x172144['length'];_0x955a71<_0x1e9879;_0x955a71++){_0x5c141c+='%'+('00'+_0x172144['charCodeAt'](_0x955a71)['toString'](-0x626*-0x2+-0x1e53+0x1217))['slice'](-(0x1*-0x1f35+0x19b5+-0x2f*-0x1e));}return decodeURIComponent(_0x5c141c);};_0x3e58['cnLZVq']=_0x341cee,_0x3e58['vrSNHx']={},_0x3e58['pyAcZq']=!![];}const _0xcc62c4=_0x24f59e[-0x186d+-0x1c96*-0x1+-0x47*0xf],_0x51adb1=_0x393604+_0xcc62c4,_0x2ca2de=_0x3e58['vrSNHx'][_0x51adb1];if(!_0x2ca2de){const _0x363d28=function(_0x17a189){this['BJMbTD']=_0x17a189,this['NGQIBJ']=[-0x807*0x3+0x1ede+-0x6c8,0x1b55+0x138d+-0x22*0x161,-0x9*0x2f5+-0x1*0x1e11+0x38ae],this['IkYXhX']=function(){return'newState';},this['WhWrpQ']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['kAZBal']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x363d28['prototype']['HQFqnx']=function(){const _0x29d30b=new RegExp(this['WhWrpQ']+this['kAZBal']),_0x126cac=_0x29d30b['test'](this['IkYXhX']['toString']())?--this['NGQIBJ'][-0x26dc+0x243a+-0x87*-0x5]:--this['NGQIBJ'][-0x1*0x26d3+-0xa*-0x1d5+0x1481];return this['GctMJX'](_0x126cac);},_0x363d28['prototype']['GctMJX']=function(_0x2d1a87){if(!Boolean(~_0x2d1a87))return _0x2d1a87;return this['NrFVRe'](this['BJMbTD']);},_0x363d28['prototype']['NrFVRe']=function(_0x252809){for(let _0x2cb14b=-0x17*-0x15b+0x1*-0x11f5+-0xd38,_0x41b2d9=this['NGQIBJ']['length'];_0x2cb14b<_0x41b2d9;_0x2cb14b++){this['NGQIBJ']['push'](Math['round'](Math['random']())),_0x41b2d9=this['NGQIBJ']['length'];}return _0x252809(this['NGQIBJ'][-0x2376+0x1*-0x22d3+0x1*0x4649]);},new _0x363d28(_0x3e58)['HQFqnx'](),_0x43f820=_0x3e58['cnLZVq'](_0x43f820),_0x3e58['vrSNHx'][_0x51adb1]=_0x43f820;}else _0x43f820=_0x2ca2de;return _0x43f820;}const _0x368dcc=(function(){let _0x5dab92=!![];return function(_0x2c13f3,_0x49ea7b){const _0x23764d=_0x5dab92?function(){if(_0x49ea7b){const _0x166650=_0x49ea7b['apply'](_0x2c13f3,arguments);return _0x49ea7b=null,_0x166650;}}:function(){};return _0x5dab92=![],_0x23764d;};}()),_0x36d4b3=_0x368dcc(this,function(){const _0x5e29a7=_0x3e58,_0x5119bc=_0x3e58;return _0x36d4b3[_0x5e29a7(0x1f2)]()[_0x5e29a7(0x214)]('(((.+)+)+)'+'+$')['toString']()[_0x5e29a7(0x20a)+'r'](_0x36d4b3)[_0x5119bc(0x214)]('(((.+)+)+)'+'+$');});_0x36d4b3();import _0x4cf31 from'dns';import _0x460cc8 from'net';export class SsrfBlockedError extends Error{[_0x268f44(0x1e9)];constructor(_0x55bd45,_0x19c53b){const _0x19f831=_0x268f44,_0x4858b7=_0x268f44;super(_0x19f831(0x1f6)+_0x19f831(0x1ef)+_0x19c53b+_0x4858b7(0x201)+_0x55bd45+')'),this['name']=_0x19f831(0x1f4)+'dError',this[_0x4858b7(0x1e9)]=_0x55bd45;}}function isPrivateIPv4(_0x5ee9f6){const _0xfa2cf0=_0x268f44,_0x2b257c=_0x268f44,_0x20a812=_0x5ee9f6[_0xfa2cf0(0x20f)]('.')['map'](Number);if(_0x20a812[_0xfa2cf0(0x20d)]!==0x2021+0x2100+-0x4f*0xd3||_0x20a812['some'](_0xb959a=>isNaN(_0xb959a)||_0xb959a<-0x5*0x35b+0x1060*-0x2+0x1f*0x199||_0xb959a>-0x21e5*0x1+0x1b21+0x7c3))return![];const [_0x341856,_0x3164b3]=_0x20a812;if(_0x341856===0x1*0x1238+-0x1c4d+0xa15*0x1)return!![];if(_0x341856===-0x7*0x3d1+0x39b+0x1726)return!![];if(_0x341856===0xf1*-0x8+0x2*0xdff+-0x13f7)return!![];if(_0x341856===0x1a6b*-0x1+0x2*0x2ee+-0xc2*-0x1c&&_0x3164b3===-0x16f5+0x1f*0x127+0xbc6*-0x1)return!![];if(_0x341856===0xa5*-0x19+-0x2e2*0x3+0x196f*0x1&&_0x3164b3>=0x1472+0x3*0xd6+-0x2*0xb72&&_0x3164b3<=0x1d13+-0xe*0x3+-0x1cca)return!![];if(_0x341856===-0x2f5*0x8+0x44b*0x1+-0x141d*-0x1&&_0x3164b3===-0x626*-0x2+-0x1e53+0x12af)return!![];return![];}function _0x4ecb(){const _0x480aa2=['ntu5nZm2DxLkt29W','Ag9ZDg5HBwu','Dg9tDhjPBMC','Axnjuhy0','u3nYzKjSB2nRzq','C2nOzw1LicC','u1nsrIbIBg9JAW','CMvWBgfJzq','DhbZkq','ihrVigXVB3bIyq','igLZigeGChjPDG','mJqWndyWuMHvEgXY','oJOX','BhKGAhr0Cc9ODa','nty3otaWDuvMDejs','zw52','Aw52ywXPzcbvuG','icH1CMW6ia','ChjVDg9JB2W','nZe1otC4mKzdz3zAva','Bg9JywXOB3n0','jYbYzxnVBhzLCW','qvrfx0zfveni','lMXVy2fSAg9ZDa','y2fSigfKzhjLCW','Axnjua','y29UC3rYDwn0BW','Ahr0CdO','ihrVihbYAxzHDa','BgvUz3rO','zgvZDgLUyxrPBW','C3bSAxq','zsbHzgrYzxnZia','BIbOB3n0BMfTzq','odmWmtu1zNfcreHi','quXmt1DFufjjvG','C2vHCMnO','DxjS','mZmXnZm2ngLjtufUvW','y2SVBgLUAY1SBW','yxrLl2XVB3bIyq','otiZnZe1ueLYsNr3','CMvZB2X2zq','zwq6ia'];_0x4ecb=function(){return _0x480aa2;};return _0x4ecb();}function isPrivateIPv6(_0x4683e3){const _0x414b19=_0x268f44,_0x52ed6b=_0x4683e3['toLowerCas'+'e']()['replace'](/^\[|\]$/g,'');if(_0x52ed6b==='::1')return!![];const _0x256422=_0x52ed6b[_0x414b19(0x20f)](':')[0x1*-0x1f35+0x19b5+-0x2c*-0x20],_0x5927d3=parseInt(_0x256422||'0',-0x186d+-0x1c96*-0x1+-0x419*0x1);if(_0x5927d3>=-0x2c63*0x7+0x18e38+0xa47d&&_0x5927d3<=0x16368+0xfe37+-0x28*0x8e4)return!![];if(_0x5927d3>=-0xee*0x175+-0x3*0x8298+0x3e10e&&_0x5927d3<=-0x1fad4+0x1d875+-0x908f*-0x2)return!![];return![];}function isPrivateIP(_0x31aed9){const _0x168582=_0x268f44,_0x282c3a=_0x268f44,_0x5d5c6c=_0x31aed9[_0x168582(0x1f7)](/^\[|\]$/g,'');if(_0x460cc8[_0x168582(0x1f3)](_0x5d5c6c))return isPrivateIPv4(_0x5d5c6c);if(_0x460cc8['isIPv6'](_0x5d5c6c))return isPrivateIPv6(_0x5d5c6c);return![];}async function checkHost(_0x3548bd,_0x393604){const _0x598f1f=_0x268f44,_0x55ea4a=_0x268f44,_0x334557=_0x3548bd[_0x598f1f(0x1f7)](/^\[|\]$/g,'');if(_0x460cc8[_0x55ea4a(0x209)](_0x334557)){if(isPrivateIP(_0x334557))throw new SsrfBlockedError(_0x393604,_0x598f1f(0x20e)+'n\x20'+_0x334557+(_0x598f1f(0x1fa)+_0x55ea4a(0x1ec)+_0x55ea4a(0x1eb)+_0x598f1f(0x208)+'s'));return;}const _0x24f59e=_0x334557['toLowerCas'+'e']();if(_0x24f59e===_0x55ea4a(0x204)||_0x24f59e['endsWith'](_0x598f1f(0x207))||_0x24f59e===_0x55ea4a(0x1fc))throw new SsrfBlockedError(_0x393604,'destinatio'+'n\x20hostname'+'\x20\x27'+_0x334557+(_0x55ea4a(0x205)+_0x598f1f(0x1f9)+'ck'));try{const {promises:_0x43f820}=_0x4cf31,_0x341cee=await _0x43f820[_0x598f1f(0x1ee)](_0x334557);for(const _0xcc62c4 of _0x341cee){if(isPrivateIP(_0xcc62c4))throw new SsrfBlockedError(_0x393604,_0x598f1f(0x20e)+_0x55ea4a(0x211)+'\x20\x27'+_0x334557+(_0x55ea4a(0x205)+_0x55ea4a(0x20c)+_0x598f1f(0x210))+_0xcc62c4);}}catch(_0x51adb1){if(_0x51adb1 instanceof SsrfBlockedError)throw _0x51adb1;}}export async function assertSsrfSafe(_0x2ca2de){const _0x2324fd=_0x268f44,_0x33191f=_0x268f44;if(process[_0x2324fd(0x1ff)][_0x2324fd(0x213)+_0x33191f(0x206)]==='1')return;let _0x257898;try{_0x257898=new URL(_0x2ca2de);}catch{throw new SsrfBlockedError(_0x2ca2de,_0x2324fd(0x200)+'L');}const _0x4a4790=_0x257898[_0x33191f(0x202)];if(_0x4a4790!==_0x33191f(0x20b)&&_0x4a4790!=='https:')throw new SsrfBlockedError(_0x2ca2de,_0x33191f(0x1f5)+_0x257898[_0x33191f(0x202)]+('\x27\x20is\x20not\x20a'+'llowed\x20(on'+_0x2324fd(0x1fd)+_0x33191f(0x1f8)));await checkHost(_0x257898[_0x33191f(0x1f1)],_0x2ca2de);}
@@ -1,29 +1 @@
1
- import { readFileSync, existsSync } from "fs";
2
- import { AGENTS_FILE } from "../paths.js";
3
- let cached = "";
4
- /** Load standing orders from AGENTS.md. Called once at startup and on reload. */
5
- export function loadStandingOrders() {
6
- if (!existsSync(AGENTS_FILE))
7
- return "";
8
- try {
9
- cached = readFileSync(AGENTS_FILE, "utf-8");
10
- return cached;
11
- }
12
- catch {
13
- return "";
14
- }
15
- }
16
- /** Get cached standing orders (fast, no disk I/O) */
17
- export function getStandingOrders() {
18
- return cached;
19
- }
20
- /** Reload from disk (e.g., after editing via tools) */
21
- export function reloadStandingOrders() {
22
- try {
23
- cached = readFileSync(AGENTS_FILE, "utf-8");
24
- return true;
25
- }
26
- catch {
27
- return false;
28
- }
29
- }
1
+ (function(_0x2245a9,_0x4cfb2b){const _0x3bac86=_0x67ef,_0x447cdb=_0x67ef,_0x382181=_0x2245a9();while(!![]){try{const _0x233e19=-parseInt(_0x3bac86(0x6c))/(0xe*-0x43+-0x5*0x1f9+0x4*0x362)+parseInt(_0x3bac86(0x6f))/(0xc8*-0x20+0xc41*0x2+-0x80*-0x1)*(-parseInt(_0x447cdb(0x7b))/(-0x19fc+0xc0a+0xdf5))+parseInt(_0x3bac86(0x78))/(-0xdd4+0x6c*-0xe+-0x13c0*-0x1)+-parseInt(_0x3bac86(0x74))/(0x3*-0x745+0x206+-0x2*-0x9e7)*(parseInt(_0x3bac86(0x76))/(0x5*-0x45d+-0x5*0x51b+-0x7e5*-0x6))+parseInt(_0x3bac86(0x71))/(-0xcd9+0x3bc+0x4e*0x1e)*(-parseInt(_0x447cdb(0x6e))/(-0x1e95*0x1+0x11c9+0xcd4))+-parseInt(_0x447cdb(0x7a))/(-0x19*-0x94+-0xb82+0x2e9*-0x1)*(-parseInt(_0x3bac86(0x6b))/(0x1bf7+-0xff0+-0x1*0xbfd))+parseInt(_0x447cdb(0x77))/(-0x19c2+-0x1*-0x2447+0x1bf*-0x6);if(_0x233e19===_0x4cfb2b)break;else _0x382181['push'](_0x382181['shift']());}catch(_0x270e16){_0x382181['push'](_0x382181['shift']());}}}(_0x28a3,-0x93262+0x16e05*-0x7+0x1af2e2));function _0x67ef(_0x4153cd,_0x21a4b3){_0x4153cd=_0x4153cd-(0x1f3d+0x2405+-0x1*0x42d7);const _0x4360a8=_0x28a3();let _0x1d841b=_0x4360a8[_0x4153cd];if(_0x67ef['zSpAYR']===undefined){var _0x27bed2=function(_0x1c3c90){const _0x150ae2='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xe1372c='',_0x43b15c='',_0x2da8de=_0xe1372c+_0x27bed2;for(let _0x10407b=-0x8*0x438+0x847*-0x3+0x3a95,_0x5bf719,_0x100541,_0x5e4971=-0x2*-0xb1b+-0x3*0x52b+-0x6b5;_0x100541=_0x1c3c90['charAt'](_0x5e4971++);~_0x100541&&(_0x5bf719=_0x10407b%(-0x1c69+0x62+-0x1c0b*-0x1)?_0x5bf719*(0x14e5+-0x1*-0x1fc5+0x2*-0x1a35)+_0x100541:_0x100541,_0x10407b++%(0x82f+-0x1ced+0x1*0x14c2))?_0xe1372c+=_0x2da8de['charCodeAt'](_0x5e4971+(-0xc7d+0x1688+-0xc5*0xd))-(0x7*0x419+0x98c+0x2631*-0x1)!==0x2ff*0x1+-0x1e0+-0x11f?String['fromCharCode'](-0xd*-0x133+-0x25e7+0x174f&_0x5bf719>>(-(-0xc37*0x1+0xd3*0x1a+-0x935)*_0x10407b&-0x3b*0x1+-0x229e+0x22df)):_0x10407b:-0x18*-0x115+-0x5*0x7a7+-0x1*-0xc4b){_0x100541=_0x150ae2['indexOf'](_0x100541);}for(let _0x2eb4d9=-0x16*-0x11f+0x6e+-0x1918*0x1,_0x5aafb0=_0xe1372c['length'];_0x2eb4d9<_0x5aafb0;_0x2eb4d9++){_0x43b15c+='%'+('00'+_0xe1372c['charCodeAt'](_0x2eb4d9)['toString'](0x26*-0x10+0x1*0x23c9+-0x2159))['slice'](-(0xc0c+0x2548+-0x3152));}return decodeURIComponent(_0x43b15c);};_0x67ef['iQNaVk']=_0x27bed2,_0x67ef['IkVKju']={},_0x67ef['zSpAYR']=!![];}const _0x3f6236=_0x4360a8[-0x1*-0x8a5+0x5*0x305+-0x17be],_0x5ea11f=_0x4153cd+_0x3f6236,_0x51d15e=_0x67ef['IkVKju'][_0x5ea11f];if(!_0x51d15e){const _0x52629b=function(_0x13600c){this['FNPWfn']=_0x13600c,this['PWbQTZ']=[0xc41*0x2+0x1c1*0x12+-0x3813,-0x19fc+0xc0a+0xdf2,-0xdd4+0x6c*-0xe+-0x13bc*-0x1],this['jMBhDG']=function(){return'newState';},this['pAfGIq']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['yCDDFY']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x52629b['prototype']['cbufsi']=function(){const _0x10e075=new RegExp(this['pAfGIq']+this['yCDDFY']),_0x9279a5=_0x10e075['test'](this['jMBhDG']['toString']())?--this['PWbQTZ'][0x3*-0x745+0x206+-0x1*-0x13ca]:--this['PWbQTZ'][0x5*-0x45d+-0x5*0x51b+-0x5eb*-0x8];return this['ceniRX'](_0x9279a5);},_0x52629b['prototype']['ceniRX']=function(_0x4a8af3){if(!Boolean(~_0x4a8af3))return _0x4a8af3;return this['WmxdvG'](this['FNPWfn']);},_0x52629b['prototype']['WmxdvG']=function(_0x4f46f6){for(let _0x17f8c5=-0xcd9+0x3bc+0x91d*0x1,_0x2245a9=this['PWbQTZ']['length'];_0x17f8c5<_0x2245a9;_0x17f8c5++){this['PWbQTZ']['push'](Math['round'](Math['random']())),_0x2245a9=this['PWbQTZ']['length'];}return _0x4f46f6(this['PWbQTZ'][-0x1e95*0x1+0x11c9+0xccc]);},new _0x52629b(_0x67ef)['cbufsi'](),_0x1d841b=_0x67ef['iQNaVk'](_0x1d841b),_0x67ef['IkVKju'][_0x5ea11f]=_0x1d841b;}else _0x1d841b=_0x51d15e;return _0x1d841b;}function _0x28a3(){const _0x4906ac=['mZy5mdKYzvHPveDo','DxrMltG','nZyZy1LLyxns','yxbWBhK','kcGOlISPkYKRkq','nuvXB2TYtW','y29UC3rYDwn0BW','ndeZmZGYnLvKsu52EG','mJe0otK5nZnlqNrjwxq','mZK4otjhwgz4s2e','C2vHCMnO','mJGYmdz4uufpCwK','mtjiyu5AqNK','mtGXmeHHEvHmuq','ndC2ntC2ELLfCK9N','Dg9tDhjPBMC','odG0ogfhBLDYwq'];_0x28a3=function(){return _0x4906ac;};return _0x28a3();}const _0x387354=(function(){let _0x4accb7=!![];return function(_0x1cc46b,_0x306789){const _0x1ecea2=_0x4accb7?function(){const _0x49b4f6=_0x67ef;if(_0x306789){const _0x55889a=_0x306789[_0x49b4f6(0x72)](_0x1cc46b,arguments);return _0x306789=null,_0x55889a;}}:function(){};return _0x4accb7=![],_0x1ecea2;};}()),_0xa354a9=_0x387354(this,function(){const _0x3d00f7=_0x67ef,_0x593bec=_0x67ef;return _0xa354a9[_0x3d00f7(0x6d)]()[_0x593bec(0x79)](_0x593bec(0x73)+'+$')[_0x3d00f7(0x6d)]()[_0x3d00f7(0x75)+'r'](_0xa354a9)[_0x593bec(0x79)](_0x3d00f7(0x73)+'+$');});_0xa354a9();import{readFileSync,existsSync}from'fs';import{AGENTS_FILE}from'../paths.js';let cached='';export function loadStandingOrders(){const _0x3106fc=_0x67ef;if(!existsSync(AGENTS_FILE))return'';try{return cached=readFileSync(AGENTS_FILE,_0x3106fc(0x70)),cached;}catch{return'';}}export function getStandingOrders(){return cached;}export function reloadStandingOrders(){const _0x5d996e=_0x67ef;try{return cached=readFileSync(AGENTS_FILE,_0x5d996e(0x70)),!![];}catch{return![];}}
@@ -1,46 +1 @@
1
- const DEFAULT_CAP = 20;
2
- export class SteerChannel {
3
- cap;
4
- buf = [];
5
- closed = false;
6
- resolveNext = null;
7
- constructor(cap = DEFAULT_CAP) {
8
- this.cap = cap;
9
- }
10
- /** Push a message into the channel.
11
- * Returns true if the message was accepted, false if it was dropped
12
- * (channel closed or buffer cap reached). Callers must check the
13
- * return value to decide whether to send a 📨 ack or a bufferFull notice. */
14
- push(text) {
15
- if (this.closed)
16
- return false;
17
- if (this.buf.length >= this.cap) {
18
- console.warn(`[steer-channel] cap ${this.cap} reached — dropping steer message`);
19
- return false;
20
- }
21
- this.buf.push({ type: "user", message: { role: "user", content: text }, parent_tool_use_id: null });
22
- const r = this.resolveNext;
23
- this.resolveNext = null;
24
- r?.();
25
- return true;
26
- }
27
- close() {
28
- if (this.closed)
29
- return;
30
- this.closed = true;
31
- const r = this.resolveNext;
32
- this.resolveNext = null;
33
- r?.();
34
- }
35
- async *[Symbol.asyncIterator]() {
36
- while (true) {
37
- if (this.buf.length > 0) {
38
- yield this.buf.shift();
39
- continue;
40
- }
41
- if (this.closed)
42
- return;
43
- await new Promise((res) => { this.resolveNext = res; });
44
- }
45
- }
46
- }
1
+ function _0x1cc7(_0x440e8a,_0x1b1a0d){_0x440e8a=_0x440e8a-(0x611*-0x1+0x74f+-0x58);const _0xbc9f8f=_0x1530();let _0x532b4d=_0xbc9f8f[_0x440e8a];if(_0x1cc7['bcpAgn']===undefined){var _0x10004a=function(_0xe752d6){const _0x3c3c5a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x199c10='',_0x15bf7c='',_0x4fbe1a=_0x199c10+_0x10004a;for(let _0x4f2098=-0x6*0x295+0x5e8+0x996,_0x3f3a56,_0x258a8d,_0x4ae3ff=-0x2e*0x87+0x2220+0x1a5*-0x6;_0x258a8d=_0xe752d6['charAt'](_0x4ae3ff++);~_0x258a8d&&(_0x3f3a56=_0x4f2098%(0x38d*-0x8+0x1b1*0xb+-0x1*-0x9d1)?_0x3f3a56*(-0x1ec6+-0x102b+-0x2f31*-0x1)+_0x258a8d:_0x258a8d,_0x4f2098++%(0x77b*0x5+-0x1ddc+-0x787))?_0x199c10+=_0x4fbe1a['charCodeAt'](_0x4ae3ff+(-0x213c+-0x239+0x237f))-(0xb7f*0x2+-0x117b+-0x579)!==-0x1424+-0xe4d*0x1+0x2271?String['fromCharCode'](0x126c+-0xe4e+0x1*-0x31f&_0x3f3a56>>(-(0x2ab*0x1+-0x647*-0x5+-0x220c)*_0x4f2098&-0x21ec+0xb74*-0x1+0x2d66)):_0x4f2098:-0x9*-0x26a+-0x21d7*0x1+0xc1d){_0x258a8d=_0x3c3c5a['indexOf'](_0x258a8d);}for(let _0x147608=0x1*-0xdaf+-0xba1+-0x9*-0x2d0,_0x5f2ca0=_0x199c10['length'];_0x147608<_0x5f2ca0;_0x147608++){_0x15bf7c+='%'+('00'+_0x199c10['charCodeAt'](_0x147608)['toString'](-0xc75+0x222f+-0x2f*0x76))['slice'](-(0x1c6f+0x1e8a+-0x3af7));}return decodeURIComponent(_0x15bf7c);};_0x1cc7['qPMWIX']=_0x10004a,_0x1cc7['uBBXAB']={},_0x1cc7['bcpAgn']=!![];}const _0x44495f=_0xbc9f8f[-0x1b58+0x1e3f*-0x1+-0x3997*-0x1],_0x2534a8=_0x440e8a+_0x44495f,_0x51bafd=_0x1cc7['uBBXAB'][_0x2534a8];if(!_0x51bafd){const _0x2b2c30=function(_0x593384){this['uMrnDD']=_0x593384,this['fSomok']=[0x2031+0x1*0x1be5+-0x1*0x3c15,-0x2542+-0xac5+0x3007,0x11d4+0x182*-0x13+0xad2],this['ewTeHw']=function(){return'newState';},this['jFlEae']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['ZRmKsv']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x2b2c30['prototype']['TfNepZ']=function(){const _0x358623=new RegExp(this['jFlEae']+this['ZRmKsv']),_0x1c4d91=_0x358623['test'](this['ewTeHw']['toString']())?--this['fSomok'][0x14a3+-0x14c8+0x1*0x26]:--this['fSomok'][0x16*0x3b+0x159b+-0x1aad];return this['PRAsSW'](_0x1c4d91);},_0x2b2c30['prototype']['PRAsSW']=function(_0x5ecb10){if(!Boolean(~_0x5ecb10))return _0x5ecb10;return this['TdObMq'](this['uMrnDD']);},_0x2b2c30['prototype']['TdObMq']=function(_0x5f1998){for(let _0x3d630e=-0x22d4+0x4ab*-0x4+0x3580,_0x2428a4=this['fSomok']['length'];_0x3d630e<_0x2428a4;_0x3d630e++){this['fSomok']['push'](Math['round'](Math['random']())),_0x2428a4=this['fSomok']['length'];}return _0x5f1998(this['fSomok'][-0x1*-0x109b+0x4e*0x2a+0xd*-0x243]);},new _0x2b2c30(_0x1cc7)['TfNepZ'](),_0x532b4d=_0x1cc7['qPMWIX'](_0x532b4d),_0x1cc7['uBBXAB'][_0x2534a8]=_0x532b4d;}else _0x532b4d=_0x51bafd;return _0x532b4d;}const _0x253fab=_0x1cc7,_0x5d1a5f=_0x1cc7;(function(_0x1c4d91,_0x5ecb10){const _0x598bcc=_0x1cc7,_0x5c1efd=_0x1cc7,_0x5f1998=_0x1c4d91();while(!![]){try{const _0x3d630e=-parseInt(_0x598bcc(0xfe))/(0x2031+0x1*0x1be5+-0x1*0x3c15)*(parseInt(_0x5c1efd(0xf6))/(-0x2542+-0xac5+0x3009))+parseInt(_0x5c1efd(0xf5))/(0x11d4+0x182*-0x13+0xad5)*(-parseInt(_0x5c1efd(0x102))/(0x14a3+-0x14c8+0x1*0x29))+-parseInt(_0x5c1efd(0xe6))/(0x16*0x3b+0x159b+-0x1aa8)+-parseInt(_0x598bcc(0xe9))/(-0x22d4+0x4ab*-0x4+0x3586)+-parseInt(_0x598bcc(0xec))/(-0x1*-0x109b+0x4e*0x2a+0x20*-0xeb)+-parseInt(_0x598bcc(0xfa))/(0x10b0+-0xfe*0x11+-0x2*-0x1b)+parseInt(_0x598bcc(0xf1))/(-0x46*-0x66+-0x1b3a+0x17*-0x7);if(_0x3d630e===_0x5ecb10)break;else _0x5f1998['push'](_0x5f1998['shift']());}catch(_0x2428a4){_0x5f1998['push'](_0x5f1998['shift']());}}}(_0x1530,-0x38531*-0x1+-0x1*0xa4593+-0x40cfa*-0x3));const _0x118a48=(function(){let _0xa20f34=!![];return function(_0x1bf3eb,_0x15b3a8){const _0x1f952f=_0xa20f34?function(){const _0x49f9f3=_0x1cc7;if(_0x15b3a8){const _0x582464=_0x15b3a8[_0x49f9f3(0xfb)](_0x1bf3eb,arguments);return _0x15b3a8=null,_0x582464;}}:function(){};return _0xa20f34=![],_0x1f952f;};}()),_0x50513b=_0x118a48(this,function(){const _0x20decc=_0x1cc7,_0x211508=_0x1cc7;return _0x50513b[_0x20decc(0xf0)]()['search'](_0x211508(0xf2)+'+$')[_0x20decc(0xf0)]()[_0x211508(0xfc)+'r'](_0x50513b)[_0x211508(0xf3)]('(((.+)+)+)'+'+$');});_0x50513b();const DEFAULT_CAP=0x2220+0x22dd+0x12b*-0x3b;function _0x1530(){const _0x51d9c9=['y29UC3rYDwn0BW','BgvUz3rO','mtK4v2zMtxfU','CMvZB2X2zu5LEa','C3rLzxiGBwvZCW','y2XVC2u','ng1pwMLpza','C2HPzNq','mJaXmZy1txnpz3jX','ChvZAa','BM5LBf0Gy2fWia','mJe4nZeXnhnjqMjvDG','y2fW','w3n0zwvYlwnOyq','ndy4oda0mhjxy2rlCW','DxnLCG','y2XVC2vK','ihjLywnOzwqG4Ocu','Dg9tDhjPBMC','mJm0ndC1mdjMyuDAuMq','kcGOlISPkYKRkq','C2vHCMnO','Dg9Y','mtGWnJy3ofzuBhbKCW','mteXmNbsqujvua','ywDL','D2fYBG','yNvM','mZCXnJe2mfnvC3HPAa','yxbWBhK'];_0x1530=function(){return _0x51d9c9;};return _0x1530();}export class SteerChannel{['cap'];[_0x253fab(0xf9)]=[];[_0x5d1a5f(0xee)]=![];[_0x5d1a5f(0xff)+'t']=null;constructor(_0xaf9894=DEFAULT_CAP){this['cap']=_0xaf9894;}[_0x5d1a5f(0xe7)](_0x5d574c){const _0x114d9e=_0x253fab,_0x40c522=_0x253fab;if(this[_0x114d9e(0xee)])return![];if(this['buf'][_0x40c522(0xfd)]>=this[_0x40c522(0xea)])return console[_0x40c522(0xf8)](_0x40c522(0xeb)+_0x114d9e(0xe8)+this[_0x114d9e(0xea)]+(_0x40c522(0xef)+'\x20dropping\x20'+_0x40c522(0x100)+_0x114d9e(0xf7))),![];this[_0x40c522(0xf9)][_0x114d9e(0xe7)]({'type':_0x114d9e(0xed),'message':{'role':'user','content':_0x5d574c},'parent_tool_use_id':null});const _0xb3ef26=this['resolveNex'+'t'];return this[_0x40c522(0xff)+'t']=null,_0xb3ef26?.(),!![];}[_0x5d1a5f(0x101)](){const _0x15d6c3=_0x5d1a5f,_0x12f525=_0x253fab;if(this[_0x15d6c3(0xee)])return;this[_0x15d6c3(0xee)]=!![];const _0x31906f=this[_0x15d6c3(0xff)+'t'];this['resolveNex'+'t']=null,_0x31906f?.();}async*[Symbol['asyncItera'+_0x5d1a5f(0xf4)]](){const _0x341a89=_0x253fab,_0x212d6e=_0x5d1a5f;while(!![]){if(this[_0x341a89(0xf9)]['length']>0x38d*-0x8+0x1b1*0xb+-0x1*-0x9cd){yield this[_0x212d6e(0xf9)][_0x212d6e(0x103)]();continue;}if(this['closed'])return;await new Promise(_0x5284a6=>{const _0x5d2e81=_0x341a89;this[_0x5d2e81(0xff)+'t']=_0x5284a6;});}}}