@poolzin/pool-bot 2026.3.6 → 2026.3.9

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 (68) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/.buildstamp +1 -1
  3. package/dist/agents/error-classifier.js +302 -0
  4. package/dist/agents/pi-tools.js +32 -2
  5. package/dist/agents/skills/security.js +217 -0
  6. package/dist/auto-reply/reply/get-reply.js +6 -0
  7. package/dist/auto-reply/reply/message-preprocess-hooks.js +17 -0
  8. package/dist/build-info.json +3 -3
  9. package/dist/cli/banner.js +20 -1
  10. package/dist/cli/lazy-commands.example.js +113 -0
  11. package/dist/cli/lazy-commands.js +329 -0
  12. package/dist/cli/program/command-registry.js +13 -0
  13. package/dist/cli/program/register.skills.js +4 -0
  14. package/dist/cli/security-cli.js +211 -2
  15. package/dist/cli/tagline.js +7 -0
  16. package/dist/config/config.js +1 -0
  17. package/dist/config/secrets-integration.js +88 -0
  18. package/dist/config/types.cli.js +1 -0
  19. package/dist/config/types.security.js +33 -0
  20. package/dist/config/zod-schema.js +15 -0
  21. package/dist/config/zod-schema.providers-core.js +1 -0
  22. package/dist/config/zod-schema.security.js +113 -0
  23. package/dist/context-engine/index.js +33 -0
  24. package/dist/context-engine/legacy.js +181 -0
  25. package/dist/context-engine/registry.js +86 -0
  26. package/dist/context-engine/summarizing.js +293 -0
  27. package/dist/context-engine/types.js +7 -0
  28. package/dist/discord/monitor/message-handler.preflight.js +11 -2
  29. package/dist/gateway/http-common.js +6 -1
  30. package/dist/hooks/fire-and-forget.js +6 -0
  31. package/dist/hooks/internal-hooks.js +64 -19
  32. package/dist/hooks/message-hook-mappers.js +179 -0
  33. package/dist/infra/abort-pattern.js +106 -0
  34. package/dist/infra/retry.js +94 -0
  35. package/dist/secrets/index.js +28 -0
  36. package/dist/secrets/resolver.js +185 -0
  37. package/dist/secrets/runtime.js +142 -0
  38. package/dist/secrets/types.js +11 -0
  39. package/dist/security/capability-guards.js +89 -0
  40. package/dist/security/capability-manager.js +76 -0
  41. package/dist/security/capability.js +147 -0
  42. package/dist/security/dangerous-tools.js +80 -0
  43. package/dist/security/index.js +7 -0
  44. package/dist/security/middleware.js +105 -0
  45. package/dist/security/types.js +12 -0
  46. package/dist/skills/commands.js +351 -0
  47. package/dist/skills/index.js +167 -0
  48. package/dist/skills/loader.js +282 -0
  49. package/dist/skills/parser.js +461 -0
  50. package/dist/skills/registry.js +397 -0
  51. package/dist/skills/security.js +318 -0
  52. package/dist/skills/types.js +21 -0
  53. package/dist/slack/monitor/context.js +1 -0
  54. package/dist/slack/monitor/message-handler/dispatch.js +14 -1
  55. package/dist/slack/monitor/provider.js +2 -0
  56. package/dist/test-utils/index.js +219 -0
  57. package/dist/tui/index.js +595 -0
  58. package/docs/INTEGRATION_PLAN.md +475 -0
  59. package/docs/INTEGRATION_SUMMARY.md +215 -0
  60. package/docs/integrations/HEXSTRIKE_PLAN.md +796 -0
  61. package/docs/integrations/INTEGRATION_PLAN.md +424 -0
  62. package/docs/integrations/PAGE_AGENT_PLAN.md +370 -0
  63. package/docs/integrations/XYOPS_PLAN.md +978 -0
  64. package/docs/skills/IMPLEMENTATION_SUMMARY.md +145 -0
  65. package/docs/skills/SKILL.md +524 -0
  66. package/docs/skills.md +405 -0
  67. package/package.json +1 -1
  68. package/skills/example-skill/SKILL.md +195 -0
