@poolzin/pool-bot 2026.1.39 → 2026.2.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/assets/chrome-extension/README.md +3 -3
- package/assets/chrome-extension/background.js +5 -5
- package/assets/chrome-extension/manifest.json +3 -3
- package/assets/chrome-extension/options.html +4 -4
- package/assets/chrome-extension/options.js +1 -1
- package/dist/acp/client.js +3 -3
- package/dist/acp/types.js +1 -1
- package/dist/agents/agent-paths.js +3 -3
- package/dist/agents/auth-profiles/paths.js +3 -3
- package/dist/agents/bash-tools.exec.js +76 -25
- package/dist/agents/cli-runner/helpers.js +10 -12
- package/dist/agents/cli-runner.js +2 -2
- package/dist/agents/cloudflare-ai-gateway.js +31 -0
- package/dist/agents/compaction.js +16 -2
- package/dist/agents/context-window-guard.js +13 -10
- package/dist/agents/context.js +4 -4
- package/dist/agents/docs-path.js +1 -1
- package/dist/agents/identity.js +47 -7
- package/dist/agents/memory-search.js +25 -8
- package/dist/agents/minimax-vlm.js +1 -1
- package/dist/agents/model-auth.js +12 -1
- package/dist/agents/model-catalog.js +4 -4
- package/dist/agents/model-selection.js +31 -4
- package/dist/agents/models-config.js +3 -3
- package/dist/agents/models-config.providers.js +147 -39
- package/dist/agents/pi-embedded-block-chunker.js +117 -42
- package/dist/agents/pi-embedded-helpers/errors.js +183 -78
- package/dist/agents/pi-embedded-helpers/openai.js +1 -1
- package/dist/agents/pi-embedded-helpers.js +1 -1
- package/dist/agents/pi-embedded-runner/compact.js +9 -8
- package/dist/agents/pi-embedded-runner/model.js +63 -4
- package/dist/agents/pi-embedded-runner/run/attempt.js +27 -17
- package/dist/agents/pi-embedded-runner/run.js +203 -50
- package/dist/agents/pi-embedded-runner/system-prompt.js +10 -2
- package/dist/agents/pi-embedded-runner/tool-result-truncation.js +275 -0
- package/dist/agents/pi-embedded-runner/utils.js +1 -1
- package/dist/agents/pi-embedded-subscribe.js +118 -29
- package/dist/agents/pi-model-discovery.js +10 -0
- package/dist/agents/pi-tool-definition-adapter.js +50 -9
- package/dist/agents/pi-tools.before-tool-call.js +67 -0
- package/dist/agents/pi-tools.js +20 -10
- package/dist/agents/pi-tools.read.js +2 -2
- package/dist/agents/poolbot-tools.js +15 -10
- package/dist/agents/sandbox-paths.js +31 -0
- package/dist/agents/session-file-repair.js +83 -0
- package/dist/agents/session-tool-result-guard.js +94 -15
- package/dist/agents/session-transcript-repair.js +68 -0
- package/dist/agents/shell-utils.js +51 -0
- package/dist/agents/skills/bundled-context.js +23 -0
- package/dist/agents/skills/bundled-dir.js +41 -7
- package/dist/agents/skills/frontmatter.js +1 -1
- package/dist/agents/skills/workspace.js +2 -2
- package/dist/agents/skills-install.js +60 -23
- package/dist/agents/subagent-announce.js +79 -34
- package/dist/agents/system-prompt.js +28 -4
- package/dist/agents/together-models.js +127 -0
- package/dist/agents/tool-images.js +1 -1
- package/dist/agents/tool-policy.conformance.js +14 -0
- package/dist/agents/tool-policy.js +25 -1
- package/dist/agents/tools/browser-tool.js +3 -3
- package/dist/agents/tools/cron-tool.js +166 -19
- package/dist/agents/tools/discord-actions-presence.js +78 -0
- package/dist/agents/tools/image-tool.js +2 -2
- package/dist/agents/tools/memory-tool.js +93 -5
- package/dist/agents/tools/message-tool.js +56 -2
- package/dist/agents/tools/sessions-history-tool.js +69 -1
- package/dist/agents/tools/web-search.js +211 -42
- package/dist/agents/usage.js +23 -1
- package/dist/agents/workspace-run.js +67 -0
- package/dist/agents/workspace-templates.js +44 -0
- package/dist/auto-reply/command-auth.js +121 -6
- package/dist/auto-reply/commands-registry.data.js +1 -1
- package/dist/auto-reply/envelope.js +50 -72
- package/dist/auto-reply/reply/commands-compact.js +1 -0
- package/dist/auto-reply/reply/commands-context-report.js +3 -2
- package/dist/auto-reply/reply/commands-context.js +1 -0
- package/dist/auto-reply/reply/commands-models.js +107 -60
- package/dist/auto-reply/reply/commands-ptt.js +171 -0
- package/dist/auto-reply/reply/commands-session.js +2 -2
- package/dist/auto-reply/reply/get-reply-run.js +16 -5
- package/dist/auto-reply/reply/groups.js +1 -1
- package/dist/auto-reply/reply/inbound-context.js +9 -1
- package/dist/auto-reply/reply/inbound-meta.js +130 -0
- package/dist/auto-reply/reply/model-selection.js +3 -3
- package/dist/auto-reply/reply/untrusted-context.js +15 -0
- package/dist/auto-reply/status.js +1 -1
- package/dist/auto-reply/thinking.js +88 -43
- package/dist/browser/bridge-server.js +13 -0
- package/dist/browser/cdp.helpers.js +38 -24
- package/dist/browser/client-fetch.js +51 -8
- package/dist/browser/config.js +2 -11
- package/dist/browser/extension-relay.js +104 -43
- package/dist/browser/pw-ai.js +1 -1
- package/dist/browser/pw-session.js +143 -8
- package/dist/browser/pw-tools-core.interactions.js +125 -27
- package/dist/browser/pw-tools-core.responses.js +1 -1
- package/dist/browser/pw-tools-core.state.js +1 -1
- package/dist/browser/routes/agent.act.js +86 -41
- package/dist/browser/routes/dispatcher.js +4 -4
- package/dist/browser/screenshot.js +1 -1
- package/dist/browser/server-context.js +2 -2
- package/dist/browser/server.js +13 -0
- package/dist/build-info.json +3 -3
- package/dist/canvas-host/a2ui.js +3 -3
- package/dist/channels/plugins/catalog.js +2 -2
- package/dist/channels/plugins/onboarding/imessage.js +1 -1
- package/dist/channels/plugins/onboarding/signal.js +1 -1
- package/dist/channels/plugins/onboarding/slack.js +4 -4
- package/dist/channels/plugins/onboarding/whatsapp.js +3 -3
- package/dist/channels/plugins/pairing-message.js +1 -1
- package/dist/channels/reply-prefix.js +8 -1
- package/dist/cli/browser-cli-extension.js +2 -2
- package/dist/cli/cron-cli/register.cron-add.js +61 -40
- package/dist/cli/cron-cli/register.cron-edit.js +60 -34
- package/dist/cli/cron-cli/shared.js +56 -41
- package/dist/cli/dns-cli.js +26 -14
- package/dist/cli/docs-cli.js +1 -1
- package/dist/cli/gateway-cli/dev.js +1 -1
- package/dist/cli/gateway-cli/register.js +37 -19
- package/dist/cli/memory-cli.js +30 -20
- package/dist/cli/nodes-cli/register.canvas.js +1 -1
- package/dist/cli/parse-bytes.js +37 -0
- package/dist/cli/plugins-cli.js +1 -1
- package/dist/cli/run-main.js +2 -2
- package/dist/cli/security-cli.js +1 -1
- package/dist/cli/tagline.js +1 -1
- package/dist/cli/update-cli.js +173 -52
- package/dist/cli/webhooks-cli.js +5 -5
- package/dist/commands/agent.js +1 -0
- package/dist/commands/agents.commands.add.js +1 -1
- package/dist/commands/auth-choice.apply.api-providers.js +305 -17
- package/dist/commands/auth-choice.apply.js +4 -1
- package/dist/commands/auth-choice.apply.plugin-provider.js +2 -2
- package/dist/commands/auth-choice.apply.xai.js +63 -0
- package/dist/commands/auth-choice.preferred-provider.js +7 -1
- package/dist/commands/configure.wizard.js +1 -1
- package/dist/commands/dashboard.js +1 -1
- package/dist/commands/docs.js +1 -1
- package/dist/commands/doctor-config-flow.js +61 -5
- package/dist/commands/doctor-gateway-services.js +3 -3
- package/dist/commands/doctor-state-migrations.js +1 -1
- package/dist/commands/doctor-update.js +3 -3
- package/dist/commands/doctor.js +1 -1
- package/dist/commands/health.js +1 -1
- package/dist/commands/model-allowlist.js +29 -0
- package/dist/commands/model-picker.js +2 -1
- package/dist/commands/models/list.probe.js +2 -2
- package/dist/commands/models/list.registry.js +4 -4
- package/dist/commands/models/list.status-command.js +44 -24
- package/dist/commands/models/shared.js +15 -0
- package/dist/commands/onboard-auth.config-core.js +366 -28
- package/dist/commands/onboard-auth.credentials.js +71 -9
- package/dist/commands/onboard-auth.js +3 -3
- package/dist/commands/onboard-auth.models.js +26 -24
- package/dist/commands/onboard-custom.js +384 -0
- package/dist/commands/onboard-non-interactive/local/auth-choice-inference.js +35 -0
- package/dist/commands/onboard-non-interactive/local/auth-choice.js +146 -9
- package/dist/commands/onboard-skills.js +63 -38
- package/dist/commands/openai-model-default.js +41 -0
- package/dist/commands/status-all/report-lines.js +1 -1
- package/dist/commands/status.command.js +1 -1
- package/dist/commands/uninstall.js +3 -3
- package/dist/compat/legacy-names.js +1 -1
- package/dist/config/defaults.js +3 -2
- package/dist/config/io.js +3 -3
- package/dist/config/paths.js +136 -35
- package/dist/config/plugin-auto-enable.js +21 -5
- package/dist/config/redact-snapshot.js +153 -0
- package/dist/config/schema.field-metadata.js +590 -0
- package/dist/config/schema.js +3 -3
- package/dist/config/sessions/store.js +291 -23
- package/dist/config/types.memory.js +1 -0
- package/dist/config/version.js +4 -4
- package/dist/config/zod-schema.agent-defaults.js +3 -0
- package/dist/config/zod-schema.agent-runtime.js +13 -2
- package/dist/config/zod-schema.providers-core.js +142 -0
- package/dist/config/zod-schema.session.js +3 -0
- package/dist/cron/delivery.js +57 -0
- package/dist/cron/isolated-agent/delivery-target.js +18 -3
- package/dist/cron/isolated-agent/helpers.js +22 -5
- package/dist/cron/isolated-agent/run.js +171 -63
- package/dist/cron/isolated-agent/session.js +2 -0
- package/dist/cron/normalize.js +356 -28
- package/dist/cron/parse.js +10 -5
- package/dist/cron/run-log.js +35 -10
- package/dist/cron/schedule.js +41 -6
- package/dist/cron/service/jobs.js +208 -35
- package/dist/cron/service/ops.js +72 -16
- package/dist/cron/service/state.js +2 -0
- package/dist/cron/service/store.js +386 -14
- package/dist/cron/service/timer.js +390 -147
- package/dist/cron/session-reaper.js +86 -0
- package/dist/cron/store.js +23 -8
- package/dist/cron/validate-timestamp.js +43 -0
- package/dist/daemon/constants.js +7 -7
- package/dist/daemon/inspect.js +6 -6
- package/dist/daemon/systemd-unit.js +1 -1
- package/dist/discord/monitor/agent-components.js +438 -0
- package/dist/discord/monitor/allow-list.js +28 -5
- package/dist/discord/monitor/gateway-registry.js +29 -0
- package/dist/discord/monitor/native-command.js +44 -23
- package/dist/discord/monitor/sender-identity.js +45 -0
- package/dist/discord/pluralkit.js +27 -0
- package/dist/discord/send.outbound.js +92 -5
- package/dist/discord/send.shared.js +60 -23
- package/dist/discord/targets.js +84 -1
- package/dist/entry.js +15 -9
- package/dist/extensionAPI.js +8 -0
- package/dist/gateway/control-ui.js +8 -1
- package/dist/gateway/hooks-mapping.js +3 -0
- package/dist/gateway/hooks.js +65 -0
- package/dist/gateway/live-image-probe.js +1 -66
- package/dist/gateway/net.js +96 -31
- package/dist/gateway/node-command-policy.js +50 -15
- package/dist/gateway/openai-http.js +2 -2
- package/dist/gateway/openresponses-http.js +4 -4
- package/dist/gateway/origin-check.js +56 -0
- package/dist/gateway/protocol/client-info.js +9 -0
- package/dist/gateway/protocol/index.js +9 -2
- package/dist/gateway/protocol/schema/agents-models-skills.js +71 -1
- package/dist/gateway/protocol/schema/cron.js +22 -10
- package/dist/gateway/protocol/schema/protocol-schemas.js +16 -2
- package/dist/gateway/protocol/schema/sessions.js +12 -0
- package/dist/gateway/server/hooks.js +1 -1
- package/dist/gateway/server-broadcast.js +26 -9
- package/dist/gateway/server-chat.js +112 -23
- package/dist/gateway/server-discovery-runtime.js +10 -2
- package/dist/gateway/server-discovery.js +2 -2
- package/dist/gateway/server-http.js +110 -12
- package/dist/gateway/server-methods/agent-timestamp.js +60 -0
- package/dist/gateway/server-methods/agents.js +321 -2
- package/dist/gateway/server-methods/usage.js +559 -16
- package/dist/gateway/server-runtime-state.js +22 -8
- package/dist/gateway/server-startup-memory.js +16 -0
- package/dist/gateway/server.impl.js +7 -3
- package/dist/gateway/session-utils.fs.js +23 -25
- package/dist/gateway/session-utils.js +20 -10
- package/dist/gateway/sessions-patch.js +7 -22
- package/dist/gateway/test-helpers.server.js +35 -2
- package/dist/hooks/frontmatter.js +1 -1
- package/dist/hooks/hooks-status.js +1 -1
- package/dist/hooks/install.js +2 -2
- package/dist/hooks/loader.js +1 -1
- package/dist/hooks/workspace.js +3 -3
- package/dist/imessage/constants.js +2 -0
- package/dist/imessage/monitor/deliver.js +4 -1
- package/dist/imessage/monitor/monitor-provider.js +51 -1
- package/dist/index.js +2 -2
- package/dist/infra/bonjour-discovery.js +131 -70
- package/dist/infra/bonjour.js +3 -3
- package/dist/infra/control-ui-assets.js +134 -12
- package/dist/infra/errors.js +12 -0
- package/dist/infra/exec-approvals.js +266 -57
- package/dist/infra/format-time/format-datetime.js +79 -0
- package/dist/infra/format-time/format-duration.js +81 -0
- package/dist/infra/format-time/format-relative.js +80 -0
- package/dist/infra/heartbeat-runner.js +140 -49
- package/dist/infra/home-dir.js +54 -0
- package/dist/infra/net/fetch-guard.js +122 -0
- package/dist/infra/net/ssrf.js +65 -29
- package/dist/infra/outbound/abort.js +14 -0
- package/dist/infra/outbound/message-action-runner.js +77 -13
- package/dist/infra/outbound/outbound-session.js +143 -37
- package/dist/infra/path-env.js +3 -3
- package/dist/infra/poolbot-root.js +43 -1
- package/dist/infra/provider-usage.fetch.minimax.js +1 -1
- package/dist/infra/restart.js +1 -1
- package/dist/infra/session-cost-usage.js +631 -41
- package/dist/infra/state-migrations.js +317 -47
- package/dist/infra/tailscale.js +1 -1
- package/dist/infra/update-global.js +35 -0
- package/dist/infra/update-runner.js +149 -43
- package/dist/infra/warning-filter.js +65 -0
- package/dist/infra/widearea-dns.js +30 -9
- package/dist/logging/redact-identifier.js +12 -0
- package/dist/macos/relay.js +2 -2
- package/dist/media/fetch.js +81 -58
- package/dist/media/input-files.js +1 -1
- package/dist/media/mime.js +4 -0
- package/dist/media/png-encode.js +74 -0
- package/dist/media-understanding/apply.js +403 -3
- package/dist/media-understanding/attachments.js +38 -27
- package/dist/media-understanding/defaults.js +16 -0
- package/dist/media-understanding/providers/deepgram/audio.js +22 -14
- package/dist/media-understanding/providers/google/audio.js +24 -17
- package/dist/media-understanding/providers/google/video.js +24 -17
- package/dist/media-understanding/providers/image.js +4 -4
- package/dist/media-understanding/providers/index.js +4 -1
- package/dist/media-understanding/providers/openai/audio.js +22 -14
- package/dist/media-understanding/providers/shared.js +16 -11
- package/dist/media-understanding/providers/zai/index.js +6 -0
- package/dist/media-understanding/runner.js +158 -90
- package/dist/memory/backend-config.js +207 -0
- package/dist/memory/batch-voyage.js +277 -0
- package/dist/memory/embeddings-voyage.js +75 -0
- package/dist/memory/embeddings.js +29 -17
- package/dist/memory/internal.js +101 -18
- package/dist/memory/manager.js +155 -48
- package/dist/memory/search-manager.js +173 -0
- package/dist/memory/session-files.js +9 -3
- package/dist/memory/types.js +1 -0
- package/dist/node-host/runner.js +36 -26
- package/dist/node-host/with-timeout.js +27 -0
- package/dist/pairing/pairing-messages.js +1 -1
- package/dist/plugins/commands.js +5 -1
- package/dist/plugins/config-state.js +86 -7
- package/dist/plugins/discovery.js +1 -1
- package/dist/plugins/install.js +2 -2
- package/dist/plugins/source-display.js +51 -0
- package/dist/plugins/update.js +1 -1
- package/dist/process/exec.js +20 -2
- package/dist/routing/resolve-route.js +12 -0
- package/dist/routing/session-key.js +15 -0
- package/dist/runtime.js +2 -0
- package/dist/security/audit-extra.async.js +601 -0
- package/dist/security/audit-extra.js +2 -830
- package/dist/security/audit-extra.sync.js +505 -0
- package/dist/security/audit.js +2 -2
- package/dist/security/channel-metadata.js +34 -0
- package/dist/security/external-content.js +88 -6
- package/dist/security/skill-scanner.js +330 -0
- package/dist/sessions/session-key-utils.js +7 -0
- package/dist/shared/text/reasoning-tags.js +52 -7
- package/dist/signal/monitor/event-handler.js +80 -1
- package/dist/slack/monitor/media.js +85 -15
- package/dist/tailscale/detect.js +145 -0
- package/dist/telegram/bot/helpers.js +109 -28
- package/dist/telegram/bot-handlers.js +144 -3
- package/dist/telegram/bot-message-context.js +38 -11
- package/dist/telegram/bot-message-dispatch.js +48 -15
- package/dist/telegram/bot-native-commands.js +86 -29
- package/dist/telegram/bot.js +30 -29
- package/dist/telegram/model-buttons.js +163 -0
- package/dist/telegram/monitor.js +110 -85
- package/dist/telegram/send.js +129 -47
- package/dist/terminal/restore.js +45 -0
- package/dist/test-helpers/state-dir-env.js +16 -0
- package/dist/test-helpers/workspace.js +11 -0
- package/dist/test-utils/channel-plugins.js +82 -0
- package/dist/test-utils/ports.js +73 -0
- package/dist/tts/tts.js +12 -6
- package/dist/tui/tui-session-actions.js +166 -54
- package/dist/utils/fetch-timeout.js +20 -0
- package/dist/utils/normalize-secret-input.js +19 -0
- package/dist/utils/shell-argv.js +61 -0
- package/dist/utils/transcript-tools.js +58 -0
- package/dist/utils.js +55 -14
- package/dist/version.js +42 -5
- package/dist/web/qr-image.js +1 -61
- package/dist/wizard/onboarding.finalize.js +7 -7
- package/dist/wizard/onboarding.js +3 -3
- package/docs/RELEASE_WORKFOTS_COMPARISON.md +3 -3
- package/docs/_config.yml +2 -2
- package/docs/_layouts/default.html +9 -9
- package/docs/concepts/typebox.md +1 -1
- package/docs/docs.json +1 -1
- package/docs/northflank.mdx +7 -7
- package/docs/railway.mdx +3 -3
- package/docs/render.mdx +5 -5
- package/docs/start/lore.md +2 -2
- package/extensions/bluebubbles/index.ts +2 -2
- package/extensions/bluebubbles/package.json +1 -1
- package/extensions/bluebubbles/src/accounts.ts +8 -8
- package/extensions/bluebubbles/src/actions.test.ts +22 -22
- package/extensions/bluebubbles/src/actions.ts +5 -5
- package/extensions/bluebubbles/src/attachments.ts +2 -2
- package/extensions/bluebubbles/src/channel.ts +16 -16
- package/extensions/bluebubbles/src/chat.ts +2 -2
- package/extensions/bluebubbles/src/media-send.ts +2 -2
- package/extensions/bluebubbles/src/monitor.test.ts +46 -46
- package/extensions/bluebubbles/src/monitor.ts +5 -5
- package/extensions/bluebubbles/src/onboarding.ts +7 -7
- package/extensions/bluebubbles/src/reactions.ts +2 -2
- package/extensions/bluebubbles/src/send.ts +2 -2
- package/extensions/copilot-proxy/README.md +1 -1
- package/extensions/copilot-proxy/package.json +1 -1
- package/extensions/diagnostics-otel/index.ts +2 -2
- package/extensions/diagnostics-otel/package.json +1 -1
- package/extensions/diagnostics-otel/src/service.ts +3 -3
- package/extensions/discord/index.ts +2 -2
- package/extensions/discord/package.json +1 -1
- package/extensions/google-antigravity-auth/README.md +1 -1
- package/extensions/google-antigravity-auth/index.ts +1 -1
- package/extensions/google-antigravity-auth/package.json +1 -1
- package/extensions/google-gemini-cli-auth/README.md +1 -1
- package/extensions/google-gemini-cli-auth/oauth.ts +1 -1
- package/extensions/google-gemini-cli-auth/package.json +1 -1
- package/extensions/googlechat/index.ts +3 -3
- package/extensions/googlechat/package.json +1 -1
- package/extensions/googlechat/src/accounts.ts +8 -8
- package/extensions/googlechat/src/actions.ts +6 -6
- package/extensions/googlechat/src/channel.ts +21 -21
- package/extensions/googlechat/src/monitor.ts +8 -8
- package/extensions/googlechat/src/onboarding.ts +10 -10
- package/extensions/imessage/index.ts +2 -2
- package/extensions/imessage/package.json +1 -1
- package/extensions/line/index.ts +2 -2
- package/extensions/line/package.json +1 -1
- package/extensions/line/src/card-command.ts +2 -2
- package/extensions/line/src/channel.logout.test.ts +4 -4
- package/extensions/line/src/channel.sendPayload.test.ts +8 -8
- package/extensions/line/src/channel.ts +3 -3
- package/extensions/llm-task/README.md +3 -3
- package/extensions/llm-task/index.ts +2 -2
- package/extensions/llm-task/package.json +1 -1
- package/extensions/llm-task/src/llm-task-tool.ts +4 -4
- package/extensions/lobster/README.md +6 -6
- package/extensions/lobster/index.ts +2 -2
- package/extensions/lobster/src/lobster-tool.test.ts +4 -4
- package/extensions/lobster/src/lobster-tool.ts +2 -2
- package/extensions/matrix/index.ts +2 -2
- package/extensions/matrix/package.json +1 -1
- package/extensions/matrix/src/matrix/client/config.ts +1 -1
- package/extensions/matrix/src/matrix/monitor/handler.ts +1 -1
- package/extensions/matrix/src/onboarding.ts +1 -1
- package/extensions/mattermost/index.ts +2 -2
- package/extensions/mattermost/package.json +1 -1
- package/extensions/mattermost/src/mattermost/accounts.ts +8 -8
- package/extensions/mattermost/src/mattermost/monitor-helpers.ts +5 -5
- package/extensions/mattermost/src/mattermost/monitor.ts +2 -2
- package/extensions/mattermost/src/onboarding-helpers.ts +3 -3
- package/extensions/mattermost/src/onboarding.ts +2 -2
- package/extensions/memory-core/index.ts +2 -2
- package/extensions/memory-core/package.json +1 -1
- package/extensions/memory-lancedb/index.ts +3 -3
- package/extensions/memory-lancedb/package.json +1 -1
- package/extensions/msteams/index.ts +2 -2
- package/extensions/msteams/package.json +1 -1
- package/extensions/msteams/src/channel.directory.test.ts +2 -2
- package/extensions/msteams/src/channel.ts +2 -2
- package/extensions/msteams/src/graph-upload.ts +4 -4
- package/extensions/msteams/src/monitor-handler.ts +2 -2
- package/extensions/msteams/src/monitor.ts +2 -2
- package/extensions/msteams/src/onboarding.ts +9 -9
- package/extensions/msteams/src/reply-dispatcher.ts +2 -2
- package/extensions/msteams/src/send-context.ts +2 -2
- package/extensions/msteams/src/send.ts +4 -4
- package/extensions/nextcloud-talk/index.ts +2 -2
- package/extensions/nextcloud-talk/package.json +1 -1
- package/extensions/nextcloud-talk/src/channel.ts +7 -7
- package/extensions/nextcloud-talk/src/inbound.ts +7 -7
- package/extensions/nextcloud-talk/src/onboarding.ts +1 -1
- package/extensions/nostr/README.md +2 -2
- package/extensions/nostr/index.ts +5 -5
- package/extensions/nostr/package.json +1 -1
- package/extensions/nostr/src/types.ts +4 -4
- package/extensions/open-prose/index.ts +2 -2
- package/extensions/qwen-portal-auth/README.md +1 -1
- package/extensions/signal/index.ts +2 -2
- package/extensions/signal/package.json +1 -1
- package/extensions/slack/index.ts +2 -2
- package/extensions/slack/package.json +1 -1
- package/extensions/telegram/index.ts +2 -2
- package/extensions/telegram/package.json +1 -1
- package/extensions/telegram/src/channel.ts +2 -2
- package/extensions/tlon/README.md +2 -2
- package/extensions/tlon/index.ts +2 -2
- package/extensions/tlon/package.json +1 -1
- package/extensions/tlon/src/channel.ts +13 -13
- package/extensions/tlon/src/monitor/index.ts +3 -3
- package/extensions/tlon/src/onboarding.ts +3 -3
- package/extensions/tlon/src/types.ts +3 -3
- package/extensions/twitch/README.md +1 -1
- package/extensions/twitch/index.ts +2 -2
- package/extensions/twitch/package.json +1 -1
- package/extensions/twitch/src/config.ts +3 -3
- package/extensions/twitch/src/monitor.ts +3 -3
- package/extensions/twitch/src/onboarding.ts +9 -9
- package/extensions/twitch/src/outbound.test.ts +2 -2
- package/extensions/twitch/src/plugin.test.ts +2 -2
- package/extensions/twitch/src/plugin.ts +8 -8
- package/extensions/twitch/src/send.test.ts +2 -2
- package/extensions/twitch/src/send.ts +4 -4
- package/extensions/twitch/src/token.test.ts +8 -8
- package/extensions/twitch/src/token.ts +3 -3
- package/extensions/twitch/src/twitch-client.ts +3 -3
- package/extensions/twitch/src/types.ts +3 -3
- package/extensions/twitch/src/utils/markdown.ts +1 -1
- package/extensions/voice-call/README.md +3 -3
- package/extensions/voice-call/package.json +1 -1
- package/extensions/voice-call/src/core-bridge.ts +2 -2
- package/extensions/voice-call/src/response-generator.ts +1 -1
- package/extensions/whatsapp/index.ts +2 -2
- package/extensions/whatsapp/package.json +1 -1
- package/extensions/zalo/README.md +1 -1
- package/extensions/zalo/index.ts +2 -2
- package/extensions/zalo/package.json +1 -1
- package/extensions/zalo/src/accounts.ts +8 -8
- package/extensions/zalo/src/actions.ts +4 -4
- package/extensions/zalo/src/channel.directory.test.ts +2 -2
- package/extensions/zalo/src/channel.ts +18 -18
- package/extensions/zalo/src/monitor.ts +9 -9
- package/extensions/zalo/src/monitor.webhook.test.ts +2 -2
- package/extensions/zalo/src/onboarding.ts +24 -24
- package/extensions/zalo/src/send.ts +2 -2
- package/extensions/zalouser/README.md +2 -2
- package/extensions/zalouser/index.ts +2 -2
- package/extensions/zalouser/package.json +1 -1
- package/extensions/zalouser/src/accounts.ts +9 -9
- package/extensions/zalouser/src/channel.ts +24 -24
- package/extensions/zalouser/src/monitor.ts +4 -4
- package/extensions/zalouser/src/onboarding.ts +28 -28
- package/package.json +13 -251
- package/skills/nano-banana-pro/scripts/generate_image.py +1 -1
- package/skills/tmux/scripts/find-sessions.sh +1 -1
- package/CHANGELOG.md +0 -102
- package/README-header.png +0 -0
- package/git-hooks/pre-commit +0 -4
- package/scripts/format-staged.js +0 -148
- package/scripts/postinstall.js +0 -300
- package/scripts/setup-git-hooks.js +0 -96
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { getGateway } from "../../discord/monitor/gateway-registry.js";
|
|
2
|
+
import { jsonResult, readStringParam } from "./common.js";
|
|
3
|
+
const ACTIVITY_TYPE_MAP = {
|
|
4
|
+
playing: 0,
|
|
5
|
+
streaming: 1,
|
|
6
|
+
listening: 2,
|
|
7
|
+
watching: 3,
|
|
8
|
+
custom: 4,
|
|
9
|
+
competing: 5,
|
|
10
|
+
};
|
|
11
|
+
const VALID_STATUSES = new Set(["online", "dnd", "idle", "invisible"]);
|
|
12
|
+
export async function handleDiscordPresenceAction(action, params, isActionEnabled) {
|
|
13
|
+
if (action !== "setPresence") {
|
|
14
|
+
throw new Error(`Unknown presence action: ${action}`);
|
|
15
|
+
}
|
|
16
|
+
if (!isActionEnabled("presence", false)) {
|
|
17
|
+
throw new Error("Discord presence changes are disabled.");
|
|
18
|
+
}
|
|
19
|
+
const accountId = readStringParam(params, "accountId");
|
|
20
|
+
const gateway = getGateway(accountId);
|
|
21
|
+
if (!gateway) {
|
|
22
|
+
throw new Error(`Discord gateway not available${accountId ? ` for account "${accountId}"` : ""}. The bot may not be connected.`);
|
|
23
|
+
}
|
|
24
|
+
if (!gateway.isConnected) {
|
|
25
|
+
throw new Error(`Discord gateway is not connected${accountId ? ` for account "${accountId}"` : ""}.`);
|
|
26
|
+
}
|
|
27
|
+
const statusRaw = readStringParam(params, "status") ?? "online";
|
|
28
|
+
if (!VALID_STATUSES.has(statusRaw)) {
|
|
29
|
+
throw new Error(`Invalid status "${statusRaw}". Must be one of: ${[...VALID_STATUSES].join(", ")}`);
|
|
30
|
+
}
|
|
31
|
+
const status = statusRaw;
|
|
32
|
+
const activityTypeRaw = readStringParam(params, "activityType");
|
|
33
|
+
const activityName = readStringParam(params, "activityName");
|
|
34
|
+
const activities = [];
|
|
35
|
+
if (activityTypeRaw || activityName) {
|
|
36
|
+
if (!activityTypeRaw) {
|
|
37
|
+
throw new Error("activityType is required when activityName is provided. " +
|
|
38
|
+
`Valid types: ${Object.keys(ACTIVITY_TYPE_MAP).join(", ")}`);
|
|
39
|
+
}
|
|
40
|
+
const typeNum = ACTIVITY_TYPE_MAP[activityTypeRaw.toLowerCase()];
|
|
41
|
+
if (typeNum === undefined) {
|
|
42
|
+
throw new Error(`Invalid activityType "${activityTypeRaw}". Must be one of: ${Object.keys(ACTIVITY_TYPE_MAP).join(", ")}`);
|
|
43
|
+
}
|
|
44
|
+
const activity = {
|
|
45
|
+
name: activityName ?? "",
|
|
46
|
+
type: typeNum,
|
|
47
|
+
};
|
|
48
|
+
// Streaming URL (Twitch/YouTube). May not render for bots but is the correct payload shape.
|
|
49
|
+
if (typeNum === 1) {
|
|
50
|
+
const url = readStringParam(params, "activityUrl");
|
|
51
|
+
if (url) {
|
|
52
|
+
activity.url = url;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const state = readStringParam(params, "activityState");
|
|
56
|
+
if (state) {
|
|
57
|
+
activity.state = state;
|
|
58
|
+
}
|
|
59
|
+
activities.push(activity);
|
|
60
|
+
}
|
|
61
|
+
const presenceData = {
|
|
62
|
+
since: null,
|
|
63
|
+
activities,
|
|
64
|
+
status,
|
|
65
|
+
afk: false,
|
|
66
|
+
};
|
|
67
|
+
gateway.updatePresence(presenceData);
|
|
68
|
+
return jsonResult({
|
|
69
|
+
ok: true,
|
|
70
|
+
status,
|
|
71
|
+
activities: activities.map((a) => ({
|
|
72
|
+
type: a.type,
|
|
73
|
+
name: a.name,
|
|
74
|
+
...(a.url ? { url: a.url } : {}),
|
|
75
|
+
...(a.state ? { state: a.state } : {}),
|
|
76
|
+
})),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
@@ -11,7 +11,7 @@ import { minimaxUnderstandImage } from "../minimax-vlm.js";
|
|
|
11
11
|
import { getApiKeyForModel, requireApiKey, resolveEnvApiKey } from "../model-auth.js";
|
|
12
12
|
import { runWithImageModelFallback } from "../model-fallback.js";
|
|
13
13
|
import { resolveConfiguredModelRef } from "../model-selection.js";
|
|
14
|
-
import {
|
|
14
|
+
import { ensurePoolbotModelsJson } from "../models-config.js";
|
|
15
15
|
import { assertSandboxPath } from "../sandbox-paths.js";
|
|
16
16
|
import { coerceImageAssistantText, coerceImageModelConfig, decodeDataUrl, resolveProviderVisionModelFromConfig, } from "./image-tool.helpers.js";
|
|
17
17
|
const DEFAULT_PROMPT = "Describe the image.";
|
|
@@ -187,7 +187,7 @@ async function runImagePrompt(params) {
|
|
|
187
187
|
},
|
|
188
188
|
}
|
|
189
189
|
: undefined;
|
|
190
|
-
await
|
|
190
|
+
await ensurePoolbotModelsJson(effectiveCfg, params.agentDir);
|
|
191
191
|
const authStorage = discoverAuthStorage(params.agentDir);
|
|
192
192
|
const modelRegistry = discoverModels(authStorage, params.agentDir);
|
|
193
193
|
const result = await runWithImageModelFallback({
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { resolveMemoryBackendConfig } from "../../memory/backend-config.js";
|
|
2
3
|
import { getMemorySearchManager } from "../../memory/index.js";
|
|
4
|
+
import { parseAgentSessionKey } from "../../routing/session-key.js";
|
|
3
5
|
import { resolveSessionAgentId } from "../agent-scope.js";
|
|
4
6
|
import { resolveMemorySearchConfig } from "../memory-search.js";
|
|
5
7
|
import { jsonResult, readNumberParam, readStringParam } from "./common.js";
|
|
@@ -15,14 +17,16 @@ const MemoryGetSchema = Type.Object({
|
|
|
15
17
|
});
|
|
16
18
|
export function createMemorySearchTool(options) {
|
|
17
19
|
const cfg = options.config;
|
|
18
|
-
if (!cfg)
|
|
20
|
+
if (!cfg) {
|
|
19
21
|
return null;
|
|
22
|
+
}
|
|
20
23
|
const agentId = resolveSessionAgentId({
|
|
21
24
|
sessionKey: options.agentSessionKey,
|
|
22
25
|
config: cfg,
|
|
23
26
|
});
|
|
24
|
-
if (!resolveMemorySearchConfig(cfg, agentId))
|
|
27
|
+
if (!resolveMemorySearchConfig(cfg, agentId)) {
|
|
25
28
|
return null;
|
|
29
|
+
}
|
|
26
30
|
return {
|
|
27
31
|
label: "Memory Search",
|
|
28
32
|
name: "memory_search",
|
|
@@ -40,17 +44,28 @@ export function createMemorySearchTool(options) {
|
|
|
40
44
|
return jsonResult({ results: [], disabled: true, error });
|
|
41
45
|
}
|
|
42
46
|
try {
|
|
43
|
-
const
|
|
47
|
+
const citationsMode = resolveMemoryCitationsMode(cfg);
|
|
48
|
+
const includeCitations = shouldIncludeCitations({
|
|
49
|
+
mode: citationsMode,
|
|
50
|
+
sessionKey: options.agentSessionKey,
|
|
51
|
+
});
|
|
52
|
+
const rawResults = await manager.search(query, {
|
|
44
53
|
maxResults,
|
|
45
54
|
minScore,
|
|
46
55
|
sessionKey: options.agentSessionKey,
|
|
47
56
|
});
|
|
48
57
|
const status = manager.status();
|
|
58
|
+
const decorated = decorateCitations(rawResults, includeCitations);
|
|
59
|
+
const resolved = resolveMemoryBackendConfig({ cfg, agentId });
|
|
60
|
+
const results = status.backend === "qmd"
|
|
61
|
+
? clampResultsByInjectedChars(decorated, resolved.qmd?.limits.maxInjectedChars)
|
|
62
|
+
: decorated;
|
|
49
63
|
return jsonResult({
|
|
50
64
|
results,
|
|
51
65
|
provider: status.provider,
|
|
52
66
|
model: status.model,
|
|
53
67
|
fallback: status.fallback,
|
|
68
|
+
citations: citationsMode,
|
|
54
69
|
});
|
|
55
70
|
}
|
|
56
71
|
catch (err) {
|
|
@@ -62,14 +77,16 @@ export function createMemorySearchTool(options) {
|
|
|
62
77
|
}
|
|
63
78
|
export function createMemoryGetTool(options) {
|
|
64
79
|
const cfg = options.config;
|
|
65
|
-
if (!cfg)
|
|
80
|
+
if (!cfg) {
|
|
66
81
|
return null;
|
|
82
|
+
}
|
|
67
83
|
const agentId = resolveSessionAgentId({
|
|
68
84
|
sessionKey: options.agentSessionKey,
|
|
69
85
|
config: cfg,
|
|
70
86
|
});
|
|
71
|
-
if (!resolveMemorySearchConfig(cfg, agentId))
|
|
87
|
+
if (!resolveMemorySearchConfig(cfg, agentId)) {
|
|
72
88
|
return null;
|
|
89
|
+
}
|
|
73
90
|
return {
|
|
74
91
|
label: "Memory Get",
|
|
75
92
|
name: "memory_get",
|
|
@@ -101,3 +118,74 @@ export function createMemoryGetTool(options) {
|
|
|
101
118
|
},
|
|
102
119
|
};
|
|
103
120
|
}
|
|
121
|
+
function resolveMemoryCitationsMode(cfg) {
|
|
122
|
+
const mode = cfg.memory?.citations;
|
|
123
|
+
if (mode === "on" || mode === "off" || mode === "auto") {
|
|
124
|
+
return mode;
|
|
125
|
+
}
|
|
126
|
+
return "auto";
|
|
127
|
+
}
|
|
128
|
+
function decorateCitations(results, include) {
|
|
129
|
+
if (!include) {
|
|
130
|
+
return results.map((entry) => ({ ...entry, citation: undefined }));
|
|
131
|
+
}
|
|
132
|
+
return results.map((entry) => {
|
|
133
|
+
const citation = formatCitation(entry);
|
|
134
|
+
const snippet = `${entry.snippet.trim()}\n\nSource: ${citation}`;
|
|
135
|
+
return { ...entry, citation, snippet };
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function formatCitation(entry) {
|
|
139
|
+
const lineRange = entry.startLine === entry.endLine
|
|
140
|
+
? `#L${entry.startLine}`
|
|
141
|
+
: `#L${entry.startLine}-L${entry.endLine}`;
|
|
142
|
+
return `${entry.path}${lineRange}`;
|
|
143
|
+
}
|
|
144
|
+
function clampResultsByInjectedChars(results, budget) {
|
|
145
|
+
if (!budget || budget <= 0) {
|
|
146
|
+
return results;
|
|
147
|
+
}
|
|
148
|
+
let remaining = budget;
|
|
149
|
+
const clamped = [];
|
|
150
|
+
for (const entry of results) {
|
|
151
|
+
if (remaining <= 0) {
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
const snippet = entry.snippet ?? "";
|
|
155
|
+
if (snippet.length <= remaining) {
|
|
156
|
+
clamped.push(entry);
|
|
157
|
+
remaining -= snippet.length;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
const trimmed = snippet.slice(0, Math.max(0, remaining));
|
|
161
|
+
clamped.push({ ...entry, snippet: trimmed });
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return clamped;
|
|
166
|
+
}
|
|
167
|
+
function shouldIncludeCitations(params) {
|
|
168
|
+
if (params.mode === "on") {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
if (params.mode === "off") {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
// auto: show citations in direct chats; suppress in groups/channels by default.
|
|
175
|
+
const chatType = deriveChatTypeFromSessionKey(params.sessionKey);
|
|
176
|
+
return chatType === "direct";
|
|
177
|
+
}
|
|
178
|
+
function deriveChatTypeFromSessionKey(sessionKey) {
|
|
179
|
+
const parsed = parseAgentSessionKey(sessionKey);
|
|
180
|
+
if (!parsed?.rest) {
|
|
181
|
+
return "direct";
|
|
182
|
+
}
|
|
183
|
+
const tokens = new Set(parsed.rest.toLowerCase().split(":").filter(Boolean));
|
|
184
|
+
if (tokens.has("channel")) {
|
|
185
|
+
return "channel";
|
|
186
|
+
}
|
|
187
|
+
if (tokens.has("group")) {
|
|
188
|
+
return "group";
|
|
189
|
+
}
|
|
190
|
+
return "direct";
|
|
191
|
+
}
|
|
@@ -11,8 +11,20 @@ import { normalizeAccountId } from "../../routing/session-key.js";
|
|
|
11
11
|
import { channelTargetSchema, channelTargetsSchema, stringEnum } from "../schema/typebox.js";
|
|
12
12
|
import { listChannelSupportedActions } from "../channel-tools.js";
|
|
13
13
|
import { normalizeMessageChannel } from "../../utils/message-channel.js";
|
|
14
|
+
import { stripReasoningTagsFromText } from "../../shared/text/reasoning-tags.js";
|
|
14
15
|
import { jsonResult, readNumberParam, readStringParam } from "./common.js";
|
|
15
16
|
const AllMessageActions = CHANNEL_MESSAGE_ACTION_NAMES;
|
|
17
|
+
const EXPLICIT_TARGET_ACTIONS = new Set([
|
|
18
|
+
"send",
|
|
19
|
+
"sendWithEffect",
|
|
20
|
+
"sendAttachment",
|
|
21
|
+
"reply",
|
|
22
|
+
"thread-reply",
|
|
23
|
+
"broadcast",
|
|
24
|
+
]);
|
|
25
|
+
function actionNeedsExplicitTarget(action) {
|
|
26
|
+
return EXPLICIT_TARGET_ACTIONS.has(action);
|
|
27
|
+
}
|
|
16
28
|
function buildRoutingSchema() {
|
|
17
29
|
return {
|
|
18
30
|
channel: Type.Optional(Type.String()),
|
|
@@ -29,7 +41,9 @@ function buildSendSchema(options) {
|
|
|
29
41
|
description: "Message effect name/id for sendWithEffect (e.g., invisible ink).",
|
|
30
42
|
})),
|
|
31
43
|
effect: Type.Optional(Type.String({ description: "Alias for effectId (e.g., invisible-ink, balloons)." })),
|
|
32
|
-
media: Type.Optional(Type.String(
|
|
44
|
+
media: Type.Optional(Type.String({
|
|
45
|
+
description: "Media URL or local path. data: URLs are not supported here, use buffer.",
|
|
46
|
+
})),
|
|
33
47
|
filename: Type.Optional(Type.String()),
|
|
34
48
|
buffer: Type.Optional(Type.String({
|
|
35
49
|
description: "Base64 payload for attachments (optionally a data: URL).",
|
|
@@ -45,6 +59,7 @@ function buildSendSchema(options) {
|
|
|
45
59
|
silent: Type.Optional(Type.Boolean()),
|
|
46
60
|
bestEffort: Type.Optional(Type.Boolean()),
|
|
47
61
|
gifPlayback: Type.Optional(Type.Boolean()),
|
|
62
|
+
quoteText: Type.Optional(Type.String({ description: "Quote text for Telegram reply_parameters" })),
|
|
48
63
|
buttons: Type.Optional(Type.Array(Type.Array(Type.Object({
|
|
49
64
|
text: Type.String(),
|
|
50
65
|
callback_data: Type.String(),
|
|
@@ -159,6 +174,23 @@ function buildChannelManagementSchema() {
|
|
|
159
174
|
})),
|
|
160
175
|
};
|
|
161
176
|
}
|
|
177
|
+
function buildPresenceSchema() {
|
|
178
|
+
return {
|
|
179
|
+
activityType: Type.Optional(Type.String({
|
|
180
|
+
description: "Activity type: playing, streaming, listening, watching, competing, custom.",
|
|
181
|
+
})),
|
|
182
|
+
activityName: Type.Optional(Type.String({
|
|
183
|
+
description: "Activity name shown in sidebar (e.g. 'with fire'). Ignored for custom type.",
|
|
184
|
+
})),
|
|
185
|
+
activityUrl: Type.Optional(Type.String({
|
|
186
|
+
description: "Streaming URL (Twitch or YouTube). Only used with streaming type; may not render for bots.",
|
|
187
|
+
})),
|
|
188
|
+
activityState: Type.Optional(Type.String({
|
|
189
|
+
description: "State text. For custom type this is the status text; for others it shows in the flyout.",
|
|
190
|
+
})),
|
|
191
|
+
status: Type.Optional(Type.String({ description: "Bot status: online, dnd, idle, invisible." })),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
162
194
|
function buildMessageToolSchemaProps(options) {
|
|
163
195
|
return {
|
|
164
196
|
...buildRoutingSchema(),
|
|
@@ -173,6 +205,7 @@ function buildMessageToolSchemaProps(options) {
|
|
|
173
205
|
...buildModerationSchema(),
|
|
174
206
|
...buildGatewaySchema(),
|
|
175
207
|
...buildChannelManagementSchema(),
|
|
208
|
+
...buildPresenceSchema(),
|
|
176
209
|
};
|
|
177
210
|
}
|
|
178
211
|
function buildMessageToolSchemaFromActions(actions, options) {
|
|
@@ -266,11 +299,31 @@ export function createMessageTool(options) {
|
|
|
266
299
|
err.name = "AbortError";
|
|
267
300
|
throw err;
|
|
268
301
|
}
|
|
269
|
-
|
|
302
|
+
// Shallow-copy so we don't mutate the original event args (used for logging/dedup).
|
|
303
|
+
const params = { ...args };
|
|
304
|
+
// Strip reasoning tags from text fields — models may include <think>…</think>
|
|
305
|
+
// in tool arguments, and the messaging tool send path has no other tag filtering.
|
|
306
|
+
for (const field of ["text", "content", "message", "caption"]) {
|
|
307
|
+
if (typeof params[field] === "string") {
|
|
308
|
+
params[field] = stripReasoningTagsFromText(params[field]);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
270
311
|
const cfg = options?.config ?? loadConfig();
|
|
271
312
|
const action = readStringParam(params, "action", {
|
|
272
313
|
required: true,
|
|
273
314
|
});
|
|
315
|
+
// Enforce explicit target when required (e.g. cron/hook-initiated runs).
|
|
316
|
+
const requireExplicitTarget = options?.requireExplicitTarget === true;
|
|
317
|
+
if (requireExplicitTarget && actionNeedsExplicitTarget(action)) {
|
|
318
|
+
const explicitTarget = (typeof params.target === "string" && params.target.trim().length > 0) ||
|
|
319
|
+
(typeof params.to === "string" && params.to.trim().length > 0) ||
|
|
320
|
+
(typeof params.channelId === "string" && params.channelId.trim().length > 0) ||
|
|
321
|
+
(Array.isArray(params.targets) &&
|
|
322
|
+
params.targets.some((value) => typeof value === "string" && value.trim().length > 0));
|
|
323
|
+
if (!explicitTarget) {
|
|
324
|
+
throw new Error("Explicit message target required for this run. Provide target/targets (and channel when needed).");
|
|
325
|
+
}
|
|
326
|
+
}
|
|
274
327
|
const accountId = readStringParam(params, "accountId") ?? agentAccountId;
|
|
275
328
|
if (accountId) {
|
|
276
329
|
params.accountId = accountId;
|
|
@@ -309,6 +362,7 @@ export function createMessageTool(options) {
|
|
|
309
362
|
agentId: options?.agentSessionKey
|
|
310
363
|
? resolveSessionAgentId({ sessionKey: options.agentSessionKey, config: cfg })
|
|
311
364
|
: undefined,
|
|
365
|
+
sandboxRoot: options?.sandboxRoot,
|
|
312
366
|
abortSignal: signal,
|
|
313
367
|
});
|
|
314
368
|
const toolResult = getToolResult(result);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Type } from "@sinclair/typebox";
|
|
2
2
|
import { loadConfig } from "../../config/config.js";
|
|
3
3
|
import { callGateway } from "../../gateway/call.js";
|
|
4
|
+
import { capArrayByJsonBytes } from "../../gateway/session-utils.fs.js";
|
|
4
5
|
import { isSubagentSessionKey, resolveAgentIdFromSessionKey } from "../../routing/session-key.js";
|
|
6
|
+
import { truncateUtf16Safe } from "../../utils.js";
|
|
5
7
|
import { jsonResult, readStringParam } from "./common.js";
|
|
6
8
|
import { createAgentToAgentPolicy, resolveSessionReference, resolveMainSessionAlias, resolveInternalSessionKey, stripToolMessages, } from "./sessions-helpers.js";
|
|
7
9
|
const SessionsHistoryToolSchema = Type.Object({
|
|
@@ -9,6 +11,63 @@ const SessionsHistoryToolSchema = Type.Object({
|
|
|
9
11
|
limit: Type.Optional(Type.Number({ minimum: 1 })),
|
|
10
12
|
includeTools: Type.Optional(Type.Boolean()),
|
|
11
13
|
});
|
|
14
|
+
/** Hard cap on the serialized JSON size of the returned messages array. */
|
|
15
|
+
const SESSIONS_HISTORY_MAX_BYTES = 512 * 1024;
|
|
16
|
+
/** Per-block text truncation limit (in UTF-16 chars). */
|
|
17
|
+
const SESSIONS_HISTORY_TEXT_MAX_CHARS = 32_000;
|
|
18
|
+
function truncateHistoryText(text, maxChars) {
|
|
19
|
+
if (text.length <= maxChars)
|
|
20
|
+
return text;
|
|
21
|
+
return `${truncateUtf16Safe(text, maxChars)}…(truncated)`;
|
|
22
|
+
}
|
|
23
|
+
function sanitizeHistoryContentBlock(block) {
|
|
24
|
+
if (!block || typeof block !== "object")
|
|
25
|
+
return block;
|
|
26
|
+
const rec = block;
|
|
27
|
+
if (typeof rec.text === "string") {
|
|
28
|
+
return { ...rec, text: truncateHistoryText(rec.text, SESSIONS_HISTORY_TEXT_MAX_CHARS) };
|
|
29
|
+
}
|
|
30
|
+
return block;
|
|
31
|
+
}
|
|
32
|
+
function sanitizeHistoryMessage(msg) {
|
|
33
|
+
if (!msg || typeof msg !== "object")
|
|
34
|
+
return msg;
|
|
35
|
+
const rec = msg;
|
|
36
|
+
if (typeof rec.content === "string") {
|
|
37
|
+
return { ...rec, content: truncateHistoryText(rec.content, SESSIONS_HISTORY_TEXT_MAX_CHARS) };
|
|
38
|
+
}
|
|
39
|
+
if (Array.isArray(rec.content)) {
|
|
40
|
+
return { ...rec, content: rec.content.map(sanitizeHistoryContentBlock) };
|
|
41
|
+
}
|
|
42
|
+
return msg;
|
|
43
|
+
}
|
|
44
|
+
function jsonUtf8Bytes(value) {
|
|
45
|
+
try {
|
|
46
|
+
return Buffer.byteLength(JSON.stringify(value), "utf8");
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return Buffer.byteLength(String(value), "utf8");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function enforceSessionsHistoryHardCap(messages) {
|
|
53
|
+
const sanitized = messages.map(sanitizeHistoryMessage);
|
|
54
|
+
const { items, bytes } = capArrayByJsonBytes(sanitized, SESSIONS_HISTORY_MAX_BYTES);
|
|
55
|
+
const droppedMessages = sanitized.length - items.length;
|
|
56
|
+
// Count how many messages had content truncated by comparing original vs sanitized text.
|
|
57
|
+
let contentTruncated = 0;
|
|
58
|
+
for (let i = 0; i < messages.length; i++) {
|
|
59
|
+
if (jsonUtf8Bytes(messages[i]) !== jsonUtf8Bytes(sanitized[i])) {
|
|
60
|
+
contentTruncated++;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
messages: items,
|
|
65
|
+
truncated: droppedMessages > 0 || contentTruncated > 0,
|
|
66
|
+
droppedMessages,
|
|
67
|
+
contentTruncated,
|
|
68
|
+
bytes,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
12
71
|
function resolveSandboxSessionToolsVisibility(cfg) {
|
|
13
72
|
return cfg.agents?.defaults?.sandbox?.sessionToolsVisibility ?? "spawned";
|
|
14
73
|
}
|
|
@@ -109,9 +168,18 @@ export function createSessionsHistoryTool(opts) {
|
|
|
109
168
|
}));
|
|
110
169
|
const rawMessages = Array.isArray(result?.messages) ? result.messages : [];
|
|
111
170
|
const messages = includeTools ? rawMessages : stripToolMessages(rawMessages);
|
|
171
|
+
const capped = enforceSessionsHistoryHardCap(messages);
|
|
112
172
|
return jsonResult({
|
|
113
173
|
sessionKey: displayKey,
|
|
114
|
-
messages,
|
|
174
|
+
messages: capped.messages,
|
|
175
|
+
...(capped.truncated
|
|
176
|
+
? {
|
|
177
|
+
truncated: true,
|
|
178
|
+
droppedMessages: capped.droppedMessages,
|
|
179
|
+
contentTruncated: capped.contentTruncated,
|
|
180
|
+
bytes: capped.bytes,
|
|
181
|
+
}
|
|
182
|
+
: {}),
|
|
115
183
|
});
|
|
116
184
|
},
|
|
117
185
|
};
|