@geminixiang/mikan 1.0.0-beta.5 → 1.0.0-beta.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +835 -0
- package/README.md +92 -36
- package/dist/adapter.d.ts +11 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +18 -1
- package/dist/adapter.js.map +1 -1
- package/dist/adapters/discord/bot.d.ts +12 -8
- package/dist/adapters/discord/bot.d.ts.map +1 -1
- package/dist/adapters/discord/bot.js +228 -252
- package/dist/adapters/discord/bot.js.map +1 -1
- package/dist/adapters/discord/components.d.ts +28 -0
- package/dist/adapters/discord/components.d.ts.map +1 -0
- package/dist/adapters/discord/components.js +32 -0
- package/dist/adapters/discord/components.js.map +1 -0
- package/dist/adapters/discord/context.d.ts +2 -6
- package/dist/adapters/discord/context.d.ts.map +1 -1
- package/dist/adapters/discord/context.js +63 -218
- package/dist/adapters/discord/context.js.map +1 -1
- package/dist/adapters/discord/format.d.ts +3 -0
- package/dist/adapters/discord/format.d.ts.map +1 -0
- package/dist/adapters/discord/format.js +84 -0
- package/dist/adapters/discord/format.js.map +1 -0
- package/dist/adapters/discord/types.d.ts +7 -0
- package/dist/adapters/discord/types.d.ts.map +1 -1
- package/dist/adapters/discord/types.js.map +1 -1
- package/dist/adapters/github/bot.d.ts +102 -0
- package/dist/adapters/github/bot.d.ts.map +1 -0
- package/dist/adapters/github/bot.js +721 -0
- package/dist/adapters/github/bot.js.map +1 -0
- package/dist/adapters/github/client.d.ts +122 -0
- package/dist/adapters/github/client.d.ts.map +1 -0
- package/dist/adapters/github/client.js +314 -0
- package/dist/adapters/github/client.js.map +1 -0
- package/dist/adapters/github/context.d.ts +5 -0
- package/dist/adapters/github/context.d.ts.map +1 -0
- package/dist/adapters/github/context.js +101 -0
- package/dist/adapters/github/context.js.map +1 -0
- package/dist/adapters/github/github-ops.d.ts +78 -0
- package/dist/adapters/github/github-ops.d.ts.map +1 -0
- package/dist/adapters/github/github-ops.js +337 -0
- package/dist/adapters/github/github-ops.js.map +1 -0
- package/dist/adapters/github/ids.d.ts +34 -0
- package/dist/adapters/github/ids.d.ts.map +1 -0
- package/dist/adapters/github/ids.js +57 -0
- package/dist/adapters/github/ids.js.map +1 -0
- package/dist/adapters/github/repo.d.ts +33 -0
- package/dist/adapters/github/repo.d.ts.map +1 -0
- package/dist/adapters/github/repo.js +141 -0
- package/dist/adapters/github/repo.js.map +1 -0
- package/dist/adapters/github/tool-pack.d.ts +14 -0
- package/dist/adapters/github/tool-pack.d.ts.map +1 -0
- package/dist/adapters/github/tool-pack.js +55 -0
- package/dist/adapters/github/tool-pack.js.map +1 -0
- package/dist/adapters/github/tools/checks.d.ts +18 -0
- package/dist/adapters/github/tools/checks.d.ts.map +1 -0
- package/dist/adapters/github/tools/checks.js +86 -0
- package/dist/adapters/github/tools/checks.js.map +1 -0
- package/dist/adapters/github/tools/issue.d.ts +21 -0
- package/dist/adapters/github/tools/issue.d.ts.map +1 -0
- package/dist/adapters/github/tools/issue.js +48 -0
- package/dist/adapters/github/tools/issue.js.map +1 -0
- package/dist/adapters/github/tools/pr.d.ts +22 -0
- package/dist/adapters/github/tools/pr.d.ts.map +1 -0
- package/dist/adapters/github/tools/pr.js +48 -0
- package/dist/adapters/github/tools/pr.js.map +1 -0
- package/dist/adapters/github/tools/read.d.ts +21 -0
- package/dist/adapters/github/tools/read.d.ts.map +1 -0
- package/dist/adapters/github/tools/read.js +141 -0
- package/dist/adapters/github/tools/read.js.map +1 -0
- package/dist/adapters/github/tools/review-reply.d.ts +17 -0
- package/dist/adapters/github/tools/review-reply.d.ts.map +1 -0
- package/dist/adapters/github/tools/review-reply.js +38 -0
- package/dist/adapters/github/tools/review-reply.js.map +1 -0
- package/dist/adapters/github/tools/sync.d.ts +17 -0
- package/dist/adapters/github/tools/sync.d.ts.map +1 -0
- package/dist/adapters/github/tools/sync.js +34 -0
- package/dist/adapters/github/tools/sync.js.map +1 -0
- package/dist/adapters/github/types.d.ts +345 -0
- package/dist/adapters/github/types.d.ts.map +1 -0
- package/dist/adapters/github/types.js.map +1 -0
- package/dist/adapters/github/webhook.d.ts +20 -0
- package/dist/adapters/github/webhook.d.ts.map +1 -0
- package/dist/adapters/github/webhook.js +78 -0
- package/dist/adapters/github/webhook.js.map +1 -0
- package/dist/adapters/intake.d.ts +16 -5
- package/dist/adapters/intake.d.ts.map +1 -1
- package/dist/adapters/intake.js +86 -23
- package/dist/adapters/intake.js.map +1 -1
- package/dist/adapters/markdown-tables.d.ts +32 -0
- package/dist/adapters/markdown-tables.d.ts.map +1 -0
- package/dist/adapters/markdown-tables.js +164 -0
- package/dist/adapters/markdown-tables.js.map +1 -0
- package/dist/adapters/progressive-renderer.d.ts +7 -0
- package/dist/adapters/progressive-renderer.d.ts.map +1 -0
- package/dist/adapters/progressive-renderer.js +433 -0
- package/dist/adapters/progressive-renderer.js.map +1 -0
- package/dist/adapters/shared.d.ts +35 -11
- package/dist/adapters/shared.d.ts.map +1 -1
- package/dist/adapters/shared.js +104 -23
- package/dist/adapters/shared.js.map +1 -1
- package/dist/adapters/slack/assistant.d.ts +73 -0
- package/dist/adapters/slack/assistant.d.ts.map +1 -0
- package/dist/adapters/slack/assistant.js +205 -0
- package/dist/adapters/slack/assistant.js.map +1 -0
- package/dist/adapters/slack/blocks.d.ts +14 -0
- package/dist/adapters/slack/blocks.d.ts.map +1 -1
- package/dist/adapters/slack/blocks.js +103 -148
- package/dist/adapters/slack/blocks.js.map +1 -1
- package/dist/adapters/slack/bot.d.ts +110 -14
- package/dist/adapters/slack/bot.d.ts.map +1 -1
- package/dist/adapters/slack/bot.js +695 -378
- package/dist/adapters/slack/bot.js.map +1 -1
- package/dist/adapters/slack/context.d.ts +2 -6
- package/dist/adapters/slack/context.d.ts.map +1 -1
- package/dist/adapters/slack/context.js +11 -17
- package/dist/adapters/slack/context.js.map +1 -1
- package/dist/adapters/slack/response-lifecycle.d.ts.map +1 -1
- package/dist/adapters/slack/response-lifecycle.js +225 -339
- package/dist/adapters/slack/response-lifecycle.js.map +1 -1
- package/dist/adapters/slack/session.d.ts.map +1 -1
- package/dist/adapters/slack/session.js +7 -11
- package/dist/adapters/slack/session.js.map +1 -1
- package/dist/adapters/slack/stream-limits.d.ts +35 -0
- package/dist/adapters/slack/stream-limits.d.ts.map +1 -0
- package/dist/adapters/slack/stream-limits.js +56 -0
- package/dist/adapters/slack/stream-limits.js.map +1 -0
- package/dist/adapters/slack/tool-pack.d.ts +11 -0
- package/dist/adapters/slack/tool-pack.d.ts.map +1 -0
- package/dist/adapters/slack/tool-pack.js +45 -0
- package/dist/adapters/slack/tool-pack.js.map +1 -0
- package/dist/adapters/slack/tools/attach.js +1 -1
- package/dist/adapters/slack/tools/attach.js.map +1 -1
- package/dist/adapters/slack/tools/blockkit.d.ts +14 -0
- package/dist/adapters/slack/tools/blockkit.d.ts.map +1 -0
- package/dist/adapters/slack/tools/blockkit.js +106 -0
- package/dist/adapters/slack/tools/blockkit.js.map +1 -0
- package/dist/adapters/slack/types.d.ts +73 -2
- package/dist/adapters/slack/types.d.ts.map +1 -1
- package/dist/adapters/slack/types.js.map +1 -1
- package/dist/adapters/telegram/bot.d.ts +11 -9
- package/dist/adapters/telegram/bot.d.ts.map +1 -1
- package/dist/adapters/telegram/bot.js +138 -196
- package/dist/adapters/telegram/bot.js.map +1 -1
- package/dist/adapters/telegram/context.d.ts +2 -6
- package/dist/adapters/telegram/context.d.ts.map +1 -1
- package/dist/adapters/telegram/context.js +52 -190
- package/dist/adapters/telegram/context.js.map +1 -1
- package/dist/adapters/types.d.ts +145 -12
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/adapters/types.js.map +1 -1
- package/dist/agent/catalog.d.ts +22 -0
- package/dist/agent/catalog.d.ts.map +1 -0
- package/dist/agent/catalog.js +104 -0
- package/dist/agent/catalog.js.map +1 -0
- package/dist/agent/execution.d.ts +25 -0
- package/dist/agent/execution.d.ts.map +1 -0
- package/dist/agent/execution.js +171 -0
- package/dist/agent/execution.js.map +1 -0
- package/dist/agent/presenter.d.ts +37 -0
- package/dist/agent/presenter.d.ts.map +1 -0
- package/dist/agent/presenter.js +674 -0
- package/dist/agent/presenter.js.map +1 -0
- package/dist/agent/prompt.d.ts +23 -0
- package/dist/agent/prompt.d.ts.map +1 -0
- package/dist/agent/prompt.js +330 -0
- package/dist/agent/prompt.js.map +1 -0
- package/dist/agent/runner.d.ts +3 -0
- package/dist/agent/runner.d.ts.map +1 -0
- package/dist/agent/runner.js +452 -0
- package/dist/agent/runner.js.map +1 -0
- package/dist/agent/types.d.ts +101 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +3 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/agent-events.d.ts +3 -2
- package/dist/agent-events.d.ts.map +1 -1
- package/dist/agent-events.js +19 -1
- package/dist/agent-events.js.map +1 -1
- package/dist/cli/arg-grammar.d.ts +25 -0
- package/dist/cli/arg-grammar.d.ts.map +1 -0
- package/dist/cli/arg-grammar.js +61 -0
- package/dist/cli/arg-grammar.js.map +1 -0
- package/dist/cli/boot.d.ts +5 -0
- package/dist/cli/boot.d.ts.map +1 -0
- package/dist/cli/boot.js +117 -0
- package/dist/cli/boot.js.map +1 -0
- package/dist/cli/download.d.ts.map +1 -0
- package/dist/{download.js → cli/download.js} +2 -0
- package/dist/cli/download.js.map +1 -0
- package/dist/cli/office.d.ts +2 -0
- package/dist/cli/office.d.ts.map +1 -0
- package/dist/cli/office.js +91 -0
- package/dist/cli/office.js.map +1 -0
- package/dist/cli/onboard.d.ts +10 -0
- package/dist/cli/onboard.d.ts.map +1 -0
- package/dist/cli/onboard.js +237 -0
- package/dist/cli/onboard.js.map +1 -0
- package/dist/cli/sessions.d.ts +2 -0
- package/dist/cli/sessions.d.ts.map +1 -0
- package/dist/cli/sessions.js +83 -0
- package/dist/cli/sessions.js.map +1 -0
- package/dist/cli/types.d.ts +23 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +3 -2
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/auto-reply.d.ts.map +1 -1
- package/dist/commands/auto-reply.js +10 -21
- package/dist/commands/auto-reply.js.map +1 -1
- package/dist/commands/login.d.ts +2 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +51 -8
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/manifest.d.ts +37 -0
- package/dist/commands/manifest.d.ts.map +1 -0
- package/dist/commands/manifest.js +147 -0
- package/dist/commands/manifest.js.map +1 -0
- package/dist/commands/model.d.ts +2 -3
- package/dist/commands/model.d.ts.map +1 -1
- package/dist/commands/model.js +63 -24
- package/dist/commands/model.js.map +1 -1
- package/dist/commands/new.d.ts.map +1 -1
- package/dist/commands/new.js +20 -3
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/registry.d.ts +2 -2
- package/dist/commands/registry.d.ts.map +1 -1
- package/dist/commands/registry.js +25 -13
- package/dist/commands/registry.js.map +1 -1
- package/dist/commands/sandbox.d.ts.map +1 -1
- package/dist/commands/sandbox.js +121 -52
- package/dist/commands/sandbox.js.map +1 -1
- package/dist/commands/session-view.d.ts.map +1 -1
- package/dist/commands/session-view.js +15 -5
- package/dist/commands/session-view.js.map +1 -1
- package/dist/commands/types.d.ts +87 -8
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/types.js.map +1 -1
- package/dist/config.d.ts +37 -16
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +280 -153
- package/dist/config.js.map +1 -1
- package/dist/dream/index.d.ts +20 -0
- package/dist/dream/index.d.ts.map +1 -0
- package/dist/dream/index.js +258 -0
- package/dist/dream/index.js.map +1 -0
- package/dist/dream/types.d.ts +30 -0
- package/dist/dream/types.d.ts.map +1 -0
- package/dist/dream/types.js +2 -0
- package/dist/dream/types.js.map +1 -0
- package/dist/env-manifest.d.ts +30 -0
- package/dist/env-manifest.d.ts.map +1 -0
- package/dist/env-manifest.js +223 -0
- package/dist/env-manifest.js.map +1 -0
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +20 -81
- package/dist/events.js.map +1 -1
- package/dist/execution-resolver.d.ts +16 -10
- package/dist/execution-resolver.d.ts.map +1 -1
- package/dist/execution-resolver.js +106 -111
- package/dist/execution-resolver.js.map +1 -1
- package/dist/harness/event-format.d.ts +33 -0
- package/dist/harness/event-format.d.ts.map +1 -0
- package/dist/harness/event-format.js +171 -0
- package/dist/harness/event-format.js.map +1 -0
- package/dist/harness/index.d.ts +14 -10
- package/dist/harness/index.d.ts.map +1 -1
- package/dist/harness/index.js +5 -6
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/models.d.ts +7 -4
- package/dist/harness/models.d.ts.map +1 -1
- package/dist/harness/models.js +54 -55
- package/dist/harness/models.js.map +1 -1
- package/dist/harness/runner.d.ts +46 -60
- package/dist/harness/runner.d.ts.map +1 -1
- package/dist/harness/runner.js +158 -103
- package/dist/harness/runner.js.map +1 -1
- package/dist/harness/session-store.d.ts +32 -69
- package/dist/harness/session-store.d.ts.map +1 -1
- package/dist/harness/session-store.js +583 -215
- package/dist/harness/session-store.js.map +1 -1
- package/dist/harness/settings.d.ts +2 -20
- package/dist/harness/settings.d.ts.map +1 -1
- package/dist/harness/settings.js +12 -1
- package/dist/harness/settings.js.map +1 -1
- package/dist/harness/skills.d.ts +10 -29
- package/dist/harness/skills.d.ts.map +1 -1
- package/dist/harness/skills.js +48 -6
- package/dist/harness/skills.js.map +1 -1
- package/dist/harness/subagent-profiles.d.ts +8 -0
- package/dist/harness/subagent-profiles.d.ts.map +1 -0
- package/dist/harness/subagent-profiles.js +299 -0
- package/dist/harness/subagent-profiles.js.map +1 -0
- package/dist/harness/subagent-runner.d.ts +45 -0
- package/dist/harness/subagent-runner.d.ts.map +1 -0
- package/dist/harness/subagent-runner.js +672 -0
- package/dist/harness/subagent-runner.js.map +1 -0
- package/dist/harness/subagent-slots.d.ts +28 -0
- package/dist/harness/subagent-slots.d.ts.map +1 -0
- package/dist/harness/subagent-slots.js +72 -0
- package/dist/harness/subagent-slots.js.map +1 -0
- package/dist/harness/types.d.ts +282 -15
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/harness/types.js +1 -1
- package/dist/harness/types.js.map +1 -1
- package/dist/harness/usage.d.ts +11 -0
- package/dist/harness/usage.d.ts.map +1 -0
- package/dist/harness/usage.js +38 -0
- package/dist/harness/usage.js.map +1 -0
- package/dist/index.d.ts +30 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -5
- package/dist/index.js.map +1 -1
- package/dist/main.js +337 -169
- package/dist/main.js.map +1 -1
- package/dist/mcp/catalog.d.ts +5 -0
- package/dist/mcp/catalog.d.ts.map +1 -0
- package/dist/mcp/catalog.js +68 -0
- package/dist/mcp/catalog.js.map +1 -0
- package/dist/mcp/loader.d.ts +12 -0
- package/dist/mcp/loader.d.ts.map +1 -0
- package/dist/mcp/loader.js +157 -0
- package/dist/mcp/loader.js.map +1 -0
- package/dist/mcp/open-connector.d.ts +14 -0
- package/dist/mcp/open-connector.d.ts.map +1 -0
- package/dist/mcp/open-connector.js +204 -0
- package/dist/mcp/open-connector.js.map +1 -0
- package/dist/mcp/types.d.ts +66 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +2 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/observability/instrument.js +7 -5
- package/dist/observability/instrument.js.map +1 -1
- package/dist/observability/sentry.d.ts +2 -0
- package/dist/observability/sentry.d.ts.map +1 -1
- package/dist/observability/sentry.js +10 -2
- package/dist/observability/sentry.js.map +1 -1
- package/dist/office/index.d.ts +139 -0
- package/dist/office/index.d.ts.map +1 -0
- package/dist/office/index.js +1052 -0
- package/dist/office/index.js.map +1 -0
- package/dist/office/types.d.ts +89 -0
- package/dist/office/types.d.ts.map +1 -0
- package/dist/office/types.js +2 -0
- package/dist/office/types.js.map +1 -0
- package/dist/packages/index.d.ts +169 -0
- package/dist/packages/index.d.ts.map +1 -0
- package/dist/packages/index.js +721 -0
- package/dist/packages/index.js.map +1 -0
- package/dist/packages/types.d.ts +100 -0
- package/dist/packages/types.d.ts.map +1 -0
- package/dist/packages/types.js +2 -0
- package/dist/packages/types.js.map +1 -0
- package/dist/process-lifecycle.d.ts +19 -0
- package/dist/process-lifecycle.d.ts.map +1 -0
- package/dist/process-lifecycle.js +60 -0
- package/dist/process-lifecycle.js.map +1 -0
- package/dist/provisioner.d.ts +62 -2
- package/dist/provisioner.d.ts.map +1 -1
- package/dist/provisioner.js +350 -18
- package/dist/provisioner.js.map +1 -1
- package/dist/runtime/conversation-runtime.d.ts +1 -1
- package/dist/runtime/conversation-runtime.d.ts.map +1 -1
- package/dist/runtime/conversation-runtime.js +380 -145
- package/dist/runtime/conversation-runtime.js.map +1 -1
- package/dist/runtime/session-lifecycle.d.ts +66 -0
- package/dist/runtime/session-lifecycle.d.ts.map +1 -0
- package/dist/runtime/session-lifecycle.js +384 -0
- package/dist/runtime/session-lifecycle.js.map +1 -0
- package/dist/runtime/types.d.ts +56 -12
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/types.js.map +1 -1
- package/dist/sandbox/cloudflare.d.ts +3 -0
- package/dist/sandbox/cloudflare.d.ts.map +1 -1
- package/dist/sandbox/cloudflare.js +14 -3
- package/dist/sandbox/cloudflare.js.map +1 -1
- package/dist/sandbox/container.d.ts +3 -0
- package/dist/sandbox/container.d.ts.map +1 -1
- package/dist/sandbox/container.js +12 -3
- package/dist/sandbox/container.js.map +1 -1
- package/dist/sandbox/host.d.ts +3 -0
- package/dist/sandbox/host.d.ts.map +1 -1
- package/dist/sandbox/host.js +22 -5
- package/dist/sandbox/host.js.map +1 -1
- package/dist/sandbox/identity.d.ts +42 -0
- package/dist/sandbox/identity.d.ts.map +1 -0
- package/dist/sandbox/identity.js +77 -0
- package/dist/sandbox/identity.js.map +1 -0
- package/dist/sandbox/index.d.ts +16 -6
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/sandbox/index.js +71 -8
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/types.d.ts +41 -9
- package/dist/sandbox/types.d.ts.map +1 -1
- package/dist/sandbox/types.js.map +1 -1
- package/dist/sandbox/utils.d.ts +19 -0
- package/dist/sandbox/utils.d.ts.map +1 -1
- package/dist/sandbox/utils.js +78 -1
- package/dist/sandbox/utils.js.map +1 -1
- package/dist/sessions/chat-history-sync.d.ts +23 -0
- package/dist/sessions/chat-history-sync.d.ts.map +1 -0
- package/dist/sessions/{agent-memory-file-manager.js → chat-history-sync.js} +224 -175
- package/dist/sessions/chat-history-sync.js.map +1 -0
- package/dist/sessions/history-line.d.ts +29 -0
- package/dist/sessions/history-line.d.ts.map +1 -0
- package/dist/sessions/history-line.js +45 -0
- package/dist/sessions/history-line.js.map +1 -0
- package/dist/sessions/migrate-pi-084.d.ts +8 -0
- package/dist/sessions/migrate-pi-084.d.ts.map +1 -0
- package/dist/sessions/migrate-pi-084.js +353 -0
- package/dist/sessions/migrate-pi-084.js.map +1 -0
- package/dist/sessions/migrate-v3.d.ts +10 -0
- package/dist/sessions/migrate-v3.d.ts.map +1 -0
- package/dist/sessions/migrate-v3.js +467 -0
- package/dist/sessions/migrate-v3.js.map +1 -0
- package/dist/sessions/session-key.d.ts +33 -0
- package/dist/sessions/session-key.d.ts.map +1 -0
- package/dist/sessions/session-key.js +115 -0
- package/dist/sessions/session-key.js.map +1 -0
- package/dist/sessions/store.d.ts +16 -9
- package/dist/sessions/store.d.ts.map +1 -1
- package/dist/sessions/store.js +180 -46
- package/dist/sessions/store.js.map +1 -1
- package/dist/sessions/types.d.ts +34 -7
- package/dist/sessions/types.d.ts.map +1 -1
- package/dist/sessions/types.js.map +1 -1
- package/dist/settings-mutation.d.ts +40 -0
- package/dist/settings-mutation.d.ts.map +1 -0
- package/dist/settings-mutation.js +66 -0
- package/dist/settings-mutation.js.map +1 -0
- package/dist/subagent-progress.d.ts +39 -0
- package/dist/subagent-progress.d.ts.map +1 -0
- package/dist/subagent-progress.js +225 -0
- package/dist/subagent-progress.js.map +1 -0
- package/dist/tools/bash.d.ts +3 -1
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +22 -22
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/edit.d.ts.map +1 -1
- package/dist/tools/edit.js +14 -13
- package/dist/tools/edit.js.map +1 -1
- package/dist/tools/event.d.ts +1 -1
- package/dist/tools/event.d.ts.map +1 -1
- package/dist/tools/event.js +59 -56
- package/dist/tools/event.js.map +1 -1
- package/dist/tools/generate-image.d.ts +23 -0
- package/dist/tools/generate-image.d.ts.map +1 -0
- package/dist/tools/generate-image.js +65 -0
- package/dist/tools/generate-image.js.map +1 -0
- package/dist/tools/host-fn-tool.d.ts +21 -0
- package/dist/tools/host-fn-tool.d.ts.map +1 -0
- package/dist/tools/host-fn-tool.js +32 -0
- package/dist/tools/host-fn-tool.js.map +1 -0
- package/dist/tools/index.d.ts +19 -3
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +24 -2
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/react.d.ts +15 -0
- package/dist/tools/react.d.ts.map +1 -0
- package/dist/tools/react.js +29 -0
- package/dist/tools/react.js.map +1 -0
- package/dist/tools/read.d.ts +1 -0
- package/dist/tools/read.d.ts.map +1 -1
- package/dist/tools/read.js +39 -33
- package/dist/tools/read.js.map +1 -1
- package/dist/tools/sandbox.d.ts +3 -3
- package/dist/tools/sandbox.d.ts.map +1 -1
- package/dist/tools/sandbox.js +12 -8
- package/dist/tools/sandbox.js.map +1 -1
- package/dist/tools/subagent.d.ts +61 -0
- package/dist/tools/subagent.d.ts.map +1 -0
- package/dist/tools/subagent.js +434 -0
- package/dist/tools/subagent.js.map +1 -0
- package/dist/tools/types.d.ts +40 -32
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js.map +1 -1
- package/dist/tools/write.d.ts.map +1 -1
- package/dist/tools/write.js +2 -8
- package/dist/tools/write.js.map +1 -1
- package/dist/trigger.d.ts +2 -1
- package/dist/trigger.d.ts.map +1 -1
- package/dist/trigger.js +6 -9
- package/dist/trigger.js.map +1 -1
- package/dist/types.d.ts +367 -67
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -2
- package/dist/types.js.map +1 -1
- package/dist/utils/file-guards.d.ts +9 -0
- package/dist/utils/file-guards.d.ts.map +1 -1
- package/dist/utils/file-guards.js +44 -1
- package/dist/utils/file-guards.js.map +1 -1
- package/dist/vault/index.d.ts +52 -2
- package/dist/vault/index.d.ts.map +1 -1
- package/dist/vault/index.js +154 -39
- package/dist/vault/index.js.map +1 -1
- package/dist/vault/types.d.ts +6 -2
- package/dist/vault/types.d.ts.map +1 -1
- package/dist/vault/types.js.map +1 -1
- package/dist/web/admin/portal.d.ts +42 -3
- package/dist/web/admin/portal.d.ts.map +1 -1
- package/dist/web/admin/portal.js +1339 -523
- package/dist/web/admin/portal.js.map +1 -1
- package/dist/web/admin/provider-models.js +1 -1
- package/dist/web/admin/provider-models.js.map +1 -1
- package/dist/web/admin/types.d.ts +25 -5
- package/dist/web/admin/types.d.ts.map +1 -1
- package/dist/web/admin/types.js.map +1 -1
- package/dist/web/login/oauth.d.ts +2 -3
- package/dist/web/login/oauth.d.ts.map +1 -1
- package/dist/web/login/oauth.js +1 -32
- package/dist/web/login/oauth.js.map +1 -1
- package/dist/web/login/portal.d.ts +8 -2
- package/dist/web/login/portal.d.ts.map +1 -1
- package/dist/web/login/portal.js +156 -114
- package/dist/web/login/portal.js.map +1 -1
- package/dist/web/login/types.d.ts +0 -11
- package/dist/web/login/types.d.ts.map +1 -1
- package/dist/web/login/types.js.map +1 -1
- package/dist/web/portal-shell.d.ts +22 -0
- package/dist/web/portal-shell.d.ts.map +1 -0
- package/dist/{portal-shell.js → web/portal-shell.js} +78 -2
- package/dist/web/portal-shell.js.map +1 -0
- package/dist/web/server.d.ts +8 -5
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js +16 -4
- package/dist/web/server.js.map +1 -1
- package/dist/web/session-view/portal.d.ts +9 -2
- package/dist/web/session-view/portal.d.ts.map +1 -1
- package/dist/web/session-view/portal.js +630 -160
- package/dist/web/session-view/portal.js.map +1 -1
- package/dist/web/session-view/types.d.ts +8 -3
- package/dist/web/session-view/types.d.ts.map +1 -1
- package/dist/web/session-view/types.js.map +1 -1
- package/dist/web/token-store.js +1 -1
- package/dist/web/token-store.js.map +1 -1
- package/dist/workspace-projection/index.d.ts +22 -0
- package/dist/workspace-projection/index.d.ts.map +1 -0
- package/dist/workspace-projection/index.js +208 -0
- package/dist/workspace-projection/index.js.map +1 -0
- package/dist/workspace-projection/types.d.ts +29 -0
- package/dist/workspace-projection/types.d.ts.map +1 -0
- package/dist/workspace-projection/types.js +2 -0
- package/dist/workspace-projection/types.js.map +1 -0
- package/package.json +68 -38
- package/dist/adapters/streaming.d.ts +0 -18
- package/dist/adapters/streaming.d.ts.map +0 -1
- package/dist/adapters/streaming.js +0 -44
- package/dist/adapters/streaming.js.map +0 -1
- package/dist/adapters/telegram/html.d.ts +0 -3
- package/dist/adapters/telegram/html.d.ts.map +0 -1
- package/dist/adapters/telegram/html.js +0 -98
- package/dist/adapters/telegram/html.js.map +0 -1
- package/dist/agent.d.ts +0 -39
- package/dist/agent.d.ts.map +0 -1
- package/dist/agent.js +0 -1277
- package/dist/agent.js.map +0 -1
- package/dist/commands/extensions.d.ts +0 -14
- package/dist/commands/extensions.d.ts.map +0 -1
- package/dist/commands/extensions.js +0 -55
- package/dist/commands/extensions.js.map +0 -1
- package/dist/commands/parse.d.ts +0 -7
- package/dist/commands/parse.d.ts.map +0 -1
- package/dist/commands/parse.js +0 -14
- package/dist/commands/parse.js.map +0 -1
- package/dist/download.d.ts.map +0 -1
- package/dist/download.js.map +0 -1
- package/dist/harness/auth.d.ts +0 -16
- package/dist/harness/auth.d.ts.map +0 -1
- package/dist/harness/auth.js +0 -86
- package/dist/harness/auth.js.map +0 -1
- package/dist/harness/extensions/loader.d.ts +0 -62
- package/dist/harness/extensions/loader.d.ts.map +0 -1
- package/dist/harness/extensions/loader.js +0 -368
- package/dist/harness/extensions/loader.js.map +0 -1
- package/dist/harness/extensions/registry.d.ts +0 -23
- package/dist/harness/extensions/registry.d.ts.map +0 -1
- package/dist/harness/extensions/registry.js +0 -45
- package/dist/harness/extensions/registry.js.map +0 -1
- package/dist/harness/extensions/types.d.ts +0 -239
- package/dist/harness/extensions/types.d.ts.map +0 -1
- package/dist/harness/extensions/types.js.map +0 -1
- package/dist/model-registry.d.ts +0 -4
- package/dist/model-registry.d.ts.map +0 -1
- package/dist/model-registry.js +0 -7
- package/dist/model-registry.js.map +0 -1
- package/dist/portal-shell.d.ts +0 -4
- package/dist/portal-shell.d.ts.map +0 -1
- package/dist/portal-shell.js.map +0 -1
- package/dist/runtime/agent-run-controller.d.ts +0 -31
- package/dist/runtime/agent-run-controller.d.ts.map +0 -1
- package/dist/runtime/agent-run-controller.js +0 -195
- package/dist/runtime/agent-run-controller.js.map +0 -1
- package/dist/sandbox/errors.d.ts +0 -6
- package/dist/sandbox/errors.d.ts.map +0 -1
- package/dist/sandbox/errors.js +0 -11
- package/dist/sandbox/errors.js.map +0 -1
- package/dist/sandbox/firecracker.d.ts +0 -15
- package/dist/sandbox/firecracker.d.ts.map +0 -1
- package/dist/sandbox/firecracker.js +0 -212
- package/dist/sandbox/firecracker.js.map +0 -1
- package/dist/sandbox/image.d.ts +0 -3
- package/dist/sandbox/image.d.ts.map +0 -1
- package/dist/sandbox/image.js +0 -27
- package/dist/sandbox/image.js.map +0 -1
- package/dist/sandbox/path-context.d.ts +0 -3
- package/dist/sandbox/path-context.d.ts.map +0 -1
- package/dist/sandbox/path-context.js +0 -20
- package/dist/sandbox/path-context.js.map +0 -1
- package/dist/sessions/agent-memory-file-manager.d.ts +0 -19
- package/dist/sessions/agent-memory-file-manager.d.ts.map +0 -1
- package/dist/sessions/agent-memory-file-manager.js.map +0 -1
- package/dist/sessions/metadata.d.ts +0 -3
- package/dist/sessions/metadata.d.ts.map +0 -1
- package/dist/sessions/metadata.js +0 -11
- package/dist/sessions/metadata.js.map +0 -1
- package/dist/sessions/policy.d.ts +0 -6
- package/dist/sessions/policy.d.ts.map +0 -1
- package/dist/sessions/policy.js +0 -23
- package/dist/sessions/policy.js.map +0 -1
- package/dist/store.d.ts +0 -46
- package/dist/store.d.ts.map +0 -1
- package/dist/store.js +0 -177
- package/dist/store.js.map +0 -1
- package/dist/tools/truncate.d.ts +0 -33
- package/dist/tools/truncate.d.ts.map +0 -1
- package/dist/tools/truncate.js +0 -184
- package/dist/tools/truncate.js.map +0 -1
- package/dist/utils/date.d.ts +0 -10
- package/dist/utils/date.d.ts.map +0 -1
- package/dist/utils/date.js +0 -23
- package/dist/utils/date.js.map +0 -1
- package/dist/utils/env.d.ts +0 -3
- package/dist/utils/env.d.ts.map +0 -1
- package/dist/utils/env.js +0 -12
- package/dist/utils/env.js.map +0 -1
- package/dist/utils/fs-atomic.d.ts +0 -10
- package/dist/utils/fs-atomic.d.ts.map +0 -1
- package/dist/utils/fs-atomic.js +0 -45
- package/dist/utils/fs-atomic.js.map +0 -1
- package/dist/utils/html.d.ts +0 -2
- package/dist/utils/html.d.ts.map +0 -1
- package/dist/utils/html.js +0 -4
- package/dist/utils/html.js.map +0 -1
- package/dist/utils/http-body.d.ts +0 -10
- package/dist/utils/http-body.d.ts.map +0 -1
- package/dist/utils/http-body.js +0 -34
- package/dist/utils/http-body.js.map +0 -1
- package/dist/vault/routing.d.ts +0 -3
- package/dist/vault/routing.d.ts.map +0 -1
- package/dist/vault/routing.js +0 -13
- package/dist/vault/routing.js.map +0 -1
- package/dist/web/admin/store.d.ts +0 -13
- package/dist/web/admin/store.d.ts.map +0 -1
- package/dist/web/admin/store.js +0 -14
- package/dist/web/admin/store.js.map +0 -1
- package/dist/web/agent-events/portal.d.ts +0 -3
- package/dist/web/agent-events/portal.d.ts.map +0 -1
- package/dist/web/agent-events/portal.js +0 -18
- package/dist/web/agent-events/portal.js.map +0 -1
- package/dist/web/login/store.d.ts +0 -8
- package/dist/web/login/store.d.ts.map +0 -1
- package/dist/web/login/store.js +0 -15
- package/dist/web/login/store.js.map +0 -1
- package/dist/web/request.d.ts +0 -3
- package/dist/web/request.d.ts.map +0 -1
- package/dist/web/request.js +0 -13
- package/dist/web/request.js.map +0 -1
- package/dist/web/session-view/command.d.ts +0 -4
- package/dist/web/session-view/command.d.ts.map +0 -1
- package/dist/web/session-view/command.js +0 -7
- package/dist/web/session-view/command.js.map +0 -1
- package/dist/web/session-view/service.d.ts +0 -6
- package/dist/web/session-view/service.d.ts.map +0 -1
- package/dist/web/session-view/service.js +0 -498
- package/dist/web/session-view/service.js.map +0 -1
- package/dist/web/session-view/store.d.ts +0 -8
- package/dist/web/session-view/store.d.ts.map +0 -1
- package/dist/web/session-view/store.js +0 -15
- package/dist/web/session-view/store.js.map +0 -1
- /package/dist/{harness/extensions → adapters/github}/types.js +0 -0
- /package/dist/{download.d.ts → cli/download.d.ts} +0 -0
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { ApplicationCommandOptionType, Client, Events, GatewayIntentBits, Partials, } from "discord.js";
|
|
2
|
-
import { readFileSync } from "fs";
|
|
3
|
-
import { basename
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { basename } from "node:path";
|
|
4
|
+
import { discordTextPayload } from "./components.js";
|
|
5
|
+
import { createConversationEvent, createConversationMessage, } from "../../adapter.js";
|
|
4
6
|
import * as log from "../../log.js";
|
|
5
|
-
import {
|
|
7
|
+
import { createOfficeAddress } from "../../office/index.js";
|
|
8
|
+
import { resolveChatSessionKey } from "../../sessions/session-key.js";
|
|
6
9
|
import { formatNothingRunning } from "../../platform-messages.js";
|
|
7
|
-
import { appendBotResponseLog, appendChannelLog, MessagingEventQueue, downloadUrlToFile, resolveOnlyScopedStopTarget, resolveStopTarget, withRetry, } from "../shared.js";
|
|
10
|
+
import { appendBotResponseLog, appendChannelLog, MessagingEventQueue, MessagingIntakeTracker, downloadUrlToFile, resolveOnlyScopedStopTarget, resolveStopTarget, saveIncomingAttachments, withRetry, } from "../shared.js";
|
|
11
|
+
import { COMMAND_MANIFEST } from "../../commands/manifest.js";
|
|
8
12
|
import { processMessageIntake } from "../intake.js";
|
|
9
13
|
import { createDiscordAdapters } from "./context.js";
|
|
10
14
|
// discord.js: DiscordAPIError exposes `.status` (HTTP status) and a `.code`.
|
|
@@ -25,13 +29,15 @@ const discordRetry = (fn) => withRetry(fn, { isRateLimited: discordIsRateLimited
|
|
|
25
29
|
export class DiscordMessagingBot {
|
|
26
30
|
constructor(handler, config) {
|
|
27
31
|
this.botUserId = null;
|
|
32
|
+
this.stopped = false;
|
|
28
33
|
this.queues = new Map();
|
|
34
|
+
this.intake = new MessagingIntakeTracker("Discord");
|
|
29
35
|
this.startupTime = 0;
|
|
30
36
|
this.channels = new Map();
|
|
31
37
|
this.users = new Map();
|
|
32
38
|
this.handler = handler;
|
|
33
39
|
this.token = config.token;
|
|
34
|
-
this.
|
|
40
|
+
this.workspace = config.workspace;
|
|
35
41
|
this.client = new Client({
|
|
36
42
|
intents: [
|
|
37
43
|
GatewayIntentBits.Guilds,
|
|
@@ -46,8 +52,13 @@ export class DiscordMessagingBot {
|
|
|
46
52
|
// Public API (implements MessagingBot)
|
|
47
53
|
// ==========================================================================
|
|
48
54
|
async start() {
|
|
55
|
+
this.stopped = false;
|
|
49
56
|
await new Promise((resolve, reject) => {
|
|
50
57
|
this.client.once(Events.ClientReady, async (readyClient) => {
|
|
58
|
+
if (this.stopped) {
|
|
59
|
+
resolve();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
51
62
|
this.botUserId = readyClient.user.id;
|
|
52
63
|
this.startupTime = Date.now();
|
|
53
64
|
log.logConnected("Discord");
|
|
@@ -55,48 +66,23 @@ export class DiscordMessagingBot {
|
|
|
55
66
|
this.loadCachedGuildData();
|
|
56
67
|
this.setupEventHandlers();
|
|
57
68
|
try {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
description: "Open the current session in the web viewer",
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
name: "new",
|
|
69
|
-
description: "Reset conversation history and start fresh",
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: "stop",
|
|
73
|
-
description: "Stop the current conversation",
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
name: "model",
|
|
77
|
-
description: "Switch this conversation's LLM model",
|
|
78
|
-
options: [
|
|
79
|
-
{
|
|
80
|
-
name: "model",
|
|
81
|
-
description: "provider/model[:thinking], e.g. anthropic/claude-sonnet-4-6:off",
|
|
82
|
-
type: ApplicationCommandOptionType.String,
|
|
83
|
-
required: false,
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
name: "sandbox",
|
|
89
|
-
description: "Show or temporarily boost this conversation's sandbox limits",
|
|
69
|
+
// Registration derives from the command manifest; routing below
|
|
70
|
+
// handles new/stop natively and the rest through one generic path.
|
|
71
|
+
await readyClient.application.commands.set(COMMAND_MANIFEST.filter((entry) => entry.discord).map((entry) => Object.assign({
|
|
72
|
+
name: entry.name,
|
|
73
|
+
description: entry.description,
|
|
74
|
+
}, entry.arg
|
|
75
|
+
? {
|
|
90
76
|
options: [
|
|
91
77
|
{
|
|
92
|
-
name:
|
|
93
|
-
description:
|
|
78
|
+
name: entry.arg.name,
|
|
79
|
+
description: entry.arg.description,
|
|
94
80
|
type: ApplicationCommandOptionType.String,
|
|
95
|
-
required:
|
|
81
|
+
required: entry.arg.required,
|
|
96
82
|
},
|
|
97
83
|
],
|
|
98
|
-
}
|
|
99
|
-
|
|
84
|
+
}
|
|
85
|
+
: {})));
|
|
100
86
|
}
|
|
101
87
|
catch (err) {
|
|
102
88
|
log.logWarning("Failed to register Discord slash commands", err instanceof Error ? err.message : String(err));
|
|
@@ -107,17 +93,38 @@ export class DiscordMessagingBot {
|
|
|
107
93
|
this.client.login(this.token).catch(reject);
|
|
108
94
|
});
|
|
109
95
|
}
|
|
96
|
+
async stop() {
|
|
97
|
+
this.stopped = true;
|
|
98
|
+
try {
|
|
99
|
+
this.client.destroy();
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
await this.intake.close();
|
|
103
|
+
await Promise.all([...this.queues.values()].map((queue) => queue.close()));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
110
106
|
async postMessage(channel, text) {
|
|
111
107
|
return discordRetry(async () => {
|
|
112
108
|
const ch = await this.fetchTextChannel(channel);
|
|
113
|
-
const msg = await ch.send(text);
|
|
109
|
+
const msg = await ch.send(discordTextPayload(text));
|
|
114
110
|
return msg.id;
|
|
115
111
|
});
|
|
116
112
|
}
|
|
117
113
|
async updateMessage(channel, ts, text) {
|
|
118
114
|
await this.updateMessageRaw(channel, ts, text);
|
|
119
115
|
}
|
|
116
|
+
async addReaction(channel, messageTs, emoji) {
|
|
117
|
+
// Discord uses Unicode emoji directly (e.g. "👀"); accept a bare name too
|
|
118
|
+
// but Slack-style short names won't resolve, so pass through as-is.
|
|
119
|
+
await discordRetry(async () => {
|
|
120
|
+
const ch = await this.fetchTextChannel(channel);
|
|
121
|
+
const msg = await ch.messages.fetch(messageTs);
|
|
122
|
+
await msg.react(emoji.replace(/^:|:$/g, ""));
|
|
123
|
+
});
|
|
124
|
+
}
|
|
120
125
|
enqueueEvent(event) {
|
|
126
|
+
if (this.stopped)
|
|
127
|
+
return false;
|
|
121
128
|
const conversationId = event.conversationId;
|
|
122
129
|
const queue = this.getQueue(conversationId);
|
|
123
130
|
if (queue.size() >= 5) {
|
|
@@ -125,16 +132,16 @@ export class DiscordMessagingBot {
|
|
|
125
132
|
return false;
|
|
126
133
|
}
|
|
127
134
|
log.logInfo(`Enqueueing event for ${conversationId}: ${event.text.substring(0, 50)}`);
|
|
128
|
-
queue.enqueue(() => {
|
|
135
|
+
return queue.enqueue(() => {
|
|
129
136
|
const context = createDiscordAdapters(event, this);
|
|
130
137
|
return this.handler.handleEvent(event, this, context);
|
|
131
138
|
});
|
|
132
|
-
return true;
|
|
133
139
|
}
|
|
134
140
|
getMessagingInfo() {
|
|
135
141
|
return {
|
|
136
142
|
name: "discord",
|
|
137
|
-
|
|
143
|
+
trustModel: "membership",
|
|
144
|
+
formattingGuide: "## Discord Formatting (Markdown)\nBold: **text**, Italic: *text*, Code: `code`, Block: ```language\ncode```\nLinks: [text](url), Spoiler: ||text||, Headings: # ## ###\nWrite ordinary Markdown, including tables — the adapter converts anything Discord cannot render. Use code blocks for code.",
|
|
138
145
|
channels: this.getAllChannels(),
|
|
139
146
|
users: this.getAllUsers(),
|
|
140
147
|
diagnostics: {
|
|
@@ -149,14 +156,14 @@ export class DiscordMessagingBot {
|
|
|
149
156
|
return discordRetry(async () => {
|
|
150
157
|
const ch = await this.fetchTextChannel(channelId);
|
|
151
158
|
const msg = await ch.messages.fetch(messageId);
|
|
152
|
-
await msg.edit(text);
|
|
159
|
+
await msg.edit(discordTextPayload(text));
|
|
153
160
|
});
|
|
154
161
|
}
|
|
155
162
|
async postReply(channelId, replyToId, text) {
|
|
156
163
|
return discordRetry(async () => {
|
|
157
164
|
const ch = await this.fetchTextChannel(channelId);
|
|
158
165
|
const replyTarget = await ch.messages.fetch(replyToId);
|
|
159
|
-
const sent = await replyTarget.reply(text);
|
|
166
|
+
const sent = await replyTarget.reply(discordTextPayload(text));
|
|
160
167
|
return sent.id;
|
|
161
168
|
});
|
|
162
169
|
}
|
|
@@ -166,7 +173,7 @@ export class DiscordMessagingBot {
|
|
|
166
173
|
const thread = await this.client.channels.fetch(threadOrMessageId);
|
|
167
174
|
if (thread && (thread.isThread() || thread.isTextBased())) {
|
|
168
175
|
return discordRetry(async () => {
|
|
169
|
-
const msg = await thread.send(text);
|
|
176
|
+
const msg = await thread.send(discordTextPayload(text));
|
|
170
177
|
return msg.id;
|
|
171
178
|
});
|
|
172
179
|
}
|
|
@@ -206,7 +213,7 @@ export class DiscordMessagingBot {
|
|
|
206
213
|
async sendDirectMessage(userId, text) {
|
|
207
214
|
return discordRetry(async () => {
|
|
208
215
|
const user = await this.client.users.fetch(userId);
|
|
209
|
-
const msg = await user.send(text);
|
|
216
|
+
const msg = await user.send(discordTextPayload(text));
|
|
210
217
|
return msg.id;
|
|
211
218
|
});
|
|
212
219
|
}
|
|
@@ -220,54 +227,33 @@ export class DiscordMessagingBot {
|
|
|
220
227
|
return Array.from(this.users.values());
|
|
221
228
|
}
|
|
222
229
|
logToFile(channelId, entry) {
|
|
223
|
-
appendChannelLog(this.
|
|
230
|
+
appendChannelLog(this.workspace.office(createOfficeAddress("discord", channelId)), entry);
|
|
224
231
|
}
|
|
225
232
|
logBotResponse(channelId, text, ts) {
|
|
226
|
-
appendBotResponseLog(this.
|
|
233
|
+
appendBotResponseLog(this.workspace.office(createOfficeAddress("discord", channelId)), text, ts);
|
|
227
234
|
}
|
|
228
235
|
/**
|
|
229
236
|
* Process attachments from a Discord message.
|
|
230
237
|
* Downloads files before returning so the agent can read them immediately.
|
|
231
238
|
*/
|
|
232
|
-
async processAttachments(channelId, attachments
|
|
233
|
-
const
|
|
234
|
-
// Discord attachments Collection - iterate over values
|
|
239
|
+
async processAttachments(channelId, attachments) {
|
|
240
|
+
const items = [];
|
|
235
241
|
for (const attachment of attachments.values()) {
|
|
236
242
|
if (!attachment.name) {
|
|
237
243
|
log.logWarning("Discord attachment missing name, skipping", attachment.url);
|
|
238
244
|
continue;
|
|
239
245
|
}
|
|
240
|
-
|
|
241
|
-
const sanitizedName = attachment.name.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
242
|
-
const filename = `${ts}_${sanitizedName}`;
|
|
243
|
-
const localPath = `${channelId}/attachments/${filename}`;
|
|
244
|
-
const fullDir = join(this.workingDir, channelId, "attachments");
|
|
245
|
-
const result = {
|
|
246
|
+
items.push({
|
|
246
247
|
name: attachment.name,
|
|
247
|
-
|
|
248
|
-
};
|
|
249
|
-
downloads.push(this.downloadAttachment(fullDir, filename, attachment.url)
|
|
250
|
-
.then(() => result)
|
|
251
|
-
.catch((err) => {
|
|
252
|
-
log.logWarning(`Failed to download Discord attachment`, `${filename}: ${err}`);
|
|
253
|
-
return null;
|
|
254
|
-
}));
|
|
255
|
-
}
|
|
256
|
-
const results = await Promise.all(downloads);
|
|
257
|
-
return results.filter((attachment) => attachment !== null);
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Download an attachment from URL to local file
|
|
261
|
-
*/
|
|
262
|
-
async downloadAttachment(dir, filename, url) {
|
|
263
|
-
try {
|
|
264
|
-
await downloadUrlToFile(url, join(dir, filename));
|
|
265
|
-
}
|
|
266
|
-
catch (err) {
|
|
267
|
-
throw new Error(`Download failed: ${err instanceof Error ? err.message : String(err)}`, {
|
|
268
|
-
cause: err,
|
|
248
|
+
download: (destPath) => downloadUrlToFile(attachment.url, destPath),
|
|
269
249
|
});
|
|
270
250
|
}
|
|
251
|
+
const office = this.workspace.office(createOfficeAddress("discord", channelId));
|
|
252
|
+
const { saved, failed } = await saveIncomingAttachments(office, items);
|
|
253
|
+
for (const failure of failed) {
|
|
254
|
+
log.logWarning(`Failed to download Discord attachment`, `${failure.name}: ${failure.error}`);
|
|
255
|
+
}
|
|
256
|
+
return saved.map((item) => ({ name: item.original, localPath: item.localPath }));
|
|
271
257
|
}
|
|
272
258
|
// ==========================================================================
|
|
273
259
|
// Private - Event Handlers
|
|
@@ -281,16 +267,13 @@ export class DiscordMessagingBot {
|
|
|
281
267
|
return queue;
|
|
282
268
|
}
|
|
283
269
|
resolveStopTarget(channelId, sessionKey) {
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
conversationId: channelId,
|
|
287
|
-
sessionKey,
|
|
288
|
-
});
|
|
270
|
+
const address = createOfficeAddress("discord", channelId);
|
|
271
|
+
const directTarget = resolveStopTarget({ handler: this.handler, address, sessionKey });
|
|
289
272
|
if (directTarget)
|
|
290
273
|
return directTarget;
|
|
291
274
|
if (sessionKey !== channelId)
|
|
292
275
|
return null;
|
|
293
|
-
return resolveOnlyScopedStopTarget(this.handler,
|
|
276
|
+
return resolveOnlyScopedStopTarget(this.handler, address);
|
|
294
277
|
}
|
|
295
278
|
loadCachedGuildData() {
|
|
296
279
|
for (const guild of this.client.guilds.cache.values()) {
|
|
@@ -337,7 +320,9 @@ export class DiscordMessagingBot {
|
|
|
337
320
|
const userName = interaction.user.username;
|
|
338
321
|
const platform = this.getMessagingInfo();
|
|
339
322
|
const shouldUseEphemeral = !isDM;
|
|
340
|
-
const message = {
|
|
323
|
+
const message = createConversationMessage({
|
|
324
|
+
platform: "discord",
|
|
325
|
+
conversationId,
|
|
341
326
|
id: interaction.id,
|
|
342
327
|
sessionKey,
|
|
343
328
|
conversationKind: isDM ? "direct" : "shared",
|
|
@@ -345,7 +330,7 @@ export class DiscordMessagingBot {
|
|
|
345
330
|
userName,
|
|
346
331
|
text: commandText,
|
|
347
332
|
attachments: [],
|
|
348
|
-
};
|
|
333
|
+
});
|
|
349
334
|
const respondPrivately = async (text, replace = false) => {
|
|
350
335
|
if (interaction.replied || interaction.deferred) {
|
|
351
336
|
if (replace) {
|
|
@@ -374,189 +359,180 @@ export class DiscordMessagingBot {
|
|
|
374
359
|
await respondPrivately(formatted);
|
|
375
360
|
},
|
|
376
361
|
setTyping: async () => { },
|
|
377
|
-
setWorking: async () => {
|
|
362
|
+
setWorking: async (working) => {
|
|
363
|
+
if (working && !interaction.replied && !interaction.deferred) {
|
|
364
|
+
await interaction.deferReply({ ephemeral: shouldUseEphemeral });
|
|
365
|
+
}
|
|
366
|
+
},
|
|
378
367
|
uploadFile: async (filePath, title) => {
|
|
379
368
|
await this.uploadFile(conversationId, filePath, title);
|
|
380
369
|
},
|
|
381
370
|
deleteResponse: async () => { },
|
|
382
371
|
};
|
|
383
|
-
return { message, responder, platform };
|
|
372
|
+
return { address: message.address, message, responder, platform };
|
|
384
373
|
}
|
|
385
374
|
setupEventHandlers() {
|
|
386
|
-
this.client.on(Events.InteractionCreate,
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
375
|
+
this.client.on(Events.InteractionCreate, (interaction) => {
|
|
376
|
+
void this.intake.run(() => this.handleInteractionCreate(interaction));
|
|
377
|
+
});
|
|
378
|
+
this.client.on(Events.MessageCreate, (message) => {
|
|
379
|
+
void this.intake.run(() => this.handleMessageCreate(message));
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
async handleInteractionCreate(interaction) {
|
|
383
|
+
if (!interaction.isChatInputCommand())
|
|
384
|
+
return;
|
|
385
|
+
const manifestEntry = COMMAND_MANIFEST.find((entry) => entry.discord && entry.name === interaction.commandName);
|
|
386
|
+
if (!manifestEntry)
|
|
387
|
+
return;
|
|
388
|
+
const isDM = !interaction.inGuild();
|
|
389
|
+
const { conversationId, threadTs } = this.resolveConversationContext({
|
|
390
|
+
channelId: interaction.channelId,
|
|
391
|
+
inGuild: interaction.inGuild(),
|
|
392
|
+
isThread: interaction.channel?.isThread() ?? false,
|
|
393
|
+
parentChannelId: interaction.channel && "parentId" in interaction.channel
|
|
394
|
+
? interaction.channel.parentId
|
|
395
|
+
: null,
|
|
396
|
+
});
|
|
397
|
+
const sessionKey = resolveChatSessionKey({
|
|
398
|
+
conversationId,
|
|
399
|
+
conversationKind: isDM ? "direct" : "shared",
|
|
400
|
+
messageId: interaction.id,
|
|
401
|
+
persistentTopLevel: true,
|
|
402
|
+
threadTs,
|
|
403
|
+
});
|
|
404
|
+
const commandArg = manifestEntry.arg
|
|
405
|
+
? interaction.options.getString(manifestEntry.arg.name)?.trim()
|
|
406
|
+
: undefined;
|
|
407
|
+
const commandText = commandArg
|
|
408
|
+
? `/${interaction.commandName} ${commandArg}`
|
|
409
|
+
: `/${interaction.commandName}`;
|
|
410
|
+
this.logToFile(conversationId, {
|
|
411
|
+
date: new Date(interaction.createdTimestamp).toISOString(),
|
|
412
|
+
ts: interaction.id,
|
|
413
|
+
...(threadTs ? { threadTs } : {}),
|
|
414
|
+
user: interaction.user.id,
|
|
415
|
+
userName: interaction.user.username,
|
|
416
|
+
text: commandText,
|
|
417
|
+
attachments: [],
|
|
418
|
+
isMessagingBot: false,
|
|
419
|
+
});
|
|
420
|
+
const context = this.createSlashCommandAdapters(interaction, commandText, sessionKey, conversationId);
|
|
421
|
+
try {
|
|
422
|
+
// Magic words are conversation-intake controls, not command handlers;
|
|
423
|
+
// the manifest's metadata routes them (today only `stop`).
|
|
424
|
+
if (manifestEntry.magicWord) {
|
|
425
|
+
const stopTarget = this.resolveStopTarget(conversationId, sessionKey);
|
|
426
|
+
if (stopTarget) {
|
|
427
|
+
await this.handler.handleStop(createOfficeAddress("discord", conversationId), stopTarget, this);
|
|
428
|
+
await context.responder.respond("Stopped the current conversation.");
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
await context.responder.respond(formatNothingRunning("discord"));
|
|
432
|
+
}
|
|
395
433
|
return;
|
|
396
434
|
}
|
|
397
|
-
const
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
inGuild: interaction.inGuild(),
|
|
401
|
-
isThread: interaction.channel?.isThread() ?? false,
|
|
402
|
-
parentChannelId: interaction.channel && "parentId" in interaction.channel
|
|
403
|
-
? interaction.channel.parentId
|
|
404
|
-
: null,
|
|
405
|
-
});
|
|
406
|
-
const sessionKey = resolveChatSessionKey({
|
|
435
|
+
const event = createConversationEvent({
|
|
436
|
+
platform: "discord",
|
|
437
|
+
type: "dm",
|
|
407
438
|
conversationId,
|
|
408
439
|
conversationKind: isDM ? "direct" : "shared",
|
|
409
|
-
messageId: interaction.id,
|
|
410
|
-
persistentTopLevel: true,
|
|
411
|
-
threadTs,
|
|
412
|
-
});
|
|
413
|
-
const modelOption = interaction.commandName === "model"
|
|
414
|
-
? interaction.options.getString("model")?.trim()
|
|
415
|
-
: undefined;
|
|
416
|
-
const sandboxAction = interaction.commandName === "sandbox"
|
|
417
|
-
? interaction.options.getString("action")?.trim()
|
|
418
|
-
: undefined;
|
|
419
|
-
const commandArg = modelOption ?? sandboxAction;
|
|
420
|
-
const commandText = commandArg
|
|
421
|
-
? `/${interaction.commandName} ${commandArg}`
|
|
422
|
-
: `/${interaction.commandName}`;
|
|
423
|
-
this.logToFile(conversationId, {
|
|
424
|
-
date: new Date(interaction.createdTimestamp).toISOString(),
|
|
425
440
|
ts: interaction.id,
|
|
426
|
-
|
|
441
|
+
thread_ts: threadTs,
|
|
442
|
+
sessionKey,
|
|
427
443
|
user: interaction.user.id,
|
|
428
|
-
userName: interaction.user.username,
|
|
429
444
|
text: commandText,
|
|
430
445
|
attachments: [],
|
|
431
|
-
isMessagingBot: false,
|
|
432
446
|
});
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
if (stopTarget) {
|
|
443
|
-
await this.handler.handleStop(stopTarget, conversationId, this);
|
|
444
|
-
await context.responder.respond("Stopped the current conversation.");
|
|
445
|
-
}
|
|
446
|
-
else {
|
|
447
|
-
await context.responder.respond(formatNothingRunning("discord"));
|
|
448
|
-
}
|
|
449
|
-
return;
|
|
450
|
-
}
|
|
451
|
-
const event = {
|
|
452
|
-
type: "dm",
|
|
453
|
-
conversationId,
|
|
454
|
-
conversationKind: isDM ? "direct" : "shared",
|
|
455
|
-
ts: interaction.id,
|
|
456
|
-
thread_ts: threadTs,
|
|
457
|
-
sessionKey,
|
|
458
|
-
user: interaction.user.id,
|
|
459
|
-
text: commandText,
|
|
460
|
-
attachments: [],
|
|
461
|
-
};
|
|
462
|
-
await this.handler.handleEvent(event, this, context);
|
|
463
|
-
}
|
|
464
|
-
catch (err) {
|
|
465
|
-
log.logWarning("Discord slash command error", err instanceof Error ? err.message : String(err));
|
|
466
|
-
if (!interaction.replied && !interaction.deferred) {
|
|
467
|
-
await interaction.reply({
|
|
468
|
-
content: `${interaction.commandName} command failed. Please try again later.`,
|
|
469
|
-
ephemeral: !isDM,
|
|
470
|
-
});
|
|
471
|
-
}
|
|
447
|
+
await this.handler.handleEvent(event, this, context);
|
|
448
|
+
}
|
|
449
|
+
catch (err) {
|
|
450
|
+
log.logWarning("Discord slash command error", err instanceof Error ? err.message : String(err));
|
|
451
|
+
if (!interaction.replied && !interaction.deferred) {
|
|
452
|
+
await interaction.reply({
|
|
453
|
+
content: `${interaction.commandName} command failed. Please try again later.`,
|
|
454
|
+
ephemeral: !isDM,
|
|
455
|
+
});
|
|
472
456
|
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
async handleMessageCreate(msg) {
|
|
460
|
+
// Skip messages from before startup
|
|
461
|
+
if (msg.createdTimestamp < this.startupTime)
|
|
462
|
+
return;
|
|
463
|
+
// Skip bot messages
|
|
464
|
+
if (msg.author.bot)
|
|
465
|
+
return;
|
|
466
|
+
const isDM = msg.channel.type === 1; // ChannelType.DM = 1
|
|
467
|
+
const isInThread = msg.channel.isThread();
|
|
468
|
+
const referencedMsgId = msg.reference?.messageId;
|
|
469
|
+
const isThreadReply = isInThread || !!referencedMsgId;
|
|
470
|
+
const isMentioned = msg.mentions.users.has(this.botUserId ?? "");
|
|
471
|
+
const isAutoReplyCandidate = !isDM && !isMentioned && !isThreadReply;
|
|
472
|
+
const { conversationId, threadTs } = this.resolveConversationContext({
|
|
473
|
+
channelId: msg.channelId,
|
|
474
|
+
inGuild: !isDM,
|
|
475
|
+
isThread: isInThread,
|
|
476
|
+
parentChannelId: "parentId" in msg.channel ? msg.channel.parentId : null,
|
|
477
|
+
referencedMsgId,
|
|
473
478
|
});
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
const eventBase = {
|
|
518
|
-
type: isDM ? "dm" : "mention",
|
|
519
|
-
conversationId,
|
|
520
|
-
conversationKind,
|
|
479
|
+
const userId = msg.author.id;
|
|
480
|
+
const userName = msg.author.username;
|
|
481
|
+
const msgId = msg.id;
|
|
482
|
+
// Track user
|
|
483
|
+
this.users.set(userId, {
|
|
484
|
+
id: userId,
|
|
485
|
+
userName,
|
|
486
|
+
displayName: msg.member?.displayName ?? userName,
|
|
487
|
+
});
|
|
488
|
+
// Track channel
|
|
489
|
+
if (!this.channels.has(conversationId) && "name" in msg.channel) {
|
|
490
|
+
const ch = msg.channel;
|
|
491
|
+
this.channels.set(conversationId, { id: conversationId, name: ch.name });
|
|
492
|
+
}
|
|
493
|
+
const conversationKind = isDM ? "direct" : "shared";
|
|
494
|
+
const sessionKey = resolveChatSessionKey({
|
|
495
|
+
conversationId,
|
|
496
|
+
conversationKind,
|
|
497
|
+
messageId: msgId,
|
|
498
|
+
persistentTopLevel: true,
|
|
499
|
+
threadTs,
|
|
500
|
+
});
|
|
501
|
+
const cleanedText = this.stripMessagingBotMention(msg.content);
|
|
502
|
+
const eventBase = createConversationEvent({
|
|
503
|
+
platform: "discord",
|
|
504
|
+
type: isDM ? "dm" : "mention",
|
|
505
|
+
conversationId,
|
|
506
|
+
conversationKind,
|
|
507
|
+
ts: msgId,
|
|
508
|
+
thread_ts: threadTs,
|
|
509
|
+
sessionKey,
|
|
510
|
+
user: userId,
|
|
511
|
+
userName,
|
|
512
|
+
text: cleanedText,
|
|
513
|
+
});
|
|
514
|
+
await processMessageIntake({
|
|
515
|
+
eventBase,
|
|
516
|
+
office: this.workspace.office(eventBase.address),
|
|
517
|
+
isAutoReplyCandidate,
|
|
518
|
+
magicWord: { addressed: !isAutoReplyCandidate, scopeFallback: "top-level" },
|
|
519
|
+
busyPolicy: "queue",
|
|
520
|
+
logEntryBase: {
|
|
521
|
+
date: msg.createdAt.toISOString(),
|
|
521
522
|
ts: msgId,
|
|
522
|
-
|
|
523
|
-
sessionKey,
|
|
523
|
+
...(!isDM && threadTs ? { threadTs } : {}),
|
|
524
524
|
user: userId,
|
|
525
525
|
userName,
|
|
526
526
|
text: cleanedText,
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
}
|
|
537
|
-
return;
|
|
538
|
-
}
|
|
539
|
-
await processMessageIntake({
|
|
540
|
-
eventBase,
|
|
541
|
-
workingDir: this.workingDir,
|
|
542
|
-
isAutoReplyCandidate,
|
|
543
|
-
logEntryBase: {
|
|
544
|
-
date: msg.createdAt.toISOString(),
|
|
545
|
-
ts: msgId,
|
|
546
|
-
...(!isDM && threadTs ? { threadTs } : {}),
|
|
547
|
-
user: userId,
|
|
548
|
-
userName,
|
|
549
|
-
text: cleanedText,
|
|
550
|
-
isMessagingBot: false,
|
|
551
|
-
},
|
|
552
|
-
log: (entry) => this.logToFile(conversationId, entry),
|
|
553
|
-
processAttachments: () => this.processAttachments(conversationId, msg.attachments, msgId),
|
|
554
|
-
queueKey: sessionKey,
|
|
555
|
-
enqueue: (queueKey, work) => this.getQueue(queueKey).enqueue(work),
|
|
556
|
-
handler: this.handler,
|
|
557
|
-
bot: this,
|
|
558
|
-
createContext: (event) => createDiscordAdapters(event, this),
|
|
559
|
-
});
|
|
527
|
+
isMessagingBot: false,
|
|
528
|
+
},
|
|
529
|
+
log: (entry) => this.logToFile(conversationId, entry),
|
|
530
|
+
processAttachments: () => this.processAttachments(conversationId, msg.attachments),
|
|
531
|
+
queueKey: sessionKey,
|
|
532
|
+
enqueue: (queueKey, work) => this.getQueue(queueKey).enqueue(work),
|
|
533
|
+
handler: this.handler,
|
|
534
|
+
bot: this,
|
|
535
|
+
createContext: (event) => createDiscordAdapters(event, this),
|
|
560
536
|
});
|
|
561
537
|
}
|
|
562
538
|
async fetchTextChannel(channelId) {
|