@shuyhere/takotako 0.0.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/CONTRIBUTING.md +84 -0
- package/LICENSE +21 -0
- package/README.md +171 -0
- package/dist/agents/communication.d.ts +48 -0
- package/dist/agents/communication.d.ts.map +1 -0
- package/dist/agents/communication.js +123 -0
- package/dist/agents/communication.js.map +1 -0
- package/dist/agents/config.d.ts +52 -0
- package/dist/agents/config.d.ts.map +1 -0
- package/dist/agents/config.js +65 -0
- package/dist/agents/config.js.map +1 -0
- package/dist/agents/model-catalog.d.ts +49 -0
- package/dist/agents/model-catalog.d.ts.map +1 -0
- package/dist/agents/model-catalog.js +79 -0
- package/dist/agents/model-catalog.js.map +1 -0
- package/dist/agents/registry.d.ts +71 -0
- package/dist/agents/registry.d.ts.map +1 -0
- package/dist/agents/registry.js +297 -0
- package/dist/agents/registry.js.map +1 -0
- package/dist/agents/roles.d.ts +79 -0
- package/dist/agents/roles.d.ts.map +1 -0
- package/dist/agents/roles.js +174 -0
- package/dist/agents/roles.js.map +1 -0
- package/dist/agents/subagent.d.ts +124 -0
- package/dist/agents/subagent.d.ts.map +1 -0
- package/dist/agents/subagent.js +352 -0
- package/dist/agents/subagent.js.map +1 -0
- package/dist/agents/templates.d.ts +18 -0
- package/dist/agents/templates.d.ts.map +1 -0
- package/dist/agents/templates.js +341 -0
- package/dist/agents/templates.js.map +1 -0
- package/dist/agents/thread-binding.d.ts +77 -0
- package/dist/agents/thread-binding.d.ts.map +1 -0
- package/dist/agents/thread-binding.js +167 -0
- package/dist/agents/thread-binding.js.map +1 -0
- package/dist/auth/agent-profiles.d.ts +46 -0
- package/dist/auth/agent-profiles.d.ts.map +1 -0
- package/dist/auth/agent-profiles.js +97 -0
- package/dist/auth/agent-profiles.js.map +1 -0
- package/dist/auth/allow-from.d.ts +27 -0
- package/dist/auth/allow-from.d.ts.map +1 -0
- package/dist/auth/allow-from.js +118 -0
- package/dist/auth/allow-from.js.map +1 -0
- package/dist/auth/oauth.d.ts +66 -0
- package/dist/auth/oauth.d.ts.map +1 -0
- package/dist/auth/oauth.js +253 -0
- package/dist/auth/oauth.js.map +1 -0
- package/dist/auth/storage.d.ts +69 -0
- package/dist/auth/storage.d.ts.map +1 -0
- package/dist/auth/storage.js +157 -0
- package/dist/auth/storage.js.map +1 -0
- package/dist/cache/file-cache.d.ts +68 -0
- package/dist/cache/file-cache.d.ts.map +1 -0
- package/dist/cache/file-cache.js +176 -0
- package/dist/cache/file-cache.js.map +1 -0
- package/dist/cache/manager.d.ts +69 -0
- package/dist/cache/manager.d.ts.map +1 -0
- package/dist/cache/manager.js +117 -0
- package/dist/cache/manager.js.map +1 -0
- package/dist/cache/symbol-index.d.ts +75 -0
- package/dist/cache/symbol-index.d.ts.map +1 -0
- package/dist/cache/symbol-index.js +267 -0
- package/dist/cache/symbol-index.js.map +1 -0
- package/dist/cache/tool-cache.d.ts +75 -0
- package/dist/cache/tool-cache.d.ts.map +1 -0
- package/dist/cache/tool-cache.js +173 -0
- package/dist/cache/tool-cache.js.map +1 -0
- package/dist/channels/channel.d.ts +156 -0
- package/dist/channels/channel.d.ts.map +1 -0
- package/dist/channels/channel.js +25 -0
- package/dist/channels/channel.js.map +1 -0
- package/dist/channels/cli.d.ts +35 -0
- package/dist/channels/cli.d.ts.map +1 -0
- package/dist/channels/cli.js +94 -0
- package/dist/channels/cli.js.map +1 -0
- package/dist/channels/delivery-queue.d.ts +31 -0
- package/dist/channels/delivery-queue.d.ts.map +1 -0
- package/dist/channels/delivery-queue.js +127 -0
- package/dist/channels/delivery-queue.js.map +1 -0
- package/dist/channels/discord.d.ts +124 -0
- package/dist/channels/discord.d.ts.map +1 -0
- package/dist/channels/discord.js +664 -0
- package/dist/channels/discord.js.map +1 -0
- package/dist/channels/retry.d.ts +31 -0
- package/dist/channels/retry.d.ts.map +1 -0
- package/dist/channels/retry.js +94 -0
- package/dist/channels/retry.js.map +1 -0
- package/dist/channels/telegram.d.ts +69 -0
- package/dist/channels/telegram.d.ts.map +1 -0
- package/dist/channels/telegram.js +499 -0
- package/dist/channels/telegram.js.map +1 -0
- package/dist/channels/tui.d.ts +42 -0
- package/dist/channels/tui.d.ts.map +1 -0
- package/dist/channels/tui.js +126 -0
- package/dist/channels/tui.js.map +1 -0
- package/dist/cli/acp.d.ts +10 -0
- package/dist/cli/acp.d.ts.map +1 -0
- package/dist/cli/acp.js +69 -0
- package/dist/cli/acp.js.map +1 -0
- package/dist/cli/audit.d.ts +11 -0
- package/dist/cli/audit.d.ts.map +1 -0
- package/dist/cli/audit.js +55 -0
- package/dist/cli/audit.js.map +1 -0
- package/dist/cli/cache.d.ts +10 -0
- package/dist/cli/cache.d.ts.map +1 -0
- package/dist/cli/cache.js +77 -0
- package/dist/cli/cache.js.map +1 -0
- package/dist/cli/config.d.ts +5 -0
- package/dist/cli/config.d.ts.map +1 -0
- package/dist/cli/config.js +168 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/cron.d.ts +5 -0
- package/dist/cli/cron.d.ts.map +1 -0
- package/dist/cli/cron.js +192 -0
- package/dist/cli/cron.js.map +1 -0
- package/dist/cli/extensions.d.ts +5 -0
- package/dist/cli/extensions.d.ts.map +1 -0
- package/dist/cli/extensions.js +53 -0
- package/dist/cli/extensions.js.map +1 -0
- package/dist/cli/logs.d.ts +5 -0
- package/dist/cli/logs.d.ts.map +1 -0
- package/dist/cli/logs.js +49 -0
- package/dist/cli/logs.js.map +1 -0
- package/dist/cli/memory.d.ts +5 -0
- package/dist/cli/memory.d.ts.map +1 -0
- package/dist/cli/memory.js +78 -0
- package/dist/cli/memory.js.map +1 -0
- package/dist/cli/message.d.ts +5 -0
- package/dist/cli/message.d.ts.map +1 -0
- package/dist/cli/message.js +69 -0
- package/dist/cli/message.js.map +1 -0
- package/dist/cli/service.d.ts +14 -0
- package/dist/cli/service.d.ts.map +1 -0
- package/dist/cli/service.js +181 -0
- package/dist/cli/service.js.map +1 -0
- package/dist/cli/symphony.d.ts +5 -0
- package/dist/cli/symphony.d.ts.map +1 -0
- package/dist/cli/symphony.js +114 -0
- package/dist/cli/symphony.js.map +1 -0
- package/dist/cli/update.d.ts +5 -0
- package/dist/cli/update.d.ts.map +1 -0
- package/dist/cli/update.js +48 -0
- package/dist/cli/update.js.map +1 -0
- package/dist/commands/channel-setup.d.ts +31 -0
- package/dist/commands/channel-setup.d.ts.map +1 -0
- package/dist/commands/channel-setup.js +138 -0
- package/dist/commands/channel-setup.js.map +1 -0
- package/dist/commands/dispatch.d.ts +48 -0
- package/dist/commands/dispatch.d.ts.map +1 -0
- package/dist/commands/dispatch.js +68 -0
- package/dist/commands/dispatch.js.map +1 -0
- package/dist/commands/model-picker.d.ts +16 -0
- package/dist/commands/model-picker.d.ts.map +1 -0
- package/dist/commands/model-picker.js +120 -0
- package/dist/commands/model-picker.js.map +1 -0
- package/dist/commands/parser.d.ts +32 -0
- package/dist/commands/parser.d.ts.map +1 -0
- package/dist/commands/parser.js +39 -0
- package/dist/commands/parser.js.map +1 -0
- package/dist/commands/registry.d.ts +76 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands/registry.js +351 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/commands/skill-commands.d.ts +35 -0
- package/dist/commands/skill-commands.d.ts.map +1 -0
- package/dist/commands/skill-commands.js +61 -0
- package/dist/commands/skill-commands.js.map +1 -0
- package/dist/config/resolve.d.ts +25 -0
- package/dist/config/resolve.d.ts.map +1 -0
- package/dist/config/resolve.js +289 -0
- package/dist/config/resolve.js.map +1 -0
- package/dist/config/schema.d.ts +520 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +123 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/core/agent-loop.d.ts +137 -0
- package/dist/core/agent-loop.d.ts.map +1 -0
- package/dist/core/agent-loop.js +700 -0
- package/dist/core/agent-loop.js.map +1 -0
- package/dist/core/audit.d.ts +87 -0
- package/dist/core/audit.d.ts.map +1 -0
- package/dist/core/audit.js +224 -0
- package/dist/core/audit.js.map +1 -0
- package/dist/core/bootstrap.d.ts +23 -0
- package/dist/core/bootstrap.d.ts.map +1 -0
- package/dist/core/bootstrap.js +162 -0
- package/dist/core/bootstrap.js.map +1 -0
- package/dist/core/context.d.ts +44 -0
- package/dist/core/context.d.ts.map +1 -0
- package/dist/core/context.js +65 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/cron.d.ts +111 -0
- package/dist/core/cron.d.ts.map +1 -0
- package/dist/core/cron.js +284 -0
- package/dist/core/cron.js.map +1 -0
- package/dist/core/exec-approvals.d.ts +50 -0
- package/dist/core/exec-approvals.d.ts.map +1 -0
- package/dist/core/exec-approvals.js +187 -0
- package/dist/core/exec-approvals.js.map +1 -0
- package/dist/core/heartbeat.d.ts +71 -0
- package/dist/core/heartbeat.d.ts.map +1 -0
- package/dist/core/heartbeat.js +214 -0
- package/dist/core/heartbeat.js.map +1 -0
- package/dist/core/message-queue.d.ts +60 -0
- package/dist/core/message-queue.d.ts.map +1 -0
- package/dist/core/message-queue.js +182 -0
- package/dist/core/message-queue.js.map +1 -0
- package/dist/core/network-policy.d.ts +39 -0
- package/dist/core/network-policy.d.ts.map +1 -0
- package/dist/core/network-policy.js +121 -0
- package/dist/core/network-policy.js.map +1 -0
- package/dist/core/progress.d.ts +48 -0
- package/dist/core/progress.d.ts.map +1 -0
- package/dist/core/progress.js +81 -0
- package/dist/core/progress.js.map +1 -0
- package/dist/core/prompt.d.ts +105 -0
- package/dist/core/prompt.d.ts.map +1 -0
- package/dist/core/prompt.js +411 -0
- package/dist/core/prompt.js.map +1 -0
- package/dist/core/pruning.d.ts +40 -0
- package/dist/core/pruning.d.ts.map +1 -0
- package/dist/core/pruning.js +165 -0
- package/dist/core/pruning.js.map +1 -0
- package/dist/core/rate-limiter.d.ts +64 -0
- package/dist/core/rate-limiter.d.ts.map +1 -0
- package/dist/core/rate-limiter.js +142 -0
- package/dist/core/rate-limiter.js.map +1 -0
- package/dist/core/reactions.d.ts +31 -0
- package/dist/core/reactions.d.ts.map +1 -0
- package/dist/core/reactions.js +67 -0
- package/dist/core/reactions.js.map +1 -0
- package/dist/core/retry-queue.d.ts +56 -0
- package/dist/core/retry-queue.d.ts.map +1 -0
- package/dist/core/retry-queue.js +106 -0
- package/dist/core/retry-queue.js.map +1 -0
- package/dist/core/sanitizer.d.ts +38 -0
- package/dist/core/sanitizer.d.ts.map +1 -0
- package/dist/core/sanitizer.js +181 -0
- package/dist/core/sanitizer.js.map +1 -0
- package/dist/core/secret-scanner.d.ts +39 -0
- package/dist/core/secret-scanner.d.ts.map +1 -0
- package/dist/core/secret-scanner.js +96 -0
- package/dist/core/secret-scanner.js.map +1 -0
- package/dist/core/secrets.d.ts +38 -0
- package/dist/core/secrets.d.ts.map +1 -0
- package/dist/core/secrets.js +137 -0
- package/dist/core/secrets.js.map +1 -0
- package/dist/core/security.d.ts +58 -0
- package/dist/core/security.d.ts.map +1 -0
- package/dist/core/security.js +120 -0
- package/dist/core/security.js.map +1 -0
- package/dist/core/self-awareness.d.ts +19 -0
- package/dist/core/self-awareness.d.ts.map +1 -0
- package/dist/core/self-awareness.js +124 -0
- package/dist/core/self-awareness.js.map +1 -0
- package/dist/core/session-init.d.ts +34 -0
- package/dist/core/session-init.d.ts.map +1 -0
- package/dist/core/session-init.js +68 -0
- package/dist/core/session-init.js.map +1 -0
- package/dist/core/streaming.d.ts +82 -0
- package/dist/core/streaming.d.ts.map +1 -0
- package/dist/core/streaming.js +264 -0
- package/dist/core/streaming.js.map +1 -0
- package/dist/core/symphony/orchestrator.d.ts +61 -0
- package/dist/core/symphony/orchestrator.d.ts.map +1 -0
- package/dist/core/symphony/orchestrator.js +476 -0
- package/dist/core/symphony/orchestrator.js.map +1 -0
- package/dist/core/symphony/status.d.ts +11 -0
- package/dist/core/symphony/status.d.ts.map +1 -0
- package/dist/core/symphony/status.js +133 -0
- package/dist/core/symphony/status.js.map +1 -0
- package/dist/core/symphony/types.d.ts +84 -0
- package/dist/core/symphony/types.d.ts.map +1 -0
- package/dist/core/symphony/types.js +5 -0
- package/dist/core/symphony/types.js.map +1 -0
- package/dist/core/symphony/workflow.d.ts +18 -0
- package/dist/core/symphony/workflow.d.ts.map +1 -0
- package/dist/core/symphony/workflow.js +149 -0
- package/dist/core/symphony/workflow.js.map +1 -0
- package/dist/core/symphony/workspace.d.ts +24 -0
- package/dist/core/symphony/workspace.d.ts.map +1 -0
- package/dist/core/symphony/workspace.js +94 -0
- package/dist/core/symphony/workspace.js.map +1 -0
- package/dist/core/thinking.d.ts +27 -0
- package/dist/core/thinking.d.ts.map +1 -0
- package/dist/core/thinking.js +83 -0
- package/dist/core/thinking.js.map +1 -0
- package/dist/core/thread-bindings.d.ts +47 -0
- package/dist/core/thread-bindings.d.ts.map +1 -0
- package/dist/core/thread-bindings.js +94 -0
- package/dist/core/thread-bindings.js.map +1 -0
- package/dist/core/timezone.d.ts +28 -0
- package/dist/core/timezone.d.ts.map +1 -0
- package/dist/core/timezone.js +72 -0
- package/dist/core/timezone.js.map +1 -0
- package/dist/core/tool-loop-detector.d.ts +41 -0
- package/dist/core/tool-loop-detector.d.ts.map +1 -0
- package/dist/core/tool-loop-detector.js +83 -0
- package/dist/core/tool-loop-detector.js.map +1 -0
- package/dist/core/tool-validator.d.ts +44 -0
- package/dist/core/tool-validator.d.ts.map +1 -0
- package/dist/core/tool-validator.js +175 -0
- package/dist/core/tool-validator.js.map +1 -0
- package/dist/core/typing.d.ts +25 -0
- package/dist/core/typing.d.ts.map +1 -0
- package/dist/core/typing.js +48 -0
- package/dist/core/typing.js.map +1 -0
- package/dist/core/usage-tracker.d.ts +66 -0
- package/dist/core/usage-tracker.d.ts.map +1 -0
- package/dist/core/usage-tracker.js +163 -0
- package/dist/core/usage-tracker.js.map +1 -0
- package/dist/daemon/commands.d.ts +16 -0
- package/dist/daemon/commands.d.ts.map +1 -0
- package/dist/daemon/commands.js +445 -0
- package/dist/daemon/commands.js.map +1 -0
- package/dist/daemon/pid.d.ts +30 -0
- package/dist/daemon/pid.d.ts.map +1 -0
- package/dist/daemon/pid.js +62 -0
- package/dist/daemon/pid.js.map +1 -0
- package/dist/doctor/checks/browser.d.ts +9 -0
- package/dist/doctor/checks/browser.d.ts.map +1 -0
- package/dist/doctor/checks/browser.js +54 -0
- package/dist/doctor/checks/browser.js.map +1 -0
- package/dist/doctor/checks/channels.d.ts +9 -0
- package/dist/doctor/checks/channels.d.ts.map +1 -0
- package/dist/doctor/checks/channels.js +90 -0
- package/dist/doctor/checks/channels.js.map +1 -0
- package/dist/doctor/checks/config.d.ts +10 -0
- package/dist/doctor/checks/config.d.ts.map +1 -0
- package/dist/doctor/checks/config.js +89 -0
- package/dist/doctor/checks/config.js.map +1 -0
- package/dist/doctor/checks/memory.d.ts +10 -0
- package/dist/doctor/checks/memory.d.ts.map +1 -0
- package/dist/doctor/checks/memory.js +82 -0
- package/dist/doctor/checks/memory.js.map +1 -0
- package/dist/doctor/checks/permissions.d.ts +9 -0
- package/dist/doctor/checks/permissions.d.ts.map +1 -0
- package/dist/doctor/checks/permissions.js +53 -0
- package/dist/doctor/checks/permissions.js.map +1 -0
- package/dist/doctor/checks/providers.d.ts +10 -0
- package/dist/doctor/checks/providers.d.ts.map +1 -0
- package/dist/doctor/checks/providers.js +93 -0
- package/dist/doctor/checks/providers.js.map +1 -0
- package/dist/doctor/checks/sessions.d.ts +10 -0
- package/dist/doctor/checks/sessions.d.ts.map +1 -0
- package/dist/doctor/checks/sessions.js +86 -0
- package/dist/doctor/checks/sessions.js.map +1 -0
- package/dist/doctor/doctor.d.ts +35 -0
- package/dist/doctor/doctor.d.ts.map +1 -0
- package/dist/doctor/doctor.js +51 -0
- package/dist/doctor/doctor.js.map +1 -0
- package/dist/doctor/repairs.d.ts +14 -0
- package/dist/doctor/repairs.d.ts.map +1 -0
- package/dist/doctor/repairs.js +34 -0
- package/dist/doctor/repairs.js.map +1 -0
- package/dist/gateway/compaction.d.ts +63 -0
- package/dist/gateway/compaction.d.ts.map +1 -0
- package/dist/gateway/compaction.js +235 -0
- package/dist/gateway/compaction.js.map +1 -0
- package/dist/gateway/gateway.d.ts +94 -0
- package/dist/gateway/gateway.d.ts.map +1 -0
- package/dist/gateway/gateway.js +466 -0
- package/dist/gateway/gateway.js.map +1 -0
- package/dist/gateway/lock.d.ts +24 -0
- package/dist/gateway/lock.d.ts.map +1 -0
- package/dist/gateway/lock.js +88 -0
- package/dist/gateway/lock.js.map +1 -0
- package/dist/gateway/protocol.d.ts +117 -0
- package/dist/gateway/protocol.d.ts.map +1 -0
- package/dist/gateway/protocol.js +5 -0
- package/dist/gateway/protocol.js.map +1 -0
- package/dist/gateway/session.d.ts +123 -0
- package/dist/gateway/session.d.ts.map +1 -0
- package/dist/gateway/session.js +573 -0
- package/dist/gateway/session.js.map +1 -0
- package/dist/hooks/hooks.d.ts +18 -0
- package/dist/hooks/hooks.d.ts.map +1 -0
- package/dist/hooks/hooks.js +45 -0
- package/dist/hooks/hooks.js.map +1 -0
- package/dist/hooks/types.d.ts +112 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +23 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2900 -0
- package/dist/index.js.map +1 -0
- package/dist/media/storage.d.ts +25 -0
- package/dist/media/storage.d.ts.map +1 -0
- package/dist/media/storage.js +97 -0
- package/dist/media/storage.js.map +1 -0
- package/dist/memory/embeddings.d.ts +46 -0
- package/dist/memory/embeddings.d.ts.map +1 -0
- package/dist/memory/embeddings.js +118 -0
- package/dist/memory/embeddings.js.map +1 -0
- package/dist/memory/hybrid.d.ts +35 -0
- package/dist/memory/hybrid.d.ts.map +1 -0
- package/dist/memory/hybrid.js +156 -0
- package/dist/memory/hybrid.js.map +1 -0
- package/dist/memory/markdown.d.ts +48 -0
- package/dist/memory/markdown.d.ts.map +1 -0
- package/dist/memory/markdown.js +228 -0
- package/dist/memory/markdown.js.map +1 -0
- package/dist/memory/store.d.ts +88 -0
- package/dist/memory/store.d.ts.map +1 -0
- package/dist/memory/store.js +21 -0
- package/dist/memory/store.js.map +1 -0
- package/dist/memory/vector.d.ts +24 -0
- package/dist/memory/vector.d.ts.map +1 -0
- package/dist/memory/vector.js +63 -0
- package/dist/memory/vector.js.map +1 -0
- package/dist/mods/mod.d.ts +100 -0
- package/dist/mods/mod.d.ts.map +1 -0
- package/dist/mods/mod.js +242 -0
- package/dist/mods/mod.js.map +1 -0
- package/dist/onboard/channels.d.ts +12 -0
- package/dist/onboard/channels.d.ts.map +1 -0
- package/dist/onboard/channels.js +283 -0
- package/dist/onboard/channels.js.map +1 -0
- package/dist/onboard/models.d.ts +13 -0
- package/dist/onboard/models.d.ts.map +1 -0
- package/dist/onboard/models.js +491 -0
- package/dist/onboard/models.js.map +1 -0
- package/dist/onboard/onboard.d.ts +12 -0
- package/dist/onboard/onboard.d.ts.map +1 -0
- package/dist/onboard/onboard.js +1137 -0
- package/dist/onboard/onboard.js.map +1 -0
- package/dist/providers/anthropic.d.ts +83 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +583 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/failover.d.ts +46 -0
- package/dist/providers/failover.d.ts.map +1 -0
- package/dist/providers/failover.js +149 -0
- package/dist/providers/failover.js.map +1 -0
- package/dist/providers/litellm.d.ts +38 -0
- package/dist/providers/litellm.d.ts.map +1 -0
- package/dist/providers/litellm.js +349 -0
- package/dist/providers/litellm.js.map +1 -0
- package/dist/providers/openai.d.ts +28 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +321 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/prompt-cache.d.ts +50 -0
- package/dist/providers/prompt-cache.d.ts.map +1 -0
- package/dist/providers/prompt-cache.js +96 -0
- package/dist/providers/prompt-cache.js.map +1 -0
- package/dist/providers/provider.d.ts +173 -0
- package/dist/providers/provider.d.ts.map +1 -0
- package/dist/providers/provider.js +22 -0
- package/dist/providers/provider.js.map +1 -0
- package/dist/sandbox/config.d.ts +42 -0
- package/dist/sandbox/config.d.ts.map +1 -0
- package/dist/sandbox/config.js +20 -0
- package/dist/sandbox/config.js.map +1 -0
- package/dist/sandbox/container.d.ts +71 -0
- package/dist/sandbox/container.d.ts.map +1 -0
- package/dist/sandbox/container.js +193 -0
- package/dist/sandbox/container.js.map +1 -0
- package/dist/sandbox/sandbox.d.ts +82 -0
- package/dist/sandbox/sandbox.d.ts.map +1 -0
- package/dist/sandbox/sandbox.js +176 -0
- package/dist/sandbox/sandbox.js.map +1 -0
- package/dist/skills/channel-loader.d.ts +18 -0
- package/dist/skills/channel-loader.d.ts.map +1 -0
- package/dist/skills/channel-loader.js +35 -0
- package/dist/skills/channel-loader.js.map +1 -0
- package/dist/skills/extension-loader.d.ts +15 -0
- package/dist/skills/extension-loader.d.ts.map +1 -0
- package/dist/skills/extension-loader.js +63 -0
- package/dist/skills/extension-loader.js.map +1 -0
- package/dist/skills/extension-registry.d.ts +32 -0
- package/dist/skills/extension-registry.d.ts.map +1 -0
- package/dist/skills/extension-registry.js +57 -0
- package/dist/skills/extension-registry.js.map +1 -0
- package/dist/skills/extensions.d.ts +91 -0
- package/dist/skills/extensions.d.ts.map +1 -0
- package/dist/skills/extensions.js +14 -0
- package/dist/skills/extensions.js.map +1 -0
- package/dist/skills/loader.d.ts +64 -0
- package/dist/skills/loader.d.ts.map +1 -0
- package/dist/skills/loader.js +382 -0
- package/dist/skills/loader.js.map +1 -0
- package/dist/skills/marketplace.d.ts +56 -0
- package/dist/skills/marketplace.d.ts.map +1 -0
- package/dist/skills/marketplace.js +183 -0
- package/dist/skills/marketplace.js.map +1 -0
- package/dist/skills/types.d.ts +94 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +9 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/tools/acp-sessions.d.ts +89 -0
- package/dist/tools/acp-sessions.d.ts.map +1 -0
- package/dist/tools/acp-sessions.js +391 -0
- package/dist/tools/acp-sessions.js.map +1 -0
- package/dist/tools/acp.d.ts +18 -0
- package/dist/tools/acp.d.ts.map +1 -0
- package/dist/tools/acp.js +102 -0
- package/dist/tools/acp.js.map +1 -0
- package/dist/tools/agent-tools.d.ts +24 -0
- package/dist/tools/agent-tools.d.ts.map +1 -0
- package/dist/tools/agent-tools.js +611 -0
- package/dist/tools/agent-tools.js.map +1 -0
- package/dist/tools/browser.d.ts +26 -0
- package/dist/tools/browser.d.ts.map +1 -0
- package/dist/tools/browser.js +242 -0
- package/dist/tools/browser.js.map +1 -0
- package/dist/tools/comms.d.ts +8 -0
- package/dist/tools/comms.d.ts.map +1 -0
- package/dist/tools/comms.js +39 -0
- package/dist/tools/comms.js.map +1 -0
- package/dist/tools/cron-tools.d.ts +9 -0
- package/dist/tools/cron-tools.d.ts.map +1 -0
- package/dist/tools/cron-tools.js +117 -0
- package/dist/tools/cron-tools.js.map +1 -0
- package/dist/tools/exec-safety.d.ts +71 -0
- package/dist/tools/exec-safety.d.ts.map +1 -0
- package/dist/tools/exec-safety.js +141 -0
- package/dist/tools/exec-safety.js.map +1 -0
- package/dist/tools/exec.d.ts +24 -0
- package/dist/tools/exec.d.ts.map +1 -0
- package/dist/tools/exec.js +191 -0
- package/dist/tools/exec.js.map +1 -0
- package/dist/tools/fs.d.ts +15 -0
- package/dist/tools/fs.d.ts.map +1 -0
- package/dist/tools/fs.js +249 -0
- package/dist/tools/fs.js.map +1 -0
- package/dist/tools/git.d.ts +9 -0
- package/dist/tools/git.d.ts.map +1 -0
- package/dist/tools/git.js +56 -0
- package/dist/tools/git.js.map +1 -0
- package/dist/tools/image.d.ts +15 -0
- package/dist/tools/image.d.ts.map +1 -0
- package/dist/tools/image.js +106 -0
- package/dist/tools/image.js.map +1 -0
- package/dist/tools/introspect.d.ts +22 -0
- package/dist/tools/introspect.d.ts.map +1 -0
- package/dist/tools/introspect.js +223 -0
- package/dist/tools/introspect.js.map +1 -0
- package/dist/tools/memory.d.ts +11 -0
- package/dist/tools/memory.d.ts.map +1 -0
- package/dist/tools/memory.js +101 -0
- package/dist/tools/memory.js.map +1 -0
- package/dist/tools/message.d.ts +24 -0
- package/dist/tools/message.d.ts.map +1 -0
- package/dist/tools/message.js +205 -0
- package/dist/tools/message.js.map +1 -0
- package/dist/tools/model.d.ts +14 -0
- package/dist/tools/model.d.ts.map +1 -0
- package/dist/tools/model.js +62 -0
- package/dist/tools/model.js.map +1 -0
- package/dist/tools/policy.d.ts +101 -0
- package/dist/tools/policy.d.ts.map +1 -0
- package/dist/tools/policy.js +168 -0
- package/dist/tools/policy.js.map +1 -0
- package/dist/tools/registry.d.ts +52 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +154 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/search.d.ts +10 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +78 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/session.d.ts +13 -0
- package/dist/tools/session.d.ts.map +1 -0
- package/dist/tools/session.js +142 -0
- package/dist/tools/session.js.map +1 -0
- package/dist/tools/spawn.d.ts +10 -0
- package/dist/tools/spawn.d.ts.map +1 -0
- package/dist/tools/spawn.js +72 -0
- package/dist/tools/spawn.js.map +1 -0
- package/dist/tools/symphony.d.ts +12 -0
- package/dist/tools/symphony.d.ts.map +1 -0
- package/dist/tools/symphony.js +142 -0
- package/dist/tools/symphony.js.map +1 -0
- package/dist/tools/system-tools.d.ts +11 -0
- package/dist/tools/system-tools.d.ts.map +1 -0
- package/dist/tools/system-tools.js +39 -0
- package/dist/tools/system-tools.js.map +1 -0
- package/dist/tools/tool.d.ts +119 -0
- package/dist/tools/tool.d.ts.map +1 -0
- package/dist/tools/tool.js +29 -0
- package/dist/tools/tool.js.map +1 -0
- package/dist/tools/web.d.ts +10 -0
- package/dist/tools/web.d.ts.map +1 -0
- package/dist/tools/web.js +105 -0
- package/dist/tools/web.js.map +1 -0
- package/dist/tui/App.d.ts +43 -0
- package/dist/tui/App.d.ts.map +1 -0
- package/dist/tui/App.js +265 -0
- package/dist/tui/App.js.map +1 -0
- package/dist/tui/bridge.d.ts +40 -0
- package/dist/tui/bridge.d.ts.map +1 -0
- package/dist/tui/bridge.js +29 -0
- package/dist/tui/bridge.js.map +1 -0
- package/dist/tui/components/Header.d.ts +14 -0
- package/dist/tui/components/Header.d.ts.map +1 -0
- package/dist/tui/components/Header.js +7 -0
- package/dist/tui/components/Header.js.map +1 -0
- package/dist/tui/components/InputBar.d.ts +10 -0
- package/dist/tui/components/InputBar.d.ts.map +1 -0
- package/dist/tui/components/InputBar.js +121 -0
- package/dist/tui/components/InputBar.js.map +1 -0
- package/dist/tui/components/MessageList.d.ts +18 -0
- package/dist/tui/components/MessageList.d.ts.map +1 -0
- package/dist/tui/components/MessageList.js +34 -0
- package/dist/tui/components/MessageList.js.map +1 -0
- package/dist/tui/components/Spinner.d.ts +9 -0
- package/dist/tui/components/Spinner.d.ts.map +1 -0
- package/dist/tui/components/Spinner.js +18 -0
- package/dist/tui/components/Spinner.js.map +1 -0
- package/dist/tui/components/StatusBar.d.ts +16 -0
- package/dist/tui/components/StatusBar.d.ts.map +1 -0
- package/dist/tui/components/StatusBar.js +15 -0
- package/dist/tui/components/StatusBar.js.map +1 -0
- package/dist/tui/components/ToolCallBox.d.ts +12 -0
- package/dist/tui/components/ToolCallBox.d.ts.map +1 -0
- package/dist/tui/components/ToolCallBox.js +12 -0
- package/dist/tui/components/ToolCallBox.js.map +1 -0
- package/dist/tui/theme.d.ts +58 -0
- package/dist/tui/theme.d.ts.map +1 -0
- package/dist/tui/theme.js +80 -0
- package/dist/tui/theme.js.map +1 -0
- package/dist/utils/logger.d.ts +16 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +70 -0
- package/dist/utils/logger.js.map +1 -0
- package/docs/DEVELOPMENT.md +74 -0
- package/docs/INSTALL.md +161 -0
- package/docs/USAGE.md +94 -0
- package/docs/architecture.md +128 -0
- package/docs/channels.md +140 -0
- package/docs/configuration.md +209 -0
- package/docs/io-system.md +430 -0
- package/docs/providers.md +99 -0
- package/docs/skill-channels.md +113 -0
- package/docs/skills.md +246 -0
- package/package.json +89 -0
- package/skills/acp-router/SKILL.md +41 -0
- package/skills/acp-router/tools/acp-router.mjs +239 -0
- package/skills/find-skills/SKILL.md +133 -0
- package/skills/security-audit/SKILL.md +181 -0
- package/skills/security-audit/audit.sh +67 -0
- package/skills/skill-creator/SKILL.md +479 -0
- package/skills/skill-security-audit/.clawhub/origin.json +7 -0
- package/skills/skill-security-audit/SKILL.md +196 -0
- package/skills/skill-security-audit/_meta.json +6 -0
- package/skills/skill-security-audit/references/prompt-injection-patterns.md +276 -0
- package/skills/skill-security-audit/references/vulnerability-patterns.md +348 -0
- package/skills/symphony/README.md +53 -0
- package/skills/symphony/SKILL.md +75 -0
- package/skills/symphony/tools/symphony-orchestrator.ts +8 -0
- package/tako.example.json +33 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security middleware — unified access point for all security modules.
|
|
3
|
+
*
|
|
4
|
+
* Initializes and provides access to:
|
|
5
|
+
* - SecretScanner (output scanning)
|
|
6
|
+
* - RateLimiter (request throttling)
|
|
7
|
+
* - InputSanitizer (prompt injection detection)
|
|
8
|
+
* - ToolValidator (argument validation)
|
|
9
|
+
* - NetworkPolicy (URL/domain control)
|
|
10
|
+
*
|
|
11
|
+
* This module is the single integration point. Other modules import
|
|
12
|
+
* from here rather than from individual security modules.
|
|
13
|
+
*/
|
|
14
|
+
import { SecretScanner } from './secret-scanner.js';
|
|
15
|
+
import { RateLimiter } from './rate-limiter.js';
|
|
16
|
+
import { InputSanitizer } from './sanitizer.js';
|
|
17
|
+
import { ToolValidator } from './tool-validator.js';
|
|
18
|
+
import { NetworkPolicy } from './network-policy.js';
|
|
19
|
+
// ─── Singleton instances ────────────────────────────────────────────
|
|
20
|
+
let secretScanner = null;
|
|
21
|
+
let rateLimiter = null;
|
|
22
|
+
let inputSanitizer = null;
|
|
23
|
+
let toolValidator = null;
|
|
24
|
+
let networkPolicy = null;
|
|
25
|
+
/**
|
|
26
|
+
* Initialize all security modules from config.
|
|
27
|
+
*/
|
|
28
|
+
export function initSecurity(config, workspaceRoot) {
|
|
29
|
+
secretScanner = new SecretScanner({
|
|
30
|
+
enabled: config.secretScanning.enabled,
|
|
31
|
+
action: config.secretScanning.action,
|
|
32
|
+
});
|
|
33
|
+
rateLimiter = new RateLimiter({
|
|
34
|
+
...config.rateLimits,
|
|
35
|
+
});
|
|
36
|
+
inputSanitizer = new InputSanitizer({
|
|
37
|
+
enabled: config.sanitizer.enabled,
|
|
38
|
+
mode: config.sanitizer.mode,
|
|
39
|
+
});
|
|
40
|
+
toolValidator = new ToolValidator({ level: config.toolValidation.level }, workspaceRoot);
|
|
41
|
+
networkPolicy = new NetworkPolicy({
|
|
42
|
+
mode: config.network.mode,
|
|
43
|
+
allowlist: config.network.allowlist,
|
|
44
|
+
blocklist: config.network.blocklist,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/** Get the secret scanner instance. */
|
|
48
|
+
export function getSecretScanner() {
|
|
49
|
+
return secretScanner;
|
|
50
|
+
}
|
|
51
|
+
/** Get the rate limiter instance. */
|
|
52
|
+
export function getRateLimiter() {
|
|
53
|
+
return rateLimiter;
|
|
54
|
+
}
|
|
55
|
+
/** Get the input sanitizer instance. */
|
|
56
|
+
export function getInputSanitizer() {
|
|
57
|
+
return inputSanitizer;
|
|
58
|
+
}
|
|
59
|
+
/** Get the tool validator instance. */
|
|
60
|
+
export function getToolValidator() {
|
|
61
|
+
return toolValidator;
|
|
62
|
+
}
|
|
63
|
+
/** Get the network policy instance. */
|
|
64
|
+
export function getNetworkPolicy() {
|
|
65
|
+
return networkPolicy;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Scan and redact secrets from outgoing text.
|
|
69
|
+
* Returns the (possibly redacted) text.
|
|
70
|
+
*/
|
|
71
|
+
export function scanSecrets(text) {
|
|
72
|
+
if (!secretScanner)
|
|
73
|
+
return text;
|
|
74
|
+
const result = secretScanner.scan(text);
|
|
75
|
+
if (result.hasSecrets && result.detections.length > 0) {
|
|
76
|
+
console.warn(`[security] Detected ${result.detections.length} secret(s) in output: ${result.detections.map((d) => d.type).join(', ')}`);
|
|
77
|
+
}
|
|
78
|
+
return result.text;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Check rate limit for a user/channel pair.
|
|
82
|
+
* Returns null if allowed, or an error message if limited.
|
|
83
|
+
*/
|
|
84
|
+
export function checkRateLimit(userId, channelId) {
|
|
85
|
+
if (!rateLimiter)
|
|
86
|
+
return null;
|
|
87
|
+
const result = rateLimiter.check(userId, channelId);
|
|
88
|
+
if (!result.allowed) {
|
|
89
|
+
return `Rate limited (${result.limitType}). Try again in ${result.retryAfterSeconds}s.`;
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Sanitize user input for prompt injection.
|
|
95
|
+
* Returns the sanitized text, or null if blocked.
|
|
96
|
+
*/
|
|
97
|
+
export function sanitizeInput(text) {
|
|
98
|
+
if (!inputSanitizer)
|
|
99
|
+
return { text, blocked: false, warnings: [] };
|
|
100
|
+
const result = inputSanitizer.sanitize(text);
|
|
101
|
+
const warnings = result.detections.map((d) => `[${d.severity}] ${d.pattern}`);
|
|
102
|
+
if (result.flagged) {
|
|
103
|
+
console.warn(`[security] Input sanitizer flagged: ${warnings.join(', ')}`);
|
|
104
|
+
}
|
|
105
|
+
return { text: result.text, blocked: result.blocked, warnings };
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Check if a URL is allowed by network policy.
|
|
109
|
+
* Returns null if allowed, or an error message if blocked.
|
|
110
|
+
*/
|
|
111
|
+
export function checkNetworkPolicy(url) {
|
|
112
|
+
if (!networkPolicy)
|
|
113
|
+
return null;
|
|
114
|
+
const result = networkPolicy.check(url);
|
|
115
|
+
if (!result.allowed) {
|
|
116
|
+
return result.reason ?? 'Blocked by network policy';
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=security.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.js","sourceRoot":"","sources":["../../src/core/security.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAA4B,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAwB,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,aAAa,EAA4B,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,aAAa,EAA4B,MAAM,qBAAqB,CAAC;AAG9E,uEAAuE;AAEvE,IAAI,aAAa,GAAyB,IAAI,CAAC;AAC/C,IAAI,WAAW,GAAuB,IAAI,CAAC;AAC3C,IAAI,cAAc,GAA0B,IAAI,CAAC;AACjD,IAAI,aAAa,GAAyB,IAAI,CAAC;AAC/C,IAAI,aAAa,GAAyB,IAAI,CAAC;AAE/C;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,MAAsB,EAAE,aAAqB;IACxE,aAAa,GAAG,IAAI,aAAa,CAAC;QAChC,OAAO,EAAE,MAAM,CAAC,cAAc,CAAC,OAAO;QACtC,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM;KACrC,CAAC,CAAC;IAEH,WAAW,GAAG,IAAI,WAAW,CAAC;QAC5B,GAAG,MAAM,CAAC,UAAU;KACrB,CAAC,CAAC;IAEH,cAAc,GAAG,IAAI,cAAc,CAAC;QAClC,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO;QACjC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI;KAC5B,CAAC,CAAC;IAEH,aAAa,GAAG,IA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M,CAAC,MAAM,IAAI,2BAA2B,CAAC;IACtD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-awareness — generates a concise repo structure map.
|
|
3
|
+
*
|
|
4
|
+
* Scans the project directory tree and produces a `tree`-like output
|
|
5
|
+
* that the agent can reference to understand its own codebase.
|
|
6
|
+
* Skips noise directories (node_modules, .git, dist, etc.).
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Check if the given path is a git repository root.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isGitRepo(dirPath: string): Promise<boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* Generate a concise repo structure map as a tree-formatted string.
|
|
14
|
+
*
|
|
15
|
+
* @param projectDir - The project root to scan
|
|
16
|
+
* @returns A formatted tree string, or empty string if not a git repo
|
|
17
|
+
*/
|
|
18
|
+
export declare function generateRepoMap(projectDir: string): Promise<string>;
|
|
19
|
+
//# sourceMappingURL=self-awareness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self-awareness.d.ts","sourceRoot":"","sources":["../../src/core/self-awareness.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqCH;;GAEG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOjE;AAkED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAwBzE"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-awareness — generates a concise repo structure map.
|
|
3
|
+
*
|
|
4
|
+
* Scans the project directory tree and produces a `tree`-like output
|
|
5
|
+
* that the agent can reference to understand its own codebase.
|
|
6
|
+
* Skips noise directories (node_modules, .git, dist, etc.).
|
|
7
|
+
*/
|
|
8
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
9
|
+
import { join, relative } from 'node:path';
|
|
10
|
+
/** Directories to always skip when scanning. */
|
|
11
|
+
const SKIP_DIRS = new Set([
|
|
12
|
+
'node_modules',
|
|
13
|
+
'.git',
|
|
14
|
+
'dist',
|
|
15
|
+
'.next',
|
|
16
|
+
'.turbo',
|
|
17
|
+
'.cache',
|
|
18
|
+
'.DS_Store',
|
|
19
|
+
'coverage',
|
|
20
|
+
'__pycache__',
|
|
21
|
+
'.venv',
|
|
22
|
+
'venv',
|
|
23
|
+
]);
|
|
24
|
+
/** Max depth to scan (prevents runaway recursion). */
|
|
25
|
+
const MAX_DEPTH = 6;
|
|
26
|
+
/** Max total entries to include in the map. */
|
|
27
|
+
const MAX_ENTRIES = 200;
|
|
28
|
+
/**
|
|
29
|
+
* Check if the given path is a git repository root.
|
|
30
|
+
*/
|
|
31
|
+
export async function isGitRepo(dirPath) {
|
|
32
|
+
try {
|
|
33
|
+
const s = await stat(join(dirPath, '.git'));
|
|
34
|
+
return s.isDirectory();
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Scan a directory tree and return a flat list of entries.
|
|
42
|
+
*/
|
|
43
|
+
async function scanTree(rootDir, currentDir, depth, entries) {
|
|
44
|
+
if (depth > MAX_DEPTH || entries.length >= MAX_ENTRIES)
|
|
45
|
+
return;
|
|
46
|
+
let items;
|
|
47
|
+
try {
|
|
48
|
+
items = await readdir(currentDir);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// Sort: directories first, then alphabetical
|
|
54
|
+
const dirEntries = [];
|
|
55
|
+
for (const name of items) {
|
|
56
|
+
if (SKIP_DIRS.has(name) || name.startsWith('.'))
|
|
57
|
+
continue;
|
|
58
|
+
try {
|
|
59
|
+
const fullPath = join(currentDir, name);
|
|
60
|
+
const s = await stat(fullPath);
|
|
61
|
+
dirEntries.push({ name, isDir: s.isDirectory(), size: s.size });
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// Skip entries we can't stat
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
dirEntries.sort((a, b) => {
|
|
68
|
+
if (a.isDir !== b.isDir)
|
|
69
|
+
return a.isDir ? -1 : 1;
|
|
70
|
+
return a.name.localeCompare(b.name);
|
|
71
|
+
});
|
|
72
|
+
for (const entry of dirEntries) {
|
|
73
|
+
if (entries.length >= MAX_ENTRIES)
|
|
74
|
+
break;
|
|
75
|
+
const fullPath = join(currentDir, entry.name);
|
|
76
|
+
const relPath = relative(rootDir, fullPath);
|
|
77
|
+
entries.push({
|
|
78
|
+
path: relPath,
|
|
79
|
+
isDir: entry.isDir,
|
|
80
|
+
depth,
|
|
81
|
+
size: entry.size,
|
|
82
|
+
});
|
|
83
|
+
if (entry.isDir) {
|
|
84
|
+
await scanTree(rootDir, fullPath, depth + 1, entries);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Format file size for display.
|
|
90
|
+
*/
|
|
91
|
+
function formatSize(bytes) {
|
|
92
|
+
if (bytes < 1024)
|
|
93
|
+
return `${bytes}B`;
|
|
94
|
+
if (bytes < 1024 * 1024)
|
|
95
|
+
return `${(bytes / 1024).toFixed(1)}K`;
|
|
96
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)}M`;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Generate a concise repo structure map as a tree-formatted string.
|
|
100
|
+
*
|
|
101
|
+
* @param projectDir - The project root to scan
|
|
102
|
+
* @returns A formatted tree string, or empty string if not a git repo
|
|
103
|
+
*/
|
|
104
|
+
export async function generateRepoMap(projectDir) {
|
|
105
|
+
if (!(await isGitRepo(projectDir)))
|
|
106
|
+
return '';
|
|
107
|
+
const entries = [];
|
|
108
|
+
await scanTree(projectDir, projectDir, 0, entries);
|
|
109
|
+
if (entries.length === 0)
|
|
110
|
+
return '';
|
|
111
|
+
const lines = ['# Repo Structure', ''];
|
|
112
|
+
lines.push('```');
|
|
113
|
+
for (const entry of entries) {
|
|
114
|
+
const indent = ' '.repeat(entry.depth);
|
|
115
|
+
const suffix = entry.isDir ? '/' : ` (${formatSize(entry.size)})`;
|
|
116
|
+
lines.push(`${indent}${entry.path.split('/').pop()}${suffix}`);
|
|
117
|
+
}
|
|
118
|
+
if (entries.length >= MAX_ENTRIES) {
|
|
119
|
+
lines.push(' ... (truncated)');
|
|
120
|
+
}
|
|
121
|
+
lines.push('```');
|
|
122
|
+
return lines.join('\n');
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=self-awareness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self-awareness.js","sourceRoot":"","sources":["../../src/core/self-awareness.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE3C,gDAAgD;AAChD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IACxB,cAAc;IACd,MAAM;IACN,MAAM;IACN,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,UAAU;IACV,aAAa;IACb,OAAO;IACP,MAAM;CACP,CAAC,CAAC;AAEH,sDAAsD;AACtD,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,+CAA+C;AAC/C,MAAM,WAAW,GAAG,GAAG,CAAC;AAaxB;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAe;IAC7C,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;QAC5C,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IACzB,CAAC;IAAC,MAAM,CAAC;QACP,O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,CAAC;QAAE,OAAO,EAAE,CAAC;IAEpC,MAAM,KAAK,GAAa,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;IACjD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAElB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACxC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;QAClE,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,IAAI,WAAW,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAElB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session init protocol — ensures agents start each session productively.
|
|
3
|
+
*
|
|
4
|
+
* After compaction or on a fresh session, injects a structured init sequence
|
|
5
|
+
* that tells the agent to:
|
|
6
|
+
* 1. Read progress file for recent work
|
|
7
|
+
* 2. Check git log for recent commits
|
|
8
|
+
* 3. Run basic health check
|
|
9
|
+
* 4. Pick ONE task to work on
|
|
10
|
+
*
|
|
11
|
+
* This prevents the agent from wasting tokens figuring out context.
|
|
12
|
+
*/
|
|
13
|
+
import type { ProgressTracker } from './progress.js';
|
|
14
|
+
export interface SessionInitConfig {
|
|
15
|
+
/** Enable session init protocol (default: true) */
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
/** Include git log summary (default: true) */
|
|
18
|
+
includeGitLog: boolean;
|
|
19
|
+
/** Number of recent progress entries to include (default: 3) */
|
|
20
|
+
progressEntries: number;
|
|
21
|
+
/** Custom init instructions (appended to default) */
|
|
22
|
+
customInstructions?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Build the session init prompt to inject after compaction or on new session.
|
|
26
|
+
* This is injected as a system message so the agent follows the protocol.
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildSessionInitPrompt(config?: Partial<SessionInitConfig>): string;
|
|
29
|
+
/**
|
|
30
|
+
* Build the full init context including progress summary.
|
|
31
|
+
* Called when a session starts fresh or after compaction.
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildSessionInitContext(progressTracker: ProgressTracker, config?: Partial<SessionInitConfig>): Promise<string>;
|
|
34
|
+
//# sourceMappingURL=session-init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-init.d.ts","sourceRoot":"","sources":["../../src/core/session-init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,mDAAmD;IACnD,OAAO,EAAE,OAAO,CAAC;IACjB,8CAA8C;IAC9C,aAAa,EAAE,OAAO,CAAC;IACvB,gEAAgE;IAChE,eAAe,EAAE,MAAM,CAAC;IACxB,qDAAqD;IACrD,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAQD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,MAAM,CAgClF;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,eAAe,EAAE,eAAe,EAChC,MAAM,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAClC,OAAO,CAAC,MAAM,CAAC,CAcjB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session init protocol — ensures agents start each session productively.
|
|
3
|
+
*
|
|
4
|
+
* After compaction or on a fresh session, injects a structured init sequence
|
|
5
|
+
* that tells the agent to:
|
|
6
|
+
* 1. Read progress file for recent work
|
|
7
|
+
* 2. Check git log for recent commits
|
|
8
|
+
* 3. Run basic health check
|
|
9
|
+
* 4. Pick ONE task to work on
|
|
10
|
+
*
|
|
11
|
+
* This prevents the agent from wasting tokens figuring out context.
|
|
12
|
+
*/
|
|
13
|
+
const DEFAULT_CONFIG = {
|
|
14
|
+
enabled: true,
|
|
15
|
+
includeGitLog: true,
|
|
16
|
+
progressEntries: 3,
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Build the session init prompt to inject after compaction or on new session.
|
|
20
|
+
* This is injected as a system message so the agent follows the protocol.
|
|
21
|
+
*/
|
|
22
|
+
export function buildSessionInitPrompt(config) {
|
|
23
|
+
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
24
|
+
const lines = [
|
|
25
|
+
'## Session Init Protocol',
|
|
26
|
+
'',
|
|
27
|
+
'You are resuming work on an ongoing project. Before doing anything else:',
|
|
28
|
+
'',
|
|
29
|
+
'1. **Read progress**: Check `tako-progress.json` for what previous sessions accomplished.',
|
|
30
|
+
'2. **Check git**: Run `git log --oneline -10` to see recent commits.',
|
|
31
|
+
'3. **Health check**: Verify the project is in a working state (build passes, no broken tests).',
|
|
32
|
+
'4. **Pick ONE task**: Choose the highest-priority incomplete task and work on it.',
|
|
33
|
+
'',
|
|
34
|
+
'### Work Rules',
|
|
35
|
+
'- Work on **one feature/task at a time**. Complete it, test it, commit it, then move on.',
|
|
36
|
+
'- **Commit frequently** with descriptive messages.',
|
|
37
|
+
'- Before declaring a task done, **verify it works** (run tests, check output).',
|
|
38
|
+
'- At the end of your work session, **update tako-progress.json** with what you did.',
|
|
39
|
+
'- Leave the codebase in a **clean, working state** — no half-implemented features.',
|
|
40
|
+
'',
|
|
41
|
+
'### Do NOT',
|
|
42
|
+
'- Try to implement everything at once.',
|
|
43
|
+
'- Declare the project "done" without verifying all tasks.',
|
|
44
|
+
'- Leave uncommitted changes.',
|
|
45
|
+
'- Skip testing.',
|
|
46
|
+
];
|
|
47
|
+
if (cfg.customInstructions) {
|
|
48
|
+
lines.push('', '### Additional Instructions', cfg.customInstructions);
|
|
49
|
+
}
|
|
50
|
+
return lines.join('\n');
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Build the full init context including progress summary.
|
|
54
|
+
* Called when a session starts fresh or after compaction.
|
|
55
|
+
*/
|
|
56
|
+
export async function buildSessionInitContext(progressTracker, config) {
|
|
57
|
+
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
58
|
+
const parts = [];
|
|
59
|
+
// Add init protocol
|
|
60
|
+
parts.push(buildSessionInitPrompt(cfg));
|
|
61
|
+
// Add progress summary if available
|
|
62
|
+
const summary = await progressTracker.getSummaryForContext(cfg.progressEntries);
|
|
63
|
+
if (summary) {
|
|
64
|
+
parts.push('', summary);
|
|
65
|
+
}
|
|
66
|
+
return parts.join('\n');
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=session-init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-init.js","sourceRoot":"","sources":["../../src/core/session-init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAeH,MAAM,cAAc,GAAsB;IACxC,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,IAAI;IACnB,eAAe,EAAE,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAmC;IACxE,MAAM,GAAG,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,MAAM,EAAE,CAAC;IAE7C,MAAM,KAAK,GAAa;QACtB,0BAA0B;QAC1B,EAAE;QACF,0EAA0E;QAC1E,EAAE;QACF,2FAA2F;QAC3F,sEAAsE;QACtE,gGAAgG;QAChG,mFAAmF;QACnF,EAAE;QACF,gBAAgB;QAChB,0FAA0F;QAC1F,oDAAoD;QACpD,gFAAgF;QAChF,qFAAqF;QACrF,oFAAoF;QACpF,EAAE;QACF,YAAY;QACZ,wCAAwC;QACxC,2DAA2D;QAC3D,8BAA8B;QAC9B,iBAAiB;KAClB,CAAC;IAEF,IAAI,GAAG,CAAC,kBAAkB,EAAE,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,6BAA6B,EAAE,GAAG,CAAC,kBAAkB,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,eAAgC,EAChC,MAAmC;IAEnC,MAAM,GAAG,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,MAAM,EAAE,CAAC;IAC7C,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,oBAAoB;IACpB,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC;IAExC,oCAAoC;IACpC,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,oBAAoB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAChF,IAAI,OAAO,EAAE,CAAC;QACZ,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response streaming — deliver model output in chunks as it's generated.
|
|
3
|
+
*
|
|
4
|
+
* Instead of waiting for the full response, stream text chunks to the
|
|
5
|
+
* channel in real-time. Handles:
|
|
6
|
+
* - Chunk buffering (don't send every token, batch ~50-100 chars)
|
|
7
|
+
* - Channel-specific chunk delivery (Discord edits, Telegram edits, CLI stdout)
|
|
8
|
+
* - Tool call handling (pause streaming during tool execution)
|
|
9
|
+
* - Markdown boundary detection (don't split mid-codeblock)
|
|
10
|
+
*/
|
|
11
|
+
import type { Channel } from '../channels/channel.js';
|
|
12
|
+
/** Configuration for response streaming behavior. */
|
|
13
|
+
export interface StreamConfig {
|
|
14
|
+
/** Enable streaming (default: true) */
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
/** Min chars to buffer before sending a chunk (default: 50) */
|
|
17
|
+
minChunkSize: number;
|
|
18
|
+
/** Max ms to wait before flushing buffer (default: 500) */
|
|
19
|
+
flushIntervalMs: number;
|
|
20
|
+
/** Max message length before splitting into new message (default: 2000 for Discord) */
|
|
21
|
+
maxMessageLength: number;
|
|
22
|
+
}
|
|
23
|
+
/** Context for a streaming session — identifies where to deliver chunks. */
|
|
24
|
+
export interface StreamContext {
|
|
25
|
+
/** Target chat/channel ID for sending messages. */
|
|
26
|
+
channelId: string;
|
|
27
|
+
/** Existing message ID to edit (for updating in-place). */
|
|
28
|
+
messageId?: string;
|
|
29
|
+
/** The channel adapter to send through. */
|
|
30
|
+
channel: Channel;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Buffers streaming text and delivers it to a channel in chunks.
|
|
34
|
+
*
|
|
35
|
+
* For channels that support `editMessage` (Discord, Telegram), the streamer
|
|
36
|
+
* sends an initial message then edits it as more text arrives. When the
|
|
37
|
+
* message exceeds `maxMessageLength`, it sends a new message and continues.
|
|
38
|
+
*
|
|
39
|
+
* For channels without edit support (CLI), text is written incrementally
|
|
40
|
+
* via `send()`.
|
|
41
|
+
*/
|
|
42
|
+
export declare class ResponseStreamer {
|
|
43
|
+
private config;
|
|
44
|
+
private context;
|
|
45
|
+
private buffer;
|
|
46
|
+
private sentMessageId?;
|
|
47
|
+
private totalSent;
|
|
48
|
+
private flushTimer?;
|
|
49
|
+
private finished;
|
|
50
|
+
constructor(config: Partial<StreamConfig>, context: StreamContext);
|
|
51
|
+
/** Add text to the stream buffer. May trigger a flush. */
|
|
52
|
+
push(text: string): Promise<void>;
|
|
53
|
+
/** Force flush remaining buffer (call at end of response). */
|
|
54
|
+
finish(): Promise<void>;
|
|
55
|
+
/** Cancel streaming (e.g., on error). */
|
|
56
|
+
cancel(): Promise<void>;
|
|
57
|
+
/** Get total characters streamed so far. */
|
|
58
|
+
get length(): number;
|
|
59
|
+
private clearTimer;
|
|
60
|
+
private shouldFlush;
|
|
61
|
+
/**
|
|
62
|
+
* Flush the buffer to the channel.
|
|
63
|
+
*
|
|
64
|
+
* Strategy depends on channel capabilities:
|
|
65
|
+
* - If channel has editMessage + sendAndGetId: edit-in-place, split on overflow
|
|
66
|
+
* - Otherwise: send incremental chunks via send()
|
|
67
|
+
*/
|
|
68
|
+
private flush;
|
|
69
|
+
/** Flush using edit-in-place (Discord/Telegram style). */
|
|
70
|
+
private flushWithEdit;
|
|
71
|
+
/**
|
|
72
|
+
* Find a safe position to break the text at, avoiding splits inside:
|
|
73
|
+
* - Fenced code blocks (```)
|
|
74
|
+
* - Markdown formatting (**bold**, *italic*, __underline__, ~~strike~~)
|
|
75
|
+
* - Bullet points / list items
|
|
76
|
+
* - Mid-word
|
|
77
|
+
*
|
|
78
|
+
* Returns the index to break at (exclusive).
|
|
79
|
+
*/
|
|
80
|
+
private findSafeBreakpoint;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=streaming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../../src/core/streaming.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAmB,MAAM,wBAAwB,CAAC;AAIvE,qDAAqD;AACrD,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,+DAA+D;IAC/D,YAAY,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,eAAe,EAAE,MAAM,CAAC;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