@@ -0,0 +1,424 @@
1
+ # PoolBot Integration Architecture Plan
2
+
3
+ ## Executive Summary
4
+
5
+ This document outlines the integration strategy for three external projects into PoolBot to create a "complete and independent" AI agent platform:
6
+
7
+ 1. **Page Agent** (Alibaba) - GUI browser automation via text-based DOM manipulation
8
+ 2. **HexStrike AI** - MCP-based cybersecurity platform with 150+ security tools
9
+ 3. **xyOps** - Job scheduling, workflow automation, and monitoring platform
10
+
11
+ ## Current PoolBot Architecture Analysis
12
+
13
+ ### Existing Systems
14
+
15
+ | System | Location | Capabilities | Integration Point |
16
+ |--------|----------|--------------|-------------------|
17
+ | **Skills System** | `src/skills/` | Modular skill loading, progressive disclosure, security scanning | New skill type: `external-service` |
18
+ | **Plugin System** | `src/plugins/` | Tools, hooks, HTTP handlers, CLI commands, gateway methods | Plugin adapters for external services |
19
+ | **Browser Automation** | `src/browser/` | Playwright-based browser control, Chrome extension relay, agent routes | Extend with Page Agent's text-based DOM approach |
20
+ | **Node Registry** | `src/gateway/node-registry.ts` | Distributed node management, command invocation | External services as "virtual nodes" |
21
+ | **Gateway Methods** | `src/gateway/server-methods/` | RPC-style API endpoints | New methods for external service proxy |
22
+ | **Agent Tools** | `src/agents/tools/` | LLM-callable tools | Auto-generated tools from external services |
23
+ | **Context Engine** | `src/context-engine/` | Legacy + Summarizing implementations | No changes needed |
24
+ | **Memory/Embeddings** | `src/memory/` | Sophisticated embedding system | No changes needed |
25
+
26
+ ### Key Integration Patterns
27
+
28
+ ```typescript
29
+ // Pattern 1: External Service as Virtual Node
30
+ interface ExternalServiceNode {
31
+ nodeId: string; // e.g., "page-agent", "hexstrike-ai"
32
+ serviceType: string; // "browser", "security", "workflow"
33
+ commands: string[]; // Available commands
34
+ caps: string[]; // Capabilities
35
+ connection: ServiceConnection;
36
+ }
37
+
38
+ // Pattern 2: Gateway Method Proxy
39
+ interface ServiceProxyHandler {
40
+ method: string; // e.g., "pageagent.navigate"
41
+ handler: GatewayRequestHandler;
42
+ serviceConfig: ServiceConfig;
43
+ }
44
+
45
+ // Pattern 3: Auto-Generated Agent Tools
46
+ type ServiceToolGenerator = (
47
+ serviceSchema: ServiceSchema
48
+ ) => AnyAgentTool[];
49
+
50
+ // Pattern 4: Plugin Adapter
51
+ interface ExternalServicePlugin {
52
+ id: string;
53
+ serviceType: string;
54
+ register: (api: PoolBotPluginApi) => void;
55
+ activate: (api: PoolBotPluginApi) => Promise<void>;
56
+ }
57
+ ```
58
+
59
+ ## Integration Architecture
60
+
61
+ ### 1. Page Agent Integration (Browser Enhancement)
62
+
63
+ **Rationale**: Page Agent's text-based DOM manipulation complements PoolBot's existing screenshot-based browser automation. It provides:
64
+ - Lower latency (no image encoding/decoding)
65
+ - Better for structured data extraction
66
+ - Multi-page task support via Chrome extension
67
+
68
+ **Integration Approach**: **Browser Route Extension**
69
+
70
+ ```
71
+ ┌─────────────────────────────────────────────────────────────┐
72
+ │ PoolBot Browser System │
73
+ ├─────────────────────────────────────────────────────────────┤
74
+ │ Existing Routes │ New Page Agent Routes │
75
+ │ ───────────────── │ ───────────────────── │
76
+ │ GET /tabs │ POST /pageagent/navigate │
77
+ │ POST /tabs/open │ POST /pageagent/act │
78
+ │ POST /agent/snapshot│ POST /pageagent/extract │
79
+ │ POST /agent/act │ POST /pageagent/scroll │
80
+ │ ... │ WebSocket /pageagent/session │
81
+ └─────────────────────────────────────────────────────────────┘
82
+
83
+
84
+ ┌─────────────────┐
85
+ │ Page Agent Core │
86
+ │ (@page-agent/*) │
87
+ └─────────────────┘
88
+ ```
89
+
90
+ **Implementation**:
91
+ - New file: `src/browser/routes/page-agent.ts`
92
+ - Extends existing browser route dispatcher
93
+ - Uses Page Agent's npm packages: `@page-agent/core`, `@page-agent/page-controller`
94
+ - Adds new agent contract methods for text-based interaction
95
+
96
+ **Agent Tools Generated**:
97
+ ```typescript
98
+ {
99
+ name: "browser_navigate_text",
100
+ description: "Navigate to URL using text-based DOM approach",
101
+ parameters: { url: string, waitFor?: string }
102
+ }
103
+ {
104
+ name: "browser_extract_data",
105
+ description: "Extract structured data from page using selectors",
106
+ parameters: { selectors: Record<string, string> }
107
+ }
108
+ {
109
+ name: "browser_multi_page_task",
110
+ description: "Execute task across multiple pages",
111
+ parameters: { steps: Array<{action: string, target: string}> }
112
+ }
113
+ ```
114
+
115
+ ### 2. HexStrike AI Integration (Security Platform)
116
+
117
+ **Rationale**: HexStrike provides 150+ security tools and 12+ AI agents. Integration adds:
118
+ - Penetration testing capabilities
119
+ - CTF solving
120
+ - Bug bounty automation
121
+ - CVE intelligence
122
+ - Compliance scanning
123
+
124
+ **Integration Approach**: **MCP Client + Virtual Node**
125
+
126
+ ```
127
+ ┌─────────────────────────────────────────────────────────────┐
128
+ │ PoolBot Gateway System │
129
+ ├─────────────────────────────────────────────────────────────┤
130
+ │ │
131
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
132
+ │ │ Node Registry│◄───│ HexStrike │ │ Other Nodes │ │
133
+ │ │ │ │ MCP Client │ │ │ │
134
+ │ └───────┬───────┘ └──────────────┘ └──────────────┘ │
135
+ │ │ │
136
+ │ ▼ │
137
+ │ ┌──────────────┐ │
138
+ │ │ Gateway Methods │
139
+ │ │ ───────────── │
140
+ │ │ hexstrike.scan │
141
+ │ │ hexstrike.exploit │
142
+ │ │ hexstrike.ctf.solve │
143
+ │ │ hexstrike.cve.lookup │
144
+ │ └──────────────┘ │
145
+ │ │
146
+ └─────────────────────────────────────────────────────────────┘
147
+
148
+ │ HTTP/MCP
149
+
150
+ ┌─────────────────┐
151
+ │ HexStrike AI │
152
+ │ Flask API:8888 │
153
+ │ FastMCP Server │
154
+ └─────────────────┘
155
+ ```
156
+
157
+ **Implementation**:
158
+ - New file: `src/gateway/server-methods/hexstrike.ts`
159
+ - MCP client wrapper: `src/integrations/mcp/client.ts`
160
+ - Service discovery from HexStrike's OpenAPI spec
161
+ - Python process management (HexStrike requires Python backend)
162
+
163
+ **Agent Tools Generated** (sample from 150+ tools):
164
+ ```typescript
165
+ {
166
+ name: "security_scan_port",
167
+ description: "Scan ports using nmap",
168
+ parameters: { target: string, ports?: string }
169
+ }
170
+ {
171
+ name: "security_scan_vulnerability",
172
+ description: "Run vulnerability scan using nuclei",
173
+ parameters: { target: string, templates?: string[] }
174
+ }
175
+ {
176
+ name: "security_test_sql_injection",
177
+ description: "Test for SQL injection using sqlmap",
178
+ parameters: { url: string, parameters?: string[] }
179
+ }
180
+ {
181
+ name: "security_solve_ctf",
182
+ description: "Solve CTF challenge using AI agent",
183
+ parameters: { challenge_type: string, description: string }
184
+ }
185
+ ```
186
+
187
+ ### 3. xyOps Integration (Workflow Automation)
188
+
189
+ **Rationale**: xyOps adds job scheduling, workflow automation, and monitoring. Integration provides:
190
+ - Scheduled agent tasks
191
+ - Visual workflow editor
192
+ - Incident response automation
193
+ - Server monitoring integration
194
+
195
+ **Integration Approach**: **Plugin + Gateway Methods**
196
+
197
+ ```
198
+ ┌─────────────────────────────────────────────────────────────┐
199
+ │ PoolBot Workflow System │
200
+ ├─────────────────────────────────────────────────────────────┤
201
+ │ │
202
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
203
+ │ │ Cron System │◄───│ xyOps │───►│ Job Queue │ │
204
+ │ │ │ │ Integration │ │ │ │
205
+ │ └──────────────┘ └──────────────┘ └──────────────┘ │
206
+ │ │ │
207
+ │ ▼ │
208
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
209
+ │ │ Workflow │ │ xyOps API │ │ Monitoring │ │
210
+ │ │ Definitions │◄───│ Client │───►│ Alerts │ │
211
+ │ └──────────────┘ └──────────────┘ └──────────────┘ │
212
+ │ │
213
+ └─────────────────────────────────────────────────────────────┘
214
+
215
+ │ HTTP/WebSocket
216
+
217
+ ┌─────────────────┐
218
+ │ xyOps Server │
219
+ │ Node.js API │
220
+ │ MongoDB/Redis │
221
+ └─────────────────┘
222
+ ```
223
+
224
+ **Implementation**:
225
+ - New plugin: `extensions/xyops/` or `src/integrations/xyops/`
226
+ - Gateway methods: `src/gateway/server-methods/xyops.ts`
227
+ - Workflow definition format compatible with xyOps
228
+ - Bidirectional event streaming
229
+
230
+ **Agent Tools Generated**:
231
+ ```typescript
232
+ {
233
+ name: "workflow_create",
234
+ description: "Create automated workflow",
235
+ parameters: { name: string, triggers: Trigger[], actions: Action[] }
236
+ }
237
+ {
238
+ name: "workflow_schedule",
239
+ description: "Schedule recurring agent task",
240
+ parameters: { cron: string, prompt: string, agentId?: string }
241
+ }
242
+ {
243
+ name: "workflow_monitor",
244
+ description: "Monitor system and alert on conditions",
245
+ parameters: { metric: string, threshold: number, alertChannel: string }
246
+ }
247
+ {
248
+ name: "workflow_incident_response",
249
+ description: "Execute incident response playbook",
250
+ parameters: { incident_type: string, severity: string }
251
+ }
252
+ ```
253
+
254
+ ## Unified Integration Layer
255
+
256
+ ### New Core Module: `src/integrations/`
257
+
258
+ ```
259
+ src/integrations/
260
+ ├── common/
261
+ │ ├── types.ts # Shared integration types
262
+ │ ├── service-registry.ts # External service registry
263
+ │ ├── connection-manager.ts # Connection lifecycle management
264
+ │ └── tool-generator.ts # Auto-generate agent tools from schemas
265
+ ├── page-agent/
266
+ │ ├── index.ts
267
+ │ ├── routes.ts
268
+ │ ├── client.ts
269
+ │ └── tools.ts
270
+ ├── hexstrike/
271
+ │ ├── index.ts
272
+ │ ├── mcp-client.ts
273
+ │ ├── gateway-methods.ts
274
+ │ ├── tool-adapter.ts
275
+ │ └── process-manager.ts # Python process management
276
+ ├── xyops/
277
+ │ ├── index.ts
278
+ │ ├── client.ts
279
+ │ ├── gateway-methods.ts
280
+ │ ├── workflow-sync.ts
281
+ │ └── plugin.ts
282
+ └── index.ts
283
+ ```
284
+
285
+ ### Service Registry
286
+
287
+ ```typescript
288
+ // src/integrations/common/service-registry.ts
289
+ interface ExternalService {
290
+ id: string;
291
+ name: string;
292
+ type: 'browser' | 'security' | 'workflow' | 'custom';
293
+ status: 'disconnected' | 'connecting' | 'connected' | 'error';
294
+ capabilities: string[];
295
+ tools: AnyAgentTool[];
296
+ gatewayMethods: string[];
297
+ config: ServiceConfig;
298
+ }
299
+
300
+ class IntegrationServiceRegistry extends EventEmitter {
301
+ register(service: ExternalService): void;
302
+ unregister(serviceId: string): void;
303
+ get(serviceId: string): ExternalService | undefined;
304
+ listByType(type: string): ExternalService[];
305
+ getAllTools(): AnyAgentTool[];
306
+ }
307
+ ```
308
+
309
+ ### Configuration Schema
310
+
311
+ ```yaml
312
+ # poolbot.yaml additions
313
+ integrations:
314
+ page-agent:
315
+ enabled: true
316
+ mode: "embedded" # or "external" for standalone
317
+ chromeExtension: true
318
+ defaultProfile: "default"
319
+
320
+ hexstrike:
321
+ enabled: true
322
+ mode: "managed" # PoolBot manages Python process
323
+ # mode: "external" # Connect to existing instance
324
+ apiUrl: "http://localhost:8888"
325
+ mcpEndpoint: "/mcp"
326
+ tools:
327
+ allowlist: [] # empty = all allowed
328
+ denylist: [] # blocked tools
329
+
330
+ xyops:
331
+ enabled: true
332
+ apiUrl: "http://localhost:3000"
333
+ wsUrl: "ws://localhost:3000/ws"
334
+ syncWorkflows: true
335
+ bidirectionalEvents: true
336
+ ```
337
+
338
+ ## Implementation Phases
339
+
340
+ ### Phase 1: Foundation (Week 1)
341
+ - [ ] Create `src/integrations/` module structure
342
+ - [ ] Implement `IntegrationServiceRegistry`
343
+ - [ ] Add configuration schema and validation
344
+ - [ ] Create common connection manager
345
+ - [ ] Add integration status to `poolbot status`
346
+
347
+ ### Phase 2: Page Agent Integration (Week 2)
348
+ - [ ] Install Page Agent npm packages
349
+ - [ ] Create browser route extensions
350
+ - [ ] Implement text-based DOM agent tools
351
+ - [ ] Add Chrome extension relay integration
352
+ - [ ] Tests and documentation
353
+
354
+ ### Phase 3: HexStrike Integration (Week 3-4)
355
+ - [ ] Implement MCP client wrapper
356
+ - [ ] Create Python process manager
357
+ - [ ] Auto-generate tools from HexStrike schema
358
+ - [ ] Add security-specific gateway methods
359
+ - [ ] Implement tool allowlist/denylist
360
+ - [ ] Tests and documentation
361
+
362
+ ### Phase 4: xyOps Integration (Week 5)
363
+ - [ ] Create xyOps API client
364
+ - [ ] Implement workflow sync
365
+ - [ ] Add bidirectional event streaming
366
+ - [ ] Create workflow agent tools
367
+ - [ ] Tests and documentation
368
+
369
+ ### Phase 5: Polish (Week 6)
370
+ - [ ] Unified CLI commands: `poolbot integrations`
371
+ - [ ] Status dashboard for all integrations
372
+ - [ ] Documentation and examples
373
+ - [ ] Performance optimization
374
+ - [ ] Final testing
375
+
376
+ ## Security Considerations
377
+
378
+ ### Sandboxing
379
+ - HexStrike tools run in isolated Python subprocess
380
+ - Network access restricted to configured endpoints
381
+ - File system access limited to temp directories
382
+
383
+ ### Tool Permissions
384
+ ```typescript
385
+ interface ToolPermissionPolicy {
386
+ service: string;
387
+ toolPattern: string; // glob pattern
388
+ allowed: boolean;
389
+ requireApproval: boolean;
390
+ rateLimit?: number;
391
+ }
392
+ ```
393
+
394
+ ### Audit Logging
395
+ - All external service calls logged
396
+ - Tool invocations tracked with session correlation
397
+ - Security tool results encrypted at rest
398
+
399
+ ## Benefits
400
+
401
+ 1. **Completeness**: PoolBot becomes a full-stack AI agent platform
402
+ 2. **Independence**: Self-hosted, no external API dependencies
403
+ 3. **Extensibility**: New integrations follow established patterns
404
+ 4. **Maintainability**: Clean separation of concerns
405
+ 5. **Performance**: Local execution where possible
406
+
407
+ ## Risk Mitigation
408
+
409
+ | Risk | Mitigation |
410
+ |------|------------|
411
+ | Python dependency for HexStrike | Optional integration, clear error messages |
412
+ | Security tool misuse | Tool allowlist, approval workflows, audit logging |
413
+ | Performance overhead | Lazy loading, connection pooling, caching |
414
+ | Maintenance burden | Clean interfaces, automated tests, documentation |
415
+
416
+ ## Conclusion
417
+
418
+ This integration architecture leverages PoolBot's existing plugin system, gateway methods, and node registry to seamlessly incorporate external capabilities. The modular design ensures each integration is optional, well-isolated, and follows established patterns.
419
+
420
+ The result is a "complete and independent" AI agent platform that can:
421
+ - Browse and interact with web pages (Page Agent)
422
+ - Perform security assessments (HexStrike)
423
+ - Automate workflows and schedules (xyOps)
424
+ - All while maintaining PoolBot's core philosophy of local-first, privacy-respecting AI