@jungjaehoon/mama-os 0.1.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.
- package/CHANGELOG.md +67 -0
- package/README.md +643 -0
- package/dist/agent/agent-loop.d.ts +98 -0
- package/dist/agent/agent-loop.d.ts.map +1 -0
- package/dist/agent/agent-loop.js +417 -0
- package/dist/agent/agent-loop.js.map +1 -0
- package/dist/agent/auto-recall.d.ts +48 -0
- package/dist/agent/auto-recall.d.ts.map +1 -0
- package/dist/agent/auto-recall.js +178 -0
- package/dist/agent/auto-recall.js.map +1 -0
- package/dist/agent/claude-cli-wrapper.d.ts +130 -0
- package/dist/agent/claude-cli-wrapper.d.ts.map +1 -0
- package/dist/agent/claude-cli-wrapper.js +227 -0
- package/dist/agent/claude-cli-wrapper.js.map +1 -0
- package/dist/agent/claude-client.d.ts +50 -0
- package/dist/agent/claude-client.d.ts.map +1 -0
- package/dist/agent/claude-client.js +214 -0
- package/dist/agent/claude-client.js.map +1 -0
- package/dist/agent/gateway-tool-executor.d.ts +75 -0
- package/dist/agent/gateway-tool-executor.d.ts.map +1 -0
- package/dist/agent/gateway-tool-executor.js +348 -0
- package/dist/agent/gateway-tool-executor.js.map +1 -0
- package/dist/agent/index.d.ts +13 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +18 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/mcp-executor.d.ts +75 -0
- package/dist/agent/mcp-executor.d.ts.map +1 -0
- package/dist/agent/mcp-executor.js +307 -0
- package/dist/agent/mcp-executor.js.map +1 -0
- package/dist/agent/session-pool.d.ts +148 -0
- package/dist/agent/session-pool.d.ts.map +1 -0
- package/dist/agent/session-pool.js +272 -0
- package/dist/agent/session-pool.js.map +1 -0
- package/dist/agent/streaming-callback-manager.d.ts +85 -0
- package/dist/agent/streaming-callback-manager.d.ts.map +1 -0
- package/dist/agent/streaming-callback-manager.js +103 -0
- package/dist/agent/streaming-callback-manager.js.map +1 -0
- package/dist/agent/types.d.ts +437 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +29 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/api/cron-handler.d.ts +44 -0
- package/dist/api/cron-handler.d.ts.map +1 -0
- package/dist/api/cron-handler.js +195 -0
- package/dist/api/cron-handler.js.map +1 -0
- package/dist/api/error-handler.d.ts +22 -0
- package/dist/api/error-handler.d.ts.map +1 -0
- package/dist/api/error-handler.js +104 -0
- package/dist/api/error-handler.js.map +1 -0
- package/dist/api/heartbeat-handler.d.ts +49 -0
- package/dist/api/heartbeat-handler.d.ts.map +1 -0
- package/dist/api/heartbeat-handler.js +91 -0
- package/dist/api/heartbeat-handler.js.map +1 -0
- package/dist/api/index.d.ts +61 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +145 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/types.d.ts +156 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +62 -0
- package/dist/api/types.js.map +1 -0
- package/dist/auth/index.d.ts +7 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +11 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/oauth-manager.d.ts +59 -0
- package/dist/auth/oauth-manager.d.ts.map +1 -0
- package/dist/auth/oauth-manager.js +237 -0
- package/dist/auth/oauth-manager.js.map +1 -0
- package/dist/auth/types.d.ts +92 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +23 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/cli/commands/init.d.ts +19 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +155 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/run.d.ts +19 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +89 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/setup.d.ts +19 -0
- package/dist/cli/commands/setup.d.ts.map +1 -0
- package/dist/cli/commands/setup.js +134 -0
- package/dist/cli/commands/setup.js.map +1 -0
- package/dist/cli/commands/start.d.ts +24 -0
- package/dist/cli/commands/start.d.ts.map +1 -0
- package/dist/cli/commands/start.js +1073 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/commands/status.d.ts +10 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +85 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/stop.d.ts +10 -0
- package/dist/cli/commands/stop.d.ts.map +1 -0
- package/dist/cli/commands/stop.js +65 -0
- package/dist/cli/commands/stop.js.map +1 -0
- package/dist/cli/config/config-manager.d.ts +51 -0
- package/dist/cli/config/config-manager.d.ts.map +1 -0
- package/dist/cli/config/config-manager.js +216 -0
- package/dist/cli/config/config-manager.js.map +1 -0
- package/dist/cli/config/types.d.ts +172 -0
- package/dist/cli/config/types.d.ts.map +1 -0
- package/dist/cli/config/types.js +48 -0
- package/dist/cli/config/types.js.map +1 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +92 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/utils/pid-manager.d.ts +66 -0
- package/dist/cli/utils/pid-manager.d.ts.map +1 -0
- package/dist/cli/utils/pid-manager.js +167 -0
- package/dist/cli/utils/pid-manager.js.map +1 -0
- package/dist/concurrency/index.d.ts +13 -0
- package/dist/concurrency/index.d.ts.map +1 -0
- package/dist/concurrency/index.js +22 -0
- package/dist/concurrency/index.js.map +1 -0
- package/dist/concurrency/lane-manager.d.ts +113 -0
- package/dist/concurrency/lane-manager.d.ts.map +1 -0
- package/dist/concurrency/lane-manager.js +245 -0
- package/dist/concurrency/lane-manager.js.map +1 -0
- package/dist/concurrency/session-key.d.ts +41 -0
- package/dist/concurrency/session-key.d.ts.map +1 -0
- package/dist/concurrency/session-key.js +61 -0
- package/dist/concurrency/session-key.js.map +1 -0
- package/dist/concurrency/types.d.ts +69 -0
- package/dist/concurrency/types.d.ts.map +1 -0
- package/dist/concurrency/types.js +16 -0
- package/dist/concurrency/types.js.map +1 -0
- package/dist/gateways/channel-history.d.ts +102 -0
- package/dist/gateways/channel-history.d.ts.map +1 -0
- package/dist/gateways/channel-history.js +181 -0
- package/dist/gateways/channel-history.js.map +1 -0
- package/dist/gateways/context-injector.d.ts +74 -0
- package/dist/gateways/context-injector.d.ts.map +1 -0
- package/dist/gateways/context-injector.js +121 -0
- package/dist/gateways/context-injector.js.map +1 -0
- package/dist/gateways/discord.d.ts +122 -0
- package/dist/gateways/discord.d.ts.map +1 -0
- package/dist/gateways/discord.js +602 -0
- package/dist/gateways/discord.js.map +1 -0
- package/dist/gateways/index.d.ts +30 -0
- package/dist/gateways/index.d.ts.map +1 -0
- package/dist/gateways/index.js +49 -0
- package/dist/gateways/index.js.map +1 -0
- package/dist/gateways/message-router.d.ts +116 -0
- package/dist/gateways/message-router.d.ts.map +1 -0
- package/dist/gateways/message-router.js +315 -0
- package/dist/gateways/message-router.js.map +1 -0
- package/dist/gateways/message-splitter.d.ts +54 -0
- package/dist/gateways/message-splitter.d.ts.map +1 -0
- package/dist/gateways/message-splitter.js +146 -0
- package/dist/gateways/message-splitter.js.map +1 -0
- package/dist/gateways/plugin-loader.d.ts +76 -0
- package/dist/gateways/plugin-loader.d.ts.map +1 -0
- package/dist/gateways/plugin-loader.js +221 -0
- package/dist/gateways/plugin-loader.js.map +1 -0
- package/dist/gateways/session-store.d.ts +77 -0
- package/dist/gateways/session-store.d.ts.map +1 -0
- package/dist/gateways/session-store.js +233 -0
- package/dist/gateways/session-store.js.map +1 -0
- package/dist/gateways/slack.d.ts +90 -0
- package/dist/gateways/slack.d.ts.map +1 -0
- package/dist/gateways/slack.js +281 -0
- package/dist/gateways/slack.js.map +1 -0
- package/dist/gateways/telegram.d.ts +79 -0
- package/dist/gateways/telegram.d.ts.map +1 -0
- package/dist/gateways/telegram.js +207 -0
- package/dist/gateways/telegram.js.map +1 -0
- package/dist/gateways/types.d.ts +340 -0
- package/dist/gateways/types.d.ts.map +1 -0
- package/dist/gateways/types.js +6 -0
- package/dist/gateways/types.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/memory/memory-logger.d.ts +47 -0
- package/dist/memory/memory-logger.d.ts.map +1 -0
- package/dist/memory/memory-logger.js +126 -0
- package/dist/memory/memory-logger.js.map +1 -0
- package/dist/onboarding/all-tools.d.ts +18 -0
- package/dist/onboarding/all-tools.d.ts.map +1 -0
- package/dist/onboarding/all-tools.js +149 -0
- package/dist/onboarding/all-tools.js.map +1 -0
- package/dist/onboarding/autonomous-discovery-tools.d.ts +13 -0
- package/dist/onboarding/autonomous-discovery-tools.d.ts.map +1 -0
- package/dist/onboarding/autonomous-discovery-tools.js +268 -0
- package/dist/onboarding/autonomous-discovery-tools.js.map +1 -0
- package/dist/onboarding/bootstrap-template.d.ts +5 -0
- package/dist/onboarding/bootstrap-template.d.ts.map +1 -0
- package/dist/onboarding/bootstrap-template.js +142 -0
- package/dist/onboarding/bootstrap-template.js.map +1 -0
- package/dist/onboarding/complete-autonomous-prompt.d.ts +13 -0
- package/dist/onboarding/complete-autonomous-prompt.d.ts.map +1 -0
- package/dist/onboarding/complete-autonomous-prompt.js +1220 -0
- package/dist/onboarding/complete-autonomous-prompt.js.map +1 -0
- package/dist/onboarding/onboarding-state.d.ts +70 -0
- package/dist/onboarding/onboarding-state.d.ts.map +1 -0
- package/dist/onboarding/onboarding-state.js +184 -0
- package/dist/onboarding/onboarding-state.js.map +1 -0
- package/dist/onboarding/personality-quiz.d.ts +35 -0
- package/dist/onboarding/personality-quiz.d.ts.map +1 -0
- package/dist/onboarding/personality-quiz.js +219 -0
- package/dist/onboarding/personality-quiz.js.map +1 -0
- package/dist/onboarding/phase-5-summary.d.ts +22 -0
- package/dist/onboarding/phase-5-summary.d.ts.map +1 -0
- package/dist/onboarding/phase-5-summary.js +151 -0
- package/dist/onboarding/phase-5-summary.js.map +1 -0
- package/dist/onboarding/phase-6-security.d.ts +33 -0
- package/dist/onboarding/phase-6-security.d.ts.map +1 -0
- package/dist/onboarding/phase-6-security.js +473 -0
- package/dist/onboarding/phase-6-security.js.map +1 -0
- package/dist/onboarding/phase-7-integrations.d.ts +66 -0
- package/dist/onboarding/phase-7-integrations.d.ts.map +1 -0
- package/dist/onboarding/phase-7-integrations.js +619 -0
- package/dist/onboarding/phase-7-integrations.js.map +1 -0
- package/dist/onboarding/phase-8-demo.d.ts +43 -0
- package/dist/onboarding/phase-8-demo.d.ts.map +1 -0
- package/dist/onboarding/phase-8-demo.js +346 -0
- package/dist/onboarding/phase-8-demo.js.map +1 -0
- package/dist/onboarding/phase-9-finalization.d.ts +22 -0
- package/dist/onboarding/phase-9-finalization.d.ts.map +1 -0
- package/dist/onboarding/phase-9-finalization.js +375 -0
- package/dist/onboarding/phase-9-finalization.js.map +1 -0
- package/dist/onboarding/ritual-prompt.d.ts +2 -0
- package/dist/onboarding/ritual-prompt.d.ts.map +1 -0
- package/dist/onboarding/ritual-prompt.js +285 -0
- package/dist/onboarding/ritual-prompt.js.map +1 -0
- package/dist/onboarding/ritual-tools.d.ts +13 -0
- package/dist/onboarding/ritual-tools.d.ts.map +1 -0
- package/dist/onboarding/ritual-tools.js +93 -0
- package/dist/onboarding/ritual-tools.js.map +1 -0
- package/dist/runners/cli-runner.d.ts +59 -0
- package/dist/runners/cli-runner.d.ts.map +1 -0
- package/dist/runners/cli-runner.js +190 -0
- package/dist/runners/cli-runner.js.map +1 -0
- package/dist/runners/index.d.ts +11 -0
- package/dist/runners/index.d.ts.map +1 -0
- package/dist/runners/index.js +15 -0
- package/dist/runners/index.js.map +1 -0
- package/dist/runners/types.d.ts +81 -0
- package/dist/runners/types.d.ts.map +1 -0
- package/dist/runners/types.js +31 -0
- package/dist/runners/types.js.map +1 -0
- package/dist/scheduler/cron-scheduler.d.ts +115 -0
- package/dist/scheduler/cron-scheduler.d.ts.map +1 -0
- package/dist/scheduler/cron-scheduler.js +320 -0
- package/dist/scheduler/cron-scheduler.js.map +1 -0
- package/dist/scheduler/heartbeat.d.ts +53 -0
- package/dist/scheduler/heartbeat.d.ts.map +1 -0
- package/dist/scheduler/heartbeat.js +160 -0
- package/dist/scheduler/heartbeat.js.map +1 -0
- package/dist/scheduler/index.d.ts +22 -0
- package/dist/scheduler/index.d.ts.map +1 -0
- package/dist/scheduler/index.js +31 -0
- package/dist/scheduler/index.js.map +1 -0
- package/dist/scheduler/job-lock.d.ts +85 -0
- package/dist/scheduler/job-lock.d.ts.map +1 -0
- package/dist/scheduler/job-lock.js +137 -0
- package/dist/scheduler/job-lock.js.map +1 -0
- package/dist/scheduler/recovery.d.ts +78 -0
- package/dist/scheduler/recovery.d.ts.map +1 -0
- package/dist/scheduler/recovery.js +124 -0
- package/dist/scheduler/recovery.js.map +1 -0
- package/dist/scheduler/schedule-store.d.ts +112 -0
- package/dist/scheduler/schedule-store.d.ts.map +1 -0
- package/dist/scheduler/schedule-store.js +259 -0
- package/dist/scheduler/schedule-store.js.map +1 -0
- package/dist/scheduler/token-keep-alive.d.ts +49 -0
- package/dist/scheduler/token-keep-alive.d.ts.map +1 -0
- package/dist/scheduler/token-keep-alive.js +102 -0
- package/dist/scheduler/token-keep-alive.js.map +1 -0
- package/dist/scheduler/types.d.ts +96 -0
- package/dist/scheduler/types.d.ts.map +1 -0
- package/dist/scheduler/types.js +21 -0
- package/dist/scheduler/types.js.map +1 -0
- package/dist/setup/setup-prompt.d.ts +2 -0
- package/dist/setup/setup-prompt.d.ts.map +1 -0
- package/dist/setup/setup-prompt.js +138 -0
- package/dist/setup/setup-prompt.js.map +1 -0
- package/dist/setup/setup-server.d.ts +8 -0
- package/dist/setup/setup-server.d.ts.map +1 -0
- package/dist/setup/setup-server.js +71 -0
- package/dist/setup/setup-server.js.map +1 -0
- package/dist/setup/setup-tools.d.ts +13 -0
- package/dist/setup/setup-tools.d.ts.map +1 -0
- package/dist/setup/setup-tools.js +103 -0
- package/dist/setup/setup-tools.js.map +1 -0
- package/dist/setup/setup-websocket.d.ts +6 -0
- package/dist/setup/setup-websocket.d.ts.map +1 -0
- package/dist/setup/setup-websocket.js +312 -0
- package/dist/setup/setup-websocket.js.map +1 -0
- package/dist/skills/index.d.ts +10 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +26 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/skill-executor.d.ts +48 -0
- package/dist/skills/skill-executor.d.ts.map +1 -0
- package/dist/skills/skill-executor.js +483 -0
- package/dist/skills/skill-executor.js.map +1 -0
- package/dist/skills/skill-loader.d.ts +40 -0
- package/dist/skills/skill-loader.d.ts.map +1 -0
- package/dist/skills/skill-loader.js +225 -0
- package/dist/skills/skill-loader.js.map +1 -0
- package/dist/skills/skill-matcher.d.ts +33 -0
- package/dist/skills/skill-matcher.d.ts.map +1 -0
- package/dist/skills/skill-matcher.js +190 -0
- package/dist/skills/skill-matcher.js.map +1 -0
- package/dist/skills/types.d.ts +123 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +12 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/tools/browser-tool.d.ts +149 -0
- package/dist/tools/browser-tool.d.ts.map +1 -0
- package/dist/tools/browser-tool.js +257 -0
- package/dist/tools/browser-tool.js.map +1 -0
- package/package.json +84 -0
- package/public/favicon.ico +0 -0
- package/public/setup.html +1026 -0
- package/public/viewer/icons/icon-192.png +0 -0
- package/public/viewer/icons/icon-512.png +0 -0
- package/public/viewer/js/modules/chat.js +1587 -0
- package/public/viewer/js/modules/dashboard.js +275 -0
- package/public/viewer/js/modules/graph.js +997 -0
- package/public/viewer/js/modules/memory.js +353 -0
- package/public/viewer/js/modules/settings.js +255 -0
- package/public/viewer/js/utils/api.js +169 -0
- package/public/viewer/js/utils/dom.js +92 -0
- package/public/viewer/js/utils/format.js +192 -0
- package/public/viewer/manifest.json +26 -0
- package/public/viewer/sw.js +131 -0
- package/public/viewer/viewer.css +500 -0
- package/public/viewer/viewer.html +1535 -0
- package/scripts/postinstall.js +118 -0
- package/templates/skills/document-analyze.md +63 -0
- package/templates/skills/heartbeat-report.md +75 -0
- package/templates/skills/image-translate.md +67 -0
- package/templates/workspace/skill-forge/DESIGN.md +115 -0
- package/templates/workspace/skill-forge/agents/architect.ts +295 -0
- package/templates/workspace/skill-forge/agents/developer.ts +364 -0
- package/templates/workspace/skill-forge/agents/qa.ts +313 -0
- package/templates/workspace/skill-forge/claude-api.ts +353 -0
- package/templates/workspace/skill-forge/discord-ui.ts +580 -0
- package/templates/workspace/skill-forge/error-handler.ts +354 -0
- package/templates/workspace/skill-forge/mama-integration.ts +357 -0
- package/templates/workspace/skill-forge/orchestrator.ts +495 -0
- package/templates/workspace/skill-forge/output/generated-skills/skills/hello-world/README.md +24 -0
- package/templates/workspace/skill-forge/output/generated-skills/skills/hello-world/index.ts +79 -0
- package/templates/workspace/skill-forge/output/generated-skills/skills/hello-world/types.ts +17 -0
- package/templates/workspace/skill-forge/package.json +21 -0
- package/templates/workspace/skill-forge/state/session.json +132 -0
- package/templates/workspace/skill-forge/test-e2e.ts +139 -0
- package/templates/workspace/skill-forge/tsconfig.json +20 -0
- package/templates/workspace/skill-forge/types.ts +159 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Message splitter for messenger platforms
|
|
4
|
+
*
|
|
5
|
+
* Splits long messages into chunks that fit within platform limits
|
|
6
|
+
* while preserving readability (splitting at newlines or spaces).
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.DEFAULT_MAX_LENGTH = void 0;
|
|
10
|
+
exports.splitMessage = splitMessage;
|
|
11
|
+
exports.splitForDiscord = splitForDiscord;
|
|
12
|
+
exports.splitForSlack = splitForSlack;
|
|
13
|
+
exports.estimateChunks = estimateChunks;
|
|
14
|
+
exports.truncateWithEllipsis = truncateWithEllipsis;
|
|
15
|
+
exports.splitWithCodeBlocks = splitWithCodeBlocks;
|
|
16
|
+
/**
|
|
17
|
+
* Default maximum message length (Discord limit)
|
|
18
|
+
*/
|
|
19
|
+
exports.DEFAULT_MAX_LENGTH = 2000;
|
|
20
|
+
/**
|
|
21
|
+
* Split a message into chunks that fit within the maximum length
|
|
22
|
+
*
|
|
23
|
+
* @param text - Text to split
|
|
24
|
+
* @param options - Split options
|
|
25
|
+
* @returns Array of text chunks
|
|
26
|
+
*/
|
|
27
|
+
function splitMessage(text, options = {}) {
|
|
28
|
+
const { maxLength = exports.DEFAULT_MAX_LENGTH, splitPoints = ['\n', ' '], chunkSuffix = '', continuationPrefix = '', } = options;
|
|
29
|
+
// Adjust max length for suffix/prefix
|
|
30
|
+
const effectiveMax = maxLength - chunkSuffix.length;
|
|
31
|
+
const firstChunkMax = effectiveMax;
|
|
32
|
+
const continuationMax = effectiveMax - continuationPrefix.length;
|
|
33
|
+
// If text fits, return as single chunk
|
|
34
|
+
if (text.length <= maxLength) {
|
|
35
|
+
return [text];
|
|
36
|
+
}
|
|
37
|
+
const chunks = [];
|
|
38
|
+
let remaining = text;
|
|
39
|
+
let isFirst = true;
|
|
40
|
+
while (remaining.length > 0) {
|
|
41
|
+
const currentMax = isFirst ? firstChunkMax : continuationMax;
|
|
42
|
+
if (remaining.length <= currentMax) {
|
|
43
|
+
// Last chunk
|
|
44
|
+
const prefix = isFirst ? '' : continuationPrefix;
|
|
45
|
+
chunks.push(prefix + remaining);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
// Find best split point
|
|
49
|
+
let splitIndex = findBestSplitPoint(remaining, currentMax, splitPoints);
|
|
50
|
+
// Add chunk
|
|
51
|
+
const prefix = isFirst ? '' : continuationPrefix;
|
|
52
|
+
const chunk = prefix + remaining.slice(0, splitIndex).trimEnd();
|
|
53
|
+
chunks.push(chunk + chunkSuffix);
|
|
54
|
+
// Move to next chunk
|
|
55
|
+
remaining = remaining.slice(splitIndex).trimStart();
|
|
56
|
+
isFirst = false;
|
|
57
|
+
}
|
|
58
|
+
return chunks;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Find the best point to split the text
|
|
62
|
+
*
|
|
63
|
+
* @param text - Text to split
|
|
64
|
+
* @param maxLength - Maximum length for this chunk
|
|
65
|
+
* @param splitPoints - Preferred split characters
|
|
66
|
+
* @returns Index to split at
|
|
67
|
+
*/
|
|
68
|
+
function findBestSplitPoint(text, maxLength, splitPoints) {
|
|
69
|
+
// Try each split point in order of preference
|
|
70
|
+
for (const splitChar of splitPoints) {
|
|
71
|
+
const lastIndex = text.lastIndexOf(splitChar, maxLength);
|
|
72
|
+
// Only use if it's not too close to the start (at least 50% of maxLength)
|
|
73
|
+
if (lastIndex >= maxLength / 2) {
|
|
74
|
+
return lastIndex + splitChar.length;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// No good split point found, just cut at maxLength
|
|
78
|
+
return maxLength;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Split message for Discord (2000 char limit)
|
|
82
|
+
*/
|
|
83
|
+
function splitForDiscord(text) {
|
|
84
|
+
return splitMessage(text, { maxLength: 2000 });
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Split message for Slack (40000 char limit for regular messages)
|
|
88
|
+
* Note: Slack has different limits for different contexts
|
|
89
|
+
*/
|
|
90
|
+
function splitForSlack(text) {
|
|
91
|
+
return splitMessage(text, { maxLength: 40000 });
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Estimate number of chunks a message will be split into
|
|
95
|
+
*/
|
|
96
|
+
function estimateChunks(text, maxLength = exports.DEFAULT_MAX_LENGTH) {
|
|
97
|
+
if (text.length <= maxLength)
|
|
98
|
+
return 1;
|
|
99
|
+
return Math.ceil(text.length / maxLength);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Truncate text with ellipsis if too long
|
|
103
|
+
*/
|
|
104
|
+
function truncateWithEllipsis(text, maxLength, ellipsis = '...') {
|
|
105
|
+
if (text.length <= maxLength)
|
|
106
|
+
return text;
|
|
107
|
+
return text.slice(0, maxLength - ellipsis.length) + ellipsis;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Split text into code blocks if it contains code
|
|
111
|
+
* Preserves code block formatting
|
|
112
|
+
*/
|
|
113
|
+
function splitWithCodeBlocks(text, maxLength = exports.DEFAULT_MAX_LENGTH) {
|
|
114
|
+
// If no code blocks or fits in one message, use simple split
|
|
115
|
+
if (!text.includes('```') || text.length <= maxLength) {
|
|
116
|
+
return splitMessage(text, { maxLength });
|
|
117
|
+
}
|
|
118
|
+
const chunks = [];
|
|
119
|
+
const codeBlockRegex = /```[\s\S]*?```/g;
|
|
120
|
+
let lastIndex = 0;
|
|
121
|
+
let match;
|
|
122
|
+
while ((match = codeBlockRegex.exec(text)) !== null) {
|
|
123
|
+
// Text before code block
|
|
124
|
+
const beforeCode = text.slice(lastIndex, match.index);
|
|
125
|
+
if (beforeCode.trim()) {
|
|
126
|
+
chunks.push(...splitMessage(beforeCode, { maxLength }));
|
|
127
|
+
}
|
|
128
|
+
// Code block itself
|
|
129
|
+
const codeBlock = match[0];
|
|
130
|
+
if (codeBlock.length <= maxLength) {
|
|
131
|
+
chunks.push(codeBlock);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
// Split long code blocks
|
|
135
|
+
chunks.push(...splitMessage(codeBlock, { maxLength, splitPoints: ['\n'] }));
|
|
136
|
+
}
|
|
137
|
+
lastIndex = match.index + match[0].length;
|
|
138
|
+
}
|
|
139
|
+
// Remaining text after last code block
|
|
140
|
+
const remaining = text.slice(lastIndex);
|
|
141
|
+
if (remaining.trim()) {
|
|
142
|
+
chunks.push(...splitMessage(remaining, { maxLength }));
|
|
143
|
+
}
|
|
144
|
+
return chunks;
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=message-splitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-splitter.js","sourceRoot":"","sources":["../../src/gateways/message-splitter.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA4BH,oCA8CC;AA4BD,0CAEC;AAMD,sCAEC;AAKD,wCAGC;AAKD,oDAOC;AAMD,kDAwCC;AAhLD;;GAEG;AACU,QAAA,kBAAkB,GAAG,IAAI,CAAC;AAgBvC;;;;;;GAMG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,UAAwB,EAAE;IACnE,MAAM,EACJ,SAAS,GAAG,0BAAkB,EAC9B,WAAW,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,EACzB,WAAW,GAAG,EAAE,EAChB,kBAAkB,GAAG,EAAE,GACxB,GAAG,OAAO,CAAC;IAEZ,sCAAsC;IACtC,MAAM,YAAY,GAAG,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC;IACpD,MAAM,aAAa,GAAG,YAAY,CAAC;IACnC,MAAM,eAAe,GAAG,YAAY,GAAG,kBAAkB,CAAC,MAAM,CAAC;IAEjE,uCAAuC;IACvC,IAAI,IAAI,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAC7B,OAAO,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IAED,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,SAAS,GAAG,IAAI,CAAC;IACrB,IAAI,OAAO,GAAG,IAAI,CAAC;IAEnB,OAAO,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,eAAe,CAAC;QAE7D,IAAI,SAAS,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;YACnC,aAAa;YACb,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC;YACjD,MAAM,CAAC,IAAI,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AAE,SAAS,EAAE,CAAC,CAAC,CAAC;QAC1D,CAAC;QAED,oBAAoB;QACpB,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,SAAS,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;YAClC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,yBAAyB;YACzB,MAAM,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAC9E,CAAC;QAED,SAAS,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC5C,CAAC;IAED,uCAAuC;IACvC,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACxC,IAAI,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;QACrB,MAAM,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gateway Plugin Loader
|
|
3
|
+
*
|
|
4
|
+
* Discovers and loads gateway plugins from ~/.mama/plugins/
|
|
5
|
+
* Each plugin is a directory with:
|
|
6
|
+
* - plugin.json (manifest)
|
|
7
|
+
* - index.ts or index.js (entry point)
|
|
8
|
+
*/
|
|
9
|
+
import type { PluginManifest, LoadedPlugin, Gateway, AgentLoopInterface, MessageSource } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Plugin loader configuration
|
|
12
|
+
*/
|
|
13
|
+
export interface PluginLoaderConfig {
|
|
14
|
+
/** Plugin directory (default: ~/.mama/plugins) */
|
|
15
|
+
pluginsDir?: string;
|
|
16
|
+
/** Gateway configurations from main config */
|
|
17
|
+
gatewayConfigs?: Record<string, unknown>;
|
|
18
|
+
/** Agent loop instance */
|
|
19
|
+
agentLoop?: AgentLoopInterface;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Plugin Loader class
|
|
23
|
+
*/
|
|
24
|
+
export declare class PluginLoader {
|
|
25
|
+
private readonly pluginsDir;
|
|
26
|
+
private readonly gatewayConfigs;
|
|
27
|
+
private readonly agentLoop?;
|
|
28
|
+
private readonly plugins;
|
|
29
|
+
private readonly messageHandlers;
|
|
30
|
+
constructor(config?: PluginLoaderConfig);
|
|
31
|
+
/**
|
|
32
|
+
* Discover all plugins in the plugins directory
|
|
33
|
+
*/
|
|
34
|
+
discover(): Promise<PluginManifest[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Check if a plugin is enabled in config
|
|
37
|
+
*/
|
|
38
|
+
private isPluginEnabled;
|
|
39
|
+
/**
|
|
40
|
+
* Load and register a plugin
|
|
41
|
+
*/
|
|
42
|
+
loadPlugin(pluginId: string): Promise<Gateway | null>;
|
|
43
|
+
/**
|
|
44
|
+
* Load all discovered plugins
|
|
45
|
+
*/
|
|
46
|
+
loadAll(): Promise<Gateway[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Create the API object for a plugin
|
|
49
|
+
*/
|
|
50
|
+
private createPluginApi;
|
|
51
|
+
/**
|
|
52
|
+
* Create a logger for a plugin
|
|
53
|
+
*/
|
|
54
|
+
private createLogger;
|
|
55
|
+
/**
|
|
56
|
+
* Get all loaded gateways
|
|
57
|
+
*/
|
|
58
|
+
getGateways(): Gateway[];
|
|
59
|
+
/**
|
|
60
|
+
* Get a specific gateway by source ID
|
|
61
|
+
*/
|
|
62
|
+
getGateway(source: MessageSource): Gateway | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Get all discovered plugins
|
|
65
|
+
*/
|
|
66
|
+
getPlugins(): LoadedPlugin[];
|
|
67
|
+
/**
|
|
68
|
+
* Stop all gateways
|
|
69
|
+
*/
|
|
70
|
+
stopAll(): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Create a plugin loader instance
|
|
74
|
+
*/
|
|
75
|
+
export declare function createPluginLoader(config?: PluginLoaderConfig): PluginLoader;
|
|
76
|
+
//# sourceMappingURL=plugin-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-loader.d.ts","sourceRoot":"","sources":["../../src/gateways/plugin-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EACV,cAAc,EAGd,YAAY,EACZ,OAAO,EAGP,kBAAkB,EAClB,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,0BAA0B;IAC1B,SAAS,CAAC,EAAE,kBAAkB,CAAC;CAChC;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA0B;IACzD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAqB;IAChD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwC;IAChE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA4C;gBAEhE,MAAM,GAAE,kBAAuB;IAO3C;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAiD3C;;OAEG;IACH,OAAO,CAAC,eAAe;IAKvB;;OAEG;IACG,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAgD3D;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAanC;;OAEG;IACH,OAAO,CAAC,eAAe;IAgCvB;;OAEG;IACH,OAAO,CAAC,YAAY;IAUpB;;OAEG;IACH,WAAW,IAAI,OAAO,EAAE;IAUxB;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,GAAG,SAAS;IAStD;;OAEG;IACH,UAAU,IAAI,YAAY,EAAE;IAI5B;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAO/B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,YAAY,CAE5E"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Gateway Plugin Loader
|
|
4
|
+
*
|
|
5
|
+
* Discovers and loads gateway plugins from ~/.mama/plugins/
|
|
6
|
+
* Each plugin is a directory with:
|
|
7
|
+
* - plugin.json (manifest)
|
|
8
|
+
* - index.ts or index.js (entry point)
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.PluginLoader = void 0;
|
|
12
|
+
exports.createPluginLoader = createPluginLoader;
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
const path_1 = require("path");
|
|
15
|
+
const url_1 = require("url");
|
|
16
|
+
/**
|
|
17
|
+
* Plugin Loader class
|
|
18
|
+
*/
|
|
19
|
+
class PluginLoader {
|
|
20
|
+
pluginsDir;
|
|
21
|
+
gatewayConfigs;
|
|
22
|
+
agentLoop;
|
|
23
|
+
plugins = new Map();
|
|
24
|
+
messageHandlers = new Map();
|
|
25
|
+
constructor(config = {}) {
|
|
26
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || '';
|
|
27
|
+
this.pluginsDir = config.pluginsDir || (0, path_1.join)(homeDir, '.mama', 'plugins');
|
|
28
|
+
this.gatewayConfigs = config.gatewayConfigs || {};
|
|
29
|
+
this.agentLoop = config.agentLoop;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Discover all plugins in the plugins directory
|
|
33
|
+
*/
|
|
34
|
+
async discover() {
|
|
35
|
+
const manifests = [];
|
|
36
|
+
if (!(0, fs_1.existsSync)(this.pluginsDir)) {
|
|
37
|
+
console.log(`[PluginLoader] Plugins directory not found: ${this.pluginsDir}`);
|
|
38
|
+
return manifests;
|
|
39
|
+
}
|
|
40
|
+
const entries = (0, fs_1.readdirSync)(this.pluginsDir, { withFileTypes: true });
|
|
41
|
+
for (const entry of entries) {
|
|
42
|
+
if (!entry.isDirectory())
|
|
43
|
+
continue;
|
|
44
|
+
const pluginDir = (0, path_1.join)(this.pluginsDir, entry.name);
|
|
45
|
+
const manifestPath = (0, path_1.join)(pluginDir, 'plugin.json');
|
|
46
|
+
if (!(0, fs_1.existsSync)(manifestPath)) {
|
|
47
|
+
console.warn(`[PluginLoader] No plugin.json in ${entry.name}, skipping`);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
const manifestContent = (0, fs_1.readFileSync)(manifestPath, 'utf-8');
|
|
52
|
+
const manifest = JSON.parse(manifestContent);
|
|
53
|
+
// Validate required fields
|
|
54
|
+
if (!manifest.id || !manifest.name || !manifest.main) {
|
|
55
|
+
console.warn(`[PluginLoader] Invalid manifest in ${entry.name}: missing required fields`);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
manifests.push(manifest);
|
|
59
|
+
// Store plugin info
|
|
60
|
+
this.plugins.set(manifest.id, {
|
|
61
|
+
manifest,
|
|
62
|
+
path: pluginDir,
|
|
63
|
+
enabled: this.isPluginEnabled(manifest.id),
|
|
64
|
+
});
|
|
65
|
+
console.log(`[PluginLoader] Discovered plugin: ${manifest.name} (${manifest.id})`);
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
console.error(`[PluginLoader] Failed to load manifest from ${entry.name}:`, err);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return manifests;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Check if a plugin is enabled in config
|
|
75
|
+
*/
|
|
76
|
+
isPluginEnabled(pluginId) {
|
|
77
|
+
const config = this.gatewayConfigs[pluginId];
|
|
78
|
+
return config?.enabled !== false; // Enabled by default
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Load and register a plugin
|
|
82
|
+
*/
|
|
83
|
+
async loadPlugin(pluginId) {
|
|
84
|
+
const plugin = this.plugins.get(pluginId);
|
|
85
|
+
if (!plugin) {
|
|
86
|
+
console.error(`[PluginLoader] Plugin not found: ${pluginId}`);
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
if (!plugin.enabled) {
|
|
90
|
+
console.log(`[PluginLoader] Plugin disabled: ${pluginId}`);
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
const entryPath = (0, path_1.join)(plugin.path, plugin.manifest.main);
|
|
94
|
+
if (!(0, fs_1.existsSync)(entryPath)) {
|
|
95
|
+
console.error(`[PluginLoader] Entry point not found: ${entryPath}`);
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
// Create plugin API
|
|
100
|
+
const api = this.createPluginApi(pluginId);
|
|
101
|
+
// Dynamic import of plugin module
|
|
102
|
+
const moduleUrl = (0, url_1.pathToFileURL)(entryPath).href;
|
|
103
|
+
const module = (await import(moduleUrl));
|
|
104
|
+
// Get the plugin module (handle both default export and named export)
|
|
105
|
+
const pluginModule = module.default || module;
|
|
106
|
+
if (!pluginModule.register || typeof pluginModule.register !== 'function') {
|
|
107
|
+
console.error(`[PluginLoader] Plugin ${pluginId} has no register function`);
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
// Register the plugin and get gateway instance
|
|
111
|
+
const gateway = await pluginModule.register(api);
|
|
112
|
+
plugin.gateway = gateway;
|
|
113
|
+
console.log(`[PluginLoader] Loaded plugin: ${plugin.manifest.name}`);
|
|
114
|
+
return gateway;
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
console.error(`[PluginLoader] Failed to load plugin ${pluginId}:`, err);
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Load all discovered plugins
|
|
123
|
+
*/
|
|
124
|
+
async loadAll() {
|
|
125
|
+
const gateways = [];
|
|
126
|
+
for (const [pluginId] of this.plugins) {
|
|
127
|
+
const gateway = await this.loadPlugin(pluginId);
|
|
128
|
+
if (gateway) {
|
|
129
|
+
gateways.push(gateway);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return gateways;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Create the API object for a plugin
|
|
136
|
+
*/
|
|
137
|
+
createPluginApi(pluginId) {
|
|
138
|
+
// Note: plugin info is available via this.plugins.get(pluginId)
|
|
139
|
+
const handlers = [];
|
|
140
|
+
this.messageHandlers.set(pluginId, handlers);
|
|
141
|
+
const logger = this.createLogger(pluginId);
|
|
142
|
+
return {
|
|
143
|
+
logger,
|
|
144
|
+
getConfig: () => {
|
|
145
|
+
return this.gatewayConfigs[pluginId];
|
|
146
|
+
},
|
|
147
|
+
getAgentLoop: () => {
|
|
148
|
+
if (!this.agentLoop) {
|
|
149
|
+
throw new Error('Agent loop not available');
|
|
150
|
+
}
|
|
151
|
+
return this.agentLoop;
|
|
152
|
+
},
|
|
153
|
+
onMessage: (handler) => {
|
|
154
|
+
handlers.push(handler);
|
|
155
|
+
},
|
|
156
|
+
sendResponse: async (_channelId, _text, _metadata) => {
|
|
157
|
+
// This will be overridden by the gateway implementation
|
|
158
|
+
logger.warn(`sendResponse not implemented for ${pluginId}`);
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Create a logger for a plugin
|
|
164
|
+
*/
|
|
165
|
+
createLogger(pluginId) {
|
|
166
|
+
const prefix = `[${pluginId}]`;
|
|
167
|
+
return {
|
|
168
|
+
info: (message, ...args) => console.log(prefix, message, ...args),
|
|
169
|
+
warn: (message, ...args) => console.warn(prefix, message, ...args),
|
|
170
|
+
error: (message, ...args) => console.error(prefix, message, ...args),
|
|
171
|
+
debug: (message, ...args) => console.debug(prefix, message, ...args),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get all loaded gateways
|
|
176
|
+
*/
|
|
177
|
+
getGateways() {
|
|
178
|
+
const gateways = [];
|
|
179
|
+
for (const plugin of this.plugins.values()) {
|
|
180
|
+
if (plugin.gateway) {
|
|
181
|
+
gateways.push(plugin.gateway);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return gateways;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Get a specific gateway by source ID
|
|
188
|
+
*/
|
|
189
|
+
getGateway(source) {
|
|
190
|
+
for (const plugin of this.plugins.values()) {
|
|
191
|
+
if (plugin.gateway?.source === source) {
|
|
192
|
+
return plugin.gateway;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Get all discovered plugins
|
|
199
|
+
*/
|
|
200
|
+
getPlugins() {
|
|
201
|
+
return Array.from(this.plugins.values());
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Stop all gateways
|
|
205
|
+
*/
|
|
206
|
+
async stopAll() {
|
|
207
|
+
for (const plugin of this.plugins.values()) {
|
|
208
|
+
if (plugin.gateway?.isConnected()) {
|
|
209
|
+
await plugin.gateway.stop();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
exports.PluginLoader = PluginLoader;
|
|
215
|
+
/**
|
|
216
|
+
* Create a plugin loader instance
|
|
217
|
+
*/
|
|
218
|
+
function createPluginLoader(config) {
|
|
219
|
+
return new PluginLoader(config);
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=plugin-loader.js.map
|
|
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AED;;OAEG;IACH,WAAW;QACT,MAAM,QAAQ,GAAc,EAAE,CAAC;QAC/B,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3C,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,MAAqB;QAC9B,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3C,IAAI,MAAM,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;gBACtC,OAAO,MAAM,CAAC,OAAO,CAAC;YACxB,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3C,IAAI,MAAM,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,CAAC;gBAClC,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAvOD,oCAuOC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,MAA2B;IAC5D,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session store for messenger conversations
|
|
3
|
+
*
|
|
4
|
+
* Manages conversation sessions with rolling context (history)
|
|
5
|
+
* for cross-platform messenger integration.
|
|
6
|
+
*/
|
|
7
|
+
import Database from 'better-sqlite3';
|
|
8
|
+
import type { Session, MessageSource, ConversationTurn } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* SQLite-backed session store for messenger conversations
|
|
11
|
+
*/
|
|
12
|
+
export declare class SessionStore {
|
|
13
|
+
private db;
|
|
14
|
+
private maxTurns;
|
|
15
|
+
private maxResponseLength;
|
|
16
|
+
constructor(db: Database.Database, options?: {
|
|
17
|
+
maxTurns?: number;
|
|
18
|
+
maxResponseLength?: number;
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Run database migration
|
|
22
|
+
*/
|
|
23
|
+
private runMigration;
|
|
24
|
+
/**
|
|
25
|
+
* Get existing session or create new one
|
|
26
|
+
*/
|
|
27
|
+
getOrCreate(source: MessageSource, channelId: string, userId?: string): Session;
|
|
28
|
+
/**
|
|
29
|
+
* Get session by ID
|
|
30
|
+
*/
|
|
31
|
+
getById(sessionId: string): Session | null;
|
|
32
|
+
/**
|
|
33
|
+
* Update session with new conversation turn
|
|
34
|
+
*/
|
|
35
|
+
updateSession(sessionId: string, userMessage: string, botResponse: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Get conversation history for a session
|
|
38
|
+
*/
|
|
39
|
+
getHistory(sessionId: string): ConversationTurn[];
|
|
40
|
+
/**
|
|
41
|
+
* Clear session context (start fresh)
|
|
42
|
+
*/
|
|
43
|
+
clearContext(sessionId: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Delete a session
|
|
46
|
+
*/
|
|
47
|
+
deleteSession(sessionId: string): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* List all sessions for a source
|
|
50
|
+
*/
|
|
51
|
+
listSessions(source?: MessageSource): Session[];
|
|
52
|
+
/**
|
|
53
|
+
* Delete inactive sessions older than specified age
|
|
54
|
+
*/
|
|
55
|
+
cleanupInactiveSessions(maxAgeMs: number): number;
|
|
56
|
+
/**
|
|
57
|
+
* Get the most recently active session for a specific source
|
|
58
|
+
*/
|
|
59
|
+
getLastActiveSession(source?: MessageSource): Session | null;
|
|
60
|
+
/**
|
|
61
|
+
* Format context as readable string for system prompt
|
|
62
|
+
*/
|
|
63
|
+
formatContextForPrompt(sessionId: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Convert database row to Session object
|
|
66
|
+
*/
|
|
67
|
+
private rowToSession;
|
|
68
|
+
/**
|
|
69
|
+
* Truncate text to specified length
|
|
70
|
+
*/
|
|
71
|
+
private truncate;
|
|
72
|
+
/**
|
|
73
|
+
* Close database connection
|
|
74
|
+
*/
|
|
75
|
+
close(): void;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=session-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-store.d.ts","sourceRoot":"","sources":["../../src/gateways/session-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAoB3E;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,EAAE,CAAoB;IAC9B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,iBAAiB,CAAS;gBAGhC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,OAAO,GAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;KAAO;IAQjE;;OAEG;IACH,OAAO,CAAC,YAAY;IAkBpB;;OAEG;IACH,WAAW,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO;IAsC/E;;OAEG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI;IAQ1C;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,WA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