@poolzin/pool-bot 2026.2.25 → 2026.2.26
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/dist/acp/event-mapper.js +87 -22
- package/dist/acp/meta.js +12 -6
- package/dist/agents/agent-paths.js +8 -9
- package/dist/agents/agent-scope.js +7 -5
- package/dist/agents/auth-profiles/oauth.js +148 -64
- package/dist/agents/auth-profiles/session-override.js +13 -7
- package/dist/agents/bash-tools.exec-host-gateway.js +14 -4
- package/dist/agents/bash-tools.exec-runtime.js +2 -25
- package/dist/agents/bedrock-discovery.js +3 -1
- package/dist/agents/byteplus-models.js +97 -0
- package/dist/agents/chutes-oauth.js +1 -0
- package/dist/agents/cli-runner/helpers.js +4 -0
- package/dist/agents/compaction.js +41 -14
- package/dist/agents/doubao-models.js +121 -0
- package/dist/agents/failover-error.js +2 -0
- package/dist/agents/huggingface-models.js +5 -3
- package/dist/agents/live-model-filter.js +5 -0
- package/dist/agents/minimax-vlm.js +10 -8
- package/dist/agents/model-auth.js +6 -0
- package/dist/agents/model-catalog.js +3 -1
- package/dist/agents/model-selection.js +7 -1
- package/dist/agents/models-config.providers.js +93 -11
- package/dist/agents/ollama-stream.js +117 -4
- package/dist/agents/opencode-zen-models.js +22 -11
- package/dist/agents/pi-embedded-helpers/errors.js +55 -33
- package/dist/agents/pi-embedded-helpers/messaging-dedupe.js +10 -5
- package/dist/agents/pi-embedded-helpers/thinking.js +10 -5
- package/dist/agents/pi-embedded-helpers.js +1 -1
- package/dist/agents/pi-embedded-runner/compact.js +29 -7
- package/dist/agents/pi-embedded-runner/extensions.js +28 -26
- package/dist/agents/pi-embedded-runner/google.js +20 -8
- package/dist/agents/pi-embedded-runner/run/attempt.js +95 -36
- package/dist/agents/pi-embedded-runner/run.js +71 -12
- package/dist/agents/pi-embedded-runner/run.overflow-compaction.mocks.shared.js +11 -2
- package/dist/agents/pi-embedded-runner/session-manager-cache.js +11 -7
- package/dist/agents/pi-embedded-runner/system-prompt.js +2 -0
- package/dist/agents/pi-embedded-runner/thinking.js +42 -0
- package/dist/agents/pi-embedded-runner/tool-name-allowlist.js +19 -0
- package/dist/agents/pi-embedded-runner/utils.js +7 -10
- package/dist/agents/pi-embedded-subscribe.handlers.lifecycle.js +45 -56
- package/dist/agents/pi-embedded-subscribe.handlers.tools.js +2 -2
- package/dist/agents/pi-embedded-subscribe.js +9 -4
- package/dist/agents/pi-embedded-subscribe.tools.js +68 -14
- package/dist/agents/pi-embedded-utils.js +3 -0
- package/dist/agents/pi-extensions/compaction-safeguard-runtime.js +4 -20
- package/dist/agents/pi-extensions/compaction-safeguard.js +75 -33
- package/dist/agents/pi-settings.js +40 -0
- package/dist/agents/pi-tools.policy.js +2 -1
- package/dist/agents/provider/config-loader.js +1 -1
- package/dist/agents/sandbox/browser.js +170 -33
- package/dist/agents/sandbox/config-hash.js +14 -27
- package/dist/agents/sandbox/config.js +21 -2
- package/dist/agents/sandbox/constants.js +2 -0
- package/dist/agents/sandbox/docker.js +16 -2
- package/dist/agents/sandbox/novnc-auth.js +62 -0
- package/dist/agents/sandbox/sanitize-env-vars.js +1 -1
- package/dist/agents/sandbox/shared.js +10 -6
- package/dist/agents/sandbox-paths.js +24 -11
- package/dist/agents/schema/clean-for-gemini.js +132 -85
- package/dist/agents/session-slug.js +10 -5
- package/dist/agents/session-tool-result-guard-wrapper.js +1 -0
- package/dist/agents/session-tool-result-guard.js +3 -1
- package/dist/agents/session-transcript-repair.js +40 -6
- package/dist/agents/skills/bundled-dir.js +19 -5
- package/dist/agents/skills/env-overrides.js +124 -43
- package/dist/agents/skills/frontmatter.js +6 -6
- package/dist/agents/skills/plugin-skills.js +14 -7
- package/dist/agents/skills/workspace.js +1 -0
- package/dist/agents/subagent-announce.js +251 -49
- package/dist/agents/subagent-lifecycle-events.js +19 -0
- package/dist/agents/subagent-registry-cleanup.js +31 -0
- package/dist/agents/subagent-registry-completion.js +68 -0
- package/dist/agents/subagent-registry-queries.js +117 -0
- package/dist/agents/subagent-registry-state.js +46 -0
- package/dist/agents/subagent-registry.js +252 -221
- package/dist/agents/subagent-registry.store.js +1 -0
- package/dist/agents/subagent-registry.types.js +1 -0
- package/dist/agents/subagent-spawn.js +195 -7
- package/dist/agents/system-prompt.js +22 -6
- package/dist/agents/test-helpers/fast-coding-tools.js +1 -18
- package/dist/agents/test-helpers/fast-core-tools.js +1 -17
- package/dist/agents/timeout.js +18 -6
- package/dist/agents/tool-call-id.js +1 -1
- package/dist/agents/tool-display-common.js +162 -29
- package/dist/agents/tool-images.js +82 -9
- package/dist/agents/tool-policy.js +51 -26
- package/dist/agents/tools/browser-tool.js +2 -2
- package/dist/agents/tools/canvas-tool.js +27 -1
- package/dist/agents/tools/common.js +45 -0
- package/dist/agents/tools/discord-actions-guild.js +4 -1
- package/dist/agents/tools/gateway-tool.js +3 -1
- package/dist/agents/tools/nodes-utils.js +1 -10
- package/dist/agents/tools/sessions-send-helpers.js +12 -6
- package/dist/agents/tools/sessions-spawn-tool.js +8 -2
- package/dist/agents/tools/subagents-tool.js +2 -1
- package/dist/agents/tools/whatsapp-actions.js +10 -2
- package/dist/agents/tools/whatsapp-target-auth.js +18 -0
- package/dist/agents/transcript-policy.js +22 -8
- package/dist/agents/venice-models.js +11 -3
- package/dist/auto-reply/commands-registry.data.js +51 -0
- package/dist/auto-reply/commands-registry.js +4 -3
- package/dist/auto-reply/group-activation.js +10 -5
- package/dist/auto-reply/inbound-debounce.js +10 -5
- package/dist/auto-reply/reply/abort.js +1 -1
- package/dist/auto-reply/reply/agent-runner-execution.js +4 -1
- package/dist/auto-reply/reply/bash-command.js +41 -39
- package/dist/auto-reply/reply/command-gates.js +25 -0
- package/dist/auto-reply/reply/commands-allowlist.js +111 -72
- package/dist/auto-reply/reply/commands-bash.js +6 -5
- package/dist/auto-reply/reply/commands-config.js +30 -28
- package/dist/auto-reply/reply/commands-core.js +2 -1
- package/dist/auto-reply/reply/commands-info.js +1 -0
- package/dist/auto-reply/reply/commands-models.js +65 -14
- package/dist/auto-reply/reply/commands-session.js +237 -82
- package/dist/auto-reply/reply/commands-setunset.js +45 -0
- package/dist/auto-reply/reply/commands-subagents/action-agents.js +44 -0
- package/dist/auto-reply/reply/commands-subagents/action-focus.js +64 -0
- package/dist/auto-reply/reply/commands-subagents/action-help.js +4 -0
- package/dist/auto-reply/reply/commands-subagents/action-info.js +45 -0
- package/dist/auto-reply/reply/commands-subagents/action-kill.js +60 -0
- package/dist/auto-reply/reply/commands-subagents/action-list.js +44 -0
- package/dist/auto-reply/reply/commands-subagents/action-log.js +29 -0
- package/dist/auto-reply/reply/commands-subagents/action-send.js +119 -0
- package/dist/auto-reply/reply/commands-subagents/action-spawn.js +52 -0
- package/dist/auto-reply/reply/commands-subagents/action-unfocus.js +30 -0
- package/dist/auto-reply/reply/commands-subagents/shared.js +303 -0
- package/dist/auto-reply/reply/commands-subagents.js +51 -587
- package/dist/auto-reply/reply/commands-tts.js +10 -5
- package/dist/auto-reply/reply/config-value.js +10 -5
- package/dist/auto-reply/reply/directive-handling.model-picker.js +12 -6
- package/dist/auto-reply/reply/directive-handling.persist.js +9 -21
- package/dist/auto-reply/reply/directive-handling.shared.js +24 -4
- package/dist/auto-reply/reply/followup-runner.js +1 -0
- package/dist/auto-reply/reply/get-reply-directives-utils.js +23 -14
- package/dist/auto-reply/reply/get-reply-directives.js +17 -28
- package/dist/auto-reply/reply/get-reply-inline-actions.js +1 -0
- package/dist/auto-reply/reply/get-reply.js +71 -12
- package/dist/auto-reply/reply/model-selection.js +80 -39
- package/dist/auto-reply/reply/queue/enqueue.js +10 -5
- package/dist/auto-reply/reply/queue/state.js +13 -12
- package/dist/auto-reply/reply/reply-payloads.js +67 -36
- package/dist/auto-reply/reply/reply-reference.js +9 -8
- package/dist/auto-reply/reply/route-reply.js +15 -8
- package/dist/auto-reply/reply/session-reset-prompt.js +1 -1
- package/dist/auto-reply/reply/session.js +22 -6
- package/dist/auto-reply/reply/strip-inbound-meta.js +147 -0
- package/dist/auto-reply/reply/subagents-utils.js +56 -30
- package/dist/auto-reply/reply/typing.js +46 -21
- package/dist/auto-reply/send-policy.js +14 -7
- package/dist/auto-reply/status.js +140 -16
- package/dist/auto-reply/templating.js +10 -5
- package/dist/auto-reply/thinking.js +7 -16
- package/dist/auto-reply/tokens.js +21 -5
- package/dist/browser/bridge-server.js +36 -20
- package/dist/browser/cdp.helpers.js +7 -14
- package/dist/browser/cdp.js +35 -15
- package/dist/browser/chrome.profile-decoration.js +7 -4
- package/dist/browser/config.js +4 -0
- package/dist/browser/extension-relay-auth.js +55 -0
- package/dist/browser/extension-relay.js +74 -29
- package/dist/browser/navigation-guard.js +9 -1
- package/dist/browser/paths.js +77 -0
- package/dist/browser/profiles.js +13 -8
- package/dist/browser/pw-ai-module.js +10 -5
- package/dist/browser/pw-session.js +76 -39
- package/dist/browser/pw-tools-core.interactions.js +14 -7
- package/dist/browser/pw-tools-core.state.js +12 -6
- package/dist/browser/routes/agent.act.js +2 -2
- package/dist/browser/server-context.js +7 -0
- package/dist/build-info.json +3 -3
- package/dist/channels/allow-from.js +2 -1
- package/dist/channels/allowlists/resolve-utils.js +43 -19
- package/dist/channels/channel-config.js +14 -7
- package/dist/channels/draft-stream-loop.js +7 -0
- package/dist/channels/model-overrides.js +82 -0
- package/dist/channels/plugins/normalize/imessage.js +14 -7
- package/dist/channels/plugins/normalize/slack.js +10 -5
- package/dist/channels/plugins/normalize/telegram.js +14 -7
- package/dist/channels/plugins/outbound/discord.js +80 -8
- package/dist/channels/plugins/outbound/signal.js +11 -11
- package/dist/channels/plugins/setup-helpers.js +10 -5
- package/dist/channels/sender-label.js +14 -7
- package/dist/channels/session.js +4 -2
- package/dist/channels/status-reactions.js +297 -0
- package/dist/cli/banner.js +1 -1
- package/dist/cli/browser-cli-actions-input/register.files-downloads.js +65 -56
- package/dist/cli/cli-name.js +11 -11
- package/dist/cli/cli-utils.js +13 -3
- package/dist/cli/command-format.js +1 -1
- package/dist/cli/config-cli.js +1 -1
- package/dist/cli/daemon-cli/lifecycle-core.js +31 -19
- package/dist/cli/daemon-cli/lifecycle.js +64 -2
- package/dist/cli/daemon-cli/restart-health.js +126 -0
- package/dist/cli/daemon-cli/status.gather.js +9 -13
- package/dist/cli/daemon-cli/status.print.js +2 -10
- package/dist/cli/deps.js +27 -22
- package/dist/cli/gateway-cli/run-loop.js +23 -5
- package/dist/cli/node-cli/register.js +14 -5
- package/dist/cli/nodes-media-utils.js +7 -2
- package/dist/cli/outbound-send-deps.js +2 -9
- package/dist/cli/outbound-send-mapping.js +11 -0
- package/dist/cli/pairing-cli.js +40 -14
- package/dist/cli/plugins-cli.js +34 -41
- package/dist/cli/ports.js +11 -10
- package/dist/cli/program/command-registry.js +2 -11
- package/dist/cli/program/command-tree.js +16 -0
- package/dist/cli/program/preaction.js +13 -9
- package/dist/cli/program/register.configure.js +3 -18
- package/dist/cli/program/register.maintenance.js +2 -2
- package/dist/cli/program/register.onboard.js +2 -0
- package/dist/cli/program/register.status-health-sessions.js +16 -17
- package/dist/cli/program/register.subclis.js +93 -52
- package/dist/cli/route.js +11 -7
- package/dist/cli/system-cli.js +36 -46
- package/dist/cli/update-cli/shared.js +22 -9
- package/dist/cli/update-cli/update-command.js +89 -14
- package/dist/cli/update-cli/wizard.js +6 -12
- package/dist/commands/agent/run-context.js +18 -5
- package/dist/commands/agent/session-store.js +17 -4
- package/dist/commands/agent.js +22 -2
- package/dist/commands/agents.bindings.js +14 -7
- package/dist/commands/agents.commands.add.js +13 -9
- package/dist/commands/agents.commands.identity.js +12 -6
- package/dist/commands/agents.commands.list.js +11 -6
- package/dist/commands/agents.config.js +8 -10
- package/dist/commands/agents.providers.js +12 -6
- package/dist/commands/auth-choice-options.js +103 -75
- package/dist/commands/auth-choice.apply.byteplus.js +55 -0
- package/dist/commands/auth-choice.apply.js +4 -0
- package/dist/commands/auth-choice.apply.minimax.js +61 -13
- package/dist/commands/auth-choice.apply.openai.js +3 -1
- package/dist/commands/auth-choice.apply.volcengine.js +55 -0
- package/dist/commands/auth-choice.preferred-provider.js +2 -0
- package/dist/commands/channels/remove.js +13 -6
- package/dist/commands/channels/shared.js +4 -14
- package/dist/commands/configure.commands.js +14 -0
- package/dist/commands/configure.gateway.js +2 -4
- package/dist/commands/configure.js +1 -1
- package/dist/commands/configure.shared.js +11 -0
- package/dist/commands/daemon-install-helpers.js +2 -2
- package/dist/commands/dashboard.js +12 -10
- package/dist/commands/docs.js +14 -8
- package/dist/commands/doctor-config-flow.js +11 -9
- package/dist/commands/doctor-legacy-config.js +281 -0
- package/dist/commands/doctor-state-integrity.js +99 -23
- package/dist/commands/doctor-update.js +12 -9
- package/dist/commands/models/list.list-command.js +7 -5
- package/dist/commands/models/set-image.js +2 -21
- package/dist/commands/node-daemon-install-helpers.js +10 -8
- package/dist/commands/onboard-auth.config-minimax.js +54 -80
- package/dist/commands/onboard-auth.config-opencode.js +2 -18
- package/dist/commands/onboard-auth.credentials.js +90 -13
- package/dist/commands/onboard-auth.js +1 -1
- package/dist/commands/onboard-auth.models.js +6 -5
- package/dist/commands/onboard-hooks.js +1 -1
- package/dist/commands/onboard-non-interactive/api-keys.js +14 -7
- package/dist/commands/onboard-non-interactive/local/auth-choice.js +64 -49
- package/dist/commands/onboard-provider-auth-flags.js +14 -0
- package/dist/commands/onboard-remote.js +14 -7
- package/dist/commands/onboard.js +11 -13
- package/dist/commands/sandbox-display.js +6 -5
- package/dist/commands/status-all/diagnosis.js +14 -10
- package/dist/commands/status-all/format.js +1 -0
- package/dist/commands/status.gateway-probe.js +1 -16
- package/dist/commands/systemd-linger.js +12 -6
- package/dist/config/agent-limits.js +2 -0
- package/dist/config/commands.js +30 -16
- package/dist/config/config-paths.js +9 -11
- package/dist/config/defaults.js +22 -2
- package/dist/config/discord-preview-streaming.js +104 -0
- package/dist/config/env-vars.js +37 -8
- package/dist/config/includes.js +4 -0
- package/dist/config/io.js +97 -12
- package/dist/config/legacy.migrations.part-1.js +189 -78
- package/dist/config/legacy.shared.js +3 -1
- package/dist/config/merge-patch.js +4 -0
- package/dist/config/prototype-keys.js +4 -0
- package/dist/config/schema.help.js +44 -7
- package/dist/config/schema.labels.js +38 -6
- package/dist/config/sessions/delivery-info.js +10 -3
- package/dist/config/sessions/main-session.js +10 -5
- package/dist/config/sessions/session-file.js +33 -0
- package/dist/config/sessions/session-key.js +10 -5
- package/dist/config/sessions/store.js +1 -1
- package/dist/config/sessions.js +1 -0
- package/dist/config/zod-schema.agent-runtime.js +11 -0
- package/dist/config/zod-schema.js +148 -13
- package/dist/config/zod-schema.providers-core.js +78 -4
- package/dist/config/zod-schema.providers.js +6 -1
- package/dist/config/zod-schema.session.js +41 -2
- package/dist/cron/run-log.js +3 -0
- package/dist/cron/schedule.js +21 -10
- package/dist/cron/service/ops.js +35 -21
- package/dist/cron/service/timer.js +116 -16
- package/dist/cron/stagger.js +3 -1
- package/dist/discord/api.js +12 -6
- package/dist/discord/draft-chunking.js +22 -0
- package/dist/discord/draft-stream.js +124 -0
- package/dist/discord/monitor/agent-components.js +1 -1
- package/dist/discord/monitor/commands.js +5 -0
- package/dist/discord/monitor/gateway-plugin.js +2 -1
- package/dist/discord/monitor/listeners.js +37 -27
- package/dist/discord/monitor/message-handler.js +4 -1
- package/dist/discord/monitor/message-handler.preflight.js +65 -8
- package/dist/discord/monitor/message-handler.process.js +246 -217
- package/dist/discord/monitor/message-utils.js +143 -6
- package/dist/discord/monitor/model-picker-preferences.js +143 -0
- package/dist/discord/monitor/model-picker.js +651 -0
- package/dist/discord/monitor/native-command.js +573 -16
- package/dist/discord/monitor/provider.allowlist.js +223 -0
- package/dist/discord/monitor/provider.js +275 -347
- package/dist/discord/monitor/provider.lifecycle.js +100 -0
- package/dist/discord/monitor/reply-delivery.js +123 -16
- package/dist/discord/monitor/thread-bindings.discord-api.js +215 -0
- package/dist/discord/monitor/thread-bindings.js +4 -0
- package/dist/discord/monitor/thread-bindings.lifecycle.js +177 -0
- package/dist/discord/monitor/thread-bindings.manager.js +423 -0
- package/dist/discord/monitor/thread-bindings.messages.js +55 -0
- package/dist/discord/monitor/thread-bindings.state.js +358 -0
- package/dist/discord/monitor/thread-bindings.types.js +6 -0
- package/dist/discord/resolve-users.js +33 -21
- package/dist/discord/send.channels.js +15 -0
- package/dist/discord/send.js +3 -2
- package/dist/discord/send.outbound.js +82 -26
- package/dist/discord/send.permissions.js +83 -30
- package/dist/discord/send.reactions.js +8 -4
- package/dist/discord/token.js +10 -5
- package/dist/discord/voice/command.js +263 -0
- package/dist/discord/voice/manager.js +531 -0
- package/dist/gateway/auth.js +34 -10
- package/dist/gateway/call.js +4 -16
- package/dist/gateway/client.js +28 -4
- package/dist/gateway/config-reload.js +3 -4
- package/dist/gateway/control-ui.js +219 -96
- package/dist/gateway/hooks-mapping.js +88 -38
- package/dist/gateway/http-auth-helpers.js +3 -2
- package/dist/gateway/http-endpoint-helpers.js +1 -0
- package/dist/gateway/net.js +54 -12
- package/dist/gateway/node-invoke-system-run-approval.js +14 -35
- package/dist/gateway/node-registry.js +10 -5
- package/dist/gateway/openai-http.js +1 -0
- package/dist/gateway/openresponses-http.js +1 -0
- package/dist/gateway/origin-check.js +1 -18
- package/dist/gateway/protocol/index.js +4 -3
- package/dist/gateway/protocol/schema/cron.js +1 -0
- package/dist/gateway/protocol/schema/devices.js +1 -0
- package/dist/gateway/protocol/schema/protocol-schemas.js +2 -1
- package/dist/gateway/protocol/schema/sessions.js +6 -0
- package/dist/gateway/role-policy.js +17 -0
- package/dist/gateway/server/ws-connection/connect-policy.js +37 -0
- package/dist/gateway/server/ws-connection/message-handler.js +175 -148
- package/dist/gateway/server-chat.js +83 -25
- package/dist/gateway/server-constants.js +10 -9
- package/dist/gateway/server-cron.js +1 -0
- package/dist/gateway/server-http.js +16 -7
- package/dist/gateway/server-maintenance.js +20 -5
- package/dist/gateway/server-methods/chat.js +10 -6
- package/dist/gateway/server-methods/config.js +12 -14
- package/dist/gateway/server-methods/devices.js +17 -3
- package/dist/gateway/server-methods/models.js +11 -1
- package/dist/gateway/server-methods/sessions.js +64 -8
- package/dist/gateway/server-methods/usage.js +162 -75
- package/dist/gateway/server-node-events.js +29 -0
- package/dist/gateway/server-runtime-config.js +34 -13
- package/dist/gateway/server-startup-memory.js +17 -11
- package/dist/gateway/session-utils.fs.js +32 -34
- package/dist/gateway/sessions-resolve.js +17 -5
- package/dist/gateway/test-helpers.openai-mock.js +14 -7
- package/dist/gateway/tools-invoke-http.js +21 -10
- package/dist/hooks/bundled/bootstrap-extra-files/handler.js +3 -1
- package/dist/hooks/bundled/command-logger/handler.js +7 -2
- package/dist/hooks/bundled/session-memory/handler.js +6 -5
- package/dist/hooks/frontmatter.js +6 -6
- package/dist/hooks/gmail-watcher.js +11 -6
- package/dist/hooks/internal-hooks.js +11 -1
- package/dist/hooks/llm-slug-generator.js +4 -1
- package/dist/hooks/workspace.js +47 -17
- package/dist/imessage/accounts.js +9 -20
- package/dist/imessage/monitor/inbound-processing.js +2 -1
- package/dist/infra/archive.js +174 -73
- package/dist/infra/control-ui-assets.js +14 -6
- package/dist/infra/device-pairing.js +108 -29
- package/dist/infra/env.js +10 -5
- package/dist/infra/exec-approvals-allowlist.js +122 -0
- package/dist/infra/exec-approvals-analysis.js +34 -3
- package/dist/infra/exec-approvals.js +5 -17
- package/dist/infra/exec-safe-bin-policy.js +53 -45
- package/dist/infra/fs-safe.js +71 -39
- package/dist/infra/gateway-lock.js +6 -2
- package/dist/infra/heartbeat-wake.js +6 -12
- package/dist/infra/host-env-security-policy.json +19 -0
- package/dist/infra/host-env-security.js +66 -0
- package/dist/infra/net/ssrf.js +131 -38
- package/dist/infra/outbound/bound-delivery-router.js +88 -0
- package/dist/infra/outbound/channel-selection.js +12 -6
- package/dist/infra/outbound/envelope.js +1 -1
- package/dist/infra/outbound/format.js +12 -6
- package/dist/infra/outbound/payloads.js +14 -7
- package/dist/infra/outbound/session-binding-service.js +123 -0
- package/dist/infra/path-guards.js +25 -0
- package/dist/infra/provider-usage.fetch.codex.js +7 -15
- package/dist/infra/provider-usage.fetch.gemini.js +14 -11
- package/dist/infra/provider-usage.fetch.shared.js +30 -1
- package/dist/infra/provider-usage.fetch.zai.js +10 -9
- package/dist/infra/retry-policy.js +4 -2
- package/dist/infra/retry.js +9 -5
- package/dist/infra/session-cost-usage.js +107 -59
- package/dist/infra/session-maintenance-warning.js +3 -1
- package/dist/infra/shell-env.js +98 -34
- package/dist/infra/ssh-config.js +12 -6
- package/dist/infra/system-run-command.js +49 -4
- package/dist/infra/update-channels.js +10 -5
- package/dist/line/accounts.js +5 -7
- package/dist/line/bot-access.js +8 -20
- package/dist/line/bot-handlers.js +3 -1
- package/dist/link-understanding/detect.js +15 -7
- package/dist/media/constants.js +15 -6
- package/dist/media/image-ops.js +7 -0
- package/dist/media/local-roots.js +3 -2
- package/dist/media-understanding/apply.js +4 -1
- package/dist/media-understanding/concurrency.js +8 -20
- package/dist/memory/backend-config.js +45 -6
- package/dist/memory/embeddings.js +10 -4
- package/dist/memory/fs-utils.js +23 -0
- package/dist/memory/manager-search.js +12 -6
- package/dist/memory/manager-sync-ops.js +12 -2
- package/dist/memory/qmd-manager.js +466 -53
- package/dist/memory/query-expansion.js +167 -3
- package/dist/memory/status-format.js +10 -5
- package/dist/memory/sync-memory-files.js +1 -1
- package/dist/node-host/invoke-system-run.js +281 -0
- package/dist/node-host/invoke.js +55 -337
- package/dist/pairing/pairing-store.js +22 -0
- package/dist/plugin-sdk/allow-from.js +1 -1
- package/dist/plugin-sdk/command-auth.js +3 -1
- package/dist/plugin-sdk/index.js +6 -3
- package/dist/plugin-sdk/webhook-targets.js +32 -0
- package/dist/plugins/bundled-dir.js +9 -6
- package/dist/plugins/hooks.js +50 -0
- package/dist/plugins/install.js +28 -16
- package/dist/plugins/runtime.js +3 -17
- package/dist/plugins/update.js +78 -12
- package/dist/process/spawn-utils.js +14 -7
- package/dist/providers/github-copilot-token.js +11 -6
- package/dist/providers/qwen-portal-oauth.js +14 -6
- package/dist/routing/account-id.js +30 -0
- package/dist/routing/resolve-route.js +3 -7
- package/dist/routing/session-key.js +2 -16
- package/dist/security/audit-channel.js +93 -2
- package/dist/security/audit-extra.async.js +159 -5
- package/dist/security/audit-extra.js +1 -1
- package/dist/security/audit-extra.sync.js +85 -6
- package/dist/security/audit.js +40 -4
- package/dist/security/dm-policy-shared.js +44 -0
- package/dist/security/external-content.js +26 -6
- package/dist/shared/entry-status.js +6 -0
- package/dist/shared/frontmatter.js +5 -5
- package/dist/shared/node-match.js +11 -4
- package/dist/shared/operator-scope-compat.js +8 -3
- package/dist/signal/accounts.js +7 -20
- package/dist/signal/monitor/event-handler.js +3 -1
- package/dist/slack/accounts.js +6 -19
- package/dist/slack/actions.js +11 -3
- package/dist/slack/monitor/auth.js +1 -1
- package/dist/slack/monitor/message-handler/dispatch.js +50 -29
- package/dist/slack/monitor/replies.js +15 -7
- package/dist/slack/monitor/slash.js +22 -13
- package/dist/slack/resolve-channels.js +10 -5
- package/dist/slack/send.js +102 -12
- package/dist/slack/stream-mode.js +10 -0
- package/dist/slack/streaming.js +4 -2
- package/dist/telegram/accounts.js +19 -14
- package/dist/telegram/bot/helpers.js +3 -5
- package/dist/telegram/bot-access.js +35 -36
- package/dist/telegram/bot-handlers.js +120 -148
- package/dist/telegram/bot-message-context.js +68 -9
- package/dist/telegram/bot-message-dispatch.js +155 -90
- package/dist/telegram/bot-native-commands.js +16 -0
- package/dist/telegram/draft-stream.js +14 -1
- package/dist/telegram/inline-buttons.js +5 -15
- package/dist/telegram/monitor.js +11 -7
- package/dist/telegram/network-config.js +19 -7
- package/dist/telegram/send.js +3 -2
- package/dist/telegram/sent-message-cache.js +5 -6
- package/dist/telegram/status-reaction-variants.js +208 -0
- package/dist/telegram/sticker-cache.js +11 -9
- package/dist/terminal/theme.js +12 -12
- package/dist/tts/tts.js +80 -567
- package/dist/tui/components/chat-log.js +41 -8
- package/dist/tui/theme/theme.js +10 -12
- package/dist/tui/tui-local-shell.js +16 -6
- package/dist/tui/tui.js +58 -6
- package/dist/utils/account-id.js +2 -4
- package/dist/utils/boolean.js +10 -5
- package/dist/utils/directive-tags.js +11 -0
- package/dist/utils/queue-helpers.js +67 -12
- package/dist/web/auto-reply/deliver-reply.js +8 -4
- package/dist/web/auto-reply/mentions.js +10 -5
- package/dist/web/auto-reply/monitor/group-members.js +14 -7
- package/dist/web/auto-reply/monitor/process-message.js +45 -24
- package/dist/web/inbound/access-control.js +5 -2
- package/dist/web/login-qr.js +12 -6
- package/dist/web/media.js +123 -16
- package/extensions/bluebubbles/src/monitor-processing.ts +580 -139
- package/extensions/bluebubbles/src/monitor.ts +208 -1950
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
|
-
import { addAllowlistEntry, buildSafeBinsShellCommand, buildSafeShellCommand, evaluateShellAllowlist, maxAsk, minSecurity, recordAllowlistUse, requiresExecApproval, resolveExecApprovals, } from "../infra/exec-approvals.js";
|
|
2
|
+
import { addAllowlistEntry, buildSafeBinsShellCommand, buildSafeShellCommand, evaluateShellAllowlist, maxAsk, minSecurity, recordAllowlistUse, requiresExecApproval, resolveAllowAlwaysPatterns, resolveExecApprovals, } from "../infra/exec-approvals.js";
|
|
3
3
|
import { markBackgrounded, tail } from "./bash-process-registry.js";
|
|
4
4
|
import { requestExecApprovalDecision } from "./bash-tools.exec-approval-request.js";
|
|
5
5
|
import { DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_NOTIFY_TAIL_CHARS, createApprovalSlug, emitExecSystemEvent, normalizeNotifyOutput, runExecProcess, } from "./bash-tools.exec-runtime.js";
|
|
@@ -26,12 +26,17 @@ export async function processGatewayAllowlist(params) {
|
|
|
26
26
|
const allowlistMatches = allowlistEval.allowlistMatches;
|
|
27
27
|
const analysisOk = allowlistEval.analysisOk;
|
|
28
28
|
const allowlistSatisfied = hostSecurity === "allowlist" && analysisOk ? allowlistEval.allowlistSatisfied : false;
|
|
29
|
+
const hasHeredocSegment = allowlistEval.segments.some((segment) => segment.argv.some((token) => token.startsWith("<<")));
|
|
30
|
+
const requiresHeredocApproval = hostSecurity === "allowlist" && analysisOk && allowlistSatisfied && hasHeredocSegment;
|
|
29
31
|
const requiresAsk = requiresExecApproval({
|
|
30
32
|
ask: hostAsk,
|
|
31
33
|
security: hostSecurity,
|
|
32
34
|
analysisOk,
|
|
33
35
|
allowlistSatisfied,
|
|
34
|
-
});
|
|
36
|
+
}) || requiresHeredocApproval;
|
|
37
|
+
if (requiresHeredocApproval) {
|
|
38
|
+
params.warnings.push("Warning: heredoc execution requires explicit approval in allowlist mode.");
|
|
39
|
+
}
|
|
35
40
|
if (requiresAsk) {
|
|
36
41
|
const approvalId = crypto.randomUUID();
|
|
37
42
|
const approvalSlug = createApprovalSlug(approvalId);
|
|
@@ -90,8 +95,13 @@ export async function processGatewayAllowlist(params) {
|
|
|
90
95
|
else if (decision === "allow-always") {
|
|
91
96
|
approvedByAsk = true;
|
|
92
97
|
if (hostSecurity === "allowlist") {
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
const patterns = resolveAllowAlwaysPatterns({
|
|
99
|
+
segments: allowlistEval.segments,
|
|
100
|
+
cwd: params.workdir,
|
|
101
|
+
env: params.env,
|
|
102
|
+
platform: process.platform,
|
|
103
|
+
});
|
|
104
|
+
for (const pattern of patterns) {
|
|
95
105
|
if (pattern) {
|
|
96
106
|
addAllowlistEntry(approvals.file, params.agentId, pattern);
|
|
97
107
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { Type } from "@sinclair/typebox";
|
|
3
3
|
import { requestHeartbeatNow } from "../infra/heartbeat-wake.js";
|
|
4
|
+
import { isDangerousHostEnvVarName } from "../infra/host-env-security.js";
|
|
4
5
|
import { mergePathPrepend } from "../infra/path-prepend.js";
|
|
5
6
|
import { enqueueSystemEvent } from "../infra/system-events.js";
|
|
6
7
|
export { applyPathPrepend, normalizePathPrepend } from "../infra/path-prepend.js";
|
|
@@ -10,37 +11,13 @@ import { addSession, appendOutput, createSessionSlug, markExited, tail, } from "
|
|
|
10
11
|
import { buildDockerExecArgs, chunkString, clampWithDefault, readEnvInt, } from "./bash-tools.shared.js";
|
|
11
12
|
import { buildCursorPositionResponse, stripDsrRequests } from "./pty-dsr.js";
|
|
12
13
|
import { getShellConfig, sanitizeBinaryOutput } from "./shell-utils.js";
|
|
13
|
-
// Security: Blocklist of environment variables that could alter execution flow
|
|
14
|
-
// or inject code when running on non-sandboxed hosts (Gateway/Node).
|
|
15
|
-
const DANGEROUS_HOST_ENV_VARS = new Set([
|
|
16
|
-
"LD_PRELOAD",
|
|
17
|
-
"LD_LIBRARY_PATH",
|
|
18
|
-
"LD_AUDIT",
|
|
19
|
-
"DYLD_INSERT_LIBRARIES",
|
|
20
|
-
"DYLD_LIBRARY_PATH",
|
|
21
|
-
"NODE_OPTIONS",
|
|
22
|
-
"NODE_PATH",
|
|
23
|
-
"PYTHONPATH",
|
|
24
|
-
"PYTHONHOME",
|
|
25
|
-
"RUBYLIB",
|
|
26
|
-
"PERL5LIB",
|
|
27
|
-
"BASH_ENV",
|
|
28
|
-
"ENV",
|
|
29
|
-
"GCONV_PATH",
|
|
30
|
-
"IFS",
|
|
31
|
-
"SSLKEYLOGFILE",
|
|
32
|
-
]);
|
|
33
|
-
const DANGEROUS_HOST_ENV_PREFIXES = ["DYLD_", "LD_"];
|
|
34
14
|
// Centralized sanitization helper.
|
|
35
15
|
// Throws an error if dangerous variables or PATH modifications are detected on the host.
|
|
36
16
|
export function validateHostEnv(env) {
|
|
37
17
|
for (const key of Object.keys(env)) {
|
|
38
18
|
const upperKey = key.toUpperCase();
|
|
39
19
|
// 1. Block known dangerous variables (Fail Closed)
|
|
40
|
-
if (
|
|
41
|
-
throw new Error(`Security Violation: Environment variable '${key}' is forbidden during host execution.`);
|
|
42
|
-
}
|
|
43
|
-
if (DANGEROUS_HOST_ENV_VARS.has(upperKey)) {
|
|
20
|
+
if (isDangerousHostEnvVarName(upperKey)) {
|
|
44
21
|
throw new Error(`Security Violation: Environment variable '${key}' is forbidden during host execution.`);
|
|
45
22
|
}
|
|
46
23
|
// 2. Strictly block PATH modification on host
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { BedrockClient, ListFoundationModelsCommand, } from "@aws-sdk/client-bedrock";
|
|
2
|
+
import { createSubsystemLogger } from "../logging/subsystem.js";
|
|
3
|
+
const log = createSubsystemLogger("bedrock-discovery");
|
|
2
4
|
const DEFAULT_REFRESH_INTERVAL_SECONDS = 3600;
|
|
3
5
|
const DEFAULT_CONTEXT_WINDOW = 32000;
|
|
4
6
|
const DEFAULT_MAX_TOKENS = 4096;
|
|
@@ -150,7 +152,7 @@ export async function discoverBedrockModels(params) {
|
|
|
150
152
|
}
|
|
151
153
|
if (!hasLoggedBedrockError) {
|
|
152
154
|
hasLoggedBedrockError = true;
|
|
153
|
-
|
|
155
|
+
log.warn(`Failed to list models: ${String(error)}`);
|
|
154
156
|
}
|
|
155
157
|
return [];
|
|
156
158
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export const BYTEPLUS_BASE_URL = "https://ark.ap-southeast.bytepluses.com/api/v3";
|
|
2
|
+
export const BYTEPLUS_CODING_BASE_URL = "https://ark.ap-southeast.bytepluses.com/api/coding/v3";
|
|
3
|
+
export const BYTEPLUS_DEFAULT_MODEL_ID = "seed-1-8-251228";
|
|
4
|
+
export const BYTEPLUS_CODING_DEFAULT_MODEL_ID = "ark-code-latest";
|
|
5
|
+
export const BYTEPLUS_DEFAULT_MODEL_REF = `byteplus/${BYTEPLUS_DEFAULT_MODEL_ID}`;
|
|
6
|
+
// BytePlus pricing (approximate, adjust based on actual pricing)
|
|
7
|
+
export const BYTEPLUS_DEFAULT_COST = {
|
|
8
|
+
input: 0.0001, // $0.0001 per 1K tokens
|
|
9
|
+
output: 0.0002, // $0.0002 per 1K tokens
|
|
10
|
+
cacheRead: 0,
|
|
11
|
+
cacheWrite: 0,
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Complete catalog of BytePlus ARK models.
|
|
15
|
+
*
|
|
16
|
+
* BytePlus ARK provides access to various models
|
|
17
|
+
* through the ARK API. Authentication requires a BYTEPLUS_API_KEY.
|
|
18
|
+
*/
|
|
19
|
+
export const BYTEPLUS_MODEL_CATALOG = [
|
|
20
|
+
{
|
|
21
|
+
id: "seed-1-8-251228",
|
|
22
|
+
name: "Seed 1.8",
|
|
23
|
+
reasoning: false,
|
|
24
|
+
input: ["text", "image"],
|
|
25
|
+
contextWindow: 256000,
|
|
26
|
+
maxTokens: 4096,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "kimi-k2-5-260127",
|
|
30
|
+
name: "Kimi K2.5",
|
|
31
|
+
reasoning: false,
|
|
32
|
+
input: ["text", "image"],
|
|
33
|
+
contextWindow: 256000,
|
|
34
|
+
maxTokens: 4096,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: "glm-4-7-251222",
|
|
38
|
+
name: "GLM 4.7",
|
|
39
|
+
reasoning: false,
|
|
40
|
+
input: ["text", "image"],
|
|
41
|
+
contextWindow: 200000,
|
|
42
|
+
maxTokens: 4096,
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
export function buildBytePlusModelDefinition(entry) {
|
|
46
|
+
return {
|
|
47
|
+
id: entry.id,
|
|
48
|
+
name: entry.name,
|
|
49
|
+
reasoning: entry.reasoning,
|
|
50
|
+
input: [...entry.input],
|
|
51
|
+
cost: BYTEPLUS_DEFAULT_COST,
|
|
52
|
+
contextWindow: entry.contextWindow,
|
|
53
|
+
maxTokens: entry.maxTokens,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export const BYTEPLUS_CODING_MODEL_CATALOG = [
|
|
57
|
+
{
|
|
58
|
+
id: "ark-code-latest",
|
|
59
|
+
name: "Ark Coding Plan",
|
|
60
|
+
reasoning: false,
|
|
61
|
+
input: ["text"],
|
|
62
|
+
contextWindow: 256000,
|
|
63
|
+
maxTokens: 4096,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "doubao-seed-code",
|
|
67
|
+
name: "Doubao Seed Code",
|
|
68
|
+
reasoning: false,
|
|
69
|
+
input: ["text"],
|
|
70
|
+
contextWindow: 256000,
|
|
71
|
+
maxTokens: 4096,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: "glm-4.7",
|
|
75
|
+
name: "GLM 4.7 Coding",
|
|
76
|
+
reasoning: false,
|
|
77
|
+
input: ["text"],
|
|
78
|
+
contextWindow: 200000,
|
|
79
|
+
maxTokens: 4096,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: "kimi-k2-thinking",
|
|
83
|
+
name: "Kimi K2 Thinking",
|
|
84
|
+
reasoning: false,
|
|
85
|
+
input: ["text"],
|
|
86
|
+
contextWindow: 256000,
|
|
87
|
+
maxTokens: 4096,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: "kimi-k2.5",
|
|
91
|
+
name: "Kimi K2.5 Coding",
|
|
92
|
+
reasoning: false,
|
|
93
|
+
input: ["text"],
|
|
94
|
+
contextWindow: 256000,
|
|
95
|
+
maxTokens: 4096,
|
|
96
|
+
},
|
|
97
|
+
];
|
|
@@ -126,6 +126,7 @@ export async function refreshChutesTokens(params) {
|
|
|
126
126
|
return {
|
|
127
127
|
...params.credential,
|
|
128
128
|
access,
|
|
129
|
+
// RFC 6749 section 6: new refresh token is optional; if present, replace old.
|
|
129
130
|
refresh: newRefresh || refreshToken,
|
|
130
131
|
expires: coerceExpiresAt(expiresIn, now),
|
|
131
132
|
clientId,
|
|
@@ -52,6 +52,10 @@ export function buildSystemPrompt(params) {
|
|
|
52
52
|
defaultThinkLevel: params.defaultThinkLevel,
|
|
53
53
|
extraSystemPrompt: params.extraSystemPrompt,
|
|
54
54
|
ownerNumbers: params.ownerNumbers,
|
|
55
|
+
ownerDisplay: params.config?.commands?.ownerDisplay,
|
|
56
|
+
ownerDisplaySecret: params.config?.commands?.ownerDisplaySecret ??
|
|
57
|
+
params.config?.gateway?.auth?.token ??
|
|
58
|
+
params.config?.gateway?.remote?.token,
|
|
55
59
|
reasoningTagHint: false,
|
|
56
60
|
heartbeatPrompt: params.heartbeatPrompt,
|
|
57
61
|
docsPath: params.docsPath,
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { estimateTokens, generateSummary } from "@mariozechner/pi-coding-agent";
|
|
2
|
+
import { retryAsync } from "../infra/retry.js";
|
|
3
|
+
import { createSubsystemLogger } from "../logging/subsystem.js";
|
|
2
4
|
import { DEFAULT_CONTEXT_TOKENS } from "./defaults.js";
|
|
3
|
-
import { repairToolUseResultPairing } from "./session-transcript-repair.js";
|
|
5
|
+
import { repairToolUseResultPairing, stripToolResultDetails } from "./session-transcript-repair.js";
|
|
6
|
+
const log = createSubsystemLogger("compaction");
|
|
4
7
|
export const BASE_CHUNK_RATIO = 0.4;
|
|
5
8
|
export const MIN_CHUNK_RATIO = 0.15;
|
|
6
9
|
export const SAFETY_MARGIN = 1.2; // 20% buffer for estimateTokens() inaccuracy
|
|
@@ -9,19 +12,24 @@ const DEFAULT_PARTS = 2;
|
|
|
9
12
|
const MERGE_SUMMARIES_INSTRUCTIONS = "Merge these partial summaries into a single cohesive summary. Preserve decisions," +
|
|
10
13
|
" TODOs, open questions, and any constraints.";
|
|
11
14
|
export function estimateMessagesTokens(messages) {
|
|
12
|
-
|
|
15
|
+
// SECURITY: toolResult.details can contain untrusted/verbose payloads; never include in LLM-facing compaction.
|
|
16
|
+
const safe = stripToolResultDetails(messages);
|
|
17
|
+
return safe.reduce((sum, message) => sum + estimateTokens(message), 0);
|
|
13
18
|
}
|
|
14
19
|
function normalizeParts(parts, messageCount) {
|
|
15
|
-
if (!Number.isFinite(parts) || parts <= 1)
|
|
20
|
+
if (!Number.isFinite(parts) || parts <= 1) {
|
|
16
21
|
return 1;
|
|
22
|
+
}
|
|
17
23
|
return Math.min(Math.max(1, Math.floor(parts)), Math.max(1, messageCount));
|
|
18
24
|
}
|
|
19
25
|
export function splitMessagesByTokenShare(messages, parts = DEFAULT_PARTS) {
|
|
20
|
-
if (messages.length === 0)
|
|
26
|
+
if (messages.length === 0) {
|
|
21
27
|
return [];
|
|
28
|
+
}
|
|
22
29
|
const normalizedParts = normalizeParts(parts, messages.length);
|
|
23
|
-
if (normalizedParts <= 1)
|
|
30
|
+
if (normalizedParts <= 1) {
|
|
24
31
|
return [messages];
|
|
32
|
+
}
|
|
25
33
|
const totalTokens = estimateMessagesTokens(messages);
|
|
26
34
|
const targetTokens = totalTokens / normalizedParts;
|
|
27
35
|
const chunks = [];
|
|
@@ -44,22 +52,30 @@ export function splitMessagesByTokenShare(messages, parts = DEFAULT_PARTS) {
|
|
|
44
52
|
}
|
|
45
53
|
return chunks;
|
|
46
54
|
}
|
|
55
|
+
// Overhead reserved for summarization prompt, system prompt, previous summary,
|
|
56
|
+
// and serialization wrappers (<conversation> tags, instructions, etc.).
|
|
57
|
+
// generateSummary uses reasoning: "high" which also consumes context budget.
|
|
58
|
+
export const SUMMARIZATION_OVERHEAD_TOKENS = 4096;
|
|
47
59
|
export function chunkMessagesByMaxTokens(messages, maxTokens) {
|
|
48
|
-
if (messages.length === 0)
|
|
60
|
+
if (messages.length === 0) {
|
|
49
61
|
return [];
|
|
62
|
+
}
|
|
63
|
+
// Apply safety margin to compensate for estimateTokens() underestimation
|
|
64
|
+
// (chars/4 heuristic misses multi-byte chars, special tokens, code tokens, etc.)
|
|
65
|
+
const effectiveMax = Math.max(1, Math.floor(maxTokens / SAFETY_MARGIN));
|
|
50
66
|
const chunks = [];
|
|
51
67
|
let currentChunk = [];
|
|
52
68
|
let currentTokens = 0;
|
|
53
69
|
for (const message of messages) {
|
|
54
70
|
const messageTokens = estimateTokens(message);
|
|
55
|
-
if (currentChunk.length > 0 && currentTokens + messageTokens >
|
|
71
|
+
if (currentChunk.length > 0 && currentTokens + messageTokens > effectiveMax) {
|
|
56
72
|
chunks.push(currentChunk);
|
|
57
73
|
currentChunk = [];
|
|
58
74
|
currentTokens = 0;
|
|
59
75
|
}
|
|
60
76
|
currentChunk.push(message);
|
|
61
77
|
currentTokens += messageTokens;
|
|
62
|
-
if (messageTokens >
|
|
78
|
+
if (messageTokens > effectiveMax) {
|
|
63
79
|
// Split oversized messages to avoid unbounded chunk growth.
|
|
64
80
|
chunks.push(currentChunk);
|
|
65
81
|
currentChunk = [];
|
|
@@ -76,8 +92,9 @@ export function chunkMessagesByMaxTokens(messages, maxTokens) {
|
|
|
76
92
|
* When messages are large, we use smaller chunks to avoid exceeding model limits.
|
|
77
93
|
*/
|
|
78
94
|
export function computeAdaptiveChunkRatio(messages, contextWindow) {
|
|
79
|
-
if (messages.length === 0)
|
|
95
|
+
if (messages.length === 0) {
|
|
80
96
|
return BASE_CHUNK_RATIO;
|
|
97
|
+
}
|
|
81
98
|
const totalTokens = estimateMessagesTokens(messages);
|
|
82
99
|
const avgTokens = totalTokens / messages.length;
|
|
83
100
|
// Apply safety margin to account for estimation inaccuracy
|
|
@@ -102,10 +119,19 @@ async function summarizeChunks(params) {
|
|
|
102
119
|
if (params.messages.length === 0) {
|
|
103
120
|
return params.previousSummary ?? DEFAULT_SUMMARY_FALLBACK;
|
|
104
121
|
}
|
|
105
|
-
|
|
122
|
+
// SECURITY: never feed toolResult.details into summarization prompts.
|
|
123
|
+
const safeMessages = stripToolResultDetails(params.messages);
|
|
124
|
+
const chunks = chunkMessagesByMaxTokens(safeMessages, params.maxChunkTokens);
|
|
106
125
|
let summary = params.previousSummary;
|
|
107
126
|
for (const chunk of chunks) {
|
|
108
|
-
summary = await generateSummary(chunk, params.model, params.reserveTokens, params.apiKey, params.signal, params.customInstructions, summary)
|
|
127
|
+
summary = await retryAsync(() => generateSummary(chunk, params.model, params.reserveTokens, params.apiKey, params.signal, params.customInstructions, summary), {
|
|
128
|
+
attempts: 3,
|
|
129
|
+
minDelayMs: 500,
|
|
130
|
+
maxDelayMs: 5000,
|
|
131
|
+
jitter: 0.2,
|
|
132
|
+
label: "compaction/generateSummary",
|
|
133
|
+
shouldRetry: (err) => !(err instanceof Error && err.name === "AbortError"),
|
|
134
|
+
});
|
|
109
135
|
}
|
|
110
136
|
return summary ?? DEFAULT_SUMMARY_FALLBACK;
|
|
111
137
|
}
|
|
@@ -123,7 +149,7 @@ export async function summarizeWithFallback(params) {
|
|
|
123
149
|
return await summarizeChunks(params);
|
|
124
150
|
}
|
|
125
151
|
catch (fullError) {
|
|
126
|
-
|
|
152
|
+
log.warn(`Full summarization failed, trying partial: ${fullError instanceof Error ? fullError.message : String(fullError)}`);
|
|
127
153
|
}
|
|
128
154
|
// Fallback 1: Summarize only small messages, note oversized ones
|
|
129
155
|
const smallMessages = [];
|
|
@@ -148,7 +174,7 @@ export async function summarizeWithFallback(params) {
|
|
|
148
174
|
return partialSummary + notes;
|
|
149
175
|
}
|
|
150
176
|
catch (partialError) {
|
|
151
|
-
|
|
177
|
+
log.warn(`Partial summarization also failed: ${partialError instanceof Error ? partialError.message : String(partialError)}`);
|
|
152
178
|
}
|
|
153
179
|
}
|
|
154
180
|
// Final fallback: Just note what was there
|
|
@@ -206,8 +232,9 @@ export function pruneHistoryForContextShare(params) {
|
|
|
206
232
|
const parts = normalizeParts(params.parts ?? DEFAULT_PARTS, keptMessages.length);
|
|
207
233
|
while (keptMessages.length > 0 && estimateMessagesTokens(keptMessages) > budgetTokens) {
|
|
208
234
|
const chunks = splitMessagesByTokenShare(keptMessages, parts);
|
|
209
|
-
if (chunks.length <= 1)
|
|
235
|
+
if (chunks.length <= 1) {
|
|
210
236
|
break;
|
|
237
|
+
}
|
|
211
238
|
const [dropped, ...rest] = chunks;
|
|
212
239
|
const flatRest = rest.flat();
|
|
213
240
|
// After dropping a chunk, repair tool_use/tool_result pairing to handle
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export const DOUBAO_BASE_URL = "https://ark.cn-beijing.volces.com/api/v3";
|
|
2
|
+
export const DOUBAO_CODING_BASE_URL = "https://ark.cn-beijing.volces.com/api/coding/v3";
|
|
3
|
+
export const DOUBAO_DEFAULT_MODEL_ID = "doubao-seed-1-8-251228";
|
|
4
|
+
export const DOUBAO_CODING_DEFAULT_MODEL_ID = "ark-code-latest";
|
|
5
|
+
export const DOUBAO_DEFAULT_MODEL_REF = `volcengine/${DOUBAO_DEFAULT_MODEL_ID}`;
|
|
6
|
+
// Volcano Engine Doubao pricing (approximate, adjust based on actual pricing)
|
|
7
|
+
export const DOUBAO_DEFAULT_COST = {
|
|
8
|
+
input: 0.0001, // ¥0.0001 per 1K tokens
|
|
9
|
+
output: 0.0002, // ¥0.0002 per 1K tokens
|
|
10
|
+
cacheRead: 0,
|
|
11
|
+
cacheWrite: 0,
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Complete catalog of Volcano Engine models.
|
|
15
|
+
*
|
|
16
|
+
* Volcano Engine provides access to models
|
|
17
|
+
* through the API. Authentication requires a Volcano Engine API Key.
|
|
18
|
+
*/
|
|
19
|
+
export const DOUBAO_MODEL_CATALOG = [
|
|
20
|
+
{
|
|
21
|
+
id: "doubao-seed-code-preview-251028",
|
|
22
|
+
name: "doubao-seed-code-preview-251028",
|
|
23
|
+
reasoning: false,
|
|
24
|
+
input: ["text", "image"],
|
|
25
|
+
contextWindow: 256000,
|
|
26
|
+
maxTokens: 4096,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "doubao-seed-1-8-251228",
|
|
30
|
+
name: "Doubao Seed 1.8",
|
|
31
|
+
reasoning: false,
|
|
32
|
+
input: ["text", "image"],
|
|
33
|
+
contextWindow: 256000,
|
|
34
|
+
maxTokens: 4096,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: "kimi-k2-5-260127",
|
|
38
|
+
name: "Kimi K2.5",
|
|
39
|
+
reasoning: false,
|
|
40
|
+
input: ["text", "image"],
|
|
41
|
+
contextWindow: 256000,
|
|
42
|
+
maxTokens: 4096,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: "glm-4-7-251222",
|
|
46
|
+
name: "GLM 4.7",
|
|
47
|
+
reasoning: false,
|
|
48
|
+
input: ["text", "image"],
|
|
49
|
+
contextWindow: 200000,
|
|
50
|
+
maxTokens: 4096,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: "deepseek-v3-2-251201",
|
|
54
|
+
name: "DeepSeek V3.2",
|
|
55
|
+
reasoning: false,
|
|
56
|
+
input: ["text", "image"],
|
|
57
|
+
contextWindow: 128000,
|
|
58
|
+
maxTokens: 4096,
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
export function buildDoubaoModelDefinition(entry) {
|
|
62
|
+
return {
|
|
63
|
+
id: entry.id,
|
|
64
|
+
name: entry.name,
|
|
65
|
+
reasoning: entry.reasoning,
|
|
66
|
+
input: [...entry.input],
|
|
67
|
+
cost: DOUBAO_DEFAULT_COST,
|
|
68
|
+
contextWindow: entry.contextWindow,
|
|
69
|
+
maxTokens: entry.maxTokens,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export const DOUBAO_CODING_MODEL_CATALOG = [
|
|
73
|
+
{
|
|
74
|
+
id: "ark-code-latest",
|
|
75
|
+
name: "Ark Coding Plan",
|
|
76
|
+
reasoning: false,
|
|
77
|
+
input: ["text"],
|
|
78
|
+
contextWindow: 256000,
|
|
79
|
+
maxTokens: 4096,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: "doubao-seed-code",
|
|
83
|
+
name: "Doubao Seed Code",
|
|
84
|
+
reasoning: false,
|
|
85
|
+
input: ["text"],
|
|
86
|
+
contextWindow: 256000,
|
|
87
|
+
maxTokens: 4096,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: "glm-4.7",
|
|
91
|
+
name: "GLM 4.7 Coding",
|
|
92
|
+
reasoning: false,
|
|
93
|
+
input: ["text"],
|
|
94
|
+
contextWindow: 200000,
|
|
95
|
+
maxTokens: 4096,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: "kimi-k2-thinking",
|
|
99
|
+
name: "Kimi K2 Thinking",
|
|
100
|
+
reasoning: false,
|
|
101
|
+
input: ["text"],
|
|
102
|
+
contextWindow: 256000,
|
|
103
|
+
maxTokens: 4096,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
id: "kimi-k2.5",
|
|
107
|
+
name: "Kimi K2.5 Coding",
|
|
108
|
+
reasoning: false,
|
|
109
|
+
input: ["text"],
|
|
110
|
+
contextWindow: 256000,
|
|
111
|
+
maxTokens: 4096,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: "doubao-seed-code-preview-251028",
|
|
115
|
+
name: "Doubao Seed Code Preview",
|
|
116
|
+
reasoning: false,
|
|
117
|
+
input: ["text"],
|
|
118
|
+
contextWindow: 256000,
|
|
119
|
+
maxTokens: 4096,
|
|
120
|
+
},
|
|
121
|
+
];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createSubsystemLogger } from "../logging/subsystem.js";
|
|
2
|
+
const log = createSubsystemLogger("huggingface-models");
|
|
1
3
|
/** Hugging Face Inference Providers (router) — OpenAI-compatible chat completions. */
|
|
2
4
|
export const HUGGINGFACE_BASE_URL = "https://router.huggingface.co/v1";
|
|
3
5
|
/** Router policy suffixes: router picks backend by cost or speed; no specific provider selection. */
|
|
@@ -114,13 +116,13 @@ export async function discoverHuggingfaceModels(apiKey) {
|
|
|
114
116
|
},
|
|
115
117
|
});
|
|
116
118
|
if (!response.ok) {
|
|
117
|
-
|
|
119
|
+
log.warn(`GET /v1/models failed: HTTP ${response.status}, using static catalog`);
|
|
118
120
|
return HUGGINGFACE_MODEL_CATALOG.map(buildHuggingfaceModelDefinition);
|
|
119
121
|
}
|
|
120
122
|
const body = (await response.json());
|
|
121
123
|
const data = body?.data;
|
|
122
124
|
if (!Array.isArray(data) || data.length === 0) {
|
|
123
|
-
|
|
125
|
+
log.warn("No models in response, using static catalog");
|
|
124
126
|
return HUGGINGFACE_MODEL_CATALOG.map(buildHuggingfaceModelDefinition);
|
|
125
127
|
}
|
|
126
128
|
const catalogById = new Map(HUGGINGFACE_MODEL_CATALOG.map((m) => [m.id, m]));
|
|
@@ -160,7 +162,7 @@ export async function discoverHuggingfaceModels(apiKey) {
|
|
|
160
162
|
: HUGGINGFACE_MODEL_CATALOG.map(buildHuggingfaceModelDefinition);
|
|
161
163
|
}
|
|
162
164
|
catch (error) {
|
|
163
|
-
|
|
165
|
+
log.warn(`Discovery failed: ${String(error)}, using static catalog`);
|
|
164
166
|
return HUGGINGFACE_MODEL_CATALOG.map(buildHuggingfaceModelDefinition);
|
|
165
167
|
}
|
|
166
168
|
}
|
|
@@ -64,6 +64,11 @@ export function isModernModelRef(ref) {
|
|
|
64
64
|
if (provider === "opencode" && id === "alpha-glm-4.7") {
|
|
65
65
|
return false;
|
|
66
66
|
}
|
|
67
|
+
// Opencode MiniMax variants have been intermittently unstable in live runs;
|
|
68
|
+
// prefer the rest of the modern catalog for deterministic smoke coverage.
|
|
69
|
+
if (provider === "opencode" && matchesPrefix(id, MINIMAX_PREFIXES)) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
67
72
|
if (provider === "openrouter" || provider === "opencode") {
|
|
68
73
|
return matchesAny(id, [
|
|
69
74
|
...ANTHROPIC_PREFIXES,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isRecord } from "../utils.js";
|
|
2
|
+
import { normalizeSecretInput } from "../utils/normalize-secret-input.js";
|
|
1
3
|
function coerceApiHost(params) {
|
|
2
4
|
const env = params.env ?? process.env;
|
|
3
5
|
const raw = params.apiHost?.trim() ||
|
|
@@ -17,23 +19,23 @@ function coerceApiHost(params) {
|
|
|
17
19
|
return "https://api.minimax.io";
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
|
-
function isRecord(value) {
|
|
21
|
-
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
22
|
-
}
|
|
23
22
|
function pickString(rec, key) {
|
|
24
23
|
const v = rec[key];
|
|
25
24
|
return typeof v === "string" ? v : "";
|
|
26
25
|
}
|
|
27
26
|
export async function minimaxUnderstandImage(params) {
|
|
28
|
-
const apiKey = params.apiKey
|
|
29
|
-
if (!apiKey)
|
|
27
|
+
const apiKey = normalizeSecretInput(params.apiKey);
|
|
28
|
+
if (!apiKey) {
|
|
30
29
|
throw new Error("MiniMax VLM: apiKey required");
|
|
30
|
+
}
|
|
31
31
|
const prompt = params.prompt.trim();
|
|
32
|
-
if (!prompt)
|
|
32
|
+
if (!prompt) {
|
|
33
33
|
throw new Error("MiniMax VLM: prompt required");
|
|
34
|
+
}
|
|
34
35
|
const imageDataUrl = params.imageDataUrl.trim();
|
|
35
|
-
if (!imageDataUrl)
|
|
36
|
+
if (!imageDataUrl) {
|
|
36
37
|
throw new Error("MiniMax VLM: imageDataUrl required");
|
|
38
|
+
}
|
|
37
39
|
if (!/^data:image\/(png|jpeg|webp);base64,/i.test(imageDataUrl)) {
|
|
38
40
|
throw new Error("MiniMax VLM: imageDataUrl must be a base64 data:image/(png|jpeg|webp) URL");
|
|
39
41
|
}
|
|
@@ -47,7 +49,7 @@ export async function minimaxUnderstandImage(params) {
|
|
|
47
49
|
headers: {
|
|
48
50
|
Authorization: `Bearer ${apiKey}`,
|
|
49
51
|
"Content-Type": "application/json",
|
|
50
|
-
"MM-API-Source": "
|
|
52
|
+
"MM-API-Source": "Pool Bot",
|
|
51
53
|
},
|
|
52
54
|
body: JSON.stringify({
|
|
53
55
|
prompt,
|
|
@@ -211,6 +211,12 @@ export function resolveEnvApiKey(provider) {
|
|
|
211
211
|
if (normalized === "qwen-portal") {
|
|
212
212
|
return pick("QWEN_OAUTH_TOKEN") ?? pick("QWEN_PORTAL_API_KEY");
|
|
213
213
|
}
|
|
214
|
+
if (normalized === "volcengine" || normalized === "volcengine-plan") {
|
|
215
|
+
return pick("VOLCANO_ENGINE_API_KEY");
|
|
216
|
+
}
|
|
217
|
+
if (normalized === "byteplus" || normalized === "byteplus-plan") {
|
|
218
|
+
return pick("BYTEPLUS_API_KEY");
|
|
219
|
+
}
|
|
214
220
|
if (normalized === "minimax-portal") {
|
|
215
221
|
return pick("MINIMAX_OAUTH_TOKEN") ?? pick("MINIMAX_API_KEY");
|
|
216
222
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { loadConfig } from "../config/config.js";
|
|
2
|
+
import { createSubsystemLogger } from "../logging/subsystem.js";
|
|
2
3
|
import { resolvePoolbotAgentDir } from "./agent-paths.js";
|
|
3
4
|
import { ensurePoolbotModelsJson } from "./models-config.js";
|
|
5
|
+
const log = createSubsystemLogger("model-catalog");
|
|
4
6
|
let modelCatalogPromise = null;
|
|
5
7
|
let hasLoggedModelCatalogError = false;
|
|
6
8
|
const defaultImportPiSdk = () => import("./pi-model-discovery.js");
|
|
@@ -97,7 +99,7 @@ export async function loadModelCatalog(params) {
|
|
|
97
99
|
catch (error) {
|
|
98
100
|
if (!hasLoggedModelCatalogError) {
|
|
99
101
|
hasLoggedModelCatalogError = true;
|
|
100
|
-
|
|
102
|
+
log.warn(`Failed to load model catalog: ${String(error)}`);
|
|
101
103
|
}
|
|
102
104
|
// Don't poison the cache on transient dependency/filesystem issues.
|
|
103
105
|
modelCatalogPromise = null;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { createSubsystemLogger } from "../logging/subsystem.js";
|
|
1
2
|
import { resolveAgentConfig, resolveAgentModelPrimary } from "./agent-scope.js";
|
|
2
3
|
import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "./defaults.js";
|
|
3
4
|
import { normalizeGoogleModelId } from "./models-config.providers.js";
|
|
5
|
+
const log = createSubsystemLogger("model-selection");
|
|
4
6
|
const ANTHROPIC_MODEL_ALIASES = {
|
|
5
7
|
"opus-4.6": "claude-opus-4-6",
|
|
6
8
|
"opus-4.5": "claude-opus-4-5",
|
|
@@ -28,6 +30,10 @@ export function normalizeProviderId(provider) {
|
|
|
28
30
|
if (normalized === "kimi-code") {
|
|
29
31
|
return "kimi-coding";
|
|
30
32
|
}
|
|
33
|
+
// Backward compatibility for older provider naming.
|
|
34
|
+
if (normalized === "bytedance" || normalized === "doubao") {
|
|
35
|
+
return "volcengine";
|
|
36
|
+
}
|
|
31
37
|
return normalized;
|
|
32
38
|
}
|
|
33
39
|
export function findNormalizedProviderValue(entries, provider) {
|
|
@@ -208,7 +214,7 @@ export function resolveConfiguredModelRef(params) {
|
|
|
208
214
|
return aliasMatch.ref;
|
|
209
215
|
}
|
|
210
216
|
// Default to anthropic if no provider is specified, but warn as this is deprecated.
|
|
211
|
-
|
|
217
|
+
log.warn(`Model "${trimmed}" specified without provider. Falling back to "anthropic/${trimmed}". Please use "anthropic/${trimmed}" in your config.`);
|
|
212
218
|
return { provider: "anthropic", model: trimmed };
|
|
213
219
|
}
|
|
214
220
|
const resolved = resolveModelRefFromString({
|