@xopcai/xopcbot 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +132 -0
- package/README.zh-CN.md +130 -0
- package/dist/__tests__/core.test.d.ts +1 -0
- package/dist/__tests__/core.test.js +72 -0
- package/dist/__tests__/core.test.js.map +1 -0
- package/dist/agent/fallback/__tests__/index.test.d.ts +1 -0
- package/dist/agent/fallback/__tests__/index.test.js +111 -0
- package/dist/agent/fallback/__tests__/index.test.js.map +1 -0
- package/dist/agent/fallback/candidates.d.ts +23 -0
- package/dist/agent/fallback/candidates.js +62 -0
- package/dist/agent/fallback/candidates.js.map +1 -0
- package/dist/agent/fallback/error.d.ts +22 -0
- package/dist/agent/fallback/error.js +27 -0
- package/dist/agent/fallback/error.js.map +1 -0
- package/dist/agent/fallback/index.d.ts +6 -0
- package/dist/agent/fallback/index.js +5 -0
- package/dist/agent/fallback/index.js.map +1 -0
- package/dist/agent/fallback/reason.d.ts +7 -0
- package/dist/agent/fallback/reason.js +78 -0
- package/dist/agent/fallback/reason.js.map +1 -0
- package/dist/agent/fallback/runner.d.ts +22 -0
- package/dist/agent/fallback/runner.js +34 -0
- package/dist/agent/fallback/runner.js.map +1 -0
- package/dist/agent/helpers.d.ts +38 -0
- package/dist/agent/helpers.js +122 -0
- package/dist/agent/helpers.js.map +1 -0
- package/dist/agent/index.d.ts +7 -0
- package/dist/agent/index.js +7 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/memory/compaction.d.ts +63 -0
- package/dist/agent/memory/compaction.js +233 -0
- package/dist/agent/memory/compaction.js.map +1 -0
- package/dist/agent/memory/window.d.ts +29 -0
- package/dist/agent/memory/window.js +64 -0
- package/dist/agent/memory/window.js.map +1 -0
- package/dist/agent/model-manager.d.ts +80 -0
- package/dist/agent/model-manager.js +213 -0
- package/dist/agent/model-manager.js.map +1 -0
- package/dist/agent/prompt/heartbeat.d.ts +97 -0
- package/dist/agent/prompt/heartbeat.js +313 -0
- package/dist/agent/prompt/heartbeat.js.map +1 -0
- package/dist/agent/prompt/index.d.ts +65 -0
- package/dist/agent/prompt/index.js +215 -0
- package/dist/agent/prompt/index.js.map +1 -0
- package/dist/agent/prompt/memory/index.d.ts +37 -0
- package/dist/agent/prompt/memory/index.js +241 -0
- package/dist/agent/prompt/memory/index.js.map +1 -0
- package/dist/agent/prompt/modes.d.ts +44 -0
- package/dist/agent/prompt/modes.js +167 -0
- package/dist/agent/prompt/modes.js.map +1 -0
- package/dist/agent/prompt/safety.d.ts +88 -0
- package/dist/agent/prompt/safety.js +290 -0
- package/dist/agent/prompt/safety.js.map +1 -0
- package/dist/agent/service.d.ts +91 -0
- package/dist/agent/service.js +641 -0
- package/dist/agent/service.js.map +1 -0
- package/dist/agent/session-tracker.d.ts +73 -0
- package/dist/agent/session-tracker.js +137 -0
- package/dist/agent/session-tracker.js.map +1 -0
- package/dist/agent/skills/__tests__/test-framework.test.d.ts +4 -0
- package/dist/agent/skills/__tests__/test-framework.test.js +343 -0
- package/dist/agent/skills/__tests__/test-framework.test.js.map +1 -0
- package/dist/agent/skills/config.d.ts +58 -0
- package/dist/agent/skills/config.js +212 -0
- package/dist/agent/skills/config.js.map +1 -0
- package/dist/agent/skills/index.d.ts +25 -0
- package/dist/agent/skills/index.js +349 -0
- package/dist/agent/skills/index.js.map +1 -0
- package/dist/agent/skills/installer.d.ts +38 -0
- package/dist/agent/skills/installer.js +352 -0
- package/dist/agent/skills/installer.js.map +1 -0
- package/dist/agent/skills/scanner.d.ts +32 -0
- package/dist/agent/skills/scanner.js +265 -0
- package/dist/agent/skills/scanner.js.map +1 -0
- package/dist/agent/skills/test-framework.d.ts +107 -0
- package/dist/agent/skills/test-framework.js +607 -0
- package/dist/agent/skills/test-framework.js.map +1 -0
- package/dist/agent/skills/types.d.ts +181 -0
- package/dist/agent/skills/types.js +7 -0
- package/dist/agent/skills/types.js.map +1 -0
- package/dist/agent/skills/watcher.d.ts +37 -0
- package/dist/agent/skills/watcher.js +124 -0
- package/dist/agent/skills/watcher.js.map +1 -0
- package/dist/agent/tools/communication.d.ts +18 -0
- package/dist/agent/tools/communication.js +56 -0
- package/dist/agent/tools/communication.js.map +1 -0
- package/dist/agent/tools/edit-diff.d.ts +21 -0
- package/dist/agent/tools/edit-diff.js +69 -0
- package/dist/agent/tools/edit-diff.js.map +1 -0
- package/dist/agent/tools/edit.d.ts +13 -0
- package/dist/agent/tools/edit.js +65 -0
- package/dist/agent/tools/edit.js.map +1 -0
- package/dist/agent/tools/find.d.ts +24 -0
- package/dist/agent/tools/find.js +99 -0
- package/dist/agent/tools/find.js.map +1 -0
- package/dist/agent/tools/grep.d.ts +33 -0
- package/dist/agent/tools/grep.js +183 -0
- package/dist/agent/tools/grep.js.map +1 -0
- package/dist/agent/tools/index.d.ts +13 -0
- package/dist/agent/tools/index.js +18 -0
- package/dist/agent/tools/index.js.map +1 -0
- package/dist/agent/tools/list-dir.d.ts +6 -0
- package/dist/agent/tools/list-dir.js +37 -0
- package/dist/agent/tools/list-dir.js.map +1 -0
- package/dist/agent/tools/memory-tool.d.ts +14 -0
- package/dist/agent/tools/memory-tool.js +81 -0
- package/dist/agent/tools/memory-tool.js.map +1 -0
- package/dist/agent/tools/path-utils.d.ts +4 -0
- package/dist/agent/tools/path-utils.js +13 -0
- package/dist/agent/tools/path-utils.js.map +1 -0
- package/dist/agent/tools/read.d.ts +7 -0
- package/dist/agent/tools/read.js +47 -0
- package/dist/agent/tools/read.js.map +1 -0
- package/dist/agent/tools/send-media.d.ts +18 -0
- package/dist/agent/tools/send-media.js +104 -0
- package/dist/agent/tools/send-media.js.map +1 -0
- package/dist/agent/tools/shell.d.ts +13 -0
- package/dist/agent/tools/shell.js +114 -0
- package/dist/agent/tools/shell.js.map +1 -0
- package/dist/agent/tools/truncate.d.ts +36 -0
- package/dist/agent/tools/truncate.js +98 -0
- package/dist/agent/tools/truncate.js.map +1 -0
- package/dist/agent/tools/web.d.ts +14 -0
- package/dist/agent/tools/web.js +109 -0
- package/dist/agent/tools/web.js.map +1 -0
- package/dist/agent/tools/write.d.ts +7 -0
- package/dist/agent/tools/write.js +35 -0
- package/dist/agent/tools/write.js.map +1 -0
- package/dist/agent/types.d.ts +8 -0
- package/dist/agent/types.js +2 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/agent/typing.d.ts +9 -0
- package/dist/agent/typing.js +32 -0
- package/dist/agent/typing.js.map +1 -0
- package/dist/auth/index.d.ts +12 -0
- package/dist/auth/index.js +14 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/oauth/anthropic.d.ts +7 -0
- package/dist/auth/oauth/anthropic.js +89 -0
- package/dist/auth/oauth/anthropic.js.map +1 -0
- package/dist/auth/oauth/github-copilot.d.ts +8 -0
- package/dist/auth/oauth/github-copilot.js +35 -0
- package/dist/auth/oauth/github-copilot.js.map +1 -0
- package/dist/auth/oauth/google-antigravity.d.ts +7 -0
- package/dist/auth/oauth/google-antigravity.js +27 -0
- package/dist/auth/oauth/google-antigravity.js.map +1 -0
- package/dist/auth/oauth/google-gemini-cli.d.ts +7 -0
- package/dist/auth/oauth/google-gemini-cli.js +28 -0
- package/dist/auth/oauth/google-gemini-cli.js.map +1 -0
- package/dist/auth/oauth/index.d.ts +14 -0
- package/dist/auth/oauth/index.js +15 -0
- package/dist/auth/oauth/index.js.map +1 -0
- package/dist/auth/oauth/kimi.d.ts +8 -0
- package/dist/auth/oauth/kimi.js +104 -0
- package/dist/auth/oauth/kimi.js.map +1 -0
- package/dist/auth/oauth/minimax.d.ts +8 -0
- package/dist/auth/oauth/minimax.js +109 -0
- package/dist/auth/oauth/minimax.js.map +1 -0
- package/dist/auth/oauth/openai-codex.d.ts +7 -0
- package/dist/auth/oauth/openai-codex.js +33 -0
- package/dist/auth/oauth/openai-codex.js.map +1 -0
- package/dist/auth/oauth/pkce.d.ts +8 -0
- package/dist/auth/oauth/pkce.js +22 -0
- package/dist/auth/oauth/pkce.js.map +1 -0
- package/dist/auth/oauth/qwen.d.ts +7 -0
- package/dist/auth/oauth/qwen.js +114 -0
- package/dist/auth/oauth/qwen.js.map +1 -0
- package/dist/auth/oauth/types.d.ts +46 -0
- package/dist/auth/oauth/types.js +7 -0
- package/dist/auth/oauth/types.js.map +1 -0
- package/dist/auth/profiles/index.d.ts +16 -0
- package/dist/auth/profiles/index.js +17 -0
- package/dist/auth/profiles/index.js.map +1 -0
- package/dist/auth/profiles/oauth.d.ts +12 -0
- package/dist/auth/profiles/oauth.js +106 -0
- package/dist/auth/profiles/oauth.js.map +1 -0
- package/dist/auth/profiles/order.d.ts +19 -0
- package/dist/auth/profiles/order.js +63 -0
- package/dist/auth/profiles/order.js.map +1 -0
- package/dist/auth/profiles/profiles.d.ts +27 -0
- package/dist/auth/profiles/profiles.js +110 -0
- package/dist/auth/profiles/profiles.js.map +1 -0
- package/dist/auth/profiles/store.d.ts +17 -0
- package/dist/auth/profiles/store.js +234 -0
- package/dist/auth/profiles/store.js.map +1 -0
- package/dist/auth/profiles/types.d.ts +64 -0
- package/dist/auth/profiles/types.js +7 -0
- package/dist/auth/profiles/types.js.map +1 -0
- package/dist/auth/profiles/usage.d.ts +24 -0
- package/dist/auth/profiles/usage.js +99 -0
- package/dist/auth/profiles/usage.js.map +1 -0
- package/dist/auth/storage.d.ts +99 -0
- package/dist/auth/storage.js +315 -0
- package/dist/auth/storage.js.map +1 -0
- package/dist/bus/index.d.ts +3 -0
- package/dist/bus/index.js +2 -0
- package/dist/bus/index.js.map +1 -0
- package/dist/bus/queue.d.ts +20 -0
- package/dist/bus/queue.js +57 -0
- package/dist/bus/queue.js.map +1 -0
- package/dist/channels/__tests__/access-control.test.d.ts +4 -0
- package/dist/channels/__tests__/access-control.test.js +310 -0
- package/dist/channels/__tests__/access-control.test.js.map +1 -0
- package/dist/channels/__tests__/draft-stream.test.d.ts +4 -0
- package/dist/channels/__tests__/draft-stream.test.js +243 -0
- package/dist/channels/__tests__/draft-stream.test.js.map +1 -0
- package/dist/channels/__tests__/format.test.d.ts +4 -0
- package/dist/channels/__tests__/format.test.js +146 -0
- package/dist/channels/__tests__/format.test.js.map +1 -0
- package/dist/channels/__tests__/manager.test.d.ts +6 -0
- package/dist/channels/__tests__/manager.test.js +34 -0
- package/dist/channels/__tests__/manager.test.js.map +1 -0
- package/dist/channels/__tests__/typing-controller.test.d.ts +4 -0
- package/dist/channels/__tests__/typing-controller.test.js +109 -0
- package/dist/channels/__tests__/typing-controller.test.js.map +1 -0
- package/dist/channels/__tests__/update-offset-store.test.d.ts +7 -0
- package/dist/channels/__tests__/update-offset-store.test.js +35 -0
- package/dist/channels/__tests__/update-offset-store.test.js.map +1 -0
- package/dist/channels/access-control.d.ts +93 -0
- package/dist/channels/access-control.js +201 -0
- package/dist/channels/access-control.js.map +1 -0
- package/dist/channels/draft-stream.d.ts +55 -0
- package/dist/channels/draft-stream.js +211 -0
- package/dist/channels/draft-stream.js.map +1 -0
- package/dist/channels/format.d.ts +38 -0
- package/dist/channels/format.js +187 -0
- package/dist/channels/format.js.map +1 -0
- package/dist/channels/index.d.ts +22 -0
- package/dist/channels/index.js +23 -0
- package/dist/channels/index.js.map +1 -0
- package/dist/channels/manager.d.ts +30 -0
- package/dist/channels/manager.js +125 -0
- package/dist/channels/manager.js.map +1 -0
- package/dist/channels/telegram/__tests__/index.test.d.ts +4 -0
- package/dist/channels/telegram/__tests__/index.test.js +153 -0
- package/dist/channels/telegram/__tests__/index.test.js.map +1 -0
- package/dist/channels/telegram/__tests__/inline-keyboards.test.d.ts +4 -0
- package/dist/channels/telegram/__tests__/inline-keyboards.test.js +99 -0
- package/dist/channels/telegram/__tests__/inline-keyboards.test.js.map +1 -0
- package/dist/channels/telegram/client.d.ts +48 -0
- package/dist/channels/telegram/client.js +177 -0
- package/dist/channels/telegram/client.js.map +1 -0
- package/dist/channels/telegram/command-handler.d.ts +28 -0
- package/dist/channels/telegram/command-handler.js +209 -0
- package/dist/channels/telegram/command-handler.js.map +1 -0
- package/dist/channels/telegram/index.d.ts +8 -0
- package/dist/channels/telegram/index.js +9 -0
- package/dist/channels/telegram/index.js.map +1 -0
- package/dist/channels/telegram/inline-keyboards.d.ts +20 -0
- package/dist/channels/telegram/inline-keyboards.js +38 -0
- package/dist/channels/telegram/inline-keyboards.js.map +1 -0
- package/dist/channels/telegram/plugin.d.ts +33 -0
- package/dist/channels/telegram/plugin.js +640 -0
- package/dist/channels/telegram/plugin.js.map +1 -0
- package/dist/channels/telegram/webhook.d.ts +31 -0
- package/dist/channels/telegram/webhook.js +129 -0
- package/dist/channels/telegram/webhook.js.map +1 -0
- package/dist/channels/types.d.ts +186 -0
- package/dist/channels/types.js +7 -0
- package/dist/channels/types.js.map +1 -0
- package/dist/channels/typing-controller.d.ts +47 -0
- package/dist/channels/typing-controller.js +117 -0
- package/dist/channels/typing-controller.js.map +1 -0
- package/dist/channels/update-offset-store.d.ts +37 -0
- package/dist/channels/update-offset-store.js +165 -0
- package/dist/channels/update-offset-store.js.map +1 -0
- package/dist/channels/whatsapp/index.d.ts +4 -0
- package/dist/channels/whatsapp/index.js +5 -0
- package/dist/channels/whatsapp/index.js.map +1 -0
- package/dist/channels/whatsapp/plugin.d.ts +27 -0
- package/dist/channels/whatsapp/plugin.js +66 -0
- package/dist/channels/whatsapp/plugin.js.map +1 -0
- package/dist/cli/__tests__/registry.test.d.ts +1 -0
- package/dist/cli/__tests__/registry.test.js +366 -0
- package/dist/cli/__tests__/registry.test.js.map +1 -0
- package/dist/cli/commands/agent.d.ts +1 -0
- package/dist/cli/commands/agent.js +216 -0
- package/dist/cli/commands/agent.js.map +1 -0
- package/dist/cli/commands/auth.d.ts +6 -0
- package/dist/cli/commands/auth.js +440 -0
- package/dist/cli/commands/auth.js.map +1 -0
- package/dist/cli/commands/config.d.ts +1 -0
- package/dist/cli/commands/config.js +135 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/configure.d.ts +1 -0
- package/dist/cli/commands/configure.js +173 -0
- package/dist/cli/commands/configure.js.map +1 -0
- package/dist/cli/commands/cron.d.ts +1 -0
- package/dist/cli/commands/cron.js +81 -0
- package/dist/cli/commands/cron.js.map +1 -0
- package/dist/cli/commands/gateway.d.ts +1 -0
- package/dist/cli/commands/gateway.js +91 -0
- package/dist/cli/commands/gateway.js.map +1 -0
- package/dist/cli/commands/index.d.ts +0 -0
- package/dist/cli/commands/index.js +2 -0
- package/dist/cli/commands/index.js.map +1 -0
- package/dist/cli/commands/models.d.ts +1 -0
- package/dist/cli/commands/models.js +79 -0
- package/dist/cli/commands/models.js.map +1 -0
- package/dist/cli/commands/onboard.d.ts +1 -0
- package/dist/cli/commands/onboard.js +621 -0
- package/dist/cli/commands/onboard.js.map +1 -0
- package/dist/cli/commands/plugin.d.ts +1 -0
- package/dist/cli/commands/plugin.js +341 -0
- package/dist/cli/commands/plugin.js.map +1 -0
- package/dist/cli/commands/session.d.ts +1 -0
- package/dist/cli/commands/session.js +450 -0
- package/dist/cli/commands/session.js.map +1 -0
- package/dist/cli/commands/skills-test.d.ts +9 -0
- package/dist/cli/commands/skills-test.js +195 -0
- package/dist/cli/commands/skills-test.js.map +1 -0
- package/dist/cli/commands/skills.d.ts +9 -0
- package/dist/cli/commands/skills.js +385 -0
- package/dist/cli/commands/skills.js.map +1 -0
- package/dist/cli/index.d.ts +19 -0
- package/dist/cli/index.js +40 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/registry.d.ts +43 -0
- package/dist/cli/registry.js +82 -0
- package/dist/cli/registry.js.map +1 -0
- package/dist/cli/templates.d.ts +19 -0
- package/dist/cli/templates.js +191 -0
- package/dist/cli/templates.js.map +1 -0
- package/dist/cli/utils/colors.d.ts +13 -0
- package/dist/cli/utils/colors.js +16 -0
- package/dist/cli/utils/colors.js.map +1 -0
- package/dist/config/__tests__/diff.test.d.ts +1 -0
- package/dist/config/__tests__/diff.test.js +192 -0
- package/dist/config/__tests__/diff.test.js.map +1 -0
- package/dist/config/__tests__/loader.test.d.ts +1 -0
- package/dist/config/__tests__/loader.test.js +356 -0
- package/dist/config/__tests__/loader.test.js.map +1 -0
- package/dist/config/__tests__/paths.test.d.ts +1 -0
- package/dist/config/__tests__/paths.test.js +192 -0
- package/dist/config/__tests__/paths.test.js.map +1 -0
- package/dist/config/__tests__/reload.test.d.ts +1 -0
- package/dist/config/__tests__/reload.test.js +374 -0
- package/dist/config/__tests__/reload.test.js.map +1 -0
- package/dist/config/__tests__/rules.test.d.ts +1 -0
- package/dist/config/__tests__/rules.test.js +204 -0
- package/dist/config/__tests__/rules.test.js.map +1 -0
- package/dist/config/__tests__/schema.test.d.ts +1 -0
- package/dist/config/__tests__/schema.test.js +672 -0
- package/dist/config/__tests__/schema.test.js.map +1 -0
- package/dist/config/diff.d.ts +7 -0
- package/dist/config/diff.js +46 -0
- package/dist/config/diff.js.map +1 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.js +7 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +5 -0
- package/dist/config/loader.js +81 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/paths.d.ts +35 -0
- package/dist/config/paths.js +79 -0
- package/dist/config/paths.js.map +1 -0
- package/dist/config/reload.d.ts +78 -0
- package/dist/config/reload.js +190 -0
- package/dist/config/reload.js.map +1 -0
- package/dist/config/rules.d.ts +42 -0
- package/dist/config/rules.js +114 -0
- package/dist/config/rules.js.map +1 -0
- package/dist/config/schema.d.ts +1340 -0
- package/dist/config/schema.js +611 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/cron/executor.d.ts +54 -0
- package/dist/cron/executor.js +364 -0
- package/dist/cron/executor.js.map +1 -0
- package/dist/cron/index.d.ts +5 -0
- package/dist/cron/index.js +6 -0
- package/dist/cron/index.js.map +1 -0
- package/dist/cron/persistence.d.ts +61 -0
- package/dist/cron/persistence.js +188 -0
- package/dist/cron/persistence.js.map +1 -0
- package/dist/cron/service.d.ts +94 -0
- package/dist/cron/service.js +382 -0
- package/dist/cron/service.js.map +1 -0
- package/dist/cron/types.d.ts +119 -0
- package/dist/cron/types.js +3 -0
- package/dist/cron/types.js.map +1 -0
- package/dist/cron/validation.d.ts +144 -0
- package/dist/cron/validation.js +113 -0
- package/dist/cron/validation.js.map +1 -0
- package/dist/errors/__tests__/index.test.d.ts +1 -0
- package/dist/errors/__tests__/index.test.js +301 -0
- package/dist/errors/__tests__/index.test.js.map +1 -0
- package/dist/errors/index.d.ts +114 -0
- package/dist/errors/index.js +278 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/gateway/hono/app.d.ts +7 -0
- package/dist/gateway/hono/app.js +668 -0
- package/dist/gateway/hono/app.js.map +1 -0
- package/dist/gateway/hono/index.d.ts +2 -0
- package/dist/gateway/hono/index.js +3 -0
- package/dist/gateway/hono/index.js.map +1 -0
- package/dist/gateway/hono/middleware/auth.d.ts +18 -0
- package/dist/gateway/hono/middleware/auth.js +79 -0
- package/dist/gateway/hono/middleware/auth.js.map +1 -0
- package/dist/gateway/hono/middleware/logger.d.ts +1 -0
- package/dist/gateway/hono/middleware/logger.js +17 -0
- package/dist/gateway/hono/middleware/logger.js.map +1 -0
- package/dist/gateway/hono/sse.d.ts +55 -0
- package/dist/gateway/hono/sse.js +224 -0
- package/dist/gateway/hono/sse.js.map +1 -0
- package/dist/gateway/index.d.ts +4 -0
- package/dist/gateway/index.js +5 -0
- package/dist/gateway/index.js.map +1 -0
- package/dist/gateway/protocol.d.ts +28 -0
- package/dist/gateway/protocol.js +14 -0
- package/dist/gateway/protocol.js.map +1 -0
- package/dist/gateway/server.d.ts +19 -0
- package/dist/gateway/server.js +64 -0
- package/dist/gateway/server.js.map +1 -0
- package/dist/gateway/service.d.ts +265 -0
- package/dist/gateway/service.js +621 -0
- package/dist/gateway/service.js.map +1 -0
- package/dist/gateway/static/root/assets/main-CfIxL-cL.js +2105 -0
- package/dist/gateway/static/root/assets/main-CfIxL-cL.js.map +1 -0
- package/dist/gateway/static/root/assets/main-DndcTCgX.css +1 -0
- package/dist/gateway/static/root/index.html +116 -0
- package/dist/heartbeat/index.d.ts +1 -0
- package/dist/heartbeat/index.js +2 -0
- package/dist/heartbeat/index.js.map +1 -0
- package/dist/heartbeat/service.d.ts +19 -0
- package/dist/heartbeat/service.js +61 -0
- package/dist/heartbeat/service.js.map +1 -0
- package/dist/plugin-sdk/index.d.ts +21 -0
- package/dist/plugin-sdk/index.js +12 -0
- package/dist/plugin-sdk/index.js.map +1 -0
- package/dist/plugins/__tests__/api.test.d.ts +1 -0
- package/dist/plugins/__tests__/api.test.js +164 -0
- package/dist/plugins/__tests__/api.test.js.map +1 -0
- package/dist/plugins/__tests__/hooks.test.d.ts +1 -0
- package/dist/plugins/__tests__/hooks.test.js +159 -0
- package/dist/plugins/__tests__/hooks.test.js.map +1 -0
- package/dist/plugins/__tests__/loader.test.d.ts +1 -0
- package/dist/plugins/__tests__/loader.test.js +120 -0
- package/dist/plugins/__tests__/loader.test.js.map +1 -0
- package/dist/plugins/api.d.ts +41 -0
- package/dist/plugins/api.js +131 -0
- package/dist/plugins/api.js.map +1 -0
- package/dist/plugins/hooks.d.ts +153 -0
- package/dist/plugins/hooks.js +172 -0
- package/dist/plugins/hooks.js.map +1 -0
- package/dist/plugins/index.d.ts +11 -0
- package/dist/plugins/index.js +16 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/install.d.ts +59 -0
- package/dist/plugins/install.js +324 -0
- package/dist/plugins/install.js.map +1 -0
- package/dist/plugins/loader.d.ts +84 -0
- package/dist/plugins/loader.js +545 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/types.d.ts +190 -0
- package/dist/plugins/types.js +7 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/providers/__tests__/registry.test.d.ts +1 -0
- package/dist/providers/__tests__/registry.test.js +110 -0
- package/dist/providers/__tests__/registry.test.js.map +1 -0
- package/dist/providers/api-strategies.d.ts +15 -0
- package/dist/providers/api-strategies.js +96 -0
- package/dist/providers/api-strategies.js.map +1 -0
- package/dist/providers/auto-discovery.d.ts +84 -0
- package/dist/providers/auto-discovery.js +236 -0
- package/dist/providers/auto-discovery.js.map +1 -0
- package/dist/providers/config.d.ts +25 -0
- package/dist/providers/config.js +42 -0
- package/dist/providers/config.js.map +1 -0
- package/dist/providers/index.d.ts +25 -0
- package/dist/providers/index.js +55 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/model-catalog.d.ts +205 -0
- package/dist/providers/model-catalog.js +1071 -0
- package/dist/providers/model-catalog.js.map +1 -0
- package/dist/providers/models-dev-data.d.ts +11 -0
- package/dist/providers/models-dev-data.js +1035 -0
- package/dist/providers/models-dev-data.js.map +1 -0
- package/dist/providers/models-dev.d.ts +30 -0
- package/dist/providers/models-dev.js +42 -0
- package/dist/providers/models-dev.js.map +1 -0
- package/dist/providers/pi-ai.d.ts +62 -0
- package/dist/providers/pi-ai.js +221 -0
- package/dist/providers/pi-ai.js.map +1 -0
- package/dist/providers/provider-catalog.d.ts +173 -0
- package/dist/providers/provider-catalog.js +834 -0
- package/dist/providers/provider-catalog.js.map +1 -0
- package/dist/providers/registry.d.ts +155 -0
- package/dist/providers/registry.js +524 -0
- package/dist/providers/registry.js.map +1 -0
- package/dist/providers/types.d.ts +95 -0
- package/dist/providers/types.js +7 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/session/chat-manager.d.ts +49 -0
- package/dist/session/chat-manager.js +167 -0
- package/dist/session/chat-manager.js.map +1 -0
- package/dist/session/chat-types.d.ts +53 -0
- package/dist/session/chat-types.js +63 -0
- package/dist/session/chat-types.js.map +1 -0
- package/dist/session/index.d.ts +5 -0
- package/dist/session/index.js +5 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/manager.d.ts +103 -0
- package/dist/session/manager.js +200 -0
- package/dist/session/manager.js.map +1 -0
- package/dist/session/store.d.ts +114 -0
- package/dist/session/store.js +687 -0
- package/dist/session/store.js.map +1 -0
- package/dist/session/types.d.ts +88 -0
- package/dist/session/types.js +10 -0
- package/dist/session/types.js.map +1 -0
- package/dist/types/index.d.ts +177 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/providers.d.ts +67 -0
- package/dist/types/providers.js +7 -0
- package/dist/types/providers.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +17 -0
- package/dist/utils/frontmatter.js +104 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/helpers.d.ts +5 -0
- package/dist/utils/helpers.js +36 -0
- package/dist/utils/helpers.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/log-store.d.ts +78 -0
- package/dist/utils/log-store.js +432 -0
- package/dist/utils/log-store.js.map +1 -0
- package/dist/utils/logger.d.ts +127 -0
- package/dist/utils/logger.js +481 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/logger.types.d.ts +152 -0
- package/dist/utils/logger.types.js +30 -0
- package/dist/utils/logger.types.js.map +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
// Heartbeat System - Proactive monitoring and intelligent checks
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
// =============================================================================
|
|
5
|
+
// Default Configuration
|
|
6
|
+
// =============================================================================
|
|
7
|
+
export const DEFAULT_HEARTBEAT_CONFIG = {
|
|
8
|
+
enabled: true,
|
|
9
|
+
interval: 30, // 30 minutes
|
|
10
|
+
checks: [
|
|
11
|
+
{
|
|
12
|
+
name: 'email',
|
|
13
|
+
enabled: false,
|
|
14
|
+
priority: 'high',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'calendar',
|
|
18
|
+
enabled: true,
|
|
19
|
+
priority: 'normal',
|
|
20
|
+
interval: 60, // 1 hour
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'mentions',
|
|
24
|
+
enabled: true,
|
|
25
|
+
priority: 'high',
|
|
26
|
+
interval: 15,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'weather',
|
|
30
|
+
enabled: false,
|
|
31
|
+
priority: 'low',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
quietHours: {
|
|
35
|
+
start: 23,
|
|
36
|
+
end: 8,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
// =============================================================================
|
|
40
|
+
// Heartbeat Manager
|
|
41
|
+
// =============================================================================
|
|
42
|
+
export class HeartbeatManager {
|
|
43
|
+
config;
|
|
44
|
+
state;
|
|
45
|
+
statePath;
|
|
46
|
+
timers = new Map();
|
|
47
|
+
constructor(configDir, config) {
|
|
48
|
+
this.config = { ...DEFAULT_HEARTBEAT_CONFIG, ...config };
|
|
49
|
+
this.statePath = join(configDir, 'heartbeat-state.json');
|
|
50
|
+
this.state = this.loadState();
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Load state from disk
|
|
54
|
+
*/
|
|
55
|
+
loadState() {
|
|
56
|
+
if (existsSync(this.statePath)) {
|
|
57
|
+
try {
|
|
58
|
+
const content = readFileSync(this.statePath, 'utf-8');
|
|
59
|
+
return JSON.parse(content);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return { lastChecks: {}, lastResults: {} };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return { lastChecks: {}, lastResults: {} };
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Save state to disk
|
|
69
|
+
*/
|
|
70
|
+
saveState() {
|
|
71
|
+
const content = JSON.stringify(this.state, null, 2);
|
|
72
|
+
writeFileSync(this.statePath, content, 'utf-8');
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Check if quiet hours are active
|
|
76
|
+
*/
|
|
77
|
+
isQuietHours() {
|
|
78
|
+
if (!this.config.quietHours)
|
|
79
|
+
return false;
|
|
80
|
+
const now = new Date();
|
|
81
|
+
const currentHour = now.getHours();
|
|
82
|
+
const { start, end } = this.config.quietHours;
|
|
83
|
+
if (start > end) {
|
|
84
|
+
// Wraps around midnight (e.g., 23-7)
|
|
85
|
+
return currentHour >= start || currentHour < end;
|
|
86
|
+
}
|
|
87
|
+
return currentHour >= start && currentHour < end;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Check if a specific check should run
|
|
91
|
+
*/
|
|
92
|
+
shouldRunCheck(check) {
|
|
93
|
+
if (!check.enabled)
|
|
94
|
+
return false;
|
|
95
|
+
if (this.isQuietHours())
|
|
96
|
+
return false;
|
|
97
|
+
const lastRun = this.state.lastChecks[check.name] || 0;
|
|
98
|
+
const interval = (check.interval || this.config.interval) * 60 * 1000;
|
|
99
|
+
const now = Date.now();
|
|
100
|
+
return (now - lastRun) >= interval;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Execute a single check
|
|
104
|
+
*/
|
|
105
|
+
async executeCheck(check) {
|
|
106
|
+
try {
|
|
107
|
+
let result;
|
|
108
|
+
switch (check.name) {
|
|
109
|
+
case 'email':
|
|
110
|
+
result = await this.checkEmail();
|
|
111
|
+
break;
|
|
112
|
+
case 'calendar':
|
|
113
|
+
result = await this.checkCalendar();
|
|
114
|
+
break;
|
|
115
|
+
case 'mentions':
|
|
116
|
+
result = await this.checkMentions();
|
|
117
|
+
break;
|
|
118
|
+
case 'weather':
|
|
119
|
+
result = await this.checkWeather();
|
|
120
|
+
break;
|
|
121
|
+
default:
|
|
122
|
+
result = {
|
|
123
|
+
check: check.name,
|
|
124
|
+
status: 'skipped',
|
|
125
|
+
message: `Unknown check: ${check.name}`,
|
|
126
|
+
timestamp: new Date(),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
// Update state
|
|
130
|
+
this.state.lastChecks[check.name] = Date.now();
|
|
131
|
+
this.state.lastResults[check.name] = result;
|
|
132
|
+
this.saveState();
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
const result = {
|
|
137
|
+
check: check.name,
|
|
138
|
+
status: 'error',
|
|
139
|
+
message: `Check failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
140
|
+
timestamp: new Date(),
|
|
141
|
+
};
|
|
142
|
+
this.state.lastChecks[check.name] = Date.now();
|
|
143
|
+
this.state.lastResults[check.name] = result;
|
|
144
|
+
this.saveState();
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Execute all due checks
|
|
150
|
+
*/
|
|
151
|
+
async executeAllChecks() {
|
|
152
|
+
const results = [];
|
|
153
|
+
for (const check of this.config.checks) {
|
|
154
|
+
if (this.shouldRunCheck(check)) {
|
|
155
|
+
const result = await this.executeCheck(check);
|
|
156
|
+
results.push(result);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return results;
|
|
160
|
+
}
|
|
161
|
+
// =============================================================================
|
|
162
|
+
// Individual Check Implementations
|
|
163
|
+
// =============================================================================
|
|
164
|
+
async checkEmail() {
|
|
165
|
+
// Placeholder - would need email API integration
|
|
166
|
+
return {
|
|
167
|
+
check: 'email',
|
|
168
|
+
status: 'ok',
|
|
169
|
+
message: 'Email check not configured',
|
|
170
|
+
timestamp: new Date(),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
async checkCalendar() {
|
|
174
|
+
// Placeholder - would need calendar API integration
|
|
175
|
+
return {
|
|
176
|
+
check: 'calendar',
|
|
177
|
+
status: 'ok',
|
|
178
|
+
message: 'Calendar check not configured',
|
|
179
|
+
timestamp: new Date(),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
async checkMentions() {
|
|
183
|
+
// Placeholder - would need social media API integration
|
|
184
|
+
return {
|
|
185
|
+
check: 'mentions',
|
|
186
|
+
status: 'ok',
|
|
187
|
+
message: 'Mentions check not configured',
|
|
188
|
+
timestamp: new Date(),
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
async checkWeather() {
|
|
192
|
+
// Placeholder - would need weather API integration
|
|
193
|
+
return {
|
|
194
|
+
check: 'weather',
|
|
195
|
+
status: 'ok',
|
|
196
|
+
message: 'Weather check not configured',
|
|
197
|
+
timestamp: new Date(),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
// =============================================================================
|
|
201
|
+
// Public API
|
|
202
|
+
// =============================================================================
|
|
203
|
+
/**
|
|
204
|
+
* Get current state
|
|
205
|
+
*/
|
|
206
|
+
getState() {
|
|
207
|
+
return { ...this.state };
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Get last result for a check
|
|
211
|
+
*/
|
|
212
|
+
getLastResult(checkName) {
|
|
213
|
+
return this.state.lastResults[checkName];
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Get all results
|
|
217
|
+
*/
|
|
218
|
+
getAllResults() {
|
|
219
|
+
return Object.values(this.state.lastResults);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Enable/disable a check
|
|
223
|
+
*/
|
|
224
|
+
setCheckEnabled(checkName, enabled) {
|
|
225
|
+
const check = this.config.checks.find(c => c.name === checkName);
|
|
226
|
+
if (!check)
|
|
227
|
+
return false;
|
|
228
|
+
check.enabled = enabled;
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Format results for display
|
|
233
|
+
*/
|
|
234
|
+
formatResults(results) {
|
|
235
|
+
if (results.length === 0) {
|
|
236
|
+
return 'No checks to report.';
|
|
237
|
+
}
|
|
238
|
+
const lines = ['## Heartbeat Results', ''];
|
|
239
|
+
for (const result of results) {
|
|
240
|
+
const icon = {
|
|
241
|
+
ok: '✅',
|
|
242
|
+
warning: '⚠️',
|
|
243
|
+
error: '🚫',
|
|
244
|
+
skipped: '⏭️',
|
|
245
|
+
}[result.status];
|
|
246
|
+
lines.push(`${icon} **${result.check}**: ${result.message}`);
|
|
247
|
+
}
|
|
248
|
+
return lines.join('\n');
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// =============================================================================
|
|
252
|
+
// Heartbeat Prompt Section
|
|
253
|
+
// =============================================================================
|
|
254
|
+
export function buildHeartbeatPromptSection(config, results = []) {
|
|
255
|
+
if (!config.enabled) {
|
|
256
|
+
return '';
|
|
257
|
+
}
|
|
258
|
+
const lines = [
|
|
259
|
+
'## Heartbeats',
|
|
260
|
+
'',
|
|
261
|
+
'Heartbeats enable proactive monitoring.',
|
|
262
|
+
'',
|
|
263
|
+
'### Available Checks',
|
|
264
|
+
];
|
|
265
|
+
for (const check of config.checks) {
|
|
266
|
+
const status = results.find(r => r.check === check.name);
|
|
267
|
+
const statusIcon = status ? {
|
|
268
|
+
ok: '✅',
|
|
269
|
+
warning: '⚠️',
|
|
270
|
+
error: '🚫',
|
|
271
|
+
skipped: '⏭️',
|
|
272
|
+
}[status.status] : '⏳';
|
|
273
|
+
lines.push(`- ${statusIcon} ${check.name} (${check.priority})`);
|
|
274
|
+
}
|
|
275
|
+
if (config.quietHours) {
|
|
276
|
+
lines.push('', `**Quiet hours**: ${config.quietHours.start}:00 - ${config.quietHours.end}:00`);
|
|
277
|
+
}
|
|
278
|
+
lines.push('', 'When polling and nothing needs attention, reply: `HEARTBEAT_OK`', 'Only reply with alerts when something needs attention.');
|
|
279
|
+
return lines.join('\n');
|
|
280
|
+
}
|
|
281
|
+
// =============================================================================
|
|
282
|
+
// Singleton
|
|
283
|
+
// =============================================================================
|
|
284
|
+
let heartbeatManager = null;
|
|
285
|
+
export function getHeartbeatManager(configDir) {
|
|
286
|
+
if (!heartbeatManager) {
|
|
287
|
+
heartbeatManager = new HeartbeatManager(configDir);
|
|
288
|
+
}
|
|
289
|
+
return heartbeatManager;
|
|
290
|
+
}
|
|
291
|
+
// =============================================================================
|
|
292
|
+
// Convenience Functions
|
|
293
|
+
// =============================================================================
|
|
294
|
+
/**
|
|
295
|
+
* Quick heartbeat check
|
|
296
|
+
*/
|
|
297
|
+
export async function quickHeartbeat(configDir) {
|
|
298
|
+
const manager = getHeartbeatManager(configDir);
|
|
299
|
+
return manager.executeAllChecks();
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Get heartbeat status summary
|
|
303
|
+
*/
|
|
304
|
+
export function getHeartbeatStatus(configDir) {
|
|
305
|
+
const manager = getHeartbeatManager(configDir);
|
|
306
|
+
return {
|
|
307
|
+
enabled: manager['config'].enabled,
|
|
308
|
+
quietHours: manager.isQuietHours(),
|
|
309
|
+
checks: manager['config'].checks.filter(c => c.enabled).length,
|
|
310
|
+
results: manager.getAllResults(),
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
//# sourceMappingURL=heartbeat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heartbeat.js","sourceRoot":"","sources":["../../../src/agent/prompt/heartbeat.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAoC5B,gFAAgF;AAChF,wBAAwB;AACxB,gFAAgF;AAEhF,MAAM,CAAC,MAAM,wBAAwB,GAAoB;IACvD,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,EAAE,EAAE,aAAa;IAC3B,MAAM,EAAE;QACN;YACE,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,MAAM;SACjB;QACD;YACE,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,QAAQ;YAClB,QAAQ,EAAE,EAAE,EAAE,SAAS;SACxB;QACD;YACE,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,MAAM;YAChB,QAAQ,EAAE,EAAE;SACb;QACD;YACE,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,KAAK;SAChB;KACF;IACD,UAAU,EAAE;QACV,KAAK,EAAE,EAAE;QACT,GAAG,EAAE,CAAC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,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,gFAAgF;AAChF,wBAAwB;AACxB,gFAAgF;AAEhF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,SAAiB;IACpD,MAAM,OAAO,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC,gBAAgB,EAAE,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAiB;IAMlD,MAAM,OAAO,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC/C,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO;QAClC,UAAU,EAAE,OAAO,CAAC,YAAY,EAAE;QAClC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM;QAC9D,OAAO,EAAE,OAAO,CAAC,aAAa,EAAE;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Static } from '@sinclair/typebox';
|
|
2
|
+
export declare const PromptConfigSchema: import("@sinclair/typebox/build/cjs/index.js").TObject<{
|
|
3
|
+
mode: import("@sinclair/typebox/build/cjs/index.js").TUnion<[import("@sinclair/typebox/build/cjs/index.js").TLiteral<"full">, import("@sinclair/typebox/build/cjs/index.js").TLiteral<"minimal">, import("@sinclair/typebox/build/cjs/index.js").TLiteral<"none">]>;
|
|
4
|
+
workspaceDir: import("@sinclair/typebox/build/cjs/index.js").TString;
|
|
5
|
+
heartbeatEnabled: import("@sinclair/typebox/build/cjs/index.js").TOptional<import("@sinclair/typebox/build/cjs/index.js").TBoolean>;
|
|
6
|
+
heartbeatPrompt: import("@sinclair/typebox/build/cjs/index.js").TOptional<import("@sinclair/typebox/build/cjs/index.js").TString>;
|
|
7
|
+
contextFiles: import("@sinclair/typebox/build/cjs/index.js").TOptional<import("@sinclair/typebox/build/cjs/index.js").TArray<import("@sinclair/typebox/build/cjs/index.js").TObject<{
|
|
8
|
+
name: import("@sinclair/typebox/build/cjs/index.js").TString;
|
|
9
|
+
content: import("@sinclair/typebox/build/cjs/index.js").TString;
|
|
10
|
+
}>>>;
|
|
11
|
+
}>;
|
|
12
|
+
export type PromptConfig = Static<typeof PromptConfigSchema>;
|
|
13
|
+
export interface PromptSection {
|
|
14
|
+
header?: string;
|
|
15
|
+
content: string;
|
|
16
|
+
priority: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function buildIdentitySection(): PromptSection;
|
|
19
|
+
export declare function buildVersionSection(version?: string): PromptSection;
|
|
20
|
+
export declare function buildToolSection(availableTools: string[]): PromptSection;
|
|
21
|
+
export declare function buildGuidelinesSection(): PromptSection;
|
|
22
|
+
export declare function buildSafetySection(): PromptSection;
|
|
23
|
+
export declare function buildMemorySection(): PromptSection;
|
|
24
|
+
export declare function buildWorkspaceSection(workspaceDir: string): PromptSection;
|
|
25
|
+
export declare function buildSkillsSection(hasSkills?: boolean, skillsCount?: number): PromptSection;
|
|
26
|
+
export declare function buildMessagingSection(channels?: string[]): PromptSection;
|
|
27
|
+
export interface ContextFile {
|
|
28
|
+
name: string;
|
|
29
|
+
content: string;
|
|
30
|
+
missing?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare function buildContextFilesSection(contextFiles?: ContextFile[]): PromptSection;
|
|
33
|
+
export declare function buildHeartbeatSection(enabled: boolean, _prompt?: string): PromptSection;
|
|
34
|
+
export declare function buildRuntimeSection(runtime: {
|
|
35
|
+
version?: string;
|
|
36
|
+
model?: string;
|
|
37
|
+
channel?: string;
|
|
38
|
+
}): PromptSection;
|
|
39
|
+
export declare class PromptBuilder {
|
|
40
|
+
private config;
|
|
41
|
+
private sections;
|
|
42
|
+
constructor(config: PromptConfig);
|
|
43
|
+
addSection(section: PromptSection): this;
|
|
44
|
+
build(): string;
|
|
45
|
+
static createFullPrompt(config: {
|
|
46
|
+
workspaceDir: string;
|
|
47
|
+
}, options?: {
|
|
48
|
+
version?: string;
|
|
49
|
+
channels?: string[];
|
|
50
|
+
skills?: {
|
|
51
|
+
enabled: boolean;
|
|
52
|
+
count: number;
|
|
53
|
+
};
|
|
54
|
+
contextFiles?: ContextFile[];
|
|
55
|
+
heartbeatEnabled?: boolean;
|
|
56
|
+
heartbeatPrompt?: string;
|
|
57
|
+
}): string;
|
|
58
|
+
static createMinimalPrompt(config: {
|
|
59
|
+
workspaceDir: string;
|
|
60
|
+
}, options?: {
|
|
61
|
+
contextFiles?: ContextFile[];
|
|
62
|
+
}): string;
|
|
63
|
+
static createNonePrompt(): string;
|
|
64
|
+
}
|
|
65
|
+
export * from './memory/index.js';
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { Type } from '@sinclair/typebox';
|
|
2
|
+
// =============================================================================
|
|
3
|
+
// Schema Definitions
|
|
4
|
+
// =============================================================================
|
|
5
|
+
export const PromptConfigSchema = Type.Object({
|
|
6
|
+
mode: Type.Union([
|
|
7
|
+
Type.Literal('full'),
|
|
8
|
+
Type.Literal('minimal'),
|
|
9
|
+
Type.Literal('none'),
|
|
10
|
+
], { default: 'full' }),
|
|
11
|
+
workspaceDir: Type.String(),
|
|
12
|
+
heartbeatEnabled: Type.Optional(Type.Boolean({ default: true })),
|
|
13
|
+
heartbeatPrompt: Type.Optional(Type.String()),
|
|
14
|
+
contextFiles: Type.Optional(Type.Array(Type.Object({
|
|
15
|
+
name: Type.String(),
|
|
16
|
+
content: Type.String(),
|
|
17
|
+
}))),
|
|
18
|
+
});
|
|
19
|
+
// Simplified identity - just who you are
|
|
20
|
+
export function buildIdentitySection() {
|
|
21
|
+
return {
|
|
22
|
+
content: `You are xopcbot, an ultra-efficient personal AI assistant.`,
|
|
23
|
+
priority: 0,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
// Compact version info
|
|
27
|
+
export function buildVersionSection(version = '1.0.0') {
|
|
28
|
+
return {
|
|
29
|
+
content: `xopcbot v${version}`,
|
|
30
|
+
priority: 1,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// Simplified tool section - just list available tools
|
|
34
|
+
export function buildToolSection(availableTools) {
|
|
35
|
+
const toolsList = availableTools.length > 0
|
|
36
|
+
? availableTools.map(t => `- ${t}`).join('\n')
|
|
37
|
+
: '(none - use filesystem and shell)';
|
|
38
|
+
return {
|
|
39
|
+
header: '## Tools',
|
|
40
|
+
content: toolsList,
|
|
41
|
+
priority: 10,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
// Key guidelines - direct and concise (inspired by pi)
|
|
45
|
+
export function buildGuidelinesSection() {
|
|
46
|
+
return {
|
|
47
|
+
header: '## Guidelines',
|
|
48
|
+
content: [
|
|
49
|
+
'Call tools directly without narrating routine steps.',
|
|
50
|
+
'Prioritize getting results over explaining process.',
|
|
51
|
+
'Use tools proactively to accomplish goals.',
|
|
52
|
+
'Be concise: value-dense responses preferred.',
|
|
53
|
+
'Show file paths when working with files.',
|
|
54
|
+
'Prefer read before edit.',
|
|
55
|
+
'Prefer grep/find over bash for file exploration.',
|
|
56
|
+
].join('\n'),
|
|
57
|
+
priority: 15,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// Minimal safety - trust the LLM
|
|
61
|
+
export function buildSafetySection() {
|
|
62
|
+
return {
|
|
63
|
+
header: '## Guidelines (Safety)',
|
|
64
|
+
content: [
|
|
65
|
+
'Do not take independent actions that persist beyond the session.',
|
|
66
|
+
'If asked to do something dangerous, refuse and explain why.',
|
|
67
|
+
].join('\n'),
|
|
68
|
+
priority: 20,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
// Compact memory section
|
|
72
|
+
export function buildMemorySection() {
|
|
73
|
+
return {
|
|
74
|
+
header: '## Memory',
|
|
75
|
+
content: [
|
|
76
|
+
'Files provide continuity:',
|
|
77
|
+
'- `memory/YYYY-MM-DD.md` — daily notes',
|
|
78
|
+
'- `MEMORY.md` — long-term memory',
|
|
79
|
+
'Before answering about prior work: memory_search → memory_get → cite sources.',
|
|
80
|
+
].join('\n'),
|
|
81
|
+
priority: 30,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export function buildWorkspaceSection(workspaceDir) {
|
|
85
|
+
return {
|
|
86
|
+
content: `Working directory: ${workspaceDir}`,
|
|
87
|
+
priority: 40,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export function buildSkillsSection(hasSkills = false, skillsCount = 0) {
|
|
91
|
+
if (!hasSkills) {
|
|
92
|
+
return { content: '', priority: 50 };
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
header: '## Skills',
|
|
96
|
+
content: `${skillsCount} skill(s) loaded. Use /skill:name to activate.`,
|
|
97
|
+
priority: 50,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export function buildMessagingSection(channels = []) {
|
|
101
|
+
if (channels.length === 0) {
|
|
102
|
+
return { content: '', priority: 60 };
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
header: '## Channels',
|
|
106
|
+
content: `Active: ${channels.join(', ')}`,
|
|
107
|
+
priority: 60,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
// Compact context files
|
|
111
|
+
export function buildContextFilesSection(contextFiles) {
|
|
112
|
+
if (!contextFiles || contextFiles.length === 0) {
|
|
113
|
+
return { content: '', priority: 90 };
|
|
114
|
+
}
|
|
115
|
+
const loadedFiles = contextFiles.filter(f => !f.missing);
|
|
116
|
+
if (loadedFiles.length === 0) {
|
|
117
|
+
return { content: '', priority: 90 };
|
|
118
|
+
}
|
|
119
|
+
const lines = ['## Project Context', ''];
|
|
120
|
+
for (const file of loadedFiles) {
|
|
121
|
+
// Only include first 2000 chars to avoid token bloat
|
|
122
|
+
const content = file.content.length > 2000
|
|
123
|
+
? file.content.slice(0, 2000) + '\n... (truncated)'
|
|
124
|
+
: file.content;
|
|
125
|
+
lines.push(`### ${file.name}`, '', content, '');
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
header: '',
|
|
129
|
+
content: lines.join('\n'),
|
|
130
|
+
priority: 90,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
export function buildHeartbeatSection(enabled, _prompt) {
|
|
134
|
+
if (!enabled) {
|
|
135
|
+
return { content: '', priority: 70 };
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
header: '## Heartbeat',
|
|
139
|
+
content: 'Poll for tasks. If nothing needs attention, reply: HEARTBEAT_OK',
|
|
140
|
+
priority: 70,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export function buildRuntimeSection(runtime) {
|
|
144
|
+
const parts = [];
|
|
145
|
+
if (runtime.version)
|
|
146
|
+
parts.push(`v${runtime.version}`);
|
|
147
|
+
if (runtime.model)
|
|
148
|
+
parts.push(`model=${runtime.model.split('/').pop()}`);
|
|
149
|
+
if (runtime.channel)
|
|
150
|
+
parts.push(`ch=${runtime.channel}`);
|
|
151
|
+
return {
|
|
152
|
+
content: parts.length > 0 ? `[${parts.join(' | ')}]` : '',
|
|
153
|
+
priority: 80,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
// =============================================================================
|
|
157
|
+
// Main Prompt Builder - Simplified
|
|
158
|
+
// =============================================================================
|
|
159
|
+
export class PromptBuilder {
|
|
160
|
+
config;
|
|
161
|
+
sections = new Map();
|
|
162
|
+
constructor(config) {
|
|
163
|
+
this.config = config;
|
|
164
|
+
}
|
|
165
|
+
addSection(section) {
|
|
166
|
+
this.sections.set(section.priority, section);
|
|
167
|
+
return this;
|
|
168
|
+
}
|
|
169
|
+
build() {
|
|
170
|
+
const lines = [];
|
|
171
|
+
const sortedSections = Array.from(this.sections.values())
|
|
172
|
+
.sort((a, b) => a.priority - b.priority);
|
|
173
|
+
for (const section of sortedSections) {
|
|
174
|
+
if (!section.content)
|
|
175
|
+
continue;
|
|
176
|
+
if (section.header) {
|
|
177
|
+
lines.push(section.header, '');
|
|
178
|
+
}
|
|
179
|
+
lines.push(section.content, '');
|
|
180
|
+
}
|
|
181
|
+
return lines.filter(Boolean).join('\n');
|
|
182
|
+
}
|
|
183
|
+
static createFullPrompt(config, options = {}) {
|
|
184
|
+
const builder = new PromptBuilder({ ...config, mode: 'full' });
|
|
185
|
+
return builder
|
|
186
|
+
.addSection(buildIdentitySection())
|
|
187
|
+
.addSection(buildVersionSection(options.version))
|
|
188
|
+
.addSection(buildGuidelinesSection())
|
|
189
|
+
.addSection(buildSafetySection())
|
|
190
|
+
.addSection(buildWorkspaceSection(config.workspaceDir))
|
|
191
|
+
.addSection(buildMemorySection())
|
|
192
|
+
.addSection(buildSkillsSection(options.skills?.enabled ?? false, options.skills?.count ?? 0))
|
|
193
|
+
.addSection(buildMessagingSection(options.channels || []))
|
|
194
|
+
.addSection(buildHeartbeatSection(options.heartbeatEnabled ?? true))
|
|
195
|
+
.addSection(buildRuntimeSection({
|
|
196
|
+
version: options.version,
|
|
197
|
+
}))
|
|
198
|
+
.addSection(buildContextFilesSection(options.contextFiles))
|
|
199
|
+
.build();
|
|
200
|
+
}
|
|
201
|
+
static createMinimalPrompt(config, options = {}) {
|
|
202
|
+
const builder = new PromptBuilder({ ...config, mode: 'minimal' });
|
|
203
|
+
return builder
|
|
204
|
+
.addSection(buildIdentitySection())
|
|
205
|
+
.addSection(buildGuidelinesSection())
|
|
206
|
+
.addSection(buildWorkspaceSection(config.workspaceDir))
|
|
207
|
+
.addSection(buildContextFilesSection(options.contextFiles))
|
|
208
|
+
.build();
|
|
209
|
+
}
|
|
210
|
+
static createNonePrompt() {
|
|
211
|
+
return `You are xopcbot, an efficient AI assistant.`;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
export * from './memory/index.js';
|
|
215
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/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}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface MemoryMatch {
|
|
2
|
+
file: string;
|
|
3
|
+
lines: string;
|
|
4
|
+
score: number;
|
|
5
|
+
lineNumbers: number[];
|
|
6
|
+
}
|
|
7
|
+
export interface MemorySearchOptions {
|
|
8
|
+
maxResults?: number;
|
|
9
|
+
minScore?: number;
|
|
10
|
+
glob?: string[];
|
|
11
|
+
exclude?: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface MemoryFile {
|
|
14
|
+
path: string;
|
|
15
|
+
content: string;
|
|
16
|
+
modified: Date;
|
|
17
|
+
}
|
|
18
|
+
export declare function getDailyMemoryPath(baseDir: string, date?: Date): string;
|
|
19
|
+
export declare function getLongTermMemoryPath(baseDir: string): string;
|
|
20
|
+
export declare function getAllMemoryPaths(baseDir: string): string[];
|
|
21
|
+
export declare function parseMemoryFile(path: string): MemoryFile;
|
|
22
|
+
export declare function extractSections(content: string): Map<string, string>;
|
|
23
|
+
export declare function fuzzyMatch(query: string, text: string): number;
|
|
24
|
+
export declare function searchInContent(query: string, content: string, options?: MemorySearchOptions): MemoryMatch | null;
|
|
25
|
+
export declare function memorySearch(baseDir: string, query: string, options?: MemorySearchOptions): Promise<MemoryMatch[]>;
|
|
26
|
+
export declare function memoryGet(baseDir: string, path: string, from?: number, lines?: number): {
|
|
27
|
+
content: string;
|
|
28
|
+
lineNumbers: {
|
|
29
|
+
start: number;
|
|
30
|
+
end: number;
|
|
31
|
+
};
|
|
32
|
+
} | null;
|
|
33
|
+
export declare function writeToMemory(baseDir: string, content: string, date?: Date): Promise<void>;
|
|
34
|
+
export declare function updateLongTermMemory(baseDir: string, content: string, section?: string): Promise<void>;
|
|
35
|
+
export declare function generateCitation(file: string, line?: number): string;
|
|
36
|
+
export declare function recallRecentContext(baseDir: string, days?: number): Promise<string>;
|
|
37
|
+
export declare function getPreference(baseDir: string, key: string): Promise<string | null>;
|