From f06dd8df06b3be411a5538e0516cfc3ffaa62f48 Mon Sep 17 00:00:00 2001 From: cpojer Date: Sun, 1 Feb 2026 10:03:47 +0900 Subject: [PATCH] chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. --- .github/workflows/formal-conformance.yml | 2 +- .oxfmtrc.jsonc | 3 + extensions/bluebubbles/index.ts | 1 - extensions/bluebubbles/src/actions.test.ts | 5 +- extensions/bluebubbles/src/actions.ts | 13 ++- .../bluebubbles/src/attachments.test.ts | 3 +- extensions/bluebubbles/src/attachments.ts | 2 +- extensions/bluebubbles/src/channel.ts | 9 +- extensions/bluebubbles/src/chat.test.ts | 1 - extensions/bluebubbles/src/chat.ts | 2 +- extensions/bluebubbles/src/media-send.ts | 2 - extensions/bluebubbles/src/monitor.test.ts | 9 +- extensions/bluebubbles/src/monitor.ts | 17 ++-- extensions/bluebubbles/src/onboarding.ts | 2 +- extensions/bluebubbles/src/reactions.test.ts | 1 - extensions/bluebubbles/src/reactions.ts | 2 +- extensions/bluebubbles/src/send.test.ts | 3 +- extensions/bluebubbles/src/send.ts | 3 +- extensions/bluebubbles/src/targets.test.ts | 1 - extensions/diagnostics-otel/index.ts | 1 - .../diagnostics-otel/src/service.test.ts | 2 +- extensions/diagnostics-otel/src/service.ts | 5 +- extensions/discord/index.ts | 1 - extensions/discord/src/channel.ts | 1 - extensions/google-gemini-cli-auth/index.ts | 1 - .../google-gemini-cli-auth/oauth.test.ts | 2 +- extensions/googlechat/index.ts | 1 - extensions/googlechat/src/accounts.ts | 1 - extensions/googlechat/src/actions.ts | 1 - extensions/googlechat/src/api.test.ts | 1 - extensions/googlechat/src/api.ts | 3 +- extensions/googlechat/src/auth.ts | 1 - extensions/googlechat/src/channel.ts | 3 +- extensions/googlechat/src/monitor.test.ts | 1 - extensions/googlechat/src/monitor.ts | 18 ++-- extensions/googlechat/src/onboarding.ts | 1 - extensions/googlechat/src/targets.test.ts | 1 - extensions/imessage/index.ts | 1 - extensions/imessage/src/channel.ts | 1 - extensions/line/index.ts | 3 +- extensions/line/src/channel.logout.test.ts | 2 +- .../line/src/channel.sendPayload.test.ts | 2 +- extensions/line/src/channel.ts | 1 - extensions/llm-task/index.ts | 1 - extensions/llm-task/src/llm-task-tool.ts | 9 +- extensions/lobster/index.ts | 1 - extensions/lobster/src/lobster-tool.test.ts | 2 - extensions/lobster/src/lobster-tool.ts | 1 - extensions/matrix/index.ts | 1 - extensions/matrix/src/actions.ts | 2 +- .../matrix/src/channel.directory.test.ts | 4 +- extensions/matrix/src/channel.ts | 5 +- extensions/matrix/src/directory-live.ts | 1 - extensions/matrix/src/group-mentions.ts | 3 +- extensions/matrix/src/matrix/accounts.test.ts | 1 - .../matrix/src/matrix/actions/client.ts | 4 +- .../matrix/src/matrix/actions/messages.ts | 6 +- extensions/matrix/src/matrix/actions/pins.ts | 6 +- .../matrix/src/matrix/actions/reactions.ts | 4 +- extensions/matrix/src/matrix/actions/room.ts | 4 +- .../matrix/src/matrix/actions/summary.ts | 1 - extensions/matrix/src/matrix/client.test.ts | 1 - extensions/matrix/src/matrix/client/config.ts | 3 +- .../matrix/src/matrix/client/create-client.ts | 6 +- extensions/matrix/src/matrix/client/shared.ts | 9 +- .../matrix/src/matrix/client/storage.ts | 3 +- extensions/matrix/src/matrix/credentials.ts | 1 - extensions/matrix/src/matrix/deps.ts | 9 +- extensions/matrix/src/matrix/format.test.ts | 1 - .../matrix/src/matrix/monitor/auto-join.ts | 3 +- .../matrix/src/matrix/monitor/events.ts | 1 - .../matrix/src/matrix/monitor/handler.ts | 5 +- extensions/matrix/src/matrix/monitor/index.ts | 5 +- .../matrix/src/matrix/monitor/location.ts | 1 - .../matrix/src/matrix/monitor/media.test.ts | 3 +- extensions/matrix/src/matrix/monitor/media.ts | 1 - .../matrix/src/matrix/monitor/replies.ts | 3 +- extensions/matrix/src/matrix/monitor/rooms.ts | 2 +- .../matrix/src/matrix/poll-types.test.ts | 1 - extensions/matrix/src/matrix/send.test.ts | 3 +- extensions/matrix/src/matrix/send.ts | 1 - extensions/matrix/src/matrix/send/client.ts | 3 +- .../matrix/src/matrix/send/formatting.ts | 2 +- extensions/matrix/src/matrix/send/media.ts | 3 +- .../matrix/src/matrix/send/targets.test.ts | 3 +- extensions/matrix/src/matrix/send/targets.ts | 1 - extensions/matrix/src/onboarding.ts | 2 +- extensions/matrix/src/outbound.ts | 3 +- extensions/matrix/src/resolve-targets.ts | 1 - extensions/matrix/src/tool-actions.ts | 15 ++- extensions/mattermost/index.ts | 1 - extensions/mattermost/src/channel.test.ts | 1 - extensions/mattermost/src/channel.ts | 5 +- extensions/mattermost/src/config-schema.ts | 3 +- extensions/mattermost/src/group-mentions.ts | 1 - .../mattermost/src/mattermost/accounts.ts | 1 - .../src/mattermost/monitor-helpers.ts | 6 +- .../mattermost/src/mattermost/monitor.ts | 4 +- extensions/mattermost/src/onboarding.ts | 1 - extensions/memory-lancedb/index.test.ts | 4 +- extensions/memory-lancedb/index.ts | 9 +- extensions/minimax-portal-auth/index.ts | 1 - extensions/msteams/index.ts | 1 - extensions/msteams/src/attachments.test.ts | 3 +- .../msteams/src/attachments/download.ts | 10 +- extensions/msteams/src/attachments/graph.ts | 12 +-- extensions/msteams/src/attachments/html.ts | 2 +- .../msteams/src/channel.directory.test.ts | 4 +- extensions/msteams/src/channel.ts | 5 +- .../msteams/src/conversation-store-fs.test.ts | 4 +- extensions/msteams/src/directory-live.ts | 1 - extensions/msteams/src/errors.test.ts | 1 - extensions/msteams/src/inbound.test.ts | 1 - extensions/msteams/src/media-helpers.test.ts | 1 - extensions/msteams/src/media-helpers.ts | 1 - extensions/msteams/src/messenger.test.ts | 3 +- extensions/msteams/src/monitor-handler.ts | 6 +- .../src/monitor-handler/inbound-media.ts | 2 +- .../src/monitor-handler/message-handler.ts | 11 +-- extensions/msteams/src/monitor.ts | 4 +- extensions/msteams/src/onboarding.ts | 3 +- extensions/msteams/src/outbound.ts | 1 - extensions/msteams/src/policy.test.ts | 3 +- extensions/msteams/src/polls-store.test.ts | 4 +- extensions/msteams/src/polls.test.ts | 4 +- extensions/msteams/src/polls.ts | 1 - extensions/msteams/src/probe.test.ts | 3 +- extensions/msteams/src/reply-dispatcher.ts | 4 +- extensions/msteams/src/send-context.ts | 2 +- extensions/msteams/src/send.ts | 2 +- .../msteams/src/sent-message-cache.test.ts | 1 - extensions/msteams/src/storage.ts | 1 - extensions/msteams/src/store-fs.ts | 1 - extensions/nextcloud-talk/index.ts | 1 - extensions/nextcloud-talk/src/accounts.ts | 2 - extensions/nextcloud-talk/src/channel.ts | 5 +- extensions/nextcloud-talk/src/inbound.ts | 5 +- extensions/nextcloud-talk/src/monitor.ts | 12 +-- extensions/nextcloud-talk/src/onboarding.ts | 3 +- extensions/nextcloud-talk/src/policy.ts | 1 - extensions/nextcloud-talk/src/room-info.ts | 4 +- extensions/nextcloud-talk/src/send.ts | 2 +- extensions/nextcloud-talk/src/signature.ts | 1 - extensions/nostr/index.ts | 9 +- extensions/nostr/src/channel.ts | 9 +- extensions/nostr/src/nostr-bus.fuzz.test.ts | 2 +- .../nostr/src/nostr-bus.integration.test.ts | 2 +- extensions/nostr/src/nostr-bus.ts | 19 ++-- .../nostr/src/nostr-profile-http.test.ts | 3 +- extensions/nostr/src/nostr-profile-http.ts | 3 +- .../nostr/src/nostr-profile-import.test.ts | 3 +- extensions/nostr/src/nostr-profile-import.ts | 3 +- .../nostr/src/nostr-profile.fuzz.test.ts | 2 +- extensions/nostr/src/nostr-profile.test.ts | 4 +- .../nostr/src/nostr-state-store.test.ts | 4 +- extensions/nostr/src/nostr-state-store.ts | 1 - extensions/nostr/src/types.ts | 2 +- extensions/qwen-portal-auth/index.ts | 1 - extensions/signal/index.ts | 1 - extensions/signal/src/channel.ts | 1 - extensions/slack/index.ts | 1 - extensions/slack/src/channel.ts | 1 - extensions/telegram/index.ts | 1 - extensions/telegram/src/channel.ts | 1 - extensions/tlon/index.ts | 1 - extensions/tlon/src/channel.ts | 9 +- extensions/tlon/src/config-schema.test.ts | 1 - extensions/tlon/src/config-schema.ts | 2 +- extensions/tlon/src/monitor/discovery.ts | 1 - extensions/tlon/src/monitor/history.ts | 1 - extensions/tlon/src/monitor/index.ts | 10 +- .../src/monitor/processed-messages.test.ts | 1 - extensions/tlon/src/onboarding.ts | 5 +- extensions/tlon/src/urbit/sse-client.test.ts | 1 - extensions/twitch/index.ts | 1 - extensions/twitch/src/access-control.test.ts | 2 +- extensions/twitch/src/actions.ts | 2 +- .../twitch/src/client-manager-registry.ts | 2 +- extensions/twitch/src/config.test.ts | 1 - extensions/twitch/src/monitor.ts | 2 +- extensions/twitch/src/onboarding.test.ts | 2 +- extensions/twitch/src/onboarding.ts | 4 +- extensions/twitch/src/outbound.test.ts | 2 +- extensions/twitch/src/outbound.ts | 4 +- extensions/twitch/src/plugin.test.ts | 2 +- extensions/twitch/src/plugin.ts | 22 ++--- extensions/twitch/src/probe.test.ts | 2 +- extensions/twitch/src/send.test.ts | 2 +- extensions/twitch/src/send.ts | 4 +- extensions/twitch/src/status.test.ts | 2 +- extensions/twitch/src/status.ts | 2 +- extensions/twitch/src/token.test.ts | 2 +- extensions/twitch/src/twitch-client.test.ts | 2 +- extensions/twitch/src/twitch-client.ts | 2 +- extensions/twitch/src/types.ts | 18 ++-- extensions/voice-call/index.ts | 2 +- extensions/voice-call/src/cli.ts | 4 +- extensions/voice-call/src/config.test.ts | 1 - extensions/voice-call/src/core-bridge.ts | 1 - extensions/voice-call/src/manager.test.ts | 8 +- extensions/voice-call/src/manager.ts | 3 +- extensions/voice-call/src/manager/context.ts | 2 +- extensions/voice-call/src/manager/events.ts | 3 +- extensions/voice-call/src/manager/outbound.ts | 7 +- extensions/voice-call/src/manager/store.ts | 1 - extensions/voice-call/src/manager/timers.ts | 2 +- .../voice-call/src/media-stream.test.ts | 1 - extensions/voice-call/src/media-stream.ts | 2 - extensions/voice-call/src/providers/mock.ts | 1 - .../voice-call/src/providers/plivo.test.ts | 1 - extensions/voice-call/src/providers/plivo.ts | 3 +- extensions/voice-call/src/providers/telnyx.ts | 1 - .../voice-call/src/providers/twilio.test.ts | 1 - extensions/voice-call/src/providers/twilio.ts | 7 +- .../src/providers/twilio/webhook.ts | 3 +- .../voice-call/src/response-generator.ts | 4 +- extensions/voice-call/src/runtime.ts | 6 +- extensions/voice-call/src/telephony-tts.ts | 2 +- extensions/voice-call/src/tunnel.ts | 1 - extensions/voice-call/src/types.ts | 1 - .../voice-call/src/webhook-security.test.ts | 2 - extensions/voice-call/src/webhook-security.ts | 1 - extensions/voice-call/src/webhook.ts | 5 +- extensions/whatsapp/index.ts | 1 - extensions/whatsapp/src/channel.ts | 1 - extensions/zalo/index.ts | 1 - extensions/zalo/src/accounts.ts | 1 - extensions/zalo/src/actions.ts | 1 - extensions/zalo/src/channel.directory.test.ts | 4 +- extensions/zalo/src/channel.ts | 3 +- extensions/zalo/src/monitor.ts | 2 - extensions/zalo/src/monitor.webhook.test.ts | 6 +- extensions/zalo/src/onboarding.ts | 1 - extensions/zalo/src/proxy.ts | 3 +- extensions/zalo/src/send.ts | 3 +- extensions/zalo/src/token.ts | 2 - extensions/zalouser/index.ts | 3 +- extensions/zalouser/src/accounts.ts | 3 +- extensions/zalouser/src/channel.test.ts | 1 - extensions/zalouser/src/channel.ts | 10 +- extensions/zalouser/src/monitor.ts | 3 +- extensions/zalouser/src/onboarding.ts | 3 +- extensions/zalouser/src/probe.ts | 2 +- extensions/zalouser/src/status-issues.test.ts | 1 - extensions/zalouser/src/tool.ts | 1 - extensions/zalouser/src/zca.ts | 1 - scripts/check-ts-max-loc.ts | 2 +- scripts/debug-claude-usage.ts | 2 +- scripts/format-staged.js | 2 +- scripts/postinstall.js | 2 +- scripts/setup-git-hooks.js | 2 +- scripts/test-force.ts | 2 +- scripts/zai-fallback-repro.ts | 2 +- src/acp/client.ts | 8 +- src/acp/event-mapper.test.ts | 1 - src/acp/server.ts | 6 +- src/acp/session-mapper.test.ts | 1 - src/acp/session-mapper.ts | 1 - src/acp/session.test.ts | 1 - src/acp/session.ts | 1 - src/acp/translator.ts | 8 +- src/acp/types.ts | 1 - src/agents/agent-paths.test.ts | 2 - src/agents/agent-paths.ts | 1 - src/agents/agent-scope.ts | 1 - src/agents/anthropic-payload-log.ts | 10 +- src/agents/anthropic.setup-token.live.test.ts | 7 +- src/agents/apply-patch.test.ts | 1 - src/agents/apply-patch.ts | 4 +- src/agents/auth-health.test.ts | 1 - src/agents/auth-profiles.chutes.test.ts | 1 - src/agents/auth-profiles/doctor.ts | 4 +- src/agents/auth-profiles/external-cli-sync.ts | 2 +- .../oauth.fallback-to-main-agent.test.ts | 4 +- src/agents/auth-profiles/oauth.ts | 5 +- src/agents/auth-profiles/order.ts | 2 +- src/agents/auth-profiles/paths.ts | 3 +- src/agents/auth-profiles/profiles.ts | 2 +- src/agents/auth-profiles/repair.ts | 2 +- .../auth-profiles/session-override.test.ts | 1 - src/agents/auth-profiles/session-override.ts | 2 +- src/agents/auth-profiles/store.ts | 4 +- src/agents/auth-profiles/types.ts | 1 - src/agents/auth-profiles/usage.ts | 2 +- .../bash-tools.exec.background-abort.test.ts | 3 +- .../bash-tools.exec.pty-fallback.test.ts | 1 - src/agents/bash-tools.exec.pty.test.ts | 3 +- src/agents/bash-tools.exec.ts | 15 ++- .../bash-tools.process.send-keys.test.ts | 1 - src/agents/bash-tools.process.ts | 1 - src/agents/bash-tools.shared.ts | 1 - src/agents/bash-tools.test.ts | 1 - src/agents/bedrock-discovery.ts | 1 - src/agents/bootstrap-files.test.ts | 6 +- src/agents/bootstrap-files.ts | 4 +- src/agents/bootstrap-hooks.test.ts | 3 +- src/agents/bootstrap-hooks.ts | 4 +- src/agents/cache-trace.test.ts | 1 - src/agents/cache-trace.ts | 6 +- src/agents/channel-tools.test.ts | 5 +- src/agents/channel-tools.ts | 6 +- src/agents/chutes-oauth.test.ts | 1 - src/agents/chutes-oauth.ts | 3 +- src/agents/claude-cli-runner.test.ts | 1 - src/agents/cli-credentials.test.ts | 1 - src/agents/cli-credentials.ts | 4 +- src/agents/cli-runner.test.ts | 1 - src/agents/cli-runner.ts | 8 +- src/agents/cli-runner/helpers.ts | 13 ++- src/agents/compaction.test.ts | 1 - src/agents/compaction.ts | 1 - src/agents/context-window-guard.test.ts | 1 - src/agents/docs-path.ts | 1 - src/agents/identity-avatar.test.ts | 2 - src/agents/identity-avatar.ts | 1 - src/agents/identity-file.test.ts | 1 - src/agents/identity-file.ts | 1 - src/agents/identity.test.ts | 1 - src/agents/memory-search.test.ts | 1 - src/agents/memory-search.ts | 1 - src/agents/model-auth.test.ts | 2 +- src/agents/model-auth.ts | 5 +- src/agents/model-catalog.test.ts | 1 - src/agents/model-fallback.test.ts | 1 - src/agents/model-fallback.ts | 12 +-- src/agents/model-scan.test.ts | 1 - src/agents/model-selection.test.ts | 2 +- src/agents/model-selection.ts | 2 +- ...s-github-copilot-provider-token-is.test.ts | 2 +- ...fault-baseurl-token-exchange-fails.test.ts | 2 +- ...ssing-provider-apikey-from-env-var.test.ts | 2 +- ...ini-3-ids-preview-google-providers.test.ts | 2 +- .../models-config.providers.ollama.test.ts | 6 +- src/agents/models-config.providers.ts | 2 +- ...s-writing-models-json-no-env-token.test.ts | 2 +- src/agents/models-config.ts | 1 - ...-github-copilot-profile-env-tokens.test.ts | 2 +- src/agents/models.profiles.live.test.ts | 2 +- src/agents/openclaw-gateway-tool.test.ts | 1 - src/agents/openclaw-tools.ts | 6 +- src/agents/opencode-zen-models.test.ts | 1 - src/agents/pi-embedded-block-chunker.test.ts | 1 - ...lpers.formatrawassistanterrorforui.test.ts | 1 - ...dded-helpers.image-dimension-error.test.ts | 1 - ...-embedded-helpers.image-size-error.test.ts | 1 - src/agents/pi-embedded-helpers/bootstrap.ts | 4 +- src/agents/pi-embedded-helpers/errors.ts | 3 +- src/agents/pi-embedded-helpers/images.ts | 1 - ...i-embedded-runner-extraparams.live.test.ts | 2 +- ...-runner.applygoogleturnorderingfix.test.ts | 2 +- ...ed-runner.buildembeddedsandboxinfo.test.ts | 2 +- src/agents/pi-embedded-runner.guard.test.ts | 1 - ...-embedded-runner.limithistoryturns.test.ts | 2 +- ...ded-pi-agent.auth-profile-rotation.test.ts | 4 +- .../pi-embedded-runner.splitsdktools.test.ts | 2 +- src/agents/pi-embedded-runner.test.ts | 1 - src/agents/pi-embedded-runner/compact.ts | 34 +++---- src/agents/pi-embedded-runner/extensions.ts | 6 +- src/agents/pi-embedded-runner/extra-params.ts | 1 - src/agents/pi-embedded-runner/google.test.ts | 3 +- src/agents/pi-embedded-runner/google.ts | 12 +-- src/agents/pi-embedded-runner/history.ts | 1 - src/agents/pi-embedded-runner/model.ts | 13 ++- .../run.overflow-compaction.test.ts | 7 +- src/agents/pi-embedded-runner/run.ts | 5 +- .../pi-embedded-runner/run/attempt.test.ts | 1 - src/agents/pi-embedded-runner/run/attempt.ts | 59 ++++++----- .../pi-embedded-runner/run/images.test.ts | 1 - src/agents/pi-embedded-runner/run/images.ts | 10 +- src/agents/pi-embedded-runner/run/params.ts | 2 +- src/agents/pi-embedded-runner/run/payloads.ts | 6 +- src/agents/pi-embedded-runner/run/types.ts | 7 +- .../session-manager-cache.ts | 1 - .../pi-embedded-runner/system-prompt.ts | 4 +- src/agents/pi-embedded-runner/tool-split.ts | 1 - src/agents/pi-embedded-runner/types.ts | 2 +- ...i-embedded-subscribe.handlers.lifecycle.ts | 3 +- ...pi-embedded-subscribe.handlers.messages.ts | 7 +- .../pi-embedded-subscribe.handlers.tools.ts | 3 +- src/agents/pi-embedded-subscribe.handlers.ts | 8 +- .../pi-embedded-subscribe.handlers.types.ts | 3 +- .../pi-embedded-subscribe.raw-stream.ts | 1 - .../pi-embedded-subscribe.tools.test.ts | 5 +- src/agents/pi-embedded-subscribe.tools.ts | 2 +- src/agents/pi-embedded-subscribe.ts | 12 +-- src/agents/pi-embedded-subscribe.types.ts | 1 - .../compaction-safeguard.test.ts | 1 - .../pi-extensions/context-pruning.test.ts | 4 +- .../context-pruning/extension.ts | 1 - .../pi-extensions/context-pruning/pruner.ts | 1 - src/agents/pi-model-discovery.ts | 3 +- src/agents/pi-settings.test.ts | 1 - src/agents/pi-tool-definition-adapter.test.ts | 1 - src/agents/pi-tools-agent-config.test.ts | 2 +- ...e-aliases-schemas-without-dropping.test.ts | 2 +- src/agents/pi-tools.policy.ts | 10 +- src/agents/pi-tools.read.ts | 3 +- src/agents/pi-tools.ts | 10 +- src/agents/pi-tools.workspace-paths.test.ts | 1 - src/agents/pty-dsr.test.ts | 1 - src/agents/pty-keys.test.ts | 1 - src/agents/sandbox-create-args.test.ts | 1 - src/agents/sandbox/browser.ts | 2 +- src/agents/sandbox/config-hash.ts | 1 - src/agents/sandbox/config.ts | 14 +-- src/agents/sandbox/constants.ts | 1 - src/agents/sandbox/context.ts | 5 +- src/agents/sandbox/docker.ts | 7 +- src/agents/sandbox/prune.ts | 2 +- src/agents/sandbox/registry.ts | 1 - src/agents/sandbox/runtime-status.ts | 4 +- src/agents/sandbox/shared.ts | 1 - src/agents/sandbox/tool-policy.ts | 6 +- src/agents/sandbox/workspace.ts | 1 - .../session-tool-result-guard-wrapper.ts | 1 - src/agents/session-tool-result-guard.test.ts | 1 - ...ult-guard.tool-result-persist-hook.test.ts | 8 +- src/agents/session-tool-result-guard.ts | 3 +- src/agents/session-write-lock.test.ts | 1 - src/agents/shell-utils.test.ts | 1 - src/agents/skills-install.ts | 3 +- src/agents/skills-status.ts | 1 - ...skills.summarize-skill-description.test.ts | 2 - src/agents/skills/config.ts | 2 +- src/agents/skills/env-overrides.ts | 2 +- src/agents/skills/frontmatter.test.ts | 1 - src/agents/skills/frontmatter.ts | 9 +- src/agents/skills/plugin-skills.ts | 1 - src/agents/skills/refresh.ts | 4 +- src/agents/skills/workspace.ts | 20 ++-- src/agents/subagent-announce.ts | 5 +- .../subagent-registry.persistence.test.ts | 1 - src/agents/subagent-registry.store.ts | 3 +- src/agents/system-prompt-params.test.ts | 2 - src/agents/system-prompt-params.ts | 1 - src/agents/system-prompt-report.ts | 3 +- src/agents/system-prompt.ts | 4 +- src/agents/tool-call-id.test.ts | 1 - src/agents/tool-call-id.ts | 3 +- src/agents/tool-display.test.ts | 1 - src/agents/tool-images.test.ts | 1 - src/agents/tool-images.ts | 1 - .../tool-policy.plugin-only-allowlist.test.ts | 1 - src/agents/tools/agent-step.ts | 1 - src/agents/tools/agents-list-tool.ts | 3 +- src/agents/tools/browser-tool.schema.ts | 1 - src/agents/tools/browser-tool.ts | 23 +++-- src/agents/tools/canvas-tool.ts | 3 +- src/agents/tools/common.test.ts | 1 - src/agents/tools/common.ts | 4 +- src/agents/tools/cron-tool.ts | 4 +- src/agents/tools/discord-actions-messaging.ts | 4 +- src/agents/tools/discord-actions.test.ts | 1 - src/agents/tools/gateway-tool.ts | 3 +- src/agents/tools/gateway.test.ts | 1 - src/agents/tools/image-tool.helpers.ts | 1 - src/agents/tools/image-tool.test.ts | 2 - src/agents/tools/image-tool.ts | 10 +- src/agents/tools/memory-tool.ts | 3 +- src/agents/tools/message-tool.test.ts | 3 +- src/agents/tools/message-tool.ts | 14 +-- src/agents/tools/nodes-tool.ts | 6 +- src/agents/tools/session-status-tool.ts | 8 +- .../tools/sessions-announce-target.test.ts | 1 - src/agents/tools/sessions-announce-target.ts | 4 +- src/agents/tools/sessions-helpers.test.ts | 1 - src/agents/tools/sessions-helpers.ts | 2 +- src/agents/tools/sessions-history-tool.ts | 3 +- src/agents/tools/sessions-list-tool.ts | 6 +- src/agents/tools/sessions-send-helpers.ts | 2 +- src/agents/tools/sessions-send-tool.a2a.ts | 3 +- src/agents/tools/sessions-send-tool.ts | 6 +- src/agents/tools/sessions-spawn-tool.ts | 8 +- src/agents/tools/slack-actions.test.ts | 1 - src/agents/tools/slack-actions.ts | 1 - src/agents/tools/telegram-actions.test.ts | 1 - src/agents/tools/telegram-actions.ts | 8 +- src/agents/tools/tts-tool.ts | 5 +- src/agents/tools/web-fetch.ssrf.test.ts | 1 - src/agents/tools/web-fetch.ts | 19 ++-- src/agents/tools/web-search.test.ts | 1 - src/agents/tools/web-search.ts | 3 +- .../tools/web-tools.enabled-defaults.test.ts | 1 - src/agents/tools/web-tools.fetch.test.ts | 1 - .../tools/web-tools.readability.test.ts | 1 - src/agents/tools/whatsapp-actions.test.ts | 1 - src/agents/tools/whatsapp-actions.ts | 1 - src/agents/transcript-policy.ts | 4 +- src/agents/usage.test.ts | 1 - src/agents/workspace-templates.test.ts | 2 - src/agents/workspace-templates.ts | 1 - src/agents/workspace.test.ts | 3 +- src/agents/workspace.ts | 2 +- src/auto-reply/chunk.test.ts | 1 - src/auto-reply/command-auth.ts | 4 +- src/auto-reply/command-control.test.ts | 3 +- src/auto-reply/commands-registry.data.ts | 8 +- src/auto-reply/commands-registry.test.ts | 7 +- src/auto-reply/commands-registry.ts | 8 +- src/auto-reply/dispatch.ts | 4 +- src/auto-reply/envelope.test.ts | 1 - src/auto-reply/envelope.ts | 2 +- src/auto-reply/heartbeat.test.ts | 1 - src/auto-reply/inbound.test.ts | 6 +- src/auto-reply/reply.block-streaming.test.ts | 2 - src/auto-reply/reply.directive.parse.test.ts | 3 +- src/auto-reply/reply.heartbeat-typing.test.ts | 2 - src/auto-reply/reply.media-note.test.ts | 2 - src/auto-reply/reply.queue.test.ts | 2 - ...summary-current-model-provider.e2e.test.ts | 2 +- ...ia-into-sandbox-workspace.security.test.ts | 2 +- ...bound-media-into-sandbox-workspace.test.ts | 2 +- ...ets-active-session-native-stop.e2e.test.ts | 2 +- src/auto-reply/reply/abort.ts | 14 +-- .../reply/agent-runner-execution.ts | 12 +-- src/auto-reply/reply/agent-runner-helpers.ts | 4 +- src/auto-reply/reply/agent-runner-memory.ts | 10 +- src/auto-reply/reply/agent-runner-payloads.ts | 4 +- .../reply/agent-runner-utils.test.ts | 1 - src/auto-reply/reply/agent-runner-utils.ts | 8 +- .../agent-runner.block-streaming.test.ts | 1 - .../reply/agent-runner.claude-cli.test.ts | 2 +- ...emini-sessions-deletes-transcripts.test.ts | 2 +- ...ction-failure-by-resetting-session.test.ts | 2 +- ...eplies-even-if-session-reset-fails.test.ts | 2 +- ...n-count-flush-compaction-completes.test.ts | 2 +- ...lush-turn-updates-session-metadata.test.ts | 2 +- ...nfigured-prompts-memory-flush-runs.test.ts | 2 +- .../agent-runner.messaging-tools.test.ts | 3 +- .../reply/agent-runner.reasoning-tags.test.ts | 3 +- ...agent-runner.response-usage-footer.test.ts | 1 - src/auto-reply/reply/agent-runner.ts | 12 +-- src/auto-reply/reply/bash-command.ts | 6 +- src/auto-reply/reply/block-reply-pipeline.ts | 4 +- src/auto-reply/reply/block-streaming.ts | 4 +- src/auto-reply/reply/commands-allowlist.ts | 30 +++--- src/auto-reply/reply/commands-approve.test.ts | 3 +- src/auto-reply/reply/commands-approve.ts | 6 +- src/auto-reply/reply/commands-bash.ts | 2 +- src/auto-reply/reply/commands-compact.ts | 4 +- src/auto-reply/reply/commands-config.ts | 16 +-- .../reply/commands-context-report.ts | 14 +-- src/auto-reply/reply/commands-context.ts | 4 +- src/auto-reply/reply/commands-core.ts | 24 ++--- src/auto-reply/reply/commands-info.ts | 4 +- src/auto-reply/reply/commands-models.ts | 8 +- src/auto-reply/reply/commands-parsing.test.ts | 3 +- src/auto-reply/reply/commands-plugin.ts | 2 +- src/auto-reply/reply/commands-policy.test.ts | 1 - src/auto-reply/reply/commands-session.ts | 8 +- src/auto-reply/reply/commands-status.ts | 16 +-- src/auto-reply/reply/commands-subagents.ts | 11 +-- src/auto-reply/reply/commands-tts.ts | 2 +- src/auto-reply/reply/commands-types.ts | 2 +- src/auto-reply/reply/commands.test.ts | 6 +- .../reply/directive-handling.auth.ts | 2 +- .../reply/directive-handling.fast-lane.ts | 4 +- .../reply/directive-handling.impl.ts | 12 +-- .../reply/directive-handling.model-picker.ts | 2 +- .../reply/directive-handling.model.test.ts | 3 +- .../reply/directive-handling.model.ts | 8 +- .../reply/directive-handling.parse.ts | 4 +- .../reply/directive-handling.persist.ts | 6 +- .../reply/directive-handling.shared.ts | 2 +- .../reply/dispatch-from-config.test.ts | 1 - src/auto-reply/reply/dispatch-from-config.ts | 8 +- src/auto-reply/reply/followup-runner.test.ts | 3 +- src/auto-reply/reply/followup-runner.ts | 12 +-- src/auto-reply/reply/formatting.test.ts | 1 - .../reply/get-reply-directives-apply.ts | 4 +- src/auto-reply/reply/get-reply-directives.ts | 8 +- .../reply/get-reply-inline-actions.ts | 16 +-- src/auto-reply/reply/get-reply-run.ts | 20 ++-- src/auto-reply/reply/get-reply.ts | 10 +- src/auto-reply/reply/groups.ts | 6 +- src/auto-reply/reply/inbound-context.ts | 2 +- src/auto-reply/reply/inbound-dedupe.ts | 2 +- src/auto-reply/reply/line-directives.ts | 2 +- src/auto-reply/reply/memory-flush.test.ts | 1 - src/auto-reply/reply/memory-flush.ts | 4 +- src/auto-reply/reply/mentions.ts | 4 +- .../model-selection.inherit-parent.test.ts | 1 - src/auto-reply/reply/model-selection.ts | 6 +- src/auto-reply/reply/normalize-reply.test.ts | 1 - src/auto-reply/reply/normalize-reply.ts | 6 +- src/auto-reply/reply/provider-dispatcher.ts | 10 +- .../reply/queue.collect-routing.test.ts | 1 - src/auto-reply/reply/queue/directive.ts | 2 +- src/auto-reply/reply/queue/drain.ts | 2 +- src/auto-reply/reply/queue/enqueue.ts | 2 +- src/auto-reply/reply/queue/settings.ts | 4 +- src/auto-reply/reply/queue/types.ts | 2 +- src/auto-reply/reply/reply-dispatcher.ts | 2 +- src/auto-reply/reply/reply-elevated.ts | 6 +- src/auto-reply/reply/reply-payloads.ts | 4 +- src/auto-reply/reply/reply-routing.test.ts | 1 - src/auto-reply/reply/reply-threading.ts | 4 +- .../reply/response-prefix-template.test.ts | 1 - src/auto-reply/reply/route-reply.test.ts | 13 ++- src/auto-reply/reply/route-reply.ts | 6 +- src/auto-reply/reply/session-reset-model.ts | 8 +- src/auto-reply/reply/session-resets.test.ts | 6 +- src/auto-reply/reply/session-updates.ts | 3 +- src/auto-reply/reply/session.test.ts | 2 - src/auto-reply/reply/session.ts | 13 ++- src/auto-reply/reply/stage-sandbox-media.ts | 4 +- src/auto-reply/reply/streaming-directives.ts | 2 +- src/auto-reply/reply/subagents-utils.test.ts | 1 - src/auto-reply/reply/test-helpers.ts | 1 - src/auto-reply/reply/typing-mode.ts | 2 +- src/auto-reply/reply/typing.test.ts | 1 - src/auto-reply/skill-commands.ts | 3 +- src/auto-reply/status.test.ts | 2 +- src/auto-reply/status.ts | 15 ++- src/auto-reply/templating.ts | 6 +- src/auto-reply/tool-meta.test.ts | 1 - src/browser/bridge-server.ts | 3 +- src/browser/cdp.helpers.test.ts | 1 - src/browser/cdp.helpers.ts | 1 - src/browser/cdp.test.ts | 1 - src/browser/chrome.executables.ts | 1 - src/browser/chrome.profile-decoration.ts | 1 - src/browser/chrome.test.ts | 2 - src/browser/chrome.ts | 5 +- src/browser/client-actions-observe.ts | 2 +- src/browser/client.test.ts | 3 +- src/browser/config.ts | 2 +- src/browser/extension-relay.test.ts | 3 +- src/browser/extension-relay.ts | 4 +- src/browser/profiles-service.test.ts | 4 +- src/browser/profiles-service.ts | 5 +- src/browser/profiles.test.ts | 1 - src/browser/pw-role-snapshot.test.ts | 1 - src/browser/pw-session.test.ts | 1 - src/browser/pw-tools-core.downloads.ts | 4 +- src/browser/pw-tools-core.state.ts | 1 - src/browser/routes/agent.act.ts | 2 +- src/browser/routes/agent.debug.ts | 3 +- src/browser/routes/agent.shared.ts | 4 +- src/browser/routes/agent.snapshot.ts | 5 +- src/browser/routes/agent.storage.ts | 2 +- src/browser/routes/agent.ts | 2 +- src/browser/routes/basic.ts | 4 +- src/browser/routes/dispatcher.ts | 2 +- src/browser/routes/index.ts | 2 +- src/browser/routes/tabs.ts | 2 +- src/browser/routes/utils.test.ts | 1 - src/browser/routes/utils.ts | 2 +- src/browser/screenshot.test.ts | 2 - ...-tab-available.prefers-last-target.test.ts | 1 - .../server-context.remote-tab-ops.test.ts | 1 - src/browser/server-context.ts | 21 ++-- src/browser/server-context.types.ts | 1 - ...-contract-form-layout-act-commands.test.ts | 1 - ....agent-contract-snapshot-endpoints.test.ts | 1 - ...overs-additional-endpoint-branches.test.ts | 1 - ...s-open-profile-unknown-returns-404.test.ts | 1 - ...es-status-starts-browser-requested.test.ts | 1 - ...fault-maxchars-explicitly-set-zero.test.ts | 1 - src/browser/server.ts | 3 +- src/browser/target-id.test.ts | 1 - src/browser/trash.ts | 1 - src/canvas-host/a2ui.ts | 3 +- src/canvas-host/server.test.ts | 2 +- src/canvas-host/server.ts | 9 +- src/channel-web.barrel.test.ts | 1 - src/channels/ack-reactions.test.ts | 1 - src/channels/channel-config.test.ts | 1 - src/channels/chat-type.test.ts | 1 - src/channels/command-gating.test.ts | 1 - src/channels/conversation-label.test.ts | 1 - src/channels/dock.ts | 26 ++--- src/channels/location.test.ts | 1 - src/channels/mention-gating.test.ts | 1 - src/channels/plugins/actions/discord.test.ts | 1 - src/channels/plugins/actions/discord.ts | 2 +- .../discord/handle-action.guild-admin.ts | 2 +- .../plugins/actions/discord/handle-action.ts | 4 +- src/channels/plugins/actions/signal.test.ts | 1 - src/channels/plugins/actions/signal.ts | 2 +- src/channels/plugins/actions/telegram.test.ts | 1 - src/channels/plugins/actions/telegram.ts | 2 +- src/channels/plugins/catalog.test.ts | 1 - src/channels/plugins/catalog.ts | 7 +- src/channels/plugins/config-schema.ts | 1 - src/channels/plugins/config-writes.test.ts | 1 - src/channels/plugins/directory-config.ts | 4 +- src/channels/plugins/group-mentions.ts | 10 +- src/channels/plugins/helpers.ts | 4 +- src/channels/plugins/index.ts | 2 +- src/channels/plugins/load.test.ts | 3 +- src/channels/plugins/load.ts | 2 +- src/channels/plugins/message-actions.ts | 3 +- .../plugins/normalize/imessage.test.ts | 1 - src/channels/plugins/normalize/signal.test.ts | 1 - src/channels/plugins/onboarding/discord.ts | 8 +- src/channels/plugins/onboarding/helpers.ts | 2 +- src/channels/plugins/onboarding/imessage.ts | 6 +- src/channels/plugins/onboarding/signal.ts | 10 +- src/channels/plugins/onboarding/slack.ts | 4 +- src/channels/plugins/onboarding/telegram.ts | 6 +- src/channels/plugins/onboarding/whatsapp.ts | 12 +-- src/channels/plugins/outbound/discord.ts | 2 +- src/channels/plugins/outbound/imessage.ts | 2 +- src/channels/plugins/outbound/load.ts | 2 +- src/channels/plugins/outbound/signal.ts | 2 +- src/channels/plugins/outbound/slack.ts | 2 +- .../plugins/outbound/telegram.test.ts | 1 - src/channels/plugins/outbound/telegram.ts | 2 +- src/channels/plugins/outbound/whatsapp.ts | 4 +- src/channels/plugins/pairing.ts | 2 +- src/channels/plugins/slack.actions.test.ts | 1 - src/channels/plugins/slack.actions.ts | 8 +- .../plugins/status-issues/whatsapp.ts | 2 +- src/channels/plugins/types.adapters.ts | 2 +- src/channels/plugins/whatsapp-heartbeat.ts | 2 +- src/channels/registry.test.ts | 1 - src/channels/reply-prefix.ts | 4 +- src/channels/sender-identity.test.ts | 1 - src/channels/targets.test.ts | 1 - src/channels/typing.test.ts | 1 - src/channels/web/index.test.ts | 1 - src/cli/acp-cli.ts | 1 - src/cli/argv.test.ts | 1 - .../register.element.ts | 2 +- .../register.files-downloads.ts | 2 +- .../register.form-wait-eval.ts | 2 +- src/cli/browser-cli-actions-observe.ts | 2 +- src/cli/browser-cli-debug.ts | 3 +- src/cli/browser-cli-extension.test.ts | 1 - src/cli/browser-cli-extension.ts | 6 +- src/cli/browser-cli-inspect.test.ts | 2 +- src/cli/browser-cli-inspect.ts | 1 - src/cli/browser-cli-state.cookies-storage.ts | 1 - src/cli/browser-cli-state.ts | 1 - src/cli/browser-cli.ts | 7 +- src/cli/channel-options.ts | 2 +- src/cli/channels-cli.ts | 2 +- src/cli/command-format.ts | 2 +- src/cli/config-cli.ts | 5 +- src/cli/cron-cli/register.cron-add.ts | 6 +- src/cli/cron-cli/register.cron-edit.ts | 2 +- src/cli/cron-cli/shared.ts | 4 +- src/cli/daemon-cli/install.ts | 4 +- src/cli/daemon-cli/lifecycle.ts | 4 +- src/cli/daemon-cli/response.ts | 1 - src/cli/daemon-cli/status.gather.ts | 10 +- src/cli/daemon-cli/status.ts | 2 +- src/cli/deps.ts | 2 +- src/cli/devices-cli.ts | 3 +- src/cli/directory-cli.ts | 3 +- src/cli/dns-cli.ts | 4 +- src/cli/docs-cli.ts | 1 - src/cli/exec-approvals-cli.ts | 11 +-- src/cli/gateway-cli/dev.ts | 3 +- src/cli/gateway-cli/register.ts | 6 +- src/cli/gateway-cli/run-loop.ts | 2 +- src/cli/gateway-cli/run.ts | 5 +- src/cli/hooks-cli.ts | 14 +-- src/cli/logs-cli.ts | 2 +- src/cli/memory-cli.ts | 10 +- src/cli/models-cli.ts | 1 - src/cli/node-cli/daemon.ts | 6 +- src/cli/node-cli/register.ts | 6 +- src/cli/nodes-camera.ts | 1 - src/cli/nodes-canvas.test.ts | 1 - src/cli/nodes-canvas.ts | 1 - src/cli/nodes-cli/register.camera.ts | 6 +- src/cli/nodes-cli/register.canvas.ts | 6 +- src/cli/nodes-cli/register.invoke.ts | 16 +-- src/cli/nodes-cli/register.location.ts | 2 +- src/cli/nodes-cli/register.notify.ts | 2 +- src/cli/nodes-cli/register.pairing.ts | 8 +- src/cli/nodes-cli/register.screen.ts | 4 +- src/cli/nodes-cli/register.status.ts | 10 +- src/cli/nodes-cli/rpc.ts | 2 +- src/cli/nodes-screen.test.ts | 1 - src/cli/nodes-screen.ts | 1 - src/cli/pairing-cli.ts | 2 +- src/cli/parse-duration.test.ts | 1 - src/cli/plugin-registry.ts | 2 +- src/cli/plugins-cli.ts | 7 +- src/cli/profile.ts | 1 - src/cli/program/build-program.ts | 2 +- src/cli/program/command-registry.ts | 3 +- src/cli/program/config-guard.ts | 8 +- src/cli/program/help.ts | 2 +- src/cli/program/message/helpers.ts | 2 +- src/cli/program/message/register.broadcast.ts | 2 +- .../program/message/register.emoji-sticker.ts | 2 +- .../message/register.permissions-search.ts | 2 +- src/cli/program/message/register.poll.ts | 2 +- src/cli/program/preaction.ts | 12 +-- src/cli/program/register.agent.ts | 6 +- src/cli/program/register.message.ts | 4 +- src/cli/program/register.onboard.ts | 2 +- src/cli/program/register.setup.ts | 2 +- src/cli/progress.test.ts | 1 - src/cli/progress.ts | 2 +- src/cli/prompt.test.ts | 1 - src/cli/prompt.ts | 1 - src/cli/route.ts | 8 +- src/cli/run-main.test.ts | 1 - src/cli/run-main.ts | 3 +- src/cli/sandbox-cli.ts | 3 +- src/cli/security-cli.ts | 1 - src/cli/skills-cli.test.ts | 1 - src/cli/system-cli.ts | 3 +- src/cli/update-cli.test.ts | 1 - src/cli/update-cli.ts | 69 +++++++------ src/cli/wait.test.ts | 1 - src/cli/webhooks-cli.ts | 13 ++- src/commands/agent-via-gateway.test.ts | 5 +- src/commands/agent-via-gateway.ts | 10 +- src/commands/agent.delivery.test.ts | 3 +- src/commands/agent.test.ts | 10 +- src/commands/agent.ts | 12 +-- src/commands/agent/delivery.ts | 16 +-- src/commands/agent/run-context.ts | 2 +- src/commands/agent/session-store.ts | 2 +- src/commands/agent/session.ts | 3 +- src/commands/agents.add.test.ts | 1 - src/commands/agents.bindings.ts | 6 +- src/commands/agents.command-shared.ts | 4 +- src/commands/agents.commands.add.ts | 7 +- src/commands/agents.commands.delete.ts | 3 +- src/commands/agents.commands.identity.ts | 5 +- src/commands/agents.commands.list.ts | 6 +- src/commands/agents.config.ts | 4 +- src/commands/agents.identity.test.ts | 2 - src/commands/agents.providers.ts | 6 +- src/commands/agents.test.ts | 2 - src/commands/auth-choice-options.test.ts | 1 - src/commands/auth-choice-prompt.ts | 2 +- src/commands/auth-choice.apply.anthropic.ts | 2 +- .../auth-choice.apply.api-providers.ts | 2 +- .../auth-choice.apply.github-copilot.ts | 2 +- src/commands/auth-choice.apply.minimax.ts | 4 +- src/commands/auth-choice.apply.oauth.ts | 2 +- src/commands/auth-choice.apply.openai.ts | 4 +- .../auth-choice.apply.plugin-provider.ts | 10 +- src/commands/auth-choice.apply.ts | 2 +- src/commands/auth-choice.model-check.ts | 4 +- src/commands/auth-choice.test.ts | 4 +- ....adds-non-default-telegram-account.test.ts | 5 +- ...time-errors-channels-status-output.test.ts | 3 +- src/commands/channels/add-mutators.ts | 2 +- src/commands/channels/add.ts | 4 +- src/commands/channels/capabilities.test.ts | 5 +- src/commands/channels/capabilities.ts | 6 +- src/commands/channels/list.ts | 2 +- src/commands/channels/logs.ts | 2 +- src/commands/channels/resolve.ts | 6 +- src/commands/channels/status.ts | 4 +- src/commands/chutes-oauth.test.ts | 2 - src/commands/chutes-oauth.ts | 4 +- src/commands/cleanup-utils.ts | 3 +- src/commands/configure.channels.ts | 4 +- src/commands/configure.commands.ts | 2 +- src/commands/configure.daemon.ts | 8 +- src/commands/configure.gateway-auth.test.ts | 1 - src/commands/configure.gateway-auth.ts | 4 +- src/commands/configure.gateway.test.ts | 1 - src/commands/configure.gateway.ts | 2 +- src/commands/configure.shared.ts | 1 - src/commands/configure.wizard.test.ts | 1 - src/commands/configure.wizard.ts | 18 ++-- src/commands/daemon-install-helpers.ts | 8 +- src/commands/dashboard.test.ts | 1 - src/commands/dashboard.ts | 2 +- src/commands/docs.ts | 6 +- ...octor-auth.deprecated-cli-profiles.test.ts | 4 +- src/commands/doctor-auth.ts | 6 +- src/commands/doctor-config-flow.test.ts | 2 - src/commands/doctor-config-flow.ts | 12 +-- src/commands/doctor-format.ts | 4 +- src/commands/doctor-gateway-daemon-flow.ts | 12 +-- src/commands/doctor-gateway-health.ts | 4 +- src/commands/doctor-gateway-services.ts | 7 +- src/commands/doctor-install.ts | 1 - src/commands/doctor-legacy-config.test.ts | 1 - ...form-notes.launchctl-env-overrides.test.ts | 4 +- src/commands/doctor-platform-notes.ts | 1 - src/commands/doctor-prompter.ts | 1 - src/commands/doctor-sandbox.ts | 7 +- src/commands/doctor-security.test.ts | 1 - src/commands/doctor-security.ts | 8 +- src/commands/doctor-state-integrity.ts | 3 +- src/commands/doctor-state-migrations.test.ts | 2 - src/commands/doctor-ui.ts | 4 +- src/commands/doctor-update.ts | 10 +- src/commands/doctor-workspace-status.ts | 2 +- src/commands/doctor-workspace.test.ts | 1 - src/commands/doctor-workspace.ts | 1 - src/commands/doctor.ts | 9 +- src/commands/gateway-status.ts | 5 +- src/commands/gateway-status/helpers.ts | 2 +- .../google-gemini-model-default.test.ts | 1 - src/commands/health-format.test.ts | 1 - src/commands/health.command.coverage.test.ts | 5 +- src/commands/health.snapshot.test.ts | 6 +- src/commands/health.test.ts | 1 - src/commands/health.ts | 8 +- src/commands/message-format.ts | 4 +- src/commands/message.test.ts | 1 - src/commands/message.ts | 4 +- src/commands/model-picker.test.ts | 3 +- src/commands/model-picker.ts | 4 +- src/commands/models/aliases.ts | 2 +- src/commands/models/auth-order.ts | 2 +- src/commands/models/auth.ts | 45 +++++---- src/commands/models/fallbacks.ts | 2 +- src/commands/models/image-fallbacks.ts | 2 +- src/commands/models/list.auth-overview.ts | 4 +- src/commands/models/list.configured.ts | 4 +- src/commands/models/list.list-command.ts | 5 +- src/commands/models/list.probe.ts | 9 +- src/commands/models/list.registry.ts | 9 +- src/commands/models/list.status-command.ts | 10 +- src/commands/models/list.table.ts | 2 +- src/commands/models/scan.ts | 2 +- src/commands/models/set-image.ts | 2 +- src/commands/models/set.ts | 2 +- src/commands/models/shared.ts | 2 +- src/commands/node-daemon-install-helpers.ts | 2 +- src/commands/onboard-auth.config-core.ts | 2 +- src/commands/onboard-auth.config-opencode.ts | 2 +- src/commands/onboard-auth.test.ts | 4 +- src/commands/onboard-channels.test.ts | 7 +- src/commands/onboard-channels.ts | 44 ++++----- src/commands/onboard-helpers.test.ts | 1 - src/commands/onboard-helpers.ts | 12 +-- src/commands/onboard-hooks.test.ts | 4 +- src/commands/onboard-hooks.ts | 2 +- src/commands/onboard-interactive.ts | 2 +- ...onboard-non-interactive.ai-gateway.test.ts | 1 - .../onboard-non-interactive.gateway.test.ts | 2 - .../onboard-non-interactive.token.test.ts | 1 - src/commands/onboard-non-interactive.ts | 6 +- .../onboard-non-interactive/api-keys.ts | 4 +- src/commands/onboard-non-interactive/local.ts | 7 +- .../local/auth-choice.ts | 8 +- .../local/daemon-install.ts | 6 +- .../local/gateway-config.ts | 2 +- .../local/workspace.ts | 2 +- .../onboard-non-interactive/remote.ts | 6 +- src/commands/onboard-remote.ts | 2 +- src/commands/onboard-skills.ts | 6 +- src/commands/onboard.ts | 6 +- .../onboarding/__tests__/test-utils.ts | 1 - src/commands/onboarding/plugin-install.ts | 12 +-- src/commands/onboarding/registry.ts | 2 +- .../openai-codex-model-default.test.ts | 1 - .../opencode-zen-model-default.test.ts | 1 - src/commands/reset.ts | 5 +- src/commands/sandbox-display.ts | 2 +- src/commands/sandbox-explain.ts | 4 +- src/commands/sandbox-formatters.test.ts | 1 - src/commands/sandbox.test.ts | 1 - src/commands/sandbox.ts | 3 +- src/commands/sessions.test.ts | 1 - src/commands/sessions.ts | 2 +- src/commands/setup.ts | 6 +- src/commands/signal-install.ts | 3 +- src/commands/status-all.ts | 12 +-- src/commands/status-all/agents.ts | 2 +- src/commands/status-all/channels.ts | 4 +- src/commands/status.agent-local.ts | 1 - src/commands/status.command.ts | 24 ++--- src/commands/status.daemon.ts | 2 +- src/commands/status.link-channel.ts | 4 +- src/commands/status.scan.ts | 6 +- src/commands/status.summary.ts | 2 +- src/commands/status.update.ts | 2 +- src/commands/systemd-linger.ts | 2 +- src/commands/uninstall.ts | 5 +- src/config/agent-dirs.ts | 2 +- src/config/channel-capabilities.test.ts | 2 +- src/config/channel-capabilities.ts | 4 +- src/config/commands.ts | 2 +- src/config/config-paths.test.ts | 1 - src/config/config.backup-rotation.test.ts | 4 +- src/config/config.identity-avatar.test.ts | 2 - src/config/config.plugin-validation.test.ts | 2 - .../config.skills-entries-config.test.ts | 1 - .../config.telegram-custom-commands.test.ts | 1 - src/config/config.tools-alsoAllow.test.ts | 1 - src/config/config.web-search-provider.test.ts | 1 - src/config/defaults.ts | 6 +- src/config/env-substitution.test.ts | 1 - src/config/group-policy.ts | 2 +- src/config/includes.test.ts | 2 - src/config/includes.ts | 3 +- src/config/io.compat.test.ts | 1 - src/config/io.ts | 8 +- src/config/legacy-migrate.ts | 2 +- src/config/legacy.ts | 2 +- src/config/markdown-tables.ts | 4 +- src/config/model-alias-defaults.test.ts | 2 +- src/config/normalize-paths.test.ts | 2 - src/config/normalize-paths.ts | 2 +- src/config/paths.test.ts | 1 - src/config/plugin-auto-enable.ts | 10 +- src/config/runtime-overrides.test.ts | 2 +- src/config/runtime-overrides.ts | 2 +- src/config/schema.test.ts | 1 - src/config/sessions.test.ts | 1 - src/config/sessions/group.ts | 2 +- src/config/sessions/main-session.ts | 2 +- src/config/sessions/metadata.test.ts | 1 - src/config/sessions/metadata.ts | 2 +- src/config/sessions/paths.ts | 2 +- src/config/sessions/reset.ts | 2 +- src/config/sessions/session-key.ts | 2 +- src/config/sessions/store.ts | 7 +- src/config/sessions/transcript.ts | 8 +- src/config/sessions/types.ts | 3 +- src/config/slack-http-config.test.ts | 1 - src/config/slack-token-validation.test.ts | 1 - src/config/test-helpers.ts | 1 - src/config/types.agent-defaults.ts | 2 +- src/config/types.channels.ts | 2 +- src/config/ui-seam-color.test.ts | 1 - src/config/validation.ts | 3 +- src/config/zod-schema.agent-runtime.ts | 1 - src/config/zod-schema.core.ts | 1 - src/config/zod-schema.providers-core.ts | 15 ++- src/config/zod-schema.providers-whatsapp.ts | 5 +- src/config/zod-schema.providers.ts | 5 +- src/config/zod-schema.session.ts | 1 - src/config/zod-schema.ts | 2 +- ...onse-has-heartbeat-ok-but-includes.test.ts | 4 +- ...p-recipient-besteffortdeliver-true.test.ts | 18 ++-- ....uses-last-non-empty-agent-text-as.test.ts | 4 +- src/cron/isolated-agent/delivery-target.ts | 4 +- src/cron/isolated-agent/run.ts | 20 ++-- src/cron/isolated-agent/session.ts | 1 - src/cron/normalize.test.ts | 1 - src/cron/normalize.ts | 2 +- src/cron/run-log.test.ts | 2 - src/cron/schedule.test.ts | 1 - .../service.prevents-duplicate-timers.test.ts | 2 - ...runs-one-shot-main-job-disables-it.test.ts | 2 - ...s-main-jobs-empty-systemevent-text.test.ts | 2 - src/cron/service.ts | 2 +- src/cron/service/jobs.ts | 5 +- src/cron/service/normalize.ts | 2 +- src/cron/service/ops.ts | 2 +- src/cron/service/store.ts | 4 +- src/cron/service/timer.ts | 2 +- src/cron/store.ts | 5 +- src/daemon/diagnostics.ts | 1 - src/daemon/inspect.ts | 1 - src/daemon/launchd.test.ts | 2 - src/daemon/launchd.ts | 5 +- src/daemon/node-service.ts | 2 +- src/daemon/paths.test.ts | 2 - src/daemon/paths.ts | 1 - src/daemon/runtime-paths.ts | 1 - src/daemon/schtasks.test.ts | 2 - src/daemon/schtasks.ts | 3 +- src/daemon/service-env.ts | 1 - src/daemon/service.ts | 2 +- src/daemon/systemd-unit.test.ts | 1 - src/daemon/systemd.test.ts | 1 - src/daemon/systemd.ts | 4 +- src/discord/api.test.ts | 1 - src/discord/chunk.test.ts | 1 - src/discord/directory-live.ts | 2 +- src/discord/gateway-logging.test.ts | 1 - src/discord/gateway-logging.ts | 3 +- src/discord/monitor.gateway.test.ts | 2 - ...ild-messages-mentionpatterns-match.test.ts | 1 - src/discord/monitor/allow-list.ts | 3 +- src/discord/monitor/exec-approvals.test.ts | 2 +- src/discord/monitor/exec-approvals.ts | 10 +- src/discord/monitor/listeners.ts | 3 +- .../message-handler.inbound-contract.test.ts | 2 - .../monitor/message-handler.preflight.ts | 17 ++-- .../monitor/message-handler.process.test.ts | 1 - .../monitor/message-handler.process.ts | 24 ++--- src/discord/monitor/message-handler.ts | 11 +-- src/discord/monitor/message-utils.ts | 1 - src/discord/monitor/native-command.ts | 23 +++-- src/discord/monitor/presence-cache.test.ts | 2 +- src/discord/monitor/provider.ts | 10 +- src/discord/monitor/reply-context.ts | 1 - src/discord/monitor/reply-delivery.ts | 3 +- src/discord/monitor/system-events.ts | 1 - src/discord/monitor/threading.test.ts | 2 +- src/discord/monitor/threading.ts | 6 +- src/discord/probe.intents.test.ts | 1 - src/discord/resolve-channels.test.ts | 1 - src/discord/send.channels.ts | 2 +- src/discord/send.creates-thread.test.ts | 1 - src/discord/send.emojis-stickers.ts | 3 +- src/discord/send.guild.ts | 2 +- src/discord/send.messages.ts | 2 +- src/discord/send.outbound.ts | 6 +- src/discord/send.permissions.ts | 7 +- src/discord/send.reactions.ts | 3 +- .../send.sends-basic-channel-messages.test.ts | 1 - src/discord/send.shared.ts | 7 +- src/discord/send.types.ts | 1 - src/discord/targets.test.ts | 1 - src/discord/targets.ts | 4 +- src/discord/token.test.ts | 1 - src/docs/slash-commands-doc.test.ts | 1 - src/entry.ts | 1 - src/gateway/assistant-identity.test.ts | 1 - src/gateway/assistant-identity.ts | 2 +- src/gateway/auth.test.ts | 1 - src/gateway/auth.ts | 2 +- src/gateway/boot.test.ts | 1 - src/gateway/boot.ts | 5 +- src/gateway/call.ts | 4 +- src/gateway/chat-attachments.test.ts | 1 - src/gateway/client.test.ts | 2 +- src/gateway/client.ts | 16 +-- src/gateway/config-reload.test.ts | 2 +- src/gateway/config-reload.ts | 2 +- src/gateway/control-ui.test.ts | 1 - src/gateway/control-ui.ts | 3 +- src/gateway/exec-approval-manager.ts | 1 - src/gateway/gateway-cli-backend.live.test.ts | 1 - .../gateway-models.profiles.live.test.ts | 7 +- src/gateway/gateway.e2e.test.ts | 4 +- src/gateway/hooks-mapping.test.ts | 1 - src/gateway/hooks-mapping.ts | 3 +- src/gateway/hooks.test.ts | 2 +- src/gateway/hooks.ts | 4 +- src/gateway/http-common.ts | 1 - src/gateway/http-utils.ts | 3 +- src/gateway/net.test.ts | 1 - src/gateway/net.ts | 1 - src/gateway/node-registry.ts | 1 - src/gateway/openai-http.e2e.test.ts | 1 - src/gateway/openai-http.ts | 3 +- src/gateway/openresponses-http.e2e.test.ts | 1 - src/gateway/openresponses-http.ts | 51 +++++----- src/gateway/probe.ts | 1 - src/gateway/protocol/index.test.ts | 3 +- src/gateway/protocol/schema/agent.ts | 1 - .../protocol/schema/agents-models-skills.ts | 1 - src/gateway/protocol/schema/channels.ts | 1 - src/gateway/protocol/schema/config.ts | 1 - src/gateway/protocol/schema/cron.ts | 1 - src/gateway/protocol/schema/devices.ts | 1 - src/gateway/protocol/schema/exec-approvals.ts | 1 - src/gateway/protocol/schema/logs-chat.ts | 1 - src/gateway/protocol/schema/nodes.ts | 1 - .../protocol/schema/protocol-schemas.ts | 19 ++-- src/gateway/protocol/schema/sessions.ts | 1 - src/gateway/protocol/schema/types.ts | 15 ++- src/gateway/protocol/schema/wizard.ts | 1 - src/gateway/server-broadcast.test.ts | 3 +- src/gateway/server-channels.ts | 8 +- src/gateway/server-chat.agent-events.test.ts | 1 - src/gateway/server-close.ts | 4 +- src/gateway/server-cron.ts | 2 +- src/gateway/server-http.ts | 12 +-- src/gateway/server-maintenance.ts | 6 +- src/gateway/server-methods.ts | 2 +- .../server-methods/agent-timestamp.test.ts | 2 +- src/gateway/server-methods/agent-timestamp.ts | 2 +- src/gateway/server-methods/agent.test.ts | 1 - src/gateway/server-methods/agent.ts | 12 +-- src/gateway/server-methods/agents.ts | 2 +- src/gateway/server-methods/browser.ts | 4 +- src/gateway/server-methods/channels.ts | 8 +- src/gateway/server-methods/chat.ts | 11 +-- src/gateway/server-methods/config.ts | 6 +- src/gateway/server-methods/connect.ts | 2 +- src/gateway/server-methods/cron.ts | 4 +- src/gateway/server-methods/devices.ts | 2 +- .../server-methods/exec-approval.test.ts | 2 +- src/gateway/server-methods/exec-approval.ts | 4 +- src/gateway/server-methods/exec-approvals.ts | 2 +- src/gateway/server-methods/health.ts | 2 +- src/gateway/server-methods/logs.test.ts | 2 - src/gateway/server-methods/logs.ts | 2 +- src/gateway/server-methods/models.ts | 2 +- src/gateway/server-methods/nodes.helpers.ts | 2 +- src/gateway/server-methods/nodes.ts | 8 +- src/gateway/server-methods/send.test.ts | 1 - src/gateway/server-methods/send.ts | 8 +- src/gateway/server-methods/sessions.ts | 3 +- src/gateway/server-methods/skills.ts | 4 +- src/gateway/server-methods/system.ts | 2 +- src/gateway/server-methods/talk.ts | 2 +- src/gateway/server-methods/tts.ts | 2 +- src/gateway/server-methods/types.ts | 2 +- src/gateway/server-methods/update.ts | 4 +- src/gateway/server-methods/usage.ts | 6 +- src/gateway/server-methods/voicewake.ts | 2 +- src/gateway/server-methods/web.ts | 2 +- src/gateway/server-methods/wizard.ts | 2 +- src/gateway/server-node-events.test.ts | 10 +- src/gateway/server-node-events.ts | 2 +- src/gateway/server-plugins.ts | 2 +- src/gateway/server-reload-handlers.ts | 8 +- src/gateway/server-restart-sentinel.ts | 2 +- src/gateway/server-runtime-state.ts | 18 ++-- src/gateway/server-startup-log.ts | 2 +- src/gateway/server-startup.ts | 8 +- src/gateway/server-ws-runtime.ts | 4 +- ...r.agent.gateway-server-agent-b.e2e.test.ts | 4 +- src/gateway/server.auth.e2e.test.ts | 4 +- ...ver.chat.gateway-server-chat-b.e2e.test.ts | 2 +- ...erver.chat.gateway-server-chat.e2e.test.ts | 2 +- src/gateway/server.config-apply.e2e.test.ts | 1 - src/gateway/server.config-patch.e2e.test.ts | 2 - src/gateway/server.health.e2e.test.ts | 2 +- src/gateway/server.impl.ts | 74 +++++++------- src/gateway/server.ios-client-id.e2e.test.ts | 1 - .../server.models-voicewake-misc.e2e.test.ts | 5 +- src/gateway/server.nodes.late-invoke.test.ts | 3 +- .../server.roles-allowlist-update.e2e.test.ts | 1 - ...ions.gateway-server-sessions-a.e2e.test.ts | 2 +- src/gateway/server/health-state.ts | 4 +- src/gateway/server/hooks.ts | 7 +- src/gateway/server/http-listen.ts | 1 - src/gateway/server/plugins-http.test.ts | 3 +- src/gateway/server/plugins-http.ts | 1 - src/gateway/server/ws-connection.ts | 12 +-- .../server/ws-connection/message-handler.ts | 18 ++-- src/gateway/server/ws-types.ts | 1 - src/gateway/session-utils.fs.ts | 3 +- src/gateway/session-utils.ts | 13 ++- src/gateway/sessions-patch.ts | 9 +- src/gateway/test-helpers.e2e.ts | 2 - src/gateway/test-helpers.mocks.ts | 5 +- src/gateway/test-helpers.server.ts | 7 +- src/gateway/tools-invoke-http.test.ts | 10 +- src/gateway/tools-invoke-http.ts | 4 +- src/gateway/ws-log.ts | 4 +- src/git-hooks.test.ts | 1 - src/hooks/bundled/boot-md/handler.ts | 4 +- src/hooks/bundled/command-logger/handler.ts | 2 +- .../bundled/session-memory/handler.test.ts | 6 +- src/hooks/bundled/session-memory/handler.ts | 4 +- src/hooks/bundled/soul-evil/handler.test.ts | 8 +- src/hooks/config.ts | 2 +- src/hooks/frontmatter.ts | 7 +- src/hooks/gmail-ops.ts | 21 ++-- src/hooks/gmail-setup-utils.test.ts | 1 - src/hooks/gmail-setup-utils.ts | 1 - src/hooks/gmail-watcher.ts | 4 +- src/hooks/gmail.ts | 1 - src/hooks/hooks-status.ts | 3 +- src/hooks/install.test.ts | 2 +- src/hooks/install.ts | 5 +- src/hooks/llm-slug-generator.ts | 2 +- src/hooks/loader.test.ts | 4 +- src/hooks/loader.ts | 6 +- src/hooks/plugin-hooks.ts | 3 +- src/hooks/soul-evil.test.ts | 6 +- src/hooks/soul-evil.ts | 3 +- src/hooks/workspace.ts | 19 ++-- src/imessage/client.ts | 1 - ...essages-without-mention-by-default.test.ts | 1 - ...last-route-chat-id-direct-messages.test.ts | 1 - src/imessage/monitor/deliver.ts | 6 +- src/imessage/monitor/monitor-provider.ts | 9 +- src/imessage/probe.test.ts | 1 - src/imessage/probe.ts | 2 +- src/imessage/send.ts | 2 +- src/imessage/targets.test.ts | 1 - src/index.ts | 3 +- src/infra/archive.test.ts | 2 +- src/infra/archive.ts | 2 +- src/infra/binaries.test.ts | 1 - src/infra/bonjour-ciao.ts | 1 - src/infra/bonjour-discovery.test.ts | 1 - src/infra/bonjour.test.ts | 2 - src/infra/brew.test.ts | 2 - src/infra/channel-activity.test.ts | 1 - src/infra/channel-summary.ts | 2 +- src/infra/channels-status-issues.ts | 2 +- src/infra/control-ui-assets.test.ts | 2 - src/infra/control-ui-assets.ts | 1 - src/infra/dedupe.test.ts | 1 - src/infra/device-auth-store.ts | 1 - src/infra/diagnostic-events.test.ts | 1 - src/infra/diagnostic-flags.test.ts | 1 - src/infra/dotenv.test.ts | 2 - src/infra/dotenv.ts | 4 +- src/infra/env-file.ts | 1 - src/infra/env.test.ts | 1 - src/infra/exec-approval-forwarder.test.ts | 1 - src/infra/exec-approval-forwarder.ts | 6 +- src/infra/exec-approvals.test.ts | 2 - src/infra/exec-approvals.ts | 1 - src/infra/fetch.test.ts | 1 - src/infra/fs-safe.ts | 2 +- src/infra/gateway-lock.test.ts | 4 +- src/infra/gateway-lock.ts | 3 +- ...espects-ackmaxchars-heartbeat-acks.test.ts | 12 +-- ...tbeat-runner.returns-default-unset.test.ts | 16 +-- ...ner.sender-prefers-delivery-target.test.ts | 11 +-- src/infra/heartbeat-runner.ts | 15 ++- src/infra/is-main.test.ts | 1 - src/infra/net/ssrf.pinning.test.ts | 1 - src/infra/net/ssrf.ts | 2 +- src/infra/node-shell.test.ts | 1 - src/infra/outbound/agent-delivery.ts | 6 +- src/infra/outbound/channel-selection.ts | 2 +- src/infra/outbound/deliver.test.ts | 3 +- src/infra/outbound/deliver.ts | 24 ++--- src/infra/outbound/envelope.test.ts | 3 +- src/infra/outbound/format.test.ts | 1 - src/infra/outbound/format.ts | 4 +- .../outbound/message-action-runner.test.ts | 9 +- .../message-action-runner.threading.test.ts | 3 +- src/infra/outbound/message-action-runner.ts | 33 +++---- src/infra/outbound/message.test.ts | 1 - src/infra/outbound/message.ts | 4 +- src/infra/outbound/outbound-policy.test.ts | 1 - src/infra/outbound/outbound-policy.ts | 2 +- src/infra/outbound/outbound-send-service.ts | 4 +- src/infra/outbound/outbound-session.test.ts | 1 - src/infra/outbound/outbound-session.ts | 10 +- src/infra/outbound/payloads.test.ts | 1 - src/infra/outbound/payloads.ts | 2 +- src/infra/outbound/target-normalization.ts | 2 +- src/infra/outbound/target-resolver.test.ts | 1 - src/infra/outbound/target-resolver.ts | 4 +- src/infra/outbound/targets.test.ts | 5 +- src/infra/outbound/targets.ts | 6 +- src/infra/path-env.test.ts | 2 - src/infra/path-env.ts | 3 +- src/infra/ports-format.ts | 2 +- src/infra/ports-inspect.ts | 6 +- src/infra/ports.test.ts | 1 - src/infra/ports.ts | 4 +- src/infra/provider-usage.auth.ts | 3 +- src/infra/provider-usage.fetch.antigravity.ts | 2 +- src/infra/provider-usage.fetch.claude.ts | 2 +- src/infra/provider-usage.fetch.codex.ts | 2 +- src/infra/provider-usage.fetch.copilot.ts | 2 +- src/infra/provider-usage.fetch.gemini.ts | 4 +- src/infra/provider-usage.fetch.minimax.ts | 2 +- src/infra/provider-usage.fetch.zai.ts | 2 +- src/infra/provider-usage.format.ts | 2 +- src/infra/provider-usage.load.ts | 12 +-- src/infra/provider-usage.shared.ts | 2 +- src/infra/restart-sentinel.test.ts | 1 - src/infra/restart-sentinel.ts | 1 - src/infra/restart.test.ts | 1 - src/infra/retry-policy.test.ts | 1 - src/infra/retry-policy.ts | 1 - src/infra/retry.test.ts | 1 - src/infra/runtime-guard.test.ts | 1 - src/infra/runtime-guard.ts | 1 - src/infra/session-cost-usage.test.ts | 2 - src/infra/session-cost-usage.ts | 3 +- src/infra/shell-env.path.test.ts | 1 - src/infra/shell-env.test.ts | 1 - src/infra/shell-env.ts | 1 - src/infra/skills-remote.ts | 10 +- src/infra/ssh-config.ts | 1 - src/infra/ssh-tunnel.test.ts | 1 - src/infra/ssh-tunnel.ts | 1 - src/infra/state-migrations.fs.test.ts | 1 - src/infra/state-migrations.fs.ts | 3 +- src/infra/state-migrations.ts | 9 +- src/infra/system-events.test.ts | 3 +- src/infra/tailnet.test.ts | 2 - src/infra/tailscale.test.ts | 1 - src/infra/tailscale.ts | 2 +- src/infra/tls/fingerprint.test.ts | 1 - src/infra/tls/gateway.ts | 1 - src/infra/transport-ready.test.ts | 1 - src/infra/transport-ready.ts | 2 +- ...handled-rejections.fatal-detection.test.ts | 3 +- src/infra/unhandled-rejections.test.ts | 1 - src/infra/unhandled-rejections.ts | 1 - src/infra/update-check.test.ts | 1 - src/infra/update-check.ts | 1 - src/infra/update-runner.test.ts | 1 - src/infra/update-runner.ts | 7 +- src/infra/update-startup.test.ts | 1 - src/infra/update-startup.ts | 11 +-- src/infra/voicewake.test.ts | 2 - src/infra/widearea-dns.test.ts | 1 - src/infra/widearea-dns.ts | 1 - src/infra/ws.ts | 3 +- src/line/accounts.test.ts | 2 +- src/line/auto-reply-delivery.test.ts | 1 - src/line/auto-reply-delivery.ts | 2 +- src/line/bot-handlers.test.ts | 2 +- src/line/bot-handlers.ts | 6 +- src/line/bot-message-context.test.ts | 4 +- src/line/bot-message-context.ts | 4 +- src/line/bot.ts | 6 +- src/line/download.ts | 6 +- src/line/monitor.ts | 20 ++-- src/line/send.ts | 2 +- src/line/webhook.ts | 4 +- src/link-understanding/apply.ts | 2 +- src/link-understanding/detect.test.ts | 1 - src/link-understanding/runner.ts | 6 +- src/logger.test.ts | 4 +- src/logging.ts | 8 +- src/logging/config.ts | 6 +- src/logging/console-capture.test.ts | 2 - src/logging/console-prefix.test.ts | 1 - src/logging/console.ts | 3 +- src/logging/logger.ts | 6 +- src/logging/parse-log-line.test.ts | 1 - src/logging/redact.test.ts | 1 - src/logging/redact.ts | 1 - src/logging/subsystem.ts | 9 +- src/markdown/frontmatter.test.ts | 1 - src/markdown/ir.ts | 3 +- src/media-understanding/apply.test.ts | 4 +- src/media-understanding/apply.ts | 19 ++-- src/media-understanding/attachments.ts | 7 +- .../providers/deepgram/audio.live.test.ts | 1 - .../providers/deepgram/audio.test.ts | 1 - .../providers/google/video.test.ts | 1 - src/media-understanding/providers/image.ts | 7 +- src/media-understanding/providers/index.ts | 2 +- .../providers/openai/audio.test.ts | 1 - .../providers/openai/audio.ts | 1 - src/media-understanding/resolve.test.ts | 1 - src/media-understanding/resolve.ts | 4 +- .../runner.auto-audio.test.ts | 4 +- .../runner.deepgram.test.ts | 4 +- src/media-understanding/runner.ts | 53 +++++----- .../runner.vision-skip.test.ts | 1 - src/media-understanding/scope.test.ts | 1 - src/media/fetch.test.ts | 1 - src/media/fetch.ts | 1 - src/media/host.test.ts | 3 +- src/media/host.ts | 2 +- src/media/image-ops.ts | 1 - src/media/input-files.ts | 4 +- src/media/mime.test.ts | 1 - src/media/mime.ts | 3 +- src/media/parse.test.ts | 1 - src/media/server.test.ts | 3 +- src/media/server.ts | 4 +- src/media/store.redirect.test.ts | 3 +- src/media/store.test.ts | 3 +- src/media/store.ts | 2 +- src/memory/batch-gemini.ts | 4 +- src/memory/batch-openai.ts | 2 +- src/memory/embeddings-gemini.ts | 2 +- src/memory/embeddings-openai.ts | 2 +- src/memory/embeddings.test.ts | 1 - src/memory/embeddings.ts | 3 +- src/memory/hybrid.test.ts | 1 - src/memory/index.test.ts | 2 - src/memory/internal.test.ts | 2 - src/memory/manager-cache-key.ts | 3 +- src/memory/manager-search.ts | 1 - src/memory/manager.async-search.test.ts | 2 - src/memory/manager.atomic-reindex.test.ts | 2 - src/memory/manager.batch.test.ts | 2 - src/memory/manager.embedding-batches.test.ts | 2 - .../manager.sync-errors-do-not-crash.test.ts | 2 - src/memory/manager.ts | 30 +++--- src/memory/manager.vector-dedupe.test.ts | 2 - src/memory/provider-key.ts | 2 +- src/memory/session-files.ts | 1 - src/memory/sqlite.ts | 1 - src/memory/sync-memory-files.ts | 1 - src/memory/sync-session-files.ts | 3 +- src/node-host/config.ts | 1 - src/node-host/runner.test.ts | 1 - src/node-host/runner.ts | 28 +++--- src/pairing/pairing-labels.ts | 2 +- src/pairing/pairing-messages.test.ts | 1 - src/pairing/pairing-messages.ts | 2 +- src/pairing/pairing-store.test.ts | 2 - src/pairing/pairing-store.ts | 3 +- src/plugin-sdk/index.test.ts | 1 - src/plugins/cli.ts | 5 +- src/plugins/config-state.test.ts | 1 - src/plugins/config-state.ts | 2 +- src/plugins/discovery.ts | 3 +- src/plugins/hook-runner-global.ts | 2 +- src/plugins/http-registry.ts | 3 +- src/plugins/install.test.ts | 2 +- src/plugins/install.ts | 4 +- src/plugins/loader.test.ts | 1 - src/plugins/loader.ts | 35 ++++--- src/plugins/manifest-registry.ts | 3 +- src/plugins/manifest.ts | 3 +- src/plugins/providers.ts | 2 +- src/plugins/registry.ts | 10 +- src/plugins/runtime/index.ts | 82 ++++++++-------- src/plugins/services.ts | 2 +- src/plugins/slots.test.ts | 1 - src/plugins/status.ts | 2 +- src/plugins/tools.optional.test.ts | 2 - src/plugins/tools.ts | 2 +- src/plugins/types.ts | 14 ++- src/plugins/update.ts | 1 - src/polls.test.ts | 1 - src/postinstall-patcher.test.ts | 1 - src/process/child-process-bridge.test.ts | 2 - src/process/command-queue.ts | 2 +- src/process/exec.test.ts | 1 - src/process/exec.ts | 1 - src/process/spawn-utils.test.ts | 3 +- src/providers/github-copilot-auth.ts | 3 +- src/providers/github-copilot-token.ts | 1 - ...unction-call-comes-after-user-turn.test.ts | 2 +- ...eserves-parameters-type-is-missing.test.ts | 2 +- src/providers/qwen-portal-oauth.test.ts | 1 - src/routing/bindings.ts | 4 +- src/routing/resolve-route.test.ts | 1 - src/routing/resolve-route.ts | 2 +- src/scripts/canvas-a2ui-copy.test.ts | 2 - src/security/audit-extra.ts | 24 +++-- src/security/audit-fs.ts | 1 - src/security/audit.test.ts | 15 ++- src/security/audit.ts | 12 +-- src/security/fix.test.ts | 2 - src/security/fix.ts | 10 +- src/security/windows-acl.ts | 1 - src/sessions/level-overrides.ts | 2 +- src/signal/client.ts | 1 - src/signal/daemon.test.ts | 1 - src/signal/format.test.ts | 1 - src/signal/format.ts | 2 +- src/signal/monitor.test.ts | 1 - ...-only-senders-uuid-allowlist-entry.test.ts | 1 - ...ends-tool-summaries-responseprefix.test.ts | 3 +- src/signal/monitor.ts | 10 +- .../event-handler.inbound-contract.test.ts | 1 - src/signal/monitor/event-handler.ts | 7 +- src/signal/probe.test.ts | 1 - src/signal/sse-reconnect.ts | 4 +- src/slack/actions.read.test.ts | 4 +- src/slack/actions.ts | 1 - src/slack/channel-migration.test.ts | 1 - src/slack/directory-live.ts | 5 +- src/slack/format.test.ts | 1 - src/slack/format.ts | 2 +- src/slack/http/registry.test.ts | 1 - src/slack/monitor.test.ts | 1 - ...onitor.threading.missing-thread-ts.test.ts | 1 - ...es-thread-replies-replytoid-is-set.test.ts | 3 +- ...ends-tool-summaries-responseprefix.test.ts | 3 +- ...p-level-replies-replytomode-is-all.test.ts | 3 +- src/slack/monitor/auth.ts | 5 +- src/slack/monitor/channel-config.test.ts | 1 - src/slack/monitor/context.test.ts | 1 - src/slack/monitor/context.ts | 9 +- src/slack/monitor/events.ts | 3 +- src/slack/monitor/events/channels.ts | 14 ++- src/slack/monitor/events/members.ts | 8 +- src/slack/monitor/events/messages.ts | 8 +- src/slack/monitor/events/pins.ts | 8 +- src/slack/monitor/events/reactions.ts | 8 +- src/slack/monitor/media.ts | 3 +- src/slack/monitor/message-handler.ts | 6 +- src/slack/monitor/message-handler/dispatch.ts | 6 +- .../prepare.inbound-contract.test.ts | 3 +- .../prepare.sender-prefix.test.ts | 1 - src/slack/monitor/message-handler/prepare.ts | 33 +++---- src/slack/monitor/message-handler/types.ts | 2 +- src/slack/monitor/provider.ts | 16 ++- src/slack/monitor/replies.ts | 6 +- .../monitor/slash.command-arg-menus.test.ts | 1 - src/slack/monitor/slash.policy.test.ts | 1 - src/slack/monitor/slash.ts | 18 ++-- src/slack/monitor/thread-resolution.test.ts | 1 - src/slack/monitor/thread-resolution.ts | 3 +- src/slack/resolve-channels.test.ts | 1 - src/slack/resolve-channels.ts | 1 - src/slack/resolve-users.ts | 1 - src/slack/scopes.ts | 1 - src/slack/send.ts | 5 +- src/slack/targets.test.ts | 1 - src/slack/threading-tool-context.test.ts | 1 - src/slack/threading.test.ts | 1 - src/telegram/accounts.test.ts | 1 - src/telegram/api-logging.ts | 2 +- src/telegram/bot-handlers.ts | 12 +-- .../bot-message-context.dm-threads.test.ts | 1 - .../bot-message-context.sender-prefix.test.ts | 1 - src/telegram/bot-message-context.ts | 27 +++--- src/telegram/bot-message-dispatch.ts | 6 +- .../bot-native-commands.plugin-auth.test.ts | 3 +- src/telegram/bot-native-commands.test.ts | 1 - src/telegram/bot-native-commands.ts | 41 ++++---- src/telegram/bot-updates.ts | 2 +- src/telegram/bot.test.ts | 4 +- src/telegram/bot.ts | 24 ++--- src/telegram/bot/delivery.test.ts | 4 +- src/telegram/bot/delivery.ts | 22 ++--- .../bot/helpers.expand-text-links.test.ts | 1 - src/telegram/bot/helpers.ts | 2 +- src/telegram/download.test.ts | 1 - src/telegram/draft-chunking.test.ts | 1 - src/telegram/draft-chunking.ts | 2 +- src/telegram/draft-stream.test.ts | 1 - src/telegram/fetch.ts | 2 +- src/telegram/format.test.ts | 1 - src/telegram/format.ts | 2 +- src/telegram/group-migration.test.ts | 1 - src/telegram/inline-buttons.test.ts | 1 - src/telegram/monitor.test.ts | 1 - src/telegram/monitor.ts | 4 +- src/telegram/network-config.test.ts | 1 - src/telegram/network-config.ts | 3 +- src/telegram/network-errors.test.ts | 1 - src/telegram/pairing-store.test.ts | 2 - src/telegram/reaction-level.test.ts | 1 - src/telegram/send.ts | 18 ++-- src/telegram/sticker-cache.ts | 10 +- src/telegram/targets.test.ts | 1 - src/telegram/token.test.ts | 2 - src/telegram/token.ts | 1 - src/telegram/update-offset-store.test.ts | 2 - src/telegram/update-offset-store.ts | 1 - src/telegram/voice.test.ts | 1 - src/telegram/webhook-set.ts | 2 +- src/telegram/webhook.test.ts | 1 - src/telegram/webhook.ts | 9 +- src/terminal/stream-writer.test.ts | 1 - src/terminal/table.test.ts | 1 - src/terminal/table.ts | 2 +- src/terminal/theme.ts | 1 - src/test-utils/channel-plugins.ts | 2 +- src/tts/tts.test.ts | 4 +- src/tts/tts.ts | 14 ++- src/tui/commands.test.ts | 1 - src/tui/commands.ts | 2 +- src/tui/components/filterable-select-list.ts | 2 +- src/tui/tui-command-handlers.test.ts | 1 - src/tui/tui-command-handlers.ts | 16 +-- src/tui/tui-event-handlers.test.ts | 3 +- src/tui/tui-event-handlers.ts | 2 +- src/tui/tui-formatters.test.ts | 1 - src/tui/tui-formatters.ts | 2 +- src/tui/tui-input-history.test.ts | 1 - src/tui/tui-local-shell.test.ts | 1 - src/tui/tui-overlays.test.ts | 1 - src/tui/tui-session-actions.ts | 6 +- src/tui/tui-status-summary.ts | 2 +- src/tui/tui-stream-assembler.test.ts | 1 - src/tui/tui-waiting.test.ts | 1 - src/tui/tui.submit-handler.test.ts | 1 - src/tui/tui.test.ts | 1 - src/tui/tui.ts | 16 +-- src/utils/boolean.test.ts | 1 - src/utils/delivery-context.test.ts | 1 - src/utils/message-channel.test.ts | 1 - src/utils/message-channel.ts | 2 +- src/web/accounts.ts | 3 +- src/web/accounts.whatsapp-auth.test.ts | 1 - src/web/active-listener.ts | 2 +- src/web/auth-store.ts | 5 +- ...asts-sequentially-configured-order.test.ts | 2 +- ...wn-broadcast-agent-ids-agents-list.test.ts | 2 +- .../auto-reply.partial-reply-gating.test.ts | 6 +- .../auto-reply.typing-controller-idle.test.ts | 2 +- ...-activation-silent-token-preserves.test.ts | 2 +- src/web/auto-reply/deliver-reply.ts | 8 +- src/web/auto-reply/heartbeat-runner.ts | 4 +- src/web/auto-reply/mentions.ts | 4 +- src/web/auto-reply/monitor.ts | 8 +- src/web/auto-reply/monitor/ack-reaction.ts | 4 +- src/web/auto-reply/monitor/broadcast.ts | 4 +- .../auto-reply/monitor/group-activation.ts | 2 +- .../auto-reply/monitor/group-gating.test.ts | 1 - src/web/auto-reply/monitor/group-gating.ts | 12 +-- .../auto-reply/monitor/message-line.test.ts | 1 - src/web/auto-reply/monitor/message-line.ts | 4 +- src/web/auto-reply/monitor/on-message.ts | 10 +- src/web/auto-reply/monitor/peer.ts | 2 +- .../process-message.inbound-contract.test.ts | 1 - src/web/auto-reply/monitor/process-message.ts | 18 ++-- src/web/auto-reply/session-snapshot.test.ts | 2 - src/web/inbound.media.test.ts | 1 - src/web/inbound.test.ts | 1 - .../access-control.pairing-history.test.ts | 1 - src/web/inbound/media.ts | 2 +- src/web/inbound/monitor.ts | 4 +- src/web/inbound/send-api.ts | 2 +- src/web/login-qr.ts | 3 +- src/web/login.coverage.test.ts | 3 +- src/web/login.test.ts | 4 +- src/web/login.ts | 2 +- src/web/logout.test.ts | 2 - src/web/media.test.ts | 2 - src/web/media.ts | 3 +- ...ssages-from-senders-allowfrom-list.test.ts | 2 - ...unauthorized-senders-not-allowfrom.test.ts | 2 - ...captures-media-path-image-messages.test.ts | 2 - ...tor-inbox.streams-inbound-messages.test.ts | 2 - src/web/outbound.test.ts | 1 - src/web/outbound.ts | 9 +- src/web/qr-image.test.ts | 2 - src/web/reconnect.test.ts | 1 - src/web/reconnect.ts | 1 - src/web/session.ts | 7 +- src/web/test-helpers.ts | 1 - src/whatsapp/normalize.test.ts | 1 - src/wizard/clack-prompter.ts | 2 +- src/wizard/onboarding.finalize.ts | 23 +++-- src/wizard/onboarding.gateway-config.test.ts | 1 - src/wizard/onboarding.gateway-config.ts | 4 +- src/wizard/onboarding.test.ts | 5 +- src/wizard/onboarding.ts | 26 ++--- src/wizard/session.test.ts | 1 - src/wizard/session.ts | 1 - test/auto-reply.retry.test.ts | 2 +- test/gateway.multi.e2e.test.ts | 2 +- test/helpers/inbound-contract.ts | 3 +- test/inbound-contract.providers.test.ts | 1 - test/media-understanding.auto.e2e.test.ts | 4 +- test/mocks/baileys.ts | 1 - test/provider-timeout.e2e.test.ts | 2 - ui/src/ui/app-channels.ts | 4 +- ui/src/ui/app-chat.ts | 16 +-- ui/src/ui/app-gateway.ts | 22 ++--- ui/src/ui/app-lifecycle.ts | 18 ++-- ui/src/ui/app-polling.ts | 4 +- ui/src/ui/app-render.helpers.ts | 13 ++- ui/src/ui/app-render.ts | 97 +++++++++---------- ui/src/ui/app-settings.test.ts | 1 - ui/src/ui/app-settings.ts | 24 ++--- ui/src/ui/app-view-state.ts | 10 +- ui/src/ui/app.ts | 81 ++++++++-------- ui/src/ui/chat-markdown.browser.test.ts | 1 - ui/src/ui/chat/grouped-render.ts | 5 +- ui/src/ui/chat/message-extract.test.ts | 1 - ui/src/ui/chat/tool-cards.ts | 9 +- ui/src/ui/config-form.browser.test.ts | 1 - ui/src/ui/controllers/chat.test.ts | 1 - ui/src/ui/controllers/chat.ts | 4 +- ui/src/ui/controllers/config.test.ts | 1 - ui/src/ui/controllers/cron.ts | 2 +- ui/src/ui/controllers/devices.ts | 2 +- ui/src/ui/controllers/sessions.ts | 2 +- ui/src/ui/focus-mode.browser.test.ts | 1 - ui/src/ui/format.test.ts | 1 - ui/src/ui/gateway.ts | 6 +- ui/src/ui/markdown.test.ts | 1 - ui/src/ui/navigation.browser.test.ts | 1 - ui/src/ui/navigation.test.ts | 1 - ui/src/ui/presenter.ts | 2 +- ui/src/ui/tool-display.ts | 2 +- ui/src/ui/uuid.test.ts | 1 - ui/src/ui/views/channels.config.ts | 1 - ui/src/ui/views/channels.discord.ts | 3 +- ui/src/ui/views/channels.googlechat.ts | 5 +- ui/src/ui/views/channels.imessage.ts | 3 +- .../ui/views/channels.nostr-profile-form.ts | 1 - ui/src/ui/views/channels.nostr.ts | 3 +- ui/src/ui/views/channels.shared.ts | 1 - ui/src/ui/views/channels.signal.ts | 3 +- ui/src/ui/views/channels.slack.ts | 3 +- ui/src/ui/views/channels.telegram.ts | 3 +- ui/src/ui/views/channels.ts | 5 +- ui/src/ui/views/channels.whatsapp.ts | 3 +- ui/src/ui/views/chat.test.ts | 1 - ui/src/ui/views/chat.ts | 6 +- ui/src/ui/views/config-form.render.ts | 2 +- ui/src/ui/views/config.browser.test.ts | 1 - ui/src/ui/views/cron.test.ts | 3 +- ui/src/ui/views/cron.ts | 5 +- ui/src/ui/views/debug.ts | 3 +- ui/src/ui/views/exec-approval.ts | 1 - ui/src/ui/views/gateway-url-confirmation.ts | 1 - ui/src/ui/views/instances.ts | 3 +- ui/src/ui/views/logs.ts | 1 - ui/src/ui/views/markdown-sidebar.ts | 1 - ui/src/ui/views/nodes.ts | 13 ++- ui/src/ui/views/overview.ts | 3 +- ui/src/ui/views/sessions.ts | 7 +- ui/src/ui/views/skills.ts | 5 +- 1778 files changed, 2949 insertions(+), 4242 deletions(-) diff --git a/.github/workflows/formal-conformance.yml b/.github/workflows/formal-conformance.yml index 36e66c4e604..50da0e7c8db 100644 --- a/.github/workflows/formal-conformance.yml +++ b/.github/workflows/formal-conformance.yml @@ -26,7 +26,7 @@ jobs: - name: Setup Node uses: actions/setup-node@v4 with: - node-version: '22' + node-version: "22" - name: Regenerate extracted constants from openclaw run: | diff --git a/.oxfmtrc.jsonc b/.oxfmtrc.jsonc index 44eebf914d7..f7208b4da3d 100644 --- a/.oxfmtrc.jsonc +++ b/.oxfmtrc.jsonc @@ -1,5 +1,8 @@ { "$schema": "./node_modules/oxfmt/configuration_schema.json", + "experimentalSortImports": { + "newlinesBetween": false, + }, "experimentalSortPackageJson": { "sortScripts": true, }, diff --git a/extensions/bluebubbles/index.ts b/extensions/bluebubbles/index.ts index 433eec31a2a..44b09e24592 100644 --- a/extensions/bluebubbles/index.ts +++ b/extensions/bluebubbles/index.ts @@ -1,6 +1,5 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { bluebubblesPlugin } from "./src/channel.js"; import { handleBlueBubblesWebhookRequest } from "./src/monitor.js"; import { setBlueBubblesRuntime } from "./src/runtime.js"; diff --git a/extensions/bluebubbles/src/actions.test.ts b/extensions/bluebubbles/src/actions.test.ts index 444ac6e0020..8dc55b1eff3 100644 --- a/extensions/bluebubbles/src/actions.test.ts +++ b/extensions/bluebubbles/src/actions.test.ts @@ -1,7 +1,6 @@ -import { describe, expect, it, vi, beforeEach } from "vitest"; - -import { bluebubblesMessageActions } from "./actions.js"; import type { OpenClawConfig } from "openclaw/plugin-sdk"; +import { describe, expect, it, vi, beforeEach } from "vitest"; +import { bluebubblesMessageActions } from "./actions.js"; vi.mock("./accounts.js", () => ({ resolveBlueBubblesAccount: vi.fn(({ cfg, accountId }) => { diff --git a/extensions/bluebubbles/src/actions.ts b/extensions/bluebubbles/src/actions.ts index 4d03d980d17..c3c2832a218 100644 --- a/extensions/bluebubbles/src/actions.ts +++ b/extensions/bluebubbles/src/actions.ts @@ -10,12 +10,9 @@ import { type ChannelMessageActionName, type ChannelToolSend, } from "openclaw/plugin-sdk"; - +import type { BlueBubblesSendTarget } from "./types.js"; import { resolveBlueBubblesAccount } from "./accounts.js"; -import { resolveBlueBubblesMessageId } from "./monitor.js"; -import { isMacOS26OrHigher } from "./probe.js"; -import { sendBlueBubblesReaction } from "./reactions.js"; -import { resolveChatGuidForTarget, sendMessageBlueBubbles } from "./send.js"; +import { sendBlueBubblesAttachment } from "./attachments.js"; import { editBlueBubblesMessage, unsendBlueBubblesMessage, @@ -25,9 +22,11 @@ import { removeBlueBubblesParticipant, leaveBlueBubblesChat, } from "./chat.js"; -import { sendBlueBubblesAttachment } from "./attachments.js"; +import { resolveBlueBubblesMessageId } from "./monitor.js"; +import { isMacOS26OrHigher } from "./probe.js"; +import { sendBlueBubblesReaction } from "./reactions.js"; +import { resolveChatGuidForTarget, sendMessageBlueBubbles } from "./send.js"; import { normalizeBlueBubblesHandle, parseBlueBubblesTarget } from "./targets.js"; -import type { BlueBubblesSendTarget } from "./types.js"; const providerId = "bluebubbles"; diff --git a/extensions/bluebubbles/src/attachments.test.ts b/extensions/bluebubbles/src/attachments.test.ts index 9611f09fd51..9bc0e4d217b 100644 --- a/extensions/bluebubbles/src/attachments.test.ts +++ b/extensions/bluebubbles/src/attachments.test.ts @@ -1,7 +1,6 @@ import { describe, expect, it, vi, beforeEach, afterEach } from "vitest"; - -import { downloadBlueBubblesAttachment, sendBlueBubblesAttachment } from "./attachments.js"; import type { BlueBubblesAttachment } from "./types.js"; +import { downloadBlueBubblesAttachment, sendBlueBubblesAttachment } from "./attachments.js"; vi.mock("./accounts.js", () => ({ resolveBlueBubblesAccount: vi.fn(({ cfg, accountId }) => { diff --git a/extensions/bluebubbles/src/attachments.ts b/extensions/bluebubbles/src/attachments.ts index 8a9bce52e01..6ce8342d8a3 100644 --- a/extensions/bluebubbles/src/attachments.ts +++ b/extensions/bluebubbles/src/attachments.ts @@ -1,6 +1,6 @@ +import type { OpenClawConfig } from "openclaw/plugin-sdk"; import crypto from "node:crypto"; import path from "node:path"; -import type { OpenClawConfig } from "openclaw/plugin-sdk"; import { resolveBlueBubblesAccount } from "./accounts.js"; import { resolveChatGuidForTarget } from "./send.js"; import { parseBlueBubblesTarget, normalizeBlueBubblesHandle } from "./targets.js"; diff --git a/extensions/bluebubbles/src/channel.ts b/extensions/bluebubbles/src/channel.ts index d48f4313ac3..74ea0b75983 100644 --- a/extensions/bluebubbles/src/channel.ts +++ b/extensions/bluebubbles/src/channel.ts @@ -13,15 +13,18 @@ import { resolveBlueBubblesGroupToolPolicy, setAccountEnabledInConfigSection, } from "openclaw/plugin-sdk"; - import { listBlueBubblesAccountIds, type ResolvedBlueBubblesAccount, resolveBlueBubblesAccount, resolveDefaultBlueBubblesAccountId, } from "./accounts.js"; +import { bluebubblesMessageActions } from "./actions.js"; import { BlueBubblesConfigSchema } from "./config-schema.js"; +import { sendBlueBubblesMedia } from "./media-send.js"; import { resolveBlueBubblesMessageId } from "./monitor.js"; +import { monitorBlueBubblesProvider, resolveWebhookPathFromConfig } from "./monitor.js"; +import { blueBubblesOnboardingAdapter } from "./onboarding.js"; import { probeBlueBubbles, type BlueBubblesProbe } from "./probe.js"; import { sendMessageBlueBubbles } from "./send.js"; import { @@ -31,10 +34,6 @@ import { normalizeBlueBubblesMessagingTarget, parseBlueBubblesTarget, } from "./targets.js"; -import { bluebubblesMessageActions } from "./actions.js"; -import { monitorBlueBubblesProvider, resolveWebhookPathFromConfig } from "./monitor.js"; -import { blueBubblesOnboardingAdapter } from "./onboarding.js"; -import { sendBlueBubblesMedia } from "./media-send.js"; const meta = { id: "bluebubbles", diff --git a/extensions/bluebubbles/src/chat.test.ts b/extensions/bluebubbles/src/chat.test.ts index 6e89c05d816..39ac3ba325a 100644 --- a/extensions/bluebubbles/src/chat.test.ts +++ b/extensions/bluebubbles/src/chat.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi, beforeEach, afterEach } from "vitest"; - import { markBlueBubblesChatRead, sendBlueBubblesTyping, setGroupIconBlueBubbles } from "./chat.js"; vi.mock("./accounts.js", () => ({ diff --git a/extensions/bluebubbles/src/chat.ts b/extensions/bluebubbles/src/chat.ts index 9ca3fa50748..374c5a896ea 100644 --- a/extensions/bluebubbles/src/chat.ts +++ b/extensions/bluebubbles/src/chat.ts @@ -1,6 +1,6 @@ +import type { OpenClawConfig } from "openclaw/plugin-sdk"; import crypto from "node:crypto"; import { resolveBlueBubblesAccount } from "./accounts.js"; -import type { OpenClawConfig } from "openclaw/plugin-sdk"; import { blueBubblesFetchWithTimeout, buildBlueBubblesApiUrl } from "./types.js"; export type BlueBubblesChatOpts = { diff --git a/extensions/bluebubbles/src/media-send.ts b/extensions/bluebubbles/src/media-send.ts index f57421d73df..ab757210567 100644 --- a/extensions/bluebubbles/src/media-send.ts +++ b/extensions/bluebubbles/src/media-send.ts @@ -1,8 +1,6 @@ import path from "node:path"; import { fileURLToPath } from "node:url"; - import { resolveChannelMediaMaxBytes, type OpenClawConfig } from "openclaw/plugin-sdk"; - import { sendBlueBubblesAttachment } from "./attachments.js"; import { resolveBlueBubblesMessageId } from "./monitor.js"; import { getBlueBubblesRuntime } from "./runtime.js"; diff --git a/extensions/bluebubbles/src/monitor.test.ts b/extensions/bluebubbles/src/monitor.test.ts index cfb39cdb8b4..902828ece2e 100644 --- a/extensions/bluebubbles/src/monitor.test.ts +++ b/extensions/bluebubbles/src/monitor.test.ts @@ -1,9 +1,9 @@ -import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { IncomingMessage, ServerResponse } from "node:http"; -import { EventEmitter } from "node:events"; - -import { removeAckReactionAfterReply, shouldAckReaction } from "openclaw/plugin-sdk"; import type { OpenClawConfig, PluginRuntime } from "openclaw/plugin-sdk"; +import { EventEmitter } from "node:events"; +import { removeAckReactionAfterReply, shouldAckReaction } from "openclaw/plugin-sdk"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import type { ResolvedBlueBubblesAccount } from "./accounts.js"; import { handleBlueBubblesWebhookRequest, registerBlueBubblesWebhookTarget, @@ -11,7 +11,6 @@ import { _resetBlueBubblesShortIdState, } from "./monitor.js"; import { setBlueBubblesRuntime } from "./runtime.js"; -import type { ResolvedBlueBubblesAccount } from "./accounts.js"; // Mock dependencies vi.mock("./send.js", () => ({ diff --git a/extensions/bluebubbles/src/monitor.ts b/extensions/bluebubbles/src/monitor.ts index 5f96d9d48b4..00a5f36e24e 100644 --- a/extensions/bluebubbles/src/monitor.ts +++ b/extensions/bluebubbles/src/monitor.ts @@ -1,5 +1,4 @@ import type { IncomingMessage, ServerResponse } from "node:http"; - import type { OpenClawConfig } from "openclaw/plugin-sdk"; import { logAckFailure, @@ -8,20 +7,20 @@ import { resolveAckReaction, resolveControlCommandGate, } from "openclaw/plugin-sdk"; -import { markBlueBubblesChatRead, sendBlueBubblesTyping } from "./chat.js"; -import { resolveChatGuidForTarget, sendMessageBlueBubbles } from "./send.js"; +import type { ResolvedBlueBubblesAccount } from "./accounts.js"; +import type { BlueBubblesAccountConfig, BlueBubblesAttachment } from "./types.js"; import { downloadBlueBubblesAttachment } from "./attachments.js"; +import { markBlueBubblesChatRead, sendBlueBubblesTyping } from "./chat.js"; +import { sendBlueBubblesMedia } from "./media-send.js"; +import { fetchBlueBubblesServerInfo } from "./probe.js"; +import { normalizeBlueBubblesReactionInput, sendBlueBubblesReaction } from "./reactions.js"; +import { getBlueBubblesRuntime } from "./runtime.js"; +import { resolveChatGuidForTarget, sendMessageBlueBubbles } from "./send.js"; import { formatBlueBubblesChatTarget, isAllowedBlueBubblesSender, normalizeBlueBubblesHandle, } from "./targets.js"; -import { sendBlueBubblesMedia } from "./media-send.js"; -import type { BlueBubblesAccountConfig, BlueBubblesAttachment } from "./types.js"; -import type { ResolvedBlueBubblesAccount } from "./accounts.js"; -import { getBlueBubblesRuntime } from "./runtime.js"; -import { normalizeBlueBubblesReactionInput, sendBlueBubblesReaction } from "./reactions.js"; -import { fetchBlueBubblesServerInfo } from "./probe.js"; export type BlueBubblesRuntimeEnv = { log?: (message: string) => void; diff --git a/extensions/bluebubbles/src/onboarding.ts b/extensions/bluebubbles/src/onboarding.ts index c0d4e922226..1d68ace62fb 100644 --- a/extensions/bluebubbles/src/onboarding.ts +++ b/extensions/bluebubbles/src/onboarding.ts @@ -17,8 +17,8 @@ import { resolveBlueBubblesAccount, resolveDefaultBlueBubblesAccountId, } from "./accounts.js"; -import { normalizeBlueBubblesServerUrl } from "./types.js"; import { parseBlueBubblesAllowTarget } from "./targets.js"; +import { normalizeBlueBubblesServerUrl } from "./types.js"; const channel = "bluebubbles" as const; diff --git a/extensions/bluebubbles/src/reactions.test.ts b/extensions/bluebubbles/src/reactions.test.ts index c9d3a18d0e5..643a926b889 100644 --- a/extensions/bluebubbles/src/reactions.test.ts +++ b/extensions/bluebubbles/src/reactions.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi, beforeEach, afterEach } from "vitest"; - import { sendBlueBubblesReaction } from "./reactions.js"; vi.mock("./accounts.js", () => ({ diff --git a/extensions/bluebubbles/src/reactions.ts b/extensions/bluebubbles/src/reactions.ts index 64a55ac0d5e..5b59eda0d88 100644 --- a/extensions/bluebubbles/src/reactions.ts +++ b/extensions/bluebubbles/src/reactions.ts @@ -1,5 +1,5 @@ -import { resolveBlueBubblesAccount } from "./accounts.js"; import type { OpenClawConfig } from "openclaw/plugin-sdk"; +import { resolveBlueBubblesAccount } from "./accounts.js"; import { blueBubblesFetchWithTimeout, buildBlueBubblesApiUrl } from "./types.js"; export type BlueBubblesReactionOpts = { diff --git a/extensions/bluebubbles/src/send.test.ts b/extensions/bluebubbles/src/send.test.ts index 84aa0ebf2b3..c2ee393c7f3 100644 --- a/extensions/bluebubbles/src/send.test.ts +++ b/extensions/bluebubbles/src/send.test.ts @@ -1,7 +1,6 @@ import { describe, expect, it, vi, beforeEach, afterEach } from "vitest"; - -import { sendMessageBlueBubbles, resolveChatGuidForTarget } from "./send.js"; import type { BlueBubblesSendTarget } from "./types.js"; +import { sendMessageBlueBubbles, resolveChatGuidForTarget } from "./send.js"; vi.mock("./accounts.js", () => ({ resolveBlueBubblesAccount: vi.fn(({ cfg, accountId }) => { diff --git a/extensions/bluebubbles/src/send.ts b/extensions/bluebubbles/src/send.ts index ee3aa9d4ec0..63333556f05 100644 --- a/extensions/bluebubbles/src/send.ts +++ b/extensions/bluebubbles/src/send.ts @@ -1,12 +1,11 @@ +import type { OpenClawConfig } from "openclaw/plugin-sdk"; import crypto from "node:crypto"; - import { resolveBlueBubblesAccount } from "./accounts.js"; import { extractHandleFromChatGuid, normalizeBlueBubblesHandle, parseBlueBubblesTarget, } from "./targets.js"; -import type { OpenClawConfig } from "openclaw/plugin-sdk"; import { blueBubblesFetchWithTimeout, buildBlueBubblesApiUrl, diff --git a/extensions/bluebubbles/src/targets.test.ts b/extensions/bluebubbles/src/targets.test.ts index ae2851ef91c..cb159b1fb75 100644 --- a/extensions/bluebubbles/src/targets.test.ts +++ b/extensions/bluebubbles/src/targets.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { looksLikeBlueBubblesTargetId, normalizeBlueBubblesMessagingTarget, diff --git a/extensions/diagnostics-otel/index.ts b/extensions/diagnostics-otel/index.ts index cf12a264279..0b9c5318def 100644 --- a/extensions/diagnostics-otel/index.ts +++ b/extensions/diagnostics-otel/index.ts @@ -1,6 +1,5 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { createDiagnosticsOtelService } from "./src/service.js"; const plugin = { diff --git a/extensions/diagnostics-otel/src/service.test.ts b/extensions/diagnostics-otel/src/service.test.ts index f1b5dadc798..fca54673044 100644 --- a/extensions/diagnostics-otel/src/service.test.ts +++ b/extensions/diagnostics-otel/src/service.test.ts @@ -103,8 +103,8 @@ vi.mock("openclaw/plugin-sdk", async () => { }; }); -import { createDiagnosticsOtelService } from "./service.js"; import { emitDiagnosticEvent } from "openclaw/plugin-sdk"; +import { createDiagnosticsOtelService } from "./service.js"; describe("diagnostics-otel service", () => { beforeEach(() => { diff --git a/extensions/diagnostics-otel/src/service.ts b/extensions/diagnostics-otel/src/service.ts index 7598cb7f45f..fe05fe4bd4c 100644 --- a/extensions/diagnostics-otel/src/service.ts +++ b/extensions/diagnostics-otel/src/service.ts @@ -1,5 +1,6 @@ -import { metrics, trace, SpanStatusCode } from "@opentelemetry/api"; import type { SeverityNumber } from "@opentelemetry/api-logs"; +import type { DiagnosticEventPayload, OpenClawPluginService } from "openclaw/plugin-sdk"; +import { metrics, trace, SpanStatusCode } from "@opentelemetry/api"; import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http"; import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http"; import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http"; @@ -9,8 +10,6 @@ import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics"; import { NodeSDK } from "@opentelemetry/sdk-node"; import { ParentBasedSampler, TraceIdRatioBasedSampler } from "@opentelemetry/sdk-trace-base"; import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions"; - -import type { DiagnosticEventPayload, OpenClawPluginService } from "openclaw/plugin-sdk"; import { onDiagnosticEvent, registerLogTransport } from "openclaw/plugin-sdk"; const DEFAULT_SERVICE_NAME = "openclaw"; diff --git a/extensions/discord/index.ts b/extensions/discord/index.ts index 81c38c9e4e0..ab639cbaff2 100644 --- a/extensions/discord/index.ts +++ b/extensions/discord/index.ts @@ -1,6 +1,5 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { discordPlugin } from "./src/channel.js"; import { setDiscordRuntime } from "./src/runtime.js"; diff --git a/extensions/discord/src/channel.ts b/extensions/discord/src/channel.ts index f28f7483bfb..e989795dc9e 100644 --- a/extensions/discord/src/channel.ts +++ b/extensions/discord/src/channel.ts @@ -26,7 +26,6 @@ import { type ChannelPlugin, type ResolvedDiscordAccount, } from "openclaw/plugin-sdk"; - import { getDiscordRuntime } from "./runtime.js"; const meta = getChatChannelMeta("discord"); diff --git a/extensions/google-gemini-cli-auth/index.ts b/extensions/google-gemini-cli-auth/index.ts index 2ceac45e058..e66071ccabc 100644 --- a/extensions/google-gemini-cli-auth/index.ts +++ b/extensions/google-gemini-cli-auth/index.ts @@ -1,5 +1,4 @@ import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { loginGeminiCliOAuth } from "./oauth.js"; const PROVIDER_ID = "google-gemini-cli"; diff --git a/extensions/google-gemini-cli-auth/oauth.test.ts b/extensions/google-gemini-cli-auth/oauth.test.ts index fad1bc01501..5831b8b1e0d 100644 --- a/extensions/google-gemini-cli-auth/oauth.test.ts +++ b/extensions/google-gemini-cli-auth/oauth.test.ts @@ -1,5 +1,5 @@ -import { describe, expect, it, vi, beforeEach, afterEach } from "vitest"; import { join, parse } from "node:path"; +import { describe, expect, it, vi, beforeEach, afterEach } from "vitest"; // Mock fs module before importing the module under test const mockExistsSync = vi.fn(); diff --git a/extensions/googlechat/index.ts b/extensions/googlechat/index.ts index 659175058da..1ade57f1e71 100644 --- a/extensions/googlechat/index.ts +++ b/extensions/googlechat/index.ts @@ -1,6 +1,5 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { googlechatDock, googlechatPlugin } from "./src/channel.js"; import { handleGoogleChatWebhookRequest } from "./src/monitor.js"; import { setGoogleChatRuntime } from "./src/runtime.js"; diff --git a/extensions/googlechat/src/accounts.ts b/extensions/googlechat/src/accounts.ts index e81c86ff762..c3210c35a12 100644 --- a/extensions/googlechat/src/accounts.ts +++ b/extensions/googlechat/src/accounts.ts @@ -1,6 +1,5 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk"; import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk"; - import type { GoogleChatAccountConfig } from "./types.config.js"; export type GoogleChatCredentialSource = "file" | "inline" | "env" | "none"; diff --git a/extensions/googlechat/src/actions.ts b/extensions/googlechat/src/actions.ts index b62a53517b4..011eaa29188 100644 --- a/extensions/googlechat/src/actions.ts +++ b/extensions/googlechat/src/actions.ts @@ -10,7 +10,6 @@ import { readReactionParams, readStringParam, } from "openclaw/plugin-sdk"; - import { listEnabledGoogleChatAccounts, resolveGoogleChatAccount } from "./accounts.js"; import { createGoogleChatReaction, diff --git a/extensions/googlechat/src/api.test.ts b/extensions/googlechat/src/api.test.ts index 959b396dfae..b98b247a66e 100644 --- a/extensions/googlechat/src/api.test.ts +++ b/extensions/googlechat/src/api.test.ts @@ -1,5 +1,4 @@ import { afterEach, describe, expect, it, vi } from "vitest"; - import type { ResolvedGoogleChatAccount } from "./accounts.js"; import { downloadGoogleChatMedia } from "./api.js"; diff --git a/extensions/googlechat/src/api.ts b/extensions/googlechat/src/api.ts index 013b239f3f6..a0cf0acf57f 100644 --- a/extensions/googlechat/src/api.ts +++ b/extensions/googlechat/src/api.ts @@ -1,8 +1,7 @@ import crypto from "node:crypto"; - import type { ResolvedGoogleChatAccount } from "./accounts.js"; -import { getGoogleChatAccessToken } from "./auth.js"; import type { GoogleChatReaction } from "./types.js"; +import { getGoogleChatAccessToken } from "./auth.js"; const CHAT_API_BASE = "https://chat.googleapis.com/v1"; const CHAT_UPLOAD_BASE = "https://chat.googleapis.com/upload/v1"; diff --git a/extensions/googlechat/src/auth.ts b/extensions/googlechat/src/auth.ts index 221d36f9e98..bee093315cc 100644 --- a/extensions/googlechat/src/auth.ts +++ b/extensions/googlechat/src/auth.ts @@ -1,5 +1,4 @@ import { GoogleAuth, OAuth2Client } from "google-auth-library"; - import type { ResolvedGoogleChatAccount } from "./accounts.js"; const CHAT_SCOPE = "https://www.googleapis.com/auth/chat.bot"; diff --git a/extensions/googlechat/src/channel.ts b/extensions/googlechat/src/channel.ts index 8c329c44761..cc1cdf22560 100644 --- a/extensions/googlechat/src/channel.ts +++ b/extensions/googlechat/src/channel.ts @@ -18,7 +18,6 @@ import { type OpenClawConfig, } from "openclaw/plugin-sdk"; import { GoogleChatConfigSchema } from "openclaw/plugin-sdk"; - import { listGoogleChatAccountIds, resolveDefaultGoogleChatAccountId, @@ -27,9 +26,9 @@ import { } from "./accounts.js"; import { googlechatMessageActions } from "./actions.js"; import { sendGoogleChatMessage, uploadGoogleChatAttachment, probeGoogleChat } from "./api.js"; +import { resolveGoogleChatWebhookPath, startGoogleChatMonitor } from "./monitor.js"; import { googlechatOnboardingAdapter } from "./onboarding.js"; import { getGoogleChatRuntime } from "./runtime.js"; -import { resolveGoogleChatWebhookPath, startGoogleChatMonitor } from "./monitor.js"; import { isGoogleChatSpaceTarget, isGoogleChatUserTarget, diff --git a/extensions/googlechat/src/monitor.test.ts b/extensions/googlechat/src/monitor.test.ts index 56e31235dea..5223ba9c9fd 100644 --- a/extensions/googlechat/src/monitor.test.ts +++ b/extensions/googlechat/src/monitor.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { isSenderAllowed } from "./monitor.js"; describe("isSenderAllowed", () => { diff --git a/extensions/googlechat/src/monitor.ts b/extensions/googlechat/src/monitor.ts index 144896de44d..b5167878b8a 100644 --- a/extensions/googlechat/src/monitor.ts +++ b/extensions/googlechat/src/monitor.ts @@ -1,8 +1,14 @@ import type { IncomingMessage, ServerResponse } from "node:http"; - import type { OpenClawConfig } from "openclaw/plugin-sdk"; import { resolveMentionGatingWithBypass } from "openclaw/plugin-sdk"; - +import type { + GoogleChatAnnotation, + GoogleChatAttachment, + GoogleChatEvent, + GoogleChatSpace, + GoogleChatMessage, + GoogleChatUser, +} from "./types.js"; import { type ResolvedGoogleChatAccount } from "./accounts.js"; import { downloadGoogleChatMedia, @@ -12,14 +18,6 @@ import { } from "./api.js"; import { verifyGoogleChatRequest, type GoogleChatAudienceType } from "./auth.js"; import { getGoogleChatRuntime } from "./runtime.js"; -import type { - GoogleChatAnnotation, - GoogleChatAttachment, - GoogleChatEvent, - GoogleChatSpace, - GoogleChatMessage, - GoogleChatUser, -} from "./types.js"; export type GoogleChatRuntimeEnv = { log?: (message: string) => void; diff --git a/extensions/googlechat/src/onboarding.ts b/extensions/googlechat/src/onboarding.ts index 4e16b0159b1..263f1029bcd 100644 --- a/extensions/googlechat/src/onboarding.ts +++ b/extensions/googlechat/src/onboarding.ts @@ -10,7 +10,6 @@ import { normalizeAccountId, migrateBaseNameToDefaultAccount, } from "openclaw/plugin-sdk"; - import { listGoogleChatAccountIds, resolveDefaultGoogleChatAccountId, diff --git a/extensions/googlechat/src/targets.test.ts b/extensions/googlechat/src/targets.test.ts index 798deec4878..bb49bd0ec1f 100644 --- a/extensions/googlechat/src/targets.test.ts +++ b/extensions/googlechat/src/targets.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { isGoogleChatSpaceTarget, isGoogleChatUserTarget, diff --git a/extensions/imessage/index.ts b/extensions/imessage/index.ts index 3ccd0bf8b71..7eb0e80b070 100644 --- a/extensions/imessage/index.ts +++ b/extensions/imessage/index.ts @@ -1,6 +1,5 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { imessagePlugin } from "./src/channel.js"; import { setIMessageRuntime } from "./src/runtime.js"; diff --git a/extensions/imessage/src/channel.ts b/extensions/imessage/src/channel.ts index 15a887d9390..39032261408 100644 --- a/extensions/imessage/src/channel.ts +++ b/extensions/imessage/src/channel.ts @@ -22,7 +22,6 @@ import { type ChannelPlugin, type ResolvedIMessageAccount, } from "openclaw/plugin-sdk"; - import { getIMessageRuntime } from "./runtime.js"; const meta = getChatChannelMeta("imessage"); diff --git a/extensions/line/index.ts b/extensions/line/index.ts index c4d9bf97103..3d90029c27b 100644 --- a/extensions/line/index.ts +++ b/extensions/line/index.ts @@ -1,8 +1,7 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - -import { linePlugin } from "./src/channel.js"; import { registerLineCardCommand } from "./src/card-command.js"; +import { linePlugin } from "./src/channel.js"; import { setLineRuntime } from "./src/runtime.js"; const plugin = { diff --git a/extensions/line/src/channel.logout.test.ts b/extensions/line/src/channel.logout.test.ts index 4b191d95a21..b7107d07caf 100644 --- a/extensions/line/src/channel.logout.test.ts +++ b/extensions/line/src/channel.logout.test.ts @@ -1,5 +1,5 @@ -import { beforeEach, describe, expect, it, vi } from "vitest"; import type { OpenClawConfig, PluginRuntime } from "openclaw/plugin-sdk"; +import { beforeEach, describe, expect, it, vi } from "vitest"; import { linePlugin } from "./channel.js"; import { setLineRuntime } from "./runtime.js"; diff --git a/extensions/line/src/channel.sendPayload.test.ts b/extensions/line/src/channel.sendPayload.test.ts index 22002e16449..94bbe9e8c42 100644 --- a/extensions/line/src/channel.sendPayload.test.ts +++ b/extensions/line/src/channel.sendPayload.test.ts @@ -1,5 +1,5 @@ -import { describe, expect, it, vi } from "vitest"; import type { OpenClawConfig, PluginRuntime } from "openclaw/plugin-sdk"; +import { describe, expect, it, vi } from "vitest"; import { linePlugin } from "./channel.js"; import { setLineRuntime } from "./runtime.js"; diff --git a/extensions/line/src/channel.ts b/extensions/line/src/channel.ts index a8f31cb4d08..780183c560a 100644 --- a/extensions/line/src/channel.ts +++ b/extensions/line/src/channel.ts @@ -10,7 +10,6 @@ import { type LineChannelData, type ResolvedLineAccount, } from "openclaw/plugin-sdk"; - import { getLineRuntime } from "./runtime.js"; // LINE channel metadata diff --git a/extensions/llm-task/index.ts b/extensions/llm-task/index.ts index 9b158196415..e42634dad07 100644 --- a/extensions/llm-task/index.ts +++ b/extensions/llm-task/index.ts @@ -1,5 +1,4 @@ import type { OpenClawPluginApi } from "../../src/plugins/types.js"; - import { createLlmTaskTool } from "./src/llm-task-tool.js"; export default function register(api: OpenClawPluginApi) { diff --git a/extensions/llm-task/src/llm-task-tool.ts b/extensions/llm-task/src/llm-task-tool.ts index 370faec8c52..7f6f15fb09d 100644 --- a/extensions/llm-task/src/llm-task-tool.ts +++ b/extensions/llm-task/src/llm-task-tool.ts @@ -1,15 +1,12 @@ +import { Type } from "@sinclair/typebox"; +import Ajv from "ajv"; +import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; -import fs from "node:fs/promises"; - -import Ajv from "ajv"; -import { Type } from "@sinclair/typebox"; - // NOTE: This extension is intended to be bundled with OpenClaw. // When running from source (tests/dev), OpenClaw internals live under src/. // When running from a built install, internals live under dist/ (no src/ tree). // So we resolve internal imports dynamically with src-first, dist-fallback. - import type { OpenClawPluginApi } from "../../../src/plugins/types.js"; type RunEmbeddedPiAgentFn = (params: Record) => Promise; diff --git a/extensions/lobster/index.ts b/extensions/lobster/index.ts index c2864c73323..3b01680165c 100644 --- a/extensions/lobster/index.ts +++ b/extensions/lobster/index.ts @@ -1,5 +1,4 @@ import type { OpenClawPluginApi } from "../../src/plugins/types.js"; - import { createLobsterTool } from "./src/lobster-tool.js"; export default function register(api: OpenClawPluginApi) { diff --git a/extensions/lobster/src/lobster-tool.test.ts b/extensions/lobster/src/lobster-tool.test.ts index bbab896ef9f..0817771d4f3 100644 --- a/extensions/lobster/src/lobster-tool.test.ts +++ b/extensions/lobster/src/lobster-tool.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import type { OpenClawPluginApi, OpenClawPluginToolContext } from "../../../src/plugins/types.js"; import { createLobsterTool } from "./lobster-tool.js"; diff --git a/extensions/lobster/src/lobster-tool.ts b/extensions/lobster/src/lobster-tool.ts index dd510e2992b..b24670eef4c 100644 --- a/extensions/lobster/src/lobster-tool.ts +++ b/extensions/lobster/src/lobster-tool.ts @@ -2,7 +2,6 @@ import { Type } from "@sinclair/typebox"; import { spawn } from "node:child_process"; import fs from "node:fs"; import path from "node:path"; - import type { OpenClawPluginApi } from "../../../src/plugins/types.js"; type LobsterEnvelope = diff --git a/extensions/matrix/index.ts b/extensions/matrix/index.ts index 9a1e24a5b60..10df32f7f79 100644 --- a/extensions/matrix/index.ts +++ b/extensions/matrix/index.ts @@ -1,6 +1,5 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { matrixPlugin } from "./src/channel.js"; import { setMatrixRuntime } from "./src/runtime.js"; diff --git a/extensions/matrix/src/actions.ts b/extensions/matrix/src/actions.ts index 2af7e951b83..a7c219536f4 100644 --- a/extensions/matrix/src/actions.ts +++ b/extensions/matrix/src/actions.ts @@ -7,9 +7,9 @@ import { type ChannelMessageActionName, type ChannelToolSend, } from "openclaw/plugin-sdk"; +import type { CoreConfig } from "./types.js"; import { resolveMatrixAccount } from "./matrix/accounts.js"; import { handleMatrixAction } from "./tool-actions.js"; -import type { CoreConfig } from "./types.js"; export const matrixMessageActions: ChannelMessageActionAdapter = { listActions: ({ cfg }) => { diff --git a/extensions/matrix/src/channel.directory.test.ts b/extensions/matrix/src/channel.directory.test.ts index 4c309f89978..eb2aeacac79 100644 --- a/extensions/matrix/src/channel.directory.test.ts +++ b/extensions/matrix/src/channel.directory.test.ts @@ -1,8 +1,6 @@ -import { beforeEach, describe, expect, it } from "vitest"; - import type { PluginRuntime } from "openclaw/plugin-sdk"; +import { beforeEach, describe, expect, it } from "vitest"; import type { CoreConfig } from "./types.js"; - import { matrixPlugin } from "./channel.js"; import { setMatrixRuntime } from "./runtime.js"; diff --git a/extensions/matrix/src/channel.ts b/extensions/matrix/src/channel.ts index a0dd3937337..eb67c49ce69 100644 --- a/extensions/matrix/src/channel.ts +++ b/extensions/matrix/src/channel.ts @@ -9,14 +9,14 @@ import { setAccountEnabledInConfigSection, type ChannelPlugin, } from "openclaw/plugin-sdk"; - +import type { CoreConfig } from "./types.js"; import { matrixMessageActions } from "./actions.js"; import { MatrixConfigSchema } from "./config-schema.js"; +import { listMatrixDirectoryGroupsLive, listMatrixDirectoryPeersLive } from "./directory-live.js"; import { resolveMatrixGroupRequireMention, resolveMatrixGroupToolPolicy, } from "./group-mentions.js"; -import type { CoreConfig } from "./types.js"; import { listMatrixAccountIds, resolveDefaultMatrixAccountId, @@ -30,7 +30,6 @@ import { sendMessageMatrix } from "./matrix/send.js"; import { matrixOnboardingAdapter } from "./onboarding.js"; import { matrixOutbound } from "./outbound.js"; import { resolveMatrixTargets } from "./resolve-targets.js"; -import { listMatrixDirectoryGroupsLive, listMatrixDirectoryPeersLive } from "./directory-live.js"; const meta = { id: "matrix", diff --git a/extensions/matrix/src/directory-live.ts b/extensions/matrix/src/directory-live.ts index 6870079ed2f..e43a7c099a6 100644 --- a/extensions/matrix/src/directory-live.ts +++ b/extensions/matrix/src/directory-live.ts @@ -1,5 +1,4 @@ import type { ChannelDirectoryEntry } from "openclaw/plugin-sdk"; - import { resolveMatrixAuth } from "./matrix/client.js"; type MatrixUserResult = { diff --git a/extensions/matrix/src/group-mentions.ts b/extensions/matrix/src/group-mentions.ts index d75ac529ced..d5b970021ba 100644 --- a/extensions/matrix/src/group-mentions.ts +++ b/extensions/matrix/src/group-mentions.ts @@ -1,7 +1,6 @@ import type { ChannelGroupContext, GroupToolPolicyConfig } from "openclaw/plugin-sdk"; - -import { resolveMatrixRoomConfig } from "./matrix/monitor/rooms.js"; import type { CoreConfig } from "./types.js"; +import { resolveMatrixRoomConfig } from "./matrix/monitor/rooms.js"; export function resolveMatrixGroupRequireMention(params: ChannelGroupContext): boolean { const rawGroupId = params.groupId?.trim() ?? ""; diff --git a/extensions/matrix/src/matrix/accounts.test.ts b/extensions/matrix/src/matrix/accounts.test.ts index 2f1cfdb1005..d453684756c 100644 --- a/extensions/matrix/src/matrix/accounts.test.ts +++ b/extensions/matrix/src/matrix/accounts.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import type { CoreConfig } from "../types.js"; import { resolveMatrixAccount } from "./accounts.js"; diff --git a/extensions/matrix/src/matrix/actions/client.ts b/extensions/matrix/src/matrix/actions/client.ts index 514fb49ca1b..d9fe477db85 100644 --- a/extensions/matrix/src/matrix/actions/client.ts +++ b/extensions/matrix/src/matrix/actions/client.ts @@ -1,5 +1,6 @@ -import { getMatrixRuntime } from "../../runtime.js"; import type { CoreConfig } from "../types.js"; +import type { MatrixActionClient, MatrixActionClientOpts } from "./types.js"; +import { getMatrixRuntime } from "../../runtime.js"; import { getActiveMatrixClient } from "../active-client.js"; import { createMatrixClient, @@ -7,7 +8,6 @@ import { resolveMatrixAuth, resolveSharedMatrixClient, } from "../client.js"; -import type { MatrixActionClient, MatrixActionClientOpts } from "./types.js"; export function ensureNodeRuntime() { if (isBunRuntime()) { diff --git a/extensions/matrix/src/matrix/actions/messages.ts b/extensions/matrix/src/matrix/actions/messages.ts index 736c3ed53a0..d9cfe372259 100644 --- a/extensions/matrix/src/matrix/actions/messages.ts +++ b/extensions/matrix/src/matrix/actions/messages.ts @@ -1,3 +1,6 @@ +import { resolveMatrixRoomId, sendMessageMatrix } from "../send.js"; +import { resolveActionClient } from "./client.js"; +import { summarizeMatrixRawEvent } from "./summary.js"; import { EventType, MsgType, @@ -7,9 +10,6 @@ import { type MatrixRawEvent, type RoomMessageEventContent, } from "./types.js"; -import { resolveActionClient } from "./client.js"; -import { summarizeMatrixRawEvent } from "./summary.js"; -import { resolveMatrixRoomId, sendMessageMatrix } from "../send.js"; export async function sendMatrixMessage( to: string, diff --git a/extensions/matrix/src/matrix/actions/pins.ts b/extensions/matrix/src/matrix/actions/pins.ts index 3dbff7373e6..7d466db652f 100644 --- a/extensions/matrix/src/matrix/actions/pins.ts +++ b/extensions/matrix/src/matrix/actions/pins.ts @@ -1,12 +1,12 @@ +import { resolveMatrixRoomId } from "../send.js"; +import { resolveActionClient } from "./client.js"; +import { fetchEventSummary, readPinnedEvents } from "./summary.js"; import { EventType, type MatrixActionClientOpts, type MatrixMessageSummary, type RoomPinnedEventsEventContent, } from "./types.js"; -import { resolveActionClient } from "./client.js"; -import { fetchEventSummary, readPinnedEvents } from "./summary.js"; -import { resolveMatrixRoomId } from "../send.js"; export async function pinMatrixMessage( roomId: string, diff --git a/extensions/matrix/src/matrix/actions/reactions.ts b/extensions/matrix/src/matrix/actions/reactions.ts index 9df5f45390c..fe802396093 100644 --- a/extensions/matrix/src/matrix/actions/reactions.ts +++ b/extensions/matrix/src/matrix/actions/reactions.ts @@ -1,3 +1,5 @@ +import { resolveMatrixRoomId } from "../send.js"; +import { resolveActionClient } from "./client.js"; import { EventType, RelationType, @@ -6,8 +8,6 @@ import { type MatrixReactionSummary, type ReactionEventContent, } from "./types.js"; -import { resolveActionClient } from "./client.js"; -import { resolveMatrixRoomId } from "../send.js"; export async function listMatrixReactions( roomId: string, diff --git a/extensions/matrix/src/matrix/actions/room.ts b/extensions/matrix/src/matrix/actions/room.ts index a16dff6193e..e1770c7bc8d 100644 --- a/extensions/matrix/src/matrix/actions/room.ts +++ b/extensions/matrix/src/matrix/actions/room.ts @@ -1,6 +1,6 @@ -import { EventType, type MatrixActionClientOpts } from "./types.js"; -import { resolveActionClient } from "./client.js"; import { resolveMatrixRoomId } from "../send.js"; +import { resolveActionClient } from "./client.js"; +import { EventType, type MatrixActionClientOpts } from "./types.js"; export async function getMatrixMemberInfo( userId: string, diff --git a/extensions/matrix/src/matrix/actions/summary.ts b/extensions/matrix/src/matrix/actions/summary.ts index b01168b1730..d200e992737 100644 --- a/extensions/matrix/src/matrix/actions/summary.ts +++ b/extensions/matrix/src/matrix/actions/summary.ts @@ -1,5 +1,4 @@ import type { MatrixClient } from "@vector-im/matrix-bot-sdk"; - import { EventType, type MatrixMessageSummary, diff --git a/extensions/matrix/src/matrix/client.test.ts b/extensions/matrix/src/matrix/client.test.ts index f806f9c81af..69de112dbd5 100644 --- a/extensions/matrix/src/matrix/client.test.ts +++ b/extensions/matrix/src/matrix/client.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { CoreConfig } from "../types.js"; import { resolveMatrixConfig } from "./client.js"; diff --git a/extensions/matrix/src/matrix/client/config.ts b/extensions/matrix/src/matrix/client/config.ts index d18826913c1..3c6c0da66b5 100644 --- a/extensions/matrix/src/matrix/client/config.ts +++ b/extensions/matrix/src/matrix/client/config.ts @@ -1,9 +1,8 @@ import { MatrixClient } from "@vector-im/matrix-bot-sdk"; - import type { CoreConfig } from "../types.js"; +import type { MatrixAuth, MatrixResolvedConfig } from "./types.js"; import { getMatrixRuntime } from "../../runtime.js"; import { ensureMatrixSdkLoggingConfigured } from "./logging.js"; -import type { MatrixAuth, MatrixResolvedConfig } from "./types.js"; function clean(value?: string): string { return value?.trim() ?? ""; diff --git a/extensions/matrix/src/matrix/client/create-client.ts b/extensions/matrix/src/matrix/client/create-client.ts index 20e532f2118..d2dc7eaf84a 100644 --- a/extensions/matrix/src/matrix/client/create-client.ts +++ b/extensions/matrix/src/matrix/client/create-client.ts @@ -1,13 +1,11 @@ -import fs from "node:fs"; - +import type { IStorageProvider, ICryptoStorageProvider } from "@vector-im/matrix-bot-sdk"; import { LogService, MatrixClient, SimpleFsStorageProvider, RustSdkCryptoStorageProvider, } from "@vector-im/matrix-bot-sdk"; -import type { IStorageProvider, ICryptoStorageProvider } from "@vector-im/matrix-bot-sdk"; - +import fs from "node:fs"; import { ensureMatrixSdkLoggingConfigured } from "./logging.js"; import { maybeMigrateLegacyStorage, diff --git a/extensions/matrix/src/matrix/client/shared.ts b/extensions/matrix/src/matrix/client/shared.ts index aa56e7150e7..201eb5bbdb2 100644 --- a/extensions/matrix/src/matrix/client/shared.ts +++ b/extensions/matrix/src/matrix/client/shared.ts @@ -1,11 +1,10 @@ -import { LogService } from "@vector-im/matrix-bot-sdk"; import type { MatrixClient } from "@vector-im/matrix-bot-sdk"; - +import { LogService } from "@vector-im/matrix-bot-sdk"; import type { CoreConfig } from "../types.js"; -import { createMatrixClient } from "./create-client.js"; -import { resolveMatrixAuth } from "./config.js"; -import { DEFAULT_ACCOUNT_KEY } from "./storage.js"; import type { MatrixAuth } from "./types.js"; +import { resolveMatrixAuth } from "./config.js"; +import { createMatrixClient } from "./create-client.js"; +import { DEFAULT_ACCOUNT_KEY } from "./storage.js"; type SharedMatrixClientState = { client: MatrixClient; diff --git a/extensions/matrix/src/matrix/client/storage.ts b/extensions/matrix/src/matrix/client/storage.ts index fbc069e0e4f..1c9dfbf3371 100644 --- a/extensions/matrix/src/matrix/client/storage.ts +++ b/extensions/matrix/src/matrix/client/storage.ts @@ -2,9 +2,8 @@ import crypto from "node:crypto"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - -import { getMatrixRuntime } from "../../runtime.js"; import type { MatrixStoragePaths } from "./types.js"; +import { getMatrixRuntime } from "../../runtime.js"; export const DEFAULT_ACCOUNT_KEY = "default"; const STORAGE_META_FILENAME = "storage-meta.json"; diff --git a/extensions/matrix/src/matrix/credentials.ts b/extensions/matrix/src/matrix/credentials.ts index faebc8fda72..04072dc72f1 100644 --- a/extensions/matrix/src/matrix/credentials.ts +++ b/extensions/matrix/src/matrix/credentials.ts @@ -1,7 +1,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import { getMatrixRuntime } from "../runtime.js"; export type MatrixStoredCredentials = { diff --git a/extensions/matrix/src/matrix/deps.ts b/extensions/matrix/src/matrix/deps.ts index d838f4d4dca..67fb5244a11 100644 --- a/extensions/matrix/src/matrix/deps.ts +++ b/extensions/matrix/src/matrix/deps.ts @@ -1,9 +1,8 @@ -import fs from "node:fs"; -import path from "node:path"; -import { createRequire } from "node:module"; -import { fileURLToPath } from "node:url"; - import type { RuntimeEnv } from "openclaw/plugin-sdk"; +import fs from "node:fs"; +import { createRequire } from "node:module"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; import { getMatrixRuntime } from "../runtime.js"; const MATRIX_SDK_PACKAGE = "@vector-im/matrix-bot-sdk"; diff --git a/extensions/matrix/src/matrix/format.test.ts b/extensions/matrix/src/matrix/format.test.ts index 5ae98c97c0e..4538c2792e2 100644 --- a/extensions/matrix/src/matrix/format.test.ts +++ b/extensions/matrix/src/matrix/format.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { markdownToMatrixHtml } from "./format.js"; describe("markdownToMatrixHtml", () => { diff --git a/extensions/matrix/src/matrix/monitor/auto-join.ts b/extensions/matrix/src/matrix/monitor/auto-join.ts index f49405037ad..6fb36b93f17 100644 --- a/extensions/matrix/src/matrix/monitor/auto-join.ts +++ b/extensions/matrix/src/matrix/monitor/auto-join.ts @@ -1,7 +1,6 @@ import type { MatrixClient } from "@vector-im/matrix-bot-sdk"; -import { AutojoinRoomsMixin } from "@vector-im/matrix-bot-sdk"; - import type { RuntimeEnv } from "openclaw/plugin-sdk"; +import { AutojoinRoomsMixin } from "@vector-im/matrix-bot-sdk"; import type { CoreConfig } from "../../types.js"; import { getMatrixRuntime } from "../../runtime.js"; diff --git a/extensions/matrix/src/matrix/monitor/events.ts b/extensions/matrix/src/matrix/monitor/events.ts index be52be00bef..1faeffc819d 100644 --- a/extensions/matrix/src/matrix/monitor/events.ts +++ b/extensions/matrix/src/matrix/monitor/events.ts @@ -1,6 +1,5 @@ import type { MatrixClient } from "@vector-im/matrix-bot-sdk"; import type { PluginRuntime } from "openclaw/plugin-sdk"; - import type { MatrixAuth } from "../client.js"; import type { MatrixRawEvent } from "./types.js"; import { EventType } from "./types.js"; diff --git a/extensions/matrix/src/matrix/monitor/handler.ts b/extensions/matrix/src/matrix/monitor/handler.ts index 27cb5e3a5d6..6f45f5ed38f 100644 --- a/extensions/matrix/src/matrix/monitor/handler.ts +++ b/extensions/matrix/src/matrix/monitor/handler.ts @@ -1,5 +1,4 @@ import type { LocationMessageEventContent, MatrixClient } from "@vector-im/matrix-bot-sdk"; - import { createReplyPrefixContext, createTypingCallbacks, @@ -10,6 +9,7 @@ import { type RuntimeEnv, } from "openclaw/plugin-sdk"; import type { CoreConfig, ReplyToMode } from "../../types.js"; +import type { MatrixRawEvent, RoomMessageEventContent } from "./types.js"; import { formatPollAsText, isPollStartType, @@ -27,13 +27,12 @@ import { resolveMatrixAllowListMatches, normalizeAllowListLower, } from "./allowlist.js"; +import { resolveMatrixLocation, type MatrixLocationPayload } from "./location.js"; import { downloadMatrixMedia } from "./media.js"; import { resolveMentions } from "./mentions.js"; import { deliverMatrixReplies } from "./replies.js"; import { resolveMatrixRoomConfig } from "./rooms.js"; import { resolveMatrixThreadRootId, resolveMatrixThreadTarget } from "./threads.js"; -import { resolveMatrixLocation, type MatrixLocationPayload } from "./location.js"; -import type { MatrixRawEvent, RoomMessageEventContent } from "./types.js"; import { EventType, RelationType } from "./types.js"; export type MatrixMonitorHandlerParams = { diff --git a/extensions/matrix/src/matrix/monitor/index.ts b/extensions/matrix/src/matrix/monitor/index.ts index 8572064575e..4ac87b25185 100644 --- a/extensions/matrix/src/matrix/monitor/index.ts +++ b/extensions/matrix/src/matrix/monitor/index.ts @@ -1,7 +1,8 @@ import { format } from "node:util"; - import { mergeAllowlist, summarizeMapping, type RuntimeEnv } from "openclaw/plugin-sdk"; import type { CoreConfig, ReplyToMode } from "../../types.js"; +import { resolveMatrixTargets } from "../../resolve-targets.js"; +import { getMatrixRuntime } from "../../runtime.js"; import { setActiveMatrixClient } from "../active-client.js"; import { isBunRuntime, @@ -14,8 +15,6 @@ import { createDirectRoomTracker } from "./direct.js"; import { registerMatrixMonitorEvents } from "./events.js"; import { createMatrixRoomMessageHandler } from "./handler.js"; import { createMatrixRoomInfoResolver } from "./room-info.js"; -import { resolveMatrixTargets } from "../../resolve-targets.js"; -import { getMatrixRuntime } from "../../runtime.js"; export type MonitorMatrixOpts = { runtime?: RuntimeEnv; diff --git a/extensions/matrix/src/matrix/monitor/location.ts b/extensions/matrix/src/matrix/monitor/location.ts index 319490a4f35..41c91aecc16 100644 --- a/extensions/matrix/src/matrix/monitor/location.ts +++ b/extensions/matrix/src/matrix/monitor/location.ts @@ -1,5 +1,4 @@ import type { LocationMessageEventContent } from "@vector-im/matrix-bot-sdk"; - import { formatLocationText, toLocationContext, diff --git a/extensions/matrix/src/matrix/monitor/media.test.ts b/extensions/matrix/src/matrix/monitor/media.test.ts index eabbc0d4c5c..590dd5148a5 100644 --- a/extensions/matrix/src/matrix/monitor/media.test.ts +++ b/extensions/matrix/src/matrix/monitor/media.test.ts @@ -1,6 +1,5 @@ -import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { PluginRuntime } from "openclaw/plugin-sdk"; +import { beforeEach, describe, expect, it, vi } from "vitest"; import { setMatrixRuntime } from "../../runtime.js"; import { downloadMatrixMedia } from "./media.js"; diff --git a/extensions/matrix/src/matrix/monitor/media.ts b/extensions/matrix/src/matrix/monitor/media.ts index 631e3813aec..c88bfc0613b 100644 --- a/extensions/matrix/src/matrix/monitor/media.ts +++ b/extensions/matrix/src/matrix/monitor/media.ts @@ -1,5 +1,4 @@ import type { MatrixClient } from "@vector-im/matrix-bot-sdk"; - import { getMatrixRuntime } from "../../runtime.js"; // Type for encrypted file info diff --git a/extensions/matrix/src/matrix/monitor/replies.ts b/extensions/matrix/src/matrix/monitor/replies.ts index 4aef77b7459..1193d59f80d 100644 --- a/extensions/matrix/src/matrix/monitor/replies.ts +++ b/extensions/matrix/src/matrix/monitor/replies.ts @@ -1,8 +1,7 @@ import type { MatrixClient } from "@vector-im/matrix-bot-sdk"; - import type { MarkdownTableMode, ReplyPayload, RuntimeEnv } from "openclaw/plugin-sdk"; -import { sendMessageMatrix } from "../send.js"; import { getMatrixRuntime } from "../../runtime.js"; +import { sendMessageMatrix } from "../send.js"; export async function deliverMatrixReplies(params: { replies: ReplyPayload[]; diff --git a/extensions/matrix/src/matrix/monitor/rooms.ts b/extensions/matrix/src/matrix/monitor/rooms.ts index 7cbf3069b35..ed705e8371a 100644 --- a/extensions/matrix/src/matrix/monitor/rooms.ts +++ b/extensions/matrix/src/matrix/monitor/rooms.ts @@ -1,5 +1,5 @@ -import type { MatrixRoomConfig } from "../../types.js"; import { buildChannelKeyCandidates, resolveChannelEntryMatch } from "openclaw/plugin-sdk"; +import type { MatrixRoomConfig } from "../../types.js"; export type MatrixRoomConfigResolved = { allowed: boolean; diff --git a/extensions/matrix/src/matrix/poll-types.test.ts b/extensions/matrix/src/matrix/poll-types.test.ts index f2d885622fa..7f1797d99c6 100644 --- a/extensions/matrix/src/matrix/poll-types.test.ts +++ b/extensions/matrix/src/matrix/poll-types.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { parsePollStartContent } from "./poll-types.js"; describe("parsePollStartContent", () => { diff --git a/extensions/matrix/src/matrix/send.test.ts b/extensions/matrix/src/matrix/send.test.ts index 2bba70e6cc8..0ebfc826f80 100644 --- a/extensions/matrix/src/matrix/send.test.ts +++ b/extensions/matrix/src/matrix/send.test.ts @@ -1,6 +1,5 @@ -import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; - import type { PluginRuntime } from "openclaw/plugin-sdk"; +import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { setMatrixRuntime } from "../runtime.js"; vi.mock("@vector-im/matrix-bot-sdk", () => ({ diff --git a/extensions/matrix/src/matrix/send.ts b/extensions/matrix/src/matrix/send.ts index 51eb11060d1..b9bfae4fe00 100644 --- a/extensions/matrix/src/matrix/send.ts +++ b/extensions/matrix/src/matrix/send.ts @@ -1,5 +1,4 @@ import type { MatrixClient } from "@vector-im/matrix-bot-sdk"; - import type { PollInput } from "openclaw/plugin-sdk"; import { getMatrixRuntime } from "../runtime.js"; import { buildPollStartContent, M_POLL_START } from "./poll-types.js"; diff --git a/extensions/matrix/src/matrix/send/client.ts b/extensions/matrix/src/matrix/send/client.ts index 359d126724a..aa0f3badb79 100644 --- a/extensions/matrix/src/matrix/send/client.ts +++ b/extensions/matrix/src/matrix/send/client.ts @@ -1,5 +1,5 @@ import type { MatrixClient } from "@vector-im/matrix-bot-sdk"; - +import type { CoreConfig } from "../types.js"; import { getMatrixRuntime } from "../../runtime.js"; import { getActiveMatrixClient } from "../active-client.js"; import { @@ -8,7 +8,6 @@ import { resolveMatrixAuth, resolveSharedMatrixClient, } from "../client.js"; -import type { CoreConfig } from "../types.js"; const getCore = () => getMatrixRuntime(); diff --git a/extensions/matrix/src/matrix/send/formatting.ts b/extensions/matrix/src/matrix/send/formatting.ts index 52f229d188c..3189d1e9086 100644 --- a/extensions/matrix/src/matrix/send/formatting.ts +++ b/extensions/matrix/src/matrix/send/formatting.ts @@ -1,5 +1,5 @@ -import { markdownToMatrixHtml } from "../format.js"; import { getMatrixRuntime } from "../../runtime.js"; +import { markdownToMatrixHtml } from "../format.js"; import { MsgType, RelationType, diff --git a/extensions/matrix/src/matrix/send/media.ts b/extensions/matrix/src/matrix/send/media.ts index 93598847e2e..c4339d90057 100644 --- a/extensions/matrix/src/matrix/send/media.ts +++ b/extensions/matrix/src/matrix/send/media.ts @@ -7,8 +7,8 @@ import type { VideoFileInfo, } from "@vector-im/matrix-bot-sdk"; import { parseBuffer, type IFileInfo } from "music-metadata"; - import { getMatrixRuntime } from "../../runtime.js"; +import { applyMatrixFormatting } from "./formatting.js"; import { type MatrixMediaContent, type MatrixMediaInfo, @@ -16,7 +16,6 @@ import { type MatrixRelation, type MediaKind, } from "./types.js"; -import { applyMatrixFormatting } from "./formatting.js"; const getCore = () => getMatrixRuntime(); diff --git a/extensions/matrix/src/matrix/send/targets.test.ts b/extensions/matrix/src/matrix/send/targets.test.ts index 39949473c74..0bc90327cc8 100644 --- a/extensions/matrix/src/matrix/send/targets.test.ts +++ b/extensions/matrix/src/matrix/send/targets.test.ts @@ -1,6 +1,5 @@ -import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { MatrixClient } from "@vector-im/matrix-bot-sdk"; +import { beforeEach, describe, expect, it, vi } from "vitest"; import { EventType } from "./types.js"; let resolveMatrixRoomId: typeof import("./targets.js").resolveMatrixRoomId; diff --git a/extensions/matrix/src/matrix/send/targets.ts b/extensions/matrix/src/matrix/send/targets.ts index ee697c3f786..b3de224eb66 100644 --- a/extensions/matrix/src/matrix/send/targets.ts +++ b/extensions/matrix/src/matrix/send/targets.ts @@ -1,5 +1,4 @@ import type { MatrixClient } from "@vector-im/matrix-bot-sdk"; - import { EventType, type MatrixDirectAccountData } from "./types.js"; function normalizeTarget(raw: string): string { diff --git a/extensions/matrix/src/onboarding.ts b/extensions/matrix/src/onboarding.ts index 2a31aa6ce8a..c85f3a25ac3 100644 --- a/extensions/matrix/src/onboarding.ts +++ b/extensions/matrix/src/onboarding.ts @@ -6,11 +6,11 @@ import { type ChannelOnboardingDmPolicy, type WizardPrompter, } from "openclaw/plugin-sdk"; +import type { CoreConfig, DmPolicy } from "./types.js"; import { listMatrixDirectoryGroupsLive } from "./directory-live.js"; import { listMatrixDirectoryPeersLive } from "./directory-live.js"; import { resolveMatrixAccount } from "./matrix/accounts.js"; import { ensureMatrixSdkInstalled, isMatrixSdkAvailable } from "./matrix/deps.js"; -import type { CoreConfig, DmPolicy } from "./types.js"; const channel = "matrix" as const; diff --git a/extensions/matrix/src/outbound.ts b/extensions/matrix/src/outbound.ts index 91a6ced80c4..86e660e663d 100644 --- a/extensions/matrix/src/outbound.ts +++ b/extensions/matrix/src/outbound.ts @@ -1,7 +1,6 @@ import type { ChannelOutboundAdapter } from "openclaw/plugin-sdk"; - -import { getMatrixRuntime } from "./runtime.js"; import { sendMessageMatrix, sendPollMatrix } from "./matrix/send.js"; +import { getMatrixRuntime } from "./runtime.js"; export const matrixOutbound: ChannelOutboundAdapter = { deliveryMode: "direct", diff --git a/extensions/matrix/src/resolve-targets.ts b/extensions/matrix/src/resolve-targets.ts index ccb790e426c..a184247e1b5 100644 --- a/extensions/matrix/src/resolve-targets.ts +++ b/extensions/matrix/src/resolve-targets.ts @@ -4,7 +4,6 @@ import type { ChannelResolveResult, RuntimeEnv, } from "openclaw/plugin-sdk"; - import { listMatrixDirectoryGroupsLive, listMatrixDirectoryPeersLive } from "./directory-live.js"; function pickBestGroupMatch( diff --git a/extensions/matrix/src/tool-actions.ts b/extensions/matrix/src/tool-actions.ts index 7e3c0315855..83ccecd7a81 100644 --- a/extensions/matrix/src/tool-actions.ts +++ b/extensions/matrix/src/tool-actions.ts @@ -1,5 +1,11 @@ import type { AgentToolResult } from "@mariozechner/pi-agent-core"; - +import { + createActionGate, + jsonResult, + readNumberParam, + readReactionParams, + readStringParam, +} from "openclaw/plugin-sdk"; import type { CoreConfig } from "./types.js"; import { deleteMatrixMessage, @@ -15,13 +21,6 @@ import { unpinMatrixMessage, } from "./matrix/actions.js"; import { reactMatrixMessage } from "./matrix/send.js"; -import { - createActionGate, - jsonResult, - readNumberParam, - readReactionParams, - readStringParam, -} from "openclaw/plugin-sdk"; const messageActions = new Set(["sendMessage", "editMessage", "deleteMessage", "readMessages"]); const reactionActions = new Set(["react", "reactions"]); diff --git a/extensions/mattermost/index.ts b/extensions/mattermost/index.ts index 0f911713d5d..276c5d01871 100644 --- a/extensions/mattermost/index.ts +++ b/extensions/mattermost/index.ts @@ -1,6 +1,5 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { mattermostPlugin } from "./src/channel.js"; import { setMattermostRuntime } from "./src/runtime.js"; diff --git a/extensions/mattermost/src/channel.test.ts b/extensions/mattermost/src/channel.test.ts index 8f6c08355f6..118d6dfb670 100644 --- a/extensions/mattermost/src/channel.test.ts +++ b/extensions/mattermost/src/channel.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { mattermostPlugin } from "./channel.js"; describe("mattermostPlugin", () => { diff --git a/extensions/mattermost/src/channel.ts b/extensions/mattermost/src/channel.ts index 75521d6ead5..a658dbb04e5 100644 --- a/extensions/mattermost/src/channel.ts +++ b/extensions/mattermost/src/channel.ts @@ -9,11 +9,8 @@ import { setAccountEnabledInConfigSection, type ChannelPlugin, } from "openclaw/plugin-sdk"; - import { MattermostConfigSchema } from "./config-schema.js"; import { resolveMattermostGroupRequireMention } from "./group-mentions.js"; -import { looksLikeMattermostTargetId, normalizeMattermostMessagingTarget } from "./normalize.js"; -import { mattermostOnboardingAdapter } from "./onboarding.js"; import { listMattermostAccountIds, resolveDefaultMattermostAccountId, @@ -24,6 +21,8 @@ import { normalizeMattermostBaseUrl } from "./mattermost/client.js"; import { monitorMattermostProvider } from "./mattermost/monitor.js"; import { probeMattermost } from "./mattermost/probe.js"; import { sendMessageMattermost } from "./mattermost/send.js"; +import { looksLikeMattermostTargetId, normalizeMattermostMessagingTarget } from "./normalize.js"; +import { mattermostOnboardingAdapter } from "./onboarding.js"; import { getMattermostRuntime } from "./runtime.js"; const meta = { diff --git a/extensions/mattermost/src/config-schema.ts b/extensions/mattermost/src/config-schema.ts index 885451827ee..4f184f38027 100644 --- a/extensions/mattermost/src/config-schema.ts +++ b/extensions/mattermost/src/config-schema.ts @@ -1,5 +1,3 @@ -import { z } from "zod"; - import { BlockStreamingCoalesceSchema, DmPolicySchema, @@ -7,6 +5,7 @@ import { MarkdownConfigSchema, requireOpenAllowFrom, } from "openclaw/plugin-sdk"; +import { z } from "zod"; const MattermostAccountSchemaBase = z .object({ diff --git a/extensions/mattermost/src/group-mentions.ts b/extensions/mattermost/src/group-mentions.ts index 416d368529a..c92da2000c0 100644 --- a/extensions/mattermost/src/group-mentions.ts +++ b/extensions/mattermost/src/group-mentions.ts @@ -1,5 +1,4 @@ import type { ChannelGroupContext } from "openclaw/plugin-sdk"; - import { resolveMattermostAccount } from "./mattermost/accounts.js"; export function resolveMattermostGroupRequireMention( diff --git a/extensions/mattermost/src/mattermost/accounts.ts b/extensions/mattermost/src/mattermost/accounts.ts index e56084316e1..d4fbd34a21f 100644 --- a/extensions/mattermost/src/mattermost/accounts.ts +++ b/extensions/mattermost/src/mattermost/accounts.ts @@ -1,6 +1,5 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk"; import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk"; - import type { MattermostAccountConfig, MattermostChatMode } from "../types.js"; import { normalizeMattermostBaseUrl } from "./client.js"; diff --git a/extensions/mattermost/src/mattermost/monitor-helpers.ts b/extensions/mattermost/src/mattermost/monitor-helpers.ts index 9e7e2a1658d..9e483f6a46b 100644 --- a/extensions/mattermost/src/mattermost/monitor-helpers.ts +++ b/extensions/mattermost/src/mattermost/monitor-helpers.ts @@ -1,8 +1,6 @@ -import { Buffer } from "node:buffer"; - -import type WebSocket from "ws"; - import type { OpenClawConfig } from "openclaw/plugin-sdk"; +import type WebSocket from "ws"; +import { Buffer } from "node:buffer"; export type ResponsePrefixContext = { model?: string; diff --git a/extensions/mattermost/src/mattermost/monitor.ts b/extensions/mattermost/src/mattermost/monitor.ts index b132d57601f..8d10b13f6b6 100644 --- a/extensions/mattermost/src/mattermost/monitor.ts +++ b/extensions/mattermost/src/mattermost/monitor.ts @@ -1,5 +1,3 @@ -import WebSocket from "ws"; - import type { ChannelAccountSnapshot, OpenClawConfig, @@ -19,7 +17,7 @@ import { resolveChannelMediaMaxBytes, type HistoryEntry, } from "openclaw/plugin-sdk"; - +import WebSocket from "ws"; import { getMattermostRuntime } from "../runtime.js"; import { resolveMattermostAccount } from "./accounts.js"; import { diff --git a/extensions/mattermost/src/onboarding.ts b/extensions/mattermost/src/onboarding.ts index eccec060032..2384558e14b 100644 --- a/extensions/mattermost/src/onboarding.ts +++ b/extensions/mattermost/src/onboarding.ts @@ -1,6 +1,5 @@ import type { ChannelOnboardingAdapter, OpenClawConfig, WizardPrompter } from "openclaw/plugin-sdk"; import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk"; - import { listMattermostAccountIds, resolveDefaultMattermostAccountId, diff --git a/extensions/memory-lancedb/index.test.ts b/extensions/memory-lancedb/index.test.ts index 02692cc280c..f90bf95ec05 100644 --- a/extensions/memory-lancedb/index.test.ts +++ b/extensions/memory-lancedb/index.test.ts @@ -8,10 +8,10 @@ * - Auto-capture filtering */ -import { describe, test, expect, beforeEach, afterEach } from "vitest"; import fs from "node:fs/promises"; -import path from "node:path"; import os from "node:os"; +import path from "node:path"; +import { describe, test, expect, beforeEach, afterEach } from "vitest"; const OPENAI_API_KEY = process.env.OPENAI_API_KEY ?? "test-key"; const HAS_OPENAI_KEY = Boolean(process.env.OPENAI_API_KEY); diff --git a/extensions/memory-lancedb/index.ts b/extensions/memory-lancedb/index.ts index 54200295abf..5e4def80fa2 100644 --- a/extensions/memory-lancedb/index.ts +++ b/extensions/memory-lancedb/index.ts @@ -6,13 +6,12 @@ * Provides seamless auto-recall and auto-capture via lifecycle hooks. */ -import { Type } from "@sinclair/typebox"; -import * as lancedb from "@lancedb/lancedb"; -import OpenAI from "openai"; -import { randomUUID } from "node:crypto"; import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; +import * as lancedb from "@lancedb/lancedb"; +import { Type } from "@sinclair/typebox"; +import { randomUUID } from "node:crypto"; +import OpenAI from "openai"; import { stringEnum } from "openclaw/plugin-sdk"; - import { MEMORY_CATEGORIES, type MemoryCategory, diff --git a/extensions/minimax-portal-auth/index.ts b/extensions/minimax-portal-auth/index.ts index 2aa76ca8df6..6c436163b74 100644 --- a/extensions/minimax-portal-auth/index.ts +++ b/extensions/minimax-portal-auth/index.ts @@ -1,5 +1,4 @@ import { emptyPluginConfigSchema } from "clawdbot/plugin-sdk"; - import { loginMiniMaxPortalOAuth, type MiniMaxRegion } from "./oauth.js"; const PROVIDER_ID = "minimax-portal"; diff --git a/extensions/msteams/index.ts b/extensions/msteams/index.ts index 31fae9d08d0..6bab4723675 100644 --- a/extensions/msteams/index.ts +++ b/extensions/msteams/index.ts @@ -1,6 +1,5 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { msteamsPlugin } from "./src/channel.js"; import { setMSTeamsRuntime } from "./src/runtime.js"; diff --git a/extensions/msteams/src/attachments.test.ts b/extensions/msteams/src/attachments.test.ts index 67013c818c7..ac8b635569e 100644 --- a/extensions/msteams/src/attachments.test.ts +++ b/extensions/msteams/src/attachments.test.ts @@ -1,6 +1,5 @@ -import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { PluginRuntime } from "openclaw/plugin-sdk"; +import { beforeEach, describe, expect, it, vi } from "vitest"; import { setMSTeamsRuntime } from "./runtime.js"; const detectMimeMock = vi.fn(async () => "image/png"); diff --git a/extensions/msteams/src/attachments/download.ts b/extensions/msteams/src/attachments/download.ts index ab9410bfbe8..9446a259ae5 100644 --- a/extensions/msteams/src/attachments/download.ts +++ b/extensions/msteams/src/attachments/download.ts @@ -1,3 +1,8 @@ +import type { + MSTeamsAccessTokenProvider, + MSTeamsAttachmentLike, + MSTeamsInboundMedia, +} from "./types.js"; import { getMSTeamsRuntime } from "../runtime.js"; import { extractInlineImageCandidates, @@ -8,11 +13,6 @@ import { normalizeContentType, resolveAllowedHosts, } from "./shared.js"; -import type { - MSTeamsAccessTokenProvider, - MSTeamsAttachmentLike, - MSTeamsInboundMedia, -} from "./types.js"; type DownloadCandidate = { url: string; diff --git a/extensions/msteams/src/attachments/graph.ts b/extensions/msteams/src/attachments/graph.ts index e1b7d2c67d5..c1f594641fe 100644 --- a/extensions/msteams/src/attachments/graph.ts +++ b/extensions/msteams/src/attachments/graph.ts @@ -1,3 +1,9 @@ +import type { + MSTeamsAccessTokenProvider, + MSTeamsAttachmentLike, + MSTeamsGraphMediaResult, + MSTeamsInboundMedia, +} from "./types.js"; import { getMSTeamsRuntime } from "../runtime.js"; import { downloadMSTeamsAttachments } from "./download.js"; import { @@ -7,12 +13,6 @@ import { normalizeContentType, resolveAllowedHosts, } from "./shared.js"; -import type { - MSTeamsAccessTokenProvider, - MSTeamsAttachmentLike, - MSTeamsGraphMediaResult, - MSTeamsInboundMedia, -} from "./types.js"; type GraphHostedContent = { id?: string | null; diff --git a/extensions/msteams/src/attachments/html.ts b/extensions/msteams/src/attachments/html.ts index 33c5d28a868..a1983d452de 100644 --- a/extensions/msteams/src/attachments/html.ts +++ b/extensions/msteams/src/attachments/html.ts @@ -1,3 +1,4 @@ +import type { MSTeamsAttachmentLike, MSTeamsHtmlAttachmentSummary } from "./types.js"; import { ATTACHMENT_TAG_RE, extractHtmlFromAttachment, @@ -6,7 +7,6 @@ import { isLikelyImageAttachment, safeHostForUrl, } from "./shared.js"; -import type { MSTeamsAttachmentLike, MSTeamsHtmlAttachmentSummary } from "./types.js"; export function summarizeMSTeamsHtmlAttachments( attachments: MSTeamsAttachmentLike[] | undefined, diff --git a/extensions/msteams/src/channel.directory.test.ts b/extensions/msteams/src/channel.directory.test.ts index f0d7e296390..e334edf9999 100644 --- a/extensions/msteams/src/channel.directory.test.ts +++ b/extensions/msteams/src/channel.directory.test.ts @@ -1,7 +1,5 @@ -import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "openclaw/plugin-sdk"; - +import { describe, expect, it } from "vitest"; import { msteamsPlugin } from "./channel.js"; describe("msteams directory", () => { diff --git a/extensions/msteams/src/channel.ts b/extensions/msteams/src/channel.ts index 4442f45190c..5bd16bc3ab9 100644 --- a/extensions/msteams/src/channel.ts +++ b/extensions/msteams/src/channel.ts @@ -5,11 +5,11 @@ import { MSTeamsConfigSchema, PAIRING_APPROVED_MESSAGE, } from "openclaw/plugin-sdk"; - +import { listMSTeamsDirectoryGroupsLive, listMSTeamsDirectoryPeersLive } from "./directory-live.js"; import { msteamsOnboardingAdapter } from "./onboarding.js"; import { msteamsOutbound } from "./outbound.js"; -import { probeMSTeams } from "./probe.js"; import { resolveMSTeamsGroupToolPolicy } from "./policy.js"; +import { probeMSTeams } from "./probe.js"; import { normalizeMSTeamsMessagingTarget, normalizeMSTeamsUserInput, @@ -20,7 +20,6 @@ import { } from "./resolve-allowlist.js"; import { sendAdaptiveCardMSTeams, sendMessageMSTeams } from "./send.js"; import { resolveMSTeamsCredentials } from "./token.js"; -import { listMSTeamsDirectoryGroupsLive, listMSTeamsDirectoryPeersLive } from "./directory-live.js"; type ResolvedMSTeamsAccount = { accountId: string; diff --git a/extensions/msteams/src/conversation-store-fs.test.ts b/extensions/msteams/src/conversation-store-fs.test.ts index 59c30897d06..aa8feb85413 100644 --- a/extensions/msteams/src/conversation-store-fs.test.ts +++ b/extensions/msteams/src/conversation-store-fs.test.ts @@ -1,10 +1,8 @@ +import type { PluginRuntime } from "openclaw/plugin-sdk"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import { beforeEach, describe, expect, it } from "vitest"; - -import type { PluginRuntime } from "openclaw/plugin-sdk"; import type { StoredConversationReference } from "./conversation-store.js"; import { createMSTeamsConversationStoreFs } from "./conversation-store-fs.js"; import { setMSTeamsRuntime } from "./runtime.js"; diff --git a/extensions/msteams/src/directory-live.ts b/extensions/msteams/src/directory-live.ts index 6608b9b7000..e885cdcbc63 100644 --- a/extensions/msteams/src/directory-live.ts +++ b/extensions/msteams/src/directory-live.ts @@ -1,5 +1,4 @@ import type { ChannelDirectoryEntry } from "openclaw/plugin-sdk"; - import { GRAPH_ROOT } from "./attachments/shared.js"; import { loadMSTeamsSdkWithAuth } from "./sdk.js"; import { resolveMSTeamsCredentials } from "./token.js"; diff --git a/extensions/msteams/src/errors.test.ts b/extensions/msteams/src/errors.test.ts index 3b4751caee1..6890e1a1d2a 100644 --- a/extensions/msteams/src/errors.test.ts +++ b/extensions/msteams/src/errors.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { classifyMSTeamsSendError, formatMSTeamsSendErrorHint, diff --git a/extensions/msteams/src/inbound.test.ts b/extensions/msteams/src/inbound.test.ts index 9396cfb948e..ecee5835b18 100644 --- a/extensions/msteams/src/inbound.test.ts +++ b/extensions/msteams/src/inbound.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { normalizeMSTeamsConversationId, parseMSTeamsActivityTimestamp, diff --git a/extensions/msteams/src/media-helpers.test.ts b/extensions/msteams/src/media-helpers.test.ts index eaec41e0f07..27a9c08ec2d 100644 --- a/extensions/msteams/src/media-helpers.test.ts +++ b/extensions/msteams/src/media-helpers.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { extractFilename, extractMessageId, getMimeType, isLocalPath } from "./media-helpers.js"; describe("msteams media-helpers", () => { diff --git a/extensions/msteams/src/media-helpers.ts b/extensions/msteams/src/media-helpers.ts index da1464258a4..c4368fb4d69 100644 --- a/extensions/msteams/src/media-helpers.ts +++ b/extensions/msteams/src/media-helpers.ts @@ -3,7 +3,6 @@ */ import path from "node:path"; - import { detectMime, extensionForMime, diff --git a/extensions/msteams/src/messenger.test.ts b/extensions/msteams/src/messenger.test.ts index 7aa47907a9f..bd49e4e8161 100644 --- a/extensions/msteams/src/messenger.test.ts +++ b/extensions/msteams/src/messenger.test.ts @@ -1,6 +1,5 @@ -import { beforeEach, describe, expect, it } from "vitest"; - import { SILENT_REPLY_TOKEN, type PluginRuntime } from "openclaw/plugin-sdk"; +import { beforeEach, describe, expect, it } from "vitest"; import type { StoredConversationReference } from "./conversation-store.js"; import { type MSTeamsAdapter, diff --git a/extensions/msteams/src/monitor-handler.ts b/extensions/msteams/src/monitor-handler.ts index c293235603d..4186d557199 100644 --- a/extensions/msteams/src/monitor-handler.ts +++ b/extensions/msteams/src/monitor-handler.ts @@ -1,12 +1,12 @@ import type { OpenClawConfig, RuntimeEnv } from "openclaw/plugin-sdk"; import type { MSTeamsConversationStore } from "./conversation-store.js"; -import { buildFileInfoCard, parseFileConsentInvoke, uploadToConsentUrl } from "./file-consent.js"; import type { MSTeamsAdapter } from "./messenger.js"; -import { createMSTeamsMessageHandler } from "./monitor-handler/message-handler.js"; import type { MSTeamsMonitorLogger } from "./monitor-types.js"; -import { getPendingUpload, removePendingUpload } from "./pending-uploads.js"; import type { MSTeamsPollStore } from "./polls.js"; import type { MSTeamsTurnContext } from "./sdk-types.js"; +import { buildFileInfoCard, parseFileConsentInvoke, uploadToConsentUrl } from "./file-consent.js"; +import { createMSTeamsMessageHandler } from "./monitor-handler/message-handler.js"; +import { getPendingUpload, removePendingUpload } from "./pending-uploads.js"; export type MSTeamsAccessTokenProvider = { getAccessToken: (scope: string) => Promise; diff --git a/extensions/msteams/src/monitor-handler/inbound-media.ts b/extensions/msteams/src/monitor-handler/inbound-media.ts index 2fba0017211..6781324ae6d 100644 --- a/extensions/msteams/src/monitor-handler/inbound-media.ts +++ b/extensions/msteams/src/monitor-handler/inbound-media.ts @@ -1,3 +1,4 @@ +import type { MSTeamsTurnContext } from "../sdk-types.js"; import { buildMSTeamsGraphMessageUrls, downloadMSTeamsAttachments, @@ -7,7 +8,6 @@ import { type MSTeamsHtmlAttachmentSummary, type MSTeamsInboundMedia, } from "../attachments.js"; -import type { MSTeamsTurnContext } from "../sdk-types.js"; type MSTeamsLogger = { debug: (message: string, meta?: Record) => void; diff --git a/extensions/msteams/src/monitor-handler/message-handler.ts b/extensions/msteams/src/monitor-handler/message-handler.ts index a7b8b820502..701e713014e 100644 --- a/extensions/msteams/src/monitor-handler/message-handler.ts +++ b/extensions/msteams/src/monitor-handler/message-handler.ts @@ -9,14 +9,15 @@ import { formatAllowlistMatchMeta, type HistoryEntry, } from "openclaw/plugin-sdk"; - +import type { StoredConversationReference } from "../conversation-store.js"; +import type { MSTeamsMessageHandlerDeps } from "../monitor-handler.js"; +import type { MSTeamsTurnContext } from "../sdk-types.js"; import { buildMSTeamsAttachmentPlaceholder, buildMSTeamsMediaPayload, type MSTeamsAttachmentLike, summarizeMSTeamsHtmlAttachments, } from "../attachments.js"; -import type { StoredConversationReference } from "../conversation-store.js"; import { formatUnknownError } from "../errors.js"; import { extractMSTeamsConversationMessageId, @@ -25,7 +26,6 @@ import { stripMSTeamsMentionTags, wasMSTeamsBotMentioned, } from "../inbound.js"; -import type { MSTeamsMessageHandlerDeps } from "../monitor-handler.js"; import { isMSTeamsGroupAllowed, resolveMSTeamsAllowlistMatch, @@ -34,10 +34,9 @@ import { } from "../policy.js"; import { extractMSTeamsPollVote } from "../polls.js"; import { createMSTeamsReplyDispatcher } from "../reply-dispatcher.js"; -import { recordMSTeamsSentMessage, wasMSTeamsMessageSent } from "../sent-message-cache.js"; -import type { MSTeamsTurnContext } from "../sdk-types.js"; -import { resolveMSTeamsInboundMedia } from "./inbound-media.js"; import { getMSTeamsRuntime } from "../runtime.js"; +import { recordMSTeamsSentMessage, wasMSTeamsMessageSent } from "../sent-message-cache.js"; +import { resolveMSTeamsInboundMedia } from "./inbound-media.js"; export function createMSTeamsMessageHandler(deps: MSTeamsMessageHandlerDeps) { const { diff --git a/extensions/msteams/src/monitor.ts b/extensions/msteams/src/monitor.ts index ba9c55b16bb..df93c081d31 100644 --- a/extensions/msteams/src/monitor.ts +++ b/extensions/msteams/src/monitor.ts @@ -6,18 +6,18 @@ import { type RuntimeEnv, } from "openclaw/plugin-sdk"; import type { MSTeamsConversationStore } from "./conversation-store.js"; +import type { MSTeamsAdapter } from "./messenger.js"; import { createMSTeamsConversationStoreFs } from "./conversation-store-fs.js"; import { formatUnknownError } from "./errors.js"; -import type { MSTeamsAdapter } from "./messenger.js"; import { registerMSTeamsHandlers } from "./monitor-handler.js"; import { createMSTeamsPollStoreFs, type MSTeamsPollStore } from "./polls.js"; import { resolveMSTeamsChannelAllowlist, resolveMSTeamsUserAllowlist, } from "./resolve-allowlist.js"; +import { getMSTeamsRuntime } from "./runtime.js"; import { createMSTeamsAdapter, loadMSTeamsSdkWithAuth } from "./sdk.js"; import { resolveMSTeamsCredentials } from "./token.js"; -import { getMSTeamsRuntime } from "./runtime.js"; export type MonitorMSTeamsOpts = { cfg: OpenClawConfig; diff --git a/extensions/msteams/src/onboarding.ts b/extensions/msteams/src/onboarding.ts index eb379bda3a3..d1f055dcfe8 100644 --- a/extensions/msteams/src/onboarding.ts +++ b/extensions/msteams/src/onboarding.ts @@ -11,13 +11,12 @@ import { formatDocsLink, promptChannelAccessConfig, } from "openclaw/plugin-sdk"; - -import { resolveMSTeamsCredentials } from "./token.js"; import { parseMSTeamsTeamEntry, resolveMSTeamsChannelAllowlist, resolveMSTeamsUserAllowlist, } from "./resolve-allowlist.js"; +import { resolveMSTeamsCredentials } from "./token.js"; const channel = "msteams" as const; diff --git a/extensions/msteams/src/outbound.ts b/extensions/msteams/src/outbound.ts index d10f9f76e7c..48f5d0c61af 100644 --- a/extensions/msteams/src/outbound.ts +++ b/extensions/msteams/src/outbound.ts @@ -1,5 +1,4 @@ import type { ChannelOutboundAdapter } from "openclaw/plugin-sdk"; - import { createMSTeamsPollStoreFs } from "./polls.js"; import { getMSTeamsRuntime } from "./runtime.js"; import { sendMessageMSTeams, sendPollMSTeams } from "./send.js"; diff --git a/extensions/msteams/src/policy.test.ts b/extensions/msteams/src/policy.test.ts index 0c00b6f5cbb..90ee1f3cd24 100644 --- a/extensions/msteams/src/policy.test.ts +++ b/extensions/msteams/src/policy.test.ts @@ -1,6 +1,5 @@ -import { describe, expect, it } from "vitest"; - import type { MSTeamsConfig } from "openclaw/plugin-sdk"; +import { describe, expect, it } from "vitest"; import { isMSTeamsGroupAllowed, resolveMSTeamsReplyPolicy, diff --git a/extensions/msteams/src/polls-store.test.ts b/extensions/msteams/src/polls-store.test.ts index eca022c9f64..ff70f13d4ab 100644 --- a/extensions/msteams/src/polls-store.test.ts +++ b/extensions/msteams/src/polls-store.test.ts @@ -1,11 +1,9 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - -import { createMSTeamsPollStoreFs } from "./polls.js"; import { createMSTeamsPollStoreMemory } from "./polls-store-memory.js"; +import { createMSTeamsPollStoreFs } from "./polls.js"; const createFsStore = async () => { const stateDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "openclaw-msteams-polls-")); diff --git a/extensions/msteams/src/polls.test.ts b/extensions/msteams/src/polls.test.ts index a3b84cd847a..0508a25bb06 100644 --- a/extensions/msteams/src/polls.test.ts +++ b/extensions/msteams/src/polls.test.ts @@ -1,10 +1,8 @@ +import type { PluginRuntime } from "openclaw/plugin-sdk"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import { beforeEach, describe, expect, it } from "vitest"; - -import type { PluginRuntime } from "openclaw/plugin-sdk"; import { buildMSTeamsPollCard, createMSTeamsPollStoreFs, extractMSTeamsPollVote } from "./polls.js"; import { setMSTeamsRuntime } from "./runtime.js"; diff --git a/extensions/msteams/src/polls.ts b/extensions/msteams/src/polls.ts index 2159b4fcce2..f538c2091fb 100644 --- a/extensions/msteams/src/polls.ts +++ b/extensions/msteams/src/polls.ts @@ -1,5 +1,4 @@ import crypto from "node:crypto"; - import { resolveMSTeamsStorePath } from "./storage.js"; import { readJsonFile, withFileLock, writeJsonFile } from "./store-fs.js"; diff --git a/extensions/msteams/src/probe.test.ts b/extensions/msteams/src/probe.test.ts index 59fae64e070..b9c18019ac5 100644 --- a/extensions/msteams/src/probe.test.ts +++ b/extensions/msteams/src/probe.test.ts @@ -1,6 +1,5 @@ -import { describe, expect, it, vi } from "vitest"; - import type { MSTeamsConfig } from "openclaw/plugin-sdk"; +import { describe, expect, it, vi } from "vitest"; const hostMockState = vi.hoisted(() => ({ tokenError: null as Error | null, diff --git a/extensions/msteams/src/reply-dispatcher.ts b/extensions/msteams/src/reply-dispatcher.ts index 01b657ae99b..517f8494125 100644 --- a/extensions/msteams/src/reply-dispatcher.ts +++ b/extensions/msteams/src/reply-dispatcher.ts @@ -9,6 +9,8 @@ import { } from "openclaw/plugin-sdk"; import type { MSTeamsAccessTokenProvider } from "./attachments/types.js"; import type { StoredConversationReference } from "./conversation-store.js"; +import type { MSTeamsMonitorLogger } from "./monitor-types.js"; +import type { MSTeamsTurnContext } from "./sdk-types.js"; import { classifyMSTeamsSendError, formatMSTeamsSendErrorHint, @@ -19,8 +21,6 @@ import { renderReplyPayloadsToMessages, sendMSTeamsMessages, } from "./messenger.js"; -import type { MSTeamsMonitorLogger } from "./monitor-types.js"; -import type { MSTeamsTurnContext } from "./sdk-types.js"; import { getMSTeamsRuntime } from "./runtime.js"; export function createMSTeamsReplyDispatcher(params: { diff --git a/extensions/msteams/src/send-context.ts b/extensions/msteams/src/send-context.ts index b718eb81286..deefe21c0b7 100644 --- a/extensions/msteams/src/send-context.ts +++ b/extensions/msteams/src/send-context.ts @@ -8,8 +8,8 @@ import type { MSTeamsConversationStore, StoredConversationReference, } from "./conversation-store.js"; -import { createMSTeamsConversationStoreFs } from "./conversation-store-fs.js"; import type { MSTeamsAdapter } from "./messenger.js"; +import { createMSTeamsConversationStoreFs } from "./conversation-store-fs.js"; import { getMSTeamsRuntime } from "./runtime.js"; import { createMSTeamsAdapter, loadMSTeamsSdkWithAuth } from "./sdk.js"; import { resolveMSTeamsCredentials } from "./token.js"; diff --git a/extensions/msteams/src/send.ts b/extensions/msteams/src/send.ts index 04836708c0b..43725ee15dc 100644 --- a/extensions/msteams/src/send.ts +++ b/extensions/msteams/src/send.ts @@ -1,5 +1,5 @@ -import { loadWebMedia, resolveChannelMediaMaxBytes } from "openclaw/plugin-sdk"; import type { OpenClawConfig } from "openclaw/plugin-sdk"; +import { loadWebMedia, resolveChannelMediaMaxBytes } from "openclaw/plugin-sdk"; import { createMSTeamsConversationStoreFs } from "./conversation-store-fs.js"; import { classifyMSTeamsSendError, diff --git a/extensions/msteams/src/sent-message-cache.test.ts b/extensions/msteams/src/sent-message-cache.test.ts index f6178253860..6892c0e1762 100644 --- a/extensions/msteams/src/sent-message-cache.test.ts +++ b/extensions/msteams/src/sent-message-cache.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { clearMSTeamsSentMessageCache, recordMSTeamsSentMessage, diff --git a/extensions/msteams/src/storage.ts b/extensions/msteams/src/storage.ts index 94ccbf900a9..3ae04de0f69 100644 --- a/extensions/msteams/src/storage.ts +++ b/extensions/msteams/src/storage.ts @@ -1,5 +1,4 @@ import path from "node:path"; - import { getMSTeamsRuntime } from "./runtime.js"; export type MSTeamsStorePathOptions = { diff --git a/extensions/msteams/src/store-fs.ts b/extensions/msteams/src/store-fs.ts index 08d53f355ba..fdeb4c663cb 100644 --- a/extensions/msteams/src/store-fs.ts +++ b/extensions/msteams/src/store-fs.ts @@ -1,7 +1,6 @@ import crypto from "node:crypto"; import fs from "node:fs"; import path from "node:path"; - import lockfile from "proper-lockfile"; const STORE_LOCK_OPTIONS = { diff --git a/extensions/nextcloud-talk/index.ts b/extensions/nextcloud-talk/index.ts index 54b371fe56d..1dc9c2d646c 100644 --- a/extensions/nextcloud-talk/index.ts +++ b/extensions/nextcloud-talk/index.ts @@ -1,6 +1,5 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { nextcloudTalkPlugin } from "./src/channel.js"; import { setNextcloudTalkRuntime } from "./src/runtime.js"; diff --git a/extensions/nextcloud-talk/src/accounts.ts b/extensions/nextcloud-talk/src/accounts.ts index 975d8212d2c..c2869944633 100644 --- a/extensions/nextcloud-talk/src/accounts.ts +++ b/extensions/nextcloud-talk/src/accounts.ts @@ -1,7 +1,5 @@ import { readFileSync } from "node:fs"; - import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk"; - import type { CoreConfig, NextcloudTalkAccountConfig } from "./types.js"; const TRUTHY_ENV = new Set(["true", "1", "yes", "on"]); diff --git a/extensions/nextcloud-talk/src/channel.ts b/extensions/nextcloud-talk/src/channel.ts index 10f6636cadf..3355ec116f9 100644 --- a/extensions/nextcloud-talk/src/channel.ts +++ b/extensions/nextcloud-talk/src/channel.ts @@ -10,7 +10,7 @@ import { type OpenClawConfig, type ChannelSetupInput, } from "openclaw/plugin-sdk"; - +import type { CoreConfig } from "./types.js"; import { listNextcloudTalkAccountIds, resolveDefaultNextcloudTalkAccountId, @@ -24,10 +24,9 @@ import { normalizeNextcloudTalkMessagingTarget, } from "./normalize.js"; import { nextcloudTalkOnboardingAdapter } from "./onboarding.js"; +import { resolveNextcloudTalkGroupToolPolicy } from "./policy.js"; import { getNextcloudTalkRuntime } from "./runtime.js"; import { sendMessageNextcloudTalk } from "./send.js"; -import type { CoreConfig } from "./types.js"; -import { resolveNextcloudTalkGroupToolPolicy } from "./policy.js"; const meta = { id: "nextcloud-talk", diff --git a/extensions/nextcloud-talk/src/inbound.ts b/extensions/nextcloud-talk/src/inbound.ts index 7fcadddab3b..a7fe45b9f43 100644 --- a/extensions/nextcloud-talk/src/inbound.ts +++ b/extensions/nextcloud-talk/src/inbound.ts @@ -4,8 +4,8 @@ import { type OpenClawConfig, type RuntimeEnv, } from "openclaw/plugin-sdk"; - import type { ResolvedNextcloudTalkAccount } from "./accounts.js"; +import type { CoreConfig, NextcloudTalkInboundMessage } from "./types.js"; import { normalizeNextcloudTalkAllowlist, resolveNextcloudTalkAllowlistMatch, @@ -15,9 +15,8 @@ import { resolveNextcloudTalkRoomMatch, } from "./policy.js"; import { resolveNextcloudTalkRoomKind } from "./room-info.js"; -import { sendMessageNextcloudTalk } from "./send.js"; import { getNextcloudTalkRuntime } from "./runtime.js"; -import type { CoreConfig, NextcloudTalkInboundMessage } from "./types.js"; +import { sendMessageNextcloudTalk } from "./send.js"; const CHANNEL_ID = "nextcloud-talk" as const; diff --git a/extensions/nextcloud-talk/src/monitor.ts b/extensions/nextcloud-talk/src/monitor.ts index 6fa4cbe906c..0981fa4cf4a 100644 --- a/extensions/nextcloud-talk/src/monitor.ts +++ b/extensions/nextcloud-talk/src/monitor.ts @@ -1,17 +1,15 @@ -import { createServer, type IncomingMessage, type Server, type ServerResponse } from "node:http"; - import type { RuntimeEnv } from "openclaw/plugin-sdk"; - -import { resolveNextcloudTalkAccount } from "./accounts.js"; -import { handleNextcloudTalkInbound } from "./inbound.js"; -import { getNextcloudTalkRuntime } from "./runtime.js"; -import { extractNextcloudTalkHeaders, verifyNextcloudTalkSignature } from "./signature.js"; +import { createServer, type IncomingMessage, type Server, type ServerResponse } from "node:http"; import type { CoreConfig, NextcloudTalkInboundMessage, NextcloudTalkWebhookPayload, NextcloudTalkWebhookServerOptions, } from "./types.js"; +import { resolveNextcloudTalkAccount } from "./accounts.js"; +import { handleNextcloudTalkInbound } from "./inbound.js"; +import { getNextcloudTalkRuntime } from "./runtime.js"; +import { extractNextcloudTalkHeaders, verifyNextcloudTalkSignature } from "./signature.js"; const DEFAULT_WEBHOOK_PORT = 8788; const DEFAULT_WEBHOOK_HOST = "0.0.0.0"; diff --git a/extensions/nextcloud-talk/src/onboarding.ts b/extensions/nextcloud-talk/src/onboarding.ts index 751949211cc..ecfebaa7dd7 100644 --- a/extensions/nextcloud-talk/src/onboarding.ts +++ b/extensions/nextcloud-talk/src/onboarding.ts @@ -8,13 +8,12 @@ import { type ChannelOnboardingDmPolicy, type WizardPrompter, } from "openclaw/plugin-sdk"; - +import type { CoreConfig, DmPolicy } from "./types.js"; import { listNextcloudTalkAccountIds, resolveDefaultNextcloudTalkAccountId, resolveNextcloudTalkAccount, } from "./accounts.js"; -import type { CoreConfig, DmPolicy } from "./types.js"; const channel = "nextcloud-talk" as const; diff --git a/extensions/nextcloud-talk/src/policy.ts b/extensions/nextcloud-talk/src/policy.ts index a38d307fc83..5d9b8cffdc7 100644 --- a/extensions/nextcloud-talk/src/policy.ts +++ b/extensions/nextcloud-talk/src/policy.ts @@ -11,7 +11,6 @@ import { resolveMentionGatingWithBypass, resolveNestedAllowlistDecision, } from "openclaw/plugin-sdk"; - import type { NextcloudTalkRoomConfig } from "./types.js"; function normalizeAllowEntry(raw: string): string { diff --git a/extensions/nextcloud-talk/src/room-info.ts b/extensions/nextcloud-talk/src/room-info.ts index 191c423d18c..b2ff6a1763c 100644 --- a/extensions/nextcloud-talk/src/room-info.ts +++ b/extensions/nextcloud-talk/src/room-info.ts @@ -1,7 +1,5 @@ -import { readFileSync } from "node:fs"; - import type { RuntimeEnv } from "openclaw/plugin-sdk"; - +import { readFileSync } from "node:fs"; import type { ResolvedNextcloudTalkAccount } from "./accounts.js"; const ROOM_CACHE_TTL_MS = 5 * 60 * 1000; diff --git a/extensions/nextcloud-talk/src/send.ts b/extensions/nextcloud-talk/src/send.ts index 0bece021c4c..2ac71f461c7 100644 --- a/extensions/nextcloud-talk/src/send.ts +++ b/extensions/nextcloud-talk/src/send.ts @@ -1,7 +1,7 @@ +import type { CoreConfig, NextcloudTalkSendResult } from "./types.js"; import { resolveNextcloudTalkAccount } from "./accounts.js"; import { getNextcloudTalkRuntime } from "./runtime.js"; import { generateNextcloudTalkSignature } from "./signature.js"; -import type { CoreConfig, NextcloudTalkSendResult } from "./types.js"; type NextcloudTalkSendOpts = { baseUrl?: string; diff --git a/extensions/nextcloud-talk/src/signature.ts b/extensions/nextcloud-talk/src/signature.ts index ad5351d36a4..c7d957806cc 100644 --- a/extensions/nextcloud-talk/src/signature.ts +++ b/extensions/nextcloud-talk/src/signature.ts @@ -1,5 +1,4 @@ import { createHmac, randomBytes } from "node:crypto"; - import type { NextcloudTalkWebhookHeaders } from "./types.js"; const SIGNATURE_HEADER = "x-nextcloud-talk-signature"; diff --git a/extensions/nostr/index.ts b/extensions/nostr/index.ts index c762ce3c127..881af8c2251 100644 --- a/extensions/nostr/index.ts +++ b/extensions/nostr/index.ts @@ -1,11 +1,10 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - -import { nostrPlugin } from "./src/channel.js"; -import { setNostrRuntime, getNostrRuntime } from "./src/runtime.js"; -import { createNostrProfileHttpHandler } from "./src/nostr-profile-http.js"; -import { resolveNostrAccount } from "./src/types.js"; import type { NostrProfile } from "./src/config-schema.js"; +import { nostrPlugin } from "./src/channel.js"; +import { createNostrProfileHttpHandler } from "./src/nostr-profile-http.js"; +import { setNostrRuntime, getNostrRuntime } from "./src/runtime.js"; +import { resolveNostrAccount } from "./src/types.js"; const plugin = { id: "nostr", diff --git a/extensions/nostr/src/channel.ts b/extensions/nostr/src/channel.ts index 3fa07064e9d..c8c71c99ddb 100644 --- a/extensions/nostr/src/channel.ts +++ b/extensions/nostr/src/channel.ts @@ -4,8 +4,11 @@ import { formatPairingApproveHint, type ChannelPlugin, } from "openclaw/plugin-sdk"; - +import type { NostrProfile } from "./config-schema.js"; +import type { MetricEvent, MetricsSnapshot } from "./metrics.js"; +import type { ProfilePublishResult } from "./nostr-profile.js"; import { NostrConfigSchema } from "./config-schema.js"; +import { normalizePubkey, startNostrBus, type NostrBusHandle } from "./nostr-bus.js"; import { getNostrRuntime } from "./runtime.js"; import { listNostrAccountIds, @@ -13,10 +16,6 @@ import { resolveNostrAccount, type ResolvedNostrAccount, } from "./types.js"; -import { normalizePubkey, startNostrBus, type NostrBusHandle } from "./nostr-bus.js"; -import type { MetricEvent, MetricsSnapshot } from "./metrics.js"; -import type { NostrProfile } from "./config-schema.js"; -import type { ProfilePublishResult } from "./nostr-profile.js"; // Store active bus handles per account const activeBuses = new Map(); diff --git a/extensions/nostr/src/nostr-bus.fuzz.test.ts b/extensions/nostr/src/nostr-bus.fuzz.test.ts index 2f1d67611a6..811cf7df5cb 100644 --- a/extensions/nostr/src/nostr-bus.fuzz.test.ts +++ b/extensions/nostr/src/nostr-bus.fuzz.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from "vitest"; +import { createMetrics, type MetricName } from "./metrics.js"; import { validatePrivateKey, isValidPubkey, normalizePubkey } from "./nostr-bus.js"; import { createSeenTracker } from "./seen-tracker.js"; -import { createMetrics, type MetricName } from "./metrics.js"; // ============================================================================ // Fuzz Tests for validatePrivateKey diff --git a/extensions/nostr/src/nostr-bus.integration.test.ts b/extensions/nostr/src/nostr-bus.integration.test.ts index b145b3ef379..6082351dd92 100644 --- a/extensions/nostr/src/nostr-bus.integration.test.ts +++ b/extensions/nostr/src/nostr-bus.integration.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it, vi } from "vitest"; -import { createSeenTracker } from "./seen-tracker.js"; import { createMetrics, createNoopMetrics, type MetricEvent } from "./metrics.js"; +import { createSeenTracker } from "./seen-tracker.js"; // ============================================================================ // Seen Tracker Integration Tests diff --git a/extensions/nostr/src/nostr-bus.ts b/extensions/nostr/src/nostr-bus.ts index eb4abfccbf9..bc19348fa8d 100644 --- a/extensions/nostr/src/nostr-bus.ts +++ b/extensions/nostr/src/nostr-bus.ts @@ -7,17 +7,7 @@ import { type Event, } from "nostr-tools"; import { decrypt, encrypt } from "nostr-tools/nip04"; - -import { - readNostrBusState, - writeNostrBusState, - computeSinceTimestamp, - readNostrProfileState, - writeNostrProfileState, -} from "./nostr-state-store.js"; -import { publishProfile as publishProfileFn, type ProfilePublishResult } from "./nostr-profile.js"; import type { NostrProfile } from "./config-schema.js"; -import { createSeenTracker, type SeenTracker } from "./seen-tracker.js"; import { createMetrics, createNoopMetrics, @@ -25,6 +15,15 @@ import { type MetricsSnapshot, type MetricEvent, } from "./metrics.js"; +import { publishProfile as publishProfileFn, type ProfilePublishResult } from "./nostr-profile.js"; +import { + readNostrBusState, + writeNostrBusState, + computeSinceTimestamp, + readNostrProfileState, + writeNostrProfileState, +} from "./nostr-state-store.js"; +import { createSeenTracker, type SeenTracker } from "./seen-tracker.js"; export const DEFAULT_RELAYS = ["wss://relay.damus.io", "wss://nos.lol"]; diff --git a/extensions/nostr/src/nostr-profile-http.test.ts b/extensions/nostr/src/nostr-profile-http.test.ts index a328960199a..4ccee61ef8e 100644 --- a/extensions/nostr/src/nostr-profile-http.test.ts +++ b/extensions/nostr/src/nostr-profile-http.test.ts @@ -2,10 +2,9 @@ * Tests for Nostr Profile HTTP Handler */ -import { describe, it, expect, vi, beforeEach } from "vitest"; import { IncomingMessage, ServerResponse } from "node:http"; import { Socket } from "node:net"; - +import { describe, it, expect, vi, beforeEach } from "vitest"; import { createNostrProfileHttpHandler, type NostrProfileHttpContext, diff --git a/extensions/nostr/src/nostr-profile-http.ts b/extensions/nostr/src/nostr-profile-http.ts index 6a8efb0c82b..499c4c8a904 100644 --- a/extensions/nostr/src/nostr-profile-http.ts +++ b/extensions/nostr/src/nostr-profile-http.ts @@ -9,9 +9,8 @@ import type { IncomingMessage, ServerResponse } from "node:http"; import { z } from "zod"; - -import { NostrProfileSchema, type NostrProfile } from "./config-schema.js"; import { publishNostrProfile, getNostrProfileState } from "./channel.js"; +import { NostrProfileSchema, type NostrProfile } from "./config-schema.js"; import { importProfileFromRelays, mergeProfiles } from "./nostr-profile-import.js"; // ============================================================================ diff --git a/extensions/nostr/src/nostr-profile-import.test.ts b/extensions/nostr/src/nostr-profile-import.test.ts index 6488195e239..57bee0e7fd8 100644 --- a/extensions/nostr/src/nostr-profile-import.test.ts +++ b/extensions/nostr/src/nostr-profile-import.test.ts @@ -3,9 +3,8 @@ */ import { describe, it, expect } from "vitest"; - -import { mergeProfiles } from "./nostr-profile-import.js"; import type { NostrProfile } from "./config-schema.js"; +import { mergeProfiles } from "./nostr-profile-import.js"; // Note: importProfileFromRelays requires real network calls or complex mocking // of nostr-tools SimplePool, so we focus on unit testing mergeProfiles diff --git a/extensions/nostr/src/nostr-profile-import.ts b/extensions/nostr/src/nostr-profile-import.ts index b839f825e60..e5a107c18c3 100644 --- a/extensions/nostr/src/nostr-profile-import.ts +++ b/extensions/nostr/src/nostr-profile-import.ts @@ -6,10 +6,9 @@ */ import { SimplePool, verifyEvent, type Event } from "nostr-tools"; - -import { contentToProfile, type ProfileContent } from "./nostr-profile.js"; import type { NostrProfile } from "./config-schema.js"; import { validateUrlSafety } from "./nostr-profile-http.js"; +import { contentToProfile, type ProfileContent } from "./nostr-profile.js"; // ============================================================================ // Types diff --git a/extensions/nostr/src/nostr-profile.fuzz.test.ts b/extensions/nostr/src/nostr-profile.fuzz.test.ts index e082830c438..1e67b66a456 100644 --- a/extensions/nostr/src/nostr-profile.fuzz.test.ts +++ b/extensions/nostr/src/nostr-profile.fuzz.test.ts @@ -1,11 +1,11 @@ import { describe, expect, it } from "vitest"; +import type { NostrProfile } from "./config-schema.js"; import { createProfileEvent, profileToContent, validateProfile, sanitizeProfileForDisplay, } from "./nostr-profile.js"; -import type { NostrProfile } from "./config-schema.js"; // Test private key const TEST_HEX_KEY = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; diff --git a/extensions/nostr/src/nostr-profile.test.ts b/extensions/nostr/src/nostr-profile.test.ts index 9b1001d913c..0d90efa754b 100644 --- a/extensions/nostr/src/nostr-profile.test.ts +++ b/extensions/nostr/src/nostr-profile.test.ts @@ -1,5 +1,6 @@ -import { describe, expect, it, vi, beforeEach } from "vitest"; import { verifyEvent, getPublicKey } from "nostr-tools"; +import { describe, expect, it, vi, beforeEach } from "vitest"; +import type { NostrProfile } from "./config-schema.js"; import { createProfileEvent, profileToContent, @@ -8,7 +9,6 @@ import { sanitizeProfileForDisplay, type ProfileContent, } from "./nostr-profile.js"; -import type { NostrProfile } from "./config-schema.js"; // Test private key (DO NOT use in production - this is a known test key) const TEST_HEX_KEY = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; diff --git a/extensions/nostr/src/nostr-state-store.test.ts b/extensions/nostr/src/nostr-state-store.test.ts index 7e8f3623f1d..a58802af7c0 100644 --- a/extensions/nostr/src/nostr-state-store.test.ts +++ b/extensions/nostr/src/nostr-state-store.test.ts @@ -1,10 +1,8 @@ +import type { PluginRuntime } from "openclaw/plugin-sdk"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; -import type { PluginRuntime } from "openclaw/plugin-sdk"; - import { readNostrBusState, writeNostrBusState, diff --git a/extensions/nostr/src/nostr-state-store.ts b/extensions/nostr/src/nostr-state-store.ts index 08a2235de52..0b07139765b 100644 --- a/extensions/nostr/src/nostr-state-store.ts +++ b/extensions/nostr/src/nostr-state-store.ts @@ -2,7 +2,6 @@ import crypto from "node:crypto"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { getNostrRuntime } from "./runtime.js"; const STORE_VERSION = 2; diff --git a/extensions/nostr/src/types.ts b/extensions/nostr/src/types.ts index f094294c583..84640b93430 100644 --- a/extensions/nostr/src/types.ts +++ b/extensions/nostr/src/types.ts @@ -1,7 +1,7 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk"; +import type { NostrProfile } from "./config-schema.js"; import { getPublicKeyFromPrivate } from "./nostr-bus.js"; import { DEFAULT_RELAYS } from "./nostr-bus.js"; -import type { NostrProfile } from "./config-schema.js"; export interface NostrAccountConfig { enabled?: boolean; diff --git a/extensions/qwen-portal-auth/index.ts b/extensions/qwen-portal-auth/index.ts index ddff6807e9b..37994fa4bde 100644 --- a/extensions/qwen-portal-auth/index.ts +++ b/extensions/qwen-portal-auth/index.ts @@ -1,5 +1,4 @@ import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { loginQwenPortalOAuth } from "./oauth.js"; const PROVIDER_ID = "qwen-portal"; diff --git a/extensions/signal/index.ts b/extensions/signal/index.ts index 00856fece03..e1069e466e2 100644 --- a/extensions/signal/index.ts +++ b/extensions/signal/index.ts @@ -1,6 +1,5 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { signalPlugin } from "./src/channel.js"; import { setSignalRuntime } from "./src/runtime.js"; diff --git a/extensions/signal/src/channel.ts b/extensions/signal/src/channel.ts index 99856ceedd3..3fba7bc6f26 100644 --- a/extensions/signal/src/channel.ts +++ b/extensions/signal/src/channel.ts @@ -22,7 +22,6 @@ import { type ChannelPlugin, type ResolvedSignalAccount, } from "openclaw/plugin-sdk"; - import { getSignalRuntime } from "./runtime.js"; const signalMessageActions: ChannelMessageActionAdapter = { diff --git a/extensions/slack/index.ts b/extensions/slack/index.ts index 13b94eec1d0..6f5945616c7 100644 --- a/extensions/slack/index.ts +++ b/extensions/slack/index.ts @@ -1,6 +1,5 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { slackPlugin } from "./src/channel.js"; import { setSlackRuntime } from "./src/runtime.js"; diff --git a/extensions/slack/src/channel.ts b/extensions/slack/src/channel.ts index d71aef81b50..e55e43dcd27 100644 --- a/extensions/slack/src/channel.ts +++ b/extensions/slack/src/channel.ts @@ -30,7 +30,6 @@ import { type ChannelPlugin, type ResolvedSlackAccount, } from "openclaw/plugin-sdk"; - import { getSlackRuntime } from "./runtime.js"; const meta = getChatChannelMeta("slack"); diff --git a/extensions/telegram/index.ts b/extensions/telegram/index.ts index 2faf35fbf34..e96fe1585f8 100644 --- a/extensions/telegram/index.ts +++ b/extensions/telegram/index.ts @@ -1,6 +1,5 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { telegramPlugin } from "./src/channel.js"; import { setTelegramRuntime } from "./src/runtime.js"; diff --git a/extensions/telegram/src/channel.ts b/extensions/telegram/src/channel.ts index 0a923529c89..a375281e400 100644 --- a/extensions/telegram/src/channel.ts +++ b/extensions/telegram/src/channel.ts @@ -26,7 +26,6 @@ import { type OpenClawConfig, type ResolvedTelegramAccount, } from "openclaw/plugin-sdk"; - import { getTelegramRuntime } from "./runtime.js"; const meta = getChatChannelMeta("telegram"); diff --git a/extensions/tlon/index.ts b/extensions/tlon/index.ts index 8649825b54e..2a31956dd39 100644 --- a/extensions/tlon/index.ts +++ b/extensions/tlon/index.ts @@ -1,6 +1,5 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { tlonPlugin } from "./src/channel.js"; import { setTlonRuntime } from "./src/runtime.js"; diff --git a/extensions/tlon/src/channel.ts b/extensions/tlon/src/channel.ts index a170e62cf40..1eb07c79ebc 100644 --- a/extensions/tlon/src/channel.ts +++ b/extensions/tlon/src/channel.ts @@ -9,14 +9,13 @@ import { DEFAULT_ACCOUNT_ID, normalizeAccountId, } from "openclaw/plugin-sdk"; - -import { resolveTlonAccount, listTlonAccountIds } from "./types.js"; +import { tlonChannelConfigSchema } from "./config-schema.js"; +import { monitorTlonProvider } from "./monitor/index.js"; +import { tlonOnboardingAdapter } from "./onboarding.js"; import { formatTargetHint, normalizeShip, parseTlonTarget } from "./targets.js"; +import { resolveTlonAccount, listTlonAccountIds } from "./types.js"; import { ensureUrbitConnectPatched, Urbit } from "./urbit/http-api.js"; import { buildMediaText, sendDm, sendGroupMessage } from "./urbit/send.js"; -import { monitorTlonProvider } from "./monitor/index.js"; -import { tlonChannelConfigSchema } from "./config-schema.js"; -import { tlonOnboardingAdapter } from "./onboarding.js"; const TLON_CHANNEL_ID = "tlon" as const; diff --git a/extensions/tlon/src/config-schema.test.ts b/extensions/tlon/src/config-schema.test.ts index 6a5b52439d3..fa532331978 100644 --- a/extensions/tlon/src/config-schema.test.ts +++ b/extensions/tlon/src/config-schema.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { TlonAuthorizationSchema, TlonConfigSchema } from "./config-schema.js"; describe("Tlon config schema", () => { diff --git a/extensions/tlon/src/config-schema.ts b/extensions/tlon/src/config-schema.ts index 12839ecc1fb..831e7865748 100644 --- a/extensions/tlon/src/config-schema.ts +++ b/extensions/tlon/src/config-schema.ts @@ -1,5 +1,5 @@ -import { z } from "zod"; import { buildChannelConfigSchema } from "openclaw/plugin-sdk"; +import { z } from "zod"; const ShipSchema = z.string().min(1); const ChannelNestSchema = z.string().min(1); diff --git a/extensions/tlon/src/monitor/discovery.ts b/extensions/tlon/src/monitor/discovery.ts index 28bb74aafc6..906e6580d95 100644 --- a/extensions/tlon/src/monitor/discovery.ts +++ b/extensions/tlon/src/monitor/discovery.ts @@ -1,5 +1,4 @@ import type { RuntimeEnv } from "openclaw/plugin-sdk"; - import { formatChangesDate } from "./utils.js"; export async function fetchGroupChanges( diff --git a/extensions/tlon/src/monitor/history.ts b/extensions/tlon/src/monitor/history.ts index f9fc39962ae..3e26e5be819 100644 --- a/extensions/tlon/src/monitor/history.ts +++ b/extensions/tlon/src/monitor/history.ts @@ -1,5 +1,4 @@ import type { RuntimeEnv } from "openclaw/plugin-sdk"; - import { extractMessageText } from "./utils.js"; export type TlonHistoryEntry = { diff --git a/extensions/tlon/src/monitor/index.ts b/extensions/tlon/src/monitor/index.ts index 6b4af5a7c5a..03f28a1ff0c 100644 --- a/extensions/tlon/src/monitor/index.ts +++ b/extensions/tlon/src/monitor/index.ts @@ -1,13 +1,12 @@ -import { format } from "node:util"; - import type { RuntimeEnv, ReplyPayload, OpenClawConfig } from "openclaw/plugin-sdk"; - +import { format } from "node:util"; import { getTlonRuntime } from "../runtime.js"; -import { resolveTlonAccount } from "../types.js"; import { normalizeShip, parseChannelNest } from "../targets.js"; +import { resolveTlonAccount } from "../types.js"; import { authenticate } from "../urbit/auth.js"; -import { UrbitSSEClient } from "../urbit/sse-client.js"; import { sendDm, sendGroupMessage } from "../urbit/send.js"; +import { UrbitSSEClient } from "../urbit/sse-client.js"; +import { fetchAllChannels } from "./discovery.js"; import { cacheMessage, getChannelHistory } from "./history.js"; import { createProcessedMessageTracker } from "./processed-messages.js"; import { @@ -17,7 +16,6 @@ import { isDmAllowed, isSummarizationRequest, } from "./utils.js"; -import { fetchAllChannels } from "./discovery.js"; export type MonitorTlonOpts = { runtime?: RuntimeEnv; diff --git a/extensions/tlon/src/monitor/processed-messages.test.ts b/extensions/tlon/src/monitor/processed-messages.test.ts index 2dd99fff985..00855690445 100644 --- a/extensions/tlon/src/monitor/processed-messages.test.ts +++ b/extensions/tlon/src/monitor/processed-messages.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { createProcessedMessageTracker } from "./processed-messages.js"; describe("createProcessedMessageTracker", () => { diff --git a/extensions/tlon/src/onboarding.ts b/extensions/tlon/src/onboarding.ts index 22bfb450816..e15e5e59251 100644 --- a/extensions/tlon/src/onboarding.ts +++ b/extensions/tlon/src/onboarding.ts @@ -1,3 +1,4 @@ +import type { OpenClawConfig } from "openclaw/plugin-sdk"; import { formatDocsLink, promptAccountId, @@ -6,10 +7,8 @@ import { type ChannelOnboardingAdapter, type WizardPrompter, } from "openclaw/plugin-sdk"; - -import { listTlonAccountIds, resolveTlonAccount } from "./types.js"; import type { TlonResolvedAccount } from "./types.js"; -import type { OpenClawConfig } from "openclaw/plugin-sdk"; +import { listTlonAccountIds, resolveTlonAccount } from "./types.js"; const channel = "tlon" as const; diff --git a/extensions/tlon/src/urbit/sse-client.test.ts b/extensions/tlon/src/urbit/sse-client.test.ts index 9b67f6bfb30..f194aafc2fa 100644 --- a/extensions/tlon/src/urbit/sse-client.test.ts +++ b/extensions/tlon/src/urbit/sse-client.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import { UrbitSSEClient } from "./sse-client.js"; const mockFetch = vi.fn(); diff --git a/extensions/twitch/index.ts b/extensions/twitch/index.ts index 7abca0afb81..66b2ed4615e 100644 --- a/extensions/twitch/index.ts +++ b/extensions/twitch/index.ts @@ -1,6 +1,5 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { twitchPlugin } from "./src/plugin.js"; import { setTwitchRuntime } from "./src/runtime.js"; diff --git a/extensions/twitch/src/access-control.test.ts b/extensions/twitch/src/access-control.test.ts index 1200f72dbc3..94c7e5533c2 100644 --- a/extensions/twitch/src/access-control.test.ts +++ b/extensions/twitch/src/access-control.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "vitest"; -import { checkTwitchAccessControl, extractMentions } from "./access-control.js"; import type { TwitchAccountConfig, TwitchChatMessage } from "./types.js"; +import { checkTwitchAccessControl, extractMentions } from "./access-control.js"; describe("checkTwitchAccessControl", () => { const mockAccount: TwitchAccountConfig = { diff --git a/extensions/twitch/src/actions.ts b/extensions/twitch/src/actions.ts index d6029b7f6bd..faeb3291772 100644 --- a/extensions/twitch/src/actions.ts +++ b/extensions/twitch/src/actions.ts @@ -4,9 +4,9 @@ * Handles tool-based actions for Twitch, such as sending messages. */ +import type { ChannelMessageActionAdapter, ChannelMessageActionContext } from "./types.js"; import { DEFAULT_ACCOUNT_ID, getAccountConfig } from "./config.js"; import { twitchOutbound } from "./outbound.js"; -import type { ChannelMessageActionAdapter, ChannelMessageActionContext } from "./types.js"; /** * Create a tool result with error content. diff --git a/extensions/twitch/src/client-manager-registry.ts b/extensions/twitch/src/client-manager-registry.ts index 1b7ae23f21f..4daceb47949 100644 --- a/extensions/twitch/src/client-manager-registry.ts +++ b/extensions/twitch/src/client-manager-registry.ts @@ -5,8 +5,8 @@ * ensuring proper cleanup when accounts are stopped or reconfigured. */ -import { TwitchClientManager } from "./twitch-client.js"; import type { ChannelLogSink } from "./types.js"; +import { TwitchClientManager } from "./twitch-client.js"; /** * Registry entry tracking a client manager and its associated account. diff --git a/extensions/twitch/src/config.test.ts b/extensions/twitch/src/config.test.ts index cdef1c4c83d..4ead8984b46 100644 --- a/extensions/twitch/src/config.test.ts +++ b/extensions/twitch/src/config.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { getAccountConfig } from "./config.js"; describe("getAccountConfig", () => { diff --git a/extensions/twitch/src/monitor.ts b/extensions/twitch/src/monitor.ts index c78b6f9e6d9..c47d7a52b3a 100644 --- a/extensions/twitch/src/monitor.ts +++ b/extensions/twitch/src/monitor.ts @@ -8,8 +8,8 @@ import type { ReplyPayload, OpenClawConfig } from "openclaw/plugin-sdk"; import type { TwitchAccountConfig, TwitchChatMessage } from "./types.js"; import { checkTwitchAccessControl } from "./access-control.js"; -import { getTwitchRuntime } from "./runtime.js"; import { getOrCreateClientManager } from "./client-manager-registry.js"; +import { getTwitchRuntime } from "./runtime.js"; import { stripMarkdownForTwitch } from "./utils/markdown.js"; export type TwitchRuntimeEnv = { diff --git a/extensions/twitch/src/onboarding.test.ts b/extensions/twitch/src/onboarding.test.ts index ce34816e7be..20b6920b515 100644 --- a/extensions/twitch/src/onboarding.test.ts +++ b/extensions/twitch/src/onboarding.test.ts @@ -11,8 +11,8 @@ * - setTwitchAccount config updates */ -import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { WizardPrompter } from "openclaw/plugin-sdk"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { TwitchAccountConfig } from "./types.js"; // Mock the helpers we're testing diff --git a/extensions/twitch/src/onboarding.ts b/extensions/twitch/src/onboarding.ts index 2768afd44b8..a3fe02ef109 100644 --- a/extensions/twitch/src/onboarding.ts +++ b/extensions/twitch/src/onboarding.ts @@ -2,6 +2,7 @@ * Twitch onboarding adapter for CLI setup wizard. */ +import type { OpenClawConfig } from "openclaw/plugin-sdk"; import { formatDocsLink, promptChannelAccessConfig, @@ -9,10 +10,9 @@ import { type ChannelOnboardingDmPolicy, type WizardPrompter, } from "openclaw/plugin-sdk"; +import type { TwitchAccountConfig, TwitchRole } from "./types.js"; import { DEFAULT_ACCOUNT_ID, getAccountConfig } from "./config.js"; import { isAccountConfigured } from "./utils/twitch.js"; -import type { TwitchAccountConfig, TwitchRole } from "./types.js"; -import type { OpenClawConfig } from "openclaw/plugin-sdk"; const channel = "twitch" as const; diff --git a/extensions/twitch/src/outbound.test.ts b/extensions/twitch/src/outbound.test.ts index 6190e8bcf0c..10705ef135e 100644 --- a/extensions/twitch/src/outbound.test.ts +++ b/extensions/twitch/src/outbound.test.ts @@ -9,9 +9,9 @@ * - Abort signal handling */ +import type { OpenClawConfig } from "openclaw/plugin-sdk"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { twitchOutbound } from "./outbound.js"; -import type { OpenClawConfig } from "openclaw/plugin-sdk"; // Mock dependencies vi.mock("./config.js", () => ({ diff --git a/extensions/twitch/src/outbound.ts b/extensions/twitch/src/outbound.ts index 76700f42fdf..c9dd4324ef2 100644 --- a/extensions/twitch/src/outbound.ts +++ b/extensions/twitch/src/outbound.ts @@ -5,13 +5,13 @@ * Supports text and media (URL) sending with markdown stripping and chunking. */ -import { DEFAULT_ACCOUNT_ID, getAccountConfig } from "./config.js"; -import { sendMessageTwitchInternal } from "./send.js"; import type { ChannelOutboundAdapter, ChannelOutboundContext, OutboundDeliveryResult, } from "./types.js"; +import { DEFAULT_ACCOUNT_ID, getAccountConfig } from "./config.js"; +import { sendMessageTwitchInternal } from "./send.js"; import { chunkTextForTwitch } from "./utils/markdown.js"; import { missingTargetError, normalizeTwitchChannel } from "./utils/twitch.js"; diff --git a/extensions/twitch/src/plugin.test.ts b/extensions/twitch/src/plugin.test.ts index 1cd1a86dc21..1e76d2e620c 100644 --- a/extensions/twitch/src/plugin.test.ts +++ b/extensions/twitch/src/plugin.test.ts @@ -1,5 +1,5 @@ -import { describe, expect, it } from "vitest"; import type { OpenClawConfig } from "openclaw/plugin-sdk"; +import { describe, expect, it } from "vitest"; import { twitchPlugin } from "./plugin.js"; describe("twitchPlugin.status.buildAccountSnapshot", () => { diff --git a/extensions/twitch/src/plugin.ts b/extensions/twitch/src/plugin.ts index 800994c62b8..b47d286280d 100644 --- a/extensions/twitch/src/plugin.ts +++ b/extensions/twitch/src/plugin.ts @@ -7,17 +7,6 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk"; import { buildChannelConfigSchema } from "openclaw/plugin-sdk"; -import { twitchMessageActions } from "./actions.js"; -import { TwitchConfigSchema } from "./config-schema.js"; -import { DEFAULT_ACCOUNT_ID, getAccountConfig, listAccountIds } from "./config.js"; -import { twitchOnboardingAdapter } from "./onboarding.js"; -import { twitchOutbound } from "./outbound.js"; -import { probeTwitch } from "./probe.js"; -import { resolveTwitchTargets } from "./resolver.js"; -import { collectTwitchStatusIssues } from "./status.js"; -import { removeClientManager } from "./client-manager-registry.js"; -import { resolveTwitchToken } from "./token.js"; -import { isAccountConfigured } from "./utils/twitch.js"; import type { ChannelAccountSnapshot, ChannelCapabilities, @@ -28,6 +17,17 @@ import type { ChannelResolveResult, TwitchAccountConfig, } from "./types.js"; +import { twitchMessageActions } from "./actions.js"; +import { removeClientManager } from "./client-manager-registry.js"; +import { TwitchConfigSchema } from "./config-schema.js"; +import { DEFAULT_ACCOUNT_ID, getAccountConfig, listAccountIds } from "./config.js"; +import { twitchOnboardingAdapter } from "./onboarding.js"; +import { twitchOutbound } from "./outbound.js"; +import { probeTwitch } from "./probe.js"; +import { resolveTwitchTargets } from "./resolver.js"; +import { collectTwitchStatusIssues } from "./status.js"; +import { resolveTwitchToken } from "./token.js"; +import { isAccountConfigured } from "./utils/twitch.js"; /** * Twitch channel plugin. diff --git a/extensions/twitch/src/probe.test.ts b/extensions/twitch/src/probe.test.ts index 5972cdaf0a6..3a54fb1698b 100644 --- a/extensions/twitch/src/probe.test.ts +++ b/extensions/twitch/src/probe.test.ts @@ -1,6 +1,6 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; -import { probeTwitch } from "./probe.js"; import type { TwitchAccountConfig } from "./types.js"; +import { probeTwitch } from "./probe.js"; // Mock Twurple modules - Vitest v4 compatible mocking const mockUnbind = vi.fn(); diff --git a/extensions/twitch/src/send.test.ts b/extensions/twitch/src/send.test.ts index 4747625ac17..8afef78202b 100644 --- a/extensions/twitch/src/send.test.ts +++ b/extensions/twitch/src/send.test.ts @@ -10,9 +10,9 @@ * - Registry integration */ +import type { OpenClawConfig } from "openclaw/plugin-sdk"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { sendMessageTwitchInternal } from "./send.js"; -import type { OpenClawConfig } from "openclaw/plugin-sdk"; // Mock dependencies vi.mock("./config.js", () => ({ diff --git a/extensions/twitch/src/send.ts b/extensions/twitch/src/send.ts index 6bae3526f2e..d8a9cc3b0c9 100644 --- a/extensions/twitch/src/send.ts +++ b/extensions/twitch/src/send.ts @@ -5,9 +5,9 @@ * They support dependency injection via the `deps` parameter for testability. */ -import { DEFAULT_ACCOUNT_ID, getAccountConfig } from "./config.js"; -import { getClientManager as getRegistryClientManager } from "./client-manager-registry.js"; import type { OpenClawConfig } from "openclaw/plugin-sdk"; +import { getClientManager as getRegistryClientManager } from "./client-manager-registry.js"; +import { DEFAULT_ACCOUNT_ID, getAccountConfig } from "./config.js"; import { resolveTwitchToken } from "./token.js"; import { stripMarkdownForTwitch } from "./utils/markdown.js"; import { generateMessageId, isAccountConfigured, normalizeTwitchChannel } from "./utils/twitch.js"; diff --git a/extensions/twitch/src/status.test.ts b/extensions/twitch/src/status.test.ts index 8f7cd55abbf..6c841f6ec16 100644 --- a/extensions/twitch/src/status.test.ts +++ b/extensions/twitch/src/status.test.ts @@ -11,8 +11,8 @@ */ import { describe, expect, it } from "vitest"; -import { collectTwitchStatusIssues } from "./status.js"; import type { ChannelAccountSnapshot } from "./types.js"; +import { collectTwitchStatusIssues } from "./status.js"; describe("status", () => { describe("collectTwitchStatusIssues", () => { diff --git a/extensions/twitch/src/status.ts b/extensions/twitch/src/status.ts index 827fec79b21..fdc560950dd 100644 --- a/extensions/twitch/src/status.ts +++ b/extensions/twitch/src/status.ts @@ -4,8 +4,8 @@ * Detects and reports configuration issues for Twitch accounts. */ -import { getAccountConfig } from "./config.js"; import type { ChannelAccountSnapshot, ChannelStatusIssue } from "./types.js"; +import { getAccountConfig } from "./config.js"; import { resolveTwitchToken } from "./token.js"; import { isAccountConfigured } from "./utils/twitch.js"; diff --git a/extensions/twitch/src/token.test.ts b/extensions/twitch/src/token.test.ts index a75541ddf41..7935d582b50 100644 --- a/extensions/twitch/src/token.test.ts +++ b/extensions/twitch/src/token.test.ts @@ -8,9 +8,9 @@ * - Account ID normalization */ +import type { OpenClawConfig } from "openclaw/plugin-sdk"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { resolveTwitchToken, type TwitchTokenSource } from "./token.js"; -import type { OpenClawConfig } from "openclaw/plugin-sdk"; describe("token", () => { // Multi-account config for testing non-default accounts diff --git a/extensions/twitch/src/twitch-client.test.ts b/extensions/twitch/src/twitch-client.test.ts index 76adfa7b9c4..07dd95d624e 100644 --- a/extensions/twitch/src/twitch-client.test.ts +++ b/extensions/twitch/src/twitch-client.test.ts @@ -10,8 +10,8 @@ */ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { TwitchClientManager } from "./twitch-client.js"; import type { ChannelLogSink, TwitchAccountConfig, TwitchChatMessage } from "./types.js"; +import { TwitchClientManager } from "./twitch-client.js"; // Mock @twurple dependencies const mockConnect = vi.fn().mockResolvedValue(undefined); diff --git a/extensions/twitch/src/twitch-client.ts b/extensions/twitch/src/twitch-client.ts index ff064de5ca0..b19345dcd00 100644 --- a/extensions/twitch/src/twitch-client.ts +++ b/extensions/twitch/src/twitch-client.ts @@ -1,6 +1,6 @@ +import type { OpenClawConfig } from "openclaw/plugin-sdk"; import { RefreshingAuthProvider, StaticAuthProvider } from "@twurple/auth"; import { ChatClient, LogLevel } from "@twurple/chat"; -import type { OpenClawConfig } from "openclaw/plugin-sdk"; import type { ChannelLogSink, TwitchAccountConfig, TwitchChatMessage } from "./types.js"; import { resolveTwitchToken } from "./token.js"; import { normalizeToken } from "./utils/twitch.js"; diff --git a/extensions/twitch/src/types.ts b/extensions/twitch/src/types.ts index ab69bf0bb05..150ebd10785 100644 --- a/extensions/twitch/src/types.ts +++ b/extensions/twitch/src/types.ts @@ -5,6 +5,14 @@ * from OpenClaw core. */ +import type { + ChannelGatewayContext, + ChannelOutboundAdapter, + ChannelOutboundContext, + ChannelResolveKind, + ChannelResolveResult, + ChannelStatusAdapter, +} from "../../../src/channels/plugins/types.adapters.js"; import type { ChannelAccountSnapshot, ChannelCapabilities, @@ -14,14 +22,6 @@ import type { ChannelMeta, } from "../../../src/channels/plugins/types.core.js"; import type { ChannelPlugin } from "../../../src/channels/plugins/types.plugin.js"; -import type { - ChannelGatewayContext, - ChannelOutboundAdapter, - ChannelOutboundContext, - ChannelResolveKind, - ChannelResolveResult, - ChannelStatusAdapter, -} from "../../../src/channels/plugins/types.adapters.js"; import type { OpenClawConfig } from "../../../src/config/config.js"; import type { OutboundDeliveryResult } from "../../../src/infra/outbound/deliver.js"; import type { RuntimeEnv } from "../../../src/runtime.js"; @@ -132,9 +132,9 @@ export type { OutboundDeliveryResult, }; +import type { z } from "zod"; // Import and re-export the schema type import type { TwitchConfigSchema } from "./config-schema.js"; -import type { z } from "zod"; export type TwitchConfig = z.infer; export type { OpenClawConfig }; diff --git a/extensions/voice-call/index.ts b/extensions/voice-call/index.ts index 1e5c9c80426..e21ca6f873e 100644 --- a/extensions/voice-call/index.ts +++ b/extensions/voice-call/index.ts @@ -1,12 +1,12 @@ import { Type } from "@sinclair/typebox"; import type { CoreConfig } from "./src/core-bridge.js"; +import { registerVoiceCallCli } from "./src/cli.js"; import { VoiceCallConfigSchema, resolveVoiceCallConfig, validateProviderConfig, type VoiceCallConfig, } from "./src/config.js"; -import { registerVoiceCallCli } from "./src/cli.js"; import { createVoiceCallRuntime, type VoiceCallRuntime } from "./src/runtime.js"; const voiceCallConfigSchema = { diff --git a/extensions/voice-call/src/cli.ts b/extensions/voice-call/src/cli.ts index bb42dc3fc9c..207ee546ccd 100644 --- a/extensions/voice-call/src/cli.ts +++ b/extensions/voice-call/src/cli.ts @@ -1,9 +1,7 @@ +import type { Command } from "commander"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - -import type { Command } from "commander"; - import type { VoiceCallConfig } from "./config.js"; import type { VoiceCallRuntime } from "./runtime.js"; import { resolveUserPath } from "./utils.js"; diff --git a/extensions/voice-call/src/config.test.ts b/extensions/voice-call/src/config.test.ts index 5971d5f68fe..68bfe188389 100644 --- a/extensions/voice-call/src/config.test.ts +++ b/extensions/voice-call/src/config.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest"; - import { validateProviderConfig, resolveVoiceCallConfig, type VoiceCallConfig } from "./config.js"; function createBaseConfig(provider: "telnyx" | "twilio" | "plivo" | "mock"): VoiceCallConfig { diff --git a/extensions/voice-call/src/core-bridge.ts b/extensions/voice-call/src/core-bridge.ts index b8f57a5d2bc..c4bdd7e3087 100644 --- a/extensions/voice-call/src/core-bridge.ts +++ b/extensions/voice-call/src/core-bridge.ts @@ -1,7 +1,6 @@ import fs from "node:fs"; import path from "node:path"; import { fileURLToPath, pathToFileURL } from "node:url"; - import type { VoiceCallTtsConfig } from "./config.js"; export type CoreConfig = { diff --git a/extensions/voice-call/src/manager.test.ts b/extensions/voice-call/src/manager.test.ts index 6f409667d4d..88ea6648523 100644 --- a/extensions/voice-call/src/manager.test.ts +++ b/extensions/voice-call/src/manager.test.ts @@ -1,10 +1,7 @@ import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - -import { VoiceCallConfigSchema } from "./config.js"; -import { CallManager } from "./manager.js"; +import type { VoiceCallProvider } from "./providers/base.js"; import type { HangupCallInput, InitiateCallInput, @@ -16,7 +13,8 @@ import type { WebhookContext, WebhookVerificationResult, } from "./types.js"; -import type { VoiceCallProvider } from "./providers/base.js"; +import { VoiceCallConfigSchema } from "./config.js"; +import { CallManager } from "./manager.js"; class FakeProvider implements VoiceCallProvider { readonly name = "plivo" as const; diff --git a/extensions/voice-call/src/manager.ts b/extensions/voice-call/src/manager.ts index 8ffbf855f60..2851a6e8ce2 100644 --- a/extensions/voice-call/src/manager.ts +++ b/extensions/voice-call/src/manager.ts @@ -3,8 +3,6 @@ import fs from "node:fs"; import fsp from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - -import { resolveUserPath } from "./utils.js"; import type { CallMode, VoiceCallConfig } from "./config.js"; import type { VoiceCallProvider } from "./providers/base.js"; import { @@ -17,6 +15,7 @@ import { TerminalStates, type TranscriptEntry, } from "./types.js"; +import { resolveUserPath } from "./utils.js"; import { escapeXml, mapVoiceToPolly } from "./voice-mapping.js"; function resolveDefaultStoreBase(config: VoiceCallConfig, storePath?: string): string { diff --git a/extensions/voice-call/src/manager/context.ts b/extensions/voice-call/src/manager/context.ts index 846dd745030..334570ab8c5 100644 --- a/extensions/voice-call/src/manager/context.ts +++ b/extensions/voice-call/src/manager/context.ts @@ -1,6 +1,6 @@ -import type { CallId, CallRecord } from "../types.js"; import type { VoiceCallConfig } from "../config.js"; import type { VoiceCallProvider } from "../providers/base.js"; +import type { CallId, CallRecord } from "../types.js"; export type TranscriptWaiter = { resolve: (text: string) => void; diff --git a/extensions/voice-call/src/manager/events.ts b/extensions/voice-call/src/manager/events.ts index 76c6f17022e..7f131eb6d32 100644 --- a/extensions/voice-call/src/manager/events.ts +++ b/extensions/voice-call/src/manager/events.ts @@ -1,8 +1,8 @@ import crypto from "node:crypto"; - import type { CallRecord, CallState, NormalizedEvent } from "../types.js"; import type { CallManagerContext } from "./context.js"; import { findCall } from "./lookup.js"; +import { endCall } from "./outbound.js"; import { addTranscriptEntry, transitionState } from "./state.js"; import { persistCallRecord } from "./store.js"; import { @@ -11,7 +11,6 @@ import { resolveTranscriptWaiter, startMaxDurationTimer, } from "./timers.js"; -import { endCall } from "./outbound.js"; function shouldAcceptInbound( config: CallManagerContext["config"], diff --git a/extensions/voice-call/src/manager/outbound.ts b/extensions/voice-call/src/manager/outbound.ts index e681ad0ac3a..2f810fec604 100644 --- a/extensions/voice-call/src/manager/outbound.ts +++ b/extensions/voice-call/src/manager/outbound.ts @@ -1,16 +1,14 @@ import crypto from "node:crypto"; - +import type { CallMode } from "../config.js"; +import type { CallManagerContext } from "./context.js"; import { TerminalStates, type CallId, type CallRecord, type OutboundCallOptions, } from "../types.js"; -import type { CallMode } from "../config.js"; import { mapVoiceToPolly } from "../voice-mapping.js"; -import type { CallManagerContext } from "./context.js"; import { getCallByProviderCallId } from "./lookup.js"; -import { generateNotifyTwiml } from "./twiml.js"; import { addTranscriptEntry, transitionState } from "./state.js"; import { persistCallRecord } from "./store.js"; import { @@ -19,6 +17,7 @@ import { rejectTranscriptWaiter, waitForFinalTranscript, } from "./timers.js"; +import { generateNotifyTwiml } from "./twiml.js"; export async function initiateCall( ctx: CallManagerContext, diff --git a/extensions/voice-call/src/manager/store.ts b/extensions/voice-call/src/manager/store.ts index b6da22f707a..888381c3342 100644 --- a/extensions/voice-call/src/manager/store.ts +++ b/extensions/voice-call/src/manager/store.ts @@ -1,7 +1,6 @@ import fs from "node:fs"; import fsp from "node:fs/promises"; import path from "node:path"; - import { CallRecordSchema, TerminalStates, type CallId, type CallRecord } from "../types.js"; export function persistCallRecord(storePath: string, call: CallRecord): void { diff --git a/extensions/voice-call/src/manager/timers.ts b/extensions/voice-call/src/manager/timers.ts index 8fcb89f0ce4..b8723ebcaaa 100644 --- a/extensions/voice-call/src/manager/timers.ts +++ b/extensions/voice-call/src/manager/timers.ts @@ -1,5 +1,5 @@ -import { TerminalStates, type CallId } from "../types.js"; import type { CallManagerContext } from "./context.js"; +import { TerminalStates, type CallId } from "../types.js"; import { persistCallRecord } from "./store.js"; export function clearMaxDurationTimer(ctx: CallManagerContext, callId: CallId): void { diff --git a/extensions/voice-call/src/media-stream.test.ts b/extensions/voice-call/src/media-stream.test.ts index 77344512147..8b5f700c591 100644 --- a/extensions/voice-call/src/media-stream.test.ts +++ b/extensions/voice-call/src/media-stream.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenAIRealtimeSTTProvider, RealtimeSTTSession, diff --git a/extensions/voice-call/src/media-stream.ts b/extensions/voice-call/src/media-stream.ts index 6a63fa5a651..64fe69c3e8e 100644 --- a/extensions/voice-call/src/media-stream.ts +++ b/extensions/voice-call/src/media-stream.ts @@ -9,9 +9,7 @@ import type { IncomingMessage } from "node:http"; import type { Duplex } from "node:stream"; - import { WebSocket, WebSocketServer } from "ws"; - import type { OpenAIRealtimeSTTProvider, RealtimeSTTSession, diff --git a/extensions/voice-call/src/providers/mock.ts b/extensions/voice-call/src/providers/mock.ts index 260bf3516e7..bc6a52efa71 100644 --- a/extensions/voice-call/src/providers/mock.ts +++ b/extensions/voice-call/src/providers/mock.ts @@ -1,5 +1,4 @@ import crypto from "node:crypto"; - import type { EndReason, HangupCallInput, diff --git a/extensions/voice-call/src/providers/plivo.test.ts b/extensions/voice-call/src/providers/plivo.test.ts index e2aa6289bc4..1f46e2d47a5 100644 --- a/extensions/voice-call/src/providers/plivo.test.ts +++ b/extensions/voice-call/src/providers/plivo.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { PlivoProvider } from "./plivo.js"; describe("PlivoProvider", () => { diff --git a/extensions/voice-call/src/providers/plivo.ts b/extensions/voice-call/src/providers/plivo.ts index 9131dc3a653..601ea6cdd60 100644 --- a/extensions/voice-call/src/providers/plivo.ts +++ b/extensions/voice-call/src/providers/plivo.ts @@ -1,5 +1,4 @@ import crypto from "node:crypto"; - import type { PlivoConfig } from "../config.js"; import type { HangupCallInput, @@ -13,9 +12,9 @@ import type { WebhookContext, WebhookVerificationResult, } from "../types.js"; +import type { VoiceCallProvider } from "./base.js"; import { escapeXml } from "../voice-mapping.js"; import { reconstructWebhookUrl, verifyPlivoWebhook } from "../webhook-security.js"; -import type { VoiceCallProvider } from "./base.js"; export interface PlivoProviderOptions { /** Override public URL origin for signature verification */ diff --git a/extensions/voice-call/src/providers/telnyx.ts b/extensions/voice-call/src/providers/telnyx.ts index 113daae3ff0..14a4b76a4d1 100644 --- a/extensions/voice-call/src/providers/telnyx.ts +++ b/extensions/voice-call/src/providers/telnyx.ts @@ -1,5 +1,4 @@ import crypto from "node:crypto"; - import type { TelnyxConfig } from "../config.js"; import type { EndReason, diff --git a/extensions/voice-call/src/providers/twilio.test.ts b/extensions/voice-call/src/providers/twilio.test.ts index 8a307201351..98e5ddbb86f 100644 --- a/extensions/voice-call/src/providers/twilio.test.ts +++ b/extensions/voice-call/src/providers/twilio.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { WebhookContext } from "../types.js"; import { TwilioProvider } from "./twilio.js"; diff --git a/extensions/voice-call/src/providers/twilio.ts b/extensions/voice-call/src/providers/twilio.ts index be0b18f7b40..b40ec5f4b99 100644 --- a/extensions/voice-call/src/providers/twilio.ts +++ b/extensions/voice-call/src/providers/twilio.ts @@ -1,7 +1,7 @@ import crypto from "node:crypto"; - import type { TwilioConfig } from "../config.js"; import type { MediaStreamHandler } from "../media-stream.js"; +import type { TelephonyTtsProvider } from "../telephony-tts.js"; import type { HangupCallInput, InitiateCallInput, @@ -14,10 +14,9 @@ import type { WebhookContext, WebhookVerificationResult, } from "../types.js"; -import { escapeXml, mapVoiceToPolly } from "../voice-mapping.js"; -import { chunkAudio } from "../telephony-audio.js"; -import type { TelephonyTtsProvider } from "../telephony-tts.js"; import type { VoiceCallProvider } from "./base.js"; +import { chunkAudio } from "../telephony-audio.js"; +import { escapeXml, mapVoiceToPolly } from "../voice-mapping.js"; import { twilioApiRequest } from "./twilio/api.js"; import { verifyTwilioProviderWebhook } from "./twilio/webhook.js"; diff --git a/extensions/voice-call/src/providers/twilio/webhook.ts b/extensions/voice-call/src/providers/twilio/webhook.ts index 3c78a3042ac..f2f2a671e8b 100644 --- a/extensions/voice-call/src/providers/twilio/webhook.ts +++ b/extensions/voice-call/src/providers/twilio/webhook.ts @@ -1,7 +1,6 @@ import type { WebhookContext, WebhookVerificationResult } from "../../types.js"; -import { verifyTwilioWebhook } from "../../webhook-security.js"; - import type { TwilioProviderOptions } from "../twilio.js"; +import { verifyTwilioWebhook } from "../../webhook-security.js"; export function verifyTwilioProviderWebhook(params: { ctx: WebhookContext; diff --git a/extensions/voice-call/src/response-generator.ts b/extensions/voice-call/src/response-generator.ts index 23c2123aae8..a13ebc3723b 100644 --- a/extensions/voice-call/src/response-generator.ts +++ b/extensions/voice-call/src/response-generator.ts @@ -4,10 +4,8 @@ */ import crypto from "node:crypto"; - -import { loadCoreAgentDeps, type CoreConfig } from "./core-bridge.js"; - import type { VoiceCallConfig } from "./config.js"; +import { loadCoreAgentDeps, type CoreConfig } from "./core-bridge.js"; export type VoiceResponseParams = { /** Voice call config */ diff --git a/extensions/voice-call/src/runtime.ts b/extensions/voice-call/src/runtime.ts index 639caa5e1db..93a2c756a5f 100644 --- a/extensions/voice-call/src/runtime.ts +++ b/extensions/voice-call/src/runtime.ts @@ -1,13 +1,13 @@ -import type { CoreConfig } from "./core-bridge.js"; import type { VoiceCallConfig } from "./config.js"; +import type { CoreConfig } from "./core-bridge.js"; +import type { VoiceCallProvider } from "./providers/base.js"; +import type { TelephonyTtsRuntime } from "./telephony-tts.js"; import { resolveVoiceCallConfig, validateProviderConfig } from "./config.js"; import { CallManager } from "./manager.js"; -import type { VoiceCallProvider } from "./providers/base.js"; import { MockProvider } from "./providers/mock.js"; import { PlivoProvider } from "./providers/plivo.js"; import { TelnyxProvider } from "./providers/telnyx.js"; import { TwilioProvider } from "./providers/twilio.js"; -import type { TelephonyTtsRuntime } from "./telephony-tts.js"; import { createTelephonyTtsProvider } from "./telephony-tts.js"; import { startTunnel, type TunnelResult } from "./tunnel.js"; import { diff --git a/extensions/voice-call/src/telephony-tts.ts b/extensions/voice-call/src/telephony-tts.ts index be16fae1d40..dde2fbc2899 100644 --- a/extensions/voice-call/src/telephony-tts.ts +++ b/extensions/voice-call/src/telephony-tts.ts @@ -1,5 +1,5 @@ -import type { CoreConfig } from "./core-bridge.js"; import type { VoiceCallTtsConfig } from "./config.js"; +import type { CoreConfig } from "./core-bridge.js"; import { convertPcmToMulaw8k } from "./telephony-audio.js"; export type TelephonyTtsRuntime = { diff --git a/extensions/voice-call/src/tunnel.ts b/extensions/voice-call/src/tunnel.ts index 6ea2d224fb8..829a68aea87 100644 --- a/extensions/voice-call/src/tunnel.ts +++ b/extensions/voice-call/src/tunnel.ts @@ -1,5 +1,4 @@ import { spawn } from "node:child_process"; - import { getTailscaleDnsName } from "./webhook.js"; /** diff --git a/extensions/voice-call/src/types.ts b/extensions/voice-call/src/types.ts index 68cca11e62f..38091baa4d4 100644 --- a/extensions/voice-call/src/types.ts +++ b/extensions/voice-call/src/types.ts @@ -1,5 +1,4 @@ import { z } from "zod"; - import type { CallMode } from "./config.js"; // ----------------------------------------------------------------------------- diff --git a/extensions/voice-call/src/webhook-security.test.ts b/extensions/voice-call/src/webhook-security.test.ts index f893bee0819..253b5904ec8 100644 --- a/extensions/voice-call/src/webhook-security.test.ts +++ b/extensions/voice-call/src/webhook-security.test.ts @@ -1,7 +1,5 @@ import crypto from "node:crypto"; - import { describe, expect, it } from "vitest"; - import { verifyPlivoWebhook, verifyTwilioWebhook } from "./webhook-security.js"; function canonicalizeBase64(input: string): string { diff --git a/extensions/voice-call/src/webhook-security.ts b/extensions/voice-call/src/webhook-security.ts index ebefea96447..26fb7a1c992 100644 --- a/extensions/voice-call/src/webhook-security.ts +++ b/extensions/voice-call/src/webhook-security.ts @@ -1,5 +1,4 @@ import crypto from "node:crypto"; - import type { WebhookContext } from "./types.js"; /** diff --git a/extensions/voice-call/src/webhook.ts b/extensions/voice-call/src/webhook.ts index 77fcd9c16b6..58a39c0f0d9 100644 --- a/extensions/voice-call/src/webhook.ts +++ b/extensions/voice-call/src/webhook.ts @@ -1,16 +1,15 @@ import { spawn } from "node:child_process"; import http from "node:http"; import { URL } from "node:url"; - import type { VoiceCallConfig } from "./config.js"; import type { CoreConfig } from "./core-bridge.js"; import type { CallManager } from "./manager.js"; import type { MediaStreamConfig } from "./media-stream.js"; -import { MediaStreamHandler } from "./media-stream.js"; import type { VoiceCallProvider } from "./providers/base.js"; -import { OpenAIRealtimeSTTProvider } from "./providers/stt-openai-realtime.js"; import type { TwilioProvider } from "./providers/twilio.js"; import type { NormalizedEvent, WebhookContext } from "./types.js"; +import { MediaStreamHandler } from "./media-stream.js"; +import { OpenAIRealtimeSTTProvider } from "./providers/stt-openai-realtime.js"; /** * HTTP server for receiving voice call webhooks from providers. diff --git a/extensions/whatsapp/index.ts b/extensions/whatsapp/index.ts index 689670f3ba4..1b19ff6775d 100644 --- a/extensions/whatsapp/index.ts +++ b/extensions/whatsapp/index.ts @@ -1,6 +1,5 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { whatsappPlugin } from "./src/channel.js"; import { setWhatsAppRuntime } from "./src/runtime.js"; diff --git a/extensions/whatsapp/src/channel.ts b/extensions/whatsapp/src/channel.ts index 056371d9047..3f127e1e1ca 100644 --- a/extensions/whatsapp/src/channel.ts +++ b/extensions/whatsapp/src/channel.ts @@ -29,7 +29,6 @@ import { type ChannelPlugin, type ResolvedWhatsAppAccount, } from "openclaw/plugin-sdk"; - import { getWhatsAppRuntime } from "./runtime.js"; const meta = getChatChannelMeta("whatsapp"); diff --git a/extensions/zalo/index.ts b/extensions/zalo/index.ts index 5eeb06d498f..20e0ea83c8f 100644 --- a/extensions/zalo/index.ts +++ b/extensions/zalo/index.ts @@ -1,6 +1,5 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { zaloDock, zaloPlugin } from "./src/channel.js"; import { handleZaloWebhookRequest } from "./src/monitor.js"; import { setZaloRuntime } from "./src/runtime.js"; diff --git a/extensions/zalo/src/accounts.ts b/extensions/zalo/src/accounts.ts index 5a49091a1cd..01e6fa74747 100644 --- a/extensions/zalo/src/accounts.ts +++ b/extensions/zalo/src/accounts.ts @@ -1,6 +1,5 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk"; import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk"; - import type { ResolvedZaloAccount, ZaloAccountConfig, ZaloConfig } from "./types.js"; import { resolveZaloToken } from "./token.js"; diff --git a/extensions/zalo/src/actions.ts b/extensions/zalo/src/actions.ts index 1a9d5d29db0..318220f8c16 100644 --- a/extensions/zalo/src/actions.ts +++ b/extensions/zalo/src/actions.ts @@ -4,7 +4,6 @@ import type { OpenClawConfig, } from "openclaw/plugin-sdk"; import { jsonResult, readStringParam } from "openclaw/plugin-sdk"; - import { listEnabledZaloAccounts } from "./accounts.js"; import { sendMessageZalo } from "./send.js"; diff --git a/extensions/zalo/src/channel.directory.test.ts b/extensions/zalo/src/channel.directory.test.ts index 327d16a30d2..91660c6b573 100644 --- a/extensions/zalo/src/channel.directory.test.ts +++ b/extensions/zalo/src/channel.directory.test.ts @@ -1,7 +1,5 @@ -import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "openclaw/plugin-sdk"; - +import { describe, expect, it } from "vitest"; import { zaloPlugin } from "./channel.js"; describe("zalo directory", () => { diff --git a/extensions/zalo/src/channel.ts b/extensions/zalo/src/channel.ts index 4ea0e0aaf93..6bf61bf68ec 100644 --- a/extensions/zalo/src/channel.ts +++ b/extensions/zalo/src/channel.ts @@ -15,7 +15,6 @@ import { PAIRING_APPROVED_MESSAGE, setAccountEnabledInConfigSection, } from "openclaw/plugin-sdk"; - import { listZaloAccountIds, resolveDefaultZaloAccountId, @@ -25,8 +24,8 @@ import { import { zaloMessageActions } from "./actions.js"; import { ZaloConfigSchema } from "./config-schema.js"; import { zaloOnboardingAdapter } from "./onboarding.js"; -import { resolveZaloProxyFetch } from "./proxy.js"; import { probeZalo } from "./probe.js"; +import { resolveZaloProxyFetch } from "./proxy.js"; import { sendMessageZalo } from "./send.js"; import { collectZaloStatusIssues } from "./status-issues.js"; diff --git a/extensions/zalo/src/monitor.ts b/extensions/zalo/src/monitor.ts index 36c85dadc01..cd8c34f1257 100644 --- a/extensions/zalo/src/monitor.ts +++ b/extensions/zalo/src/monitor.ts @@ -1,7 +1,5 @@ import type { IncomingMessage, ServerResponse } from "node:http"; - import type { OpenClawConfig, MarkdownTableMode } from "openclaw/plugin-sdk"; - import type { ResolvedZaloAccount } from "./accounts.js"; import { ZaloApiError, diff --git a/extensions/zalo/src/monitor.webhook.test.ts b/extensions/zalo/src/monitor.webhook.test.ts index fcfbd0ceec7..60d042e2e84 100644 --- a/extensions/zalo/src/monitor.webhook.test.ts +++ b/extensions/zalo/src/monitor.webhook.test.ts @@ -1,9 +1,7 @@ -import { createServer } from "node:http"; import type { AddressInfo } from "node:net"; - -import { describe, expect, it } from "vitest"; - import type { OpenClawConfig, PluginRuntime } from "openclaw/plugin-sdk"; +import { createServer } from "node:http"; +import { describe, expect, it } from "vitest"; import type { ResolvedZaloAccount } from "./types.js"; import { handleZaloWebhookRequest, registerZaloWebhookTarget } from "./monitor.js"; diff --git a/extensions/zalo/src/onboarding.ts b/extensions/zalo/src/onboarding.ts index 7590fb27d13..36fd7db0374 100644 --- a/extensions/zalo/src/onboarding.ts +++ b/extensions/zalo/src/onboarding.ts @@ -10,7 +10,6 @@ import { normalizeAccountId, promptAccountId, } from "openclaw/plugin-sdk"; - import { listZaloAccountIds, resolveDefaultZaloAccountId, resolveZaloAccount } from "./accounts.js"; const channel = "zalo" as const; diff --git a/extensions/zalo/src/proxy.ts b/extensions/zalo/src/proxy.ts index 0a6a39b9688..4c59f16aa1f 100644 --- a/extensions/zalo/src/proxy.ts +++ b/extensions/zalo/src/proxy.ts @@ -1,6 +1,5 @@ -import { ProxyAgent, fetch as undiciFetch } from "undici"; import type { Dispatcher } from "undici"; - +import { ProxyAgent, fetch as undiciFetch } from "undici"; import type { ZaloFetch } from "./api.js"; const proxyCache = new Map(); diff --git a/extensions/zalo/src/send.ts b/extensions/zalo/src/send.ts index ca5c7398e35..9b98759eeb5 100644 --- a/extensions/zalo/src/send.ts +++ b/extensions/zalo/src/send.ts @@ -1,8 +1,7 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk"; - import type { ZaloFetch } from "./api.js"; -import { sendMessage, sendPhoto } from "./api.js"; import { resolveZaloAccount } from "./accounts.js"; +import { sendMessage, sendPhoto } from "./api.js"; import { resolveZaloProxyFetch } from "./proxy.js"; import { resolveZaloToken } from "./token.js"; diff --git a/extensions/zalo/src/token.ts b/extensions/zalo/src/token.ts index 5955350112c..480f66c8fad 100644 --- a/extensions/zalo/src/token.ts +++ b/extensions/zalo/src/token.ts @@ -1,7 +1,5 @@ import { readFileSync } from "node:fs"; - import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk"; - import type { ZaloConfig } from "./types.js"; export type ZaloTokenResolution = { diff --git a/extensions/zalouser/index.ts b/extensions/zalouser/index.ts index 39465e5b116..fd27aba276d 100644 --- a/extensions/zalouser/index.ts +++ b/extensions/zalouser/index.ts @@ -1,9 +1,8 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { emptyPluginConfigSchema } from "openclaw/plugin-sdk"; - import { zalouserDock, zalouserPlugin } from "./src/channel.js"; -import { ZalouserToolSchema, executeZalouserTool } from "./src/tool.js"; import { setZalouserRuntime } from "./src/runtime.js"; +import { ZalouserToolSchema, executeZalouserTool } from "./src/tool.js"; const plugin = { id: "zalouser", diff --git a/extensions/zalouser/src/accounts.ts b/extensions/zalouser/src/accounts.ts index e218a7e33ba..d70c4247dd3 100644 --- a/extensions/zalouser/src/accounts.ts +++ b/extensions/zalouser/src/accounts.ts @@ -1,8 +1,7 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk"; import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk"; - -import { runZca, parseJsonOutput } from "./zca.js"; import type { ResolvedZalouserAccount, ZalouserAccountConfig, ZalouserConfig } from "./types.js"; +import { runZca, parseJsonOutput } from "./zca.js"; function listConfiguredAccountIds(cfg: OpenClawConfig): string[] { const accounts = (cfg.channels?.zalouser as ZalouserConfig | undefined)?.accounts; diff --git a/extensions/zalouser/src/channel.test.ts b/extensions/zalouser/src/channel.test.ts index a5ba68f9549..65b759b226e 100644 --- a/extensions/zalouser/src/channel.test.ts +++ b/extensions/zalouser/src/channel.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { zalouserPlugin } from "./channel.js"; describe("zalouser outbound chunker", () => { diff --git a/extensions/zalouser/src/channel.ts b/extensions/zalouser/src/channel.ts index c901a19ca8e..e0fd6f8d5f3 100644 --- a/extensions/zalouser/src/channel.ts +++ b/extensions/zalouser/src/channel.ts @@ -17,6 +17,7 @@ import { normalizeAccountId, setAccountEnabledInConfigSection, } from "openclaw/plugin-sdk"; +import type { ZcaFriend, ZcaGroup, ZcaUserInfo } from "./types.js"; import { listZalouserAccountIds, resolveDefaultZalouserAccountId, @@ -25,13 +26,12 @@ import { checkZcaAuthenticated, type ResolvedZalouserAccount, } from "./accounts.js"; -import { zalouserOnboardingAdapter } from "./onboarding.js"; -import { sendMessageZalouser } from "./send.js"; -import { checkZcaInstalled, parseJsonOutput, runZca, runZcaInteractive } from "./zca.js"; -import type { ZcaFriend, ZcaGroup, ZcaUserInfo } from "./types.js"; import { ZalouserConfigSchema } from "./config-schema.js"; -import { collectZalouserStatusIssues } from "./status-issues.js"; +import { zalouserOnboardingAdapter } from "./onboarding.js"; import { probeZalouser } from "./probe.js"; +import { sendMessageZalouser } from "./send.js"; +import { collectZalouserStatusIssues } from "./status-issues.js"; +import { checkZcaInstalled, parseJsonOutput, runZca, runZcaInteractive } from "./zca.js"; const meta = { id: "zalouser", diff --git a/extensions/zalouser/src/monitor.ts b/extensions/zalouser/src/monitor.ts index bbea88ecd92..3d945851468 100644 --- a/extensions/zalouser/src/monitor.ts +++ b/extensions/zalouser/src/monitor.ts @@ -1,10 +1,9 @@ import type { ChildProcess } from "node:child_process"; - import type { OpenClawConfig, MarkdownTableMode, RuntimeEnv } from "openclaw/plugin-sdk"; import { mergeAllowlist, summarizeMapping } from "openclaw/plugin-sdk"; -import { sendMessageZalouser } from "./send.js"; import type { ResolvedZalouserAccount, ZcaFriend, ZcaGroup, ZcaMessage } from "./types.js"; import { getZalouserRuntime } from "./runtime.js"; +import { sendMessageZalouser } from "./send.js"; import { parseJsonOutput, runZca, runZcaStreaming } from "./zca.js"; export type ZalouserMonitorOptions = { diff --git a/extensions/zalouser/src/onboarding.ts b/extensions/zalouser/src/onboarding.ts index 2d0d1fe832e..7c702505100 100644 --- a/extensions/zalouser/src/onboarding.ts +++ b/extensions/zalouser/src/onboarding.ts @@ -11,7 +11,7 @@ import { promptAccountId, promptChannelAccessConfig, } from "openclaw/plugin-sdk"; - +import type { ZcaFriend, ZcaGroup } from "./types.js"; import { listZalouserAccountIds, resolveDefaultZalouserAccountId, @@ -19,7 +19,6 @@ import { checkZcaAuthenticated, } from "./accounts.js"; import { runZca, runZcaInteractive, checkZcaInstalled, parseJsonOutput } from "./zca.js"; -import type { ZcaFriend, ZcaGroup } from "./types.js"; const channel = "zalouser" as const; diff --git a/extensions/zalouser/src/probe.ts b/extensions/zalouser/src/probe.ts index 9ef290133d1..bfeb92ec586 100644 --- a/extensions/zalouser/src/probe.ts +++ b/extensions/zalouser/src/probe.ts @@ -1,5 +1,5 @@ -import { runZca, parseJsonOutput } from "./zca.js"; import type { ZcaUserInfo } from "./types.js"; +import { runZca, parseJsonOutput } from "./zca.js"; export interface ZalouserProbeResult { ok: boolean; diff --git a/extensions/zalouser/src/status-issues.test.ts b/extensions/zalouser/src/status-issues.test.ts index 8e592c59be2..b84d15d6f25 100644 --- a/extensions/zalouser/src/status-issues.test.ts +++ b/extensions/zalouser/src/status-issues.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { collectZalouserStatusIssues } from "./status-issues.js"; describe("collectZalouserStatusIssues", () => { diff --git a/extensions/zalouser/src/tool.ts b/extensions/zalouser/src/tool.ts index 963f70a0e23..2f4d7be4cb5 100644 --- a/extensions/zalouser/src/tool.ts +++ b/extensions/zalouser/src/tool.ts @@ -1,5 +1,4 @@ import { Type } from "@sinclair/typebox"; - import { runZca, parseJsonOutput } from "./zca.js"; const ACTIONS = ["send", "image", "link", "friends", "groups", "me", "status"] as const; diff --git a/extensions/zalouser/src/zca.ts b/extensions/zalouser/src/zca.ts index 55272afa9ce..3e20984acad 100644 --- a/extensions/zalouser/src/zca.ts +++ b/extensions/zalouser/src/zca.ts @@ -1,5 +1,4 @@ import { spawn, type SpawnOptions } from "node:child_process"; - import type { ZcaResult, ZcaRunOptions } from "./types.js"; const ZCA_BINARY = "zca"; diff --git a/scripts/check-ts-max-loc.ts b/scripts/check-ts-max-loc.ts index 969da2047fc..88b9a0d477e 100644 --- a/scripts/check-ts-max-loc.ts +++ b/scripts/check-ts-max-loc.ts @@ -1,6 +1,6 @@ +import { execFileSync } from "node:child_process"; import { existsSync } from "node:fs"; import { readFile } from "node:fs/promises"; -import { execFileSync } from "node:child_process"; type ParsedArgs = { maxLines: number; diff --git a/scripts/debug-claude-usage.ts b/scripts/debug-claude-usage.ts index 210d13e0fa1..556360c394e 100644 --- a/scripts/debug-claude-usage.ts +++ b/scripts/debug-claude-usage.ts @@ -1,8 +1,8 @@ +import { execFileSync } from "node:child_process"; import crypto from "node:crypto"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; -import { execFileSync } from "node:child_process"; type Args = { agentId: string; diff --git a/scripts/format-staged.js b/scripts/format-staged.js index 8230824c525..4c5249dd898 100644 --- a/scripts/format-staged.js +++ b/scripts/format-staged.js @@ -1,6 +1,6 @@ +import { spawnSync } from "node:child_process"; import fs from "node:fs"; import path from "node:path"; -import { spawnSync } from "node:child_process"; import { fileURLToPath } from "node:url"; const OXFMT_EXTENSIONS = new Set([".cjs", ".js", ".json", ".jsonc", ".jsx", ".mjs", ".ts", ".tsx"]); diff --git a/scripts/postinstall.js b/scripts/postinstall.js index aa0d0c3fc60..e5adce74e7b 100644 --- a/scripts/postinstall.js +++ b/scripts/postinstall.js @@ -1,6 +1,6 @@ +import { spawnSync } from "node:child_process"; import fs from "node:fs"; import path from "node:path"; -import { spawnSync } from "node:child_process"; import { fileURLToPath } from "node:url"; import { setupGitHooks } from "./setup-git-hooks.js"; diff --git a/scripts/setup-git-hooks.js b/scripts/setup-git-hooks.js index decce5feba6..a9023b9dc1b 100644 --- a/scripts/setup-git-hooks.js +++ b/scripts/setup-git-hooks.js @@ -1,6 +1,6 @@ +import { spawnSync } from "node:child_process"; import fs from "node:fs"; import path from "node:path"; -import { spawnSync } from "node:child_process"; import { fileURLToPath } from "node:url"; const DEFAULT_HOOKS_PATH = "git-hooks"; diff --git a/scripts/test-force.ts b/scripts/test-force.ts index d7833a990b9..bb691dde223 100755 --- a/scripts/test-force.ts +++ b/scripts/test-force.ts @@ -1,7 +1,7 @@ #!/usr/bin/env -S node --import tsx +import { spawnSync } from "node:child_process"; import os from "node:os"; import path from "node:path"; -import { spawnSync } from "node:child_process"; import { forceFreePort, type PortProcess } from "../src/cli/ports.js"; const DEFAULT_PORT = 18789; diff --git a/scripts/zai-fallback-repro.ts b/scripts/zai-fallback-repro.ts index a418dc8d1c6..71e9e343845 100644 --- a/scripts/zai-fallback-repro.ts +++ b/scripts/zai-fallback-repro.ts @@ -1,5 +1,5 @@ -import { randomUUID } from "node:crypto"; import { spawn } from "node:child_process"; +import { randomUUID } from "node:crypto"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; diff --git a/src/acp/client.ts b/src/acp/client.ts index db84c5eb961..e1b86979029 100644 --- a/src/acp/client.ts +++ b/src/acp/client.ts @@ -1,7 +1,3 @@ -import { spawn, type ChildProcess } from "node:child_process"; -import * as readline from "node:readline"; -import { Readable, Writable } from "node:stream"; - import { ClientSideConnection, PROTOCOL_VERSION, @@ -9,7 +5,9 @@ import { type RequestPermissionRequest, type SessionNotification, } from "@agentclientprotocol/sdk"; - +import { spawn, type ChildProcess } from "node:child_process"; +import * as readline from "node:readline"; +import { Readable, Writable } from "node:stream"; import { ensureOpenClawCliOnPath } from "../infra/path-env.js"; export type AcpClientOptions = { diff --git a/src/acp/event-mapper.test.ts b/src/acp/event-mapper.test.ts index cbb72c27986..0b7682ef358 100644 --- a/src/acp/event-mapper.test.ts +++ b/src/acp/event-mapper.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { extractAttachmentsFromPrompt, extractTextFromPrompt } from "./event-mapper.js"; describe("acp event mapper", () => { diff --git a/src/acp/server.ts b/src/acp/server.ts index 5cc366b1992..4a2c835b549 100644 --- a/src/acp/server.ts +++ b/src/acp/server.ts @@ -1,9 +1,8 @@ #!/usr/bin/env node +import { AgentSideConnection, ndJsonStream } from "@agentclientprotocol/sdk"; import { Readable, Writable } from "node:stream"; import { fileURLToPath } from "node:url"; - -import { AgentSideConnection, ndJsonStream } from "@agentclientprotocol/sdk"; - +import type { AcpServerOptions } from "./types.js"; import { loadConfig } from "../config/config.js"; import { resolveGatewayAuth } from "../gateway/auth.js"; import { buildGatewayConnectionDetails } from "../gateway/call.js"; @@ -11,7 +10,6 @@ import { GatewayClient } from "../gateway/client.js"; import { isMainModule } from "../infra/is-main.js"; import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; import { AcpGatewayAgent } from "./translator.js"; -import type { AcpServerOptions } from "./types.js"; export function serveAcpGateway(opts: AcpServerOptions = {}): void { const cfg = loadConfig(); diff --git a/src/acp/session-mapper.test.ts b/src/acp/session-mapper.test.ts index d92315db933..859b1da7380 100644 --- a/src/acp/session-mapper.test.ts +++ b/src/acp/session-mapper.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { GatewayClient } from "../gateway/client.js"; import { parseSessionMeta, resolveSessionKey } from "./session-mapper.js"; diff --git a/src/acp/session-mapper.ts b/src/acp/session-mapper.ts index 6fa8b047e8e..56887618957 100644 --- a/src/acp/session-mapper.ts +++ b/src/acp/session-mapper.ts @@ -1,5 +1,4 @@ import type { GatewayClient } from "../gateway/client.js"; - import type { AcpServerOptions } from "./types.js"; import { readBool, readString } from "./meta.js"; diff --git a/src/acp/session.test.ts b/src/acp/session.test.ts index 619df3b5e9e..a38b58f1703 100644 --- a/src/acp/session.test.ts +++ b/src/acp/session.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, afterEach } from "vitest"; - import { createInMemorySessionStore } from "./session.js"; describe("acp session manager", () => { diff --git a/src/acp/session.ts b/src/acp/session.ts index ecec6fb8d01..3214b08c301 100644 --- a/src/acp/session.ts +++ b/src/acp/session.ts @@ -1,5 +1,4 @@ import { randomUUID } from "node:crypto"; - import type { AcpSession } from "./types.js"; export type AcpSessionStore = { diff --git a/src/acp/translator.ts b/src/acp/translator.ts index 7475cff226f..d120794e6d6 100644 --- a/src/acp/translator.ts +++ b/src/acp/translator.ts @@ -1,5 +1,3 @@ -import { randomUUID } from "node:crypto"; - import type { Agent, AgentSideConnection, @@ -21,21 +19,21 @@ import type { StopReason, } from "@agentclientprotocol/sdk"; import { PROTOCOL_VERSION } from "@agentclientprotocol/sdk"; - +import { randomUUID } from "node:crypto"; import type { GatewayClient } from "../gateway/client.js"; import type { EventFrame } from "../gateway/protocol/index.js"; import type { SessionsListResult } from "../gateway/session-utils.js"; import { getAvailableCommands } from "./commands.js"; -import { readBool, readNumber, readString } from "./meta.js"; import { extractAttachmentsFromPrompt, extractTextFromPrompt, formatToolTitle, inferToolKind, } from "./event-mapper.js"; +import { readBool, readNumber, readString } from "./meta.js"; import { parseSessionMeta, resetSessionIfNeeded, resolveSessionKey } from "./session-mapper.js"; -import { ACP_AGENT_INFO, type AcpServerOptions } from "./types.js"; import { defaultAcpSessionStore, type AcpSessionStore } from "./session.js"; +import { ACP_AGENT_INFO, type AcpServerOptions } from "./types.js"; type PendingPrompt = { sessionId: string; diff --git a/src/acp/types.ts b/src/acp/types.ts index 45a812f04c1..b6c713442b1 100644 --- a/src/acp/types.ts +++ b/src/acp/types.ts @@ -1,5 +1,4 @@ import type { SessionId } from "@agentclientprotocol/sdk"; - import { VERSION } from "../version.js"; export type AcpSession = { diff --git a/src/agents/agent-paths.test.ts b/src/agents/agent-paths.test.ts index a19dfab95e1..f455f82862c 100644 --- a/src/agents/agent-paths.test.ts +++ b/src/agents/agent-paths.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, describe, expect, it } from "vitest"; - import { resolveOpenClawAgentDir } from "./agent-paths.js"; describe("resolveOpenClawAgentDir", () => { diff --git a/src/agents/agent-paths.ts b/src/agents/agent-paths.ts index d5ce3dd86f1..cfb874d3112 100644 --- a/src/agents/agent-paths.ts +++ b/src/agents/agent-paths.ts @@ -1,5 +1,4 @@ import path from "node:path"; - import { resolveStateDir } from "../config/paths.js"; import { DEFAULT_AGENT_ID } from "../routing/session-key.js"; import { resolveUserPath } from "../utils.js"; diff --git a/src/agents/agent-scope.ts b/src/agents/agent-scope.ts index 0d8c637c6bd..57237c4de55 100644 --- a/src/agents/agent-scope.ts +++ b/src/agents/agent-scope.ts @@ -1,6 +1,5 @@ import os from "node:os"; import path from "node:path"; - import type { OpenClawConfig } from "../config/config.js"; import { resolveStateDir } from "../config/paths.js"; import { diff --git a/src/agents/anthropic-payload-log.ts b/src/agents/anthropic-payload-log.ts index 415159ada1d..fbc0f254e72 100644 --- a/src/agents/anthropic-payload-log.ts +++ b/src/agents/anthropic-payload-log.ts @@ -1,14 +1,12 @@ +import type { AgentMessage, StreamFn } from "@mariozechner/pi-agent-core"; +import type { Api, Model } from "@mariozechner/pi-ai"; import crypto from "node:crypto"; import fs from "node:fs/promises"; import path from "node:path"; - -import type { AgentMessage, StreamFn } from "@mariozechner/pi-agent-core"; -import type { Api, Model } from "@mariozechner/pi-ai"; - import { resolveStateDir } from "../config/paths.js"; -import { parseBooleanValue } from "../utils/boolean.js"; -import { resolveUserPath } from "../utils.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; +import { resolveUserPath } from "../utils.js"; +import { parseBooleanValue } from "../utils/boolean.js"; type PayloadLogStage = "request" | "usage"; diff --git a/src/agents/anthropic.setup-token.live.test.ts b/src/agents/anthropic.setup-token.live.test.ts index 8ff3d6f33f9..6415bb79961 100644 --- a/src/agents/anthropic.setup-token.live.test.ts +++ b/src/agents/anthropic.setup-token.live.test.ts @@ -1,17 +1,15 @@ +import { type Api, completeSimple, type Model } from "@mariozechner/pi-ai"; import { randomUUID } from "node:crypto"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - -import { type Api, completeSimple, type Model } from "@mariozechner/pi-ai"; -import { discoverAuthStorage, discoverModels } from "./pi-model-discovery.js"; import { describe, expect, it } from "vitest"; -import { isTruthyEnvValue } from "../infra/env.js"; import { ANTHROPIC_SETUP_TOKEN_PREFIX, validateAnthropicSetupToken, } from "../commands/auth-token.js"; import { loadConfig } from "../config/config.js"; +import { isTruthyEnvValue } from "../infra/env.js"; import { resolveOpenClawAgentDir } from "./agent-paths.js"; import { type AuthProfileCredential, @@ -21,6 +19,7 @@ import { import { getApiKeyForModel, requireApiKey } from "./model-auth.js"; import { normalizeProviderId, parseModelRef } from "./model-selection.js"; import { ensureOpenClawModelsJson } from "./models-config.js"; +import { discoverAuthStorage, discoverModels } from "./pi-model-discovery.js"; const LIVE = isTruthyEnvValue(process.env.LIVE) || isTruthyEnvValue(process.env.OPENCLAW_LIVE_TEST); const SETUP_TOKEN_RAW = process.env.OPENCLAW_LIVE_SETUP_TOKEN?.trim() ?? ""; diff --git a/src/agents/apply-patch.test.ts b/src/agents/apply-patch.test.ts index 6ee1cb9a867..0e71fbc7c58 100644 --- a/src/agents/apply-patch.test.ts +++ b/src/agents/apply-patch.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { describe, expect, it } from "vitest"; - import { applyPatch } from "./apply-patch.js"; async function withTempDir(fn: (dir: string) => Promise) { diff --git a/src/agents/apply-patch.ts b/src/agents/apply-patch.ts index 275e6231878..ffce0d5055e 100644 --- a/src/agents/apply-patch.ts +++ b/src/agents/apply-patch.ts @@ -1,8 +1,8 @@ +import type { AgentTool } from "@mariozechner/pi-agent-core"; +import { Type } from "@sinclair/typebox"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; -import type { AgentTool } from "@mariozechner/pi-agent-core"; -import { Type } from "@sinclair/typebox"; import { applyUpdateHunk } from "./apply-patch-update.js"; import { assertSandboxPath } from "./sandbox-paths.js"; diff --git a/src/agents/auth-health.test.ts b/src/agents/auth-health.test.ts index 80b38a6c6f4..35b56303d70 100644 --- a/src/agents/auth-health.test.ts +++ b/src/agents/auth-health.test.ts @@ -1,5 +1,4 @@ import { afterEach, describe, expect, it, vi } from "vitest"; - import { buildAuthHealthSummary, DEFAULT_OAUTH_WARN_MS } from "./auth-health.js"; describe("buildAuthHealthSummary", () => { diff --git a/src/agents/auth-profiles.chutes.test.ts b/src/agents/auth-profiles.chutes.test.ts index 01affcdebf7..317ce9c771a 100644 --- a/src/agents/auth-profiles.chutes.test.ts +++ b/src/agents/auth-profiles.chutes.test.ts @@ -1,7 +1,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, describe, expect, it, vi } from "vitest"; import { type AuthProfileStore, diff --git a/src/agents/auth-profiles/doctor.ts b/src/agents/auth-profiles/doctor.ts index ee743a06000..cd79fed43ac 100644 --- a/src/agents/auth-profiles/doctor.ts +++ b/src/agents/auth-profiles/doctor.ts @@ -1,9 +1,9 @@ -import { formatCliCommand } from "../../cli/command-format.js"; import type { OpenClawConfig } from "../../config/config.js"; +import type { AuthProfileStore } from "./types.js"; +import { formatCliCommand } from "../../cli/command-format.js"; import { normalizeProviderId } from "../model-selection.js"; import { listProfilesForProvider } from "./profiles.js"; import { suggestOAuthProfileIdForLegacyDefault } from "./repair.js"; -import type { AuthProfileStore } from "./types.js"; export function formatAuthDoctorHint(params: { cfg?: OpenClawConfig; diff --git a/src/agents/auth-profiles/external-cli-sync.ts b/src/agents/auth-profiles/external-cli-sync.ts index 56ca400cf16..998e5dc3f01 100644 --- a/src/agents/auth-profiles/external-cli-sync.ts +++ b/src/agents/auth-profiles/external-cli-sync.ts @@ -1,3 +1,4 @@ +import type { AuthProfileCredential, AuthProfileStore, OAuthCredential } from "./types.js"; import { readQwenCliCredentialsCached, readMiniMaxCliCredentialsCached, @@ -9,7 +10,6 @@ import { MINIMAX_CLI_PROFILE_ID, log, } from "./constants.js"; -import type { AuthProfileCredential, AuthProfileStore, OAuthCredential } from "./types.js"; function shallowEqualOAuthCredentials(a: OAuthCredential | undefined, b: OAuthCredential): boolean { if (!a) { diff --git a/src/agents/auth-profiles/oauth.fallback-to-main-agent.test.ts b/src/agents/auth-profiles/oauth.fallback-to-main-agent.test.ts index 90197b991cc..9379d387913 100644 --- a/src/agents/auth-profiles/oauth.fallback-to-main-agent.test.ts +++ b/src/agents/auth-profiles/oauth.fallback-to-main-agent.test.ts @@ -1,10 +1,10 @@ import fs from "node:fs/promises"; -import path from "node:path"; import os from "node:os"; +import path from "node:path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import type { AuthProfileStore } from "./types.js"; import { resolveApiKeyForProfile } from "./oauth.js"; import { ensureAuthProfileStore } from "./store.js"; -import type { AuthProfileStore } from "./types.js"; describe("resolveApiKeyForProfile fallback to main agent", () => { const previousStateDir = process.env.OPENCLAW_STATE_DIR; diff --git a/src/agents/auth-profiles/oauth.ts b/src/agents/auth-profiles/oauth.ts index faeb063a438..bb5944a2f54 100644 --- a/src/agents/auth-profiles/oauth.ts +++ b/src/agents/auth-profiles/oauth.ts @@ -1,15 +1,14 @@ import { getOAuthApiKey, type OAuthCredentials } from "@mariozechner/pi-ai"; import lockfile from "proper-lockfile"; - import type { OpenClawConfig } from "../../config/config.js"; -import { refreshChutesTokens } from "../chutes-oauth.js"; +import type { AuthProfileStore } from "./types.js"; import { refreshQwenPortalCredentials } from "../../providers/qwen-portal-oauth.js"; +import { refreshChutesTokens } from "../chutes-oauth.js"; import { AUTH_STORE_LOCK_OPTIONS, log } from "./constants.js"; import { formatAuthDoctorHint } from "./doctor.js"; import { ensureAuthStoreFile, resolveAuthStorePath } from "./paths.js"; import { suggestOAuthProfileIdForLegacyDefault } from "./repair.js"; import { ensureAuthProfileStore, saveAuthProfileStore } from "./store.js"; -import type { AuthProfileStore } from "./types.js"; function buildOAuthApiKey(provider: string, credentials: OAuthCredentials): string { const needsProjectId = provider === "google-gemini-cli" || provider === "google-antigravity"; diff --git a/src/agents/auth-profiles/order.ts b/src/agents/auth-profiles/order.ts index 5f26f23f737..31b7814b5f3 100644 --- a/src/agents/auth-profiles/order.ts +++ b/src/agents/auth-profiles/order.ts @@ -1,7 +1,7 @@ import type { OpenClawConfig } from "../../config/config.js"; +import type { AuthProfileStore } from "./types.js"; import { normalizeProviderId } from "../model-selection.js"; import { listProfilesForProvider } from "./profiles.js"; -import type { AuthProfileStore } from "./types.js"; import { isProfileInCooldown } from "./usage.js"; function resolveProfileUnusableUntil(stats: { diff --git a/src/agents/auth-profiles/paths.ts b/src/agents/auth-profiles/paths.ts index 3b4ca0a69d8..edb795d126a 100644 --- a/src/agents/auth-profiles/paths.ts +++ b/src/agents/auth-profiles/paths.ts @@ -1,11 +1,10 @@ import fs from "node:fs"; import path from "node:path"; - +import type { AuthProfileStore } from "./types.js"; import { saveJsonFile } from "../../infra/json-file.js"; import { resolveUserPath } from "../../utils.js"; import { resolveOpenClawAgentDir } from "../agent-paths.js"; import { AUTH_PROFILE_FILENAME, AUTH_STORE_VERSION, LEGACY_AUTH_FILENAME } from "./constants.js"; -import type { AuthProfileStore } from "./types.js"; export function resolveAuthStorePath(agentDir?: string): string { const resolved = resolveUserPath(agentDir ?? resolveOpenClawAgentDir()); diff --git a/src/agents/auth-profiles/profiles.ts b/src/agents/auth-profiles/profiles.ts index ed9204e7bf2..94ce600fd7f 100644 --- a/src/agents/auth-profiles/profiles.ts +++ b/src/agents/auth-profiles/profiles.ts @@ -1,10 +1,10 @@ +import type { AuthProfileCredential, AuthProfileStore } from "./types.js"; import { normalizeProviderId } from "../model-selection.js"; import { ensureAuthProfileStore, saveAuthProfileStore, updateAuthProfileStoreWithLock, } from "./store.js"; -import type { AuthProfileCredential, AuthProfileStore } from "./types.js"; export async function setAuthProfileOrder(params: { agentDir?: string; diff --git a/src/agents/auth-profiles/repair.ts b/src/agents/auth-profiles/repair.ts index f7d2fa05832..f2ccf2ec612 100644 --- a/src/agents/auth-profiles/repair.ts +++ b/src/agents/auth-profiles/repair.ts @@ -1,8 +1,8 @@ import type { OpenClawConfig } from "../../config/config.js"; import type { AuthProfileConfig } from "../../config/types.js"; +import type { AuthProfileIdRepairResult, AuthProfileStore } from "./types.js"; import { normalizeProviderId } from "../model-selection.js"; import { listProfilesForProvider } from "./profiles.js"; -import type { AuthProfileIdRepairResult, AuthProfileStore } from "./types.js"; function getProfileSuffix(profileId: string): string { const idx = profileId.indexOf(":"); diff --git a/src/agents/auth-profiles/session-override.test.ts b/src/agents/auth-profiles/session-override.test.ts index 671053102bf..cae0d86f548 100644 --- a/src/agents/auth-profiles/session-override.test.ts +++ b/src/agents/auth-profiles/session-override.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import type { SessionEntry } from "../../config/sessions.js"; import { resolveSessionAuthProfileOverride } from "./session-override.js"; diff --git a/src/agents/auth-profiles/session-override.ts b/src/agents/auth-profiles/session-override.ts index 5ed395820c5..55cc34adbd7 100644 --- a/src/agents/auth-profiles/session-override.ts +++ b/src/agents/auth-profiles/session-override.ts @@ -1,11 +1,11 @@ import type { OpenClawConfig } from "../../config/config.js"; import { updateSessionStore, type SessionEntry } from "../../config/sessions.js"; -import { normalizeProviderId } from "../model-selection.js"; import { ensureAuthProfileStore, isProfileInCooldown, resolveAuthProfileOrder, } from "../auth-profiles.js"; +import { normalizeProviderId } from "../model-selection.js"; function isProfileForProvider(params: { provider: string; diff --git a/src/agents/auth-profiles/store.ts b/src/agents/auth-profiles/store.ts index c8a31622155..65c133384da 100644 --- a/src/agents/auth-profiles/store.ts +++ b/src/agents/auth-profiles/store.ts @@ -1,12 +1,12 @@ -import fs from "node:fs"; import type { OAuthCredentials } from "@mariozechner/pi-ai"; +import fs from "node:fs"; import lockfile from "proper-lockfile"; +import type { AuthProfileCredential, AuthProfileStore, ProfileUsageStats } from "./types.js"; import { resolveOAuthPath } from "../../config/paths.js"; import { loadJsonFile, saveJsonFile } from "../../infra/json-file.js"; import { AUTH_STORE_LOCK_OPTIONS, AUTH_STORE_VERSION, log } from "./constants.js"; import { syncExternalCliCredentials } from "./external-cli-sync.js"; import { ensureAuthStoreFile, resolveAuthStorePath, resolveLegacyAuthStorePath } from "./paths.js"; -import type { AuthProfileCredential, AuthProfileStore, ProfileUsageStats } from "./types.js"; type LegacyAuthStore = Record; diff --git a/src/agents/auth-profiles/types.ts b/src/agents/auth-profiles/types.ts index 216c977faa4..4d08d301d8a 100644 --- a/src/agents/auth-profiles/types.ts +++ b/src/agents/auth-profiles/types.ts @@ -1,5 +1,4 @@ import type { OAuthCredentials } from "@mariozechner/pi-ai"; - import type { OpenClawConfig } from "../../config/config.js"; export type ApiKeyCredential = { diff --git a/src/agents/auth-profiles/usage.ts b/src/agents/auth-profiles/usage.ts index 1839637d5d7..8028a7f08a9 100644 --- a/src/agents/auth-profiles/usage.ts +++ b/src/agents/auth-profiles/usage.ts @@ -1,7 +1,7 @@ import type { OpenClawConfig } from "../../config/config.js"; +import type { AuthProfileFailureReason, AuthProfileStore, ProfileUsageStats } from "./types.js"; import { normalizeProviderId } from "../model-selection.js"; import { saveAuthProfileStore, updateAuthProfileStoreWithLock } from "./store.js"; -import type { AuthProfileFailureReason, AuthProfileStore, ProfileUsageStats } from "./types.js"; function resolveProfileUnusableUntil(stats: ProfileUsageStats): number | null { const values = [stats.cooldownUntil, stats.disabledUntil] diff --git a/src/agents/bash-tools.exec.background-abort.test.ts b/src/agents/bash-tools.exec.background-abort.test.ts index 686a30217b5..a3d69f327f4 100644 --- a/src/agents/bash-tools.exec.background-abort.test.ts +++ b/src/agents/bash-tools.exec.background-abort.test.ts @@ -1,11 +1,10 @@ import { afterEach, expect, test } from "vitest"; - -import { createExecTool } from "./bash-tools.exec"; import { getFinishedSession, getSession, resetProcessRegistryForTests, } from "./bash-process-registry"; +import { createExecTool } from "./bash-tools.exec"; import { killProcessTree } from "./shell-utils"; const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); diff --git a/src/agents/bash-tools.exec.pty-fallback.test.ts b/src/agents/bash-tools.exec.pty-fallback.test.ts index 18455a1b164..8b4df5dd4e1 100644 --- a/src/agents/bash-tools.exec.pty-fallback.test.ts +++ b/src/agents/bash-tools.exec.pty-fallback.test.ts @@ -1,5 +1,4 @@ import { afterEach, expect, test, vi } from "vitest"; - import { resetProcessRegistryForTests } from "./bash-process-registry"; afterEach(() => { diff --git a/src/agents/bash-tools.exec.pty.test.ts b/src/agents/bash-tools.exec.pty.test.ts index 8ada2eccade..699e0ac65b6 100644 --- a/src/agents/bash-tools.exec.pty.test.ts +++ b/src/agents/bash-tools.exec.pty.test.ts @@ -1,7 +1,6 @@ import { afterEach, expect, test } from "vitest"; - -import { createExecTool } from "./bash-tools.exec"; import { resetProcessRegistryForTests } from "./bash-process-registry"; +import { createExecTool } from "./bash-tools.exec"; afterEach(() => { resetProcessRegistryForTests(); diff --git a/src/agents/bash-tools.exec.ts b/src/agents/bash-tools.exec.ts index 23fa6fd26b6..2f8b026ac4a 100644 --- a/src/agents/bash-tools.exec.ts +++ b/src/agents/bash-tools.exec.ts @@ -1,9 +1,9 @@ -import crypto from "node:crypto"; -import type { ChildProcessWithoutNullStreams } from "node:child_process"; -import path from "node:path"; import type { AgentTool, AgentToolResult } from "@mariozechner/pi-agent-core"; +import type { ChildProcessWithoutNullStreams } from "node:child_process"; import { Type } from "@sinclair/typebox"; - +import crypto from "node:crypto"; +import path from "node:path"; +import type { BashSandboxConfig } from "./bash-tools.shared.js"; import { type ExecAsk, type ExecHost, @@ -28,6 +28,7 @@ import { import { enqueueSystemEvent } from "../infra/system-events.js"; import { logInfo, logWarn } from "../logger.js"; import { formatSpawnError, spawnWithFallback } from "../process/spawn-utils.js"; +import { parseAgentSessionKey, resolveAgentIdFromSessionKey } from "../routing/session-key.js"; import { type ProcessSession, type SessionStdin, @@ -38,7 +39,6 @@ import { markExited, tail, } from "./bash-process-registry.js"; -import type { BashSandboxConfig } from "./bash-tools.shared.js"; import { buildDockerExecArgs, buildSandboxEnv, @@ -51,11 +51,10 @@ import { resolveWorkdir, truncateMiddle, } from "./bash-tools.shared.js"; +import { buildCursorPositionResponse, stripDsrRequests } from "./pty-dsr.js"; +import { getShellConfig, sanitizeBinaryOutput } from "./shell-utils.js"; import { callGatewayTool } from "./tools/gateway.js"; import { listNodes, resolveNodeIdFromList } from "./tools/nodes-utils.js"; -import { getShellConfig, sanitizeBinaryOutput } from "./shell-utils.js"; -import { buildCursorPositionResponse, stripDsrRequests } from "./pty-dsr.js"; -import { parseAgentSessionKey, resolveAgentIdFromSessionKey } from "../routing/session-key.js"; const DEFAULT_MAX_OUTPUT = clampNumber( readEnvInt("PI_BASH_MAX_OUTPUT_CHARS"), diff --git a/src/agents/bash-tools.process.send-keys.test.ts b/src/agents/bash-tools.process.send-keys.test.ts index 765265a300a..d12adbb2844 100644 --- a/src/agents/bash-tools.process.send-keys.test.ts +++ b/src/agents/bash-tools.process.send-keys.test.ts @@ -1,5 +1,4 @@ import { afterEach, expect, test } from "vitest"; - import { resetProcessRegistryForTests } from "./bash-process-registry"; import { createExecTool } from "./bash-tools.exec"; import { createProcessTool } from "./bash-tools.process"; diff --git a/src/agents/bash-tools.process.ts b/src/agents/bash-tools.process.ts index b498537b3be..d7222dc398c 100644 --- a/src/agents/bash-tools.process.ts +++ b/src/agents/bash-tools.process.ts @@ -1,6 +1,5 @@ import type { AgentTool } from "@mariozechner/pi-agent-core"; import { Type } from "@sinclair/typebox"; - import { deleteSession, drainSession, diff --git a/src/agents/bash-tools.shared.ts b/src/agents/bash-tools.shared.ts index d3965e8bc14..e0f68c613bd 100644 --- a/src/agents/bash-tools.shared.ts +++ b/src/agents/bash-tools.shared.ts @@ -3,7 +3,6 @@ import { existsSync, statSync } from "node:fs"; import fs from "node:fs/promises"; import { homedir } from "node:os"; import path from "node:path"; - import { sliceUtf16Safe } from "../utils.js"; import { assertSandboxPath } from "./sandbox-paths.js"; import { killProcessTree } from "./shell-utils.js"; diff --git a/src/agents/bash-tools.test.ts b/src/agents/bash-tools.test.ts index e0e6bce26e5..f4f2a938c43 100644 --- a/src/agents/bash-tools.test.ts +++ b/src/agents/bash-tools.test.ts @@ -1,6 +1,5 @@ import fs from "node:fs"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it } from "vitest"; import { peekSystemEvents, resetSystemEventsForTest } from "../infra/system-events.js"; import { getFinishedSession, resetProcessRegistryForTests } from "./bash-process-registry.js"; diff --git a/src/agents/bedrock-discovery.ts b/src/agents/bedrock-discovery.ts index 43411e42aee..7dd514a9c37 100644 --- a/src/agents/bedrock-discovery.ts +++ b/src/agents/bedrock-discovery.ts @@ -3,7 +3,6 @@ import { ListFoundationModelsCommand, type ListFoundationModelsCommandOutput, } from "@aws-sdk/client-bedrock"; - import type { BedrockDiscoveryConfig, ModelDefinitionConfig } from "../config/types.js"; const DEFAULT_REFRESH_INTERVAL_SECONDS = 3600; diff --git a/src/agents/bootstrap-files.test.ts b/src/agents/bootstrap-files.test.ts index 69892ff5835..4cf0941e6a2 100644 --- a/src/agents/bootstrap-files.test.ts +++ b/src/agents/bootstrap-files.test.ts @@ -1,14 +1,12 @@ import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it } from "vitest"; - -import { resolveBootstrapContextForRun, resolveBootstrapFilesForRun } from "./bootstrap-files.js"; -import { makeTempWorkspace } from "../test-helpers/workspace.js"; import { clearInternalHooks, registerInternalHook, type AgentBootstrapHookContext, } from "../hooks/internal-hooks.js"; +import { makeTempWorkspace } from "../test-helpers/workspace.js"; +import { resolveBootstrapContextForRun, resolveBootstrapFilesForRun } from "./bootstrap-files.js"; describe("resolveBootstrapFilesForRun", () => { beforeEach(() => clearInternalHooks()); diff --git a/src/agents/bootstrap-files.ts b/src/agents/bootstrap-files.ts index 99692c7ac67..30e825171e9 100644 --- a/src/agents/bootstrap-files.ts +++ b/src/agents/bootstrap-files.ts @@ -1,12 +1,12 @@ import type { OpenClawConfig } from "../config/config.js"; +import type { EmbeddedContextFile } from "./pi-embedded-helpers.js"; import { applyBootstrapHookOverrides } from "./bootstrap-hooks.js"; +import { buildBootstrapContextFiles, resolveBootstrapMaxChars } from "./pi-embedded-helpers.js"; import { filterBootstrapFilesForSession, loadWorkspaceBootstrapFiles, type WorkspaceBootstrapFile, } from "./workspace.js"; -import { buildBootstrapContextFiles, resolveBootstrapMaxChars } from "./pi-embedded-helpers.js"; -import type { EmbeddedContextFile } from "./pi-embedded-helpers.js"; export function makeBootstrapWarn(params: { sessionLabel: string; diff --git a/src/agents/bootstrap-hooks.test.ts b/src/agents/bootstrap-hooks.test.ts index dc6b54bfc21..46f61ea4bd8 100644 --- a/src/agents/bootstrap-hooks.test.ts +++ b/src/agents/bootstrap-hooks.test.ts @@ -1,11 +1,10 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest"; - -import { applyBootstrapHookOverrides } from "./bootstrap-hooks.js"; import { clearInternalHooks, registerInternalHook, type AgentBootstrapHookContext, } from "../hooks/internal-hooks.js"; +import { applyBootstrapHookOverrides } from "./bootstrap-hooks.js"; import { DEFAULT_SOUL_FILENAME, type WorkspaceBootstrapFile } from "./workspace.js"; function makeFile(name = DEFAULT_SOUL_FILENAME): WorkspaceBootstrapFile { diff --git a/src/agents/bootstrap-hooks.ts b/src/agents/bootstrap-hooks.ts index 4d5af077466..5662d2c6554 100644 --- a/src/agents/bootstrap-hooks.ts +++ b/src/agents/bootstrap-hooks.ts @@ -1,8 +1,8 @@ import type { OpenClawConfig } from "../config/config.js"; -import { createInternalHookEvent, triggerInternalHook } from "../hooks/internal-hooks.js"; import type { AgentBootstrapHookContext } from "../hooks/internal-hooks.js"; -import { resolveAgentIdFromSessionKey } from "../routing/session-key.js"; import type { WorkspaceBootstrapFile } from "./workspace.js"; +import { createInternalHookEvent, triggerInternalHook } from "../hooks/internal-hooks.js"; +import { resolveAgentIdFromSessionKey } from "../routing/session-key.js"; export async function applyBootstrapHookOverrides(params: { files: WorkspaceBootstrapFile[]; diff --git a/src/agents/cache-trace.test.ts b/src/agents/cache-trace.test.ts index 4d58b9f9146..c2aae1455b6 100644 --- a/src/agents/cache-trace.test.ts +++ b/src/agents/cache-trace.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { resolveUserPath } from "../utils.js"; import { createCacheTrace } from "./cache-trace.js"; diff --git a/src/agents/cache-trace.ts b/src/agents/cache-trace.ts index bde9ac7ccea..d27c81d1d3e 100644 --- a/src/agents/cache-trace.ts +++ b/src/agents/cache-trace.ts @@ -1,13 +1,11 @@ +import type { AgentMessage, StreamFn } from "@mariozechner/pi-agent-core"; import crypto from "node:crypto"; import fs from "node:fs/promises"; import path from "node:path"; - -import type { AgentMessage, StreamFn } from "@mariozechner/pi-agent-core"; - import type { OpenClawConfig } from "../config/config.js"; import { resolveStateDir } from "../config/paths.js"; -import { parseBooleanValue } from "../utils/boolean.js"; import { resolveUserPath } from "../utils.js"; +import { parseBooleanValue } from "../utils/boolean.js"; export type CacheTraceStage = | "session:loaded" diff --git a/src/agents/channel-tools.test.ts b/src/agents/channel-tools.test.ts index b2e9222745d..c9e125ab3ca 100644 --- a/src/agents/channel-tools.test.ts +++ b/src/agents/channel-tools.test.ts @@ -1,10 +1,9 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - -import type { OpenClawConfig } from "../config/config.js"; import type { ChannelPlugin } from "../channels/plugins/types.js"; +import type { OpenClawConfig } from "../config/config.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; -import { createTestRegistry } from "../test-utils/channel-plugins.js"; import { defaultRuntime } from "../runtime.js"; +import { createTestRegistry } from "../test-utils/channel-plugins.js"; import { __testing, listAllChannelSupportedActions } from "./channel-tools.js"; describe("channel tools", () => { diff --git a/src/agents/channel-tools.ts b/src/agents/channel-tools.ts index 30fdb1bbad1..b6b7c2dc0db 100644 --- a/src/agents/channel-tools.ts +++ b/src/agents/channel-tools.ts @@ -1,12 +1,12 @@ -import { getChannelDock } from "../channels/dock.js"; -import { getChannelPlugin, listChannelPlugins } from "../channels/plugins/index.js"; -import { normalizeAnyChannelId } from "../channels/registry.js"; import type { ChannelAgentTool, ChannelMessageActionName, ChannelPlugin, } from "../channels/plugins/types.js"; import type { OpenClawConfig } from "../config/config.js"; +import { getChannelDock } from "../channels/dock.js"; +import { getChannelPlugin, listChannelPlugins } from "../channels/plugins/index.js"; +import { normalizeAnyChannelId } from "../channels/registry.js"; import { defaultRuntime } from "../runtime.js"; /** diff --git a/src/agents/chutes-oauth.test.ts b/src/agents/chutes-oauth.test.ts index 55f90e4461e..5ac270699c9 100644 --- a/src/agents/chutes-oauth.test.ts +++ b/src/agents/chutes-oauth.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { CHUTES_TOKEN_ENDPOINT, CHUTES_USERINFO_ENDPOINT, diff --git a/src/agents/chutes-oauth.ts b/src/agents/chutes-oauth.ts index 8207e9dc858..63ba4e26cb8 100644 --- a/src/agents/chutes-oauth.ts +++ b/src/agents/chutes-oauth.ts @@ -1,6 +1,5 @@ -import { createHash, randomBytes } from "node:crypto"; - import type { OAuthCredentials } from "@mariozechner/pi-ai"; +import { createHash, randomBytes } from "node:crypto"; export const CHUTES_OAUTH_ISSUER = "https://api.chutes.ai"; export const CHUTES_AUTHORIZE_ENDPOINT = `${CHUTES_OAUTH_ISSUER}/idp/authorize`; diff --git a/src/agents/claude-cli-runner.test.ts b/src/agents/claude-cli-runner.test.ts index 6ec758e76b4..5cf82fe1e57 100644 --- a/src/agents/claude-cli-runner.test.ts +++ b/src/agents/claude-cli-runner.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import { runClaudeCliAgent } from "./claude-cli-runner.js"; const runCommandWithTimeoutMock = vi.fn(); diff --git a/src/agents/cli-credentials.test.ts b/src/agents/cli-credentials.test.ts index 18fbbf41a18..c6c9bb4816b 100644 --- a/src/agents/cli-credentials.test.ts +++ b/src/agents/cli-credentials.test.ts @@ -1,7 +1,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; const execSyncMock = vi.fn(); diff --git a/src/agents/cli-credentials.ts b/src/agents/cli-credentials.ts index 19a4fd4b56d..53b3352072e 100644 --- a/src/agents/cli-credentials.ts +++ b/src/agents/cli-credentials.ts @@ -1,10 +1,8 @@ +import type { OAuthCredentials, OAuthProvider } from "@mariozechner/pi-ai"; import { execSync } from "node:child_process"; import { createHash } from "node:crypto"; import fs from "node:fs"; import path from "node:path"; - -import type { OAuthCredentials, OAuthProvider } from "@mariozechner/pi-ai"; - import { loadJsonFile, saveJsonFile } from "../infra/json-file.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { resolveUserPath } from "../utils.js"; diff --git a/src/agents/cli-runner.test.ts b/src/agents/cli-runner.test.ts index ca3ea0b9081..2293648e2ec 100644 --- a/src/agents/cli-runner.test.ts +++ b/src/agents/cli-runner.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { CliBackendConfig } from "../config/types.js"; import { runCliAgent } from "./cli-runner.js"; import { cleanupSuspendedCliProcesses } from "./cli-runner/helpers.js"; diff --git a/src/agents/cli-runner.ts b/src/agents/cli-runner.ts index 910a9da00fc..4b4c108e410 100644 --- a/src/agents/cli-runner.ts +++ b/src/agents/cli-runner.ts @@ -1,13 +1,13 @@ import type { ImageContent } from "@mariozechner/pi-ai"; -import { resolveHeartbeatPrompt } from "../auto-reply/heartbeat.js"; import type { ThinkLevel } from "../auto-reply/thinking.js"; import type { OpenClawConfig } from "../config/config.js"; -import { isTruthyEnvValue } from "../infra/env.js"; +import type { EmbeddedPiRunResult } from "./pi-embedded-runner.js"; +import { resolveHeartbeatPrompt } from "../auto-reply/heartbeat.js"; import { shouldLogVerbose } from "../globals.js"; +import { isTruthyEnvValue } from "../infra/env.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { runCommandWithTimeout } from "../process/exec.js"; import { resolveUserPath } from "../utils.js"; -import { resolveOpenClawDocsPath } from "./docs-path.js"; import { resolveSessionAgentIds } from "./agent-scope.js"; import { makeBootstrapWarn, resolveBootstrapContextForRun } from "./bootstrap-files.js"; import { resolveCliBackendConfig } from "./cli-backends.js"; @@ -26,9 +26,9 @@ import { resolveSystemPromptUsage, writeCliImages, } from "./cli-runner/helpers.js"; +import { resolveOpenClawDocsPath } from "./docs-path.js"; import { FailoverError, resolveFailoverStatus } from "./failover-error.js"; import { classifyFailoverReason, isFailoverErrorMessage } from "./pi-embedded-helpers.js"; -import type { EmbeddedPiRunResult } from "./pi-embedded-runner.js"; const log = createSubsystemLogger("agent/claude-cli"); diff --git a/src/agents/cli-runner/helpers.ts b/src/agents/cli-runner/helpers.ts index 7a39eaa9740..f40fdd92d98 100644 --- a/src/agents/cli-runner/helpers.ts +++ b/src/agents/cli-runner/helpers.ts @@ -1,19 +1,18 @@ +import type { AgentTool } from "@mariozechner/pi-agent-core"; +import type { ImageContent } from "@mariozechner/pi-ai"; import crypto from "node:crypto"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - -import type { AgentTool } from "@mariozechner/pi-agent-core"; -import type { ImageContent } from "@mariozechner/pi-ai"; import type { ThinkLevel } from "../../auto-reply/thinking.js"; import type { OpenClawConfig } from "../../config/config.js"; import type { CliBackendConfig } from "../../config/types.js"; -import { runExec } from "../../process/exec.js"; import type { EmbeddedContextFile } from "../pi-embedded-helpers.js"; -import { buildSystemPromptParams } from "../system-prompt-params.js"; -import { resolveDefaultModelForAgent } from "../model-selection.js"; -import { buildAgentSystemPrompt } from "../system-prompt.js"; +import { runExec } from "../../process/exec.js"; import { buildTtsSystemPromptHint } from "../../tts/tts.js"; +import { resolveDefaultModelForAgent } from "../model-selection.js"; +import { buildSystemPromptParams } from "../system-prompt-params.js"; +import { buildAgentSystemPrompt } from "../system-prompt.js"; const CLI_RUN_QUEUE = new Map>(); diff --git a/src/agents/compaction.test.ts b/src/agents/compaction.test.ts index b2d3dac46d6..9663b8a520c 100644 --- a/src/agents/compaction.test.ts +++ b/src/agents/compaction.test.ts @@ -1,6 +1,5 @@ import type { AgentMessage } from "@mariozechner/pi-agent-core"; import { describe, expect, it } from "vitest"; - import { estimateMessagesTokens, pruneHistoryForContextShare, diff --git a/src/agents/compaction.ts b/src/agents/compaction.ts index 1cebfe28d90..baa101be8ef 100644 --- a/src/agents/compaction.ts +++ b/src/agents/compaction.ts @@ -1,7 +1,6 @@ import type { AgentMessage } from "@mariozechner/pi-agent-core"; import type { ExtensionContext } from "@mariozechner/pi-coding-agent"; import { estimateTokens, generateSummary } from "@mariozechner/pi-coding-agent"; - import { DEFAULT_CONTEXT_TOKENS } from "./defaults.js"; export const BASE_CHUNK_RATIO = 0.4; diff --git a/src/agents/context-window-guard.test.ts b/src/agents/context-window-guard.test.ts index 2225e2df0d8..e60c55b918a 100644 --- a/src/agents/context-window-guard.test.ts +++ b/src/agents/context-window-guard.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { CONTEXT_WINDOW_HARD_MIN_TOKENS, diff --git a/src/agents/docs-path.ts b/src/agents/docs-path.ts index 61fdfdabc3a..2227d3e7221 100644 --- a/src/agents/docs-path.ts +++ b/src/agents/docs-path.ts @@ -1,6 +1,5 @@ import fs from "node:fs"; import path from "node:path"; - import { resolveOpenClawPackageRoot } from "../infra/openclaw-root.js"; export async function resolveOpenClawDocsPath(params: { diff --git a/src/agents/identity-avatar.test.ts b/src/agents/identity-avatar.test.ts index 957f56b52c5..bb9404395f3 100644 --- a/src/agents/identity-avatar.test.ts +++ b/src/agents/identity-avatar.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { resolveAgentAvatar } from "./identity-avatar.js"; diff --git a/src/agents/identity-avatar.ts b/src/agents/identity-avatar.ts index f70e271a0be..1c9a822589d 100644 --- a/src/agents/identity-avatar.ts +++ b/src/agents/identity-avatar.ts @@ -1,6 +1,5 @@ import fs from "node:fs"; import path from "node:path"; - import type { OpenClawConfig } from "../config/config.js"; import { resolveUserPath } from "../utils.js"; import { resolveAgentWorkspaceDir } from "./agent-scope.js"; diff --git a/src/agents/identity-file.test.ts b/src/agents/identity-file.test.ts index 7ebad4114aa..b42806a7a8a 100644 --- a/src/agents/identity-file.test.ts +++ b/src/agents/identity-file.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { parseIdentityMarkdown } from "./identity-file.js"; describe("parseIdentityMarkdown", () => { diff --git a/src/agents/identity-file.ts b/src/agents/identity-file.ts index 8b9ca213992..5942589a2bf 100644 --- a/src/agents/identity-file.ts +++ b/src/agents/identity-file.ts @@ -1,6 +1,5 @@ import fs from "node:fs"; import path from "node:path"; - import { DEFAULT_IDENTITY_FILENAME } from "./workspace.js"; export type AgentIdentityFile = { diff --git a/src/agents/identity.test.ts b/src/agents/identity.test.ts index fcde19f6c85..c2fd298578a 100644 --- a/src/agents/identity.test.ts +++ b/src/agents/identity.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { resolveHumanDelayConfig } from "./identity.js"; diff --git a/src/agents/memory-search.test.ts b/src/agents/memory-search.test.ts index c3165815f27..538b1859866 100644 --- a/src/agents/memory-search.test.ts +++ b/src/agents/memory-search.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { resolveMemorySearchConfig } from "./memory-search.js"; describe("memory search config", () => { diff --git a/src/agents/memory-search.ts b/src/agents/memory-search.ts index 50f3f302ddb..658771a11b1 100644 --- a/src/agents/memory-search.ts +++ b/src/agents/memory-search.ts @@ -1,6 +1,5 @@ import os from "node:os"; import path from "node:path"; - import type { OpenClawConfig, MemorySearchConfig } from "../config/config.js"; import { resolveStateDir } from "../config/paths.js"; import { clampInt, clampNumber, resolveUserPath } from "../utils.js"; diff --git a/src/agents/model-auth.test.ts b/src/agents/model-auth.test.ts index d5ce433490a..4f12290b9d5 100644 --- a/src/agents/model-auth.test.ts +++ b/src/agents/model-auth.test.ts @@ -1,7 +1,7 @@ +import type { Api, Model } from "@mariozechner/pi-ai"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; -import type { Api, Model } from "@mariozechner/pi-ai"; import { describe, expect, it, vi } from "vitest"; const oauthFixture = { diff --git a/src/agents/model-auth.ts b/src/agents/model-auth.ts index e55cdd127ff..4a4b5702ccc 100644 --- a/src/agents/model-auth.ts +++ b/src/agents/model-auth.ts @@ -1,10 +1,9 @@ -import path from "node:path"; - import { type Api, getEnvApiKey, type Model } from "@mariozechner/pi-ai"; +import path from "node:path"; import type { OpenClawConfig } from "../config/config.js"; import type { ModelProviderAuthMode, ModelProviderConfig } from "../config/types.js"; -import { getShellEnvAppliedKeys } from "../infra/shell-env.js"; import { formatCliCommand } from "../cli/command-format.js"; +import { getShellEnvAppliedKeys } from "../infra/shell-env.js"; import { type AuthProfileStore, ensureAuthProfileStore, diff --git a/src/agents/model-catalog.test.ts b/src/agents/model-catalog.test.ts index bfdf09879b7..3e90d8ee488 100644 --- a/src/agents/model-catalog.test.ts +++ b/src/agents/model-catalog.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { __setModelCatalogImportForTest, diff --git a/src/agents/model-fallback.test.ts b/src/agents/model-fallback.test.ts index 497e08756c5..2b40307217a 100644 --- a/src/agents/model-fallback.test.ts +++ b/src/agents/model-fallback.test.ts @@ -3,7 +3,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import type { AuthProfileStore } from "./auth-profiles.js"; import { saveAuthProfileStore } from "./auth-profiles.js"; diff --git a/src/agents/model-fallback.ts b/src/agents/model-fallback.ts index 2ad35b3993e..c5ee529c433 100644 --- a/src/agents/model-fallback.ts +++ b/src/agents/model-fallback.ts @@ -1,4 +1,10 @@ import type { OpenClawConfig } from "../config/config.js"; +import type { FailoverReason } from "./pi-embedded-helpers.js"; +import { + ensureAuthProfileStore, + isProfileInCooldown, + resolveAuthProfileOrder, +} from "./auth-profiles.js"; import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "./defaults.js"; import { coerceToFailoverError, @@ -13,12 +19,6 @@ import { resolveConfiguredModelRef, resolveModelRefFromString, } from "./model-selection.js"; -import type { FailoverReason } from "./pi-embedded-helpers.js"; -import { - ensureAuthProfileStore, - isProfileInCooldown, - resolveAuthProfileOrder, -} from "./auth-profiles.js"; type ModelCandidate = { provider: string; diff --git a/src/agents/model-scan.test.ts b/src/agents/model-scan.test.ts index d694453242a..574ad51224a 100644 --- a/src/agents/model-scan.test.ts +++ b/src/agents/model-scan.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { scanOpenRouterModels } from "./model-scan.js"; function createFetchFixture(payload: unknown): typeof fetch { diff --git a/src/agents/model-selection.test.ts b/src/agents/model-selection.test.ts index 8d38d91a09a..532936b8c67 100644 --- a/src/agents/model-selection.test.ts +++ b/src/agents/model-selection.test.ts @@ -1,4 +1,5 @@ import { describe, it, expect, vi } from "vitest"; +import type { OpenClawConfig } from "../config/config.js"; import { parseModelRef, resolveModelRefFromString, @@ -7,7 +8,6 @@ import { normalizeProviderId, modelKey, } from "./model-selection.js"; -import type { OpenClawConfig } from "../config/config.js"; describe("model-selection", () => { describe("normalizeProviderId", () => { diff --git a/src/agents/model-selection.ts b/src/agents/model-selection.ts index 82a4537946d..2f169639176 100644 --- a/src/agents/model-selection.ts +++ b/src/agents/model-selection.ts @@ -1,8 +1,8 @@ import type { OpenClawConfig } from "../config/config.js"; import type { ModelCatalogEntry } from "./model-catalog.js"; -import { normalizeGoogleModelId } from "./models-config.providers.js"; import { resolveAgentModelPrimary } from "./agent-scope.js"; import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "./defaults.js"; +import { normalizeGoogleModelId } from "./models-config.providers.js"; export type ModelRef = { provider: string; diff --git a/src/agents/models-config.auto-injects-github-copilot-provider-token-is.test.ts b/src/agents/models-config.auto-injects-github-copilot-provider-token-is.test.ts index 360ad793499..199ba0ca89b 100644 --- a/src/agents/models-config.auto-injects-github-copilot-provider-token-is.test.ts +++ b/src/agents/models-config.auto-injects-github-copilot-provider-token-is.test.ts @@ -1,8 +1,8 @@ import fs from "node:fs/promises"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; import type { OpenClawConfig } from "../config/config.js"; +import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; async function withTempHome(fn: (home: string) => Promise): Promise { return withTempHomeBase(fn, { prefix: "openclaw-models-" }); diff --git a/src/agents/models-config.falls-back-default-baseurl-token-exchange-fails.test.ts b/src/agents/models-config.falls-back-default-baseurl-token-exchange-fails.test.ts index 71177858743..6f5371c5091 100644 --- a/src/agents/models-config.falls-back-default-baseurl-token-exchange-fails.test.ts +++ b/src/agents/models-config.falls-back-default-baseurl-token-exchange-fails.test.ts @@ -1,8 +1,8 @@ import fs from "node:fs/promises"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; import type { OpenClawConfig } from "../config/config.js"; +import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; async function withTempHome(fn: (home: string) => Promise): Promise { return withTempHomeBase(fn, { prefix: "openclaw-models-" }); diff --git a/src/agents/models-config.fills-missing-provider-apikey-from-env-var.test.ts b/src/agents/models-config.fills-missing-provider-apikey-from-env-var.test.ts index 35f8779b498..cafc01a4ebc 100644 --- a/src/agents/models-config.fills-missing-provider-apikey-from-env-var.test.ts +++ b/src/agents/models-config.fills-missing-provider-apikey-from-env-var.test.ts @@ -1,8 +1,8 @@ import fs from "node:fs/promises"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; import type { OpenClawConfig } from "../config/config.js"; +import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; async function withTempHome(fn: (home: string) => Promise): Promise { return withTempHomeBase(fn, { prefix: "openclaw-models-" }); diff --git a/src/agents/models-config.normalizes-gemini-3-ids-preview-google-providers.test.ts b/src/agents/models-config.normalizes-gemini-3-ids-preview-google-providers.test.ts index 765d5b4d6f7..d881a6acfad 100644 --- a/src/agents/models-config.normalizes-gemini-3-ids-preview-google-providers.test.ts +++ b/src/agents/models-config.normalizes-gemini-3-ids-preview-google-providers.test.ts @@ -1,8 +1,8 @@ import fs from "node:fs/promises"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; import type { OpenClawConfig } from "../config/config.js"; +import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; async function withTempHome(fn: (home: string) => Promise): Promise { return withTempHomeBase(fn, { prefix: "openclaw-models-" }); diff --git a/src/agents/models-config.providers.ollama.test.ts b/src/agents/models-config.providers.ollama.test.ts index d9e51c9c521..da7c3f373ec 100644 --- a/src/agents/models-config.providers.ollama.test.ts +++ b/src/agents/models-config.providers.ollama.test.ts @@ -1,8 +1,8 @@ +import { mkdtempSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; import { describe, expect, it } from "vitest"; import { resolveImplicitProviders } from "./models-config.providers.js"; -import { mkdtempSync } from "node:fs"; -import { join } from "node:path"; -import { tmpdir } from "node:os"; describe("Ollama provider", () => { it("should not include ollama when no API key is configured", async () => { diff --git a/src/agents/models-config.providers.ts b/src/agents/models-config.providers.ts index 471c4776528..6ad93813dd0 100644 --- a/src/agents/models-config.providers.ts +++ b/src/agents/models-config.providers.ts @@ -5,8 +5,8 @@ import { resolveCopilotApiToken, } from "../providers/github-copilot-token.js"; import { ensureAuthProfileStore, listProfilesForProvider } from "./auth-profiles.js"; -import { resolveAwsSdkEnvVarName, resolveEnvApiKey } from "./model-auth.js"; import { discoverBedrockModels } from "./bedrock-discovery.js"; +import { resolveAwsSdkEnvVarName, resolveEnvApiKey } from "./model-auth.js"; import { buildSyntheticModelDefinition, SYNTHETIC_BASE_URL, diff --git a/src/agents/models-config.skips-writing-models-json-no-env-token.test.ts b/src/agents/models-config.skips-writing-models-json-no-env-token.test.ts index 306622dca91..671a814a808 100644 --- a/src/agents/models-config.skips-writing-models-json-no-env-token.test.ts +++ b/src/agents/models-config.skips-writing-models-json-no-env-token.test.ts @@ -1,8 +1,8 @@ import fs from "node:fs/promises"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; import type { OpenClawConfig } from "../config/config.js"; +import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; async function withTempHome(fn: (home: string) => Promise): Promise { return withTempHomeBase(fn, { prefix: "openclaw-models-" }); diff --git a/src/agents/models-config.ts b/src/agents/models-config.ts index 8270a7a0c99..b322f7d6111 100644 --- a/src/agents/models-config.ts +++ b/src/agents/models-config.ts @@ -1,6 +1,5 @@ import fs from "node:fs/promises"; import path from "node:path"; - import { type OpenClawConfig, loadConfig } from "../config/config.js"; import { resolveOpenClawAgentDir } from "./agent-paths.js"; import { diff --git a/src/agents/models-config.uses-first-github-copilot-profile-env-tokens.test.ts b/src/agents/models-config.uses-first-github-copilot-profile-env-tokens.test.ts index fe5321d6482..3e321dc0b1f 100644 --- a/src/agents/models-config.uses-first-github-copilot-profile-env-tokens.test.ts +++ b/src/agents/models-config.uses-first-github-copilot-profile-env-tokens.test.ts @@ -1,8 +1,8 @@ import fs from "node:fs/promises"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; import type { OpenClawConfig } from "../config/config.js"; +import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; async function withTempHome(fn: (home: string) => Promise): Promise { return withTempHomeBase(fn, { prefix: "openclaw-models-" }); diff --git a/src/agents/models.profiles.live.test.ts b/src/agents/models.profiles.live.test.ts index 77ce14eb27e..accd8215f8f 100644 --- a/src/agents/models.profiles.live.test.ts +++ b/src/agents/models.profiles.live.test.ts @@ -1,5 +1,4 @@ import { type Api, completeSimple, type Model } from "@mariozechner/pi-ai"; -import { discoverAuthStorage, discoverModels } from "./pi-model-discovery.js"; import { Type } from "@sinclair/typebox"; import { describe, expect, it } from "vitest"; import { loadConfig } from "../config/config.js"; @@ -14,6 +13,7 @@ import { isModernModelRef } from "./live-model-filter.js"; import { getApiKeyForModel, requireApiKey } from "./model-auth.js"; import { ensureOpenClawModelsJson } from "./models-config.js"; import { isRateLimitErrorMessage } from "./pi-embedded-helpers/errors.js"; +import { discoverAuthStorage, discoverModels } from "./pi-model-discovery.js"; const LIVE = isTruthyEnvValue(process.env.LIVE) || isTruthyEnvValue(process.env.OPENCLAW_LIVE_TEST); const DIRECT_ENABLED = Boolean(process.env.OPENCLAW_LIVE_MODELS?.trim()); diff --git a/src/agents/openclaw-gateway-tool.test.ts b/src/agents/openclaw-gateway-tool.test.ts index 54b8301230b..2a038b5d512 100644 --- a/src/agents/openclaw-gateway-tool.test.ts +++ b/src/agents/openclaw-gateway-tool.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { describe, expect, it, vi } from "vitest"; - import "./test-helpers/fast-core-tools.js"; import { createOpenClawTools } from "./openclaw-tools.js"; diff --git a/src/agents/openclaw-tools.ts b/src/agents/openclaw-tools.ts index c93bbb85392..4604ae09752 100644 --- a/src/agents/openclaw-tools.ts +++ b/src/agents/openclaw-tools.ts @@ -1,11 +1,11 @@ import type { OpenClawConfig } from "../config/config.js"; -import { resolvePluginTools } from "../plugins/tools.js"; import type { GatewayMessageChannel } from "../utils/message-channel.js"; +import type { AnyAgentTool } from "./tools/common.js"; +import { resolvePluginTools } from "../plugins/tools.js"; import { resolveSessionAgentId } from "./agent-scope.js"; import { createAgentsListTool } from "./tools/agents-list-tool.js"; import { createBrowserTool } from "./tools/browser-tool.js"; import { createCanvasTool } from "./tools/canvas-tool.js"; -import type { AnyAgentTool } from "./tools/common.js"; import { createCronTool } from "./tools/cron-tool.js"; import { createGatewayTool } from "./tools/gateway-tool.js"; import { createImageTool } from "./tools/image-tool.js"; @@ -16,8 +16,8 @@ import { createSessionsHistoryTool } from "./tools/sessions-history-tool.js"; import { createSessionsListTool } from "./tools/sessions-list-tool.js"; import { createSessionsSendTool } from "./tools/sessions-send-tool.js"; import { createSessionsSpawnTool } from "./tools/sessions-spawn-tool.js"; -import { createWebFetchTool, createWebSearchTool } from "./tools/web-tools.js"; import { createTtsTool } from "./tools/tts-tool.js"; +import { createWebFetchTool, createWebSearchTool } from "./tools/web-tools.js"; export function createOpenClawTools(options?: { sandboxBrowserBridgeUrl?: string; diff --git a/src/agents/opencode-zen-models.test.ts b/src/agents/opencode-zen-models.test.ts index 19734a78da1..69c6a0497f3 100644 --- a/src/agents/opencode-zen-models.test.ts +++ b/src/agents/opencode-zen-models.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { getOpencodeZenStaticFallbackModels, OPENCODE_ZEN_MODEL_ALIASES, diff --git a/src/agents/pi-embedded-block-chunker.test.ts b/src/agents/pi-embedded-block-chunker.test.ts index ae48f384417..9af9f2c0b4e 100644 --- a/src/agents/pi-embedded-block-chunker.test.ts +++ b/src/agents/pi-embedded-block-chunker.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { EmbeddedBlockChunker } from "./pi-embedded-block-chunker.js"; describe("EmbeddedBlockChunker", () => { diff --git a/src/agents/pi-embedded-helpers.formatrawassistanterrorforui.test.ts b/src/agents/pi-embedded-helpers.formatrawassistanterrorforui.test.ts index 9dbadf7777d..137bf8536e3 100644 --- a/src/agents/pi-embedded-helpers.formatrawassistanterrorforui.test.ts +++ b/src/agents/pi-embedded-helpers.formatrawassistanterrorforui.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { formatRawAssistantErrorForUi } from "./pi-embedded-helpers.js"; describe("formatRawAssistantErrorForUi", () => { diff --git a/src/agents/pi-embedded-helpers.image-dimension-error.test.ts b/src/agents/pi-embedded-helpers.image-dimension-error.test.ts index d56f662a208..2c92ed68125 100644 --- a/src/agents/pi-embedded-helpers.image-dimension-error.test.ts +++ b/src/agents/pi-embedded-helpers.image-dimension-error.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { isImageDimensionErrorMessage, parseImageDimensionError } from "./pi-embedded-helpers.js"; describe("image dimension errors", () => { diff --git a/src/agents/pi-embedded-helpers.image-size-error.test.ts b/src/agents/pi-embedded-helpers.image-size-error.test.ts index 75b165d8d8c..d69a3c381ae 100644 --- a/src/agents/pi-embedded-helpers.image-size-error.test.ts +++ b/src/agents/pi-embedded-helpers.image-size-error.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { parseImageSizeError } from "./pi-embedded-helpers.js"; describe("parseImageSizeError", () => { diff --git a/src/agents/pi-embedded-helpers/bootstrap.ts b/src/agents/pi-embedded-helpers/bootstrap.ts index 9283c666a64..725324be9fb 100644 --- a/src/agents/pi-embedded-helpers/bootstrap.ts +++ b/src/agents/pi-embedded-helpers/bootstrap.ts @@ -1,8 +1,6 @@ +import type { AgentMessage } from "@mariozechner/pi-agent-core"; import fs from "node:fs/promises"; import path from "node:path"; - -import type { AgentMessage } from "@mariozechner/pi-agent-core"; - import type { OpenClawConfig } from "../../config/config.js"; import type { WorkspaceBootstrapFile } from "../workspace.js"; import type { EmbeddedContextFile } from "./types.js"; diff --git a/src/agents/pi-embedded-helpers/errors.ts b/src/agents/pi-embedded-helpers/errors.ts index 473628202c8..0df9ac02a2f 100644 --- a/src/agents/pi-embedded-helpers/errors.ts +++ b/src/agents/pi-embedded-helpers/errors.ts @@ -1,8 +1,7 @@ import type { AssistantMessage } from "@mariozechner/pi-ai"; - import type { OpenClawConfig } from "../../config/config.js"; -import { formatSandboxToolPolicyBlockedMessage } from "../sandbox.js"; import type { FailoverReason } from "./types.js"; +import { formatSandboxToolPolicyBlockedMessage } from "../sandbox.js"; export function isContextOverflowError(errorMessage?: string): boolean { if (!errorMessage) { diff --git a/src/agents/pi-embedded-helpers/images.ts b/src/agents/pi-embedded-helpers/images.ts index 1e4af24b0d5..9162bb812b4 100644 --- a/src/agents/pi-embedded-helpers/images.ts +++ b/src/agents/pi-embedded-helpers/images.ts @@ -1,5 +1,4 @@ import type { AgentMessage, AgentToolResult } from "@mariozechner/pi-agent-core"; - import type { ToolCallIdMode } from "../tool-call-id.js"; import { sanitizeToolCallIdsForCloudCodeAssist } from "../tool-call-id.js"; import { sanitizeContentBlocksImages } from "../tool-images.js"; diff --git a/src/agents/pi-embedded-runner-extraparams.live.test.ts b/src/agents/pi-embedded-runner-extraparams.live.test.ts index a272186dd07..44600c957b3 100644 --- a/src/agents/pi-embedded-runner-extraparams.live.test.ts +++ b/src/agents/pi-embedded-runner-extraparams.live.test.ts @@ -1,8 +1,8 @@ import type { Model } from "@mariozechner/pi-ai"; import { getModel, streamSimple } from "@mariozechner/pi-ai"; import { describe, expect, it } from "vitest"; -import { isTruthyEnvValue } from "../infra/env.js"; import type { OpenClawConfig } from "../config/config.js"; +import { isTruthyEnvValue } from "../infra/env.js"; import { applyExtraParamsToAgent } from "./pi-embedded-runner.js"; const OPENAI_KEY = process.env.OPENAI_API_KEY ?? ""; diff --git a/src/agents/pi-embedded-runner.applygoogleturnorderingfix.test.ts b/src/agents/pi-embedded-runner.applygoogleturnorderingfix.test.ts index f74ce5a3259..0ca26b54672 100644 --- a/src/agents/pi-embedded-runner.applygoogleturnorderingfix.test.ts +++ b/src/agents/pi-embedded-runner.applygoogleturnorderingfix.test.ts @@ -1,6 +1,6 @@ -import fs from "node:fs/promises"; import type { AgentMessage } from "@mariozechner/pi-agent-core"; import { SessionManager } from "@mariozechner/pi-coding-agent"; +import fs from "node:fs/promises"; import { describe, expect, it, vi } from "vitest"; import type { OpenClawConfig } from "../config/config.js"; import { ensureOpenClawModelsJson } from "./models-config.js"; diff --git a/src/agents/pi-embedded-runner.buildembeddedsandboxinfo.test.ts b/src/agents/pi-embedded-runner.buildembeddedsandboxinfo.test.ts index 8c94d1a9aa5..f5a29ec8eba 100644 --- a/src/agents/pi-embedded-runner.buildembeddedsandboxinfo.test.ts +++ b/src/agents/pi-embedded-runner.buildembeddedsandboxinfo.test.ts @@ -1,9 +1,9 @@ import fs from "node:fs/promises"; import { describe, expect, it, vi } from "vitest"; import type { OpenClawConfig } from "../config/config.js"; +import type { SandboxContext } from "./sandbox.js"; import { ensureOpenClawModelsJson } from "./models-config.js"; import { buildEmbeddedSandboxInfo } from "./pi-embedded-runner.js"; -import type { SandboxContext } from "./sandbox.js"; vi.mock("@mariozechner/pi-ai", async () => { const actual = await vi.importActual("@mariozechner/pi-ai"); diff --git a/src/agents/pi-embedded-runner.guard.test.ts b/src/agents/pi-embedded-runner.guard.test.ts index e9ccfa753c4..1a10d806c1f 100644 --- a/src/agents/pi-embedded-runner.guard.test.ts +++ b/src/agents/pi-embedded-runner.guard.test.ts @@ -1,7 +1,6 @@ import type { AgentMessage } from "@mariozechner/pi-agent-core"; import { SessionManager } from "@mariozechner/pi-coding-agent"; import { describe, expect, it } from "vitest"; - import { guardSessionManager } from "./session-tool-result-guard-wrapper.js"; import { sanitizeToolUseResultPairing } from "./session-transcript-repair.js"; diff --git a/src/agents/pi-embedded-runner.limithistoryturns.test.ts b/src/agents/pi-embedded-runner.limithistoryturns.test.ts index abff9de20a7..c5ce7979471 100644 --- a/src/agents/pi-embedded-runner.limithistoryturns.test.ts +++ b/src/agents/pi-embedded-runner.limithistoryturns.test.ts @@ -1,5 +1,5 @@ -import fs from "node:fs/promises"; import type { AgentMessage } from "@mariozechner/pi-agent-core"; +import fs from "node:fs/promises"; import { describe, expect, it, vi } from "vitest"; import type { OpenClawConfig } from "../config/config.js"; import { ensureOpenClawModelsJson } from "./models-config.js"; diff --git a/src/agents/pi-embedded-runner.run-embedded-pi-agent.auth-profile-rotation.test.ts b/src/agents/pi-embedded-runner.run-embedded-pi-agent.auth-profile-rotation.test.ts index 7621ab9d90b..51cfc40ac84 100644 --- a/src/agents/pi-embedded-runner.run-embedded-pi-agent.auth-profile-rotation.test.ts +++ b/src/agents/pi-embedded-runner.run-embedded-pi-agent.auth-profile-rotation.test.ts @@ -1,10 +1,8 @@ +import type { AssistantMessage } from "@mariozechner/pi-ai"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - -import type { AssistantMessage } from "@mariozechner/pi-ai"; import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import type { EmbeddedRunAttemptResult } from "./pi-embedded-runner/run/types.js"; diff --git a/src/agents/pi-embedded-runner.splitsdktools.test.ts b/src/agents/pi-embedded-runner.splitsdktools.test.ts index 3eb1b9ef23e..258d10b683c 100644 --- a/src/agents/pi-embedded-runner.splitsdktools.test.ts +++ b/src/agents/pi-embedded-runner.splitsdktools.test.ts @@ -1,5 +1,5 @@ -import fs from "node:fs/promises"; import type { AgentTool, AgentToolResult } from "@mariozechner/pi-agent-core"; +import fs from "node:fs/promises"; import { describe, expect, it, vi } from "vitest"; import type { OpenClawConfig } from "../config/config.js"; import { ensureOpenClawModelsJson } from "./models-config.js"; diff --git a/src/agents/pi-embedded-runner.test.ts b/src/agents/pi-embedded-runner.test.ts index 3e86deae12c..8db5994d99c 100644 --- a/src/agents/pi-embedded-runner.test.ts +++ b/src/agents/pi-embedded-runner.test.ts @@ -1,7 +1,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterAll, beforeAll, describe, expect, it, vi } from "vitest"; import "./test-helpers/fast-coding-tools.js"; import type { OpenClawConfig } from "../config/config.js"; diff --git a/src/agents/pi-embedded-runner/compact.ts b/src/agents/pi-embedded-runner/compact.ts index ac1fa1e6712..ea50e216534 100644 --- a/src/agents/pi-embedded-runner/compact.ts +++ b/src/agents/pi-embedded-runner/compact.ts @@ -1,6 +1,3 @@ -import fs from "node:fs/promises"; -import os from "node:os"; - import { createAgentSession, DefaultResourceLoader, @@ -8,27 +5,31 @@ import { SessionManager, SettingsManager, } from "@mariozechner/pi-coding-agent"; - -import { resolveHeartbeatPrompt } from "../../auto-reply/heartbeat.js"; +import fs from "node:fs/promises"; +import os from "node:os"; import type { ReasoningLevel, ThinkLevel } from "../../auto-reply/thinking.js"; -import { listChannelSupportedActions, resolveChannelMessageToolHints } from "../channel-tools.js"; -import { resolveChannelCapabilities } from "../../config/channel-capabilities.js"; import type { OpenClawConfig } from "../../config/config.js"; +import type { ExecElevatedDefaults } from "../bash-tools.js"; +import type { EmbeddedPiCompactResult } from "./types.js"; +import { resolveHeartbeatPrompt } from "../../auto-reply/heartbeat.js"; +import { resolveChannelCapabilities } from "../../config/channel-capabilities.js"; import { getMachineDisplayName } from "../../infra/machine-name.js"; +import { type enqueueCommand, enqueueCommandInLane } from "../../process/command-queue.js"; +import { isSubagentSessionKey } from "../../routing/session-key.js"; +import { resolveSignalReactionLevel } from "../../signal/reaction-level.js"; import { resolveTelegramInlineButtonsScope } from "../../telegram/inline-buttons.js"; import { resolveTelegramReactionLevel } from "../../telegram/reaction-level.js"; -import { resolveSignalReactionLevel } from "../../signal/reaction-level.js"; -import { type enqueueCommand, enqueueCommandInLane } from "../../process/command-queue.js"; -import { normalizeMessageChannel } from "../../utils/message-channel.js"; -import { isSubagentSessionKey } from "../../routing/session-key.js"; -import { isReasoningTagProvider } from "../../utils/provider-utils.js"; +import { buildTtsSystemPromptHint } from "../../tts/tts.js"; import { resolveUserPath } from "../../utils.js"; +import { normalizeMessageChannel } from "../../utils/message-channel.js"; +import { isReasoningTagProvider } from "../../utils/provider-utils.js"; import { resolveOpenClawAgentDir } from "../agent-paths.js"; import { resolveSessionAgentIds } from "../agent-scope.js"; import { makeBootstrapWarn, resolveBootstrapContextForRun } from "../bootstrap-files.js"; -import { resolveOpenClawDocsPath } from "../docs-path.js"; -import type { ExecElevatedDefaults } from "../bash-tools.js"; +import { listChannelSupportedActions, resolveChannelMessageToolHints } from "../channel-tools.js"; +import { formatUserTime, resolveUserTimeFormat, resolveUserTimezone } from "../date-time.js"; import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../defaults.js"; +import { resolveOpenClawDocsPath } from "../docs-path.js"; import { getApiKeyForModel, resolveModelAuthMode } from "../model-auth.js"; import { ensureOpenClawModelsJson } from "../models-config.js"; import { @@ -43,7 +44,6 @@ import { import { createOpenClawCodingTools } from "../pi-tools.js"; import { resolveSandboxContext } from "../sandbox.js"; import { guardSessionManager } from "../session-tool-result-guard-wrapper.js"; -import { resolveTranscriptPolicy } from "../transcript-policy.js"; import { acquireSessionWriteLock } from "../session-write-lock.js"; import { applySkillEnvOverrides, @@ -52,6 +52,7 @@ import { resolveSkillsPromptForRun, type SkillSnapshot, } from "../skills.js"; +import { resolveTranscriptPolicy } from "../transcript-policy.js"; import { buildEmbeddedExtensionPaths } from "./extensions.js"; import { logToolSchemasForGoogle, @@ -66,10 +67,7 @@ import { buildEmbeddedSandboxInfo } from "./sandbox-info.js"; import { prewarmSessionFile, trackSessionManagerAccess } from "./session-manager-cache.js"; import { buildEmbeddedSystemPrompt, createSystemPromptOverride } from "./system-prompt.js"; import { splitSdkTools } from "./tool-split.js"; -import type { EmbeddedPiCompactResult } from "./types.js"; -import { formatUserTime, resolveUserTimeFormat, resolveUserTimezone } from "../date-time.js"; import { describeUnknownError, mapThinkingLevel, resolveExecToolDefaults } from "./utils.js"; -import { buildTtsSystemPromptHint } from "../../tts/tts.js"; export type CompactEmbeddedPiSessionParams = { sessionId: string; diff --git a/src/agents/pi-embedded-runner/extensions.ts b/src/agents/pi-embedded-runner/extensions.ts index 26a40b2c58d..0364d880ca4 100644 --- a/src/agents/pi-embedded-runner/extensions.ts +++ b/src/agents/pi-embedded-runner/extensions.ts @@ -1,9 +1,7 @@ -import path from "node:path"; -import { fileURLToPath } from "node:url"; - import type { Api, Model } from "@mariozechner/pi-ai"; import type { SessionManager } from "@mariozechner/pi-coding-agent"; - +import path from "node:path"; +import { fileURLToPath } from "node:url"; import type { OpenClawConfig } from "../../config/config.js"; import { resolveContextWindowInfo } from "../context-window-guard.js"; import { DEFAULT_CONTEXT_TOKENS } from "../defaults.js"; diff --git a/src/agents/pi-embedded-runner/extra-params.ts b/src/agents/pi-embedded-runner/extra-params.ts index 911c67565c3..f2a3e1935d5 100644 --- a/src/agents/pi-embedded-runner/extra-params.ts +++ b/src/agents/pi-embedded-runner/extra-params.ts @@ -1,7 +1,6 @@ import type { StreamFn } from "@mariozechner/pi-agent-core"; import type { SimpleStreamOptions } from "@mariozechner/pi-ai"; import { streamSimple } from "@mariozechner/pi-ai"; - import type { OpenClawConfig } from "../../config/config.js"; import { log } from "./logger.js"; diff --git a/src/agents/pi-embedded-runner/google.test.ts b/src/agents/pi-embedded-runner/google.test.ts index ed872ce5790..30c8c7f8da6 100644 --- a/src/agents/pi-embedded-runner/google.test.ts +++ b/src/agents/pi-embedded-runner/google.test.ts @@ -1,6 +1,5 @@ -import { describe, expect, it } from "vitest"; - import type { AgentTool } from "@mariozechner/pi-agent-core"; +import { describe, expect, it } from "vitest"; import { sanitizeToolsForGoogle } from "./google.js"; describe("sanitizeToolsForGoogle", () => { diff --git a/src/agents/pi-embedded-runner/google.ts b/src/agents/pi-embedded-runner/google.ts index 764772fe3c4..5bfdaf8662b 100644 --- a/src/agents/pi-embedded-runner/google.ts +++ b/src/agents/pi-embedded-runner/google.ts @@ -1,9 +1,8 @@ -import { EventEmitter } from "node:events"; - import type { AgentMessage, AgentTool } from "@mariozechner/pi-agent-core"; -import type { TSchema } from "@sinclair/typebox"; import type { SessionManager } from "@mariozechner/pi-coding-agent"; - +import type { TSchema } from "@sinclair/typebox"; +import { EventEmitter } from "node:events"; +import type { TranscriptPolicy } from "../transcript-policy.js"; import { registerUnhandledRejectionHandler } from "../../infra/unhandled-rejections.js"; import { downgradeOpenAIReasoningBlocks, @@ -12,12 +11,11 @@ import { sanitizeGoogleTurnOrdering, sanitizeSessionMessagesImages, } from "../pi-embedded-helpers.js"; +import { cleanToolSchemaForGemini } from "../pi-tools.schema.js"; import { sanitizeToolUseResultPairing } from "../session-transcript-repair.js"; +import { resolveTranscriptPolicy } from "../transcript-policy.js"; import { log } from "./logger.js"; import { describeUnknownError } from "./utils.js"; -import { cleanToolSchemaForGemini } from "../pi-tools.schema.js"; -import type { TranscriptPolicy } from "../transcript-policy.js"; -import { resolveTranscriptPolicy } from "../transcript-policy.js"; const GOOGLE_TURN_ORDERING_CUSTOM_TYPE = "google-turn-ordering-bootstrap"; const GOOGLE_SCHEMA_UNSUPPORTED_KEYWORDS = new Set([ diff --git a/src/agents/pi-embedded-runner/history.ts b/src/agents/pi-embedded-runner/history.ts index 5ece1a8f2f1..e34ee4ab892 100644 --- a/src/agents/pi-embedded-runner/history.ts +++ b/src/agents/pi-embedded-runner/history.ts @@ -1,5 +1,4 @@ import type { AgentMessage } from "@mariozechner/pi-agent-core"; - import type { OpenClawConfig } from "../../config/config.js"; const THREAD_SUFFIX_REGEX = /^(.*)(?::(?:thread|topic):\d+)$/i; diff --git a/src/agents/pi-embedded-runner/model.ts b/src/agents/pi-embedded-runner/model.ts index 315cd735298..7d8c21ed564 100644 --- a/src/agents/pi-embedded-runner/model.ts +++ b/src/agents/pi-embedded-runner/model.ts @@ -1,17 +1,16 @@ import type { Api, Model } from "@mariozechner/pi-ai"; -import { - discoverAuthStorage, - discoverModels, - type AuthStorage, - type ModelRegistry, -} from "../pi-model-discovery.js"; - import type { OpenClawConfig } from "../../config/config.js"; import type { ModelDefinitionConfig } from "../../config/types.js"; import { resolveOpenClawAgentDir } from "../agent-paths.js"; import { DEFAULT_CONTEXT_TOKENS } from "../defaults.js"; import { normalizeModelCompat } from "../model-compat.js"; import { normalizeProviderId } from "../model-selection.js"; +import { + discoverAuthStorage, + discoverModels, + type AuthStorage, + type ModelRegistry, +} from "../pi-model-discovery.js"; type InlineModelEntry = ModelDefinitionConfig & { provider: string; baseUrl?: string }; type InlineProviderConfig = { diff --git a/src/agents/pi-embedded-runner/run.overflow-compaction.test.ts b/src/agents/pi-embedded-runner/run.overflow-compaction.test.ts index 8865eb2ded0..802c5edc0bf 100644 --- a/src/agents/pi-embedded-runner/run.overflow-compaction.test.ts +++ b/src/agents/pi-embedded-runner/run.overflow-compaction.test.ts @@ -145,12 +145,11 @@ vi.mock("../pi-embedded-helpers.js", async () => { }; }); -import { runEmbeddedPiAgent } from "./run.js"; -import { runEmbeddedAttempt } from "./run/attempt.js"; +import type { EmbeddedRunAttemptResult } from "./run/types.js"; import { compactEmbeddedPiSessionDirect } from "./compact.js"; import { log } from "./logger.js"; - -import type { EmbeddedRunAttemptResult } from "./run/types.js"; +import { runEmbeddedPiAgent } from "./run.js"; +import { runEmbeddedAttempt } from "./run/attempt.js"; const mockedRunEmbeddedAttempt = vi.mocked(runEmbeddedAttempt); const mockedCompactDirect = vi.mocked(compactEmbeddedPiSessionDirect); diff --git a/src/agents/pi-embedded-runner/run.ts b/src/agents/pi-embedded-runner/run.ts index 7f571e4a32f..e7c9ad44a61 100644 --- a/src/agents/pi-embedded-runner/run.ts +++ b/src/agents/pi-embedded-runner/run.ts @@ -1,5 +1,7 @@ import fs from "node:fs/promises"; import type { ThinkLevel } from "../../auto-reply/thinking.js"; +import type { RunEmbeddedPiAgentParams } from "./run/params.js"; +import type { EmbeddedPiAgentMeta, EmbeddedPiRunResult } from "./types.js"; import { enqueueCommandInLane } from "../../process/command-queue.js"; import { resolveUserPath } from "../../utils.js"; import { isMarkdownCapableMessageChannel } from "../../utils/message-channel.js"; @@ -42,15 +44,12 @@ import { type FailoverReason, } from "../pi-embedded-helpers.js"; import { normalizeUsage, type UsageLike } from "../usage.js"; - import { compactEmbeddedPiSessionDirect } from "./compact.js"; import { resolveGlobalLane, resolveSessionLane } from "./lanes.js"; import { log } from "./logger.js"; import { resolveModel } from "./model.js"; import { runEmbeddedAttempt } from "./run/attempt.js"; -import type { RunEmbeddedPiAgentParams } from "./run/params.js"; import { buildEmbeddedRunPayloads } from "./run/payloads.js"; -import type { EmbeddedPiAgentMeta, EmbeddedPiRunResult } from "./types.js"; import { describeUnknownError } from "./utils.js"; type ApiKeyInfo = ResolvedProviderAuth; diff --git a/src/agents/pi-embedded-runner/run/attempt.test.ts b/src/agents/pi-embedded-runner/run/attempt.test.ts index c94c657365a..0b5da8979c7 100644 --- a/src/agents/pi-embedded-runner/run/attempt.test.ts +++ b/src/agents/pi-embedded-runner/run/attempt.test.ts @@ -1,7 +1,6 @@ import type { AgentMessage } from "@mariozechner/pi-agent-core"; import type { ImageContent } from "@mariozechner/pi-ai"; import { describe, expect, it } from "vitest"; - import { injectHistoryImagesIntoMessages } from "./attempt.js"; describe("injectHistoryImagesIntoMessages", () => { diff --git a/src/agents/pi-embedded-runner/run/attempt.ts b/src/agents/pi-embedded-runner/run/attempt.ts index 692401da92c..a839c10a08b 100644 --- a/src/agents/pi-embedded-runner/run/attempt.ts +++ b/src/agents/pi-embedded-runner/run/attempt.ts @@ -1,6 +1,3 @@ -import fs from "node:fs/promises"; -import os from "node:os"; - import type { AgentMessage } from "@mariozechner/pi-agent-core"; import type { ImageContent } from "@mariozechner/pi-ai"; import { streamSimple } from "@mariozechner/pi-ai"; @@ -10,28 +7,35 @@ import { SessionManager, SettingsManager, } from "@mariozechner/pi-coding-agent"; - +import fs from "node:fs/promises"; +import os from "node:os"; +import type { EmbeddedRunAttemptParams, EmbeddedRunAttemptResult } from "./types.js"; import { resolveHeartbeatPrompt } from "../../../auto-reply/heartbeat.js"; +import { resolveChannelCapabilities } from "../../../config/channel-capabilities.js"; +import { getMachineDisplayName } from "../../../infra/machine-name.js"; +import { MAX_IMAGE_BYTES } from "../../../media/constants.js"; +import { getGlobalHookRunner } from "../../../plugins/hook-runner-global.js"; +import { isSubagentSessionKey } from "../../../routing/session-key.js"; +import { resolveSignalReactionLevel } from "../../../signal/reaction-level.js"; +import { resolveTelegramInlineButtonsScope } from "../../../telegram/inline-buttons.js"; +import { resolveTelegramReactionLevel } from "../../../telegram/reaction-level.js"; +import { buildTtsSystemPromptHint } from "../../../tts/tts.js"; +import { resolveUserPath } from "../../../utils.js"; +import { normalizeMessageChannel } from "../../../utils/message-channel.js"; +import { isReasoningTagProvider } from "../../../utils/provider-utils.js"; +import { resolveOpenClawAgentDir } from "../../agent-paths.js"; +import { resolveSessionAgentIds } from "../../agent-scope.js"; +import { createAnthropicPayloadLogger } from "../../anthropic-payload-log.js"; +import { makeBootstrapWarn, resolveBootstrapContextForRun } from "../../bootstrap-files.js"; +import { createCacheTrace } from "../../cache-trace.js"; import { listChannelSupportedActions, resolveChannelMessageToolHints, } from "../../channel-tools.js"; -import { resolveChannelCapabilities } from "../../../config/channel-capabilities.js"; -import { getMachineDisplayName } from "../../../infra/machine-name.js"; -import { resolveTelegramInlineButtonsScope } from "../../../telegram/inline-buttons.js"; -import { resolveTelegramReactionLevel } from "../../../telegram/reaction-level.js"; -import { resolveSignalReactionLevel } from "../../../signal/reaction-level.js"; -import { normalizeMessageChannel } from "../../../utils/message-channel.js"; -import { isReasoningTagProvider } from "../../../utils/provider-utils.js"; -import { isSubagentSessionKey } from "../../../routing/session-key.js"; -import { resolveUserPath } from "../../../utils.js"; -import { createCacheTrace } from "../../cache-trace.js"; -import { createAnthropicPayloadLogger } from "../../anthropic-payload-log.js"; -import { resolveOpenClawAgentDir } from "../../agent-paths.js"; -import { resolveSessionAgentIds } from "../../agent-scope.js"; -import { makeBootstrapWarn, resolveBootstrapContextForRun } from "../../bootstrap-files.js"; import { resolveOpenClawDocsPath } from "../../docs-path.js"; +import { isTimeoutError } from "../../failover-error.js"; import { resolveModelAuthMode } from "../../model-auth.js"; +import { resolveDefaultModelForAgent } from "../../model-selection.js"; import { isCloudCodeAssistFormatError, resolveBootstrapMaxChars, @@ -43,10 +47,11 @@ import { ensurePiCompactionReserveTokens, resolveCompactionReserveTokensFloor, } from "../../pi-settings.js"; +import { toClientToolDefinitions } from "../../pi-tool-definition-adapter.js"; import { createOpenClawCodingTools } from "../../pi-tools.js"; import { resolveSandboxContext } from "../../sandbox.js"; +import { resolveSandboxRuntimeStatus } from "../../sandbox/runtime-status.js"; import { guardSessionManager } from "../../session-tool-result-guard-wrapper.js"; -import { resolveTranscriptPolicy } from "../../transcript-policy.js"; import { acquireSessionWriteLock } from "../../session-write-lock.js"; import { applySkillEnvOverrides, @@ -54,14 +59,14 @@ import { loadWorkspaceSkillEntries, resolveSkillsPromptForRun, } from "../../skills.js"; -import { DEFAULT_BOOTSTRAP_FILENAME } from "../../workspace.js"; +import { buildSystemPromptParams } from "../../system-prompt-params.js"; import { buildSystemPromptReport } from "../../system-prompt-report.js"; -import { resolveDefaultModelForAgent } from "../../model-selection.js"; - +import { resolveTranscriptPolicy } from "../../transcript-policy.js"; +import { DEFAULT_BOOTSTRAP_FILENAME } from "../../workspace.js"; import { isAbortError } from "../abort.js"; +import { appendCacheTtlTimestamp, isCacheTtlEligibleProvider } from "../cache-ttl.js"; import { buildEmbeddedExtensionPaths } from "../extensions.js"; import { applyExtraParamsToAgent } from "../extra-params.js"; -import { appendCacheTtlTimestamp, isCacheTtlEligibleProvider } from "../cache-ttl.js"; import { logToolSchemasForGoogle, sanitizeSessionHistory, @@ -80,15 +85,7 @@ import { prewarmSessionFile, trackSessionManagerAccess } from "../session-manage import { prepareSessionManagerForRun } from "../session-manager-init.js"; import { buildEmbeddedSystemPrompt, createSystemPromptOverride } from "../system-prompt.js"; import { splitSdkTools } from "../tool-split.js"; -import { toClientToolDefinitions } from "../../pi-tool-definition-adapter.js"; -import { buildSystemPromptParams } from "../../system-prompt-params.js"; import { describeUnknownError, mapThinkingLevel } from "../utils.js"; -import { resolveSandboxRuntimeStatus } from "../../sandbox/runtime-status.js"; -import { buildTtsSystemPromptHint } from "../../../tts/tts.js"; -import { isTimeoutError } from "../../failover-error.js"; -import { getGlobalHookRunner } from "../../../plugins/hook-runner-global.js"; -import { MAX_IMAGE_BYTES } from "../../../media/constants.js"; -import type { EmbeddedRunAttemptParams, EmbeddedRunAttemptResult } from "./types.js"; import { detectAndLoadPromptImages } from "./images.js"; export function injectHistoryImagesIntoMessages( diff --git a/src/agents/pi-embedded-runner/run/images.test.ts b/src/agents/pi-embedded-runner/run/images.test.ts index 71c0d91c99c..e37846e83a1 100644 --- a/src/agents/pi-embedded-runner/run/images.test.ts +++ b/src/agents/pi-embedded-runner/run/images.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { detectAndLoadPromptImages, detectImageReferences, modelSupportsImages } from "./images.js"; describe("detectImageReferences", () => { diff --git a/src/agents/pi-embedded-runner/run/images.ts b/src/agents/pi-embedded-runner/run/images.ts index 9cd32940da8..4bd6a35ba02 100644 --- a/src/agents/pi-embedded-runner/run/images.ts +++ b/src/agents/pi-embedded-runner/run/images.ts @@ -1,14 +1,12 @@ +import type { ImageContent } from "@mariozechner/pi-ai"; import fs from "node:fs/promises"; import path from "node:path"; import { fileURLToPath } from "node:url"; - -import type { ImageContent } from "@mariozechner/pi-ai"; - +import { extractTextFromMessage } from "../../../tui/tui-formatters.js"; +import { resolveUserPath } from "../../../utils.js"; +import { loadWebMedia } from "../../../web/media.js"; import { assertSandboxPath } from "../../sandbox-paths.js"; import { sanitizeImageBlocks } from "../../tool-images.js"; -import { extractTextFromMessage } from "../../../tui/tui-formatters.js"; -import { loadWebMedia } from "../../../web/media.js"; -import { resolveUserPath } from "../../../utils.js"; import { log } from "../logger.js"; /** diff --git a/src/agents/pi-embedded-runner/run/params.ts b/src/agents/pi-embedded-runner/run/params.ts index ac5753bf6d7..d98a425f403 100644 --- a/src/agents/pi-embedded-runner/run/params.ts +++ b/src/agents/pi-embedded-runner/run/params.ts @@ -1,7 +1,7 @@ import type { ImageContent } from "@mariozechner/pi-ai"; import type { ReasoningLevel, ThinkLevel, VerboseLevel } from "../../../auto-reply/thinking.js"; -import type { OpenClawConfig } from "../../../config/config.js"; import type { AgentStreamParams } from "../../../commands/agent/types.js"; +import type { OpenClawConfig } from "../../../config/config.js"; import type { enqueueCommand } from "../../../process/command-queue.js"; import type { ExecElevatedDefaults, ExecToolDefaults } from "../../bash-tools.js"; import type { BlockReplyChunking, ToolResultFormat } from "../../pi-embedded-subscribe.js"; diff --git a/src/agents/pi-embedded-runner/run/payloads.ts b/src/agents/pi-embedded-runner/run/payloads.ts index bc4263d51c5..7f58a2c3d62 100644 --- a/src/agents/pi-embedded-runner/run/payloads.ts +++ b/src/agents/pi-embedded-runner/run/payloads.ts @@ -1,9 +1,10 @@ import type { AssistantMessage } from "@mariozechner/pi-ai"; -import { parseReplyDirectives } from "../../../auto-reply/reply/reply-directives.js"; import type { ReasoningLevel, VerboseLevel } from "../../../auto-reply/thinking.js"; +import type { OpenClawConfig } from "../../../config/config.js"; +import type { ToolResultFormat } from "../../pi-embedded-subscribe.js"; +import { parseReplyDirectives } from "../../../auto-reply/reply/reply-directives.js"; import { isSilentReplyText, SILENT_REPLY_TOKEN } from "../../../auto-reply/tokens.js"; import { formatToolAggregate } from "../../../auto-reply/tool-meta.js"; -import type { OpenClawConfig } from "../../../config/config.js"; import { formatAssistantErrorText, formatRawAssistantErrorForUi, @@ -16,7 +17,6 @@ import { extractAssistantThinking, formatReasoningMessage, } from "../../pi-embedded-utils.js"; -import type { ToolResultFormat } from "../../pi-embedded-subscribe.js"; type ToolMetaEntry = { toolName: string; meta?: string }; diff --git a/src/agents/pi-embedded-runner/run/types.ts b/src/agents/pi-embedded-runner/run/types.ts index 3205b62938a..471f4111c34 100644 --- a/src/agents/pi-embedded-runner/run/types.ts +++ b/src/agents/pi-embedded-runner/run/types.ts @@ -1,15 +1,14 @@ import type { AgentMessage } from "@mariozechner/pi-agent-core"; import type { Api, AssistantMessage, ImageContent, Model } from "@mariozechner/pi-ai"; -import type { AuthStorage, ModelRegistry } from "../../pi-model-discovery.js"; - import type { ReasoningLevel, ThinkLevel, VerboseLevel } from "../../../auto-reply/thinking.js"; -import type { OpenClawConfig } from "../../../config/config.js"; import type { AgentStreamParams } from "../../../commands/agent/types.js"; +import type { OpenClawConfig } from "../../../config/config.js"; +import type { SessionSystemPromptReport } from "../../../config/sessions/types.js"; import type { ExecElevatedDefaults, ExecToolDefaults } from "../../bash-tools.js"; import type { MessagingToolSend } from "../../pi-embedded-messaging.js"; import type { BlockReplyChunking, ToolResultFormat } from "../../pi-embedded-subscribe.js"; +import type { AuthStorage, ModelRegistry } from "../../pi-model-discovery.js"; import type { SkillSnapshot } from "../../skills.js"; -import type { SessionSystemPromptReport } from "../../../config/sessions/types.js"; import type { ClientToolDefinition } from "./params.js"; export type EmbeddedRunAttemptParams = { diff --git a/src/agents/pi-embedded-runner/session-manager-cache.ts b/src/agents/pi-embedded-runner/session-manager-cache.ts index 4d81086c0f1..99dd340496f 100644 --- a/src/agents/pi-embedded-runner/session-manager-cache.ts +++ b/src/agents/pi-embedded-runner/session-manager-cache.ts @@ -1,6 +1,5 @@ import { Buffer } from "node:buffer"; import fs from "node:fs/promises"; - import { isCacheEnabled, resolveCacheTtlMs } from "../../config/cache-utils.js"; type SessionManagerCacheEntry = { diff --git a/src/agents/pi-embedded-runner/system-prompt.ts b/src/agents/pi-embedded-runner/system-prompt.ts index c452e1f0590..16ff41db7bf 100644 --- a/src/agents/pi-embedded-runner/system-prompt.ts +++ b/src/agents/pi-embedded-runner/system-prompt.ts @@ -1,10 +1,10 @@ import type { AgentTool } from "@mariozechner/pi-agent-core"; import type { ResolvedTimeFormat } from "../date-time.js"; import type { EmbeddedContextFile } from "../pi-embedded-helpers.js"; -import { buildAgentSystemPrompt, type PromptMode } from "../system-prompt.js"; -import { buildToolSummaryMap } from "../tool-summaries.js"; import type { EmbeddedSandboxInfo } from "./types.js"; import type { ReasoningLevel, ThinkLevel } from "./utils.js"; +import { buildAgentSystemPrompt, type PromptMode } from "../system-prompt.js"; +import { buildToolSummaryMap } from "../tool-summaries.js"; export function buildEmbeddedSystemPrompt(params: { workspaceDir: string; diff --git a/src/agents/pi-embedded-runner/tool-split.ts b/src/agents/pi-embedded-runner/tool-split.ts index 13e440a20ce..26eb08667da 100644 --- a/src/agents/pi-embedded-runner/tool-split.ts +++ b/src/agents/pi-embedded-runner/tool-split.ts @@ -1,5 +1,4 @@ import type { AgentTool } from "@mariozechner/pi-agent-core"; - import { toToolDefinitions } from "../pi-tool-definition-adapter.js"; // We always pass tools via `customTools` so our policy filtering, sandbox integration, diff --git a/src/agents/pi-embedded-runner/types.ts b/src/agents/pi-embedded-runner/types.ts index 27ccfa64ea1..9b6c3491623 100644 --- a/src/agents/pi-embedded-runner/types.ts +++ b/src/agents/pi-embedded-runner/types.ts @@ -1,5 +1,5 @@ -import type { MessagingToolSend } from "../pi-embedded-messaging.js"; import type { SessionSystemPromptReport } from "../../config/sessions/types.js"; +import type { MessagingToolSend } from "../pi-embedded-messaging.js"; export type EmbeddedPiAgentMeta = { sessionId: string; diff --git a/src/agents/pi-embedded-subscribe.handlers.lifecycle.ts b/src/agents/pi-embedded-subscribe.handlers.lifecycle.ts index 1c840246501..de8c8bd6aef 100644 --- a/src/agents/pi-embedded-subscribe.handlers.lifecycle.ts +++ b/src/agents/pi-embedded-subscribe.handlers.lifecycle.ts @@ -1,8 +1,7 @@ import type { AgentEvent } from "@mariozechner/pi-agent-core"; - +import type { EmbeddedPiSubscribeContext } from "./pi-embedded-subscribe.handlers.types.js"; import { emitAgentEvent } from "../infra/agent-events.js"; import { createInlineCodeState } from "../markdown/code-spans.js"; -import type { EmbeddedPiSubscribeContext } from "./pi-embedded-subscribe.handlers.types.js"; export function handleAgentStart(ctx: EmbeddedPiSubscribeContext) { ctx.log.debug(`embedded run agent start: runId=${ctx.params.runId}`); diff --git a/src/agents/pi-embedded-subscribe.handlers.messages.ts b/src/agents/pi-embedded-subscribe.handlers.messages.ts index bbaa3276d49..840d5c74b76 100644 --- a/src/agents/pi-embedded-subscribe.handlers.messages.ts +++ b/src/agents/pi-embedded-subscribe.handlers.messages.ts @@ -1,12 +1,12 @@ import type { AgentEvent, AgentMessage } from "@mariozechner/pi-agent-core"; - +import type { EmbeddedPiSubscribeContext } from "./pi-embedded-subscribe.handlers.types.js"; +import { parseReplyDirectives } from "../auto-reply/reply/reply-directives.js"; import { emitAgentEvent } from "../infra/agent-events.js"; +import { createInlineCodeState } from "../markdown/code-spans.js"; import { isMessagingToolDuplicateNormalized, normalizeTextForComparison, } from "./pi-embedded-helpers.js"; -import { parseReplyDirectives } from "../auto-reply/reply/reply-directives.js"; -import type { EmbeddedPiSubscribeContext } from "./pi-embedded-subscribe.handlers.types.js"; import { appendRawStream } from "./pi-embedded-subscribe.raw-stream.js"; import { extractAssistantText, @@ -16,7 +16,6 @@ import { formatReasoningMessage, promoteThinkingTagsToBlocks, } from "./pi-embedded-utils.js"; -import { createInlineCodeState } from "../markdown/code-spans.js"; const stripTrailingDirective = (text: string): string => { const openIndex = text.lastIndexOf("[["); diff --git a/src/agents/pi-embedded-subscribe.handlers.tools.ts b/src/agents/pi-embedded-subscribe.handlers.tools.ts index c8017c18d04..39dc8d8fa54 100644 --- a/src/agents/pi-embedded-subscribe.handlers.tools.ts +++ b/src/agents/pi-embedded-subscribe.handlers.tools.ts @@ -1,9 +1,8 @@ import type { AgentEvent } from "@mariozechner/pi-agent-core"; - +import type { EmbeddedPiSubscribeContext } from "./pi-embedded-subscribe.handlers.types.js"; import { emitAgentEvent } from "../infra/agent-events.js"; import { normalizeTextForComparison } from "./pi-embedded-helpers.js"; import { isMessagingTool, isMessagingToolSendAction } from "./pi-embedded-messaging.js"; -import type { EmbeddedPiSubscribeContext } from "./pi-embedded-subscribe.handlers.types.js"; import { extractToolErrorMessage, extractToolResultText, diff --git a/src/agents/pi-embedded-subscribe.handlers.ts b/src/agents/pi-embedded-subscribe.handlers.ts index 9856b57e05e..8352bf3b10f 100644 --- a/src/agents/pi-embedded-subscribe.handlers.ts +++ b/src/agents/pi-embedded-subscribe.handlers.ts @@ -1,3 +1,7 @@ +import type { + EmbeddedPiSubscribeContext, + EmbeddedPiSubscribeEvent, +} from "./pi-embedded-subscribe.handlers.types.js"; import { handleAgentEnd, handleAgentStart, @@ -14,10 +18,6 @@ import { handleToolExecutionStart, handleToolExecutionUpdate, } from "./pi-embedded-subscribe.handlers.tools.js"; -import type { - EmbeddedPiSubscribeContext, - EmbeddedPiSubscribeEvent, -} from "./pi-embedded-subscribe.handlers.types.js"; export function createEmbeddedPiSessionEventHandler(ctx: EmbeddedPiSubscribeContext) { return (evt: EmbeddedPiSubscribeEvent) => { diff --git a/src/agents/pi-embedded-subscribe.handlers.types.ts b/src/agents/pi-embedded-subscribe.handlers.types.ts index e7029845eb6..e9758ba8fc2 100644 --- a/src/agents/pi-embedded-subscribe.handlers.types.ts +++ b/src/agents/pi-embedded-subscribe.handlers.types.ts @@ -1,7 +1,6 @@ import type { AgentEvent, AgentMessage } from "@mariozechner/pi-agent-core"; - -import type { ReasoningLevel } from "../auto-reply/thinking.js"; import type { ReplyDirectiveParseResult } from "../auto-reply/reply/reply-directives.js"; +import type { ReasoningLevel } from "../auto-reply/thinking.js"; import type { InlineCodeState } from "../markdown/code-spans.js"; import type { EmbeddedBlockChunker } from "./pi-embedded-block-chunker.js"; import type { MessagingToolSend } from "./pi-embedded-messaging.js"; diff --git a/src/agents/pi-embedded-subscribe.raw-stream.ts b/src/agents/pi-embedded-subscribe.raw-stream.ts index 308d4889995..eaf156b64d4 100644 --- a/src/agents/pi-embedded-subscribe.raw-stream.ts +++ b/src/agents/pi-embedded-subscribe.raw-stream.ts @@ -1,6 +1,5 @@ import fs from "node:fs"; import path from "node:path"; - import { resolveStateDir } from "../config/paths.js"; import { isTruthyEnvValue } from "../infra/env.js"; diff --git a/src/agents/pi-embedded-subscribe.tools.test.ts b/src/agents/pi-embedded-subscribe.tools.test.ts index 60e0a874309..d526ac6fd3a 100644 --- a/src/agents/pi-embedded-subscribe.tools.test.ts +++ b/src/agents/pi-embedded-subscribe.tools.test.ts @@ -1,9 +1,8 @@ import { beforeEach, describe, expect, it } from "vitest"; - -import { extractMessagingToolSend } from "./pi-embedded-subscribe.tools.js"; +import { telegramPlugin } from "../../extensions/telegram/src/channel.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import { createTestRegistry } from "../test-utils/channel-plugins.js"; -import { telegramPlugin } from "../../extensions/telegram/src/channel.js"; +import { extractMessagingToolSend } from "./pi-embedded-subscribe.tools.js"; describe("extractMessagingToolSend", () => { beforeEach(() => { diff --git a/src/agents/pi-embedded-subscribe.tools.ts b/src/agents/pi-embedded-subscribe.tools.ts index a979d8723ab..d5fe8aaf9ea 100644 --- a/src/agents/pi-embedded-subscribe.tools.ts +++ b/src/agents/pi-embedded-subscribe.tools.ts @@ -1,7 +1,7 @@ import { getChannelPlugin, normalizeChannelId } from "../channels/plugins/index.js"; +import { normalizeTargetForProvider } from "../infra/outbound/target-normalization.js"; import { truncateUtf16Safe } from "../utils.js"; import { type MessagingToolSend } from "./pi-embedded-messaging.js"; -import { normalizeTargetForProvider } from "../infra/outbound/target-normalization.js"; const TOOL_RESULT_MAX_CHARS = 8000; const TOOL_ERROR_MAX_CHARS = 400; diff --git a/src/agents/pi-embedded-subscribe.ts b/src/agents/pi-embedded-subscribe.ts index f74164fa37d..e9853775065 100644 --- a/src/agents/pi-embedded-subscribe.ts +++ b/src/agents/pi-embedded-subscribe.ts @@ -1,8 +1,13 @@ +import type { InlineCodeState } from "../markdown/code-spans.js"; +import type { + EmbeddedPiSubscribeContext, + EmbeddedPiSubscribeState, +} from "./pi-embedded-subscribe.handlers.types.js"; +import type { SubscribeEmbeddedPiSessionParams } from "./pi-embedded-subscribe.types.js"; import { parseReplyDirectives } from "../auto-reply/reply/reply-directives.js"; import { createStreamingDirectiveAccumulator } from "../auto-reply/reply/streaming-directives.js"; import { formatToolAggregate } from "../auto-reply/tool-meta.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; -import type { InlineCodeState } from "../markdown/code-spans.js"; import { buildCodeSpanIndex, createInlineCodeState } from "../markdown/code-spans.js"; import { EmbeddedBlockChunker } from "./pi-embedded-block-chunker.js"; import { @@ -10,11 +15,6 @@ import { normalizeTextForComparison, } from "./pi-embedded-helpers.js"; import { createEmbeddedPiSessionEventHandler } from "./pi-embedded-subscribe.handlers.js"; -import type { - EmbeddedPiSubscribeContext, - EmbeddedPiSubscribeState, -} from "./pi-embedded-subscribe.handlers.types.js"; -import type { SubscribeEmbeddedPiSessionParams } from "./pi-embedded-subscribe.types.js"; import { formatReasoningMessage } from "./pi-embedded-utils.js"; const THINKING_TAG_SCAN_RE = /<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\s*>/gi; diff --git a/src/agents/pi-embedded-subscribe.types.ts b/src/agents/pi-embedded-subscribe.types.ts index 766ff7f1807..5f7ebb70954 100644 --- a/src/agents/pi-embedded-subscribe.types.ts +++ b/src/agents/pi-embedded-subscribe.types.ts @@ -1,5 +1,4 @@ import type { AgentSession } from "@mariozechner/pi-coding-agent"; - import type { ReasoningLevel, VerboseLevel } from "../auto-reply/thinking.js"; import type { BlockReplyChunking } from "./pi-embedded-block-chunker.js"; diff --git a/src/agents/pi-extensions/compaction-safeguard.test.ts b/src/agents/pi-extensions/compaction-safeguard.test.ts index 23ab1efda67..8a7c00a5a42 100644 --- a/src/agents/pi-extensions/compaction-safeguard.test.ts +++ b/src/agents/pi-extensions/compaction-safeguard.test.ts @@ -1,6 +1,5 @@ import type { AgentMessage } from "@mariozechner/pi-agent-core"; import { describe, expect, it } from "vitest"; - import { getCompactionSafeguardRuntime, setCompactionSafeguardRuntime, diff --git a/src/agents/pi-extensions/context-pruning.test.ts b/src/agents/pi-extensions/context-pruning.test.ts index bf0bad5fd1c..4bc5afc156d 100644 --- a/src/agents/pi-extensions/context-pruning.test.ts +++ b/src/agents/pi-extensions/context-pruning.test.ts @@ -1,15 +1,13 @@ import type { AgentMessage } from "@mariozechner/pi-agent-core"; import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent"; import { describe, expect, it } from "vitest"; - -import { getContextPruningRuntime, setContextPruningRuntime } from "./context-pruning/runtime.js"; - import { computeEffectiveSettings, default as contextPruningExtension, DEFAULT_CONTEXT_PRUNING_SETTINGS, pruneContextMessages, } from "./context-pruning.js"; +import { getContextPruningRuntime, setContextPruningRuntime } from "./context-pruning/runtime.js"; function toolText(msg: AgentMessage): string { if (msg.role !== "toolResult") { diff --git a/src/agents/pi-extensions/context-pruning/extension.ts b/src/agents/pi-extensions/context-pruning/extension.ts index 8f68c3f2387..2a4063ae78c 100644 --- a/src/agents/pi-extensions/context-pruning/extension.ts +++ b/src/agents/pi-extensions/context-pruning/extension.ts @@ -1,5 +1,4 @@ import type { ContextEvent, ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent"; - import { pruneContextMessages } from "./pruner.js"; import { getContextPruningRuntime } from "./runtime.js"; diff --git a/src/agents/pi-extensions/context-pruning/pruner.ts b/src/agents/pi-extensions/context-pruning/pruner.ts index dd66c454cc8..acfa6316611 100644 --- a/src/agents/pi-extensions/context-pruning/pruner.ts +++ b/src/agents/pi-extensions/context-pruning/pruner.ts @@ -1,7 +1,6 @@ import type { AgentMessage } from "@mariozechner/pi-agent-core"; import type { ImageContent, TextContent, ToolResultMessage } from "@mariozechner/pi-ai"; import type { ExtensionContext } from "@mariozechner/pi-coding-agent"; - import type { EffectiveContextPruningSettings } from "./settings.js"; import { makeToolPrunablePredicate } from "./tools.js"; diff --git a/src/agents/pi-model-discovery.ts b/src/agents/pi-model-discovery.ts index 584d6f2e54a..e6726cf4cc1 100644 --- a/src/agents/pi-model-discovery.ts +++ b/src/agents/pi-model-discovery.ts @@ -1,6 +1,5 @@ -import path from "node:path"; - import { AuthStorage, ModelRegistry } from "@mariozechner/pi-coding-agent"; +import path from "node:path"; export { AuthStorage, ModelRegistry } from "@mariozechner/pi-coding-agent"; diff --git a/src/agents/pi-settings.test.ts b/src/agents/pi-settings.test.ts index 6a55dce2af4..dc0f0341556 100644 --- a/src/agents/pi-settings.test.ts +++ b/src/agents/pi-settings.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { DEFAULT_PI_COMPACTION_RESERVE_TOKENS_FLOOR, ensurePiCompactionReserveTokens, diff --git a/src/agents/pi-tool-definition-adapter.test.ts b/src/agents/pi-tool-definition-adapter.test.ts index e773a874c21..e54ec613a9f 100644 --- a/src/agents/pi-tool-definition-adapter.test.ts +++ b/src/agents/pi-tool-definition-adapter.test.ts @@ -1,6 +1,5 @@ import type { AgentTool } from "@mariozechner/pi-agent-core"; import { describe, expect, it } from "vitest"; - import { toToolDefinitions } from "./pi-tool-definition-adapter.js"; describe("pi tool definition adapter", () => { diff --git a/src/agents/pi-tools-agent-config.test.ts b/src/agents/pi-tools-agent-config.test.ts index f515c4014c1..b3b0367af0f 100644 --- a/src/agents/pi-tools-agent-config.test.ts +++ b/src/agents/pi-tools-agent-config.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it } from "vitest"; import "./test-helpers/fast-coding-tools.js"; import type { OpenClawConfig } from "../config/config.js"; -import { createOpenClawCodingTools } from "./pi-tools.js"; import type { SandboxDockerConfig } from "./sandbox.js"; +import { createOpenClawCodingTools } from "./pi-tools.js"; describe("Agent-specific tool filtering", () => { it("should apply global tool policy when no agent-specific policy exists", () => { diff --git a/src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping.test.ts b/src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping.test.ts index cab315ec529..2ec219f6144 100644 --- a/src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping.test.ts +++ b/src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping.test.ts @@ -1,7 +1,7 @@ +import type { AgentTool } from "@mariozechner/pi-agent-core"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; -import type { AgentTool } from "@mariozechner/pi-agent-core"; import { describe, expect, it, vi } from "vitest"; import "./test-helpers/fast-coding-tools.js"; import { createOpenClawTools } from "./openclaw-tools.js"; diff --git a/src/agents/pi-tools.policy.ts b/src/agents/pi-tools.policy.ts index bbc8ebc4067..dffd98d4977 100644 --- a/src/agents/pi-tools.policy.ts +++ b/src/agents/pi-tools.policy.ts @@ -1,12 +1,12 @@ import type { OpenClawConfig } from "../config/config.js"; -import { getChannelDock } from "../channels/dock.js"; -import { resolveChannelGroupToolsPolicy } from "../config/group-policy.js"; -import { resolveAgentConfig, resolveAgentIdFromSessionKey } from "./agent-scope.js"; import type { AnyAgentTool } from "./pi-tools.types.js"; import type { SandboxToolPolicy } from "./sandbox.js"; -import { expandToolGroups, normalizeToolName } from "./tool-policy.js"; -import { normalizeMessageChannel } from "../utils/message-channel.js"; +import { getChannelDock } from "../channels/dock.js"; +import { resolveChannelGroupToolsPolicy } from "../config/group-policy.js"; import { resolveThreadParentSessionKey } from "../sessions/session-key-utils.js"; +import { normalizeMessageChannel } from "../utils/message-channel.js"; +import { resolveAgentConfig, resolveAgentIdFromSessionKey } from "./agent-scope.js"; +import { expandToolGroups, normalizeToolName } from "./tool-policy.js"; type CompiledPattern = | { kind: "all" } diff --git a/src/agents/pi-tools.read.ts b/src/agents/pi-tools.read.ts index 0d27702032e..d218add3307 100644 --- a/src/agents/pi-tools.read.ts +++ b/src/agents/pi-tools.read.ts @@ -1,8 +1,7 @@ import type { AgentToolResult } from "@mariozechner/pi-agent-core"; import { createEditTool, createReadTool, createWriteTool } from "@mariozechner/pi-coding-agent"; - -import { detectMime } from "../media/mime.js"; import type { AnyAgentTool } from "./pi-tools.types.js"; +import { detectMime } from "../media/mime.js"; import { assertSandboxPath } from "./sandbox-paths.js"; import { sanitizeToolResultImages } from "./tool-images.js"; diff --git a/src/agents/pi-tools.ts b/src/agents/pi-tools.ts index 371868ee145..1aa45c51d3c 100644 --- a/src/agents/pi-tools.ts +++ b/src/agents/pi-tools.ts @@ -6,6 +6,11 @@ import { readTool, } from "@mariozechner/pi-coding-agent"; import type { OpenClawConfig } from "../config/config.js"; +import type { ModelAuthMode } from "./model-auth.js"; +import type { AnyAgentTool } from "./pi-tools.types.js"; +import type { SandboxContext } from "./sandbox.js"; +import { logWarn } from "../logger.js"; +import { getPluginToolMeta } from "../plugins/tools.js"; import { isSubagentSessionKey } from "../routing/session-key.js"; import { resolveGatewayMessageChannel } from "../utils/message-channel.js"; import { createApplyPatchTool } from "./apply-patch.js"; @@ -17,7 +22,6 @@ import { } from "./bash-tools.js"; import { listChannelAgentTools } from "./channel-tools.js"; import { createOpenClawTools } from "./openclaw-tools.js"; -import type { ModelAuthMode } from "./model-auth.js"; import { wrapToolWithAbortSignal } from "./pi-tools.abort.js"; import { filterToolsByPolicy, @@ -38,8 +42,6 @@ import { wrapToolParamNormalization, } from "./pi-tools.read.js"; import { cleanToolSchemaForGemini, normalizeToolParameters } from "./pi-tools.schema.js"; -import type { AnyAgentTool } from "./pi-tools.types.js"; -import type { SandboxContext } from "./sandbox.js"; import { buildPluginToolGroups, collectExplicitAllowlist, @@ -48,8 +50,6 @@ import { resolveToolProfilePolicy, stripPluginOnlyAllowlist, } from "./tool-policy.js"; -import { getPluginToolMeta } from "../plugins/tools.js"; -import { logWarn } from "../logger.js"; function isOpenAIProvider(provider?: string) { const normalized = provider?.trim().toLowerCase(); diff --git a/src/agents/pi-tools.workspace-paths.test.ts b/src/agents/pi-tools.workspace-paths.test.ts index 0e7e1bc9d58..f6388c8841b 100644 --- a/src/agents/pi-tools.workspace-paths.test.ts +++ b/src/agents/pi-tools.workspace-paths.test.ts @@ -1,7 +1,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; import { createOpenClawCodingTools } from "./pi-tools.js"; diff --git a/src/agents/pty-dsr.test.ts b/src/agents/pty-dsr.test.ts index f2c629cfe44..a71f95c0265 100644 --- a/src/agents/pty-dsr.test.ts +++ b/src/agents/pty-dsr.test.ts @@ -1,5 +1,4 @@ import { expect, test } from "vitest"; - import { buildCursorPositionResponse, stripDsrRequests } from "./pty-dsr.js"; test("stripDsrRequests removes cursor queries and counts them", () => { diff --git a/src/agents/pty-keys.test.ts b/src/agents/pty-keys.test.ts index f7464e5ca3e..a295a11b8b5 100644 --- a/src/agents/pty-keys.test.ts +++ b/src/agents/pty-keys.test.ts @@ -1,5 +1,4 @@ import { expect, test } from "vitest"; - import { BRACKETED_PASTE_END, BRACKETED_PASTE_START, diff --git a/src/agents/sandbox-create-args.test.ts b/src/agents/sandbox-create-args.test.ts index c005d29cf17..0bc8de62fce 100644 --- a/src/agents/sandbox-create-args.test.ts +++ b/src/agents/sandbox-create-args.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { buildSandboxCreateArgs, type SandboxDockerConfig } from "./sandbox.js"; describe("buildSandboxCreateArgs", () => { diff --git a/src/agents/sandbox/browser.ts b/src/agents/sandbox/browser.ts index 0a26a1c68e6..a7140ebc780 100644 --- a/src/agents/sandbox/browser.ts +++ b/src/agents/sandbox/browser.ts @@ -1,3 +1,4 @@ +import type { SandboxBrowserContext, SandboxConfig } from "./types.js"; import { startBrowserBridgeServer, stopBrowserBridgeServer } from "../../browser/bridge-server.js"; import { type ResolvedBrowserConfig, resolveProfile } from "../../browser/config.js"; import { @@ -16,7 +17,6 @@ import { import { updateBrowserRegistry } from "./registry.js"; import { slugifySessionKey } from "./shared.js"; import { isToolAllowed } from "./tool-policy.js"; -import type { SandboxBrowserContext, SandboxConfig } from "./types.js"; async function waitForSandboxCdp(params: { cdpPort: number; timeoutMs: number }): Promise { const deadline = Date.now() + Math.max(0, params.timeoutMs); diff --git a/src/agents/sandbox/config-hash.ts b/src/agents/sandbox/config-hash.ts index 604168d79b4..31066434340 100644 --- a/src/agents/sandbox/config-hash.ts +++ b/src/agents/sandbox/config-hash.ts @@ -1,5 +1,4 @@ import crypto from "node:crypto"; - import type { SandboxDockerConfig, SandboxWorkspaceAccess } from "./types.js"; type SandboxHashInput = { diff --git a/src/agents/sandbox/config.ts b/src/agents/sandbox/config.ts index b07ec715eb9..9619ccd9053 100644 --- a/src/agents/sandbox/config.ts +++ b/src/agents/sandbox/config.ts @@ -1,4 +1,11 @@ import type { OpenClawConfig } from "../../config/config.js"; +import type { + SandboxBrowserConfig, + SandboxConfig, + SandboxDockerConfig, + SandboxPruneConfig, + SandboxScope, +} from "./types.js"; import { resolveAgentConfig } from "../agent-scope.js"; import { DEFAULT_SANDBOX_BROWSER_AUTOSTART_TIMEOUT_MS, @@ -15,13 +22,6 @@ import { DEFAULT_SANDBOX_WORKSPACE_ROOT, } from "./constants.js"; import { resolveSandboxToolPolicyForAgent } from "./tool-policy.js"; -import type { - SandboxBrowserConfig, - SandboxConfig, - SandboxDockerConfig, - SandboxPruneConfig, - SandboxScope, -} from "./types.js"; export function resolveSandboxScope(params: { scope?: SandboxScope; diff --git a/src/agents/sandbox/constants.ts b/src/agents/sandbox/constants.ts index 80a5e0fe09f..7f565eb6442 100644 --- a/src/agents/sandbox/constants.ts +++ b/src/agents/sandbox/constants.ts @@ -1,6 +1,5 @@ import os from "node:os"; import path from "node:path"; - import { CHANNEL_IDS } from "../../channels/registry.js"; import { STATE_DIR } from "../../config/config.js"; diff --git a/src/agents/sandbox/context.ts b/src/agents/sandbox/context.ts index c6f3ffa0890..9f654dc2989 100644 --- a/src/agents/sandbox/context.ts +++ b/src/agents/sandbox/context.ts @@ -1,9 +1,9 @@ import fs from "node:fs/promises"; - import type { OpenClawConfig } from "../../config/config.js"; +import type { SandboxContext, SandboxWorkspaceInfo } from "./types.js"; +import { DEFAULT_BROWSER_EVALUATE_ENABLED } from "../../browser/constants.js"; import { defaultRuntime } from "../../runtime.js"; import { resolveUserPath } from "../../utils.js"; -import { DEFAULT_BROWSER_EVALUATE_ENABLED } from "../../browser/constants.js"; import { syncSkillsToWorkspace } from "../skills.js"; import { DEFAULT_AGENT_WORKSPACE_DIR } from "../workspace.js"; import { ensureSandboxBrowser } from "./browser.js"; @@ -12,7 +12,6 @@ import { ensureSandboxContainer } from "./docker.js"; import { maybePruneSandboxes } from "./prune.js"; import { resolveSandboxRuntimeStatus } from "./runtime-status.js"; import { resolveSandboxScopeKey, resolveSandboxWorkspaceDir } from "./shared.js"; -import type { SandboxContext, SandboxWorkspaceInfo } from "./types.js"; import { ensureSandboxWorkspace } from "./workspace.js"; export async function resolveSandboxContext(params: { diff --git a/src/agents/sandbox/docker.ts b/src/agents/sandbox/docker.ts index a0031b5505b..2392bb53674 100644 --- a/src/agents/sandbox/docker.ts +++ b/src/agents/sandbox/docker.ts @@ -1,12 +1,11 @@ import { spawn } from "node:child_process"; - -import { defaultRuntime } from "../../runtime.js"; +import type { SandboxConfig, SandboxDockerConfig, SandboxWorkspaceAccess } from "./types.js"; import { formatCliCommand } from "../../cli/command-format.js"; +import { defaultRuntime } from "../../runtime.js"; +import { computeSandboxConfigHash } from "./config-hash.js"; import { DEFAULT_SANDBOX_IMAGE, SANDBOX_AGENT_WORKSPACE_MOUNT } from "./constants.js"; import { readRegistry, updateRegistry } from "./registry.js"; -import { computeSandboxConfigHash } from "./config-hash.js"; import { resolveSandboxAgentId, resolveSandboxScopeKey, slugifySessionKey } from "./shared.js"; -import type { SandboxConfig, SandboxDockerConfig, SandboxWorkspaceAccess } from "./types.js"; const HOT_CONTAINER_WINDOW_MS = 5 * 60 * 1000; diff --git a/src/agents/sandbox/prune.ts b/src/agents/sandbox/prune.ts index a106df2aa53..de3616f7e49 100644 --- a/src/agents/sandbox/prune.ts +++ b/src/agents/sandbox/prune.ts @@ -1,3 +1,4 @@ +import type { SandboxConfig } from "./types.js"; import { stopBrowserBridgeServer } from "../../browser/bridge-server.js"; import { defaultRuntime } from "../../runtime.js"; import { BROWSER_BRIDGES } from "./browser-bridges.js"; @@ -8,7 +9,6 @@ import { removeBrowserRegistryEntry, removeRegistryEntry, } from "./registry.js"; -import type { SandboxConfig } from "./types.js"; let lastPruneAtMs = 0; diff --git a/src/agents/sandbox/registry.ts b/src/agents/sandbox/registry.ts index c0b2d4b9aeb..2fa34eeef9f 100644 --- a/src/agents/sandbox/registry.ts +++ b/src/agents/sandbox/registry.ts @@ -1,5 +1,4 @@ import fs from "node:fs/promises"; - import { SANDBOX_BROWSER_REGISTRY_PATH, SANDBOX_REGISTRY_PATH, diff --git a/src/agents/sandbox/runtime-status.ts b/src/agents/sandbox/runtime-status.ts index 4489d3c3d6a..92d37613276 100644 --- a/src/agents/sandbox/runtime-status.ts +++ b/src/agents/sandbox/runtime-status.ts @@ -1,11 +1,11 @@ import type { OpenClawConfig } from "../../config/config.js"; +import type { SandboxConfig, SandboxToolPolicyResolved } from "./types.js"; +import { formatCliCommand } from "../../cli/command-format.js"; import { canonicalizeMainSessionAlias, resolveAgentMainSessionKey } from "../../config/sessions.js"; import { resolveSessionAgentId } from "../agent-scope.js"; import { expandToolGroups } from "../tool-policy.js"; -import { formatCliCommand } from "../../cli/command-format.js"; import { resolveSandboxConfigForAgent } from "./config.js"; import { resolveSandboxToolPolicyForAgent } from "./tool-policy.js"; -import type { SandboxConfig, SandboxToolPolicyResolved } from "./types.js"; function shouldSandboxSession(cfg: SandboxConfig, sessionKey: string, mainSessionKey: string) { if (cfg.mode === "off") { diff --git a/src/agents/sandbox/shared.ts b/src/agents/sandbox/shared.ts index 1cff3525e95..0c9bc849c4d 100644 --- a/src/agents/sandbox/shared.ts +++ b/src/agents/sandbox/shared.ts @@ -1,6 +1,5 @@ import crypto from "node:crypto"; import path from "node:path"; - import { normalizeAgentId } from "../../routing/session-key.js"; import { resolveUserPath } from "../../utils.js"; import { resolveAgentIdFromSessionKey } from "../agent-scope.js"; diff --git a/src/agents/sandbox/tool-policy.ts b/src/agents/sandbox/tool-policy.ts index a853e2ff01b..ea632a39464 100644 --- a/src/agents/sandbox/tool-policy.ts +++ b/src/agents/sandbox/tool-policy.ts @@ -1,12 +1,12 @@ import type { OpenClawConfig } from "../../config/config.js"; -import { resolveAgentConfig } from "../agent-scope.js"; -import { expandToolGroups } from "../tool-policy.js"; -import { DEFAULT_TOOL_ALLOW, DEFAULT_TOOL_DENY } from "./constants.js"; import type { SandboxToolPolicy, SandboxToolPolicyResolved, SandboxToolPolicySource, } from "./types.js"; +import { resolveAgentConfig } from "../agent-scope.js"; +import { expandToolGroups } from "../tool-policy.js"; +import { DEFAULT_TOOL_ALLOW, DEFAULT_TOOL_DENY } from "./constants.js"; type CompiledPattern = | { kind: "all" } diff --git a/src/agents/sandbox/workspace.ts b/src/agents/sandbox/workspace.ts index 023f5cdce39..e2ce3008ce3 100644 --- a/src/agents/sandbox/workspace.ts +++ b/src/agents/sandbox/workspace.ts @@ -1,6 +1,5 @@ import fs from "node:fs/promises"; import path from "node:path"; - import { resolveUserPath } from "../../utils.js"; import { DEFAULT_AGENTS_FILENAME, diff --git a/src/agents/session-tool-result-guard-wrapper.ts b/src/agents/session-tool-result-guard-wrapper.ts index 956247a24ec..8b6bb21a4f1 100644 --- a/src/agents/session-tool-result-guard-wrapper.ts +++ b/src/agents/session-tool-result-guard-wrapper.ts @@ -1,5 +1,4 @@ import type { SessionManager } from "@mariozechner/pi-coding-agent"; - import { getGlobalHookRunner } from "../plugins/hook-runner-global.js"; import { installSessionToolResultGuard } from "./session-tool-result-guard.js"; diff --git a/src/agents/session-tool-result-guard.test.ts b/src/agents/session-tool-result-guard.test.ts index 1bfcb31ed4e..65a51cfb405 100644 --- a/src/agents/session-tool-result-guard.test.ts +++ b/src/agents/session-tool-result-guard.test.ts @@ -1,7 +1,6 @@ import type { AgentMessage } from "@mariozechner/pi-agent-core"; import { SessionManager } from "@mariozechner/pi-coding-agent"; import { describe, expect, it } from "vitest"; - import { installSessionToolResultGuard } from "./session-tool-result-guard.js"; const toolCallMessage = { diff --git a/src/agents/session-tool-result-guard.tool-result-persist-hook.test.ts b/src/agents/session-tool-result-guard.tool-result-persist-hook.test.ts index 77228da9064..0e54c665cc3 100644 --- a/src/agents/session-tool-result-guard.tool-result-persist-hook.test.ts +++ b/src/agents/session-tool-result-guard.tool-result-persist-hook.test.ts @@ -1,13 +1,11 @@ +import type { AgentMessage } from "@mariozechner/pi-agent-core"; +import { SessionManager } from "@mariozechner/pi-coding-agent"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - -import type { AgentMessage } from "@mariozechner/pi-agent-core"; -import { SessionManager } from "@mariozechner/pi-coding-agent"; import { describe, expect, it, afterEach } from "vitest"; - -import { loadOpenClawPlugins } from "../plugins/loader.js"; import { resetGlobalHookRunner } from "../plugins/hook-runner-global.js"; +import { loadOpenClawPlugins } from "../plugins/loader.js"; import { guardSessionManager } from "./session-tool-result-guard-wrapper.js"; const EMPTY_PLUGIN_SCHEMA = { type: "object", additionalProperties: false, properties: {} }; diff --git a/src/agents/session-tool-result-guard.ts b/src/agents/session-tool-result-guard.ts index 2a8fb2f27dc..44d4cf13c33 100644 --- a/src/agents/session-tool-result-guard.ts +++ b/src/agents/session-tool-result-guard.ts @@ -1,8 +1,7 @@ import type { AgentMessage } from "@mariozechner/pi-agent-core"; import type { SessionManager } from "@mariozechner/pi-coding-agent"; - -import { makeMissingToolResult } from "./session-transcript-repair.js"; import { emitSessionTranscriptUpdate } from "../sessions/transcript-events.js"; +import { makeMissingToolResult } from "./session-transcript-repair.js"; type ToolCall = { id: string; name?: string }; diff --git a/src/agents/session-write-lock.test.ts b/src/agents/session-write-lock.test.ts index 27e793d5af7..16c28ae7aa8 100644 --- a/src/agents/session-write-lock.test.ts +++ b/src/agents/session-write-lock.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { describe, expect, it } from "vitest"; - import { __testing, acquireSessionWriteLock } from "./session-write-lock.js"; describe("acquireSessionWriteLock", () => { diff --git a/src/agents/shell-utils.test.ts b/src/agents/shell-utils.test.ts index 00aae55eaa2..8bf9edc82e9 100644 --- a/src/agents/shell-utils.test.ts +++ b/src/agents/shell-utils.test.ts @@ -1,7 +1,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it } from "vitest"; import { getShellConfig } from "./shell-utils.js"; diff --git a/src/agents/skills-install.ts b/src/agents/skills-install.ts index f0dcea620d9..4b0482dc224 100644 --- a/src/agents/skills-install.ts +++ b/src/agents/skills-install.ts @@ -1,9 +1,8 @@ +import type { ReadableStream as NodeReadableStream } from "node:stream/web"; import fs from "node:fs"; import path from "node:path"; import { Readable } from "node:stream"; -import type { ReadableStream as NodeReadableStream } from "node:stream/web"; import { pipeline } from "node:stream/promises"; - import type { OpenClawConfig } from "../config/config.js"; import { resolveBrewExecutable } from "../infra/brew.js"; import { runCommandWithTimeout } from "../process/exec.js"; diff --git a/src/agents/skills-status.ts b/src/agents/skills-status.ts index db7e4ff2f76..03c962044b5 100644 --- a/src/agents/skills-status.ts +++ b/src/agents/skills-status.ts @@ -1,5 +1,4 @@ import path from "node:path"; - import type { OpenClawConfig } from "../config/config.js"; import { CONFIG_DIR } from "../utils.js"; import { diff --git a/src/agents/skills.summarize-skill-description.test.ts b/src/agents/skills.summarize-skill-description.test.ts index ca0d67c6d84..dd9a5cc371c 100644 --- a/src/agents/skills.summarize-skill-description.test.ts +++ b/src/agents/skills.summarize-skill-description.test.ts @@ -1,8 +1,6 @@ import fs from "node:fs"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import { parseFrontmatter } from "./skills/frontmatter.js"; describe("skills/summarize frontmatter", () => { diff --git a/src/agents/skills/config.ts b/src/agents/skills/config.ts index 9e7a74c05e3..6e08e49c69b 100644 --- a/src/agents/skills/config.ts +++ b/src/agents/skills/config.ts @@ -1,8 +1,8 @@ import fs from "node:fs"; import path from "node:path"; import type { OpenClawConfig, SkillConfig } from "../../config/config.js"; -import { resolveSkillKey } from "./frontmatter.js"; import type { SkillEligibilityContext, SkillEntry } from "./types.js"; +import { resolveSkillKey } from "./frontmatter.js"; const DEFAULT_CONFIG_VALUES: Record = { "browser.enabled": true, diff --git a/src/agents/skills/env-overrides.ts b/src/agents/skills/env-overrides.ts index 5acebaf3da8..4d6e97a2e32 100644 --- a/src/agents/skills/env-overrides.ts +++ b/src/agents/skills/env-overrides.ts @@ -1,7 +1,7 @@ import type { OpenClawConfig } from "../../config/config.js"; +import type { SkillEntry, SkillSnapshot } from "./types.js"; import { resolveSkillConfig } from "./config.js"; import { resolveSkillKey } from "./frontmatter.js"; -import type { SkillEntry, SkillSnapshot } from "./types.js"; export function applySkillEnvOverrides(params: { skills: SkillEntry[]; config?: OpenClawConfig }) { const { skills, config } = params; diff --git a/src/agents/skills/frontmatter.test.ts b/src/agents/skills/frontmatter.test.ts index 82a9cdd756d..28014096325 100644 --- a/src/agents/skills/frontmatter.test.ts +++ b/src/agents/skills/frontmatter.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { resolveSkillInvocationPolicy } from "./frontmatter.js"; describe("resolveSkillInvocationPolicy", () => { diff --git a/src/agents/skills/frontmatter.ts b/src/agents/skills/frontmatter.ts index c82f9eb39cf..a2c29016960 100644 --- a/src/agents/skills/frontmatter.ts +++ b/src/agents/skills/frontmatter.ts @@ -1,9 +1,5 @@ -import JSON5 from "json5"; import type { Skill } from "@mariozechner/pi-coding-agent"; - -import { LEGACY_MANIFEST_KEYS, MANIFEST_KEY } from "../../compat/legacy-names.js"; -import { parseFrontmatterBlock } from "../../markdown/frontmatter.js"; -import { parseBooleanValue } from "../../utils/boolean.js"; +import JSON5 from "json5"; import type { OpenClawSkillMetadata, ParsedSkillFrontmatter, @@ -11,6 +7,9 @@ import type { SkillInstallSpec, SkillInvocationPolicy, } from "./types.js"; +import { LEGACY_MANIFEST_KEYS, MANIFEST_KEY } from "../../compat/legacy-names.js"; +import { parseFrontmatterBlock } from "../../markdown/frontmatter.js"; +import { parseBooleanValue } from "../../utils/boolean.js"; export function parseFrontmatter(content: string): ParsedSkillFrontmatter { return parseFrontmatterBlock(content); diff --git a/src/agents/skills/plugin-skills.ts b/src/agents/skills/plugin-skills.ts index 14e2adc67da..ca799fe05de 100644 --- a/src/agents/skills/plugin-skills.ts +++ b/src/agents/skills/plugin-skills.ts @@ -1,6 +1,5 @@ import fs from "node:fs"; import path from "node:path"; - import type { OpenClawConfig } from "../../config/config.js"; import { createSubsystemLogger } from "../../logging/subsystem.js"; import { diff --git a/src/agents/skills/refresh.ts b/src/agents/skills/refresh.ts index cf114686ff4..141271ae202 100644 --- a/src/agents/skills/refresh.ts +++ b/src/agents/skills/refresh.ts @@ -1,7 +1,5 @@ -import path from "node:path"; - import chokidar, { type FSWatcher } from "chokidar"; - +import path from "node:path"; import type { OpenClawConfig } from "../../config/config.js"; import { createSubsystemLogger } from "../../logging/subsystem.js"; import { CONFIG_DIR, resolveUserPath } from "../../utils.js"; diff --git a/src/agents/skills/workspace.ts b/src/agents/skills/workspace.ts index 51ef238f6c1..c02701653ad 100644 --- a/src/agents/skills/workspace.ts +++ b/src/agents/skills/workspace.ts @@ -1,13 +1,18 @@ -import fs from "node:fs"; -import path from "node:path"; - import { formatSkillsForPrompt, loadSkillsFromDir, type Skill, } from "@mariozechner/pi-coding-agent"; - +import fs from "node:fs"; +import path from "node:path"; import type { OpenClawConfig } from "../../config/config.js"; +import type { + ParsedSkillFrontmatter, + SkillEligibilityContext, + SkillCommandSpec, + SkillEntry, + SkillSnapshot, +} from "./types.js"; import { createSubsystemLogger } from "../../logging/subsystem.js"; import { CONFIG_DIR, resolveUserPath } from "../../utils.js"; import { resolveBundledSkillsDir } from "./bundled-dir.js"; @@ -19,13 +24,6 @@ import { } from "./frontmatter.js"; import { resolvePluginSkillDirs } from "./plugin-skills.js"; import { serializeByKey } from "./serialize.js"; -import type { - ParsedSkillFrontmatter, - SkillEligibilityContext, - SkillCommandSpec, - SkillEntry, - SkillSnapshot, -} from "./types.js"; const fsp = fs.promises; const skillsLogger = createSubsystemLogger("skills"); diff --git a/src/agents/subagent-announce.ts b/src/agents/subagent-announce.ts index 5bfc0f0effb..5145d8b703a 100644 --- a/src/agents/subagent-announce.ts +++ b/src/agents/subagent-announce.ts @@ -1,6 +1,6 @@ import crypto from "node:crypto"; import path from "node:path"; - +import { resolveQueueSettings } from "../auto-reply/reply/queue.js"; import { loadConfig } from "../config/config.js"; import { loadSessionStore, @@ -8,9 +8,8 @@ import { resolveMainSessionKey, resolveStorePath, } from "../config/sessions.js"; -import { normalizeMainKey } from "../routing/session-key.js"; -import { resolveQueueSettings } from "../auto-reply/reply/queue.js"; import { callGateway } from "../gateway/call.js"; +import { normalizeMainKey } from "../routing/session-key.js"; import { defaultRuntime } from "../runtime.js"; import { type DeliveryContext, diff --git a/src/agents/subagent-registry.persistence.test.ts b/src/agents/subagent-registry.persistence.test.ts index cd2ee9fadc8..f97312a8850 100644 --- a/src/agents/subagent-registry.persistence.test.ts +++ b/src/agents/subagent-registry.persistence.test.ts @@ -1,7 +1,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, describe, expect, it, vi } from "vitest"; const noop = () => {}; diff --git a/src/agents/subagent-registry.store.ts b/src/agents/subagent-registry.store.ts index a72b2232238..510268e522c 100644 --- a/src/agents/subagent-registry.store.ts +++ b/src/agents/subagent-registry.store.ts @@ -1,9 +1,8 @@ import path from "node:path"; - +import type { SubagentRunRecord } from "./subagent-registry.js"; import { STATE_DIR } from "../config/paths.js"; import { loadJsonFile, saveJsonFile } from "../infra/json-file.js"; import { normalizeDeliveryContext } from "../utils/delivery-context.js"; -import type { SubagentRunRecord } from "./subagent-registry.js"; export type PersistedSubagentRegistryVersion = 1 | 2; diff --git a/src/agents/system-prompt-params.test.ts b/src/agents/system-prompt-params.test.ts index ab73eb3c4b9..a4215d3a869 100644 --- a/src/agents/system-prompt-params.test.ts +++ b/src/agents/system-prompt-params.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { buildSystemPromptParams } from "./system-prompt-params.js"; diff --git a/src/agents/system-prompt-params.ts b/src/agents/system-prompt-params.ts index f450768d094..d269253223a 100644 --- a/src/agents/system-prompt-params.ts +++ b/src/agents/system-prompt-params.ts @@ -1,6 +1,5 @@ import fs from "node:fs"; import path from "node:path"; - import type { OpenClawConfig } from "../config/config.js"; import { formatUserTime, diff --git a/src/agents/system-prompt-report.ts b/src/agents/system-prompt-report.ts index 4ce7ece5635..4f4b43fb06f 100644 --- a/src/agents/system-prompt-report.ts +++ b/src/agents/system-prompt-report.ts @@ -1,8 +1,7 @@ import type { AgentTool } from "@mariozechner/pi-agent-core"; - +import type { SessionSystemPromptReport } from "../config/sessions/types.js"; import type { EmbeddedContextFile } from "./pi-embedded-helpers.js"; import type { WorkspaceBootstrapFile } from "./workspace.js"; -import type { SessionSystemPromptReport } from "../config/sessions/types.js"; function extractBetween( input: string, diff --git a/src/agents/system-prompt.ts b/src/agents/system-prompt.ts index b75082551bb..dc4f1332a84 100644 --- a/src/agents/system-prompt.ts +++ b/src/agents/system-prompt.ts @@ -1,8 +1,8 @@ import type { ReasoningLevel, ThinkLevel } from "../auto-reply/thinking.js"; -import { SILENT_REPLY_TOKEN } from "../auto-reply/tokens.js"; -import { listDeliverableMessageChannels } from "../utils/message-channel.js"; import type { ResolvedTimeFormat } from "./date-time.js"; import type { EmbeddedContextFile } from "./pi-embedded-helpers.js"; +import { SILENT_REPLY_TOKEN } from "../auto-reply/tokens.js"; +import { listDeliverableMessageChannels } from "../utils/message-channel.js"; /** * Controls which hardcoded sections are included in the system prompt. diff --git a/src/agents/tool-call-id.test.ts b/src/agents/tool-call-id.test.ts index 5ce554e4281..37128fc3d1c 100644 --- a/src/agents/tool-call-id.test.ts +++ b/src/agents/tool-call-id.test.ts @@ -1,6 +1,5 @@ import type { AgentMessage } from "@mariozechner/pi-agent-core"; import { describe, expect, it } from "vitest"; - import { isValidCloudCodeAssistToolId, sanitizeToolCallIdsForCloudCodeAssist, diff --git a/src/agents/tool-call-id.ts b/src/agents/tool-call-id.ts index 380c93c18a7..040a935beac 100644 --- a/src/agents/tool-call-id.ts +++ b/src/agents/tool-call-id.ts @@ -1,6 +1,5 @@ -import { createHash } from "node:crypto"; - import type { AgentMessage } from "@mariozechner/pi-agent-core"; +import { createHash } from "node:crypto"; export type ToolCallIdMode = "strict" | "strict9"; diff --git a/src/agents/tool-display.test.ts b/src/agents/tool-display.test.ts index 7d97f57f387..760ef591a48 100644 --- a/src/agents/tool-display.test.ts +++ b/src/agents/tool-display.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { formatToolDetail, resolveToolDisplay } from "./tool-display.js"; describe("tool display details", () => { diff --git a/src/agents/tool-images.test.ts b/src/agents/tool-images.test.ts index f656c13ae84..e5dff0a9e91 100644 --- a/src/agents/tool-images.test.ts +++ b/src/agents/tool-images.test.ts @@ -1,6 +1,5 @@ import sharp from "sharp"; import { describe, expect, it } from "vitest"; - import { sanitizeContentBlocksImages, sanitizeImageBlocks } from "./tool-images.js"; describe("tool image sanitizing", () => { diff --git a/src/agents/tool-images.ts b/src/agents/tool-images.ts index 8b8ec4e3d3d..897c82ef4c2 100644 --- a/src/agents/tool-images.ts +++ b/src/agents/tool-images.ts @@ -1,6 +1,5 @@ import type { AgentToolResult } from "@mariozechner/pi-agent-core"; import type { ImageContent } from "@mariozechner/pi-ai"; - import { createSubsystemLogger } from "../logging/subsystem.js"; import { getImageMetadata, resizeToJpeg } from "../media/image-ops.js"; diff --git a/src/agents/tool-policy.plugin-only-allowlist.test.ts b/src/agents/tool-policy.plugin-only-allowlist.test.ts index 7964519aab2..d0d19b7d4d6 100644 --- a/src/agents/tool-policy.plugin-only-allowlist.test.ts +++ b/src/agents/tool-policy.plugin-only-allowlist.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { stripPluginOnlyAllowlist, type PluginToolGroups } from "./tool-policy.js"; const pluginGroups: PluginToolGroups = { diff --git a/src/agents/tools/agent-step.ts b/src/agents/tools/agent-step.ts index 927ebf0ad92..5193fe519b0 100644 --- a/src/agents/tools/agent-step.ts +++ b/src/agents/tools/agent-step.ts @@ -1,5 +1,4 @@ import crypto from "node:crypto"; - import { callGateway } from "../../gateway/call.js"; import { INTERNAL_MESSAGE_CHANNEL } from "../../utils/message-channel.js"; import { AGENT_LANE_NESTED } from "../lanes.js"; diff --git a/src/agents/tools/agents-list-tool.ts b/src/agents/tools/agents-list-tool.ts index ee4c5d964f3..1782484a30d 100644 --- a/src/agents/tools/agents-list-tool.ts +++ b/src/agents/tools/agents-list-tool.ts @@ -1,5 +1,5 @@ import { Type } from "@sinclair/typebox"; - +import type { AnyAgentTool } from "./common.js"; import { loadConfig } from "../../config/config.js"; import { DEFAULT_AGENT_ID, @@ -7,7 +7,6 @@ import { parseAgentSessionKey, } from "../../routing/session-key.js"; import { resolveAgentConfig } from "../agent-scope.js"; -import type { AnyAgentTool } from "./common.js"; import { jsonResult } from "./common.js"; import { resolveInternalSessionKey, resolveMainSessionAlias } from "./sessions-helpers.js"; diff --git a/src/agents/tools/browser-tool.schema.ts b/src/agents/tools/browser-tool.schema.ts index 30cf3cc0f53..53a482d6d7b 100644 --- a/src/agents/tools/browser-tool.schema.ts +++ b/src/agents/tools/browser-tool.schema.ts @@ -1,5 +1,4 @@ import { Type } from "@sinclair/typebox"; - import { optionalStringEnum, stringEnum } from "../schema/typebox.js"; const BROWSER_ACT_KINDS = [ diff --git a/src/agents/tools/browser-tool.ts b/src/agents/tools/browser-tool.ts index 575ca46094d..d434d48adfb 100644 --- a/src/agents/tools/browser-tool.ts +++ b/src/agents/tools/browser-tool.ts @@ -1,3 +1,13 @@ +import crypto from "node:crypto"; +import { + browserAct, + browserArmDialog, + browserArmFileChooser, + browserConsoleMessages, + browserNavigate, + browserPdfSave, + browserScreenshotAction, +} from "../../browser/client-actions.js"; import { browserCloseTab, browserFocusTab, @@ -9,25 +19,14 @@ import { browserStop, browserTabs, } from "../../browser/client.js"; -import { - browserAct, - browserArmDialog, - browserArmFileChooser, - browserConsoleMessages, - browserNavigate, - browserPdfSave, - browserScreenshotAction, -} from "../../browser/client-actions.js"; -import crypto from "node:crypto"; - import { resolveBrowserConfig } from "../../browser/config.js"; import { DEFAULT_AI_SNAPSHOT_MAX_CHARS } from "../../browser/constants.js"; import { loadConfig } from "../../config/config.js"; import { saveMediaBuffer } from "../../media/store.js"; -import { listNodes, resolveNodeIdFromList, type NodeListNode } from "./nodes-utils.js"; import { BrowserToolSchema } from "./browser-tool.schema.js"; import { type AnyAgentTool, imageResultFromFile, jsonResult, readStringParam } from "./common.js"; import { callGatewayTool } from "./gateway.js"; +import { listNodes, resolveNodeIdFromList, type NodeListNode } from "./nodes-utils.js"; type BrowserProxyFile = { path: string; diff --git a/src/agents/tools/canvas-tool.ts b/src/agents/tools/canvas-tool.ts index d112fe19178..44ddea30fcc 100644 --- a/src/agents/tools/canvas-tool.ts +++ b/src/agents/tools/canvas-tool.ts @@ -1,7 +1,6 @@ +import { Type } from "@sinclair/typebox"; import crypto from "node:crypto"; import fs from "node:fs/promises"; - -import { Type } from "@sinclair/typebox"; import { writeBase64ToFile } from "../../cli/nodes-camera.js"; import { canvasSnapshotTempPath, parseCanvasSnapshotPayload } from "../../cli/nodes-canvas.js"; import { imageMimeFromFormat } from "../../media/mime.js"; diff --git a/src/agents/tools/common.test.ts b/src/agents/tools/common.test.ts index c8a572b8877..67c6b23c0ed 100644 --- a/src/agents/tools/common.test.ts +++ b/src/agents/tools/common.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { createActionGate, readNumberParam, diff --git a/src/agents/tools/common.ts b/src/agents/tools/common.ts index 732144163d9..c656c77b07d 100644 --- a/src/agents/tools/common.ts +++ b/src/agents/tools/common.ts @@ -1,7 +1,5 @@ -import fs from "node:fs/promises"; - import type { AgentTool, AgentToolResult } from "@mariozechner/pi-agent-core"; - +import fs from "node:fs/promises"; import { detectMime } from "../../media/mime.js"; import { sanitizeToolResultImages } from "../tool-images.js"; diff --git a/src/agents/tools/cron-tool.ts b/src/agents/tools/cron-tool.ts index 1c6bbc16301..a3f8de89eef 100644 --- a/src/agents/tools/cron-tool.ts +++ b/src/agents/tools/cron-tool.ts @@ -1,9 +1,9 @@ import { Type } from "@sinclair/typebox"; -import { normalizeCronJobCreate, normalizeCronJobPatch } from "../../cron/normalize.js"; import { loadConfig } from "../../config/config.js"; +import { normalizeCronJobCreate, normalizeCronJobPatch } from "../../cron/normalize.js"; import { truncateUtf16Safe } from "../../utils.js"; -import { optionalStringEnum, stringEnum } from "../schema/typebox.js"; import { resolveSessionAgentId } from "../agent-scope.js"; +import { optionalStringEnum, stringEnum } from "../schema/typebox.js"; import { type AnyAgentTool, jsonResult, readStringParam } from "./common.js"; import { callGatewayTool, type GatewayCallOptions } from "./gateway.js"; import { resolveInternalSessionKey, resolveMainSessionAlias } from "./sessions-helpers.js"; diff --git a/src/agents/tools/discord-actions-messaging.ts b/src/agents/tools/discord-actions-messaging.ts index 9d2029ca9f5..3a39cc248d0 100644 --- a/src/agents/tools/discord-actions-messaging.ts +++ b/src/agents/tools/discord-actions-messaging.ts @@ -20,6 +20,8 @@ import { sendStickerDiscord, unpinMessageDiscord, } from "../../discord/send.js"; +import { resolveDiscordChannelId } from "../../discord/targets.js"; +import { withNormalizedTimestamp } from "../date-time.js"; import { type ActionGate, jsonResult, @@ -27,8 +29,6 @@ import { readStringArrayParam, readStringParam, } from "./common.js"; -import { withNormalizedTimestamp } from "../date-time.js"; -import { resolveDiscordChannelId } from "../../discord/targets.js"; function parseDiscordMessageLink(link: string) { const normalized = link.trim(); diff --git a/src/agents/tools/discord-actions.test.ts b/src/agents/tools/discord-actions.test.ts index c676a94f15a..a36de127f18 100644 --- a/src/agents/tools/discord-actions.test.ts +++ b/src/agents/tools/discord-actions.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { DiscordActionConfig } from "../../config/config.js"; import { handleDiscordGuildAction } from "./discord-actions-guild.js"; import { handleDiscordMessagingAction } from "./discord-actions-messaging.js"; diff --git a/src/agents/tools/gateway-tool.ts b/src/agents/tools/gateway-tool.ts index 4c2037bf0d5..ea83faf00cc 100644 --- a/src/agents/tools/gateway-tool.ts +++ b/src/agents/tools/gateway-tool.ts @@ -1,14 +1,13 @@ import { Type } from "@sinclair/typebox"; - import type { OpenClawConfig } from "../../config/config.js"; import { loadConfig, resolveConfigSnapshotHash } from "../../config/io.js"; import { loadSessionStore, resolveStorePath } from "../../config/sessions.js"; -import { scheduleGatewaySigusr1Restart } from "../../infra/restart.js"; import { formatDoctorNonInteractiveHint, type RestartSentinelPayload, writeRestartSentinel, } from "../../infra/restart-sentinel.js"; +import { scheduleGatewaySigusr1Restart } from "../../infra/restart.js"; import { stringEnum } from "../schema/typebox.js"; import { type AnyAgentTool, jsonResult, readStringParam } from "./common.js"; import { callGatewayTool } from "./gateway.js"; diff --git a/src/agents/tools/gateway.test.ts b/src/agents/tools/gateway.test.ts index 7827a79470e..5b3b8495b7b 100644 --- a/src/agents/tools/gateway.test.ts +++ b/src/agents/tools/gateway.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import { callGatewayTool, resolveGatewayOptions } from "./gateway.js"; const callGatewayMock = vi.fn(); diff --git a/src/agents/tools/image-tool.helpers.ts b/src/agents/tools/image-tool.helpers.ts index 9fc366f90d9..ae98e40ba26 100644 --- a/src/agents/tools/image-tool.helpers.ts +++ b/src/agents/tools/image-tool.helpers.ts @@ -1,5 +1,4 @@ import type { AssistantMessage } from "@mariozechner/pi-ai"; - import type { OpenClawConfig } from "../../config/config.js"; import { extractAssistantText } from "../pi-embedded-utils.js"; diff --git a/src/agents/tools/image-tool.test.ts b/src/agents/tools/image-tool.test.ts index 39c21ab3cf1..e9e4661fd03 100644 --- a/src/agents/tools/image-tool.test.ts +++ b/src/agents/tools/image-tool.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import { __testing, createImageTool, resolveImageModelConfigForTool } from "./image-tool.js"; diff --git a/src/agents/tools/image-tool.ts b/src/agents/tools/image-tool.ts index d6968fc7357..fd87ad31053 100644 --- a/src/agents/tools/image-tool.ts +++ b/src/agents/tools/image-tool.ts @@ -1,11 +1,9 @@ +import { type Api, type Context, complete, type Model } from "@mariozechner/pi-ai"; +import { Type } from "@sinclair/typebox"; import fs from "node:fs/promises"; import path from "node:path"; - -import { type Api, type Context, complete, type Model } from "@mariozechner/pi-ai"; -import { discoverAuthStorage, discoverModels } from "../pi-model-discovery.js"; -import { Type } from "@sinclair/typebox"; - import type { OpenClawConfig } from "../../config/config.js"; +import type { AnyAgentTool } from "./common.js"; import { resolveUserPath } from "../../utils.js"; import { loadWebMedia } from "../../web/media.js"; import { ensureAuthProfileStore, listProfilesForProvider } from "../auth-profiles.js"; @@ -15,8 +13,8 @@ import { getApiKeyForModel, requireApiKey, resolveEnvApiKey } from "../model-aut import { runWithImageModelFallback } from "../model-fallback.js"; import { resolveConfiguredModelRef } from "../model-selection.js"; import { ensureOpenClawModelsJson } from "../models-config.js"; +import { discoverAuthStorage, discoverModels } from "../pi-model-discovery.js"; import { assertSandboxPath } from "../sandbox-paths.js"; -import type { AnyAgentTool } from "./common.js"; import { coerceImageAssistantText, coerceImageModelConfig, diff --git a/src/agents/tools/memory-tool.ts b/src/agents/tools/memory-tool.ts index 172ce75e17a..40dca26961c 100644 --- a/src/agents/tools/memory-tool.ts +++ b/src/agents/tools/memory-tool.ts @@ -1,10 +1,9 @@ import { Type } from "@sinclair/typebox"; - import type { OpenClawConfig } from "../../config/config.js"; +import type { AnyAgentTool } from "./common.js"; import { getMemorySearchManager } from "../../memory/index.js"; import { resolveSessionAgentId } from "../agent-scope.js"; import { resolveMemorySearchConfig } from "../memory-search.js"; -import type { AnyAgentTool } from "./common.js"; import { jsonResult, readNumberParam, readStringParam } from "./common.js"; const MemorySearchSchema = Type.Object({ diff --git a/src/agents/tools/message-tool.test.ts b/src/agents/tools/message-tool.test.ts index 97c34c9cebe..accff1d9459 100644 --- a/src/agents/tools/message-tool.test.ts +++ b/src/agents/tools/message-tool.test.ts @@ -1,8 +1,7 @@ import { describe, expect, it, vi } from "vitest"; - +import type { ChannelPlugin } from "../../channels/plugins/types.js"; import type { MessageActionRunResult } from "../../infra/outbound/message-action-runner.js"; import { setActivePluginRegistry } from "../../plugins/runtime.js"; -import type { ChannelPlugin } from "../../channels/plugins/types.js"; import { createTestRegistry } from "../../test-utils/channel-plugins.js"; import { createMessageTool } from "./message-tool.js"; diff --git a/src/agents/tools/message-tool.ts b/src/agents/tools/message-tool.ts index 3896590524f..ebb70c162a0 100644 --- a/src/agents/tools/message-tool.ts +++ b/src/agents/tools/message-tool.ts @@ -1,4 +1,7 @@ import { Type } from "@sinclair/typebox"; +import type { OpenClawConfig } from "../../config/config.js"; +import type { AnyAgentTool } from "./common.js"; +import { BLUEBUBBLES_GROUP_ACTIONS } from "../../channels/plugins/bluebubbles-actions.js"; import { listChannelMessageActions, supportsChannelMessageButtons, @@ -8,18 +11,15 @@ import { CHANNEL_MESSAGE_ACTION_NAMES, type ChannelMessageActionName, } from "../../channels/plugins/types.js"; -import { BLUEBUBBLES_GROUP_ACTIONS } from "../../channels/plugins/bluebubbles-actions.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { loadConfig } from "../../config/config.js"; import { GATEWAY_CLIENT_IDS, GATEWAY_CLIENT_MODES } from "../../gateway/protocol/client-info.js"; -import { normalizeTargetForProvider } from "../../infra/outbound/target-normalization.js"; import { getToolResult, runMessageAction } from "../../infra/outbound/message-action-runner.js"; -import { resolveSessionAgentId } from "../agent-scope.js"; +import { normalizeTargetForProvider } from "../../infra/outbound/target-normalization.js"; import { normalizeAccountId } from "../../routing/session-key.js"; -import { channelTargetSchema, channelTargetsSchema, stringEnum } from "../schema/typebox.js"; -import { listChannelSupportedActions } from "../channel-tools.js"; import { normalizeMessageChannel } from "../../utils/message-channel.js"; -import type { AnyAgentTool } from "./common.js"; +import { resolveSessionAgentId } from "../agent-scope.js"; +import { listChannelSupportedActions } from "../channel-tools.js"; +import { channelTargetSchema, channelTargetsSchema, stringEnum } from "../schema/typebox.js"; import { jsonResult, readNumberParam, readStringParam } from "./common.js"; const AllMessageActions = CHANNEL_MESSAGE_ACTION_NAMES; diff --git a/src/agents/tools/nodes-tool.ts b/src/agents/tools/nodes-tool.ts index 7d6b7aeacda..4fce2a7f385 100644 --- a/src/agents/tools/nodes-tool.ts +++ b/src/agents/tools/nodes-tool.ts @@ -1,8 +1,7 @@ -import crypto from "node:crypto"; - import type { AgentToolResult } from "@mariozechner/pi-agent-core"; import { Type } from "@sinclair/typebox"; - +import crypto from "node:crypto"; +import type { OpenClawConfig } from "../../config/config.js"; import { type CameraFacing, cameraTempPath, @@ -17,7 +16,6 @@ import { writeScreenRecordToFile, } from "../../cli/nodes-screen.js"; import { parseDurationMs } from "../../cli/parse-duration.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { imageMimeFromFormat } from "../../media/mime.js"; import { resolveSessionAgentId } from "../agent-scope.js"; import { optionalStringEnum, stringEnum } from "../schema/typebox.js"; diff --git a/src/agents/tools/session-status-tool.ts b/src/agents/tools/session-status-tool.ts index d1cf333ce2d..798cf6bada9 100644 --- a/src/agents/tools/session-status-tool.ts +++ b/src/agents/tools/session-status-tool.ts @@ -1,4 +1,6 @@ import { Type } from "@sinclair/typebox"; +import type { OpenClawConfig } from "../../config/config.js"; +import type { AnyAgentTool } from "./common.js"; import { resolveAgentDir } from "../../agents/agent-scope.js"; import { ensureAuthProfileStore, @@ -15,11 +17,9 @@ import { resolveDefaultModelForAgent, resolveModelRefFromString, } from "../../agents/model-selection.js"; -import { formatUserTime, resolveUserTimeFormat, resolveUserTimezone } from "../date-time.js"; import { normalizeGroupActivation } from "../../auto-reply/group-activation.js"; import { getFollowupQueueDepth, resolveQueueSettings } from "../../auto-reply/reply/queue.js"; import { buildStatusMessage } from "../../auto-reply/status.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { loadConfig } from "../../config/config.js"; import { loadSessionStore, @@ -27,6 +27,7 @@ import { type SessionEntry, updateSessionStore, } from "../../config/sessions.js"; +import { loadCombinedSessionStoreForGateway } from "../../gateway/session-utils.js"; import { formatUsageWindowSummary, loadProviderUsageSummary, @@ -38,7 +39,7 @@ import { resolveAgentIdFromSessionKey, } from "../../routing/session-key.js"; import { applyModelOverrideToSessionEntry } from "../../sessions/model-overrides.js"; -import type { AnyAgentTool } from "./common.js"; +import { formatUserTime, resolveUserTimeFormat, resolveUserTimezone } from "../date-time.js"; import { readStringParam } from "./common.js"; import { shouldResolveSessionIdInput, @@ -46,7 +47,6 @@ import { resolveMainSessionAlias, createAgentToAgentPolicy, } from "./sessions-helpers.js"; -import { loadCombinedSessionStoreForGateway } from "../../gateway/session-utils.js"; const SessionStatusToolSchema = Type.Object({ sessionKey: Type.Optional(Type.String()), diff --git a/src/agents/tools/sessions-announce-target.test.ts b/src/agents/tools/sessions-announce-target.test.ts index 80ba138dd10..4a339e7fbd6 100644 --- a/src/agents/tools/sessions-announce-target.test.ts +++ b/src/agents/tools/sessions-announce-target.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import { createTestRegistry } from "../../test-utils/channel-plugins.js"; const callGatewayMock = vi.fn(); diff --git a/src/agents/tools/sessions-announce-target.ts b/src/agents/tools/sessions-announce-target.ts index 076fc341af3..f4119e033df 100644 --- a/src/agents/tools/sessions-announce-target.ts +++ b/src/agents/tools/sessions-announce-target.ts @@ -1,8 +1,8 @@ +import type { AnnounceTarget } from "./sessions-send-helpers.js"; import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js"; import { callGateway } from "../../gateway/call.js"; -import type { AnnounceTarget } from "./sessions-send-helpers.js"; -import { resolveAnnounceTargetFromKey } from "./sessions-send-helpers.js"; import { SessionListRow } from "./sessions-helpers.js"; +import { resolveAnnounceTargetFromKey } from "./sessions-send-helpers.js"; export async function resolveAnnounceTarget(params: { sessionKey: string; diff --git a/src/agents/tools/sessions-helpers.test.ts b/src/agents/tools/sessions-helpers.test.ts index cc6d1fbc7bc..34c85d6466e 100644 --- a/src/agents/tools/sessions-helpers.test.ts +++ b/src/agents/tools/sessions-helpers.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { extractAssistantText, sanitizeTextContent } from "./sessions-helpers.js"; describe("sanitizeTextContent", () => { diff --git a/src/agents/tools/sessions-helpers.ts b/src/agents/tools/sessions-helpers.ts index b951fe9a858..30a287e88f2 100644 --- a/src/agents/tools/sessions-helpers.ts +++ b/src/agents/tools/sessions-helpers.ts @@ -1,12 +1,12 @@ import type { OpenClawConfig } from "../../config/config.js"; import { callGateway } from "../../gateway/call.js"; +import { isAcpSessionKey, normalizeMainKey } from "../../routing/session-key.js"; import { sanitizeUserFacingText } from "../pi-embedded-helpers.js"; import { stripDowngradedToolCallText, stripMinimaxToolCallXml, stripThinkingTagsFromText, } from "../pi-embedded-utils.js"; -import { isAcpSessionKey, normalizeMainKey } from "../../routing/session-key.js"; export type SessionKind = "main" | "group" | "cron" | "hook" | "node" | "other"; diff --git a/src/agents/tools/sessions-history-tool.ts b/src/agents/tools/sessions-history-tool.ts index b1e54488a02..091d8051c82 100644 --- a/src/agents/tools/sessions-history-tool.ts +++ b/src/agents/tools/sessions-history-tool.ts @@ -1,9 +1,8 @@ import { Type } from "@sinclair/typebox"; - +import type { AnyAgentTool } from "./common.js"; import { loadConfig } from "../../config/config.js"; import { callGateway } from "../../gateway/call.js"; import { isSubagentSessionKey, resolveAgentIdFromSessionKey } from "../../routing/session-key.js"; -import type { AnyAgentTool } from "./common.js"; import { jsonResult, readStringParam } from "./common.js"; import { createAgentToAgentPolicy, diff --git a/src/agents/tools/sessions-list-tool.ts b/src/agents/tools/sessions-list-tool.ts index 1e666fd9619..41b76815411 100644 --- a/src/agents/tools/sessions-list-tool.ts +++ b/src/agents/tools/sessions-list-tool.ts @@ -1,11 +1,9 @@ -import path from "node:path"; - import { Type } from "@sinclair/typebox"; - +import path from "node:path"; +import type { AnyAgentTool } from "./common.js"; import { loadConfig } from "../../config/config.js"; import { callGateway } from "../../gateway/call.js"; import { isSubagentSessionKey, resolveAgentIdFromSessionKey } from "../../routing/session-key.js"; -import type { AnyAgentTool } from "./common.js"; import { jsonResult, readStringArrayParam } from "./common.js"; import { createAgentToAgentPolicy, diff --git a/src/agents/tools/sessions-send-helpers.ts b/src/agents/tools/sessions-send-helpers.ts index 94dc3fe0c6a..ef8b4c1df0d 100644 --- a/src/agents/tools/sessions-send-helpers.ts +++ b/src/agents/tools/sessions-send-helpers.ts @@ -1,9 +1,9 @@ +import type { OpenClawConfig } from "../../config/config.js"; import { getChannelPlugin, normalizeChannelId as normalizeAnyChannelId, } from "../../channels/plugins/index.js"; import { normalizeChannelId as normalizeChatChannelId } from "../../channels/registry.js"; -import type { OpenClawConfig } from "../../config/config.js"; const ANNOUNCE_SKIP_TOKEN = "ANNOUNCE_SKIP"; const REPLY_SKIP_TOKEN = "REPLY_SKIP"; diff --git a/src/agents/tools/sessions-send-tool.a2a.ts b/src/agents/tools/sessions-send-tool.a2a.ts index b0650f372bf..2157e8461ba 100644 --- a/src/agents/tools/sessions-send-tool.a2a.ts +++ b/src/agents/tools/sessions-send-tool.a2a.ts @@ -1,9 +1,8 @@ import crypto from "node:crypto"; - +import type { GatewayMessageChannel } from "../../utils/message-channel.js"; import { callGateway } from "../../gateway/call.js"; import { formatErrorMessage } from "../../infra/errors.js"; import { createSubsystemLogger } from "../../logging/subsystem.js"; -import type { GatewayMessageChannel } from "../../utils/message-channel.js"; import { AGENT_LANE_NESTED } from "../lanes.js"; import { readLatestAssistantReply, runAgentStep } from "./agent-step.js"; import { resolveAnnounceTarget } from "./sessions-announce-target.js"; diff --git a/src/agents/tools/sessions-send-tool.ts b/src/agents/tools/sessions-send-tool.ts index 5a792818a4d..de97e2a3685 100644 --- a/src/agents/tools/sessions-send-tool.ts +++ b/src/agents/tools/sessions-send-tool.ts @@ -1,7 +1,6 @@ -import crypto from "node:crypto"; - import { Type } from "@sinclair/typebox"; - +import crypto from "node:crypto"; +import type { AnyAgentTool } from "./common.js"; import { loadConfig } from "../../config/config.js"; import { callGateway } from "../../gateway/call.js"; import { @@ -15,7 +14,6 @@ import { INTERNAL_MESSAGE_CHANNEL, } from "../../utils/message-channel.js"; import { AGENT_LANE_NESTED } from "../lanes.js"; -import type { AnyAgentTool } from "./common.js"; import { jsonResult, readStringParam } from "./common.js"; import { createAgentToAgentPolicy, diff --git a/src/agents/tools/sessions-spawn-tool.ts b/src/agents/tools/sessions-spawn-tool.ts index c9bf851f3a9..c1abe004a96 100644 --- a/src/agents/tools/sessions-spawn-tool.ts +++ b/src/agents/tools/sessions-spawn-tool.ts @@ -1,7 +1,7 @@ -import crypto from "node:crypto"; - import { Type } from "@sinclair/typebox"; - +import crypto from "node:crypto"; +import type { GatewayMessageChannel } from "../../utils/message-channel.js"; +import type { AnyAgentTool } from "./common.js"; import { formatThinkingLevels, normalizeThinkLevel } from "../../auto-reply/thinking.js"; import { loadConfig } from "../../config/config.js"; import { callGateway } from "../../gateway/call.js"; @@ -11,13 +11,11 @@ import { parseAgentSessionKey, } from "../../routing/session-key.js"; import { normalizeDeliveryContext } from "../../utils/delivery-context.js"; -import type { GatewayMessageChannel } from "../../utils/message-channel.js"; import { resolveAgentConfig } from "../agent-scope.js"; import { AGENT_LANE_SUBAGENT } from "../lanes.js"; import { optionalStringEnum } from "../schema/typebox.js"; import { buildSubagentSystemPrompt } from "../subagent-announce.js"; import { registerSubagentRun } from "../subagent-registry.js"; -import type { AnyAgentTool } from "./common.js"; import { jsonResult, readStringParam } from "./common.js"; import { resolveDisplaySessionKey, diff --git a/src/agents/tools/slack-actions.test.ts b/src/agents/tools/slack-actions.test.ts index a8ac103d158..6ce3c8b9507 100644 --- a/src/agents/tools/slack-actions.test.ts +++ b/src/agents/tools/slack-actions.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import { handleSlackAction } from "./slack-actions.js"; diff --git a/src/agents/tools/slack-actions.ts b/src/agents/tools/slack-actions.ts index 88834c3eeb8..e4de2472ad9 100644 --- a/src/agents/tools/slack-actions.ts +++ b/src/agents/tools/slack-actions.ts @@ -1,5 +1,4 @@ import type { AgentToolResult } from "@mariozechner/pi-agent-core"; - import type { OpenClawConfig } from "../../config/config.js"; import { resolveSlackAccount } from "../../slack/accounts.js"; import { diff --git a/src/agents/tools/telegram-actions.test.ts b/src/agents/tools/telegram-actions.test.ts index 9c1acb97c7a..397edf036f5 100644 --- a/src/agents/tools/telegram-actions.test.ts +++ b/src/agents/tools/telegram-actions.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import { handleTelegramAction, readTelegramButtons } from "./telegram-actions.js"; diff --git a/src/agents/tools/telegram-actions.ts b/src/agents/tools/telegram-actions.ts index 8853cfa8d05..56ebcdd56cb 100644 --- a/src/agents/tools/telegram-actions.ts +++ b/src/agents/tools/telegram-actions.ts @@ -1,5 +1,9 @@ import type { AgentToolResult } from "@mariozechner/pi-agent-core"; import type { OpenClawConfig } from "../../config/config.js"; +import { + resolveTelegramInlineButtonsScope, + resolveTelegramTargetChatType, +} from "../../telegram/inline-buttons.js"; import { resolveTelegramReactionLevel } from "../../telegram/reaction-level.js"; import { deleteMessageTelegram, @@ -10,10 +14,6 @@ import { } from "../../telegram/send.js"; import { getCacheStats, searchStickers } from "../../telegram/sticker-cache.js"; import { resolveTelegramToken } from "../../telegram/token.js"; -import { - resolveTelegramInlineButtonsScope, - resolveTelegramTargetChatType, -} from "../../telegram/inline-buttons.js"; import { createActionGate, jsonResult, diff --git a/src/agents/tools/tts-tool.ts b/src/agents/tools/tts-tool.ts index fed7bd90cb4..1add5054db6 100644 --- a/src/agents/tools/tts-tool.ts +++ b/src/agents/tools/tts-tool.ts @@ -1,10 +1,9 @@ import { Type } from "@sinclair/typebox"; - -import { loadConfig } from "../../config/config.js"; import type { OpenClawConfig } from "../../config/config.js"; import type { GatewayMessageChannel } from "../../utils/message-channel.js"; -import { textToSpeech } from "../../tts/tts.js"; import type { AnyAgentTool } from "./common.js"; +import { loadConfig } from "../../config/config.js"; +import { textToSpeech } from "../../tts/tts.js"; import { readStringParam } from "./common.js"; const TtsToolSchema = Type.Object({ diff --git a/src/agents/tools/web-fetch.ssrf.test.ts b/src/agents/tools/web-fetch.ssrf.test.ts index b5c1936b1cf..3ff36a65d0f 100644 --- a/src/agents/tools/web-fetch.ssrf.test.ts +++ b/src/agents/tools/web-fetch.ssrf.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import * as ssrf from "../../infra/net/ssrf.js"; const lookupMock = vi.fn(); diff --git a/src/agents/tools/web-fetch.ts b/src/agents/tools/web-fetch.ts index b40f33c2bc8..94b6776878a 100644 --- a/src/agents/tools/web-fetch.ts +++ b/src/agents/tools/web-fetch.ts @@ -1,16 +1,22 @@ +import type { Dispatcher } from "undici"; import { Type } from "@sinclair/typebox"; - import type { OpenClawConfig } from "../../config/config.js"; +import type { AnyAgentTool } from "./common.js"; import { closeDispatcher, createPinnedDispatcher, resolvePinnedHostname, SsrFBlockedError, } from "../../infra/net/ssrf.js"; -import type { Dispatcher } from "undici"; import { stringEnum } from "../schema/typebox.js"; -import type { AnyAgentTool } from "./common.js"; import { jsonResult, readNumberParam, readStringParam } from "./common.js"; +import { + extractReadableContent, + htmlToMarkdown, + markdownToText, + truncateText, + type ExtractMode, +} from "./web-fetch-utils.js"; import { CacheEntry, DEFAULT_CACHE_TTL_MINUTES, @@ -23,13 +29,6 @@ import { withTimeout, writeCache, } from "./web-shared.js"; -import { - extractReadableContent, - htmlToMarkdown, - markdownToText, - truncateText, - type ExtractMode, -} from "./web-fetch-utils.js"; export { extractReadableContent } from "./web-fetch-utils.js"; diff --git a/src/agents/tools/web-search.test.ts b/src/agents/tools/web-search.test.ts index c6d2b64057d..ca836f82160 100644 --- a/src/agents/tools/web-search.test.ts +++ b/src/agents/tools/web-search.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { __testing } from "./web-search.js"; const { inferPerplexityBaseUrlFromApiKey, resolvePerplexityBaseUrl, normalizeFreshness } = diff --git a/src/agents/tools/web-search.ts b/src/agents/tools/web-search.ts index 4e0cc9f0ea4..1d891fbd5e3 100644 --- a/src/agents/tools/web-search.ts +++ b/src/agents/tools/web-search.ts @@ -1,8 +1,7 @@ import { Type } from "@sinclair/typebox"; - import type { OpenClawConfig } from "../../config/config.js"; -import { formatCliCommand } from "../../cli/command-format.js"; import type { AnyAgentTool } from "./common.js"; +import { formatCliCommand } from "../../cli/command-format.js"; import { jsonResult, readNumberParam, readStringParam } from "./common.js"; import { CacheEntry, diff --git a/src/agents/tools/web-tools.enabled-defaults.test.ts b/src/agents/tools/web-tools.enabled-defaults.test.ts index 41d44b12dcf..f9cdc2539fa 100644 --- a/src/agents/tools/web-tools.enabled-defaults.test.ts +++ b/src/agents/tools/web-tools.enabled-defaults.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import { createWebFetchTool, createWebSearchTool } from "./web-tools.js"; describe("web tools defaults", () => { diff --git a/src/agents/tools/web-tools.fetch.test.ts b/src/agents/tools/web-tools.fetch.test.ts index 15b9bd2ee95..9fad21f83b4 100644 --- a/src/agents/tools/web-tools.fetch.test.ts +++ b/src/agents/tools/web-tools.fetch.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import * as ssrf from "../../infra/net/ssrf.js"; import { createWebFetchTool } from "./web-tools.js"; diff --git a/src/agents/tools/web-tools.readability.test.ts b/src/agents/tools/web-tools.readability.test.ts index 75728bdeeb6..e907f16fa90 100644 --- a/src/agents/tools/web-tools.readability.test.ts +++ b/src/agents/tools/web-tools.readability.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { extractReadableContent } from "./web-tools.js"; const SAMPLE_HTML = ` diff --git a/src/agents/tools/whatsapp-actions.test.ts b/src/agents/tools/whatsapp-actions.test.ts index a3a976307dd..907c29e5195 100644 --- a/src/agents/tools/whatsapp-actions.test.ts +++ b/src/agents/tools/whatsapp-actions.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import { handleWhatsAppAction } from "./whatsapp-actions.js"; diff --git a/src/agents/tools/whatsapp-actions.ts b/src/agents/tools/whatsapp-actions.ts index 9e55e5bb6e5..d3b7fedb9c3 100644 --- a/src/agents/tools/whatsapp-actions.ts +++ b/src/agents/tools/whatsapp-actions.ts @@ -1,5 +1,4 @@ import type { AgentToolResult } from "@mariozechner/pi-agent-core"; - import type { OpenClawConfig } from "../../config/config.js"; import { sendReactionWhatsApp } from "../../web/outbound.js"; import { createActionGate, jsonResult, readReactionParams, readStringParam } from "./common.js"; diff --git a/src/agents/transcript-policy.ts b/src/agents/transcript-policy.ts index 6f1b167c7f9..6d74c3832b7 100644 --- a/src/agents/transcript-policy.ts +++ b/src/agents/transcript-policy.ts @@ -1,6 +1,6 @@ -import { isAntigravityClaude, isGoogleModelApi } from "./pi-embedded-helpers/google.js"; -import { normalizeProviderId } from "./model-selection.js"; import type { ToolCallIdMode } from "./tool-call-id.js"; +import { normalizeProviderId } from "./model-selection.js"; +import { isAntigravityClaude, isGoogleModelApi } from "./pi-embedded-helpers/google.js"; export type TranscriptSanitizeMode = "full" | "images-only"; diff --git a/src/agents/usage.test.ts b/src/agents/usage.test.ts index f0b0d53b4d0..8250f2488ef 100644 --- a/src/agents/usage.test.ts +++ b/src/agents/usage.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { hasNonzeroUsage, normalizeUsage } from "./usage.js"; describe("normalizeUsage", () => { diff --git a/src/agents/workspace-templates.test.ts b/src/agents/workspace-templates.test.ts index 5619ae44f55..39012e48b99 100644 --- a/src/agents/workspace-templates.test.ts +++ b/src/agents/workspace-templates.test.ts @@ -2,9 +2,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { pathToFileURL } from "node:url"; - import { describe, expect, it } from "vitest"; - import { resetWorkspaceTemplateDirCache, resolveWorkspaceTemplateDir, diff --git a/src/agents/workspace-templates.ts b/src/agents/workspace-templates.ts index c55e1d8ed39..ba5c0125311 100644 --- a/src/agents/workspace-templates.ts +++ b/src/agents/workspace-templates.ts @@ -1,7 +1,6 @@ import fs from "node:fs/promises"; import path from "node:path"; import { fileURLToPath } from "node:url"; - import { resolveOpenClawPackageRoot } from "../infra/openclaw-root.js"; const FALLBACK_TEMPLATE_DIR = path.resolve( diff --git a/src/agents/workspace.test.ts b/src/agents/workspace.test.ts index f8962b8ab16..282883e4d5c 100644 --- a/src/agents/workspace.test.ts +++ b/src/agents/workspace.test.ts @@ -1,11 +1,10 @@ import { describe, expect, it } from "vitest"; - +import { makeTempWorkspace, writeWorkspaceFile } from "../test-helpers/workspace.js"; import { DEFAULT_MEMORY_ALT_FILENAME, DEFAULT_MEMORY_FILENAME, loadWorkspaceBootstrapFiles, } from "./workspace.js"; -import { makeTempWorkspace, writeWorkspaceFile } from "../test-helpers/workspace.js"; describe("loadWorkspaceBootstrapFiles", () => { it("includes MEMORY.md when present", async () => { diff --git a/src/agents/workspace.ts b/src/agents/workspace.ts index 3c7ffc03705..f130a836afa 100644 --- a/src/agents/workspace.ts +++ b/src/agents/workspace.ts @@ -1,8 +1,8 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; -import { isSubagentSessionKey } from "../routing/session-key.js"; import { runCommandWithTimeout } from "../process/exec.js"; +import { isSubagentSessionKey } from "../routing/session-key.js"; import { resolveUserPath } from "../utils.js"; import { resolveWorkspaceTemplateDir } from "./workspace-templates.js"; diff --git a/src/auto-reply/chunk.test.ts b/src/auto-reply/chunk.test.ts index e1417d18c02..fc846fb9220 100644 --- a/src/auto-reply/chunk.test.ts +++ b/src/auto-reply/chunk.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { chunkByNewline, chunkMarkdownText, diff --git a/src/auto-reply/command-auth.ts b/src/auto-reply/command-auth.ts index aad616424e3..f08c9a6be61 100644 --- a/src/auto-reply/command-auth.ts +++ b/src/auto-reply/command-auth.ts @@ -1,9 +1,9 @@ import type { ChannelDock } from "../channels/dock.js"; -import { getChannelDock, listChannelDocks } from "../channels/dock.js"; import type { ChannelId } from "../channels/plugins/types.js"; -import { normalizeAnyChannelId } from "../channels/registry.js"; import type { OpenClawConfig } from "../config/config.js"; import type { MsgContext } from "./templating.js"; +import { getChannelDock, listChannelDocks } from "../channels/dock.js"; +import { normalizeAnyChannelId } from "../channels/registry.js"; export type CommandAuthorization = { providerId?: ChannelId; diff --git a/src/auto-reply/command-control.test.ts b/src/auto-reply/command-control.test.ts index 72b6b788e9c..c06d81aa73c 100644 --- a/src/auto-reply/command-control.test.ts +++ b/src/auto-reply/command-control.test.ts @@ -1,6 +1,6 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; +import type { MsgContext } from "./templating.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import { createTestRegistry } from "../test-utils/channel-plugins.js"; import { resolveCommandAuthorization } from "./command-auth.js"; @@ -8,7 +8,6 @@ import { hasControlCommand, hasInlineCommandTokens } from "./command-detection.j import { listChatCommands } from "./commands-registry.js"; import { parseActivationCommand } from "./group-activation.js"; import { parseSendPolicyCommand } from "./send-policy.js"; -import type { MsgContext } from "./templating.js"; beforeEach(() => { setActivePluginRegistry(createTestRegistry([])); diff --git a/src/auto-reply/commands-registry.data.ts b/src/auto-reply/commands-registry.data.ts index e9395347ed1..076541d98a6 100644 --- a/src/auto-reply/commands-registry.data.ts +++ b/src/auto-reply/commands-registry.data.ts @@ -1,12 +1,12 @@ -import { listChannelDocks } from "../channels/dock.js"; -import { getActivePluginRegistry } from "../plugins/runtime.js"; -import { listThinkingLevels } from "./thinking.js"; -import { COMMAND_ARG_FORMATTERS } from "./commands-args.js"; import type { ChatCommandDefinition, CommandCategory, CommandScope, } from "./commands-registry.types.js"; +import { listChannelDocks } from "../channels/dock.js"; +import { getActivePluginRegistry } from "../plugins/runtime.js"; +import { COMMAND_ARG_FORMATTERS } from "./commands-args.js"; +import { listThinkingLevels } from "./thinking.js"; type DefineChatCommandInput = { key: string; diff --git a/src/auto-reply/commands-registry.test.ts b/src/auto-reply/commands-registry.test.ts index f8209039c09..87fc8cd6aba 100644 --- a/src/auto-reply/commands-registry.test.ts +++ b/src/auto-reply/commands-registry.test.ts @@ -1,5 +1,7 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest"; - +import type { ChatCommandDefinition } from "./commands-registry.types.js"; +import { setActivePluginRegistry } from "../plugins/runtime.js"; +import { createTestRegistry } from "../test-utils/channel-plugins.js"; import { buildCommandText, buildCommandTextFromArgs, @@ -15,9 +17,6 @@ import { serializeCommandArgs, shouldHandleTextCommands, } from "./commands-registry.js"; -import type { ChatCommandDefinition } from "./commands-registry.types.js"; -import { setActivePluginRegistry } from "../plugins/runtime.js"; -import { createTestRegistry } from "../test-utils/channel-plugins.js"; beforeEach(() => { setActivePluginRegistry(createTestRegistry([])); diff --git a/src/auto-reply/commands-registry.ts b/src/auto-reply/commands-registry.ts index 7c0b099eb99..bff1c376455 100644 --- a/src/auto-reply/commands-registry.ts +++ b/src/auto-reply/commands-registry.ts @@ -1,8 +1,5 @@ -import type { OpenClawConfig } from "../config/types.js"; import type { SkillCommandSpec } from "../agents/skills.js"; -import { getChatCommands, getNativeCommandSurfaces } from "./commands-registry.data.js"; -import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js"; -import { resolveConfiguredModelRef } from "../agents/model-selection.js"; +import type { OpenClawConfig } from "../config/types.js"; import type { ChatCommandDefinition, CommandArgChoiceContext, @@ -15,6 +12,9 @@ import type { NativeCommandSpec, ShouldHandleTextCommandsParams, } from "./commands-registry.types.js"; +import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js"; +import { resolveConfiguredModelRef } from "../agents/model-selection.js"; +import { getChatCommands, getNativeCommandSurfaces } from "./commands-registry.data.js"; export type { ChatCommandDefinition, diff --git a/src/auto-reply/dispatch.ts b/src/auto-reply/dispatch.ts index b17dacc635a..d018623c7e0 100644 --- a/src/auto-reply/dispatch.ts +++ b/src/auto-reply/dispatch.ts @@ -1,9 +1,9 @@ import type { OpenClawConfig } from "../config/config.js"; +import type { DispatchFromConfigResult } from "./reply/dispatch-from-config.js"; import type { FinalizedMsgContext, MsgContext } from "./templating.js"; import type { GetReplyOptions } from "./types.js"; -import { finalizeInboundContext } from "./reply/inbound-context.js"; -import type { DispatchFromConfigResult } from "./reply/dispatch-from-config.js"; import { dispatchReplyFromConfig } from "./reply/dispatch-from-config.js"; +import { finalizeInboundContext } from "./reply/inbound-context.js"; import { createReplyDispatcher, createReplyDispatcherWithTyping, diff --git a/src/auto-reply/envelope.test.ts b/src/auto-reply/envelope.test.ts index 7860ecb497d..ecb35f0dd9c 100644 --- a/src/auto-reply/envelope.test.ts +++ b/src/auto-reply/envelope.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { formatAgentEnvelope, formatInboundEnvelope, diff --git a/src/auto-reply/envelope.ts b/src/auto-reply/envelope.ts index 6c1d83a913f..96b81b6b0fc 100644 --- a/src/auto-reply/envelope.ts +++ b/src/auto-reply/envelope.ts @@ -1,7 +1,7 @@ +import type { OpenClawConfig } from "../config/config.js"; import { resolveUserTimezone } from "../agents/date-time.js"; import { normalizeChatType } from "../channels/chat-type.js"; import { resolveSenderLabel, type SenderLabelParams } from "../channels/sender-label.js"; -import type { OpenClawConfig } from "../config/config.js"; export type AgentEnvelopeParams = { channel: string; diff --git a/src/auto-reply/heartbeat.test.ts b/src/auto-reply/heartbeat.test.ts index dd952e03733..5763d16261b 100644 --- a/src/auto-reply/heartbeat.test.ts +++ b/src/auto-reply/heartbeat.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { DEFAULT_HEARTBEAT_ACK_MAX_CHARS, isHeartbeatContentEffectivelyEmpty, diff --git a/src/auto-reply/inbound.test.ts b/src/auto-reply/inbound.test.ts index 40bc2be8e41..a1b6b35e6c3 100644 --- a/src/auto-reply/inbound.test.ts +++ b/src/auto-reply/inbound.test.ts @@ -1,13 +1,11 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import type { GroupKeyResolution } from "../config/sessions.js"; import { createInboundDebouncer } from "./inbound-debounce.js"; -import { applyTemplate, type MsgContext, type TemplateContext } from "./templating.js"; +import { resolveGroupRequireMention } from "./reply/groups.js"; import { finalizeInboundContext } from "./reply/inbound-context.js"; import { buildInboundDedupeKey, @@ -16,13 +14,13 @@ import { } from "./reply/inbound-dedupe.js"; import { formatInboundBodyWithSenderMeta } from "./reply/inbound-sender-meta.js"; import { normalizeInboundTextNewlines } from "./reply/inbound-text.js"; -import { resolveGroupRequireMention } from "./reply/groups.js"; import { buildMentionRegexes, matchesMentionPatterns, normalizeMentionText, } from "./reply/mentions.js"; import { initSessionState } from "./reply/session.js"; +import { applyTemplate, type MsgContext, type TemplateContext } from "./templating.js"; describe("applyTemplate", () => { it("renders primitive values", () => { diff --git a/src/auto-reply/reply.block-streaming.test.ts b/src/auto-reply/reply.block-streaming.test.ts index 340f04de0c9..5a1f97d1d4d 100644 --- a/src/auto-reply/reply.block-streaming.test.ts +++ b/src/auto-reply/reply.block-streaming.test.ts @@ -1,7 +1,5 @@ import path from "node:path"; - import { beforeEach, describe, expect, it, vi } from "vitest"; - import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; import { loadModelCatalog } from "../agents/model-catalog.js"; import { getReplyFromConfig } from "./reply.js"; diff --git a/src/auto-reply/reply.directive.parse.test.ts b/src/auto-reply/reply.directive.parse.test.ts index 545c5e16976..bbaa3f0d0fc 100644 --- a/src/auto-reply/reply.directive.parse.test.ts +++ b/src/auto-reply/reply.directive.parse.test.ts @@ -1,6 +1,4 @@ import { describe, expect, it } from "vitest"; - -import { extractStatusDirective } from "./reply/directives.js"; import { extractElevatedDirective, extractExecDirective, @@ -10,6 +8,7 @@ import { extractThinkDirective, extractVerboseDirective, } from "./reply.js"; +import { extractStatusDirective } from "./reply/directives.js"; describe("directive parsing", () => { it("ignores verbose directive inside URL", () => { diff --git a/src/auto-reply/reply.heartbeat-typing.test.ts b/src/auto-reply/reply.heartbeat-typing.test.ts index 25ceca37db4..3b374ec4850 100644 --- a/src/auto-reply/reply.heartbeat-typing.test.ts +++ b/src/auto-reply/reply.heartbeat-typing.test.ts @@ -1,7 +1,5 @@ import { join } from "node:path"; - import { afterEach, describe, expect, it, vi } from "vitest"; - import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; const runEmbeddedPiAgentMock = vi.fn(); diff --git a/src/auto-reply/reply.media-note.test.ts b/src/auto-reply/reply.media-note.test.ts index 7c62fbf9b38..d864addc8b8 100644 --- a/src/auto-reply/reply.media-note.test.ts +++ b/src/auto-reply/reply.media-note.test.ts @@ -1,7 +1,5 @@ import path from "node:path"; - import { describe, expect, it, vi } from "vitest"; - import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; import { runEmbeddedPiAgent } from "../agents/pi-embedded.js"; import { getReplyFromConfig } from "./reply.js"; diff --git a/src/auto-reply/reply.queue.test.ts b/src/auto-reply/reply.queue.test.ts index b8fbab6f7ab..5630046c9b5 100644 --- a/src/auto-reply/reply.queue.test.ts +++ b/src/auto-reply/reply.queue.test.ts @@ -1,7 +1,5 @@ import path from "node:path"; - import { afterEach, describe, expect, it, vi } from "vitest"; - import { pollUntil } from "../../test/helpers/poll.js"; import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; import { diff --git a/src/auto-reply/reply.triggers.trigger-handling.filters-usage-summary-current-model-provider.e2e.test.ts b/src/auto-reply/reply.triggers.trigger-handling.filters-usage-summary-current-model-provider.e2e.test.ts index dcf2bbc5ca7..92e6b15df8c 100644 --- a/src/auto-reply/reply.triggers.trigger-handling.filters-usage-summary-current-model-provider.e2e.test.ts +++ b/src/auto-reply/reply.triggers.trigger-handling.filters-usage-summary-current-model-provider.e2e.test.ts @@ -1,5 +1,5 @@ -import { join } from "node:path"; import { readFile } from "node:fs/promises"; +import { join } from "node:path"; import { afterEach, describe, expect, it, vi } from "vitest"; import { normalizeTestText } from "../../test/helpers/normalize-text.js"; import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; diff --git a/src/auto-reply/reply.triggers.trigger-handling.stages-inbound-media-into-sandbox-workspace.security.test.ts b/src/auto-reply/reply.triggers.trigger-handling.stages-inbound-media-into-sandbox-workspace.security.test.ts index cd17bb340ae..4fdf420d13a 100644 --- a/src/auto-reply/reply.triggers.trigger-handling.stages-inbound-media-into-sandbox-workspace.security.test.ts +++ b/src/auto-reply/reply.triggers.trigger-handling.stages-inbound-media-into-sandbox-workspace.security.test.ts @@ -1,8 +1,8 @@ import fs from "node:fs/promises"; import { basename, join } from "node:path"; import { afterEach, describe, expect, it, vi } from "vitest"; -import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; import type { MsgContext, TemplateContext } from "../templating.js"; +import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; const sandboxMocks = vi.hoisted(() => ({ ensureSandboxWorkspaceForSession: vi.fn(), diff --git a/src/auto-reply/reply.triggers.trigger-handling.stages-inbound-media-into-sandbox-workspace.test.ts b/src/auto-reply/reply.triggers.trigger-handling.stages-inbound-media-into-sandbox-workspace.test.ts index 78c1d1c8294..cd453e969b3 100644 --- a/src/auto-reply/reply.triggers.trigger-handling.stages-inbound-media-into-sandbox-workspace.test.ts +++ b/src/auto-reply/reply.triggers.trigger-handling.stages-inbound-media-into-sandbox-workspace.test.ts @@ -1,8 +1,8 @@ import fs from "node:fs/promises"; import { basename, join } from "node:path"; import { afterEach, describe, expect, it, vi } from "vitest"; -import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; import type { MsgContext, TemplateContext } from "./templating.js"; +import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; const sandboxMocks = vi.hoisted(() => ({ ensureSandboxWorkspaceForSession: vi.fn(), diff --git a/src/auto-reply/reply.triggers.trigger-handling.targets-active-session-native-stop.e2e.test.ts b/src/auto-reply/reply.triggers.trigger-handling.targets-active-session-native-stop.e2e.test.ts index a9112637578..a6511f9e1e6 100644 --- a/src/auto-reply/reply.triggers.trigger-handling.targets-active-session-native-stop.e2e.test.ts +++ b/src/auto-reply/reply.triggers.trigger-handling.targets-active-session-native-stop.e2e.test.ts @@ -50,8 +50,8 @@ vi.mock("../agents/model-catalog.js", () => modelCatalogMocks); import { abortEmbeddedPiRun, runEmbeddedPiAgent } from "../agents/pi-embedded.js"; import { loadSessionStore } from "../config/sessions.js"; -import { enqueueFollowupRun, getFollowupQueueDepth, type FollowupRun } from "./reply/queue.js"; import { getReplyFromConfig } from "./reply.js"; +import { enqueueFollowupRun, getFollowupQueueDepth, type FollowupRun } from "./reply/queue.js"; const MAIN_SESSION_KEY = "agent:main:main"; diff --git a/src/auto-reply/reply/abort.ts b/src/auto-reply/reply/abort.ts index 053f5890b0c..42b4f1708ab 100644 --- a/src/auto-reply/reply/abort.ts +++ b/src/auto-reply/reply/abort.ts @@ -1,24 +1,24 @@ +import type { OpenClawConfig } from "../../config/config.js"; +import type { FinalizedMsgContext, MsgContext } from "../templating.js"; import { resolveSessionAgentId } from "../../agents/agent-scope.js"; import { abortEmbeddedPiRun } from "../../agents/pi-embedded.js"; import { listSubagentRunsForRequester } from "../../agents/subagent-registry.js"; -import type { OpenClawConfig } from "../../config/config.js"; +import { + resolveInternalSessionKey, + resolveMainSessionAlias, +} from "../../agents/tools/sessions-helpers.js"; import { loadSessionStore, resolveStorePath, type SessionEntry, updateSessionStore, } from "../../config/sessions.js"; +import { logVerbose } from "../../globals.js"; import { parseAgentSessionKey } from "../../routing/session-key.js"; import { resolveCommandAuthorization } from "../command-auth.js"; import { normalizeCommandBody } from "../commands-registry.js"; -import type { FinalizedMsgContext, MsgContext } from "../templating.js"; -import { logVerbose } from "../../globals.js"; import { stripMentions, stripStructuralPrefixes } from "./mentions.js"; import { clearSessionQueues } from "./queue.js"; -import { - resolveInternalSessionKey, - resolveMainSessionAlias, -} from "../../agents/tools/sessions-helpers.js"; const ABORT_TRIGGERS = new Set(["stop", "esc", "abort", "wait", "exit", "interrupt"]); const ABORT_MEMORY = new Map(); diff --git a/src/auto-reply/reply/agent-runner-execution.ts b/src/auto-reply/reply/agent-runner-execution.ts index 6db986835f4..2cb64459d4f 100644 --- a/src/auto-reply/reply/agent-runner-execution.ts +++ b/src/auto-reply/reply/agent-runner-execution.ts @@ -1,17 +1,22 @@ import crypto from "node:crypto"; import fs from "node:fs"; +import type { TemplateContext } from "../templating.js"; +import type { VerboseLevel } from "../thinking.js"; +import type { GetReplyOptions, ReplyPayload } from "../types.js"; +import type { FollowupRun } from "./queue.js"; +import type { TypingSignaler } from "./typing-mode.js"; import { resolveAgentModelFallbacksOverride } from "../../agents/agent-scope.js"; import { runCliAgent } from "../../agents/cli-runner.js"; import { getCliSessionId } from "../../agents/cli-session.js"; import { runWithModelFallback } from "../../agents/model-fallback.js"; import { isCliProvider } from "../../agents/model-selection.js"; -import { runEmbeddedPiAgent } from "../../agents/pi-embedded.js"; import { isCompactionFailureError, isContextOverflowError, isLikelyContextOverflowError, sanitizeUserFacingText, } from "../../agents/pi-embedded-helpers.js"; +import { runEmbeddedPiAgent } from "../../agents/pi-embedded.js"; import { resolveAgentIdFromSessionKey, resolveGroupSessionKey, @@ -27,16 +32,11 @@ import { resolveMessageChannel, } from "../../utils/message-channel.js"; import { stripHeartbeatToken } from "../heartbeat.js"; -import type { TemplateContext } from "../templating.js"; -import type { VerboseLevel } from "../thinking.js"; import { isSilentReplyText, SILENT_REPLY_TOKEN } from "../tokens.js"; -import type { GetReplyOptions, ReplyPayload } from "../types.js"; import { buildThreadingToolContext, resolveEnforceFinalTag } from "./agent-runner-utils.js"; import { createBlockReplyPayloadKey, type BlockReplyPipeline } from "./block-reply-pipeline.js"; -import type { FollowupRun } from "./queue.js"; import { parseReplyDirectives } from "./reply-directives.js"; import { applyReplyTagsToPayload, isRenderablePayload } from "./reply-payloads.js"; -import type { TypingSignaler } from "./typing-mode.js"; export type AgentRunLoopResult = | { diff --git a/src/auto-reply/reply/agent-runner-helpers.ts b/src/auto-reply/reply/agent-runner-helpers.ts index 6f3658b7436..8e302841ccd 100644 --- a/src/auto-reply/reply/agent-runner-helpers.ts +++ b/src/auto-reply/reply/agent-runner-helpers.ts @@ -1,9 +1,9 @@ +import type { ReplyPayload } from "../types.js"; +import type { TypingSignaler } from "./typing-mode.js"; import { loadSessionStore } from "../../config/sessions.js"; import { isAudioFileName } from "../../media/mime.js"; import { normalizeVerboseLevel, type VerboseLevel } from "../thinking.js"; -import type { ReplyPayload } from "../types.js"; import { scheduleFollowupDrain } from "./queue.js"; -import type { TypingSignaler } from "./typing-mode.js"; const hasAudioMedia = (urls?: string[]): boolean => Boolean(urls?.some((url) => isAudioFileName(url))); diff --git a/src/auto-reply/reply/agent-runner-memory.ts b/src/auto-reply/reply/agent-runner-memory.ts index 1c2bb260058..867ba42f924 100644 --- a/src/auto-reply/reply/agent-runner-memory.ts +++ b/src/auto-reply/reply/agent-runner-memory.ts @@ -1,10 +1,14 @@ import crypto from "node:crypto"; +import type { OpenClawConfig } from "../../config/config.js"; +import type { TemplateContext } from "../templating.js"; +import type { VerboseLevel } from "../thinking.js"; +import type { GetReplyOptions } from "../types.js"; +import type { FollowupRun } from "./queue.js"; import { resolveAgentModelFallbacksOverride } from "../../agents/agent-scope.js"; import { runWithModelFallback } from "../../agents/model-fallback.js"; import { isCliProvider } from "../../agents/model-selection.js"; import { runEmbeddedPiAgent } from "../../agents/pi-embedded.js"; import { resolveSandboxConfigForAgent, resolveSandboxRuntimeStatus } from "../../agents/sandbox.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { resolveAgentIdFromSessionKey, type SessionEntry, @@ -12,16 +16,12 @@ import { } from "../../config/sessions.js"; import { logVerbose } from "../../globals.js"; import { registerAgentRunContext } from "../../infra/agent-events.js"; -import type { TemplateContext } from "../templating.js"; -import type { VerboseLevel } from "../thinking.js"; -import type { GetReplyOptions } from "../types.js"; import { buildThreadingToolContext, resolveEnforceFinalTag } from "./agent-runner-utils.js"; import { resolveMemoryFlushContextWindowTokens, resolveMemoryFlushSettings, shouldRunMemoryFlush, } from "./memory-flush.js"; -import type { FollowupRun } from "./queue.js"; import { incrementCompactionCount } from "./session-updates.js"; export async function runMemoryFlushIfNeeded(params: { diff --git a/src/auto-reply/reply/agent-runner-payloads.ts b/src/auto-reply/reply/agent-runner-payloads.ts index 614c1d7d04f..e8aad67063b 100644 --- a/src/auto-reply/reply/agent-runner-payloads.ts +++ b/src/auto-reply/reply/agent-runner-payloads.ts @@ -1,9 +1,9 @@ import type { ReplyToMode } from "../../config/types.js"; +import type { OriginatingChannelType } from "../templating.js"; +import type { ReplyPayload } from "../types.js"; import { logVerbose } from "../../globals.js"; import { stripHeartbeatToken } from "../heartbeat.js"; -import type { OriginatingChannelType } from "../templating.js"; import { SILENT_REPLY_TOKEN } from "../tokens.js"; -import type { ReplyPayload } from "../types.js"; import { formatBunFetchSocketError, isBunFetchSocketError } from "./agent-runner-utils.js"; import { createBlockReplyPayloadKey, type BlockReplyPipeline } from "./block-reply-pipeline.js"; import { parseReplyDirectives } from "./reply-directives.js"; diff --git a/src/auto-reply/reply/agent-runner-utils.test.ts b/src/auto-reply/reply/agent-runner-utils.test.ts index 98da5e1581b..145b93bd61d 100644 --- a/src/auto-reply/reply/agent-runner-utils.test.ts +++ b/src/auto-reply/reply/agent-runner-utils.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import type { TemplateContext } from "../templating.js"; import { buildThreadingToolContext } from "./agent-runner-utils.js"; diff --git a/src/auto-reply/reply/agent-runner-utils.ts b/src/auto-reply/reply/agent-runner-utils.ts index 164e6dfb8e0..b7c7153c70a 100644 --- a/src/auto-reply/reply/agent-runner-utils.ts +++ b/src/auto-reply/reply/agent-runner-utils.ts @@ -1,13 +1,13 @@ import type { NormalizedUsage } from "../../agents/usage.js"; -import { getChannelDock } from "../../channels/dock.js"; import type { ChannelId, ChannelThreadingToolContext } from "../../channels/plugins/types.js"; -import { normalizeAnyChannelId, normalizeChannelId } from "../../channels/registry.js"; import type { OpenClawConfig } from "../../config/config.js"; -import { isReasoningTagProvider } from "../../utils/provider-utils.js"; -import { estimateUsageCost, formatTokenCount, formatUsd } from "../../utils/usage-format.js"; import type { TemplateContext } from "../templating.js"; import type { ReplyPayload } from "../types.js"; import type { FollowupRun } from "./queue.js"; +import { getChannelDock } from "../../channels/dock.js"; +import { normalizeAnyChannelId, normalizeChannelId } from "../../channels/registry.js"; +import { isReasoningTagProvider } from "../../utils/provider-utils.js"; +import { estimateUsageCost, formatTokenCount, formatUsd } from "../../utils/usage-format.js"; const BUN_FETCH_SOCKET_ERROR_RE = /socket connection was closed unexpectedly/i; diff --git a/src/auto-reply/reply/agent-runner.block-streaming.test.ts b/src/auto-reply/reply/agent-runner.block-streaming.test.ts index 313f8916c60..8e6f036a13b 100644 --- a/src/auto-reply/reply/agent-runner.block-streaming.test.ts +++ b/src/auto-reply/reply/agent-runner.block-streaming.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { TemplateContext } from "../templating.js"; import type { FollowupRun, QueueSettings } from "./queue.js"; import { createMockTypingController } from "./test-helpers.js"; diff --git a/src/auto-reply/reply/agent-runner.claude-cli.test.ts b/src/auto-reply/reply/agent-runner.claude-cli.test.ts index 8b624f947a0..11b14253363 100644 --- a/src/auto-reply/reply/agent-runner.claude-cli.test.ts +++ b/src/auto-reply/reply/agent-runner.claude-cli.test.ts @@ -1,8 +1,8 @@ import crypto from "node:crypto"; import { describe, expect, it, vi } from "vitest"; -import { onAgentEvent } from "../../infra/agent-events.js"; import type { TemplateContext } from "../templating.js"; import type { FollowupRun, QueueSettings } from "./queue.js"; +import { onAgentEvent } from "../../infra/agent-events.js"; import { createMockTypingController } from "./test-helpers.js"; const runEmbeddedPiAgentMock = vi.fn(); diff --git a/src/auto-reply/reply/agent-runner.heartbeat-typing.runreplyagent-typing-heartbeat.resets-corrupted-gemini-sessions-deletes-transcripts.test.ts b/src/auto-reply/reply/agent-runner.heartbeat-typing.runreplyagent-typing-heartbeat.resets-corrupted-gemini-sessions-deletes-transcripts.test.ts index 6d6ac8fb3f6..9caaccf649e 100644 --- a/src/auto-reply/reply/agent-runner.heartbeat-typing.runreplyagent-typing-heartbeat.resets-corrupted-gemini-sessions-deletes-transcripts.test.ts +++ b/src/auto-reply/reply/agent-runner.heartbeat-typing.runreplyagent-typing-heartbeat.resets-corrupted-gemini-sessions-deletes-transcripts.test.ts @@ -3,11 +3,11 @@ import { tmpdir } from "node:os"; import path from "node:path"; import { describe, expect, it, vi } from "vitest"; import type { SessionEntry } from "../../config/sessions.js"; -import * as sessions from "../../config/sessions.js"; import type { TypingMode } from "../../config/types.js"; import type { TemplateContext } from "../templating.js"; import type { GetReplyOptions } from "../types.js"; import type { FollowupRun, QueueSettings } from "./queue.js"; +import * as sessions from "../../config/sessions.js"; import { createMockTypingController } from "./test-helpers.js"; const runEmbeddedPiAgentMock = vi.fn(); diff --git a/src/auto-reply/reply/agent-runner.heartbeat-typing.runreplyagent-typing-heartbeat.retries-after-compaction-failure-by-resetting-session.test.ts b/src/auto-reply/reply/agent-runner.heartbeat-typing.runreplyagent-typing-heartbeat.retries-after-compaction-failure-by-resetting-session.test.ts index 244ae5440ee..7f63443dfa2 100644 --- a/src/auto-reply/reply/agent-runner.heartbeat-typing.runreplyagent-typing-heartbeat.retries-after-compaction-failure-by-resetting-session.test.ts +++ b/src/auto-reply/reply/agent-runner.heartbeat-typing.runreplyagent-typing-heartbeat.retries-after-compaction-failure-by-resetting-session.test.ts @@ -3,11 +3,11 @@ import { tmpdir } from "node:os"; import path from "node:path"; import { beforeEach, describe, expect, it, vi } from "vitest"; import type { SessionEntry } from "../../config/sessions.js"; -import * as sessions from "../../config/sessions.js"; import type { TypingMode } from "../../config/types.js"; import type { TemplateContext } from "../templating.js"; import type { GetReplyOptions } from "../types.js"; import type { FollowupRun, QueueSettings } from "./queue.js"; +import * as sessions from "../../config/sessions.js"; import { createMockTypingController } from "./test-helpers.js"; const runEmbeddedPiAgentMock = vi.fn(); diff --git a/src/auto-reply/reply/agent-runner.heartbeat-typing.runreplyagent-typing-heartbeat.still-replies-even-if-session-reset-fails.test.ts b/src/auto-reply/reply/agent-runner.heartbeat-typing.runreplyagent-typing-heartbeat.still-replies-even-if-session-reset-fails.test.ts index 810fb6d1723..34a2ab73e1d 100644 --- a/src/auto-reply/reply/agent-runner.heartbeat-typing.runreplyagent-typing-heartbeat.still-replies-even-if-session-reset-fails.test.ts +++ b/src/auto-reply/reply/agent-runner.heartbeat-typing.runreplyagent-typing-heartbeat.still-replies-even-if-session-reset-fails.test.ts @@ -3,11 +3,11 @@ import { tmpdir } from "node:os"; import path from "node:path"; import { describe, expect, it, vi } from "vitest"; import type { SessionEntry } from "../../config/sessions.js"; -import * as sessions from "../../config/sessions.js"; import type { TypingMode } from "../../config/types.js"; import type { TemplateContext } from "../templating.js"; import type { GetReplyOptions } from "../types.js"; import type { FollowupRun, QueueSettings } from "./queue.js"; +import * as sessions from "../../config/sessions.js"; import { createMockTypingController } from "./test-helpers.js"; const runEmbeddedPiAgentMock = vi.fn(); diff --git a/src/auto-reply/reply/agent-runner.memory-flush.runreplyagent-memory-flush.increments-compaction-count-flush-compaction-completes.test.ts b/src/auto-reply/reply/agent-runner.memory-flush.runreplyagent-memory-flush.increments-compaction-count-flush-compaction-completes.test.ts index d9e8466129b..4279dbff356 100644 --- a/src/auto-reply/reply/agent-runner.memory-flush.runreplyagent-memory-flush.increments-compaction-count-flush-compaction-completes.test.ts +++ b/src/auto-reply/reply/agent-runner.memory-flush.runreplyagent-memory-flush.increments-compaction-count-flush-compaction-completes.test.ts @@ -3,8 +3,8 @@ import os from "node:os"; import path from "node:path"; import { describe, expect, it, vi } from "vitest"; import type { TemplateContext } from "../templating.js"; -import { DEFAULT_MEMORY_FLUSH_PROMPT } from "./memory-flush.js"; import type { FollowupRun, QueueSettings } from "./queue.js"; +import { DEFAULT_MEMORY_FLUSH_PROMPT } from "./memory-flush.js"; import { createMockTypingController } from "./test-helpers.js"; const runEmbeddedPiAgentMock = vi.fn(); diff --git a/src/auto-reply/reply/agent-runner.memory-flush.runreplyagent-memory-flush.runs-memory-flush-turn-updates-session-metadata.test.ts b/src/auto-reply/reply/agent-runner.memory-flush.runreplyagent-memory-flush.runs-memory-flush-turn-updates-session-metadata.test.ts index a93b3a13730..0a93669a3ac 100644 --- a/src/auto-reply/reply/agent-runner.memory-flush.runreplyagent-memory-flush.runs-memory-flush-turn-updates-session-metadata.test.ts +++ b/src/auto-reply/reply/agent-runner.memory-flush.runreplyagent-memory-flush.runs-memory-flush-turn-updates-session-metadata.test.ts @@ -3,8 +3,8 @@ import os from "node:os"; import path from "node:path"; import { describe, expect, it, vi } from "vitest"; import type { TemplateContext } from "../templating.js"; -import { DEFAULT_MEMORY_FLUSH_PROMPT } from "./memory-flush.js"; import type { FollowupRun, QueueSettings } from "./queue.js"; +import { DEFAULT_MEMORY_FLUSH_PROMPT } from "./memory-flush.js"; import { createMockTypingController } from "./test-helpers.js"; const runEmbeddedPiAgentMock = vi.fn(); diff --git a/src/auto-reply/reply/agent-runner.memory-flush.runreplyagent-memory-flush.uses-configured-prompts-memory-flush-runs.test.ts b/src/auto-reply/reply/agent-runner.memory-flush.runreplyagent-memory-flush.uses-configured-prompts-memory-flush-runs.test.ts index 30d69d8550a..df3de6b375e 100644 --- a/src/auto-reply/reply/agent-runner.memory-flush.runreplyagent-memory-flush.uses-configured-prompts-memory-flush-runs.test.ts +++ b/src/auto-reply/reply/agent-runner.memory-flush.runreplyagent-memory-flush.uses-configured-prompts-memory-flush-runs.test.ts @@ -3,8 +3,8 @@ import os from "node:os"; import path from "node:path"; import { describe, expect, it, vi } from "vitest"; import type { TemplateContext } from "../templating.js"; -import { DEFAULT_MEMORY_FLUSH_PROMPT } from "./memory-flush.js"; import type { FollowupRun, QueueSettings } from "./queue.js"; +import { DEFAULT_MEMORY_FLUSH_PROMPT } from "./memory-flush.js"; import { createMockTypingController } from "./test-helpers.js"; const runEmbeddedPiAgentMock = vi.fn(); diff --git a/src/auto-reply/reply/agent-runner.messaging-tools.test.ts b/src/auto-reply/reply/agent-runner.messaging-tools.test.ts index b93a9227c81..7cdb9286e5c 100644 --- a/src/auto-reply/reply/agent-runner.messaging-tools.test.ts +++ b/src/auto-reply/reply/agent-runner.messaging-tools.test.ts @@ -2,10 +2,9 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { describe, expect, it, vi } from "vitest"; - import type { TemplateContext } from "../templating.js"; -import { loadSessionStore, saveSessionStore, type SessionEntry } from "../../config/sessions.js"; import type { FollowupRun, QueueSettings } from "./queue.js"; +import { loadSessionStore, saveSessionStore, type SessionEntry } from "../../config/sessions.js"; import { createMockTypingController } from "./test-helpers.js"; const runEmbeddedPiAgentMock = vi.fn(); diff --git a/src/auto-reply/reply/agent-runner.reasoning-tags.test.ts b/src/auto-reply/reply/agent-runner.reasoning-tags.test.ts index 2859439f940..657b860dbe4 100644 --- a/src/auto-reply/reply/agent-runner.reasoning-tags.test.ts +++ b/src/auto-reply/reply/agent-runner.reasoning-tags.test.ts @@ -1,9 +1,8 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { SessionEntry } from "../../config/sessions.js"; import type { TemplateContext } from "../templating.js"; -import { DEFAULT_MEMORY_FLUSH_PROMPT } from "./memory-flush.js"; import type { FollowupRun, QueueSettings } from "./queue.js"; +import { DEFAULT_MEMORY_FLUSH_PROMPT } from "./memory-flush.js"; import { createMockTypingController } from "./test-helpers.js"; const runEmbeddedPiAgentMock = vi.fn(); diff --git a/src/auto-reply/reply/agent-runner.response-usage-footer.test.ts b/src/auto-reply/reply/agent-runner.response-usage-footer.test.ts index 27511f31229..5b53ed7eff1 100644 --- a/src/auto-reply/reply/agent-runner.response-usage-footer.test.ts +++ b/src/auto-reply/reply/agent-runner.response-usage-footer.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { SessionEntry } from "../../config/sessions.js"; import type { TemplateContext } from "../templating.js"; import type { FollowupRun, QueueSettings } from "./queue.js"; diff --git a/src/auto-reply/reply/agent-runner.ts b/src/auto-reply/reply/agent-runner.ts index c6ead849c2f..51655ea178a 100644 --- a/src/auto-reply/reply/agent-runner.ts +++ b/src/auto-reply/reply/agent-runner.ts @@ -1,5 +1,9 @@ import crypto from "node:crypto"; import fs from "node:fs"; +import type { TypingMode } from "../../config/types.js"; +import type { OriginatingChannelType, TemplateContext } from "../templating.js"; +import type { GetReplyOptions, ReplyPayload } from "../types.js"; +import type { TypingController } from "./typing.js"; import { lookupContextTokens } from "../../agents/context.js"; import { DEFAULT_CONTEXT_TOKENS } from "../../agents/defaults.js"; import { resolveModelAuthMode } from "../../agents/model-auth.js"; @@ -14,12 +18,10 @@ import { updateSessionStore, updateSessionStoreEntry, } from "../../config/sessions.js"; -import type { TypingMode } from "../../config/types.js"; +import { emitDiagnosticEvent, isDiagnosticsEnabled } from "../../infra/diagnostic-events.js"; import { defaultRuntime } from "../../runtime.js"; import { estimateUsageCost, resolveModelCostConfig } from "../../utils/usage-format.js"; -import type { OriginatingChannelType, TemplateContext } from "../templating.js"; import { resolveResponseUsageMode, type VerboseLevel } from "../thinking.js"; -import type { GetReplyOptions, ReplyPayload } from "../types.js"; import { runAgentTurnWithFallback } from "./agent-runner-execution.js"; import { createShouldEmitToolOutput, @@ -36,11 +38,9 @@ import { resolveBlockStreamingCoalescing } from "./block-streaming.js"; import { createFollowupRunner } from "./followup-runner.js"; import { enqueueFollowupRun, type FollowupRun, type QueueSettings } from "./queue.js"; import { createReplyToModeFilterForChannel, resolveReplyToMode } from "./reply-threading.js"; -import { persistSessionUsageUpdate } from "./session-usage.js"; import { incrementCompactionCount } from "./session-updates.js"; -import type { TypingController } from "./typing.js"; +import { persistSessionUsageUpdate } from "./session-usage.js"; import { createTypingSignaler } from "./typing-mode.js"; -import { emitDiagnosticEvent, isDiagnosticsEnabled } from "../../infra/diagnostic-events.js"; const BLOCK_REPLY_SEND_TIMEOUT_MS = 15_000; diff --git a/src/auto-reply/reply/bash-command.ts b/src/auto-reply/reply/bash-command.ts index f57afeb616c..9d0449de837 100644 --- a/src/auto-reply/reply/bash-command.ts +++ b/src/auto-reply/reply/bash-command.ts @@ -1,14 +1,14 @@ +import type { OpenClawConfig } from "../../config/config.js"; +import type { MsgContext } from "../templating.js"; +import type { ReplyPayload } from "../types.js"; import { resolveSessionAgentId } from "../../agents/agent-scope.js"; import { getFinishedSession, getSession, markExited } from "../../agents/bash-process-registry.js"; import { createExecTool } from "../../agents/bash-tools.js"; import { resolveSandboxRuntimeStatus } from "../../agents/sandbox.js"; import { killProcessTree } from "../../agents/shell-utils.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { formatCliCommand } from "../../cli/command-format.js"; import { logVerbose } from "../../globals.js"; import { clampInt } from "../../utils.js"; -import type { MsgContext } from "../templating.js"; -import type { ReplyPayload } from "../types.js"; import { stripMentions, stripStructuralPrefixes } from "./mentions.js"; const CHAT_BASH_SCOPE_KEY = "chat:bash"; diff --git a/src/auto-reply/reply/block-reply-pipeline.ts b/src/auto-reply/reply/block-reply-pipeline.ts index e6ed2a056fc..0bdf2fd9ff2 100644 --- a/src/auto-reply/reply/block-reply-pipeline.ts +++ b/src/auto-reply/reply/block-reply-pipeline.ts @@ -1,7 +1,7 @@ -import { logVerbose } from "../../globals.js"; import type { ReplyPayload } from "../types.js"; -import { createBlockReplyCoalescer } from "./block-reply-coalescer.js"; import type { BlockStreamingCoalescing } from "./block-streaming.js"; +import { logVerbose } from "../../globals.js"; +import { createBlockReplyCoalescer } from "./block-reply-coalescer.js"; export type BlockReplyPipeline = { enqueue: (payload: ReplyPayload) => void; diff --git a/src/auto-reply/reply/block-streaming.ts b/src/auto-reply/reply/block-streaming.ts index b9e93927166..28b12d69622 100644 --- a/src/auto-reply/reply/block-streaming.ts +++ b/src/auto-reply/reply/block-streaming.ts @@ -1,7 +1,7 @@ -import { getChannelDock } from "../../channels/dock.js"; -import { normalizeChannelId } from "../../channels/plugins/index.js"; import type { OpenClawConfig } from "../../config/config.js"; import type { BlockStreamingCoalesceConfig } from "../../config/types.js"; +import { getChannelDock } from "../../channels/dock.js"; +import { normalizeChannelId } from "../../channels/plugins/index.js"; import { normalizeAccountId } from "../../routing/session-key.js"; import { INTERNAL_MESSAGE_CHANNEL, diff --git a/src/auto-reply/reply/commands-allowlist.ts b/src/auto-reply/reply/commands-allowlist.ts index fd4f371319d..a57c739f45d 100644 --- a/src/auto-reply/reply/commands-allowlist.ts +++ b/src/auto-reply/reply/commands-allowlist.ts @@ -1,30 +1,30 @@ +import type { ChannelId } from "../../channels/plugins/types.js"; +import type { OpenClawConfig } from "../../config/config.js"; +import type { CommandHandler } from "./commands-types.js"; +import { getChannelDock } from "../../channels/dock.js"; +import { resolveChannelConfigWrites } from "../../channels/plugins/config-writes.js"; +import { listPairingChannels } from "../../channels/plugins/pairing.js"; +import { normalizeChannelId } from "../../channels/registry.js"; import { readConfigFileSnapshot, validateConfigObjectWithPlugins, writeConfigFile, } from "../../config/config.js"; -import { resolveChannelConfigWrites } from "../../channels/plugins/config-writes.js"; -import { getChannelDock } from "../../channels/dock.js"; -import { normalizeChannelId } from "../../channels/registry.js"; -import { listPairingChannels } from "../../channels/plugins/pairing.js"; -import { logVerbose } from "../../globals.js"; -import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../routing/session-key.js"; import { resolveDiscordAccount } from "../../discord/accounts.js"; -import { resolveIMessageAccount } from "../../imessage/accounts.js"; -import { resolveSignalAccount } from "../../signal/accounts.js"; -import { resolveSlackAccount } from "../../slack/accounts.js"; -import { resolveTelegramAccount } from "../../telegram/accounts.js"; -import { resolveWhatsAppAccount } from "../../web/accounts.js"; -import { resolveSlackUserAllowlist } from "../../slack/resolve-users.js"; import { resolveDiscordUserAllowlist } from "../../discord/resolve-users.js"; +import { logVerbose } from "../../globals.js"; +import { resolveIMessageAccount } from "../../imessage/accounts.js"; import { addChannelAllowFromStoreEntry, readChannelAllowFromStore, removeChannelAllowFromStoreEntry, } from "../../pairing/pairing-store.js"; -import type { OpenClawConfig } from "../../config/config.js"; -import type { ChannelId } from "../../channels/plugins/types.js"; -import type { CommandHandler } from "./commands-types.js"; +import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../routing/session-key.js"; +import { resolveSignalAccount } from "../../signal/accounts.js"; +import { resolveSlackAccount } from "../../slack/accounts.js"; +import { resolveSlackUserAllowlist } from "../../slack/resolve-users.js"; +import { resolveTelegramAccount } from "../../telegram/accounts.js"; +import { resolveWhatsAppAccount } from "../../web/accounts.js"; type AllowlistScope = "dm" | "group" | "all"; type AllowlistAction = "list" | "add" | "remove"; diff --git a/src/auto-reply/reply/commands-approve.test.ts b/src/auto-reply/reply/commands-approve.test.ts index b5fae963a3a..a4e2301b7e0 100644 --- a/src/auto-reply/reply/commands-approve.test.ts +++ b/src/auto-reply/reply/commands-approve.test.ts @@ -1,10 +1,9 @@ import { describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import type { MsgContext } from "../templating.js"; +import { callGateway } from "../../gateway/call.js"; import { buildCommandContext, handleCommands } from "./commands.js"; import { parseInlineDirectives } from "./directive-handling.js"; -import { callGateway } from "../../gateway/call.js"; vi.mock("../../gateway/call.js", () => ({ callGateway: vi.fn(), diff --git a/src/auto-reply/reply/commands-approve.ts b/src/auto-reply/reply/commands-approve.ts index 35f3400c754..30695ab7b5e 100644 --- a/src/auto-reply/reply/commands-approve.ts +++ b/src/auto-reply/reply/commands-approve.ts @@ -1,7 +1,7 @@ -import { callGateway } from "../../gateway/call.js"; -import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../utils/message-channel.js"; -import { logVerbose } from "../../globals.js"; import type { CommandHandler } from "./commands-types.js"; +import { callGateway } from "../../gateway/call.js"; +import { logVerbose } from "../../globals.js"; +import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../utils/message-channel.js"; const COMMAND = "/approve"; diff --git a/src/auto-reply/reply/commands-bash.ts b/src/auto-reply/reply/commands-bash.ts index de884241e66..541f342da61 100644 --- a/src/auto-reply/reply/commands-bash.ts +++ b/src/auto-reply/reply/commands-bash.ts @@ -1,6 +1,6 @@ +import type { CommandHandler } from "./commands-types.js"; import { logVerbose } from "../../globals.js"; import { handleBashChatCommand } from "./bash-command.js"; -import type { CommandHandler } from "./commands-types.js"; export const handleBashCommand: CommandHandler = async (params, allowTextCommands) => { if (!allowTextCommands) { diff --git a/src/auto-reply/reply/commands-compact.ts b/src/auto-reply/reply/commands-compact.ts index d9b63d4fbd4..59dcbcd8b6e 100644 --- a/src/auto-reply/reply/commands-compact.ts +++ b/src/auto-reply/reply/commands-compact.ts @@ -1,15 +1,15 @@ +import type { OpenClawConfig } from "../../config/config.js"; +import type { CommandHandler } from "./commands-types.js"; import { abortEmbeddedPiRun, compactEmbeddedPiSession, isEmbeddedPiRunActive, waitForEmbeddedPiRunEnd, } from "../../agents/pi-embedded.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { resolveSessionFilePath } from "../../config/sessions.js"; import { logVerbose } from "../../globals.js"; import { enqueueSystemEvent } from "../../infra/system-events.js"; import { formatContextUsageShort, formatTokenCount } from "../status.js"; -import type { CommandHandler } from "./commands-types.js"; import { stripMentions, stripStructuralPrefixes } from "./mentions.js"; import { incrementCompactionCount } from "./session-updates.js"; diff --git a/src/auto-reply/reply/commands-config.ts b/src/auto-reply/reply/commands-config.ts index c81be681cf7..e5f42c78a4f 100644 --- a/src/auto-reply/reply/commands-config.ts +++ b/src/auto-reply/reply/commands-config.ts @@ -1,24 +1,24 @@ -import { - readConfigFileSnapshot, - validateConfigObjectWithPlugins, - writeConfigFile, -} from "../../config/config.js"; +import type { CommandHandler } from "./commands-types.js"; +import { resolveChannelConfigWrites } from "../../channels/plugins/config-writes.js"; +import { normalizeChannelId } from "../../channels/registry.js"; import { getConfigValueAtPath, parseConfigPath, setConfigValueAtPath, unsetConfigValueAtPath, } from "../../config/config-paths.js"; +import { + readConfigFileSnapshot, + validateConfigObjectWithPlugins, + writeConfigFile, +} from "../../config/config.js"; import { getConfigOverrides, resetConfigOverrides, setConfigOverride, unsetConfigOverride, } from "../../config/runtime-overrides.js"; -import { resolveChannelConfigWrites } from "../../channels/plugins/config-writes.js"; -import { normalizeChannelId } from "../../channels/registry.js"; import { logVerbose } from "../../globals.js"; -import type { CommandHandler } from "./commands-types.js"; import { parseConfigCommand } from "./config-commands.js"; import { parseDebugCommand } from "./debug-commands.js"; diff --git a/src/auto-reply/reply/commands-context-report.ts b/src/auto-reply/reply/commands-context-report.ts index 20968f09414..f23575f7ac0 100644 --- a/src/auto-reply/reply/commands-context-report.ts +++ b/src/auto-reply/reply/commands-context-report.ts @@ -1,20 +1,20 @@ +import type { SessionSystemPromptReport } from "../../config/sessions/types.js"; +import type { ReplyPayload } from "../types.js"; +import type { HandleCommandsParams } from "./commands-types.js"; import { resolveSessionAgentIds } from "../../agents/agent-scope.js"; +import { resolveBootstrapContextForRun } from "../../agents/bootstrap-files.js"; +import { resolveDefaultModelForAgent } from "../../agents/model-selection.js"; import { resolveBootstrapMaxChars } from "../../agents/pi-embedded-helpers.js"; import { createOpenClawCodingTools } from "../../agents/pi-tools.js"; import { resolveSandboxRuntimeStatus } from "../../agents/sandbox.js"; import { buildWorkspaceSkillSnapshot } from "../../agents/skills.js"; import { getSkillsSnapshotVersion } from "../../agents/skills/refresh.js"; -import { buildAgentSystemPrompt } from "../../agents/system-prompt.js"; -import { buildSystemPromptReport } from "../../agents/system-prompt-report.js"; import { buildSystemPromptParams } from "../../agents/system-prompt-params.js"; -import { resolveDefaultModelForAgent } from "../../agents/model-selection.js"; +import { buildSystemPromptReport } from "../../agents/system-prompt-report.js"; +import { buildAgentSystemPrompt } from "../../agents/system-prompt.js"; import { buildToolSummaryMap } from "../../agents/tool-summaries.js"; -import { resolveBootstrapContextForRun } from "../../agents/bootstrap-files.js"; -import type { SessionSystemPromptReport } from "../../config/sessions/types.js"; import { getRemoteSkillEligibility } from "../../infra/skills-remote.js"; import { buildTtsSystemPromptHint } from "../../tts/tts.js"; -import type { ReplyPayload } from "../types.js"; -import type { HandleCommandsParams } from "./commands-types.js"; function estimateTokensFromChars(chars: number): number { return Math.ceil(Math.max(0, chars) / 4); diff --git a/src/auto-reply/reply/commands-context.ts b/src/auto-reply/reply/commands-context.ts index d5dd7d0b951..bacff2edd76 100644 --- a/src/auto-reply/reply/commands-context.ts +++ b/src/auto-reply/reply/commands-context.ts @@ -1,8 +1,8 @@ import type { OpenClawConfig } from "../../config/config.js"; -import { resolveCommandAuthorization } from "../command-auth.js"; -import { normalizeCommandBody } from "../commands-registry.js"; import type { MsgContext } from "../templating.js"; import type { CommandContext } from "./commands-types.js"; +import { resolveCommandAuthorization } from "../command-auth.js"; +import { normalizeCommandBody } from "../commands-registry.js"; import { stripMentions } from "./mentions.js"; export function buildCommandContext(params: { diff --git a/src/auto-reply/reply/commands-core.ts b/src/auto-reply/reply/commands-core.ts index 27fdad40b4b..4c20d8f66b1 100644 --- a/src/auto-reply/reply/commands-core.ts +++ b/src/auto-reply/reply/commands-core.ts @@ -1,8 +1,14 @@ +import type { + CommandHandler, + CommandHandlerResult, + HandleCommandsParams, +} from "./commands-types.js"; import { logVerbose } from "../../globals.js"; +import { createInternalHookEvent, triggerInternalHook } from "../../hooks/internal-hooks.js"; import { resolveSendPolicy } from "../../sessions/send-policy.js"; import { shouldHandleTextCommands } from "../commands-registry.js"; -import { createInternalHookEvent, triggerInternalHook } from "../../hooks/internal-hooks.js"; -import { routeReply } from "./route-reply.js"; +import { handleAllowlistCommand } from "./commands-allowlist.js"; +import { handleApproveCommand } from "./commands-approve.js"; import { handleBashCommand } from "./commands-bash.js"; import { handleCompactCommand } from "./commands-compact.js"; import { handleConfigCommand, handleDebugCommand } from "./commands-config.js"; @@ -13,11 +19,8 @@ import { handleStatusCommand, handleWhoamiCommand, } from "./commands-info.js"; -import { handleAllowlistCommand } from "./commands-allowlist.js"; -import { handleApproveCommand } from "./commands-approve.js"; -import { handleSubagentsCommand } from "./commands-subagents.js"; import { handleModelsCommand } from "./commands-models.js"; -import { handleTtsCommands } from "./commands-tts.js"; +import { handlePluginCommand } from "./commands-plugin.js"; import { handleAbortTrigger, handleActivationCommand, @@ -26,12 +29,9 @@ import { handleStopCommand, handleUsageCommand, } from "./commands-session.js"; -import { handlePluginCommand } from "./commands-plugin.js"; -import type { - CommandHandler, - CommandHandlerResult, - HandleCommandsParams, -} from "./commands-types.js"; +import { handleSubagentsCommand } from "./commands-subagents.js"; +import { handleTtsCommands } from "./commands-tts.js"; +import { routeReply } from "./route-reply.js"; const HANDLERS: CommandHandler[] = [ // Plugin commands are processed first, before built-in commands diff --git a/src/auto-reply/reply/commands-info.ts b/src/auto-reply/reply/commands-info.ts index b3bfcd7ae98..d10bd5af60d 100644 --- a/src/auto-reply/reply/commands-info.ts +++ b/src/auto-reply/reply/commands-info.ts @@ -1,3 +1,4 @@ +import type { CommandHandler } from "./commands-types.js"; import { logVerbose } from "../../globals.js"; import { listSkillCommandsForAgents } from "../skill-commands.js"; import { @@ -5,9 +6,8 @@ import { buildCommandsMessagePaginated, buildHelpMessage, } from "../status.js"; -import { buildStatusReply } from "./commands-status.js"; import { buildContextReply } from "./commands-context-report.js"; -import type { CommandHandler } from "./commands-types.js"; +import { buildStatusReply } from "./commands-status.js"; export const handleHelpCommand: CommandHandler = async (params, allowTextCommands) => { if (!allowTextCommands) { diff --git a/src/auto-reply/reply/commands-models.ts b/src/auto-reply/reply/commands-models.ts index 0759c881f30..dcef33d42a0 100644 --- a/src/auto-reply/reply/commands-models.ts +++ b/src/auto-reply/reply/commands-models.ts @@ -1,3 +1,7 @@ +import type { OpenClawConfig } from "../../config/config.js"; +import type { ReplyPayload } from "../types.js"; +import type { CommandHandler } from "./commands-types.js"; +import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../../agents/defaults.js"; import { loadModelCatalog } from "../../agents/model-catalog.js"; import { buildAllowedModelSet, @@ -6,10 +10,6 @@ import { resolveConfiguredModelRef, resolveModelRefFromString, } from "../../agents/model-selection.js"; -import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../../agents/defaults.js"; -import type { OpenClawConfig } from "../../config/config.js"; -import type { ReplyPayload } from "../types.js"; -import type { CommandHandler } from "./commands-types.js"; const PAGE_SIZE_DEFAULT = 20; const PAGE_SIZE_MAX = 100; diff --git a/src/auto-reply/reply/commands-parsing.test.ts b/src/auto-reply/reply/commands-parsing.test.ts index 7325f260a18..908cf7ca43c 100644 --- a/src/auto-reply/reply/commands-parsing.test.ts +++ b/src/auto-reply/reply/commands-parsing.test.ts @@ -1,9 +1,8 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import type { MsgContext } from "../templating.js"; -import { buildCommandContext, handleCommands } from "./commands.js"; import { extractMessageText } from "./commands-subagents.js"; +import { buildCommandContext, handleCommands } from "./commands.js"; import { parseConfigCommand } from "./config-commands.js"; import { parseDebugCommand } from "./debug-commands.js"; import { parseInlineDirectives } from "./directive-handling.js"; diff --git a/src/auto-reply/reply/commands-plugin.ts b/src/auto-reply/reply/commands-plugin.ts index 933576aad23..6cfc4f0f1fd 100644 --- a/src/auto-reply/reply/commands-plugin.ts +++ b/src/auto-reply/reply/commands-plugin.ts @@ -5,8 +5,8 @@ * This handler is called before built-in command handlers. */ -import { matchPluginCommand, executePluginCommand } from "../../plugins/commands.js"; import type { CommandHandler, CommandHandlerResult } from "./commands-types.js"; +import { matchPluginCommand, executePluginCommand } from "../../plugins/commands.js"; /** * Handle plugin-registered commands. diff --git a/src/auto-reply/reply/commands-policy.test.ts b/src/auto-reply/reply/commands-policy.test.ts index daab2f1576c..20c3f6828d8 100644 --- a/src/auto-reply/reply/commands-policy.test.ts +++ b/src/auto-reply/reply/commands-policy.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import type { MsgContext } from "../templating.js"; import { buildCommandContext, handleCommands } from "./commands.js"; diff --git a/src/auto-reply/reply/commands-session.ts b/src/auto-reply/reply/commands-session.ts index ff361a6a41a..a6c794cee20 100644 --- a/src/auto-reply/reply/commands-session.ts +++ b/src/auto-reply/reply/commands-session.ts @@ -1,21 +1,21 @@ -import { abortEmbeddedPiRun } from "../../agents/pi-embedded.js"; import type { SessionEntry } from "../../config/sessions.js"; +import type { CommandHandler } from "./commands-types.js"; +import { abortEmbeddedPiRun } from "../../agents/pi-embedded.js"; import { updateSessionStore } from "../../config/sessions.js"; import { logVerbose } from "../../globals.js"; import { createInternalHookEvent, triggerInternalHook } from "../../hooks/internal-hooks.js"; import { scheduleGatewaySigusr1Restart, triggerOpenClawRestart } from "../../infra/restart.js"; +import { loadCostUsageSummary, loadSessionCostSummary } from "../../infra/session-cost-usage.js"; +import { formatTokenCount, formatUsd } from "../../utils/usage-format.js"; import { parseActivationCommand } from "../group-activation.js"; import { parseSendPolicyCommand } from "../send-policy.js"; import { normalizeUsageDisplay, resolveResponseUsageMode } from "../thinking.js"; -import { loadCostUsageSummary, loadSessionCostSummary } from "../../infra/session-cost-usage.js"; -import { formatTokenCount, formatUsd } from "../../utils/usage-format.js"; import { formatAbortReplyText, isAbortTrigger, setAbortMemory, stopSubagentsForRequester, } from "./abort.js"; -import type { CommandHandler } from "./commands-types.js"; import { clearSessionQueues } from "./queue.js"; function resolveSessionEntryForKey( diff --git a/src/auto-reply/reply/commands-status.ts b/src/auto-reply/reply/commands-status.ts index 256512f0df9..d9a5176a251 100644 --- a/src/auto-reply/reply/commands-status.ts +++ b/src/auto-reply/reply/commands-status.ts @@ -1,22 +1,26 @@ +import type { OpenClawConfig } from "../../config/config.js"; +import type { SessionEntry, SessionScope } from "../../config/sessions.js"; +import type { MediaUnderstandingDecision } from "../../media-understanding/types.js"; +import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "../thinking.js"; +import type { ReplyPayload } from "../types.js"; +import type { CommandContext } from "./commands-types.js"; import { resolveAgentDir, resolveDefaultAgentId, resolveSessionAgentId, } from "../../agents/agent-scope.js"; -import { listSubagentRunsForRequester } from "../../agents/subagent-registry.js"; import { ensureAuthProfileStore, resolveAuthProfileDisplayLabel, resolveAuthProfileOrder, } from "../../agents/auth-profiles.js"; import { getCustomProviderApiKey, resolveEnvApiKey } from "../../agents/model-auth.js"; +import { normalizeProviderId } from "../../agents/model-selection.js"; +import { listSubagentRunsForRequester } from "../../agents/subagent-registry.js"; import { resolveInternalSessionKey, resolveMainSessionAlias, } from "../../agents/tools/sessions-helpers.js"; -import { normalizeProviderId } from "../../agents/model-selection.js"; -import type { OpenClawConfig } from "../../config/config.js"; -import type { SessionEntry, SessionScope } from "../../config/sessions.js"; import { logVerbose } from "../../globals.js"; import { formatUsageWindowSummary, @@ -25,11 +29,7 @@ import { } from "../../infra/provider-usage.js"; import { normalizeGroupActivation } from "../group-activation.js"; import { buildStatusMessage } from "../status.js"; -import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "../thinking.js"; -import type { ReplyPayload } from "../types.js"; -import type { CommandContext } from "./commands-types.js"; import { getFollowupQueueDepth, resolveQueueSettings } from "./queue.js"; -import type { MediaUnderstandingDecision } from "../../media-understanding/types.js"; import { resolveSubagentLabel } from "./subagents-utils.js"; function formatApiKeySnippet(apiKey: string): string { diff --git a/src/auto-reply/reply/commands-subagents.ts b/src/auto-reply/reply/commands-subagents.ts index 12e15140a4b..7d0d47e62b7 100644 --- a/src/auto-reply/reply/commands-subagents.ts +++ b/src/auto-reply/reply/commands-subagents.ts @@ -1,7 +1,8 @@ import crypto from "node:crypto"; - -import { abortEmbeddedPiRun } from "../../agents/pi-embedded.js"; +import type { SubagentRunRecord } from "../../agents/subagent-registry.js"; +import type { CommandHandler } from "./commands-types.js"; import { AGENT_LANE_SUBAGENT } from "../../agents/lanes.js"; +import { abortEmbeddedPiRun } from "../../agents/pi-embedded.js"; import { listSubagentRunsForRequester } from "../../agents/subagent-registry.js"; import { extractAssistantText, @@ -10,12 +11,13 @@ import { sanitizeTextContent, stripToolMessages, } from "../../agents/tools/sessions-helpers.js"; -import type { SubagentRunRecord } from "../../agents/subagent-registry.js"; import { loadSessionStore, resolveStorePath, updateSessionStore } from "../../config/sessions.js"; import { callGateway } from "../../gateway/call.js"; import { logVerbose } from "../../globals.js"; import { parseAgentSessionKey } from "../../routing/session-key.js"; import { INTERNAL_MESSAGE_CHANNEL } from "../../utils/message-channel.js"; +import { stopSubagentsForRequester } from "./abort.js"; +import { clearSessionQueues } from "./queue.js"; import { formatAgeShort, formatDurationShort, @@ -23,9 +25,6 @@ import { formatRunStatus, sortSubagentRuns, } from "./subagents-utils.js"; -import { stopSubagentsForRequester } from "./abort.js"; -import type { CommandHandler } from "./commands-types.js"; -import { clearSessionQueues } from "./queue.js"; type SubagentTargetResolution = { entry?: SubagentRunRecord; diff --git a/src/auto-reply/reply/commands-tts.ts b/src/auto-reply/reply/commands-tts.ts index 7ecee9b7e56..b31c5d1d766 100644 --- a/src/auto-reply/reply/commands-tts.ts +++ b/src/auto-reply/reply/commands-tts.ts @@ -1,6 +1,6 @@ -import { logVerbose } from "../../globals.js"; import type { ReplyPayload } from "../types.js"; import type { CommandHandler } from "./commands-types.js"; +import { logVerbose } from "../../globals.js"; import { getLastTtsAttempt, getTtsMaxLength, diff --git a/src/auto-reply/reply/commands-types.ts b/src/auto-reply/reply/commands-types.ts index 4c2fa696009..69689f6e989 100644 --- a/src/auto-reply/reply/commands-types.ts +++ b/src/auto-reply/reply/commands-types.ts @@ -1,7 +1,7 @@ +import type { SkillCommandSpec } from "../../agents/skills.js"; import type { ChannelId } from "../../channels/plugins/types.js"; import type { OpenClawConfig } from "../../config/config.js"; import type { SessionEntry, SessionScope } from "../../config/sessions.js"; -import type { SkillCommandSpec } from "../../agents/skills.js"; import type { MsgContext } from "../templating.js"; import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "../thinking.js"; import type { ReplyPayload } from "../types.js"; diff --git a/src/auto-reply/reply/commands.test.ts b/src/auto-reply/reply/commands.test.ts index d0d52520fb7..cef3e5149ec 100644 --- a/src/auto-reply/reply/commands.test.ts +++ b/src/auto-reply/reply/commands.test.ts @@ -1,17 +1,15 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterAll, beforeAll, describe, expect, it, vi } from "vitest"; - +import type { OpenClawConfig } from "../../config/config.js"; +import type { MsgContext } from "../templating.js"; import { addSubagentRunForTests, resetSubagentRegistryForTests, } from "../../agents/subagent-registry.js"; -import type { OpenClawConfig } from "../../config/config.js"; import * as internalHooks from "../../hooks/internal-hooks.js"; import { clearPluginCommands, registerPluginCommand } from "../../plugins/commands.js"; -import type { MsgContext } from "../templating.js"; import { resetBashChatCommandForTests } from "./bash-command.js"; import { buildCommandContext, handleCommands } from "./commands.js"; import { parseInlineDirectives } from "./directive-handling.js"; diff --git a/src/auto-reply/reply/directive-handling.auth.ts b/src/auto-reply/reply/directive-handling.auth.ts index a0eb43f134b..1b9ae92f8b2 100644 --- a/src/auto-reply/reply/directive-handling.auth.ts +++ b/src/auto-reply/reply/directive-handling.auth.ts @@ -1,3 +1,4 @@ +import type { OpenClawConfig } from "../../config/config.js"; import { isProfileInCooldown, resolveAuthProfileDisplayLabel, @@ -10,7 +11,6 @@ import { resolveEnvApiKey, } from "../../agents/model-auth.js"; import { normalizeProviderId } from "../../agents/model-selection.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { shortenHomePath } from "../../utils.js"; export type ModelAuthDetailMode = "compact" | "verbose"; diff --git a/src/auto-reply/reply/directive-handling.fast-lane.ts b/src/auto-reply/reply/directive-handling.fast-lane.ts index 39cec02d219..df183b16b5e 100644 --- a/src/auto-reply/reply/directive-handling.fast-lane.ts +++ b/src/auto-reply/reply/directive-handling.fast-lane.ts @@ -3,10 +3,10 @@ import type { OpenClawConfig } from "../../config/config.js"; import type { SessionEntry } from "../../config/sessions.js"; import type { MsgContext } from "../templating.js"; import type { ReplyPayload } from "../types.js"; -import { handleDirectiveOnly } from "./directive-handling.impl.js"; import type { InlineDirectives } from "./directive-handling.parse.js"; -import { isDirectiveOnly } from "./directive-handling.parse.js"; import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "./directives.js"; +import { handleDirectiveOnly } from "./directive-handling.impl.js"; +import { isDirectiveOnly } from "./directive-handling.parse.js"; export async function applyInlineDirectivesFastLane(params: { directives: InlineDirectives; diff --git a/src/auto-reply/reply/directive-handling.impl.ts b/src/auto-reply/reply/directive-handling.impl.ts index 76eda2d9bf9..a4ebc46a4d4 100644 --- a/src/auto-reply/reply/directive-handling.impl.ts +++ b/src/auto-reply/reply/directive-handling.impl.ts @@ -1,23 +1,24 @@ +import type { ModelAliasIndex } from "../../agents/model-selection.js"; +import type { OpenClawConfig } from "../../config/config.js"; +import type { ExecAsk, ExecHost, ExecSecurity } from "../../infra/exec-approvals.js"; +import type { ReplyPayload } from "../types.js"; +import type { InlineDirectives } from "./directive-handling.parse.js"; +import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "./directives.js"; import { resolveAgentConfig, resolveAgentDir, resolveSessionAgentId, } from "../../agents/agent-scope.js"; -import type { ModelAliasIndex } from "../../agents/model-selection.js"; import { resolveSandboxRuntimeStatus } from "../../agents/sandbox.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { type SessionEntry, updateSessionStore } from "../../config/sessions.js"; -import type { ExecAsk, ExecHost, ExecSecurity } from "../../infra/exec-approvals.js"; import { enqueueSystemEvent } from "../../infra/system-events.js"; import { applyVerboseOverride } from "../../sessions/level-overrides.js"; import { applyModelOverrideToSessionEntry } from "../../sessions/model-overrides.js"; import { formatThinkingLevels, formatXHighModelHint, supportsXHighThinking } from "../thinking.js"; -import type { ReplyPayload } from "../types.js"; import { maybeHandleModelDirectiveInfo, resolveModelSelectionFromDirective, } from "./directive-handling.model.js"; -import type { InlineDirectives } from "./directive-handling.parse.js"; import { maybeHandleQueueDirective } from "./directive-handling.queue-validation.js"; import { formatDirectiveAck, @@ -27,7 +28,6 @@ import { formatReasoningEvent, withOptions, } from "./directive-handling.shared.js"; -import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "./directives.js"; function resolveExecDefaults(params: { cfg: OpenClawConfig; diff --git a/src/auto-reply/reply/directive-handling.model-picker.ts b/src/auto-reply/reply/directive-handling.model-picker.ts index 0c2bcaf61e6..f95c7141bae 100644 --- a/src/auto-reply/reply/directive-handling.model-picker.ts +++ b/src/auto-reply/reply/directive-handling.model-picker.ts @@ -1,5 +1,5 @@ -import { type ModelRef, normalizeProviderId } from "../../agents/model-selection.js"; import type { OpenClawConfig } from "../../config/config.js"; +import { type ModelRef, normalizeProviderId } from "../../agents/model-selection.js"; export type ModelPickerCatalogEntry = { provider: string; diff --git a/src/auto-reply/reply/directive-handling.model.test.ts b/src/auto-reply/reply/directive-handling.model.test.ts index cf4cc19b639..4588908d157 100644 --- a/src/auto-reply/reply/directive-handling.model.test.ts +++ b/src/auto-reply/reply/directive-handling.model.test.ts @@ -1,10 +1,9 @@ import { describe, expect, it, vi } from "vitest"; - import type { ModelAliasIndex } from "../../agents/model-selection.js"; import type { OpenClawConfig } from "../../config/config.js"; import type { SessionEntry } from "../../config/sessions.js"; -import { parseInlineDirectives } from "./directive-handling.js"; import { handleDirectiveOnly } from "./directive-handling.impl.js"; +import { parseInlineDirectives } from "./directive-handling.js"; import { maybeHandleModelDirectiveInfo, resolveModelSelectionFromDirective, diff --git a/src/auto-reply/reply/directive-handling.model.ts b/src/auto-reply/reply/directive-handling.model.ts index eca6ae0ee84..c517b5cb1d3 100644 --- a/src/auto-reply/reply/directive-handling.model.ts +++ b/src/auto-reply/reply/directive-handling.model.ts @@ -1,3 +1,6 @@ +import type { OpenClawConfig } from "../../config/config.js"; +import type { ReplyPayload } from "../types.js"; +import type { InlineDirectives } from "./directive-handling.parse.js"; import { resolveAuthStorePathForDisplay } from "../../agents/auth-profiles.js"; import { type ModelAliasIndex, @@ -6,9 +9,8 @@ import { resolveConfiguredModelRef, resolveModelRefFromString, } from "../../agents/model-selection.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { shortenHomePath } from "../../utils.js"; -import type { ReplyPayload } from "../types.js"; +import { resolveModelsCommandReply } from "./commands-models.js"; import { formatAuthLabel, type ModelAuthDetailMode, @@ -19,8 +21,6 @@ import { type ModelPickerCatalogEntry, resolveProviderEndpointLabel, } from "./directive-handling.model-picker.js"; -import type { InlineDirectives } from "./directive-handling.parse.js"; -import { resolveModelsCommandReply } from "./commands-models.js"; import { type ModelDirectiveSelection, resolveModelDirectiveSelection } from "./model-selection.js"; function buildModelPickerCatalog(params: { diff --git a/src/auto-reply/reply/directive-handling.parse.ts b/src/auto-reply/reply/directive-handling.parse.ts index b09d5c553bc..dbef035b3b7 100644 --- a/src/auto-reply/reply/directive-handling.parse.ts +++ b/src/auto-reply/reply/directive-handling.parse.ts @@ -1,8 +1,9 @@ import type { OpenClawConfig } from "../../config/config.js"; import type { ExecAsk, ExecHost, ExecSecurity } from "../../infra/exec-approvals.js"; -import { extractModelDirective } from "../model.js"; import type { MsgContext } from "../templating.js"; import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "./directives.js"; +import type { QueueDropPolicy, QueueMode } from "./queue.js"; +import { extractModelDirective } from "../model.js"; import { extractElevatedDirective, extractExecDirective, @@ -12,7 +13,6 @@ import { extractVerboseDirective, } from "./directives.js"; import { stripMentions, stripStructuralPrefixes } from "./mentions.js"; -import type { QueueDropPolicy, QueueMode } from "./queue.js"; import { extractQueueDirective } from "./queue.js"; export type InlineDirectives = { diff --git a/src/auto-reply/reply/directive-handling.persist.ts b/src/auto-reply/reply/directive-handling.persist.ts index a96ea20870f..0e700238b30 100644 --- a/src/auto-reply/reply/directive-handling.persist.ts +++ b/src/auto-reply/reply/directive-handling.persist.ts @@ -1,3 +1,6 @@ +import type { OpenClawConfig } from "../../config/config.js"; +import type { InlineDirectives } from "./directive-handling.parse.js"; +import type { ElevatedLevel, ReasoningLevel } from "./directives.js"; import { resolveAgentDir, resolveDefaultAgentId, @@ -12,15 +15,12 @@ import { resolveDefaultModelForAgent, resolveModelRefFromString, } from "../../agents/model-selection.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { type SessionEntry, updateSessionStore } from "../../config/sessions.js"; import { enqueueSystemEvent } from "../../infra/system-events.js"; import { applyVerboseOverride } from "../../sessions/level-overrides.js"; import { applyModelOverrideToSessionEntry } from "../../sessions/model-overrides.js"; import { resolveProfileOverride } from "./directive-handling.auth.js"; -import type { InlineDirectives } from "./directive-handling.parse.js"; import { formatElevatedEvent, formatReasoningEvent } from "./directive-handling.shared.js"; -import type { ElevatedLevel, ReasoningLevel } from "./directives.js"; export async function persistInlineDirectives(params: { directives: InlineDirectives; diff --git a/src/auto-reply/reply/directive-handling.shared.ts b/src/auto-reply/reply/directive-handling.shared.ts index f380d3a7538..04d7ad0f64b 100644 --- a/src/auto-reply/reply/directive-handling.shared.ts +++ b/src/auto-reply/reply/directive-handling.shared.ts @@ -1,5 +1,5 @@ -import { formatCliCommand } from "../../cli/command-format.js"; import type { ElevatedLevel, ReasoningLevel } from "./directives.js"; +import { formatCliCommand } from "../../cli/command-format.js"; export const SYSTEM_MARK = "⚙️"; diff --git a/src/auto-reply/reply/dispatch-from-config.test.ts b/src/auto-reply/reply/dispatch-from-config.test.ts index c9084666a01..01c96466965 100644 --- a/src/auto-reply/reply/dispatch-from-config.test.ts +++ b/src/auto-reply/reply/dispatch-from-config.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import type { MsgContext } from "../templating.js"; import type { GetReplyOptions, ReplyPayload } from "../types.js"; diff --git a/src/auto-reply/reply/dispatch-from-config.ts b/src/auto-reply/reply/dispatch-from-config.ts index 3192f4d516f..a903300a20b 100644 --- a/src/auto-reply/reply/dispatch-from-config.ts +++ b/src/auto-reply/reply/dispatch-from-config.ts @@ -1,4 +1,7 @@ import type { OpenClawConfig } from "../../config/config.js"; +import type { FinalizedMsgContext } from "../templating.js"; +import type { GetReplyOptions, ReplyPayload } from "../types.js"; +import type { ReplyDispatcher, ReplyDispatchKind } from "./reply-dispatcher.js"; import { resolveSessionAgentId } from "../../agents/agent-scope.js"; import { loadSessionStore, resolveStorePath } from "../../config/sessions.js"; import { logVerbose } from "../../globals.js"; @@ -9,14 +12,11 @@ import { logSessionStateChange, } from "../../logging/diagnostic.js"; import { getGlobalHookRunner } from "../../plugins/hook-runner-global.js"; +import { maybeApplyTtsToPayload, normalizeTtsAutoMode, resolveTtsConfig } from "../../tts/tts.js"; import { getReplyFromConfig } from "../reply.js"; -import type { FinalizedMsgContext } from "../templating.js"; -import type { GetReplyOptions, ReplyPayload } from "../types.js"; import { formatAbortReplyText, tryFastAbortFromMessage } from "./abort.js"; import { shouldSkipDuplicateInbound } from "./inbound-dedupe.js"; -import type { ReplyDispatcher, ReplyDispatchKind } from "./reply-dispatcher.js"; import { isRoutableChannel, routeReply } from "./route-reply.js"; -import { maybeApplyTtsToPayload, normalizeTtsAutoMode, resolveTtsConfig } from "../../tts/tts.js"; const AUDIO_PLACEHOLDER_RE = /^(\s*\([^)]*\))?$/i; const AUDIO_HEADER_RE = /^\[Audio\b/i; diff --git a/src/auto-reply/reply/followup-runner.test.ts b/src/auto-reply/reply/followup-runner.test.ts index e4876e1e0c1..3ae3e318cf2 100644 --- a/src/auto-reply/reply/followup-runner.test.ts +++ b/src/auto-reply/reply/followup-runner.test.ts @@ -2,9 +2,8 @@ import fs from "node:fs/promises"; import { tmpdir } from "node:os"; import path from "node:path"; import { describe, expect, it, vi } from "vitest"; - -import { loadSessionStore, saveSessionStore, type SessionEntry } from "../../config/sessions.js"; import type { FollowupRun } from "./queue.js"; +import { loadSessionStore, saveSessionStore, type SessionEntry } from "../../config/sessions.js"; import { createMockTypingController } from "./test-helpers.js"; const runEmbeddedPiAgentMock = vi.fn(); diff --git a/src/auto-reply/reply/followup-runner.ts b/src/auto-reply/reply/followup-runner.ts index 8204c8184d8..1ca51d0f4b1 100644 --- a/src/auto-reply/reply/followup-runner.ts +++ b/src/auto-reply/reply/followup-runner.ts @@ -1,19 +1,20 @@ import crypto from "node:crypto"; +import type { TypingMode } from "../../config/types.js"; +import type { OriginatingChannelType } from "../templating.js"; +import type { GetReplyOptions, ReplyPayload } from "../types.js"; +import type { FollowupRun } from "./queue.js"; +import type { TypingController } from "./typing.js"; import { resolveAgentModelFallbacksOverride } from "../../agents/agent-scope.js"; import { lookupContextTokens } from "../../agents/context.js"; import { DEFAULT_CONTEXT_TOKENS } from "../../agents/defaults.js"; import { runWithModelFallback } from "../../agents/model-fallback.js"; import { runEmbeddedPiAgent } from "../../agents/pi-embedded.js"; import { resolveAgentIdFromSessionKey, type SessionEntry } from "../../config/sessions.js"; -import type { TypingMode } from "../../config/types.js"; import { logVerbose } from "../../globals.js"; import { registerAgentRunContext } from "../../infra/agent-events.js"; import { defaultRuntime } from "../../runtime.js"; import { stripHeartbeatToken } from "../heartbeat.js"; -import type { OriginatingChannelType } from "../templating.js"; import { isSilentReplyText, SILENT_REPLY_TOKEN } from "../tokens.js"; -import type { GetReplyOptions, ReplyPayload } from "../types.js"; -import type { FollowupRun } from "./queue.js"; import { applyReplyThreading, filterMessagingToolDuplicates, @@ -21,9 +22,8 @@ import { } from "./reply-payloads.js"; import { resolveReplyToMode } from "./reply-threading.js"; import { isRoutableChannel, routeReply } from "./route-reply.js"; -import { persistSessionUsageUpdate } from "./session-usage.js"; import { incrementCompactionCount } from "./session-updates.js"; -import type { TypingController } from "./typing.js"; +import { persistSessionUsageUpdate } from "./session-usage.js"; import { createTypingSignaler } from "./typing-mode.js"; export function createFollowupRunner(params: { diff --git a/src/auto-reply/reply/formatting.test.ts b/src/auto-reply/reply/formatting.test.ts index a7a9f6174de..2ad4d153f0c 100644 --- a/src/auto-reply/reply/formatting.test.ts +++ b/src/auto-reply/reply/formatting.test.ts @@ -1,5 +1,4 @@ import { afterEach, describe, expect, it, vi } from "vitest"; - import { parseAudioTag } from "./audio-tags.js"; import { createBlockReplyCoalescer } from "./block-reply-coalescer.js"; import { createReplyReferencePlanner } from "./reply-reference.js"; diff --git a/src/auto-reply/reply/get-reply-directives-apply.ts b/src/auto-reply/reply/get-reply-directives-apply.ts index 153dba1e12d..4b926240f63 100644 --- a/src/auto-reply/reply/get-reply-directives-apply.ts +++ b/src/auto-reply/reply/get-reply-directives-apply.ts @@ -3,6 +3,8 @@ import type { SessionEntry } from "../../config/sessions.js"; import type { MsgContext } from "../templating.js"; import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "../thinking.js"; import type { ReplyPayload } from "../types.js"; +import type { createModelSelectionState } from "./model-selection.js"; +import type { TypingController } from "./typing.js"; import { buildStatusReply } from "./commands.js"; import { applyInlineDirectivesFastLane, @@ -11,8 +13,6 @@ import { isDirectiveOnly, persistInlineDirectives, } from "./directive-handling.js"; -import type { createModelSelectionState } from "./model-selection.js"; -import type { TypingController } from "./typing.js"; type AgentDefaults = NonNullable["defaults"]; diff --git a/src/auto-reply/reply/get-reply-directives.ts b/src/auto-reply/reply/get-reply-directives.ts index 67641efa2fb..4ab24e97cc5 100644 --- a/src/auto-reply/reply/get-reply-directives.ts +++ b/src/auto-reply/reply/get-reply-directives.ts @@ -1,14 +1,15 @@ import type { ExecToolDefaults } from "../../agents/bash-tools.js"; import type { ModelAliasIndex } from "../../agents/model-selection.js"; import type { SkillCommandSpec } from "../../agents/skills.js"; -import { resolveSandboxRuntimeStatus } from "../../agents/sandbox.js"; import type { OpenClawConfig } from "../../config/config.js"; import type { SessionEntry } from "../../config/sessions.js"; -import { listChatCommands, shouldHandleTextCommands } from "../commands-registry.js"; -import { listSkillCommandsForWorkspace } from "../skill-commands.js"; import type { MsgContext, TemplateContext } from "../templating.js"; import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "../thinking.js"; import type { GetReplyOptions, ReplyPayload } from "../types.js"; +import type { TypingController } from "./typing.js"; +import { resolveSandboxRuntimeStatus } from "../../agents/sandbox.js"; +import { listChatCommands, shouldHandleTextCommands } from "../commands-registry.js"; +import { listSkillCommandsForWorkspace } from "../skill-commands.js"; import { resolveBlockStreamingChunking } from "./block-streaming.js"; import { buildCommandContext } from "./commands.js"; import { type InlineDirectives, parseInlineDirectives } from "./directive-handling.js"; @@ -19,7 +20,6 @@ import { CURRENT_MESSAGE_MARKER, stripMentions, stripStructuralPrefixes } from " import { createModelSelectionState, resolveContextTokens } from "./model-selection.js"; import { formatElevatedUnavailableMessage, resolveElevatedPermissions } from "./reply-elevated.js"; import { stripInlineStatus } from "./reply-inline.js"; -import type { TypingController } from "./typing.js"; type AgentDefaults = NonNullable["defaults"]; type ExecOverrides = Pick; diff --git a/src/auto-reply/reply/get-reply-inline-actions.ts b/src/auto-reply/reply/get-reply-inline-actions.ts index 92bb25d0f7c..d3bb1f72cd9 100644 --- a/src/auto-reply/reply/get-reply-inline-actions.ts +++ b/src/auto-reply/reply/get-reply-inline-actions.ts @@ -1,21 +1,21 @@ -import { getChannelDock } from "../../channels/dock.js"; import type { SkillCommandSpec } from "../../agents/skills.js"; import type { OpenClawConfig } from "../../config/config.js"; import type { SessionEntry } from "../../config/sessions.js"; import type { MsgContext, TemplateContext } from "../templating.js"; import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "../thinking.js"; import type { GetReplyOptions, ReplyPayload } from "../types.js"; +import type { InlineDirectives } from "./directive-handling.js"; +import type { createModelSelectionState } from "./model-selection.js"; +import type { TypingController } from "./typing.js"; +import { createOpenClawTools } from "../../agents/openclaw-tools.js"; +import { getChannelDock } from "../../channels/dock.js"; +import { logVerbose } from "../../globals.js"; +import { resolveGatewayMessageChannel } from "../../utils/message-channel.js"; +import { listSkillCommandsForWorkspace, resolveSkillCommandInvocation } from "../skill-commands.js"; import { getAbortMemory } from "./abort.js"; import { buildStatusReply, handleCommands } from "./commands.js"; -import type { InlineDirectives } from "./directive-handling.js"; import { isDirectiveOnly } from "./directive-handling.js"; -import type { createModelSelectionState } from "./model-selection.js"; import { extractInlineSimpleCommand } from "./reply-inline.js"; -import type { TypingController } from "./typing.js"; -import { listSkillCommandsForWorkspace, resolveSkillCommandInvocation } from "../skill-commands.js"; -import { logVerbose } from "../../globals.js"; -import { createOpenClawTools } from "../../agents/openclaw-tools.js"; -import { resolveGatewayMessageChannel } from "../../utils/message-channel.js"; export type InlineActionResult = | { kind: "reply"; reply: ReplyPayload | ReplyPayload[] | undefined } diff --git a/src/auto-reply/reply/get-reply-run.ts b/src/auto-reply/reply/get-reply-run.ts index d9c7d19cd07..3ffd3c25f29 100644 --- a/src/auto-reply/reply/get-reply-run.ts +++ b/src/auto-reply/reply/get-reply-run.ts @@ -1,13 +1,19 @@ import crypto from "node:crypto"; +import type { ExecToolDefaults } from "../../agents/bash-tools.js"; +import type { OpenClawConfig } from "../../config/config.js"; +import type { MsgContext, TemplateContext } from "../templating.js"; +import type { GetReplyOptions, ReplyPayload } from "../types.js"; +import type { buildCommandContext } from "./commands.js"; +import type { InlineDirectives } from "./directive-handling.js"; +import type { createModelSelectionState } from "./model-selection.js"; +import type { TypingController } from "./typing.js"; +import { resolveSessionAuthProfileOverride } from "../../agents/auth-profiles/session-override.js"; import { abortEmbeddedPiRun, isEmbeddedPiRunActive, isEmbeddedPiRunStreaming, resolveEmbeddedSessionLane, } from "../../agents/pi-embedded.js"; -import { resolveSessionAuthProfileOverride } from "../../agents/auth-profiles/session-override.js"; -import type { ExecToolDefaults } from "../../agents/bash-tools.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { resolveGroupSessionKey, resolveSessionFilePath, @@ -20,7 +26,6 @@ import { normalizeMainKey } from "../../routing/session-key.js"; import { isReasoningTagProvider } from "../../utils/provider-utils.js"; import { hasControlCommand } from "../command-detection.js"; import { buildInboundMediaNote } from "../media-note.js"; -import type { MsgContext, TemplateContext } from "../templating.js"; import { type ElevatedLevel, formatXHighModelHint, @@ -31,17 +36,12 @@ import { type VerboseLevel, } from "../thinking.js"; import { SILENT_REPLY_TOKEN } from "../tokens.js"; -import type { GetReplyOptions, ReplyPayload } from "../types.js"; import { runReplyAgent } from "./agent-runner.js"; import { applySessionHints } from "./body.js"; -import { routeReply } from "./route-reply.js"; -import type { buildCommandContext } from "./commands.js"; -import type { InlineDirectives } from "./directive-handling.js"; import { buildGroupIntro } from "./groups.js"; -import type { createModelSelectionState } from "./model-selection.js"; import { resolveQueueSettings } from "./queue.js"; +import { routeReply } from "./route-reply.js"; import { ensureSkillSnapshot, prependSystemEvents } from "./session-updates.js"; -import type { TypingController } from "./typing.js"; import { resolveTypingMode } from "./typing-mode.js"; type AgentDefaults = NonNullable["defaults"]; diff --git a/src/auto-reply/reply/get-reply.ts b/src/auto-reply/reply/get-reply.ts index 67b0c308edb..c5cccf4b839 100644 --- a/src/auto-reply/reply/get-reply.ts +++ b/src/auto-reply/reply/get-reply.ts @@ -1,3 +1,5 @@ +import type { MsgContext } from "../templating.js"; +import type { GetReplyOptions, ReplyPayload } from "../types.js"; import { resolveAgentDir, resolveAgentWorkspaceDir, @@ -7,20 +9,18 @@ import { resolveModelRefFromString } from "../../agents/model-selection.js"; import { resolveAgentTimeoutMs } from "../../agents/timeout.js"; import { DEFAULT_AGENT_WORKSPACE_DIR, ensureAgentWorkspace } from "../../agents/workspace.js"; import { type OpenClawConfig, loadConfig } from "../../config/config.js"; +import { applyLinkUnderstanding } from "../../link-understanding/apply.js"; +import { applyMediaUnderstanding } from "../../media-understanding/apply.js"; import { defaultRuntime } from "../../runtime.js"; import { resolveCommandAuthorization } from "../command-auth.js"; -import type { MsgContext } from "../templating.js"; import { SILENT_REPLY_TOKEN } from "../tokens.js"; -import { applyMediaUnderstanding } from "../../media-understanding/apply.js"; -import { applyLinkUnderstanding } from "../../link-understanding/apply.js"; -import type { GetReplyOptions, ReplyPayload } from "../types.js"; import { resolveDefaultModel } from "./directive-handling.js"; import { resolveReplyDirectives } from "./get-reply-directives.js"; import { handleInlineActions } from "./get-reply-inline-actions.js"; import { runPreparedReply } from "./get-reply-run.js"; import { finalizeInboundContext } from "./inbound-context.js"; -import { initSessionState } from "./session.js"; import { applyResetModelOverride } from "./session-reset-model.js"; +import { initSessionState } from "./session.js"; import { stageSandboxMedia } from "./stage-sandbox-media.js"; import { createTypingController } from "./typing.js"; diff --git a/src/auto-reply/reply/groups.ts b/src/auto-reply/reply/groups.ts index b947be7da1d..68397203376 100644 --- a/src/auto-reply/reply/groups.ts +++ b/src/auto-reply/reply/groups.ts @@ -1,10 +1,10 @@ -import { getChannelDock } from "../../channels/dock.js"; -import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js"; import type { OpenClawConfig } from "../../config/config.js"; import type { GroupKeyResolution, SessionEntry } from "../../config/sessions.js"; +import type { TemplateContext } from "../templating.js"; +import { getChannelDock } from "../../channels/dock.js"; +import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js"; import { isInternalMessageChannel } from "../../utils/message-channel.js"; import { normalizeGroupActivation } from "../group-activation.js"; -import type { TemplateContext } from "../templating.js"; function extractGroupId(raw: string | undefined | null): string | undefined { const trimmed = (raw ?? "").trim(); diff --git a/src/auto-reply/reply/inbound-context.ts b/src/auto-reply/reply/inbound-context.ts index 353e2b41d10..3e82fca0d39 100644 --- a/src/auto-reply/reply/inbound-context.ts +++ b/src/auto-reply/reply/inbound-context.ts @@ -1,6 +1,6 @@ +import type { FinalizedMsgContext, MsgContext } from "../templating.js"; import { normalizeChatType } from "../../channels/chat-type.js"; import { resolveConversationLabel } from "../../channels/conversation-label.js"; -import type { FinalizedMsgContext, MsgContext } from "../templating.js"; import { formatInboundBodyWithSenderMeta } from "./inbound-sender-meta.js"; import { normalizeInboundTextNewlines } from "./inbound-text.js"; diff --git a/src/auto-reply/reply/inbound-dedupe.ts b/src/auto-reply/reply/inbound-dedupe.ts index 191e4c4f478..fa6ecd56759 100644 --- a/src/auto-reply/reply/inbound-dedupe.ts +++ b/src/auto-reply/reply/inbound-dedupe.ts @@ -1,6 +1,6 @@ +import type { MsgContext } from "../templating.js"; import { logVerbose, shouldLogVerbose } from "../../globals.js"; import { createDedupeCache, type DedupeCache } from "../../infra/dedupe.js"; -import type { MsgContext } from "../templating.js"; const DEFAULT_INBOUND_DEDUPE_TTL_MS = 20 * 60_000; const DEFAULT_INBOUND_DEDUPE_MAX = 5000; diff --git a/src/auto-reply/reply/line-directives.ts b/src/auto-reply/reply/line-directives.ts index 6c6cc41b9e1..c3e052972c7 100644 --- a/src/auto-reply/reply/line-directives.ts +++ b/src/auto-reply/reply/line-directives.ts @@ -1,5 +1,5 @@ -import type { ReplyPayload } from "../types.js"; import type { LineChannelData } from "../../line/types.js"; +import type { ReplyPayload } from "../types.js"; import { createMediaPlayerCard, createEventCard, diff --git a/src/auto-reply/reply/memory-flush.test.ts b/src/auto-reply/reply/memory-flush.test.ts index 6d04b21e310..ce3a7929528 100644 --- a/src/auto-reply/reply/memory-flush.test.ts +++ b/src/auto-reply/reply/memory-flush.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { DEFAULT_MEMORY_FLUSH_SOFT_TOKENS, resolveMemoryFlushContextWindowTokens, diff --git a/src/auto-reply/reply/memory-flush.ts b/src/auto-reply/reply/memory-flush.ts index ad271f64c24..e337cfd93d5 100644 --- a/src/auto-reply/reply/memory-flush.ts +++ b/src/auto-reply/reply/memory-flush.ts @@ -1,8 +1,8 @@ +import type { OpenClawConfig } from "../../config/config.js"; +import type { SessionEntry } from "../../config/sessions.js"; import { lookupContextTokens } from "../../agents/context.js"; import { DEFAULT_CONTEXT_TOKENS } from "../../agents/defaults.js"; import { DEFAULT_PI_COMPACTION_RESERVE_TOKENS_FLOOR } from "../../agents/pi-settings.js"; -import type { OpenClawConfig } from "../../config/config.js"; -import type { SessionEntry } from "../../config/sessions.js"; import { SILENT_REPLY_TOKEN } from "../tokens.js"; export const DEFAULT_MEMORY_FLUSH_SOFT_TOKENS = 4000; diff --git a/src/auto-reply/reply/mentions.ts b/src/auto-reply/reply/mentions.ts index f22b22d83d9..07def8de980 100644 --- a/src/auto-reply/reply/mentions.ts +++ b/src/auto-reply/reply/mentions.ts @@ -1,8 +1,8 @@ +import type { OpenClawConfig } from "../../config/config.js"; +import type { MsgContext } from "../templating.js"; import { resolveAgentConfig } from "../../agents/agent-scope.js"; import { getChannelDock } from "../../channels/dock.js"; import { normalizeChannelId } from "../../channels/plugins/index.js"; -import type { OpenClawConfig } from "../../config/config.js"; -import type { MsgContext } from "../templating.js"; function escapeRegExp(text: string): string { return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); diff --git a/src/auto-reply/reply/model-selection.inherit-parent.test.ts b/src/auto-reply/reply/model-selection.inherit-parent.test.ts index f93146ee087..f0d72e23535 100644 --- a/src/auto-reply/reply/model-selection.inherit-parent.test.ts +++ b/src/auto-reply/reply/model-selection.inherit-parent.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import { createModelSelectionState } from "./model-selection.js"; diff --git a/src/auto-reply/reply/model-selection.ts b/src/auto-reply/reply/model-selection.ts index 027791546cb..5a4329790df 100644 --- a/src/auto-reply/reply/model-selection.ts +++ b/src/auto-reply/reply/model-selection.ts @@ -1,3 +1,6 @@ +import type { OpenClawConfig } from "../../config/config.js"; +import type { ThinkLevel } from "./directives.js"; +import { clearSessionAuthProfileOverride } from "../../agents/auth-profiles/session-override.js"; import { lookupContextTokens } from "../../agents/context.js"; import { DEFAULT_CONTEXT_TOKENS } from "../../agents/defaults.js"; import { loadModelCatalog } from "../../agents/model-catalog.js"; @@ -9,12 +12,9 @@ import { resolveModelRefFromString, resolveThinkingDefault, } from "../../agents/model-selection.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { type SessionEntry, updateSessionStore } from "../../config/sessions.js"; -import { clearSessionAuthProfileOverride } from "../../agents/auth-profiles/session-override.js"; import { applyModelOverrideToSessionEntry } from "../../sessions/model-overrides.js"; import { resolveThreadParentSessionKey } from "../../sessions/session-key-utils.js"; -import type { ThinkLevel } from "./directives.js"; export type ModelDirectiveSelection = { provider: string; diff --git a/src/auto-reply/reply/normalize-reply.test.ts b/src/auto-reply/reply/normalize-reply.test.ts index b9547c2b1e1..26866892669 100644 --- a/src/auto-reply/reply/normalize-reply.test.ts +++ b/src/auto-reply/reply/normalize-reply.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { SILENT_REPLY_TOKEN } from "../tokens.js"; import { normalizeReplyPayload } from "./normalize-reply.js"; diff --git a/src/auto-reply/reply/normalize-reply.ts b/src/auto-reply/reply/normalize-reply.ts index 9b1d24eb95c..ec44416842e 100644 --- a/src/auto-reply/reply/normalize-reply.ts +++ b/src/auto-reply/reply/normalize-reply.ts @@ -1,12 +1,12 @@ -import { stripHeartbeatToken } from "../heartbeat.js"; -import { HEARTBEAT_TOKEN, isSilentReplyText, SILENT_REPLY_TOKEN } from "../tokens.js"; import type { ReplyPayload } from "../types.js"; import { sanitizeUserFacingText } from "../../agents/pi-embedded-helpers.js"; +import { stripHeartbeatToken } from "../heartbeat.js"; +import { HEARTBEAT_TOKEN, isSilentReplyText, SILENT_REPLY_TOKEN } from "../tokens.js"; +import { hasLineDirectives, parseLineDirectives } from "./line-directives.js"; import { resolveResponsePrefixTemplate, type ResponsePrefixContext, } from "./response-prefix-template.js"; -import { hasLineDirectives, parseLineDirectives } from "./line-directives.js"; export type NormalizeReplySkipReason = "empty" | "silent" | "heartbeat"; diff --git a/src/auto-reply/reply/provider-dispatcher.ts b/src/auto-reply/reply/provider-dispatcher.ts index f28e19c20b0..6bcdca74248 100644 --- a/src/auto-reply/reply/provider-dispatcher.ts +++ b/src/auto-reply/reply/provider-dispatcher.ts @@ -1,15 +1,15 @@ import type { OpenClawConfig } from "../../config/config.js"; +import type { DispatchInboundResult } from "../dispatch.js"; import type { FinalizedMsgContext, MsgContext } from "../templating.js"; import type { GetReplyOptions } from "../types.js"; -import type { DispatchInboundResult } from "../dispatch.js"; -import { - dispatchInboundMessageWithBufferedDispatcher, - dispatchInboundMessageWithDispatcher, -} from "../dispatch.js"; import type { ReplyDispatcherOptions, ReplyDispatcherWithTypingOptions, } from "./reply-dispatcher.js"; +import { + dispatchInboundMessageWithBufferedDispatcher, + dispatchInboundMessageWithDispatcher, +} from "../dispatch.js"; export async function dispatchReplyWithBufferedBlockDispatcher(params: { ctx: MsgContext | FinalizedMsgContext; diff --git a/src/auto-reply/reply/queue.collect-routing.test.ts b/src/auto-reply/reply/queue.collect-routing.test.ts index 04e4b19a76e..215cffdae2a 100644 --- a/src/auto-reply/reply/queue.collect-routing.test.ts +++ b/src/auto-reply/reply/queue.collect-routing.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import type { FollowupRun, QueueSettings } from "./queue.js"; import { enqueueFollowupRun, scheduleFollowupDrain } from "./queue.js"; diff --git a/src/auto-reply/reply/queue/directive.ts b/src/auto-reply/reply/queue/directive.ts index c906d826159..9621d2fafc7 100644 --- a/src/auto-reply/reply/queue/directive.ts +++ b/src/auto-reply/reply/queue/directive.ts @@ -1,6 +1,6 @@ +import type { QueueDropPolicy, QueueMode } from "./types.js"; import { parseDurationMs } from "../../../cli/parse-duration.js"; import { normalizeQueueDropPolicy, normalizeQueueMode } from "./normalize.js"; -import type { QueueDropPolicy, QueueMode } from "./types.js"; function parseQueueDebounce(raw?: string): number | undefined { if (!raw) { diff --git a/src/auto-reply/reply/queue/drain.ts b/src/auto-reply/reply/queue/drain.ts index addc91b4a69..4340650c3cb 100644 --- a/src/auto-reply/reply/queue/drain.ts +++ b/src/auto-reply/reply/queue/drain.ts @@ -1,3 +1,4 @@ +import type { FollowupRun } from "./types.js"; import { defaultRuntime } from "../../../runtime.js"; import { buildCollectPrompt, @@ -7,7 +8,6 @@ import { } from "../../../utils/queue-helpers.js"; import { isRoutableChannel } from "../route-reply.js"; import { FOLLOWUP_QUEUES } from "./state.js"; -import type { FollowupRun } from "./types.js"; export function scheduleFollowupDrain( key: string, diff --git a/src/auto-reply/reply/queue/enqueue.ts b/src/auto-reply/reply/queue/enqueue.ts index f5444c0a96b..16f6bdf2ed9 100644 --- a/src/auto-reply/reply/queue/enqueue.ts +++ b/src/auto-reply/reply/queue/enqueue.ts @@ -1,6 +1,6 @@ +import type { FollowupRun, QueueDedupeMode, QueueSettings } from "./types.js"; import { applyQueueDropPolicy, shouldSkipQueueItem } from "../../../utils/queue-helpers.js"; import { FOLLOWUP_QUEUES, getFollowupQueue } from "./state.js"; -import type { FollowupRun, QueueDedupeMode, QueueSettings } from "./types.js"; function isRunAlreadyQueued( run: FollowupRun, diff --git a/src/auto-reply/reply/queue/settings.ts b/src/auto-reply/reply/queue/settings.ts index 4aec6d23758..9bf0619cde5 100644 --- a/src/auto-reply/reply/queue/settings.ts +++ b/src/auto-reply/reply/queue/settings.ts @@ -1,8 +1,8 @@ -import { getChannelPlugin } from "../../../channels/plugins/index.js"; import type { InboundDebounceByProvider } from "../../../config/types.messages.js"; +import type { QueueMode, QueueSettings, ResolveQueueSettingsParams } from "./types.js"; +import { getChannelPlugin } from "../../../channels/plugins/index.js"; import { normalizeQueueDropPolicy, normalizeQueueMode } from "./normalize.js"; import { DEFAULT_QUEUE_CAP, DEFAULT_QUEUE_DEBOUNCE_MS, DEFAULT_QUEUE_DROP } from "./state.js"; -import type { QueueMode, QueueSettings, ResolveQueueSettingsParams } from "./types.js"; function defaultQueueModeForChannel(_channel?: string): QueueMode { return "collect"; diff --git a/src/auto-reply/reply/queue/types.ts b/src/auto-reply/reply/queue/types.ts index 3c5f3ec9d1d..8fee2005923 100644 --- a/src/auto-reply/reply/queue/types.ts +++ b/src/auto-reply/reply/queue/types.ts @@ -1,9 +1,9 @@ +import type { ExecToolDefaults } from "../../../agents/bash-tools.js"; import type { SkillSnapshot } from "../../../agents/skills.js"; import type { OpenClawConfig } from "../../../config/config.js"; import type { SessionEntry } from "../../../config/sessions.js"; import type { OriginatingChannelType } from "../../templating.js"; import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "../directives.js"; -import type { ExecToolDefaults } from "../../../agents/bash-tools.js"; export type QueueMode = "steer" | "followup" | "collect" | "steer-backlog" | "interrupt" | "queue"; diff --git a/src/auto-reply/reply/reply-dispatcher.ts b/src/auto-reply/reply/reply-dispatcher.ts index 090571a2e98..52b363797dd 100644 --- a/src/auto-reply/reply/reply-dispatcher.ts +++ b/src/auto-reply/reply/reply-dispatcher.ts @@ -1,8 +1,8 @@ import type { HumanDelayConfig } from "../../config/types.js"; import type { GetReplyOptions, ReplyPayload } from "../types.js"; -import { normalizeReplyPayload, type NormalizeReplySkipReason } from "./normalize-reply.js"; import type { ResponsePrefixContext } from "./response-prefix-template.js"; import type { TypingController } from "./typing.js"; +import { normalizeReplyPayload, type NormalizeReplySkipReason } from "./normalize-reply.js"; export type ReplyDispatchKind = "tool" | "block" | "final"; diff --git a/src/auto-reply/reply/reply-elevated.ts b/src/auto-reply/reply/reply-elevated.ts index 04372f0a049..4b66fc63a9c 100644 --- a/src/auto-reply/reply/reply-elevated.ts +++ b/src/auto-reply/reply/reply-elevated.ts @@ -1,11 +1,11 @@ +import type { AgentElevatedAllowFromConfig, OpenClawConfig } from "../../config/config.js"; +import type { MsgContext } from "../templating.js"; import { resolveAgentConfig } from "../../agents/agent-scope.js"; import { getChannelDock } from "../../channels/dock.js"; import { normalizeChannelId } from "../../channels/plugins/index.js"; import { CHAT_CHANNEL_ORDER } from "../../channels/registry.js"; -import type { AgentElevatedAllowFromConfig, OpenClawConfig } from "../../config/config.js"; -import { INTERNAL_MESSAGE_CHANNEL } from "../../utils/message-channel.js"; import { formatCliCommand } from "../../cli/command-format.js"; -import type { MsgContext } from "../templating.js"; +import { INTERNAL_MESSAGE_CHANNEL } from "../../utils/message-channel.js"; function normalizeAllowToken(value?: string) { if (!value) { diff --git a/src/auto-reply/reply/reply-payloads.ts b/src/auto-reply/reply/reply-payloads.ts index 0bc7e63a08b..231bfb9bada 100644 --- a/src/auto-reply/reply/reply-payloads.ts +++ b/src/auto-reply/reply/reply-payloads.ts @@ -1,9 +1,9 @@ -import { isMessagingToolDuplicate } from "../../agents/pi-embedded-helpers.js"; -import { normalizeTargetForProvider } from "../../infra/outbound/target-normalization.js"; import type { MessagingToolSend } from "../../agents/pi-embedded-runner.js"; import type { ReplyToMode } from "../../config/types.js"; import type { OriginatingChannelType } from "../templating.js"; import type { ReplyPayload } from "../types.js"; +import { isMessagingToolDuplicate } from "../../agents/pi-embedded-helpers.js"; +import { normalizeTargetForProvider } from "../../infra/outbound/target-normalization.js"; import { extractReplyToTag } from "./reply-tags.js"; import { createReplyToModeFilterForChannel } from "./reply-threading.js"; diff --git a/src/auto-reply/reply/reply-routing.test.ts b/src/auto-reply/reply/reply-routing.test.ts index b4f1fbb3bd7..6637c6c1401 100644 --- a/src/auto-reply/reply/reply-routing.test.ts +++ b/src/auto-reply/reply/reply-routing.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import { HEARTBEAT_TOKEN, SILENT_REPLY_TOKEN } from "../tokens.js"; import { createReplyDispatcher } from "./reply-dispatcher.js"; diff --git a/src/auto-reply/reply/reply-threading.ts b/src/auto-reply/reply/reply-threading.ts index 140e2837dc8..e745f165617 100644 --- a/src/auto-reply/reply/reply-threading.ts +++ b/src/auto-reply/reply/reply-threading.ts @@ -1,9 +1,9 @@ -import { getChannelDock } from "../../channels/dock.js"; -import { normalizeChannelId } from "../../channels/plugins/index.js"; import type { OpenClawConfig } from "../../config/config.js"; import type { ReplyToMode } from "../../config/types.js"; import type { OriginatingChannelType } from "../templating.js"; import type { ReplyPayload } from "../types.js"; +import { getChannelDock } from "../../channels/dock.js"; +import { normalizeChannelId } from "../../channels/plugins/index.js"; export function resolveReplyToMode( cfg: OpenClawConfig, diff --git a/src/auto-reply/reply/response-prefix-template.test.ts b/src/auto-reply/reply/response-prefix-template.test.ts index b048deb96c6..41c28e23ed9 100644 --- a/src/auto-reply/reply/response-prefix-template.test.ts +++ b/src/auto-reply/reply/response-prefix-template.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { extractShortModelName, hasTemplateVariables, diff --git a/src/auto-reply/reply/route-reply.test.ts b/src/auto-reply/reply/route-reply.test.ts index 3f6483a9ff3..e2eecad16a6 100644 --- a/src/auto-reply/reply/route-reply.test.ts +++ b/src/auto-reply/reply/route-reply.test.ts @@ -1,20 +1,19 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import type { ChannelOutboundAdapter, ChannelPlugin } from "../../channels/plugins/types.js"; import type { OpenClawConfig } from "../../config/config.js"; import type { PluginRegistry } from "../../plugins/registry.js"; -import { setActivePluginRegistry } from "../../plugins/runtime.js"; -import { - createIMessageTestPlugin, - createOutboundTestPlugin, - createTestRegistry, -} from "../../test-utils/channel-plugins.js"; import { discordOutbound } from "../../channels/plugins/outbound/discord.js"; import { imessageOutbound } from "../../channels/plugins/outbound/imessage.js"; import { signalOutbound } from "../../channels/plugins/outbound/signal.js"; import { slackOutbound } from "../../channels/plugins/outbound/slack.js"; import { telegramOutbound } from "../../channels/plugins/outbound/telegram.js"; import { whatsappOutbound } from "../../channels/plugins/outbound/whatsapp.js"; +import { setActivePluginRegistry } from "../../plugins/runtime.js"; +import { + createIMessageTestPlugin, + createOutboundTestPlugin, + createTestRegistry, +} from "../../test-utils/channel-plugins.js"; import { SILENT_REPLY_TOKEN } from "../tokens.js"; const mocks = vi.hoisted(() => ({ diff --git a/src/auto-reply/reply/route-reply.ts b/src/auto-reply/reply/route-reply.ts index 9500a294a33..df21524d8a1 100644 --- a/src/auto-reply/reply/route-reply.ts +++ b/src/auto-reply/reply/route-reply.ts @@ -7,13 +7,13 @@ * across multiple providers. */ +import type { OpenClawConfig } from "../../config/config.js"; +import type { OriginatingChannelType } from "../templating.js"; +import type { ReplyPayload } from "../types.js"; import { resolveSessionAgentId } from "../../agents/agent-scope.js"; import { resolveEffectiveMessagesConfig } from "../../agents/identity.js"; import { normalizeChannelId } from "../../channels/plugins/index.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { INTERNAL_MESSAGE_CHANNEL } from "../../utils/message-channel.js"; -import type { OriginatingChannelType } from "../templating.js"; -import type { ReplyPayload } from "../types.js"; import { normalizeReplyPayload } from "./normalize-reply.js"; export type RouteReplyParams = { diff --git a/src/auto-reply/reply/session-reset-model.ts b/src/auto-reply/reply/session-reset-model.ts index 34364d6bbe1..eed6f054298 100644 --- a/src/auto-reply/reply/session-reset-model.ts +++ b/src/auto-reply/reply/session-reset-model.ts @@ -1,3 +1,6 @@ +import type { OpenClawConfig } from "../../config/config.js"; +import type { SessionEntry } from "../../config/sessions.js"; +import type { MsgContext, TemplateContext } from "../templating.js"; import { loadModelCatalog } from "../../agents/model-catalog.js"; import { buildAllowedModelSet, @@ -6,13 +9,10 @@ import { resolveModelRefFromString, type ModelAliasIndex, } from "../../agents/model-selection.js"; -import type { OpenClawConfig } from "../../config/config.js"; -import type { SessionEntry } from "../../config/sessions.js"; import { updateSessionStore } from "../../config/sessions.js"; -import type { MsgContext, TemplateContext } from "../templating.js"; +import { applyModelOverrideToSessionEntry } from "../../sessions/model-overrides.js"; import { formatInboundBodyWithSenderMeta } from "./inbound-sender-meta.js"; import { resolveModelDirectiveSelection, type ModelDirectiveSelection } from "./model-selection.js"; -import { applyModelOverrideToSessionEntry } from "../../sessions/model-overrides.js"; type ResetModelResult = { selection?: ModelDirectiveSelection; diff --git a/src/auto-reply/reply/session-resets.test.ts b/src/auto-reply/reply/session-resets.test.ts index 652896458fc..b53d44aa6bd 100644 --- a/src/auto-reply/reply/session-resets.test.ts +++ b/src/auto-reply/reply/session-resets.test.ts @@ -1,15 +1,13 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it, vi } from "vitest"; - -import { buildModelAliasIndex } from "../../agents/model-selection.js"; import type { OpenClawConfig } from "../../config/config.js"; +import { buildModelAliasIndex } from "../../agents/model-selection.js"; import { enqueueSystemEvent, resetSystemEventsForTest } from "../../infra/system-events.js"; -import { initSessionState } from "./session.js"; import { applyResetModelOverride } from "./session-reset-model.js"; import { prependSystemEvents } from "./session-updates.js"; +import { initSessionState } from "./session.js"; vi.mock("../../agents/model-catalog.js", () => ({ loadModelCatalog: vi.fn(async () => [ diff --git a/src/auto-reply/reply/session-updates.ts b/src/auto-reply/reply/session-updates.ts index 7787603a6c1..36cd0a02ce4 100644 --- a/src/auto-reply/reply/session-updates.ts +++ b/src/auto-reply/reply/session-updates.ts @@ -1,9 +1,8 @@ import crypto from "node:crypto"; - +import type { OpenClawConfig } from "../../config/config.js"; import { resolveUserTimezone } from "../../agents/date-time.js"; import { buildWorkspaceSkillSnapshot } from "../../agents/skills.js"; import { ensureSkillsWatcher, getSkillsSnapshotVersion } from "../../agents/skills/refresh.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { type SessionEntry, updateSessionStore } from "../../config/sessions.js"; import { buildChannelSummary } from "../../infra/channel-summary.js"; import { getRemoteSkillEligibility } from "../../infra/skills-remote.js"; diff --git a/src/auto-reply/reply/session.test.ts b/src/auto-reply/reply/session.test.ts index db420ce3227..6d6b93d5f81 100644 --- a/src/auto-reply/reply/session.test.ts +++ b/src/auto-reply/reply/session.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import { saveSessionStore } from "../../config/sessions.js"; import { initSessionState } from "./session.js"; diff --git a/src/auto-reply/reply/session.ts b/src/auto-reply/reply/session.ts index fff056516f1..895c4d07e00 100644 --- a/src/auto-reply/reply/session.ts +++ b/src/auto-reply/reply/session.ts @@ -1,11 +1,12 @@ +import { CURRENT_SESSION_VERSION, SessionManager } from "@mariozechner/pi-coding-agent"; import crypto from "node:crypto"; import fs from "node:fs"; import path from "node:path"; - -import { CURRENT_SESSION_VERSION, SessionManager } from "@mariozechner/pi-coding-agent"; -import { resolveSessionAgentId } from "../../agents/agent-scope.js"; import type { OpenClawConfig } from "../../config/config.js"; import type { TtsAutoMode } from "../../config/types.tts.js"; +import type { MsgContext, TemplateContext } from "../templating.js"; +import { resolveSessionAgentId } from "../../agents/agent-scope.js"; +import { normalizeChatType } from "../../channels/chat-type.js"; import { DEFAULT_RESET_TRIGGERS, deriveSessionMetaPatch, @@ -26,13 +27,11 @@ import { updateSessionStore, } from "../../config/sessions.js"; import { normalizeMainKey } from "../../routing/session-key.js"; +import { normalizeSessionDeliveryFields } from "../../utils/delivery-context.js"; import { resolveCommandAuthorization } from "../command-auth.js"; -import type { MsgContext, TemplateContext } from "../templating.js"; -import { normalizeChatType } from "../../channels/chat-type.js"; -import { stripMentions, stripStructuralPrefixes } from "./mentions.js"; import { formatInboundBodyWithSenderMeta } from "./inbound-sender-meta.js"; import { normalizeInboundTextNewlines } from "./inbound-text.js"; -import { normalizeSessionDeliveryFields } from "../../utils/delivery-context.js"; +import { stripMentions, stripStructuralPrefixes } from "./mentions.js"; export type SessionInitResult = { sessionCtx: TemplateContext; diff --git a/src/auto-reply/reply/stage-sandbox-media.ts b/src/auto-reply/reply/stage-sandbox-media.ts index 43d289da5e5..2cd882ea0c8 100644 --- a/src/auto-reply/reply/stage-sandbox-media.ts +++ b/src/auto-reply/reply/stage-sandbox-media.ts @@ -2,13 +2,13 @@ import { spawn } from "node:child_process"; import fs from "node:fs/promises"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import type { OpenClawConfig } from "../../config/config.js"; +import type { MsgContext, TemplateContext } from "../templating.js"; import { assertSandboxPath } from "../../agents/sandbox-paths.js"; import { ensureSandboxWorkspaceForSession } from "../../agents/sandbox.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { logVerbose } from "../../globals.js"; import { getMediaDir } from "../../media/store.js"; import { CONFIG_DIR } from "../../utils.js"; -import type { MsgContext, TemplateContext } from "../templating.js"; export async function stageSandboxMedia(params: { ctx: MsgContext; diff --git a/src/auto-reply/reply/streaming-directives.ts b/src/auto-reply/reply/streaming-directives.ts index c3a0cec758a..0a933f6962f 100644 --- a/src/auto-reply/reply/streaming-directives.ts +++ b/src/auto-reply/reply/streaming-directives.ts @@ -1,7 +1,7 @@ +import type { ReplyDirectiveParseResult } from "./reply-directives.js"; import { splitMediaFromOutput } from "../../media/parse.js"; import { parseInlineDirectives } from "../../utils/directive-tags.js"; import { isSilentReplyText, SILENT_REPLY_TOKEN } from "../tokens.js"; -import type { ReplyDirectiveParseResult } from "./reply-directives.js"; type PendingReplyState = { explicitId?: string; diff --git a/src/auto-reply/reply/subagents-utils.test.ts b/src/auto-reply/reply/subagents-utils.test.ts index a7496a16d05..bec83a8a233 100644 --- a/src/auto-reply/reply/subagents-utils.test.ts +++ b/src/auto-reply/reply/subagents-utils.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { SubagentRunRecord } from "../../agents/subagent-registry.js"; import { formatDurationShort, diff --git a/src/auto-reply/reply/test-helpers.ts b/src/auto-reply/reply/test-helpers.ts index 2bbef29adcf..4c30ae6756a 100644 --- a/src/auto-reply/reply/test-helpers.ts +++ b/src/auto-reply/reply/test-helpers.ts @@ -1,5 +1,4 @@ import { vi } from "vitest"; - import type { TypingController } from "./typing.js"; export function createMockTypingController( diff --git a/src/auto-reply/reply/typing-mode.ts b/src/auto-reply/reply/typing-mode.ts index 37805ef3be6..554754bea18 100644 --- a/src/auto-reply/reply/typing-mode.ts +++ b/src/auto-reply/reply/typing-mode.ts @@ -1,6 +1,6 @@ import type { TypingMode } from "../../config/types.js"; -import { isSilentReplyText, SILENT_REPLY_TOKEN } from "../tokens.js"; import type { TypingController } from "./typing.js"; +import { isSilentReplyText, SILENT_REPLY_TOKEN } from "../tokens.js"; export type TypingModeContext = { configured?: TypingMode; diff --git a/src/auto-reply/reply/typing.test.ts b/src/auto-reply/reply/typing.test.ts index 06e9003c597..edefc57f8ee 100644 --- a/src/auto-reply/reply/typing.test.ts +++ b/src/auto-reply/reply/typing.test.ts @@ -1,5 +1,4 @@ import { afterEach, describe, expect, it, vi } from "vitest"; - import { createMockTypingController } from "./test-helpers.js"; import { createTypingSignaler, resolveTypingMode } from "./typing-mode.js"; import { createTypingController } from "./typing.js"; diff --git a/src/auto-reply/skill-commands.ts b/src/auto-reply/skill-commands.ts index 1b00d2077fc..16ba7b87056 100644 --- a/src/auto-reply/skill-commands.ts +++ b/src/auto-reply/skill-commands.ts @@ -1,9 +1,8 @@ import fs from "node:fs"; - import type { OpenClawConfig } from "../config/config.js"; import { listAgentIds, resolveAgentWorkspaceDir } from "../agents/agent-scope.js"; -import { getRemoteSkillEligibility } from "../infra/skills-remote.js"; import { buildWorkspaceSkillCommandSpecs, type SkillCommandSpec } from "../agents/skills.js"; +import { getRemoteSkillEligibility } from "../infra/skills-remote.js"; import { listChatCommands } from "./commands-registry.js"; function resolveReservedCommandNames(): Set { diff --git a/src/auto-reply/status.test.ts b/src/auto-reply/status.test.ts index 5c6a7b4bf89..69fe1294488 100644 --- a/src/auto-reply/status.test.ts +++ b/src/auto-reply/status.test.ts @@ -1,9 +1,9 @@ import fs from "node:fs"; import path from "node:path"; import { afterEach, describe, expect, it, vi } from "vitest"; +import type { OpenClawConfig } from "../config/config.js"; import { normalizeTestText } from "../../test/helpers/normalize-text.js"; import { withTempHome } from "../../test/helpers/temp-home.js"; -import type { OpenClawConfig } from "../config/config.js"; import { buildCommandsMessage, buildCommandsMessagePaginated, diff --git a/src/auto-reply/status.ts b/src/auto-reply/status.ts index dc74c192bf6..0b3f842d012 100644 --- a/src/auto-reply/status.ts +++ b/src/auto-reply/status.ts @@ -1,18 +1,23 @@ import fs from "node:fs"; - +import type { SkillCommandSpec } from "../agents/skills.js"; +import type { OpenClawConfig } from "../config/config.js"; +import type { MediaUnderstandingDecision } from "../media-understanding/types.js"; +import type { CommandCategory } from "./commands-registry.types.js"; +import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "./thinking.js"; import { lookupContextTokens } from "../agents/context.js"; import { DEFAULT_CONTEXT_TOKENS, DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js"; import { resolveModelAuthMode } from "../agents/model-auth.js"; import { resolveConfiguredModelRef } from "../agents/model-selection.js"; import { resolveSandboxRuntimeStatus } from "../agents/sandbox.js"; import { derivePromptTokens, normalizeUsage, type UsageLike } from "../agents/usage.js"; -import type { OpenClawConfig } from "../config/config.js"; import { resolveMainSessionKey, resolveSessionFilePath, type SessionEntry, type SessionScope, } from "../config/sessions.js"; +import { resolveCommitHash } from "../infra/git-commit.js"; +import { listPluginCommands } from "../plugins/commands.js"; import { getTtsMaxLength, getTtsProvider, @@ -21,7 +26,6 @@ import { resolveTtsConfig, resolveTtsPrefsPath, } from "../tts/tts.js"; -import { resolveCommitHash } from "../infra/git-commit.js"; import { estimateUsageCost, formatTokenCount as formatTokenCountShared, @@ -34,11 +38,6 @@ import { listChatCommandsForConfig, type ChatCommandDefinition, } from "./commands-registry.js"; -import { listPluginCommands } from "../plugins/commands.js"; -import type { SkillCommandSpec } from "../agents/skills.js"; -import type { CommandCategory } from "./commands-registry.types.js"; -import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "./thinking.js"; -import type { MediaUnderstandingDecision } from "../media-understanding/types.js"; type AgentConfig = Partial["defaults"]>>; diff --git a/src/auto-reply/templating.ts b/src/auto-reply/templating.ts index 517e2492039..9cc89087d95 100644 --- a/src/auto-reply/templating.ts +++ b/src/auto-reply/templating.ts @@ -1,11 +1,11 @@ import type { ChannelId } from "../channels/plugins/types.js"; -import type { StickerMetadata } from "../telegram/bot/types.js"; -import type { InternalMessageChannel } from "../utils/message-channel.js"; -import type { CommandArgs } from "./commands-registry.types.js"; import type { MediaUnderstandingDecision, MediaUnderstandingOutput, } from "../media-understanding/types.js"; +import type { StickerMetadata } from "../telegram/bot/types.js"; +import type { InternalMessageChannel } from "../utils/message-channel.js"; +import type { CommandArgs } from "./commands-registry.types.js"; /** Valid message channels for routing. */ export type OriginatingChannelType = ChannelId | InternalMessageChannel; diff --git a/src/auto-reply/tool-meta.test.ts b/src/auto-reply/tool-meta.test.ts index 6447effd9a3..293a340ea67 100644 --- a/src/auto-reply/tool-meta.test.ts +++ b/src/auto-reply/tool-meta.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import { formatToolAggregate, formatToolPrefix, shortenMeta, shortenPath } from "./tool-meta.js"; describe("tool meta formatting", () => { diff --git a/src/browser/bridge-server.ts b/src/browser/bridge-server.ts index 66373c5b0f6..513258406c0 100644 --- a/src/browser/bridge-server.ts +++ b/src/browser/bridge-server.ts @@ -1,10 +1,9 @@ import type { Server } from "node:http"; import type { AddressInfo } from "node:net"; import express from "express"; - import type { ResolvedBrowserConfig } from "./config.js"; -import { registerBrowserRoutes } from "./routes/index.js"; import type { BrowserRouteRegistrar } from "./routes/types.js"; +import { registerBrowserRoutes } from "./routes/index.js"; import { type BrowserServerState, createBrowserRouteContext, diff --git a/src/browser/cdp.helpers.test.ts b/src/browser/cdp.helpers.test.ts index e479c054b96..b41864ee431 100644 --- a/src/browser/cdp.helpers.test.ts +++ b/src/browser/cdp.helpers.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { appendCdpPath, getHeadersWithAuth } from "./cdp.helpers.js"; describe("cdp.helpers", () => { diff --git a/src/browser/cdp.helpers.ts b/src/browser/cdp.helpers.ts index f7cc4bab509..f34e16edda1 100644 --- a/src/browser/cdp.helpers.ts +++ b/src/browser/cdp.helpers.ts @@ -1,5 +1,4 @@ import WebSocket from "ws"; - import { rawDataToString } from "../infra/ws.js"; type CdpResponse = { diff --git a/src/browser/cdp.test.ts b/src/browser/cdp.test.ts index 46faaa7945a..979ff4af559 100644 --- a/src/browser/cdp.test.ts +++ b/src/browser/cdp.test.ts @@ -1,5 +1,4 @@ import { createServer } from "node:http"; - import { afterEach, describe, expect, it } from "vitest"; import { WebSocketServer } from "ws"; import { rawDataToString } from "../infra/ws.js"; diff --git a/src/browser/chrome.executables.ts b/src/browser/chrome.executables.ts index 9abfb4368f2..729127c9df9 100644 --- a/src/browser/chrome.executables.ts +++ b/src/browser/chrome.executables.ts @@ -2,7 +2,6 @@ import { execFileSync } from "node:child_process"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import type { ResolvedBrowserConfig } from "./config.js"; export type BrowserExecutable = { diff --git a/src/browser/chrome.profile-decoration.ts b/src/browser/chrome.profile-decoration.ts index fe6fece723e..8739860e2a4 100644 --- a/src/browser/chrome.profile-decoration.ts +++ b/src/browser/chrome.profile-decoration.ts @@ -1,6 +1,5 @@ import fs from "node:fs"; import path from "node:path"; - import { DEFAULT_OPENCLAW_BROWSER_COLOR, DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME, diff --git a/src/browser/chrome.test.ts b/src/browser/chrome.test.ts index 5f53742431b..471218a1c7c 100644 --- a/src/browser/chrome.test.ts +++ b/src/browser/chrome.test.ts @@ -2,9 +2,7 @@ import fs from "node:fs"; import fsp from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, describe, expect, it, vi } from "vitest"; - import { decorateOpenClawProfile, ensureProfileCleanExit, diff --git a/src/browser/chrome.ts b/src/browser/chrome.ts index 8a9b0b76f40..f30d4e6e96e 100644 --- a/src/browser/chrome.ts +++ b/src/browser/chrome.ts @@ -3,12 +3,12 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import WebSocket from "ws"; - +import type { ResolvedBrowserConfig, ResolvedBrowserProfile } from "./config.js"; import { ensurePortAvailable } from "../infra/ports.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { CONFIG_DIR } from "../utils.js"; -import { getHeadersWithAuth, normalizeCdpWsUrl } from "./cdp.js"; import { appendCdpPath } from "./cdp.helpers.js"; +import { getHeadersWithAuth, normalizeCdpWsUrl } from "./cdp.js"; import { type BrowserExecutable, resolveBrowserExecutableForPlatform, @@ -18,7 +18,6 @@ import { ensureProfileCleanExit, isProfileDecorated, } from "./chrome.profile-decoration.js"; -import type { ResolvedBrowserConfig, ResolvedBrowserProfile } from "./config.js"; import { DEFAULT_OPENCLAW_BROWSER_COLOR, DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME, diff --git a/src/browser/client-actions-observe.ts b/src/browser/client-actions-observe.ts index 50d0948683a..13ac92b05b7 100644 --- a/src/browser/client-actions-observe.ts +++ b/src/browser/client-actions-observe.ts @@ -1,10 +1,10 @@ import type { BrowserActionPathResult, BrowserActionTargetOk } from "./client-actions-types.js"; -import { fetchBrowserJson } from "./client-fetch.js"; import type { BrowserConsoleMessage, BrowserNetworkRequest, BrowserPageError, } from "./pw-session.js"; +import { fetchBrowserJson } from "./client-fetch.js"; function buildProfileQuery(profile?: string): string { return profile ? `?profile=${encodeURIComponent(profile)}` : ""; diff --git a/src/browser/client.test.ts b/src/browser/client.test.ts index 848c53d180a..c406c57640b 100644 --- a/src/browser/client.test.ts +++ b/src/browser/client.test.ts @@ -1,6 +1,4 @@ import { afterEach, describe, expect, it, vi } from "vitest"; - -import { browserOpenTab, browserSnapshot, browserStatus, browserTabs } from "./client.js"; import { browserAct, browserArmDialog, @@ -10,6 +8,7 @@ import { browserPdfSave, browserScreenshotAction, } from "./client-actions.js"; +import { browserOpenTab, browserSnapshot, browserStatus, browserTabs } from "./client.js"; describe("browser client", () => { afterEach(() => { diff --git a/src/browser/config.ts b/src/browser/config.ts index 5c384e59a7c..ec8572acf35 100644 --- a/src/browser/config.ts +++ b/src/browser/config.ts @@ -1,10 +1,10 @@ import type { BrowserConfig, BrowserProfileConfig, OpenClawConfig } from "../config/config.js"; +import { resolveGatewayPort } from "../config/paths.js"; import { deriveDefaultBrowserCdpPortRange, deriveDefaultBrowserControlPort, DEFAULT_BROWSER_CONTROL_PORT, } from "../config/port-defaults.js"; -import { resolveGatewayPort } from "../config/paths.js"; import { DEFAULT_OPENCLAW_BROWSER_COLOR, DEFAULT_OPENCLAW_BROWSER_ENABLED, diff --git a/src/browser/extension-relay.test.ts b/src/browser/extension-relay.test.ts index 2abdb1847ef..87f1fe449d1 100644 --- a/src/browser/extension-relay.test.ts +++ b/src/browser/extension-relay.test.ts @@ -1,8 +1,7 @@ -import { createServer } from "node:http"; import type { AddressInfo } from "node:net"; +import { createServer } from "node:http"; import { afterEach, describe, expect, it } from "vitest"; import WebSocket from "ws"; - import { ensureChromeExtensionRelayServer, stopChromeExtensionRelayServer, diff --git a/src/browser/extension-relay.ts b/src/browser/extension-relay.ts index 8ca3061f8c4..6c9164f0f0d 100644 --- a/src/browser/extension-relay.ts +++ b/src/browser/extension-relay.ts @@ -1,9 +1,7 @@ -import { createServer } from "node:http"; import type { AddressInfo } from "node:net"; import type { Duplex } from "node:stream"; - +import { createServer } from "node:http"; import WebSocket, { WebSocketServer } from "ws"; - import { rawDataToString } from "../infra/ws.js"; type CdpCommand = { diff --git a/src/browser/profiles-service.test.ts b/src/browser/profiles-service.test.ts index 3e2372a19c0..e7ac6a6315d 100644 --- a/src/browser/profiles-service.test.ts +++ b/src/browser/profiles-service.test.ts @@ -1,11 +1,9 @@ import fs from "node:fs"; import path from "node:path"; - import { describe, expect, it, vi } from "vitest"; - +import type { BrowserRouteContext, BrowserServerState } from "./server-context.js"; import { resolveBrowserConfig } from "./config.js"; import { createBrowserProfilesService } from "./profiles-service.js"; -import type { BrowserRouteContext, BrowserServerState } from "./server-context.js"; vi.mock("../config/config.js", async (importOriginal) => { const actual = await importOriginal(); diff --git a/src/browser/profiles-service.ts b/src/browser/profiles-service.ts index d39c67b9864..72a36b2bf5d 100644 --- a/src/browser/profiles-service.ts +++ b/src/browser/profiles-service.ts @@ -1,12 +1,12 @@ import fs from "node:fs"; import path from "node:path"; - import type { BrowserProfileConfig, OpenClawConfig } from "../config/config.js"; +import type { BrowserRouteContext, ProfileStatus } from "./server-context.js"; import { loadConfig, writeConfigFile } from "../config/config.js"; import { deriveDefaultBrowserCdpPortRange } from "../config/port-defaults.js"; -import { DEFAULT_BROWSER_DEFAULT_PROFILE_NAME } from "./constants.js"; import { resolveOpenClawUserDataDir } from "./chrome.js"; import { parseHttpUrl, resolveProfile } from "./config.js"; +import { DEFAULT_BROWSER_DEFAULT_PROFILE_NAME } from "./constants.js"; import { allocateCdpPort, allocateColor, @@ -14,7 +14,6 @@ import { getUsedPorts, isValidProfileName, } from "./profiles.js"; -import type { BrowserRouteContext, ProfileStatus } from "./server-context.js"; import { movePathToTrash } from "./trash.js"; export type CreateProfileParams = { diff --git a/src/browser/profiles.test.ts b/src/browser/profiles.test.ts index 6f5d3ca8d89..bfded2b94b2 100644 --- a/src/browser/profiles.test.ts +++ b/src/browser/profiles.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { allocateCdpPort, allocateColor, diff --git a/src/browser/pw-role-snapshot.test.ts b/src/browser/pw-role-snapshot.test.ts index 28af3c7ac28..7fdce9a179a 100644 --- a/src/browser/pw-role-snapshot.test.ts +++ b/src/browser/pw-role-snapshot.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { buildRoleSnapshotFromAiSnapshot, buildRoleSnapshotFromAriaSnapshot, diff --git a/src/browser/pw-session.test.ts b/src/browser/pw-session.test.ts index 1832120a5f0..a472cda6fcf 100644 --- a/src/browser/pw-session.test.ts +++ b/src/browser/pw-session.test.ts @@ -1,6 +1,5 @@ import type { Page } from "playwright-core"; import { describe, expect, it, vi } from "vitest"; - import { ensurePageState, refLocator, diff --git a/src/browser/pw-tools-core.downloads.ts b/src/browser/pw-tools-core.downloads.ts index c63b6d9eb81..60788d8fbdd 100644 --- a/src/browser/pw-tools-core.downloads.ts +++ b/src/browser/pw-tools-core.downloads.ts @@ -1,9 +1,7 @@ +import type { Page } from "playwright-core"; import crypto from "node:crypto"; import fs from "node:fs/promises"; import path from "node:path"; - -import type { Page } from "playwright-core"; - import { ensurePageState, getPageForTargetId, diff --git a/src/browser/pw-tools-core.state.ts b/src/browser/pw-tools-core.state.ts index b7b0e146b66..aeeb8859d8f 100644 --- a/src/browser/pw-tools-core.state.ts +++ b/src/browser/pw-tools-core.state.ts @@ -1,6 +1,5 @@ import type { CDPSession, Page } from "playwright-core"; import { devices as playwrightDevices } from "playwright-core"; - import { ensurePageState, getPageForTargetId } from "./pw-session.js"; async function withCdpSession(page: Page, fn: (session: CDPSession) => Promise): Promise { diff --git a/src/browser/routes/agent.act.ts b/src/browser/routes/agent.act.ts index 1fc40e72d0f..b3e97ccba81 100644 --- a/src/browser/routes/agent.act.ts +++ b/src/browser/routes/agent.act.ts @@ -1,5 +1,6 @@ import type { BrowserFormField } from "../client-actions-core.js"; import type { BrowserRouteContext } from "../server-context.js"; +import type { BrowserRouteRegistrar } from "./types.js"; import { type ActKind, isActKind, @@ -14,7 +15,6 @@ import { SELECTOR_UNSUPPORTED_MESSAGE, } from "./agent.shared.js"; import { jsonError, toBoolean, toNumber, toStringArray, toStringOrEmpty } from "./utils.js"; -import type { BrowserRouteRegistrar } from "./types.js"; export function registerBrowserAgentActRoutes( app: BrowserRouteRegistrar, diff --git a/src/browser/routes/agent.debug.ts b/src/browser/routes/agent.debug.ts index 5650cbf8380..62056de8c0d 100644 --- a/src/browser/routes/agent.debug.ts +++ b/src/browser/routes/agent.debug.ts @@ -1,11 +1,10 @@ import crypto from "node:crypto"; import fs from "node:fs/promises"; import path from "node:path"; - import type { BrowserRouteContext } from "../server-context.js"; +import type { BrowserRouteRegistrar } from "./types.js"; import { handleRouteError, readBody, requirePwAi, resolveProfileContext } from "./agent.shared.js"; import { toBoolean, toStringOrEmpty } from "./utils.js"; -import type { BrowserRouteRegistrar } from "./types.js"; export function registerBrowserAgentDebugRoutes( app: BrowserRouteRegistrar, diff --git a/src/browser/routes/agent.shared.ts b/src/browser/routes/agent.shared.ts index fbe50f4c445..7d3ddac4e8c 100644 --- a/src/browser/routes/agent.shared.ts +++ b/src/browser/routes/agent.shared.ts @@ -1,8 +1,8 @@ -import type { BrowserRouteContext, ProfileContext } from "../server-context.js"; import type { PwAiModule } from "../pw-ai-module.js"; +import type { BrowserRouteContext, ProfileContext } from "../server-context.js"; +import type { BrowserRequest, BrowserResponse } from "./types.js"; import { getPwAiModule as getPwAiModuleBase } from "../pw-ai-module.js"; import { getProfileContext, jsonError } from "./utils.js"; -import type { BrowserRequest, BrowserResponse } from "./types.js"; export const SELECTOR_UNSUPPORTED_MESSAGE = [ "Error: 'selector' is not supported. Use 'ref' from snapshot instead.", diff --git a/src/browser/routes/agent.snapshot.ts b/src/browser/routes/agent.snapshot.ts index 315b7a83a03..fb65f0e64c7 100644 --- a/src/browser/routes/agent.snapshot.ts +++ b/src/browser/routes/agent.snapshot.ts @@ -1,5 +1,6 @@ import path from "node:path"; - +import type { BrowserRouteContext } from "../server-context.js"; +import type { BrowserRouteRegistrar } from "./types.js"; import { ensureMediaDir, saveMediaBuffer } from "../../media/store.js"; import { captureScreenshot, snapshotAria } from "../cdp.js"; import { @@ -12,7 +13,6 @@ import { DEFAULT_BROWSER_SCREENSHOT_MAX_SIDE, normalizeBrowserScreenshot, } from "../screenshot.js"; -import type { BrowserRouteContext } from "../server-context.js"; import { getPwAiModule, handleRouteError, @@ -21,7 +21,6 @@ import { resolveProfileContext, } from "./agent.shared.js"; import { jsonError, toBoolean, toNumber, toStringOrEmpty } from "./utils.js"; -import type { BrowserRouteRegistrar } from "./types.js"; export function registerBrowserAgentSnapshotRoutes( app: BrowserRouteRegistrar, diff --git a/src/browser/routes/agent.storage.ts b/src/browser/routes/agent.storage.ts index 24f8994e11a..e1ba311466e 100644 --- a/src/browser/routes/agent.storage.ts +++ b/src/browser/routes/agent.storage.ts @@ -1,7 +1,7 @@ import type { BrowserRouteContext } from "../server-context.js"; +import type { BrowserRouteRegistrar } from "./types.js"; import { handleRouteError, readBody, requirePwAi, resolveProfileContext } from "./agent.shared.js"; import { jsonError, toBoolean, toNumber, toStringOrEmpty } from "./utils.js"; -import type { BrowserRouteRegistrar } from "./types.js"; export function registerBrowserAgentStorageRoutes( app: BrowserRouteRegistrar, diff --git a/src/browser/routes/agent.ts b/src/browser/routes/agent.ts index dc5e65433ac..218d378e2dc 100644 --- a/src/browser/routes/agent.ts +++ b/src/browser/routes/agent.ts @@ -1,9 +1,9 @@ import type { BrowserRouteContext } from "../server-context.js"; +import type { BrowserRouteRegistrar } from "./types.js"; import { registerBrowserAgentActRoutes } from "./agent.act.js"; import { registerBrowserAgentDebugRoutes } from "./agent.debug.js"; import { registerBrowserAgentSnapshotRoutes } from "./agent.snapshot.js"; import { registerBrowserAgentStorageRoutes } from "./agent.storage.js"; -import type { BrowserRouteRegistrar } from "./types.js"; export function registerBrowserAgentRoutes(app: BrowserRouteRegistrar, ctx: BrowserRouteContext) { registerBrowserAgentSnapshotRoutes(app, ctx); diff --git a/src/browser/routes/basic.ts b/src/browser/routes/basic.ts index f677affd4fd..598ff8c97d5 100644 --- a/src/browser/routes/basic.ts +++ b/src/browser/routes/basic.ts @@ -1,8 +1,8 @@ +import type { BrowserRouteContext } from "../server-context.js"; +import type { BrowserRouteRegistrar } from "./types.js"; import { resolveBrowserExecutableForPlatform } from "../chrome.executables.js"; import { createBrowserProfilesService } from "../profiles-service.js"; -import type { BrowserRouteContext } from "../server-context.js"; import { getProfileContext, jsonError, toStringOrEmpty } from "./utils.js"; -import type { BrowserRouteRegistrar } from "./types.js"; export function registerBrowserBasicRoutes(app: BrowserRouteRegistrar, ctx: BrowserRouteContext) { // List all profiles with their status diff --git a/src/browser/routes/dispatcher.ts b/src/browser/routes/dispatcher.ts index d7dd6a6d654..8610a6138c7 100644 --- a/src/browser/routes/dispatcher.ts +++ b/src/browser/routes/dispatcher.ts @@ -1,6 +1,6 @@ import type { BrowserRouteContext } from "../server-context.js"; -import { registerBrowserRoutes } from "./index.js"; import type { BrowserRequest, BrowserResponse, BrowserRouteRegistrar } from "./types.js"; +import { registerBrowserRoutes } from "./index.js"; type BrowserDispatchRequest = { method: "GET" | "POST" | "DELETE"; diff --git a/src/browser/routes/index.ts b/src/browser/routes/index.ts index 3c20ef1c646..27c8732d65a 100644 --- a/src/browser/routes/index.ts +++ b/src/browser/routes/index.ts @@ -1,8 +1,8 @@ import type { BrowserRouteContext } from "../server-context.js"; +import type { BrowserRouteRegistrar } from "./types.js"; import { registerBrowserAgentRoutes } from "./agent.js"; import { registerBrowserBasicRoutes } from "./basic.js"; import { registerBrowserTabRoutes } from "./tabs.js"; -import type { BrowserRouteRegistrar } from "./types.js"; export function registerBrowserRoutes(app: BrowserRouteRegistrar, ctx: BrowserRouteContext) { registerBrowserBasicRoutes(app, ctx); diff --git a/src/browser/routes/tabs.ts b/src/browser/routes/tabs.ts index 2769ff59f5f..42e469fa034 100644 --- a/src/browser/routes/tabs.ts +++ b/src/browser/routes/tabs.ts @@ -1,6 +1,6 @@ import type { BrowserRouteContext } from "../server-context.js"; -import { getProfileContext, jsonError, toNumber, toStringOrEmpty } from "./utils.js"; import type { BrowserRouteRegistrar } from "./types.js"; +import { getProfileContext, jsonError, toNumber, toStringOrEmpty } from "./utils.js"; export function registerBrowserTabRoutes(app: BrowserRouteRegistrar, ctx: BrowserRouteContext) { app.get("/tabs", async (req, res) => { diff --git a/src/browser/routes/utils.test.ts b/src/browser/routes/utils.test.ts index 72bd18cc6d8..4f7762a944e 100644 --- a/src/browser/routes/utils.test.ts +++ b/src/browser/routes/utils.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { toBoolean } from "./utils.js"; describe("toBoolean", () => { diff --git a/src/browser/routes/utils.ts b/src/browser/routes/utils.ts index 23ab7f20acf..1bd03c9ed20 100644 --- a/src/browser/routes/utils.ts +++ b/src/browser/routes/utils.ts @@ -1,6 +1,6 @@ import type { BrowserRouteContext, ProfileContext } from "../server-context.js"; -import { parseBooleanValue } from "../../utils/boolean.js"; import type { BrowserRequest, BrowserResponse } from "./types.js"; +import { parseBooleanValue } from "../../utils/boolean.js"; /** * Extract profile name from query string or body and get profile context. diff --git a/src/browser/screenshot.test.ts b/src/browser/screenshot.test.ts index 802dbdfd265..f317376bf15 100644 --- a/src/browser/screenshot.test.ts +++ b/src/browser/screenshot.test.ts @@ -1,8 +1,6 @@ import crypto from "node:crypto"; - import sharp from "sharp"; import { describe, expect, it } from "vitest"; - import { normalizeBrowserScreenshot } from "./screenshot.js"; describe("browser screenshot normalization", () => { diff --git a/src/browser/server-context.ensure-tab-available.prefers-last-target.test.ts b/src/browser/server-context.ensure-tab-available.prefers-last-target.test.ts index 4cfe2298a76..95d3f9c076f 100644 --- a/src/browser/server-context.ensure-tab-available.prefers-last-target.test.ts +++ b/src/browser/server-context.ensure-tab-available.prefers-last-target.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { BrowserServerState } from "./server-context.js"; import { createBrowserRouteContext } from "./server-context.js"; diff --git a/src/browser/server-context.remote-tab-ops.test.ts b/src/browser/server-context.remote-tab-ops.test.ts index d4c7ce7ab77..0d35ccd2219 100644 --- a/src/browser/server-context.remote-tab-ops.test.ts +++ b/src/browser/server-context.remote-tab-ops.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { BrowserServerState } from "./server-context.js"; vi.mock("./chrome.js", () => ({ diff --git a/src/browser/server-context.ts b/src/browser/server-context.ts index 80a62285882..7957b3bfaa2 100644 --- a/src/browser/server-context.ts +++ b/src/browser/server-context.ts @@ -1,15 +1,6 @@ import fs from "node:fs"; - -import { appendCdpPath, createTargetViaCdp, getHeadersWithAuth, normalizeCdpWsUrl } from "./cdp.js"; -import { - isChromeCdpReady, - isChromeReachable, - launchOpenClawChrome, - resolveOpenClawUserDataDir, - stopOpenClawChrome, -} from "./chrome.js"; import type { ResolvedBrowserProfile } from "./config.js"; -import { resolveProfile } from "./config.js"; +import type { PwAiModule } from "./pw-ai-module.js"; import type { BrowserRouteContext, BrowserTab, @@ -18,11 +9,19 @@ import type { ProfileRuntimeState, ProfileStatus, } from "./server-context.types.js"; +import { appendCdpPath, createTargetViaCdp, getHeadersWithAuth, normalizeCdpWsUrl } from "./cdp.js"; +import { + isChromeCdpReady, + isChromeReachable, + launchOpenClawChrome, + resolveOpenClawUserDataDir, + stopOpenClawChrome, +} from "./chrome.js"; +import { resolveProfile } from "./config.js"; import { ensureChromeExtensionRelayServer, stopChromeExtensionRelayServer, } from "./extension-relay.js"; -import type { PwAiModule } from "./pw-ai-module.js"; import { getPwAiModule } from "./pw-ai-module.js"; import { resolveTargetIdFromTabs } from "./target-id.js"; import { movePathToTrash } from "./trash.js"; diff --git a/src/browser/server-context.types.ts b/src/browser/server-context.types.ts index 7fa6d273a14..62a8ae02862 100644 --- a/src/browser/server-context.types.ts +++ b/src/browser/server-context.types.ts @@ -1,5 +1,4 @@ import type { Server } from "node:http"; - import type { RunningChrome } from "./chrome.js"; import type { BrowserTab } from "./client.js"; import type { ResolvedBrowserConfig, ResolvedBrowserProfile } from "./config.js"; diff --git a/src/browser/server.agent-contract-form-layout-act-commands.test.ts b/src/browser/server.agent-contract-form-layout-act-commands.test.ts index 8bbcc78a712..a8b8a38744a 100644 --- a/src/browser/server.agent-contract-form-layout-act-commands.test.ts +++ b/src/browser/server.agent-contract-form-layout-act-commands.test.ts @@ -1,6 +1,5 @@ import { type AddressInfo, createServer } from "node:net"; import { fetch as realFetch } from "undici"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; let testPort = 0; diff --git a/src/browser/server.agent-contract-snapshot-endpoints.test.ts b/src/browser/server.agent-contract-snapshot-endpoints.test.ts index e8892f6597e..ab8c70317d2 100644 --- a/src/browser/server.agent-contract-snapshot-endpoints.test.ts +++ b/src/browser/server.agent-contract-snapshot-endpoints.test.ts @@ -1,6 +1,5 @@ import { type AddressInfo, createServer } from "node:net"; import { fetch as realFetch } from "undici"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { DEFAULT_AI_SNAPSHOT_MAX_CHARS } from "./constants.js"; diff --git a/src/browser/server.covers-additional-endpoint-branches.test.ts b/src/browser/server.covers-additional-endpoint-branches.test.ts index 1b99f8d8afe..70fa7bfefb3 100644 --- a/src/browser/server.covers-additional-endpoint-branches.test.ts +++ b/src/browser/server.covers-additional-endpoint-branches.test.ts @@ -1,6 +1,5 @@ import { type AddressInfo, createServer } from "node:net"; import { fetch as realFetch } from "undici"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; let testPort = 0; diff --git a/src/browser/server.post-tabs-open-profile-unknown-returns-404.test.ts b/src/browser/server.post-tabs-open-profile-unknown-returns-404.test.ts index dbb6a01bc34..e2c75a85f0e 100644 --- a/src/browser/server.post-tabs-open-profile-unknown-returns-404.test.ts +++ b/src/browser/server.post-tabs-open-profile-unknown-returns-404.test.ts @@ -1,6 +1,5 @@ import { type AddressInfo, createServer } from "node:net"; import { fetch as realFetch } from "undici"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; let testPort = 0; diff --git a/src/browser/server.serves-status-starts-browser-requested.test.ts b/src/browser/server.serves-status-starts-browser-requested.test.ts index e879b4ce104..df9deed4a5c 100644 --- a/src/browser/server.serves-status-starts-browser-requested.test.ts +++ b/src/browser/server.serves-status-starts-browser-requested.test.ts @@ -1,6 +1,5 @@ import { type AddressInfo, createServer } from "node:net"; import { fetch as realFetch } from "undici"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; let testPort = 0; diff --git a/src/browser/server.skips-default-maxchars-explicitly-set-zero.test.ts b/src/browser/server.skips-default-maxchars-explicitly-set-zero.test.ts index c02fad6fb81..7caa3b292cd 100644 --- a/src/browser/server.skips-default-maxchars-explicitly-set-zero.test.ts +++ b/src/browser/server.skips-default-maxchars-explicitly-set-zero.test.ts @@ -1,6 +1,5 @@ import { type AddressInfo, createServer } from "node:net"; import { fetch as realFetch } from "undici"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; let testPort = 0; diff --git a/src/browser/server.ts b/src/browser/server.ts index 1c71a0803c3..8be214654b9 100644 --- a/src/browser/server.ts +++ b/src/browser/server.ts @@ -1,12 +1,11 @@ import type { Server } from "node:http"; import express from "express"; - +import type { BrowserRouteRegistrar } from "./routes/types.js"; import { loadConfig } from "../config/config.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { resolveBrowserConfig, resolveProfile } from "./config.js"; import { ensureChromeExtensionRelayServer } from "./extension-relay.js"; import { registerBrowserRoutes } from "./routes/index.js"; -import type { BrowserRouteRegistrar } from "./routes/types.js"; import { type BrowserServerState, createBrowserRouteContext } from "./server-context.js"; let state: BrowserServerState | null = null; diff --git a/src/browser/target-id.test.ts b/src/browser/target-id.test.ts index 120e782777a..a63b6aedbf3 100644 --- a/src/browser/target-id.test.ts +++ b/src/browser/target-id.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { resolveTargetIdFromTabs } from "./target-id.js"; describe("browser target id resolution", () => { diff --git a/src/browser/trash.ts b/src/browser/trash.ts index f6efcc952ca..5dcecbb106b 100644 --- a/src/browser/trash.ts +++ b/src/browser/trash.ts @@ -1,7 +1,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import { runExec } from "../process/exec.js"; export async function movePathToTrash(targetPath: string): Promise { diff --git a/src/canvas-host/a2ui.ts b/src/canvas-host/a2ui.ts index 9d89cd84a91..bea05486484 100644 --- a/src/canvas-host/a2ui.ts +++ b/src/canvas-host/a2ui.ts @@ -1,8 +1,7 @@ -import fs from "node:fs/promises"; import type { IncomingMessage, ServerResponse } from "node:http"; +import fs from "node:fs/promises"; import path from "node:path"; import { fileURLToPath } from "node:url"; - import { detectMime } from "../media/mime.js"; export const A2UI_PATH = "/__openclaw__/a2ui"; diff --git a/src/canvas-host/server.test.ts b/src/canvas-host/server.test.ts index 4f007e1e000..e59651aa127 100644 --- a/src/canvas-host/server.test.ts +++ b/src/canvas-host/server.test.ts @@ -1,6 +1,6 @@ +import type { AddressInfo } from "node:net"; import fs from "node:fs/promises"; import { createServer } from "node:http"; -import type { AddressInfo } from "node:net"; import os from "node:os"; import path from "node:path"; import { describe, expect, it, vi } from "vitest"; diff --git a/src/canvas-host/server.ts b/src/canvas-host/server.ts index ecec8bb92b4..2ba0fcf893a 100644 --- a/src/canvas-host/server.ts +++ b/src/canvas-host/server.ts @@ -1,17 +1,16 @@ +import type { Socket } from "node:net"; +import type { Duplex } from "node:stream"; +import chokidar from "chokidar"; import * as fsSync from "node:fs"; import fs from "node:fs/promises"; import http, { type IncomingMessage, type Server, type ServerResponse } from "node:http"; -import type { Socket } from "node:net"; import os from "node:os"; import path from "node:path"; -import type { Duplex } from "node:stream"; - -import chokidar from "chokidar"; import { type WebSocket, WebSocketServer } from "ws"; +import type { RuntimeEnv } from "../runtime.js"; import { isTruthyEnvValue } from "../infra/env.js"; import { SafeOpenError, openFileWithinRoot } from "../infra/fs-safe.js"; import { detectMime } from "../media/mime.js"; -import type { RuntimeEnv } from "../runtime.js"; import { ensureDir, resolveUserPath } from "../utils.js"; import { CANVAS_HOST_PATH, diff --git a/src/channel-web.barrel.test.ts b/src/channel-web.barrel.test.ts index 41e89ed52bf..0c52598c3e2 100644 --- a/src/channel-web.barrel.test.ts +++ b/src/channel-web.barrel.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import * as mod from "./channel-web.js"; describe("channel-web barrel", () => { diff --git a/src/channels/ack-reactions.test.ts b/src/channels/ack-reactions.test.ts index ed018ba5abe..862dff9f29a 100644 --- a/src/channels/ack-reactions.test.ts +++ b/src/channels/ack-reactions.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { removeAckReactionAfterReply, shouldAckReaction, diff --git a/src/channels/channel-config.test.ts b/src/channels/channel-config.test.ts index 984a486c0dd..9af6cedc135 100644 --- a/src/channels/channel-config.test.ts +++ b/src/channels/channel-config.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { buildChannelKeyCandidates, normalizeChannelSlug, diff --git a/src/channels/chat-type.test.ts b/src/channels/chat-type.test.ts index c7ceef7e937..e5893419a72 100644 --- a/src/channels/chat-type.test.ts +++ b/src/channels/chat-type.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { normalizeChatType } from "./chat-type.js"; describe("normalizeChatType", () => { diff --git a/src/channels/command-gating.test.ts b/src/channels/command-gating.test.ts index 8d922c4cd82..5ea0614e287 100644 --- a/src/channels/command-gating.test.ts +++ b/src/channels/command-gating.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { resolveCommandAuthorizedFromAuthorizers, resolveControlCommandGate, diff --git a/src/channels/conversation-label.test.ts b/src/channels/conversation-label.test.ts index 72adb35a7b7..7e261e1c55a 100644 --- a/src/channels/conversation-label.test.ts +++ b/src/channels/conversation-label.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { MsgContext } from "../auto-reply/templating.js"; import { resolveConversationLabel } from "./conversation-label.js"; diff --git a/src/channels/dock.ts b/src/channels/dock.ts index 632f725fb2d..e30a10b3c59 100644 --- a/src/channels/dock.ts +++ b/src/channels/dock.ts @@ -1,15 +1,26 @@ import type { OpenClawConfig } from "../config/config.js"; +import type { + ChannelCapabilities, + ChannelCommandAdapter, + ChannelElevatedAdapter, + ChannelGroupAdapter, + ChannelId, + ChannelAgentPromptAdapter, + ChannelMentionAdapter, + ChannelPlugin, + ChannelThreadingAdapter, +} from "./plugins/types.js"; import { resolveDiscordAccount } from "../discord/accounts.js"; import { resolveIMessageAccount } from "../imessage/accounts.js"; +import { requireActivePluginRegistry } from "../plugins/runtime.js"; +import { normalizeAccountId } from "../routing/session-key.js"; import { resolveSignalAccount } from "../signal/accounts.js"; import { resolveSlackAccount, resolveSlackReplyToMode } from "../slack/accounts.js"; import { buildSlackThreadingToolContext } from "../slack/threading-tool-context.js"; import { resolveTelegramAccount } from "../telegram/accounts.js"; -import { normalizeAccountId } from "../routing/session-key.js"; import { normalizeE164 } from "../utils.js"; import { resolveWhatsAppAccount } from "../web/accounts.js"; import { normalizeWhatsAppTarget } from "../whatsapp/normalize.js"; -import { requireActivePluginRegistry } from "../plugins/runtime.js"; import { resolveDiscordGroupRequireMention, resolveDiscordGroupToolPolicy, @@ -24,17 +35,6 @@ import { resolveWhatsAppGroupRequireMention, resolveWhatsAppGroupToolPolicy, } from "./plugins/group-mentions.js"; -import type { - ChannelCapabilities, - ChannelCommandAdapter, - ChannelElevatedAdapter, - ChannelGroupAdapter, - ChannelId, - ChannelAgentPromptAdapter, - ChannelMentionAdapter, - ChannelPlugin, - ChannelThreadingAdapter, -} from "./plugins/types.js"; import { CHAT_CHANNEL_ORDER, type ChatChannelId, getChatChannelMeta } from "./registry.js"; export type ChannelDock = { diff --git a/src/channels/location.test.ts b/src/channels/location.test.ts index 2b0085126b9..d6eade8585f 100644 --- a/src/channels/location.test.ts +++ b/src/channels/location.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { formatLocationText, toLocationContext } from "./location.js"; describe("provider location helpers", () => { diff --git a/src/channels/mention-gating.test.ts b/src/channels/mention-gating.test.ts index 5c205b3121a..e4c7c54aba2 100644 --- a/src/channels/mention-gating.test.ts +++ b/src/channels/mention-gating.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { resolveMentionGating, resolveMentionGatingWithBypass } from "./mention-gating.js"; describe("resolveMentionGating", () => { diff --git a/src/channels/plugins/actions/discord.test.ts b/src/channels/plugins/actions/discord.test.ts index 966520126da..7c41cda9d61 100644 --- a/src/channels/plugins/actions/discord.test.ts +++ b/src/channels/plugins/actions/discord.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../../../config/config.js"; type SendMessageDiscord = typeof import("../../../discord/send.js").sendMessageDiscord; type SendPollDiscord = typeof import("../../../discord/send.js").sendPollDiscord; diff --git a/src/channels/plugins/actions/discord.ts b/src/channels/plugins/actions/discord.ts index 9720d4f0bfb..5d33a62dfda 100644 --- a/src/channels/plugins/actions/discord.ts +++ b/src/channels/plugins/actions/discord.ts @@ -1,6 +1,6 @@ +import type { ChannelMessageActionAdapter, ChannelMessageActionName } from "../types.js"; import { createActionGate } from "../../../agents/tools/common.js"; import { listEnabledDiscordAccounts } from "../../../discord/accounts.js"; -import type { ChannelMessageActionAdapter, ChannelMessageActionName } from "../types.js"; import { handleDiscordMessageAction } from "./discord/handle-action.js"; export const discordMessageActions: ChannelMessageActionAdapter = { diff --git a/src/channels/plugins/actions/discord/handle-action.guild-admin.ts b/src/channels/plugins/actions/discord/handle-action.guild-admin.ts index 1be557648c2..bcffb7e97cc 100644 --- a/src/channels/plugins/actions/discord/handle-action.guild-admin.ts +++ b/src/channels/plugins/actions/discord/handle-action.guild-admin.ts @@ -1,11 +1,11 @@ import type { AgentToolResult } from "@mariozechner/pi-agent-core"; +import type { ChannelMessageActionContext } from "../../types.js"; import { readNumberParam, readStringArrayParam, readStringParam, } from "../../../../agents/tools/common.js"; import { handleDiscordAction } from "../../../../agents/tools/discord-actions.js"; -import type { ChannelMessageActionContext } from "../../types.js"; type Ctx = Pick; diff --git a/src/channels/plugins/actions/discord/handle-action.ts b/src/channels/plugins/actions/discord/handle-action.ts index bf8736dd1ee..bccc7fac24a 100644 --- a/src/channels/plugins/actions/discord/handle-action.ts +++ b/src/channels/plugins/actions/discord/handle-action.ts @@ -1,13 +1,13 @@ import type { AgentToolResult } from "@mariozechner/pi-agent-core"; +import type { ChannelMessageActionContext } from "../../types.js"; import { readNumberParam, readStringArrayParam, readStringParam, } from "../../../../agents/tools/common.js"; import { handleDiscordAction } from "../../../../agents/tools/discord-actions.js"; -import type { ChannelMessageActionContext } from "../../types.js"; -import { tryHandleDiscordMessageActionGuildAdmin } from "./handle-action.guild-admin.js"; import { resolveDiscordChannelId } from "../../../../discord/targets.js"; +import { tryHandleDiscordMessageActionGuildAdmin } from "./handle-action.guild-admin.js"; const providerId = "discord"; diff --git a/src/channels/plugins/actions/signal.test.ts b/src/channels/plugins/actions/signal.test.ts index bf9515bbdfe..613b725f77a 100644 --- a/src/channels/plugins/actions/signal.test.ts +++ b/src/channels/plugins/actions/signal.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../../../config/config.js"; import { signalMessageActions } from "./signal.js"; diff --git a/src/channels/plugins/actions/signal.ts b/src/channels/plugins/actions/signal.ts index 7a7ec55bd7c..b9dd4b5c597 100644 --- a/src/channels/plugins/actions/signal.ts +++ b/src/channels/plugins/actions/signal.ts @@ -1,8 +1,8 @@ +import type { ChannelMessageActionAdapter, ChannelMessageActionName } from "../types.js"; import { createActionGate, jsonResult, readStringParam } from "../../../agents/tools/common.js"; import { listEnabledSignalAccounts, resolveSignalAccount } from "../../../signal/accounts.js"; import { resolveSignalReactionLevel } from "../../../signal/reaction-level.js"; import { sendReactionSignal, removeReactionSignal } from "../../../signal/send-reactions.js"; -import type { ChannelMessageActionAdapter, ChannelMessageActionName } from "../types.js"; const providerId = "signal"; const GROUP_PREFIX = "group:"; diff --git a/src/channels/plugins/actions/telegram.test.ts b/src/channels/plugins/actions/telegram.test.ts index 1ccc1e628e3..21922905e53 100644 --- a/src/channels/plugins/actions/telegram.test.ts +++ b/src/channels/plugins/actions/telegram.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../../../config/config.js"; import { telegramMessageActions } from "./telegram.js"; diff --git a/src/channels/plugins/actions/telegram.ts b/src/channels/plugins/actions/telegram.ts index 6a0b5751b72..a4af24e46fe 100644 --- a/src/channels/plugins/actions/telegram.ts +++ b/src/channels/plugins/actions/telegram.ts @@ -1,3 +1,4 @@ +import type { ChannelMessageActionAdapter, ChannelMessageActionName } from "../types.js"; import { createActionGate, readNumberParam, @@ -8,7 +9,6 @@ import { import { handleTelegramAction } from "../../../agents/tools/telegram-actions.js"; import { listEnabledTelegramAccounts } from "../../../telegram/accounts.js"; import { isTelegramInlineButtonsEnabled } from "../../../telegram/inline-buttons.js"; -import type { ChannelMessageActionAdapter, ChannelMessageActionName } from "../types.js"; const providerId = "telegram"; diff --git a/src/channels/plugins/catalog.test.ts b/src/channels/plugins/catalog.test.ts index d2ec963f564..d62fac8a8fc 100644 --- a/src/channels/plugins/catalog.test.ts +++ b/src/channels/plugins/catalog.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { describe, expect, it } from "vitest"; - import { getChannelPluginCatalogEntry, listChannelPluginCatalogEntries } from "./catalog.js"; describe("channel plugin catalog", () => { diff --git a/src/channels/plugins/catalog.ts b/src/channels/plugins/catalog.ts index 57d7add8dc0..e5774fba724 100644 --- a/src/channels/plugins/catalog.ts +++ b/src/channels/plugins/catalog.ts @@ -1,12 +1,11 @@ import fs from "node:fs"; import path from "node:path"; - +import type { OpenClawPackageManifest } from "../../plugins/manifest.js"; +import type { PluginOrigin } from "../../plugins/types.js"; +import type { ChannelMeta } from "./types.js"; import { MANIFEST_KEY } from "../../compat/legacy-names.js"; import { discoverOpenClawPlugins } from "../../plugins/discovery.js"; -import type { PluginOrigin } from "../../plugins/types.js"; -import type { OpenClawPackageManifest } from "../../plugins/manifest.js"; import { CONFIG_DIR, resolveUserPath } from "../../utils.js"; -import type { ChannelMeta } from "./types.js"; export type ChannelUiMetaEntry = { id: string; diff --git a/src/channels/plugins/config-schema.ts b/src/channels/plugins/config-schema.ts index f5b4f8b80cc..50b81e83b92 100644 --- a/src/channels/plugins/config-schema.ts +++ b/src/channels/plugins/config-schema.ts @@ -1,5 +1,4 @@ import type { ZodTypeAny } from "zod"; - import type { ChannelConfigSchema } from "./types.plugin.js"; export function buildChannelConfigSchema(schema: ZodTypeAny): ChannelConfigSchema { diff --git a/src/channels/plugins/config-writes.test.ts b/src/channels/plugins/config-writes.test.ts index 107f4222160..00fe9164f8e 100644 --- a/src/channels/plugins/config-writes.test.ts +++ b/src/channels/plugins/config-writes.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { resolveChannelConfigWrites } from "./config-writes.js"; describe("resolveChannelConfigWrites", () => { diff --git a/src/channels/plugins/directory-config.ts b/src/channels/plugins/directory-config.ts index 2afd45df449..5c25993a50b 100644 --- a/src/channels/plugins/directory-config.ts +++ b/src/channels/plugins/directory-config.ts @@ -1,11 +1,11 @@ import type { OpenClawConfig } from "../../config/types.js"; import type { ChannelDirectoryEntry } from "./types.js"; -import { resolveSlackAccount } from "../../slack/accounts.js"; import { resolveDiscordAccount } from "../../discord/accounts.js"; +import { resolveSlackAccount } from "../../slack/accounts.js"; import { resolveTelegramAccount } from "../../telegram/accounts.js"; import { resolveWhatsAppAccount } from "../../web/accounts.js"; -import { normalizeSlackMessagingTarget } from "./normalize/slack.js"; import { isWhatsAppGroupJid, normalizeWhatsAppTarget } from "../../whatsapp/normalize.js"; +import { normalizeSlackMessagingTarget } from "./normalize/slack.js"; export type DirectoryConfigParams = { cfg: OpenClawConfig; diff --git a/src/channels/plugins/group-mentions.ts b/src/channels/plugins/group-mentions.ts index b274312166b..708b4d3c190 100644 --- a/src/channels/plugins/group-mentions.ts +++ b/src/channels/plugins/group-mentions.ts @@ -1,14 +1,14 @@ import type { OpenClawConfig } from "../../config/config.js"; -import { - resolveChannelGroupRequireMention, - resolveChannelGroupToolsPolicy, - resolveToolsBySender, -} from "../../config/group-policy.js"; import type { DiscordConfig } from "../../config/types.js"; import type { GroupToolPolicyBySenderConfig, GroupToolPolicyConfig, } from "../../config/types.tools.js"; +import { + resolveChannelGroupRequireMention, + resolveChannelGroupToolsPolicy, + resolveToolsBySender, +} from "../../config/group-policy.js"; import { resolveSlackAccount } from "../../slack/accounts.js"; type GroupMentionParams = { diff --git a/src/channels/plugins/helpers.ts b/src/channels/plugins/helpers.ts index 9e7499c2375..f4eea637409 100644 --- a/src/channels/plugins/helpers.ts +++ b/src/channels/plugins/helpers.ts @@ -1,7 +1,7 @@ -import { formatCliCommand } from "../../cli/command-format.js"; import type { OpenClawConfig } from "../../config/config.js"; -import { DEFAULT_ACCOUNT_ID } from "../../routing/session-key.js"; import type { ChannelPlugin } from "./types.js"; +import { formatCliCommand } from "../../cli/command-format.js"; +import { DEFAULT_ACCOUNT_ID } from "../../routing/session-key.js"; // Channel docking helper: use this when selecting the default account for a plugin. export function resolveChannelDefaultAccountId(params: { diff --git a/src/channels/plugins/index.ts b/src/channels/plugins/index.ts index ffa00b20a17..ef9870a3d94 100644 --- a/src/channels/plugins/index.ts +++ b/src/channels/plugins/index.ts @@ -1,6 +1,6 @@ -import { CHAT_CHANNEL_ORDER, type ChatChannelId, normalizeAnyChannelId } from "../registry.js"; import type { ChannelId, ChannelPlugin } from "./types.js"; import { requireActivePluginRegistry } from "../../plugins/runtime.js"; +import { CHAT_CHANNEL_ORDER, type ChatChannelId, normalizeAnyChannelId } from "../registry.js"; // Channel plugins registry (runtime). // diff --git a/src/channels/plugins/load.test.ts b/src/channels/plugins/load.test.ts index d2cea25e1b9..f3daf0543c7 100644 --- a/src/channels/plugins/load.test.ts +++ b/src/channels/plugins/load.test.ts @@ -1,7 +1,6 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest"; - -import type { ChannelOutboundAdapter, ChannelPlugin } from "./types.js"; import type { PluginRegistry } from "../../plugins/registry.js"; +import type { ChannelOutboundAdapter, ChannelPlugin } from "./types.js"; import { setActivePluginRegistry } from "../../plugins/runtime.js"; import { loadChannelPlugin } from "./load.js"; import { loadChannelOutboundAdapter } from "./outbound/load.js"; diff --git a/src/channels/plugins/load.ts b/src/channels/plugins/load.ts index 565b0a56717..6b0d6e90b41 100644 --- a/src/channels/plugins/load.ts +++ b/src/channels/plugins/load.ts @@ -1,5 +1,5 @@ -import type { ChannelId, ChannelPlugin } from "./types.js"; import type { PluginRegistry } from "../../plugins/registry.js"; +import type { ChannelId, ChannelPlugin } from "./types.js"; import { getActivePluginRegistry } from "../../plugins/runtime.js"; const cache = new Map(); diff --git a/src/channels/plugins/message-actions.ts b/src/channels/plugins/message-actions.ts index 491d76abb7d..806d2985d51 100644 --- a/src/channels/plugins/message-actions.ts +++ b/src/channels/plugins/message-actions.ts @@ -1,8 +1,7 @@ import type { AgentToolResult } from "@mariozechner/pi-agent-core"; - import type { OpenClawConfig } from "../../config/config.js"; -import { getChannelPlugin, listChannelPlugins } from "./index.js"; import type { ChannelMessageActionContext, ChannelMessageActionName } from "./types.js"; +import { getChannelPlugin, listChannelPlugins } from "./index.js"; export function listChannelMessageActions(cfg: OpenClawConfig): ChannelMessageActionName[] { const actions = new Set(["send", "broadcast"]); diff --git a/src/channels/plugins/normalize/imessage.test.ts b/src/channels/plugins/normalize/imessage.test.ts index afb2ec358f8..a3cbf0501eb 100644 --- a/src/channels/plugins/normalize/imessage.test.ts +++ b/src/channels/plugins/normalize/imessage.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { normalizeIMessageMessagingTarget } from "./imessage.js"; describe("imessage target normalization", () => { diff --git a/src/channels/plugins/normalize/signal.test.ts b/src/channels/plugins/normalize/signal.test.ts index 6f4aee049ae..29a8c5d42b6 100644 --- a/src/channels/plugins/normalize/signal.test.ts +++ b/src/channels/plugins/normalize/signal.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { looksLikeSignalTargetId, normalizeSignalMessagingTarget } from "./signal.js"; describe("signal target normalization", () => { diff --git a/src/channels/plugins/onboarding/discord.ts b/src/channels/plugins/onboarding/discord.ts index 79c80b41eb2..96047ac3e4b 100644 --- a/src/channels/plugins/onboarding/discord.ts +++ b/src/channels/plugins/onboarding/discord.ts @@ -1,21 +1,21 @@ import type { OpenClawConfig } from "../../../config/config.js"; -import type { DmPolicy } from "../../../config/types.js"; import type { DiscordGuildEntry } from "../../../config/types.discord.js"; +import type { DmPolicy } from "../../../config/types.js"; +import type { WizardPrompter } from "../../../wizard/prompts.js"; +import type { ChannelOnboardingAdapter, ChannelOnboardingDmPolicy } from "../onboarding-types.js"; import { listDiscordAccountIds, resolveDefaultDiscordAccountId, resolveDiscordAccount, } from "../../../discord/accounts.js"; import { normalizeDiscordSlug } from "../../../discord/monitor/allow-list.js"; -import { resolveDiscordUserAllowlist } from "../../../discord/resolve-users.js"; import { resolveDiscordChannelAllowlist, type DiscordChannelResolution, } from "../../../discord/resolve-channels.js"; +import { resolveDiscordUserAllowlist } from "../../../discord/resolve-users.js"; import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../routing/session-key.js"; import { formatDocsLink } from "../../../terminal/links.js"; -import type { WizardPrompter } from "../../../wizard/prompts.js"; -import type { ChannelOnboardingAdapter, ChannelOnboardingDmPolicy } from "../onboarding-types.js"; import { promptChannelAccessConfig } from "./channel-access.js"; import { addWildcardAllowFrom, promptAccountId } from "./helpers.js"; diff --git a/src/channels/plugins/onboarding/helpers.ts b/src/channels/plugins/onboarding/helpers.ts index 6469eaa4e44..951f4522a8f 100644 --- a/src/channels/plugins/onboarding/helpers.ts +++ b/src/channels/plugins/onboarding/helpers.ts @@ -1,5 +1,5 @@ -import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../routing/session-key.js"; import type { PromptAccountId, PromptAccountIdParams } from "../onboarding-types.js"; +import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../routing/session-key.js"; export const promptAccountId: PromptAccountId = async (params: PromptAccountIdParams) => { const existingIds = params.listAccountIds(params.cfg); diff --git a/src/channels/plugins/onboarding/imessage.ts b/src/channels/plugins/onboarding/imessage.ts index 573e3f3aec4..61167fe7005 100644 --- a/src/channels/plugins/onboarding/imessage.ts +++ b/src/channels/plugins/onboarding/imessage.ts @@ -1,6 +1,8 @@ -import { detectBinary } from "../../../commands/onboard-helpers.js"; import type { OpenClawConfig } from "../../../config/config.js"; import type { DmPolicy } from "../../../config/types.js"; +import type { WizardPrompter } from "../../../wizard/prompts.js"; +import type { ChannelOnboardingAdapter, ChannelOnboardingDmPolicy } from "../onboarding-types.js"; +import { detectBinary } from "../../../commands/onboard-helpers.js"; import { listIMessageAccountIds, resolveDefaultIMessageAccountId, @@ -9,8 +11,6 @@ import { import { normalizeIMessageHandle } from "../../../imessage/targets.js"; import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../routing/session-key.js"; import { formatDocsLink } from "../../../terminal/links.js"; -import type { WizardPrompter } from "../../../wizard/prompts.js"; -import type { ChannelOnboardingAdapter, ChannelOnboardingDmPolicy } from "../onboarding-types.js"; import { addWildcardAllowFrom, promptAccountId } from "./helpers.js"; const channel = "imessage" as const; diff --git a/src/channels/plugins/onboarding/signal.ts b/src/channels/plugins/onboarding/signal.ts index ed594e9ed8c..3f5b969e5d5 100644 --- a/src/channels/plugins/onboarding/signal.ts +++ b/src/channels/plugins/onboarding/signal.ts @@ -1,7 +1,10 @@ -import { detectBinary } from "../../../commands/onboard-helpers.js"; -import { installSignalCli } from "../../../commands/signal-install.js"; import type { OpenClawConfig } from "../../../config/config.js"; import type { DmPolicy } from "../../../config/types.js"; +import type { WizardPrompter } from "../../../wizard/prompts.js"; +import type { ChannelOnboardingAdapter, ChannelOnboardingDmPolicy } from "../onboarding-types.js"; +import { formatCliCommand } from "../../../cli/command-format.js"; +import { detectBinary } from "../../../commands/onboard-helpers.js"; +import { installSignalCli } from "../../../commands/signal-install.js"; import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../routing/session-key.js"; import { listSignalAccountIds, @@ -9,10 +12,7 @@ import { resolveSignalAccount, } from "../../../signal/accounts.js"; import { formatDocsLink } from "../../../terminal/links.js"; -import { formatCliCommand } from "../../../cli/command-format.js"; import { normalizeE164 } from "../../../utils.js"; -import type { WizardPrompter } from "../../../wizard/prompts.js"; -import type { ChannelOnboardingAdapter, ChannelOnboardingDmPolicy } from "../onboarding-types.js"; import { addWildcardAllowFrom, promptAccountId } from "./helpers.js"; const channel = "signal" as const; diff --git a/src/channels/plugins/onboarding/slack.ts b/src/channels/plugins/onboarding/slack.ts index 860534209c0..0919a35bf6a 100644 --- a/src/channels/plugins/onboarding/slack.ts +++ b/src/channels/plugins/onboarding/slack.ts @@ -1,5 +1,7 @@ import type { OpenClawConfig } from "../../../config/config.js"; import type { DmPolicy } from "../../../config/types.js"; +import type { WizardPrompter } from "../../../wizard/prompts.js"; +import type { ChannelOnboardingAdapter, ChannelOnboardingDmPolicy } from "../onboarding-types.js"; import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../routing/session-key.js"; import { listSlackAccountIds, @@ -9,8 +11,6 @@ import { import { resolveSlackChannelAllowlist } from "../../../slack/resolve-channels.js"; import { resolveSlackUserAllowlist } from "../../../slack/resolve-users.js"; import { formatDocsLink } from "../../../terminal/links.js"; -import type { WizardPrompter } from "../../../wizard/prompts.js"; -import type { ChannelOnboardingAdapter, ChannelOnboardingDmPolicy } from "../onboarding-types.js"; import { promptChannelAccessConfig } from "./channel-access.js"; import { addWildcardAllowFrom, promptAccountId } from "./helpers.js"; diff --git a/src/channels/plugins/onboarding/telegram.ts b/src/channels/plugins/onboarding/telegram.ts index 0923d5d40a8..d84a1aded51 100644 --- a/src/channels/plugins/onboarding/telegram.ts +++ b/src/channels/plugins/onboarding/telegram.ts @@ -1,5 +1,8 @@ import type { OpenClawConfig } from "../../../config/config.js"; import type { DmPolicy } from "../../../config/types.js"; +import type { WizardPrompter } from "../../../wizard/prompts.js"; +import type { ChannelOnboardingAdapter, ChannelOnboardingDmPolicy } from "../onboarding-types.js"; +import { formatCliCommand } from "../../../cli/command-format.js"; import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../routing/session-key.js"; import { listTelegramAccountIds, @@ -7,9 +10,6 @@ import { resolveTelegramAccount, } from "../../../telegram/accounts.js"; import { formatDocsLink } from "../../../terminal/links.js"; -import { formatCliCommand } from "../../../cli/command-format.js"; -import type { WizardPrompter } from "../../../wizard/prompts.js"; -import type { ChannelOnboardingAdapter, ChannelOnboardingDmPolicy } from "../onboarding-types.js"; import { addWildcardAllowFrom, promptAccountId } from "./helpers.js"; const channel = "telegram" as const; diff --git a/src/channels/plugins/onboarding/whatsapp.ts b/src/channels/plugins/onboarding/whatsapp.ts index c337ce9a455..761f2f8cb20 100644 --- a/src/channels/plugins/onboarding/whatsapp.ts +++ b/src/channels/plugins/onboarding/whatsapp.ts @@ -1,21 +1,21 @@ import fs from "node:fs/promises"; import path from "node:path"; -import { loginWeb } from "../../../channel-web.js"; import type { OpenClawConfig } from "../../../config/config.js"; -import { mergeWhatsAppConfig } from "../../../config/merge-config.js"; import type { DmPolicy } from "../../../config/types.js"; -import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../routing/session-key.js"; import type { RuntimeEnv } from "../../../runtime.js"; -import { formatDocsLink } from "../../../terminal/links.js"; +import type { WizardPrompter } from "../../../wizard/prompts.js"; +import type { ChannelOnboardingAdapter } from "../onboarding-types.js"; +import { loginWeb } from "../../../channel-web.js"; import { formatCliCommand } from "../../../cli/command-format.js"; +import { mergeWhatsAppConfig } from "../../../config/merge-config.js"; +import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../routing/session-key.js"; +import { formatDocsLink } from "../../../terminal/links.js"; import { normalizeE164 } from "../../../utils.js"; import { listWhatsAppAccountIds, resolveDefaultWhatsAppAccountId, resolveWhatsAppAuthDir, } from "../../../web/accounts.js"; -import type { WizardPrompter } from "../../../wizard/prompts.js"; -import type { ChannelOnboardingAdapter } from "../onboarding-types.js"; import { promptAccountId } from "./helpers.js"; const channel = "whatsapp" as const; diff --git a/src/channels/plugins/outbound/discord.ts b/src/channels/plugins/outbound/discord.ts index b3dca39e86a..bc8126d4d3d 100644 --- a/src/channels/plugins/outbound/discord.ts +++ b/src/channels/plugins/outbound/discord.ts @@ -1,5 +1,5 @@ -import { sendMessageDiscord, sendPollDiscord } from "../../../discord/send.js"; import type { ChannelOutboundAdapter } from "../types.js"; +import { sendMessageDiscord, sendPollDiscord } from "../../../discord/send.js"; export const discordOutbound: ChannelOutboundAdapter = { deliveryMode: "direct", diff --git a/src/channels/plugins/outbound/imessage.ts b/src/channels/plugins/outbound/imessage.ts index 03dd0722299..2cfd122bd6f 100644 --- a/src/channels/plugins/outbound/imessage.ts +++ b/src/channels/plugins/outbound/imessage.ts @@ -1,7 +1,7 @@ +import type { ChannelOutboundAdapter } from "../types.js"; import { chunkText } from "../../../auto-reply/chunk.js"; import { sendMessageIMessage } from "../../../imessage/send.js"; import { resolveChannelMediaMaxBytes } from "../media-limits.js"; -import type { ChannelOutboundAdapter } from "../types.js"; export const imessageOutbound: ChannelOutboundAdapter = { deliveryMode: "direct", diff --git a/src/channels/plugins/outbound/load.ts b/src/channels/plugins/outbound/load.ts index b4697b052be..c3b2ba068dd 100644 --- a/src/channels/plugins/outbound/load.ts +++ b/src/channels/plugins/outbound/load.ts @@ -1,5 +1,5 @@ -import type { ChannelId, ChannelOutboundAdapter } from "../types.js"; import type { PluginRegistry } from "../../../plugins/registry.js"; +import type { ChannelId, ChannelOutboundAdapter } from "../types.js"; import { getActivePluginRegistry } from "../../../plugins/runtime.js"; // Channel docking: outbound sends should stay cheap to import. diff --git a/src/channels/plugins/outbound/signal.ts b/src/channels/plugins/outbound/signal.ts index c2f0710cfda..8f880745fe7 100644 --- a/src/channels/plugins/outbound/signal.ts +++ b/src/channels/plugins/outbound/signal.ts @@ -1,7 +1,7 @@ +import type { ChannelOutboundAdapter } from "../types.js"; import { chunkText } from "../../../auto-reply/chunk.js"; import { sendMessageSignal } from "../../../signal/send.js"; import { resolveChannelMediaMaxBytes } from "../media-limits.js"; -import type { ChannelOutboundAdapter } from "../types.js"; export const signalOutbound: ChannelOutboundAdapter = { deliveryMode: "direct", diff --git a/src/channels/plugins/outbound/slack.ts b/src/channels/plugins/outbound/slack.ts index 0f33b16b513..08d27bd7073 100644 --- a/src/channels/plugins/outbound/slack.ts +++ b/src/channels/plugins/outbound/slack.ts @@ -1,5 +1,5 @@ -import { sendMessageSlack } from "../../../slack/send.js"; import type { ChannelOutboundAdapter } from "../types.js"; +import { sendMessageSlack } from "../../../slack/send.js"; export const slackOutbound: ChannelOutboundAdapter = { deliveryMode: "direct", diff --git a/src/channels/plugins/outbound/telegram.test.ts b/src/channels/plugins/outbound/telegram.test.ts index 1b14056f3c2..7981addf566 100644 --- a/src/channels/plugins/outbound/telegram.test.ts +++ b/src/channels/plugins/outbound/telegram.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../../../config/config.js"; import { telegramOutbound } from "./telegram.js"; diff --git a/src/channels/plugins/outbound/telegram.ts b/src/channels/plugins/outbound/telegram.ts index a42550292d4..25e3301b45c 100644 --- a/src/channels/plugins/outbound/telegram.ts +++ b/src/channels/plugins/outbound/telegram.ts @@ -1,6 +1,6 @@ +import type { ChannelOutboundAdapter } from "../types.js"; import { markdownToTelegramHtmlChunks } from "../../../telegram/format.js"; import { sendMessageTelegram } from "../../../telegram/send.js"; -import type { ChannelOutboundAdapter } from "../types.js"; function parseReplyToMessageId(replyToId?: string | null) { if (!replyToId) { diff --git a/src/channels/plugins/outbound/whatsapp.ts b/src/channels/plugins/outbound/whatsapp.ts index 303a015da62..cf1f7b3ab79 100644 --- a/src/channels/plugins/outbound/whatsapp.ts +++ b/src/channels/plugins/outbound/whatsapp.ts @@ -1,9 +1,9 @@ +import type { ChannelOutboundAdapter } from "../types.js"; import { chunkText } from "../../../auto-reply/chunk.js"; import { shouldLogVerbose } from "../../../globals.js"; +import { missingTargetError } from "../../../infra/outbound/target-errors.js"; import { sendPollWhatsApp } from "../../../web/outbound.js"; import { isWhatsAppGroupJid, normalizeWhatsAppTarget } from "../../../whatsapp/normalize.js"; -import type { ChannelOutboundAdapter } from "../types.js"; -import { missingTargetError } from "../../../infra/outbound/target-errors.js"; export const whatsappOutbound: ChannelOutboundAdapter = { deliveryMode: "gateway", diff --git a/src/channels/plugins/pairing.ts b/src/channels/plugins/pairing.ts index f179ae6983e..ea5e5451c01 100644 --- a/src/channels/plugins/pairing.ts +++ b/src/channels/plugins/pairing.ts @@ -1,12 +1,12 @@ import type { OpenClawConfig } from "../../config/config.js"; import type { RuntimeEnv } from "../../runtime.js"; +import type { ChannelPairingAdapter } from "./types.js"; import { type ChannelId, getChannelPlugin, listChannelPlugins, normalizeChannelId, } from "./index.js"; -import type { ChannelPairingAdapter } from "./types.js"; export function listPairingChannels(): ChannelId[] { // Channel docking: pairing support is declared via plugin.pairing. diff --git a/src/channels/plugins/slack.actions.test.ts b/src/channels/plugins/slack.actions.test.ts index 51a7390fc67..a6644e3965d 100644 --- a/src/channels/plugins/slack.actions.test.ts +++ b/src/channels/plugins/slack.actions.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import { createSlackActions } from "./slack.actions.js"; diff --git a/src/channels/plugins/slack.actions.ts b/src/channels/plugins/slack.actions.ts index 13fef011555..60601f4fdf1 100644 --- a/src/channels/plugins/slack.actions.ts +++ b/src/channels/plugins/slack.actions.ts @@ -1,13 +1,13 @@ -import { createActionGate, readNumberParam, readStringParam } from "../../agents/tools/common.js"; -import { handleSlackAction, type SlackActionContext } from "../../agents/tools/slack-actions.js"; -import { listEnabledSlackAccounts } from "../../slack/accounts.js"; -import { resolveSlackChannelId } from "../../slack/targets.js"; import type { ChannelMessageActionAdapter, ChannelMessageActionContext, ChannelMessageActionName, ChannelToolSend, } from "./types.js"; +import { createActionGate, readNumberParam, readStringParam } from "../../agents/tools/common.js"; +import { handleSlackAction, type SlackActionContext } from "../../agents/tools/slack-actions.js"; +import { listEnabledSlackAccounts } from "../../slack/accounts.js"; +import { resolveSlackChannelId } from "../../slack/targets.js"; export function createSlackActions(providerId: string): ChannelMessageActionAdapter { return { diff --git a/src/channels/plugins/status-issues/whatsapp.ts b/src/channels/plugins/status-issues/whatsapp.ts index 99ed65a0008..66e23a61de0 100644 --- a/src/channels/plugins/status-issues/whatsapp.ts +++ b/src/channels/plugins/status-issues/whatsapp.ts @@ -1,5 +1,5 @@ -import { formatCliCommand } from "../../../cli/command-format.js"; import type { ChannelAccountSnapshot, ChannelStatusIssue } from "../types.js"; +import { formatCliCommand } from "../../../cli/command-format.js"; import { asString, isRecord } from "./shared.js"; type WhatsAppAccountStatus = { diff --git a/src/channels/plugins/types.adapters.ts b/src/channels/plugins/types.adapters.ts index a4eeaa0dd91..f1f0720b0bd 100644 --- a/src/channels/plugins/types.adapters.ts +++ b/src/channels/plugins/types.adapters.ts @@ -1,5 +1,5 @@ -import type { OpenClawConfig } from "../../config/config.js"; import type { ReplyPayload } from "../../auto-reply/types.js"; +import type { OpenClawConfig } from "../../config/config.js"; import type { GroupToolPolicyConfig } from "../../config/types.tools.js"; import type { OutboundDeliveryResult, OutboundSendDeps } from "../../infra/outbound/deliver.js"; import type { RuntimeEnv } from "../../runtime.js"; diff --git a/src/channels/plugins/whatsapp-heartbeat.ts b/src/channels/plugins/whatsapp-heartbeat.ts index ba19747577b..0710ab15e3f 100644 --- a/src/channels/plugins/whatsapp-heartbeat.ts +++ b/src/channels/plugins/whatsapp-heartbeat.ts @@ -1,5 +1,5 @@ -import { normalizeChatChannelId } from "../../channels/registry.js"; import type { OpenClawConfig } from "../../config/config.js"; +import { normalizeChatChannelId } from "../../channels/registry.js"; import { loadSessionStore, resolveStorePath } from "../../config/sessions.js"; import { normalizeE164 } from "../../utils.js"; diff --git a/src/channels/registry.test.ts b/src/channels/registry.test.ts index c5da14e9a1a..5101519b98c 100644 --- a/src/channels/registry.test.ts +++ b/src/channels/registry.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { formatChannelSelectionLine, listChatChannels, diff --git a/src/channels/reply-prefix.ts b/src/channels/reply-prefix.ts index b6fae796277..07cc4edc276 100644 --- a/src/channels/reply-prefix.ts +++ b/src/channels/reply-prefix.ts @@ -1,6 +1,6 @@ -import { resolveEffectiveMessagesConfig, resolveIdentityName } from "../agents/identity.js"; -import type { OpenClawConfig } from "../config/config.js"; import type { GetReplyOptions } from "../auto-reply/types.js"; +import type { OpenClawConfig } from "../config/config.js"; +import { resolveEffectiveMessagesConfig, resolveIdentityName } from "../agents/identity.js"; import { extractShortModelName, type ResponsePrefixContext, diff --git a/src/channels/sender-identity.test.ts b/src/channels/sender-identity.test.ts index c20a402b79e..7c93821efbe 100644 --- a/src/channels/sender-identity.test.ts +++ b/src/channels/sender-identity.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { MsgContext } from "../auto-reply/templating.js"; import { validateSenderIdentity } from "./sender-identity.js"; diff --git a/src/channels/targets.test.ts b/src/channels/targets.test.ts index bcd17db3b1e..256c60bc435 100644 --- a/src/channels/targets.test.ts +++ b/src/channels/targets.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { buildMessagingTarget, ensureTargetId, requireTargetKind } from "./targets.js"; describe("ensureTargetId", () => { diff --git a/src/channels/typing.test.ts b/src/channels/typing.test.ts index 42080b3c109..5df7e02aa0b 100644 --- a/src/channels/typing.test.ts +++ b/src/channels/typing.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { createTypingCallbacks } from "./typing.js"; const flush = () => new Promise((resolve) => setTimeout(resolve, 0)); diff --git a/src/channels/web/index.test.ts b/src/channels/web/index.test.ts index 23f2dc5113a..8f628495798 100644 --- a/src/channels/web/index.test.ts +++ b/src/channels/web/index.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import * as impl from "../../channel-web.js"; import * as entry from "./index.js"; diff --git a/src/cli/acp-cli.ts b/src/cli/acp-cli.ts index ea3772db0b3..1be77e71fcd 100644 --- a/src/cli/acp-cli.ts +++ b/src/cli/acp-cli.ts @@ -1,5 +1,4 @@ import type { Command } from "commander"; - import { runAcpClientInteractive } from "../acp/client.js"; import { serveAcpGateway } from "../acp/server.js"; import { defaultRuntime } from "../runtime.js"; diff --git a/src/cli/argv.test.ts b/src/cli/argv.test.ts index 01b0a50bba6..207a28caefe 100644 --- a/src/cli/argv.test.ts +++ b/src/cli/argv.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { buildParseArgv, getFlagValue, diff --git a/src/cli/browser-cli-actions-input/register.element.ts b/src/cli/browser-cli-actions-input/register.element.ts index 270d59d6825..10e3b6497c8 100644 --- a/src/cli/browser-cli-actions-input/register.element.ts +++ b/src/cli/browser-cli-actions-input/register.element.ts @@ -1,7 +1,7 @@ import type { Command } from "commander"; +import type { BrowserParentOpts } from "../browser-cli-shared.js"; import { danger } from "../../globals.js"; import { defaultRuntime } from "../../runtime.js"; -import type { BrowserParentOpts } from "../browser-cli-shared.js"; import { callBrowserAct, requireRef, resolveBrowserActionContext } from "./shared.js"; export function registerBrowserElementCommands( diff --git a/src/cli/browser-cli-actions-input/register.files-downloads.ts b/src/cli/browser-cli-actions-input/register.files-downloads.ts index fd1182e1dbd..efbc40363d1 100644 --- a/src/cli/browser-cli-actions-input/register.files-downloads.ts +++ b/src/cli/browser-cli-actions-input/register.files-downloads.ts @@ -1,9 +1,9 @@ import type { Command } from "commander"; import { danger } from "../../globals.js"; import { defaultRuntime } from "../../runtime.js"; +import { shortenHomePath } from "../../utils.js"; import { callBrowserRequest, type BrowserParentOpts } from "../browser-cli-shared.js"; import { resolveBrowserActionContext } from "./shared.js"; -import { shortenHomePath } from "../../utils.js"; export function registerBrowserFilesAndDownloadsCommands( browser: Command, diff --git a/src/cli/browser-cli-actions-input/register.form-wait-eval.ts b/src/cli/browser-cli-actions-input/register.form-wait-eval.ts index f5e90c1321c..4a574e68d03 100644 --- a/src/cli/browser-cli-actions-input/register.form-wait-eval.ts +++ b/src/cli/browser-cli-actions-input/register.form-wait-eval.ts @@ -1,7 +1,7 @@ import type { Command } from "commander"; +import type { BrowserParentOpts } from "../browser-cli-shared.js"; import { danger } from "../../globals.js"; import { defaultRuntime } from "../../runtime.js"; -import type { BrowserParentOpts } from "../browser-cli-shared.js"; import { callBrowserAct, readFields, resolveBrowserActionContext } from "./shared.js"; export function registerBrowserFormWaitEvalCommands( diff --git a/src/cli/browser-cli-actions-observe.ts b/src/cli/browser-cli-actions-observe.ts index 63abd357d79..22c5fbd37da 100644 --- a/src/cli/browser-cli-actions-observe.ts +++ b/src/cli/browser-cli-actions-observe.ts @@ -1,9 +1,9 @@ import type { Command } from "commander"; import { danger } from "../globals.js"; import { defaultRuntime } from "../runtime.js"; +import { shortenHomePath } from "../utils.js"; import { callBrowserRequest, type BrowserParentOpts } from "./browser-cli-shared.js"; import { runCommandWithRuntime } from "./cli-utils.js"; -import { shortenHomePath } from "../utils.js"; function runBrowserObserve(action: () => Promise) { return runCommandWithRuntime(defaultRuntime, action, (err) => { diff --git a/src/cli/browser-cli-debug.ts b/src/cli/browser-cli-debug.ts index 25ebab5a48d..58ae72cdf38 100644 --- a/src/cli/browser-cli-debug.ts +++ b/src/cli/browser-cli-debug.ts @@ -1,10 +1,9 @@ import type { Command } from "commander"; - import { danger } from "../globals.js"; import { defaultRuntime } from "../runtime.js"; +import { shortenHomePath } from "../utils.js"; import { callBrowserRequest, type BrowserParentOpts } from "./browser-cli-shared.js"; import { runCommandWithRuntime } from "./cli-utils.js"; -import { shortenHomePath } from "../utils.js"; function runBrowserDebug(action: () => Promise) { return runCommandWithRuntime(defaultRuntime, action, (err) => { diff --git a/src/cli/browser-cli-extension.test.ts b/src/cli/browser-cli-extension.test.ts index 6b3df4b8d55..60750e6eeb7 100644 --- a/src/cli/browser-cli-extension.test.ts +++ b/src/cli/browser-cli-extension.test.ts @@ -1,7 +1,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it, vi } from "vitest"; const copyToClipboard = vi.fn(); diff --git a/src/cli/browser-cli-extension.ts b/src/cli/browser-cli-extension.ts index a8cc25f1635..a3b0d6a68cb 100644 --- a/src/cli/browser-cli-extension.ts +++ b/src/cli/browser-cli-extension.ts @@ -1,14 +1,12 @@ +import type { Command } from "commander"; import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; - -import type { Command } from "commander"; - +import { movePathToTrash } from "../browser/trash.js"; import { STATE_DIR } from "../config/paths.js"; import { danger, info } from "../globals.js"; import { copyToClipboard } from "../infra/clipboard.js"; import { defaultRuntime } from "../runtime.js"; -import { movePathToTrash } from "../browser/trash.js"; import { formatDocsLink } from "../terminal/links.js"; import { theme } from "../terminal/theme.js"; import { shortenHomePath } from "../utils.js"; diff --git a/src/cli/browser-cli-inspect.test.ts b/src/cli/browser-cli-inspect.test.ts index 8b398e510df..f4223a1d064 100644 --- a/src/cli/browser-cli-inspect.test.ts +++ b/src/cli/browser-cli-inspect.test.ts @@ -1,5 +1,5 @@ -import { afterEach, describe, expect, it, vi } from "vitest"; import { Command } from "commander"; +import { afterEach, describe, expect, it, vi } from "vitest"; const gatewayMocks = vi.hoisted(() => ({ callGatewayFromCli: vi.fn(async () => ({ diff --git a/src/cli/browser-cli-inspect.ts b/src/cli/browser-cli-inspect.ts index e36b5c79712..31846e21069 100644 --- a/src/cli/browser-cli-inspect.ts +++ b/src/cli/browser-cli-inspect.ts @@ -1,5 +1,4 @@ import type { Command } from "commander"; - import type { SnapshotResult } from "../browser/client.js"; import { loadConfig } from "../config/config.js"; import { danger } from "../globals.js"; diff --git a/src/cli/browser-cli-state.cookies-storage.ts b/src/cli/browser-cli-state.cookies-storage.ts index a9db259cfbb..47b4eec7524 100644 --- a/src/cli/browser-cli-state.cookies-storage.ts +++ b/src/cli/browser-cli-state.cookies-storage.ts @@ -1,5 +1,4 @@ import type { Command } from "commander"; - import { danger } from "../globals.js"; import { defaultRuntime } from "../runtime.js"; import { callBrowserRequest, type BrowserParentOpts } from "./browser-cli-shared.js"; diff --git a/src/cli/browser-cli-state.ts b/src/cli/browser-cli-state.ts index 81e21162ca5..b9cbccdc7ab 100644 --- a/src/cli/browser-cli-state.ts +++ b/src/cli/browser-cli-state.ts @@ -1,5 +1,4 @@ import type { Command } from "commander"; - import { danger } from "../globals.js"; import { defaultRuntime } from "../runtime.js"; import { parseBooleanValue } from "../utils/boolean.js"; diff --git a/src/cli/browser-cli.ts b/src/cli/browser-cli.ts index bf61942257e..91865a56428 100644 --- a/src/cli/browser-cli.ts +++ b/src/cli/browser-cli.ts @@ -1,11 +1,9 @@ import type { Command } from "commander"; - +import type { BrowserParentOpts } from "./browser-cli-shared.js"; import { danger } from "../globals.js"; import { defaultRuntime } from "../runtime.js"; import { formatDocsLink } from "../terminal/links.js"; import { theme } from "../terminal/theme.js"; -import { formatCliCommand } from "./command-format.js"; -import { formatHelpExamples } from "./help-format.js"; import { registerBrowserActionInputCommands } from "./browser-cli-actions-input.js"; import { registerBrowserActionObserveCommands } from "./browser-cli-actions-observe.js"; import { registerBrowserDebugCommands } from "./browser-cli-debug.js"; @@ -13,9 +11,10 @@ import { browserActionExamples, browserCoreExamples } from "./browser-cli-exampl import { registerBrowserExtensionCommands } from "./browser-cli-extension.js"; import { registerBrowserInspectCommands } from "./browser-cli-inspect.js"; import { registerBrowserManageCommands } from "./browser-cli-manage.js"; -import type { BrowserParentOpts } from "./browser-cli-shared.js"; import { registerBrowserStateCommands } from "./browser-cli-state.js"; +import { formatCliCommand } from "./command-format.js"; import { addGatewayClientOptions } from "./gateway-rpc.js"; +import { formatHelpExamples } from "./help-format.js"; export function registerBrowserCli(program: Command) { const browser = program diff --git a/src/cli/channel-options.ts b/src/cli/channel-options.ts index 97ba059887b..357133f1d65 100644 --- a/src/cli/channel-options.ts +++ b/src/cli/channel-options.ts @@ -1,6 +1,6 @@ import { listChannelPluginCatalogEntries } from "../channels/plugins/catalog.js"; -import { CHAT_CHANNEL_ORDER } from "../channels/registry.js"; import { listChannelPlugins } from "../channels/plugins/index.js"; +import { CHAT_CHANNEL_ORDER } from "../channels/registry.js"; import { isTruthyEnvValue } from "../infra/env.js"; import { ensurePluginRegistryLoaded } from "./plugin-registry.js"; diff --git a/src/cli/channels-cli.ts b/src/cli/channels-cli.ts index dd60016d437..e859bfc1259 100644 --- a/src/cli/channels-cli.ts +++ b/src/cli/channels-cli.ts @@ -1,5 +1,4 @@ import type { Command } from "commander"; -import { formatCliChannelOptions } from "./channel-options.js"; import { channelsAddCommand, channelsCapabilitiesCommand, @@ -14,6 +13,7 @@ import { defaultRuntime } from "../runtime.js"; import { formatDocsLink } from "../terminal/links.js"; import { theme } from "../terminal/theme.js"; import { runChannelLogin, runChannelLogout } from "./channel-auth.js"; +import { formatCliChannelOptions } from "./channel-options.js"; import { runCommandWithRuntime } from "./cli-utils.js"; import { hasExplicitOptions } from "./command-options.js"; diff --git a/src/cli/command-format.ts b/src/cli/command-format.ts index 8fd4e64ea41..cc9477b5aa6 100644 --- a/src/cli/command-format.ts +++ b/src/cli/command-format.ts @@ -1,5 +1,5 @@ -import { normalizeProfileName } from "./profile-utils.js"; import { replaceCliName, resolveCliName } from "./cli-name.js"; +import { normalizeProfileName } from "./profile-utils.js"; const CLI_PREFIX_RE = /^(?:pnpm|npm|bunx|npx)\s+openclaw\b|^openclaw\b/; const PROFILE_FLAG_RE = /(?:^|\s)--profile(?:\s|=|$)/; diff --git a/src/cli/config-cli.ts b/src/cli/config-cli.ts index a88ea70de05..7eabdef994b 100644 --- a/src/cli/config-cli.ts +++ b/src/cli/config-cli.ts @@ -1,13 +1,12 @@ -import JSON5 from "json5"; import type { Command } from "commander"; - +import JSON5 from "json5"; import { readConfigFileSnapshot, writeConfigFile } from "../config/config.js"; import { danger, info } from "../globals.js"; import { defaultRuntime } from "../runtime.js"; import { formatDocsLink } from "../terminal/links.js"; -import { formatCliCommand } from "./command-format.js"; import { theme } from "../terminal/theme.js"; import { shortenHomePath } from "../utils.js"; +import { formatCliCommand } from "./command-format.js"; type PathSegment = string; diff --git a/src/cli/cron-cli/register.cron-add.ts b/src/cli/cron-cli/register.cron-add.ts index 588669655f1..0254a8188c6 100644 --- a/src/cli/cron-cli/register.cron-add.ts +++ b/src/cli/cron-cli/register.cron-add.ts @@ -1,9 +1,9 @@ import type { Command } from "commander"; import type { CronJob } from "../../cron/types.js"; -import { danger } from "../../globals.js"; -import { defaultRuntime } from "../../runtime.js"; -import { sanitizeAgentId } from "../../routing/session-key.js"; import type { GatewayRpcOpts } from "../gateway-rpc.js"; +import { danger } from "../../globals.js"; +import { sanitizeAgentId } from "../../routing/session-key.js"; +import { defaultRuntime } from "../../runtime.js"; import { addGatewayClientOptions, callGatewayFromCli } from "../gateway-rpc.js"; import { parsePositiveIntOrUndefined } from "../program/helpers.js"; import { diff --git a/src/cli/cron-cli/register.cron-edit.ts b/src/cli/cron-cli/register.cron-edit.ts index b8dbe02f6b4..340bf64bad1 100644 --- a/src/cli/cron-cli/register.cron-edit.ts +++ b/src/cli/cron-cli/register.cron-edit.ts @@ -1,7 +1,7 @@ import type { Command } from "commander"; import { danger } from "../../globals.js"; -import { defaultRuntime } from "../../runtime.js"; import { sanitizeAgentId } from "../../routing/session-key.js"; +import { defaultRuntime } from "../../runtime.js"; import { addGatewayClientOptions, callGatewayFromCli } from "../gateway-rpc.js"; import { getCronChannelOptions, diff --git a/src/cli/cron-cli/shared.ts b/src/cli/cron-cli/shared.ts index 9481e510020..884610dcf23 100644 --- a/src/cli/cron-cli/shared.ts +++ b/src/cli/cron-cli/shared.ts @@ -1,9 +1,9 @@ +import type { CronJob, CronSchedule } from "../../cron/types.js"; +import type { GatewayRpcOpts } from "../gateway-rpc.js"; import { listChannelPlugins } from "../../channels/plugins/index.js"; import { parseAbsoluteTimeMs } from "../../cron/parse.js"; -import type { CronJob, CronSchedule } from "../../cron/types.js"; import { defaultRuntime } from "../../runtime.js"; import { colorize, isRich, theme } from "../../terminal/theme.js"; -import type { GatewayRpcOpts } from "../gateway-rpc.js"; import { callGatewayFromCli } from "../gateway-rpc.js"; export const getCronChannelOptions = () => diff --git a/src/cli/daemon-cli/install.ts b/src/cli/daemon-cli/install.ts index 54c9c5a394c..1838d09a20d 100644 --- a/src/cli/daemon-cli/install.ts +++ b/src/cli/daemon-cli/install.ts @@ -1,8 +1,9 @@ +import type { DaemonInstallOptions } from "./types.js"; +import { buildGatewayInstallPlan } from "../../commands/daemon-install-helpers.js"; import { DEFAULT_GATEWAY_DAEMON_RUNTIME, isGatewayDaemonRuntime, } from "../../commands/daemon-runtime.js"; -import { buildGatewayInstallPlan } from "../../commands/daemon-install-helpers.js"; import { loadConfig, resolveGatewayPort } from "../../config/config.js"; import { resolveIsNixMode } from "../../config/paths.js"; import { resolveGatewayService } from "../../daemon/service.js"; @@ -10,7 +11,6 @@ import { defaultRuntime } from "../../runtime.js"; import { formatCliCommand } from "../command-format.js"; import { buildDaemonServiceSnapshot, createNullWriter, emitDaemonActionJson } from "./response.js"; import { parsePort } from "./shared.js"; -import type { DaemonInstallOptions } from "./types.js"; export async function runDaemonInstall(opts: DaemonInstallOptions) { const json = Boolean(opts.json); diff --git a/src/cli/daemon-cli/lifecycle.ts b/src/cli/daemon-cli/lifecycle.ts index 55458b6f239..ef3574b53a0 100644 --- a/src/cli/daemon-cli/lifecycle.ts +++ b/src/cli/daemon-cli/lifecycle.ts @@ -1,12 +1,12 @@ +import type { DaemonLifecycleOptions } from "./types.js"; import { resolveIsNixMode } from "../../config/paths.js"; import { resolveGatewayService } from "../../daemon/service.js"; -import { isSystemdUserServiceAvailable } from "../../daemon/systemd.js"; import { renderSystemdUnavailableHints } from "../../daemon/systemd-hints.js"; +import { isSystemdUserServiceAvailable } from "../../daemon/systemd.js"; import { isWSL } from "../../infra/wsl.js"; import { defaultRuntime } from "../../runtime.js"; import { buildDaemonServiceSnapshot, createNullWriter, emitDaemonActionJson } from "./response.js"; import { renderGatewayServiceStartHints } from "./shared.js"; -import type { DaemonLifecycleOptions } from "./types.js"; export async function runDaemonUninstall(opts: DaemonLifecycleOptions = {}) { const json = Boolean(opts.json); diff --git a/src/cli/daemon-cli/response.ts b/src/cli/daemon-cli/response.ts index 98de30c0955..cab26213d67 100644 --- a/src/cli/daemon-cli/response.ts +++ b/src/cli/daemon-cli/response.ts @@ -1,5 +1,4 @@ import { Writable } from "node:stream"; - import type { GatewayService } from "../../daemon/service.js"; import { defaultRuntime } from "../../runtime.js"; diff --git a/src/cli/daemon-cli/status.gather.ts b/src/cli/daemon-cli/status.gather.ts index afa39143ec3..f4b323ad08c 100644 --- a/src/cli/daemon-cli/status.gather.ts +++ b/src/cli/daemon-cli/status.gather.ts @@ -1,16 +1,17 @@ +import type { GatewayBindMode, GatewayControlUiConfig } from "../../config/types.js"; +import type { FindExtraGatewayServicesOptions } from "../../daemon/inspect.js"; +import type { ServiceConfigAudit } from "../../daemon/service-audit.js"; +import type { GatewayRpcOpts } from "./types.js"; import { createConfigIO, resolveConfigPath, resolveGatewayPort, resolveStateDir, } from "../../config/config.js"; -import type { GatewayBindMode, GatewayControlUiConfig } from "../../config/types.js"; import { readLastGatewayErrorLine } from "../../daemon/diagnostics.js"; -import type { FindExtraGatewayServicesOptions } from "../../daemon/inspect.js"; import { findExtraGatewayServices } from "../../daemon/inspect.js"; -import { resolveGatewayService } from "../../daemon/service.js"; -import type { ServiceConfigAudit } from "../../daemon/service-audit.js"; import { auditGatewayServiceConfig } from "../../daemon/service-audit.js"; +import { resolveGatewayService } from "../../daemon/service.js"; import { resolveGatewayBindHost } from "../../gateway/net.js"; import { formatPortDiagnostics, @@ -21,7 +22,6 @@ import { import { pickPrimaryTailnetIPv4 } from "../../infra/tailnet.js"; import { probeGatewayStatus } from "./probe.js"; import { normalizeListenerAddress, parsePortFromArgs, pickProbeHostForBind } from "./shared.js"; -import type { GatewayRpcOpts } from "./types.js"; type ConfigSummary = { path: string; diff --git a/src/cli/daemon-cli/status.ts b/src/cli/daemon-cli/status.ts index 2af5a1977ec..aa24d2ee619 100644 --- a/src/cli/daemon-cli/status.ts +++ b/src/cli/daemon-cli/status.ts @@ -1,8 +1,8 @@ +import type { DaemonStatusOptions } from "./types.js"; import { defaultRuntime } from "../../runtime.js"; import { colorize, isRich, theme } from "../../terminal/theme.js"; import { gatherDaemonStatus } from "./status.gather.js"; import { printDaemonStatus } from "./status.print.js"; -import type { DaemonStatusOptions } from "./types.js"; export async function runDaemonStatus(opts: DaemonStatusOptions) { try { diff --git a/src/cli/deps.ts b/src/cli/deps.ts index f14013a0f6a..1f0e8e587f0 100644 --- a/src/cli/deps.ts +++ b/src/cli/deps.ts @@ -1,7 +1,7 @@ +import type { OutboundSendDeps } from "../infra/outbound/deliver.js"; import { logWebSelfId, sendMessageWhatsApp } from "../channels/web/index.js"; import { sendMessageDiscord } from "../discord/send.js"; import { sendMessageIMessage } from "../imessage/send.js"; -import type { OutboundSendDeps } from "../infra/outbound/deliver.js"; import { sendMessageSignal } from "../signal/send.js"; import { sendMessageSlack } from "../slack/send.js"; import { sendMessageTelegram } from "../telegram/send.js"; diff --git a/src/cli/devices-cli.ts b/src/cli/devices-cli.ts index 3633774a786..8e0b8bd3d55 100644 --- a/src/cli/devices-cli.ts +++ b/src/cli/devices-cli.ts @@ -1,10 +1,9 @@ import type { Command } from "commander"; - import { callGateway } from "../gateway/call.js"; -import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; import { defaultRuntime } from "../runtime.js"; import { renderTable } from "../terminal/table.js"; import { theme } from "../terminal/theme.js"; +import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; import { withProgress } from "./progress.js"; type DevicesRpcOpts = { diff --git a/src/cli/directory-cli.ts b/src/cli/directory-cli.ts index 5bb9bad9ce8..54ef51b015b 100644 --- a/src/cli/directory-cli.ts +++ b/src/cli/directory-cli.ts @@ -1,5 +1,4 @@ import type { Command } from "commander"; - import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js"; import { getChannelPlugin } from "../channels/plugins/index.js"; import { loadConfig } from "../config/config.js"; @@ -7,8 +6,8 @@ import { danger } from "../globals.js"; import { resolveMessageChannelSelection } from "../infra/outbound/channel-selection.js"; import { defaultRuntime } from "../runtime.js"; import { formatDocsLink } from "../terminal/links.js"; -import { theme } from "../terminal/theme.js"; import { renderTable } from "../terminal/table.js"; +import { theme } from "../terminal/theme.js"; function parseLimit(value: unknown): number | null { if (typeof value === "number" && Number.isFinite(value)) { diff --git a/src/cli/dns-cli.ts b/src/cli/dns-cli.ts index 8de558cdfaf..9dfc1b0d16a 100644 --- a/src/cli/dns-cli.ts +++ b/src/cli/dns-cli.ts @@ -1,9 +1,7 @@ +import type { Command } from "commander"; import { spawnSync } from "node:child_process"; import fs from "node:fs"; import path from "node:path"; - -import type { Command } from "commander"; - import { loadConfig } from "../config/config.js"; import { pickPrimaryTailnetIPv4, pickPrimaryTailnetIPv6 } from "../infra/tailnet.js"; import { getWideAreaZonePath, resolveWideAreaDiscoveryDomain } from "../infra/widearea-dns.js"; diff --git a/src/cli/docs-cli.ts b/src/cli/docs-cli.ts index d2c90d64b9b..dc100908454 100644 --- a/src/cli/docs-cli.ts +++ b/src/cli/docs-cli.ts @@ -1,5 +1,4 @@ import type { Command } from "commander"; - import { docsSearchCommand } from "../commands/docs.js"; import { defaultRuntime } from "../runtime.js"; import { formatDocsLink } from "../terminal/links.js"; diff --git a/src/cli/exec-approvals-cli.ts b/src/cli/exec-approvals-cli.ts index 725c922d92d..924778e57e6 100644 --- a/src/cli/exec-approvals-cli.ts +++ b/src/cli/exec-approvals-cli.ts @@ -1,7 +1,7 @@ -import fs from "node:fs/promises"; -import JSON5 from "json5"; import type { Command } from "commander"; - +import JSON5 from "json5"; +import fs from "node:fs/promises"; +import type { NodesRpcOpts } from "./nodes-cli/types.js"; import { readExecApprovalsSnapshot, saveExecApprovals, @@ -10,12 +10,11 @@ import { } from "../infra/exec-approvals.js"; import { defaultRuntime } from "../runtime.js"; import { formatDocsLink } from "../terminal/links.js"; -import { isRich, theme } from "../terminal/theme.js"; import { renderTable } from "../terminal/table.js"; -import { callGatewayFromCli } from "./gateway-rpc.js"; +import { isRich, theme } from "../terminal/theme.js"; import { describeUnknownError } from "./gateway-cli/shared.js"; +import { callGatewayFromCli } from "./gateway-rpc.js"; import { nodesCallOpts, resolveNodeId } from "./nodes-cli/rpc.js"; -import type { NodesRpcOpts } from "./nodes-cli/types.js"; type ExecApprovalsSnapshot = { path: string; diff --git a/src/cli/gateway-cli/dev.ts b/src/cli/gateway-cli/dev.ts index bd574c8d0a1..9ab872a6c38 100644 --- a/src/cli/gateway-cli/dev.ts +++ b/src/cli/gateway-cli/dev.ts @@ -1,9 +1,8 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - -import { resolveDefaultAgentWorkspaceDir } from "../../agents/workspace.js"; import { resolveWorkspaceTemplateDir } from "../../agents/workspace-templates.js"; +import { resolveDefaultAgentWorkspaceDir } from "../../agents/workspace.js"; import { handleReset } from "../../commands/onboard-helpers.js"; import { createConfigIO, writeConfigFile } from "../../config/config.js"; import { defaultRuntime } from "../../runtime.js"; diff --git a/src/cli/gateway-cli/register.ts b/src/cli/gateway-cli/register.ts index 971334e2c41..3ec90bb5262 100644 --- a/src/cli/gateway-cli/register.ts +++ b/src/cli/gateway-cli/register.ts @@ -1,15 +1,15 @@ import type { Command } from "commander"; +import type { CostUsageSummary } from "../../infra/session-cost-usage.js"; +import type { GatewayDiscoverOpts } from "./discover.js"; import { gatewayStatusCommand } from "../../commands/gateway-status.js"; import { formatHealthChannelLines, type HealthSummary } from "../../commands/health.js"; import { loadConfig } from "../../config/config.js"; import { discoverGatewayBeacons } from "../../infra/bonjour-discovery.js"; -import type { CostUsageSummary } from "../../infra/session-cost-usage.js"; import { resolveWideAreaDiscoveryDomain } from "../../infra/widearea-dns.js"; import { defaultRuntime } from "../../runtime.js"; import { formatDocsLink } from "../../terminal/links.js"; import { colorize, isRich, theme } from "../../terminal/theme.js"; import { formatTokenCount, formatUsd } from "../../utils/usage-format.js"; -import { withProgress } from "../progress.js"; import { runCommandWithRuntime } from "../cli-utils.js"; import { runDaemonInstall, @@ -19,8 +19,8 @@ import { runDaemonStop, runDaemonUninstall, } from "../daemon-cli.js"; +import { withProgress } from "../progress.js"; import { callGatewayCli, gatewayCallOpts } from "./call.js"; -import type { GatewayDiscoverOpts } from "./discover.js"; import { dedupeBeacons, parseDiscoverTimeoutMs, diff --git a/src/cli/gateway-cli/run-loop.ts b/src/cli/gateway-cli/run-loop.ts index 358d9a3cb19..9cdcf18652a 100644 --- a/src/cli/gateway-cli/run-loop.ts +++ b/src/cli/gateway-cli/run-loop.ts @@ -1,11 +1,11 @@ import type { startGatewayServer } from "../../gateway/server.js"; +import type { defaultRuntime } from "../../runtime.js"; import { acquireGatewayLock } from "../../infra/gateway-lock.js"; import { consumeGatewaySigusr1RestartAuthorization, isGatewaySigusr1RestartExternallyAllowed, } from "../../infra/restart.js"; import { createSubsystemLogger } from "../../logging/subsystem.js"; -import type { defaultRuntime } from "../../runtime.js"; const gatewayLog = createSubsystemLogger("gateway"); diff --git a/src/cli/gateway-cli/run.ts b/src/cli/gateway-cli/run.ts index d5e1f4eaaba..e3a30bb52a2 100644 --- a/src/cli/gateway-cli/run.ts +++ b/src/cli/gateway-cli/run.ts @@ -1,7 +1,7 @@ -import fs from "node:fs"; - import type { Command } from "commander"; +import fs from "node:fs"; import type { GatewayAuthMode } from "../../config/config.js"; +import type { GatewayWsLogStyle } from "../../gateway/ws-logging.js"; import { CONFIG_PATH, loadConfig, @@ -10,7 +10,6 @@ import { } from "../../config/config.js"; import { resolveGatewayAuth } from "../../gateway/auth.js"; import { startGatewayServer } from "../../gateway/server.js"; -import type { GatewayWsLogStyle } from "../../gateway/ws-logging.js"; import { setGatewayWsLogStyle } from "../../gateway/ws-logging.js"; import { setVerbose } from "../../globals.js"; import { GatewayLockError } from "../../infra/gateway-lock.js"; diff --git a/src/cli/hooks-cli.ts b/src/cli/hooks-cli.ts index aa5c25f7f42..e75dff0ea9c 100644 --- a/src/cli/hooks-cli.ts +++ b/src/cli/hooks-cli.ts @@ -1,31 +1,31 @@ +import type { Command } from "commander"; import fs from "node:fs"; import fsp from "node:fs/promises"; import path from "node:path"; -import type { Command } from "commander"; -import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; import type { OpenClawConfig } from "../config/config.js"; -import { resolveArchiveKind } from "../infra/archive.js"; +import type { HookEntry } from "../hooks/types.js"; +import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; +import { loadConfig, writeConfigFile } from "../config/io.js"; import { buildWorkspaceHookStatus, type HookStatusEntry, type HookStatusReport, } from "../hooks/hooks-status.js"; -import type { HookEntry } from "../hooks/types.js"; -import { loadWorkspaceHookEntries } from "../hooks/workspace.js"; -import { loadConfig, writeConfigFile } from "../config/io.js"; import { installHooksFromNpmSpec, installHooksFromPath, resolveHookInstallDir, } from "../hooks/install.js"; import { recordHookInstall } from "../hooks/installs.js"; +import { loadWorkspaceHookEntries } from "../hooks/workspace.js"; +import { resolveArchiveKind } from "../infra/archive.js"; import { buildPluginStatusReport } from "../plugins/status.js"; import { defaultRuntime } from "../runtime.js"; import { formatDocsLink } from "../terminal/links.js"; import { renderTable } from "../terminal/table.js"; import { theme } from "../terminal/theme.js"; -import { formatCliCommand } from "./command-format.js"; import { resolveUserPath, shortenHomePath } from "../utils.js"; +import { formatCliCommand } from "./command-format.js"; export type HooksListOptions = { json?: boolean; diff --git a/src/cli/logs-cli.ts b/src/cli/logs-cli.ts index b29e1b822a4..f6e53bd7360 100644 --- a/src/cli/logs-cli.ts +++ b/src/cli/logs-cli.ts @@ -1,5 +1,5 @@ -import { setTimeout as delay } from "node:timers/promises"; import type { Command } from "commander"; +import { setTimeout as delay } from "node:timers/promises"; import { buildGatewayConnectionDetails } from "../gateway/call.js"; import { parseLogLine } from "../logging/parse-log-line.js"; import { formatDocsLink } from "../terminal/links.js"; diff --git a/src/cli/memory-cli.ts b/src/cli/memory-cli.ts index 38b45e07945..58557eec65c 100644 --- a/src/cli/memory-cli.ts +++ b/src/cli/memory-cli.ts @@ -1,23 +1,21 @@ +import type { Command } from "commander"; import fsSync from "node:fs"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - -import type { Command } from "commander"; - import { resolveDefaultAgentId } from "../agents/agent-scope.js"; import { loadConfig } from "../config/config.js"; +import { resolveStateDir } from "../config/paths.js"; import { resolveSessionTranscriptsDirForAgent } from "../config/sessions/paths.js"; import { setVerbose } from "../globals.js"; -import { withProgress, withProgressTotals } from "./progress.js"; -import { formatErrorMessage, withManager } from "./cli-utils.js"; import { getMemorySearchManager, type MemorySearchManagerResult } from "../memory/index.js"; import { listMemoryFiles, normalizeExtraMemoryPaths } from "../memory/internal.js"; import { defaultRuntime } from "../runtime.js"; import { formatDocsLink } from "../terminal/links.js"; import { colorize, isRich, theme } from "../terminal/theme.js"; -import { resolveStateDir } from "../config/paths.js"; import { shortenHomeInString, shortenHomePath } from "../utils.js"; +import { formatErrorMessage, withManager } from "./cli-utils.js"; +import { withProgress, withProgressTotals } from "./progress.js"; type MemoryCommandOptions = { agent?: string; diff --git a/src/cli/models-cli.ts b/src/cli/models-cli.ts index 653acc127d5..d3be2d6c131 100644 --- a/src/cli/models-cli.ts +++ b/src/cli/models-cli.ts @@ -1,5 +1,4 @@ import type { Command } from "commander"; - import { githubCopilotLoginCommand, modelsAliasesAddCommand, diff --git a/src/cli/node-cli/daemon.ts b/src/cli/node-cli/daemon.ts index db5bf394f9c..271ea318f87 100644 --- a/src/cli/node-cli/daemon.ts +++ b/src/cli/node-cli/daemon.ts @@ -1,8 +1,10 @@ +import type { GatewayServiceRuntime } from "../../daemon/service-runtime.js"; import { buildNodeInstallPlan } from "../../commands/node-daemon-install-helpers.js"; import { DEFAULT_NODE_DAEMON_RUNTIME, isNodeDaemonRuntime, } from "../../commands/node-daemon-runtime.js"; +import { resolveIsNixMode } from "../../config/paths.js"; import { resolveNodeLaunchAgentLabel, resolveNodeSystemdServiceName, @@ -10,10 +12,8 @@ import { } from "../../daemon/constants.js"; import { resolveGatewayLogPaths } from "../../daemon/launchd.js"; import { resolveNodeService } from "../../daemon/node-service.js"; -import type { GatewayServiceRuntime } from "../../daemon/service-runtime.js"; -import { isSystemdUserServiceAvailable } from "../../daemon/systemd.js"; import { renderSystemdUnavailableHints } from "../../daemon/systemd-hints.js"; -import { resolveIsNixMode } from "../../config/paths.js"; +import { isSystemdUserServiceAvailable } from "../../daemon/systemd.js"; import { isWSL } from "../../infra/wsl.js"; import { loadNodeHostConfig } from "../../node-host/config.js"; import { defaultRuntime } from "../../runtime.js"; diff --git a/src/cli/node-cli/register.ts b/src/cli/node-cli/register.ts index 53030c4f3e4..1ecdaa503ce 100644 --- a/src/cli/node-cli/register.ts +++ b/src/cli/node-cli/register.ts @@ -1,8 +1,9 @@ import type { Command } from "commander"; -import { formatDocsLink } from "../../terminal/links.js"; -import { theme } from "../../terminal/theme.js"; import { loadNodeHostConfig } from "../../node-host/config.js"; import { runNodeHost } from "../../node-host/runner.js"; +import { formatDocsLink } from "../../terminal/links.js"; +import { theme } from "../../terminal/theme.js"; +import { parsePort } from "../daemon-cli/shared.js"; import { runNodeDaemonInstall, runNodeDaemonRestart, @@ -10,7 +11,6 @@ import { runNodeDaemonStop, runNodeDaemonUninstall, } from "./daemon.js"; -import { parsePort } from "../daemon-cli/shared.js"; function parsePortWithFallback(value: unknown, fallback: number): number { const parsed = parsePort(value); diff --git a/src/cli/nodes-camera.ts b/src/cli/nodes-camera.ts index f5bf2f2ea80..7ad14aa3904 100644 --- a/src/cli/nodes-camera.ts +++ b/src/cli/nodes-camera.ts @@ -2,7 +2,6 @@ import { randomUUID } from "node:crypto"; import * as fs from "node:fs/promises"; import * as os from "node:os"; import * as path from "node:path"; - import { resolveCliName } from "./cli-name.js"; export type CameraFacing = "front" | "back"; diff --git a/src/cli/nodes-canvas.test.ts b/src/cli/nodes-canvas.test.ts index dab98b3819c..a3b7a394582 100644 --- a/src/cli/nodes-canvas.test.ts +++ b/src/cli/nodes-canvas.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { parseCanvasSnapshotPayload } from "./nodes-canvas.js"; describe("nodes canvas helpers", () => { diff --git a/src/cli/nodes-canvas.ts b/src/cli/nodes-canvas.ts index 577c20560c0..eb7a90236c8 100644 --- a/src/cli/nodes-canvas.ts +++ b/src/cli/nodes-canvas.ts @@ -1,7 +1,6 @@ import { randomUUID } from "node:crypto"; import * as os from "node:os"; import * as path from "node:path"; - import { resolveCliName } from "./cli-name.js"; export type CanvasSnapshotPayload = { diff --git a/src/cli/nodes-cli/register.camera.ts b/src/cli/nodes-cli/register.camera.ts index 58ca330eb7d..d1c711f4899 100644 --- a/src/cli/nodes-cli/register.camera.ts +++ b/src/cli/nodes-cli/register.camera.ts @@ -1,6 +1,9 @@ import type { Command } from "commander"; +import type { NodesRpcOpts } from "./types.js"; import { randomIdempotencyKey } from "../../gateway/call.js"; import { defaultRuntime } from "../../runtime.js"; +import { renderTable } from "../../terminal/table.js"; +import { shortenHomePath } from "../../utils.js"; import { type CameraFacing, cameraTempPath, @@ -11,9 +14,6 @@ import { import { parseDurationMs } from "../parse-duration.js"; import { getNodesTheme, runNodesCommand } from "./cli-utils.js"; import { callGatewayCli, nodesCallOpts, resolveNodeId } from "./rpc.js"; -import type { NodesRpcOpts } from "./types.js"; -import { renderTable } from "../../terminal/table.js"; -import { shortenHomePath } from "../../utils.js"; const parseFacing = (value: string): CameraFacing => { const v = String(value ?? "") diff --git a/src/cli/nodes-cli/register.canvas.ts b/src/cli/nodes-cli/register.canvas.ts index 5a328c23e52..5883953eb47 100644 --- a/src/cli/nodes-cli/register.canvas.ts +++ b/src/cli/nodes-cli/register.canvas.ts @@ -1,15 +1,15 @@ -import fs from "node:fs/promises"; import type { Command } from "commander"; +import fs from "node:fs/promises"; +import type { NodesRpcOpts } from "./types.js"; import { randomIdempotencyKey } from "../../gateway/call.js"; import { defaultRuntime } from "../../runtime.js"; +import { shortenHomePath } from "../../utils.js"; import { writeBase64ToFile } from "../nodes-camera.js"; import { canvasSnapshotTempPath, parseCanvasSnapshotPayload } from "../nodes-canvas.js"; import { parseTimeoutMs } from "../nodes-run.js"; import { buildA2UITextJsonl, validateA2UIJsonl } from "./a2ui-jsonl.js"; import { getNodesTheme, runNodesCommand } from "./cli-utils.js"; import { callGatewayCli, nodesCallOpts, resolveNodeId } from "./rpc.js"; -import type { NodesRpcOpts } from "./types.js"; -import { shortenHomePath } from "../../utils.js"; async function invokeCanvas(opts: NodesRpcOpts, command: string, params?: Record) { const nodeId = await resolveNodeId(opts, String(opts.node ?? "")); diff --git a/src/cli/nodes-cli/register.invoke.ts b/src/cli/nodes-cli/register.invoke.ts index 2f75bff35c8..022907fa85a 100644 --- a/src/cli/nodes-cli/register.invoke.ts +++ b/src/cli/nodes-cli/register.invoke.ts @@ -1,14 +1,9 @@ -import path from "node:path"; import type { Command } from "commander"; -import { randomIdempotencyKey } from "../../gateway/call.js"; -import { defaultRuntime } from "../../runtime.js"; -import { parseEnvPairs, parseTimeoutMs } from "../nodes-run.js"; -import { getNodesTheme, runNodesCommand } from "./cli-utils.js"; -import { parseNodeList } from "./format.js"; -import { callGatewayCli, nodesCallOpts, resolveNodeId, unauthorizedHintForMessage } from "./rpc.js"; +import path from "node:path"; import type { NodesRpcOpts } from "./types.js"; -import { loadConfig } from "../../config/config.js"; import { resolveAgentConfig, resolveDefaultAgentId } from "../../agents/agent-scope.js"; +import { loadConfig } from "../../config/config.js"; +import { randomIdempotencyKey } from "../../gateway/call.js"; import { type ExecApprovalsFile, type ExecAsk, @@ -18,6 +13,11 @@ import { resolveExecApprovalsFromFile, } from "../../infra/exec-approvals.js"; import { buildNodeShellCommand } from "../../infra/node-shell.js"; +import { defaultRuntime } from "../../runtime.js"; +import { parseEnvPairs, parseTimeoutMs } from "../nodes-run.js"; +import { getNodesTheme, runNodesCommand } from "./cli-utils.js"; +import { parseNodeList } from "./format.js"; +import { callGatewayCli, nodesCallOpts, resolveNodeId, unauthorizedHintForMessage } from "./rpc.js"; type NodesRunOpts = NodesRpcOpts & { node?: string; diff --git a/src/cli/nodes-cli/register.location.ts b/src/cli/nodes-cli/register.location.ts index c4dd02356e8..89028feaec3 100644 --- a/src/cli/nodes-cli/register.location.ts +++ b/src/cli/nodes-cli/register.location.ts @@ -1,9 +1,9 @@ import type { Command } from "commander"; +import type { NodesRpcOpts } from "./types.js"; import { randomIdempotencyKey } from "../../gateway/call.js"; import { defaultRuntime } from "../../runtime.js"; import { runNodesCommand } from "./cli-utils.js"; import { callGatewayCli, nodesCallOpts, resolveNodeId } from "./rpc.js"; -import type { NodesRpcOpts } from "./types.js"; export function registerNodesLocationCommands(nodes: Command) { const location = nodes.command("location").description("Fetch location from a paired node"); diff --git a/src/cli/nodes-cli/register.notify.ts b/src/cli/nodes-cli/register.notify.ts index 25952a2d8a5..9843eb76950 100644 --- a/src/cli/nodes-cli/register.notify.ts +++ b/src/cli/nodes-cli/register.notify.ts @@ -1,9 +1,9 @@ import type { Command } from "commander"; +import type { NodesRpcOpts } from "./types.js"; import { randomIdempotencyKey } from "../../gateway/call.js"; import { defaultRuntime } from "../../runtime.js"; import { getNodesTheme, runNodesCommand } from "./cli-utils.js"; import { callGatewayCli, nodesCallOpts, resolveNodeId } from "./rpc.js"; -import type { NodesRpcOpts } from "./types.js"; export function registerNodesNotifyCommand(nodes: Command) { nodesCallOpts( diff --git a/src/cli/nodes-cli/register.pairing.ts b/src/cli/nodes-cli/register.pairing.ts index 1746ef944df..65b361cffc2 100644 --- a/src/cli/nodes-cli/register.pairing.ts +++ b/src/cli/nodes-cli/register.pairing.ts @@ -1,10 +1,10 @@ import type { Command } from "commander"; -import { defaultRuntime } from "../../runtime.js"; -import { formatAge, parsePairingList } from "./format.js"; -import { getNodesTheme, runNodesCommand } from "./cli-utils.js"; -import { callGatewayCli, nodesCallOpts, resolveNodeId } from "./rpc.js"; import type { NodesRpcOpts } from "./types.js"; +import { defaultRuntime } from "../../runtime.js"; import { renderTable } from "../../terminal/table.js"; +import { getNodesTheme, runNodesCommand } from "./cli-utils.js"; +import { formatAge, parsePairingList } from "./format.js"; +import { callGatewayCli, nodesCallOpts, resolveNodeId } from "./rpc.js"; export function registerNodesPairingCommands(nodes: Command) { nodesCallOpts( diff --git a/src/cli/nodes-cli/register.screen.ts b/src/cli/nodes-cli/register.screen.ts index 7dca7dd1c69..60ff4ec9716 100644 --- a/src/cli/nodes-cli/register.screen.ts +++ b/src/cli/nodes-cli/register.screen.ts @@ -1,6 +1,8 @@ import type { Command } from "commander"; +import type { NodesRpcOpts } from "./types.js"; import { randomIdempotencyKey } from "../../gateway/call.js"; import { defaultRuntime } from "../../runtime.js"; +import { shortenHomePath } from "../../utils.js"; import { parseScreenRecordPayload, screenRecordTempPath, @@ -9,8 +11,6 @@ import { import { parseDurationMs } from "../parse-duration.js"; import { runNodesCommand } from "./cli-utils.js"; import { callGatewayCli, nodesCallOpts, resolveNodeId } from "./rpc.js"; -import type { NodesRpcOpts } from "./types.js"; -import { shortenHomePath } from "../../utils.js"; export function registerNodesScreenCommands(nodes: Command) { const screen = nodes diff --git a/src/cli/nodes-cli/register.status.ts b/src/cli/nodes-cli/register.status.ts index 241dc94f011..e8cdd52720e 100644 --- a/src/cli/nodes-cli/register.status.ts +++ b/src/cli/nodes-cli/register.status.ts @@ -1,12 +1,12 @@ import type { Command } from "commander"; -import { defaultRuntime } from "../../runtime.js"; -import { formatAge, formatPermissions, parseNodeList, parsePairingList } from "./format.js"; -import { getNodesTheme, runNodesCommand } from "./cli-utils.js"; -import { callGatewayCli, nodesCallOpts, resolveNodeId } from "./rpc.js"; import type { NodesRpcOpts } from "./types.js"; +import { defaultRuntime } from "../../runtime.js"; import { renderTable } from "../../terminal/table.js"; -import { parseDurationMs } from "../parse-duration.js"; import { shortenHomeInString } from "../../utils.js"; +import { parseDurationMs } from "../parse-duration.js"; +import { getNodesTheme, runNodesCommand } from "./cli-utils.js"; +import { formatAge, formatPermissions, parseNodeList, parsePairingList } from "./format.js"; +import { callGatewayCli, nodesCallOpts, resolveNodeId } from "./rpc.js"; function formatVersionLabel(raw: string) { const trimmed = raw.trim(); diff --git a/src/cli/nodes-cli/rpc.ts b/src/cli/nodes-cli/rpc.ts index 742e5811251..e5593fd6799 100644 --- a/src/cli/nodes-cli/rpc.ts +++ b/src/cli/nodes-cli/rpc.ts @@ -1,9 +1,9 @@ import type { Command } from "commander"; +import type { NodeListNode, NodesRpcOpts } from "./types.js"; import { callGateway } from "../../gateway/call.js"; import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../utils/message-channel.js"; import { withProgress } from "../progress.js"; import { parseNodeList, parsePairingList } from "./format.js"; -import type { NodeListNode, NodesRpcOpts } from "./types.js"; export const nodesCallOpts = (cmd: Command, defaults?: { timeoutMs?: number }) => cmd diff --git a/src/cli/nodes-screen.test.ts b/src/cli/nodes-screen.test.ts index 6ca516114fb..5aa6dfe8361 100644 --- a/src/cli/nodes-screen.test.ts +++ b/src/cli/nodes-screen.test.ts @@ -1,6 +1,5 @@ import path from "node:path"; import { describe, expect, it } from "vitest"; - import { parseScreenRecordPayload, screenRecordTempPath } from "./nodes-screen.js"; describe("nodes screen helpers", () => { diff --git a/src/cli/nodes-screen.ts b/src/cli/nodes-screen.ts index 0ca537fec7b..5d167e2f1e5 100644 --- a/src/cli/nodes-screen.ts +++ b/src/cli/nodes-screen.ts @@ -1,7 +1,6 @@ import { randomUUID } from "node:crypto"; import * as os from "node:os"; import * as path from "node:path"; - import { writeBase64ToFile } from "./nodes-camera.js"; export type ScreenRecordPayload = { diff --git a/src/cli/pairing-cli.ts b/src/cli/pairing-cli.ts index b0362dc1b53..e576d1b5723 100644 --- a/src/cli/pairing-cli.ts +++ b/src/cli/pairing-cli.ts @@ -1,6 +1,6 @@ import type { Command } from "commander"; -import { listPairingChannels, notifyPairingApproved } from "../channels/plugins/pairing.js"; import { normalizeChannelId } from "../channels/plugins/index.js"; +import { listPairingChannels, notifyPairingApproved } from "../channels/plugins/pairing.js"; import { loadConfig } from "../config/config.js"; import { resolvePairingIdLabel } from "../pairing/pairing-labels.js"; import { diff --git a/src/cli/parse-duration.test.ts b/src/cli/parse-duration.test.ts index c26bcc114c8..ad9d6a3a60c 100644 --- a/src/cli/parse-duration.test.ts +++ b/src/cli/parse-duration.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { parseDurationMs } from "./parse-duration.js"; describe("parseDurationMs", () => { diff --git a/src/cli/plugin-registry.ts b/src/cli/plugin-registry.ts index ce7af63e154..5ce740437bb 100644 --- a/src/cli/plugin-registry.ts +++ b/src/cli/plugin-registry.ts @@ -1,8 +1,8 @@ +import type { PluginLogger } from "../plugins/types.js"; import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; import { loadConfig } from "../config/config.js"; import { createSubsystemLogger } from "../logging.js"; import { loadOpenClawPlugins } from "../plugins/loader.js"; -import type { PluginLogger } from "../plugins/types.js"; const log = createSubsystemLogger("plugins"); let pluginRegistryLoaded = false; diff --git a/src/cli/plugins-cli.ts b/src/cli/plugins-cli.ts index 87ab458f11c..a3832d8c9db 100644 --- a/src/cli/plugins-cli.ts +++ b/src/cli/plugins-cli.ts @@ -1,14 +1,13 @@ +import type { Command } from "commander"; import fs from "node:fs"; import path from "node:path"; -import type { Command } from "commander"; - -import { loadConfig, writeConfigFile } from "../config/config.js"; import type { OpenClawConfig } from "../config/config.js"; +import type { PluginRecord } from "../plugins/registry.js"; +import { loadConfig, writeConfigFile } from "../config/config.js"; import { resolveArchiveKind } from "../infra/archive.js"; import { installPluginFromNpmSpec, installPluginFromPath } from "../plugins/install.js"; import { recordPluginInstall } from "../plugins/installs.js"; import { applyExclusiveSlotSelection } from "../plugins/slots.js"; -import type { PluginRecord } from "../plugins/registry.js"; import { buildPluginStatusReport } from "../plugins/status.js"; import { updateNpmInstalledPlugins } from "../plugins/update.js"; import { defaultRuntime } from "../runtime.js"; diff --git a/src/cli/profile.ts b/src/cli/profile.ts index ac3e965d5df..8eea8310c56 100644 --- a/src/cli/profile.ts +++ b/src/cli/profile.ts @@ -1,6 +1,5 @@ import os from "node:os"; import path from "node:path"; - import { isValidProfileName } from "./profile-utils.js"; export type CliProfileParseResult = diff --git a/src/cli/program/build-program.ts b/src/cli/program/build-program.ts index 917ee53f347..4feff385f9c 100644 --- a/src/cli/program/build-program.ts +++ b/src/cli/program/build-program.ts @@ -1,6 +1,6 @@ import { Command } from "commander"; -import { createProgramContext } from "./context.js"; import { registerProgramCommands } from "./command-registry.js"; +import { createProgramContext } from "./context.js"; import { configureProgramHelp } from "./help.js"; import { registerPreActionHooks } from "./preaction.js"; diff --git a/src/cli/program/command-registry.ts b/src/cli/program/command-registry.ts index 70f0dc19698..7d7de6bfb8c 100644 --- a/src/cli/program/command-registry.ts +++ b/src/cli/program/command-registry.ts @@ -1,5 +1,5 @@ import type { Command } from "commander"; - +import type { ProgramContext } from "./context.js"; import { agentsListCommand } from "../../commands/agents.js"; import { healthCommand } from "../../commands/health.js"; import { sessionsCommand } from "../../commands/sessions.js"; @@ -17,7 +17,6 @@ import { registerOnboardCommand } from "./register.onboard.js"; import { registerSetupCommand } from "./register.setup.js"; import { registerStatusHealthSessionsCommands } from "./register.status-health-sessions.js"; import { registerSubCliCommands } from "./register.subclis.js"; -import type { ProgramContext } from "./context.js"; type CommandRegisterParams = { program: Command; diff --git a/src/cli/program/config-guard.ts b/src/cli/program/config-guard.ts index 89e61839977..7737de03ccf 100644 --- a/src/cli/program/config-guard.ts +++ b/src/cli/program/config-guard.ts @@ -1,9 +1,9 @@ -import { readConfigFileSnapshot } from "../../config/config.js"; -import { loadAndMaybeMigrateDoctorConfig } from "../../commands/doctor-config-flow.js"; -import { colorize, isRich, theme } from "../../terminal/theme.js"; import type { RuntimeEnv } from "../../runtime.js"; -import { formatCliCommand } from "../command-format.js"; +import { loadAndMaybeMigrateDoctorConfig } from "../../commands/doctor-config-flow.js"; +import { readConfigFileSnapshot } from "../../config/config.js"; +import { colorize, isRich, theme } from "../../terminal/theme.js"; import { shortenHomePath } from "../../utils.js"; +import { formatCliCommand } from "../command-format.js"; const ALLOWED_INVALID_COMMANDS = new Set(["doctor", "logs", "health", "help", "status"]); const ALLOWED_INVALID_GATEWAY_SUBCOMMANDS = new Set([ diff --git a/src/cli/program/help.ts b/src/cli/program/help.ts index 109c4270a1b..17b041e2d2f 100644 --- a/src/cli/program/help.ts +++ b/src/cli/program/help.ts @@ -1,9 +1,9 @@ import type { Command } from "commander"; +import type { ProgramContext } from "./context.js"; import { formatDocsLink } from "../../terminal/links.js"; import { isRich, theme } from "../../terminal/theme.js"; import { formatCliBannerLine, hasEmittedCliBanner } from "../banner.js"; import { replaceCliName, resolveCliName } from "../cli-name.js"; -import type { ProgramContext } from "./context.js"; const CLI_NAME = resolveCliName(); diff --git a/src/cli/program/message/helpers.ts b/src/cli/program/message/helpers.ts index 2173bb0540e..803c064e93f 100644 --- a/src/cli/program/message/helpers.ts +++ b/src/cli/program/message/helpers.ts @@ -3,8 +3,8 @@ import { messageCommand } from "../../../commands/message.js"; import { danger, setVerbose } from "../../../globals.js"; import { CHANNEL_TARGET_DESCRIPTION } from "../../../infra/outbound/channel-target.js"; import { defaultRuntime } from "../../../runtime.js"; -import { createDefaultDeps } from "../../deps.js"; import { runCommandWithRuntime } from "../../cli-utils.js"; +import { createDefaultDeps } from "../../deps.js"; import { ensurePluginRegistryLoaded } from "../../plugin-registry.js"; export type MessageCliHelpers = { diff --git a/src/cli/program/message/register.broadcast.ts b/src/cli/program/message/register.broadcast.ts index bfdd1ebeebd..9550571f5fd 100644 --- a/src/cli/program/message/register.broadcast.ts +++ b/src/cli/program/message/register.broadcast.ts @@ -1,6 +1,6 @@ import type { Command } from "commander"; -import { CHANNEL_TARGETS_DESCRIPTION } from "../../../infra/outbound/channel-target.js"; import type { MessageCliHelpers } from "./helpers.js"; +import { CHANNEL_TARGETS_DESCRIPTION } from "../../../infra/outbound/channel-target.js"; export function registerMessageBroadcastCommand(message: Command, helpers: MessageCliHelpers) { helpers diff --git a/src/cli/program/message/register.emoji-sticker.ts b/src/cli/program/message/register.emoji-sticker.ts index 221a3865850..dd2e04eac0d 100644 --- a/src/cli/program/message/register.emoji-sticker.ts +++ b/src/cli/program/message/register.emoji-sticker.ts @@ -1,6 +1,6 @@ import type { Command } from "commander"; -import { collectOption } from "../helpers.js"; import type { MessageCliHelpers } from "./helpers.js"; +import { collectOption } from "../helpers.js"; export function registerMessageEmojiCommands(message: Command, helpers: MessageCliHelpers) { const emoji = message.command("emoji").description("Emoji actions"); diff --git a/src/cli/program/message/register.permissions-search.ts b/src/cli/program/message/register.permissions-search.ts index 4aeb7103edd..75b8882fbf3 100644 --- a/src/cli/program/message/register.permissions-search.ts +++ b/src/cli/program/message/register.permissions-search.ts @@ -1,6 +1,6 @@ import type { Command } from "commander"; -import { collectOption } from "../helpers.js"; import type { MessageCliHelpers } from "./helpers.js"; +import { collectOption } from "../helpers.js"; export function registerMessagePermissionsCommand(message: Command, helpers: MessageCliHelpers) { helpers diff --git a/src/cli/program/message/register.poll.ts b/src/cli/program/message/register.poll.ts index a113bdcc69b..522055823c1 100644 --- a/src/cli/program/message/register.poll.ts +++ b/src/cli/program/message/register.poll.ts @@ -1,6 +1,6 @@ import type { Command } from "commander"; -import { collectOption } from "../helpers.js"; import type { MessageCliHelpers } from "./helpers.js"; +import { collectOption } from "../helpers.js"; export function registerMessagePollCommand(message: Command, helpers: MessageCliHelpers) { helpers diff --git a/src/cli/program/preaction.ts b/src/cli/program/preaction.ts index d38c688c68b..8fb1b7b5319 100644 --- a/src/cli/program/preaction.ts +++ b/src/cli/program/preaction.ts @@ -1,12 +1,12 @@ import type { Command } from "commander"; -import { defaultRuntime } from "../../runtime.js"; -import { emitCliBanner } from "../banner.js"; -import { getCommandPath, getVerboseFlag, hasHelpOrVersion } from "../argv.js"; -import { ensureConfigReady } from "./config-guard.js"; -import { ensurePluginRegistryLoaded } from "../plugin-registry.js"; -import { isTruthyEnvValue } from "../../infra/env.js"; import { setVerbose } from "../../globals.js"; +import { isTruthyEnvValue } from "../../infra/env.js"; +import { defaultRuntime } from "../../runtime.js"; +import { getCommandPath, getVerboseFlag, hasHelpOrVersion } from "../argv.js"; +import { emitCliBanner } from "../banner.js"; import { resolveCliName } from "../cli-name.js"; +import { ensurePluginRegistryLoaded } from "../plugin-registry.js"; +import { ensureConfigReady } from "./config-guard.js"; function setProcessTitleForCommand(actionCommand: Command) { let current: Command = actionCommand; diff --git a/src/cli/program/register.agent.ts b/src/cli/program/register.agent.ts index 9997906fd76..7d114591dd9 100644 --- a/src/cli/program/register.agent.ts +++ b/src/cli/program/register.agent.ts @@ -11,10 +11,10 @@ import { setVerbose } from "../../globals.js"; import { defaultRuntime } from "../../runtime.js"; import { formatDocsLink } from "../../terminal/links.js"; import { theme } from "../../terminal/theme.js"; -import { hasExplicitOptions } from "../command-options.js"; -import { formatHelpExamples } from "../help-format.js"; -import { createDefaultDeps } from "../deps.js"; import { runCommandWithRuntime } from "../cli-utils.js"; +import { hasExplicitOptions } from "../command-options.js"; +import { createDefaultDeps } from "../deps.js"; +import { formatHelpExamples } from "../help-format.js"; import { collectOption } from "./helpers.js"; export function registerAgentCommands(program: Command, args: { agentChannelOptions: string }) { diff --git a/src/cli/program/register.message.ts b/src/cli/program/register.message.ts index b8bc57a8938..5a1026b3760 100644 --- a/src/cli/program/register.message.ts +++ b/src/cli/program/register.message.ts @@ -1,9 +1,10 @@ import type { Command } from "commander"; +import type { ProgramContext } from "./context.js"; import { formatDocsLink } from "../../terminal/links.js"; import { theme } from "../../terminal/theme.js"; import { formatHelpExamples } from "../help-format.js"; -import type { ProgramContext } from "./context.js"; import { createMessageCliHelpers } from "./message/helpers.js"; +import { registerMessageBroadcastCommand } from "./message/register.broadcast.js"; import { registerMessageDiscordAdminCommands } from "./message/register.discord-admin.js"; import { registerMessageEmojiCommands, @@ -19,7 +20,6 @@ import { registerMessageReactionsCommands } from "./message/register.reactions.j import { registerMessageReadEditDeleteCommands } from "./message/register.read-edit-delete.js"; import { registerMessageSendCommand } from "./message/register.send.js"; import { registerMessageThreadCommands } from "./message/register.thread.js"; -import { registerMessageBroadcastCommand } from "./message/register.broadcast.js"; export function registerMessageCommands(program: Command, ctx: ProgramContext) { const message = program diff --git a/src/cli/program/register.onboard.ts b/src/cli/program/register.onboard.ts index 086c8fd9d82..94d46fda371 100644 --- a/src/cli/program/register.onboard.ts +++ b/src/cli/program/register.onboard.ts @@ -1,6 +1,5 @@ import type { Command } from "commander"; import type { GatewayDaemonRuntime } from "../../commands/daemon-runtime.js"; -import { onboardCommand } from "../../commands/onboard.js"; import type { AuthChoice, GatewayAuthChoice, @@ -8,6 +7,7 @@ import type { NodeManagerChoice, TailscaleMode, } from "../../commands/onboard-types.js"; +import { onboardCommand } from "../../commands/onboard.js"; import { defaultRuntime } from "../../runtime.js"; import { formatDocsLink } from "../../terminal/links.js"; import { theme } from "../../terminal/theme.js"; diff --git a/src/cli/program/register.setup.ts b/src/cli/program/register.setup.ts index 44fe931c7e8..ec580a2344e 100644 --- a/src/cli/program/register.setup.ts +++ b/src/cli/program/register.setup.ts @@ -4,8 +4,8 @@ import { setupCommand } from "../../commands/setup.js"; import { defaultRuntime } from "../../runtime.js"; import { formatDocsLink } from "../../terminal/links.js"; import { theme } from "../../terminal/theme.js"; -import { hasExplicitOptions } from "../command-options.js"; import { runCommandWithRuntime } from "../cli-utils.js"; +import { hasExplicitOptions } from "../command-options.js"; export function registerSetupCommand(program: Command) { program diff --git a/src/cli/progress.test.ts b/src/cli/progress.test.ts index e696f71261b..2f9004ee40c 100644 --- a/src/cli/progress.test.ts +++ b/src/cli/progress.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { createCliProgress } from "./progress.js"; describe("cli progress", () => { diff --git a/src/cli/progress.ts b/src/cli/progress.ts index 64974e5c867..0f4f50df4b1 100644 --- a/src/cli/progress.ts +++ b/src/cli/progress.ts @@ -1,11 +1,11 @@ import { spinner } from "@clack/prompts"; import { createOscProgressController, supportsOscProgress } from "osc-progress"; -import { theme } from "../terminal/theme.js"; import { clearActiveProgressLine, registerActiveProgressLine, unregisterActiveProgressLine, } from "../terminal/progress-line.js"; +import { theme } from "../terminal/theme.js"; const DEFAULT_DELAY_MS = 0; let activeProgress = 0; diff --git a/src/cli/prompt.test.ts b/src/cli/prompt.test.ts index 808140497f8..efeb1807a94 100644 --- a/src/cli/prompt.test.ts +++ b/src/cli/prompt.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { isYes, setVerbose, setYes } from "../globals.js"; vi.mock("node:readline/promises", () => { diff --git a/src/cli/prompt.ts b/src/cli/prompt.ts index 7b78c185849..7b16e59c2c9 100644 --- a/src/cli/prompt.ts +++ b/src/cli/prompt.ts @@ -1,6 +1,5 @@ import { stdin as input, stdout as output } from "node:process"; import readline from "node:readline/promises"; - import { isVerbose, isYes } from "../globals.js"; export async function promptYesNo(question: string, defaultYes = false): Promise { diff --git a/src/cli/route.ts b/src/cli/route.ts index 39a34d9864f..7a1ddf15ae9 100644 --- a/src/cli/route.ts +++ b/src/cli/route.ts @@ -1,11 +1,11 @@ -import { defaultRuntime } from "../runtime.js"; -import { ensurePluginRegistryLoaded } from "./plugin-registry.js"; import { isTruthyEnvValue } from "../infra/env.js"; -import { emitCliBanner } from "./banner.js"; +import { defaultRuntime } from "../runtime.js"; import { VERSION } from "../version.js"; import { getCommandPath, hasHelpOrVersion } from "./argv.js"; -import { ensureConfigReady } from "./program/config-guard.js"; +import { emitCliBanner } from "./banner.js"; +import { ensurePluginRegistryLoaded } from "./plugin-registry.js"; import { findRoutedCommand } from "./program/command-registry.js"; +import { ensureConfigReady } from "./program/config-guard.js"; async function prepareRoutedCommand(params: { argv: string[]; diff --git a/src/cli/run-main.test.ts b/src/cli/run-main.test.ts index 65bc2bf0b49..5013b076cb5 100644 --- a/src/cli/run-main.test.ts +++ b/src/cli/run-main.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { rewriteUpdateFlagArgv } from "./run-main.js"; describe("rewriteUpdateFlagArgv", () => { diff --git a/src/cli/run-main.ts b/src/cli/run-main.ts index 92944937ef2..bad3f91a21f 100644 --- a/src/cli/run-main.ts +++ b/src/cli/run-main.ts @@ -2,13 +2,12 @@ import fs from "node:fs"; import path from "node:path"; import process from "node:process"; import { fileURLToPath } from "node:url"; - import { loadDotEnv } from "../infra/dotenv.js"; import { normalizeEnv } from "../infra/env.js"; +import { formatUncaughtError } from "../infra/errors.js"; import { isMainModule } from "../infra/is-main.js"; import { ensureOpenClawCliOnPath } from "../infra/path-env.js"; import { assertSupportedRuntime } from "../infra/runtime-guard.js"; -import { formatUncaughtError } from "../infra/errors.js"; import { installUnhandledRejectionHandler } from "../infra/unhandled-rejections.js"; import { enableConsoleCapture } from "../logging.js"; import { getPrimaryCommand, hasHelpOrVersion } from "./argv.js"; diff --git a/src/cli/sandbox-cli.ts b/src/cli/sandbox-cli.ts index 5396c3a3f1f..57b4d82ab8d 100644 --- a/src/cli/sandbox-cli.ts +++ b/src/cli/sandbox-cli.ts @@ -1,7 +1,6 @@ import type { Command } from "commander"; - -import { sandboxListCommand, sandboxRecreateCommand } from "../commands/sandbox.js"; import { sandboxExplainCommand } from "../commands/sandbox-explain.js"; +import { sandboxListCommand, sandboxRecreateCommand } from "../commands/sandbox.js"; import { defaultRuntime } from "../runtime.js"; import { formatDocsLink } from "../terminal/links.js"; import { theme } from "../terminal/theme.js"; diff --git a/src/cli/security-cli.ts b/src/cli/security-cli.ts index a2570b1ce9d..bcaa9cf0bee 100644 --- a/src/cli/security-cli.ts +++ b/src/cli/security-cli.ts @@ -1,5 +1,4 @@ import type { Command } from "commander"; - import { loadConfig } from "../config/config.js"; import { defaultRuntime } from "../runtime.js"; import { runSecurityAudit } from "../security/audit.js"; diff --git a/src/cli/skills-cli.test.ts b/src/cli/skills-cli.test.ts index ca644698a29..70e7aa06f91 100644 --- a/src/cli/skills-cli.test.ts +++ b/src/cli/skills-cli.test.ts @@ -1,7 +1,6 @@ import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; - import { describe, expect, it } from "vitest"; import { buildWorkspaceSkillStatus, diff --git a/src/cli/system-cli.ts b/src/cli/system-cli.ts index 2cc95412e36..b4c92e98adf 100644 --- a/src/cli/system-cli.ts +++ b/src/cli/system-cli.ts @@ -1,10 +1,9 @@ import type { Command } from "commander"; - +import type { GatewayRpcOpts } from "./gateway-rpc.js"; import { danger } from "../globals.js"; import { defaultRuntime } from "../runtime.js"; import { formatDocsLink } from "../terminal/links.js"; import { theme } from "../terminal/theme.js"; -import type { GatewayRpcOpts } from "./gateway-rpc.js"; import { addGatewayClientOptions, callGatewayFromCli } from "./gateway-rpc.js"; type SystemEventOpts = GatewayRpcOpts & { text?: string; mode?: string; json?: boolean }; diff --git a/src/cli/update-cli.test.ts b/src/cli/update-cli.test.ts index 8810b48fd38..09948cfdf29 100644 --- a/src/cli/update-cli.test.ts +++ b/src/cli/update-cli.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { UpdateRunResult } from "../infra/update-runner.js"; const confirm = vi.fn(); diff --git a/src/cli/update-cli.ts b/src/cli/update-cli.ts index 237fcf5c730..56a8daafb60 100644 --- a/src/cli/update-cli.ts +++ b/src/cli/update-cli.ts @@ -1,32 +1,17 @@ +import type { Command } from "commander"; import { confirm, isCancel, select, spinner } from "@clack/prompts"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; -import type { Command } from "commander"; - +import { + formatUpdateAvailableHint, + formatUpdateOneLiner, + resolveUpdateAvailability, +} from "../commands/status.update.js"; import { readConfigFileSnapshot, writeConfigFile } from "../config/config.js"; import { resolveOpenClawPackageRoot } from "../infra/openclaw-root.js"; -import { - checkUpdateStatus, - compareSemverStrings, - fetchNpmTagVersion, - resolveNpmChannelTag, -} from "../infra/update-check.js"; +import { trimLogTail } from "../infra/restart-sentinel.js"; import { parseSemver } from "../infra/runtime-guard.js"; -import { - runGatewayUpdate, - type UpdateRunResult, - type UpdateStepInfo, - type UpdateStepResult, - type UpdateStepProgress, -} from "../infra/update-runner.js"; -import { - detectGlobalInstallManagerByPresence, - detectGlobalInstallManagerForRoot, - globalInstallArgs, - resolveGlobalPackageRoot, - type GlobalInstallManager, -} from "../infra/update-global.js"; import { channelToNpmTag, DEFAULT_GIT_CHANNEL, @@ -35,22 +20,36 @@ import { normalizeUpdateChannel, resolveEffectiveUpdateChannel, } from "../infra/update-channels.js"; -import { trimLogTail } from "../infra/restart-sentinel.js"; -import { defaultRuntime } from "../runtime.js"; -import { formatDocsLink } from "../terminal/links.js"; -import { formatCliCommand } from "./command-format.js"; -import { replaceCliName, resolveCliName } from "./cli-name.js"; -import { stylePromptHint, stylePromptMessage } from "../terminal/prompt-style.js"; -import { theme } from "../terminal/theme.js"; -import { renderTable } from "../terminal/table.js"; -import { formatHelpExamples } from "./help-format.js"; import { - formatUpdateAvailableHint, - formatUpdateOneLiner, - resolveUpdateAvailability, -} from "../commands/status.update.js"; + checkUpdateStatus, + compareSemverStrings, + fetchNpmTagVersion, + resolveNpmChannelTag, +} from "../infra/update-check.js"; +import { + detectGlobalInstallManagerByPresence, + detectGlobalInstallManagerForRoot, + globalInstallArgs, + resolveGlobalPackageRoot, + type GlobalInstallManager, +} from "../infra/update-global.js"; +import { + runGatewayUpdate, + type UpdateRunResult, + type UpdateStepInfo, + type UpdateStepResult, + type UpdateStepProgress, +} from "../infra/update-runner.js"; import { syncPluginsForUpdateChannel, updateNpmInstalledPlugins } from "../plugins/update.js"; import { runCommandWithTimeout } from "../process/exec.js"; +import { defaultRuntime } from "../runtime.js"; +import { formatDocsLink } from "../terminal/links.js"; +import { stylePromptHint, stylePromptMessage } from "../terminal/prompt-style.js"; +import { renderTable } from "../terminal/table.js"; +import { theme } from "../terminal/theme.js"; +import { replaceCliName, resolveCliName } from "./cli-name.js"; +import { formatCliCommand } from "./command-format.js"; +import { formatHelpExamples } from "./help-format.js"; export type UpdateCommandOptions = { json?: boolean; diff --git a/src/cli/wait.test.ts b/src/cli/wait.test.ts index 99b52780606..5af1ba32a64 100644 --- a/src/cli/wait.test.ts +++ b/src/cli/wait.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { waitForever } from "./wait.js"; describe("waitForever", () => { diff --git a/src/cli/webhooks-cli.ts b/src/cli/webhooks-cli.ts index 58ca9c502b4..c9c49a2b1ba 100644 --- a/src/cli/webhooks-cli.ts +++ b/src/cli/webhooks-cli.ts @@ -1,6 +1,11 @@ import type { Command } from "commander"; - import { danger } from "../globals.js"; +import { + type GmailRunOptions, + type GmailSetupOptions, + runGmailService, + runGmailSetup, +} from "../hooks/gmail-ops.js"; import { DEFAULT_GMAIL_LABEL, DEFAULT_GMAIL_MAX_BYTES, @@ -11,12 +16,6 @@ import { DEFAULT_GMAIL_SUBSCRIPTION, DEFAULT_GMAIL_TOPIC, } from "../hooks/gmail.js"; -import { - type GmailRunOptions, - type GmailSetupOptions, - runGmailService, - runGmailSetup, -} from "../hooks/gmail-ops.js"; import { defaultRuntime } from "../runtime.js"; import { formatDocsLink } from "../terminal/links.js"; import { theme } from "../terminal/theme.js"; diff --git a/src/commands/agent-via-gateway.test.ts b/src/commands/agent-via-gateway.test.ts index 2ee4a7a96d3..d0513b6ccbe 100644 --- a/src/commands/agent-via-gateway.test.ts +++ b/src/commands/agent-via-gateway.test.ts @@ -1,7 +1,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import { beforeEach, describe, expect, it, vi } from "vitest"; vi.mock("../gateway/call.js", () => ({ @@ -13,11 +12,11 @@ vi.mock("./agent.js", () => ({ })); import type { OpenClawConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; import * as configModule from "../config/config.js"; import { callGateway } from "../gateway/call.js"; -import type { RuntimeEnv } from "../runtime.js"; -import { agentCommand } from "./agent.js"; import { agentCliCommand } from "./agent-via-gateway.js"; +import { agentCommand } from "./agent.js"; const runtime: RuntimeEnv = { log: vi.fn(), diff --git a/src/commands/agent-via-gateway.ts b/src/commands/agent-via-gateway.ts index 49270a9f076..ef1e8e97ba1 100644 --- a/src/commands/agent-via-gateway.ts +++ b/src/commands/agent-via-gateway.ts @@ -1,19 +1,19 @@ -import { DEFAULT_CHAT_CHANNEL } from "../channels/registry.js"; import type { CliDeps } from "../cli/deps.js"; +import type { RuntimeEnv } from "../runtime.js"; +import { listAgentIds } from "../agents/agent-scope.js"; +import { DEFAULT_CHAT_CHANNEL } from "../channels/registry.js"; +import { formatCliCommand } from "../cli/command-format.js"; import { withProgress } from "../cli/progress.js"; import { loadConfig } from "../config/config.js"; -import { resolveSessionKeyForRequest } from "./agent/session.js"; import { callGateway, randomIdempotencyKey } from "../gateway/call.js"; -import { listAgentIds } from "../agents/agent-scope.js"; import { normalizeAgentId } from "../routing/session-key.js"; -import type { RuntimeEnv } from "../runtime.js"; -import { formatCliCommand } from "../cli/command-format.js"; import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES, normalizeMessageChannel, } from "../utils/message-channel.js"; import { agentCommand } from "./agent.js"; +import { resolveSessionKeyForRequest } from "./agent/session.js"; type AgentGatewayResult = { payloads?: Array<{ diff --git a/src/commands/agent.delivery.test.ts b/src/commands/agent.delivery.test.ts index f34373af488..a97ace67b16 100644 --- a/src/commands/agent.delivery.test.ts +++ b/src/commands/agent.delivery.test.ts @@ -1,9 +1,8 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { CliDeps } from "../cli/deps.js"; import type { OpenClawConfig } from "../config/config.js"; -import type { RuntimeEnv } from "../runtime.js"; import type { SessionEntry } from "../config/sessions.js"; +import type { RuntimeEnv } from "../runtime.js"; const mocks = vi.hoisted(() => ({ deliverOutboundPayloads: vi.fn(async () => []), diff --git a/src/commands/agent.test.ts b/src/commands/agent.test.ts index 96a7221899f..914bde96fcd 100644 --- a/src/commands/agent.test.ts +++ b/src/commands/agent.test.ts @@ -1,8 +1,6 @@ import fs from "node:fs"; import path from "node:path"; - import { beforeEach, describe, expect, it, type MockInstance, vi } from "vitest"; - import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; vi.mock("../agents/pi-embedded.js", () => ({ @@ -14,18 +12,18 @@ vi.mock("../agents/model-catalog.js", () => ({ loadModelCatalog: vi.fn(), })); +import type { OpenClawConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; +import { telegramPlugin } from "../../extensions/telegram/src/channel.js"; +import { setTelegramRuntime } from "../../extensions/telegram/src/runtime.js"; import { loadModelCatalog } from "../agents/model-catalog.js"; import { runEmbeddedPiAgent } from "../agents/pi-embedded.js"; -import type { OpenClawConfig } from "../config/config.js"; import * as configModule from "../config/config.js"; import { emitAgentEvent, onAgentEvent } from "../infra/agent-events.js"; -import type { RuntimeEnv } from "../runtime.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import { createPluginRuntime } from "../plugins/runtime/index.js"; import { createTestRegistry } from "../test-utils/channel-plugins.js"; import { agentCommand } from "./agent.js"; -import { telegramPlugin } from "../../extensions/telegram/src/channel.js"; -import { setTelegramRuntime } from "../../extensions/telegram/src/runtime.js"; const runtime: RuntimeEnv = { log: vi.fn(), diff --git a/src/commands/agent.ts b/src/commands/agent.ts index 675ab39ed00..e8818495b36 100644 --- a/src/commands/agent.ts +++ b/src/commands/agent.ts @@ -1,3 +1,4 @@ +import type { AgentCommandOpts } from "./agent/types.js"; import { listAgentIds, resolveAgentDir, @@ -6,6 +7,7 @@ import { resolveAgentWorkspaceDir, } from "../agents/agent-scope.js"; import { ensureAuthProfileStore } from "../agents/auth-profiles.js"; +import { clearSessionAuthProfileOverride } from "../agents/auth-profiles/session-override.js"; import { runCliAgent } from "../agents/cli-runner.js"; import { getCliSessionId } from "../agents/cli-session.js"; import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js"; @@ -32,6 +34,7 @@ import { type ThinkLevel, type VerboseLevel, } from "../auto-reply/thinking.js"; +import { formatCliCommand } from "../cli/command-format.js"; import { type CliDeps, createDefaultDeps } from "../cli/deps.js"; import { loadConfig } from "../config/config.js"; import { @@ -46,19 +49,16 @@ import { registerAgentRunContext, } from "../infra/agent-events.js"; import { getRemoteSkillEligibility } from "../infra/skills-remote.js"; +import { normalizeAgentId } from "../routing/session-key.js"; import { defaultRuntime, type RuntimeEnv } from "../runtime.js"; -import { formatCliCommand } from "../cli/command-format.js"; import { applyVerboseOverride } from "../sessions/level-overrides.js"; -import { resolveSendPolicy } from "../sessions/send-policy.js"; import { applyModelOverrideToSessionEntry } from "../sessions/model-overrides.js"; -import { clearSessionAuthProfileOverride } from "../agents/auth-profiles/session-override.js"; +import { resolveSendPolicy } from "../sessions/send-policy.js"; import { resolveMessageChannel } from "../utils/message-channel.js"; import { deliverAgentCommandResult } from "./agent/delivery.js"; import { resolveAgentRunContext } from "./agent/run-context.js"; -import { resolveSession } from "./agent/session.js"; import { updateSessionStoreAfterAgentRun } from "./agent/session-store.js"; -import type { AgentCommandOpts } from "./agent/types.js"; -import { normalizeAgentId } from "../routing/session-key.js"; +import { resolveSession } from "./agent/session.js"; export async function agentCommand( opts: AgentCommandOpts, diff --git a/src/commands/agent/delivery.ts b/src/commands/agent/delivery.ts index 79ef7ca7431..5f5cb66924b 100644 --- a/src/commands/agent/delivery.ts +++ b/src/commands/agent/delivery.ts @@ -1,8 +1,14 @@ +import type { OpenClawConfig } from "../../config/config.js"; +import type { SessionEntry } from "../../config/sessions.js"; +import type { RuntimeEnv } from "../../runtime.js"; +import type { AgentCommandOpts } from "./types.js"; import { AGENT_LANE_NESTED } from "../../agents/lanes.js"; import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js"; import { createOutboundSendDeps, type CliDeps } from "../../cli/outbound-send-deps.js"; -import type { OpenClawConfig } from "../../config/config.js"; -import type { SessionEntry } from "../../config/sessions.js"; +import { + resolveAgentDeliveryPlan, + resolveAgentOutboundTarget, +} from "../../infra/outbound/agent-delivery.js"; import { deliverOutboundPayloads } from "../../infra/outbound/deliver.js"; import { buildOutboundResultEnvelope } from "../../infra/outbound/envelope.js"; import { @@ -11,13 +17,7 @@ import { normalizeOutboundPayloads, normalizeOutboundPayloadsForJson, } from "../../infra/outbound/payloads.js"; -import { - resolveAgentDeliveryPlan, - resolveAgentOutboundTarget, -} from "../../infra/outbound/agent-delivery.js"; -import type { RuntimeEnv } from "../../runtime.js"; import { isInternalMessageChannel } from "../../utils/message-channel.js"; -import type { AgentCommandOpts } from "./types.js"; type RunResult = Awaited< ReturnType<(typeof import("../../agents/pi-embedded.js"))["runEmbeddedPiAgent"]> diff --git a/src/commands/agent/run-context.ts b/src/commands/agent/run-context.ts index fcf8d0845b7..445e03a5dba 100644 --- a/src/commands/agent/run-context.ts +++ b/src/commands/agent/run-context.ts @@ -1,6 +1,6 @@ +import type { AgentCommandOpts, AgentRunContext } from "./types.js"; import { normalizeAccountId } from "../../utils/account-id.js"; import { resolveMessageChannel } from "../../utils/message-channel.js"; -import type { AgentCommandOpts, AgentRunContext } from "./types.js"; export function resolveAgentRunContext(opts: AgentCommandOpts): AgentRunContext { const merged: AgentRunContext = opts.runContext ? { ...opts.runContext } : {}; diff --git a/src/commands/agent/session-store.ts b/src/commands/agent/session-store.ts index 5680af5ea5f..2c97d3ddf7e 100644 --- a/src/commands/agent/session-store.ts +++ b/src/commands/agent/session-store.ts @@ -1,9 +1,9 @@ +import type { OpenClawConfig } from "../../config/config.js"; import { setCliSessionId } from "../../agents/cli-session.js"; import { lookupContextTokens } from "../../agents/context.js"; import { DEFAULT_CONTEXT_TOKENS } from "../../agents/defaults.js"; import { isCliProvider } from "../../agents/model-selection.js"; import { hasNonzeroUsage } from "../../agents/usage.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { type SessionEntry, updateSessionStore } from "../../config/sessions.js"; type RunResult = Awaited< diff --git a/src/commands/agent/session.ts b/src/commands/agent/session.ts index e2fd1a75217..889e8e55943 100644 --- a/src/commands/agent/session.ts +++ b/src/commands/agent/session.ts @@ -1,13 +1,12 @@ import crypto from "node:crypto"; - import type { MsgContext } from "../../auto-reply/templating.js"; +import type { OpenClawConfig } from "../../config/config.js"; import { normalizeThinkLevel, normalizeVerboseLevel, type ThinkLevel, type VerboseLevel, } from "../../auto-reply/thinking.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { evaluateSessionFreshness, loadSessionStore, diff --git a/src/commands/agents.add.test.ts b/src/commands/agents.add.test.ts index b4bed020fb3..3175cd3fd10 100644 --- a/src/commands/agents.add.test.ts +++ b/src/commands/agents.add.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { RuntimeEnv } from "../runtime.js"; const configMocks = vi.hoisted(() => ({ diff --git a/src/commands/agents.bindings.ts b/src/commands/agents.bindings.ts index f0eaf959e1e..31d0f4bce1e 100644 --- a/src/commands/agents.bindings.ts +++ b/src/commands/agents.bindings.ts @@ -1,10 +1,10 @@ -import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js"; -import { getChannelPlugin, normalizeChannelId } from "../channels/plugins/index.js"; import type { ChannelId } from "../channels/plugins/types.js"; import type { OpenClawConfig } from "../config/config.js"; import type { AgentBinding } from "../config/types.js"; -import { DEFAULT_ACCOUNT_ID, normalizeAgentId } from "../routing/session-key.js"; import type { ChannelChoice } from "./onboard-types.js"; +import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js"; +import { getChannelPlugin, normalizeChannelId } from "../channels/plugins/index.js"; +import { DEFAULT_ACCOUNT_ID, normalizeAgentId } from "../routing/session-key.js"; function bindingMatchKey(match: AgentBinding["match"]) { const accountId = match.accountId?.trim() || DEFAULT_ACCOUNT_ID; diff --git a/src/commands/agents.command-shared.ts b/src/commands/agents.command-shared.ts index 4e173864599..7917b27db2d 100644 --- a/src/commands/agents.command-shared.ts +++ b/src/commands/agents.command-shared.ts @@ -1,7 +1,7 @@ -import { formatCliCommand } from "../cli/command-format.js"; import type { OpenClawConfig } from "../config/config.js"; -import { readConfigFileSnapshot } from "../config/config.js"; import type { RuntimeEnv } from "../runtime.js"; +import { formatCliCommand } from "../cli/command-format.js"; +import { readConfigFileSnapshot } from "../config/config.js"; export function createQuietRuntime(runtime: RuntimeEnv): RuntimeEnv { return { ...runtime, log: () => {} }; diff --git a/src/commands/agents.commands.add.ts b/src/commands/agents.commands.add.ts index 9ee3c3742bc..8a9fde8fb30 100644 --- a/src/commands/agents.commands.add.ts +++ b/src/commands/agents.commands.add.ts @@ -1,6 +1,7 @@ import fs from "node:fs/promises"; import path from "node:path"; - +import type { RuntimeEnv } from "../runtime.js"; +import type { ChannelChoice } from "./onboard-types.js"; import { resolveAgentDir, resolveAgentWorkspaceDir, @@ -11,7 +12,6 @@ import { resolveAuthStorePath } from "../agents/auth-profiles/paths.js"; import { writeConfigFile } from "../config/config.js"; import { logConfigUpdated } from "../config/logging.js"; import { DEFAULT_AGENT_ID, normalizeAgentId } from "../routing/session-key.js"; -import type { RuntimeEnv } from "../runtime.js"; import { defaultRuntime } from "../runtime.js"; import { resolveUserPath, shortenHomePath } from "../utils.js"; import { createClackPrompter } from "../wizard/clack-prompter.js"; @@ -24,11 +24,10 @@ import { } from "./agents.bindings.js"; import { createQuietRuntime, requireValidConfig } from "./agents.command-shared.js"; import { applyAgentConfig, findAgentEntryIndex, listAgentEntries } from "./agents.config.js"; -import { applyAuthChoice, warnIfModelConfigLooksOff } from "./auth-choice.js"; import { promptAuthChoiceGrouped } from "./auth-choice-prompt.js"; +import { applyAuthChoice, warnIfModelConfigLooksOff } from "./auth-choice.js"; import { setupChannels } from "./onboard-channels.js"; import { ensureWorkspaceAndSessions } from "./onboard-helpers.js"; -import type { ChannelChoice } from "./onboard-types.js"; type AgentsAddOptions = { name?: string; diff --git a/src/commands/agents.commands.delete.ts b/src/commands/agents.commands.delete.ts index b5bd9357369..6d45834a4ed 100644 --- a/src/commands/agents.commands.delete.ts +++ b/src/commands/agents.commands.delete.ts @@ -1,12 +1,11 @@ +import type { RuntimeEnv } from "../runtime.js"; import { resolveAgentDir, resolveAgentWorkspaceDir } from "../agents/agent-scope.js"; import { writeConfigFile } from "../config/config.js"; import { logConfigUpdated } from "../config/logging.js"; import { resolveSessionTranscriptsDirForAgent } from "../config/sessions.js"; import { DEFAULT_AGENT_ID, normalizeAgentId } from "../routing/session-key.js"; -import type { RuntimeEnv } from "../runtime.js"; import { defaultRuntime } from "../runtime.js"; import { createClackPrompter } from "../wizard/clack-prompter.js"; - import { createQuietRuntime, requireValidConfig } from "./agents.command-shared.js"; import { findAgentEntryIndex, listAgentEntries, pruneAgentConfig } from "./agents.config.js"; import { moveToTrash } from "./onboard-helpers.js"; diff --git a/src/commands/agents.commands.identity.ts b/src/commands/agents.commands.identity.ts index e93ab74b190..2e150a405cf 100644 --- a/src/commands/agents.commands.identity.ts +++ b/src/commands/agents.commands.identity.ts @@ -1,14 +1,13 @@ import fs from "node:fs/promises"; import path from "node:path"; - +import type { IdentityConfig } from "../config/types.js"; +import type { RuntimeEnv } from "../runtime.js"; import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; import { identityHasValues, parseIdentityMarkdown } from "../agents/identity-file.js"; import { DEFAULT_IDENTITY_FILENAME } from "../agents/workspace.js"; import { writeConfigFile } from "../config/config.js"; import { logConfigUpdated } from "../config/logging.js"; -import type { IdentityConfig } from "../config/types.js"; import { normalizeAgentId } from "../routing/session-key.js"; -import type { RuntimeEnv } from "../runtime.js"; import { defaultRuntime } from "../runtime.js"; import { resolveUserPath, shortenHomePath } from "../utils.js"; import { requireValidConfig } from "./agents.command-shared.js"; diff --git a/src/commands/agents.commands.list.ts b/src/commands/agents.commands.list.ts index e9571c23659..3af388de412 100644 --- a/src/commands/agents.commands.list.ts +++ b/src/commands/agents.commands.list.ts @@ -1,12 +1,12 @@ import type { AgentBinding } from "../config/types.js"; -import { normalizeAgentId } from "../routing/session-key.js"; import type { RuntimeEnv } from "../runtime.js"; -import { defaultRuntime } from "../runtime.js"; +import type { AgentSummary } from "./agents.config.js"; import { formatCliCommand } from "../cli/command-format.js"; +import { normalizeAgentId } from "../routing/session-key.js"; +import { defaultRuntime } from "../runtime.js"; import { shortenHomePath } from "../utils.js"; import { describeBinding } from "./agents.bindings.js"; import { requireValidConfig } from "./agents.command-shared.js"; -import type { AgentSummary } from "./agents.config.js"; import { buildAgentSummaries } from "./agents.config.js"; import { buildProviderStatusIndex, diff --git a/src/commands/agents.config.ts b/src/commands/agents.config.ts index 5647ea990fa..fe0907c04cb 100644 --- a/src/commands/agents.config.ts +++ b/src/commands/agents.config.ts @@ -1,15 +1,15 @@ +import type { AgentIdentityFile } from "../agents/identity-file.js"; +import type { OpenClawConfig } from "../config/config.js"; import { resolveAgentDir, resolveAgentWorkspaceDir, resolveDefaultAgentId, } from "../agents/agent-scope.js"; -import type { AgentIdentityFile } from "../agents/identity-file.js"; import { identityHasValues, loadAgentIdentityFromWorkspace, parseIdentityMarkdown as parseIdentityMarkdownFile, } from "../agents/identity-file.js"; -import type { OpenClawConfig } from "../config/config.js"; import { normalizeAgentId } from "../routing/session-key.js"; export type AgentSummary = { diff --git a/src/commands/agents.identity.test.ts b/src/commands/agents.identity.test.ts index 50348f1ccd3..7956d8dec3d 100644 --- a/src/commands/agents.identity.test.ts +++ b/src/commands/agents.identity.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { RuntimeEnv } from "../runtime.js"; const configMocks = vi.hoisted(() => ({ diff --git a/src/commands/agents.providers.ts b/src/commands/agents.providers.ts index 0d53a62051e..13090119660 100644 --- a/src/commands/agents.providers.ts +++ b/src/commands/agents.providers.ts @@ -1,12 +1,12 @@ +import type { ChannelId } from "../channels/plugins/types.js"; +import type { OpenClawConfig } from "../config/config.js"; +import type { AgentBinding } from "../config/types.js"; import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js"; import { getChannelPlugin, listChannelPlugins, normalizeChannelId, } from "../channels/plugins/index.js"; -import type { ChannelId } from "../channels/plugins/types.js"; -import type { OpenClawConfig } from "../config/config.js"; -import type { AgentBinding } from "../config/types.js"; import { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js"; type ProviderAccountStatus = { diff --git a/src/commands/agents.test.ts b/src/commands/agents.test.ts index 2af9ef5b7a5..83e7c6cd680 100644 --- a/src/commands/agents.test.ts +++ b/src/commands/agents.test.ts @@ -1,8 +1,6 @@ import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { applyAgentBindings, diff --git a/src/commands/auth-choice-options.test.ts b/src/commands/auth-choice-options.test.ts index c85cc0b4dde..df00d6afe7d 100644 --- a/src/commands/auth-choice-options.test.ts +++ b/src/commands/auth-choice-options.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { AuthProfileStore } from "../agents/auth-profiles.js"; import { buildAuthChoiceOptions } from "./auth-choice-options.js"; diff --git a/src/commands/auth-choice-prompt.ts b/src/commands/auth-choice-prompt.ts index fcb5554cac8..3fbacdfdb41 100644 --- a/src/commands/auth-choice-prompt.ts +++ b/src/commands/auth-choice-prompt.ts @@ -1,7 +1,7 @@ import type { AuthProfileStore } from "../agents/auth-profiles.js"; import type { WizardPrompter } from "../wizard/prompts.js"; -import { buildAuthChoiceGroups } from "./auth-choice-options.js"; import type { AuthChoice } from "./onboard-types.js"; +import { buildAuthChoiceGroups } from "./auth-choice-options.js"; const BACK_VALUE = "__back"; diff --git a/src/commands/auth-choice.apply.anthropic.ts b/src/commands/auth-choice.apply.anthropic.ts index b28b8ebee16..545efc201eb 100644 --- a/src/commands/auth-choice.apply.anthropic.ts +++ b/src/commands/auth-choice.apply.anthropic.ts @@ -1,10 +1,10 @@ +import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.js"; import { upsertAuthProfile } from "../agents/auth-profiles.js"; import { formatApiKeyPreview, normalizeApiKeyInput, validateApiKeyInput, } from "./auth-choice.api-key.js"; -import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.js"; import { buildTokenProfileId, validateAnthropicSetupToken } from "./auth-token.js"; import { applyAuthProfileConfig, setAnthropicApiKey } from "./onboard-auth.js"; diff --git a/src/commands/auth-choice.apply.api-providers.ts b/src/commands/auth-choice.apply.api-providers.ts index 001517b4b02..ef059e3de41 100644 --- a/src/commands/auth-choice.apply.api-providers.ts +++ b/src/commands/auth-choice.apply.api-providers.ts @@ -1,3 +1,4 @@ +import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.js"; import { ensureAuthProfileStore, resolveAuthProfileOrder } from "../agents/auth-profiles.js"; import { resolveEnvApiKey } from "../agents/model-auth.js"; import { @@ -5,7 +6,6 @@ import { normalizeApiKeyInput, validateApiKeyInput, } from "./auth-choice.api-key.js"; -import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.js"; import { applyDefaultModelChoice } from "./auth-choice.default-model.js"; import { applyGoogleGeminiModelDefault, diff --git a/src/commands/auth-choice.apply.github-copilot.ts b/src/commands/auth-choice.apply.github-copilot.ts index cd67ae1cbdf..b31a5be5e72 100644 --- a/src/commands/auth-choice.apply.github-copilot.ts +++ b/src/commands/auth-choice.apply.github-copilot.ts @@ -1,5 +1,5 @@ -import { githubCopilotLoginCommand } from "../providers/github-copilot-auth.js"; import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.js"; +import { githubCopilotLoginCommand } from "../providers/github-copilot-auth.js"; import { applyAuthProfileConfig } from "./onboard-auth.js"; export async function applyAuthChoiceGitHubCopilot( diff --git a/src/commands/auth-choice.apply.minimax.ts b/src/commands/auth-choice.apply.minimax.ts index 562d855bb24..1dd75dcdb00 100644 --- a/src/commands/auth-choice.apply.minimax.ts +++ b/src/commands/auth-choice.apply.minimax.ts @@ -1,12 +1,12 @@ +import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.js"; import { resolveEnvApiKey } from "../agents/model-auth.js"; import { formatApiKeyPreview, normalizeApiKeyInput, validateApiKeyInput, } from "./auth-choice.api-key.js"; -import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.js"; -import { applyDefaultModelChoice } from "./auth-choice.default-model.js"; import { applyAuthChoicePluginProvider } from "./auth-choice.apply.plugin-provider.js"; +import { applyDefaultModelChoice } from "./auth-choice.default-model.js"; import { applyAuthProfileConfig, applyMinimaxApiConfig, diff --git a/src/commands/auth-choice.apply.oauth.ts b/src/commands/auth-choice.apply.oauth.ts index 5ae0da301d4..ca5a8558752 100644 --- a/src/commands/auth-choice.apply.oauth.ts +++ b/src/commands/auth-choice.apply.oauth.ts @@ -1,6 +1,6 @@ -import { isRemoteEnvironment } from "./oauth-env.js"; import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.js"; import { loginChutes } from "./chutes-oauth.js"; +import { isRemoteEnvironment } from "./oauth-env.js"; import { createVpsAwareOAuthHandlers } from "./oauth-flow.js"; import { applyAuthProfileConfig, writeOAuthCredentials } from "./onboard-auth.js"; import { openUrl } from "./onboard-helpers.js"; diff --git a/src/commands/auth-choice.apply.openai.ts b/src/commands/auth-choice.apply.openai.ts index 9ecf42f0790..2022d5d0dda 100644 --- a/src/commands/auth-choice.apply.openai.ts +++ b/src/commands/auth-choice.apply.openai.ts @@ -1,13 +1,13 @@ import { loginOpenAICodex } from "@mariozechner/pi-ai"; +import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.js"; import { resolveEnvApiKey } from "../agents/model-auth.js"; import { upsertSharedEnvVar } from "../infra/env-file.js"; -import { isRemoteEnvironment } from "./oauth-env.js"; import { formatApiKeyPreview, normalizeApiKeyInput, validateApiKeyInput, } from "./auth-choice.api-key.js"; -import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.js"; +import { isRemoteEnvironment } from "./oauth-env.js"; import { createVpsAwareOAuthHandlers } from "./oauth-flow.js"; import { applyAuthProfileConfig, writeOAuthCredentials } from "./onboard-auth.js"; import { openUrl } from "./onboard-helpers.js"; diff --git a/src/commands/auth-choice.apply.plugin-provider.ts b/src/commands/auth-choice.apply.plugin-provider.ts index 098e2fff361..5555c17266d 100644 --- a/src/commands/auth-choice.apply.plugin-provider.ts +++ b/src/commands/auth-choice.apply.plugin-provider.ts @@ -1,3 +1,6 @@ +import type { OpenClawConfig } from "../config/config.js"; +import type { ProviderAuthMethod, ProviderPlugin } from "../plugins/types.js"; +import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.js"; import { resolveOpenClawAgentDir } from "../agents/agent-paths.js"; import { resolveDefaultAgentId, @@ -7,15 +10,12 @@ import { import { upsertAuthProfile } from "../agents/auth-profiles.js"; import { normalizeProviderId } from "../agents/model-selection.js"; import { resolveDefaultAgentWorkspaceDir } from "../agents/workspace.js"; -import type { OpenClawConfig } from "../config/config.js"; import { enablePluginInConfig } from "../plugins/enable.js"; import { resolvePluginProviders } from "../plugins/providers.js"; -import type { ProviderAuthMethod, ProviderPlugin } from "../plugins/types.js"; -import type { ApplyAuthChoiceParams, ApplyAuthChoiceResult } from "./auth-choice.apply.js"; +import { isRemoteEnvironment } from "./oauth-env.js"; +import { createVpsAwareOAuthHandlers } from "./oauth-flow.js"; import { applyAuthProfileConfig } from "./onboard-auth.js"; import { openUrl } from "./onboard-helpers.js"; -import { createVpsAwareOAuthHandlers } from "./oauth-flow.js"; -import { isRemoteEnvironment } from "./oauth-env.js"; export type PluginProviderAuthChoiceOptions = { authChoice: string; diff --git a/src/commands/auth-choice.apply.ts b/src/commands/auth-choice.apply.ts index 5abd026f44a..37dc0f272ec 100644 --- a/src/commands/auth-choice.apply.ts +++ b/src/commands/auth-choice.apply.ts @@ -1,6 +1,7 @@ import type { OpenClawConfig } from "../config/config.js"; import type { RuntimeEnv } from "../runtime.js"; import type { WizardPrompter } from "../wizard/prompts.js"; +import type { AuthChoice } from "./onboard-types.js"; import { applyAuthChoiceAnthropic } from "./auth-choice.apply.anthropic.js"; import { applyAuthChoiceApiProviders } from "./auth-choice.apply.api-providers.js"; import { applyAuthChoiceCopilotProxy } from "./auth-choice.apply.copilot-proxy.js"; @@ -11,7 +12,6 @@ import { applyAuthChoiceMiniMax } from "./auth-choice.apply.minimax.js"; import { applyAuthChoiceOAuth } from "./auth-choice.apply.oauth.js"; import { applyAuthChoiceOpenAI } from "./auth-choice.apply.openai.js"; import { applyAuthChoiceQwenPortal } from "./auth-choice.apply.qwen-portal.js"; -import type { AuthChoice } from "./onboard-types.js"; export type ApplyAuthChoiceParams = { authChoice: AuthChoice; diff --git a/src/commands/auth-choice.model-check.ts b/src/commands/auth-choice.model-check.ts index b1579ea3483..378a6a9fd81 100644 --- a/src/commands/auth-choice.model-check.ts +++ b/src/commands/auth-choice.model-check.ts @@ -1,11 +1,11 @@ +import type { OpenClawConfig } from "../config/config.js"; +import type { WizardPrompter } from "../wizard/prompts.js"; import { resolveAgentModelPrimary } from "../agents/agent-scope.js"; import { ensureAuthProfileStore, listProfilesForProvider } from "../agents/auth-profiles.js"; import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js"; import { getCustomProviderApiKey, resolveEnvApiKey } from "../agents/model-auth.js"; import { loadModelCatalog } from "../agents/model-catalog.js"; import { resolveConfiguredModelRef } from "../agents/model-selection.js"; -import type { OpenClawConfig } from "../config/config.js"; -import type { WizardPrompter } from "../wizard/prompts.js"; import { OPENAI_CODEX_DEFAULT_MODEL } from "./openai-codex-model-default.js"; export async function warnIfModelConfigLooksOff( diff --git a/src/commands/auth-choice.test.ts b/src/commands/auth-choice.test.ts index 5013ccca1d0..c034b6144aa 100644 --- a/src/commands/auth-choice.test.ts +++ b/src/commands/auth-choice.test.ts @@ -1,13 +1,11 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, describe, expect, it, vi } from "vitest"; - import type { RuntimeEnv } from "../runtime.js"; import type { WizardPrompter } from "../wizard/prompts.js"; -import { applyAuthChoice, resolvePreferredProviderForAuthChoice } from "./auth-choice.js"; import type { AuthChoice } from "./onboard-types.js"; +import { applyAuthChoice, resolvePreferredProviderForAuthChoice } from "./auth-choice.js"; vi.mock("../providers/github-copilot-auth.js", () => ({ githubCopilotLoginCommand: vi.fn(async () => {}), diff --git a/src/commands/channels.adds-non-default-telegram-account.test.ts b/src/commands/channels.adds-non-default-telegram-account.test.ts index 66e603a7598..a9539141be0 100644 --- a/src/commands/channels.adds-non-default-telegram-account.test.ts +++ b/src/commands/channels.adds-non-default-telegram-account.test.ts @@ -1,14 +1,13 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { RuntimeEnv } from "../runtime.js"; -import { setActivePluginRegistry } from "../plugins/runtime.js"; -import { createTestRegistry } from "../test-utils/channel-plugins.js"; import { discordPlugin } from "../../extensions/discord/src/channel.js"; import { imessagePlugin } from "../../extensions/imessage/src/channel.js"; import { signalPlugin } from "../../extensions/signal/src/channel.js"; import { slackPlugin } from "../../extensions/slack/src/channel.js"; import { telegramPlugin } from "../../extensions/telegram/src/channel.js"; import { whatsappPlugin } from "../../extensions/whatsapp/src/channel.js"; +import { setActivePluginRegistry } from "../plugins/runtime.js"; +import { createTestRegistry } from "../test-utils/channel-plugins.js"; const configMocks = vi.hoisted(() => ({ readConfigFileSnapshot: vi.fn(), diff --git a/src/commands/channels.surfaces-signal-runtime-errors-channels-status-output.test.ts b/src/commands/channels.surfaces-signal-runtime-errors-channels-status-output.test.ts index 268393df9b9..0b4af8bd3d4 100644 --- a/src/commands/channels.surfaces-signal-runtime-errors-channels-status-output.test.ts +++ b/src/commands/channels.surfaces-signal-runtime-errors-channels-status-output.test.ts @@ -1,9 +1,8 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import type { RuntimeEnv } from "../runtime.js"; +import { signalPlugin } from "../../extensions/signal/src/channel.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import { createIMessageTestPlugin, createTestRegistry } from "../test-utils/channel-plugins.js"; -import { signalPlugin } from "../../extensions/signal/src/channel.js"; const configMocks = vi.hoisted(() => ({ readConfigFileSnapshot: vi.fn(), diff --git a/src/commands/channels/add-mutators.ts b/src/commands/channels/add-mutators.ts index 1ec280cfc19..b081ed33122 100644 --- a/src/commands/channels/add-mutators.ts +++ b/src/commands/channels/add-mutators.ts @@ -1,6 +1,6 @@ -import { getChannelPlugin } from "../../channels/plugins/index.js"; import type { ChannelId, ChannelSetupInput } from "../../channels/plugins/types.js"; import type { OpenClawConfig } from "../../config/config.js"; +import { getChannelPlugin } from "../../channels/plugins/index.js"; import { normalizeAccountId } from "../../routing/session-key.js"; type ChatChannel = ChannelId; diff --git a/src/commands/channels/add.ts b/src/commands/channels/add.ts index 524f86ceee8..89e44a015f8 100644 --- a/src/commands/channels/add.ts +++ b/src/commands/channels/add.ts @@ -1,13 +1,13 @@ +import type { ChannelId } from "../../channels/plugins/types.js"; +import type { ChannelChoice } from "../onboard-types.js"; import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../../agents/agent-scope.js"; import { listChannelPluginCatalogEntries } from "../../channels/plugins/catalog.js"; import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js"; -import type { ChannelId } from "../../channels/plugins/types.js"; import { writeConfigFile, type OpenClawConfig } from "../../config/config.js"; import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../routing/session-key.js"; import { defaultRuntime, type RuntimeEnv } from "../../runtime.js"; import { createClackPrompter } from "../../wizard/clack-prompter.js"; import { setupChannels } from "../onboard-channels.js"; -import type { ChannelChoice } from "../onboard-types.js"; import { ensureOnboardingPluginInstalled, reloadOnboardingPluginRegistry, diff --git a/src/commands/channels/capabilities.test.ts b/src/commands/channels/capabilities.test.ts index 68d3073e53f..0112a62e7df 100644 --- a/src/commands/channels/capabilities.test.ts +++ b/src/commands/channels/capabilities.test.ts @@ -1,11 +1,10 @@ process.env.NO_COLOR = "1"; import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { ChannelPlugin } from "../../channels/plugins/types.js"; -import { channelsCapabilitiesCommand } from "./capabilities.js"; -import { fetchSlackScopes } from "../../slack/scopes.js"; import { getChannelPlugin, listChannelPlugins } from "../../channels/plugins/index.js"; +import { fetchSlackScopes } from "../../slack/scopes.js"; +import { channelsCapabilitiesCommand } from "./capabilities.js"; const logs: string[] = []; const errors: string[] = []; diff --git a/src/commands/channels/capabilities.ts b/src/commands/channels/capabilities.ts index 968108ac1c0..86df7333720 100644 --- a/src/commands/channels/capabilities.ts +++ b/src/commands/channels/capabilities.ts @@ -1,10 +1,10 @@ -import { getChannelPlugin, listChannelPlugins } from "../../channels/plugins/index.js"; -import { resolveChannelDefaultAccountId } from "../../channels/plugins/helpers.js"; import type { ChannelCapabilities, ChannelPlugin } from "../../channels/plugins/types.js"; +import type { OpenClawConfig } from "../../config/config.js"; +import { resolveChannelDefaultAccountId } from "../../channels/plugins/helpers.js"; +import { getChannelPlugin, listChannelPlugins } from "../../channels/plugins/index.js"; import { fetchChannelPermissionsDiscord } from "../../discord/send.js"; import { parseDiscordTarget } from "../../discord/targets.js"; import { danger } from "../../globals.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { defaultRuntime, type RuntimeEnv } from "../../runtime.js"; import { fetchSlackScopes, type SlackScopesResult } from "../../slack/scopes.js"; import { theme } from "../../terminal/theme.js"; diff --git a/src/commands/channels/list.ts b/src/commands/channels/list.ts index 06caefb3d98..5c589479b8b 100644 --- a/src/commands/channels/list.ts +++ b/src/commands/channels/list.ts @@ -1,7 +1,7 @@ +import type { ChannelAccountSnapshot, ChannelPlugin } from "../../channels/plugins/types.js"; import { loadAuthProfileStore } from "../../agents/auth-profiles.js"; import { listChannelPlugins } from "../../channels/plugins/index.js"; import { buildChannelAccountSnapshot } from "../../channels/plugins/status.js"; -import type { ChannelAccountSnapshot, ChannelPlugin } from "../../channels/plugins/types.js"; import { withProgress } from "../../cli/progress.js"; import { formatUsageReportLines, loadProviderUsageSummary } from "../../infra/provider-usage.js"; import { defaultRuntime, type RuntimeEnv } from "../../runtime.js"; diff --git a/src/commands/channels/logs.ts b/src/commands/channels/logs.ts index 4a910efd40e..2682f170e49 100644 --- a/src/commands/channels/logs.ts +++ b/src/commands/channels/logs.ts @@ -1,7 +1,7 @@ import fs from "node:fs/promises"; import { listChannelPlugins } from "../../channels/plugins/index.js"; -import { parseLogLine } from "../../logging/parse-log-line.js"; import { getResolvedLoggerSettings } from "../../logging.js"; +import { parseLogLine } from "../../logging/parse-log-line.js"; import { defaultRuntime, type RuntimeEnv } from "../../runtime.js"; import { theme } from "../../terminal/theme.js"; diff --git a/src/commands/channels/resolve.ts b/src/commands/channels/resolve.ts index 9bcd633a0ec..0891a56ef5d 100644 --- a/src/commands/channels/resolve.ts +++ b/src/commands/channels/resolve.ts @@ -1,9 +1,9 @@ +import type { ChannelResolveKind, ChannelResolveResult } from "../../channels/plugins/types.js"; +import type { RuntimeEnv } from "../../runtime.js"; +import { getChannelPlugin } from "../../channels/plugins/index.js"; import { loadConfig } from "../../config/config.js"; import { danger } from "../../globals.js"; -import { getChannelPlugin } from "../../channels/plugins/index.js"; -import type { ChannelResolveKind, ChannelResolveResult } from "../../channels/plugins/types.js"; import { resolveMessageChannelSelection } from "../../infra/outbound/channel-selection.js"; -import type { RuntimeEnv } from "../../runtime.js"; export type ChannelsResolveOptions = { channel?: string; diff --git a/src/commands/channels/status.ts b/src/commands/channels/status.ts index e6855cbf066..145187c141a 100644 --- a/src/commands/channels/status.ts +++ b/src/commands/channels/status.ts @@ -1,6 +1,7 @@ +import type { ChannelAccountSnapshot } from "../../channels/plugins/types.js"; import { listChannelPlugins } from "../../channels/plugins/index.js"; import { buildChannelAccountSnapshot } from "../../channels/plugins/status.js"; -import type { ChannelAccountSnapshot } from "../../channels/plugins/types.js"; +import { formatCliCommand } from "../../cli/command-format.js"; import { withProgress } from "../../cli/progress.js"; import { type OpenClawConfig, readConfigFileSnapshot } from "../../config/config.js"; import { callGateway } from "../../gateway/call.js"; @@ -8,7 +9,6 @@ import { formatAge } from "../../infra/channel-summary.js"; import { collectChannelStatusIssues } from "../../infra/channels-status-issues.js"; import { defaultRuntime, type RuntimeEnv } from "../../runtime.js"; import { formatDocsLink } from "../../terminal/links.js"; -import { formatCliCommand } from "../../cli/command-format.js"; import { theme } from "../../terminal/theme.js"; import { type ChatChannel, formatChannelAccountLabel, requireValidConfig } from "./shared.js"; diff --git a/src/commands/chutes-oauth.test.ts b/src/commands/chutes-oauth.test.ts index 0d94d1c4dce..9a0e49d0f6c 100644 --- a/src/commands/chutes-oauth.test.ts +++ b/src/commands/chutes-oauth.test.ts @@ -1,7 +1,5 @@ import net from "node:net"; - import { describe, expect, it, vi } from "vitest"; - import { CHUTES_TOKEN_ENDPOINT, CHUTES_USERINFO_ENDPOINT } from "../agents/chutes-oauth.js"; import { loginChutes } from "./chutes-oauth.js"; diff --git a/src/commands/chutes-oauth.ts b/src/commands/chutes-oauth.ts index 5e98e057216..91f56fd51ba 100644 --- a/src/commands/chutes-oauth.ts +++ b/src/commands/chutes-oauth.ts @@ -1,8 +1,6 @@ +import type { OAuthCredentials } from "@mariozechner/pi-ai"; import { randomBytes } from "node:crypto"; import { createServer } from "node:http"; - -import type { OAuthCredentials } from "@mariozechner/pi-ai"; - import type { ChutesOAuthAppConfig } from "../agents/chutes-oauth.js"; import { CHUTES_AUTHORIZE_ENDPOINT, diff --git a/src/commands/cleanup-utils.ts b/src/commands/cleanup-utils.ts index f4d235fac7d..a1c8dbb7c50 100644 --- a/src/commands/cleanup-utils.ts +++ b/src/commands/cleanup-utils.ts @@ -1,9 +1,8 @@ import fs from "node:fs/promises"; import path from "node:path"; - -import { resolveDefaultAgentWorkspaceDir } from "../agents/workspace.js"; import type { OpenClawConfig } from "../config/config.js"; import type { RuntimeEnv } from "../runtime.js"; +import { resolveDefaultAgentWorkspaceDir } from "../agents/workspace.js"; import { resolveHomeDir, resolveUserPath, shortenHomeInString } from "../utils.js"; export type RemovalResult = { diff --git a/src/commands/configure.channels.ts b/src/commands/configure.channels.ts index 7170fa88eb0..8829b15738e 100644 --- a/src/commands/configure.channels.ts +++ b/src/commands/configure.channels.ts @@ -1,8 +1,8 @@ +import type { OpenClawConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; import { getChannelPlugin, listChannelPlugins } from "../channels/plugins/index.js"; import { formatCliCommand } from "../cli/command-format.js"; -import type { OpenClawConfig } from "../config/config.js"; import { CONFIG_PATH } from "../config/config.js"; -import type { RuntimeEnv } from "../runtime.js"; import { note } from "../terminal/note.js"; import { shortenHomePath } from "../utils.js"; import { confirm, select } from "./configure.shared.js"; diff --git a/src/commands/configure.commands.ts b/src/commands/configure.commands.ts index 991c7c1178f..e519a7d45e9 100644 --- a/src/commands/configure.commands.ts +++ b/src/commands/configure.commands.ts @@ -1,6 +1,6 @@ import type { RuntimeEnv } from "../runtime.js"; -import { defaultRuntime } from "../runtime.js"; import type { WizardSection } from "./configure.shared.js"; +import { defaultRuntime } from "../runtime.js"; import { runConfigureWizard } from "./configure.wizard.js"; export async function configureCommand(runtime: RuntimeEnv = defaultRuntime) { diff --git a/src/commands/configure.daemon.ts b/src/commands/configure.daemon.ts index 3cf45b66e78..b6cc7960516 100644 --- a/src/commands/configure.daemon.ts +++ b/src/commands/configure.daemon.ts @@ -1,9 +1,10 @@ -import { buildGatewayInstallPlan, gatewayInstallErrorHint } from "./daemon-install-helpers.js"; -import { resolveGatewayService } from "../daemon/service.js"; -import { withProgress } from "../cli/progress.js"; import type { RuntimeEnv } from "../runtime.js"; +import { withProgress } from "../cli/progress.js"; +import { loadConfig } from "../config/config.js"; +import { resolveGatewayService } from "../daemon/service.js"; import { note } from "../terminal/note.js"; import { confirm, select } from "./configure.shared.js"; +import { buildGatewayInstallPlan, gatewayInstallErrorHint } from "./daemon-install-helpers.js"; import { DEFAULT_GATEWAY_DAEMON_RUNTIME, GATEWAY_DAEMON_RUNTIME_OPTIONS, @@ -11,7 +12,6 @@ import { } from "./daemon-runtime.js"; import { guardCancel } from "./onboard-helpers.js"; import { ensureSystemdUserLingerInteractive } from "./systemd-linger.js"; -import { loadConfig } from "../config/config.js"; export async function maybeInstallDaemon(params: { runtime: RuntimeEnv; diff --git a/src/commands/configure.gateway-auth.test.ts b/src/commands/configure.gateway-auth.test.ts index 26a3729f2d5..50c6635778e 100644 --- a/src/commands/configure.gateway-auth.test.ts +++ b/src/commands/configure.gateway-auth.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { buildGatewayAuthConfig } from "./configure.js"; describe("buildGatewayAuthConfig", () => { diff --git a/src/commands/configure.gateway-auth.ts b/src/commands/configure.gateway-auth.ts index 01ac0d9a0d1..f99499b20bd 100644 --- a/src/commands/configure.gateway-auth.ts +++ b/src/commands/configure.gateway-auth.ts @@ -1,9 +1,9 @@ -import { ensureAuthProfileStore } from "../agents/auth-profiles.js"; import type { OpenClawConfig, GatewayAuthConfig } from "../config/config.js"; import type { RuntimeEnv } from "../runtime.js"; import type { WizardPrompter } from "../wizard/prompts.js"; -import { applyAuthChoice, resolvePreferredProviderForAuthChoice } from "./auth-choice.js"; +import { ensureAuthProfileStore } from "../agents/auth-profiles.js"; import { promptAuthChoiceGrouped } from "./auth-choice-prompt.js"; +import { applyAuthChoice, resolvePreferredProviderForAuthChoice } from "./auth-choice.js"; import { applyModelAllowlist, applyModelFallbacksFromSelection, diff --git a/src/commands/configure.gateway.test.ts b/src/commands/configure.gateway.test.ts index b2d2257d5b5..b22f4668bf2 100644 --- a/src/commands/configure.gateway.test.ts +++ b/src/commands/configure.gateway.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { RuntimeEnv } from "../runtime.js"; const mocks = vi.hoisted(() => ({ diff --git a/src/commands/configure.gateway.ts b/src/commands/configure.gateway.ts index 398321c6053..6e92a94a089 100644 --- a/src/commands/configure.gateway.ts +++ b/src/commands/configure.gateway.ts @@ -1,7 +1,7 @@ import type { OpenClawConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; import { resolveGatewayPort } from "../config/config.js"; import { findTailscaleBinary } from "../infra/tailscale.js"; -import type { RuntimeEnv } from "../runtime.js"; import { note } from "../terminal/note.js"; import { buildGatewayAuthConfig } from "./configure.gateway-auth.js"; import { confirm, select, text } from "./configure.shared.js"; diff --git a/src/commands/configure.shared.ts b/src/commands/configure.shared.ts index bc89529d8ca..9377c06f4bb 100644 --- a/src/commands/configure.shared.ts +++ b/src/commands/configure.shared.ts @@ -5,7 +5,6 @@ import { select as clackSelect, text as clackText, } from "@clack/prompts"; - import { stylePromptHint, stylePromptMessage, stylePromptTitle } from "../terminal/prompt-style.js"; export const CONFIGURE_WIZARD_SECTIONS = [ diff --git a/src/commands/configure.wizard.test.ts b/src/commands/configure.wizard.test.ts index 0bc2290b79a..a3f8ffd4d1e 100644 --- a/src/commands/configure.wizard.test.ts +++ b/src/commands/configure.wizard.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; const mocks = vi.hoisted(() => ({ diff --git a/src/commands/configure.wizard.ts b/src/commands/configure.wizard.ts index 3182fe17b43..8f9ff2fc9fb 100644 --- a/src/commands/configure.wizard.ts +++ b/src/commands/configure.wizard.ts @@ -1,9 +1,14 @@ -import { formatCliCommand } from "../cli/command-format.js"; import type { OpenClawConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; +import type { + ChannelsWizardMode, + ConfigureWizardParams, + WizardSection, +} from "./configure.shared.js"; +import { formatCliCommand } from "../cli/command-format.js"; import { readConfigFileSnapshot, resolveGatewayPort, writeConfigFile } from "../config/config.js"; import { logConfigUpdated } from "../config/logging.js"; import { ensureControlUiAssetsBuilt } from "../infra/control-ui-assets.js"; -import type { RuntimeEnv } from "../runtime.js"; import { defaultRuntime } from "../runtime.js"; import { note } from "../terminal/note.js"; import { resolveUserPath } from "../utils.js"; @@ -11,13 +16,8 @@ import { createClackPrompter } from "../wizard/clack-prompter.js"; import { WizardCancelledError } from "../wizard/prompts.js"; import { removeChannelConfigWizard } from "./configure.channels.js"; import { maybeInstallDaemon } from "./configure.daemon.js"; -import { promptGatewayConfig } from "./configure.gateway.js"; import { promptAuthConfig } from "./configure.gateway-auth.js"; -import type { - ChannelsWizardMode, - ConfigureWizardParams, - WizardSection, -} from "./configure.shared.js"; +import { promptGatewayConfig } from "./configure.gateway.js"; import { CONFIGURE_SECTION_OPTIONS, confirm, @@ -26,8 +26,8 @@ import { select, text, } from "./configure.shared.js"; -import { healthCommand } from "./health.js"; import { formatHealthCheckFailure } from "./health-format.js"; +import { healthCommand } from "./health.js"; import { noteChannelStatus, setupChannels } from "./onboard-channels.js"; import { applyWizardMetadata, diff --git a/src/commands/daemon-install-helpers.ts b/src/commands/daemon-install-helpers.ts index 6584671423c..6a6df53fa2f 100644 --- a/src/commands/daemon-install-helpers.ts +++ b/src/commands/daemon-install-helpers.ts @@ -1,3 +1,7 @@ +import type { OpenClawConfig } from "../config/types.js"; +import type { GatewayDaemonRuntime } from "./daemon-runtime.js"; +import { formatCliCommand } from "../cli/command-format.js"; +import { collectConfigEnvVars } from "../config/env-vars.js"; import { resolveGatewayLaunchAgentLabel } from "../daemon/constants.js"; import { resolveGatewayProgramArguments } from "../daemon/program-args.js"; import { @@ -6,10 +10,6 @@ import { resolveSystemNodeInfo, } from "../daemon/runtime-paths.js"; import { buildServiceEnvironment } from "../daemon/service-env.js"; -import { formatCliCommand } from "../cli/command-format.js"; -import { collectConfigEnvVars } from "../config/env-vars.js"; -import type { OpenClawConfig } from "../config/types.js"; -import type { GatewayDaemonRuntime } from "./daemon-runtime.js"; type WarnFn = (message: string, title?: string) => void; diff --git a/src/commands/dashboard.test.ts b/src/commands/dashboard.test.ts index 062dd26ac5d..7e50a459e7e 100644 --- a/src/commands/dashboard.test.ts +++ b/src/commands/dashboard.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import { dashboardCommand } from "./dashboard.js"; const mocks = vi.hoisted(() => ({ diff --git a/src/commands/dashboard.ts b/src/commands/dashboard.ts index 19efccc2c5c..bd47237df24 100644 --- a/src/commands/dashboard.ts +++ b/src/commands/dashboard.ts @@ -1,6 +1,6 @@ +import type { RuntimeEnv } from "../runtime.js"; import { readConfigFileSnapshot, resolveGatewayPort } from "../config/config.js"; import { copyToClipboard } from "../infra/clipboard.js"; -import type { RuntimeEnv } from "../runtime.js"; import { defaultRuntime } from "../runtime.js"; import { detectBrowserOpenSupport, diff --git a/src/commands/docs.ts b/src/commands/docs.ts index b72498e4662..20509fc5929 100644 --- a/src/commands/docs.ts +++ b/src/commands/docs.ts @@ -1,9 +1,9 @@ -import { hasBinary } from "../agents/skills.js"; -import { runCommandWithTimeout } from "../process/exec.js"; import type { RuntimeEnv } from "../runtime.js"; +import { hasBinary } from "../agents/skills.js"; +import { formatCliCommand } from "../cli/command-format.js"; +import { runCommandWithTimeout } from "../process/exec.js"; import { formatDocsLink } from "../terminal/links.js"; import { isRich, theme } from "../terminal/theme.js"; -import { formatCliCommand } from "../cli/command-format.js"; const SEARCH_TOOL = "https://docs.openclaw.ai/mcp.SearchOpenClaw"; const SEARCH_TIMEOUT_MS = 30_000; diff --git a/src/commands/doctor-auth.deprecated-cli-profiles.test.ts b/src/commands/doctor-auth.deprecated-cli-profiles.test.ts index 38d01e8bab7..170becdca01 100644 --- a/src/commands/doctor-auth.deprecated-cli-profiles.test.ts +++ b/src/commands/doctor-auth.deprecated-cli-profiles.test.ts @@ -1,11 +1,9 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - -import { maybeRemoveDeprecatedCliAuthProfiles } from "./doctor-auth.js"; import type { DoctorPrompter } from "./doctor-prompter.js"; +import { maybeRemoveDeprecatedCliAuthProfiles } from "./doctor-auth.js"; let originalAgentDir: string | undefined; let originalPiAgentDir: string | undefined; diff --git a/src/commands/doctor-auth.ts b/src/commands/doctor-auth.ts index c735c350cde..c3eb7399ce9 100644 --- a/src/commands/doctor-auth.ts +++ b/src/commands/doctor-auth.ts @@ -1,3 +1,5 @@ +import type { OpenClawConfig } from "../config/config.js"; +import type { DoctorPrompter } from "./doctor-prompter.js"; import { buildAuthHealthSummary, DEFAULT_OAUTH_WARN_MS, @@ -12,10 +14,8 @@ import { resolveProfileUnusableUntilForDisplay, } from "../agents/auth-profiles.js"; import { updateAuthProfileStoreWithLock } from "../agents/auth-profiles/store.js"; -import type { OpenClawConfig } from "../config/config.js"; -import { note } from "../terminal/note.js"; import { formatCliCommand } from "../cli/command-format.js"; -import type { DoctorPrompter } from "./doctor-prompter.js"; +import { note } from "../terminal/note.js"; export async function maybeRepairAnthropicOAuthProfileId( cfg: OpenClawConfig, diff --git a/src/commands/doctor-config-flow.test.ts b/src/commands/doctor-config-flow.test.ts index 6d775f6f14f..548a77f9ff4 100644 --- a/src/commands/doctor-config-flow.test.ts +++ b/src/commands/doctor-config-flow.test.ts @@ -1,8 +1,6 @@ import fs from "node:fs/promises"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import { withTempHome } from "../../test/helpers/temp-home.js"; import { loadAndMaybeMigrateDoctorConfig } from "./doctor-config-flow.js"; diff --git a/src/commands/doctor-config-flow.ts b/src/commands/doctor-config-flow.ts index 516bba716c9..fa53910df40 100644 --- a/src/commands/doctor-config-flow.ts +++ b/src/commands/doctor-config-flow.ts @@ -1,9 +1,9 @@ +import type { ZodIssue } from "zod"; import fs from "node:fs/promises"; import path from "node:path"; - -import type { ZodIssue } from "zod"; - import type { OpenClawConfig } from "../config/config.js"; +import type { DoctorOptions } from "./doctor-prompter.js"; +import { formatCliCommand } from "../cli/command-format.js"; import { OpenClawSchema, CONFIG_PATH, @@ -11,12 +11,10 @@ import { readConfigFileSnapshot, } from "../config/config.js"; import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js"; -import { formatCliCommand } from "../cli/command-format.js"; import { note } from "../terminal/note.js"; -import { normalizeLegacyConfigValues } from "./doctor-legacy-config.js"; -import type { DoctorOptions } from "./doctor-prompter.js"; -import { autoMigrateLegacyStateDir } from "./doctor-state-migrations.js"; import { resolveHomeDir } from "../utils.js"; +import { normalizeLegacyConfigValues } from "./doctor-legacy-config.js"; +import { autoMigrateLegacyStateDir } from "./doctor-state-migrations.js"; function isRecord(value: unknown): value is Record { return Boolean(value && typeof value === "object" && !Array.isArray(value)); diff --git a/src/commands/doctor-format.ts b/src/commands/doctor-format.ts index 6eecd7f7cb7..a99a155aa21 100644 --- a/src/commands/doctor-format.ts +++ b/src/commands/doctor-format.ts @@ -1,3 +1,5 @@ +import type { GatewayServiceRuntime } from "../daemon/service-runtime.js"; +import { formatCliCommand } from "../cli/command-format.js"; import { resolveGatewayLaunchAgentLabel, resolveGatewaySystemdServiceName, @@ -8,9 +10,7 @@ import { isSystemdUnavailableDetail, renderSystemdUnavailableHints, } from "../daemon/systemd-hints.js"; -import { formatCliCommand } from "../cli/command-format.js"; import { isWSLEnv } from "../infra/wsl.js"; -import type { GatewayServiceRuntime } from "../daemon/service-runtime.js"; import { getResolvedLoggerSettings } from "../logging.js"; type RuntimeHintOptions = { diff --git a/src/commands/doctor-gateway-daemon-flow.ts b/src/commands/doctor-gateway-daemon-flow.ts index e859903dddb..46007942832 100644 --- a/src/commands/doctor-gateway-daemon-flow.ts +++ b/src/commands/doctor-gateway-daemon-flow.ts @@ -1,4 +1,7 @@ import type { OpenClawConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; +import type { DoctorOptions, DoctorPrompter } from "./doctor-prompter.js"; +import { formatCliCommand } from "../cli/command-format.js"; import { resolveGatewayPort } from "../config/config.js"; import { resolveGatewayLaunchAgentLabel, @@ -12,24 +15,21 @@ import { repairLaunchAgentBootstrap, } from "../daemon/launchd.js"; import { resolveGatewayService } from "../daemon/service.js"; -import { isSystemdUserServiceAvailable } from "../daemon/systemd.js"; import { renderSystemdUnavailableHints } from "../daemon/systemd-hints.js"; +import { isSystemdUserServiceAvailable } from "../daemon/systemd.js"; import { formatPortDiagnostics, inspectPortUsage } from "../infra/ports.js"; import { isWSL } from "../infra/wsl.js"; -import type { RuntimeEnv } from "../runtime.js"; -import { formatCliCommand } from "../cli/command-format.js"; import { note } from "../terminal/note.js"; import { sleep } from "../utils.js"; +import { buildGatewayInstallPlan, gatewayInstallErrorHint } from "./daemon-install-helpers.js"; import { DEFAULT_GATEWAY_DAEMON_RUNTIME, GATEWAY_DAEMON_RUNTIME_OPTIONS, type GatewayDaemonRuntime, } from "./daemon-runtime.js"; -import { buildGatewayInstallPlan, gatewayInstallErrorHint } from "./daemon-install-helpers.js"; import { buildGatewayRuntimeHints, formatGatewayRuntimeSummary } from "./doctor-format.js"; -import type { DoctorOptions, DoctorPrompter } from "./doctor-prompter.js"; -import { healthCommand } from "./health.js"; import { formatHealthCheckFailure } from "./health-format.js"; +import { healthCommand } from "./health.js"; async function maybeRepairLaunchAgentBootstrap(params: { env: Record; diff --git a/src/commands/doctor-gateway-health.ts b/src/commands/doctor-gateway-health.ts index a8c83447b0d..e728f67a7fa 100644 --- a/src/commands/doctor-gateway-health.ts +++ b/src/commands/doctor-gateway-health.ts @@ -1,10 +1,10 @@ import type { OpenClawConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; import { buildGatewayConnectionDetails, callGateway } from "../gateway/call.js"; import { collectChannelStatusIssues } from "../infra/channels-status-issues.js"; -import type { RuntimeEnv } from "../runtime.js"; import { note } from "../terminal/note.js"; -import { healthCommand } from "./health.js"; import { formatHealthCheckFailure } from "./health-format.js"; +import { healthCommand } from "./health.js"; export async function checkGatewayHealth(params: { runtime: RuntimeEnv; diff --git a/src/commands/doctor-gateway-services.ts b/src/commands/doctor-gateway-services.ts index ac6b6af0be4..b2861681e93 100644 --- a/src/commands/doctor-gateway-services.ts +++ b/src/commands/doctor-gateway-services.ts @@ -3,22 +3,21 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { promisify } from "node:util"; - import type { OpenClawConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; +import type { DoctorOptions, DoctorPrompter } from "./doctor-prompter.js"; import { resolveGatewayPort, resolveIsNixMode } from "../config/paths.js"; import { findExtraGatewayServices, renderGatewayServiceCleanupHints } from "../daemon/inspect.js"; import { renderSystemNodeWarning, resolveSystemNodeInfo } from "../daemon/runtime-paths.js"; -import { resolveGatewayService } from "../daemon/service.js"; import { auditGatewayServiceConfig, needsNodeRuntimeMigration, SERVICE_AUDIT_CODES, } from "../daemon/service-audit.js"; -import type { RuntimeEnv } from "../runtime.js"; +import { resolveGatewayService } from "../daemon/service.js"; import { note } from "../terminal/note.js"; import { buildGatewayInstallPlan } from "./daemon-install-helpers.js"; import { DEFAULT_GATEWAY_DAEMON_RUNTIME, type GatewayDaemonRuntime } from "./daemon-runtime.js"; -import type { DoctorOptions, DoctorPrompter } from "./doctor-prompter.js"; const execFileAsync = promisify(execFile); diff --git a/src/commands/doctor-install.ts b/src/commands/doctor-install.ts index ca493c95bc9..4b83c61447e 100644 --- a/src/commands/doctor-install.ts +++ b/src/commands/doctor-install.ts @@ -1,6 +1,5 @@ import fs from "node:fs"; import path from "node:path"; - import { note } from "../terminal/note.js"; export function noteSourceInstallIssues(root: string | null) { diff --git a/src/commands/doctor-legacy-config.test.ts b/src/commands/doctor-legacy-config.test.ts index 23a9601755a..87db2a508b0 100644 --- a/src/commands/doctor-legacy-config.test.ts +++ b/src/commands/doctor-legacy-config.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it } from "vitest"; - import { normalizeLegacyConfigValues } from "./doctor-legacy-config.js"; describe("normalizeLegacyConfigValues", () => { diff --git a/src/commands/doctor-platform-notes.launchctl-env-overrides.test.ts b/src/commands/doctor-platform-notes.launchctl-env-overrides.test.ts index aea8f03b2f3..e88aff77511 100644 --- a/src/commands/doctor-platform-notes.launchctl-env-overrides.test.ts +++ b/src/commands/doctor-platform-notes.launchctl-env-overrides.test.ts @@ -1,7 +1,5 @@ -import type { OpenClawConfig } from "../config/config.js"; - import { describe, expect, it, vi } from "vitest"; - +import type { OpenClawConfig } from "../config/config.js"; import { noteMacLaunchctlGatewayEnvOverrides } from "./doctor-platform-notes.js"; describe("noteMacLaunchctlGatewayEnvOverrides", () => { diff --git a/src/commands/doctor-platform-notes.ts b/src/commands/doctor-platform-notes.ts index 940b80e8caa..8bfe94f8f4e 100644 --- a/src/commands/doctor-platform-notes.ts +++ b/src/commands/doctor-platform-notes.ts @@ -3,7 +3,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { promisify } from "node:util"; - import type { OpenClawConfig } from "../config/config.js"; import { note } from "../terminal/note.js"; import { shortenHomePath } from "../utils.js"; diff --git a/src/commands/doctor-prompter.ts b/src/commands/doctor-prompter.ts index e1cb27de8f8..0755fe8e3b8 100644 --- a/src/commands/doctor-prompter.ts +++ b/src/commands/doctor-prompter.ts @@ -1,5 +1,4 @@ import { confirm, select } from "@clack/prompts"; - import type { RuntimeEnv } from "../runtime.js"; import { stylePromptHint, stylePromptMessage } from "../terminal/prompt-style.js"; import { guardCancel } from "./onboard-helpers.js"; diff --git a/src/commands/doctor-sandbox.ts b/src/commands/doctor-sandbox.ts index d39b5353ec0..9d0e060c9c6 100644 --- a/src/commands/doctor-sandbox.ts +++ b/src/commands/doctor-sandbox.ts @@ -1,17 +1,16 @@ import fs from "node:fs"; import path from "node:path"; - +import type { OpenClawConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; +import type { DoctorPrompter } from "./doctor-prompter.js"; import { DEFAULT_SANDBOX_BROWSER_IMAGE, DEFAULT_SANDBOX_COMMON_IMAGE, DEFAULT_SANDBOX_IMAGE, resolveSandboxScope, } from "../agents/sandbox.js"; -import type { OpenClawConfig } from "../config/config.js"; import { runCommandWithTimeout, runExec } from "../process/exec.js"; -import type { RuntimeEnv } from "../runtime.js"; import { note } from "../terminal/note.js"; -import type { DoctorPrompter } from "./doctor-prompter.js"; type SandboxScriptInfo = { scriptPath: string; diff --git a/src/commands/doctor-security.test.ts b/src/commands/doctor-security.test.ts index 66a595b4029..f948f2617ad 100644 --- a/src/commands/doctor-security.test.ts +++ b/src/commands/doctor-security.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; const note = vi.hoisted(() => vi.fn()); diff --git a/src/commands/doctor-security.ts b/src/commands/doctor-security.ts index 5c7b8f0ef06..98156562114 100644 --- a/src/commands/doctor-security.ts +++ b/src/commands/doctor-security.ts @@ -1,12 +1,12 @@ -import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js"; -import { listChannelPlugins } from "../channels/plugins/index.js"; import type { ChannelId } from "../channels/plugins/types.js"; import type { OpenClawConfig, GatewayBindMode } from "../config/config.js"; -import { readChannelAllowFromStore } from "../pairing/pairing-store.js"; -import { note } from "../terminal/note.js"; +import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js"; +import { listChannelPlugins } from "../channels/plugins/index.js"; import { formatCliCommand } from "../cli/command-format.js"; import { resolveGatewayAuth } from "../gateway/auth.js"; import { isLoopbackHost, resolveGatewayBindHost } from "../gateway/net.js"; +import { readChannelAllowFromStore } from "../pairing/pairing-store.js"; +import { note } from "../terminal/note.js"; export async function noteSecurityWarnings(cfg: OpenClawConfig) { const warnings: string[] = []; diff --git a/src/commands/doctor-state-integrity.ts b/src/commands/doctor-state-integrity.ts index 20d58b09ea0..7637877b274 100644 --- a/src/commands/doctor-state-integrity.ts +++ b/src/commands/doctor-state-integrity.ts @@ -1,9 +1,8 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - -import { resolveDefaultAgentId } from "../agents/agent-scope.js"; import type { OpenClawConfig } from "../config/config.js"; +import { resolveDefaultAgentId } from "../agents/agent-scope.js"; import { resolveOAuthDir, resolveStateDir } from "../config/paths.js"; import { loadSessionStore, diff --git a/src/commands/doctor-state-migrations.test.ts b/src/commands/doctor-state-migrations.test.ts index e9fe16f1ba1..ed89975c9c7 100644 --- a/src/commands/doctor-state-migrations.test.ts +++ b/src/commands/doctor-state-migrations.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import { afterEach, describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { autoMigrateLegacyStateDir, diff --git a/src/commands/doctor-ui.ts b/src/commands/doctor-ui.ts index 92c61252884..718ed4a8f61 100644 --- a/src/commands/doctor-ui.ts +++ b/src/commands/doctor-ui.ts @@ -1,10 +1,10 @@ import fs from "node:fs/promises"; import path from "node:path"; +import type { RuntimeEnv } from "../runtime.js"; +import type { DoctorPrompter } from "./doctor-prompter.js"; import { resolveOpenClawPackageRoot } from "../infra/openclaw-root.js"; import { runCommandWithTimeout } from "../process/exec.js"; -import type { RuntimeEnv } from "../runtime.js"; import { note } from "../terminal/note.js"; -import type { DoctorPrompter } from "./doctor-prompter.js"; export async function maybeRepairUiProtocolFreshness( _runtime: RuntimeEnv, diff --git a/src/commands/doctor-update.ts b/src/commands/doctor-update.ts index ad62ec4b6c3..e0beaa77434 100644 --- a/src/commands/doctor-update.ts +++ b/src/commands/doctor-update.ts @@ -1,10 +1,10 @@ -import { runGatewayUpdate } from "../infra/update-runner.js"; -import { isTruthyEnvValue } from "../infra/env.js"; -import { runCommandWithTimeout } from "../process/exec.js"; import type { RuntimeEnv } from "../runtime.js"; -import { note } from "../terminal/note.js"; -import { formatCliCommand } from "../cli/command-format.js"; import type { DoctorOptions } from "./doctor-prompter.js"; +import { formatCliCommand } from "../cli/command-format.js"; +import { isTruthyEnvValue } from "../infra/env.js"; +import { runGatewayUpdate } from "../infra/update-runner.js"; +import { runCommandWithTimeout } from "../process/exec.js"; +import { note } from "../terminal/note.js"; async function detectOpenClawGitCheckout(root: string): Promise<"git" | "not-git" | "unknown"> { const res = await runCommandWithTimeout(["git", "-C", root, "rev-parse", "--show-toplevel"], { diff --git a/src/commands/doctor-workspace-status.ts b/src/commands/doctor-workspace-status.ts index 34cffe18092..9830d5a7f7c 100644 --- a/src/commands/doctor-workspace-status.ts +++ b/src/commands/doctor-workspace-status.ts @@ -1,6 +1,6 @@ +import type { OpenClawConfig } from "../config/config.js"; import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; import { buildWorkspaceSkillStatus } from "../agents/skills-status.js"; -import type { OpenClawConfig } from "../config/config.js"; import { loadOpenClawPlugins } from "../plugins/loader.js"; import { note } from "../terminal/note.js"; import { detectLegacyWorkspaceDirs, formatLegacyWorkspaceWarning } from "./doctor-workspace.js"; diff --git a/src/commands/doctor-workspace.test.ts b/src/commands/doctor-workspace.test.ts index 5f991ca79cc..fb0d46a56e8 100644 --- a/src/commands/doctor-workspace.test.ts +++ b/src/commands/doctor-workspace.test.ts @@ -1,6 +1,5 @@ import path from "node:path"; import { describe, expect, it } from "vitest"; - import { detectLegacyWorkspaceDirs } from "./doctor-workspace.js"; describe("detectLegacyWorkspaceDirs", () => { diff --git a/src/commands/doctor-workspace.ts b/src/commands/doctor-workspace.ts index fcc006b8d3d..6ac387a08ad 100644 --- a/src/commands/doctor-workspace.ts +++ b/src/commands/doctor-workspace.ts @@ -1,6 +1,5 @@ import fs from "node:fs"; import path from "node:path"; - import { DEFAULT_AGENTS_FILENAME } from "../agents/workspace.js"; import { shortenHomePath } from "../utils.js"; diff --git a/src/commands/doctor.ts b/src/commands/doctor.ts index 3933fe91b21..bee6db0217f 100644 --- a/src/commands/doctor.ts +++ b/src/commands/doctor.ts @@ -1,6 +1,7 @@ -import fs from "node:fs"; - import { intro as clackIntro, outro as clackOutro } from "@clack/prompts"; +import fs from "node:fs"; +import type { OpenClawConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js"; import { loadModelCatalog } from "../agents/model-catalog.js"; @@ -10,14 +11,12 @@ import { resolveHooksGmailModel, } from "../agents/model-selection.js"; import { formatCliCommand } from "../cli/command-format.js"; -import type { OpenClawConfig } from "../config/config.js"; import { CONFIG_PATH, readConfigFileSnapshot, writeConfigFile } from "../config/config.js"; import { logConfigUpdated } from "../config/logging.js"; import { resolveGatewayService } from "../daemon/service.js"; import { resolveGatewayAuth } from "../gateway/auth.js"; import { buildGatewayConnectionDetails } from "../gateway/call.js"; import { resolveOpenClawPackageRoot } from "../infra/openclaw-root.js"; -import type { RuntimeEnv } from "../runtime.js"; import { defaultRuntime } from "../runtime.js"; import { note } from "../terminal/note.js"; import { stylePromptTitle } from "../terminal/prompt-style.js"; @@ -50,8 +49,8 @@ import { } from "./doctor-state-migrations.js"; import { maybeRepairUiProtocolFreshness } from "./doctor-ui.js"; import { maybeOfferUpdateBeforeDoctor } from "./doctor-update.js"; -import { MEMORY_SYSTEM_PROMPT, shouldSuggestMemorySystem } from "./doctor-workspace.js"; import { noteWorkspaceStatus } from "./doctor-workspace-status.js"; +import { MEMORY_SYSTEM_PROMPT, shouldSuggestMemorySystem } from "./doctor-workspace.js"; import { applyWizardMetadata, printWizardHeader, randomToken } from "./onboard-helpers.js"; import { ensureSystemdUserLingerInteractive } from "./systemd-linger.js"; diff --git a/src/commands/gateway-status.ts b/src/commands/gateway-status.ts index d935d966e8b..9959642d6f8 100644 --- a/src/commands/gateway-status.ts +++ b/src/commands/gateway-status.ts @@ -1,13 +1,12 @@ +import type { RuntimeEnv } from "../runtime.js"; import { withProgress } from "../cli/progress.js"; import { loadConfig, resolveGatewayPort } from "../config/config.js"; import { probeGateway } from "../gateway/probe.js"; import { discoverGatewayBeacons } from "../infra/bonjour-discovery.js"; -import { resolveWideAreaDiscoveryDomain } from "../infra/widearea-dns.js"; import { resolveSshConfig } from "../infra/ssh-config.js"; import { parseSshTarget, startSshPortForward } from "../infra/ssh-tunnel.js"; -import type { RuntimeEnv } from "../runtime.js"; +import { resolveWideAreaDiscoveryDomain } from "../infra/widearea-dns.js"; import { colorize, isRich, theme } from "../terminal/theme.js"; - import { buildNetworkHints, extractConfigSummary, diff --git a/src/commands/gateway-status/helpers.ts b/src/commands/gateway-status/helpers.ts index 2181d006287..daf9ab7364b 100644 --- a/src/commands/gateway-status/helpers.ts +++ b/src/commands/gateway-status/helpers.ts @@ -1,6 +1,6 @@ -import { resolveGatewayPort } from "../../config/config.js"; import type { OpenClawConfig, ConfigFileSnapshot } from "../../config/types.js"; import type { GatewayProbeResult } from "../../gateway/probe.js"; +import { resolveGatewayPort } from "../../config/config.js"; import { pickPrimaryTailnetIPv4 } from "../../infra/tailnet.js"; import { colorize, theme } from "../../terminal/theme.js"; diff --git a/src/commands/google-gemini-model-default.test.ts b/src/commands/google-gemini-model-default.test.ts index 3107730f273..82df89bc785 100644 --- a/src/commands/google-gemini-model-default.test.ts +++ b/src/commands/google-gemini-model-default.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { applyGoogleGeminiModelDefault, diff --git a/src/commands/health-format.test.ts b/src/commands/health-format.test.ts index a34abf73a81..bc3a732fd50 100644 --- a/src/commands/health-format.test.ts +++ b/src/commands/health-format.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { formatHealthCheckFailure } from "./health-format.js"; const ansiEscape = String.fromCharCode(27); diff --git a/src/commands/health.command.coverage.test.ts b/src/commands/health.command.coverage.test.ts index 996e75161aa..794f9adb586 100644 --- a/src/commands/health.command.coverage.test.ts +++ b/src/commands/health.command.coverage.test.ts @@ -1,10 +1,9 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { HealthSummary } from "./health.js"; -import { healthCommand } from "./health.js"; -import { stripAnsi } from "../terminal/ansi.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; +import { stripAnsi } from "../terminal/ansi.js"; import { createTestRegistry } from "../test-utils/channel-plugins.js"; +import { healthCommand } from "./health.js"; const callGatewayMock = vi.fn(); const logWebSelfIdMock = vi.fn(); diff --git a/src/commands/health.snapshot.test.ts b/src/commands/health.snapshot.test.ts index 734b4d39a13..ff94d695a7f 100644 --- a/src/commands/health.snapshot.test.ts +++ b/src/commands/health.snapshot.test.ts @@ -1,14 +1,12 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import type { HealthSummary } from "./health.js"; -import { getHealthSnapshot } from "./health.js"; +import { telegramPlugin } from "../../extensions/telegram/src/channel.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import { createTestRegistry } from "../test-utils/channel-plugins.js"; -import { telegramPlugin } from "../../extensions/telegram/src/channel.js"; +import { getHealthSnapshot } from "./health.js"; let testConfig: Record = {}; let testStore: Record = {}; diff --git a/src/commands/health.test.ts b/src/commands/health.test.ts index 0cea428bfc3..289af11bb79 100644 --- a/src/commands/health.test.ts +++ b/src/commands/health.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { HealthSummary } from "./health.js"; import { formatHealthChannelLines, healthCommand } from "./health.js"; diff --git a/src/commands/health.ts b/src/commands/health.ts index 8a54fabc207..99b3613ab38 100644 --- a/src/commands/health.ts +++ b/src/commands/health.ts @@ -1,20 +1,20 @@ +import type { ChannelAccountSnapshot } from "../channels/plugins/types.js"; +import type { OpenClawConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; import { resolveDefaultAgentId } from "../agents/agent-scope.js"; import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js"; import { getChannelPlugin, listChannelPlugins } from "../channels/plugins/index.js"; -import type { ChannelAccountSnapshot } from "../channels/plugins/types.js"; import { withProgress } from "../cli/progress.js"; -import type { OpenClawConfig } from "../config/config.js"; import { loadConfig } from "../config/config.js"; import { loadSessionStore, resolveStorePath } from "../config/sessions.js"; import { buildGatewayConnectionDetails, callGateway } from "../gateway/call.js"; import { info } from "../globals.js"; -import { formatErrorMessage } from "../infra/errors.js"; import { isTruthyEnvValue } from "../infra/env.js"; +import { formatErrorMessage } from "../infra/errors.js"; import { type HeartbeatSummary, resolveHeartbeatSummaryForAgent, } from "../infra/heartbeat-runner.js"; -import type { RuntimeEnv } from "../runtime.js"; import { buildChannelAccountBindings, resolvePreferredAccountId } from "../routing/bindings.js"; import { normalizeAgentId } from "../routing/session-key.js"; import { theme } from "../terminal/theme.js"; diff --git a/src/commands/message-format.ts b/src/commands/message-format.ts index 55547826904..2a9b51daeb1 100644 --- a/src/commands/message-format.ts +++ b/src/commands/message-format.ts @@ -1,9 +1,9 @@ -import { getChannelPlugin } from "../channels/plugins/index.js"; import type { ChannelId, ChannelMessageActionName } from "../channels/plugins/types.js"; import type { OutboundDeliveryResult } from "../infra/outbound/deliver.js"; +import type { MessageActionRunResult } from "../infra/outbound/message-action-runner.js"; +import { getChannelPlugin } from "../channels/plugins/index.js"; import { formatGatewaySummary, formatOutboundDeliverySummary } from "../infra/outbound/format.js"; import { formatTargetDisplay } from "../infra/outbound/target-resolver.js"; -import type { MessageActionRunResult } from "../infra/outbound/message-action-runner.js"; import { renderTable } from "../terminal/table.js"; import { isRich, theme } from "../terminal/theme.js"; diff --git a/src/commands/message.test.ts b/src/commands/message.test.ts index 1711a95a922..81d9269c43e 100644 --- a/src/commands/message.test.ts +++ b/src/commands/message.test.ts @@ -1,5 +1,4 @@ import { afterAll, beforeEach, describe, expect, it, vi } from "vitest"; - import type { ChannelMessageActionAdapter, ChannelOutboundAdapter, diff --git a/src/commands/message.ts b/src/commands/message.ts index caf7e6d63cd..d10733706e9 100644 --- a/src/commands/message.ts +++ b/src/commands/message.ts @@ -1,3 +1,5 @@ +import type { OutboundSendDeps } from "../infra/outbound/deliver.js"; +import type { RuntimeEnv } from "../runtime.js"; import { CHANNEL_MESSAGE_ACTION_NAMES, type ChannelMessageActionName, @@ -5,9 +7,7 @@ import { import { createOutboundSendDeps, type CliDeps } from "../cli/outbound-send-deps.js"; import { withProgress } from "../cli/progress.js"; import { loadConfig } from "../config/config.js"; -import type { OutboundSendDeps } from "../infra/outbound/deliver.js"; import { runMessageAction } from "../infra/outbound/message-action-runner.js"; -import type { RuntimeEnv } from "../runtime.js"; import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; import { buildMessageCliJson, formatMessageCliText } from "./message-format.js"; diff --git a/src/commands/model-picker.test.ts b/src/commands/model-picker.test.ts index 4b06dfd6f4f..692aa445a61 100644 --- a/src/commands/model-picker.test.ts +++ b/src/commands/model-picker.test.ts @@ -1,13 +1,12 @@ import { describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; -import { makePrompter } from "./onboarding/__tests__/test-utils.js"; import { applyModelAllowlist, applyModelFallbacksFromSelection, promptDefaultModel, promptModelAllowlist, } from "./model-picker.js"; +import { makePrompter } from "./onboarding/__tests__/test-utils.js"; const loadModelCatalog = vi.hoisted(() => vi.fn()); vi.mock("../agents/model-catalog.js", () => ({ diff --git a/src/commands/model-picker.ts b/src/commands/model-picker.ts index 83c4ad7f9ec..c0e0a3ea774 100644 --- a/src/commands/model-picker.ts +++ b/src/commands/model-picker.ts @@ -1,3 +1,5 @@ +import type { OpenClawConfig } from "../config/config.js"; +import type { WizardPrompter, WizardSelectOption } from "../wizard/prompts.js"; import { ensureAuthProfileStore, listProfilesForProvider } from "../agents/auth-profiles.js"; import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js"; import { getCustomProviderApiKey, resolveEnvApiKey } from "../agents/model-auth.js"; @@ -9,8 +11,6 @@ import { normalizeProviderId, resolveConfiguredModelRef, } from "../agents/model-selection.js"; -import type { OpenClawConfig } from "../config/config.js"; -import type { WizardPrompter, WizardSelectOption } from "../wizard/prompts.js"; import { formatTokenK } from "./models/shared.js"; const KEEP_VALUE = "__keep__"; diff --git a/src/commands/models/aliases.ts b/src/commands/models/aliases.ts index 5a84721d2d5..d719ee7bc4d 100644 --- a/src/commands/models/aliases.ts +++ b/src/commands/models/aliases.ts @@ -1,6 +1,6 @@ +import type { RuntimeEnv } from "../../runtime.js"; import { loadConfig } from "../../config/config.js"; import { logConfigUpdated } from "../../config/logging.js"; -import type { RuntimeEnv } from "../../runtime.js"; import { ensureFlagCompatibility, normalizeAlias, diff --git a/src/commands/models/auth-order.ts b/src/commands/models/auth-order.ts index 2e4611a08cb..b8f373eaaa3 100644 --- a/src/commands/models/auth-order.ts +++ b/src/commands/models/auth-order.ts @@ -1,3 +1,4 @@ +import type { RuntimeEnv } from "../../runtime.js"; import { resolveAgentDir, resolveDefaultAgentId } from "../../agents/agent-scope.js"; import { type AuthProfileStore, @@ -6,7 +7,6 @@ import { } from "../../agents/auth-profiles.js"; import { normalizeProviderId } from "../../agents/model-selection.js"; import { loadConfig } from "../../config/config.js"; -import type { RuntimeEnv } from "../../runtime.js"; import { shortenHomePath } from "../../utils.js"; import { resolveKnownAgentId } from "./shared.js"; diff --git a/src/commands/models/auth.ts b/src/commands/models/auth.ts index 060c7835c01..8f685d89881 100644 --- a/src/commands/models/auth.ts +++ b/src/commands/models/auth.ts @@ -1,33 +1,32 @@ import { confirm as clackConfirm, select as clackSelect, text as clackText } from "@clack/prompts"; - -import { upsertAuthProfile } from "../../agents/auth-profiles.js"; -import { normalizeProviderId } from "../../agents/model-selection.js"; -import { - resolveAgentDir, - resolveAgentWorkspaceDir, - resolveDefaultAgentId, -} from "../../agents/agent-scope.js"; -import { resolveDefaultAgentWorkspaceDir } from "../../agents/workspace.js"; -import { parseDurationMs } from "../../cli/parse-duration.js"; -import { formatCliCommand } from "../../cli/command-format.js"; -import { readConfigFileSnapshot, type OpenClawConfig } from "../../config/config.js"; -import { logConfigUpdated } from "../../config/logging.js"; -import type { RuntimeEnv } from "../../runtime.js"; -import { stylePromptHint, stylePromptMessage } from "../../terminal/prompt-style.js"; -import { applyAuthProfileConfig } from "../onboard-auth.js"; -import { isRemoteEnvironment } from "../oauth-env.js"; -import { openUrl } from "../onboard-helpers.js"; -import { createVpsAwareOAuthHandlers } from "../oauth-flow.js"; -import { updateConfig } from "./shared.js"; -import { resolvePluginProviders } from "../../plugins/providers.js"; -import { createClackPrompter } from "../../wizard/clack-prompter.js"; +import type { AuthProfileCredential } from "../../agents/auth-profiles/types.js"; import type { ProviderAuthMethod, ProviderAuthResult, ProviderPlugin, } from "../../plugins/types.js"; -import type { AuthProfileCredential } from "../../agents/auth-profiles/types.js"; +import type { RuntimeEnv } from "../../runtime.js"; +import { + resolveAgentDir, + resolveAgentWorkspaceDir, + resolveDefaultAgentId, +} from "../../agents/agent-scope.js"; +import { upsertAuthProfile } from "../../agents/auth-profiles.js"; +import { normalizeProviderId } from "../../agents/model-selection.js"; +import { resolveDefaultAgentWorkspaceDir } from "../../agents/workspace.js"; +import { formatCliCommand } from "../../cli/command-format.js"; +import { parseDurationMs } from "../../cli/parse-duration.js"; +import { readConfigFileSnapshot, type OpenClawConfig } from "../../config/config.js"; +import { logConfigUpdated } from "../../config/logging.js"; +import { resolvePluginProviders } from "../../plugins/providers.js"; +import { stylePromptHint, stylePromptMessage } from "../../terminal/prompt-style.js"; +import { createClackPrompter } from "../../wizard/clack-prompter.js"; import { validateAnthropicSetupToken } from "../auth-token.js"; +import { isRemoteEnvironment } from "../oauth-env.js"; +import { createVpsAwareOAuthHandlers } from "../oauth-flow.js"; +import { applyAuthProfileConfig } from "../onboard-auth.js"; +import { openUrl } from "../onboard-helpers.js"; +import { updateConfig } from "./shared.js"; const confirm = (params: Parameters[0]) => clackConfirm({ diff --git a/src/commands/models/fallbacks.ts b/src/commands/models/fallbacks.ts index 4311885b9e0..afd14667b21 100644 --- a/src/commands/models/fallbacks.ts +++ b/src/commands/models/fallbacks.ts @@ -1,7 +1,7 @@ +import type { RuntimeEnv } from "../../runtime.js"; import { buildModelAliasIndex, resolveModelRefFromString } from "../../agents/model-selection.js"; import { loadConfig } from "../../config/config.js"; import { logConfigUpdated } from "../../config/logging.js"; -import type { RuntimeEnv } from "../../runtime.js"; import { DEFAULT_PROVIDER, ensureFlagCompatibility, diff --git a/src/commands/models/image-fallbacks.ts b/src/commands/models/image-fallbacks.ts index 19a9d98fbcd..e4beb1adf26 100644 --- a/src/commands/models/image-fallbacks.ts +++ b/src/commands/models/image-fallbacks.ts @@ -1,7 +1,7 @@ +import type { RuntimeEnv } from "../../runtime.js"; import { buildModelAliasIndex, resolveModelRefFromString } from "../../agents/model-selection.js"; import { loadConfig } from "../../config/config.js"; import { logConfigUpdated } from "../../config/logging.js"; -import type { RuntimeEnv } from "../../runtime.js"; import { DEFAULT_PROVIDER, ensureFlagCompatibility, diff --git a/src/commands/models/list.auth-overview.ts b/src/commands/models/list.auth-overview.ts index 3a36d4bafcd..7bd4014e2be 100644 --- a/src/commands/models/list.auth-overview.ts +++ b/src/commands/models/list.auth-overview.ts @@ -1,3 +1,5 @@ +import type { OpenClawConfig } from "../../config/config.js"; +import type { ProviderAuthOverview } from "./list.types.js"; import { formatRemainingShort } from "../../agents/auth-health.js"; import { type AuthProfileStore, @@ -7,10 +9,8 @@ import { resolveProfileUnusableUntilForDisplay, } from "../../agents/auth-profiles.js"; import { getCustomProviderApiKey, resolveEnvApiKey } from "../../agents/model-auth.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { shortenHomePath } from "../../utils.js"; import { maskApiKey } from "./list.format.js"; -import type { ProviderAuthOverview } from "./list.types.js"; export function resolveProviderAuthOverview(params: { provider: string; diff --git a/src/commands/models/list.configured.ts b/src/commands/models/list.configured.ts index a4300ea563a..d2d3f76855d 100644 --- a/src/commands/models/list.configured.ts +++ b/src/commands/models/list.configured.ts @@ -1,11 +1,11 @@ +import type { OpenClawConfig } from "../../config/config.js"; +import type { ConfiguredEntry } from "./list.types.js"; import { buildModelAliasIndex, parseModelRef, resolveConfiguredModelRef, resolveModelRefFromString, } from "../../agents/model-selection.js"; -import type { OpenClawConfig } from "../../config/config.js"; -import type { ConfiguredEntry } from "./list.types.js"; import { DEFAULT_MODEL, DEFAULT_PROVIDER, modelKey } from "./shared.js"; export function resolveConfiguredEntries(cfg: OpenClawConfig) { diff --git a/src/commands/models/list.list-command.ts b/src/commands/models/list.list-command.ts index b7c30e1d66d..a5c5e987448 100644 --- a/src/commands/models/list.list-command.ts +++ b/src/commands/models/list.list-command.ts @@ -1,13 +1,12 @@ import type { Api, Model } from "@mariozechner/pi-ai"; - +import type { RuntimeEnv } from "../../runtime.js"; +import type { ModelRow } from "./list.types.js"; import { ensureAuthProfileStore } from "../../agents/auth-profiles.js"; import { parseModelRef } from "../../agents/model-selection.js"; import { loadConfig } from "../../config/config.js"; -import type { RuntimeEnv } from "../../runtime.js"; import { resolveConfiguredEntries } from "./list.configured.js"; import { loadModelRegistry, toModelRow } from "./list.registry.js"; import { printModelTable } from "./list.table.js"; -import type { ModelRow } from "./list.types.js"; import { DEFAULT_PROVIDER, ensureFlagCompatibility, modelKey } from "./shared.js"; export async function modelsListCommand( diff --git a/src/commands/models/list.probe.ts b/src/commands/models/list.probe.ts index ad3c1c4d498..ee7a874fe88 100644 --- a/src/commands/models/list.probe.ts +++ b/src/commands/models/list.probe.ts @@ -1,21 +1,20 @@ import crypto from "node:crypto"; import fs from "node:fs/promises"; - +import type { OpenClawConfig } from "../../config/config.js"; import { resolveOpenClawAgentDir } from "../../agents/agent-paths.js"; +import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../../agents/agent-scope.js"; import { ensureAuthProfileStore, listProfilesForProvider, resolveAuthProfileDisplayLabel, resolveAuthProfileOrder, } from "../../agents/auth-profiles.js"; -import { runEmbeddedPiAgent } from "../../agents/pi-embedded.js"; import { describeFailoverError } from "../../agents/failover-error.js"; -import { loadModelCatalog } from "../../agents/model-catalog.js"; import { getCustomProviderApiKey, resolveEnvApiKey } from "../../agents/model-auth.js"; +import { loadModelCatalog } from "../../agents/model-catalog.js"; import { normalizeProviderId, parseModelRef } from "../../agents/model-selection.js"; -import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../../agents/agent-scope.js"; +import { runEmbeddedPiAgent } from "../../agents/pi-embedded.js"; import { resolveDefaultAgentWorkspaceDir } from "../../agents/workspace.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { resolveSessionTranscriptPath, resolveSessionTranscriptsDirForAgent, diff --git a/src/commands/models/list.registry.ts b/src/commands/models/list.registry.ts index 3ca02d3127f..00f14643c4d 100644 --- a/src/commands/models/list.registry.ts +++ b/src/commands/models/list.registry.ts @@ -1,8 +1,8 @@ import type { Api, Model } from "@mariozechner/pi-ai"; -import { discoverAuthStorage, discoverModels } from "../../agents/pi-model-discovery.js"; - -import { resolveOpenClawAgentDir } from "../../agents/agent-paths.js"; import type { AuthProfileStore } from "../../agents/auth-profiles.js"; +import type { OpenClawConfig } from "../../config/config.js"; +import type { ModelRow } from "./list.types.js"; +import { resolveOpenClawAgentDir } from "../../agents/agent-paths.js"; import { listProfilesForProvider } from "../../agents/auth-profiles.js"; import { getCustomProviderApiKey, @@ -10,8 +10,7 @@ import { resolveEnvApiKey, } from "../../agents/model-auth.js"; import { ensureOpenClawModelsJson } from "../../agents/models-config.js"; -import type { OpenClawConfig } from "../../config/config.js"; -import type { ModelRow } from "./list.types.js"; +import { discoverAuthStorage, discoverModels } from "../../agents/pi-model-discovery.js"; import { modelKey } from "./shared.js"; const isLocalBaseUrl = (baseUrl: string) => { diff --git a/src/commands/models/list.status-command.ts b/src/commands/models/list.status-command.ts index ccb68eaf706..66f830b2f55 100644 --- a/src/commands/models/list.status-command.ts +++ b/src/commands/models/list.status-command.ts @@ -1,4 +1,5 @@ import path from "node:path"; +import type { RuntimeEnv } from "../../runtime.js"; import { resolveOpenClawAgentDir } from "../../agents/agent-paths.js"; import { resolveAgentDir, @@ -23,19 +24,18 @@ import { resolveDefaultModelForAgent, resolveModelRefFromString, } from "../../agents/model-selection.js"; -import { CONFIG_PATH, loadConfig } from "../../config/config.js"; -import { getShellEnvAppliedKeys, shouldEnableShellEnvFallback } from "../../infra/shell-env.js"; +import { formatCliCommand } from "../../cli/command-format.js"; import { withProgressTotals } from "../../cli/progress.js"; +import { CONFIG_PATH, loadConfig } from "../../config/config.js"; import { formatUsageWindowSummary, loadProviderUsageSummary, resolveUsageProviderId, type UsageProviderId, } from "../../infra/provider-usage.js"; -import type { RuntimeEnv } from "../../runtime.js"; -import { colorize, theme } from "../../terminal/theme.js"; +import { getShellEnvAppliedKeys, shouldEnableShellEnvFallback } from "../../infra/shell-env.js"; import { renderTable } from "../../terminal/table.js"; -import { formatCliCommand } from "../../cli/command-format.js"; +import { colorize, theme } from "../../terminal/theme.js"; import { shortenHomePath } from "../../utils.js"; import { resolveProviderAuthOverview } from "./list.auth-overview.js"; import { isRich } from "./list.format.js"; diff --git a/src/commands/models/list.table.ts b/src/commands/models/list.table.ts index 3211ce57b15..b8f52f0bea3 100644 --- a/src/commands/models/list.table.ts +++ b/src/commands/models/list.table.ts @@ -1,7 +1,7 @@ import type { RuntimeEnv } from "../../runtime.js"; +import type { ModelRow } from "./list.types.js"; import { colorize, theme } from "../../terminal/theme.js"; import { formatTag, isRich, pad, truncate } from "./list.format.js"; -import type { ModelRow } from "./list.types.js"; import { formatTokenK } from "./shared.js"; const MODEL_PAD = 42; diff --git a/src/commands/models/scan.ts b/src/commands/models/scan.ts index a4a402483d1..ae4ff1a1b52 100644 --- a/src/commands/models/scan.ts +++ b/src/commands/models/scan.ts @@ -1,10 +1,10 @@ import { cancel, multiselect as clackMultiselect, isCancel } from "@clack/prompts"; +import type { RuntimeEnv } from "../../runtime.js"; import { resolveApiKeyForProvider } from "../../agents/model-auth.js"; import { type ModelScanResult, scanOpenRouterModels } from "../../agents/model-scan.js"; import { withProgressTotals } from "../../cli/progress.js"; import { loadConfig } from "../../config/config.js"; import { logConfigUpdated } from "../../config/logging.js"; -import type { RuntimeEnv } from "../../runtime.js"; import { stylePromptHint, stylePromptMessage, diff --git a/src/commands/models/set-image.ts b/src/commands/models/set-image.ts index 0f8f9d641c9..82531414ef2 100644 --- a/src/commands/models/set-image.ts +++ b/src/commands/models/set-image.ts @@ -1,5 +1,5 @@ -import { logConfigUpdated } from "../../config/logging.js"; import type { RuntimeEnv } from "../../runtime.js"; +import { logConfigUpdated } from "../../config/logging.js"; import { resolveModelTarget, updateConfig } from "./shared.js"; export async function modelsSetImageCommand(modelRaw: string, runtime: RuntimeEnv) { diff --git a/src/commands/models/set.ts b/src/commands/models/set.ts index 12e683c4e7b..83db6723fbd 100644 --- a/src/commands/models/set.ts +++ b/src/commands/models/set.ts @@ -1,5 +1,5 @@ -import { logConfigUpdated } from "../../config/logging.js"; import type { RuntimeEnv } from "../../runtime.js"; +import { logConfigUpdated } from "../../config/logging.js"; import { resolveModelTarget, updateConfig } from "./shared.js"; export async function modelsSetCommand(modelRaw: string, runtime: RuntimeEnv) { diff --git a/src/commands/models/shared.ts b/src/commands/models/shared.ts index 85f852c6384..99c64dff78f 100644 --- a/src/commands/models/shared.ts +++ b/src/commands/models/shared.ts @@ -1,3 +1,4 @@ +import { listAgentIds } from "../../agents/agent-scope.js"; import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../../agents/defaults.js"; import { buildModelAliasIndex, @@ -5,7 +6,6 @@ import { parseModelRef, resolveModelRefFromString, } from "../../agents/model-selection.js"; -import { listAgentIds } from "../../agents/agent-scope.js"; import { formatCliCommand } from "../../cli/command-format.js"; import { type OpenClawConfig, diff --git a/src/commands/node-daemon-install-helpers.ts b/src/commands/node-daemon-install-helpers.ts index ef8007f8e5a..750b681406a 100644 --- a/src/commands/node-daemon-install-helpers.ts +++ b/src/commands/node-daemon-install-helpers.ts @@ -1,3 +1,4 @@ +import type { NodeDaemonRuntime } from "./node-daemon-runtime.js"; import { formatNodeServiceDescription } from "../daemon/constants.js"; import { resolveNodeProgramArguments } from "../daemon/program-args.js"; import { @@ -7,7 +8,6 @@ import { } from "../daemon/runtime-paths.js"; import { buildNodeServiceEnvironment } from "../daemon/service-env.js"; import { resolveGatewayDevMode } from "./daemon-install-helpers.js"; -import type { NodeDaemonRuntime } from "./node-daemon-runtime.js"; type WarnFn = (message: string, title?: string) => void; diff --git a/src/commands/onboard-auth.config-core.ts b/src/commands/onboard-auth.config-core.ts index c8dbdcc978a..cd74eb590bb 100644 --- a/src/commands/onboard-auth.config-core.ts +++ b/src/commands/onboard-auth.config-core.ts @@ -1,3 +1,4 @@ +import type { OpenClawConfig } from "../config/config.js"; import { buildXiaomiProvider, XIAOMI_DEFAULT_MODEL_ID } from "../agents/models-config.providers.js"; import { buildSyntheticModelDefinition, @@ -11,7 +12,6 @@ import { VENICE_DEFAULT_MODEL_REF, VENICE_MODEL_CATALOG, } from "../agents/venice-models.js"; -import type { OpenClawConfig } from "../config/config.js"; import { OPENROUTER_DEFAULT_MODEL_REF, VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF, diff --git a/src/commands/onboard-auth.config-opencode.ts b/src/commands/onboard-auth.config-opencode.ts index 38741cb20ad..fd3a77076dd 100644 --- a/src/commands/onboard-auth.config-opencode.ts +++ b/src/commands/onboard-auth.config-opencode.ts @@ -1,5 +1,5 @@ -import { OPENCODE_ZEN_DEFAULT_MODEL_REF } from "../agents/opencode-zen-models.js"; import type { OpenClawConfig } from "../config/config.js"; +import { OPENCODE_ZEN_DEFAULT_MODEL_REF } from "../agents/opencode-zen-models.js"; export function applyOpencodeZenProviderConfig(cfg: OpenClawConfig): OpenClawConfig { // Use the built-in opencode provider from pi-ai; only seed the allowlist alias. diff --git a/src/commands/onboard-auth.test.ts b/src/commands/onboard-auth.test.ts index 0aa080336cf..366aaeae38b 100644 --- a/src/commands/onboard-auth.test.ts +++ b/src/commands/onboard-auth.test.ts @@ -1,10 +1,8 @@ +import type { OAuthCredentials } from "@mariozechner/pi-ai"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - -import type { OAuthCredentials } from "@mariozechner/pi-ai"; import { afterEach, describe, expect, it } from "vitest"; - import { applyAuthProfileConfig, applyMinimaxApiConfig, diff --git a/src/commands/onboard-channels.test.ts b/src/commands/onboard-channels.test.ts index 786f0a62f90..978b8b51507 100644 --- a/src/commands/onboard-channels.test.ts +++ b/src/commands/onboard-channels.test.ts @@ -1,17 +1,16 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import type { RuntimeEnv } from "../runtime.js"; import type { WizardPrompter } from "../wizard/prompts.js"; -import { setupChannels } from "./onboard-channels.js"; -import { setActivePluginRegistry } from "../plugins/runtime.js"; -import { createTestRegistry } from "../test-utils/channel-plugins.js"; import { discordPlugin } from "../../extensions/discord/src/channel.js"; import { imessagePlugin } from "../../extensions/imessage/src/channel.js"; import { signalPlugin } from "../../extensions/signal/src/channel.js"; import { slackPlugin } from "../../extensions/slack/src/channel.js"; import { telegramPlugin } from "../../extensions/telegram/src/channel.js"; import { whatsappPlugin } from "../../extensions/whatsapp/src/channel.js"; +import { setActivePluginRegistry } from "../plugins/runtime.js"; +import { createTestRegistry } from "../test-utils/channel-plugins.js"; +import { setupChannels } from "./onboard-channels.js"; vi.mock("node:fs/promises", () => ({ default: { diff --git a/src/commands/onboard-channels.ts b/src/commands/onboard-channels.ts index 9628daa3960..f8bc7266743 100644 --- a/src/commands/onboard-channels.ts +++ b/src/commands/onboard-channels.ts @@ -1,36 +1,36 @@ -import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; -import { listChannelPluginCatalogEntries } from "../channels/plugins/catalog.js"; -import { listChannelPlugins, getChannelPlugin } from "../channels/plugins/index.js"; import type { ChannelMeta } from "../channels/plugins/types.js"; -import { - formatChannelPrimerLine, - formatChannelSelectionLine, - listChatChannels, -} from "../channels/registry.js"; import type { OpenClawConfig } from "../config/config.js"; -import { isChannelConfigured } from "../config/plugin-auto-enable.js"; import type { DmPolicy } from "../config/types.js"; -import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js"; -import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.js"; import type { RuntimeEnv } from "../runtime.js"; -import { formatDocsLink } from "../terminal/links.js"; -import { formatCliCommand } from "../cli/command-format.js"; -import { enablePluginInConfig } from "../plugins/enable.js"; import type { WizardPrompter, WizardSelectOption } from "../wizard/prompts.js"; import type { ChannelChoice } from "./onboard-types.js"; -import { - getChannelOnboardingAdapter, - listChannelOnboardingAdapters, -} from "./onboarding/registry.js"; -import { - ensureOnboardingPluginInstalled, - reloadOnboardingPluginRegistry, -} from "./onboarding/plugin-install.js"; import type { ChannelOnboardingDmPolicy, ChannelOnboardingStatus, SetupChannelsOptions, } from "./onboarding/types.js"; +import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; +import { listChannelPluginCatalogEntries } from "../channels/plugins/catalog.js"; +import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js"; +import { listChannelPlugins, getChannelPlugin } from "../channels/plugins/index.js"; +import { + formatChannelPrimerLine, + formatChannelSelectionLine, + listChatChannels, +} from "../channels/registry.js"; +import { formatCliCommand } from "../cli/command-format.js"; +import { isChannelConfigured } from "../config/plugin-auto-enable.js"; +import { enablePluginInConfig } from "../plugins/enable.js"; +import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.js"; +import { formatDocsLink } from "../terminal/links.js"; +import { + ensureOnboardingPluginInstalled, + reloadOnboardingPluginRegistry, +} from "./onboarding/plugin-install.js"; +import { + getChannelOnboardingAdapter, + listChannelOnboardingAdapters, +} from "./onboarding/registry.js"; type ConfiguredChannelAction = "update" | "disable" | "delete" | "skip"; diff --git a/src/commands/onboard-helpers.test.ts b/src/commands/onboard-helpers.test.ts index e64a7cd1cb9..d351c21527a 100644 --- a/src/commands/onboard-helpers.test.ts +++ b/src/commands/onboard-helpers.test.ts @@ -1,5 +1,4 @@ import { afterEach, describe, expect, it, vi } from "vitest"; - import { normalizeGatewayTokenInput, openUrl, diff --git a/src/commands/onboard-helpers.ts b/src/commands/onboard-helpers.ts index ff2a8ce7b3a..55dcaa8582a 100644 --- a/src/commands/onboard-helpers.ts +++ b/src/commands/onboard-helpers.ts @@ -1,12 +1,12 @@ +import { cancel, isCancel } from "@clack/prompts"; import crypto from "node:crypto"; import fs from "node:fs/promises"; import path from "node:path"; import { inspect } from "node:util"; - -import { cancel, isCancel } from "@clack/prompts"; - -import { DEFAULT_AGENT_WORKSPACE_DIR, ensureAgentWorkspace } from "../agents/workspace.js"; import type { OpenClawConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; +import type { NodeManagerChoice, OnboardMode, ResetScope } from "./onboard-types.js"; +import { DEFAULT_AGENT_WORKSPACE_DIR, ensureAgentWorkspace } from "../agents/workspace.js"; import { CONFIG_PATH } from "../config/config.js"; import { resolveSessionTranscriptsDirForAgent } from "../config/sessions.js"; import { callGateway } from "../gateway/call.js"; @@ -15,9 +15,7 @@ import { isSafeExecutableValue } from "../infra/exec-safety.js"; import { pickPrimaryTailnetIPv4 } from "../infra/tailnet.js"; import { isWSL } from "../infra/wsl.js"; import { runCommandWithTimeout } from "../process/exec.js"; -import type { RuntimeEnv } from "../runtime.js"; import { stylePromptTitle } from "../terminal/prompt-style.js"; -import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; import { CONFIG_DIR, resolveUserPath, @@ -25,8 +23,8 @@ import { shortenHomePath, sleep, } from "../utils.js"; +import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; import { VERSION } from "../version.js"; -import type { NodeManagerChoice, OnboardMode, ResetScope } from "./onboard-types.js"; export function guardCancel(value: T | symbol, runtime: RuntimeEnv): T { if (isCancel(value)) { diff --git a/src/commands/onboard-hooks.test.ts b/src/commands/onboard-hooks.test.ts index 8b1227e1fb1..1ab2b47caec 100644 --- a/src/commands/onboard-hooks.test.ts +++ b/src/commands/onboard-hooks.test.ts @@ -1,9 +1,9 @@ import { describe, expect, it, vi, beforeEach } from "vitest"; -import { setupInternalHooks } from "./onboard-hooks.js"; import type { OpenClawConfig } from "../config/config.js"; +import type { HookStatusReport } from "../hooks/hooks-status.js"; import type { RuntimeEnv } from "../runtime.js"; import type { WizardPrompter } from "../wizard/prompts.js"; -import type { HookStatusReport } from "../hooks/hooks-status.js"; +import { setupInternalHooks } from "./onboard-hooks.js"; // Mock hook discovery modules vi.mock("../hooks/hooks-status.js", () => ({ diff --git a/src/commands/onboard-hooks.ts b/src/commands/onboard-hooks.ts index c5428664ee0..403e1369c5a 100644 --- a/src/commands/onboard-hooks.ts +++ b/src/commands/onboard-hooks.ts @@ -1,9 +1,9 @@ import type { OpenClawConfig } from "../config/config.js"; import type { RuntimeEnv } from "../runtime.js"; import type { WizardPrompter } from "../wizard/prompts.js"; -import { buildWorkspaceHookStatus } from "../hooks/hooks-status.js"; import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; import { formatCliCommand } from "../cli/command-format.js"; +import { buildWorkspaceHookStatus } from "../hooks/hooks-status.js"; export async function setupInternalHooks( cfg: OpenClawConfig, diff --git a/src/commands/onboard-interactive.ts b/src/commands/onboard-interactive.ts index 29c457ce903..2c534f0cfa9 100644 --- a/src/commands/onboard-interactive.ts +++ b/src/commands/onboard-interactive.ts @@ -1,9 +1,9 @@ import type { RuntimeEnv } from "../runtime.js"; +import type { OnboardOptions } from "./onboard-types.js"; import { defaultRuntime } from "../runtime.js"; import { createClackPrompter } from "../wizard/clack-prompter.js"; import { runOnboardingWizard } from "../wizard/onboarding.js"; import { WizardCancelledError } from "../wizard/prompts.js"; -import type { OnboardOptions } from "./onboard-types.js"; export async function runInteractiveOnboarding( opts: OnboardOptions, diff --git a/src/commands/onboard-non-interactive.ai-gateway.test.ts b/src/commands/onboard-non-interactive.ai-gateway.test.ts index 7bace3b86a7..a154724517a 100644 --- a/src/commands/onboard-non-interactive.ai-gateway.test.ts +++ b/src/commands/onboard-non-interactive.ai-gateway.test.ts @@ -1,7 +1,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it, vi } from "vitest"; describe("onboard (non-interactive): Vercel AI Gateway", () => { diff --git a/src/commands/onboard-non-interactive.gateway.test.ts b/src/commands/onboard-non-interactive.gateway.test.ts index bd5c46ed574..1397ea2f736 100644 --- a/src/commands/onboard-non-interactive.gateway.test.ts +++ b/src/commands/onboard-non-interactive.gateway.test.ts @@ -2,9 +2,7 @@ import fs from "node:fs/promises"; import { createServer } from "node:net"; import os from "node:os"; import path from "node:path"; - import { afterAll, beforeAll, describe, expect, it, vi } from "vitest"; - import { getDeterministicFreePortBlock } from "../test-utils/ports.js"; const gatewayClientCalls: Array<{ diff --git a/src/commands/onboard-non-interactive.token.test.ts b/src/commands/onboard-non-interactive.token.test.ts index 69b2e25c532..bcbe2c221b4 100644 --- a/src/commands/onboard-non-interactive.token.test.ts +++ b/src/commands/onboard-non-interactive.token.test.ts @@ -1,7 +1,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it, vi } from "vitest"; describe("onboard (non-interactive): token auth", () => { diff --git a/src/commands/onboard-non-interactive.ts b/src/commands/onboard-non-interactive.ts index 4b4d1223226..f65abdfd0f6 100644 --- a/src/commands/onboard-non-interactive.ts +++ b/src/commands/onboard-non-interactive.ts @@ -1,11 +1,11 @@ -import { formatCliCommand } from "../cli/command-format.js"; import type { OpenClawConfig } from "../config/config.js"; -import { readConfigFileSnapshot } from "../config/config.js"; import type { RuntimeEnv } from "../runtime.js"; +import type { OnboardOptions } from "./onboard-types.js"; +import { formatCliCommand } from "../cli/command-format.js"; +import { readConfigFileSnapshot } from "../config/config.js"; import { defaultRuntime } from "../runtime.js"; import { runNonInteractiveOnboardingLocal } from "./onboard-non-interactive/local.js"; import { runNonInteractiveOnboardingRemote } from "./onboard-non-interactive/remote.js"; -import type { OnboardOptions } from "./onboard-types.js"; export async function runNonInteractiveOnboarding( opts: OnboardOptions, diff --git a/src/commands/onboard-non-interactive/api-keys.ts b/src/commands/onboard-non-interactive/api-keys.ts index 43c73f08252..0e81746e42a 100644 --- a/src/commands/onboard-non-interactive/api-keys.ts +++ b/src/commands/onboard-non-interactive/api-keys.ts @@ -1,11 +1,11 @@ +import type { OpenClawConfig } from "../../config/config.js"; +import type { RuntimeEnv } from "../../runtime.js"; import { ensureAuthProfileStore, resolveApiKeyForProfile, resolveAuthProfileOrder, } from "../../agents/auth-profiles.js"; import { resolveEnvApiKey } from "../../agents/model-auth.js"; -import type { OpenClawConfig } from "../../config/config.js"; -import type { RuntimeEnv } from "../../runtime.js"; export type NonInteractiveApiKeySource = "flag" | "env" | "profile"; diff --git a/src/commands/onboard-non-interactive/local.ts b/src/commands/onboard-non-interactive/local.ts index 5a4edf68562..5546e9d2863 100644 --- a/src/commands/onboard-non-interactive/local.ts +++ b/src/commands/onboard-non-interactive/local.ts @@ -1,8 +1,9 @@ import type { OpenClawConfig } from "../../config/config.js"; +import type { RuntimeEnv } from "../../runtime.js"; +import type { OnboardOptions } from "../onboard-types.js"; +import { formatCliCommand } from "../../cli/command-format.js"; import { resolveGatewayPort, writeConfigFile } from "../../config/config.js"; import { logConfigUpdated } from "../../config/logging.js"; -import type { RuntimeEnv } from "../../runtime.js"; -import { formatCliCommand } from "../../cli/command-format.js"; import { DEFAULT_GATEWAY_DAEMON_RUNTIME } from "../daemon-runtime.js"; import { healthCommand } from "../health.js"; import { @@ -12,8 +13,6 @@ import { resolveControlUiLinks, waitForGatewayReachable, } from "../onboard-helpers.js"; -import type { OnboardOptions } from "../onboard-types.js"; - import { applyNonInteractiveAuthChoice } from "./local/auth-choice.js"; import { installGatewayDaemonNonInteractive } from "./local/daemon-install.js"; import { applyNonInteractiveGatewayConfig } from "./local/gateway-config.js"; diff --git a/src/commands/onboard-non-interactive/local/auth-choice.ts b/src/commands/onboard-non-interactive/local/auth-choice.ts index dfc36a5cc59..98d11b002c3 100644 --- a/src/commands/onboard-non-interactive/local/auth-choice.ts +++ b/src/commands/onboard-non-interactive/local/auth-choice.ts @@ -1,9 +1,11 @@ +import type { OpenClawConfig } from "../../../config/config.js"; +import type { RuntimeEnv } from "../../../runtime.js"; +import type { AuthChoice, OnboardOptions } from "../../onboard-types.js"; import { upsertAuthProfile } from "../../../agents/auth-profiles.js"; import { normalizeProviderId } from "../../../agents/model-selection.js"; import { parseDurationMs } from "../../../cli/parse-duration.js"; -import type { OpenClawConfig } from "../../../config/config.js"; import { upsertSharedEnvVar } from "../../../infra/env-file.js"; -import type { RuntimeEnv } from "../../../runtime.js"; +import { shortenHomePath } from "../../../utils.js"; import { buildTokenProfileId, validateAnthropicSetupToken } from "../../auth-token.js"; import { applyGoogleGeminiModelDefault } from "../../google-gemini-model-default.js"; import { @@ -32,9 +34,7 @@ import { setXiaomiApiKey, setZaiApiKey, } from "../../onboard-auth.js"; -import type { AuthChoice, OnboardOptions } from "../../onboard-types.js"; import { resolveNonInteractiveApiKey } from "../api-keys.js"; -import { shortenHomePath } from "../../../utils.js"; export async function applyNonInteractiveAuthChoice(params: { nextConfig: OpenClawConfig; diff --git a/src/commands/onboard-non-interactive/local/daemon-install.ts b/src/commands/onboard-non-interactive/local/daemon-install.ts index 9d994bfed50..984113226cc 100644 --- a/src/commands/onboard-non-interactive/local/daemon-install.ts +++ b/src/commands/onboard-non-interactive/local/daemon-install.ts @@ -1,10 +1,10 @@ import type { OpenClawConfig } from "../../../config/config.js"; +import type { RuntimeEnv } from "../../../runtime.js"; +import type { OnboardOptions } from "../../onboard-types.js"; import { resolveGatewayService } from "../../../daemon/service.js"; import { isSystemdUserServiceAvailable } from "../../../daemon/systemd.js"; -import type { RuntimeEnv } from "../../../runtime.js"; -import { DEFAULT_GATEWAY_DAEMON_RUNTIME, isGatewayDaemonRuntime } from "../../daemon-runtime.js"; import { buildGatewayInstallPlan, gatewayInstallErrorHint } from "../../daemon-install-helpers.js"; -import type { OnboardOptions } from "../../onboard-types.js"; +import { DEFAULT_GATEWAY_DAEMON_RUNTIME, isGatewayDaemonRuntime } from "../../daemon-runtime.js"; import { ensureSystemdUserLingerNonInteractive } from "../../systemd-linger.js"; export async function installGatewayDaemonNonInteractive(params: { diff --git a/src/commands/onboard-non-interactive/local/gateway-config.ts b/src/commands/onboard-non-interactive/local/gateway-config.ts index a786838cefb..4f509bb203b 100644 --- a/src/commands/onboard-non-interactive/local/gateway-config.ts +++ b/src/commands/onboard-non-interactive/local/gateway-config.ts @@ -1,7 +1,7 @@ import type { OpenClawConfig } from "../../../config/config.js"; import type { RuntimeEnv } from "../../../runtime.js"; -import { randomToken } from "../../onboard-helpers.js"; import type { OnboardOptions } from "../../onboard-types.js"; +import { randomToken } from "../../onboard-helpers.js"; export function applyNonInteractiveGatewayConfig(params: { nextConfig: OpenClawConfig; diff --git a/src/commands/onboard-non-interactive/local/workspace.ts b/src/commands/onboard-non-interactive/local/workspace.ts index a24e5c66d63..2384d6e71cf 100644 --- a/src/commands/onboard-non-interactive/local/workspace.ts +++ b/src/commands/onboard-non-interactive/local/workspace.ts @@ -1,6 +1,6 @@ import type { OpenClawConfig } from "../../../config/config.js"; -import { resolveUserPath } from "../../../utils.js"; import type { OnboardOptions } from "../../onboard-types.js"; +import { resolveUserPath } from "../../../utils.js"; export function resolveNonInteractiveWorkspaceDir(params: { opts: OnboardOptions; diff --git a/src/commands/onboard-non-interactive/remote.ts b/src/commands/onboard-non-interactive/remote.ts index 5647e0c07dd..eb020503f3d 100644 --- a/src/commands/onboard-non-interactive/remote.ts +++ b/src/commands/onboard-non-interactive/remote.ts @@ -1,10 +1,10 @@ import type { OpenClawConfig } from "../../config/config.js"; +import type { RuntimeEnv } from "../../runtime.js"; +import type { OnboardOptions } from "../onboard-types.js"; +import { formatCliCommand } from "../../cli/command-format.js"; import { writeConfigFile } from "../../config/config.js"; import { logConfigUpdated } from "../../config/logging.js"; -import type { RuntimeEnv } from "../../runtime.js"; -import { formatCliCommand } from "../../cli/command-format.js"; import { applyWizardMetadata } from "../onboard-helpers.js"; -import type { OnboardOptions } from "../onboard-types.js"; export async function runNonInteractiveOnboardingRemote(params: { opts: OnboardOptions; diff --git a/src/commands/onboard-remote.ts b/src/commands/onboard-remote.ts index 57b93a82700..1ecea324e49 100644 --- a/src/commands/onboard-remote.ts +++ b/src/commands/onboard-remote.ts @@ -1,8 +1,8 @@ import type { OpenClawConfig } from "../config/config.js"; import type { GatewayBonjourBeacon } from "../infra/bonjour-discovery.js"; +import type { WizardPrompter } from "../wizard/prompts.js"; import { discoverGatewayBeacons } from "../infra/bonjour-discovery.js"; import { resolveWideAreaDiscoveryDomain } from "../infra/widearea-dns.js"; -import type { WizardPrompter } from "../wizard/prompts.js"; import { detectBinary } from "./onboard-helpers.js"; const DEFAULT_GATEWAY_URL = "ws://127.0.0.1:18789"; diff --git a/src/commands/onboard-skills.ts b/src/commands/onboard-skills.ts index 6432de0f85c..b39bdf52514 100644 --- a/src/commands/onboard-skills.ts +++ b/src/commands/onboard-skills.ts @@ -1,9 +1,9 @@ -import { installSkill } from "../agents/skills-install.js"; -import { buildWorkspaceSkillStatus } from "../agents/skills-status.js"; -import { formatCliCommand } from "../cli/command-format.js"; import type { OpenClawConfig } from "../config/config.js"; import type { RuntimeEnv } from "../runtime.js"; import type { WizardPrompter } from "../wizard/prompts.js"; +import { installSkill } from "../agents/skills-install.js"; +import { buildWorkspaceSkillStatus } from "../agents/skills-status.js"; +import { formatCliCommand } from "../cli/command-format.js"; import { detectBinary, resolveNodeManagerOptions } from "./onboard-helpers.js"; function summarizeInstallFailure(message: string): string | undefined { diff --git a/src/commands/onboard.ts b/src/commands/onboard.ts index 915097d838c..5b730c7488b 100644 --- a/src/commands/onboard.ts +++ b/src/commands/onboard.ts @@ -1,13 +1,13 @@ +import type { RuntimeEnv } from "../runtime.js"; +import type { OnboardOptions } from "./onboard-types.js"; +import { formatCliCommand } from "../cli/command-format.js"; import { readConfigFileSnapshot } from "../config/config.js"; import { assertSupportedRuntime } from "../infra/runtime-guard.js"; -import type { RuntimeEnv } from "../runtime.js"; import { defaultRuntime } from "../runtime.js"; import { resolveUserPath } from "../utils.js"; import { DEFAULT_WORKSPACE, handleReset } from "./onboard-helpers.js"; import { runInteractiveOnboarding } from "./onboard-interactive.js"; import { runNonInteractiveOnboarding } from "./onboard-non-interactive.js"; -import { formatCliCommand } from "../cli/command-format.js"; -import type { OnboardOptions } from "./onboard-types.js"; export async function onboardCommand(opts: OnboardOptions, runtime: RuntimeEnv = defaultRuntime) { assertSupportedRuntime(runtime); diff --git a/src/commands/onboarding/__tests__/test-utils.ts b/src/commands/onboarding/__tests__/test-utils.ts index aea7f9cda48..6faa7b5849f 100644 --- a/src/commands/onboarding/__tests__/test-utils.ts +++ b/src/commands/onboarding/__tests__/test-utils.ts @@ -1,5 +1,4 @@ import { vi } from "vitest"; - import type { RuntimeEnv } from "../../../runtime.js"; import type { WizardPrompter } from "../../../wizard/prompts.js"; diff --git a/src/commands/onboarding/plugin-install.ts b/src/commands/onboarding/plugin-install.ts index 3e55657349b..235a64f3af1 100644 --- a/src/commands/onboarding/plugin-install.ts +++ b/src/commands/onboarding/plugin-install.ts @@ -1,15 +1,15 @@ import fs from "node:fs"; import path from "node:path"; -import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../../agents/agent-scope.js"; import type { ChannelPluginCatalogEntry } from "../../channels/plugins/catalog.js"; import type { OpenClawConfig } from "../../config/config.js"; -import { createSubsystemLogger } from "../../logging/subsystem.js"; -import { recordPluginInstall } from "../../plugins/installs.js"; -import { enablePluginInConfig } from "../../plugins/enable.js"; -import { loadOpenClawPlugins } from "../../plugins/loader.js"; -import { installPluginFromNpmSpec } from "../../plugins/install.js"; import type { RuntimeEnv } from "../../runtime.js"; import type { WizardPrompter } from "../../wizard/prompts.js"; +import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../../agents/agent-scope.js"; +import { createSubsystemLogger } from "../../logging/subsystem.js"; +import { enablePluginInConfig } from "../../plugins/enable.js"; +import { installPluginFromNpmSpec } from "../../plugins/install.js"; +import { recordPluginInstall } from "../../plugins/installs.js"; +import { loadOpenClawPlugins } from "../../plugins/loader.js"; type InstallChoice = "npm" | "local" | "skip"; diff --git a/src/commands/onboarding/registry.ts b/src/commands/onboarding/registry.ts index d3fdbef2ce9..f305e295b84 100644 --- a/src/commands/onboarding/registry.ts +++ b/src/commands/onboarding/registry.ts @@ -1,6 +1,6 @@ -import { listChannelPlugins } from "../../channels/plugins/index.js"; import type { ChannelChoice } from "../onboard-types.js"; import type { ChannelOnboardingAdapter } from "./types.js"; +import { listChannelPlugins } from "../../channels/plugins/index.js"; const CHANNEL_ONBOARDING_ADAPTERS = () => new Map( diff --git a/src/commands/openai-codex-model-default.test.ts b/src/commands/openai-codex-model-default.test.ts index de0e4ee8c93..eed5979a11f 100644 --- a/src/commands/openai-codex-model-default.test.ts +++ b/src/commands/openai-codex-model-default.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { applyOpenAICodexModelDefault, diff --git a/src/commands/opencode-zen-model-default.test.ts b/src/commands/opencode-zen-model-default.test.ts index b4f1b915fe9..67fbc5b9d80 100644 --- a/src/commands/opencode-zen-model-default.test.ts +++ b/src/commands/opencode-zen-model-default.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { applyOpencodeZenModelDefault, diff --git a/src/commands/reset.ts b/src/commands/reset.ts index 3b49867d704..0717544a431 100644 --- a/src/commands/reset.ts +++ b/src/commands/reset.ts @@ -1,5 +1,6 @@ import { cancel, confirm, isCancel, select } from "@clack/prompts"; - +import type { RuntimeEnv } from "../runtime.js"; +import { formatCliCommand } from "../cli/command-format.js"; import { isNixMode, loadConfig, @@ -8,9 +9,7 @@ import { resolveStateDir, } from "../config/config.js"; import { resolveGatewayService } from "../daemon/service.js"; -import type { RuntimeEnv } from "../runtime.js"; import { stylePromptHint, stylePromptMessage, stylePromptTitle } from "../terminal/prompt-style.js"; -import { formatCliCommand } from "../cli/command-format.js"; import { collectWorkspaceDirs, isPathWithin, diff --git a/src/commands/sandbox-display.ts b/src/commands/sandbox-display.ts index 82493a8bbba..ea0c4fbb470 100644 --- a/src/commands/sandbox-display.ts +++ b/src/commands/sandbox-display.ts @@ -3,8 +3,8 @@ */ import type { SandboxBrowserInfo, SandboxContainerInfo } from "../agents/sandbox.js"; -import { formatCliCommand } from "../cli/command-format.js"; import type { RuntimeEnv } from "../runtime.js"; +import { formatCliCommand } from "../cli/command-format.js"; import { formatAge, formatImageMatch, diff --git a/src/commands/sandbox-explain.ts b/src/commands/sandbox-explain.ts index f91ab07c819..8e79688fe9a 100644 --- a/src/commands/sandbox-explain.ts +++ b/src/commands/sandbox-explain.ts @@ -1,10 +1,11 @@ +import type { OpenClawConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; import { resolveAgentConfig } from "../agents/agent-scope.js"; import { resolveSandboxConfigForAgent, resolveSandboxToolPolicyForAgent, } from "../agents/sandbox.js"; import { normalizeAnyChannelId } from "../channels/registry.js"; -import type { OpenClawConfig } from "../config/config.js"; import { loadConfig } from "../config/config.js"; import { loadSessionStore, @@ -19,7 +20,6 @@ import { parseAgentSessionKey, resolveAgentIdFromSessionKey, } from "../routing/session-key.js"; -import type { RuntimeEnv } from "../runtime.js"; import { formatDocsLink } from "../terminal/links.js"; import { colorize, isRich, theme } from "../terminal/theme.js"; import { INTERNAL_MESSAGE_CHANNEL } from "../utils/message-channel.js"; diff --git a/src/commands/sandbox-formatters.test.ts b/src/commands/sandbox-formatters.test.ts index 7377568235d..d8bf8383a8f 100644 --- a/src/commands/sandbox-formatters.test.ts +++ b/src/commands/sandbox-formatters.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { countMismatches, countRunning, diff --git a/src/commands/sandbox.test.ts b/src/commands/sandbox.test.ts index 00200182b50..83900c7f55e 100644 --- a/src/commands/sandbox.test.ts +++ b/src/commands/sandbox.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { SandboxBrowserInfo, SandboxContainerInfo } from "../agents/sandbox.js"; // --- Mocks --- diff --git a/src/commands/sandbox.ts b/src/commands/sandbox.ts index b087033a195..9fca4206a3a 100644 --- a/src/commands/sandbox.ts +++ b/src/commands/sandbox.ts @@ -1,5 +1,5 @@ import { confirm as clackConfirm } from "@clack/prompts"; - +import type { RuntimeEnv } from "../runtime.js"; import { listSandboxBrowsers, listSandboxContainers, @@ -8,7 +8,6 @@ import { type SandboxBrowserInfo, type SandboxContainerInfo, } from "../agents/sandbox.js"; -import type { RuntimeEnv } from "../runtime.js"; import { displayBrowsers, displayContainers, diff --git a/src/commands/sessions.test.ts b/src/commands/sessions.test.ts index ce673715956..4d181d0d6a9 100644 --- a/src/commands/sessions.test.ts +++ b/src/commands/sessions.test.ts @@ -1,7 +1,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; // Disable colors for deterministic snapshots. diff --git a/src/commands/sessions.ts b/src/commands/sessions.ts index 0c091267c90..54235086cd8 100644 --- a/src/commands/sessions.ts +++ b/src/commands/sessions.ts @@ -1,10 +1,10 @@ +import type { RuntimeEnv } from "../runtime.js"; import { lookupContextTokens } from "../agents/context.js"; import { DEFAULT_CONTEXT_TOKENS, DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js"; import { resolveConfiguredModelRef } from "../agents/model-selection.js"; import { loadConfig } from "../config/config.js"; import { loadSessionStore, resolveStorePath, type SessionEntry } from "../config/sessions.js"; import { info } from "../globals.js"; -import type { RuntimeEnv } from "../runtime.js"; import { isRich, theme } from "../terminal/theme.js"; type SessionRow = { diff --git a/src/commands/setup.ts b/src/commands/setup.ts index df3323d3486..70e595599bd 100644 --- a/src/commands/setup.ts +++ b/src/commands/setup.ts @@ -1,12 +1,10 @@ -import fs from "node:fs/promises"; - import JSON5 from "json5"; - +import fs from "node:fs/promises"; +import type { RuntimeEnv } from "../runtime.js"; import { DEFAULT_AGENT_WORKSPACE_DIR, ensureAgentWorkspace } from "../agents/workspace.js"; import { type OpenClawConfig, createConfigIO, writeConfigFile } from "../config/config.js"; import { formatConfigPath, logConfigUpdated } from "../config/logging.js"; import { resolveSessionTranscriptsDir } from "../config/sessions.js"; -import type { RuntimeEnv } from "../runtime.js"; import { defaultRuntime } from "../runtime.js"; import { shortenHomePath } from "../utils.js"; diff --git a/src/commands/signal-install.ts b/src/commands/signal-install.ts index b795a3085a1..e5b492a36ff 100644 --- a/src/commands/signal-install.ts +++ b/src/commands/signal-install.ts @@ -4,9 +4,8 @@ import { request } from "node:https"; import os from "node:os"; import path from "node:path"; import { pipeline } from "node:stream/promises"; - -import { runCommandWithTimeout } from "../process/exec.js"; import type { RuntimeEnv } from "../runtime.js"; +import { runCommandWithTimeout } from "../process/exec.js"; import { CONFIG_DIR } from "../utils.js"; type ReleaseAsset = { diff --git a/src/commands/status-all.ts b/src/commands/status-all.ts index c194c53e321..8f04e985b8a 100644 --- a/src/commands/status-all.ts +++ b/src/commands/status-all.ts @@ -1,11 +1,12 @@ +import type { GatewayService } from "../daemon/service.js"; +import type { RuntimeEnv } from "../runtime.js"; import { buildWorkspaceSkillStatus } from "../agents/skills-status.js"; -import { withProgress } from "../cli/progress.js"; import { formatCliCommand } from "../cli/command-format.js"; +import { withProgress } from "../cli/progress.js"; import { loadConfig, readConfigFileSnapshot, resolveGatewayPort } from "../config/config.js"; import { readLastGatewayErrorLine } from "../daemon/diagnostics.js"; -import type { GatewayService } from "../daemon/service.js"; -import { resolveGatewayService } from "../daemon/service.js"; import { resolveNodeService } from "../daemon/node-service.js"; +import { resolveGatewayService } from "../daemon/service.js"; import { buildGatewayConnectionDetails, callGateway } from "../gateway/call.js"; import { normalizeControlUiBasePath } from "../gateway/control-ui-shared.js"; import { probeGateway } from "../gateway/probe.js"; @@ -14,16 +15,15 @@ import { resolveOpenClawPackageRoot } from "../infra/openclaw-root.js"; import { resolveOsSummary } from "../infra/os-summary.js"; import { inspectPortUsage } from "../infra/ports.js"; import { readRestartSentinel } from "../infra/restart-sentinel.js"; +import { getRemoteSkillEligibility } from "../infra/skills-remote.js"; import { readTailscaleStatusJson } from "../infra/tailscale.js"; -import { checkUpdateStatus, compareSemverStrings } from "../infra/update-check.js"; import { formatUpdateChannelLabel, normalizeUpdateChannel, resolveEffectiveUpdateChannel, } from "../infra/update-channels.js"; -import { getRemoteSkillEligibility } from "../infra/skills-remote.js"; +import { checkUpdateStatus, compareSemverStrings } from "../infra/update-check.js"; import { runExec } from "../process/exec.js"; -import type { RuntimeEnv } from "../runtime.js"; import { VERSION } from "../version.js"; import { resolveControlUiLinks } from "./onboard-helpers.js"; import { getAgentLocalStatuses } from "./status-all/agents.js"; diff --git a/src/commands/status-all/agents.ts b/src/commands/status-all/agents.ts index caf1ae03ed2..a30f65e128a 100644 --- a/src/commands/status-all/agents.ts +++ b/src/commands/status-all/agents.ts @@ -1,7 +1,7 @@ import fs from "node:fs/promises"; import path from "node:path"; -import { resolveAgentWorkspaceDir } from "../../agents/agent-scope.js"; import type { OpenClawConfig } from "../../config/config.js"; +import { resolveAgentWorkspaceDir } from "../../agents/agent-scope.js"; import { loadSessionStore, resolveStorePath } from "../../config/sessions.js"; import { listAgentsForGateway } from "../../gateway/session-utils.js"; diff --git a/src/commands/status-all/channels.ts b/src/commands/status-all/channels.ts index 8b7d22fe45e..d7be6ad75c2 100644 --- a/src/commands/status-all/channels.ts +++ b/src/commands/status-all/channels.ts @@ -1,13 +1,13 @@ import crypto from "node:crypto"; import fs from "node:fs"; -import { resolveChannelDefaultAccountId } from "../../channels/plugins/helpers.js"; -import { listChannelPlugins } from "../../channels/plugins/index.js"; import type { ChannelAccountSnapshot, ChannelId, ChannelPlugin, } from "../../channels/plugins/types.js"; import type { OpenClawConfig } from "../../config/config.js"; +import { resolveChannelDefaultAccountId } from "../../channels/plugins/helpers.js"; +import { listChannelPlugins } from "../../channels/plugins/index.js"; import { formatAge } from "./format.js"; export type ChannelRow = { diff --git a/src/commands/status.agent-local.ts b/src/commands/status.agent-local.ts index eb2cce8d1d4..b7bb8bdf127 100644 --- a/src/commands/status.agent-local.ts +++ b/src/commands/status.agent-local.ts @@ -1,6 +1,5 @@ import fs from "node:fs/promises"; import path from "node:path"; - import { resolveAgentWorkspaceDir } from "../agents/agent-scope.js"; import { loadConfig } from "../config/config.js"; import { loadSessionStore, resolveStorePath } from "../config/sessions.js"; diff --git a/src/commands/status.command.ts b/src/commands/status.command.ts index af0305d75f2..a82cd6b0df4 100644 --- a/src/commands/status.command.ts +++ b/src/commands/status.command.ts @@ -1,21 +1,28 @@ +import type { RuntimeEnv } from "../runtime.js"; +import { formatCliCommand } from "../cli/command-format.js"; import { withProgress } from "../cli/progress.js"; import { resolveGatewayPort } from "../config/config.js"; import { buildGatewayConnectionDetails, callGateway } from "../gateway/call.js"; import { info } from "../globals.js"; import { formatUsageReportLines, loadProviderUsageSummary } from "../infra/provider-usage.js"; -import type { RuntimeEnv } from "../runtime.js"; -import { runSecurityAudit } from "../security/audit.js"; -import { renderTable } from "../terminal/table.js"; -import { theme } from "../terminal/theme.js"; -import { formatCliCommand } from "../cli/command-format.js"; +import { + formatUpdateChannelLabel, + normalizeUpdateChannel, + resolveEffectiveUpdateChannel, +} from "../infra/update-channels.js"; import { resolveMemoryCacheSummary, resolveMemoryFtsState, resolveMemoryVectorState, type Tone, } from "../memory/status-format.js"; +import { runSecurityAudit } from "../security/audit.js"; +import { renderTable } from "../terminal/table.js"; +import { theme } from "../terminal/theme.js"; import { formatHealthChannelLines, type HealthSummary } from "./health.js"; import { resolveControlUiLinks } from "./onboard-helpers.js"; +import { statusAllCommand } from "./status-all.js"; +import { formatGatewayAuthUsed } from "./status-all/format.js"; import { getDaemonStatusSummary, getNodeDaemonStatusSummary } from "./status.daemon.js"; import { formatAge, @@ -31,13 +38,6 @@ import { formatUpdateOneLiner, resolveUpdateAvailability, } from "./status.update.js"; -import { formatGatewayAuthUsed } from "./status-all/format.js"; -import { statusAllCommand } from "./status-all.js"; -import { - formatUpdateChannelLabel, - normalizeUpdateChannel, - resolveEffectiveUpdateChannel, -} from "../infra/update-channels.js"; export async function statusCommand( opts: { diff --git a/src/commands/status.daemon.ts b/src/commands/status.daemon.ts index 91cbab7698e..e1fd4820b66 100644 --- a/src/commands/status.daemon.ts +++ b/src/commands/status.daemon.ts @@ -1,6 +1,6 @@ import type { GatewayService } from "../daemon/service.js"; -import { resolveGatewayService } from "../daemon/service.js"; import { resolveNodeService } from "../daemon/node-service.js"; +import { resolveGatewayService } from "../daemon/service.js"; import { formatDaemonRuntimeShort } from "./status.format.js"; type DaemonStatusSummary = { diff --git a/src/commands/status.link-channel.ts b/src/commands/status.link-channel.ts index cea7b8feb91..d936dddf2b2 100644 --- a/src/commands/status.link-channel.ts +++ b/src/commands/status.link-channel.ts @@ -1,7 +1,7 @@ -import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js"; -import { listChannelPlugins } from "../channels/plugins/index.js"; import type { ChannelAccountSnapshot, ChannelPlugin } from "../channels/plugins/types.js"; import type { OpenClawConfig } from "../config/config.js"; +import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js"; +import { listChannelPlugins } from "../channels/plugins/index.js"; export type LinkChannelContext = { linked: boolean; diff --git a/src/commands/status.scan.ts b/src/commands/status.scan.ts index 66998475874..f045540f43f 100644 --- a/src/commands/status.scan.ts +++ b/src/commands/status.scan.ts @@ -1,3 +1,5 @@ +import type { MemoryIndexManager } from "../memory/manager.js"; +import type { RuntimeEnv } from "../runtime.js"; import { withProgress } from "../cli/progress.js"; import { loadConfig } from "../config/config.js"; import { buildGatewayConnectionDetails, callGateway } from "../gateway/call.js"; @@ -6,14 +8,12 @@ import { probeGateway } from "../gateway/probe.js"; import { collectChannelStatusIssues } from "../infra/channels-status-issues.js"; import { resolveOsSummary } from "../infra/os-summary.js"; import { getTailnetHostname } from "../infra/tailscale.js"; -import type { MemoryIndexManager } from "../memory/manager.js"; import { runExec } from "../process/exec.js"; -import type { RuntimeEnv } from "../runtime.js"; +import { buildChannelsTable } from "./status-all/channels.js"; import { getAgentLocalStatuses } from "./status.agent-local.js"; import { pickGatewaySelfPresence, resolveGatewayProbeAuth } from "./status.gateway-probe.js"; import { getStatusSummary } from "./status.summary.js"; import { getUpdateCheckResult } from "./status.update.js"; -import { buildChannelsTable } from "./status-all/channels.js"; type MemoryStatusSnapshot = ReturnType & { agentId: string; diff --git a/src/commands/status.summary.ts b/src/commands/status.summary.ts index ec326b32f5d..2e865d654a4 100644 --- a/src/commands/status.summary.ts +++ b/src/commands/status.summary.ts @@ -1,3 +1,4 @@ +import type { HeartbeatStatus, SessionStatus, StatusSummary } from "./status.types.js"; import { lookupContextTokens } from "../agents/context.js"; import { DEFAULT_CONTEXT_TOKENS, DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js"; import { resolveConfiguredModelRef } from "../agents/model-selection.js"; @@ -14,7 +15,6 @@ import { resolveHeartbeatSummaryForAgent } from "../infra/heartbeat-runner.js"; import { peekSystemEvents } from "../infra/system-events.js"; import { parseAgentSessionKey } from "../routing/session-key.js"; import { resolveLinkChannelContext } from "./status.link-channel.js"; -import type { HeartbeatStatus, SessionStatus, StatusSummary } from "./status.types.js"; const classifyKey = (key: string, entry?: SessionEntry): SessionStatus["kind"] => { if (key === "global") { diff --git a/src/commands/status.update.ts b/src/commands/status.update.ts index 6010f2fe6b9..9d3215995de 100644 --- a/src/commands/status.update.ts +++ b/src/commands/status.update.ts @@ -1,10 +1,10 @@ +import { formatCliCommand } from "../cli/command-format.js"; import { resolveOpenClawPackageRoot } from "../infra/openclaw-root.js"; import { checkUpdateStatus, compareSemverStrings, type UpdateCheckResult, } from "../infra/update-check.js"; -import { formatCliCommand } from "../cli/command-format.js"; import { VERSION } from "../version.js"; export async function getUpdateCheckResult(params: { diff --git a/src/commands/systemd-linger.ts b/src/commands/systemd-linger.ts index f810f5c2500..ef0356f8f83 100644 --- a/src/commands/systemd-linger.ts +++ b/src/commands/systemd-linger.ts @@ -1,9 +1,9 @@ +import type { RuntimeEnv } from "../runtime.js"; import { enableSystemdUserLinger, isSystemdUserServiceAvailable, readSystemdUserLingerStatus, } from "../daemon/systemd.js"; -import type { RuntimeEnv } from "../runtime.js"; import { note } from "../terminal/note.js"; export type LingerPrompter = { diff --git a/src/commands/uninstall.ts b/src/commands/uninstall.ts index 1843edc6e17..6f9e9941e3c 100644 --- a/src/commands/uninstall.ts +++ b/src/commands/uninstall.ts @@ -1,6 +1,6 @@ -import path from "node:path"; import { cancel, confirm, isCancel, multiselect } from "@clack/prompts"; - +import path from "node:path"; +import type { RuntimeEnv } from "../runtime.js"; import { isNixMode, loadConfig, @@ -9,7 +9,6 @@ import { resolveStateDir, } from "../config/config.js"; import { resolveGatewayService } from "../daemon/service.js"; -import type { RuntimeEnv } from "../runtime.js"; import { stylePromptHint, stylePromptMessage, stylePromptTitle } from "../terminal/prompt-style.js"; import { resolveHomeDir } from "../utils.js"; import { collectWorkspaceDirs, isPathWithin, removePath } from "./cleanup-utils.js"; diff --git a/src/config/agent-dirs.ts b/src/config/agent-dirs.ts index 1860230587f..6ba4c875de0 100644 --- a/src/config/agent-dirs.ts +++ b/src/config/agent-dirs.ts @@ -1,9 +1,9 @@ import os from "node:os"; import path from "node:path"; +import type { OpenClawConfig } from "./types.js"; import { DEFAULT_AGENT_ID, normalizeAgentId } from "../routing/session-key.js"; import { resolveUserPath } from "../utils.js"; import { resolveStateDir } from "./paths.js"; -import type { OpenClawConfig } from "./types.js"; export type DuplicateAgentDir = { agentDir: string; diff --git a/src/config/channel-capabilities.test.ts b/src/config/channel-capabilities.test.ts index 7af4c320108..ca67fdd8f13 100644 --- a/src/config/channel-capabilities.test.ts +++ b/src/config/channel-capabilities.test.ts @@ -1,9 +1,9 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest"; import type { ChannelPlugin } from "../channels/plugins/types.js"; import type { PluginRegistry } from "../plugins/registry.js"; +import type { OpenClawConfig } from "./config.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import { resolveChannelCapabilities } from "./channel-capabilities.js"; -import type { OpenClawConfig } from "./config.js"; describe("resolveChannelCapabilities", () => { beforeEach(() => { diff --git a/src/config/channel-capabilities.ts b/src/config/channel-capabilities.ts index 7e5bd75461c..9754decb1d4 100644 --- a/src/config/channel-capabilities.ts +++ b/src/config/channel-capabilities.ts @@ -1,7 +1,7 @@ -import { normalizeChannelId } from "../channels/plugins/index.js"; -import { normalizeAccountId } from "../routing/session-key.js"; import type { OpenClawConfig } from "./config.js"; import type { TelegramCapabilitiesConfig } from "./types.telegram.js"; +import { normalizeChannelId } from "../channels/plugins/index.js"; +import { normalizeAccountId } from "../routing/session-key.js"; type CapabilitiesConfig = TelegramCapabilitiesConfig; diff --git a/src/config/commands.ts b/src/config/commands.ts index 1271a09e410..7a248faad28 100644 --- a/src/config/commands.ts +++ b/src/config/commands.ts @@ -1,6 +1,6 @@ import type { ChannelId } from "../channels/plugins/types.js"; -import { normalizeChannelId } from "../channels/plugins/index.js"; import type { NativeCommandsSetting } from "./types.js"; +import { normalizeChannelId } from "../channels/plugins/index.js"; function resolveAutoDefault(providerId?: ChannelId): boolean { const id = normalizeChannelId(providerId); diff --git a/src/config/config-paths.test.ts b/src/config/config-paths.test.ts index 61d613f2567..a4dc7192ecd 100644 --- a/src/config/config-paths.test.ts +++ b/src/config/config-paths.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { getConfigValueAtPath, parseConfigPath, diff --git a/src/config/config.backup-rotation.test.ts b/src/config/config.backup-rotation.test.ts index c7785d50334..166deed0dca 100644 --- a/src/config/config.backup-rotation.test.ts +++ b/src/config/config.backup-rotation.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; - import { describe, expect, it } from "vitest"; - -import { withTempHome } from "./test-helpers.js"; import type { OpenClawConfig } from "./types.js"; +import { withTempHome } from "./test-helpers.js"; describe("config backup rotation", () => { it("keeps a 5-deep backup ring for config writes", async () => { diff --git a/src/config/config.identity-avatar.test.ts b/src/config/config.identity-avatar.test.ts index 61751e27ea5..0f3ab8865fb 100644 --- a/src/config/config.identity-avatar.test.ts +++ b/src/config/config.identity-avatar.test.ts @@ -1,7 +1,5 @@ import path from "node:path"; - import { describe, expect, it } from "vitest"; - import { validateConfigObject } from "./config.js"; import { withTempHome } from "./test-helpers.js"; diff --git a/src/config/config.plugin-validation.test.ts b/src/config/config.plugin-validation.test.ts index caeddf201a5..35e4b9a8a50 100644 --- a/src/config/config.plugin-validation.test.ts +++ b/src/config/config.plugin-validation.test.ts @@ -1,8 +1,6 @@ import fs from "node:fs/promises"; import path from "node:path"; - import { describe, expect, it, vi } from "vitest"; - import { withTempHome } from "./test-helpers.js"; async function writePluginFixture(params: { diff --git a/src/config/config.skills-entries-config.test.ts b/src/config/config.skills-entries-config.test.ts index 3295281e6d5..c0398219642 100644 --- a/src/config/config.skills-entries-config.test.ts +++ b/src/config/config.skills-entries-config.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { OpenClawSchema } from "./zod-schema.js"; describe("skills entries config schema", () => { diff --git a/src/config/config.telegram-custom-commands.test.ts b/src/config/config.telegram-custom-commands.test.ts index cb21cd86dc7..8b6a8a4b601 100644 --- a/src/config/config.telegram-custom-commands.test.ts +++ b/src/config/config.telegram-custom-commands.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { OpenClawSchema } from "./zod-schema.js"; describe("telegram custom commands schema", () => { diff --git a/src/config/config.tools-alsoAllow.test.ts b/src/config/config.tools-alsoAllow.test.ts index aea4f02d989..ac800b060c3 100644 --- a/src/config/config.tools-alsoAllow.test.ts +++ b/src/config/config.tools-alsoAllow.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { validateConfigObject } from "./validation.js"; // NOTE: These tests ensure allow + alsoAllow cannot be set in the same scope. diff --git a/src/config/config.web-search-provider.test.ts b/src/config/config.web-search-provider.test.ts index a91c0f438de..a0f1c6acded 100644 --- a/src/config/config.web-search-provider.test.ts +++ b/src/config/config.web-search-provider.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { validateConfigObject } from "./config.js"; describe("web search provider config", () => { diff --git a/src/config/defaults.ts b/src/config/defaults.ts index 686b4c09c8e..e944d82115e 100644 --- a/src/config/defaults.ts +++ b/src/config/defaults.ts @@ -1,9 +1,9 @@ +import type { OpenClawConfig } from "./types.js"; +import type { ModelDefinitionConfig } from "./types.models.js"; import { DEFAULT_CONTEXT_TOKENS } from "../agents/defaults.js"; import { parseModelRef } from "../agents/model-selection.js"; -import { resolveTalkApiKey } from "./talk.js"; -import type { OpenClawConfig } from "./types.js"; import { DEFAULT_AGENT_MAX_CONCURRENT, DEFAULT_SUBAGENT_MAX_CONCURRENT } from "./agent-limits.js"; -import type { ModelDefinitionConfig } from "./types.models.js"; +import { resolveTalkApiKey } from "./talk.js"; type WarnState = { warned: boolean }; diff --git a/src/config/env-substitution.test.ts b/src/config/env-substitution.test.ts index 8fad7071122..cb9924e52c9 100644 --- a/src/config/env-substitution.test.ts +++ b/src/config/env-substitution.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { MissingEnvVarError, resolveConfigEnvVars } from "./env-substitution.js"; describe("resolveConfigEnvVars", () => { diff --git a/src/config/group-policy.ts b/src/config/group-policy.ts index 7472d39081f..2adc60f9bc0 100644 --- a/src/config/group-policy.ts +++ b/src/config/group-policy.ts @@ -1,7 +1,7 @@ import type { ChannelId } from "../channels/plugins/types.js"; -import { normalizeAccountId } from "../routing/session-key.js"; import type { OpenClawConfig } from "./config.js"; import type { GroupToolPolicyBySenderConfig, GroupToolPolicyConfig } from "./types.tools.js"; +import { normalizeAccountId } from "../routing/session-key.js"; export type GroupPolicyChannel = ChannelId; diff --git a/src/config/includes.test.ts b/src/config/includes.test.ts index d55c299bfc8..4c7f6b6be92 100644 --- a/src/config/includes.test.ts +++ b/src/config/includes.test.ts @@ -1,7 +1,5 @@ import path from "node:path"; - import { describe, expect, it } from "vitest"; - import { CircularIncludeError, ConfigIncludeError, diff --git a/src/config/includes.ts b/src/config/includes.ts index 1817e47e365..5f7982b337a 100644 --- a/src/config/includes.ts +++ b/src/config/includes.ts @@ -10,11 +10,10 @@ * ``` */ +import JSON5 from "json5"; import fs from "node:fs"; import path from "node:path"; -import JSON5 from "json5"; - export const INCLUDE_KEY = "$include"; export const MAX_INCLUDE_DEPTH = 10; diff --git a/src/config/io.compat.test.ts b/src/config/io.compat.test.ts index 0d69470a7dd..4618f639f1a 100644 --- a/src/config/io.compat.test.ts +++ b/src/config/io.compat.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { describe, expect, it } from "vitest"; - import { createConfigIO } from "./io.js"; async function withTempHome(run: (home: string) => Promise): Promise { diff --git a/src/config/io.ts b/src/config/io.ts index bb9956a0ab7..d4b9938c317 100644 --- a/src/config/io.ts +++ b/src/config/io.ts @@ -1,16 +1,16 @@ +import JSON5 from "json5"; import crypto from "node:crypto"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - -import JSON5 from "json5"; - +import type { OpenClawConfig, ConfigFileSnapshot, LegacyConfigIssue } from "./types.js"; import { loadShellEnvFallback, resolveShellEnvFallbackTimeoutMs, shouldDeferShellEnvFallback, shouldEnableShellEnvFallback, } from "../infra/shell-env.js"; +import { VERSION } from "../version.js"; import { DuplicateAgentDirError, findDuplicateAgentDirs } from "./agent-dirs.js"; import { applyCompactionDefaults, @@ -22,7 +22,6 @@ import { applySessionDefaults, applyTalkApiKey, } from "./defaults.js"; -import { VERSION } from "../version.js"; import { MissingEnvVarError, resolveConfigEnvVars } from "./env-substitution.js"; import { collectConfigEnvVars } from "./env-vars.js"; import { ConfigIncludeError, resolveConfigIncludes } from "./includes.js"; @@ -30,7 +29,6 @@ import { findLegacyConfigIssues } from "./legacy.js"; import { normalizeConfigPaths } from "./normalize-paths.js"; import { resolveConfigPath, resolveDefaultConfigCandidates, resolveStateDir } from "./paths.js"; import { applyConfigOverrides } from "./runtime-overrides.js"; -import type { OpenClawConfig, ConfigFileSnapshot, LegacyConfigIssue } from "./types.js"; import { validateConfigObjectWithPlugins } from "./validation.js"; import { compareOpenClawVersions } from "./version.js"; diff --git a/src/config/legacy-migrate.ts b/src/config/legacy-migrate.ts index fedb59c2d63..15617f19808 100644 --- a/src/config/legacy-migrate.ts +++ b/src/config/legacy-migrate.ts @@ -1,5 +1,5 @@ -import { applyLegacyMigrations } from "./legacy.js"; import type { OpenClawConfig } from "./types.js"; +import { applyLegacyMigrations } from "./legacy.js"; import { validateConfigObjectWithPlugins } from "./validation.js"; export function migrateLegacyConfig(raw: unknown): { diff --git a/src/config/legacy.ts b/src/config/legacy.ts index 4f34fb95631..c5ba7d02fc3 100644 --- a/src/config/legacy.ts +++ b/src/config/legacy.ts @@ -1,6 +1,6 @@ +import type { LegacyConfigIssue } from "./types.js"; import { LEGACY_CONFIG_MIGRATIONS } from "./legacy.migrations.js"; import { LEGACY_CONFIG_RULES } from "./legacy.rules.js"; -import type { LegacyConfigIssue } from "./types.js"; export function findLegacyConfigIssues(raw: unknown): LegacyConfigIssue[] { if (!raw || typeof raw !== "object") { diff --git a/src/config/markdown-tables.ts b/src/config/markdown-tables.ts index 8815a90b139..d74ee20d7d4 100644 --- a/src/config/markdown-tables.ts +++ b/src/config/markdown-tables.ts @@ -1,7 +1,7 @@ -import { normalizeChannelId } from "../channels/plugins/index.js"; -import { normalizeAccountId } from "../routing/session-key.js"; import type { OpenClawConfig } from "./config.js"; import type { MarkdownTableMode } from "./types.base.js"; +import { normalizeChannelId } from "../channels/plugins/index.js"; +import { normalizeAccountId } from "../routing/session-key.js"; type MarkdownConfigEntry = { markdown?: { diff --git a/src/config/model-alias-defaults.test.ts b/src/config/model-alias-defaults.test.ts index 82bff85dada..b0fb9ac6b38 100644 --- a/src/config/model-alias-defaults.test.ts +++ b/src/config/model-alias-defaults.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from "vitest"; +import type { OpenClawConfig } from "./types.js"; import { DEFAULT_CONTEXT_TOKENS } from "../agents/defaults.js"; import { applyModelDefaults } from "./defaults.js"; -import type { OpenClawConfig } from "./types.js"; describe("applyModelDefaults", () => { it("adds default aliases when models are present", () => { diff --git a/src/config/normalize-paths.test.ts b/src/config/normalize-paths.test.ts index f2e2569cd80..c3059495b37 100644 --- a/src/config/normalize-paths.test.ts +++ b/src/config/normalize-paths.test.ts @@ -1,7 +1,5 @@ import path from "node:path"; - import { describe, expect, it, vi } from "vitest"; - import { withTempHome } from "../../test/helpers/temp-home.js"; describe("normalizeConfigPaths", () => { diff --git a/src/config/normalize-paths.ts b/src/config/normalize-paths.ts index 187815f5da1..165c715a947 100644 --- a/src/config/normalize-paths.ts +++ b/src/config/normalize-paths.ts @@ -1,5 +1,5 @@ -import { resolveUserPath } from "../utils.js"; import type { OpenClawConfig } from "./types.js"; +import { resolveUserPath } from "../utils.js"; const PATH_VALUE_RE = /^~(?=$|[\\/])/; diff --git a/src/config/paths.test.ts b/src/config/paths.test.ts index 247cdeb510a..1b5c803e68f 100644 --- a/src/config/paths.test.ts +++ b/src/config/paths.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { describe, expect, it, vi } from "vitest"; - import { resolveDefaultConfigCandidates, resolveConfigPath, diff --git a/src/config/plugin-auto-enable.ts b/src/config/plugin-auto-enable.ts index a7b8184f343..800e7634d5e 100644 --- a/src/config/plugin-auto-enable.ts +++ b/src/config/plugin-auto-enable.ts @@ -1,14 +1,14 @@ import type { OpenClawConfig } from "./config.js"; +import { normalizeProviderId } from "../agents/model-selection.js"; +import { + getChannelPluginCatalogEntry, + listChannelPluginCatalogEntries, +} from "../channels/plugins/catalog.js"; import { getChatChannelMeta, listChatChannels, normalizeChatChannelId, } from "../channels/registry.js"; -import { - getChannelPluginCatalogEntry, - listChannelPluginCatalogEntries, -} from "../channels/plugins/catalog.js"; -import { normalizeProviderId } from "../agents/model-selection.js"; import { hasAnyWhatsAppAuth } from "../web/accounts.js"; type PluginEnableChange = { diff --git a/src/config/runtime-overrides.test.ts b/src/config/runtime-overrides.test.ts index 2f859e10bee..3dfdf4457c8 100644 --- a/src/config/runtime-overrides.test.ts +++ b/src/config/runtime-overrides.test.ts @@ -1,4 +1,5 @@ import { beforeEach, describe, expect, it } from "vitest"; +import type { OpenClawConfig } from "./types.js"; import { applyConfigOverrides, getConfigOverrides, @@ -6,7 +7,6 @@ import { setConfigOverride, unsetConfigOverride, } from "./runtime-overrides.js"; -import type { OpenClawConfig } from "./types.js"; describe("runtime overrides", () => { beforeEach(() => { diff --git a/src/config/runtime-overrides.ts b/src/config/runtime-overrides.ts index 5bfae75af34..fb3fe585a4c 100644 --- a/src/config/runtime-overrides.ts +++ b/src/config/runtime-overrides.ts @@ -1,5 +1,5 @@ -import { parseConfigPath, setConfigValueAtPath, unsetConfigValueAtPath } from "./config-paths.js"; import type { OpenClawConfig } from "./types.js"; +import { parseConfigPath, setConfigValueAtPath, unsetConfigValueAtPath } from "./config-paths.js"; type OverrideTree = Record; diff --git a/src/config/schema.test.ts b/src/config/schema.test.ts index c6525ad8205..f7f90f37e47 100644 --- a/src/config/schema.test.ts +++ b/src/config/schema.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { buildConfigSchema } from "./schema.js"; describe("config schema", () => { diff --git a/src/config/sessions.test.ts b/src/config/sessions.test.ts index 606e0984ea8..1a0d204350e 100644 --- a/src/config/sessions.test.ts +++ b/src/config/sessions.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { describe, expect, it } from "vitest"; - import { buildGroupDisplayName, deriveSessionKey, diff --git a/src/config/sessions/group.ts b/src/config/sessions/group.ts index d02726a0044..76ff191cc5b 100644 --- a/src/config/sessions/group.ts +++ b/src/config/sessions/group.ts @@ -1,6 +1,6 @@ import type { MsgContext } from "../../auto-reply/templating.js"; -import { listDeliverableMessageChannels } from "../../utils/message-channel.js"; import type { GroupKeyResolution } from "./types.js"; +import { listDeliverableMessageChannels } from "../../utils/message-channel.js"; const getGroupSurfaces = () => new Set([...listDeliverableMessageChannels(), "webchat"]); diff --git a/src/config/sessions/main-session.ts b/src/config/sessions/main-session.ts index b9e4ef16423..ea90fc8bb78 100644 --- a/src/config/sessions/main-session.ts +++ b/src/config/sessions/main-session.ts @@ -1,3 +1,4 @@ +import type { SessionScope } from "./types.js"; import { buildAgentMainSessionKey, DEFAULT_AGENT_ID, @@ -6,7 +7,6 @@ import { resolveAgentIdFromSessionKey, } from "../../routing/session-key.js"; import { loadConfig } from "../config.js"; -import type { SessionScope } from "./types.js"; export function resolveMainSessionKey(cfg?: { session?: { scope?: SessionScope; mainKey?: string }; diff --git a/src/config/sessions/metadata.test.ts b/src/config/sessions/metadata.test.ts index c532b862be2..c85624f0cbb 100644 --- a/src/config/sessions/metadata.test.ts +++ b/src/config/sessions/metadata.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { deriveSessionMetaPatch } from "./metadata.js"; describe("deriveSessionMetaPatch", () => { diff --git a/src/config/sessions/metadata.ts b/src/config/sessions/metadata.ts index c438fd60f2b..b250951b351 100644 --- a/src/config/sessions/metadata.ts +++ b/src/config/sessions/metadata.ts @@ -1,11 +1,11 @@ import type { MsgContext } from "../../auto-reply/templating.js"; +import type { GroupKeyResolution, SessionEntry, SessionOrigin } from "./types.js"; import { normalizeChatType } from "../../channels/chat-type.js"; import { resolveConversationLabel } from "../../channels/conversation-label.js"; import { getChannelDock } from "../../channels/dock.js"; import { normalizeChannelId } from "../../channels/plugins/index.js"; import { normalizeMessageChannel } from "../../utils/message-channel.js"; import { buildGroupDisplayName, resolveGroupSessionKey } from "./group.js"; -import type { GroupKeyResolution, SessionEntry, SessionOrigin } from "./types.js"; const mergeOrigin = ( existing: SessionOrigin | undefined, diff --git a/src/config/sessions/paths.ts b/src/config/sessions/paths.ts index 7987631971b..f4a1e35e978 100644 --- a/src/config/sessions/paths.ts +++ b/src/config/sessions/paths.ts @@ -1,8 +1,8 @@ import os from "node:os"; import path from "node:path"; +import type { SessionEntry } from "./types.js"; import { DEFAULT_AGENT_ID, normalizeAgentId } from "../../routing/session-key.js"; import { resolveStateDir } from "../paths.js"; -import type { SessionEntry } from "./types.js"; function resolveAgentSessionsDir( agentId?: string, diff --git a/src/config/sessions/reset.ts b/src/config/sessions/reset.ts index 5ae0ca680a1..ca856fb7881 100644 --- a/src/config/sessions/reset.ts +++ b/src/config/sessions/reset.ts @@ -1,6 +1,6 @@ import type { SessionConfig, SessionResetConfig } from "../types.base.js"; -import { DEFAULT_IDLE_MINUTES } from "./types.js"; import { normalizeMessageChannel } from "../../utils/message-channel.js"; +import { DEFAULT_IDLE_MINUTES } from "./types.js"; export type SessionResetMode = "daily" | "idle"; export type SessionResetType = "dm" | "group" | "thread"; diff --git a/src/config/sessions/session-key.ts b/src/config/sessions/session-key.ts index 3244f5c7c60..08c645f3cf3 100644 --- a/src/config/sessions/session-key.ts +++ b/src/config/sessions/session-key.ts @@ -1,4 +1,5 @@ import type { MsgContext } from "../../auto-reply/templating.js"; +import type { SessionScope } from "./types.js"; import { buildAgentMainSessionKey, DEFAULT_AGENT_ID, @@ -6,7 +7,6 @@ import { } from "../../routing/session-key.js"; import { normalizeE164 } from "../../utils.js"; import { resolveGroupSessionKey } from "./group.js"; -import type { SessionScope } from "./types.js"; // Decide which session bucket to use (per-sender vs global). export function deriveSessionKey(scope: SessionScope, ctx: MsgContext) { diff --git a/src/config/sessions/store.ts b/src/config/sessions/store.ts index 8f1833257ee..ae239ae8801 100644 --- a/src/config/sessions/store.ts +++ b/src/config/sessions/store.ts @@ -1,9 +1,8 @@ +import JSON5 from "json5"; import crypto from "node:crypto"; import fs from "node:fs"; import path from "node:path"; - -import JSON5 from "json5"; -import { getFileMtimeMs, isCacheEnabled, resolveCacheTtlMs } from "../cache-utils.js"; +import type { MsgContext } from "../../auto-reply/templating.js"; import { deliveryContextFromSession, mergeDeliveryContext, @@ -11,7 +10,7 @@ import { normalizeSessionDeliveryFields, type DeliveryContext, } from "../../utils/delivery-context.js"; -import type { MsgContext } from "../../auto-reply/templating.js"; +import { getFileMtimeMs, isCacheEnabled, resolveCacheTtlMs } from "../cache-utils.js"; import { deriveSessionMetaPatch } from "./metadata.js"; import { mergeSessionEntry, type SessionEntry } from "./types.js"; diff --git a/src/config/sessions/transcript.ts b/src/config/sessions/transcript.ts index 0f67a7f2c97..864825f0b6d 100644 --- a/src/config/sessions/transcript.ts +++ b/src/config/sessions/transcript.ts @@ -1,12 +1,10 @@ +import { CURRENT_SESSION_VERSION, SessionManager } from "@mariozechner/pi-coding-agent"; import fs from "node:fs"; import path from "node:path"; - -import { CURRENT_SESSION_VERSION, SessionManager } from "@mariozechner/pi-coding-agent"; - import type { SessionEntry } from "./types.js"; -import { loadSessionStore, updateSessionStore } from "./store.js"; -import { resolveDefaultSessionStorePath, resolveSessionTranscriptPath } from "./paths.js"; import { emitSessionTranscriptUpdate } from "../../sessions/transcript-events.js"; +import { resolveDefaultSessionStorePath, resolveSessionTranscriptPath } from "./paths.js"; +import { loadSessionStore, updateSessionStore } from "./store.js"; function stripQuery(value: string): string { const noHash = value.split("#")[0] ?? value; diff --git a/src/config/sessions/types.ts b/src/config/sessions/types.ts index 5ec81a8ab46..ec0fadf7c08 100644 --- a/src/config/sessions/types.ts +++ b/src/config/sessions/types.ts @@ -1,6 +1,5 @@ -import crypto from "node:crypto"; - import type { Skill } from "@mariozechner/pi-coding-agent"; +import crypto from "node:crypto"; import type { NormalizedChatType } from "../../channels/chat-type.js"; import type { ChannelId } from "../../channels/plugins/types.js"; import type { DeliveryContext } from "../../utils/delivery-context.js"; diff --git a/src/config/slack-http-config.test.ts b/src/config/slack-http-config.test.ts index ec30479a25c..baa1283e3f3 100644 --- a/src/config/slack-http-config.test.ts +++ b/src/config/slack-http-config.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { validateConfigObject } from "./config.js"; describe("Slack HTTP mode config", () => { diff --git a/src/config/slack-token-validation.test.ts b/src/config/slack-token-validation.test.ts index ce25a5f4216..8a678afdc10 100644 --- a/src/config/slack-token-validation.test.ts +++ b/src/config/slack-token-validation.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { validateConfigObject } from "./config.js"; describe("Slack token config fields", () => { diff --git a/src/config/test-helpers.ts b/src/config/test-helpers.ts index 82b39d5f135..5831c0665d8 100644 --- a/src/config/test-helpers.ts +++ b/src/config/test-helpers.ts @@ -1,5 +1,4 @@ import { vi } from "vitest"; - import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; export async function withTempHome(fn: (home: string) => Promise): Promise { diff --git a/src/config/types.agent-defaults.ts b/src/config/types.agent-defaults.ts index 9c6ce0211ff..319a6f9fc99 100644 --- a/src/config/types.agent-defaults.ts +++ b/src/config/types.agent-defaults.ts @@ -1,10 +1,10 @@ +import type { ChannelId } from "../channels/plugins/types.js"; import type { BlockStreamingChunkConfig, BlockStreamingCoalesceConfig, HumanDelayConfig, TypingMode, } from "./types.base.js"; -import type { ChannelId } from "../channels/plugins/types.js"; import type { SandboxBrowserSettings, SandboxDockerSettings, diff --git a/src/config/types.channels.ts b/src/config/types.channels.ts index 77f4f1bc3af..b6319f3a53a 100644 --- a/src/config/types.channels.ts +++ b/src/config/types.channels.ts @@ -1,3 +1,4 @@ +import type { GroupPolicy } from "./types.base.js"; import type { DiscordConfig } from "./types.discord.js"; import type { GoogleChatConfig } from "./types.googlechat.js"; import type { IMessageConfig } from "./types.imessage.js"; @@ -6,7 +7,6 @@ import type { SignalConfig } from "./types.signal.js"; import type { SlackConfig } from "./types.slack.js"; import type { TelegramConfig } from "./types.telegram.js"; import type { WhatsAppConfig } from "./types.whatsapp.js"; -import type { GroupPolicy } from "./types.base.js"; export type ChannelHeartbeatVisibilityConfig = { /** Show HEARTBEAT_OK acknowledgments in chat (default: false). */ diff --git a/src/config/ui-seam-color.test.ts b/src/config/ui-seam-color.test.ts index 9865e0e93ca..6483a0c8129 100644 --- a/src/config/ui-seam-color.test.ts +++ b/src/config/ui-seam-color.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { validateConfigObject } from "./config.js"; describe("ui.seamColor", () => { diff --git a/src/config/validation.ts b/src/config/validation.ts index 2a5946f729f..2ad57e6d0dc 100644 --- a/src/config/validation.ts +++ b/src/config/validation.ts @@ -1,5 +1,5 @@ import path from "node:path"; - +import type { OpenClawConfig, ConfigValidationIssue } from "./types.js"; import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; import { CHANNEL_IDS, normalizeChatChannelId } from "../channels/registry.js"; import { @@ -12,7 +12,6 @@ import { validateJsonSchemaValue } from "../plugins/schema-validator.js"; import { findDuplicateAgentDirs, formatDuplicateAgentDirError } from "./agent-dirs.js"; import { applyAgentDefaults, applyModelDefaults, applySessionDefaults } from "./defaults.js"; import { findLegacyConfigIssues } from "./legacy.js"; -import type { OpenClawConfig, ConfigValidationIssue } from "./types.js"; import { OpenClawSchema } from "./zod-schema.js"; const AVATAR_SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i; diff --git a/src/config/zod-schema.agent-runtime.ts b/src/config/zod-schema.agent-runtime.ts index 228bfc70ac5..aec597c54b6 100644 --- a/src/config/zod-schema.agent-runtime.ts +++ b/src/config/zod-schema.agent-runtime.ts @@ -1,5 +1,4 @@ import { z } from "zod"; - import { parseDurationMs } from "../cli/parse-duration.js"; import { GroupChatSchema, diff --git a/src/config/zod-schema.core.ts b/src/config/zod-schema.core.ts index 8f2fcf6f11a..627a8987331 100644 --- a/src/config/zod-schema.core.ts +++ b/src/config/zod-schema.core.ts @@ -1,5 +1,4 @@ import { z } from "zod"; - import { isSafeExecutableValue } from "../infra/exec-safety.js"; export const ModelApiSchema = z.union([ diff --git a/src/config/zod-schema.providers-core.ts b/src/config/zod-schema.providers-core.ts index a1ca83f7ded..9f0582fdc1e 100644 --- a/src/config/zod-schema.providers-core.ts +++ b/src/config/zod-schema.providers-core.ts @@ -1,5 +1,11 @@ import { z } from "zod"; - +import { + normalizeTelegramCommandDescription, + normalizeTelegramCommandName, + resolveTelegramCustomCommands, +} from "./telegram-custom-commands.js"; +import { ToolPolicySchema } from "./zod-schema.agent-runtime.js"; +import { ChannelHeartbeatVisibilitySchema } from "./zod-schema.channels.js"; import { BlockStreamingChunkSchema, BlockStreamingCoalesceSchema, @@ -14,13 +20,6 @@ import { RetryConfigSchema, requireOpenAllowFrom, } from "./zod-schema.core.js"; -import { ToolPolicySchema } from "./zod-schema.agent-runtime.js"; -import { ChannelHeartbeatVisibilitySchema } from "./zod-schema.channels.js"; -import { - normalizeTelegramCommandDescription, - normalizeTelegramCommandName, - resolveTelegramCustomCommands, -} from "./telegram-custom-commands.js"; const ToolPolicyBySenderSchema = z.record(z.string(), ToolPolicySchema).optional(); diff --git a/src/config/zod-schema.providers-whatsapp.ts b/src/config/zod-schema.providers-whatsapp.ts index 108a731ee42..9a549250420 100644 --- a/src/config/zod-schema.providers-whatsapp.ts +++ b/src/config/zod-schema.providers-whatsapp.ts @@ -1,5 +1,6 @@ import { z } from "zod"; - +import { ToolPolicySchema } from "./zod-schema.agent-runtime.js"; +import { ChannelHeartbeatVisibilitySchema } from "./zod-schema.channels.js"; import { BlockStreamingCoalesceSchema, DmConfigSchema, @@ -7,8 +8,6 @@ import { GroupPolicySchema, MarkdownConfigSchema, } from "./zod-schema.core.js"; -import { ToolPolicySchema } from "./zod-schema.agent-runtime.js"; -import { ChannelHeartbeatVisibilitySchema } from "./zod-schema.channels.js"; const ToolPolicyBySenderSchema = z.record(z.string(), ToolPolicySchema).optional(); diff --git a/src/config/zod-schema.providers.ts b/src/config/zod-schema.providers.ts index 0a7ec9db866..f227fccf650 100644 --- a/src/config/zod-schema.providers.ts +++ b/src/config/zod-schema.providers.ts @@ -1,5 +1,6 @@ import { z } from "zod"; - +import { ChannelHeartbeatVisibilitySchema } from "./zod-schema.channels.js"; +import { GroupPolicySchema } from "./zod-schema.core.js"; import { BlueBubblesConfigSchema, DiscordConfigSchema, @@ -11,8 +12,6 @@ import { TelegramConfigSchema, } from "./zod-schema.providers-core.js"; import { WhatsAppConfigSchema } from "./zod-schema.providers-whatsapp.js"; -import { GroupPolicySchema } from "./zod-schema.core.js"; -import { ChannelHeartbeatVisibilitySchema } from "./zod-schema.channels.js"; export * from "./zod-schema.providers-core.js"; export * from "./zod-schema.providers-whatsapp.js"; diff --git a/src/config/zod-schema.session.ts b/src/config/zod-schema.session.ts index 4412f551502..a5fd889da09 100644 --- a/src/config/zod-schema.session.ts +++ b/src/config/zod-schema.session.ts @@ -1,5 +1,4 @@ import { z } from "zod"; - import { GroupChatSchema, InboundDebounceSchema, diff --git a/src/config/zod-schema.ts b/src/config/zod-schema.ts index 044dbf54d33..c9691e0e162 100644 --- a/src/config/zod-schema.ts +++ b/src/config/zod-schema.ts @@ -1,7 +1,7 @@ import { z } from "zod"; import { ToolsSchema } from "./zod-schema.agent-runtime.js"; -import { ApprovalsSchema } from "./zod-schema.approvals.js"; import { AgentsSchema, AudioSchema, BindingsSchema, BroadcastSchema } from "./zod-schema.agents.js"; +import { ApprovalsSchema } from "./zod-schema.approvals.js"; import { HexColorSchema, ModelsConfigSchema } from "./zod-schema.core.js"; import { HookMappingSchema, HooksGmailSchema, InternalHooksSchema } from "./zod-schema.hooks.js"; import { ChannelsSchema } from "./zod-schema.providers.js"; diff --git a/src/cron/isolated-agent.delivers-response-has-heartbeat-ok-but-includes.test.ts b/src/cron/isolated-agent.delivers-response-has-heartbeat-ok-but-includes.test.ts index 49a6d644e81..7745fe828ad 100644 --- a/src/cron/isolated-agent.delivers-response-has-heartbeat-ok-but-includes.test.ts +++ b/src/cron/isolated-agent.delivers-response-has-heartbeat-ok-but-includes.test.ts @@ -1,12 +1,10 @@ import fs from "node:fs/promises"; import path from "node:path"; - import { beforeEach, describe, expect, it, vi } from "vitest"; - -import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; import type { CliDeps } from "../cli/deps.js"; import type { OpenClawConfig } from "../config/config.js"; import type { CronJob } from "./types.js"; +import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; vi.mock("../agents/pi-embedded.js", () => ({ abortEmbeddedPiRun: vi.fn().mockReturnValue(false), diff --git a/src/cron/isolated-agent.skips-delivery-without-whatsapp-recipient-besteffortdeliver-true.test.ts b/src/cron/isolated-agent.skips-delivery-without-whatsapp-recipient-besteffortdeliver-true.test.ts index ca211554e16..078893563ae 100644 --- a/src/cron/isolated-agent.skips-delivery-without-whatsapp-recipient-besteffortdeliver-true.test.ts +++ b/src/cron/isolated-agent.skips-delivery-without-whatsapp-recipient-besteffortdeliver-true.test.ts @@ -1,21 +1,19 @@ import fs from "node:fs/promises"; import path from "node:path"; - import { beforeEach, describe, expect, it, vi } from "vitest"; - -import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; import type { CliDeps } from "../cli/deps.js"; import type { OpenClawConfig } from "../config/config.js"; +import type { CronJob } from "./types.js"; +import { discordPlugin } from "../../extensions/discord/src/channel.js"; +import { setDiscordRuntime } from "../../extensions/discord/src/runtime.js"; +import { telegramPlugin } from "../../extensions/telegram/src/channel.js"; +import { setTelegramRuntime } from "../../extensions/telegram/src/runtime.js"; +import { whatsappPlugin } from "../../extensions/whatsapp/src/channel.js"; +import { setWhatsAppRuntime } from "../../extensions/whatsapp/src/runtime.js"; +import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import { createPluginRuntime } from "../plugins/runtime/index.js"; import { createTestRegistry } from "../test-utils/channel-plugins.js"; -import type { CronJob } from "./types.js"; -import { discordPlugin } from "../../extensions/discord/src/channel.js"; -import { telegramPlugin } from "../../extensions/telegram/src/channel.js"; -import { whatsappPlugin } from "../../extensions/whatsapp/src/channel.js"; -import { setDiscordRuntime } from "../../extensions/discord/src/runtime.js"; -import { setTelegramRuntime } from "../../extensions/telegram/src/runtime.js"; -import { setWhatsAppRuntime } from "../../extensions/whatsapp/src/runtime.js"; vi.mock("../agents/pi-embedded.js", () => ({ abortEmbeddedPiRun: vi.fn().mockReturnValue(false), diff --git a/src/cron/isolated-agent.uses-last-non-empty-agent-text-as.test.ts b/src/cron/isolated-agent.uses-last-non-empty-agent-text-as.test.ts index 8f5a4507980..3340225d93d 100644 --- a/src/cron/isolated-agent.uses-last-non-empty-agent-text-as.test.ts +++ b/src/cron/isolated-agent.uses-last-non-empty-agent-text-as.test.ts @@ -1,12 +1,10 @@ import fs from "node:fs/promises"; import path from "node:path"; - import { beforeEach, describe, expect, it, vi } from "vitest"; - -import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; import type { CliDeps } from "../cli/deps.js"; import type { OpenClawConfig } from "../config/config.js"; import type { CronJob } from "./types.js"; +import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js"; vi.mock("../agents/pi-embedded.js", () => ({ abortEmbeddedPiRun: vi.fn().mockReturnValue(false), diff --git a/src/cron/isolated-agent/delivery-target.ts b/src/cron/isolated-agent/delivery-target.ts index a3cfe88ae36..75d5853a641 100644 --- a/src/cron/isolated-agent/delivery-target.ts +++ b/src/cron/isolated-agent/delivery-target.ts @@ -1,13 +1,13 @@ import type { ChannelId } from "../../channels/plugins/types.js"; -import { DEFAULT_CHAT_CHANNEL } from "../../channels/registry.js"; import type { OpenClawConfig } from "../../config/config.js"; +import type { OutboundChannel } from "../../infra/outbound/targets.js"; +import { DEFAULT_CHAT_CHANNEL } from "../../channels/registry.js"; import { loadSessionStore, resolveAgentMainSessionKey, resolveStorePath, } from "../../config/sessions.js"; import { resolveMessageChannelSelection } from "../../infra/outbound/channel-selection.js"; -import type { OutboundChannel } from "../../infra/outbound/targets.js"; import { resolveOutboundTarget, resolveSessionDeliveryTarget, diff --git a/src/cron/isolated-agent/run.ts b/src/cron/isolated-agent/run.ts index 88bee00da62..c0d6ae3cdb2 100644 --- a/src/cron/isolated-agent/run.ts +++ b/src/cron/isolated-agent/run.ts @@ -1,3 +1,7 @@ +import type { MessagingToolSend } from "../../agents/pi-embedded-messaging.js"; +import type { OpenClawConfig } from "../../config/config.js"; +import type { AgentDefaultsConfig } from "../../config/types.js"; +import type { CronJob } from "../types.js"; import { resolveAgentConfig, resolveAgentDir, @@ -8,6 +12,11 @@ import { import { runCliAgent } from "../../agents/cli-runner.js"; import { getCliSessionId, setCliSessionId } from "../../agents/cli-session.js"; import { lookupContextTokens } from "../../agents/context.js"; +import { + formatUserTime, + resolveUserTimeFormat, + resolveUserTimezone, +} from "../../agents/date-time.js"; import { DEFAULT_CONTEXT_TOKENS, DEFAULT_MODEL, DEFAULT_PROVIDER } from "../../agents/defaults.js"; import { loadModelCatalog } from "../../agents/model-catalog.js"; import { runWithModelFallback } from "../../agents/model-fallback.js"; @@ -20,17 +29,11 @@ import { resolveThinkingDefault, } from "../../agents/model-selection.js"; import { runEmbeddedPiAgent } from "../../agents/pi-embedded.js"; -import type { MessagingToolSend } from "../../agents/pi-embedded-messaging.js"; import { buildWorkspaceSkillSnapshot } from "../../agents/skills.js"; import { getSkillsSnapshotVersion } from "../../agents/skills/refresh.js"; import { resolveAgentTimeoutMs } from "../../agents/timeout.js"; import { hasNonzeroUsage } from "../../agents/usage.js"; import { ensureAgentWorkspace } from "../../agents/workspace.js"; -import { - formatUserTime, - resolveUserTimeFormat, - resolveUserTimezone, -} from "../../agents/date-time.js"; import { formatXHighModelHint, normalizeThinkLevel, @@ -38,12 +41,11 @@ import { supportsXHighThinking, } from "../../auto-reply/thinking.js"; import { createOutboundSendDeps, type CliDeps } from "../../cli/outbound-send-deps.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { resolveSessionTranscriptPath, updateSessionStore } from "../../config/sessions.js"; -import type { AgentDefaultsConfig } from "../../config/types.js"; import { registerAgentRunContext } from "../../infra/agent-events.js"; import { deliverOutboundPayloads } from "../../infra/outbound/deliver.js"; import { getRemoteSkillEligibility } from "../../infra/skills-remote.js"; +import { logWarn } from "../../logger.js"; import { buildAgentMainSessionKey, normalizeAgentId } from "../../routing/session-key.js"; import { buildSafeExternalPrompt, @@ -51,8 +53,6 @@ import { getHookType, isExternalHookSession, } from "../../security/external-content.js"; -import { logWarn } from "../../logger.js"; -import type { CronJob } from "../types.js"; import { resolveDeliveryTarget } from "./delivery-target.js"; import { isHeartbeatOnlyResponse, diff --git a/src/cron/isolated-agent/session.ts b/src/cron/isolated-agent/session.ts index 733d499555f..8428efeb4f0 100644 --- a/src/cron/isolated-agent/session.ts +++ b/src/cron/isolated-agent/session.ts @@ -1,5 +1,4 @@ import crypto from "node:crypto"; - import type { OpenClawConfig } from "../../config/config.js"; import { loadSessionStore, resolveStorePath, type SessionEntry } from "../../config/sessions.js"; diff --git a/src/cron/normalize.test.ts b/src/cron/normalize.test.ts index b7823e5375c..12bd6e587d5 100644 --- a/src/cron/normalize.test.ts +++ b/src/cron/normalize.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { normalizeCronJobCreate } from "./normalize.js"; describe("normalizeCronJobCreate", () => { diff --git a/src/cron/normalize.ts b/src/cron/normalize.ts index 427ba028318..13b5cb28984 100644 --- a/src/cron/normalize.ts +++ b/src/cron/normalize.ts @@ -1,7 +1,7 @@ +import type { CronJobCreate, CronJobPatch } from "./types.js"; import { sanitizeAgentId } from "../routing/session-key.js"; import { parseAbsoluteTimeMs } from "./parse.js"; import { migrateLegacyCronPayload } from "./payload-migration.js"; -import type { CronJobCreate, CronJobPatch } from "./types.js"; type UnknownRecord = Record; diff --git a/src/cron/run-log.test.ts b/src/cron/run-log.test.ts index 8b308f4f9b0..cef09acfe2d 100644 --- a/src/cron/run-log.test.ts +++ b/src/cron/run-log.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import { appendCronRunLog, readCronRunLogEntries, resolveCronRunLogPath } from "./run-log.js"; describe("cron run log", () => { diff --git a/src/cron/schedule.test.ts b/src/cron/schedule.test.ts index b0d4fcace15..262e776c52e 100644 --- a/src/cron/schedule.test.ts +++ b/src/cron/schedule.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { computeNextRunAtMs } from "./schedule.js"; describe("cron schedule", () => { diff --git a/src/cron/service.prevents-duplicate-timers.test.ts b/src/cron/service.prevents-duplicate-timers.test.ts index 9f22450a22e..dac1ad634be 100644 --- a/src/cron/service.prevents-duplicate-timers.test.ts +++ b/src/cron/service.prevents-duplicate-timers.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import { CronService } from "./service.js"; const noopLogger = { diff --git a/src/cron/service.runs-one-shot-main-job-disables-it.test.ts b/src/cron/service.runs-one-shot-main-job-disables-it.test.ts index 44aa7b682fc..3bf9f2f5f02 100644 --- a/src/cron/service.runs-one-shot-main-job-disables-it.test.ts +++ b/src/cron/service.runs-one-shot-main-job-disables-it.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import type { HeartbeatRunResult } from "../infra/heartbeat-wake.js"; import { CronService } from "./service.js"; diff --git a/src/cron/service.skips-main-jobs-empty-systemevent-text.test.ts b/src/cron/service.skips-main-jobs-empty-systemevent-text.test.ts index 10f91203420..aa20ba36ad2 100644 --- a/src/cron/service.skips-main-jobs-empty-systemevent-text.test.ts +++ b/src/cron/service.skips-main-jobs-empty-systemevent-text.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import { CronService } from "./service.js"; const noopLogger = { diff --git a/src/cron/service.ts b/src/cron/service.ts index 748fd038d33..8f82a2e6947 100644 --- a/src/cron/service.ts +++ b/src/cron/service.ts @@ -1,6 +1,6 @@ +import type { CronJobCreate, CronJobPatch } from "./types.js"; import * as ops from "./service/ops.js"; import { type CronServiceDeps, createCronServiceState } from "./service/state.js"; -import type { CronJobCreate, CronJobPatch } from "./types.js"; export type { CronEvent, CronServiceDeps } from "./service/state.js"; diff --git a/src/cron/service/jobs.ts b/src/cron/service/jobs.ts index 74e23a41280..e0d566ce351 100644 --- a/src/cron/service/jobs.ts +++ b/src/cron/service/jobs.ts @@ -1,6 +1,4 @@ import crypto from "node:crypto"; - -import { computeNextRunAtMs } from "../schedule.js"; import type { CronJob, CronJobCreate, @@ -8,13 +6,14 @@ import type { CronPayload, CronPayloadPatch, } from "../types.js"; +import type { CronServiceState } from "./state.js"; +import { computeNextRunAtMs } from "../schedule.js"; import { normalizeOptionalAgentId, normalizeOptionalText, normalizePayloadToSystemText, normalizeRequiredName, } from "./normalize.js"; -import type { CronServiceState } from "./state.js"; const STUCK_RUN_MS = 2 * 60 * 60 * 1000; diff --git a/src/cron/service/normalize.ts b/src/cron/service/normalize.ts index 2712a9f86b9..15198c26109 100644 --- a/src/cron/service/normalize.ts +++ b/src/cron/service/normalize.ts @@ -1,6 +1,6 @@ +import type { CronPayload } from "../types.js"; import { normalizeAgentId } from "../../routing/session-key.js"; import { truncateUtf16Safe } from "../../utils.js"; -import type { CronPayload } from "../types.js"; export function normalizeRequiredName(raw: unknown) { if (typeof raw !== "string") { diff --git a/src/cron/service/ops.ts b/src/cron/service/ops.ts index 8e734ea18dd..d1459765692 100644 --- a/src/cron/service/ops.ts +++ b/src/cron/service/ops.ts @@ -1,4 +1,5 @@ import type { CronJobCreate, CronJobPatch } from "../types.js"; +import type { CronServiceState } from "./state.js"; import { applyJobPatch, computeJobNextRunAtMs, @@ -9,7 +10,6 @@ import { recomputeNextRuns, } from "./jobs.js"; import { locked } from "./locked.js"; -import type { CronServiceState } from "./state.js"; import { ensureLoaded, persist, warnIfDisabled } from "./store.js"; import { armTimer, emit, executeJob, stopTimer, wake } from "./timer.js"; diff --git a/src/cron/service/store.ts b/src/cron/service/store.ts index 6b2f041332a..d1d15ad045f 100644 --- a/src/cron/service/store.ts +++ b/src/cron/service/store.ts @@ -1,8 +1,8 @@ +import type { CronJob } from "../types.js"; +import type { CronServiceState } from "./state.js"; import { migrateLegacyCronPayload } from "../payload-migration.js"; import { loadCronStore, saveCronStore } from "../store.js"; -import type { CronJob } from "../types.js"; import { inferLegacyName, normalizeOptionalText } from "./normalize.js"; -import type { CronServiceState } from "./state.js"; const storeCache = new Map(); diff --git a/src/cron/service/timer.ts b/src/cron/service/timer.ts index 9344cdf73e1..d7672c0d248 100644 --- a/src/cron/service/timer.ts +++ b/src/cron/service/timer.ts @@ -1,8 +1,8 @@ import type { HeartbeatRunResult } from "../../infra/heartbeat-wake.js"; import type { CronJob } from "../types.js"; +import type { CronEvent, CronServiceState } from "./state.js"; import { computeJobNextRunAtMs, nextWakeAtMs, resolveJobPayloadTextForMain } from "./jobs.js"; import { locked } from "./locked.js"; -import type { CronEvent, CronServiceState } from "./state.js"; import { ensureLoaded, persist } from "./store.js"; const MAX_TIMEOUT_MS = 2 ** 31 - 1; diff --git a/src/cron/store.ts b/src/cron/store.ts index f74308156f8..5fb296153a4 100644 --- a/src/cron/store.ts +++ b/src/cron/store.ts @@ -1,10 +1,9 @@ +import JSON5 from "json5"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - -import JSON5 from "json5"; -import { CONFIG_DIR } from "../utils.js"; import type { CronStoreFile } from "./types.js"; +import { CONFIG_DIR } from "../utils.js"; export const DEFAULT_CRON_DIR = path.join(CONFIG_DIR, "cron"); export const DEFAULT_CRON_STORE_PATH = path.join(DEFAULT_CRON_DIR, "jobs.json"); diff --git a/src/daemon/diagnostics.ts b/src/daemon/diagnostics.ts index 9592347c23f..ab897964698 100644 --- a/src/daemon/diagnostics.ts +++ b/src/daemon/diagnostics.ts @@ -1,5 +1,4 @@ import fs from "node:fs/promises"; - import { resolveGatewayLogPaths } from "./launchd.js"; const GATEWAY_LOG_ERROR_PATTERNS = [ diff --git a/src/daemon/inspect.ts b/src/daemon/inspect.ts index e8a4d9a3a8d..63970351a9c 100644 --- a/src/daemon/inspect.ts +++ b/src/daemon/inspect.ts @@ -2,7 +2,6 @@ import { execFile } from "node:child_process"; import fs from "node:fs/promises"; import path from "node:path"; import { promisify } from "node:util"; - import { GATEWAY_SERVICE_KIND, GATEWAY_SERVICE_MARKER, diff --git a/src/daemon/launchd.test.ts b/src/daemon/launchd.test.ts index dd5c1b45e28..c3e094bfdde 100644 --- a/src/daemon/launchd.test.ts +++ b/src/daemon/launchd.test.ts @@ -2,9 +2,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { PassThrough } from "node:stream"; - import { describe, expect, it } from "vitest"; - import { installLaunchAgent, isLaunchAgentListed, diff --git a/src/daemon/launchd.ts b/src/daemon/launchd.ts index 5832bde7f7e..273d2e31a25 100644 --- a/src/daemon/launchd.ts +++ b/src/daemon/launchd.ts @@ -2,7 +2,7 @@ import { execFile } from "node:child_process"; import fs from "node:fs/promises"; import path from "node:path"; import { promisify } from "node:util"; - +import type { GatewayServiceRuntime } from "./service-runtime.js"; import { colorize, isRich, theme } from "../terminal/theme.js"; import { formatGatewayServiceDescription, @@ -14,9 +14,8 @@ import { buildLaunchAgentPlist as buildLaunchAgentPlistImpl, readLaunchAgentProgramArgumentsFromFile, } from "./launchd-plist.js"; -import { parseKeyValueOutput } from "./runtime-parse.js"; -import type { GatewayServiceRuntime } from "./service-runtime.js"; import { resolveGatewayStateDir, resolveHomeDir } from "./paths.js"; +import { parseKeyValueOutput } from "./runtime-parse.js"; const execFileAsync = promisify(execFile); const toPosixPath = (value: string) => value.replace(/\\/g, "/"); diff --git a/src/daemon/node-service.ts b/src/daemon/node-service.ts index 3ef03ad8a32..da4ac8e87d4 100644 --- a/src/daemon/node-service.ts +++ b/src/daemon/node-service.ts @@ -1,5 +1,4 @@ import type { GatewayService, GatewayServiceInstallArgs } from "./service.js"; -import { resolveGatewayService } from "./service.js"; import { NODE_SERVICE_KIND, NODE_SERVICE_MARKER, @@ -8,6 +7,7 @@ import { resolveNodeSystemdServiceName, resolveNodeWindowsTaskName, } from "./constants.js"; +import { resolveGatewayService } from "./service.js"; function withNodeServiceEnv( env: Record, diff --git a/src/daemon/paths.test.ts b/src/daemon/paths.test.ts index a4b62f57aef..5bcdb22cf69 100644 --- a/src/daemon/paths.test.ts +++ b/src/daemon/paths.test.ts @@ -1,7 +1,5 @@ import path from "node:path"; - import { describe, expect, it } from "vitest"; - import { resolveGatewayStateDir } from "./paths.js"; describe("resolveGatewayStateDir", () => { diff --git a/src/daemon/paths.ts b/src/daemon/paths.ts index fd8895f7ca5..4b2621f92a4 100644 --- a/src/daemon/paths.ts +++ b/src/daemon/paths.ts @@ -1,5 +1,4 @@ import path from "node:path"; - import { resolveGatewayProfileSuffix } from "./constants.js"; const windowsAbsolutePath = /^[a-zA-Z]:[\\/]/; diff --git a/src/daemon/runtime-paths.ts b/src/daemon/runtime-paths.ts index 1d3d31a8dfe..c2c74b82fc0 100644 --- a/src/daemon/runtime-paths.ts +++ b/src/daemon/runtime-paths.ts @@ -2,7 +2,6 @@ import { execFile } from "node:child_process"; import fs from "node:fs/promises"; import path from "node:path"; import { promisify } from "node:util"; - import { isSupportedNodeVersion } from "../infra/runtime-guard.js"; const VERSION_MANAGER_MARKERS = [ diff --git a/src/daemon/schtasks.test.ts b/src/daemon/schtasks.test.ts index a7e703161ba..5855951f2ba 100644 --- a/src/daemon/schtasks.test.ts +++ b/src/daemon/schtasks.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import { parseSchtasksQuery, readScheduledTaskCommand, resolveTaskScriptPath } from "./schtasks.js"; describe("schtasks runtime parsing", () => { diff --git a/src/daemon/schtasks.ts b/src/daemon/schtasks.ts index 41766accb22..3d85855965a 100644 --- a/src/daemon/schtasks.ts +++ b/src/daemon/schtasks.ts @@ -2,12 +2,11 @@ import { execFile } from "node:child_process"; import fs from "node:fs/promises"; import path from "node:path"; import { promisify } from "node:util"; - +import type { GatewayServiceRuntime } from "./service-runtime.js"; import { colorize, isRich, theme } from "../terminal/theme.js"; import { formatGatewayServiceDescription, resolveGatewayWindowsTaskName } from "./constants.js"; import { resolveGatewayStateDir } from "./paths.js"; import { parseKeyValueOutput } from "./runtime-parse.js"; -import type { GatewayServiceRuntime } from "./service-runtime.js"; const execFileAsync = promisify(execFile); diff --git a/src/daemon/service-env.ts b/src/daemon/service-env.ts index 7a83f3259ea..d340b599c28 100644 --- a/src/daemon/service-env.ts +++ b/src/daemon/service-env.ts @@ -1,5 +1,4 @@ import path from "node:path"; - import { VERSION } from "../version.js"; import { GATEWAY_SERVICE_KIND, diff --git a/src/daemon/service.ts b/src/daemon/service.ts index 45fe2f638a2..615e8193ef3 100644 --- a/src/daemon/service.ts +++ b/src/daemon/service.ts @@ -1,3 +1,4 @@ +import type { GatewayServiceRuntime } from "./service-runtime.js"; import { installLaunchAgent, isLaunchAgentLoaded, @@ -16,7 +17,6 @@ import { stopScheduledTask, uninstallScheduledTask, } from "./schtasks.js"; -import type { GatewayServiceRuntime } from "./service-runtime.js"; import { installSystemdService, isSystemdServiceEnabled, diff --git a/src/daemon/systemd-unit.test.ts b/src/daemon/systemd-unit.test.ts index d8cb1a8f73f..c671763409f 100644 --- a/src/daemon/systemd-unit.test.ts +++ b/src/daemon/systemd-unit.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { parseSystemdExecStart } from "./systemd-unit.js"; describe("parseSystemdExecStart", () => { diff --git a/src/daemon/systemd.test.ts b/src/daemon/systemd.test.ts index 6d98e3cf171..692a445e5a9 100644 --- a/src/daemon/systemd.test.ts +++ b/src/daemon/systemd.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { parseSystemdShow, resolveSystemdUserUnitPath } from "./systemd.js"; describe("systemd runtime parsing", () => { diff --git a/src/daemon/systemd.ts b/src/daemon/systemd.ts index 2c2d3bbc953..7b314dd38a0 100644 --- a/src/daemon/systemd.ts +++ b/src/daemon/systemd.ts @@ -2,15 +2,15 @@ import { execFile } from "node:child_process"; import fs from "node:fs/promises"; import path from "node:path"; import { promisify } from "node:util"; +import type { GatewayServiceRuntime } from "./service-runtime.js"; import { colorize, isRich, theme } from "../terminal/theme.js"; import { formatGatewayServiceDescription, LEGACY_GATEWAY_SYSTEMD_SERVICE_NAMES, resolveGatewaySystemdServiceName, } from "./constants.js"; -import { parseKeyValueOutput } from "./runtime-parse.js"; -import type { GatewayServiceRuntime } from "./service-runtime.js"; import { resolveHomeDir } from "./paths.js"; +import { parseKeyValueOutput } from "./runtime-parse.js"; import { enableSystemdUserLinger, readSystemdUserLingerStatus, diff --git a/src/discord/api.test.ts b/src/discord/api.test.ts index d06f94bf3e0..557f794239d 100644 --- a/src/discord/api.test.ts +++ b/src/discord/api.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { fetchDiscord } from "./api.js"; function jsonResponse(body: unknown, status = 200) { diff --git a/src/discord/chunk.test.ts b/src/discord/chunk.test.ts index c35b86e63f3..674d2cd63e6 100644 --- a/src/discord/chunk.test.ts +++ b/src/discord/chunk.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { chunkDiscordText, chunkDiscordTextWithMode } from "./chunk.js"; function countLines(text: string) { diff --git a/src/discord/directory-live.ts b/src/discord/directory-live.ts index 3797f70e08b..73222843c91 100644 --- a/src/discord/directory-live.ts +++ b/src/discord/directory-live.ts @@ -1,5 +1,5 @@ -import type { ChannelDirectoryEntry } from "../channels/plugins/types.js"; import type { DirectoryConfigParams } from "../channels/plugins/directory-config.js"; +import type { ChannelDirectoryEntry } from "../channels/plugins/types.js"; import { resolveDiscordAccount } from "./accounts.js"; import { fetchDiscord } from "./api.js"; import { normalizeDiscordSlug } from "./monitor/allow-list.js"; diff --git a/src/discord/gateway-logging.test.ts b/src/discord/gateway-logging.test.ts index 958c42b705e..ef95aff6313 100644 --- a/src/discord/gateway-logging.test.ts +++ b/src/discord/gateway-logging.test.ts @@ -1,5 +1,4 @@ import { EventEmitter } from "node:events"; - import { afterEach, describe, expect, it, vi } from "vitest"; vi.mock("../globals.js", () => ({ diff --git a/src/discord/gateway-logging.ts b/src/discord/gateway-logging.ts index 027ea1df89c..e1f8fcf2580 100644 --- a/src/discord/gateway-logging.ts +++ b/src/discord/gateway-logging.ts @@ -1,7 +1,6 @@ import type { EventEmitter } from "node:events"; - -import { logVerbose } from "../globals.js"; import type { RuntimeEnv } from "../runtime.js"; +import { logVerbose } from "../globals.js"; type GatewayEmitter = Pick; diff --git a/src/discord/monitor.gateway.test.ts b/src/discord/monitor.gateway.test.ts index f052e0f00ee..95c3f9e232f 100644 --- a/src/discord/monitor.gateway.test.ts +++ b/src/discord/monitor.gateway.test.ts @@ -1,7 +1,5 @@ import { EventEmitter } from "node:events"; - import { describe, expect, it, vi } from "vitest"; - import { waitForDiscordGatewayStop } from "./monitor.gateway.js"; describe("waitForDiscordGatewayStop", () => { diff --git a/src/discord/monitor.tool-result.accepts-guild-messages-mentionpatterns-match.test.ts b/src/discord/monitor.tool-result.accepts-guild-messages-mentionpatterns-match.test.ts index 0777063d48a..44f2589148d 100644 --- a/src/discord/monitor.tool-result.accepts-guild-messages-mentionpatterns-match.test.ts +++ b/src/discord/monitor.tool-result.accepts-guild-messages-mentionpatterns-match.test.ts @@ -2,7 +2,6 @@ import type { Client } from "@buape/carbon"; import { ChannelType, MessageType } from "@buape/carbon"; import { Routes } from "discord-api-types/v10"; import { beforeEach, describe, expect, it, vi } from "vitest"; - import { __resetDiscordChannelInfoCacheForTest } from "./monitor/message-utils.js"; const sendMock = vi.fn(); diff --git a/src/discord/monitor/allow-list.ts b/src/discord/monitor/allow-list.ts index 66fb8fd83f4..29e0c66660d 100644 --- a/src/discord/monitor/allow-list.ts +++ b/src/discord/monitor/allow-list.ts @@ -1,12 +1,11 @@ import type { Guild, User } from "@buape/carbon"; - +import type { AllowlistMatch } from "../../channels/allowlist-match.js"; import { buildChannelKeyCandidates, resolveChannelEntryMatchWithFallback, resolveChannelMatchConfig, type ChannelMatchSource, } from "../../channels/channel-config.js"; -import type { AllowlistMatch } from "../../channels/allowlist-match.js"; import { formatDiscordUserTag } from "./format.js"; export type DiscordAllowList = { diff --git a/src/discord/monitor/exec-approvals.test.ts b/src/discord/monitor/exec-approvals.test.ts index 044b3eb97d0..9b39acd6794 100644 --- a/src/discord/monitor/exec-approvals.test.ts +++ b/src/discord/monitor/exec-approvals.test.ts @@ -1,11 +1,11 @@ import { describe, expect, it } from "vitest"; +import type { DiscordExecApprovalConfig } from "../../config/types.discord.js"; import { buildExecApprovalCustomId, parseExecApprovalData, type ExecApprovalRequest, DiscordExecApprovalHandler, } from "./exec-approvals.js"; -import type { DiscordExecApprovalConfig } from "../../config/types.discord.js"; describe("buildExecApprovalCustomId", () => { it("encodes approval id and action", () => { diff --git a/src/discord/monitor/exec-approvals.ts b/src/discord/monitor/exec-approvals.ts index 014b35b1edd..4b6fc546b6e 100644 --- a/src/discord/monitor/exec-approvals.ts +++ b/src/discord/monitor/exec-approvals.ts @@ -1,14 +1,14 @@ import { Button, type ButtonInteraction, type ComponentData } from "@buape/carbon"; import { ButtonStyle, Routes } from "discord-api-types/v10"; import type { OpenClawConfig } from "../../config/config.js"; -import { GatewayClient } from "../../gateway/client.js"; -import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../utils/message-channel.js"; +import type { DiscordExecApprovalConfig } from "../../config/types.discord.js"; import type { EventFrame } from "../../gateway/protocol/index.js"; import type { ExecApprovalDecision } from "../../infra/exec-approvals.js"; -import { createDiscordClient } from "../send.shared.js"; -import { logDebug, logError } from "../../logger.js"; -import type { DiscordExecApprovalConfig } from "../../config/types.discord.js"; import type { RuntimeEnv } from "../../runtime.js"; +import { GatewayClient } from "../../gateway/client.js"; +import { logDebug, logError } from "../../logger.js"; +import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../utils/message-channel.js"; +import { createDiscordClient } from "../send.shared.js"; const EXEC_APPROVAL_KEY = "execapproval"; diff --git a/src/discord/monitor/listeners.ts b/src/discord/monitor/listeners.ts index 14e7d86e21d..a7cd9ce3332 100644 --- a/src/discord/monitor/listeners.ts +++ b/src/discord/monitor/listeners.ts @@ -6,11 +6,9 @@ import { MessageReactionRemoveListener, PresenceUpdateListener, } from "@buape/carbon"; - import { danger } from "../../globals.js"; import { formatDurationSeconds } from "../../infra/format-duration.js"; import { enqueueSystemEvent } from "../../infra/system-events.js"; -import { setPresence } from "./presence-cache.js"; import { createSubsystemLogger } from "../../logging/subsystem.js"; import { resolveAgentRoute } from "../../routing/resolve-route.js"; import { @@ -21,6 +19,7 @@ import { } from "./allow-list.js"; import { formatDiscordReactionEmoji, formatDiscordUserTag } from "./format.js"; import { resolveDiscordChannelInfo } from "./message-utils.js"; +import { setPresence } from "./presence-cache.js"; type LoadedConfig = ReturnType; type RuntimeEnv = import("../../runtime.js").RuntimeEnv; diff --git a/src/discord/monitor/message-handler.inbound-contract.test.ts b/src/discord/monitor/message-handler.inbound-contract.test.ts index b21392daba9..cceab2ea3d2 100644 --- a/src/discord/monitor/message-handler.inbound-contract.test.ts +++ b/src/discord/monitor/message-handler.inbound-contract.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it, vi } from "vitest"; - import type { MsgContext } from "../../auto-reply/templating.js"; import { expectInboundContextContract } from "../../../test/helpers/inbound-contract.js"; diff --git a/src/discord/monitor/message-handler.preflight.ts b/src/discord/monitor/message-handler.preflight.ts index 1f9ec0b725c..17124cabf81 100644 --- a/src/discord/monitor/message-handler.preflight.ts +++ b/src/discord/monitor/message-handler.preflight.ts @@ -1,5 +1,8 @@ import { ChannelType, MessageType, type User } from "@buape/carbon"; - +import type { + DiscordMessagePreflightContext, + DiscordMessagePreflightParams, +} from "./message-handler.preflight.types.js"; import { hasControlCommand } from "../../auto-reply/command-detection.js"; import { shouldHandleTextCommands } from "../../auto-reply/commands-registry.js"; import { @@ -10,6 +13,10 @@ import { buildMentionRegexes, matchesMentionWithExplicit, } from "../../auto-reply/reply/mentions.js"; +import { formatAllowlistMatchMeta } from "../../channels/allowlist-match.js"; +import { resolveControlCommandGate } from "../../channels/command-gating.js"; +import { logInboundDrop } from "../../channels/logging.js"; +import { resolveMentionGatingWithBypass } from "../../channels/mention-gating.js"; import { logVerbose, shouldLogVerbose } from "../../globals.js"; import { recordChannelActivity } from "../../infra/channel-activity.js"; import { enqueueSystemEvent } from "../../infra/system-events.js"; @@ -20,11 +27,7 @@ import { upsertChannelPairingRequest, } from "../../pairing/pairing-store.js"; import { resolveAgentRoute } from "../../routing/resolve-route.js"; -import { resolveMentionGatingWithBypass } from "../../channels/mention-gating.js"; -import { formatAllowlistMatchMeta } from "../../channels/allowlist-match.js"; import { sendMessageDiscord } from "../send.js"; -import { resolveControlCommandGate } from "../../channels/command-gating.js"; -import { logInboundDrop } from "../../channels/logging.js"; import { allowListMatches, isDiscordGroupAllowedByPolicy, @@ -42,10 +45,6 @@ import { resolveDiscordSystemLocation, resolveTimestampMs, } from "./format.js"; -import type { - DiscordMessagePreflightContext, - DiscordMessagePreflightParams, -} from "./message-handler.preflight.types.js"; import { resolveDiscordChannelInfo, resolveDiscordMessageText } from "./message-utils.js"; import { resolveDiscordSystemEvent } from "./system-events.js"; import { resolveDiscordThreadChannel, resolveDiscordThreadParentInfo } from "./threading.js"; diff --git a/src/discord/monitor/message-handler.process.test.ts b/src/discord/monitor/message-handler.process.test.ts index 9514bb866ee..534eede87a7 100644 --- a/src/discord/monitor/message-handler.process.test.ts +++ b/src/discord/monitor/message-handler.process.test.ts @@ -1,7 +1,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { beforeEach, describe, expect, it, vi } from "vitest"; const reactMessageDiscord = vi.fn(async () => {}); diff --git a/src/discord/monitor/message-handler.process.ts b/src/discord/monitor/message-handler.process.ts index 6d502be21e3..68a9a09e49e 100644 --- a/src/discord/monitor/message-handler.process.ts +++ b/src/discord/monitor/message-handler.process.ts @@ -1,29 +1,30 @@ import { ChannelType } from "@buape/carbon"; +import type { ReplyPayload } from "../../auto-reply/types.js"; +import type { DiscordMessagePreflightContext } from "./message-handler.preflight.js"; import { resolveAckReaction, resolveHumanDelayConfig } from "../../agents/identity.js"; -import { - removeAckReactionAfterReply, - shouldAckReaction as shouldAckReactionGate, -} from "../../channels/ack-reactions.js"; -import { logTypingFailure, logAckFailure } from "../../channels/logging.js"; -import { createReplyPrefixContext } from "../../channels/reply-prefix.js"; -import { createTypingCallbacks } from "../../channels/typing.js"; +import { resolveChunkMode } from "../../auto-reply/chunk.js"; +import { dispatchInboundMessage } from "../../auto-reply/dispatch.js"; import { formatInboundEnvelope, formatThreadStarterEnvelope, resolveEnvelopeFormatOptions, } from "../../auto-reply/envelope.js"; -import { dispatchInboundMessage } from "../../auto-reply/dispatch.js"; import { buildPendingHistoryContextFromMap, clearHistoryEntriesIfEnabled, } from "../../auto-reply/reply/history.js"; import { finalizeInboundContext } from "../../auto-reply/reply/inbound-context.js"; import { createReplyDispatcherWithTyping } from "../../auto-reply/reply/reply-dispatcher.js"; -import type { ReplyPayload } from "../../auto-reply/types.js"; +import { + removeAckReactionAfterReply, + shouldAckReaction as shouldAckReactionGate, +} from "../../channels/ack-reactions.js"; +import { logTypingFailure, logAckFailure } from "../../channels/logging.js"; +import { createReplyPrefixContext } from "../../channels/reply-prefix.js"; import { recordInboundSession } from "../../channels/session.js"; -import { readSessionUpdatedAt, resolveStorePath } from "../../config/sessions.js"; -import { resolveChunkMode } from "../../auto-reply/chunk.js"; +import { createTypingCallbacks } from "../../channels/typing.js"; import { resolveMarkdownTableMode } from "../../config/markdown-tables.js"; +import { readSessionUpdatedAt, resolveStorePath } from "../../config/sessions.js"; import { danger, logVerbose, shouldLogVerbose } from "../../globals.js"; import { buildAgentSessionKey } from "../../routing/resolve-route.js"; import { resolveThreadSessionKeys } from "../../routing/session-key.js"; @@ -31,7 +32,6 @@ import { truncateUtf16Safe } from "../../utils.js"; import { reactMessageDiscord, removeReactionDiscord } from "../send.js"; import { normalizeDiscordSlug } from "./allow-list.js"; import { formatDiscordUserTag, resolveTimestampMs } from "./format.js"; -import type { DiscordMessagePreflightContext } from "./message-handler.preflight.js"; import { buildDiscordMediaPayload, resolveDiscordMessageText, diff --git a/src/discord/monitor/message-handler.ts b/src/discord/monitor/message-handler.ts index ab04ab051d4..5945e719a2e 100644 --- a/src/discord/monitor/message-handler.ts +++ b/src/discord/monitor/message-handler.ts @@ -1,16 +1,15 @@ import type { Client } from "@buape/carbon"; - +import type { HistoryEntry } from "../../auto-reply/reply/history.js"; +import type { ReplyToMode } from "../../config/config.js"; +import type { RuntimeEnv } from "../../runtime.js"; +import type { DiscordGuildEntryResolved } from "./allow-list.js"; +import type { DiscordMessageEvent, DiscordMessageHandler } from "./listeners.js"; import { hasControlCommand } from "../../auto-reply/command-detection.js"; import { createInboundDebouncer, resolveInboundDebounceMs, } from "../../auto-reply/inbound-debounce.js"; -import type { HistoryEntry } from "../../auto-reply/reply/history.js"; -import type { ReplyToMode } from "../../config/config.js"; import { danger } from "../../globals.js"; -import type { RuntimeEnv } from "../../runtime.js"; -import type { DiscordGuildEntryResolved } from "./allow-list.js"; -import type { DiscordMessageEvent, DiscordMessageHandler } from "./listeners.js"; import { preflightDiscordMessage } from "./message-handler.preflight.js"; import { processDiscordMessage } from "./message-handler.process.js"; import { resolveDiscordMessageText } from "./message-utils.js"; diff --git a/src/discord/monitor/message-utils.ts b/src/discord/monitor/message-utils.ts index 1e6ad76603a..f3968312415 100644 --- a/src/discord/monitor/message-utils.ts +++ b/src/discord/monitor/message-utils.ts @@ -1,6 +1,5 @@ import type { ChannelType, Client, Message } from "@buape/carbon"; import type { APIAttachment } from "discord-api-types/v10"; - import { logVerbose } from "../../globals.js"; import { fetchRemoteMedia } from "../../media/fetch.js"; import { saveMediaBuffer } from "../../media/store.js"; diff --git a/src/discord/monitor/native-command.ts b/src/discord/monitor/native-command.ts index ab40850abbf..35890f004b2 100644 --- a/src/discord/monitor/native-command.ts +++ b/src/discord/monitor/native-command.ts @@ -10,7 +10,15 @@ import { type ComponentData, } from "@buape/carbon"; import { ApplicationCommandOptionType, ButtonStyle } from "discord-api-types/v10"; - +import type { + ChatCommandDefinition, + CommandArgDefinition, + CommandArgValues, + CommandArgs, + NativeCommandSpec, +} from "../../auto-reply/commands-registry.js"; +import type { ReplyPayload } from "../../auto-reply/types.js"; +import type { OpenClawConfig, loadConfig } from "../../config/config.js"; import { resolveEffectiveMessagesConfig, resolveHumanDelayConfig } from "../../agents/identity.js"; import { resolveChunkMode, resolveTextChunkLimit } from "../../auto-reply/chunk.js"; import { @@ -22,17 +30,9 @@ import { resolveCommandArgMenu, serializeCommandArgs, } from "../../auto-reply/commands-registry.js"; -import type { - ChatCommandDefinition, - CommandArgDefinition, - CommandArgValues, - CommandArgs, - NativeCommandSpec, -} from "../../auto-reply/commands-registry.js"; -import { dispatchReplyWithDispatcher } from "../../auto-reply/reply/provider-dispatcher.js"; import { finalizeInboundContext } from "../../auto-reply/reply/inbound-context.js"; -import type { ReplyPayload } from "../../auto-reply/types.js"; -import type { OpenClawConfig, loadConfig } from "../../config/config.js"; +import { dispatchReplyWithDispatcher } from "../../auto-reply/reply/provider-dispatcher.js"; +import { resolveCommandAuthorizedFromAuthorizers } from "../../channels/command-gating.js"; import { buildPairingReply } from "../../pairing/pairing-messages.js"; import { readChannelAllowFromStore, @@ -41,7 +41,6 @@ import { import { resolveAgentRoute } from "../../routing/resolve-route.js"; import { loadWebMedia } from "../../web/media.js"; import { chunkDiscordTextWithMode } from "../chunk.js"; -import { resolveCommandAuthorizedFromAuthorizers } from "../../channels/command-gating.js"; import { allowListMatches, isDiscordGroupAllowedByPolicy, diff --git a/src/discord/monitor/presence-cache.test.ts b/src/discord/monitor/presence-cache.test.ts index 007d0548afb..e7dd04d0806 100644 --- a/src/discord/monitor/presence-cache.test.ts +++ b/src/discord/monitor/presence-cache.test.ts @@ -1,5 +1,5 @@ -import { beforeEach, describe, expect, it } from "vitest"; import type { GatewayPresenceUpdate } from "discord-api-types/v10"; +import { beforeEach, describe, expect, it } from "vitest"; import { clearPresences, getPresence, presenceCacheSize, setPresence } from "./presence-cache.js"; describe("presence-cache", () => { diff --git a/src/discord/monitor/provider.ts b/src/discord/monitor/provider.ts index dbc2ee1e147..8e907e0d9d9 100644 --- a/src/discord/monitor/provider.ts +++ b/src/discord/monitor/provider.ts @@ -1,24 +1,24 @@ -import { inspect } from "node:util"; import { Client } from "@buape/carbon"; import { GatewayIntents, GatewayPlugin } from "@buape/carbon/gateway"; import { Routes } from "discord-api-types/v10"; +import { inspect } from "node:util"; +import type { HistoryEntry } from "../../auto-reply/reply/history.js"; +import type { OpenClawConfig, ReplyToMode } from "../../config/config.js"; +import type { RuntimeEnv } from "../../runtime.js"; import { resolveTextChunkLimit } from "../../auto-reply/chunk.js"; import { listNativeCommandSpecsForConfig } from "../../auto-reply/commands-registry.js"; import { listSkillCommandsForAgents } from "../../auto-reply/skill-commands.js"; -import type { HistoryEntry } from "../../auto-reply/reply/history.js"; import { mergeAllowlist, summarizeMapping } from "../../channels/allowlists/resolve-utils.js"; import { isNativeCommandsExplicitlyDisabled, resolveNativeCommandsEnabled, resolveNativeSkillsEnabled, } from "../../config/commands.js"; -import type { OpenClawConfig, ReplyToMode } from "../../config/config.js"; import { loadConfig } from "../../config/config.js"; import { danger, logVerbose, shouldLogVerbose, warn } from "../../globals.js"; import { formatErrorMessage } from "../../infra/errors.js"; import { createDiscordRetryRunner } from "../../infra/retry-policy.js"; import { createSubsystemLogger } from "../../logging/subsystem.js"; -import type { RuntimeEnv } from "../../runtime.js"; import { resolveDiscordAccount } from "../accounts.js"; import { attachDiscordGatewayLogging } from "../gateway-logging.js"; import { getDiscordGatewayEmitter, waitForDiscordGatewayStop } from "../monitor.gateway.js"; @@ -26,6 +26,7 @@ import { fetchDiscordApplicationId } from "../probe.js"; import { resolveDiscordChannelAllowlist } from "../resolve-channels.js"; import { resolveDiscordUserAllowlist } from "../resolve-users.js"; import { normalizeDiscordToken } from "../token.js"; +import { createExecApprovalButton, DiscordExecApprovalHandler } from "./exec-approvals.js"; import { DiscordMessageListener, DiscordPresenceListener, @@ -38,7 +39,6 @@ import { createDiscordCommandArgFallbackButton, createDiscordNativeCommand, } from "./native-command.js"; -import { createExecApprovalButton, DiscordExecApprovalHandler } from "./exec-approvals.js"; export type MonitorDiscordOpts = { token?: string; diff --git a/src/discord/monitor/reply-context.ts b/src/discord/monitor/reply-context.ts index 6a1a5635b75..c0bee55075a 100644 --- a/src/discord/monitor/reply-context.ts +++ b/src/discord/monitor/reply-context.ts @@ -1,5 +1,4 @@ import type { Guild, Message, User } from "@buape/carbon"; - import { formatAgentEnvelope, type EnvelopeFormatOptions } from "../../auto-reply/envelope.js"; import { formatDiscordUserTag, resolveTimestampMs } from "./format.js"; diff --git a/src/discord/monitor/reply-delivery.ts b/src/discord/monitor/reply-delivery.ts index e2b01beaef9..f3513aad60f 100644 --- a/src/discord/monitor/reply-delivery.ts +++ b/src/discord/monitor/reply-delivery.ts @@ -1,10 +1,9 @@ import type { RequestClient } from "@buape/carbon"; - import type { ChunkMode } from "../../auto-reply/chunk.js"; import type { ReplyPayload } from "../../auto-reply/types.js"; import type { MarkdownTableMode } from "../../config/types.base.js"; -import { convertMarkdownTables } from "../../markdown/tables.js"; import type { RuntimeEnv } from "../../runtime.js"; +import { convertMarkdownTables } from "../../markdown/tables.js"; import { chunkDiscordTextWithMode } from "../chunk.js"; import { sendMessageDiscord } from "../send.js"; diff --git a/src/discord/monitor/system-events.ts b/src/discord/monitor/system-events.ts index e87205408ec..3117639c576 100644 --- a/src/discord/monitor/system-events.ts +++ b/src/discord/monitor/system-events.ts @@ -1,5 +1,4 @@ import { type Message, MessageType } from "@buape/carbon"; - import { formatDiscordUserTag } from "./format.js"; export function resolveDiscordSystemEvent(message: Message, location: string): string | null { diff --git a/src/discord/monitor/threading.test.ts b/src/discord/monitor/threading.test.ts index 34377869ff8..b4a1c42f6c7 100644 --- a/src/discord/monitor/threading.test.ts +++ b/src/discord/monitor/threading.test.ts @@ -1,6 +1,6 @@ +import type { Client } from "@buape/carbon"; import { describe, expect, it } from "vitest"; import { buildAgentSessionKey } from "../../routing/resolve-route.js"; -import type { Client } from "@buape/carbon"; import { resolveDiscordAutoThreadContext, resolveDiscordAutoThreadReplyPlan, diff --git a/src/discord/monitor/threading.ts b/src/discord/monitor/threading.ts index 8ffa264fdaf..b862efff012 100644 --- a/src/discord/monitor/threading.ts +++ b/src/discord/monitor/threading.ts @@ -1,12 +1,12 @@ import { ChannelType, type Client } from "@buape/carbon"; import { Routes } from "discord-api-types/v10"; -import { createReplyReferencePlanner } from "../../auto-reply/reply/reply-reference.js"; import type { ReplyToMode } from "../../config/config.js"; +import type { DiscordChannelConfigResolved } from "./allow-list.js"; +import type { DiscordMessageEvent } from "./listeners.js"; +import { createReplyReferencePlanner } from "../../auto-reply/reply/reply-reference.js"; import { logVerbose } from "../../globals.js"; import { buildAgentSessionKey } from "../../routing/resolve-route.js"; import { truncateUtf16Safe } from "../../utils.js"; -import type { DiscordChannelConfigResolved } from "./allow-list.js"; -import type { DiscordMessageEvent } from "./listeners.js"; import { resolveDiscordChannelInfo } from "./message-utils.js"; export type DiscordThreadChannel = { diff --git a/src/discord/probe.intents.test.ts b/src/discord/probe.intents.test.ts index 39a88c2a700..97122195730 100644 --- a/src/discord/probe.intents.test.ts +++ b/src/discord/probe.intents.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { resolveDiscordPrivilegedIntentsFromFlags } from "./probe.js"; describe("resolveDiscordPrivilegedIntentsFromFlags", () => { diff --git a/src/discord/resolve-channels.test.ts b/src/discord/resolve-channels.test.ts index 885f898fe37..b34597324e9 100644 --- a/src/discord/resolve-channels.test.ts +++ b/src/discord/resolve-channels.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { resolveDiscordChannelAllowlist } from "./resolve-channels.js"; function jsonResponse(body: unknown) { diff --git a/src/discord/send.channels.ts b/src/discord/send.channels.ts index 7b13e1445d6..e8324706047 100644 --- a/src/discord/send.channels.ts +++ b/src/discord/send.channels.ts @@ -1,6 +1,5 @@ import type { APIChannel } from "discord-api-types/v10"; import { Routes } from "discord-api-types/v10"; -import { resolveDiscordRest } from "./send.shared.js"; import type { DiscordChannelCreate, DiscordChannelEdit, @@ -8,6 +7,7 @@ import type { DiscordChannelPermissionSet, DiscordReactOpts, } from "./send.types.js"; +import { resolveDiscordRest } from "./send.shared.js"; export async function createChannelDiscord( payload: DiscordChannelCreate, diff --git a/src/discord/send.creates-thread.test.ts b/src/discord/send.creates-thread.test.ts index 90284df1404..3bd2d4a04b0 100644 --- a/src/discord/send.creates-thread.test.ts +++ b/src/discord/send.creates-thread.test.ts @@ -1,7 +1,6 @@ import { RateLimitError } from "@buape/carbon"; import { Routes } from "discord-api-types/v10"; import { beforeEach, describe, expect, it, vi } from "vitest"; - import { addRoleDiscord, banMemberDiscord, diff --git a/src/discord/send.emojis-stickers.ts b/src/discord/send.emojis-stickers.ts index c0297437d08..a56b47bccc9 100644 --- a/src/discord/send.emojis-stickers.ts +++ b/src/discord/send.emojis-stickers.ts @@ -1,8 +1,7 @@ import { Routes } from "discord-api-types/v10"; - +import type { DiscordEmojiUpload, DiscordReactOpts, DiscordStickerUpload } from "./send.types.js"; import { loadWebMediaRaw } from "../web/media.js"; import { normalizeEmojiName, resolveDiscordRest } from "./send.shared.js"; -import type { DiscordEmojiUpload, DiscordReactOpts, DiscordStickerUpload } from "./send.types.js"; import { DISCORD_MAX_EMOJI_BYTES, DISCORD_MAX_STICKER_BYTES } from "./send.types.js"; export async function listGuildEmojisDiscord(guildId: string, opts: DiscordReactOpts = {}) { diff --git a/src/discord/send.guild.ts b/src/discord/send.guild.ts index fab1aff9ace..bb6abc4012f 100644 --- a/src/discord/send.guild.ts +++ b/src/discord/send.guild.ts @@ -7,13 +7,13 @@ import type { RESTPostAPIGuildScheduledEventJSONBody, } from "discord-api-types/v10"; import { Routes } from "discord-api-types/v10"; -import { resolveDiscordRest } from "./send.shared.js"; import type { DiscordModerationTarget, DiscordReactOpts, DiscordRoleChange, DiscordTimeoutTarget, } from "./send.types.js"; +import { resolveDiscordRest } from "./send.shared.js"; export async function fetchMemberInfoDiscord( guildId: string, diff --git a/src/discord/send.messages.ts b/src/discord/send.messages.ts index 0a2d0658153..f0899bbe9d1 100644 --- a/src/discord/send.messages.ts +++ b/src/discord/send.messages.ts @@ -1,6 +1,5 @@ import type { APIMessage } from "discord-api-types/v10"; import { Routes } from "discord-api-types/v10"; -import { resolveDiscordRest } from "./send.shared.js"; import type { DiscordMessageEdit, DiscordMessageQuery, @@ -9,6 +8,7 @@ import type { DiscordThreadCreate, DiscordThreadList, } from "./send.types.js"; +import { resolveDiscordRest } from "./send.shared.js"; export async function readMessagesDiscord( channelId: string, diff --git a/src/discord/send.outbound.ts b/src/discord/send.outbound.ts index 22b402ae372..f994c02a87c 100644 --- a/src/discord/send.outbound.ts +++ b/src/discord/send.outbound.ts @@ -1,12 +1,13 @@ import type { RequestClient } from "@buape/carbon"; import { Routes } from "discord-api-types/v10"; +import type { RetryConfig } from "../infra/retry.js"; +import type { PollInput } from "../polls.js"; +import type { DiscordSendResult } from "./send.types.js"; import { resolveChunkMode } from "../auto-reply/chunk.js"; import { loadConfig } from "../config/config.js"; import { resolveMarkdownTableMode } from "../config/markdown-tables.js"; import { recordChannelActivity } from "../infra/channel-activity.js"; import { convertMarkdownTables } from "../markdown/tables.js"; -import type { RetryConfig } from "../infra/retry.js"; -import type { PollInput } from "../polls.js"; import { resolveDiscordAccount } from "./accounts.js"; import { buildDiscordSendError, @@ -18,7 +19,6 @@ import { sendDiscordMedia, sendDiscordText, } from "./send.shared.js"; -import type { DiscordSendResult } from "./send.types.js"; type DiscordSendOpts = { token?: string; diff --git a/src/discord/send.permissions.ts b/src/discord/send.permissions.ts index 23ca5ac069b..a360622f35d 100644 --- a/src/discord/send.permissions.ts +++ b/src/discord/send.permissions.ts @@ -1,11 +1,10 @@ -import { RequestClient } from "@buape/carbon"; import type { APIChannel, APIGuild, APIGuildMember, APIRole } from "discord-api-types/v10"; +import { RequestClient } from "@buape/carbon"; import { ChannelType, PermissionFlagsBits, Routes } from "discord-api-types/v10"; - -import { loadConfig } from "../config/config.js"; import type { RetryConfig } from "../infra/retry.js"; -import { resolveDiscordAccount } from "./accounts.js"; import type { DiscordPermissionsSummary, DiscordReactOpts } from "./send.types.js"; +import { loadConfig } from "../config/config.js"; +import { resolveDiscordAccount } from "./accounts.js"; import { normalizeDiscordToken } from "./token.js"; const PERMISSION_ENTRIES = Object.entries(PermissionFlagsBits).filter( diff --git a/src/discord/send.reactions.ts b/src/discord/send.reactions.ts index 4ec224b29ad..3aef057ff76 100644 --- a/src/discord/send.reactions.ts +++ b/src/discord/send.reactions.ts @@ -1,5 +1,5 @@ import { Routes } from "discord-api-types/v10"; - +import type { DiscordReactionSummary, DiscordReactOpts } from "./send.types.js"; import { loadConfig } from "../config/config.js"; import { buildReactionIdentifier, @@ -8,7 +8,6 @@ import { normalizeReactionEmoji, resolveDiscordRest, } from "./send.shared.js"; -import type { DiscordReactionSummary, DiscordReactOpts } from "./send.types.js"; export async function reactMessageDiscord( channelId: string, diff --git a/src/discord/send.sends-basic-channel-messages.test.ts b/src/discord/send.sends-basic-channel-messages.test.ts index ada991d6b7c..ebe2a3f7aac 100644 --- a/src/discord/send.sends-basic-channel-messages.test.ts +++ b/src/discord/send.sends-basic-channel-messages.test.ts @@ -1,6 +1,5 @@ import { PermissionFlagsBits, Routes } from "discord-api-types/v10"; import { beforeEach, describe, expect, it, vi } from "vitest"; - import { deleteMessageDiscord, editMessageDiscord, diff --git a/src/discord/send.shared.ts b/src/discord/send.shared.ts index 7b88c9c4052..ea666913d11 100644 --- a/src/discord/send.shared.ts +++ b/src/discord/send.shared.ts @@ -1,15 +1,14 @@ +import type { RESTAPIPoll } from "discord-api-types/rest/v10"; import { RequestClient } from "@buape/carbon"; import { PollLayoutType } from "discord-api-types/payloads/v10"; -import type { RESTAPIPoll } from "discord-api-types/rest/v10"; import { Routes } from "discord-api-types/v10"; - -import { loadConfig } from "../config/config.js"; +import type { ChunkMode } from "../auto-reply/chunk.js"; import type { RetryConfig } from "../infra/retry.js"; +import { loadConfig } from "../config/config.js"; import { createDiscordRetryRunner, type RetryRunner } from "../infra/retry-policy.js"; import { normalizePollDurationHours, normalizePollInput, type PollInput } from "../polls.js"; import { loadWebMedia } from "../web/media.js"; import { resolveDiscordAccount } from "./accounts.js"; -import type { ChunkMode } from "../auto-reply/chunk.js"; import { chunkDiscordTextWithMode } from "./chunk.js"; import { fetchChannelPermissionsDiscord, isThreadChannelType } from "./send.permissions.js"; import { DiscordSendError } from "./send.types.js"; diff --git a/src/discord/send.types.ts b/src/discord/send.types.ts index c199a24be63..1a31d42ace4 100644 --- a/src/discord/send.types.ts +++ b/src/discord/send.types.ts @@ -1,5 +1,4 @@ import type { RequestClient } from "@buape/carbon"; - import type { RetryConfig } from "../infra/retry.js"; export class DiscordSendError extends Error { diff --git a/src/discord/targets.test.ts b/src/discord/targets.test.ts index 223dacbaf9b..654c59d1f7d 100644 --- a/src/discord/targets.test.ts +++ b/src/discord/targets.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { normalizeDiscordMessagingTarget } from "../channels/plugins/normalize/discord.js"; import { listDiscordDirectoryPeersLive } from "./directory-live.js"; diff --git a/src/discord/targets.ts b/src/discord/targets.ts index e4e6cdd5221..02c5890d211 100644 --- a/src/discord/targets.ts +++ b/src/discord/targets.ts @@ -1,3 +1,4 @@ +import type { DirectoryConfigParams } from "../channels/plugins/directory-config.js"; import { buildMessagingTarget, ensureTargetId, @@ -6,9 +7,6 @@ import { type MessagingTargetKind, type MessagingTargetParseOptions, } from "../channels/targets.js"; - -import type { DirectoryConfigParams } from "../channels/plugins/directory-config.js"; - import { listDiscordDirectoryPeersLive } from "./directory-live.js"; export type DiscordTargetKind = MessagingTargetKind; diff --git a/src/discord/token.test.ts b/src/discord/token.test.ts index 316c137802f..eae2e7794e7 100644 --- a/src/discord/token.test.ts +++ b/src/discord/token.test.ts @@ -1,5 +1,4 @@ import { afterEach, describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { resolveDiscordToken } from "./token.js"; diff --git a/src/docs/slash-commands-doc.test.ts b/src/docs/slash-commands-doc.test.ts index 39de4e1b42f..87e5bc70247 100644 --- a/src/docs/slash-commands-doc.test.ts +++ b/src/docs/slash-commands-doc.test.ts @@ -1,7 +1,6 @@ import fs from "node:fs/promises"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it } from "vitest"; - import { listChatCommands } from "../auto-reply/commands-registry.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import { createTestRegistry } from "../test-utils/channel-plugins.js"; diff --git a/src/entry.ts b/src/entry.ts index 151c8905483..d58bbae2822 100644 --- a/src/entry.ts +++ b/src/entry.ts @@ -2,7 +2,6 @@ import { spawn } from "node:child_process"; import path from "node:path"; import process from "node:process"; - import { applyCliProfileEnv, parseCliProfileArgs } from "./cli/profile.js"; import { isTruthyEnvValue, normalizeEnv } from "./infra/env.js"; import { installProcessWarningFilter } from "./infra/warnings.js"; diff --git a/src/gateway/assistant-identity.test.ts b/src/gateway/assistant-identity.test.ts index 72e643ac179..f91619baf8d 100644 --- a/src/gateway/assistant-identity.test.ts +++ b/src/gateway/assistant-identity.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { DEFAULT_ASSISTANT_IDENTITY, resolveAssistantIdentity } from "./assistant-identity.js"; diff --git a/src/gateway/assistant-identity.ts b/src/gateway/assistant-identity.ts index 812a090d5c1..52c4cc7c396 100644 --- a/src/gateway/assistant-identity.ts +++ b/src/gateway/assistant-identity.ts @@ -1,7 +1,7 @@ +import type { OpenClawConfig } from "../config/config.js"; import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; import { resolveAgentIdentity } from "../agents/identity.js"; import { loadAgentIdentity } from "../commands/agents.config.js"; -import type { OpenClawConfig } from "../config/config.js"; import { normalizeAgentId } from "../routing/session-key.js"; const MAX_ASSISTANT_NAME = 50; diff --git a/src/gateway/auth.test.ts b/src/gateway/auth.test.ts index 7e10221246a..7910adeff77 100644 --- a/src/gateway/auth.test.ts +++ b/src/gateway/auth.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { authorizeGatewayConnect } from "./auth.js"; describe("gateway auth", () => { diff --git a/src/gateway/auth.ts b/src/gateway/auth.ts index 98d603686f2..294b2c94bb3 100644 --- a/src/gateway/auth.ts +++ b/src/gateway/auth.ts @@ -1,5 +1,5 @@ -import { timingSafeEqual } from "node:crypto"; import type { IncomingMessage } from "node:http"; +import { timingSafeEqual } from "node:crypto"; import type { GatewayAuthConfig, GatewayTailscaleMode } from "../config/config.js"; import { readTailscaleWhoisIdentity, type TailscaleWhoisIdentity } from "../infra/tailscale.js"; import { isTrustedProxyAddress, parseForwardedForClientIp, resolveGatewayClientIp } from "./net.js"; diff --git a/src/gateway/boot.test.ts b/src/gateway/boot.test.ts index a680a8d73bf..9e6ead765b9 100644 --- a/src/gateway/boot.test.ts +++ b/src/gateway/boot.test.ts @@ -1,7 +1,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { beforeEach, describe, expect, it, vi } from "vitest"; const agentCommand = vi.fn(); diff --git a/src/gateway/boot.ts b/src/gateway/boot.ts index 32cb6ec8616..d02e81fd275 100644 --- a/src/gateway/boot.ts +++ b/src/gateway/boot.ts @@ -1,11 +1,10 @@ import fs from "node:fs/promises"; import path from "node:path"; - -import { SILENT_REPLY_TOKEN } from "../auto-reply/tokens.js"; import type { CliDeps } from "../cli/deps.js"; import type { OpenClawConfig } from "../config/config.js"; -import { resolveMainSessionKey } from "../config/sessions/main-session.js"; +import { SILENT_REPLY_TOKEN } from "../auto-reply/tokens.js"; import { agentCommand } from "../commands/agent.js"; +import { resolveMainSessionKey } from "../config/sessions/main-session.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { type RuntimeEnv, defaultRuntime } from "../runtime.js"; diff --git a/src/gateway/call.ts b/src/gateway/call.ts index bd563dcd24c..bb196883a52 100644 --- a/src/gateway/call.ts +++ b/src/gateway/call.ts @@ -6,15 +6,15 @@ import { resolveGatewayPort, resolveStateDir, } from "../config/config.js"; -import { pickPrimaryTailnetIPv4 } from "../infra/tailnet.js"; import { loadOrCreateDeviceIdentity } from "../infra/device-identity.js"; +import { pickPrimaryTailnetIPv4 } from "../infra/tailnet.js"; +import { loadGatewayTlsRuntime } from "../infra/tls/gateway.js"; import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES, type GatewayClientMode, type GatewayClientName, } from "../utils/message-channel.js"; -import { loadGatewayTlsRuntime } from "../infra/tls/gateway.js"; import { GatewayClient } from "./client.js"; import { PROTOCOL_VERSION } from "./protocol/index.js"; diff --git a/src/gateway/chat-attachments.test.ts b/src/gateway/chat-attachments.test.ts index 764cb253bf1..43556047254 100644 --- a/src/gateway/chat-attachments.test.ts +++ b/src/gateway/chat-attachments.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { buildMessageWithAttachments, type ChatAttachment, diff --git a/src/gateway/client.test.ts b/src/gateway/client.test.ts index 88498bcad74..2b7978b19da 100644 --- a/src/gateway/client.test.ts +++ b/src/gateway/client.test.ts @@ -1,5 +1,5 @@ -import { createServer } from "node:net"; import { createServer as createHttpsServer } from "node:https"; +import { createServer } from "node:net"; import { afterEach, describe, expect, test } from "vitest"; import { WebSocketServer } from "ws"; import { rawDataToString } from "../infra/ws.js"; diff --git a/src/gateway/client.ts b/src/gateway/client.ts index 55d37282cab..cf2e6984a2e 100644 --- a/src/gateway/client.ts +++ b/src/gateway/client.ts @@ -1,19 +1,19 @@ import { randomUUID } from "node:crypto"; import { WebSocket, type ClientOptions, type CertMeta } from "ws"; -import { normalizeFingerprint } from "../infra/tls/fingerprint.js"; -import { rawDataToString } from "../infra/ws.js"; -import { logDebug, logError } from "../logger.js"; import type { DeviceIdentity } from "../infra/device-identity.js"; -import { - loadOrCreateDeviceIdentity, - publicKeyRawBase64UrlFromPem, - signDevicePayload, -} from "../infra/device-identity.js"; import { clearDeviceAuthToken, loadDeviceAuthToken, storeDeviceAuthToken, } from "../infra/device-auth-store.js"; +import { + loadOrCreateDeviceIdentity, + publicKeyRawBase64UrlFromPem, + signDevicePayload, +} from "../infra/device-identity.js"; +import { normalizeFingerprint } from "../infra/tls/fingerprint.js"; +import { rawDataToString } from "../infra/ws.js"; +import { logDebug, logError } from "../logger.js"; import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES, diff --git a/src/gateway/config-reload.test.ts b/src/gateway/config-reload.test.ts index 3ad545855f2..9259de73a89 100644 --- a/src/gateway/config-reload.test.ts +++ b/src/gateway/config-reload.test.ts @@ -1,6 +1,6 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest"; -import { listChannelPlugins } from "../channels/plugins/index.js"; import type { ChannelPlugin } from "../channels/plugins/types.js"; +import { listChannelPlugins } from "../channels/plugins/index.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import { createTestRegistry } from "../test-utils/channel-plugins.js"; import { diff --git a/src/gateway/config-reload.ts b/src/gateway/config-reload.ts index b31e504cd5d..5bfd6c57535 100644 --- a/src/gateway/config-reload.ts +++ b/src/gateway/config-reload.ts @@ -1,7 +1,7 @@ import chokidar from "chokidar"; +import type { OpenClawConfig, ConfigFileSnapshot, GatewayReloadMode } from "../config/config.js"; import { type ChannelId, listChannelPlugins } from "../channels/plugins/index.js"; import { getActivePluginRegistry } from "../plugins/runtime.js"; -import type { OpenClawConfig, ConfigFileSnapshot, GatewayReloadMode } from "../config/config.js"; export type GatewayReloadSettings = { mode: GatewayReloadMode; diff --git a/src/gateway/control-ui.test.ts b/src/gateway/control-ui.test.ts index 06719d2764c..9ae2267ed55 100644 --- a/src/gateway/control-ui.test.ts +++ b/src/gateway/control-ui.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { buildControlUiAvatarUrl, normalizeControlUiBasePath, diff --git a/src/gateway/control-ui.ts b/src/gateway/control-ui.ts index fde3218f722..b223e9f87e5 100644 --- a/src/gateway/control-ui.ts +++ b/src/gateway/control-ui.ts @@ -1,8 +1,7 @@ -import fs from "node:fs"; import type { IncomingMessage, ServerResponse } from "node:http"; +import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; - import type { OpenClawConfig } from "../config/config.js"; import { DEFAULT_ASSISTANT_IDENTITY, resolveAssistantIdentity } from "./assistant-identity.js"; import { diff --git a/src/gateway/exec-approval-manager.ts b/src/gateway/exec-approval-manager.ts index 2eb32d84ab2..3c33aac4d59 100644 --- a/src/gateway/exec-approval-manager.ts +++ b/src/gateway/exec-approval-manager.ts @@ -1,5 +1,4 @@ import { randomUUID } from "node:crypto"; - import type { ExecApprovalDecision } from "../infra/exec-approvals.js"; export type ExecApprovalRequestPayload = { diff --git a/src/gateway/gateway-cli-backend.live.test.ts b/src/gateway/gateway-cli-backend.live.test.ts index 88a4153d27d..431658a8aff 100644 --- a/src/gateway/gateway-cli-backend.live.test.ts +++ b/src/gateway/gateway-cli-backend.live.test.ts @@ -3,7 +3,6 @@ import fs from "node:fs/promises"; import { createServer } from "node:net"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; import { parseModelRef } from "../agents/model-selection.js"; import { loadConfig } from "../config/config.js"; diff --git a/src/gateway/gateway-models.profiles.live.test.ts b/src/gateway/gateway-models.profiles.live.test.ts index 30992927246..d941c1d2626 100644 --- a/src/gateway/gateway-models.profiles.live.test.ts +++ b/src/gateway/gateway-models.profiles.live.test.ts @@ -1,12 +1,11 @@ +import type { Api, Model } from "@mariozechner/pi-ai"; import { randomBytes, randomUUID } from "node:crypto"; import fs from "node:fs/promises"; import { createServer } from "node:net"; import os from "node:os"; import path from "node:path"; - -import type { Api, Model } from "@mariozechner/pi-ai"; -import { discoverAuthStorage, discoverModels } from "../agents/pi-model-discovery.js"; import { describe, it } from "vitest"; +import type { OpenClawConfig, ModelProviderConfig } from "../config/types.js"; import { resolveOpenClawAgentDir } from "../agents/agent-paths.js"; import { resolveAgentWorkspaceDir } from "../agents/agent-scope.js"; import { @@ -22,8 +21,8 @@ import { import { isModernModelRef } from "../agents/live-model-filter.js"; import { getApiKeyForModel } from "../agents/model-auth.js"; import { ensureOpenClawModelsJson } from "../agents/models-config.js"; +import { discoverAuthStorage, discoverModels } from "../agents/pi-model-discovery.js"; import { loadConfig } from "../config/config.js"; -import type { OpenClawConfig, ModelProviderConfig } from "../config/types.js"; import { isTruthyEnvValue } from "../infra/env.js"; import { DEFAULT_AGENT_ID } from "../routing/session-key.js"; import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; diff --git a/src/gateway/gateway.e2e.test.ts b/src/gateway/gateway.e2e.test.ts index 4a5619518b6..bb9e152d59e 100644 --- a/src/gateway/gateway.e2e.test.ts +++ b/src/gateway/gateway.e2e.test.ts @@ -2,16 +2,14 @@ import { randomUUID } from "node:crypto"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - +import { startGatewayServer } from "./server.js"; import { connectDeviceAuthReq, connectGatewayClient, getFreeGatewayPort, } from "./test-helpers.e2e.js"; import { installOpenAiResponsesMock } from "./test-helpers.openai-mock.js"; -import { startGatewayServer } from "./server.js"; function extractPayloadText(result: unknown): string { const record = result as Record; diff --git a/src/gateway/hooks-mapping.test.ts b/src/gateway/hooks-mapping.test.ts index 872edfaca65..d7b9924ed46 100644 --- a/src/gateway/hooks-mapping.test.ts +++ b/src/gateway/hooks-mapping.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { describe, expect, it } from "vitest"; - import { applyHookMappings, resolveHookMappings } from "./hooks-mapping.js"; const baseUrl = new URL("http://127.0.0.1:18789/hooks/gmail"); diff --git a/src/gateway/hooks-mapping.ts b/src/gateway/hooks-mapping.ts index d3a14b47ab7..abcea54f673 100644 --- a/src/gateway/hooks-mapping.ts +++ b/src/gateway/hooks-mapping.ts @@ -1,8 +1,7 @@ import path from "node:path"; import { pathToFileURL } from "node:url"; - -import { CONFIG_PATH, type HookMappingConfig, type HooksConfig } from "../config/config.js"; import type { HookMessageChannel } from "./hooks.js"; +import { CONFIG_PATH, type HookMappingConfig, type HooksConfig } from "../config/config.js"; export type HookMappingResolved = { id: string; diff --git a/src/gateway/hooks.test.ts b/src/gateway/hooks.test.ts index 970acde4d2a..550ba9caf35 100644 --- a/src/gateway/hooks.test.ts +++ b/src/gateway/hooks.test.ts @@ -1,7 +1,7 @@ import type { IncomingMessage } from "node:http"; import { afterEach, beforeEach, describe, expect, test } from "vitest"; -import type { OpenClawConfig } from "../config/config.js"; import type { ChannelPlugin } from "../channels/plugins/types.js"; +import type { OpenClawConfig } from "../config/config.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import { createIMessageTestPlugin, createTestRegistry } from "../test-utils/channel-plugins.js"; import { diff --git a/src/gateway/hooks.ts b/src/gateway/hooks.ts index 26b44c8de08..543faf747a4 100644 --- a/src/gateway/hooks.ts +++ b/src/gateway/hooks.ts @@ -1,8 +1,8 @@ -import { randomUUID } from "node:crypto"; import type { IncomingMessage } from "node:http"; -import { listChannelPlugins } from "../channels/plugins/index.js"; +import { randomUUID } from "node:crypto"; import type { ChannelId } from "../channels/plugins/types.js"; import type { OpenClawConfig } from "../config/config.js"; +import { listChannelPlugins } from "../channels/plugins/index.js"; import { normalizeMessageChannel } from "../utils/message-channel.js"; import { type HookMappingResolved, resolveHookMappings } from "./hooks-mapping.js"; diff --git a/src/gateway/http-common.ts b/src/gateway/http-common.ts index 993a3ac3649..c7abc82860c 100644 --- a/src/gateway/http-common.ts +++ b/src/gateway/http-common.ts @@ -1,5 +1,4 @@ import type { IncomingMessage, ServerResponse } from "node:http"; - import { readJsonBody } from "./hooks.js"; export function sendJson(res: ServerResponse, status: number, body: unknown) { diff --git a/src/gateway/http-utils.ts b/src/gateway/http-utils.ts index f857a6caac5..95be8d2210a 100644 --- a/src/gateway/http-utils.ts +++ b/src/gateway/http-utils.ts @@ -1,6 +1,5 @@ -import { randomUUID } from "node:crypto"; import type { IncomingMessage } from "node:http"; - +import { randomUUID } from "node:crypto"; import { buildAgentMainSessionKey, normalizeAgentId } from "../routing/session-key.js"; export function getHeader(req: IncomingMessage, name: string): string | undefined { diff --git a/src/gateway/net.test.ts b/src/gateway/net.test.ts index 46c426d63fe..2cbd75a2ef1 100644 --- a/src/gateway/net.test.ts +++ b/src/gateway/net.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { resolveGatewayListenHosts } from "./net.js"; describe("resolveGatewayListenHosts", () => { diff --git a/src/gateway/net.ts b/src/gateway/net.ts index dd9c2ccc3dd..e7730428b9e 100644 --- a/src/gateway/net.ts +++ b/src/gateway/net.ts @@ -1,5 +1,4 @@ import net from "node:net"; - import { pickPrimaryTailnetIPv4, pickPrimaryTailnetIPv6 } from "../infra/tailnet.js"; export function isLoopbackAddress(ip: string | undefined): boolean { diff --git a/src/gateway/node-registry.ts b/src/gateway/node-registry.ts index e29b55fe53e..c29737ebb0d 100644 --- a/src/gateway/node-registry.ts +++ b/src/gateway/node-registry.ts @@ -1,5 +1,4 @@ import { randomUUID } from "node:crypto"; - import type { GatewayWsClient } from "./server/ws-types.js"; export type NodeSession = { diff --git a/src/gateway/openai-http.e2e.test.ts b/src/gateway/openai-http.e2e.test.ts index 99698ca7291..713ab5e7ffa 100644 --- a/src/gateway/openai-http.e2e.test.ts +++ b/src/gateway/openai-http.e2e.test.ts @@ -1,5 +1,4 @@ import { afterAll, beforeAll, describe, expect, it } from "vitest"; - import { HISTORY_CONTEXT_MARKER } from "../auto-reply/reply/history.js"; import { CURRENT_MESSAGE_MARKER } from "../auto-reply/reply/mentions.js"; import { emitAgentEvent } from "../infra/agent-events.js"; diff --git a/src/gateway/openai-http.ts b/src/gateway/openai-http.ts index 15f361ab33b..9a623d75ee2 100644 --- a/src/gateway/openai-http.ts +++ b/src/gateway/openai-http.ts @@ -1,6 +1,5 @@ -import { randomUUID } from "node:crypto"; import type { IncomingMessage, ServerResponse } from "node:http"; - +import { randomUUID } from "node:crypto"; import { buildHistoryContextFromEntries, type HistoryEntry } from "../auto-reply/reply/history.js"; import { createDefaultDeps } from "../cli/deps.js"; import { agentCommand } from "../commands/agent.js"; diff --git a/src/gateway/openresponses-http.e2e.test.ts b/src/gateway/openresponses-http.e2e.test.ts index 548fa179f43..b79aa55a897 100644 --- a/src/gateway/openresponses-http.e2e.test.ts +++ b/src/gateway/openresponses-http.e2e.test.ts @@ -1,5 +1,4 @@ import { afterAll, beforeAll, describe, expect, it } from "vitest"; - import { HISTORY_CONTEXT_MARKER } from "../auto-reply/reply/history.js"; import { CURRENT_MESSAGE_MARKER } from "../auto-reply/reply/mentions.js"; import { emitAgentEvent } from "../infra/agent-events.js"; diff --git a/src/gateway/openresponses-http.ts b/src/gateway/openresponses-http.ts index be8f5bbd5ab..adbc49e6b3e 100644 --- a/src/gateway/openresponses-http.ts +++ b/src/gateway/openresponses-http.ts @@ -6,37 +6,15 @@ * @see https://www.open-responses.com/ */ -import { randomUUID } from "node:crypto"; import type { IncomingMessage, ServerResponse } from "node:http"; - +import { randomUUID } from "node:crypto"; +import type { ClientToolDefinition } from "../agents/pi-embedded-runner/run/params.js"; +import type { ImageContent } from "../commands/agent/types.js"; +import type { GatewayHttpResponsesConfig } from "../config/types.gateway.js"; import { buildHistoryContextFromEntries, type HistoryEntry } from "../auto-reply/reply/history.js"; import { createDefaultDeps } from "../cli/deps.js"; import { agentCommand } from "../commands/agent.js"; import { emitAgentEvent, onAgentEvent } from "../infra/agent-events.js"; -import { defaultRuntime } from "../runtime.js"; -import { authorizeGatewayConnect, type ResolvedGatewayAuth } from "./auth.js"; -import { getBearerToken, resolveAgentIdForRequest, resolveSessionKey } from "./http-utils.js"; -import { - readJsonBodyOrError, - sendJson, - sendMethodNotAllowed, - sendUnauthorized, - setSseHeaders, - writeDone, -} from "./http-common.js"; -import { - CreateResponseBodySchema, - type ContentPart, - type CreateResponseBody, - type ItemParam, - type OutputItem, - type ResponseResource, - type StreamingEvent, - type Usage, -} from "./open-responses.schema.js"; -import type { GatewayHttpResponsesConfig } from "../config/types.gateway.js"; -import type { ClientToolDefinition } from "../agents/pi-embedded-runner/run/params.js"; -import type { ImageContent } from "../commands/agent/types.js"; import { DEFAULT_INPUT_FILE_MAX_BYTES, DEFAULT_INPUT_FILE_MAX_CHARS, @@ -55,6 +33,27 @@ import { type InputImageLimits, type InputImageSource, } from "../media/input-files.js"; +import { defaultRuntime } from "../runtime.js"; +import { authorizeGatewayConnect, type ResolvedGatewayAuth } from "./auth.js"; +import { + readJsonBodyOrError, + sendJson, + sendMethodNotAllowed, + sendUnauthorized, + setSseHeaders, + writeDone, +} from "./http-common.js"; +import { getBearerToken, resolveAgentIdForRequest, resolveSessionKey } from "./http-utils.js"; +import { + CreateResponseBodySchema, + type ContentPart, + type CreateResponseBody, + type ItemParam, + type OutputItem, + type ResponseResource, + type StreamingEvent, + type Usage, +} from "./open-responses.schema.js"; type OpenResponsesHttpOptions = { auth: ResolvedGatewayAuth; diff --git a/src/gateway/probe.ts b/src/gateway/probe.ts index a57e23774d0..c2593e0410d 100644 --- a/src/gateway/probe.ts +++ b/src/gateway/probe.ts @@ -1,5 +1,4 @@ import { randomUUID } from "node:crypto"; - import type { SystemPresence } from "../infra/system-presence.js"; import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; import { GatewayClient } from "./client.js"; diff --git a/src/gateway/protocol/index.test.ts b/src/gateway/protocol/index.test.ts index 82895136608..c74e7361db3 100644 --- a/src/gateway/protocol/index.test.ts +++ b/src/gateway/protocol/index.test.ts @@ -1,6 +1,5 @@ -import { describe, expect, it } from "vitest"; import type { ErrorObject } from "ajv"; - +import { describe, expect, it } from "vitest"; import { formatValidationErrors } from "./index.js"; const makeError = (overrides: Partial): ErrorObject => ({ diff --git a/src/gateway/protocol/schema/agent.ts b/src/gateway/protocol/schema/agent.ts index 3f1a5b5a8f7..9e11a63415d 100644 --- a/src/gateway/protocol/schema/agent.ts +++ b/src/gateway/protocol/schema/agent.ts @@ -1,5 +1,4 @@ import { Type } from "@sinclair/typebox"; - import { NonEmptyString, SessionLabelString } from "./primitives.js"; export const AgentEventSchema = Type.Object( diff --git a/src/gateway/protocol/schema/agents-models-skills.ts b/src/gateway/protocol/schema/agents-models-skills.ts index c3b39257f10..564fa68a2b1 100644 --- a/src/gateway/protocol/schema/agents-models-skills.ts +++ b/src/gateway/protocol/schema/agents-models-skills.ts @@ -1,5 +1,4 @@ import { Type } from "@sinclair/typebox"; - import { NonEmptyString } from "./primitives.js"; export const ModelChoiceSchema = Type.Object( diff --git a/src/gateway/protocol/schema/channels.ts b/src/gateway/protocol/schema/channels.ts index 76c6ac4d8cb..cbbaaa1922c 100644 --- a/src/gateway/protocol/schema/channels.ts +++ b/src/gateway/protocol/schema/channels.ts @@ -1,5 +1,4 @@ import { Type } from "@sinclair/typebox"; - import { NonEmptyString } from "./primitives.js"; export const TalkModeParamsSchema = Type.Object( diff --git a/src/gateway/protocol/schema/config.ts b/src/gateway/protocol/schema/config.ts index beeaac5d517..eb7389a4d1d 100644 --- a/src/gateway/protocol/schema/config.ts +++ b/src/gateway/protocol/schema/config.ts @@ -1,5 +1,4 @@ import { Type } from "@sinclair/typebox"; - import { NonEmptyString } from "./primitives.js"; export const ConfigGetParamsSchema = Type.Object({}, { additionalProperties: false }); diff --git a/src/gateway/protocol/schema/cron.ts b/src/gateway/protocol/schema/cron.ts index 63ed0c209c5..47c26ec91ee 100644 --- a/src/gateway/protocol/schema/cron.ts +++ b/src/gateway/protocol/schema/cron.ts @@ -1,5 +1,4 @@ import { Type } from "@sinclair/typebox"; - import { NonEmptyString } from "./primitives.js"; export const CronScheduleSchema = Type.Union([ diff --git a/src/gateway/protocol/schema/devices.ts b/src/gateway/protocol/schema/devices.ts index ec32f381b27..8163be27a3b 100644 --- a/src/gateway/protocol/schema/devices.ts +++ b/src/gateway/protocol/schema/devices.ts @@ -1,5 +1,4 @@ import { Type } from "@sinclair/typebox"; - import { NonEmptyString } from "./primitives.js"; export const DevicePairListParamsSchema = Type.Object({}, { additionalProperties: false }); diff --git a/src/gateway/protocol/schema/exec-approvals.ts b/src/gateway/protocol/schema/exec-approvals.ts index e6f7ce9068b..a88cdffcdc3 100644 --- a/src/gateway/protocol/schema/exec-approvals.ts +++ b/src/gateway/protocol/schema/exec-approvals.ts @@ -1,5 +1,4 @@ import { Type } from "@sinclair/typebox"; - import { NonEmptyString } from "./primitives.js"; export const ExecApprovalsAllowlistEntrySchema = Type.Object( diff --git a/src/gateway/protocol/schema/logs-chat.ts b/src/gateway/protocol/schema/logs-chat.ts index dc04a29d526..b8d0fe1ba45 100644 --- a/src/gateway/protocol/schema/logs-chat.ts +++ b/src/gateway/protocol/schema/logs-chat.ts @@ -1,5 +1,4 @@ import { Type } from "@sinclair/typebox"; - import { NonEmptyString } from "./primitives.js"; export const LogsTailParamsSchema = Type.Object( diff --git a/src/gateway/protocol/schema/nodes.ts b/src/gateway/protocol/schema/nodes.ts index 7762f30b8d6..4eaccb8d7fa 100644 --- a/src/gateway/protocol/schema/nodes.ts +++ b/src/gateway/protocol/schema/nodes.ts @@ -1,5 +1,4 @@ import { Type } from "@sinclair/typebox"; - import { NonEmptyString } from "./primitives.js"; export const NodePairRequestParamsSchema = Type.Object( diff --git a/src/gateway/protocol/schema/protocol-schemas.ts b/src/gateway/protocol/schema/protocol-schemas.ts index e92f114e292..11eb6e2ba9e 100644 --- a/src/gateway/protocol/schema/protocol-schemas.ts +++ b/src/gateway/protocol/schema/protocol-schemas.ts @@ -1,5 +1,4 @@ import type { TSchema } from "@sinclair/typebox"; - import { AgentEventSchema, AgentIdentityParamsSchema, @@ -51,15 +50,6 @@ import { CronStatusParamsSchema, CronUpdateParamsSchema, } from "./cron.js"; -import { - ExecApprovalsGetParamsSchema, - ExecApprovalsNodeGetParamsSchema, - ExecApprovalsNodeSetParamsSchema, - ExecApprovalsSetParamsSchema, - ExecApprovalsSnapshotSchema, - ExecApprovalRequestParamsSchema, - ExecApprovalResolveParamsSchema, -} from "./exec-approvals.js"; import { DevicePairApproveParamsSchema, DevicePairListParamsSchema, @@ -69,6 +59,15 @@ import { DeviceTokenRevokeParamsSchema, DeviceTokenRotateParamsSchema, } from "./devices.js"; +import { + ExecApprovalsGetParamsSchema, + ExecApprovalsNodeGetParamsSchema, + ExecApprovalsNodeSetParamsSchema, + ExecApprovalsSetParamsSchema, + ExecApprovalsSnapshotSchema, + ExecApprovalRequestParamsSchema, + ExecApprovalResolveParamsSchema, +} from "./exec-approvals.js"; import { ConnectParamsSchema, ErrorShapeSchema, diff --git a/src/gateway/protocol/schema/sessions.ts b/src/gateway/protocol/schema/sessions.ts index 67156a5de7d..ab6bbb12a75 100644 --- a/src/gateway/protocol/schema/sessions.ts +++ b/src/gateway/protocol/schema/sessions.ts @@ -1,5 +1,4 @@ import { Type } from "@sinclair/typebox"; - import { NonEmptyString, SessionLabelString } from "./primitives.js"; export const SessionsListParamsSchema = Type.Object( diff --git a/src/gateway/protocol/schema/types.ts b/src/gateway/protocol/schema/types.ts index 6965037212c..193784bc81b 100644 --- a/src/gateway/protocol/schema/types.ts +++ b/src/gateway/protocol/schema/types.ts @@ -1,5 +1,4 @@ import type { Static } from "@sinclair/typebox"; - import type { AgentEventSchema, AgentIdentityParamsSchema, @@ -49,6 +48,13 @@ import type { CronStatusParamsSchema, CronUpdateParamsSchema, } from "./cron.js"; +import type { + DevicePairApproveParamsSchema, + DevicePairListParamsSchema, + DevicePairRejectParamsSchema, + DeviceTokenRevokeParamsSchema, + DeviceTokenRotateParamsSchema, +} from "./devices.js"; import type { ExecApprovalsGetParamsSchema, ExecApprovalsNodeGetParamsSchema, @@ -58,13 +64,6 @@ import type { ExecApprovalRequestParamsSchema, ExecApprovalResolveParamsSchema, } from "./exec-approvals.js"; -import type { - DevicePairApproveParamsSchema, - DevicePairListParamsSchema, - DevicePairRejectParamsSchema, - DeviceTokenRevokeParamsSchema, - DeviceTokenRotateParamsSchema, -} from "./devices.js"; import type { ConnectParamsSchema, ErrorShapeSchema, diff --git a/src/gateway/protocol/schema/wizard.ts b/src/gateway/protocol/schema/wizard.ts index 1ceaa0b9a95..2a5f75e2e1d 100644 --- a/src/gateway/protocol/schema/wizard.ts +++ b/src/gateway/protocol/schema/wizard.ts @@ -1,5 +1,4 @@ import { Type } from "@sinclair/typebox"; - import { NonEmptyString } from "./primitives.js"; export const WizardStartParamsSchema = Type.Object( diff --git a/src/gateway/server-broadcast.test.ts b/src/gateway/server-broadcast.test.ts index 44d164cf0e8..0dcec9e0974 100644 --- a/src/gateway/server-broadcast.test.ts +++ b/src/gateway/server-broadcast.test.ts @@ -1,7 +1,6 @@ import { describe, expect, it, vi } from "vitest"; - -import { createGatewayBroadcaster } from "./server-broadcast.js"; import type { GatewayWsClient } from "./server/ws-types.js"; +import { createGatewayBroadcaster } from "./server-broadcast.js"; type TestSocket = { bufferedAmount: number; diff --git a/src/gateway/server-channels.ts b/src/gateway/server-channels.ts index 7b1567b43b0..73a6a11cd7a 100644 --- a/src/gateway/server-channels.ts +++ b/src/gateway/server-channels.ts @@ -1,12 +1,12 @@ -import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js"; -import { type ChannelId, getChannelPlugin, listChannelPlugins } from "../channels/plugins/index.js"; import type { ChannelAccountSnapshot } from "../channels/plugins/types.js"; import type { OpenClawConfig } from "../config/config.js"; +import type { createSubsystemLogger } from "../logging/subsystem.js"; +import type { RuntimeEnv } from "../runtime.js"; +import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js"; +import { type ChannelId, getChannelPlugin, listChannelPlugins } from "../channels/plugins/index.js"; import { formatErrorMessage } from "../infra/errors.js"; import { resetDirectoryCache } from "../infra/outbound/target-resolver.js"; -import type { createSubsystemLogger } from "../logging/subsystem.js"; import { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js"; -import type { RuntimeEnv } from "../runtime.js"; export type ChannelRuntimeSnapshot = { channels: Partial>; diff --git a/src/gateway/server-chat.agent-events.test.ts b/src/gateway/server-chat.agent-events.test.ts index 14657464a7e..43761af11aa 100644 --- a/src/gateway/server-chat.agent-events.test.ts +++ b/src/gateway/server-chat.agent-events.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { createAgentEventHandler, createChatRunState } from "./server-chat.js"; describe("agent event handler", () => { diff --git a/src/gateway/server-close.ts b/src/gateway/server-close.ts index da9f5a39e97..ea0323587a9 100644 --- a/src/gateway/server-close.ts +++ b/src/gateway/server-close.ts @@ -1,10 +1,10 @@ import type { Server as HttpServer } from "node:http"; import type { WebSocketServer } from "ws"; import type { CanvasHostHandler, CanvasHostServer } from "../canvas-host/server.js"; -import { type ChannelId, listChannelPlugins } from "../channels/plugins/index.js"; -import { stopGmailWatcher } from "../hooks/gmail-watcher.js"; import type { HeartbeatRunner } from "../infra/heartbeat-runner.js"; import type { PluginServicesHandle } from "../plugins/services.js"; +import { type ChannelId, listChannelPlugins } from "../channels/plugins/index.js"; +import { stopGmailWatcher } from "../hooks/gmail-watcher.js"; export function createGatewayCloseHandler(params: { bonjourStop: (() => Promise) | null; diff --git a/src/gateway/server-cron.ts b/src/gateway/server-cron.ts index 46d335c3906..68b0bc095e3 100644 --- a/src/gateway/server-cron.ts +++ b/src/gateway/server-cron.ts @@ -1,5 +1,5 @@ -import { resolveDefaultAgentId } from "../agents/agent-scope.js"; import type { CliDeps } from "../cli/deps.js"; +import { resolveDefaultAgentId } from "../agents/agent-scope.js"; import { loadConfig } from "../config/config.js"; import { resolveAgentMainSessionKey } from "../config/sessions.js"; import { runCronIsolatedAgentTurn } from "../cron/isolated-agent.js"; diff --git a/src/gateway/server-http.ts b/src/gateway/server-http.ts index f725c2abf50..d2dcdef958a 100644 --- a/src/gateway/server-http.ts +++ b/src/gateway/server-http.ts @@ -1,3 +1,5 @@ +import type { TlsOptions } from "node:tls"; +import type { WebSocketServer } from "ws"; import { createServer as createHttpServer, type Server as HttpServer, @@ -5,15 +7,14 @@ import { type ServerResponse, } from "node:http"; import { createServer as createHttpsServer } from "node:https"; -import type { TlsOptions } from "node:tls"; -import type { WebSocketServer } from "ws"; -import { handleA2uiHttpRequest } from "../canvas-host/a2ui.js"; import type { CanvasHostHandler } from "../canvas-host/server.js"; -import { loadConfig } from "../config/config.js"; import type { createSubsystemLogger } from "../logging/subsystem.js"; -import { handleSlackHttpRequest } from "../slack/http/index.js"; import { resolveAgentAvatar } from "../agents/identity-avatar.js"; +import { handleA2uiHttpRequest } from "../canvas-host/a2ui.js"; +import { loadConfig } from "../config/config.js"; +import { handleSlackHttpRequest } from "../slack/http/index.js"; import { handleControlUiAvatarRequest, handleControlUiHttpRequest } from "./control-ui.js"; +import { applyHookMappings } from "./hooks-mapping.js"; import { extractHookToken, getHookChannelError, @@ -26,7 +27,6 @@ import { resolveHookChannel, resolveHookDeliver, } from "./hooks.js"; -import { applyHookMappings } from "./hooks-mapping.js"; import { handleOpenAiHttpRequest } from "./openai-http.js"; import { handleOpenResponsesHttpRequest } from "./openresponses-http.js"; import { handleToolsInvokeHttpRequest } from "./tools-invoke-http.js"; diff --git a/src/gateway/server-maintenance.ts b/src/gateway/server-maintenance.ts index 0c440eee87b..898e8ef74fc 100644 --- a/src/gateway/server-maintenance.ts +++ b/src/gateway/server-maintenance.ts @@ -1,15 +1,15 @@ import type { HealthSummary } from "../commands/health.js"; -import { abortChatRunById, type ChatAbortControllerEntry } from "./chat-abort.js"; -import { setBroadcastHealthUpdate } from "./server/health-state.js"; import type { ChatRunEntry } from "./server-chat.js"; +import type { DedupeEntry } from "./server-shared.js"; +import { abortChatRunById, type ChatAbortControllerEntry } from "./chat-abort.js"; import { DEDUPE_MAX, DEDUPE_TTL_MS, HEALTH_REFRESH_INTERVAL_MS, TICK_INTERVAL_MS, } from "./server-constants.js"; -import type { DedupeEntry } from "./server-shared.js"; import { formatError } from "./server-utils.js"; +import { setBroadcastHealthUpdate } from "./server/health-state.js"; export function startGatewayMaintenanceTimers(params: { broadcast: ( diff --git a/src/gateway/server-methods.ts b/src/gateway/server-methods.ts index fac38858beb..f76a637fa63 100644 --- a/src/gateway/server-methods.ts +++ b/src/gateway/server-methods.ts @@ -1,3 +1,4 @@ +import type { GatewayRequestHandlers, GatewayRequestOptions } from "./server-methods/types.js"; import { ErrorCodes, errorShape } from "./protocol/index.js"; import { agentHandlers } from "./server-methods/agent.js"; import { agentsHandlers } from "./server-methods/agents.js"; @@ -19,7 +20,6 @@ import { skillsHandlers } from "./server-methods/skills.js"; import { systemHandlers } from "./server-methods/system.js"; import { talkHandlers } from "./server-methods/talk.js"; import { ttsHandlers } from "./server-methods/tts.js"; -import type { GatewayRequestHandlers, GatewayRequestOptions } from "./server-methods/types.js"; import { updateHandlers } from "./server-methods/update.js"; import { usageHandlers } from "./server-methods/usage.js"; import { voicewakeHandlers } from "./server-methods/voicewake.js"; diff --git a/src/gateway/server-methods/agent-timestamp.test.ts b/src/gateway/server-methods/agent-timestamp.test.ts index 9ac3f7d1317..1b291ca8f42 100644 --- a/src/gateway/server-methods/agent-timestamp.test.ts +++ b/src/gateway/server-methods/agent-timestamp.test.ts @@ -1,6 +1,6 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { injectTimestamp, timestampOptsFromConfig } from "./agent-timestamp.js"; import { formatZonedTimestamp } from "../../auto-reply/envelope.js"; +import { injectTimestamp, timestampOptsFromConfig } from "./agent-timestamp.js"; describe("injectTimestamp", () => { beforeEach(() => { diff --git a/src/gateway/server-methods/agent-timestamp.ts b/src/gateway/server-methods/agent-timestamp.ts index 51b6d1907de..715262de288 100644 --- a/src/gateway/server-methods/agent-timestamp.ts +++ b/src/gateway/server-methods/agent-timestamp.ts @@ -1,6 +1,6 @@ +import type { OpenClawConfig } from "../../config/types.js"; import { resolveUserTimezone } from "../../agents/date-time.js"; import { formatZonedTimestamp } from "../../auto-reply/envelope.js"; -import type { OpenClawConfig } from "../../config/types.js"; /** * Cron jobs inject "Current time: ..." into their messages. diff --git a/src/gateway/server-methods/agent.test.ts b/src/gateway/server-methods/agent.test.ts index 669a8aa075c..797309d21c5 100644 --- a/src/gateway/server-methods/agent.test.ts +++ b/src/gateway/server-methods/agent.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { GatewayRequestContext } from "./types.js"; import { agentHandlers } from "./agent.js"; diff --git a/src/gateway/server-methods/agent.ts b/src/gateway/server-methods/agent.ts index b2e524d3274..8377699ccd1 100644 --- a/src/gateway/server-methods/agent.ts +++ b/src/gateway/server-methods/agent.ts @@ -1,8 +1,8 @@ import { randomUUID } from "node:crypto"; -import { agentCommand } from "../../commands/agent.js"; +import type { GatewayRequestHandlers } from "./types.js"; import { listAgentIds } from "../../agents/agent-scope.js"; +import { agentCommand } from "../../commands/agent.js"; import { loadConfig } from "../../config/config.js"; -import { injectTimestamp, timestampOptsFromConfig } from "./agent-timestamp.js"; import { resolveAgentIdFromSessionKey, resolveExplicitAgentSessionKey, @@ -15,6 +15,7 @@ import { resolveAgentDeliveryPlan, resolveAgentOutboundTarget, } from "../../infra/outbound/agent-delivery.js"; +import { normalizeAgentId } from "../../routing/session-key.js"; import { defaultRuntime } from "../../runtime.js"; import { resolveSendPolicy } from "../../sessions/send-policy.js"; import { normalizeSessionDeliveryFields } from "../../utils/delivery-context.js"; @@ -24,8 +25,9 @@ import { isGatewayMessageChannel, normalizeMessageChannel, } from "../../utils/message-channel.js"; -import { normalizeAgentId } from "../../routing/session-key.js"; +import { resolveAssistantIdentity } from "../assistant-identity.js"; import { parseMessageWithAttachments } from "../chat-attachments.js"; +import { resolveAssistantAvatarUrl } from "../control-ui-shared.js"; import { ErrorCodes, errorShape, @@ -36,10 +38,8 @@ import { } from "../protocol/index.js"; import { loadSessionEntry } from "../session-utils.js"; import { formatForLog } from "../ws-log.js"; -import { resolveAssistantIdentity } from "../assistant-identity.js"; -import { resolveAssistantAvatarUrl } from "../control-ui-shared.js"; import { waitForAgentJob } from "./agent-job.js"; -import type { GatewayRequestHandlers } from "./types.js"; +import { injectTimestamp, timestampOptsFromConfig } from "./agent-timestamp.js"; export const agentHandlers: GatewayRequestHandlers = { agent: async ({ params, respond, context }) => { diff --git a/src/gateway/server-methods/agents.ts b/src/gateway/server-methods/agents.ts index 444efbe9d82..a700e495ed4 100644 --- a/src/gateway/server-methods/agents.ts +++ b/src/gateway/server-methods/agents.ts @@ -1,3 +1,4 @@ +import type { GatewayRequestHandlers } from "./types.js"; import { loadConfig } from "../../config/config.js"; import { ErrorCodes, @@ -6,7 +7,6 @@ import { validateAgentsListParams, } from "../protocol/index.js"; import { listAgentsForGateway } from "../session-utils.js"; -import type { GatewayRequestHandlers } from "./types.js"; export const agentsHandlers: GatewayRequestHandlers = { "agents.list": ({ params, respond }) => { diff --git a/src/gateway/server-methods/browser.ts b/src/gateway/server-methods/browser.ts index 24adf8af0ed..42e53e85983 100644 --- a/src/gateway/server-methods/browser.ts +++ b/src/gateway/server-methods/browser.ts @@ -1,4 +1,6 @@ import crypto from "node:crypto"; +import type { NodeSession } from "../node-registry.js"; +import type { GatewayRequestHandlers } from "./types.js"; import { createBrowserControlContext, startBrowserControlServiceFromConfig, @@ -7,10 +9,8 @@ import { createBrowserRouteDispatcher } from "../../browser/routes/dispatcher.js import { loadConfig } from "../../config/config.js"; import { saveMediaBuffer } from "../../media/store.js"; import { isNodeCommandAllowed, resolveNodeCommandAllowlist } from "../node-command-policy.js"; -import type { NodeSession } from "../node-registry.js"; import { ErrorCodes, errorShape } from "../protocol/index.js"; import { safeParseJson } from "./nodes.helpers.js"; -import type { GatewayRequestHandlers } from "./types.js"; type BrowserRequestParams = { method?: string; diff --git a/src/gateway/server-methods/channels.ts b/src/gateway/server-methods/channels.ts index ad71d593af6..529fba686f2 100644 --- a/src/gateway/server-methods/channels.ts +++ b/src/gateway/server-methods/channels.ts @@ -1,3 +1,7 @@ +import type { ChannelAccountSnapshot, ChannelPlugin } from "../../channels/plugins/types.js"; +import type { OpenClawConfig } from "../../config/config.js"; +import type { GatewayRequestContext, GatewayRequestHandlers } from "./types.js"; +import { buildChannelUiCatalog } from "../../channels/plugins/catalog.js"; import { resolveChannelDefaultAccountId } from "../../channels/plugins/helpers.js"; import { type ChannelId, @@ -5,10 +9,7 @@ import { listChannelPlugins, normalizeChannelId, } from "../../channels/plugins/index.js"; -import { buildChannelUiCatalog } from "../../channels/plugins/catalog.js"; import { buildChannelAccountSnapshot } from "../../channels/plugins/status.js"; -import type { ChannelAccountSnapshot, ChannelPlugin } from "../../channels/plugins/types.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { loadConfig, readConfigFileSnapshot } from "../../config/config.js"; import { getChannelActivity } from "../../infra/channel-activity.js"; import { DEFAULT_ACCOUNT_ID } from "../../routing/session-key.js"; @@ -21,7 +22,6 @@ import { validateChannelsStatusParams, } from "../protocol/index.js"; import { formatForLog } from "../ws-log.js"; -import type { GatewayRequestContext, GatewayRequestHandlers } from "./types.js"; type ChannelLogoutPayload = { channel: ChannelId; diff --git a/src/gateway/server-methods/chat.ts b/src/gateway/server-methods/chat.ts index d2cfc51ed33..ba5347dc3fb 100644 --- a/src/gateway/server-methods/chat.ts +++ b/src/gateway/server-methods/chat.ts @@ -1,11 +1,11 @@ +import { CURRENT_SESSION_VERSION } from "@mariozechner/pi-coding-agent"; import { randomUUID } from "node:crypto"; import fs from "node:fs"; import path from "node:path"; - -import { CURRENT_SESSION_VERSION } from "@mariozechner/pi-coding-agent"; +import type { MsgContext } from "../../auto-reply/templating.js"; +import type { GatewayRequestContext, GatewayRequestHandlers } from "./types.js"; import { resolveSessionAgentId } from "../../agents/agent-scope.js"; import { resolveEffectiveMessagesConfig, resolveIdentityName } from "../../agents/identity.js"; -import { injectTimestamp, timestampOptsFromConfig } from "./agent-timestamp.js"; import { resolveThinkingDefault } from "../../agents/model-selection.js"; import { resolveAgentTimeoutMs } from "../../agents/timeout.js"; import { dispatchInboundMessage } from "../../auto-reply/dispatch.js"; @@ -14,7 +14,6 @@ import { extractShortModelName, type ResponsePrefixContext, } from "../../auto-reply/reply/response-prefix-template.js"; -import type { MsgContext } from "../../auto-reply/templating.js"; import { resolveSendPolicy } from "../../sessions/send-policy.js"; import { INTERNAL_MESSAGE_CHANNEL } from "../../utils/message-channel.js"; import { @@ -24,6 +23,7 @@ import { resolveChatRunExpiresAtMs, } from "../chat-abort.js"; import { type ChatImageContent, parseMessageWithAttachments } from "../chat-attachments.js"; +import { stripEnvelopeFromMessages } from "../chat-sanitize.js"; import { ErrorCodes, errorShape, @@ -40,9 +40,8 @@ import { readSessionMessages, resolveSessionModelRef, } from "../session-utils.js"; -import { stripEnvelopeFromMessages } from "../chat-sanitize.js"; import { formatForLog } from "../ws-log.js"; -import type { GatewayRequestContext, GatewayRequestHandlers } from "./types.js"; +import { injectTimestamp, timestampOptsFromConfig } from "./agent-timestamp.js"; type TranscriptAppendResult = { ok: boolean; diff --git a/src/gateway/server-methods/config.ts b/src/gateway/server-methods/config.ts index 8984a5ca7ae..0ac9bf9ee11 100644 --- a/src/gateway/server-methods/config.ts +++ b/src/gateway/server-methods/config.ts @@ -1,4 +1,6 @@ +import type { GatewayRequestHandlers, RespondFn } from "./types.js"; import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../../agents/agent-scope.js"; +import { listChannelPlugins } from "../../channels/plugins/index.js"; import { CONFIG_PATH, loadConfig, @@ -11,13 +13,12 @@ import { import { applyLegacyMigrations } from "../../config/legacy.js"; import { applyMergePatch } from "../../config/merge-patch.js"; import { buildConfigSchema } from "../../config/schema.js"; -import { scheduleGatewaySigusr1Restart } from "../../infra/restart.js"; import { formatDoctorNonInteractiveHint, type RestartSentinelPayload, writeRestartSentinel, } from "../../infra/restart-sentinel.js"; -import { listChannelPlugins } from "../../channels/plugins/index.js"; +import { scheduleGatewaySigusr1Restart } from "../../infra/restart.js"; import { loadOpenClawPlugins } from "../../plugins/loader.js"; import { ErrorCodes, @@ -29,7 +30,6 @@ import { validateConfigSchemaParams, validateConfigSetParams, } from "../protocol/index.js"; -import type { GatewayRequestHandlers, RespondFn } from "./types.js"; function resolveBaseHash(params: unknown): string | null { const raw = (params as { baseHash?: unknown })?.baseHash; diff --git a/src/gateway/server-methods/connect.ts b/src/gateway/server-methods/connect.ts index 309693782a3..bd7d70072e3 100644 --- a/src/gateway/server-methods/connect.ts +++ b/src/gateway/server-methods/connect.ts @@ -1,5 +1,5 @@ -import { ErrorCodes, errorShape } from "../protocol/index.js"; import type { GatewayRequestHandlers } from "./types.js"; +import { ErrorCodes, errorShape } from "../protocol/index.js"; export const connectHandlers: GatewayRequestHandlers = { connect: ({ respond }) => { diff --git a/src/gateway/server-methods/cron.ts b/src/gateway/server-methods/cron.ts index 68bbd228c2f..82591dd35a8 100644 --- a/src/gateway/server-methods/cron.ts +++ b/src/gateway/server-methods/cron.ts @@ -1,6 +1,7 @@ +import type { CronJobCreate, CronJobPatch } from "../../cron/types.js"; +import type { GatewayRequestHandlers } from "./types.js"; import { normalizeCronJobCreate, normalizeCronJobPatch } from "../../cron/normalize.js"; import { readCronRunLogEntries, resolveCronRunLogPath } from "../../cron/run-log.js"; -import type { CronJobCreate, CronJobPatch } from "../../cron/types.js"; import { ErrorCodes, errorShape, @@ -14,7 +15,6 @@ import { validateCronUpdateParams, validateWakeParams, } from "../protocol/index.js"; -import type { GatewayRequestHandlers } from "./types.js"; export const cronHandlers: GatewayRequestHandlers = { wake: ({ params, respond, context }) => { diff --git a/src/gateway/server-methods/devices.ts b/src/gateway/server-methods/devices.ts index ebf7d7f9474..b57cfd6d9f4 100644 --- a/src/gateway/server-methods/devices.ts +++ b/src/gateway/server-methods/devices.ts @@ -1,3 +1,4 @@ +import type { GatewayRequestHandlers } from "./types.js"; import { approveDevicePairing, listDevicePairing, @@ -17,7 +18,6 @@ import { validateDeviceTokenRevokeParams, validateDeviceTokenRotateParams, } from "../protocol/index.js"; -import type { GatewayRequestHandlers } from "./types.js"; function redactPairedDevice( device: { tokens?: Record } & Record, diff --git a/src/gateway/server-methods/exec-approval.test.ts b/src/gateway/server-methods/exec-approval.test.ts index 6a9fdb720ab..0a80b9e9d22 100644 --- a/src/gateway/server-methods/exec-approval.test.ts +++ b/src/gateway/server-methods/exec-approval.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from "vitest"; import { ExecApprovalManager } from "../exec-approval-manager.js"; -import { createExecApprovalHandlers } from "./exec-approval.js"; import { validateExecApprovalRequestParams } from "../protocol/index.js"; +import { createExecApprovalHandlers } from "./exec-approval.js"; const noop = () => {}; diff --git a/src/gateway/server-methods/exec-approval.ts b/src/gateway/server-methods/exec-approval.ts index 572afc58f9e..beb3f03725f 100644 --- a/src/gateway/server-methods/exec-approval.ts +++ b/src/gateway/server-methods/exec-approval.ts @@ -1,6 +1,7 @@ -import type { ExecApprovalDecision } from "../../infra/exec-approvals.js"; import type { ExecApprovalForwarder } from "../../infra/exec-approval-forwarder.js"; +import type { ExecApprovalDecision } from "../../infra/exec-approvals.js"; import type { ExecApprovalManager } from "../exec-approval-manager.js"; +import type { GatewayRequestHandlers } from "./types.js"; import { ErrorCodes, errorShape, @@ -8,7 +9,6 @@ import { validateExecApprovalRequestParams, validateExecApprovalResolveParams, } from "../protocol/index.js"; -import type { GatewayRequestHandlers } from "./types.js"; export function createExecApprovalHandlers( manager: ExecApprovalManager, diff --git a/src/gateway/server-methods/exec-approvals.ts b/src/gateway/server-methods/exec-approvals.ts index 7fdda355705..df015745993 100644 --- a/src/gateway/server-methods/exec-approvals.ts +++ b/src/gateway/server-methods/exec-approvals.ts @@ -1,3 +1,4 @@ +import type { GatewayRequestHandlers, RespondFn } from "./types.js"; import { ensureExecApprovals, normalizeExecApprovals, @@ -17,7 +18,6 @@ import { validateExecApprovalsSetParams, } from "../protocol/index.js"; import { respondUnavailableOnThrow, safeParseJson } from "./nodes.helpers.js"; -import type { GatewayRequestHandlers, RespondFn } from "./types.js"; function resolveBaseHash(params: unknown): string | null { const raw = (params as { baseHash?: unknown })?.baseHash; diff --git a/src/gateway/server-methods/health.ts b/src/gateway/server-methods/health.ts index d03a468eef1..b4e0ae8ae92 100644 --- a/src/gateway/server-methods/health.ts +++ b/src/gateway/server-methods/health.ts @@ -1,9 +1,9 @@ +import type { GatewayRequestHandlers } from "./types.js"; import { getStatusSummary } from "../../commands/status.js"; import { ErrorCodes, errorShape } from "../protocol/index.js"; import { HEALTH_REFRESH_INTERVAL_MS } from "../server-constants.js"; import { formatError } from "../server-utils.js"; import { formatForLog } from "../ws-log.js"; -import type { GatewayRequestHandlers } from "./types.js"; export const healthHandlers: GatewayRequestHandlers = { health: async ({ respond, context, params }) => { diff --git a/src/gateway/server-methods/logs.test.ts b/src/gateway/server-methods/logs.test.ts index 67d6f473da7..fd9a46f920b 100644 --- a/src/gateway/server-methods/logs.test.ts +++ b/src/gateway/server-methods/logs.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, describe, expect, it, vi } from "vitest"; - import { resetLogger, setLoggerOverride } from "../../logging.js"; import { logsHandlers } from "./logs.js"; diff --git a/src/gateway/server-methods/logs.ts b/src/gateway/server-methods/logs.ts index 97091386d60..e3c1af75f31 100644 --- a/src/gateway/server-methods/logs.ts +++ b/src/gateway/server-methods/logs.ts @@ -1,5 +1,6 @@ import fs from "node:fs/promises"; import path from "node:path"; +import type { GatewayRequestHandlers } from "./types.js"; import { getResolvedLoggerSettings } from "../../logging.js"; import { ErrorCodes, @@ -7,7 +8,6 @@ import { formatValidationErrors, validateLogsTailParams, } from "../protocol/index.js"; -import type { GatewayRequestHandlers } from "./types.js"; const DEFAULT_LIMIT = 500; const DEFAULT_MAX_BYTES = 250_000; diff --git a/src/gateway/server-methods/models.ts b/src/gateway/server-methods/models.ts index ec2f5a0aa54..68eca48a128 100644 --- a/src/gateway/server-methods/models.ts +++ b/src/gateway/server-methods/models.ts @@ -1,10 +1,10 @@ +import type { GatewayRequestHandlers } from "./types.js"; import { ErrorCodes, errorShape, formatValidationErrors, validateModelsListParams, } from "../protocol/index.js"; -import type { GatewayRequestHandlers } from "./types.js"; export const modelsHandlers: GatewayRequestHandlers = { "models.list": async ({ params, respond, context }) => { diff --git a/src/gateway/server-methods/nodes.helpers.ts b/src/gateway/server-methods/nodes.helpers.ts index 2c1ffae4efa..5f77112e14c 100644 --- a/src/gateway/server-methods/nodes.helpers.ts +++ b/src/gateway/server-methods/nodes.helpers.ts @@ -1,7 +1,7 @@ import type { ErrorObject } from "ajv"; +import type { RespondFn } from "./types.js"; import { ErrorCodes, errorShape, formatValidationErrors } from "../protocol/index.js"; import { formatForLog } from "../ws-log.js"; -import type { RespondFn } from "./types.js"; type ValidatorFn = ((value: unknown) => boolean) & { errors?: ErrorObject[] | null; diff --git a/src/gateway/server-methods/nodes.ts b/src/gateway/server-methods/nodes.ts index dd39784938a..b4ad29ba4cb 100644 --- a/src/gateway/server-methods/nodes.ts +++ b/src/gateway/server-methods/nodes.ts @@ -1,3 +1,6 @@ +import type { GatewayRequestHandlers } from "./types.js"; +import { loadConfig } from "../../config/config.js"; +import { listDevicePairing } from "../../infra/device-pairing.js"; import { approveNodePairing, listNodePairing, @@ -6,7 +9,7 @@ import { requestNodePairing, verifyNodeToken, } from "../../infra/node-pairing.js"; -import { listDevicePairing } from "../../infra/device-pairing.js"; +import { isNodeCommandAllowed, resolveNodeCommandAllowlist } from "../node-command-policy.js"; import { ErrorCodes, errorShape, @@ -28,9 +31,6 @@ import { safeParseJson, uniqueSortedStrings, } from "./nodes.helpers.js"; -import { loadConfig } from "../../config/config.js"; -import { isNodeCommandAllowed, resolveNodeCommandAllowlist } from "../node-command-policy.js"; -import type { GatewayRequestHandlers } from "./types.js"; function isNodeEntry(entry: { role?: string; roles?: string[] }) { if (entry.role === "node") { diff --git a/src/gateway/server-methods/send.test.ts b/src/gateway/server-methods/send.test.ts index 8c50da881ae..e581aed2c5e 100644 --- a/src/gateway/server-methods/send.test.ts +++ b/src/gateway/server-methods/send.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { GatewayRequestContext } from "./types.js"; import { sendHandlers } from "./send.js"; diff --git a/src/gateway/server-methods/send.ts b/src/gateway/server-methods/send.ts index 8981acc8cf5..246ee27e27a 100644 --- a/src/gateway/server-methods/send.ts +++ b/src/gateway/server-methods/send.ts @@ -1,14 +1,15 @@ +import type { GatewayRequestContext, GatewayRequestHandlers } from "./types.js"; +import { resolveSessionAgentId } from "../../agents/agent-scope.js"; import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js"; import { DEFAULT_CHAT_CHANNEL } from "../../channels/registry.js"; -import { loadConfig } from "../../config/config.js"; import { createOutboundSendDeps } from "../../cli/deps.js"; +import { loadConfig } from "../../config/config.js"; import { deliverOutboundPayloads } from "../../infra/outbound/deliver.js"; -import { normalizeReplyPayloadsForDelivery } from "../../infra/outbound/payloads.js"; import { ensureOutboundSessionEntry, resolveOutboundSessionRoute, } from "../../infra/outbound/outbound-session.js"; -import { resolveSessionAgentId } from "../../agents/agent-scope.js"; +import { normalizeReplyPayloadsForDelivery } from "../../infra/outbound/payloads.js"; import { resolveOutboundTarget } from "../../infra/outbound/targets.js"; import { normalizePollInput } from "../../polls.js"; import { @@ -19,7 +20,6 @@ import { validateSendParams, } from "../protocol/index.js"; import { formatForLog } from "../ws-log.js"; -import type { GatewayRequestContext, GatewayRequestHandlers } from "./types.js"; type InflightResult = { ok: boolean; diff --git a/src/gateway/server-methods/sessions.ts b/src/gateway/server-methods/sessions.ts index cb71accfb21..3fdb4ee75aa 100644 --- a/src/gateway/server-methods/sessions.ts +++ b/src/gateway/server-methods/sessions.ts @@ -1,6 +1,6 @@ import { randomUUID } from "node:crypto"; import fs from "node:fs"; - +import type { GatewayRequestHandlers } from "./types.js"; import { abortEmbeddedPiRun, waitForEmbeddedPiRunEnd } from "../../agents/pi-embedded.js"; import { stopSubagentsForRequester } from "../../auto-reply/reply/abort.js"; import { clearSessionQueues } from "../../auto-reply/reply/queue.js"; @@ -38,7 +38,6 @@ import { } from "../session-utils.js"; import { applySessionsPatchToStore } from "../sessions-patch.js"; import { resolveSessionKeyFromResolveParams } from "../sessions-resolve.js"; -import type { GatewayRequestHandlers } from "./types.js"; export const sessionsHandlers: GatewayRequestHandlers = { "sessions.list": ({ params, respond }) => { diff --git a/src/gateway/server-methods/skills.ts b/src/gateway/server-methods/skills.ts index d9ecb3a8c23..0bdda27f8fa 100644 --- a/src/gateway/server-methods/skills.ts +++ b/src/gateway/server-methods/skills.ts @@ -1,8 +1,9 @@ +import type { OpenClawConfig } from "../../config/config.js"; +import type { GatewayRequestHandlers } from "./types.js"; import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../../agents/agent-scope.js"; import { installSkill } from "../../agents/skills-install.js"; import { buildWorkspaceSkillStatus } from "../../agents/skills-status.js"; import { loadWorkspaceSkillEntries, type SkillEntry } from "../../agents/skills.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { loadConfig, writeConfigFile } from "../../config/config.js"; import { getRemoteSkillEligibility } from "../../infra/skills-remote.js"; import { @@ -14,7 +15,6 @@ import { validateSkillsStatusParams, validateSkillsUpdateParams, } from "../protocol/index.js"; -import type { GatewayRequestHandlers } from "./types.js"; function listWorkspaceDirs(cfg: OpenClawConfig): string[] { const dirs = new Set(); diff --git a/src/gateway/server-methods/system.ts b/src/gateway/server-methods/system.ts index b9c5e64ca03..fa440a29a7b 100644 --- a/src/gateway/server-methods/system.ts +++ b/src/gateway/server-methods/system.ts @@ -1,10 +1,10 @@ +import type { GatewayRequestHandlers } from "./types.js"; import { resolveMainSessionKeyFromConfig } from "../../config/sessions.js"; import { getLastHeartbeatEvent } from "../../infra/heartbeat-events.js"; import { setHeartbeatsEnabled } from "../../infra/heartbeat-runner.js"; import { enqueueSystemEvent, isSystemEventContextChanged } from "../../infra/system-events.js"; import { listSystemPresence, updateSystemPresence } from "../../infra/system-presence.js"; import { ErrorCodes, errorShape } from "../protocol/index.js"; -import type { GatewayRequestHandlers } from "./types.js"; export const systemHandlers: GatewayRequestHandlers = { "last-heartbeat": ({ respond }) => { diff --git a/src/gateway/server-methods/talk.ts b/src/gateway/server-methods/talk.ts index 491ed1401ba..78f354b9496 100644 --- a/src/gateway/server-methods/talk.ts +++ b/src/gateway/server-methods/talk.ts @@ -1,10 +1,10 @@ +import type { GatewayRequestHandlers } from "./types.js"; import { ErrorCodes, errorShape, formatValidationErrors, validateTalkModeParams, } from "../protocol/index.js"; -import type { GatewayRequestHandlers } from "./types.js"; export const talkHandlers: GatewayRequestHandlers = { "talk.mode": ({ params, respond, context, client, isWebchatConnect }) => { diff --git a/src/gateway/server-methods/tts.ts b/src/gateway/server-methods/tts.ts index 5e4e8254eba..4535149bb5f 100644 --- a/src/gateway/server-methods/tts.ts +++ b/src/gateway/server-methods/tts.ts @@ -1,3 +1,4 @@ +import type { GatewayRequestHandlers } from "./types.js"; import { loadConfig } from "../../config/config.js"; import { OPENAI_TTS_MODELS, @@ -16,7 +17,6 @@ import { } from "../../tts/tts.js"; import { ErrorCodes, errorShape } from "../protocol/index.js"; import { formatForLog } from "../ws-log.js"; -import type { GatewayRequestHandlers } from "./types.js"; export const ttsHandlers: GatewayRequestHandlers = { "tts.status": async ({ respond }) => { diff --git a/src/gateway/server-methods/types.ts b/src/gateway/server-methods/types.ts index c23459a2d57..e6b944f75a6 100644 --- a/src/gateway/server-methods/types.ts +++ b/src/gateway/server-methods/types.ts @@ -2,13 +2,13 @@ import type { ModelCatalogEntry } from "../../agents/model-catalog.js"; import type { createDefaultDeps } from "../../cli/deps.js"; import type { HealthSummary } from "../../commands/health.js"; import type { CronService } from "../../cron/service.js"; +import type { createSubsystemLogger } from "../../logging/subsystem.js"; import type { WizardSession } from "../../wizard/session.js"; import type { ChatAbortControllerEntry } from "../chat-abort.js"; import type { NodeRegistry } from "../node-registry.js"; import type { ConnectParams, ErrorShape, RequestFrame } from "../protocol/index.js"; import type { ChannelRuntimeSnapshot } from "../server-channels.js"; import type { DedupeEntry } from "../server-shared.js"; -import type { createSubsystemLogger } from "../../logging/subsystem.js"; type SubsystemLogger = ReturnType; diff --git a/src/gateway/server-methods/update.ts b/src/gateway/server-methods/update.ts index 672f54a5f73..5f7bdcee3ef 100644 --- a/src/gateway/server-methods/update.ts +++ b/src/gateway/server-methods/update.ts @@ -1,10 +1,11 @@ +import type { GatewayRequestHandlers } from "./types.js"; import { resolveOpenClawPackageRoot } from "../../infra/openclaw-root.js"; -import { scheduleGatewaySigusr1Restart } from "../../infra/restart.js"; import { formatDoctorNonInteractiveHint, type RestartSentinelPayload, writeRestartSentinel, } from "../../infra/restart-sentinel.js"; +import { scheduleGatewaySigusr1Restart } from "../../infra/restart.js"; import { runGatewayUpdate } from "../../infra/update-runner.js"; import { ErrorCodes, @@ -12,7 +13,6 @@ import { formatValidationErrors, validateUpdateRunParams, } from "../protocol/index.js"; -import type { GatewayRequestHandlers } from "./types.js"; export const updateHandlers: GatewayRequestHandlers = { "update.run": async ({ params, respond }) => { diff --git a/src/gateway/server-methods/usage.ts b/src/gateway/server-methods/usage.ts index 1774e9d8fcd..550217a5db8 100644 --- a/src/gateway/server-methods/usage.ts +++ b/src/gateway/server-methods/usage.ts @@ -1,8 +1,8 @@ -import { loadConfig } from "../../config/config.js"; import type { CostUsageSummary } from "../../infra/session-cost-usage.js"; -import { loadCostUsageSummary } from "../../infra/session-cost-usage.js"; -import { loadProviderUsageSummary } from "../../infra/provider-usage.js"; import type { GatewayRequestHandlers } from "./types.js"; +import { loadConfig } from "../../config/config.js"; +import { loadProviderUsageSummary } from "../../infra/provider-usage.js"; +import { loadCostUsageSummary } from "../../infra/session-cost-usage.js"; const COST_USAGE_CACHE_TTL_MS = 30_000; diff --git a/src/gateway/server-methods/voicewake.ts b/src/gateway/server-methods/voicewake.ts index 3f43488aa98..aa1355dc7f8 100644 --- a/src/gateway/server-methods/voicewake.ts +++ b/src/gateway/server-methods/voicewake.ts @@ -1,8 +1,8 @@ +import type { GatewayRequestHandlers } from "./types.js"; import { loadVoiceWakeConfig, setVoiceWakeTriggers } from "../../infra/voicewake.js"; import { ErrorCodes, errorShape } from "../protocol/index.js"; import { normalizeVoiceWakeTriggers } from "../server-utils.js"; import { formatForLog } from "../ws-log.js"; -import type { GatewayRequestHandlers } from "./types.js"; export const voicewakeHandlers: GatewayRequestHandlers = { "voicewake.get": async ({ respond }) => { diff --git a/src/gateway/server-methods/web.ts b/src/gateway/server-methods/web.ts index e55f5f2fb54..18cf2e2fd04 100644 --- a/src/gateway/server-methods/web.ts +++ b/src/gateway/server-methods/web.ts @@ -1,3 +1,4 @@ +import type { GatewayRequestHandlers } from "./types.js"; import { listChannelPlugins } from "../../channels/plugins/index.js"; import { ErrorCodes, @@ -7,7 +8,6 @@ import { validateWebLoginWaitParams, } from "../protocol/index.js"; import { formatForLog } from "../ws-log.js"; -import type { GatewayRequestHandlers } from "./types.js"; const WEB_LOGIN_METHODS = new Set(["web.login.start", "web.login.wait"]); diff --git a/src/gateway/server-methods/wizard.ts b/src/gateway/server-methods/wizard.ts index e3a3fca26e1..8585a066cb5 100644 --- a/src/gateway/server-methods/wizard.ts +++ b/src/gateway/server-methods/wizard.ts @@ -1,4 +1,5 @@ import { randomUUID } from "node:crypto"; +import type { GatewayRequestHandlers } from "./types.js"; import { defaultRuntime } from "../../runtime.js"; import { WizardSession } from "../../wizard/session.js"; import { @@ -11,7 +12,6 @@ import { validateWizardStatusParams, } from "../protocol/index.js"; import { formatForLog } from "../ws-log.js"; -import type { GatewayRequestHandlers } from "./types.js"; export const wizardHandlers: GatewayRequestHandlers = { "wizard.start": async ({ params, respond, context }) => { diff --git a/src/gateway/server-node-events.test.ts b/src/gateway/server-node-events.test.ts index 25372dabbb9..f21bb2fe2f5 100644 --- a/src/gateway/server-node-events.test.ts +++ b/src/gateway/server-node-events.test.ts @@ -7,12 +7,12 @@ vi.mock("../infra/heartbeat-wake.js", () => ({ requestHeartbeatNow: vi.fn(), })); -import { enqueueSystemEvent } from "../infra/system-events.js"; -import { requestHeartbeatNow } from "../infra/heartbeat-wake.js"; -import { handleNodeEvent } from "./server-node-events.js"; -import type { NodeEventContext } from "./server-node-events-types.js"; -import type { HealthSummary } from "../commands/health.js"; import type { CliDeps } from "../cli/deps.js"; +import type { HealthSummary } from "../commands/health.js"; +import type { NodeEventContext } from "./server-node-events-types.js"; +import { requestHeartbeatNow } from "../infra/heartbeat-wake.js"; +import { enqueueSystemEvent } from "../infra/system-events.js"; +import { handleNodeEvent } from "./server-node-events.js"; const enqueueSystemEventMock = vi.mocked(enqueueSystemEvent); const requestHeartbeatNowMock = vi.mocked(requestHeartbeatNow); diff --git a/src/gateway/server-node-events.ts b/src/gateway/server-node-events.ts index 2913f263b60..10933485bbd 100644 --- a/src/gateway/server-node-events.ts +++ b/src/gateway/server-node-events.ts @@ -1,4 +1,5 @@ import { randomUUID } from "node:crypto"; +import type { NodeEvent, NodeEventContext } from "./server-node-events-types.js"; import { normalizeChannelId } from "../channels/plugins/index.js"; import { agentCommand } from "../commands/agent.js"; import { loadConfig } from "../config/config.js"; @@ -7,7 +8,6 @@ import { requestHeartbeatNow } from "../infra/heartbeat-wake.js"; import { enqueueSystemEvent } from "../infra/system-events.js"; import { normalizeMainKey } from "../routing/session-key.js"; import { defaultRuntime } from "../runtime.js"; -import type { NodeEvent, NodeEventContext } from "./server-node-events-types.js"; import { loadSessionEntry } from "./session-utils.js"; import { formatForLog } from "./ws-log.js"; diff --git a/src/gateway/server-plugins.ts b/src/gateway/server-plugins.ts index e879310c304..39d1d4773e2 100644 --- a/src/gateway/server-plugins.ts +++ b/src/gateway/server-plugins.ts @@ -1,6 +1,6 @@ import type { loadConfig } from "../config/config.js"; -import { loadOpenClawPlugins } from "../plugins/loader.js"; import type { GatewayRequestHandler } from "./server-methods/types.js"; +import { loadOpenClawPlugins } from "../plugins/loader.js"; export function loadGatewayPlugins(params: { cfg: ReturnType; diff --git a/src/gateway/server-reload-handlers.ts b/src/gateway/server-reload-handlers.ts index 4d114926994..393a38cf778 100644 --- a/src/gateway/server-reload-handlers.ts +++ b/src/gateway/server-reload-handlers.ts @@ -1,17 +1,17 @@ import type { CliDeps } from "../cli/deps.js"; import type { loadConfig } from "../config/config.js"; -import { startGmailWatcher, stopGmailWatcher } from "../hooks/gmail-watcher.js"; import type { HeartbeatRunner } from "../infra/heartbeat-runner.js"; +import type { ChannelKind, GatewayReloadPlan } from "./config-reload.js"; +import { resolveAgentMaxConcurrent, resolveSubagentMaxConcurrent } from "../config/agent-limits.js"; +import { startGmailWatcher, stopGmailWatcher } from "../hooks/gmail-watcher.js"; +import { isTruthyEnvValue } from "../infra/env.js"; import { resetDirectoryCache } from "../infra/outbound/target-resolver.js"; import { authorizeGatewaySigusr1Restart, setGatewaySigusr1RestartPolicy, } from "../infra/restart.js"; import { setCommandLaneConcurrency } from "../process/command-queue.js"; -import { resolveAgentMaxConcurrent, resolveSubagentMaxConcurrent } from "../config/agent-limits.js"; import { CommandLane } from "../process/lanes.js"; -import { isTruthyEnvValue } from "../infra/env.js"; -import type { ChannelKind, GatewayReloadPlan } from "./config-reload.js"; import { resolveHooksConfig } from "./hooks.js"; import { startBrowserControlServerIfEnabled } from "./server-browser.js"; import { buildGatewayCronService, type GatewayCronState } from "./server-cron.js"; diff --git a/src/gateway/server-restart-sentinel.ts b/src/gateway/server-restart-sentinel.ts index 969e0c577df..2600a0b6380 100644 --- a/src/gateway/server-restart-sentinel.ts +++ b/src/gateway/server-restart-sentinel.ts @@ -1,6 +1,6 @@ +import type { CliDeps } from "../cli/deps.js"; import { resolveAnnounceTargetFromKey } from "../agents/tools/sessions-send-helpers.js"; import { normalizeChannelId } from "../channels/plugins/index.js"; -import type { CliDeps } from "../cli/deps.js"; import { agentCommand } from "../commands/agent.js"; import { resolveMainSessionKeyFromConfig } from "../config/sessions.js"; import { resolveOutboundTarget } from "../infra/outbound/targets.js"; diff --git a/src/gateway/server-runtime-state.ts b/src/gateway/server-runtime-state.ts index 24dd043f5b3..5e5d2d78c52 100644 --- a/src/gateway/server-runtime-state.ts +++ b/src/gateway/server-runtime-state.ts @@ -1,25 +1,25 @@ import type { Server as HttpServer } from "node:http"; import { WebSocketServer } from "ws"; -import { CANVAS_HOST_PATH } from "../canvas-host/a2ui.js"; -import { type CanvasHostHandler, createCanvasHostHandler } from "../canvas-host/server.js"; import type { CliDeps } from "../cli/deps.js"; import type { createSubsystemLogger } from "../logging/subsystem.js"; +import type { PluginRegistry } from "../plugins/registry.js"; import type { RuntimeEnv } from "../runtime.js"; import type { ResolvedGatewayAuth } from "./auth.js"; import type { ChatAbortControllerEntry } from "./chat-abort.js"; import type { HooksConfigResolved } from "./hooks.js"; -import { createGatewayHooksRequestHandler } from "./server/hooks.js"; -import { listenGatewayHttpServer } from "./server/http-listen.js"; -import { resolveGatewayListenHosts } from "./net.js"; -import { createGatewayPluginRequestHandler } from "./server/plugins-http.js"; +import type { DedupeEntry } from "./server-shared.js"; +import type { GatewayTlsRuntime } from "./server/tls.js"; import type { GatewayWsClient } from "./server/ws-types.js"; +import { CANVAS_HOST_PATH } from "../canvas-host/a2ui.js"; +import { type CanvasHostHandler, createCanvasHostHandler } from "../canvas-host/server.js"; +import { resolveGatewayListenHosts } from "./net.js"; import { createGatewayBroadcaster } from "./server-broadcast.js"; import { type ChatRunEntry, createChatRunState } from "./server-chat.js"; import { MAX_PAYLOAD_BYTES } from "./server-constants.js"; import { attachGatewayUpgradeHandler, createGatewayHttpServer } from "./server-http.js"; -import type { DedupeEntry } from "./server-shared.js"; -import type { PluginRegistry } from "../plugins/registry.js"; -import type { GatewayTlsRuntime } from "./server/tls.js"; +import { createGatewayHooksRequestHandler } from "./server/hooks.js"; +import { listenGatewayHttpServer } from "./server/http-listen.js"; +import { createGatewayPluginRequestHandler } from "./server/plugins-http.js"; export async function createGatewayRuntimeState(params: { cfg: import("../config/config.js").OpenClawConfig; diff --git a/src/gateway/server-startup-log.ts b/src/gateway/server-startup-log.ts index cf6d2575c7c..a62adaf882b 100644 --- a/src/gateway/server-startup-log.ts +++ b/src/gateway/server-startup-log.ts @@ -1,7 +1,7 @@ import chalk from "chalk"; +import type { loadConfig } from "../config/config.js"; import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js"; import { resolveConfiguredModelRef } from "../agents/model-selection.js"; -import type { loadConfig } from "../config/config.js"; import { getResolvedLoggerSettings } from "../logging.js"; export function logGatewayStartup(params: { diff --git a/src/gateway/server-startup.ts b/src/gateway/server-startup.ts index 8cd30e338c5..1971ef8a2d3 100644 --- a/src/gateway/server-startup.ts +++ b/src/gateway/server-startup.ts @@ -1,3 +1,6 @@ +import type { CliDeps } from "../cli/deps.js"; +import type { loadConfig } from "../config/config.js"; +import type { loadOpenClawPlugins } from "../plugins/loader.js"; import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js"; import { loadModelCatalog } from "../agents/model-catalog.js"; import { @@ -5,9 +8,6 @@ import { resolveConfiguredModelRef, resolveHooksGmailModel, } from "../agents/model-selection.js"; -import type { CliDeps } from "../cli/deps.js"; -import type { loadConfig } from "../config/config.js"; -import { isTruthyEnvValue } from "../infra/env.js"; import { startGmailWatcher } from "../hooks/gmail-watcher.js"; import { clearInternalHooks, @@ -15,7 +15,7 @@ import { triggerInternalHook, } from "../hooks/internal-hooks.js"; import { loadInternalHooks } from "../hooks/loader.js"; -import type { loadOpenClawPlugins } from "../plugins/loader.js"; +import { isTruthyEnvValue } from "../infra/env.js"; import { type PluginServicesHandle, startPluginServices } from "../plugins/services.js"; import { startBrowserControlServerIfEnabled } from "./server-browser.js"; import { diff --git a/src/gateway/server-ws-runtime.ts b/src/gateway/server-ws-runtime.ts index 6f12748e725..563caf89f4c 100644 --- a/src/gateway/server-ws-runtime.ts +++ b/src/gateway/server-ws-runtime.ts @@ -1,9 +1,9 @@ import type { WebSocketServer } from "ws"; import type { createSubsystemLogger } from "../logging/subsystem.js"; import type { ResolvedGatewayAuth } from "./auth.js"; -import { attachGatewayWsConnectionHandler } from "./server/ws-connection.js"; -import type { GatewayWsClient } from "./server/ws-types.js"; import type { GatewayRequestContext, GatewayRequestHandlers } from "./server-methods/types.js"; +import type { GatewayWsClient } from "./server/ws-types.js"; +import { attachGatewayWsConnectionHandler } from "./server/ws-connection.js"; export function attachGatewayWsHandlers(params: { wss: WebSocketServer; diff --git a/src/gateway/server.agent.gateway-server-agent-b.e2e.test.ts b/src/gateway/server.agent.gateway-server-agent-b.e2e.test.ts index 9e6511ef858..ceb01d498e4 100644 --- a/src/gateway/server.agent.gateway-server-agent-b.e2e.test.ts +++ b/src/gateway/server.agent.gateway-server-agent-b.e2e.test.ts @@ -4,11 +4,11 @@ import path from "node:path"; import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; import { WebSocket } from "ws"; import type { ChannelPlugin } from "../channels/plugins/types.js"; -import { emitAgentEvent, registerAgentRunContext } from "../infra/agent-events.js"; import type { PluginRegistry } from "../plugins/registry.js"; +import { whatsappPlugin } from "../../extensions/whatsapp/src/channel.js"; +import { emitAgentEvent, registerAgentRunContext } from "../infra/agent-events.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; -import { whatsappPlugin } from "../../extensions/whatsapp/src/channel.js"; import { agentCommand, connectOk, diff --git a/src/gateway/server.auth.e2e.test.ts b/src/gateway/server.auth.e2e.test.ts index 5adcf3ec8d0..cc8533f43fa 100644 --- a/src/gateway/server.auth.e2e.test.ts +++ b/src/gateway/server.auth.e2e.test.ts @@ -1,8 +1,9 @@ import { afterAll, beforeAll, describe, expect, test, vi } from "vitest"; import { WebSocket } from "ws"; +import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; +import { buildDeviceAuthPayload } from "./device-auth.js"; import { PROTOCOL_VERSION } from "./protocol/index.js"; import { getHandshakeTimeoutMs } from "./server-constants.js"; -import { buildDeviceAuthPayload } from "./device-auth.js"; import { connectReq, getFreePort, @@ -12,7 +13,6 @@ import { startServerWithClient, testState, } from "./test-helpers.js"; -import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; installGatewayTestHooks({ scope: "suite" }); diff --git a/src/gateway/server.chat.gateway-server-chat-b.e2e.test.ts b/src/gateway/server.chat.gateway-server-chat-b.e2e.test.ts index dd6c39bcf8b..6caefbe0011 100644 --- a/src/gateway/server.chat.gateway-server-chat-b.e2e.test.ts +++ b/src/gateway/server.chat.gateway-server-chat-b.e2e.test.ts @@ -3,6 +3,7 @@ import os from "node:os"; import path from "node:path"; import { describe, expect, test, vi } from "vitest"; import { emitAgentEvent } from "../infra/agent-events.js"; +import { __setMaxChatHistoryMessagesBytesForTest } from "./server-constants.js"; import { connectOk, getReplyFromConfig, @@ -14,7 +15,6 @@ import { testState, writeSessionStore, } from "./test-helpers.js"; -import { __setMaxChatHistoryMessagesBytesForTest } from "./server-constants.js"; installGatewayTestHooks({ scope: "suite" }); async function waitFor(condition: () => boolean, timeoutMs = 1500) { const deadline = Date.now() + timeoutMs; diff --git a/src/gateway/server.chat.gateway-server-chat.e2e.test.ts b/src/gateway/server.chat.gateway-server-chat.e2e.test.ts index c3e77a73231..59c0bec18b0 100644 --- a/src/gateway/server.chat.gateway-server-chat.e2e.test.ts +++ b/src/gateway/server.chat.gateway-server-chat.e2e.test.ts @@ -3,8 +3,8 @@ import os from "node:os"; import path from "node:path"; import { afterAll, beforeAll, describe, expect, test, vi } from "vitest"; import { WebSocket } from "ws"; -import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; import { emitAgentEvent, registerAgentRunContext } from "../infra/agent-events.js"; +import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; import { connectOk, getReplyFromConfig, diff --git a/src/gateway/server.config-apply.e2e.test.ts b/src/gateway/server.config-apply.e2e.test.ts index 4505ef7fbd1..2172555fbd9 100644 --- a/src/gateway/server.config-apply.e2e.test.ts +++ b/src/gateway/server.config-apply.e2e.test.ts @@ -3,7 +3,6 @@ import os from "node:os"; import path from "node:path"; import { afterAll, beforeAll, describe, expect, it } from "vitest"; import { WebSocket } from "ws"; - import { connectOk, getFreePort, diff --git a/src/gateway/server.config-patch.e2e.test.ts b/src/gateway/server.config-patch.e2e.test.ts index 982a28f29f5..0ce19ebe386 100644 --- a/src/gateway/server.config-patch.e2e.test.ts +++ b/src/gateway/server.config-patch.e2e.test.ts @@ -2,9 +2,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { afterAll, beforeAll, describe, expect, it } from "vitest"; - import { resolveConfigSnapshotHash } from "../config/config.js"; - import { connectOk, installGatewayTestHooks, diff --git a/src/gateway/server.health.e2e.test.ts b/src/gateway/server.health.e2e.test.ts index 2faf7bb3f28..797e3b646c5 100644 --- a/src/gateway/server.health.e2e.test.ts +++ b/src/gateway/server.health.e2e.test.ts @@ -11,6 +11,7 @@ import { } from "../infra/device-identity.js"; import { emitHeartbeatEvent } from "../infra/heartbeat-events.js"; import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; +import { buildDeviceAuthPayload } from "./device-auth.js"; import { connectOk, getFreePort, @@ -19,7 +20,6 @@ import { startGatewayServer, startServerWithClient, } from "./test-helpers.js"; -import { buildDeviceAuthPayload } from "./device-auth.js"; installGatewayTestHooks({ scope: "suite" }); diff --git a/src/gateway/server.impl.ts b/src/gateway/server.impl.ts index da190eb655a..9e5142f1351 100644 --- a/src/gateway/server.impl.ts +++ b/src/gateway/server.impl.ts @@ -1,10 +1,13 @@ -import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; -import { initSubagentRegistry } from "../agents/subagent-registry.js"; -import { registerSkillsChangeListener } from "../agents/skills/refresh.js"; import type { CanvasHostServer } from "../canvas-host/server.js"; +import type { PluginServicesHandle } from "../plugins/services.js"; +import type { RuntimeEnv } from "../runtime.js"; +import type { startBrowserControlServerIfEnabled } from "./server-browser.js"; +import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; +import { registerSkillsChangeListener } from "../agents/skills/refresh.js"; +import { initSubagentRegistry } from "../agents/subagent-registry.js"; import { type ChannelId, listChannelPlugins } from "../channels/plugins/index.js"; -import { createDefaultDeps } from "../cli/deps.js"; import { formatCliCommand } from "../cli/command-format.js"; +import { createDefaultDeps } from "../cli/deps.js"; import { CONFIG_PATH, isNixMode, @@ -13,27 +16,52 @@ import { readConfigFileSnapshot, writeConfigFile, } from "../config/config.js"; -import { isDiagnosticsEnabled } from "../infra/diagnostic-events.js"; -import { logAcceptedEnvOption } from "../infra/env.js"; import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js"; import { clearAgentRunContext, onAgentEvent } from "../infra/agent-events.js"; +import { isDiagnosticsEnabled } from "../infra/diagnostic-events.js"; +import { logAcceptedEnvOption } from "../infra/env.js"; +import { createExecApprovalForwarder } from "../infra/exec-approval-forwarder.js"; import { onHeartbeatEvent } from "../infra/heartbeat-events.js"; import { startHeartbeatRunner } from "../infra/heartbeat-runner.js"; import { getMachineDisplayName } from "../infra/machine-name.js"; import { ensureOpenClawCliOnPath } from "../infra/path-env.js"; +import { setGatewaySigusr1RestartPolicy } from "../infra/restart.js"; import { primeRemoteSkillsCache, refreshRemoteBinsForConnectedNodes, setSkillsRemoteRegistry, } from "../infra/skills-remote.js"; import { scheduleGatewayUpdateCheck } from "../infra/update-startup.js"; -import { setGatewaySigusr1RestartPolicy } from "../infra/restart.js"; import { startDiagnosticHeartbeat, stopDiagnosticHeartbeat } from "../logging/diagnostic.js"; import { createSubsystemLogger, runtimeForLogger } from "../logging/subsystem.js"; -import type { PluginServicesHandle } from "../plugins/services.js"; -import type { RuntimeEnv } from "../runtime.js"; import { runOnboardingWizard } from "../wizard/onboarding.js"; import { startGatewayConfigReloader } from "./config-reload.js"; +import { ExecApprovalManager } from "./exec-approval-manager.js"; +import { NodeRegistry } from "./node-registry.js"; +import { createChannelManager } from "./server-channels.js"; +import { createAgentEventHandler } from "./server-chat.js"; +import { createGatewayCloseHandler } from "./server-close.js"; +import { buildGatewayCronService } from "./server-cron.js"; +import { startGatewayDiscovery } from "./server-discovery-runtime.js"; +import { applyGatewayLaneConcurrency } from "./server-lanes.js"; +import { startGatewayMaintenanceTimers } from "./server-maintenance.js"; +import { GATEWAY_EVENTS, listGatewayMethods } from "./server-methods-list.js"; +import { coreGatewayHandlers } from "./server-methods.js"; +import { createExecApprovalHandlers } from "./server-methods/exec-approval.js"; +import { safeParseJson } from "./server-methods/nodes.helpers.js"; +import { hasConnectedMobileNode } from "./server-mobile-nodes.js"; +import { loadGatewayModelCatalog } from "./server-model-catalog.js"; +import { createNodeSubscriptionManager } from "./server-node-subscriptions.js"; +import { loadGatewayPlugins } from "./server-plugins.js"; +import { createGatewayReloadHandlers } from "./server-reload-handlers.js"; +import { resolveGatewayRuntimeConfig } from "./server-runtime-config.js"; +import { createGatewayRuntimeState } from "./server-runtime-state.js"; +import { resolveSessionKeyForRun } from "./server-session-key.js"; +import { logGatewayStartup } from "./server-startup-log.js"; +import { startGatewaySidecars } from "./server-startup.js"; +import { startGatewayTailscaleExposure } from "./server-tailscale.js"; +import { createWizardSessionTracker } from "./server-wizard-sessions.js"; +import { attachGatewayWsHandlers } from "./server-ws-runtime.js"; import { getHealthCache, getHealthVersion, @@ -41,35 +69,7 @@ import { incrementPresenceVersion, refreshGatewayHealthSnapshot, } from "./server/health-state.js"; -import { startGatewayDiscovery } from "./server-discovery-runtime.js"; -import { ExecApprovalManager } from "./exec-approval-manager.js"; -import { createExecApprovalHandlers } from "./server-methods/exec-approval.js"; -import { createExecApprovalForwarder } from "../infra/exec-approval-forwarder.js"; -import type { startBrowserControlServerIfEnabled } from "./server-browser.js"; -import { createChannelManager } from "./server-channels.js"; -import { createAgentEventHandler } from "./server-chat.js"; -import { createGatewayCloseHandler } from "./server-close.js"; -import { buildGatewayCronService } from "./server-cron.js"; -import { applyGatewayLaneConcurrency } from "./server-lanes.js"; -import { startGatewayMaintenanceTimers } from "./server-maintenance.js"; -import { coreGatewayHandlers } from "./server-methods.js"; -import { GATEWAY_EVENTS, listGatewayMethods } from "./server-methods-list.js"; -import { loadGatewayModelCatalog } from "./server-model-catalog.js"; -import { NodeRegistry } from "./node-registry.js"; -import { createNodeSubscriptionManager } from "./server-node-subscriptions.js"; -import { safeParseJson } from "./server-methods/nodes.helpers.js"; -import { loadGatewayPlugins } from "./server-plugins.js"; -import { createGatewayReloadHandlers } from "./server-reload-handlers.js"; -import { resolveGatewayRuntimeConfig } from "./server-runtime-config.js"; -import { createGatewayRuntimeState } from "./server-runtime-state.js"; -import { hasConnectedMobileNode } from "./server-mobile-nodes.js"; -import { resolveSessionKeyForRun } from "./server-session-key.js"; -import { startGatewaySidecars } from "./server-startup.js"; -import { logGatewayStartup } from "./server-startup-log.js"; -import { startGatewayTailscaleExposure } from "./server-tailscale.js"; import { loadGatewayTlsRuntime } from "./server/tls.js"; -import { createWizardSessionTracker } from "./server-wizard-sessions.js"; -import { attachGatewayWsHandlers } from "./server-ws-runtime.js"; export { __resetModelCatalogCacheForTest } from "./server-model-catalog.js"; diff --git a/src/gateway/server.ios-client-id.e2e.test.ts b/src/gateway/server.ios-client-id.e2e.test.ts index 3c00d23fb1e..f612bdcf09a 100644 --- a/src/gateway/server.ios-client-id.e2e.test.ts +++ b/src/gateway/server.ios-client-id.e2e.test.ts @@ -1,6 +1,5 @@ import { afterAll, beforeAll, test } from "vitest"; import WebSocket from "ws"; - import { PROTOCOL_VERSION } from "./protocol/index.js"; import { getFreePort, onceMessage, startGatewayServer } from "./test-helpers.server.js"; diff --git a/src/gateway/server.models-voicewake-misc.e2e.test.ts b/src/gateway/server.models-voicewake-misc.e2e.test.ts index 828067da435..27ae4237a5d 100644 --- a/src/gateway/server.models-voicewake-misc.e2e.test.ts +++ b/src/gateway/server.models-voicewake-misc.e2e.test.ts @@ -4,12 +4,11 @@ import os from "node:os"; import path from "node:path"; import { afterAll, beforeAll, describe, expect, test } from "vitest"; import { WebSocket } from "ws"; - -import { getChannelPlugin } from "../channels/plugins/index.js"; import type { ChannelOutboundAdapter } from "../channels/plugins/types.js"; +import type { PluginRegistry } from "../plugins/registry.js"; +import { getChannelPlugin } from "../channels/plugins/index.js"; import { resolveCanvasHostUrl } from "../infra/canvas-host-url.js"; import { GatewayLockError } from "../infra/gateway-lock.js"; -import type { PluginRegistry } from "../plugins/registry.js"; import { getActivePluginRegistry, setActivePluginRegistry } from "../plugins/runtime.js"; import { createOutboundTestPlugin } from "../test-utils/channel-plugins.js"; import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; diff --git a/src/gateway/server.nodes.late-invoke.test.ts b/src/gateway/server.nodes.late-invoke.test.ts index 52f73e898e0..36a7972e38b 100644 --- a/src/gateway/server.nodes.late-invoke.test.ts +++ b/src/gateway/server.nodes.late-invoke.test.ts @@ -1,8 +1,7 @@ import { afterAll, beforeAll, describe, expect, test, vi } from "vitest"; import { WebSocket } from "ws"; - -import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; import { loadOrCreateDeviceIdentity } from "../infra/device-identity.js"; +import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; vi.mock("../infra/update-runner.js", () => ({ runGatewayUpdate: vi.fn(async () => ({ diff --git a/src/gateway/server.roles-allowlist-update.e2e.test.ts b/src/gateway/server.roles-allowlist-update.e2e.test.ts index 0fe6daec4e2..406ba342c24 100644 --- a/src/gateway/server.roles-allowlist-update.e2e.test.ts +++ b/src/gateway/server.roles-allowlist-update.e2e.test.ts @@ -3,7 +3,6 @@ import os from "node:os"; import path from "node:path"; import { afterAll, beforeAll, describe, expect, test, vi } from "vitest"; import { WebSocket } from "ws"; - import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; import { GatewayClient } from "./client.js"; diff --git a/src/gateway/server.sessions.gateway-server-sessions-a.e2e.test.ts b/src/gateway/server.sessions.gateway-server-sessions-a.e2e.test.ts index c21472f3455..90cd4dcc517 100644 --- a/src/gateway/server.sessions.gateway-server-sessions-a.e2e.test.ts +++ b/src/gateway/server.sessions.gateway-server-sessions-a.e2e.test.ts @@ -3,6 +3,7 @@ import os from "node:os"; import path from "node:path"; import { afterAll, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; import { WebSocket } from "ws"; +import { DEFAULT_PROVIDER } from "../agents/defaults.js"; import { connectOk, embeddedRunMock, @@ -14,7 +15,6 @@ import { testState, writeSessionStore, } from "./test-helpers.js"; -import { DEFAULT_PROVIDER } from "../agents/defaults.js"; const sessionCleanupMocks = vi.hoisted(() => ({ clearSessionQueues: vi.fn(() => ({ followupCleared: 0, laneCleared: 0, keys: [] })), diff --git a/src/gateway/server/health-state.ts b/src/gateway/server/health-state.ts index 6eee1ecd8c8..8bc481dfc8c 100644 --- a/src/gateway/server/health-state.ts +++ b/src/gateway/server/health-state.ts @@ -1,10 +1,10 @@ +import type { Snapshot } from "../protocol/index.js"; import { resolveDefaultAgentId } from "../../agents/agent-scope.js"; import { getHealthSnapshot, type HealthSummary } from "../../commands/health.js"; import { CONFIG_PATH, STATE_DIR, loadConfig } from "../../config/config.js"; import { resolveMainSessionKey } from "../../config/sessions.js"; -import { normalizeMainKey } from "../../routing/session-key.js"; import { listSystemPresence } from "../../infra/system-presence.js"; -import type { Snapshot } from "../protocol/index.js"; +import { normalizeMainKey } from "../../routing/session-key.js"; let presenceVersion = 1; let healthVersion = 1; diff --git a/src/gateway/server/hooks.ts b/src/gateway/server/hooks.ts index 18d46368f35..8b4c107b5d5 100644 --- a/src/gateway/server/hooks.ts +++ b/src/gateway/server/hooks.ts @@ -1,14 +1,13 @@ import { randomUUID } from "node:crypto"; - import type { CliDeps } from "../../cli/deps.js"; +import type { CronJob } from "../../cron/types.js"; +import type { createSubsystemLogger } from "../../logging/subsystem.js"; +import type { HookMessageChannel, HooksConfigResolved } from "../hooks.js"; import { loadConfig } from "../../config/config.js"; import { resolveMainSessionKeyFromConfig } from "../../config/sessions.js"; import { runCronIsolatedAgentTurn } from "../../cron/isolated-agent.js"; -import type { CronJob } from "../../cron/types.js"; import { requestHeartbeatNow } from "../../infra/heartbeat-wake.js"; import { enqueueSystemEvent } from "../../infra/system-events.js"; -import type { createSubsystemLogger } from "../../logging/subsystem.js"; -import type { HookMessageChannel, HooksConfigResolved } from "../hooks.js"; import { createHooksRequestHandler } from "../server-http.js"; type SubsystemLogger = ReturnType; diff --git a/src/gateway/server/http-listen.ts b/src/gateway/server/http-listen.ts index b890a14d267..c2ae20a879f 100644 --- a/src/gateway/server/http-listen.ts +++ b/src/gateway/server/http-listen.ts @@ -1,5 +1,4 @@ import type { Server as HttpServer } from "node:http"; - import { GatewayLockError } from "../../infra/gateway-lock.js"; export async function listenGatewayHttpServer(params: { diff --git a/src/gateway/server/plugins-http.test.ts b/src/gateway/server/plugins-http.test.ts index 0308ebe316a..b373a23df93 100644 --- a/src/gateway/server/plugins-http.test.ts +++ b/src/gateway/server/plugins-http.test.ts @@ -1,8 +1,7 @@ import type { IncomingMessage, ServerResponse } from "node:http"; import { describe, expect, it, vi } from "vitest"; - -import { createGatewayPluginRequestHandler } from "./plugins-http.js"; import { createTestRegistry } from "./__tests__/test-utils.js"; +import { createGatewayPluginRequestHandler } from "./plugins-http.js"; const makeResponse = (): { res: ServerResponse; diff --git a/src/gateway/server/plugins-http.ts b/src/gateway/server/plugins-http.ts index 7d72adfc23b..8140be67d99 100644 --- a/src/gateway/server/plugins-http.ts +++ b/src/gateway/server/plugins-http.ts @@ -1,5 +1,4 @@ import type { IncomingMessage, ServerResponse } from "node:http"; - import type { createSubsystemLogger } from "../../logging/subsystem.js"; import type { PluginRegistry } from "../../plugins/registry.js"; diff --git a/src/gateway/server/ws-connection.ts b/src/gateway/server/ws-connection.ts index 5bcf698faea..661ed17a244 100644 --- a/src/gateway/server/ws-connection.ts +++ b/src/gateway/server/ws-connection.ts @@ -1,20 +1,18 @@ -import { randomUUID } from "node:crypto"; - import type { WebSocket, WebSocketServer } from "ws"; +import { randomUUID } from "node:crypto"; +import type { createSubsystemLogger } from "../../logging/subsystem.js"; +import type { ResolvedGatewayAuth } from "../auth.js"; +import type { GatewayRequestContext, GatewayRequestHandlers } from "../server-methods/types.js"; +import type { GatewayWsClient } from "./ws-types.js"; import { resolveCanvasHostUrl } from "../../infra/canvas-host-url.js"; import { listSystemPresence, upsertPresence } from "../../infra/system-presence.js"; -import type { createSubsystemLogger } from "../../logging/subsystem.js"; import { isWebchatClient } from "../../utils/message-channel.js"; - -import type { ResolvedGatewayAuth } from "../auth.js"; import { isLoopbackAddress } from "../net.js"; import { getHandshakeTimeoutMs } from "../server-constants.js"; -import type { GatewayRequestContext, GatewayRequestHandlers } from "../server-methods/types.js"; import { formatError } from "../server-utils.js"; import { logWs } from "../ws-log.js"; import { getHealthVersion, getPresenceVersion, incrementPresenceVersion } from "./health-state.js"; import { attachGatewayWsMessageHandler } from "./ws-connection/message-handler.js"; -import type { GatewayWsClient } from "./ws-types.js"; type SubsystemLogger = ReturnType; diff --git a/src/gateway/server/ws-connection/message-handler.ts b/src/gateway/server/ws-connection/message-handler.ts index 070e996ef4f..3ddcb725362 100644 --- a/src/gateway/server/ws-connection/message-handler.ts +++ b/src/gateway/server/ws-connection/message-handler.ts @@ -1,7 +1,11 @@ import type { IncomingMessage } from "node:http"; -import os from "node:os"; - import type { WebSocket } from "ws"; +import os from "node:os"; +import type { createSubsystemLogger } from "../../../logging/subsystem.js"; +import type { ResolvedGatewayAuth } from "../../auth.js"; +import type { GatewayRequestContext, GatewayRequestHandlers } from "../../server-methods/types.js"; +import type { GatewayWsClient } from "../ws-types.js"; +import { loadConfig } from "../../../config/config.js"; import { deriveDeviceIdFromPublicKey, normalizeDevicePublicKeyBase64Url, @@ -17,17 +21,15 @@ import { } from "../../../infra/device-pairing.js"; import { updatePairedNodeMetadata } from "../../../infra/node-pairing.js"; import { recordRemoteNodeInfo, refreshRemoteNodeBins } from "../../../infra/skills-remote.js"; -import { loadVoiceWakeConfig } from "../../../infra/voicewake.js"; import { upsertPresence } from "../../../infra/system-presence.js"; +import { loadVoiceWakeConfig } from "../../../infra/voicewake.js"; import { rawDataToString } from "../../../infra/ws.js"; -import type { createSubsystemLogger } from "../../../logging/subsystem.js"; import { isGatewayCliClient, isWebchatClient } from "../../../utils/message-channel.js"; -import type { ResolvedGatewayAuth } from "../../auth.js"; import { authorizeGatewayConnect, isLocalDirectRequest } from "../../auth.js"; -import { loadConfig } from "../../../config/config.js"; import { buildDeviceAuthPayload } from "../../device-auth.js"; import { isLoopbackAddress, isTrustedProxyAddress, resolveGatewayClientIp } from "../../net.js"; import { resolveNodeCommandAllowlist } from "../../node-command-policy.js"; +import { GATEWAY_CLIENT_IDS } from "../../protocol/client-info.js"; import { type ConnectParams, ErrorCodes, @@ -38,13 +40,10 @@ import { validateConnectParams, validateRequestFrame, } from "../../protocol/index.js"; -import { GATEWAY_CLIENT_IDS } from "../../protocol/client-info.js"; import { MAX_BUFFERED_BYTES, MAX_PAYLOAD_BYTES, TICK_INTERVAL_MS } from "../../server-constants.js"; -import type { GatewayRequestContext, GatewayRequestHandlers } from "../../server-methods/types.js"; import { handleGatewayRequest } from "../../server-methods.js"; import { formatError } from "../../server-utils.js"; import { formatForLog, logWs } from "../../ws-log.js"; - import { truncateCloseReason } from "../close-reason.js"; import { buildGatewaySnapshot, @@ -53,7 +52,6 @@ import { incrementPresenceVersion, refreshGatewayHealthSnapshot, } from "../health-state.js"; -import type { GatewayWsClient } from "../ws-types.js"; type SubsystemLogger = ReturnType; diff --git a/src/gateway/server/ws-types.ts b/src/gateway/server/ws-types.ts index f604b37df79..daeda9a2923 100644 --- a/src/gateway/server/ws-types.ts +++ b/src/gateway/server/ws-types.ts @@ -1,5 +1,4 @@ import type { WebSocket } from "ws"; - import type { ConnectParams } from "../protocol/index.js"; export type GatewayWsClient = { diff --git a/src/gateway/session-utils.fs.ts b/src/gateway/session-utils.fs.ts index fbb8a33abc3..936ad941983 100644 --- a/src/gateway/session-utils.fs.ts +++ b/src/gateway/session-utils.fs.ts @@ -1,10 +1,9 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - +import type { SessionPreviewItem } from "./session-utils.types.js"; import { resolveSessionTranscriptPath } from "../config/sessions.js"; import { stripEnvelope } from "./chat-sanitize.js"; -import type { SessionPreviewItem } from "./session-utils.types.js"; export function readSessionMessages( sessionId: string, diff --git a/src/gateway/session-utils.ts b/src/gateway/session-utils.ts index 670742fda56..ec3b147f847 100644 --- a/src/gateway/session-utils.ts +++ b/src/gateway/session-utils.ts @@ -1,6 +1,11 @@ import fs from "node:fs"; import path from "node:path"; - +import type { + GatewayAgentRow, + GatewaySessionRow, + GatewaySessionsDefaults, + SessionsListResult, +} from "./session-utils.types.js"; import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; import { lookupContextTokens } from "../agents/context.js"; import { DEFAULT_CONTEXT_TOKENS, DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js"; @@ -26,12 +31,6 @@ import { readFirstUserMessageFromTranscript, readLastMessagePreviewFromTranscript, } from "./session-utils.fs.js"; -import type { - GatewayAgentRow, - GatewaySessionRow, - GatewaySessionsDefaults, - SessionsListResult, -} from "./session-utils.types.js"; export { archiveFileOnDisk, diff --git a/src/gateway/sessions-patch.ts b/src/gateway/sessions-patch.ts index f2d693b342b..36fe85e3a30 100644 --- a/src/gateway/sessions-patch.ts +++ b/src/gateway/sessions-patch.ts @@ -1,7 +1,8 @@ import { randomUUID } from "node:crypto"; - -import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js"; import type { ModelCatalogEntry } from "../agents/model-catalog.js"; +import type { OpenClawConfig } from "../config/config.js"; +import type { SessionEntry } from "../config/sessions.js"; +import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js"; import { resolveAllowedModelRef, resolveConfiguredModelRef } from "../agents/model-selection.js"; import { normalizeGroupActivation } from "../auto-reply/group-activation.js"; import { @@ -13,13 +14,11 @@ import { normalizeUsageDisplay, supportsXHighThinking, } from "../auto-reply/thinking.js"; -import type { OpenClawConfig } from "../config/config.js"; -import type { SessionEntry } from "../config/sessions.js"; import { isSubagentSessionKey } from "../routing/session-key.js"; import { applyVerboseOverride, parseVerboseOverride } from "../sessions/level-overrides.js"; +import { applyModelOverrideToSessionEntry } from "../sessions/model-overrides.js"; import { normalizeSendPolicy } from "../sessions/send-policy.js"; import { parseSessionLabel } from "../sessions/session-label.js"; -import { applyModelOverrideToSessionEntry } from "../sessions/model-overrides.js"; import { ErrorCodes, type ErrorShape, diff --git a/src/gateway/test-helpers.e2e.ts b/src/gateway/test-helpers.e2e.ts index 62db8923f0d..3a5fe38ff61 100644 --- a/src/gateway/test-helpers.e2e.ts +++ b/src/gateway/test-helpers.e2e.ts @@ -1,5 +1,4 @@ import { WebSocket } from "ws"; - import { loadOrCreateDeviceIdentity, publicKeyRawBase64UrlFromPem, @@ -13,7 +12,6 @@ import { type GatewayClientMode, type GatewayClientName, } from "../utils/message-channel.js"; - import { GatewayClient } from "./client.js"; import { buildDeviceAuthPayload } from "./device-auth.js"; import { PROTOCOL_VERSION } from "./protocol/index.js"; diff --git a/src/gateway/test-helpers.mocks.ts b/src/gateway/test-helpers.mocks.ts index 8539d8e824b..792a644c98f 100644 --- a/src/gateway/test-helpers.mocks.ts +++ b/src/gateway/test-helpers.mocks.ts @@ -1,15 +1,14 @@ import crypto from "node:crypto"; -import fs from "node:fs/promises"; import fsSync from "node:fs"; +import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { Mock, vi } from "vitest"; - import type { ChannelPlugin, ChannelOutboundAdapter } from "../channels/plugins/types.js"; -import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js"; import type { AgentBinding } from "../config/types.agents.js"; import type { HooksConfig } from "../config/types.hooks.js"; import type { PluginRegistry } from "../plugins/registry.js"; +import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js"; diff --git a/src/gateway/test-helpers.server.ts b/src/gateway/test-helpers.server.ts index a8a5ba2362d..99317df4499 100644 --- a/src/gateway/test-helpers.server.ts +++ b/src/gateway/test-helpers.server.ts @@ -2,10 +2,9 @@ import fs from "node:fs/promises"; import { type AddressInfo, createServer } from "node:net"; import os from "node:os"; import path from "node:path"; - import { afterAll, afterEach, beforeAll, beforeEach, expect, vi } from "vitest"; import { WebSocket } from "ws"; - +import type { GatewayServerOptions } from "./server.js"; import { resolveMainSessionKeyFromConfig, type SessionEntry } from "../config/sessions.js"; import { resetAgentRunContextForTest } from "../infra/agent-events.js"; import { @@ -19,10 +18,8 @@ import { resetLogger, setLoggerOverride } from "../logging.js"; import { DEFAULT_AGENT_ID, toAgentStoreSessionKey } from "../routing/session-key.js"; import { getDeterministicFreePortBlock } from "../test-utils/ports.js"; import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; - -import { PROTOCOL_VERSION } from "./protocol/index.js"; import { buildDeviceAuthPayload } from "./device-auth.js"; -import type { GatewayServerOptions } from "./server.js"; +import { PROTOCOL_VERSION } from "./protocol/index.js"; import { agentCommand, cronIsolatedRun, diff --git a/src/gateway/tools-invoke-http.test.ts b/src/gateway/tools-invoke-http.test.ts index e61cdff01ba..d24654d9174 100644 --- a/src/gateway/tools-invoke-http.test.ts +++ b/src/gateway/tools-invoke-http.test.ts @@ -1,13 +1,11 @@ -import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { IncomingMessage, ServerResponse } from "node:http"; import { promises as fs } from "node:fs"; import path from "node:path"; - -import { installGatewayTestHooks, getFreePort, startGatewayServer } from "./test-helpers.server.js"; -import { resetTestPluginRegistry, setTestPluginRegistry, testState } from "./test-helpers.mocks.js"; -import { createTestRegistry } from "../test-utils/channel-plugins.js"; +import { beforeEach, describe, expect, it, vi } from "vitest"; import { CONFIG_PATH } from "../config/config.js"; +import { createTestRegistry } from "../test-utils/channel-plugins.js"; +import { resetTestPluginRegistry, setTestPluginRegistry, testState } from "./test-helpers.mocks.js"; +import { installGatewayTestHooks, getFreePort, startGatewayServer } from "./test-helpers.server.js"; installGatewayTestHooks({ scope: "suite" }); diff --git a/src/gateway/tools-invoke-http.ts b/src/gateway/tools-invoke-http.ts index 0b97fe17aff..c0f83747237 100644 --- a/src/gateway/tools-invoke-http.ts +++ b/src/gateway/tools-invoke-http.ts @@ -1,5 +1,4 @@ import type { IncomingMessage, ServerResponse } from "node:http"; - import { createOpenClawTools } from "../agents/openclaw-tools.js"; import { filterToolsByPolicy, @@ -22,9 +21,7 @@ import { isTestDefaultMemorySlotDisabled } from "../plugins/config-state.js"; import { getPluginToolMeta } from "../plugins/tools.js"; import { isSubagentSessionKey } from "../routing/session-key.js"; import { normalizeMessageChannel } from "../utils/message-channel.js"; - import { authorizeGatewayConnect, type ResolvedGatewayAuth } from "./auth.js"; -import { getBearerToken, getHeader } from "./http-utils.js"; import { readJsonBodyOrError, sendInvalidRequest, @@ -32,6 +29,7 @@ import { sendMethodNotAllowed, sendUnauthorized, } from "./http-common.js"; +import { getBearerToken, getHeader } from "./http-utils.js"; const DEFAULT_BODY_BYTES = 2 * 1024 * 1024; const MEMORY_TOOL_NAMES = new Set(["memory_search", "memory_get"]); diff --git a/src/gateway/ws-log.ts b/src/gateway/ws-log.ts index 2716fe3a037..7c540267ce3 100644 --- a/src/gateway/ws-log.ts +++ b/src/gateway/ws-log.ts @@ -1,9 +1,9 @@ import chalk from "chalk"; import { isVerbose } from "../globals.js"; -import { parseAgentSessionKey } from "../routing/session-key.js"; import { shouldLogSubsystemToConsole } from "../logging/console.js"; -import { createSubsystemLogger } from "../logging/subsystem.js"; import { getDefaultRedactPatterns, redactSensitiveText } from "../logging/redact.js"; +import { createSubsystemLogger } from "../logging/subsystem.js"; +import { parseAgentSessionKey } from "../routing/session-key.js"; import { DEFAULT_WS_SLOW_MS, getGatewayWsLogStyle } from "./ws-logging.js"; const LOG_VALUE_LIMIT = 240; diff --git a/src/git-hooks.test.ts b/src/git-hooks.test.ts index b2a70f97dd3..569f9fcbbd0 100644 --- a/src/git-hooks.test.ts +++ b/src/git-hooks.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { describe, expect, it, vi } from "vitest"; - import { filterOxfmtTargets, filterOutPartialTargets, diff --git a/src/hooks/bundled/boot-md/handler.ts b/src/hooks/bundled/boot-md/handler.ts index 6d41a144b4c..4084d17987d 100644 --- a/src/hooks/bundled/boot-md/handler.ts +++ b/src/hooks/bundled/boot-md/handler.ts @@ -1,8 +1,8 @@ import type { CliDeps } from "../../../cli/deps.js"; -import { createDefaultDeps } from "../../../cli/deps.js"; import type { OpenClawConfig } from "../../../config/config.js"; -import { runBootOnce } from "../../../gateway/boot.js"; import type { HookHandler } from "../../hooks.js"; +import { createDefaultDeps } from "../../../cli/deps.js"; +import { runBootOnce } from "../../../gateway/boot.js"; type BootHookContext = { cfg?: OpenClawConfig; diff --git a/src/hooks/bundled/command-logger/handler.ts b/src/hooks/bundled/command-logger/handler.ts index c292c68f790..16cd071ed45 100644 --- a/src/hooks/bundled/command-logger/handler.ts +++ b/src/hooks/bundled/command-logger/handler.ts @@ -24,8 +24,8 @@ */ import fs from "node:fs/promises"; -import path from "node:path"; import os from "node:os"; +import path from "node:path"; import type { HookHandler } from "../../hooks.js"; /** diff --git a/src/hooks/bundled/session-memory/handler.test.ts b/src/hooks/bundled/session-memory/handler.test.ts index 9c558789ede..5561a812a57 100644 --- a/src/hooks/bundled/session-memory/handler.test.ts +++ b/src/hooks/bundled/session-memory/handler.test.ts @@ -1,12 +1,10 @@ import fs from "node:fs/promises"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - -import handler from "./handler.js"; -import { createHookEvent } from "../../hooks.js"; import type { OpenClawConfig } from "../../../config/config.js"; import { makeTempWorkspace, writeWorkspaceFile } from "../../../test-helpers/workspace.js"; +import { createHookEvent } from "../../hooks.js"; +import handler from "./handler.js"; /** * Create a mock session JSONL file with various entry types diff --git a/src/hooks/bundled/session-memory/handler.ts b/src/hooks/bundled/session-memory/handler.ts index 28082c1d7e9..dd99839d226 100644 --- a/src/hooks/bundled/session-memory/handler.ts +++ b/src/hooks/bundled/session-memory/handler.ts @@ -6,14 +6,14 @@ */ import fs from "node:fs/promises"; -import path from "node:path"; import os from "node:os"; +import path from "node:path"; import { fileURLToPath } from "node:url"; import type { OpenClawConfig } from "../../../config/config.js"; +import type { HookHandler } from "../../hooks.js"; import { resolveAgentWorkspaceDir } from "../../../agents/agent-scope.js"; import { resolveAgentIdFromSessionKey } from "../../../routing/session-key.js"; import { resolveHookConfig } from "../../config.js"; -import type { HookHandler } from "../../hooks.js"; /** * Read recent messages from session file for slug generation diff --git a/src/hooks/bundled/soul-evil/handler.test.ts b/src/hooks/bundled/soul-evil/handler.test.ts index c7a2844e7b7..8cb4be14c49 100644 --- a/src/hooks/bundled/soul-evil/handler.test.ts +++ b/src/hooks/bundled/soul-evil/handler.test.ts @@ -1,12 +1,10 @@ import path from "node:path"; - import { describe, expect, it } from "vitest"; - -import handler from "./handler.js"; -import { createHookEvent } from "../../hooks.js"; -import type { AgentBootstrapHookContext } from "../../hooks.js"; import type { OpenClawConfig } from "../../../config/config.js"; +import type { AgentBootstrapHookContext } from "../../hooks.js"; import { makeTempWorkspace, writeWorkspaceFile } from "../../../test-helpers/workspace.js"; +import { createHookEvent } from "../../hooks.js"; +import handler from "./handler.js"; describe("soul-evil hook", () => { it("skips subagent sessions", async () => { diff --git a/src/hooks/config.ts b/src/hooks/config.ts index 553ac68b0f4..04d4beac683 100644 --- a/src/hooks/config.ts +++ b/src/hooks/config.ts @@ -1,8 +1,8 @@ import fs from "node:fs"; import path from "node:path"; import type { OpenClawConfig, HookConfig } from "../config/config.js"; -import { resolveHookKey } from "./frontmatter.js"; import type { HookEligibilityContext, HookEntry } from "./types.js"; +import { resolveHookKey } from "./frontmatter.js"; const DEFAULT_CONFIG_VALUES: Record = { "browser.enabled": true, diff --git a/src/hooks/frontmatter.ts b/src/hooks/frontmatter.ts index 18a20bf647c..a213d048706 100644 --- a/src/hooks/frontmatter.ts +++ b/src/hooks/frontmatter.ts @@ -1,8 +1,4 @@ import JSON5 from "json5"; - -import { LEGACY_MANIFEST_KEYS, MANIFEST_KEY } from "../compat/legacy-names.js"; -import { parseFrontmatterBlock } from "../markdown/frontmatter.js"; -import { parseBooleanValue } from "../utils/boolean.js"; import type { OpenClawHookMetadata, HookEntry, @@ -10,6 +6,9 @@ import type { HookInvocationPolicy, ParsedHookFrontmatter, } from "./types.js"; +import { LEGACY_MANIFEST_KEYS, MANIFEST_KEY } from "../compat/legacy-names.js"; +import { parseFrontmatterBlock } from "../markdown/frontmatter.js"; +import { parseBooleanValue } from "../utils/boolean.js"; export function parseFrontmatter(content: string): ParsedHookFrontmatter { return parseFrontmatterBlock(content); diff --git a/src/hooks/gmail-ops.ts b/src/hooks/gmail-ops.ts index 4922040764c..b8fbd4aba15 100644 --- a/src/hooks/gmail-ops.ts +++ b/src/hooks/gmail-ops.ts @@ -1,5 +1,5 @@ import { spawn } from "node:child_process"; - +import { formatCliCommand } from "../cli/command-format.js"; import { type OpenClawConfig, CONFIG_PATH, @@ -11,8 +11,16 @@ import { } from "../config/config.js"; import { runCommandWithTimeout } from "../process/exec.js"; import { defaultRuntime } from "../runtime.js"; -import { formatCliCommand } from "../cli/command-format.js"; import { displayPath } from "../utils.js"; +import { + ensureDependency, + ensureGcloudAuth, + ensureSubscription, + ensureTailscaleEndpoint, + ensureTopic, + resolveProjectIdFromGogCredentials, + runGcloud, +} from "./gmail-setup-utils.js"; import { buildDefaultHookUrl, buildGogWatchServeArgs, @@ -35,15 +43,6 @@ import { parseTopicPath, resolveGmailHookRuntimeConfig, } from "./gmail.js"; -import { - ensureDependency, - ensureGcloudAuth, - ensureSubscription, - ensureTailscaleEndpoint, - ensureTopic, - resolveProjectIdFromGogCredentials, - runGcloud, -} from "./gmail-setup-utils.js"; export type GmailSetupOptions = { account: string; diff --git a/src/hooks/gmail-setup-utils.test.ts b/src/hooks/gmail-setup-utils.test.ts index 20382614759..1876dd8ea44 100644 --- a/src/hooks/gmail-setup-utils.test.ts +++ b/src/hooks/gmail-setup-utils.test.ts @@ -1,7 +1,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { beforeEach, describe, expect, it, vi } from "vitest"; const itUnix = process.platform === "win32" ? it.skip : it; diff --git a/src/hooks/gmail-setup-utils.ts b/src/hooks/gmail-setup-utils.ts index daa1a0e1132..4a95b10ab14 100644 --- a/src/hooks/gmail-setup-utils.ts +++ b/src/hooks/gmail-setup-utils.ts @@ -1,6 +1,5 @@ import fs from "node:fs"; import path from "node:path"; - import { hasBinary } from "../agents/skills.js"; import { runCommandWithTimeout, type SpawnResult } from "../process/exec.js"; import { resolveUserPath } from "../utils.js"; diff --git a/src/hooks/gmail-watcher.ts b/src/hooks/gmail-watcher.ts index 67bb003e091..16512e3550e 100644 --- a/src/hooks/gmail-watcher.ts +++ b/src/hooks/gmail-watcher.ts @@ -6,17 +6,17 @@ */ import { type ChildProcess, spawn } from "node:child_process"; -import { hasBinary } from "../agents/skills.js"; import type { OpenClawConfig } from "../config/config.js"; +import { hasBinary } from "../agents/skills.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { runCommandWithTimeout } from "../process/exec.js"; +import { ensureTailscaleEndpoint } from "./gmail-setup-utils.js"; import { buildGogWatchServeArgs, buildGogWatchStartArgs, type GmailHookRuntimeConfig, resolveGmailHookRuntimeConfig, } from "./gmail.js"; -import { ensureTailscaleEndpoint } from "./gmail-setup-utils.js"; const log = createSubsystemLogger("gmail-watcher"); diff --git a/src/hooks/gmail.ts b/src/hooks/gmail.ts index 9907f802b8e..5b3c890324b 100644 --- a/src/hooks/gmail.ts +++ b/src/hooks/gmail.ts @@ -1,5 +1,4 @@ import { randomBytes } from "node:crypto"; - import { type OpenClawConfig, DEFAULT_GATEWAY_PORT, diff --git a/src/hooks/hooks-status.ts b/src/hooks/hooks-status.ts index 9ceef9972d7..0a8018e11d5 100644 --- a/src/hooks/hooks-status.ts +++ b/src/hooks/hooks-status.ts @@ -1,9 +1,8 @@ import path from "node:path"; - import type { OpenClawConfig } from "../config/config.js"; +import type { HookEligibilityContext, HookEntry, HookInstallSpec } from "./types.js"; import { CONFIG_DIR } from "../utils.js"; import { hasBinary, isConfigPathTruthy, resolveConfigPath, resolveHookConfig } from "./config.js"; -import type { HookEligibilityContext, HookEntry, HookInstallSpec } from "./types.js"; import { loadWorkspaceHookEntries } from "./workspace.js"; export type HookStatusConfigCheck = { diff --git a/src/hooks/install.test.ts b/src/hooks/install.test.ts index 212c15cc004..97bc7682abf 100644 --- a/src/hooks/install.test.ts +++ b/src/hooks/install.test.ts @@ -1,8 +1,8 @@ +import JSZip from "jszip"; import { randomUUID } from "node:crypto"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; -import JSZip from "jszip"; import * as tar from "tar"; import { afterEach, describe, expect, it } from "vitest"; diff --git a/src/hooks/install.ts b/src/hooks/install.ts index 7fe7b5eaaa1..4594f99dfb7 100644 --- a/src/hooks/install.ts +++ b/src/hooks/install.ts @@ -1,10 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { MANIFEST_KEY } from "../compat/legacy-names.js"; -import { runCommandWithTimeout } from "../process/exec.js"; -import { CONFIG_DIR, resolveUserPath } from "../utils.js"; import { extractArchive, fileExists, @@ -12,6 +9,8 @@ import { resolveArchiveKind, resolvePackedRootDir, } from "../infra/archive.js"; +import { runCommandWithTimeout } from "../process/exec.js"; +import { CONFIG_DIR, resolveUserPath } from "../utils.js"; import { parseFrontmatter } from "./frontmatter.js"; export type HookInstallLogger = { diff --git a/src/hooks/llm-slug-generator.ts b/src/hooks/llm-slug-generator.ts index c52627176e5..95161b66b4e 100644 --- a/src/hooks/llm-slug-generator.ts +++ b/src/hooks/llm-slug-generator.ts @@ -5,13 +5,13 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; -import { runEmbeddedPiAgent } from "../agents/pi-embedded.js"; import type { OpenClawConfig } from "../config/config.js"; import { resolveDefaultAgentId, resolveAgentWorkspaceDir, resolveAgentDir, } from "../agents/agent-scope.js"; +import { runEmbeddedPiAgent } from "../agents/pi-embedded.js"; /** * Generate a short 1-2 word filename slug from session content using LLM diff --git a/src/hooks/loader.test.ts b/src/hooks/loader.test.ts index 634bf6f3677..7bf4e11fa5b 100644 --- a/src/hooks/loader.test.ts +++ b/src/hooks/loader.test.ts @@ -2,14 +2,14 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { loadInternalHooks } from "./loader.js"; +import type { OpenClawConfig } from "../config/config.js"; import { clearInternalHooks, getRegisteredEventKeys, triggerInternalHook, createInternalHookEvent, } from "./internal-hooks.js"; -import type { OpenClawConfig } from "../config/config.js"; +import { loadInternalHooks } from "./loader.js"; describe("loader", () => { let tmpDir: string; diff --git a/src/hooks/loader.ts b/src/hooks/loader.ts index 9f0899a97ae..2b7bc5395e3 100644 --- a/src/hooks/loader.ts +++ b/src/hooks/loader.ts @@ -5,14 +5,14 @@ * and from directory-based discovery (bundled, managed, workspace) */ -import { pathToFileURL } from "node:url"; import path from "node:path"; -import { registerInternalHook } from "./internal-hooks.js"; +import { pathToFileURL } from "node:url"; import type { OpenClawConfig } from "../config/config.js"; import type { InternalHookHandler } from "./internal-hooks.js"; -import { loadWorkspaceHookEntries } from "./workspace.js"; import { resolveHookConfig } from "./config.js"; import { shouldIncludeHook } from "./config.js"; +import { registerInternalHook } from "./internal-hooks.js"; +import { loadWorkspaceHookEntries } from "./workspace.js"; /** * Load and register all hook handlers diff --git a/src/hooks/plugin-hooks.ts b/src/hooks/plugin-hooks.ts index 5e98d130c49..faf34323b57 100644 --- a/src/hooks/plugin-hooks.ts +++ b/src/hooks/plugin-hooks.ts @@ -1,11 +1,10 @@ import path from "node:path"; import { pathToFileURL } from "node:url"; - import type { OpenClawPluginApi } from "../plugins/types.js"; +import type { InternalHookHandler } from "./internal-hooks.js"; import type { HookEntry } from "./types.js"; import { shouldIncludeHook } from "./config.js"; import { loadHookEntriesFromDir } from "./workspace.js"; -import type { InternalHookHandler } from "./internal-hooks.js"; export type PluginHookLoadResult = { hooks: HookEntry[]; diff --git a/src/hooks/soul-evil.test.ts b/src/hooks/soul-evil.test.ts index db13f24035b..b6d41904c38 100644 --- a/src/hooks/soul-evil.test.ts +++ b/src/hooks/soul-evil.test.ts @@ -1,15 +1,13 @@ import path from "node:path"; - import { describe, expect, it } from "vitest"; - +import { DEFAULT_SOUL_FILENAME, type WorkspaceBootstrapFile } from "../agents/workspace.js"; +import { makeTempWorkspace, writeWorkspaceFile } from "../test-helpers/workspace.js"; import { applySoulEvilOverride, decideSoulEvil, DEFAULT_SOUL_EVIL_FILENAME, resolveSoulEvilConfigFromHook, } from "./soul-evil.js"; -import { DEFAULT_SOUL_FILENAME, type WorkspaceBootstrapFile } from "../agents/workspace.js"; -import { makeTempWorkspace, writeWorkspaceFile } from "../test-helpers/workspace.js"; const makeFiles = (overrides?: Partial) => [ { diff --git a/src/hooks/soul-evil.ts b/src/hooks/soul-evil.ts index 0e60c92dc41..fc1591737d2 100644 --- a/src/hooks/soul-evil.ts +++ b/src/hooks/soul-evil.ts @@ -1,8 +1,7 @@ import fs from "node:fs/promises"; import path from "node:path"; - -import { resolveUserTimezone } from "../agents/date-time.js"; import type { WorkspaceBootstrapFile } from "../agents/workspace.js"; +import { resolveUserTimezone } from "../agents/date-time.js"; import { parseDurationMs } from "../cli/parse-duration.js"; import { resolveUserPath } from "../utils.js"; diff --git a/src/hooks/workspace.ts b/src/hooks/workspace.ts index 3c75968af60..e476279fe22 100644 --- a/src/hooks/workspace.ts +++ b/src/hooks/workspace.ts @@ -1,16 +1,6 @@ import fs from "node:fs"; import path from "node:path"; - -import { MANIFEST_KEY } from "../compat/legacy-names.js"; import type { OpenClawConfig } from "../config/config.js"; -import { CONFIG_DIR, resolveUserPath } from "../utils.js"; -import { resolveBundledHooksDir } from "./bundled-dir.js"; -import { shouldIncludeHook } from "./config.js"; -import { - parseFrontmatter, - resolveOpenClawMetadata, - resolveHookInvocationPolicy, -} from "./frontmatter.js"; import type { Hook, HookEligibilityContext, @@ -19,6 +9,15 @@ import type { HookSource, ParsedHookFrontmatter, } from "./types.js"; +import { MANIFEST_KEY } from "../compat/legacy-names.js"; +import { CONFIG_DIR, resolveUserPath } from "../utils.js"; +import { resolveBundledHooksDir } from "./bundled-dir.js"; +import { shouldIncludeHook } from "./config.js"; +import { + parseFrontmatter, + resolveOpenClawMetadata, + resolveHookInvocationPolicy, +} from "./frontmatter.js"; type HookPackageManifest = { name?: string; diff --git a/src/imessage/client.ts b/src/imessage/client.ts index 47ed0586860..9811de08387 100644 --- a/src/imessage/client.ts +++ b/src/imessage/client.ts @@ -1,6 +1,5 @@ import { type ChildProcessWithoutNullStreams, spawn } from "node:child_process"; import { createInterface, type Interface } from "node:readline"; - import type { RuntimeEnv } from "../runtime.js"; import { resolveUserPath } from "../utils.js"; diff --git a/src/imessage/monitor.skips-group-messages-without-mention-by-default.test.ts b/src/imessage/monitor.skips-group-messages-without-mention-by-default.test.ts index 08656d482cb..099e8508da0 100644 --- a/src/imessage/monitor.skips-group-messages-without-mention-by-default.test.ts +++ b/src/imessage/monitor.skips-group-messages-without-mention-by-default.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import { monitorIMessageProvider } from "./monitor.js"; const requestMock = vi.fn(); diff --git a/src/imessage/monitor.updates-last-route-chat-id-direct-messages.test.ts b/src/imessage/monitor.updates-last-route-chat-id-direct-messages.test.ts index 8573de0223f..96123bd58ff 100644 --- a/src/imessage/monitor.updates-last-route-chat-id-direct-messages.test.ts +++ b/src/imessage/monitor.updates-last-route-chat-id-direct-messages.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import { monitorIMessageProvider } from "./monitor.js"; const requestMock = vi.fn(); diff --git a/src/imessage/monitor/deliver.ts b/src/imessage/monitor/deliver.ts index 84ee848e5a3..eb5b72dd38b 100644 --- a/src/imessage/monitor/deliver.ts +++ b/src/imessage/monitor/deliver.ts @@ -1,10 +1,10 @@ +import type { ReplyPayload } from "../../auto-reply/types.js"; +import type { RuntimeEnv } from "../../runtime.js"; +import type { createIMessageRpcClient } from "../client.js"; import { chunkTextWithMode, resolveChunkMode } from "../../auto-reply/chunk.js"; import { loadConfig } from "../../config/config.js"; import { resolveMarkdownTableMode } from "../../config/markdown-tables.js"; import { convertMarkdownTables } from "../../markdown/tables.js"; -import type { ReplyPayload } from "../../auto-reply/types.js"; -import type { RuntimeEnv } from "../../runtime.js"; -import type { createIMessageRpcClient } from "../client.js"; import { sendMessageIMessage } from "../send.js"; export async function deliverReplies(params: { diff --git a/src/imessage/monitor/monitor-provider.ts b/src/imessage/monitor/monitor-provider.ts index 7896650ace4..08fb36aea66 100644 --- a/src/imessage/monitor/monitor-provider.ts +++ b/src/imessage/monitor/monitor-provider.ts @@ -1,8 +1,9 @@ import fs from "node:fs/promises"; - +import type { IMessagePayload, MonitorIMessageOpts } from "./types.js"; import { resolveHumanDelayConfig } from "../../agents/identity.js"; import { resolveTextChunkLimit } from "../../auto-reply/chunk.js"; import { hasControlCommand } from "../../auto-reply/command-detection.js"; +import { dispatchInboundMessage } from "../../auto-reply/dispatch.js"; import { formatInboundEnvelope, formatInboundFromLabel, @@ -12,8 +13,6 @@ import { createInboundDebouncer, resolveInboundDebounceMs, } from "../../auto-reply/inbound-debounce.js"; -import { dispatchInboundMessage } from "../../auto-reply/dispatch.js"; -import { finalizeInboundContext } from "../../auto-reply/reply/inbound-context.js"; import { buildPendingHistoryContextFromMap, clearHistoryEntriesIfEnabled, @@ -21,8 +20,10 @@ import { recordPendingHistoryEntryIfEnabled, type HistoryEntry, } from "../../auto-reply/reply/history.js"; +import { finalizeInboundContext } from "../../auto-reply/reply/inbound-context.js"; import { buildMentionRegexes, matchesMentionPatterns } from "../../auto-reply/reply/mentions.js"; import { createReplyDispatcher } from "../../auto-reply/reply/reply-dispatcher.js"; +import { resolveControlCommandGate } from "../../channels/command-gating.js"; import { logInboundDrop } from "../../channels/logging.js"; import { createReplyPrefixContext } from "../../channels/reply-prefix.js"; import { recordInboundSession } from "../../channels/session.js"; @@ -42,7 +43,6 @@ import { } from "../../pairing/pairing-store.js"; import { resolveAgentRoute } from "../../routing/resolve-route.js"; import { truncateUtf16Safe } from "../../utils.js"; -import { resolveControlCommandGate } from "../../channels/command-gating.js"; import { resolveIMessageAccount } from "../accounts.js"; import { createIMessageRpcClient } from "../client.js"; import { probeIMessage } from "../probe.js"; @@ -54,7 +54,6 @@ import { } from "../targets.js"; import { deliverReplies } from "./deliver.js"; import { normalizeAllowList, resolveRuntime } from "./runtime.js"; -import type { IMessagePayload, MonitorIMessageOpts } from "./types.js"; /** * Try to detect remote host from an SSH wrapper script like: diff --git a/src/imessage/probe.test.ts b/src/imessage/probe.test.ts index 5a3e030e742..3faa7cb2af5 100644 --- a/src/imessage/probe.test.ts +++ b/src/imessage/probe.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import { probeIMessage } from "./probe.js"; const detectBinaryMock = vi.hoisted(() => vi.fn()); diff --git a/src/imessage/probe.ts b/src/imessage/probe.ts index 7eb37c1b5d7..92d131565c8 100644 --- a/src/imessage/probe.ts +++ b/src/imessage/probe.ts @@ -1,7 +1,7 @@ +import type { RuntimeEnv } from "../runtime.js"; import { detectBinary } from "../commands/onboard-helpers.js"; import { loadConfig } from "../config/config.js"; import { runCommandWithTimeout } from "../process/exec.js"; -import type { RuntimeEnv } from "../runtime.js"; import { createIMessageRpcClient } from "./client.js"; export type IMessageProbe = { diff --git a/src/imessage/send.ts b/src/imessage/send.ts index 8b8395460f5..adc7052c34d 100644 --- a/src/imessage/send.ts +++ b/src/imessage/send.ts @@ -1,9 +1,9 @@ import { loadConfig } from "../config/config.js"; import { resolveMarkdownTableMode } from "../config/markdown-tables.js"; +import { convertMarkdownTables } from "../markdown/tables.js"; import { mediaKindFromMime } from "../media/constants.js"; import { saveMediaBuffer } from "../media/store.js"; import { loadWebMedia } from "../web/media.js"; -import { convertMarkdownTables } from "../markdown/tables.js"; import { resolveIMessageAccount } from "./accounts.js"; import { createIMessageRpcClient, type IMessageRpcClient } from "./client.js"; import { formatIMessageChatTarget, type IMessageService, parseIMessageTarget } from "./targets.js"; diff --git a/src/imessage/targets.test.ts b/src/imessage/targets.test.ts index 6350167a305..3a011821526 100644 --- a/src/imessage/targets.test.ts +++ b/src/imessage/targets.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { formatIMessageChatTarget, isAllowedIMessageSender, diff --git a/src/index.ts b/src/index.ts index 8c2ffc7b9b9..61d96ccee33 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,6 @@ #!/usr/bin/env node import process from "node:process"; import { fileURLToPath } from "node:url"; - import { getReplyFromConfig } from "./auto-reply/reply.js"; import { applyTemplate } from "./auto-reply/templating.js"; import { monitorWebChannel } from "./channel-web.js"; @@ -19,6 +18,7 @@ import { import { ensureBinary } from "./infra/binaries.js"; import { loadDotEnv } from "./infra/dotenv.js"; import { normalizeEnv } from "./infra/env.js"; +import { formatUncaughtError } from "./infra/errors.js"; import { isMainModule } from "./infra/is-main.js"; import { ensureOpenClawCliOnPath } from "./infra/path-env.js"; import { @@ -28,7 +28,6 @@ import { PortInUseError, } from "./infra/ports.js"; import { assertSupportedRuntime } from "./infra/runtime-guard.js"; -import { formatUncaughtError } from "./infra/errors.js"; import { installUnhandledRejectionHandler } from "./infra/unhandled-rejections.js"; import { enableConsoleCapture } from "./logging.js"; import { runCommandWithTimeout, runExec } from "./process/exec.js"; diff --git a/src/infra/archive.test.ts b/src/infra/archive.test.ts index 81f986a1320..10ea1a601e8 100644 --- a/src/infra/archive.test.ts +++ b/src/infra/archive.test.ts @@ -1,7 +1,7 @@ +import JSZip from "jszip"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; -import JSZip from "jszip"; import * as tar from "tar"; import { afterEach, describe, expect, it } from "vitest"; import { extractArchive, resolveArchiveKind, resolvePackedRootDir } from "./archive.js"; diff --git a/src/infra/archive.ts b/src/infra/archive.ts index 64133b72004..305b8f14719 100644 --- a/src/infra/archive.ts +++ b/src/infra/archive.ts @@ -1,7 +1,7 @@ +import JSZip from "jszip"; import fs from "node:fs/promises"; import path from "node:path"; import * as tar from "tar"; -import JSZip from "jszip"; export type ArchiveKind = "tar" | "zip"; diff --git a/src/infra/binaries.test.ts b/src/infra/binaries.test.ts index 50b48d3726d..4deee7bd01f 100644 --- a/src/infra/binaries.test.ts +++ b/src/infra/binaries.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { runExec } from "../process/exec.js"; import type { RuntimeEnv } from "../runtime.js"; import { ensureBinary } from "./binaries.js"; diff --git a/src/infra/bonjour-ciao.ts b/src/infra/bonjour-ciao.ts index 17df4e78ccc..878997c6203 100644 --- a/src/infra/bonjour-ciao.ts +++ b/src/infra/bonjour-ciao.ts @@ -1,5 +1,4 @@ import { logDebug } from "../logger.js"; - import { formatBonjourError } from "./bonjour-errors.js"; export function ignoreCiaoCancellationRejection(reason: unknown): boolean { diff --git a/src/infra/bonjour-discovery.test.ts b/src/infra/bonjour-discovery.test.ts index b3d859f53f3..c58a4eeed3e 100644 --- a/src/infra/bonjour-discovery.test.ts +++ b/src/infra/bonjour-discovery.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { runCommandWithTimeout } from "../process/exec.js"; import { discoverGatewayBeacons } from "./bonjour-discovery.js"; diff --git a/src/infra/bonjour.test.ts b/src/infra/bonjour.test.ts index 6057fb57c90..a9320e02177 100644 --- a/src/infra/bonjour.test.ts +++ b/src/infra/bonjour.test.ts @@ -1,7 +1,5 @@ import os from "node:os"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import * as logging from "../logging.js"; const mocks = vi.hoisted(() => ({ diff --git a/src/infra/brew.test.ts b/src/infra/brew.test.ts index e265d7bf004..87e34a3a9b7 100644 --- a/src/infra/brew.test.ts +++ b/src/infra/brew.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import { resolveBrewExecutable, resolveBrewPathDirs } from "./brew.js"; describe("brew helpers", () => { diff --git a/src/infra/channel-activity.test.ts b/src/infra/channel-activity.test.ts index fa84c1b241d..a12d47bfb60 100644 --- a/src/infra/channel-activity.test.ts +++ b/src/infra/channel-activity.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import { getChannelActivity, recordChannelActivity, diff --git a/src/infra/channel-summary.ts b/src/infra/channel-summary.ts index 8701cea4008..d95a3adfe1d 100644 --- a/src/infra/channel-summary.ts +++ b/src/infra/channel-summary.ts @@ -1,5 +1,5 @@ -import { listChannelPlugins } from "../channels/plugins/index.js"; import type { ChannelAccountSnapshot, ChannelPlugin } from "../channels/plugins/types.js"; +import { listChannelPlugins } from "../channels/plugins/index.js"; import { type OpenClawConfig, loadConfig } from "../config/config.js"; import { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js"; import { theme } from "../terminal/theme.js"; diff --git a/src/infra/channels-status-issues.ts b/src/infra/channels-status-issues.ts index 6ec5d19672e..b5e5a610b07 100644 --- a/src/infra/channels-status-issues.ts +++ b/src/infra/channels-status-issues.ts @@ -1,5 +1,5 @@ -import { listChannelPlugins } from "../channels/plugins/index.js"; import type { ChannelAccountSnapshot, ChannelStatusIssue } from "../channels/plugins/types.js"; +import { listChannelPlugins } from "../channels/plugins/index.js"; export function collectChannelStatusIssues(payload: Record): ChannelStatusIssue[] { const issues: ChannelStatusIssue[] = []; diff --git a/src/infra/control-ui-assets.test.ts b/src/infra/control-ui-assets.test.ts index 7f3e99d4c72..1936e5af680 100644 --- a/src/infra/control-ui-assets.test.ts +++ b/src/infra/control-ui-assets.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import { resolveControlUiDistIndexPath, resolveControlUiRepoRoot } from "./control-ui-assets.js"; describe("control UI assets helpers", () => { diff --git a/src/infra/control-ui-assets.ts b/src/infra/control-ui-assets.ts index 867485f5cd3..97a8508859f 100644 --- a/src/infra/control-ui-assets.ts +++ b/src/infra/control-ui-assets.ts @@ -1,6 +1,5 @@ import fs from "node:fs"; import path from "node:path"; - import { runCommandWithTimeout } from "../process/exec.js"; import { defaultRuntime, type RuntimeEnv } from "../runtime.js"; import { resolveOpenClawPackageRoot } from "./openclaw-root.js"; diff --git a/src/infra/dedupe.test.ts b/src/infra/dedupe.test.ts index 3d41938a4c3..366f0d52fca 100644 --- a/src/infra/dedupe.test.ts +++ b/src/infra/dedupe.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { createDedupeCache } from "./dedupe.js"; describe("createDedupeCache", () => { diff --git a/src/infra/device-auth-store.ts b/src/infra/device-auth-store.ts index 6776d23af25..62a27c97afb 100644 --- a/src/infra/device-auth-store.ts +++ b/src/infra/device-auth-store.ts @@ -1,6 +1,5 @@ import fs from "node:fs"; import path from "node:path"; - import { resolveStateDir } from "../config/paths.js"; export type DeviceAuthEntry = { diff --git a/src/infra/diagnostic-events.test.ts b/src/infra/diagnostic-events.test.ts index 2235c9c8a8e..50fa72e00d1 100644 --- a/src/infra/diagnostic-events.test.ts +++ b/src/infra/diagnostic-events.test.ts @@ -1,5 +1,4 @@ import { describe, expect, test } from "vitest"; - import { emitDiagnosticEvent, onDiagnosticEvent, diff --git a/src/infra/diagnostic-flags.test.ts b/src/infra/diagnostic-flags.test.ts index 0d02a8314b6..b2d94a8dae7 100644 --- a/src/infra/diagnostic-flags.test.ts +++ b/src/infra/diagnostic-flags.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { isDiagnosticFlagEnabled, resolveDiagnosticFlags } from "./diagnostic-flags.js"; diff --git a/src/infra/dotenv.test.ts b/src/infra/dotenv.test.ts index 5cd76416fe3..c9cab5456b9 100644 --- a/src/infra/dotenv.test.ts +++ b/src/infra/dotenv.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import { loadDotEnv } from "./dotenv.js"; async function writeEnvFile(filePath: string, contents: string) { diff --git a/src/infra/dotenv.ts b/src/infra/dotenv.ts index b93c7a7af6b..e6474b40748 100644 --- a/src/infra/dotenv.ts +++ b/src/infra/dotenv.ts @@ -1,8 +1,6 @@ +import dotenv from "dotenv"; import fs from "node:fs"; import path from "node:path"; - -import dotenv from "dotenv"; - import { resolveConfigDir } from "../utils.js"; export function loadDotEnv(opts?: { quiet?: boolean }) { diff --git a/src/infra/env-file.ts b/src/infra/env-file.ts index 55a5cd18250..c20222a6cc0 100644 --- a/src/infra/env-file.ts +++ b/src/infra/env-file.ts @@ -1,6 +1,5 @@ import fs from "node:fs"; import path from "node:path"; - import { resolveConfigDir } from "../utils.js"; function escapeRegExp(value: string): string { diff --git a/src/infra/env.test.ts b/src/infra/env.test.ts index 97ba6440acd..c0351037174 100644 --- a/src/infra/env.test.ts +++ b/src/infra/env.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { isTruthyEnvValue, normalizeZaiEnv } from "./env.js"; describe("normalizeZaiEnv", () => { diff --git a/src/infra/exec-approval-forwarder.test.ts b/src/infra/exec-approval-forwarder.test.ts index 71368d31323..60f8ad1485d 100644 --- a/src/infra/exec-approval-forwarder.test.ts +++ b/src/infra/exec-approval-forwarder.test.ts @@ -1,5 +1,4 @@ import { afterEach, describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { createExecApprovalForwarder } from "./exec-approval-forwarder.js"; diff --git a/src/infra/exec-approval-forwarder.ts b/src/infra/exec-approval-forwarder.ts index c1b663ec895..8ce0748cc56 100644 --- a/src/infra/exec-approval-forwarder.ts +++ b/src/infra/exec-approval-forwarder.ts @@ -1,14 +1,14 @@ import type { OpenClawConfig } from "../config/config.js"; -import { loadConfig } from "../config/config.js"; -import { loadSessionStore, resolveStorePath } from "../config/sessions.js"; import type { ExecApprovalForwardingConfig, ExecApprovalForwardTarget, } from "../config/types.approvals.js"; +import type { ExecApprovalDecision } from "./exec-approvals.js"; +import { loadConfig } from "../config/config.js"; +import { loadSessionStore, resolveStorePath } from "../config/sessions.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { parseAgentSessionKey } from "../routing/session-key.js"; import { isDeliverableMessageChannel, normalizeMessageChannel } from "../utils/message-channel.js"; -import type { ExecApprovalDecision } from "./exec-approvals.js"; import { deliverOutboundPayloads } from "./outbound/deliver.js"; import { resolveSessionDeliveryTarget } from "./outbound/targets.js"; diff --git a/src/infra/exec-approvals.test.ts b/src/infra/exec-approvals.test.ts index 16a9cfc9873..091f34e1446 100644 --- a/src/infra/exec-approvals.test.ts +++ b/src/infra/exec-approvals.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it, vi } from "vitest"; - import { analyzeArgvCommand, analyzeShellCommand, diff --git a/src/infra/exec-approvals.ts b/src/infra/exec-approvals.ts index 2254cba4b69..61a757ba8a8 100644 --- a/src/infra/exec-approvals.ts +++ b/src/infra/exec-approvals.ts @@ -3,7 +3,6 @@ import fs from "node:fs"; import net from "node:net"; import os from "node:os"; import path from "node:path"; - import { DEFAULT_AGENT_ID } from "../routing/session-key.js"; export type ExecHost = "sandbox" | "gateway" | "node"; diff --git a/src/infra/fetch.test.ts b/src/infra/fetch.test.ts index f69bd601d1b..6fb471106d4 100644 --- a/src/infra/fetch.test.ts +++ b/src/infra/fetch.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { wrapFetchWithAbortSignal } from "./fetch.js"; describe("wrapFetchWithAbortSignal", () => { diff --git a/src/infra/fs-safe.ts b/src/infra/fs-safe.ts index 2a6d073799d..fc8d4ce526f 100644 --- a/src/infra/fs-safe.ts +++ b/src/infra/fs-safe.ts @@ -1,6 +1,6 @@ -import { constants as fsConstants } from "node:fs"; import type { Stats } from "node:fs"; import type { FileHandle } from "node:fs/promises"; +import { constants as fsConstants } from "node:fs"; import fs from "node:fs/promises"; import path from "node:path"; diff --git a/src/infra/gateway-lock.test.ts b/src/infra/gateway-lock.test.ts index f40dd62b162..12a93fd5857 100644 --- a/src/infra/gateway-lock.test.ts +++ b/src/infra/gateway-lock.test.ts @@ -3,11 +3,9 @@ import fsSync from "node:fs"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it, vi } from "vitest"; - -import { acquireGatewayLock, GatewayLockError } from "./gateway-lock.js"; import { resolveConfigPath, resolveGatewayLockDir, resolveStateDir } from "../config/paths.js"; +import { acquireGatewayLock, GatewayLockError } from "./gateway-lock.js"; async function makeEnv() { const dir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-gateway-lock-")); diff --git a/src/infra/gateway-lock.ts b/src/infra/gateway-lock.ts index aec746a2d44..ef89f42a101 100644 --- a/src/infra/gateway-lock.ts +++ b/src/infra/gateway-lock.ts @@ -1,8 +1,7 @@ import { createHash } from "node:crypto"; -import fs from "node:fs/promises"; import fsSync from "node:fs"; +import fs from "node:fs/promises"; import path from "node:path"; - import { resolveConfigPath, resolveGatewayLockDir, resolveStateDir } from "../config/paths.js"; const DEFAULT_TIMEOUT_MS = 5000; diff --git a/src/infra/heartbeat-runner.respects-ackmaxchars-heartbeat-acks.test.ts b/src/infra/heartbeat-runner.respects-ackmaxchars-heartbeat-acks.test.ts index 773cc5342c4..88c6b98e8ea 100644 --- a/src/infra/heartbeat-runner.respects-ackmaxchars-heartbeat-acks.test.ts +++ b/src/infra/heartbeat-runner.respects-ackmaxchars-heartbeat-acks.test.ts @@ -2,17 +2,17 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { beforeEach, describe, expect, it, vi } from "vitest"; -import * as replyModule from "../auto-reply/reply.js"; import type { OpenClawConfig } from "../config/config.js"; +import { telegramPlugin } from "../../extensions/telegram/src/channel.js"; +import { setTelegramRuntime } from "../../extensions/telegram/src/runtime.js"; +import { whatsappPlugin } from "../../extensions/whatsapp/src/channel.js"; +import { setWhatsAppRuntime } from "../../extensions/whatsapp/src/runtime.js"; +import * as replyModule from "../auto-reply/reply.js"; import { resolveMainSessionKey } from "../config/sessions.js"; -import { runHeartbeatOnce } from "./heartbeat-runner.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import { createPluginRuntime } from "../plugins/runtime/index.js"; import { createTestRegistry } from "../test-utils/channel-plugins.js"; -import { telegramPlugin } from "../../extensions/telegram/src/channel.js"; -import { whatsappPlugin } from "../../extensions/whatsapp/src/channel.js"; -import { setTelegramRuntime } from "../../extensions/telegram/src/runtime.js"; -import { setWhatsAppRuntime } from "../../extensions/whatsapp/src/runtime.js"; +import { runHeartbeatOnce } from "./heartbeat-runner.js"; // Avoid pulling optional runtime deps during isolated runs. vi.mock("jiti", () => ({ createJiti: () => () => ({}) })); diff --git a/src/infra/heartbeat-runner.returns-default-unset.test.ts b/src/infra/heartbeat-runner.returns-default-unset.test.ts index 5c52332b03d..a43ff683404 100644 --- a/src/infra/heartbeat-runner.returns-default-unset.test.ts +++ b/src/infra/heartbeat-runner.returns-default-unset.test.ts @@ -2,16 +2,23 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { beforeEach, describe, expect, it, vi } from "vitest"; +import type { OpenClawConfig } from "../config/config.js"; +import { telegramPlugin } from "../../extensions/telegram/src/channel.js"; +import { setTelegramRuntime } from "../../extensions/telegram/src/runtime.js"; +import { whatsappPlugin } from "../../extensions/whatsapp/src/channel.js"; +import { setWhatsAppRuntime } from "../../extensions/whatsapp/src/runtime.js"; import { HEARTBEAT_PROMPT } from "../auto-reply/heartbeat.js"; import * as replyModule from "../auto-reply/reply.js"; -import type { OpenClawConfig } from "../config/config.js"; import { resolveAgentIdFromSessionKey, resolveAgentMainSessionKey, resolveMainSessionKey, resolveStorePath, } from "../config/sessions.js"; +import { setActivePluginRegistry } from "../plugins/runtime.js"; +import { createPluginRuntime } from "../plugins/runtime/index.js"; import { buildAgentPeerSessionKey } from "../routing/session-key.js"; +import { createTestRegistry } from "../test-utils/channel-plugins.js"; import { isHeartbeatEnabledForAgent, resolveHeartbeatIntervalMs, @@ -19,13 +26,6 @@ import { runHeartbeatOnce, } from "./heartbeat-runner.js"; import { resolveHeartbeatDeliveryTarget } from "./outbound/targets.js"; -import { setActivePluginRegistry } from "../plugins/runtime.js"; -import { createPluginRuntime } from "../plugins/runtime/index.js"; -import { createTestRegistry } from "../test-utils/channel-plugins.js"; -import { telegramPlugin } from "../../extensions/telegram/src/channel.js"; -import { whatsappPlugin } from "../../extensions/whatsapp/src/channel.js"; -import { setTelegramRuntime } from "../../extensions/telegram/src/runtime.js"; -import { setWhatsAppRuntime } from "../../extensions/whatsapp/src/runtime.js"; // Avoid pulling optional runtime deps during isolated runs. vi.mock("jiti", () => ({ createJiti: () => () => ({}) })); diff --git a/src/infra/heartbeat-runner.sender-prefers-delivery-target.test.ts b/src/infra/heartbeat-runner.sender-prefers-delivery-target.test.ts index d55bb712a8d..405d41877b8 100644 --- a/src/infra/heartbeat-runner.sender-prefers-delivery-target.test.ts +++ b/src/infra/heartbeat-runner.sender-prefers-delivery-target.test.ts @@ -2,19 +2,18 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { beforeEach, describe, expect, it, vi } from "vitest"; - -import * as replyModule from "../auto-reply/reply.js"; import type { OpenClawConfig } from "../config/config.js"; -import { resolveMainSessionKey } from "../config/sessions.js"; -import { setActivePluginRegistry } from "../plugins/runtime.js"; -import { createPluginRuntime } from "../plugins/runtime/index.js"; -import { createTestRegistry } from "../test-utils/channel-plugins.js"; import { slackPlugin } from "../../extensions/slack/src/channel.js"; import { setSlackRuntime } from "../../extensions/slack/src/runtime.js"; import { telegramPlugin } from "../../extensions/telegram/src/channel.js"; import { setTelegramRuntime } from "../../extensions/telegram/src/runtime.js"; import { whatsappPlugin } from "../../extensions/whatsapp/src/channel.js"; import { setWhatsAppRuntime } from "../../extensions/whatsapp/src/runtime.js"; +import * as replyModule from "../auto-reply/reply.js"; +import { resolveMainSessionKey } from "../config/sessions.js"; +import { setActivePluginRegistry } from "../plugins/runtime.js"; +import { createPluginRuntime } from "../plugins/runtime/index.js"; +import { createTestRegistry } from "../test-utils/channel-plugins.js"; import { runHeartbeatOnce } from "./heartbeat-runner.js"; // Avoid pulling optional runtime deps during isolated runs. diff --git a/src/infra/heartbeat-runner.ts b/src/infra/heartbeat-runner.ts index 754b05eeaa8..9b6b77aa51d 100644 --- a/src/infra/heartbeat-runner.ts +++ b/src/infra/heartbeat-runner.ts @@ -1,6 +1,10 @@ import fs from "node:fs/promises"; import path from "node:path"; - +import type { ReplyPayload } from "../auto-reply/types.js"; +import type { ChannelHeartbeatDeps } from "../channels/plugins/types.js"; +import type { OpenClawConfig } from "../config/config.js"; +import type { AgentDefaultsConfig } from "../config/types.agent-defaults.js"; +import type { OutboundSendDeps } from "./outbound/deliver.js"; import { resolveAgentConfig, resolveAgentWorkspaceDir, @@ -16,13 +20,10 @@ import { resolveHeartbeatPrompt as resolveHeartbeatPromptText, stripHeartbeatToken, } from "../auto-reply/heartbeat.js"; -import { HEARTBEAT_TOKEN } from "../auto-reply/tokens.js"; import { getReplyFromConfig } from "../auto-reply/reply.js"; -import type { ReplyPayload } from "../auto-reply/types.js"; +import { HEARTBEAT_TOKEN } from "../auto-reply/tokens.js"; import { getChannelPlugin } from "../channels/plugins/index.js"; -import type { ChannelHeartbeatDeps } from "../channels/plugins/types.js"; import { parseDurationMs } from "../cli/parse-duration.js"; -import type { OpenClawConfig } from "../config/config.js"; import { loadConfig } from "../config/config.js"; import { canonicalizeMainSessionAlias, @@ -33,14 +34,13 @@ import { saveSessionStore, updateSessionStore, } from "../config/sessions.js"; -import type { AgentDefaultsConfig } from "../config/types.agent-defaults.js"; import { formatErrorMessage } from "../infra/errors.js"; import { peekSystemEvents } from "../infra/system-events.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { getQueueSize } from "../process/command-queue.js"; import { CommandLane } from "../process/lanes.js"; -import { defaultRuntime, type RuntimeEnv } from "../runtime.js"; import { normalizeAgentId, toAgentStoreSessionKey } from "../routing/session-key.js"; +import { defaultRuntime, type RuntimeEnv } from "../runtime.js"; import { emitHeartbeatEvent, resolveIndicatorType } from "./heartbeat-events.js"; import { resolveHeartbeatVisibility } from "./heartbeat-visibility.js"; import { @@ -49,7 +49,6 @@ import { requestHeartbeatNow, setHeartbeatWakeHandler, } from "./heartbeat-wake.js"; -import type { OutboundSendDeps } from "./outbound/deliver.js"; import { deliverOutboundPayloads } from "./outbound/deliver.js"; import { resolveHeartbeatDeliveryTarget, diff --git a/src/infra/is-main.test.ts b/src/infra/is-main.test.ts index 5a0eaaab04a..a94c2a8162a 100644 --- a/src/infra/is-main.test.ts +++ b/src/infra/is-main.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { isMainModule } from "./is-main.js"; describe("isMainModule", () => { diff --git a/src/infra/net/ssrf.pinning.test.ts b/src/infra/net/ssrf.pinning.test.ts index 954270e0c96..653996083e6 100644 --- a/src/infra/net/ssrf.pinning.test.ts +++ b/src/infra/net/ssrf.pinning.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { createPinnedLookup, resolvePinnedHostname } from "./ssrf.js"; describe("ssrf pinning", () => { diff --git a/src/infra/net/ssrf.ts b/src/infra/net/ssrf.ts index 49cb2e57c22..02611370678 100644 --- a/src/infra/net/ssrf.ts +++ b/src/infra/net/ssrf.ts @@ -1,5 +1,5 @@ -import { lookup as dnsLookup } from "node:dns/promises"; import { lookup as dnsLookupCb, type LookupAddress } from "node:dns"; +import { lookup as dnsLookup } from "node:dns/promises"; import { Agent, type Dispatcher } from "undici"; type LookupCallback = ( diff --git a/src/infra/node-shell.test.ts b/src/infra/node-shell.test.ts index 8f95a29a824..55683eaba89 100644 --- a/src/infra/node-shell.test.ts +++ b/src/infra/node-shell.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { buildNodeShellCommand } from "./node-shell.js"; describe("buildNodeShellCommand", () => { diff --git a/src/infra/outbound/agent-delivery.ts b/src/infra/outbound/agent-delivery.ts index 4091e61bc2c..c2398943d8b 100644 --- a/src/infra/outbound/agent-delivery.ts +++ b/src/infra/outbound/agent-delivery.ts @@ -1,6 +1,8 @@ -import { DEFAULT_CHAT_CHANNEL } from "../../channels/registry.js"; import type { ChannelOutboundTargetMode } from "../../channels/plugins/types.js"; +import type { OpenClawConfig } from "../../config/config.js"; import type { SessionEntry } from "../../config/sessions.js"; +import type { OutboundTargetResolution } from "./targets.js"; +import { DEFAULT_CHAT_CHANNEL } from "../../channels/registry.js"; import { normalizeAccountId } from "../../utils/account-id.js"; import { INTERNAL_MESSAGE_CHANNEL, @@ -14,8 +16,6 @@ import { resolveSessionDeliveryTarget, type SessionDeliveryTarget, } from "./targets.js"; -import type { OpenClawConfig } from "../../config/config.js"; -import type { OutboundTargetResolution } from "./targets.js"; export type AgentDeliveryPlan = { baseDelivery: SessionDeliveryTarget; diff --git a/src/infra/outbound/channel-selection.ts b/src/infra/outbound/channel-selection.ts index a8ba2b699ea..6ef5d161715 100644 --- a/src/infra/outbound/channel-selection.ts +++ b/src/infra/outbound/channel-selection.ts @@ -1,6 +1,6 @@ -import { listChannelPlugins } from "../../channels/plugins/index.js"; import type { ChannelPlugin } from "../../channels/plugins/types.js"; import type { OpenClawConfig } from "../../config/config.js"; +import { listChannelPlugins } from "../../channels/plugins/index.js"; import { listDeliverableMessageChannels, type DeliverableMessageChannel, diff --git a/src/infra/outbound/deliver.test.ts b/src/infra/outbound/deliver.test.ts index abae530bb5e..417e037f034 100644 --- a/src/infra/outbound/deliver.test.ts +++ b/src/infra/outbound/deliver.test.ts @@ -1,11 +1,10 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import { signalOutbound } from "../../channels/plugins/outbound/signal.js"; import { telegramOutbound } from "../../channels/plugins/outbound/telegram.js"; import { whatsappOutbound } from "../../channels/plugins/outbound/whatsapp.js"; -import { markdownToSignalTextChunks } from "../../signal/format.js"; import { setActivePluginRegistry } from "../../plugins/runtime.js"; +import { markdownToSignalTextChunks } from "../../signal/format.js"; import { createIMessageTestPlugin, createOutboundTestPlugin, diff --git a/src/infra/outbound/deliver.ts b/src/infra/outbound/deliver.ts index ca3b5fd6a90..de7931a6492 100644 --- a/src/infra/outbound/deliver.ts +++ b/src/infra/outbound/deliver.ts @@ -1,29 +1,29 @@ +import type { ReplyPayload } from "../../auto-reply/types.js"; +import type { ChannelOutboundAdapter } from "../../channels/plugins/types.js"; +import type { OpenClawConfig } from "../../config/config.js"; +import type { sendMessageDiscord } from "../../discord/send.js"; +import type { sendMessageIMessage } from "../../imessage/send.js"; +import type { sendMessageSlack } from "../../slack/send.js"; +import type { sendMessageTelegram } from "../../telegram/send.js"; +import type { sendMessageWhatsApp } from "../../web/outbound.js"; +import type { NormalizedOutboundPayload } from "./payloads.js"; +import type { OutboundChannel } from "./targets.js"; import { chunkByParagraph, chunkMarkdownTextWithMode, resolveChunkMode, resolveTextChunkLimit, } from "../../auto-reply/chunk.js"; -import type { ReplyPayload } from "../../auto-reply/types.js"; import { resolveChannelMediaMaxBytes } from "../../channels/plugins/media-limits.js"; import { loadChannelOutboundAdapter } from "../../channels/plugins/outbound/load.js"; -import type { ChannelOutboundAdapter } from "../../channels/plugins/types.js"; -import type { OpenClawConfig } from "../../config/config.js"; import { resolveMarkdownTableMode } from "../../config/markdown-tables.js"; -import type { sendMessageDiscord } from "../../discord/send.js"; -import type { sendMessageIMessage } from "../../imessage/send.js"; -import { markdownToSignalTextChunks, type SignalTextStyleRange } from "../../signal/format.js"; -import { sendMessageSignal } from "../../signal/send.js"; -import type { sendMessageSlack } from "../../slack/send.js"; -import type { sendMessageTelegram } from "../../telegram/send.js"; -import type { sendMessageWhatsApp } from "../../web/outbound.js"; import { appendAssistantMessageToSessionTranscript, resolveMirroredTranscriptText, } from "../../config/sessions.js"; -import type { NormalizedOutboundPayload } from "./payloads.js"; +import { markdownToSignalTextChunks, type SignalTextStyleRange } from "../../signal/format.js"; +import { sendMessageSignal } from "../../signal/send.js"; import { normalizeReplyPayloadsForDelivery } from "./payloads.js"; -import type { OutboundChannel } from "./targets.js"; export type { NormalizedOutboundPayload } from "./payloads.js"; export { normalizeOutboundPayloads } from "./payloads.js"; diff --git a/src/infra/outbound/envelope.test.ts b/src/infra/outbound/envelope.test.ts index e0e6a928f56..71effdee808 100644 --- a/src/infra/outbound/envelope.test.ts +++ b/src/infra/outbound/envelope.test.ts @@ -1,7 +1,6 @@ import { describe, expect, it } from "vitest"; - -import { buildOutboundResultEnvelope } from "./envelope.js"; import type { OutboundDeliveryJson } from "./format.js"; +import { buildOutboundResultEnvelope } from "./envelope.js"; describe("buildOutboundResultEnvelope", () => { it("flattens delivery-only payloads by default", () => { diff --git a/src/infra/outbound/format.test.ts b/src/infra/outbound/format.test.ts index e9133014334..950bb3e5fd1 100644 --- a/src/infra/outbound/format.test.ts +++ b/src/infra/outbound/format.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { buildOutboundDeliveryJson, formatGatewaySummary, diff --git a/src/infra/outbound/format.ts b/src/infra/outbound/format.ts index d74f5939a6a..4772ee91725 100644 --- a/src/infra/outbound/format.ts +++ b/src/infra/outbound/format.ts @@ -1,7 +1,7 @@ -import { getChannelPlugin } from "../../channels/plugins/index.js"; -import { getChatChannelMeta, normalizeChatChannelId } from "../../channels/registry.js"; import type { ChannelId } from "../../channels/plugins/types.js"; import type { OutboundDeliveryResult } from "./deliver.js"; +import { getChannelPlugin } from "../../channels/plugins/index.js"; +import { getChatChannelMeta, normalizeChatChannelId } from "../../channels/registry.js"; export type OutboundDeliveryJson = { channel: string; diff --git a/src/infra/outbound/message-action-runner.test.ts b/src/infra/outbound/message-action-runner.test.ts index 6445292f6a7..ed432b07047 100644 --- a/src/infra/outbound/message-action-runner.test.ts +++ b/src/infra/outbound/message-action-runner.test.ts @@ -1,15 +1,14 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - +import type { ChannelPlugin } from "../../channels/plugins/types.js"; import type { OpenClawConfig } from "../../config/config.js"; -import { setActivePluginRegistry } from "../../plugins/runtime.js"; -import { createIMessageTestPlugin, createTestRegistry } from "../../test-utils/channel-plugins.js"; import { slackPlugin } from "../../../extensions/slack/src/channel.js"; import { telegramPlugin } from "../../../extensions/telegram/src/channel.js"; import { whatsappPlugin } from "../../../extensions/whatsapp/src/channel.js"; +import { jsonResult } from "../../agents/tools/common.js"; +import { setActivePluginRegistry } from "../../plugins/runtime.js"; +import { createIMessageTestPlugin, createTestRegistry } from "../../test-utils/channel-plugins.js"; import { loadWebMedia } from "../../web/media.js"; import { runMessageAction } from "./message-action-runner.js"; -import { jsonResult } from "../../agents/tools/common.js"; -import type { ChannelPlugin } from "../../channels/plugins/types.js"; vi.mock("../../web/media.js", async () => { const actual = await vi.importActual("../../web/media.js"); diff --git a/src/infra/outbound/message-action-runner.threading.test.ts b/src/infra/outbound/message-action-runner.threading.test.ts index 0a6ca44e9ef..b467823ddcf 100644 --- a/src/infra/outbound/message-action-runner.threading.test.ts +++ b/src/infra/outbound/message-action-runner.threading.test.ts @@ -1,9 +1,8 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; +import { slackPlugin } from "../../../extensions/slack/src/channel.js"; import { setActivePluginRegistry } from "../../plugins/runtime.js"; import { createTestRegistry } from "../../test-utils/channel-plugins.js"; -import { slackPlugin } from "../../../extensions/slack/src/channel.js"; const mocks = vi.hoisted(() => ({ executeSendAction: vi.fn(), diff --git a/src/infra/outbound/message-action-runner.ts b/src/infra/outbound/message-action-runner.ts index 16718adf475..e19ae852881 100644 --- a/src/infra/outbound/message-action-runner.ts +++ b/src/infra/outbound/message-action-runner.ts @@ -1,35 +1,37 @@ +import type { AgentToolResult } from "@mariozechner/pi-agent-core"; import path from "node:path"; import { fileURLToPath } from "node:url"; - -import type { AgentToolResult } from "@mariozechner/pi-agent-core"; -import { - readNumberParam, - readStringArrayParam, - readStringParam, -} from "../../agents/tools/common.js"; -import { resolveSessionAgentId } from "../../agents/agent-scope.js"; -import { parseReplyDirectives } from "../../auto-reply/reply/reply-directives.js"; -import { dispatchChannelMessageAction } from "../../channels/plugins/message-actions.js"; import type { ChannelId, ChannelMessageActionName, ChannelThreadingToolContext, } from "../../channels/plugins/types.js"; import type { OpenClawConfig } from "../../config/config.js"; +import type { OutboundSendDeps } from "./deliver.js"; +import type { MessagePollResult, MessageSendResult } from "./message.js"; +import { resolveSessionAgentId } from "../../agents/agent-scope.js"; +import { + readNumberParam, + readStringArrayParam, + readStringParam, +} from "../../agents/tools/common.js"; +import { parseReplyDirectives } from "../../auto-reply/reply/reply-directives.js"; +import { dispatchChannelMessageAction } from "../../channels/plugins/message-actions.js"; +import { extensionForMime } from "../../media/mime.js"; +import { parseSlackTarget } from "../../slack/targets.js"; import { isDeliverableMessageChannel, normalizeMessageChannel, type GatewayClientMode, type GatewayClientName, } from "../../utils/message-channel.js"; +import { loadWebMedia } from "../../web/media.js"; import { listConfiguredMessageChannels, resolveMessageChannelSelection, } from "./channel-selection.js"; import { applyTargetToParams } from "./channel-target.js"; -import { ensureOutboundSessionEntry, resolveOutboundSessionRoute } from "./outbound-session.js"; -import type { OutboundSendDeps } from "./deliver.js"; -import type { MessagePollResult, MessageSendResult } from "./message.js"; +import { actionHasTarget, actionRequiresTarget } from "./message-action-spec.js"; import { applyCrossContextDecoration, buildCrossContextDecoration, @@ -38,11 +40,8 @@ import { shouldApplyCrossContextMarker, } from "./outbound-policy.js"; import { executePollAction, executeSendAction } from "./outbound-send-service.js"; -import { actionHasTarget, actionRequiresTarget } from "./message-action-spec.js"; +import { ensureOutboundSessionEntry, resolveOutboundSessionRoute } from "./outbound-session.js"; import { resolveChannelTarget, type ResolvedMessagingTarget } from "./target-resolver.js"; -import { loadWebMedia } from "../../web/media.js"; -import { extensionForMime } from "../../media/mime.js"; -import { parseSlackTarget } from "../../slack/targets.js"; export type MessageActionRunnerGateway = { url?: string; diff --git a/src/infra/outbound/message.test.ts b/src/infra/outbound/message.test.ts index eebd53d974b..9bd8f0d1b71 100644 --- a/src/infra/outbound/message.test.ts +++ b/src/infra/outbound/message.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import type { ChannelOutboundAdapter, ChannelPlugin } from "../../channels/plugins/types.js"; import { createIMessageTestPlugin, createTestRegistry } from "../../test-utils/channel-plugins.js"; const loadMessage = async () => await import("./message.js"); diff --git a/src/infra/outbound/message.ts b/src/infra/outbound/message.ts index 3175d251cea..1efcf601deb 100644 --- a/src/infra/outbound/message.ts +++ b/src/infra/outbound/message.ts @@ -1,8 +1,8 @@ -import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js"; import type { OpenClawConfig } from "../../config/config.js"; +import type { PollInput } from "../../polls.js"; +import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js"; import { loadConfig } from "../../config/config.js"; import { callGateway, randomIdempotencyKey } from "../../gateway/call.js"; -import type { PollInput } from "../../polls.js"; import { normalizePollInput } from "../../polls.js"; import { GATEWAY_CLIENT_MODES, diff --git a/src/infra/outbound/outbound-policy.test.ts b/src/infra/outbound/outbound-policy.test.ts index 9d47a79262c..8cac1f8c391 100644 --- a/src/infra/outbound/outbound-policy.test.ts +++ b/src/infra/outbound/outbound-policy.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import { applyCrossContextDecoration, diff --git a/src/infra/outbound/outbound-policy.ts b/src/infra/outbound/outbound-policy.ts index d6d3e4c894a..809c523dcf5 100644 --- a/src/infra/outbound/outbound-policy.ts +++ b/src/infra/outbound/outbound-policy.ts @@ -1,4 +1,3 @@ -import { normalizeTargetForProvider } from "./target-normalization.js"; import type { ChannelId, ChannelMessageActionName, @@ -6,6 +5,7 @@ import type { } from "../../channels/plugins/types.js"; import type { OpenClawConfig } from "../../config/config.js"; import { getChannelMessageAdapter } from "./channel-adapters.js"; +import { normalizeTargetForProvider } from "./target-normalization.js"; import { formatTargetDisplay, lookupDirectoryDisplay } from "./target-resolver.js"; export type CrossContextDecoration = { diff --git a/src/infra/outbound/outbound-send-service.ts b/src/infra/outbound/outbound-send-service.ts index 650eb629790..cc9cb9476b8 100644 --- a/src/infra/outbound/outbound-send-service.ts +++ b/src/infra/outbound/outbound-send-service.ts @@ -1,11 +1,11 @@ import type { AgentToolResult } from "@mariozechner/pi-agent-core"; -import { dispatchChannelMessageAction } from "../../channels/plugins/message-actions.js"; import type { ChannelId, ChannelThreadingToolContext } from "../../channels/plugins/types.js"; import type { OpenClawConfig } from "../../config/config.js"; -import { appendAssistantMessageToSessionTranscript } from "../../config/sessions.js"; import type { GatewayClientMode, GatewayClientName } from "../../utils/message-channel.js"; import type { OutboundSendDeps } from "./deliver.js"; import type { MessagePollResult, MessageSendResult } from "./message.js"; +import { dispatchChannelMessageAction } from "../../channels/plugins/message-actions.js"; +import { appendAssistantMessageToSessionTranscript } from "../../config/sessions.js"; import { sendMessage, sendPoll } from "./message.js"; export type OutboundGatewayContext = { diff --git a/src/infra/outbound/outbound-session.test.ts b/src/infra/outbound/outbound-session.test.ts index b06864d2c2f..944dbf8692a 100644 --- a/src/infra/outbound/outbound-session.test.ts +++ b/src/infra/outbound/outbound-session.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import { resolveOutboundSessionRoute } from "./outbound-session.js"; diff --git a/src/infra/outbound/outbound-session.ts b/src/infra/outbound/outbound-session.ts index cd58048351e..c31b18aca52 100644 --- a/src/infra/outbound/outbound-session.ts +++ b/src/infra/outbound/outbound-session.ts @@ -1,7 +1,8 @@ import type { MsgContext } from "../../auto-reply/templating.js"; -import { getChannelPlugin } from "../../channels/plugins/index.js"; import type { ChannelId } from "../../channels/plugins/types.js"; import type { OpenClawConfig } from "../../config/config.js"; +import type { ResolvedMessagingTarget } from "./target-resolver.js"; +import { getChannelPlugin } from "../../channels/plugins/index.js"; import { recordSessionMetaFromInbound, resolveStorePath } from "../../config/sessions.js"; import { parseDiscordTarget } from "../../discord/targets.js"; import { parseIMessageTarget, normalizeIMessageHandle } from "../../imessage/targets.js"; @@ -11,20 +12,19 @@ import { type RoutePeerKind, } from "../../routing/resolve-route.js"; import { resolveThreadSessionKeys } from "../../routing/session-key.js"; -import { resolveSlackAccount } from "../../slack/accounts.js"; -import { createSlackWebClient } from "../../slack/client.js"; -import { normalizeAllowListLower } from "../../slack/monitor/allow-list.js"; import { resolveSignalPeerId, resolveSignalRecipient, resolveSignalSender, } from "../../signal/identity.js"; +import { resolveSlackAccount } from "../../slack/accounts.js"; +import { createSlackWebClient } from "../../slack/client.js"; +import { normalizeAllowListLower } from "../../slack/monitor/allow-list.js"; import { parseSlackTarget } from "../../slack/targets.js"; import { buildTelegramGroupPeerId } from "../../telegram/bot/helpers.js"; import { resolveTelegramTargetChatType } from "../../telegram/inline-buttons.js"; import { parseTelegramTarget } from "../../telegram/targets.js"; import { isWhatsAppGroupJid, normalizeWhatsAppTarget } from "../../whatsapp/normalize.js"; -import type { ResolvedMessagingTarget } from "./target-resolver.js"; export type OutboundSessionRoute = { sessionKey: string; diff --git a/src/infra/outbound/payloads.test.ts b/src/infra/outbound/payloads.test.ts index 9165abed906..be3f66daf38 100644 --- a/src/infra/outbound/payloads.test.ts +++ b/src/infra/outbound/payloads.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { formatOutboundPayloadLog, normalizeOutboundPayloads, diff --git a/src/infra/outbound/payloads.ts b/src/infra/outbound/payloads.ts index 888f3624e1c..a44fdf2f1ab 100644 --- a/src/infra/outbound/payloads.ts +++ b/src/infra/outbound/payloads.ts @@ -1,6 +1,6 @@ +import type { ReplyPayload } from "../../auto-reply/types.js"; import { parseReplyDirectives } from "../../auto-reply/reply/reply-directives.js"; import { isRenderablePayload } from "../../auto-reply/reply/reply-payloads.js"; -import type { ReplyPayload } from "../../auto-reply/types.js"; export type NormalizedOutboundPayload = { text: string; diff --git a/src/infra/outbound/target-normalization.ts b/src/infra/outbound/target-normalization.ts index 9964ff90e97..5077404466a 100644 --- a/src/infra/outbound/target-normalization.ts +++ b/src/infra/outbound/target-normalization.ts @@ -1,5 +1,5 @@ -import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js"; import type { ChannelId } from "../../channels/plugins/types.js"; +import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js"; export function normalizeChannelTargetInput(raw: string): string { return raw.trim(); diff --git a/src/infra/outbound/target-resolver.test.ts b/src/infra/outbound/target-resolver.test.ts index 62e9ab84a53..3b9c37486d3 100644 --- a/src/infra/outbound/target-resolver.test.ts +++ b/src/infra/outbound/target-resolver.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { ChannelDirectoryEntry } from "../../channels/plugins/types.js"; import type { OpenClawConfig } from "../../config/config.js"; import { resetDirectoryCache, resolveMessagingTarget } from "./target-resolver.js"; diff --git a/src/infra/outbound/target-resolver.ts b/src/infra/outbound/target-resolver.ts index c8eb7de85be..d2bac1e9dd5 100644 --- a/src/infra/outbound/target-resolver.ts +++ b/src/infra/outbound/target-resolver.ts @@ -1,18 +1,18 @@ -import { getChannelPlugin } from "../../channels/plugins/index.js"; import type { ChannelDirectoryEntry, ChannelDirectoryEntryKind, ChannelId, } from "../../channels/plugins/types.js"; import type { OpenClawConfig } from "../../config/config.js"; +import { getChannelPlugin } from "../../channels/plugins/index.js"; import { defaultRuntime, type RuntimeEnv } from "../../runtime.js"; import { buildDirectoryCacheKey, DirectoryCache } from "./directory-cache.js"; +import { ambiguousTargetError, unknownTargetError } from "./target-errors.js"; import { buildTargetResolverSignature, normalizeChannelTargetInput, normalizeTargetForProvider, } from "./target-normalization.js"; -import { ambiguousTargetError, unknownTargetError } from "./target-errors.js"; export type TargetResolveKind = ChannelDirectoryEntryKind | "channel"; diff --git a/src/infra/outbound/targets.test.ts b/src/infra/outbound/targets.test.ts index 1040f0c65c3..a8b45af3138 100644 --- a/src/infra/outbound/targets.test.ts +++ b/src/infra/outbound/targets.test.ts @@ -1,10 +1,9 @@ import { beforeEach, describe, expect, it } from "vitest"; import type { OpenClawConfig } from "../../config/config.js"; - -import { setActivePluginRegistry } from "../../plugins/runtime.js"; -import { createTestRegistry } from "../../test-utils/channel-plugins.js"; import { telegramPlugin } from "../../../extensions/telegram/src/channel.js"; import { whatsappPlugin } from "../../../extensions/whatsapp/src/channel.js"; +import { setActivePluginRegistry } from "../../plugins/runtime.js"; +import { createTestRegistry } from "../../test-utils/channel-plugins.js"; import { resolveOutboundTarget, resolveSessionDeliveryTarget } from "./targets.js"; describe("resolveOutboundTarget", () => { diff --git a/src/infra/outbound/targets.ts b/src/infra/outbound/targets.ts index 8937896cf64..f2703e2b806 100644 --- a/src/infra/outbound/targets.ts +++ b/src/infra/outbound/targets.ts @@ -1,14 +1,14 @@ -import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js"; -import { formatCliCommand } from "../../cli/command-format.js"; import type { ChannelOutboundTargetMode } from "../../channels/plugins/types.js"; import type { OpenClawConfig } from "../../config/config.js"; import type { SessionEntry } from "../../config/sessions.js"; import type { AgentDefaultsConfig } from "../../config/types.agent-defaults.js"; -import { deliveryContextFromSession } from "../../utils/delivery-context.js"; import type { DeliverableMessageChannel, GatewayMessageChannel, } from "../../utils/message-channel.js"; +import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js"; +import { formatCliCommand } from "../../cli/command-format.js"; +import { deliveryContextFromSession } from "../../utils/delivery-context.js"; import { INTERNAL_MESSAGE_CHANNEL, isDeliverableMessageChannel, diff --git a/src/infra/path-env.test.ts b/src/infra/path-env.test.ts index c731389f8e1..49d577ce3e0 100644 --- a/src/infra/path-env.test.ts +++ b/src/infra/path-env.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import { ensureOpenClawCliOnPath } from "./path-env.js"; describe("ensureOpenClawCliOnPath", () => { diff --git a/src/infra/path-env.ts b/src/infra/path-env.ts index 469dca5da7c..dc7458789b1 100644 --- a/src/infra/path-env.ts +++ b/src/infra/path-env.ts @@ -1,9 +1,8 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; -import { isTruthyEnvValue } from "./env.js"; - import { resolveBrewPathDirs } from "./brew.js"; +import { isTruthyEnvValue } from "./env.js"; type EnsureOpenClawPathOpts = { execPath?: string; diff --git a/src/infra/ports-format.ts b/src/infra/ports-format.ts index d8c45dfe27a..54fb75b66ca 100644 --- a/src/infra/ports-format.ts +++ b/src/infra/ports-format.ts @@ -1,5 +1,5 @@ -import { formatCliCommand } from "../cli/command-format.js"; import type { PortListener, PortListenerKind, PortUsage } from "./ports-types.js"; +import { formatCliCommand } from "../cli/command-format.js"; export function classifyPortListener(listener: PortListener, port: number): PortListenerKind { const raw = `${listener.commandLine ?? ""} ${listener.command ?? ""}`.trim().toLowerCase(); diff --git a/src/infra/ports-inspect.ts b/src/infra/ports-inspect.ts index 4daf1c0cd45..970a1c11cea 100644 --- a/src/infra/ports-inspect.ts +++ b/src/infra/ports-inspect.ts @@ -1,8 +1,8 @@ import net from "node:net"; -import { runCommandWithTimeout } from "../process/exec.js"; -import { resolveLsofCommand } from "./ports-lsof.js"; -import { buildPortHints } from "./ports-format.js"; import type { PortListener, PortUsage, PortUsageStatus } from "./ports-types.js"; +import { runCommandWithTimeout } from "../process/exec.js"; +import { buildPortHints } from "./ports-format.js"; +import { resolveLsofCommand } from "./ports-lsof.js"; type CommandResult = { stdout: string; diff --git a/src/infra/ports.test.ts b/src/infra/ports.test.ts index 9a70d049e01..96a9294a4be 100644 --- a/src/infra/ports.test.ts +++ b/src/infra/ports.test.ts @@ -1,6 +1,5 @@ import net from "node:net"; import { describe, expect, it, vi } from "vitest"; - import { buildPortHints, classifyPortListener, diff --git a/src/infra/ports.ts b/src/infra/ports.ts index 697b74325f7..cdbc395fe53 100644 --- a/src/infra/ports.ts +++ b/src/infra/ports.ts @@ -1,11 +1,11 @@ import net from "node:net"; +import type { RuntimeEnv } from "../runtime.js"; +import type { PortListener, PortListenerKind, PortUsage, PortUsageStatus } from "./ports-types.js"; import { danger, info, shouldLogVerbose, warn } from "../globals.js"; import { logDebug } from "../logger.js"; -import type { RuntimeEnv } from "../runtime.js"; import { defaultRuntime } from "../runtime.js"; import { formatPortDiagnostics } from "./ports-format.js"; import { inspectPortUsage } from "./ports-inspect.js"; -import type { PortListener, PortListenerKind, PortUsage, PortUsageStatus } from "./ports-types.js"; class PortInUseError extends Error { port: number; diff --git a/src/infra/provider-usage.auth.ts b/src/infra/provider-usage.auth.ts index 53479f563de..6be3753d8b8 100644 --- a/src/infra/provider-usage.auth.ts +++ b/src/infra/provider-usage.auth.ts @@ -1,7 +1,7 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - +import type { UsageProviderId } from "./provider-usage.types.js"; import { ensureAuthProfileStore, listProfilesForProvider, @@ -11,7 +11,6 @@ import { import { getCustomProviderApiKey, resolveEnvApiKey } from "../agents/model-auth.js"; import { normalizeProviderId } from "../agents/model-selection.js"; import { loadConfig } from "../config/config.js"; -import type { UsageProviderId } from "./provider-usage.types.js"; export type ProviderAuth = { provider: UsageProviderId; diff --git a/src/infra/provider-usage.fetch.antigravity.ts b/src/infra/provider-usage.fetch.antigravity.ts index fe4fd9de10a..e739458c943 100644 --- a/src/infra/provider-usage.fetch.antigravity.ts +++ b/src/infra/provider-usage.fetch.antigravity.ts @@ -1,7 +1,7 @@ +import type { ProviderUsageSnapshot, UsageWindow } from "./provider-usage.types.js"; import { logDebug } from "../logger.js"; import { fetchJson } from "./provider-usage.fetch.shared.js"; import { clampPercent, PROVIDER_LABELS } from "./provider-usage.shared.js"; -import type { ProviderUsageSnapshot, UsageWindow } from "./provider-usage.types.js"; type LoadCodeAssistResponse = { availablePromptCredits?: number | string; diff --git a/src/infra/provider-usage.fetch.claude.ts b/src/infra/provider-usage.fetch.claude.ts index 9093bc6ef9b..e0d0b67e43f 100644 --- a/src/infra/provider-usage.fetch.claude.ts +++ b/src/infra/provider-usage.fetch.claude.ts @@ -1,6 +1,6 @@ +import type { ProviderUsageSnapshot, UsageWindow } from "./provider-usage.types.js"; import { fetchJson } from "./provider-usage.fetch.shared.js"; import { clampPercent, PROVIDER_LABELS } from "./provider-usage.shared.js"; -import type { ProviderUsageSnapshot, UsageWindow } from "./provider-usage.types.js"; type ClaudeUsageResponse = { five_hour?: { utilization?: number; resets_at?: string }; diff --git a/src/infra/provider-usage.fetch.codex.ts b/src/infra/provider-usage.fetch.codex.ts index 6078c95e136..fa433586a26 100644 --- a/src/infra/provider-usage.fetch.codex.ts +++ b/src/infra/provider-usage.fetch.codex.ts @@ -1,6 +1,6 @@ +import type { ProviderUsageSnapshot, UsageWindow } from "./provider-usage.types.js"; import { fetchJson } from "./provider-usage.fetch.shared.js"; import { clampPercent, PROVIDER_LABELS } from "./provider-usage.shared.js"; -import type { ProviderUsageSnapshot, UsageWindow } from "./provider-usage.types.js"; type CodexUsageResponse = { rate_limit?: { diff --git a/src/infra/provider-usage.fetch.copilot.ts b/src/infra/provider-usage.fetch.copilot.ts index 3782982aa20..bcdd9a43170 100644 --- a/src/infra/provider-usage.fetch.copilot.ts +++ b/src/infra/provider-usage.fetch.copilot.ts @@ -1,6 +1,6 @@ +import type { ProviderUsageSnapshot, UsageWindow } from "./provider-usage.types.js"; import { fetchJson } from "./provider-usage.fetch.shared.js"; import { clampPercent, PROVIDER_LABELS } from "./provider-usage.shared.js"; -import type { ProviderUsageSnapshot, UsageWindow } from "./provider-usage.types.js"; type CopilotUsageResponse = { quota_snapshots?: { diff --git a/src/infra/provider-usage.fetch.gemini.ts b/src/infra/provider-usage.fetch.gemini.ts index 39a5806417e..7ec96651da8 100644 --- a/src/infra/provider-usage.fetch.gemini.ts +++ b/src/infra/provider-usage.fetch.gemini.ts @@ -1,10 +1,10 @@ -import { fetchJson } from "./provider-usage.fetch.shared.js"; -import { clampPercent, PROVIDER_LABELS } from "./provider-usage.shared.js"; import type { ProviderUsageSnapshot, UsageProviderId, UsageWindow, } from "./provider-usage.types.js"; +import { fetchJson } from "./provider-usage.fetch.shared.js"; +import { clampPercent, PROVIDER_LABELS } from "./provider-usage.shared.js"; type GeminiUsageResponse = { buckets?: Array<{ modelId?: string; remainingFraction?: number }>; diff --git a/src/infra/provider-usage.fetch.minimax.ts b/src/infra/provider-usage.fetch.minimax.ts index ffcd644ebe8..0ff4c680ec7 100644 --- a/src/infra/provider-usage.fetch.minimax.ts +++ b/src/infra/provider-usage.fetch.minimax.ts @@ -1,6 +1,6 @@ +import type { ProviderUsageSnapshot, UsageWindow } from "./provider-usage.types.js"; import { fetchJson } from "./provider-usage.fetch.shared.js"; import { clampPercent, PROVIDER_LABELS } from "./provider-usage.shared.js"; -import type { ProviderUsageSnapshot, UsageWindow } from "./provider-usage.types.js"; type MinimaxBaseResp = { status_code?: number; diff --git a/src/infra/provider-usage.fetch.zai.ts b/src/infra/provider-usage.fetch.zai.ts index 97a7a9a90ea..1a8fc2ea8fe 100644 --- a/src/infra/provider-usage.fetch.zai.ts +++ b/src/infra/provider-usage.fetch.zai.ts @@ -1,6 +1,6 @@ +import type { ProviderUsageSnapshot, UsageWindow } from "./provider-usage.types.js"; import { fetchJson } from "./provider-usage.fetch.shared.js"; import { clampPercent, PROVIDER_LABELS } from "./provider-usage.shared.js"; -import type { ProviderUsageSnapshot, UsageWindow } from "./provider-usage.types.js"; type ZaiUsageResponse = { success?: boolean; diff --git a/src/infra/provider-usage.format.ts b/src/infra/provider-usage.format.ts index 3b02828f499..7733d81210c 100644 --- a/src/infra/provider-usage.format.ts +++ b/src/infra/provider-usage.format.ts @@ -1,5 +1,5 @@ -import { clampPercent } from "./provider-usage.shared.js"; import type { ProviderUsageSnapshot, UsageSummary, UsageWindow } from "./provider-usage.types.js"; +import { clampPercent } from "./provider-usage.shared.js"; function formatResetRemaining(targetMs?: number, now?: number): string | null { if (!targetMs) { diff --git a/src/infra/provider-usage.load.ts b/src/infra/provider-usage.load.ts index 519b67c0c4c..ea3a5b4348a 100644 --- a/src/infra/provider-usage.load.ts +++ b/src/infra/provider-usage.load.ts @@ -1,3 +1,9 @@ +import type { + ProviderUsageSnapshot, + UsageProviderId, + UsageSummary, +} from "./provider-usage.types.js"; +import { resolveFetch } from "./fetch.js"; import { type ProviderAuth, resolveProviderAuths } from "./provider-usage.auth.js"; import { fetchAntigravityUsage, @@ -15,12 +21,6 @@ import { usageProviders, withTimeout, } from "./provider-usage.shared.js"; -import type { - ProviderUsageSnapshot, - UsageProviderId, - UsageSummary, -} from "./provider-usage.types.js"; -import { resolveFetch } from "./fetch.js"; type UsageSummaryOptions = { now?: number; diff --git a/src/infra/provider-usage.shared.ts b/src/infra/provider-usage.shared.ts index 763eca4e8ae..2f66a7403f2 100644 --- a/src/infra/provider-usage.shared.ts +++ b/src/infra/provider-usage.shared.ts @@ -1,5 +1,5 @@ -import { normalizeProviderId } from "../agents/model-selection.js"; import type { UsageProviderId } from "./provider-usage.types.js"; +import { normalizeProviderId } from "../agents/model-selection.js"; export const DEFAULT_TIMEOUT_MS = 5000; diff --git a/src/infra/restart-sentinel.test.ts b/src/infra/restart-sentinel.test.ts index 50525f9ea4d..638d389f561 100644 --- a/src/infra/restart-sentinel.test.ts +++ b/src/infra/restart-sentinel.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it } from "vitest"; - import { consumeRestartSentinel, readRestartSentinel, diff --git a/src/infra/restart-sentinel.ts b/src/infra/restart-sentinel.ts index e62b4e58fed..1f3b13094f9 100644 --- a/src/infra/restart-sentinel.ts +++ b/src/infra/restart-sentinel.ts @@ -1,6 +1,5 @@ import fs from "node:fs/promises"; import path from "node:path"; - import { formatCliCommand } from "../cli/command-format.js"; import { resolveStateDir } from "../config/paths.js"; diff --git a/src/infra/restart.test.ts b/src/infra/restart.test.ts index 010f7123924..d9d09696e0b 100644 --- a/src/infra/restart.test.ts +++ b/src/infra/restart.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import { __testing, consumeGatewaySigusr1RestartAuthorization, diff --git a/src/infra/retry-policy.test.ts b/src/infra/retry-policy.test.ts index 02aedb08700..00962367ef3 100644 --- a/src/infra/retry-policy.test.ts +++ b/src/infra/retry-policy.test.ts @@ -1,5 +1,4 @@ import { afterEach, describe, expect, it, vi } from "vitest"; - import { createTelegramRetryRunner } from "./retry-policy.js"; describe("createTelegramRetryRunner", () => { diff --git a/src/infra/retry-policy.ts b/src/infra/retry-policy.ts index bdd1790a5c6..d0a23217925 100644 --- a/src/infra/retry-policy.ts +++ b/src/infra/retry-policy.ts @@ -1,5 +1,4 @@ import { RateLimitError } from "@buape/carbon"; - import { formatErrorMessage } from "./errors.js"; import { type RetryConfig, resolveRetryConfig, retryAsync } from "./retry.js"; diff --git a/src/infra/retry.test.ts b/src/infra/retry.test.ts index e5f450447c2..ed4b43feaae 100644 --- a/src/infra/retry.test.ts +++ b/src/infra/retry.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { retryAsync } from "./retry.js"; describe("retryAsync", () => { diff --git a/src/infra/runtime-guard.test.ts b/src/infra/runtime-guard.test.ts index 07bd429d14d..1e3d4ef223d 100644 --- a/src/infra/runtime-guard.test.ts +++ b/src/infra/runtime-guard.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { assertSupportedRuntime, detectRuntime, diff --git a/src/infra/runtime-guard.ts b/src/infra/runtime-guard.ts index c6bde581d7c..c15668ebf59 100644 --- a/src/infra/runtime-guard.ts +++ b/src/infra/runtime-guard.ts @@ -1,5 +1,4 @@ import process from "node:process"; - import { defaultRuntime, type RuntimeEnv } from "../runtime.js"; export type RuntimeKind = "node" | "unknown"; diff --git a/src/infra/session-cost-usage.test.ts b/src/infra/session-cost-usage.test.ts index 7da3e65e98d..bb598bcb76c 100644 --- a/src/infra/session-cost-usage.test.ts +++ b/src/infra/session-cost-usage.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { loadCostUsageSummary, loadSessionCostSummary } from "./session-cost-usage.js"; diff --git a/src/infra/session-cost-usage.ts b/src/infra/session-cost-usage.ts index 9d5fba2fdd2..3e592825a7a 100644 --- a/src/infra/session-cost-usage.ts +++ b/src/infra/session-cost-usage.ts @@ -1,11 +1,10 @@ import fs from "node:fs"; import path from "node:path"; import readline from "node:readline"; - import type { NormalizedUsage, UsageLike } from "../agents/usage.js"; -import { normalizeUsage } from "../agents/usage.js"; import type { OpenClawConfig } from "../config/config.js"; import type { SessionEntry } from "../config/sessions/types.js"; +import { normalizeUsage } from "../agents/usage.js"; import { resolveSessionFilePath, resolveSessionTranscriptsDirForAgent, diff --git a/src/infra/shell-env.path.test.ts b/src/infra/shell-env.path.test.ts index 5e584d89797..1ae19f0bea6 100644 --- a/src/infra/shell-env.path.test.ts +++ b/src/infra/shell-env.path.test.ts @@ -1,5 +1,4 @@ import { afterEach, describe, expect, it, vi } from "vitest"; - import { getShellPathFromLoginShell, resetShellPathCacheForTests } from "./shell-env.js"; describe("getShellPathFromLoginShell", () => { diff --git a/src/infra/shell-env.test.ts b/src/infra/shell-env.test.ts index 3dc48b77133..c2391fb9639 100644 --- a/src/infra/shell-env.test.ts +++ b/src/infra/shell-env.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { loadShellEnvFallback, resolveShellEnvFallbackTimeoutMs, diff --git a/src/infra/shell-env.ts b/src/infra/shell-env.ts index 1d9c778f461..7082db2ca21 100644 --- a/src/infra/shell-env.ts +++ b/src/infra/shell-env.ts @@ -1,5 +1,4 @@ import { execFileSync } from "node:child_process"; - import { isTruthyEnvValue } from "./env.js"; const DEFAULT_TIMEOUT_MS = 15_000; diff --git a/src/infra/skills-remote.ts b/src/infra/skills-remote.ts index 0e6d1009944..5854810d366 100644 --- a/src/infra/skills-remote.ts +++ b/src/infra/skills-remote.ts @@ -1,11 +1,11 @@ import type { SkillEligibilityContext, SkillEntry } from "../agents/skills.js"; -import { loadWorkspaceSkillEntries } from "../agents/skills.js"; -import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; import type { OpenClawConfig } from "../config/config.js"; -import { listNodePairing, updatePairedNodeMetadata } from "./node-pairing.js"; -import { createSubsystemLogger } from "../logging/subsystem.js"; -import { bumpSkillsSnapshotVersion } from "../agents/skills/refresh.js"; import type { NodeRegistry } from "../gateway/node-registry.js"; +import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; +import { loadWorkspaceSkillEntries } from "../agents/skills.js"; +import { bumpSkillsSnapshotVersion } from "../agents/skills/refresh.js"; +import { createSubsystemLogger } from "../logging/subsystem.js"; +import { listNodePairing, updatePairedNodeMetadata } from "./node-pairing.js"; type RemoteNodeRecord = { nodeId: string; diff --git a/src/infra/ssh-config.ts b/src/infra/ssh-config.ts index dd55ef635e4..fe3c26f01d2 100644 --- a/src/infra/ssh-config.ts +++ b/src/infra/ssh-config.ts @@ -1,5 +1,4 @@ import { spawn } from "node:child_process"; - import type { SshParsedTarget } from "./ssh-tunnel.js"; export type SshResolvedConfig = { diff --git a/src/infra/ssh-tunnel.test.ts b/src/infra/ssh-tunnel.test.ts index d31f25d1a5a..10aeb21a34c 100644 --- a/src/infra/ssh-tunnel.test.ts +++ b/src/infra/ssh-tunnel.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { parseSshTarget } from "./ssh-tunnel.js"; describe("parseSshTarget", () => { diff --git a/src/infra/ssh-tunnel.ts b/src/infra/ssh-tunnel.ts index 095af810608..a86169c8b6c 100644 --- a/src/infra/ssh-tunnel.ts +++ b/src/infra/ssh-tunnel.ts @@ -1,6 +1,5 @@ import { spawn } from "node:child_process"; import net from "node:net"; - import { ensurePortAvailable } from "./ports.js"; export type SshParsedTarget = { diff --git a/src/infra/state-migrations.fs.test.ts b/src/infra/state-migrations.fs.test.ts index d9e69924779..0fab215976e 100644 --- a/src/infra/state-migrations.fs.test.ts +++ b/src/infra/state-migrations.fs.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { describe, expect, it } from "vitest"; - import { readSessionStoreJson5 } from "./state-migrations.fs.js"; describe("state migrations fs", () => { diff --git a/src/infra/state-migrations.fs.ts b/src/infra/state-migrations.fs.ts index 73752dda683..1f105d8cdbd 100644 --- a/src/infra/state-migrations.fs.ts +++ b/src/infra/state-migrations.fs.ts @@ -1,6 +1,5 @@ -import fs from "node:fs"; - import JSON5 from "json5"; +import fs from "node:fs"; export type SessionEntryLike = { sessionId?: string; diff --git a/src/infra/state-migrations.ts b/src/infra/state-migrations.ts index fa7f1aecb1b..39e601fd317 100644 --- a/src/infra/state-migrations.ts +++ b/src/infra/state-migrations.ts @@ -1,18 +1,18 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - -import { resolveDefaultAgentId } from "../agents/agent-scope.js"; import type { OpenClawConfig } from "../config/config.js"; +import type { SessionEntry } from "../config/sessions.js"; +import type { SessionScope } from "../config/sessions/types.js"; +import { resolveDefaultAgentId } from "../agents/agent-scope.js"; import { resolveLegacyStateDirs, resolveNewStateDir, resolveOAuthDir, resolveStateDir, } from "../config/paths.js"; -import type { SessionEntry } from "../config/sessions.js"; -import type { SessionScope } from "../config/sessions/types.js"; import { saveSessionStore } from "../config/sessions.js"; +import { canonicalizeMainSessionAlias } from "../config/sessions/main-session.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { buildAgentMainSessionKey, @@ -20,7 +20,6 @@ import { DEFAULT_MAIN_KEY, normalizeAgentId, } from "../routing/session-key.js"; -import { canonicalizeMainSessionAlias } from "../config/sessions/main-session.js"; import { ensureDir, existsDir, diff --git a/src/infra/system-events.test.ts b/src/infra/system-events.test.ts index eb394a87fe5..03a39cd9e73 100644 --- a/src/infra/system-events.test.ts +++ b/src/infra/system-events.test.ts @@ -1,7 +1,6 @@ import { beforeEach, describe, expect, it } from "vitest"; - -import { prependSystemEvents } from "../auto-reply/reply/session-updates.js"; import type { OpenClawConfig } from "../config/config.js"; +import { prependSystemEvents } from "../auto-reply/reply/session-updates.js"; import { resolveMainSessionKey } from "../config/sessions.js"; import { enqueueSystemEvent, peekSystemEvents, resetSystemEventsForTest } from "./system-events.js"; diff --git a/src/infra/tailnet.test.ts b/src/infra/tailnet.test.ts index 1068d1098e9..15c18368f8c 100644 --- a/src/infra/tailnet.test.ts +++ b/src/infra/tailnet.test.ts @@ -1,7 +1,5 @@ import os from "node:os"; - import { describe, expect, it, vi } from "vitest"; - import { listTailnetAddresses } from "./tailnet.js"; describe("tailnet address detection", () => { diff --git a/src/infra/tailscale.test.ts b/src/infra/tailscale.test.ts index cc31c3ca9f5..0e30c1f729f 100644 --- a/src/infra/tailscale.test.ts +++ b/src/infra/tailscale.test.ts @@ -1,5 +1,4 @@ import { afterEach, describe, expect, it, vi } from "vitest"; - import * as tailscale from "./tailscale.js"; const { diff --git a/src/infra/tailscale.ts b/src/infra/tailscale.ts index ff6a070e66d..bf74306bfc0 100644 --- a/src/infra/tailscale.ts +++ b/src/infra/tailscale.ts @@ -1,10 +1,10 @@ import { existsSync } from "node:fs"; +import { formatCliCommand } from "../cli/command-format.js"; import { promptYesNo } from "../cli/prompt.js"; import { danger, info, logVerbose, shouldLogVerbose, warn } from "../globals.js"; import { runExec } from "../process/exec.js"; import { defaultRuntime, type RuntimeEnv } from "../runtime.js"; import { colorize, isRich, theme } from "../terminal/theme.js"; -import { formatCliCommand } from "../cli/command-format.js"; import { ensureBinary } from "./binaries.js"; function parsePossiblyNoisyJsonObject(stdout: string): Record { diff --git a/src/infra/tls/fingerprint.test.ts b/src/infra/tls/fingerprint.test.ts index f1412d7474e..7e0f99ec6da 100644 --- a/src/infra/tls/fingerprint.test.ts +++ b/src/infra/tls/fingerprint.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { normalizeFingerprint } from "./fingerprint.js"; describe("normalizeFingerprint", () => { diff --git a/src/infra/tls/gateway.ts b/src/infra/tls/gateway.ts index e7224968411..5e5d4eca7c6 100644 --- a/src/infra/tls/gateway.ts +++ b/src/infra/tls/gateway.ts @@ -4,7 +4,6 @@ import fs from "node:fs/promises"; import path from "node:path"; import tls from "node:tls"; import { promisify } from "node:util"; - import type { GatewayTlsConfig } from "../../config/types.gateway.js"; import { CONFIG_DIR, ensureDir, resolveUserPath, shortenHomeInString } from "../../utils.js"; import { normalizeFingerprint } from "./fingerprint.js"; diff --git a/src/infra/transport-ready.test.ts b/src/infra/transport-ready.test.ts index 66100a30a5b..3768908e001 100644 --- a/src/infra/transport-ready.test.ts +++ b/src/infra/transport-ready.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { waitForTransportReady } from "./transport-ready.js"; describe("waitForTransportReady", () => { diff --git a/src/infra/transport-ready.ts b/src/infra/transport-ready.ts index 42c1476c20c..6c1225079c9 100644 --- a/src/infra/transport-ready.ts +++ b/src/infra/transport-ready.ts @@ -1,5 +1,5 @@ -import { danger } from "../globals.js"; import type { RuntimeEnv } from "../runtime.js"; +import { danger } from "../globals.js"; import { sleepWithAbort } from "./backoff.js"; export type TransportReadyResult = { diff --git a/src/infra/unhandled-rejections.fatal-detection.test.ts b/src/infra/unhandled-rejections.fatal-detection.test.ts index e991c67c955..76cc2256820 100644 --- a/src/infra/unhandled-rejections.fatal-detection.test.ts +++ b/src/infra/unhandled-rejections.fatal-detection.test.ts @@ -1,6 +1,5 @@ -import { describe, it, expect, vi, beforeAll, afterAll, beforeEach, afterEach } from "vitest"; import process from "node:process"; - +import { describe, it, expect, vi, beforeAll, afterAll, beforeEach, afterEach } from "vitest"; import { installUnhandledRejectionHandler } from "./unhandled-rejections.js"; describe("installUnhandledRejectionHandler - fatal detection", () => { diff --git a/src/infra/unhandled-rejections.test.ts b/src/infra/unhandled-rejections.test.ts index 1ec144ba1a3..150e644ea42 100644 --- a/src/infra/unhandled-rejections.test.ts +++ b/src/infra/unhandled-rejections.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { isAbortError, isTransientNetworkError } from "./unhandled-rejections.js"; describe("isAbortError", () => { diff --git a/src/infra/unhandled-rejections.ts b/src/infra/unhandled-rejections.ts index c60da1ff548..c2e8d935cfd 100644 --- a/src/infra/unhandled-rejections.ts +++ b/src/infra/unhandled-rejections.ts @@ -1,5 +1,4 @@ import process from "node:process"; - import { extractErrorCode, formatUncaughtError } from "./errors.js"; type UnhandledRejectionHandler = (reason: unknown) => boolean; diff --git a/src/infra/update-check.test.ts b/src/infra/update-check.test.ts index a259c07c57a..faa3482efcd 100644 --- a/src/infra/update-check.test.ts +++ b/src/infra/update-check.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import { resolveNpmChannelTag } from "./update-check.js"; describe("resolveNpmChannelTag", () => { diff --git a/src/infra/update-check.ts b/src/infra/update-check.ts index f8aadd74d07..c4be8d5da28 100644 --- a/src/infra/update-check.ts +++ b/src/infra/update-check.ts @@ -1,6 +1,5 @@ import fs from "node:fs/promises"; import path from "node:path"; - import { runCommandWithTimeout } from "../process/exec.js"; import { parseSemver } from "./runtime-guard.js"; import { channelToNpmTag, type UpdateChannel } from "./update-channels.js"; diff --git a/src/infra/update-runner.test.ts b/src/infra/update-runner.test.ts index 6492ad37d55..fea01b88f10 100644 --- a/src/infra/update-runner.test.ts +++ b/src/infra/update-runner.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import { runGatewayUpdate } from "./update-runner.js"; type CommandResult = { stdout?: string; stderr?: string; code?: number }; diff --git a/src/infra/update-runner.ts b/src/infra/update-runner.ts index e03c3466d25..2ca0fcbadae 100644 --- a/src/infra/update-runner.ts +++ b/src/infra/update-runner.ts @@ -1,12 +1,11 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { type CommandOptions, runCommandWithTimeout } from "../process/exec.js"; -import { compareSemverStrings } from "./update-check.js"; -import { DEV_BRANCH, isBetaTag, isStableTag, type UpdateChannel } from "./update-channels.js"; -import { detectGlobalInstallManagerForRoot, globalInstallArgs } from "./update-global.js"; import { trimLogTail } from "./restart-sentinel.js"; +import { DEV_BRANCH, isBetaTag, isStableTag, type UpdateChannel } from "./update-channels.js"; +import { compareSemverStrings } from "./update-check.js"; +import { detectGlobalInstallManagerForRoot, globalInstallArgs } from "./update-global.js"; export type UpdateStepResult = { name: string; diff --git a/src/infra/update-startup.test.ts b/src/infra/update-startup.test.ts index 85041f99bc2..1d0aafd26f8 100644 --- a/src/infra/update-startup.test.ts +++ b/src/infra/update-startup.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import type { UpdateCheckResult } from "./update-check.js"; vi.mock("./openclaw-root.js", () => ({ diff --git a/src/infra/update-startup.ts b/src/infra/update-startup.ts index d24652f6551..4f9e7e42d1b 100644 --- a/src/infra/update-startup.ts +++ b/src/infra/update-startup.ts @@ -1,13 +1,12 @@ import fs from "node:fs/promises"; import path from "node:path"; - import type { loadConfig } from "../config/config.js"; -import { resolveStateDir } from "../config/paths.js"; -import { resolveOpenClawPackageRoot } from "./openclaw-root.js"; -import { compareSemverStrings, resolveNpmChannelTag, checkUpdateStatus } from "./update-check.js"; -import { normalizeUpdateChannel, DEFAULT_PACKAGE_CHANNEL } from "./update-channels.js"; -import { VERSION } from "../version.js"; import { formatCliCommand } from "../cli/command-format.js"; +import { resolveStateDir } from "../config/paths.js"; +import { VERSION } from "../version.js"; +import { resolveOpenClawPackageRoot } from "./openclaw-root.js"; +import { normalizeUpdateChannel, DEFAULT_PACKAGE_CHANNEL } from "./update-channels.js"; +import { compareSemverStrings, resolveNpmChannelTag, checkUpdateStatus } from "./update-check.js"; type UpdateCheckState = { lastCheckedAt?: string; diff --git a/src/infra/voicewake.test.ts b/src/infra/voicewake.test.ts index ce3a110a473..55665b7ea7d 100644 --- a/src/infra/voicewake.test.ts +++ b/src/infra/voicewake.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import { defaultVoiceWakeTriggers, loadVoiceWakeConfig, diff --git a/src/infra/widearea-dns.test.ts b/src/infra/widearea-dns.test.ts index 820aa29c5dd..409c5cc4283 100644 --- a/src/infra/widearea-dns.test.ts +++ b/src/infra/widearea-dns.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { renderWideAreaGatewayZoneText } from "./widearea-dns.js"; describe("wide-area DNS-SD zone rendering", () => { diff --git a/src/infra/widearea-dns.ts b/src/infra/widearea-dns.ts index 6829b966198..40cf936b745 100644 --- a/src/infra/widearea-dns.ts +++ b/src/infra/widearea-dns.ts @@ -1,7 +1,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import { CONFIG_DIR, ensureDir } from "../utils.js"; export function normalizeWideAreaDomain(raw?: string | null): string | null { diff --git a/src/infra/ws.ts b/src/infra/ws.ts index b4db274308b..585e181bcab 100644 --- a/src/infra/ws.ts +++ b/src/infra/ws.ts @@ -1,6 +1,5 @@ -import { Buffer } from "node:buffer"; - import type WebSocket from "ws"; +import { Buffer } from "node:buffer"; export function rawDataToString( data: WebSocket.RawData, diff --git a/src/line/accounts.test.ts b/src/line/accounts.test.ts index a4658d29d2e..3330d052391 100644 --- a/src/line/accounts.test.ts +++ b/src/line/accounts.test.ts @@ -1,4 +1,5 @@ import { describe, it, expect, beforeEach, afterEach } from "vitest"; +import type { OpenClawConfig } from "../config/config.js"; import { resolveLineAccount, listLineAccountIds, @@ -6,7 +7,6 @@ import { normalizeAccountId, DEFAULT_ACCOUNT_ID, } from "./accounts.js"; -import type { OpenClawConfig } from "../config/config.js"; describe("LINE accounts", () => { const originalEnv = { ...process.env }; diff --git a/src/line/auto-reply-delivery.test.ts b/src/line/auto-reply-delivery.test.ts index 48a7bf7249c..1acab3a8a89 100644 --- a/src/line/auto-reply-delivery.test.ts +++ b/src/line/auto-reply-delivery.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { deliverLineAutoReply } from "./auto-reply-delivery.js"; import { sendLineReplyChunks } from "./reply-chunks.js"; diff --git a/src/line/auto-reply-delivery.ts b/src/line/auto-reply-delivery.ts index bbb0012c375..c303382f9b2 100644 --- a/src/line/auto-reply-delivery.ts +++ b/src/line/auto-reply-delivery.ts @@ -2,8 +2,8 @@ import type { messagingApi } from "@line/bot-sdk"; import type { ReplyPayload } from "../auto-reply/types.js"; import type { FlexContainer } from "./flex-templates.js"; import type { ProcessedLineMessage } from "./markdown-to-line.js"; -import type { LineChannelData, LineTemplateMessagePayload } from "./types.js"; import type { LineReplyMessage, SendLineReplyChunksParams } from "./reply-chunks.js"; +import type { LineChannelData, LineTemplateMessagePayload } from "./types.js"; export type LineAutoReplyDeps = { buildTemplateMessageFromPayload: ( diff --git a/src/line/bot-handlers.test.ts b/src/line/bot-handlers.test.ts index 00f0082ed67..695c318c2f7 100644 --- a/src/line/bot-handlers.test.ts +++ b/src/line/bot-handlers.test.ts @@ -1,5 +1,5 @@ -import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import type { MessageEvent } from "@line/bot-sdk"; +import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; const { buildLineMessageContextMock, buildLinePostbackContextMock } = vi.hoisted(() => ({ buildLineMessageContextMock: vi.fn(async () => ({ diff --git a/src/line/bot-handlers.ts b/src/line/bot-handlers.ts index 5884e0a2c66..757c8c180e5 100644 --- a/src/line/bot-handlers.ts +++ b/src/line/bot-handlers.ts @@ -9,6 +9,8 @@ import type { EventSource, } from "@line/bot-sdk"; import type { OpenClawConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; +import type { LineGroupConfig, ResolvedLineAccount } from "./types.js"; import { danger, logVerbose } from "../globals.js"; import { resolvePairingIdLabel } from "../pairing/pairing-labels.js"; import { buildPairingReply } from "../pairing/pairing-messages.js"; @@ -16,16 +18,14 @@ import { readChannelAllowFromStore, upsertChannelPairingRequest, } from "../pairing/pairing-store.js"; -import type { RuntimeEnv } from "../runtime.js"; +import { firstDefined, isSenderAllowed, normalizeAllowFromWithStore } from "./bot-access.js"; import { buildLineMessageContext, buildLinePostbackContext, type LineInboundContext, } from "./bot-message-context.js"; -import { firstDefined, isSenderAllowed, normalizeAllowFromWithStore } from "./bot-access.js"; import { downloadLineMedia } from "./download.js"; import { pushMessageLine, replyMessageLine } from "./send.js"; -import type { LineGroupConfig, ResolvedLineAccount } from "./types.js"; interface MediaRef { path: string; diff --git a/src/line/bot-message-context.test.ts b/src/line/bot-message-context.test.ts index 2960cc081ea..b75300dc09e 100644 --- a/src/line/bot-message-context.test.ts +++ b/src/line/bot-message-context.test.ts @@ -1,8 +1,8 @@ -import { afterEach, beforeEach, describe, expect, it } from "vitest"; +import type { MessageEvent, PostbackEvent } from "@line/bot-sdk"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; -import type { MessageEvent, PostbackEvent } from "@line/bot-sdk"; +import { afterEach, beforeEach, describe, expect, it } from "vitest"; import type { OpenClawConfig } from "../config/config.js"; import type { ResolvedLineAccount } from "./types.js"; import { buildLineMessageContext, buildLinePostbackContext } from "./bot-message-context.js"; diff --git a/src/line/bot-message-context.ts b/src/line/bot-message-context.ts index 2de94fd75c3..f11729adef7 100644 --- a/src/line/bot-message-context.ts +++ b/src/line/bot-message-context.ts @@ -1,8 +1,9 @@ import type { MessageEvent, StickerEventMessage, EventSource, PostbackEvent } from "@line/bot-sdk"; +import type { OpenClawConfig } from "../config/config.js"; +import type { ResolvedLineAccount } from "./types.js"; import { formatInboundEnvelope, resolveEnvelopeFormatOptions } from "../auto-reply/envelope.js"; import { finalizeInboundContext } from "../auto-reply/reply/inbound-context.js"; import { formatLocationText, toLocationContext } from "../channels/location.js"; -import type { OpenClawConfig } from "../config/config.js"; import { readSessionUpdatedAt, recordSessionMetaFromInbound, @@ -12,7 +13,6 @@ import { import { logVerbose, shouldLogVerbose } from "../globals.js"; import { recordChannelActivity } from "../infra/channel-activity.js"; import { resolveAgentRoute } from "../routing/resolve-route.js"; -import type { ResolvedLineAccount } from "./types.js"; interface MediaRef { path: string; diff --git a/src/line/bot.ts b/src/line/bot.ts index ecea6ef79f7..b78a667e190 100644 --- a/src/line/bot.ts +++ b/src/line/bot.ts @@ -1,14 +1,14 @@ import type { WebhookRequestBody } from "@line/bot-sdk"; import type { Request, Response, NextFunction } from "express"; import type { OpenClawConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; +import type { LineInboundContext } from "./bot-message-context.js"; +import type { ResolvedLineAccount } from "./types.js"; import { loadConfig } from "../config/config.js"; import { logVerbose } from "../globals.js"; -import type { RuntimeEnv } from "../runtime.js"; import { resolveLineAccount } from "./accounts.js"; import { handleLineWebhookEvents } from "./bot-handlers.js"; -import type { LineInboundContext } from "./bot-message-context.js"; import { startLineWebhook } from "./webhook.js"; -import type { ResolvedLineAccount } from "./types.js"; export interface LineBotOptions { channelAccessToken: string; diff --git a/src/line/download.ts b/src/line/download.ts index e48cb0e7198..9219025cc42 100644 --- a/src/line/download.ts +++ b/src/line/download.ts @@ -1,7 +1,7 @@ -import fs from "node:fs"; -import path from "node:path"; -import os from "node:os"; import { messagingApi } from "@line/bot-sdk"; +import fs from "node:fs"; +import os from "node:os"; +import path from "node:path"; import { logVerbose } from "../globals.js"; interface DownloadResult { diff --git a/src/line/monitor.ts b/src/line/monitor.ts index 6017c01684b..8880e4a778d 100644 --- a/src/line/monitor.ts +++ b/src/line/monitor.ts @@ -1,12 +1,18 @@ import type { WebhookRequestBody } from "@line/bot-sdk"; import type { IncomingMessage, ServerResponse } from "node:http"; import type { OpenClawConfig } from "../config/config.js"; -import { danger, logVerbose } from "../globals.js"; import type { RuntimeEnv } from "../runtime.js"; -import { createLineBot } from "./bot.js"; -import { validateLineSignature } from "./signature.js"; +import type { LineChannelData, ResolvedLineAccount } from "./types.js"; +import { resolveEffectiveMessagesConfig } from "../agents/identity.js"; +import { chunkMarkdownText } from "../auto-reply/chunk.js"; +import { dispatchReplyWithBufferedBlockDispatcher } from "../auto-reply/reply/provider-dispatcher.js"; +import { danger, logVerbose } from "../globals.js"; import { normalizePluginHttpPath } from "../plugins/http-path.js"; import { registerPluginHttpRoute } from "../plugins/http-registry.js"; +import { deliverLineAutoReply } from "./auto-reply-delivery.js"; +import { createLineBot } from "./bot.js"; +import { processLineMessage } from "./markdown-to-line.js"; +import { sendLineReplyChunks } from "./reply-chunks.js"; import { replyMessageLine, showLoadingAnimation, @@ -20,14 +26,8 @@ import { createImageMessage, createLocationMessage, } from "./send.js"; +import { validateLineSignature } from "./signature.js"; import { buildTemplateMessageFromPayload } from "./template-messages.js"; -import type { LineChannelData, ResolvedLineAccount } from "./types.js"; -import { dispatchReplyWithBufferedBlockDispatcher } from "../auto-reply/reply/provider-dispatcher.js"; -import { resolveEffectiveMessagesConfig } from "../agents/identity.js"; -import { chunkMarkdownText } from "../auto-reply/chunk.js"; -import { processLineMessage } from "./markdown-to-line.js"; -import { sendLineReplyChunks } from "./reply-chunks.js"; -import { deliverLineAutoReply } from "./auto-reply-delivery.js"; export interface MonitorLineProviderOptions { channelAccessToken: string; diff --git a/src/line/send.ts b/src/line/send.ts index 0c844b1fb99..874a7ea4199 100644 --- a/src/line/send.ts +++ b/src/line/send.ts @@ -1,9 +1,9 @@ import { messagingApi } from "@line/bot-sdk"; +import type { LineSendResult } from "./types.js"; import { loadConfig } from "../config/config.js"; import { logVerbose } from "../globals.js"; import { recordChannelActivity } from "../infra/channel-activity.js"; import { resolveLineAccount } from "./accounts.js"; -import type { LineSendResult } from "./types.js"; // Use the messaging API types directly type Message = messagingApi.Message; diff --git a/src/line/webhook.ts b/src/line/webhook.ts index 74c0cfde178..b2e9806fad3 100644 --- a/src/line/webhook.ts +++ b/src/line/webhook.ts @@ -1,7 +1,7 @@ -import type { Request, Response, NextFunction } from "express"; import type { WebhookRequestBody } from "@line/bot-sdk"; -import { logVerbose, danger } from "../globals.js"; +import type { Request, Response, NextFunction } from "express"; import type { RuntimeEnv } from "../runtime.js"; +import { logVerbose, danger } from "../globals.js"; import { validateLineSignature } from "./signature.js"; export interface LineWebhookOptions { diff --git a/src/link-understanding/apply.ts b/src/link-understanding/apply.ts index 17ab6c249c6..f2bd97981d9 100644 --- a/src/link-understanding/apply.ts +++ b/src/link-understanding/apply.ts @@ -1,5 +1,5 @@ -import type { OpenClawConfig } from "../config/config.js"; import type { MsgContext } from "../auto-reply/templating.js"; +import type { OpenClawConfig } from "../config/config.js"; import { finalizeInboundContext } from "../auto-reply/reply/inbound-context.js"; import { formatLinkUnderstandingBody } from "./format.js"; import { runLinkUnderstanding } from "./runner.js"; diff --git a/src/link-understanding/detect.test.ts b/src/link-understanding/detect.test.ts index 07545f40383..f65280b8b7f 100644 --- a/src/link-understanding/detect.test.ts +++ b/src/link-understanding/detect.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { extractLinksFromMessage } from "./detect.js"; describe("extractLinksFromMessage", () => { diff --git a/src/link-understanding/runner.ts b/src/link-understanding/runner.ts index bc6dc2bd9fc..f77f0f85cf8 100644 --- a/src/link-understanding/runner.ts +++ b/src/link-understanding/runner.ts @@ -1,15 +1,15 @@ -import type { OpenClawConfig } from "../config/config.js"; import type { MsgContext } from "../auto-reply/templating.js"; -import { applyTemplate } from "../auto-reply/templating.js"; +import type { OpenClawConfig } from "../config/config.js"; import type { LinkModelConfig, LinkToolsConfig } from "../config/types.tools.js"; +import { applyTemplate } from "../auto-reply/templating.js"; import { logVerbose, shouldLogVerbose } from "../globals.js"; -import { runExec } from "../process/exec.js"; import { CLI_OUTPUT_MAX_BUFFER } from "../media-understanding/defaults.js"; import { resolveTimeoutMs } from "../media-understanding/resolve.js"; import { normalizeMediaUnderstandingChatType, resolveMediaUnderstandingScope, } from "../media-understanding/scope.js"; +import { runExec } from "../process/exec.js"; import { DEFAULT_LINK_TIMEOUT_SECONDS } from "./defaults.js"; import { extractLinksFromMessage } from "./detect.js"; diff --git a/src/logger.test.ts b/src/logger.test.ts index 96e4591383e..9f87d4b3794 100644 --- a/src/logger.test.ts +++ b/src/logger.test.ts @@ -2,13 +2,11 @@ import crypto from "node:crypto"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import { afterEach, describe, expect, it, vi } from "vitest"; - +import type { RuntimeEnv } from "./runtime.js"; import { setVerbose } from "./globals.js"; import { logDebug, logError, logInfo, logSuccess, logWarn } from "./logger.js"; import { DEFAULT_LOG_DIR, resetLogger, setLoggerOverride } from "./logging.js"; -import type { RuntimeEnv } from "./runtime.js"; describe("logger helpers", () => { afterEach(() => { diff --git a/src/logging.ts b/src/logging.ts index ed7a11167b3..5706787cd0f 100644 --- a/src/logging.ts +++ b/src/logging.ts @@ -1,3 +1,7 @@ +import type { ConsoleLoggerSettings, ConsoleStyle } from "./logging/console.js"; +import type { LogLevel } from "./logging/levels.js"; +import type { LoggerResolvedSettings, LoggerSettings, PinoLikeLogger } from "./logging/logger.js"; +import type { SubsystemLogger } from "./logging/subsystem.js"; import { enableConsoleCapture, getConsoleSettings, @@ -7,9 +11,7 @@ import { setConsoleTimestampPrefix, shouldLogSubsystemToConsole, } from "./logging/console.js"; -import type { ConsoleLoggerSettings, ConsoleStyle } from "./logging/console.js"; import { ALLOWED_LOG_LEVELS, levelToMinLevel, normalizeLogLevel } from "./logging/levels.js"; -import type { LogLevel } from "./logging/levels.js"; import { DEFAULT_LOG_DIR, DEFAULT_LOG_FILE, @@ -21,14 +23,12 @@ import { setLoggerOverride, toPinoLikeLogger, } from "./logging/logger.js"; -import type { LoggerResolvedSettings, LoggerSettings, PinoLikeLogger } from "./logging/logger.js"; import { createSubsystemLogger, createSubsystemRuntime, runtimeForLogger, stripRedundantSubsystemPrefixForConsole, } from "./logging/subsystem.js"; -import type { SubsystemLogger } from "./logging/subsystem.js"; export { enableConsoleCapture, diff --git a/src/logging/config.ts b/src/logging/config.ts index 7a98126909c..a421453477c 100644 --- a/src/logging/config.ts +++ b/src/logging/config.ts @@ -1,9 +1,7 @@ -import fs from "node:fs"; - import json5 from "json5"; - -import { resolveConfigPath } from "../config/paths.js"; +import fs from "node:fs"; import type { OpenClawConfig } from "../config/types.js"; +import { resolveConfigPath } from "../config/paths.js"; type LoggingConfig = OpenClawConfig["logging"]; diff --git a/src/logging/console-capture.test.ts b/src/logging/console-capture.test.ts index c9581bd37b2..638332ddf9c 100644 --- a/src/logging/console-capture.test.ts +++ b/src/logging/console-capture.test.ts @@ -1,9 +1,7 @@ import crypto from "node:crypto"; import os from "node:os"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import { enableConsoleCapture, resetLogger, diff --git a/src/logging/console-prefix.test.ts b/src/logging/console-prefix.test.ts index 2fd3bf091d4..3bc3b13df91 100644 --- a/src/logging/console-prefix.test.ts +++ b/src/logging/console-prefix.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { stripRedundantSubsystemPrefixForConsole } from "../logging.js"; describe("stripRedundantSubsystemPrefixForConsole", () => { diff --git a/src/logging/console.ts b/src/logging/console.ts index fe33876964b..986bf89ace0 100644 --- a/src/logging/console.ts +++ b/src/logging/console.ts @@ -1,12 +1,11 @@ import { createRequire } from "node:module"; import util from "node:util"; - import type { OpenClawConfig } from "../config/types.js"; import { isVerbose } from "../globals.js"; import { stripAnsi } from "../terminal/ansi.js"; +import { readLoggingConfig } from "./config.js"; import { type LogLevel, normalizeLogLevel } from "./levels.js"; import { getLogger, type LoggerSettings } from "./logger.js"; -import { readLoggingConfig } from "./config.js"; import { loggingState } from "./state.js"; export type ConsoleStyle = "pretty" | "compact" | "json"; diff --git a/src/logging/logger.ts b/src/logging/logger.ts index 231802f21c8..819a14a8aba 100644 --- a/src/logging/logger.ts +++ b/src/logging/logger.ts @@ -1,13 +1,11 @@ -import { createRequire } from "node:module"; import fs from "node:fs"; +import { createRequire } from "node:module"; import path from "node:path"; - import { Logger as TsLogger } from "tslog"; - import type { OpenClawConfig } from "../config/types.js"; import type { ConsoleStyle } from "./console.js"; -import { type LogLevel, levelToMinLevel, normalizeLogLevel } from "./levels.js"; import { readLoggingConfig } from "./config.js"; +import { type LogLevel, levelToMinLevel, normalizeLogLevel } from "./levels.js"; import { loggingState } from "./state.js"; // Pin to /tmp so mac Debug UI and docs match; os.tmpdir() can be a per-user diff --git a/src/logging/parse-log-line.test.ts b/src/logging/parse-log-line.test.ts index 272ce176e95..cf1fb6058b8 100644 --- a/src/logging/parse-log-line.test.ts +++ b/src/logging/parse-log-line.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { parseLogLine } from "./parse-log-line.js"; describe("parseLogLine", () => { diff --git a/src/logging/redact.test.ts b/src/logging/redact.test.ts index 5b3ecbfb87f..3e8b754dd71 100644 --- a/src/logging/redact.test.ts +++ b/src/logging/redact.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { getDefaultRedactPatterns, redactSensitiveText } from "./redact.js"; const defaults = getDefaultRedactPatterns(); diff --git a/src/logging/redact.ts b/src/logging/redact.ts index 5adb892dd26..f79bed7e07f 100644 --- a/src/logging/redact.ts +++ b/src/logging/redact.ts @@ -1,5 +1,4 @@ import { createRequire } from "node:module"; - import type { OpenClawConfig } from "../config/config.js"; const requireConfig = createRequire(import.meta.url); diff --git a/src/logging/subsystem.ts b/src/logging/subsystem.ts index d0e80194b19..a1ec00abc29 100644 --- a/src/logging/subsystem.ts +++ b/src/logging/subsystem.ts @@ -1,14 +1,13 @@ -import { Chalk } from "chalk"; import type { Logger as TsLogger } from "tslog"; - +import { Chalk } from "chalk"; import { CHAT_CHANNEL_ORDER } from "../channels/registry.js"; -import { defaultRuntime, type RuntimeEnv } from "../runtime.js"; -import { getConsoleSettings, shouldLogSubsystemToConsole } from "./console.js"; import { isVerbose } from "../globals.js"; +import { defaultRuntime, type RuntimeEnv } from "../runtime.js"; +import { clearActiveProgressLine } from "../terminal/progress-line.js"; +import { getConsoleSettings, shouldLogSubsystemToConsole } from "./console.js"; import { type LogLevel, levelToMinLevel } from "./levels.js"; import { getChildLogger } from "./logger.js"; import { loggingState } from "./state.js"; -import { clearActiveProgressLine } from "../terminal/progress-line.js"; type LogObj = { date?: Date } & Record; diff --git a/src/markdown/frontmatter.test.ts b/src/markdown/frontmatter.test.ts index 033c1dded93..dfc822c86b9 100644 --- a/src/markdown/frontmatter.test.ts +++ b/src/markdown/frontmatter.test.ts @@ -1,6 +1,5 @@ import JSON5 from "json5"; import { describe, expect, it } from "vitest"; - import { parseFrontmatterBlock } from "./frontmatter.js"; describe("parseFrontmatterBlock", () => { diff --git a/src/markdown/ir.ts b/src/markdown/ir.ts index 3fe985766ce..2fd3a5a0c6b 100644 --- a/src/markdown/ir.ts +++ b/src/markdown/ir.ts @@ -1,7 +1,6 @@ import MarkdownIt from "markdown-it"; - -import { chunkText } from "../auto-reply/chunk.js"; import type { MarkdownTableMode } from "../config/types.base.js"; +import { chunkText } from "../auto-reply/chunk.js"; type ListState = { type: "bullet" | "ordered"; diff --git a/src/media-understanding/apply.test.ts b/src/media-understanding/apply.test.ts index 3dad57023c1..238293d5ef5 100644 --- a/src/media-understanding/apply.test.ts +++ b/src/media-understanding/apply.test.ts @@ -1,11 +1,9 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { beforeEach, describe, expect, it, vi } from "vitest"; - -import type { OpenClawConfig } from "../config/config.js"; import type { MsgContext } from "../auto-reply/templating.js"; +import type { OpenClawConfig } from "../config/config.js"; import { resolveApiKeyForProvider } from "../agents/model-auth.js"; import { fetchRemoteMedia } from "../media/fetch.js"; diff --git a/src/media-understanding/apply.ts b/src/media-understanding/apply.ts index 3c9103038b7..000439a0d87 100644 --- a/src/media-understanding/apply.ts +++ b/src/media-understanding/apply.ts @@ -1,7 +1,12 @@ import path from "node:path"; - -import type { OpenClawConfig } from "../config/config.js"; import type { MsgContext } from "../auto-reply/templating.js"; +import type { OpenClawConfig } from "../config/config.js"; +import type { + MediaUnderstandingCapability, + MediaUnderstandingDecision, + MediaUnderstandingOutput, + MediaUnderstandingProvider, +} from "./types.js"; import { finalizeInboundContext } from "../auto-reply/reply/inbound-context.js"; import { logVerbose, shouldLogVerbose } from "../globals.js"; import { @@ -17,20 +22,14 @@ import { normalizeMimeList, normalizeMimeType, } from "../media/input-files.js"; +import { resolveAttachmentKind } from "./attachments.js"; +import { runWithConcurrency } from "./concurrency.js"; import { extractMediaUserText, formatAudioTranscripts, formatMediaUnderstandingBody, } from "./format.js"; -import type { - MediaUnderstandingCapability, - MediaUnderstandingDecision, - MediaUnderstandingOutput, - MediaUnderstandingProvider, -} from "./types.js"; -import { runWithConcurrency } from "./concurrency.js"; import { resolveConcurrency } from "./resolve.js"; -import { resolveAttachmentKind } from "./attachments.js"; import { type ActiveMediaModel, buildProviderRegistry, diff --git a/src/media-understanding/attachments.ts b/src/media-understanding/attachments.ts index 54dd90ed99d..97b3b5ac5b7 100644 --- a/src/media-understanding/attachments.ts +++ b/src/media-understanding/attachments.ts @@ -3,15 +3,14 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { fileURLToPath } from "node:url"; - import type { MsgContext } from "../auto-reply/templating.js"; import type { MediaUnderstandingAttachmentsConfig } from "../config/types.tools.js"; +import type { MediaAttachment, MediaUnderstandingCapability } from "./types.js"; +import { logVerbose, shouldLogVerbose } from "../globals.js"; import { fetchRemoteMedia, MediaFetchError } from "../media/fetch.js"; import { detectMime, getFileExtension, isAudioFileName, kindFromMime } from "../media/mime.js"; -import { logVerbose, shouldLogVerbose } from "../globals.js"; -import { fetchWithTimeout } from "./providers/shared.js"; -import type { MediaAttachment, MediaUnderstandingCapability } from "./types.js"; import { MediaUnderstandingSkipError } from "./errors.js"; +import { fetchWithTimeout } from "./providers/shared.js"; type MediaBufferResult = { buffer: Buffer; diff --git a/src/media-understanding/providers/deepgram/audio.live.test.ts b/src/media-understanding/providers/deepgram/audio.live.test.ts index 140c949e861..75a4cb872cf 100644 --- a/src/media-understanding/providers/deepgram/audio.live.test.ts +++ b/src/media-understanding/providers/deepgram/audio.live.test.ts @@ -1,6 +1,5 @@ import { describe, expect, it } from "vitest"; import { isTruthyEnvValue } from "../../../infra/env.js"; - import { transcribeDeepgramAudio } from "./audio.js"; const DEEPGRAM_KEY = process.env.DEEPGRAM_API_KEY ?? ""; diff --git a/src/media-understanding/providers/deepgram/audio.test.ts b/src/media-understanding/providers/deepgram/audio.test.ts index 0635da66faa..98c268e12e4 100644 --- a/src/media-understanding/providers/deepgram/audio.test.ts +++ b/src/media-understanding/providers/deepgram/audio.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { transcribeDeepgramAudio } from "./audio.js"; const resolveRequestUrl = (input: RequestInfo | URL) => { diff --git a/src/media-understanding/providers/google/video.test.ts b/src/media-understanding/providers/google/video.test.ts index 5b776438c9c..4d05a8e0475 100644 --- a/src/media-understanding/providers/google/video.test.ts +++ b/src/media-understanding/providers/google/video.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { describeGeminiVideo } from "./video.js"; const resolveRequestUrl = (input: RequestInfo | URL) => { diff --git a/src/media-understanding/providers/image.ts b/src/media-understanding/providers/image.ts index a4e876b3144..371f7dc4704 100644 --- a/src/media-understanding/providers/image.ts +++ b/src/media-understanding/providers/image.ts @@ -1,12 +1,11 @@ import type { Api, Context, Model } from "@mariozechner/pi-ai"; import { complete } from "@mariozechner/pi-ai"; -import { discoverAuthStorage, discoverModels } from "../../agents/pi-model-discovery.js"; - +import type { ImageDescriptionRequest, ImageDescriptionResult } from "../types.js"; +import { minimaxUnderstandImage } from "../../agents/minimax-vlm.js"; import { getApiKeyForModel, requireApiKey } from "../../agents/model-auth.js"; import { ensureOpenClawModelsJson } from "../../agents/models-config.js"; -import { minimaxUnderstandImage } from "../../agents/minimax-vlm.js"; +import { discoverAuthStorage, discoverModels } from "../../agents/pi-model-discovery.js"; import { coerceImageAssistantText } from "../../agents/tools/image-tool.helpers.js"; -import type { ImageDescriptionRequest, ImageDescriptionResult } from "../types.js"; export async function describeImageWithModel( params: ImageDescriptionRequest, diff --git a/src/media-understanding/providers/index.ts b/src/media-understanding/providers/index.ts index bbc40baf812..5fc5bd02ed5 100644 --- a/src/media-understanding/providers/index.ts +++ b/src/media-understanding/providers/index.ts @@ -1,5 +1,5 @@ -import { normalizeProviderId } from "../../agents/model-selection.js"; import type { MediaUnderstandingProvider } from "../types.js"; +import { normalizeProviderId } from "../../agents/model-selection.js"; import { anthropicProvider } from "./anthropic/index.js"; import { deepgramProvider } from "./deepgram/index.js"; import { googleProvider } from "./google/index.js"; diff --git a/src/media-understanding/providers/openai/audio.test.ts b/src/media-understanding/providers/openai/audio.test.ts index a9df11c977b..43c6be6faa2 100644 --- a/src/media-understanding/providers/openai/audio.test.ts +++ b/src/media-understanding/providers/openai/audio.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { transcribeOpenAiCompatibleAudio } from "./audio.js"; const resolveRequestUrl = (input: RequestInfo | URL) => { diff --git a/src/media-understanding/providers/openai/audio.ts b/src/media-understanding/providers/openai/audio.ts index fb9cd90a02d..35eab2f1e8f 100644 --- a/src/media-understanding/providers/openai/audio.ts +++ b/src/media-understanding/providers/openai/audio.ts @@ -1,5 +1,4 @@ import path from "node:path"; - import type { AudioTranscriptionRequest, AudioTranscriptionResult } from "../../types.js"; import { fetchWithTimeout, normalizeBaseUrl, readErrorResponse } from "../shared.js"; diff --git a/src/media-understanding/resolve.test.ts b/src/media-understanding/resolve.test.ts index d06a777f875..9898794b404 100644 --- a/src/media-understanding/resolve.test.ts +++ b/src/media-understanding/resolve.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { resolveEntriesWithActiveFallback, resolveModelEntries } from "./resolve.js"; diff --git a/src/media-understanding/resolve.ts b/src/media-understanding/resolve.ts index add62cbde38..0a05ad9eae3 100644 --- a/src/media-understanding/resolve.ts +++ b/src/media-understanding/resolve.ts @@ -1,10 +1,11 @@ -import type { OpenClawConfig } from "../config/config.js"; import type { MsgContext } from "../auto-reply/templating.js"; +import type { OpenClawConfig } from "../config/config.js"; import type { MediaUnderstandingConfig, MediaUnderstandingModelConfig, MediaUnderstandingScopeConfig, } from "../config/types.tools.js"; +import type { MediaUnderstandingCapability } from "./types.js"; import { logVerbose, shouldLogVerbose } from "../globals.js"; import { DEFAULT_MAX_BYTES, @@ -14,7 +15,6 @@ import { } from "./defaults.js"; import { normalizeMediaProviderId } from "./providers/index.js"; import { normalizeMediaUnderstandingChatType, resolveMediaUnderstandingScope } from "./scope.js"; -import type { MediaUnderstandingCapability } from "./types.js"; export function resolveTimeoutMs(seconds: number | undefined, fallbackSeconds: number): number { const value = typeof seconds === "number" && Number.isFinite(seconds) ? seconds : fallbackSeconds; diff --git a/src/media-understanding/runner.auto-audio.test.ts b/src/media-understanding/runner.auto-audio.test.ts index a28e7b73e52..fa437011f9b 100644 --- a/src/media-understanding/runner.auto-audio.test.ts +++ b/src/media-understanding/runner.auto-audio.test.ts @@ -1,11 +1,9 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - -import type { OpenClawConfig } from "../config/config.js"; import type { MsgContext } from "../auto-reply/templating.js"; +import type { OpenClawConfig } from "../config/config.js"; import { buildProviderRegistry, createMediaAttachmentCache, diff --git a/src/media-understanding/runner.deepgram.test.ts b/src/media-understanding/runner.deepgram.test.ts index 460e8083562..ac7082adbf4 100644 --- a/src/media-understanding/runner.deepgram.test.ts +++ b/src/media-understanding/runner.deepgram.test.ts @@ -1,11 +1,9 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - -import type { OpenClawConfig } from "../config/config.js"; import type { MsgContext } from "../auto-reply/templating.js"; +import type { OpenClawConfig } from "../config/config.js"; import { buildProviderRegistry, createMediaAttachmentCache, diff --git a/src/media-understanding/runner.ts b/src/media-understanding/runner.ts index 36a25195546..6bbcf304b4b 100644 --- a/src/media-understanding/runner.ts +++ b/src/media-understanding/runner.ts @@ -2,37 +2,12 @@ import { constants as fsConstants } from "node:fs"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - -import type { OpenClawConfig } from "../config/config.js"; -import { - findModelInCatalog, - loadModelCatalog, - modelSupportsVision, -} from "../agents/model-catalog.js"; import type { MsgContext } from "../auto-reply/templating.js"; -import { applyTemplate } from "../auto-reply/templating.js"; -import { requireApiKey, resolveApiKeyForProvider } from "../agents/model-auth.js"; -import { logVerbose, shouldLogVerbose } from "../globals.js"; -import { runExec } from "../process/exec.js"; +import type { OpenClawConfig } from "../config/config.js"; import type { MediaUnderstandingConfig, MediaUnderstandingModelConfig, } from "../config/types.tools.js"; -import { MediaAttachmentCache, normalizeAttachments, selectAttachments } from "./attachments.js"; -import { - CLI_OUTPUT_MAX_BUFFER, - DEFAULT_AUDIO_MODELS, - DEFAULT_TIMEOUT_SECONDS, -} from "./defaults.js"; -import { isMediaUnderstandingSkipError, MediaUnderstandingSkipError } from "./errors.js"; -import { - resolveMaxBytes, - resolveMaxChars, - resolveModelEntries, - resolvePrompt, - resolveScopeDecision, - resolveTimeoutMs, -} from "./resolve.js"; import type { MediaAttachment, MediaUnderstandingCapability, @@ -41,12 +16,36 @@ import type { MediaUnderstandingOutput, MediaUnderstandingProvider, } from "./types.js"; +import { requireApiKey, resolveApiKeyForProvider } from "../agents/model-auth.js"; +import { + findModelInCatalog, + loadModelCatalog, + modelSupportsVision, +} from "../agents/model-catalog.js"; +import { applyTemplate } from "../auto-reply/templating.js"; +import { logVerbose, shouldLogVerbose } from "../globals.js"; +import { runExec } from "../process/exec.js"; +import { MediaAttachmentCache, normalizeAttachments, selectAttachments } from "./attachments.js"; +import { + CLI_OUTPUT_MAX_BUFFER, + DEFAULT_AUDIO_MODELS, + DEFAULT_TIMEOUT_SECONDS, +} from "./defaults.js"; +import { isMediaUnderstandingSkipError, MediaUnderstandingSkipError } from "./errors.js"; +import { describeImageWithModel } from "./providers/image.js"; import { buildMediaUnderstandingRegistry, getMediaUnderstandingProvider, normalizeMediaProviderId, } from "./providers/index.js"; -import { describeImageWithModel } from "./providers/image.js"; +import { + resolveMaxBytes, + resolveMaxChars, + resolveModelEntries, + resolvePrompt, + resolveScopeDecision, + resolveTimeoutMs, +} from "./resolve.js"; import { estimateBase64Size, resolveVideoMaxBase64Bytes } from "./video.js"; const AUTO_AUDIO_KEY_PROVIDERS = ["openai", "groq", "deepgram", "google"] as const; diff --git a/src/media-understanding/runner.vision-skip.test.ts b/src/media-understanding/runner.vision-skip.test.ts index 0859cc1072a..8a289b845e4 100644 --- a/src/media-understanding/runner.vision-skip.test.ts +++ b/src/media-understanding/runner.vision-skip.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { MsgContext } from "../auto-reply/templating.js"; import type { OpenClawConfig } from "../config/config.js"; import { diff --git a/src/media-understanding/scope.test.ts b/src/media-understanding/scope.test.ts index 3f9bff48a53..0607c4bf2cb 100644 --- a/src/media-understanding/scope.test.ts +++ b/src/media-understanding/scope.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { normalizeMediaUnderstandingChatType, resolveMediaUnderstandingScope } from "./scope.js"; describe("media understanding scope", () => { diff --git a/src/media/fetch.test.ts b/src/media/fetch.test.ts index 46445b1bb0a..2af4f46632b 100644 --- a/src/media/fetch.test.ts +++ b/src/media/fetch.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { fetchRemoteMedia } from "./fetch.js"; function makeStream(chunks: Uint8Array[]) { diff --git a/src/media/fetch.ts b/src/media/fetch.ts index 539d2e9e38f..b47213da75b 100644 --- a/src/media/fetch.ts +++ b/src/media/fetch.ts @@ -1,5 +1,4 @@ import path from "node:path"; - import { detectMime, extensionForMime } from "./mime.js"; type FetchMediaResult = { diff --git a/src/media/host.test.ts b/src/media/host.test.ts index d229d5ee0b2..c67ccea5c47 100644 --- a/src/media/host.test.ts +++ b/src/media/host.test.ts @@ -1,6 +1,5 @@ -import fs from "node:fs/promises"; import type { Server } from "node:http"; - +import fs from "node:fs/promises"; import { beforeEach, describe, expect, it, vi } from "vitest"; const mocks = vi.hoisted(() => ({ diff --git a/src/media/host.ts b/src/media/host.ts index b70b6bc12fc..d2032192c3e 100644 --- a/src/media/host.ts +++ b/src/media/host.ts @@ -1,9 +1,9 @@ import fs from "node:fs/promises"; +import { formatCliCommand } from "../cli/command-format.js"; import { ensurePortAvailable, PortInUseError } from "../infra/ports.js"; import { getTailnetHostname } from "../infra/tailscale.js"; import { logInfo } from "../logger.js"; import { defaultRuntime, type RuntimeEnv } from "../runtime.js"; -import { formatCliCommand } from "../cli/command-format.js"; import { startMediaServer } from "./server.js"; import { saveMediaSource } from "./store.js"; diff --git a/src/media/image-ops.ts b/src/media/image-ops.ts index 6a71e03b929..3973d452839 100644 --- a/src/media/image-ops.ts +++ b/src/media/image-ops.ts @@ -1,7 +1,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { runExec } from "../process/exec.js"; type Sharp = typeof import("sharp"); diff --git a/src/media/input-files.ts b/src/media/input-files.ts index 0481ff5e2de..677bba74fee 100644 --- a/src/media/input-files.ts +++ b/src/media/input-files.ts @@ -1,10 +1,10 @@ -import { logWarn } from "../logger.js"; +import type { Dispatcher } from "undici"; import { closeDispatcher, createPinnedDispatcher, resolvePinnedHostname, } from "../infra/net/ssrf.js"; -import type { Dispatcher } from "undici"; +import { logWarn } from "../logger.js"; type CanvasModule = typeof import("@napi-rs/canvas"); type PdfJsModule = typeof import("pdfjs-dist/legacy/build/pdf.mjs"); diff --git a/src/media/mime.test.ts b/src/media/mime.test.ts index 92325a62e73..df9f9c4f00a 100644 --- a/src/media/mime.test.ts +++ b/src/media/mime.test.ts @@ -1,6 +1,5 @@ import JSZip from "jszip"; import { describe, expect, it } from "vitest"; - import { detectMime, extensionForMime, imageMimeFromFormat } from "./mime.js"; async function makeOoxmlZip(opts: { mainMime: string; partPath: string }): Promise { diff --git a/src/media/mime.ts b/src/media/mime.ts index 73f6a9b9abe..154bd3ba407 100644 --- a/src/media/mime.ts +++ b/src/media/mime.ts @@ -1,6 +1,5 @@ -import path from "node:path"; - import { fileTypeFromBuffer } from "file-type"; +import path from "node:path"; import { type MediaKind, mediaKindFromMime } from "./constants.js"; // Map common mimes to preferred file extensions. diff --git a/src/media/parse.test.ts b/src/media/parse.test.ts index 77b302477f5..5475ae28159 100644 --- a/src/media/parse.test.ts +++ b/src/media/parse.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { splitMediaFromOutput } from "./parse.js"; describe("splitMediaFromOutput", () => { diff --git a/src/media/server.test.ts b/src/media/server.test.ts index 34182c5f2b3..6273f1d8a7c 100644 --- a/src/media/server.test.ts +++ b/src/media/server.test.ts @@ -1,7 +1,6 @@ -import fs from "node:fs/promises"; import type { AddressInfo } from "node:net"; +import fs from "node:fs/promises"; import path from "node:path"; - import { afterAll, beforeAll, describe, expect, it, vi } from "vitest"; const MEDIA_DIR = path.join(process.cwd(), "tmp-media-test"); diff --git a/src/media/server.ts b/src/media/server.ts index ab1574f3c94..6f7543b1b20 100644 --- a/src/media/server.ts +++ b/src/media/server.ts @@ -1,9 +1,9 @@ -import fs from "node:fs/promises"; import type { Server } from "node:http"; import express, { type Express } from "express"; +import fs from "node:fs/promises"; import { danger } from "../globals.js"; -import { defaultRuntime, type RuntimeEnv } from "../runtime.js"; import { SafeOpenError, openFileWithinRoot } from "../infra/fs-safe.js"; +import { defaultRuntime, type RuntimeEnv } from "../runtime.js"; import { detectMime } from "./mime.js"; import { cleanOldMedia, getMediaDir, MEDIA_MAX_BYTES } from "./store.js"; diff --git a/src/media/store.redirect.test.ts b/src/media/store.redirect.test.ts index 97c54e7aeb6..f940c6052b4 100644 --- a/src/media/store.redirect.test.ts +++ b/src/media/store.redirect.test.ts @@ -1,8 +1,7 @@ +import JSZip from "jszip"; import fs from "node:fs/promises"; import path from "node:path"; import { PassThrough } from "node:stream"; - -import JSZip from "jszip"; import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; const realOs = await vi.importActual("node:os"); diff --git a/src/media/store.test.ts b/src/media/store.test.ts index 169f35ba49d..5e7f510a829 100644 --- a/src/media/store.test.ts +++ b/src/media/store.test.ts @@ -1,10 +1,9 @@ +import JSZip from "jszip"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; -import JSZip from "jszip"; import sharp from "sharp"; import { afterAll, beforeAll, describe, expect, it } from "vitest"; - import { isPathWithinBase } from "../../test/helpers/paths.js"; describe("media store", () => { diff --git a/src/media/store.ts b/src/media/store.ts index 8ab481d6cbe..43b8c5851d3 100644 --- a/src/media/store.ts +++ b/src/media/store.ts @@ -5,8 +5,8 @@ import { request as httpRequest } from "node:http"; import { request as httpsRequest } from "node:https"; import path from "node:path"; import { pipeline } from "node:stream/promises"; -import { resolveConfigDir } from "../utils.js"; import { resolvePinnedHostname } from "../infra/net/ssrf.js"; +import { resolveConfigDir } from "../utils.js"; import { detectMime, extensionForMime } from "./mime.js"; const resolveMediaDir = () => path.join(resolveConfigDir(), "media"); diff --git a/src/memory/batch-gemini.ts b/src/memory/batch-gemini.ts index 698a5173065..60c8c7e9a8a 100644 --- a/src/memory/batch-gemini.ts +++ b/src/memory/batch-gemini.ts @@ -1,6 +1,6 @@ -import { createSubsystemLogger } from "../logging/subsystem.js"; -import { isTruthyEnvValue } from "../infra/env.js"; import type { GeminiEmbeddingClient } from "./embeddings-gemini.js"; +import { isTruthyEnvValue } from "../infra/env.js"; +import { createSubsystemLogger } from "../logging/subsystem.js"; import { hashText } from "./internal.js"; export type GeminiBatchRequest = { diff --git a/src/memory/batch-openai.ts b/src/memory/batch-openai.ts index ac12f8bd1f6..292730704b5 100644 --- a/src/memory/batch-openai.ts +++ b/src/memory/batch-openai.ts @@ -1,5 +1,5 @@ -import { retryAsync } from "../infra/retry.js"; import type { OpenAiEmbeddingClient } from "./embeddings-openai.js"; +import { retryAsync } from "../infra/retry.js"; import { hashText } from "./internal.js"; export type OpenAiBatchRequest = { diff --git a/src/memory/embeddings-gemini.ts b/src/memory/embeddings-gemini.ts index bb11dda134e..95f8137ea35 100644 --- a/src/memory/embeddings-gemini.ts +++ b/src/memory/embeddings-gemini.ts @@ -1,7 +1,7 @@ +import type { EmbeddingProvider, EmbeddingProviderOptions } from "./embeddings.js"; import { requireApiKey, resolveApiKeyForProvider } from "../agents/model-auth.js"; import { isTruthyEnvValue } from "../infra/env.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; -import type { EmbeddingProvider, EmbeddingProviderOptions } from "./embeddings.js"; export type GeminiEmbeddingClient = { baseUrl: string; diff --git a/src/memory/embeddings-openai.ts b/src/memory/embeddings-openai.ts index 7efe3290e2f..d125fa816b0 100644 --- a/src/memory/embeddings-openai.ts +++ b/src/memory/embeddings-openai.ts @@ -1,5 +1,5 @@ -import { requireApiKey, resolveApiKeyForProvider } from "../agents/model-auth.js"; import type { EmbeddingProvider, EmbeddingProviderOptions } from "./embeddings.js"; +import { requireApiKey, resolveApiKeyForProvider } from "../agents/model-auth.js"; export type OpenAiEmbeddingClient = { baseUrl: string; diff --git a/src/memory/embeddings.test.ts b/src/memory/embeddings.test.ts index 55a261a1cc8..de0081b3a9b 100644 --- a/src/memory/embeddings.test.ts +++ b/src/memory/embeddings.test.ts @@ -1,5 +1,4 @@ import { afterEach, describe, expect, it, vi } from "vitest"; - import { DEFAULT_GEMINI_EMBEDDING_MODEL } from "./embeddings-gemini.js"; vi.mock("../agents/model-auth.js", () => ({ diff --git a/src/memory/embeddings.ts b/src/memory/embeddings.ts index 00f674354eb..a8926fe939f 100644 --- a/src/memory/embeddings.ts +++ b/src/memory/embeddings.ts @@ -1,6 +1,5 @@ -import fsSync from "node:fs"; - import type { Llama, LlamaEmbeddingContext, LlamaModel } from "node-llama-cpp"; +import fsSync from "node:fs"; import type { OpenClawConfig } from "../config/config.js"; import { resolveUserPath } from "../utils.js"; import { createGeminiEmbeddingProvider, type GeminiEmbeddingClient } from "./embeddings-gemini.js"; diff --git a/src/memory/hybrid.test.ts b/src/memory/hybrid.test.ts index 294dc995008..7105e9ecf27 100644 --- a/src/memory/hybrid.test.ts +++ b/src/memory/hybrid.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { bm25RankToScore, buildFtsQuery, mergeHybridResults } from "./hybrid.js"; describe("memory hybrid helpers", () => { diff --git a/src/memory/index.test.ts b/src/memory/index.test.ts index a772700e326..3f01ab85593 100644 --- a/src/memory/index.test.ts +++ b/src/memory/index.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import { getMemorySearchManager, type MemoryIndexManager } from "./index.js"; let embedBatchCalls = 0; diff --git a/src/memory/internal.test.ts b/src/memory/internal.test.ts index 7530d8e4445..0f5199892a9 100644 --- a/src/memory/internal.test.ts +++ b/src/memory/internal.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it } from "vitest"; - import { chunkMarkdown, listMemoryFiles, normalizeExtraMemoryPaths } from "./internal.js"; describe("normalizeExtraMemoryPaths", () => { diff --git a/src/memory/manager-cache-key.ts b/src/memory/manager-cache-key.ts index 1b03fcd6746..0ab15a1372e 100644 --- a/src/memory/manager-cache-key.ts +++ b/src/memory/manager-cache-key.ts @@ -1,7 +1,6 @@ import type { ResolvedMemorySearchConfig } from "../agents/memory-search.js"; - -import { hashText } from "./internal.js"; import { fingerprintHeaderNames } from "./headers-fingerprint.js"; +import { hashText } from "./internal.js"; export function computeMemoryManagerCacheKey(params: { agentId: string; diff --git a/src/memory/manager-search.ts b/src/memory/manager-search.ts index 3880c1e3604..f77751a618b 100644 --- a/src/memory/manager-search.ts +++ b/src/memory/manager-search.ts @@ -1,5 +1,4 @@ import type { DatabaseSync } from "node:sqlite"; - import { truncateUtf16Safe } from "../utils.js"; import { cosineSimilarity, parseEmbedding } from "./internal.js"; diff --git a/src/memory/manager.async-search.test.ts b/src/memory/manager.async-search.test.ts index 020639b9e26..7f60ef0ea9f 100644 --- a/src/memory/manager.async-search.test.ts +++ b/src/memory/manager.async-search.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import { getMemorySearchManager, type MemoryIndexManager } from "./index.js"; const embedBatch = vi.fn(async () => []); diff --git a/src/memory/manager.atomic-reindex.test.ts b/src/memory/manager.atomic-reindex.test.ts index 14ab997dfdb..4f4f0dc32b9 100644 --- a/src/memory/manager.atomic-reindex.test.ts +++ b/src/memory/manager.atomic-reindex.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import { getMemorySearchManager, type MemoryIndexManager } from "./index.js"; let shouldFail = false; diff --git a/src/memory/manager.batch.test.ts b/src/memory/manager.batch.test.ts index a2116529d01..60586d2ec58 100644 --- a/src/memory/manager.batch.test.ts +++ b/src/memory/manager.batch.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import { getMemorySearchManager, type MemoryIndexManager } from "./index.js"; const embedBatch = vi.fn(async () => []); diff --git a/src/memory/manager.embedding-batches.test.ts b/src/memory/manager.embedding-batches.test.ts index 6070adb20b1..3c4019d366b 100644 --- a/src/memory/manager.embedding-batches.test.ts +++ b/src/memory/manager.embedding-batches.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import { getMemorySearchManager, type MemoryIndexManager } from "./index.js"; const embedBatch = vi.fn(async (texts: string[]) => texts.map(() => [0, 1, 0])); diff --git a/src/memory/manager.sync-errors-do-not-crash.test.ts b/src/memory/manager.sync-errors-do-not-crash.test.ts index c907384f86d..faa56cc11f3 100644 --- a/src/memory/manager.sync-errors-do-not-crash.test.ts +++ b/src/memory/manager.sync-errors-do-not-crash.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import { getMemorySearchManager, type MemoryIndexManager } from "./index.js"; vi.mock("chokidar", () => ({ diff --git a/src/memory/manager.ts b/src/memory/manager.ts index 08b1925ea51..684a460b8a3 100644 --- a/src/memory/manager.ts +++ b/src/memory/manager.ts @@ -1,19 +1,25 @@ +import type { DatabaseSync } from "node:sqlite"; +import chokidar, { type FSWatcher } from "chokidar"; import { randomUUID } from "node:crypto"; import fsSync from "node:fs"; import fs from "node:fs/promises"; import path from "node:path"; - -import type { DatabaseSync } from "node:sqlite"; -import chokidar, { type FSWatcher } from "chokidar"; - -import { resolveAgentDir, resolveAgentWorkspaceDir } from "../agents/agent-scope.js"; import type { ResolvedMemorySearchConfig } from "../agents/memory-search.js"; -import { resolveMemorySearchConfig } from "../agents/memory-search.js"; import type { OpenClawConfig } from "../config/config.js"; +import { resolveAgentDir, resolveAgentWorkspaceDir } from "../agents/agent-scope.js"; +import { resolveMemorySearchConfig } from "../agents/memory-search.js"; import { resolveSessionTranscriptsDirForAgent } from "../config/sessions/paths.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { onSessionTranscriptUpdate } from "../sessions/transcript-events.js"; import { resolveUserPath } from "../utils.js"; +import { runGeminiEmbeddingBatches, type GeminiBatchRequest } from "./batch-gemini.js"; +import { + OPENAI_BATCH_ENDPOINT, + type OpenAiBatchRequest, + runOpenAiEmbeddingBatches, +} from "./batch-openai.js"; +import { DEFAULT_GEMINI_EMBEDDING_MODEL } from "./embeddings-gemini.js"; +import { DEFAULT_OPENAI_EMBEDDING_MODEL } from "./embeddings-openai.js"; import { createEmbeddingProvider, type EmbeddingProvider, @@ -21,14 +27,7 @@ import { type GeminiEmbeddingClient, type OpenAiEmbeddingClient, } from "./embeddings.js"; -import { DEFAULT_GEMINI_EMBEDDING_MODEL } from "./embeddings-gemini.js"; -import { DEFAULT_OPENAI_EMBEDDING_MODEL } from "./embeddings-openai.js"; -import { - OPENAI_BATCH_ENDPOINT, - type OpenAiBatchRequest, - runOpenAiEmbeddingBatches, -} from "./batch-openai.js"; -import { runGeminiEmbeddingBatches, type GeminiBatchRequest } from "./batch-gemini.js"; +import { bm25RankToScore, buildFtsQuery, mergeHybridResults } from "./hybrid.js"; import { buildFileEntry, chunkMarkdown, @@ -41,11 +40,10 @@ import { type MemoryFileEntry, parseEmbedding, } from "./internal.js"; -import { bm25RankToScore, buildFtsQuery, mergeHybridResults } from "./hybrid.js"; import { searchKeyword, searchVector } from "./manager-search.js"; import { ensureMemoryIndexSchema } from "./memory-schema.js"; -import { requireNodeSqlite } from "./sqlite.js"; import { loadSqliteVecExtension } from "./sqlite-vec.js"; +import { requireNodeSqlite } from "./sqlite.js"; type MemorySource = "memory" | "sessions"; diff --git a/src/memory/manager.vector-dedupe.test.ts b/src/memory/manager.vector-dedupe.test.ts index 6778f92dec4..eb15fb481ee 100644 --- a/src/memory/manager.vector-dedupe.test.ts +++ b/src/memory/manager.vector-dedupe.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import { getMemorySearchManager, type MemoryIndexManager } from "./index.js"; import { buildFileEntry } from "./internal.js"; diff --git a/src/memory/provider-key.ts b/src/memory/provider-key.ts index 09485c0f2e4..494e2445a1b 100644 --- a/src/memory/provider-key.ts +++ b/src/memory/provider-key.ts @@ -1,5 +1,5 @@ -import { hashText } from "./internal.js"; import { fingerprintHeaderNames } from "./headers-fingerprint.js"; +import { hashText } from "./internal.js"; export function computeEmbeddingProviderKey(params: { providerId: string; diff --git a/src/memory/session-files.ts b/src/memory/session-files.ts index 8a953ffcafb..1823e96690a 100644 --- a/src/memory/session-files.ts +++ b/src/memory/session-files.ts @@ -1,6 +1,5 @@ import fs from "node:fs/promises"; import path from "node:path"; - import { resolveSessionTranscriptsDirForAgent } from "../config/sessions/paths.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { hashText } from "./internal.js"; diff --git a/src/memory/sqlite.ts b/src/memory/sqlite.ts index 98b006941ed..bbda48dd203 100644 --- a/src/memory/sqlite.ts +++ b/src/memory/sqlite.ts @@ -1,5 +1,4 @@ import { createRequire } from "node:module"; - import { installProcessWarningFilter } from "../infra/warnings.js"; const require = createRequire(import.meta.url); diff --git a/src/memory/sync-memory-files.ts b/src/memory/sync-memory-files.ts index 7ed92d80de4..e282bba7cf5 100644 --- a/src/memory/sync-memory-files.ts +++ b/src/memory/sync-memory-files.ts @@ -1,5 +1,4 @@ import type { DatabaseSync } from "node:sqlite"; - import { createSubsystemLogger } from "../logging/subsystem.js"; import { buildFileEntry, listMemoryFiles, type MemoryFileEntry } from "./internal.js"; diff --git a/src/memory/sync-session-files.ts b/src/memory/sync-session-files.ts index b55108a7f0d..efcf1b4aa39 100644 --- a/src/memory/sync-session-files.ts +++ b/src/memory/sync-session-files.ts @@ -1,7 +1,6 @@ import type { DatabaseSync } from "node:sqlite"; - -import { createSubsystemLogger } from "../logging/subsystem.js"; import type { SessionFileEntry } from "./session-files.js"; +import { createSubsystemLogger } from "../logging/subsystem.js"; import { buildSessionEntry, listSessionFilesForAgent, diff --git a/src/node-host/config.ts b/src/node-host/config.ts index 42d59d4c492..ebb11614518 100644 --- a/src/node-host/config.ts +++ b/src/node-host/config.ts @@ -1,7 +1,6 @@ import crypto from "node:crypto"; import fs from "node:fs/promises"; import path from "node:path"; - import { resolveStateDir } from "../config/paths.js"; export type NodeHostGatewayConfig = { diff --git a/src/node-host/runner.test.ts b/src/node-host/runner.test.ts index 9d89a009705..932f811ed44 100644 --- a/src/node-host/runner.test.ts +++ b/src/node-host/runner.test.ts @@ -1,5 +1,4 @@ import { describe, expect, test } from "vitest"; - import { buildNodeInvokeResultParams } from "./runner.js"; describe("buildNodeInvokeResultParams", () => { diff --git a/src/node-host/runner.ts b/src/node-host/runner.ts index d3da92d405b..e0a425c6b65 100644 --- a/src/node-host/runner.ts +++ b/src/node-host/runner.ts @@ -1,9 +1,18 @@ -import crypto from "node:crypto"; import { spawn } from "node:child_process"; +import crypto from "node:crypto"; import fs from "node:fs"; import fsPromises from "node:fs/promises"; import path from "node:path"; - +import { resolveAgentConfig } from "../agents/agent-scope.js"; +import { resolveBrowserConfig } from "../browser/config.js"; +import { + createBrowserControlContext, + startBrowserControlServiceFromConfig, +} from "../browser/control-service.js"; +import { createBrowserRouteDispatcher } from "../browser/routes/dispatcher.js"; +import { loadConfig } from "../config/config.js"; +import { GatewayClient } from "../gateway/client.js"; +import { loadOrCreateDeviceIdentity } from "../infra/device-identity.js"; import { addAllowlistEntry, analyzeArgvCommand, @@ -31,22 +40,11 @@ import { type ExecHostRunResult, } from "../infra/exec-host.js"; import { getMachineDisplayName } from "../infra/machine-name.js"; -import { loadOrCreateDeviceIdentity } from "../infra/device-identity.js"; -import { loadConfig } from "../config/config.js"; -import { resolveBrowserConfig } from "../browser/config.js"; -import { - createBrowserControlContext, - startBrowserControlServiceFromConfig, -} from "../browser/control-service.js"; -import { createBrowserRouteDispatcher } from "../browser/routes/dispatcher.js"; -import { detectMime } from "../media/mime.js"; -import { resolveAgentConfig } from "../agents/agent-scope.js"; import { ensureOpenClawCliOnPath } from "../infra/path-env.js"; -import { VERSION } from "../version.js"; +import { detectMime } from "../media/mime.js"; import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; - +import { VERSION } from "../version.js"; import { ensureNodeHostConfig, saveNodeHostConfig, type NodeHostGatewayConfig } from "./config.js"; -import { GatewayClient } from "../gateway/client.js"; type NodeHostRunOptions = { gatewayHost: string; diff --git a/src/pairing/pairing-labels.ts b/src/pairing/pairing-labels.ts index a7a5145434e..b230cd2d38a 100644 --- a/src/pairing/pairing-labels.ts +++ b/src/pairing/pairing-labels.ts @@ -1,5 +1,5 @@ -import { getPairingAdapter } from "../channels/plugins/pairing.js"; import type { PairingChannel } from "./pairing-store.js"; +import { getPairingAdapter } from "../channels/plugins/pairing.js"; export function resolvePairingIdLabel(channel: PairingChannel): string { return getPairingAdapter(channel)?.idLabel ?? "userId"; diff --git a/src/pairing/pairing-messages.test.ts b/src/pairing/pairing-messages.test.ts index 30586ee8a09..d8994e88c9c 100644 --- a/src/pairing/pairing-messages.test.ts +++ b/src/pairing/pairing-messages.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest"; - import { buildPairingReply } from "./pairing-messages.js"; describe("buildPairingReply", () => { diff --git a/src/pairing/pairing-messages.ts b/src/pairing/pairing-messages.ts index 7055145cfe2..86e3b471a74 100644 --- a/src/pairing/pairing-messages.ts +++ b/src/pairing/pairing-messages.ts @@ -1,5 +1,5 @@ -import { formatCliCommand } from "../cli/command-format.js"; import type { PairingChannel } from "./pairing-store.js"; +import { formatCliCommand } from "../cli/command-format.js"; export function buildPairingReply(params: { channel: PairingChannel; diff --git a/src/pairing/pairing-store.test.ts b/src/pairing/pairing-store.test.ts index f4c47b7131f..f858d0f3f61 100644 --- a/src/pairing/pairing-store.test.ts +++ b/src/pairing/pairing-store.test.ts @@ -2,9 +2,7 @@ import crypto from "node:crypto"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it, vi } from "vitest"; - import { resolveOAuthDir } from "../config/paths.js"; import { listChannelPairingRequests, upsertChannelPairingRequest } from "./pairing-store.js"; diff --git a/src/pairing/pairing-store.ts b/src/pairing/pairing-store.ts index c6fd63a2849..c394a1f76a4 100644 --- a/src/pairing/pairing-store.ts +++ b/src/pairing/pairing-store.ts @@ -2,10 +2,9 @@ import crypto from "node:crypto"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import lockfile from "proper-lockfile"; -import { getPairingAdapter } from "../channels/plugins/pairing.js"; import type { ChannelId, ChannelPairingAdapter } from "../channels/plugins/types.js"; +import { getPairingAdapter } from "../channels/plugins/pairing.js"; import { resolveOAuthDir, resolveStateDir } from "../config/paths.js"; const PAIRING_CODE_LENGTH = 8; diff --git a/src/plugin-sdk/index.test.ts b/src/plugin-sdk/index.test.ts index 920e2af2ac3..ae085b00d9c 100644 --- a/src/plugin-sdk/index.test.ts +++ b/src/plugin-sdk/index.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import * as sdk from "./index.js"; describe("plugin-sdk exports", () => { diff --git a/src/plugins/cli.ts b/src/plugins/cli.ts index 0d1da1b0c12..fe13718554c 100644 --- a/src/plugins/cli.ts +++ b/src/plugins/cli.ts @@ -1,11 +1,10 @@ import type { Command } from "commander"; - -import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; import type { OpenClawConfig } from "../config/config.js"; +import type { PluginLogger } from "./types.js"; +import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; import { loadConfig } from "../config/config.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { loadOpenClawPlugins } from "./loader.js"; -import type { PluginLogger } from "./types.js"; const log = createSubsystemLogger("plugins"); diff --git a/src/plugins/config-state.test.ts b/src/plugins/config-state.test.ts index c5c4924eb3c..9a0cdf4f59f 100644 --- a/src/plugins/config-state.test.ts +++ b/src/plugins/config-state.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { normalizePluginsConfig } from "./config-state.js"; describe("normalizePluginsConfig", () => { diff --git a/src/plugins/config-state.ts b/src/plugins/config-state.ts index fc6e2ce6568..72344daa33f 100644 --- a/src/plugins/config-state.ts +++ b/src/plugins/config-state.ts @@ -1,6 +1,6 @@ import type { OpenClawConfig } from "../config/config.js"; -import { defaultSlotIdForKey } from "./slots.js"; import type { PluginRecord } from "./registry.js"; +import { defaultSlotIdForKey } from "./slots.js"; export type NormalizedPluginsConfig = { enabled: boolean; diff --git a/src/plugins/discovery.ts b/src/plugins/discovery.ts index 41b45d813a1..fd9ca62c27f 100644 --- a/src/plugins/discovery.ts +++ b/src/plugins/discovery.ts @@ -1,6 +1,6 @@ import fs from "node:fs"; import path from "node:path"; - +import type { PluginDiagnostic, PluginOrigin } from "./types.js"; import { resolveConfigDir, resolveUserPath } from "../utils.js"; import { resolveBundledPluginsDir } from "./bundled-dir.js"; import { @@ -8,7 +8,6 @@ import { type OpenClawPackageManifest, type PackageManifest, } from "./manifest.js"; -import type { PluginDiagnostic, PluginOrigin } from "./types.js"; const EXTENSION_EXTS = new Set([".ts", ".js", ".mts", ".cts", ".mjs", ".cjs"]); diff --git a/src/plugins/hook-runner-global.ts b/src/plugins/hook-runner-global.ts index 368d7668474..28d741c79c9 100644 --- a/src/plugins/hook-runner-global.ts +++ b/src/plugins/hook-runner-global.ts @@ -5,9 +5,9 @@ * and can be called from anywhere in the codebase. */ +import type { PluginRegistry } from "./registry.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { createHookRunner, type HookRunner } from "./hooks.js"; -import type { PluginRegistry } from "./registry.js"; const log = createSubsystemLogger("plugins"); diff --git a/src/plugins/http-registry.ts b/src/plugins/http-registry.ts index ae84fc91c41..4234d3c2b76 100644 --- a/src/plugins/http-registry.ts +++ b/src/plugins/http-registry.ts @@ -1,8 +1,7 @@ import type { IncomingMessage, ServerResponse } from "node:http"; - import type { PluginHttpRouteRegistration, PluginRegistry } from "./registry.js"; -import { requireActivePluginRegistry } from "./runtime.js"; import { normalizePluginHttpPath } from "./http-path.js"; +import { requireActivePluginRegistry } from "./runtime.js"; export type PluginHttpRouteHandler = ( req: IncomingMessage, diff --git a/src/plugins/install.test.ts b/src/plugins/install.test.ts index 412165fc7cc..22bd0990bf0 100644 --- a/src/plugins/install.test.ts +++ b/src/plugins/install.test.ts @@ -1,9 +1,9 @@ +import JSZip from "jszip"; import { spawnSync } from "node:child_process"; import { randomUUID } from "node:crypto"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; -import JSZip from "jszip"; import { afterEach, describe, expect, it } from "vitest"; const tempDirs: string[] = []; diff --git a/src/plugins/install.ts b/src/plugins/install.ts index a0d02873270..fa27dad2a4f 100644 --- a/src/plugins/install.ts +++ b/src/plugins/install.ts @@ -2,8 +2,6 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { MANIFEST_KEY } from "../compat/legacy-names.js"; -import { runCommandWithTimeout } from "../process/exec.js"; -import { CONFIG_DIR, resolveUserPath } from "../utils.js"; import { extractArchive, fileExists, @@ -11,6 +9,8 @@ import { resolveArchiveKind, resolvePackedRootDir, } from "../infra/archive.js"; +import { runCommandWithTimeout } from "../process/exec.js"; +import { CONFIG_DIR, resolveUserPath } from "../utils.js"; type PluginInstallLogger = { info?: (message: string) => void; diff --git a/src/plugins/loader.test.ts b/src/plugins/loader.test.ts index 8610a4b495d..cd27cc69ef2 100644 --- a/src/plugins/loader.test.ts +++ b/src/plugins/loader.test.ts @@ -3,7 +3,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { afterEach, describe, expect, it } from "vitest"; - import { loadOpenClawPlugins } from "./loader.js"; type TempPlugin = { dir: string; file: string; id: string }; diff --git a/src/plugins/loader.ts b/src/plugins/loader.ts index f1b28ac3f5e..6ea8a2215b2 100644 --- a/src/plugins/loader.ts +++ b/src/plugins/loader.ts @@ -1,32 +1,31 @@ +import { createJiti } from "jiti"; import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; -import { createJiti } from "jiti"; - import type { OpenClawConfig } from "../config/config.js"; import type { GatewayRequestHandler } from "../gateway/server-methods/types.js"; -import { createSubsystemLogger } from "../logging/subsystem.js"; -import { resolveUserPath } from "../utils.js"; -import { discoverOpenClawPlugins } from "./discovery.js"; -import { loadPluginManifestRegistry } from "./manifest-registry.js"; -import { - normalizePluginsConfig, - resolveEnableState, - resolveMemorySlotDecision, - type NormalizedPluginsConfig, -} from "./config-state.js"; -import { initializeGlobalHookRunner } from "./hook-runner-global.js"; -import { clearPluginCommands } from "./commands.js"; -import { createPluginRegistry, type PluginRecord, type PluginRegistry } from "./registry.js"; -import { createPluginRuntime } from "./runtime/index.js"; -import { setActivePluginRegistry } from "./runtime.js"; -import { validateJsonSchemaValue } from "./schema-validator.js"; import type { OpenClawPluginDefinition, OpenClawPluginModule, PluginDiagnostic, PluginLogger, } from "./types.js"; +import { createSubsystemLogger } from "../logging/subsystem.js"; +import { resolveUserPath } from "../utils.js"; +import { clearPluginCommands } from "./commands.js"; +import { + normalizePluginsConfig, + resolveEnableState, + resolveMemorySlotDecision, + type NormalizedPluginsConfig, +} from "./config-state.js"; +import { discoverOpenClawPlugins } from "./discovery.js"; +import { initializeGlobalHookRunner } from "./hook-runner-global.js"; +import { loadPluginManifestRegistry } from "./manifest-registry.js"; +import { createPluginRegistry, type PluginRecord, type PluginRegistry } from "./registry.js"; +import { setActivePluginRegistry } from "./runtime.js"; +import { createPluginRuntime } from "./runtime/index.js"; +import { validateJsonSchemaValue } from "./schema-validator.js"; export type PluginLoadResult = PluginRegistry; diff --git a/src/plugins/manifest-registry.ts b/src/plugins/manifest-registry.ts index c7dfd250a14..4980ddad617 100644 --- a/src/plugins/manifest-registry.ts +++ b/src/plugins/manifest-registry.ts @@ -1,11 +1,10 @@ import fs from "node:fs"; - import type { OpenClawConfig } from "../config/config.js"; +import type { PluginConfigUiHint, PluginDiagnostic, PluginKind, PluginOrigin } from "./types.js"; import { resolveUserPath } from "../utils.js"; import { normalizePluginsConfig, type NormalizedPluginsConfig } from "./config-state.js"; import { discoverOpenClawPlugins, type PluginCandidate } from "./discovery.js"; import { loadPluginManifest, type PluginManifest } from "./manifest.js"; -import type { PluginConfigUiHint, PluginDiagnostic, PluginKind, PluginOrigin } from "./types.js"; export type PluginManifestRecord = { id: string; diff --git a/src/plugins/manifest.ts b/src/plugins/manifest.ts index 952035d3222..023dc28d4dd 100644 --- a/src/plugins/manifest.ts +++ b/src/plugins/manifest.ts @@ -1,8 +1,7 @@ import fs from "node:fs"; import path from "node:path"; - -import { MANIFEST_KEY } from "../compat/legacy-names.js"; import type { PluginConfigUiHint, PluginKind } from "./types.js"; +import { MANIFEST_KEY } from "../compat/legacy-names.js"; export const PLUGIN_MANIFEST_FILENAME = "openclaw.plugin.json"; export const PLUGIN_MANIFEST_FILENAMES = [PLUGIN_MANIFEST_FILENAME] as const; diff --git a/src/plugins/providers.ts b/src/plugins/providers.ts index 7ab2d1848e1..0236a5d4d9d 100644 --- a/src/plugins/providers.ts +++ b/src/plugins/providers.ts @@ -1,6 +1,6 @@ +import type { ProviderPlugin } from "./types.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { loadOpenClawPlugins, type PluginLoadOptions } from "./loader.js"; -import type { ProviderPlugin } from "./types.js"; const log = createSubsystemLogger("plugins"); diff --git a/src/plugins/registry.ts b/src/plugins/registry.ts index 958f43da801..ef763910036 100644 --- a/src/plugins/registry.ts +++ b/src/plugins/registry.ts @@ -1,3 +1,4 @@ +import path from "node:path"; import type { AnyAgentTool } from "../agents/tools/common.js"; import type { ChannelDock } from "../channels/dock.js"; import type { ChannelPlugin } from "../channels/plugins/types.js"; @@ -5,8 +6,8 @@ import type { GatewayRequestHandler, GatewayRequestHandlers, } from "../gateway/server-methods/types.js"; -import { registerInternalHook } from "../hooks/internal-hooks.js"; -import { resolveUserPath } from "../utils.js"; +import type { HookEntry } from "../hooks/types.js"; +import type { PluginRuntime } from "./runtime/types.js"; import type { OpenClawPluginApi, OpenClawPluginChannelRegistration, @@ -28,10 +29,9 @@ import type { PluginHookHandlerMap, PluginHookRegistration as TypedPluginHookRegistration, } from "./types.js"; +import { registerInternalHook } from "../hooks/internal-hooks.js"; +import { resolveUserPath } from "../utils.js"; import { registerPluginCommand } from "./commands.js"; -import type { PluginRuntime } from "./runtime/types.js"; -import type { HookEntry } from "../hooks/types.js"; -import path from "node:path"; import { normalizePluginHttpPath } from "./http-path.js"; export type PluginToolRegistration = { diff --git a/src/plugins/runtime/index.ts b/src/plugins/runtime/index.ts index 23e5ed2d508..4f3618a76e3 100644 --- a/src/plugins/runtime/index.ts +++ b/src/plugins/runtime/index.ts @@ -1,5 +1,9 @@ import { createRequire } from "node:module"; - +import type { PluginRuntime } from "./types.js"; +import { resolveEffectiveMessagesConfig, resolveHumanDelayConfig } from "../../agents/identity.js"; +import { createMemoryGetTool, createMemorySearchTool } from "../../agents/tools/memory-tool.js"; +import { handleSlackAction } from "../../agents/tools/slack-actions.js"; +import { handleWhatsAppAction } from "../../agents/tools/whatsapp-actions.js"; import { chunkByNewline, chunkMarkdownText, @@ -15,16 +19,17 @@ import { shouldComputeCommandAuthorized, } from "../../auto-reply/command-detection.js"; import { shouldHandleTextCommands } from "../../auto-reply/commands-registry.js"; -import { - createInboundDebouncer, - resolveInboundDebounceMs, -} from "../../auto-reply/inbound-debounce.js"; import { formatAgentEnvelope, formatInboundEnvelope, resolveEnvelopeFormatOptions, } from "../../auto-reply/envelope.js"; +import { + createInboundDebouncer, + resolveInboundDebounceMs, +} from "../../auto-reply/inbound-debounce.js"; import { dispatchReplyFromConfig } from "../../auto-reply/reply/dispatch-from-config.js"; +import { finalizeInboundContext } from "../../auto-reply/reply/inbound-context.js"; import { buildMentionRegexes, matchesMentionPatterns, @@ -32,26 +37,22 @@ import { } from "../../auto-reply/reply/mentions.js"; import { dispatchReplyWithBufferedBlockDispatcher } from "../../auto-reply/reply/provider-dispatcher.js"; import { createReplyDispatcherWithTyping } from "../../auto-reply/reply/reply-dispatcher.js"; -import { finalizeInboundContext } from "../../auto-reply/reply/inbound-context.js"; -import { resolveEffectiveMessagesConfig, resolveHumanDelayConfig } from "../../agents/identity.js"; -import { createMemoryGetTool, createMemorySearchTool } from "../../agents/tools/memory-tool.js"; -import { handleSlackAction } from "../../agents/tools/slack-actions.js"; -import { handleWhatsAppAction } from "../../agents/tools/whatsapp-actions.js"; import { removeAckReactionAfterReply, shouldAckReaction } from "../../channels/ack-reactions.js"; import { resolveCommandAuthorizedFromAuthorizers } from "../../channels/command-gating.js"; -import { recordInboundSession } from "../../channels/session.js"; import { discordMessageActions } from "../../channels/plugins/actions/discord.js"; import { signalMessageActions } from "../../channels/plugins/actions/signal.js"; import { telegramMessageActions } from "../../channels/plugins/actions/telegram.js"; import { createWhatsAppLoginTool } from "../../channels/plugins/agent-tools/whatsapp-login.js"; +import { recordInboundSession } from "../../channels/session.js"; import { monitorWebChannel } from "../../channels/web/index.js"; +import { registerMemoryCli } from "../../cli/memory-cli.js"; +import { loadConfig, writeConfigFile } from "../../config/config.js"; import { resolveChannelGroupPolicy, resolveChannelGroupRequireMention, } from "../../config/group-policy.js"; import { resolveMarkdownTableMode } from "../../config/markdown-tables.js"; import { resolveStateDir } from "../../config/paths.js"; -import { loadConfig, writeConfigFile } from "../../config/config.js"; import { readSessionUpdatedAt, recordSessionMetaFromInbound, @@ -68,15 +69,34 @@ import { probeDiscord } from "../../discord/probe.js"; import { resolveDiscordChannelAllowlist } from "../../discord/resolve-channels.js"; import { resolveDiscordUserAllowlist } from "../../discord/resolve-users.js"; import { sendMessageDiscord, sendPollDiscord } from "../../discord/send.js"; -import { getChannelActivity, recordChannelActivity } from "../../infra/channel-activity.js"; -import { enqueueSystemEvent } from "../../infra/system-events.js"; +import { shouldLogVerbose } from "../../globals.js"; import { monitorIMessageProvider } from "../../imessage/monitor.js"; import { probeIMessage } from "../../imessage/probe.js"; import { sendMessageIMessage } from "../../imessage/send.js"; -import { shouldLogVerbose } from "../../globals.js"; -import { convertMarkdownTables } from "../../markdown/tables.js"; +import { getChannelActivity, recordChannelActivity } from "../../infra/channel-activity.js"; +import { enqueueSystemEvent } from "../../infra/system-events.js"; +import { + listLineAccountIds, + normalizeAccountId as normalizeLineAccountId, + resolveDefaultLineAccountId, + resolveLineAccount, +} from "../../line/accounts.js"; +import { monitorLineProvider } from "../../line/monitor.js"; +import { probeLineBot } from "../../line/probe.js"; +import { + createQuickReplyItems, + pushMessageLine, + pushMessagesLine, + pushFlexMessage, + pushTemplateMessage, + pushLocationMessage, + pushTextMessageWithQuickReplies, + sendMessageLine, +} from "../../line/send.js"; +import { buildTemplateMessageFromPayload } from "../../line/template-messages.js"; import { getChildLogger } from "../../logging.js"; import { normalizeLogLevel } from "../../logging/levels.js"; +import { convertMarkdownTables } from "../../markdown/tables.js"; import { isVoiceCompatibleAudio } from "../../media/audio.js"; import { mediaKindFromMime } from "../../media/constants.js"; import { fetchRemoteMedia } from "../../media/fetch.js"; @@ -93,11 +113,11 @@ import { resolveAgentRoute } from "../../routing/resolve-route.js"; import { monitorSignalProvider } from "../../signal/index.js"; import { probeSignal } from "../../signal/probe.js"; import { sendMessageSignal } from "../../signal/send.js"; -import { monitorSlackProvider } from "../../slack/index.js"; import { listSlackDirectoryGroupsLive, listSlackDirectoryPeersLive, } from "../../slack/directory-live.js"; +import { monitorSlackProvider } from "../../slack/index.js"; import { probeSlack } from "../../slack/probe.js"; import { resolveSlackChannelAllowlist } from "../../slack/resolve-channels.js"; import { resolveSlackUserAllowlist } from "../../slack/resolve-users.js"; @@ -110,7 +130,7 @@ import { monitorTelegramProvider } from "../../telegram/monitor.js"; import { probeTelegram } from "../../telegram/probe.js"; import { sendMessageTelegram } from "../../telegram/send.js"; import { resolveTelegramToken } from "../../telegram/token.js"; -import { loadWebMedia } from "../../web/media.js"; +import { textToSpeechTelephony } from "../../tts/tts.js"; import { getActiveWebListener } from "../../web/active-listener.js"; import { getWebAuthAgeMs, @@ -119,33 +139,11 @@ import { readWebSelfId, webAuthExists, } from "../../web/auth-store.js"; -import { loginWeb } from "../../web/login.js"; import { startWebLoginWithQr, waitForWebLogin } from "../../web/login-qr.js"; +import { loginWeb } from "../../web/login.js"; +import { loadWebMedia } from "../../web/media.js"; import { sendMessageWhatsApp, sendPollWhatsApp } from "../../web/outbound.js"; -import { registerMemoryCli } from "../../cli/memory-cli.js"; import { formatNativeDependencyHint } from "./native-deps.js"; -import { textToSpeechTelephony } from "../../tts/tts.js"; -import { - listLineAccountIds, - normalizeAccountId as normalizeLineAccountId, - resolveDefaultLineAccountId, - resolveLineAccount, -} from "../../line/accounts.js"; -import { probeLineBot } from "../../line/probe.js"; -import { - createQuickReplyItems, - pushMessageLine, - pushMessagesLine, - pushFlexMessage, - pushTemplateMessage, - pushLocationMessage, - pushTextMessageWithQuickReplies, - sendMessageLine, -} from "../../line/send.js"; -import { monitorLineProvider } from "../../line/monitor.js"; -import { buildTemplateMessageFromPayload } from "../../line/template-messages.js"; - -import type { PluginRuntime } from "./types.js"; let cachedVersion: string | null = null; diff --git a/src/plugins/services.ts b/src/plugins/services.ts index 8c71300c20d..09e96634c7e 100644 --- a/src/plugins/services.ts +++ b/src/plugins/services.ts @@ -1,7 +1,7 @@ import type { OpenClawConfig } from "../config/config.js"; +import type { PluginRegistry } from "./registry.js"; import { STATE_DIR } from "../config/paths.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; -import type { PluginRegistry } from "./registry.js"; const log = createSubsystemLogger("plugins"); diff --git a/src/plugins/slots.test.ts b/src/plugins/slots.test.ts index 6fc1a2c8382..bc1cca8d967 100644 --- a/src/plugins/slots.test.ts +++ b/src/plugins/slots.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { applyExclusiveSlotSelection } from "./slots.js"; diff --git a/src/plugins/status.ts b/src/plugins/status.ts index b5d444cc3b0..9077602a4d6 100644 --- a/src/plugins/status.ts +++ b/src/plugins/status.ts @@ -1,9 +1,9 @@ +import type { PluginRegistry } from "./registry.js"; import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; import { resolveDefaultAgentWorkspaceDir } from "../agents/workspace.js"; import { loadConfig } from "../config/config.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { loadOpenClawPlugins } from "./loader.js"; -import type { PluginRegistry } from "./registry.js"; export type PluginStatusReport = PluginRegistry & { workspaceDir?: string; diff --git a/src/plugins/tools.optional.test.ts b/src/plugins/tools.optional.test.ts index 53efdc1d0c0..1f15eec90ea 100644 --- a/src/plugins/tools.optional.test.ts +++ b/src/plugins/tools.optional.test.ts @@ -2,9 +2,7 @@ import { randomUUID } from "node:crypto"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import { afterEach, describe, expect, it } from "vitest"; - import { resolvePluginTools } from "./tools.js"; type TempPlugin = { dir: string; file: string; id: string }; diff --git a/src/plugins/tools.ts b/src/plugins/tools.ts index eebc92cabef..4284c87d60e 100644 --- a/src/plugins/tools.ts +++ b/src/plugins/tools.ts @@ -1,8 +1,8 @@ import type { AnyAgentTool } from "../agents/tools/common.js"; +import type { OpenClawPluginToolContext } from "./types.js"; import { normalizeToolName } from "../agents/tool-policy.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { loadOpenClawPlugins } from "./loader.js"; -import type { OpenClawPluginToolContext } from "./types.js"; const log = createSubsystemLogger("plugins"); diff --git a/src/plugins/types.ts b/src/plugins/types.ts index 8bc887068b8..4dbab48ff14 100644 --- a/src/plugins/types.ts +++ b/src/plugins/types.ts @@ -1,21 +1,19 @@ -import type { IncomingMessage, ServerResponse } from "node:http"; -import type { Command } from "commander"; - import type { AgentMessage } from "@mariozechner/pi-agent-core"; - +import type { Command } from "commander"; +import type { IncomingMessage, ServerResponse } from "node:http"; import type { AuthProfileCredential, OAuthCredential } from "../agents/auth-profiles/types.js"; import type { AnyAgentTool } from "../agents/tools/common.js"; +import type { ReplyPayload } from "../auto-reply/types.js"; import type { ChannelDock } from "../channels/dock.js"; import type { ChannelPlugin } from "../channels/plugins/types.js"; +import type { createVpsAwareOAuthHandlers } from "../commands/oauth-flow.js"; import type { OpenClawConfig } from "../config/config.js"; +import type { ModelProviderConfig } from "../config/types.js"; +import type { GatewayRequestHandler } from "../gateway/server-methods/types.js"; import type { InternalHookHandler } from "../hooks/internal-hooks.js"; import type { HookEntry } from "../hooks/types.js"; -import type { ModelProviderConfig } from "../config/types.js"; import type { RuntimeEnv } from "../runtime.js"; -import type { ReplyPayload } from "../auto-reply/types.js"; import type { WizardPrompter } from "../wizard/prompts.js"; -import type { createVpsAwareOAuthHandlers } from "../commands/oauth-flow.js"; -import type { GatewayRequestHandler } from "../gateway/server-methods/types.js"; import type { PluginRuntime } from "./runtime/types.js"; export type { PluginRuntime } from "./runtime/types.js"; diff --git a/src/plugins/update.ts b/src/plugins/update.ts index 6e9a2880801..df312dc1e02 100644 --- a/src/plugins/update.ts +++ b/src/plugins/update.ts @@ -1,5 +1,4 @@ import fs from "node:fs/promises"; - import type { OpenClawConfig } from "../config/config.js"; import type { UpdateChannel } from "../infra/update-channels.js"; import { resolveUserPath } from "../utils.js"; diff --git a/src/polls.test.ts b/src/polls.test.ts index 6cf2fed810d..f5cf5d200a6 100644 --- a/src/polls.test.ts +++ b/src/polls.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { normalizePollDurationHours, normalizePollInput } from "./polls.js"; describe("polls", () => { diff --git a/src/postinstall-patcher.test.ts b/src/postinstall-patcher.test.ts index 9e6a2df856c..2d3f6c16811 100644 --- a/src/postinstall-patcher.test.ts +++ b/src/postinstall-patcher.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { describe, expect, it } from "vitest"; - import { applyPatchSet, detectPackageManager, diff --git a/src/process/child-process-bridge.test.ts b/src/process/child-process-bridge.test.ts index 6dec88bd299..0a37ac7504a 100644 --- a/src/process/child-process-bridge.test.ts +++ b/src/process/child-process-bridge.test.ts @@ -2,9 +2,7 @@ import { spawn } from "node:child_process"; import net from "node:net"; import path from "node:path"; import process from "node:process"; - import { afterEach, describe, expect, it } from "vitest"; - import { attachChildProcessBridge } from "./child-process-bridge.js"; function waitForLine(stream: NodeJS.ReadableStream, timeoutMs = 10_000): Promise { diff --git a/src/process/command-queue.ts b/src/process/command-queue.ts index 4e5404aa66b..f9f2f0093f2 100644 --- a/src/process/command-queue.ts +++ b/src/process/command-queue.ts @@ -1,5 +1,5 @@ -import { CommandLane } from "./lanes.js"; import { diagnosticLogger as diag, logLaneDequeue, logLaneEnqueue } from "../logging/diagnostic.js"; +import { CommandLane } from "./lanes.js"; // Minimal in-process queue to serialize command executions. // Default lane ("main") preserves the existing behavior. Additional lanes allow diff --git a/src/process/exec.test.ts b/src/process/exec.test.ts index 7515f60d402..ae8a865ad18 100644 --- a/src/process/exec.test.ts +++ b/src/process/exec.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { runCommandWithTimeout } from "./exec.js"; describe("runCommandWithTimeout", () => { diff --git a/src/process/exec.ts b/src/process/exec.ts index 74a0413b2a4..43b92ed53b6 100644 --- a/src/process/exec.ts +++ b/src/process/exec.ts @@ -1,7 +1,6 @@ import { execFile, spawn } from "node:child_process"; import path from "node:path"; import { promisify } from "node:util"; - import { danger, shouldLogVerbose } from "../globals.js"; import { logDebug, logError } from "../logger.js"; import { resolveCommandStdio } from "./spawn-utils.js"; diff --git a/src/process/spawn-utils.test.ts b/src/process/spawn-utils.test.ts index d290d593874..cb3e0dc1dc0 100644 --- a/src/process/spawn-utils.test.ts +++ b/src/process/spawn-utils.test.ts @@ -1,8 +1,7 @@ +import type { ChildProcess } from "node:child_process"; import { EventEmitter } from "node:events"; import { PassThrough } from "node:stream"; -import type { ChildProcess } from "node:child_process"; import { describe, expect, it, vi } from "vitest"; - import { spawnWithFallback } from "./spawn-utils.js"; function createStubChild() { diff --git a/src/providers/github-copilot-auth.ts b/src/providers/github-copilot-auth.ts index be81164a039..e0f1cf55ce3 100644 --- a/src/providers/github-copilot-auth.ts +++ b/src/providers/github-copilot-auth.ts @@ -1,10 +1,9 @@ import { intro, note, outro, spinner } from "@clack/prompts"; - +import type { RuntimeEnv } from "../runtime.js"; import { ensureAuthProfileStore, upsertAuthProfile } from "../agents/auth-profiles.js"; import { updateConfig } from "../commands/models/shared.js"; import { applyAuthProfileConfig } from "../commands/onboard-auth.js"; import { logConfigUpdated } from "../config/logging.js"; -import type { RuntimeEnv } from "../runtime.js"; import { stylePromptTitle } from "../terminal/prompt-style.js"; const CLIENT_ID = "Iv1.b507a08c87ecfe98"; diff --git a/src/providers/github-copilot-token.ts b/src/providers/github-copilot-token.ts index eb794ed27e6..37ec22a3f73 100644 --- a/src/providers/github-copilot-token.ts +++ b/src/providers/github-copilot-token.ts @@ -1,5 +1,4 @@ import path from "node:path"; - import { resolveStateDir } from "../config/paths.js"; import { loadJsonFile, saveJsonFile } from "../infra/json-file.js"; diff --git a/src/providers/google-shared.ensures-function-call-comes-after-user-turn.test.ts b/src/providers/google-shared.ensures-function-call-comes-after-user-turn.test.ts index c8d6a604f98..f3ecc5d34e7 100644 --- a/src/providers/google-shared.ensures-function-call-comes-after-user-turn.test.ts +++ b/src/providers/google-shared.ensures-function-call-comes-after-user-turn.test.ts @@ -1,5 +1,5 @@ -import { convertMessages } from "@mariozechner/pi-ai/dist/providers/google-shared.js"; import type { Context, Model } from "@mariozechner/pi-ai/dist/types.js"; +import { convertMessages } from "@mariozechner/pi-ai/dist/providers/google-shared.js"; import { describe, expect, it } from "vitest"; const asRecord = (value: unknown): Record => { diff --git a/src/providers/google-shared.preserves-parameters-type-is-missing.test.ts b/src/providers/google-shared.preserves-parameters-type-is-missing.test.ts index 576f5f5b533..f7f3781ed96 100644 --- a/src/providers/google-shared.preserves-parameters-type-is-missing.test.ts +++ b/src/providers/google-shared.preserves-parameters-type-is-missing.test.ts @@ -1,5 +1,5 @@ -import { convertMessages, convertTools } from "@mariozechner/pi-ai/dist/providers/google-shared.js"; import type { Context, Model, Tool } from "@mariozechner/pi-ai/dist/types.js"; +import { convertMessages, convertTools } from "@mariozechner/pi-ai/dist/providers/google-shared.js"; import { describe, expect, it } from "vitest"; const asRecord = (value: unknown): Record => { diff --git a/src/providers/qwen-portal-oauth.test.ts b/src/providers/qwen-portal-oauth.test.ts index eac76163372..0abe4eddbc9 100644 --- a/src/providers/qwen-portal-oauth.test.ts +++ b/src/providers/qwen-portal-oauth.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi, afterEach } from "vitest"; - import { refreshQwenPortalCredentials } from "./qwen-portal-oauth.js"; const originalFetch = globalThis.fetch; diff --git a/src/routing/bindings.ts b/src/routing/bindings.ts index 44f428edfbc..fadd193628d 100644 --- a/src/routing/bindings.ts +++ b/src/routing/bindings.ts @@ -1,7 +1,7 @@ -import { resolveDefaultAgentId } from "../agents/agent-scope.js"; -import { normalizeChatChannelId } from "../channels/registry.js"; import type { OpenClawConfig } from "../config/config.js"; import type { AgentBinding } from "../config/types.agents.js"; +import { resolveDefaultAgentId } from "../agents/agent-scope.js"; +import { normalizeChatChannelId } from "../channels/registry.js"; import { normalizeAccountId, normalizeAgentId } from "./session-key.js"; function normalizeBindingChannelId(raw?: string | null): string | null { diff --git a/src/routing/resolve-route.test.ts b/src/routing/resolve-route.test.ts index 51094e12572..cd38a496ba1 100644 --- a/src/routing/resolve-route.test.ts +++ b/src/routing/resolve-route.test.ts @@ -1,5 +1,4 @@ import { describe, expect, test } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { resolveAgentRoute } from "./resolve-route.js"; diff --git a/src/routing/resolve-route.ts b/src/routing/resolve-route.ts index e034d24ca44..0dca0e18883 100644 --- a/src/routing/resolve-route.ts +++ b/src/routing/resolve-route.ts @@ -1,5 +1,5 @@ -import { resolveDefaultAgentId } from "../agents/agent-scope.js"; import type { OpenClawConfig } from "../config/config.js"; +import { resolveDefaultAgentId } from "../agents/agent-scope.js"; import { listBindings } from "./bindings.js"; import { buildAgentMainSessionKey, diff --git a/src/scripts/canvas-a2ui-copy.test.ts b/src/scripts/canvas-a2ui-copy.test.ts index abf277f67d6..207c36e2338 100644 --- a/src/scripts/canvas-a2ui-copy.test.ts +++ b/src/scripts/canvas-a2ui-copy.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import { copyA2uiAssets } from "../../scripts/canvas-a2ui-copy.js"; describe("canvas a2ui copy", () => { diff --git a/src/security/audit-extra.ts b/src/security/audit-extra.ts index 35669055b12..c784dc853be 100644 --- a/src/security/audit-extra.ts +++ b/src/security/audit-extra.ts @@ -1,25 +1,24 @@ +import JSON5 from "json5"; import fs from "node:fs/promises"; import path from "node:path"; - -import JSON5 from "json5"; - +import type { SandboxToolPolicy } from "../agents/sandbox/types.js"; import type { OpenClawConfig, ConfigFileSnapshot } from "../config/config.js"; -import { createConfigIO } from "../config/config.js"; -import { resolveNativeSkillsEnabled } from "../config/commands.js"; -import { resolveOAuthDir } from "../config/paths.js"; -import { formatCliCommand } from "../cli/command-format.js"; -import { resolveDefaultAgentId } from "../agents/agent-scope.js"; import type { AgentToolsConfig } from "../config/types.tools.js"; -import { resolveBrowserConfig } from "../browser/config.js"; +import type { ExecFn } from "./windows-acl.js"; +import { resolveDefaultAgentId } from "../agents/agent-scope.js"; import { isToolAllowedByPolicies } from "../agents/pi-tools.policy.js"; -import { resolveToolProfilePolicy } from "../agents/tool-policy.js"; import { resolveSandboxConfigForAgent, resolveSandboxToolPolicyForAgent, } from "../agents/sandbox.js"; -import { resolveGatewayAuth } from "../gateway/auth.js"; -import type { SandboxToolPolicy } from "../agents/sandbox/types.js"; +import { resolveToolProfilePolicy } from "../agents/tool-policy.js"; +import { resolveBrowserConfig } from "../browser/config.js"; +import { formatCliCommand } from "../cli/command-format.js"; +import { resolveNativeSkillsEnabled } from "../config/commands.js"; +import { createConfigIO } from "../config/config.js"; import { INCLUDE_KEY, MAX_INCLUDE_DEPTH } from "../config/includes.js"; +import { resolveOAuthDir } from "../config/paths.js"; +import { resolveGatewayAuth } from "../gateway/auth.js"; import { normalizeAgentId } from "../routing/session-key.js"; import { formatPermissionDetail, @@ -27,7 +26,6 @@ import { inspectPathPermissions, safeStat, } from "./audit-fs.js"; -import type { ExecFn } from "./windows-acl.js"; export type SecurityAuditFinding = { checkId: string; diff --git a/src/security/audit-fs.ts b/src/security/audit-fs.ts index 10b5dd1ab80..7d6d6130f6e 100644 --- a/src/security/audit-fs.ts +++ b/src/security/audit-fs.ts @@ -1,5 +1,4 @@ import fs from "node:fs/promises"; - import { formatIcaclsResetCommand, formatWindowsAclSummary, diff --git a/src/security/audit.test.ts b/src/security/audit.test.ts index 38fbb9a77ca..d12b54744ce 100644 --- a/src/security/audit.test.ts +++ b/src/security/audit.test.ts @@ -1,14 +1,13 @@ -import { afterEach, beforeEach, describe, expect, it } from "vitest"; - -import type { OpenClawConfig } from "../config/config.js"; -import type { ChannelPlugin } from "../channels/plugins/types.js"; -import { runSecurityAudit } from "./audit.js"; -import { discordPlugin } from "../../extensions/discord/src/channel.js"; -import { slackPlugin } from "../../extensions/slack/src/channel.js"; -import { telegramPlugin } from "../../extensions/telegram/src/channel.js"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; +import { afterEach, beforeEach, describe, expect, it } from "vitest"; +import type { ChannelPlugin } from "../channels/plugins/types.js"; +import type { OpenClawConfig } from "../config/config.js"; +import { discordPlugin } from "../../extensions/discord/src/channel.js"; +import { slackPlugin } from "../../extensions/slack/src/channel.js"; +import { telegramPlugin } from "../../extensions/telegram/src/channel.js"; +import { runSecurityAudit } from "./audit.js"; const isWindows = process.platform === "win32"; diff --git a/src/security/audit.ts b/src/security/audit.ts index 8ee915d74b5..583d9130f17 100644 --- a/src/security/audit.ts +++ b/src/security/audit.ts @@ -1,13 +1,16 @@ -import { listChannelPlugins } from "../channels/plugins/index.js"; -import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js"; import type { ChannelId } from "../channels/plugins/types.js"; import type { OpenClawConfig } from "../config/config.js"; +import type { ExecFn } from "./windows-acl.js"; import { resolveBrowserConfig, resolveProfile } from "../browser/config.js"; +import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js"; +import { listChannelPlugins } from "../channels/plugins/index.js"; +import { formatCliCommand } from "../cli/command-format.js"; +import { resolveNativeCommandsEnabled, resolveNativeSkillsEnabled } from "../config/commands.js"; import { resolveConfigPath, resolveStateDir } from "../config/paths.js"; import { resolveGatewayAuth } from "../gateway/auth.js"; -import { formatCliCommand } from "../cli/command-format.js"; import { buildGatewayConnectionDetails } from "../gateway/call.js"; import { probeGateway } from "../gateway/probe.js"; +import { readChannelAllowFromStore } from "../pairing/pairing-store.js"; import { collectAttackSurfaceSummaryFindings, collectExposureMatrixFindings, @@ -21,14 +24,11 @@ import { collectSyncedFolderFindings, readConfigSnapshotForAudit, } from "./audit-extra.js"; -import { readChannelAllowFromStore } from "../pairing/pairing-store.js"; -import { resolveNativeCommandsEnabled, resolveNativeSkillsEnabled } from "../config/commands.js"; import { formatPermissionDetail, formatPermissionRemediation, inspectPathPermissions, } from "./audit-fs.js"; -import type { ExecFn } from "./windows-acl.js"; export type SecurityAuditSeverity = "info" | "warn" | "critical"; diff --git a/src/security/fix.test.ts b/src/security/fix.test.ts index ac975081b18..4347f993805 100644 --- a/src/security/fix.test.ts +++ b/src/security/fix.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import { fixSecurityFootguns } from "./fix.js"; const isWindows = process.platform === "win32"; diff --git a/src/security/fix.ts b/src/security/fix.ts index 972c3338121..0ecfc1e7d00 100644 --- a/src/security/fix.ts +++ b/src/security/fix.ts @@ -1,16 +1,14 @@ +import JSON5 from "json5"; import fs from "node:fs/promises"; import path from "node:path"; - -import JSON5 from "json5"; - import type { OpenClawConfig } from "../config/config.js"; -import { createConfigIO } from "../config/config.js"; -import { resolveConfigPath, resolveOAuthDir, resolveStateDir } from "../config/paths.js"; import { resolveDefaultAgentId } from "../agents/agent-scope.js"; +import { createConfigIO } from "../config/config.js"; import { INCLUDE_KEY, MAX_INCLUDE_DEPTH } from "../config/includes.js"; -import { normalizeAgentId } from "../routing/session-key.js"; +import { resolveConfigPath, resolveOAuthDir, resolveStateDir } from "../config/paths.js"; import { readChannelAllowFromStore } from "../pairing/pairing-store.js"; import { runExec } from "../process/exec.js"; +import { normalizeAgentId } from "../routing/session-key.js"; import { createIcaclsResetCommand, formatIcaclsResetCommand, type ExecFn } from "./windows-acl.js"; export type SecurityFixChmodAction = { diff --git a/src/security/windows-acl.ts b/src/security/windows-acl.ts index b0b04450769..01d2c6ef9cc 100644 --- a/src/security/windows-acl.ts +++ b/src/security/windows-acl.ts @@ -1,5 +1,4 @@ import os from "node:os"; - import { runExec } from "../process/exec.js"; export type ExecFn = typeof runExec; diff --git a/src/sessions/level-overrides.ts b/src/sessions/level-overrides.ts index 29add6f1955..f0016fa439d 100644 --- a/src/sessions/level-overrides.ts +++ b/src/sessions/level-overrides.ts @@ -1,5 +1,5 @@ -import { normalizeVerboseLevel, type VerboseLevel } from "../auto-reply/thinking.js"; import type { SessionEntry } from "../config/sessions.js"; +import { normalizeVerboseLevel, type VerboseLevel } from "../auto-reply/thinking.js"; export function parseVerboseOverride( raw: unknown, diff --git a/src/signal/client.ts b/src/signal/client.ts index 59d4541ca41..1551183f141 100644 --- a/src/signal/client.ts +++ b/src/signal/client.ts @@ -1,5 +1,4 @@ import { randomUUID } from "node:crypto"; - import { resolveFetch } from "../infra/fetch.js"; export type SignalRpcOptions = { diff --git a/src/signal/daemon.test.ts b/src/signal/daemon.test.ts index 396713ef4af..b83208654bf 100644 --- a/src/signal/daemon.test.ts +++ b/src/signal/daemon.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { classifySignalCliLogLine } from "./daemon.js"; describe("classifySignalCliLogLine", () => { diff --git a/src/signal/format.test.ts b/src/signal/format.test.ts index 7c66e3013b5..40e509fa891 100644 --- a/src/signal/format.test.ts +++ b/src/signal/format.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { markdownToSignalText } from "./format.js"; describe("markdownToSignalText", () => { diff --git a/src/signal/format.ts b/src/signal/format.ts index 51c9516fa5e..f310b75a6ee 100644 --- a/src/signal/format.ts +++ b/src/signal/format.ts @@ -1,10 +1,10 @@ +import type { MarkdownTableMode } from "../config/types.base.js"; import { chunkMarkdownIR, markdownToIR, type MarkdownIR, type MarkdownStyle, } from "../markdown/ir.js"; -import type { MarkdownTableMode } from "../config/types.base.js"; type SignalTextStyle = "BOLD" | "ITALIC" | "STRIKETHROUGH" | "MONOSPACE" | "SPOILER"; diff --git a/src/signal/monitor.test.ts b/src/signal/monitor.test.ts index 0012166b4ee..a15956ce119 100644 --- a/src/signal/monitor.test.ts +++ b/src/signal/monitor.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { isSignalGroupAllowed } from "./identity.js"; describe("signal groupPolicy gating", () => { diff --git a/src/signal/monitor.tool-result.pairs-uuid-only-senders-uuid-allowlist-entry.test.ts b/src/signal/monitor.tool-result.pairs-uuid-only-senders-uuid-allowlist-entry.test.ts index 489b6a86707..c64f2cd106c 100644 --- a/src/signal/monitor.tool-result.pairs-uuid-only-senders-uuid-allowlist-entry.test.ts +++ b/src/signal/monitor.tool-result.pairs-uuid-only-senders-uuid-allowlist-entry.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js"; import { resetSystemEventsForTest } from "../infra/system-events.js"; import { monitorSignalProvider } from "./monitor.js"; diff --git a/src/signal/monitor.tool-result.sends-tool-summaries-responseprefix.test.ts b/src/signal/monitor.tool-result.sends-tool-summaries-responseprefix.test.ts index a8d55db668e..5d29bee6d19 100644 --- a/src/signal/monitor.tool-result.sends-tool-summaries-responseprefix.test.ts +++ b/src/signal/monitor.tool-result.sends-tool-summaries-responseprefix.test.ts @@ -1,7 +1,6 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - -import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js"; import type { OpenClawConfig } from "../config/config.js"; +import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js"; import { peekSystemEvents, resetSystemEventsForTest } from "../infra/system-events.js"; import { resolveAgentRoute } from "../routing/resolve-route.js"; import { normalizeE164 } from "../utils.js"; diff --git a/src/signal/monitor.ts b/src/signal/monitor.ts index a96d6f4eb00..aabe0021b43 100644 --- a/src/signal/monitor.ts +++ b/src/signal/monitor.ts @@ -1,13 +1,13 @@ -import { chunkTextWithMode, resolveChunkMode, resolveTextChunkLimit } from "../auto-reply/chunk.js"; -import { DEFAULT_GROUP_HISTORY_LIMIT, type HistoryEntry } from "../auto-reply/reply/history.js"; import type { ReplyPayload } from "../auto-reply/types.js"; import type { OpenClawConfig } from "../config/config.js"; -import { loadConfig } from "../config/config.js"; import type { SignalReactionNotificationMode } from "../config/types.js"; -import { saveMediaBuffer } from "../media/store.js"; import type { RuntimeEnv } from "../runtime.js"; -import { normalizeE164 } from "../utils.js"; +import { chunkTextWithMode, resolveChunkMode, resolveTextChunkLimit } from "../auto-reply/chunk.js"; +import { DEFAULT_GROUP_HISTORY_LIMIT, type HistoryEntry } from "../auto-reply/reply/history.js"; +import { loadConfig } from "../config/config.js"; import { waitForTransportReady } from "../infra/transport-ready.js"; +import { saveMediaBuffer } from "../media/store.js"; +import { normalizeE164 } from "../utils.js"; import { resolveSignalAccount } from "./accounts.js"; import { signalCheck, signalRpcRequest } from "./client.js"; import { spawnSignalDaemon } from "./daemon.js"; diff --git a/src/signal/monitor/event-handler.inbound-contract.test.ts b/src/signal/monitor/event-handler.inbound-contract.test.ts index d073357ff48..f2a833bc7c3 100644 --- a/src/signal/monitor/event-handler.inbound-contract.test.ts +++ b/src/signal/monitor/event-handler.inbound-contract.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { MsgContext } from "../../auto-reply/templating.js"; import { expectInboundContextContract } from "../../../test/helpers/inbound-contract.js"; diff --git a/src/signal/monitor/event-handler.ts b/src/signal/monitor/event-handler.ts index 4c1ae1be97a..34e21dc4103 100644 --- a/src/signal/monitor/event-handler.ts +++ b/src/signal/monitor/event-handler.ts @@ -1,5 +1,7 @@ +import type { SignalEventHandlerDeps, SignalReceivePayload } from "./event-handler.types.js"; import { resolveHumanDelayConfig } from "../../agents/identity.js"; import { hasControlCommand } from "../../auto-reply/command-detection.js"; +import { dispatchInboundMessage } from "../../auto-reply/dispatch.js"; import { formatInboundEnvelope, formatInboundFromLabel, @@ -9,13 +11,13 @@ import { createInboundDebouncer, resolveInboundDebounceMs, } from "../../auto-reply/inbound-debounce.js"; -import { dispatchInboundMessage } from "../../auto-reply/dispatch.js"; import { buildPendingHistoryContextFromMap, clearHistoryEntriesIfEnabled, } from "../../auto-reply/reply/history.js"; import { finalizeInboundContext } from "../../auto-reply/reply/inbound-context.js"; import { createReplyDispatcherWithTyping } from "../../auto-reply/reply/reply-dispatcher.js"; +import { resolveControlCommandGate } from "../../channels/command-gating.js"; import { logInboundDrop, logTypingFailure } from "../../channels/logging.js"; import { createReplyPrefixContext } from "../../channels/reply-prefix.js"; import { recordInboundSession } from "../../channels/session.js"; @@ -31,7 +33,6 @@ import { } from "../../pairing/pairing-store.js"; import { resolveAgentRoute } from "../../routing/resolve-route.js"; import { normalizeE164 } from "../../utils.js"; -import { resolveControlCommandGate } from "../../channels/command-gating.js"; import { formatSignalPairingIdLine, formatSignalSenderDisplay, @@ -43,8 +44,6 @@ import { } from "../identity.js"; import { sendMessageSignal, sendReadReceiptSignal, sendTypingSignal } from "../send.js"; -import type { SignalEventHandlerDeps, SignalReceivePayload } from "./event-handler.types.js"; - export function createSignalEventHandler(deps: SignalEventHandlerDeps) { const inboundDebounceMs = resolveInboundDebounceMs({ cfg: deps.cfg, channel: "signal" }); diff --git a/src/signal/probe.test.ts b/src/signal/probe.test.ts index 5a0c699d01b..5b813b8599b 100644 --- a/src/signal/probe.test.ts +++ b/src/signal/probe.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import { probeSignal } from "./probe.js"; const signalCheckMock = vi.fn(); diff --git a/src/signal/sse-reconnect.ts b/src/signal/sse-reconnect.ts index f119388f3d1..c6dfd5d8a9e 100644 --- a/src/signal/sse-reconnect.ts +++ b/src/signal/sse-reconnect.ts @@ -1,7 +1,7 @@ -import { logVerbose, shouldLogVerbose } from "../globals.js"; import type { BackoffPolicy } from "../infra/backoff.js"; -import { computeBackoff, sleepWithAbort } from "../infra/backoff.js"; import type { RuntimeEnv } from "../runtime.js"; +import { logVerbose, shouldLogVerbose } from "../globals.js"; +import { computeBackoff, sleepWithAbort } from "../infra/backoff.js"; import { type SignalSseEvent, streamSignalEvents } from "./client.js"; const DEFAULT_RECONNECT_POLICY: BackoffPolicy = { diff --git a/src/slack/actions.read.test.ts b/src/slack/actions.read.test.ts index cfd72d61cfe..af9f61a3fa2 100644 --- a/src/slack/actions.read.test.ts +++ b/src/slack/actions.read.test.ts @@ -1,7 +1,5 @@ -import { describe, expect, it, vi } from "vitest"; - import type { WebClient } from "@slack/web-api"; - +import { describe, expect, it, vi } from "vitest"; import { readSlackMessages } from "./actions.js"; function createClient() { diff --git a/src/slack/actions.ts b/src/slack/actions.ts index a8ef335d65f..f6ef345bd9a 100644 --- a/src/slack/actions.ts +++ b/src/slack/actions.ts @@ -1,5 +1,4 @@ import type { WebClient } from "@slack/web-api"; - import { loadConfig } from "../config/config.js"; import { logVerbose } from "../globals.js"; import { resolveSlackAccount } from "./accounts.js"; diff --git a/src/slack/channel-migration.test.ts b/src/slack/channel-migration.test.ts index b2837b55429..86cc1154226 100644 --- a/src/slack/channel-migration.test.ts +++ b/src/slack/channel-migration.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { migrateSlackChannelConfig } from "./channel-migration.js"; describe("migrateSlackChannelConfig", () => { diff --git a/src/slack/directory-live.ts b/src/slack/directory-live.ts index 1f2265bf6fd..05387ee2ecf 100644 --- a/src/slack/directory-live.ts +++ b/src/slack/directory-live.ts @@ -1,8 +1,7 @@ -import { createSlackWebClient } from "./client.js"; - -import type { ChannelDirectoryEntry } from "../channels/plugins/types.js"; import type { DirectoryConfigParams } from "../channels/plugins/directory-config.js"; +import type { ChannelDirectoryEntry } from "../channels/plugins/types.js"; import { resolveSlackAccount } from "./accounts.js"; +import { createSlackWebClient } from "./client.js"; type SlackUser = { id?: string; diff --git a/src/slack/format.test.ts b/src/slack/format.test.ts index 6e090a7d7bf..7ccda8e8758 100644 --- a/src/slack/format.test.ts +++ b/src/slack/format.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { markdownToSlackMrkdwn } from "./format.js"; describe("markdownToSlackMrkdwn", () => { diff --git a/src/slack/format.ts b/src/slack/format.ts index 69e2ebe4d42..97fbed7d1e8 100644 --- a/src/slack/format.ts +++ b/src/slack/format.ts @@ -1,5 +1,5 @@ -import { chunkMarkdownIR, markdownToIR, type MarkdownLinkSpan } from "../markdown/ir.js"; import type { MarkdownTableMode } from "../config/types.base.js"; +import { chunkMarkdownIR, markdownToIR, type MarkdownLinkSpan } from "../markdown/ir.js"; import { renderMarkdownWithMarkers } from "../markdown/render.js"; // Escape special characters for Slack mrkdwn format. diff --git a/src/slack/http/registry.test.ts b/src/slack/http/registry.test.ts index eb347841717..a17c678b782 100644 --- a/src/slack/http/registry.test.ts +++ b/src/slack/http/registry.test.ts @@ -1,6 +1,5 @@ import type { IncomingMessage, ServerResponse } from "node:http"; import { afterEach, describe, expect, it, vi } from "vitest"; - import { handleSlackHttpRequest, normalizeSlackWebhookPath, diff --git a/src/slack/monitor.test.ts b/src/slack/monitor.test.ts index 58d3353493e..9a1e5e991d0 100644 --- a/src/slack/monitor.test.ts +++ b/src/slack/monitor.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { buildSlackSlashCommandMatcher, isSlackChannelAllowedByPolicy, diff --git a/src/slack/monitor.threading.missing-thread-ts.test.ts b/src/slack/monitor.threading.missing-thread-ts.test.ts index c20ed94141d..31b95b0de52 100644 --- a/src/slack/monitor.threading.missing-thread-ts.test.ts +++ b/src/slack/monitor.threading.missing-thread-ts.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js"; import { monitorSlackProvider } from "./monitor.js"; diff --git a/src/slack/monitor.tool-result.forces-thread-replies-replytoid-is-set.test.ts b/src/slack/monitor.tool-result.forces-thread-replies-replytoid-is-set.test.ts index 4626bbe1ed4..1906c74788e 100644 --- a/src/slack/monitor.tool-result.forces-thread-replies-replytoid-is-set.test.ts +++ b/src/slack/monitor.tool-result.forces-thread-replies-replytoid-is-set.test.ts @@ -1,6 +1,6 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js"; +import { monitorSlackProvider } from "./monitor.js"; import { defaultSlackTestConfig, flush, @@ -10,7 +10,6 @@ import { resetSlackTestState, waitForSlackEvent, } from "./monitor.test-helpers.js"; -import { monitorSlackProvider } from "./monitor.js"; const slackTestState = getSlackTestState(); const { sendMock, replyMock, reactMock, upsertPairingRequestMock } = slackTestState; diff --git a/src/slack/monitor.tool-result.sends-tool-summaries-responseprefix.test.ts b/src/slack/monitor.tool-result.sends-tool-summaries-responseprefix.test.ts index 384db1a7c47..eae8fad0e00 100644 --- a/src/slack/monitor.tool-result.sends-tool-summaries-responseprefix.test.ts +++ b/src/slack/monitor.tool-result.sends-tool-summaries-responseprefix.test.ts @@ -1,8 +1,8 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import { HISTORY_CONTEXT_MARKER } from "../auto-reply/reply/history.js"; import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js"; import { CURRENT_MESSAGE_MARKER } from "../auto-reply/reply/mentions.js"; +import { monitorSlackProvider } from "./monitor.js"; import { defaultSlackTestConfig, flush, @@ -12,7 +12,6 @@ import { resetSlackTestState, waitForSlackEvent, } from "./monitor.test-helpers.js"; -import { monitorSlackProvider } from "./monitor.js"; const slackTestState = getSlackTestState(); const { sendMock, replyMock } = slackTestState; diff --git a/src/slack/monitor.tool-result.threads-top-level-replies-replytomode-is-all.test.ts b/src/slack/monitor.tool-result.threads-top-level-replies-replytomode-is-all.test.ts index a24656331c2..c0143355c10 100644 --- a/src/slack/monitor.tool-result.threads-top-level-replies-replytomode-is-all.test.ts +++ b/src/slack/monitor.tool-result.threads-top-level-replies-replytomode-is-all.test.ts @@ -1,6 +1,6 @@ import { beforeEach, describe, expect, it } from "vitest"; - import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js"; +import { monitorSlackProvider } from "./monitor.js"; import { defaultSlackTestConfig, flush, @@ -10,7 +10,6 @@ import { resetSlackTestState, waitForSlackEvent, } from "./monitor.test-helpers.js"; -import { monitorSlackProvider } from "./monitor.js"; const slackTestState = getSlackTestState(); const { sendMock, replyMock } = slackTestState; diff --git a/src/slack/monitor/auth.ts b/src/slack/monitor/auth.ts index c4a3700e0f9..2bfbbed59ef 100644 --- a/src/slack/monitor/auth.ts +++ b/src/slack/monitor/auth.ts @@ -1,7 +1,6 @@ -import { readChannelAllowFromStore } from "../../pairing/pairing-store.js"; - -import { allowListMatches, normalizeAllowList, normalizeAllowListLower } from "./allow-list.js"; import type { SlackMonitorContext } from "./context.js"; +import { readChannelAllowFromStore } from "../../pairing/pairing-store.js"; +import { allowListMatches, normalizeAllowList, normalizeAllowListLower } from "./allow-list.js"; export async function resolveSlackEffectiveAllowFrom(ctx: SlackMonitorContext) { const storeAllowFrom = await readChannelAllowFromStore("slack").catch(() => []); diff --git a/src/slack/monitor/channel-config.test.ts b/src/slack/monitor/channel-config.test.ts index d090d8ac50c..9303605a99d 100644 --- a/src/slack/monitor/channel-config.test.ts +++ b/src/slack/monitor/channel-config.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { resolveSlackChannelConfig } from "./channel-config.js"; describe("resolveSlackChannelConfig", () => { diff --git a/src/slack/monitor/context.test.ts b/src/slack/monitor/context.test.ts index 87b1fe425e1..0afde23461c 100644 --- a/src/slack/monitor/context.test.ts +++ b/src/slack/monitor/context.test.ts @@ -1,6 +1,5 @@ import type { App } from "@slack/bolt"; import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import type { RuntimeEnv } from "../../runtime.js"; import { createSlackMonitorContext, normalizeSlackChannelType } from "./context.js"; diff --git a/src/slack/monitor/context.ts b/src/slack/monitor/context.ts index 8c8f9cc9a87..57f5fbc2550 100644 --- a/src/slack/monitor/context.ts +++ b/src/slack/monitor/context.ts @@ -1,15 +1,14 @@ import type { App } from "@slack/bolt"; import type { HistoryEntry } from "../../auto-reply/reply/history.js"; import type { OpenClawConfig, SlackReactionNotificationMode } from "../../config/config.js"; -import { resolveSessionKey, type SessionScope } from "../../config/sessions.js"; import type { DmPolicy, GroupPolicy } from "../../config/types.js"; -import { logVerbose } from "../../globals.js"; -import { createDedupeCache } from "../../infra/dedupe.js"; -import { getChildLogger } from "../../logging.js"; import type { RuntimeEnv } from "../../runtime.js"; import type { SlackMessageEvent } from "../types.js"; import { formatAllowlistMatchMeta } from "../../channels/allowlist-match.js"; - +import { resolveSessionKey, type SessionScope } from "../../config/sessions.js"; +import { logVerbose } from "../../globals.js"; +import { createDedupeCache } from "../../infra/dedupe.js"; +import { getChildLogger } from "../../logging.js"; import { normalizeAllowList, normalizeAllowListLower, normalizeSlackSlug } from "./allow-list.js"; import { resolveSlackChannelConfig } from "./channel-config.js"; import { isSlackChannelAllowedByPolicy } from "./policy.js"; diff --git a/src/slack/monitor/events.ts b/src/slack/monitor/events.ts index a4130d67bbf..90ad3e16ffa 100644 --- a/src/slack/monitor/events.ts +++ b/src/slack/monitor/events.ts @@ -1,12 +1,11 @@ import type { ResolvedSlackAccount } from "../accounts.js"; - import type { SlackMonitorContext } from "./context.js"; +import type { SlackMessageHandler } from "./message-handler.js"; import { registerSlackChannelEvents } from "./events/channels.js"; import { registerSlackMemberEvents } from "./events/members.js"; import { registerSlackMessageEvents } from "./events/messages.js"; import { registerSlackPinEvents } from "./events/pins.js"; import { registerSlackReactionEvents } from "./events/reactions.js"; -import type { SlackMessageHandler } from "./message-handler.js"; export function registerSlackMonitorEvents(params: { ctx: SlackMonitorContext; diff --git a/src/slack/monitor/events/channels.ts b/src/slack/monitor/events/channels.ts index 2ab9b00e06c..94492da2485 100644 --- a/src/slack/monitor/events/channels.ts +++ b/src/slack/monitor/events/channels.ts @@ -1,18 +1,16 @@ import type { SlackEventMiddlewareArgs } from "@slack/bolt"; - -import { loadConfig, writeConfigFile } from "../../../config/config.js"; -import { resolveChannelConfigWrites } from "../../../channels/plugins/config-writes.js"; -import { danger, warn } from "../../../globals.js"; -import { enqueueSystemEvent } from "../../../infra/system-events.js"; - -import { resolveSlackChannelLabel } from "../channel-config.js"; import type { SlackMonitorContext } from "../context.js"; -import { migrateSlackChannelConfig } from "../../channel-migration.js"; import type { SlackChannelCreatedEvent, SlackChannelIdChangedEvent, SlackChannelRenamedEvent, } from "../types.js"; +import { resolveChannelConfigWrites } from "../../../channels/plugins/config-writes.js"; +import { loadConfig, writeConfigFile } from "../../../config/config.js"; +import { danger, warn } from "../../../globals.js"; +import { enqueueSystemEvent } from "../../../infra/system-events.js"; +import { migrateSlackChannelConfig } from "../../channel-migration.js"; +import { resolveSlackChannelLabel } from "../channel-config.js"; export function registerSlackChannelEvents(params: { ctx: SlackMonitorContext }) { const { ctx } = params; diff --git a/src/slack/monitor/events/members.ts b/src/slack/monitor/events/members.ts index 2491ed65959..cf7b5b03ece 100644 --- a/src/slack/monitor/events/members.ts +++ b/src/slack/monitor/events/members.ts @@ -1,11 +1,9 @@ import type { SlackEventMiddlewareArgs } from "@slack/bolt"; - -import { danger } from "../../../globals.js"; -import { enqueueSystemEvent } from "../../../infra/system-events.js"; - -import { resolveSlackChannelLabel } from "../channel-config.js"; import type { SlackMonitorContext } from "../context.js"; import type { SlackMemberChannelEvent } from "../types.js"; +import { danger } from "../../../globals.js"; +import { enqueueSystemEvent } from "../../../infra/system-events.js"; +import { resolveSlackChannelLabel } from "../channel-config.js"; export function registerSlackMemberEvents(params: { ctx: SlackMonitorContext }) { const { ctx } = params; diff --git a/src/slack/monitor/events/messages.ts b/src/slack/monitor/events/messages.ts index 03ba506714a..3aacb80c0af 100644 --- a/src/slack/monitor/events/messages.ts +++ b/src/slack/monitor/events/messages.ts @@ -1,10 +1,5 @@ import type { SlackEventMiddlewareArgs } from "@slack/bolt"; - -import { danger } from "../../../globals.js"; -import { enqueueSystemEvent } from "../../../infra/system-events.js"; - import type { SlackAppMentionEvent, SlackMessageEvent } from "../../types.js"; -import { resolveSlackChannelLabel } from "../channel-config.js"; import type { SlackMonitorContext } from "../context.js"; import type { SlackMessageHandler } from "../message-handler.js"; import type { @@ -12,6 +7,9 @@ import type { SlackMessageDeletedEvent, SlackThreadBroadcastEvent, } from "../types.js"; +import { danger } from "../../../globals.js"; +import { enqueueSystemEvent } from "../../../infra/system-events.js"; +import { resolveSlackChannelLabel } from "../channel-config.js"; export function registerSlackMessageEvents(params: { ctx: SlackMonitorContext; diff --git a/src/slack/monitor/events/pins.ts b/src/slack/monitor/events/pins.ts index 7005ecb79e1..c1259179efb 100644 --- a/src/slack/monitor/events/pins.ts +++ b/src/slack/monitor/events/pins.ts @@ -1,11 +1,9 @@ import type { SlackEventMiddlewareArgs } from "@slack/bolt"; - -import { danger } from "../../../globals.js"; -import { enqueueSystemEvent } from "../../../infra/system-events.js"; - -import { resolveSlackChannelLabel } from "../channel-config.js"; import type { SlackMonitorContext } from "../context.js"; import type { SlackPinEvent } from "../types.js"; +import { danger } from "../../../globals.js"; +import { enqueueSystemEvent } from "../../../infra/system-events.js"; +import { resolveSlackChannelLabel } from "../channel-config.js"; export function registerSlackPinEvents(params: { ctx: SlackMonitorContext }) { const { ctx } = params; diff --git a/src/slack/monitor/events/reactions.ts b/src/slack/monitor/events/reactions.ts index 21f87812998..0844fddd840 100644 --- a/src/slack/monitor/events/reactions.ts +++ b/src/slack/monitor/events/reactions.ts @@ -1,11 +1,9 @@ import type { SlackEventMiddlewareArgs } from "@slack/bolt"; - -import { danger } from "../../../globals.js"; -import { enqueueSystemEvent } from "../../../infra/system-events.js"; - -import { resolveSlackChannelLabel } from "../channel-config.js"; import type { SlackMonitorContext } from "../context.js"; import type { SlackReactionEvent } from "../types.js"; +import { danger } from "../../../globals.js"; +import { enqueueSystemEvent } from "../../../infra/system-events.js"; +import { resolveSlackChannelLabel } from "../channel-config.js"; export function registerSlackReactionEvents(params: { ctx: SlackMonitorContext }) { const { ctx } = params; diff --git a/src/slack/monitor/media.ts b/src/slack/monitor/media.ts index 561fefb0666..161237edcdc 100644 --- a/src/slack/monitor/media.ts +++ b/src/slack/monitor/media.ts @@ -1,9 +1,8 @@ import type { WebClient as SlackWebClient } from "@slack/web-api"; - import type { FetchLike } from "../../media/fetch.js"; +import type { SlackFile } from "../types.js"; import { fetchRemoteMedia } from "../../media/fetch.js"; import { saveMediaBuffer } from "../../media/store.js"; -import type { SlackFile } from "../types.js"; /** * Fetches a URL with Authorization header, handling cross-origin redirects. diff --git a/src/slack/monitor/message-handler.ts b/src/slack/monitor/message-handler.ts index 42ba9b2f117..f87c14ccc86 100644 --- a/src/slack/monitor/message-handler.ts +++ b/src/slack/monitor/message-handler.ts @@ -1,11 +1,11 @@ +import type { ResolvedSlackAccount } from "../accounts.js"; +import type { SlackMessageEvent } from "../types.js"; +import type { SlackMonitorContext } from "./context.js"; import { hasControlCommand } from "../../auto-reply/command-detection.js"; import { createInboundDebouncer, resolveInboundDebounceMs, } from "../../auto-reply/inbound-debounce.js"; -import type { ResolvedSlackAccount } from "../accounts.js"; -import type { SlackMessageEvent } from "../types.js"; -import type { SlackMonitorContext } from "./context.js"; import { dispatchPreparedSlackMessage } from "./message-handler/dispatch.js"; import { prepareSlackMessage } from "./message-handler/prepare.js"; import { createSlackThreadTsResolver } from "./thread-resolution.js"; diff --git a/src/slack/monitor/message-handler/dispatch.ts b/src/slack/monitor/message-handler/dispatch.ts index 52f911ae205..0028b1c3bee 100644 --- a/src/slack/monitor/message-handler/dispatch.ts +++ b/src/slack/monitor/message-handler/dispatch.ts @@ -1,20 +1,18 @@ +import type { PreparedSlackMessage } from "./types.js"; import { resolveHumanDelayConfig } from "../../../agents/identity.js"; import { dispatchInboundMessage } from "../../../auto-reply/dispatch.js"; import { clearHistoryEntriesIfEnabled } from "../../../auto-reply/reply/history.js"; +import { createReplyDispatcherWithTyping } from "../../../auto-reply/reply/reply-dispatcher.js"; import { removeAckReactionAfterReply } from "../../../channels/ack-reactions.js"; import { logAckFailure, logTypingFailure } from "../../../channels/logging.js"; import { createReplyPrefixContext } from "../../../channels/reply-prefix.js"; import { createTypingCallbacks } from "../../../channels/typing.js"; -import { createReplyDispatcherWithTyping } from "../../../auto-reply/reply/reply-dispatcher.js"; import { resolveStorePath, updateLastRoute } from "../../../config/sessions.js"; import { danger, logVerbose, shouldLogVerbose } from "../../../globals.js"; import { removeSlackReaction } from "../../actions.js"; import { resolveSlackThreadTargets } from "../../threading.js"; - import { createSlackReplyDeliveryPlan, deliverReplies } from "../replies.js"; -import type { PreparedSlackMessage } from "./types.js"; - export async function dispatchPreparedSlackMessage(prepared: PreparedSlackMessage) { const { ctx, account, message, route } = prepared; const cfg = ctx.cfg; diff --git a/src/slack/monitor/message-handler/prepare.inbound-contract.test.ts b/src/slack/monitor/message-handler/prepare.inbound-contract.test.ts index 1a614d6c587..178f12d4df7 100644 --- a/src/slack/monitor/message-handler/prepare.inbound-contract.test.ts +++ b/src/slack/monitor/message-handler/prepare.inbound-contract.test.ts @@ -1,11 +1,10 @@ import type { App } from "@slack/bolt"; import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../../../config/config.js"; import type { RuntimeEnv } from "../../../runtime.js"; -import { expectInboundContextContract } from "../../../../test/helpers/inbound-contract.js"; import type { ResolvedSlackAccount } from "../../accounts.js"; import type { SlackMessageEvent } from "../../types.js"; +import { expectInboundContextContract } from "../../../../test/helpers/inbound-contract.js"; import { createSlackMonitorContext } from "../context.js"; import { prepareSlackMessage } from "./prepare.js"; diff --git a/src/slack/monitor/message-handler/prepare.sender-prefix.test.ts b/src/slack/monitor/message-handler/prepare.sender-prefix.test.ts index f7aa2df5264..79983a7c81d 100644 --- a/src/slack/monitor/message-handler/prepare.sender-prefix.test.ts +++ b/src/slack/monitor/message-handler/prepare.sender-prefix.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { SlackMonitorContext } from "../context.js"; import { prepareSlackMessage } from "./prepare.js"; diff --git a/src/slack/monitor/message-handler/prepare.ts b/src/slack/monitor/message-handler/prepare.ts index c84c825a13e..2a9eceea648 100644 --- a/src/slack/monitor/message-handler/prepare.ts +++ b/src/slack/monitor/message-handler/prepare.ts @@ -1,7 +1,10 @@ +import type { FinalizedMsgContext } from "../../../auto-reply/templating.js"; +import type { ResolvedSlackAccount } from "../../accounts.js"; +import type { SlackMessageEvent } from "../../types.js"; +import type { PreparedSlackMessage } from "./types.js"; import { resolveAckReaction } from "../../../agents/identity.js"; import { hasControlCommand } from "../../../auto-reply/command-detection.js"; import { shouldHandleTextCommands } from "../../../auto-reply/commands-registry.js"; -import type { FinalizedMsgContext } from "../../../auto-reply/templating.js"; import { formatInboundEnvelope, formatThreadStarterEnvelope, @@ -16,38 +19,32 @@ import { buildMentionRegexes, matchesMentionWithExplicit, } from "../../../auto-reply/reply/mentions.js"; +import { + shouldAckReaction as shouldAckReactionGate, + type AckReactionScope, +} from "../../../channels/ack-reactions.js"; +import { formatAllowlistMatchMeta } from "../../../channels/allowlist-match.js"; +import { resolveControlCommandGate } from "../../../channels/command-gating.js"; +import { resolveConversationLabel } from "../../../channels/conversation-label.js"; +import { logInboundDrop } from "../../../channels/logging.js"; +import { resolveMentionGatingWithBypass } from "../../../channels/mention-gating.js"; +import { recordInboundSession } from "../../../channels/session.js"; +import { readSessionUpdatedAt, resolveStorePath } from "../../../config/sessions.js"; import { logVerbose, shouldLogVerbose } from "../../../globals.js"; import { enqueueSystemEvent } from "../../../infra/system-events.js"; import { buildPairingReply } from "../../../pairing/pairing-messages.js"; import { upsertChannelPairingRequest } from "../../../pairing/pairing-store.js"; import { resolveAgentRoute } from "../../../routing/resolve-route.js"; import { resolveThreadSessionKeys } from "../../../routing/session-key.js"; -import { - shouldAckReaction as shouldAckReactionGate, - type AckReactionScope, -} from "../../../channels/ack-reactions.js"; -import { resolveMentionGatingWithBypass } from "../../../channels/mention-gating.js"; -import { resolveConversationLabel } from "../../../channels/conversation-label.js"; -import { resolveControlCommandGate } from "../../../channels/command-gating.js"; -import { logInboundDrop } from "../../../channels/logging.js"; -import { formatAllowlistMatchMeta } from "../../../channels/allowlist-match.js"; -import { recordInboundSession } from "../../../channels/session.js"; -import { readSessionUpdatedAt, resolveStorePath } from "../../../config/sessions.js"; - -import type { ResolvedSlackAccount } from "../../accounts.js"; import { reactSlackMessage } from "../../actions.js"; import { sendMessageSlack } from "../../send.js"; -import type { SlackMessageEvent } from "../../types.js"; import { resolveSlackThreadContext } from "../../threading.js"; - import { resolveSlackAllowListMatch, resolveSlackUserAllowed } from "../allow-list.js"; import { resolveSlackEffectiveAllowFrom } from "../auth.js"; import { resolveSlackChannelConfig } from "../channel-config.js"; import { normalizeSlackChannelType, type SlackMonitorContext } from "../context.js"; import { resolveSlackMedia, resolveSlackThreadStarter } from "../media.js"; -import type { PreparedSlackMessage } from "./types.js"; - export async function prepareSlackMessage(params: { ctx: SlackMonitorContext; account: ResolvedSlackAccount; diff --git a/src/slack/monitor/message-handler/types.ts b/src/slack/monitor/message-handler/types.ts index e7b4b080789..8fbf4a939dd 100644 --- a/src/slack/monitor/message-handler/types.ts +++ b/src/slack/monitor/message-handler/types.ts @@ -1,5 +1,5 @@ -import type { ResolvedAgentRoute } from "../../../routing/resolve-route.js"; import type { FinalizedMsgContext } from "../../../auto-reply/templating.js"; +import type { ResolvedAgentRoute } from "../../../routing/resolve-route.js"; import type { ResolvedSlackAccount } from "../../accounts.js"; import type { SlackMessageEvent } from "../../types.js"; import type { SlackChannelConfigResolved } from "../channel-config.js"; diff --git a/src/slack/monitor/provider.ts b/src/slack/monitor/provider.ts index 2bf8e0b071f..ee440d56555 100644 --- a/src/slack/monitor/provider.ts +++ b/src/slack/monitor/provider.ts @@ -1,30 +1,26 @@ import type { IncomingMessage, ServerResponse } from "node:http"; - import SlackBolt from "@slack/bolt"; - +import type { SessionScope } from "../../config/sessions.js"; +import type { RuntimeEnv } from "../../runtime.js"; +import type { MonitorSlackOpts } from "./types.js"; import { resolveTextChunkLimit } from "../../auto-reply/chunk.js"; import { DEFAULT_GROUP_HISTORY_LIMIT } from "../../auto-reply/reply/history.js"; import { mergeAllowlist, summarizeMapping } from "../../channels/allowlists/resolve-utils.js"; import { loadConfig } from "../../config/config.js"; -import type { SessionScope } from "../../config/sessions.js"; import { warn } from "../../globals.js"; import { normalizeMainKey } from "../../routing/session-key.js"; -import type { RuntimeEnv } from "../../runtime.js"; - import { resolveSlackAccount } from "../accounts.js"; +import { resolveSlackWebClientOptions } from "../client.js"; +import { normalizeSlackWebhookPath, registerSlackHttpHandler } from "../http/index.js"; import { resolveSlackChannelAllowlist } from "../resolve-channels.js"; import { resolveSlackUserAllowlist } from "../resolve-users.js"; import { resolveSlackAppToken, resolveSlackBotToken } from "../token.js"; -import { normalizeSlackWebhookPath, registerSlackHttpHandler } from "../http/index.js"; -import { resolveSlackWebClientOptions } from "../client.js"; +import { normalizeAllowList } from "./allow-list.js"; import { resolveSlackSlashCommandConfig } from "./commands.js"; import { createSlackMonitorContext } from "./context.js"; import { registerSlackMonitorEvents } from "./events.js"; import { createSlackMessageHandler } from "./message-handler.js"; import { registerSlackMonitorSlashCommands } from "./slash.js"; -import { normalizeAllowList } from "./allow-list.js"; - -import type { MonitorSlackOpts } from "./types.js"; const slackBoltModule = SlackBolt as typeof import("@slack/bolt") & { default?: typeof import("@slack/bolt"); diff --git a/src/slack/monitor/replies.ts b/src/slack/monitor/replies.ts index 1c55daaa539..c759ca0b500 100644 --- a/src/slack/monitor/replies.ts +++ b/src/slack/monitor/replies.ts @@ -1,10 +1,10 @@ -import { createReplyReferencePlanner } from "../../auto-reply/reply/reply-reference.js"; -import { isSilentReplyText, SILENT_REPLY_TOKEN } from "../../auto-reply/tokens.js"; import type { ChunkMode } from "../../auto-reply/chunk.js"; -import { chunkMarkdownTextWithMode } from "../../auto-reply/chunk.js"; import type { ReplyPayload } from "../../auto-reply/types.js"; import type { MarkdownTableMode } from "../../config/types.base.js"; import type { RuntimeEnv } from "../../runtime.js"; +import { chunkMarkdownTextWithMode } from "../../auto-reply/chunk.js"; +import { createReplyReferencePlanner } from "../../auto-reply/reply/reply-reference.js"; +import { isSilentReplyText, SILENT_REPLY_TOKEN } from "../../auto-reply/tokens.js"; import { markdownToSlackMrkdwnChunks } from "../format.js"; import { sendMessageSlack } from "../send.js"; diff --git a/src/slack/monitor/slash.command-arg-menus.test.ts b/src/slack/monitor/slash.command-arg-menus.test.ts index 3b27e7e8a7d..ebf40aeca39 100644 --- a/src/slack/monitor/slash.command-arg-menus.test.ts +++ b/src/slack/monitor/slash.command-arg-menus.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import { registerSlackMonitorSlashCommands } from "./slash.js"; const dispatchMock = vi.fn(); diff --git a/src/slack/monitor/slash.policy.test.ts b/src/slack/monitor/slash.policy.test.ts index bac3e81d82a..72606e75523 100644 --- a/src/slack/monitor/slash.policy.test.ts +++ b/src/slack/monitor/slash.policy.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import { registerSlackMonitorSlashCommands } from "./slash.js"; const dispatchMock = vi.fn(); diff --git a/src/slack/monitor/slash.ts b/src/slack/monitor/slash.ts index 6eb9351c020..4519ce6383e 100644 --- a/src/slack/monitor/slash.ts +++ b/src/slack/monitor/slash.ts @@ -1,7 +1,9 @@ import type { SlackActionMiddlewareArgs, SlackCommandMiddlewareArgs } from "@slack/bolt"; import type { ChatCommandDefinition, CommandArgs } from "../../auto-reply/commands-registry.js"; -import { resolveChunkMode } from "../../auto-reply/chunk.js"; +import type { ResolvedSlackAccount } from "../accounts.js"; +import type { SlackMonitorContext } from "./context.js"; import { resolveEffectiveMessagesConfig } from "../../agents/identity.js"; +import { resolveChunkMode } from "../../auto-reply/chunk.js"; import { buildCommandTextFromArgs, findCommandByNativeName, @@ -9,9 +11,12 @@ import { parseCommandArgs, resolveCommandArgMenu, } from "../../auto-reply/commands-registry.js"; -import { listSkillCommandsForAgents } from "../../auto-reply/skill-commands.js"; -import { dispatchReplyWithDispatcher } from "../../auto-reply/reply/provider-dispatcher.js"; import { finalizeInboundContext } from "../../auto-reply/reply/inbound-context.js"; +import { dispatchReplyWithDispatcher } from "../../auto-reply/reply/provider-dispatcher.js"; +import { listSkillCommandsForAgents } from "../../auto-reply/skill-commands.js"; +import { formatAllowlistMatchMeta } from "../../channels/allowlist-match.js"; +import { resolveCommandAuthorizedFromAuthorizers } from "../../channels/command-gating.js"; +import { resolveConversationLabel } from "../../channels/conversation-label.js"; import { resolveNativeCommandsEnabled, resolveNativeSkillsEnabled } from "../../config/commands.js"; import { resolveMarkdownTableMode } from "../../config/markdown-tables.js"; import { danger, logVerbose } from "../../globals.js"; @@ -21,12 +26,6 @@ import { upsertChannelPairingRequest, } from "../../pairing/pairing-store.js"; import { resolveAgentRoute } from "../../routing/resolve-route.js"; -import { resolveConversationLabel } from "../../channels/conversation-label.js"; -import { resolveCommandAuthorizedFromAuthorizers } from "../../channels/command-gating.js"; -import { formatAllowlistMatchMeta } from "../../channels/allowlist-match.js"; - -import type { ResolvedSlackAccount } from "../accounts.js"; - import { normalizeAllowList, normalizeAllowListLower, @@ -35,7 +34,6 @@ import { } from "./allow-list.js"; import { resolveSlackChannelConfig, type SlackChannelConfigResolved } from "./channel-config.js"; import { buildSlackSlashCommandMatcher, resolveSlackSlashCommandConfig } from "./commands.js"; -import type { SlackMonitorContext } from "./context.js"; import { isSlackChannelAllowedByPolicy } from "./policy.js"; import { deliverSlackSlashReplies } from "./replies.js"; diff --git a/src/slack/monitor/thread-resolution.test.ts b/src/slack/monitor/thread-resolution.test.ts index e670f1ee65e..3016f82d978 100644 --- a/src/slack/monitor/thread-resolution.test.ts +++ b/src/slack/monitor/thread-resolution.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { SlackMessageEvent } from "../types.js"; import { createSlackThreadTsResolver } from "./thread-resolution.js"; diff --git a/src/slack/monitor/thread-resolution.ts b/src/slack/monitor/thread-resolution.ts index ecbe99b5c28..87e9978f09b 100644 --- a/src/slack/monitor/thread-resolution.ts +++ b/src/slack/monitor/thread-resolution.ts @@ -1,7 +1,6 @@ import type { WebClient as SlackWebClient } from "@slack/web-api"; - -import { logVerbose, shouldLogVerbose } from "../../globals.js"; import type { SlackMessageEvent } from "../types.js"; +import { logVerbose, shouldLogVerbose } from "../../globals.js"; type ThreadTsCacheEntry = { threadTs: string | null; diff --git a/src/slack/resolve-channels.test.ts b/src/slack/resolve-channels.test.ts index 27ea0f4ed5d..17e04d80a7e 100644 --- a/src/slack/resolve-channels.test.ts +++ b/src/slack/resolve-channels.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { resolveSlackChannelAllowlist } from "./resolve-channels.js"; describe("resolveSlackChannelAllowlist", () => { diff --git a/src/slack/resolve-channels.ts b/src/slack/resolve-channels.ts index 4003a9c1080..2112a2a3c2d 100644 --- a/src/slack/resolve-channels.ts +++ b/src/slack/resolve-channels.ts @@ -1,5 +1,4 @@ import type { WebClient } from "@slack/web-api"; - import { createSlackWebClient } from "./client.js"; export type SlackChannelLookup = { diff --git a/src/slack/resolve-users.ts b/src/slack/resolve-users.ts index 24c25a50237..66f101d3221 100644 --- a/src/slack/resolve-users.ts +++ b/src/slack/resolve-users.ts @@ -1,5 +1,4 @@ import type { WebClient } from "@slack/web-api"; - import { createSlackWebClient } from "./client.js"; export type SlackUserLookup = { diff --git a/src/slack/scopes.ts b/src/slack/scopes.ts index a64a5bd29eb..7c49ff3059c 100644 --- a/src/slack/scopes.ts +++ b/src/slack/scopes.ts @@ -1,5 +1,4 @@ import type { WebClient } from "@slack/web-api"; - import { createSlackWebClient } from "./client.js"; export type SlackScopesResult = { diff --git a/src/slack/send.ts b/src/slack/send.ts index 57ed292b73c..6bdf4ab2ffa 100644 --- a/src/slack/send.ts +++ b/src/slack/send.ts @@ -1,18 +1,17 @@ import { type FilesUploadV2Arguments, type WebClient } from "@slack/web-api"; - +import type { SlackTokenSource } from "./accounts.js"; import { chunkMarkdownTextWithMode, resolveChunkMode, resolveTextChunkLimit, } from "../auto-reply/chunk.js"; import { loadConfig } from "../config/config.js"; +import { resolveMarkdownTableMode } from "../config/markdown-tables.js"; import { logVerbose } from "../globals.js"; import { loadWebMedia } from "../web/media.js"; -import type { SlackTokenSource } from "./accounts.js"; import { resolveSlackAccount } from "./accounts.js"; import { createSlackWebClient } from "./client.js"; import { markdownToSlackMrkdwnChunks } from "./format.js"; -import { resolveMarkdownTableMode } from "../config/markdown-tables.js"; import { parseSlackTarget } from "./targets.js"; import { resolveSlackBotToken } from "./token.js"; diff --git a/src/slack/targets.test.ts b/src/slack/targets.test.ts index 5b5cfe849b6..a15906884cb 100644 --- a/src/slack/targets.test.ts +++ b/src/slack/targets.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { normalizeSlackMessagingTarget } from "../channels/plugins/normalize/slack.js"; import { parseSlackTarget, resolveSlackChannelId } from "./targets.js"; diff --git a/src/slack/threading-tool-context.test.ts b/src/slack/threading-tool-context.test.ts index fae665dc3c8..9975a818c30 100644 --- a/src/slack/threading-tool-context.test.ts +++ b/src/slack/threading-tool-context.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { buildSlackThreadingToolContext } from "./threading-tool-context.js"; diff --git a/src/slack/threading.test.ts b/src/slack/threading.test.ts index 837d3ddbcc6..a9f107254ef 100644 --- a/src/slack/threading.test.ts +++ b/src/slack/threading.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { resolveSlackThreadContext, resolveSlackThreadTargets } from "./threading.js"; describe("resolveSlackThreadTargets", () => { diff --git a/src/telegram/accounts.test.ts b/src/telegram/accounts.test.ts index 79273611dde..e04284ca89d 100644 --- a/src/telegram/accounts.test.ts +++ b/src/telegram/accounts.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { resolveTelegramAccount } from "./accounts.js"; diff --git a/src/telegram/api-logging.ts b/src/telegram/api-logging.ts index 4534b3f8264..6dc2776c2ac 100644 --- a/src/telegram/api-logging.ts +++ b/src/telegram/api-logging.ts @@ -1,7 +1,7 @@ +import type { RuntimeEnv } from "../runtime.js"; import { danger } from "../globals.js"; import { formatErrorMessage } from "../infra/errors.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; -import type { RuntimeEnv } from "../runtime.js"; export type TelegramApiLogger = (message: string) => void; diff --git a/src/telegram/bot-handlers.ts b/src/telegram/bot-handlers.ts index 2caa1bddec8..878b5c5d960 100644 --- a/src/telegram/bot-handlers.ts +++ b/src/telegram/bot-handlers.ts @@ -1,3 +1,5 @@ +import type { TelegramMessage } from "./bot/types.js"; +import { resolveDefaultAgentId } from "../agents/agent-scope.js"; // @ts-nocheck import { hasControlCommand } from "../auto-reply/command-detection.js"; import { @@ -5,22 +7,20 @@ import { resolveInboundDebounceMs, } from "../auto-reply/inbound-debounce.js"; import { buildCommandsPaginationKeyboard } from "../auto-reply/reply/commands-info.js"; -import { buildCommandsMessagePaginated } from "../auto-reply/status.js"; import { listSkillCommandsForAgents } from "../auto-reply/skill-commands.js"; -import { resolveDefaultAgentId } from "../agents/agent-scope.js"; +import { buildCommandsMessagePaginated } from "../auto-reply/status.js"; +import { resolveChannelConfigWrites } from "../channels/plugins/config-writes.js"; import { loadConfig } from "../config/config.js"; import { writeConfigFile } from "../config/io.js"; import { danger, logVerbose, warn } from "../globals.js"; -import { resolveMedia } from "./bot/delivery.js"; import { withTelegramApiErrorLogging } from "./api-logging.js"; -import { resolveTelegramForumThreadId } from "./bot/helpers.js"; -import type { TelegramMessage } from "./bot/types.js"; import { firstDefined, isSenderAllowed, normalizeAllowFromWithStore } from "./bot-access.js"; import { MEDIA_GROUP_TIMEOUT_MS, type MediaGroupEntry } from "./bot-updates.js"; +import { resolveMedia } from "./bot/delivery.js"; +import { resolveTelegramForumThreadId } from "./bot/helpers.js"; import { migrateTelegramGroupConfig } from "./group-migration.js"; import { resolveTelegramInlineButtonsScope } from "./inline-buttons.js"; import { readTelegramAllowFromStore } from "./pairing-store.js"; -import { resolveChannelConfigWrites } from "../channels/plugins/config-writes.js"; import { buildInlineKeyboard } from "./send.js"; export const registerTelegramHandlers = ({ diff --git a/src/telegram/bot-message-context.dm-threads.test.ts b/src/telegram/bot-message-context.dm-threads.test.ts index 6162e1cb1bf..24dc73ad7a3 100644 --- a/src/telegram/bot-message-context.dm-threads.test.ts +++ b/src/telegram/bot-message-context.dm-threads.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { buildTelegramMessageContext } from "./bot-message-context.js"; describe("buildTelegramMessageContext dm thread sessions", () => { diff --git a/src/telegram/bot-message-context.sender-prefix.test.ts b/src/telegram/bot-message-context.sender-prefix.test.ts index 03c4dbb9a8e..c93e8df89d3 100644 --- a/src/telegram/bot-message-context.sender-prefix.test.ts +++ b/src/telegram/bot-message-context.sender-prefix.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { buildTelegramMessageContext } from "./bot-message-context.js"; describe("buildTelegramMessageContext sender prefix", () => { diff --git a/src/telegram/bot-message-context.ts b/src/telegram/bot-message-context.ts index 06b6dc0aa4a..1427e6ec507 100644 --- a/src/telegram/bot-message-context.ts +++ b/src/telegram/bot-message-context.ts @@ -1,5 +1,7 @@ import type { Bot } from "grammy"; - +import type { OpenClawConfig } from "../config/config.js"; +import type { DmPolicy, TelegramGroupConfig, TelegramTopicConfig } from "../config/types.js"; +import type { TelegramContext } from "./bot/types.js"; import { resolveAckReaction } from "../agents/identity.js"; import { findModelInCatalog, @@ -17,21 +19,25 @@ import { } from "../auto-reply/reply/history.js"; import { finalizeInboundContext } from "../auto-reply/reply/inbound-context.js"; import { buildMentionRegexes, matchesMentionWithExplicit } from "../auto-reply/reply/mentions.js"; +import { shouldAckReaction as shouldAckReactionGate } from "../channels/ack-reactions.js"; +import { resolveControlCommandGate } from "../channels/command-gating.js"; import { formatLocationText, toLocationContext } from "../channels/location.js"; +import { logInboundDrop } from "../channels/logging.js"; +import { resolveMentionGatingWithBypass } from "../channels/mention-gating.js"; import { recordInboundSession } from "../channels/session.js"; import { formatCliCommand } from "../cli/command-format.js"; import { readSessionUpdatedAt, resolveStorePath } from "../config/sessions.js"; -import type { OpenClawConfig } from "../config/config.js"; -import type { DmPolicy, TelegramGroupConfig, TelegramTopicConfig } from "../config/types.js"; import { logVerbose, shouldLogVerbose } from "../globals.js"; import { recordChannelActivity } from "../infra/channel-activity.js"; import { resolveAgentRoute } from "../routing/resolve-route.js"; import { resolveThreadSessionKeys } from "../routing/session-key.js"; -import { shouldAckReaction as shouldAckReactionGate } from "../channels/ack-reactions.js"; -import { resolveMentionGatingWithBypass } from "../channels/mention-gating.js"; -import { resolveControlCommandGate } from "../channels/command-gating.js"; -import { logInboundDrop } from "../channels/logging.js"; import { withTelegramApiErrorLogging } from "./api-logging.js"; +import { + firstDefined, + isSenderAllowed, + normalizeAllowFromWithStore, + resolveSenderAllowMatch, +} from "./bot-access.js"; import { buildGroupLabel, buildSenderLabel, @@ -46,14 +52,7 @@ import { hasBotMention, resolveTelegramForumThreadId, } from "./bot/helpers.js"; -import { - firstDefined, - isSenderAllowed, - normalizeAllowFromWithStore, - resolveSenderAllowMatch, -} from "./bot-access.js"; import { upsertTelegramPairingRequest } from "./pairing-store.js"; -import type { TelegramContext } from "./bot/types.js"; type TelegramMediaRef = { path: string; diff --git a/src/telegram/bot-message-dispatch.ts b/src/telegram/bot-message-dispatch.ts index 03a448dd747..4bc6b182366 100644 --- a/src/telegram/bot-message-dispatch.ts +++ b/src/telegram/bot-message-dispatch.ts @@ -1,11 +1,12 @@ +import { resolveAgentDir } from "../agents/agent-scope.js"; // @ts-nocheck import { findModelInCatalog, loadModelCatalog, modelSupportsVision, } from "../agents/model-catalog.js"; -import { EmbeddedBlockChunker } from "../agents/pi-embedded-block-chunker.js"; import { resolveDefaultModelForAgent } from "../agents/model-selection.js"; +import { EmbeddedBlockChunker } from "../agents/pi-embedded-block-chunker.js"; import { resolveChunkMode } from "../auto-reply/chunk.js"; import { clearHistoryEntriesIfEnabled } from "../auto-reply/reply/history.js"; import { dispatchReplyWithBufferedBlockDispatcher } from "../auto-reply/reply/provider-dispatcher.js"; @@ -13,13 +14,12 @@ import { removeAckReactionAfterReply } from "../channels/ack-reactions.js"; import { logAckFailure, logTypingFailure } from "../channels/logging.js"; import { createReplyPrefixContext } from "../channels/reply-prefix.js"; import { createTypingCallbacks } from "../channels/typing.js"; -import { danger, logVerbose } from "../globals.js"; import { resolveMarkdownTableMode } from "../config/markdown-tables.js"; +import { danger, logVerbose } from "../globals.js"; import { deliverReplies } from "./bot/delivery.js"; import { resolveTelegramDraftStreamingChunking } from "./draft-chunking.js"; import { createTelegramDraftStream } from "./draft-stream.js"; import { cacheSticker, describeStickerImage } from "./sticker-cache.js"; -import { resolveAgentDir } from "../agents/agent-scope.js"; const EMPTY_RESPONSE_FALLBACK = "No response generated. Please try again."; diff --git a/src/telegram/bot-native-commands.plugin-auth.test.ts b/src/telegram/bot-native-commands.plugin-auth.test.ts index 533f5fda3c5..60e315e8dbf 100644 --- a/src/telegram/bot-native-commands.plugin-auth.test.ts +++ b/src/telegram/bot-native-commands.plugin-auth.test.ts @@ -1,7 +1,6 @@ import { describe, expect, it, vi } from "vitest"; - -import type { ChannelGroupPolicy } from "../config/group-policy.js"; import type { OpenClawConfig } from "../config/config.js"; +import type { ChannelGroupPolicy } from "../config/group-policy.js"; import type { TelegramAccountConfig } from "../config/types.js"; import type { RuntimeEnv } from "../runtime.js"; import { registerTelegramNativeCommands } from "./bot-native-commands.js"; diff --git a/src/telegram/bot-native-commands.test.ts b/src/telegram/bot-native-commands.test.ts index dc6b94dccf4..1226ec701c0 100644 --- a/src/telegram/bot-native-commands.test.ts +++ b/src/telegram/bot-native-commands.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import type { TelegramAccountConfig } from "../config/types.js"; import type { RuntimeEnv } from "../runtime.js"; diff --git a/src/telegram/bot-native-commands.ts b/src/telegram/bot-native-commands.ts index cde1656cd9c..a64d261a5a5 100644 --- a/src/telegram/bot-native-commands.ts +++ b/src/telegram/bot-native-commands.ts @@ -1,5 +1,14 @@ import type { Bot, Context } from "grammy"; - +import type { CommandArgs } from "../auto-reply/commands-registry.js"; +import type { OpenClawConfig } from "../config/config.js"; +import type { ChannelGroupPolicy } from "../config/group-policy.js"; +import type { + ReplyToMode, + TelegramAccountConfig, + TelegramGroupConfig, + TelegramTopicConfig, +} from "../config/types.js"; +import type { RuntimeEnv } from "../runtime.js"; import { resolveEffectiveMessagesConfig } from "../agents/identity.js"; import { resolveChunkMode } from "../auto-reply/chunk.js"; import { @@ -10,45 +19,35 @@ import { parseCommandArgs, resolveCommandArgMenu, } from "../auto-reply/commands-registry.js"; -import { listSkillCommandsForAgents } from "../auto-reply/skill-commands.js"; -import type { CommandArgs } from "../auto-reply/commands-registry.js"; -import { resolveTelegramCustomCommands } from "../config/telegram-custom-commands.js"; -import { dispatchReplyWithBufferedBlockDispatcher } from "../auto-reply/reply/provider-dispatcher.js"; import { finalizeInboundContext } from "../auto-reply/reply/inbound-context.js"; -import { danger, logVerbose } from "../globals.js"; +import { dispatchReplyWithBufferedBlockDispatcher } from "../auto-reply/reply/provider-dispatcher.js"; +import { listSkillCommandsForAgents } from "../auto-reply/skill-commands.js"; +import { resolveCommandAuthorizedFromAuthorizers } from "../channels/command-gating.js"; import { resolveMarkdownTableMode } from "../config/markdown-tables.js"; -import { withTelegramApiErrorLogging } from "./api-logging.js"; +import { resolveTelegramCustomCommands } from "../config/telegram-custom-commands.js"; import { normalizeTelegramCommandName, TELEGRAM_COMMAND_NAME_PATTERN, } from "../config/telegram-custom-commands.js"; -import { resolveAgentRoute } from "../routing/resolve-route.js"; -import { resolveThreadSessionKeys } from "../routing/session-key.js"; -import { resolveCommandAuthorizedFromAuthorizers } from "../channels/command-gating.js"; +import { danger, logVerbose } from "../globals.js"; import { executePluginCommand, getPluginCommandSpecs, matchPluginCommand, } from "../plugins/commands.js"; -import type { ChannelGroupPolicy } from "../config/group-policy.js"; -import type { - ReplyToMode, - TelegramAccountConfig, - TelegramGroupConfig, - TelegramTopicConfig, -} from "../config/types.js"; -import type { OpenClawConfig } from "../config/config.js"; -import type { RuntimeEnv } from "../runtime.js"; +import { resolveAgentRoute } from "../routing/resolve-route.js"; +import { resolveThreadSessionKeys } from "../routing/session-key.js"; +import { withTelegramApiErrorLogging } from "./api-logging.js"; +import { firstDefined, isSenderAllowed, normalizeAllowFromWithStore } from "./bot-access.js"; import { deliverReplies } from "./bot/delivery.js"; -import { buildInlineKeyboard } from "./send.js"; import { buildSenderName, buildTelegramGroupFrom, buildTelegramGroupPeerId, resolveTelegramForumThreadId, } from "./bot/helpers.js"; -import { firstDefined, isSenderAllowed, normalizeAllowFromWithStore } from "./bot-access.js"; import { readTelegramAllowFromStore } from "./pairing-store.js"; +import { buildInlineKeyboard } from "./send.js"; const EMPTY_RESPONSE_FALLBACK = "No response generated. Please try again."; diff --git a/src/telegram/bot-updates.ts b/src/telegram/bot-updates.ts index 662cb92df25..c59e9ac219a 100644 --- a/src/telegram/bot-updates.ts +++ b/src/telegram/bot-updates.ts @@ -1,5 +1,5 @@ -import { createDedupeCache } from "../infra/dedupe.js"; import type { TelegramContext, TelegramMessage } from "./bot/types.js"; +import { createDedupeCache } from "../infra/dedupe.js"; const MEDIA_GROUP_TIMEOUT_MS = 500; const RECENT_TELEGRAM_UPDATE_TTL_MS = 5 * 60_000; diff --git a/src/telegram/bot.test.ts b/src/telegram/bot.test.ts index 3516588f79c..ab79c7adab1 100644 --- a/src/telegram/bot.test.ts +++ b/src/telegram/bot.test.ts @@ -2,12 +2,12 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { escapeRegExp, formatEnvelopeTimestamp } from "../../test/helpers/envelope-timestamp.js"; +import { expectInboundContextContract } from "../../test/helpers/inbound-contract.js"; import { listNativeCommandSpecs, listNativeCommandSpecsForConfig, } from "../auto-reply/commands-registry.js"; -import { escapeRegExp, formatEnvelopeTimestamp } from "../../test/helpers/envelope-timestamp.js"; -import { expectInboundContextContract } from "../../test/helpers/inbound-contract.js"; import { resolveTelegramFetch } from "./fetch.js"; let createTelegramBot: typeof import("./bot.js").createTelegramBot; diff --git a/src/telegram/bot.ts b/src/telegram/bot.ts index f4416ca307b..2a83c322932 100644 --- a/src/telegram/bot.ts +++ b/src/telegram/bot.ts @@ -1,18 +1,20 @@ +import type { ApiClientOptions } from "grammy"; // @ts-nocheck import { sequentialize } from "@grammyjs/runner"; import { apiThrottler } from "@grammyjs/transformer-throttler"; -import type { ApiClientOptions } from "grammy"; import { Bot, webhookCallback } from "grammy"; +import type { OpenClawConfig, ReplyToMode } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; +import type { TelegramContext, TelegramMessage } from "./bot/types.js"; import { resolveDefaultAgentId } from "../agents/agent-scope.js"; -import { isControlCommandMessage } from "../auto-reply/command-detection.js"; import { resolveTextChunkLimit } from "../auto-reply/chunk.js"; +import { isControlCommandMessage } from "../auto-reply/command-detection.js"; import { DEFAULT_GROUP_HISTORY_LIMIT, type HistoryEntry } from "../auto-reply/reply/history.js"; import { isNativeCommandsExplicitlyDisabled, resolveNativeCommandsEnabled, resolveNativeSkillsEnabled, } from "../config/commands.js"; -import type { OpenClawConfig, ReplyToMode } from "../config/config.js"; import { loadConfig } from "../config/config.js"; import { resolveChannelGroupPolicy, @@ -20,20 +22,14 @@ import { } from "../config/group-policy.js"; import { loadSessionStore, resolveStorePath } from "../config/sessions.js"; import { danger, logVerbose, shouldLogVerbose } from "../globals.js"; -import { createSubsystemLogger } from "../logging/subsystem.js"; import { formatUncaughtError } from "../infra/errors.js"; import { enqueueSystemEvent } from "../infra/system-events.js"; import { getChildLogger } from "../logging.js"; +import { createSubsystemLogger } from "../logging/subsystem.js"; import { resolveAgentRoute } from "../routing/resolve-route.js"; import { resolveThreadSessionKeys } from "../routing/session-key.js"; -import type { RuntimeEnv } from "../runtime.js"; import { resolveTelegramAccount } from "./accounts.js"; -import { - buildTelegramGroupPeerId, - resolveTelegramForumThreadId, - resolveTelegramStreamMode, -} from "./bot/helpers.js"; -import type { TelegramContext, TelegramMessage } from "./bot/types.js"; +import { withTelegramApiErrorLogging } from "./api-logging.js"; import { registerTelegramHandlers } from "./bot-handlers.js"; import { createTelegramMessageProcessor } from "./bot-message.js"; import { registerTelegramNativeCommands } from "./bot-native-commands.js"; @@ -43,7 +39,11 @@ import { resolveTelegramUpdateId, type TelegramUpdateKeyContext, } from "./bot-updates.js"; -import { withTelegramApiErrorLogging } from "./api-logging.js"; +import { + buildTelegramGroupPeerId, + resolveTelegramForumThreadId, + resolveTelegramStreamMode, +} from "./bot/helpers.js"; import { resolveTelegramFetch } from "./fetch.js"; import { wasSentByBot } from "./sent-message-cache.js"; diff --git a/src/telegram/bot/delivery.test.ts b/src/telegram/bot/delivery.test.ts index 3cf1b25348a..0fb388a35e0 100644 --- a/src/telegram/bot/delivery.test.ts +++ b/src/telegram/bot/delivery.test.ts @@ -1,7 +1,5 @@ -import { beforeEach, describe, expect, it, vi } from "vitest"; - import type { Bot } from "grammy"; - +import { beforeEach, describe, expect, it, vi } from "vitest"; import { deliverReplies } from "./delivery.js"; const loadWebMedia = vi.fn(); diff --git a/src/telegram/bot/delivery.ts b/src/telegram/bot/delivery.ts index 2fca5dc7231..5583fec5410 100644 --- a/src/telegram/bot/delivery.ts +++ b/src/telegram/bot/delivery.ts @@ -1,28 +1,28 @@ import { type Bot, GrammyError, InputFile } from "grammy"; -import { - markdownToTelegramChunks, - markdownToTelegramHtml, - renderTelegramHtmlText, -} from "../format.js"; -import { withTelegramApiErrorLogging } from "../api-logging.js"; -import { chunkMarkdownTextWithMode, type ChunkMode } from "../../auto-reply/chunk.js"; -import { splitTelegramCaption } from "../caption.js"; import type { ReplyPayload } from "../../auto-reply/types.js"; import type { ReplyToMode } from "../../config/config.js"; import type { MarkdownTableMode } from "../../config/types.base.js"; +import type { RuntimeEnv } from "../../runtime.js"; +import type { StickerMetadata, TelegramContext } from "./types.js"; +import { chunkMarkdownTextWithMode, type ChunkMode } from "../../auto-reply/chunk.js"; import { danger, logVerbose } from "../../globals.js"; import { formatErrorMessage } from "../../infra/errors.js"; import { mediaKindFromMime } from "../../media/constants.js"; import { fetchRemoteMedia } from "../../media/fetch.js"; import { isGifMedia } from "../../media/mime.js"; import { saveMediaBuffer } from "../../media/store.js"; -import type { RuntimeEnv } from "../../runtime.js"; import { loadWebMedia } from "../../web/media.js"; +import { withTelegramApiErrorLogging } from "../api-logging.js"; +import { splitTelegramCaption } from "../caption.js"; +import { + markdownToTelegramChunks, + markdownToTelegramHtml, + renderTelegramHtmlText, +} from "../format.js"; import { buildInlineKeyboard } from "../send.js"; +import { cacheSticker, getCachedSticker } from "../sticker-cache.js"; import { resolveTelegramVoiceSend } from "../voice.js"; import { buildTelegramThreadParams, resolveTelegramReplyId } from "./helpers.js"; -import type { StickerMetadata, TelegramContext } from "./types.js"; -import { cacheSticker, getCachedSticker } from "../sticker-cache.js"; const PARSE_ERR_RE = /can't parse entities|parse entities|find end of the entity/i; const VOICE_FORBIDDEN_RE = /VOICE_MESSAGES_FORBIDDEN/; diff --git a/src/telegram/bot/helpers.expand-text-links.test.ts b/src/telegram/bot/helpers.expand-text-links.test.ts index aed680682ea..7035a670a66 100644 --- a/src/telegram/bot/helpers.expand-text-links.test.ts +++ b/src/telegram/bot/helpers.expand-text-links.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { expandTextLinks } from "./helpers.js"; describe("expandTextLinks", () => { diff --git a/src/telegram/bot/helpers.ts b/src/telegram/bot/helpers.ts index 1ee479be300..4e059c8798a 100644 --- a/src/telegram/bot/helpers.ts +++ b/src/telegram/bot/helpers.ts @@ -1,4 +1,3 @@ -import { formatLocationText, type NormalizedLocation } from "../../channels/location.js"; import type { TelegramForwardChat, TelegramForwardOrigin, @@ -9,6 +8,7 @@ import type { TelegramStreamMode, TelegramVenue, } from "./types.js"; +import { formatLocationText, type NormalizedLocation } from "../../channels/location.js"; const TELEGRAM_GENERAL_TOPIC_ID = 1; diff --git a/src/telegram/download.test.ts b/src/telegram/download.test.ts index 6625cbcf5a3..5738877ca1c 100644 --- a/src/telegram/download.test.ts +++ b/src/telegram/download.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { downloadTelegramFile, getTelegramFile, type TelegramFileInfo } from "./download.js"; describe("telegram download", () => { diff --git a/src/telegram/draft-chunking.test.ts b/src/telegram/draft-chunking.test.ts index 4c8dae7633d..1885efd94c3 100644 --- a/src/telegram/draft-chunking.test.ts +++ b/src/telegram/draft-chunking.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../../config/config.js"; import { resolveTelegramDraftStreamingChunking } from "./draft-chunking.js"; diff --git a/src/telegram/draft-chunking.ts b/src/telegram/draft-chunking.ts index e73a76ae8cc..8c594cb654a 100644 --- a/src/telegram/draft-chunking.ts +++ b/src/telegram/draft-chunking.ts @@ -1,6 +1,6 @@ +import type { OpenClawConfig } from "../config/config.js"; import { resolveTextChunkLimit } from "../auto-reply/chunk.js"; import { getChannelDock } from "../channels/dock.js"; -import type { OpenClawConfig } from "../config/config.js"; import { normalizeAccountId } from "../routing/session-key.js"; const DEFAULT_TELEGRAM_DRAFT_STREAM_MIN = 200; diff --git a/src/telegram/draft-stream.test.ts b/src/telegram/draft-stream.test.ts index 920951e861d..b67e13fca9e 100644 --- a/src/telegram/draft-stream.test.ts +++ b/src/telegram/draft-stream.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { createTelegramDraftStream } from "./draft-stream.js"; describe("createTelegramDraftStream", () => { diff --git a/src/telegram/fetch.ts b/src/telegram/fetch.ts index 9ae004e8063..96cb092772d 100644 --- a/src/telegram/fetch.ts +++ b/src/telegram/fetch.ts @@ -1,6 +1,6 @@ import * as net from "node:net"; -import { resolveFetch } from "../infra/fetch.js"; import type { TelegramNetworkConfig } from "../config/types.telegram.js"; +import { resolveFetch } from "../infra/fetch.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { resolveTelegramAutoSelectFamilyDecision } from "./network-config.js"; diff --git a/src/telegram/format.test.ts b/src/telegram/format.test.ts index e267719a836..7dedc2c6fa0 100644 --- a/src/telegram/format.test.ts +++ b/src/telegram/format.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { markdownToTelegramHtml } from "./format.js"; describe("markdownToTelegramHtml", () => { diff --git a/src/telegram/format.ts b/src/telegram/format.ts index 26a003c2e30..e3d7e4c4301 100644 --- a/src/telegram/format.ts +++ b/src/telegram/format.ts @@ -1,3 +1,4 @@ +import type { MarkdownTableMode } from "../config/types.base.js"; import { chunkMarkdownIR, markdownToIR, @@ -5,7 +6,6 @@ import { type MarkdownIR, } from "../markdown/ir.js"; import { renderMarkdownWithMarkers } from "../markdown/render.js"; -import type { MarkdownTableMode } from "../config/types.base.js"; export type TelegramFormattedChunk = { html: string; diff --git a/src/telegram/group-migration.test.ts b/src/telegram/group-migration.test.ts index f6cc03360cd..4d4ca9758a1 100644 --- a/src/telegram/group-migration.test.ts +++ b/src/telegram/group-migration.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { migrateTelegramGroupConfig } from "./group-migration.js"; describe("migrateTelegramGroupConfig", () => { diff --git a/src/telegram/inline-buttons.test.ts b/src/telegram/inline-buttons.test.ts index 687d29bddc4..5828e3d1e7f 100644 --- a/src/telegram/inline-buttons.test.ts +++ b/src/telegram/inline-buttons.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { resolveTelegramTargetChatType } from "./inline-buttons.js"; describe("resolveTelegramTargetChatType", () => { diff --git a/src/telegram/monitor.test.ts b/src/telegram/monitor.test.ts index 66c47f112c2..20ffd4e1bc0 100644 --- a/src/telegram/monitor.test.ts +++ b/src/telegram/monitor.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import { monitorTelegramProvider } from "./monitor.js"; type MockCtx = { diff --git a/src/telegram/monitor.ts b/src/telegram/monitor.ts index c39eb5e59ea..7a3a796b520 100644 --- a/src/telegram/monitor.ts +++ b/src/telegram/monitor.ts @@ -1,11 +1,11 @@ import { type RunOptions, run } from "@grammyjs/runner"; import type { OpenClawConfig } from "../config/config.js"; -import { loadConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; import { resolveAgentMaxConcurrent } from "../config/agent-limits.js"; +import { loadConfig } from "../config/config.js"; import { computeBackoff, sleepWithAbort } from "../infra/backoff.js"; import { formatErrorMessage } from "../infra/errors.js"; import { formatDurationMs } from "../infra/format-duration.js"; -import type { RuntimeEnv } from "../runtime.js"; import { resolveTelegramAccount } from "./accounts.js"; import { resolveTelegramAllowedUpdates } from "./allowed-updates.js"; import { createTelegramBot } from "./bot.js"; diff --git a/src/telegram/network-config.test.ts b/src/telegram/network-config.test.ts index 1766fac71f8..ed4aa8a0139 100644 --- a/src/telegram/network-config.test.ts +++ b/src/telegram/network-config.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { resolveTelegramAutoSelectFamilyDecision } from "./network-config.js"; describe("resolveTelegramAutoSelectFamilyDecision", () => { diff --git a/src/telegram/network-config.ts b/src/telegram/network-config.ts index 4e856010564..4a8fb1ef1b7 100644 --- a/src/telegram/network-config.ts +++ b/src/telegram/network-config.ts @@ -1,7 +1,6 @@ import process from "node:process"; - -import { isTruthyEnvValue } from "../infra/env.js"; import type { TelegramNetworkConfig } from "../config/types.telegram.js"; +import { isTruthyEnvValue } from "../infra/env.js"; export const TELEGRAM_DISABLE_AUTO_SELECT_FAMILY_ENV = "OPENCLAW_TELEGRAM_DISABLE_AUTO_SELECT_FAMILY"; diff --git a/src/telegram/network-errors.test.ts b/src/telegram/network-errors.test.ts index db582355f45..462932bd20b 100644 --- a/src/telegram/network-errors.test.ts +++ b/src/telegram/network-errors.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { isRecoverableTelegramNetworkError } from "./network-errors.js"; describe("isRecoverableTelegramNetworkError", () => { diff --git a/src/telegram/pairing-store.test.ts b/src/telegram/pairing-store.test.ts index 74db8ee41ac..08ef7bdb261 100644 --- a/src/telegram/pairing-store.test.ts +++ b/src/telegram/pairing-store.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import { approveTelegramPairingCode, listTelegramPairingRequests, diff --git a/src/telegram/reaction-level.test.ts b/src/telegram/reaction-level.test.ts index 7fddd7d2df4..a90f49f204a 100644 --- a/src/telegram/reaction-level.test.ts +++ b/src/telegram/reaction-level.test.ts @@ -1,5 +1,4 @@ import { afterAll, beforeAll, describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { resolveTelegramReactionLevel } from "./reaction-level.js"; diff --git a/src/telegram/send.ts b/src/telegram/send.ts index ec279e6e07d..cf5f8029873 100644 --- a/src/telegram/send.ts +++ b/src/telegram/send.ts @@ -5,13 +5,13 @@ import type { ReactionTypeEmoji, } from "@grammyjs/types"; import { type ApiClientOptions, Bot, HttpError, InputFile } from "grammy"; +import type { RetryConfig } from "../infra/retry.js"; import { loadConfig } from "../config/config.js"; +import { resolveMarkdownTableMode } from "../config/markdown-tables.js"; import { logVerbose } from "../globals.js"; import { recordChannelActivity } from "../infra/channel-activity.js"; -import { withTelegramApiErrorLogging } from "./api-logging.js"; -import { formatErrorMessage, formatUncaughtError } from "../infra/errors.js"; import { isDiagnosticFlagEnabled } from "../infra/diagnostic-flags.js"; -import type { RetryConfig } from "../infra/retry.js"; +import { formatErrorMessage, formatUncaughtError } from "../infra/errors.js"; import { createTelegramRetryRunner } from "../infra/retry-policy.js"; import { redactSensitiveText } from "../logging/redact.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; @@ -19,16 +19,16 @@ import { mediaKindFromMime } from "../media/constants.js"; import { isGifMedia } from "../media/mime.js"; import { loadWebMedia } from "../web/media.js"; import { type ResolvedTelegramAccount, resolveTelegramAccount } from "./accounts.js"; -import { resolveTelegramFetch } from "./fetch.js"; -import { makeProxyFetch } from "./proxy.js"; -import { renderTelegramHtmlText } from "./format.js"; -import { resolveMarkdownTableMode } from "../config/markdown-tables.js"; -import { isRecoverableTelegramNetworkError } from "./network-errors.js"; +import { withTelegramApiErrorLogging } from "./api-logging.js"; +import { buildTelegramThreadParams } from "./bot/helpers.js"; import { splitTelegramCaption } from "./caption.js"; +import { resolveTelegramFetch } from "./fetch.js"; +import { renderTelegramHtmlText } from "./format.js"; +import { isRecoverableTelegramNetworkError } from "./network-errors.js"; +import { makeProxyFetch } from "./proxy.js"; import { recordSentMessage } from "./sent-message-cache.js"; import { parseTelegramTarget, stripTelegramInternalPrefixes } from "./targets.js"; import { resolveTelegramVoiceSend } from "./voice.js"; -import { buildTelegramThreadParams } from "./bot/helpers.js"; type TelegramSendOpts = { token?: string; diff --git a/src/telegram/sticker-cache.ts b/src/telegram/sticker-cache.ts index d03276a233d..d49877b6056 100644 --- a/src/telegram/sticker-cache.ts +++ b/src/telegram/sticker-cache.ts @@ -1,17 +1,17 @@ import fs from "node:fs/promises"; import path from "node:path"; -import type { OpenClawConfig } from "../config/config.js"; -import { STATE_DIR } from "../config/paths.js"; -import { loadJsonFile, saveJsonFile } from "../infra/json-file.js"; -import { logVerbose } from "../globals.js"; import type { ModelCatalogEntry } from "../agents/model-catalog.js"; +import type { OpenClawConfig } from "../config/config.js"; +import { resolveApiKeyForProvider } from "../agents/model-auth.js"; import { findModelInCatalog, loadModelCatalog, modelSupportsVision, } from "../agents/model-catalog.js"; -import { resolveApiKeyForProvider } from "../agents/model-auth.js"; import { resolveDefaultModelForAgent } from "../agents/model-selection.js"; +import { STATE_DIR } from "../config/paths.js"; +import { logVerbose } from "../globals.js"; +import { loadJsonFile, saveJsonFile } from "../infra/json-file.js"; import { resolveAutoImageModel } from "../media-understanding/runner.js"; const CACHE_FILE = path.join(STATE_DIR, "telegram", "sticker-cache.json"); diff --git a/src/telegram/targets.test.ts b/src/telegram/targets.test.ts index f0b28fef1dc..e25e38b2c3c 100644 --- a/src/telegram/targets.test.ts +++ b/src/telegram/targets.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { parseTelegramTarget, stripTelegramInternalPrefixes } from "./targets.js"; describe("stripTelegramInternalPrefixes", () => { diff --git a/src/telegram/token.test.ts b/src/telegram/token.test.ts index 8be3fd6a6fb..ad5a389ddcc 100644 --- a/src/telegram/token.test.ts +++ b/src/telegram/token.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; - import { afterEach, describe, expect, it, vi } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { resolveTelegramToken } from "./token.js"; diff --git a/src/telegram/token.ts b/src/telegram/token.ts index 710a764a06b..ed11d3f7476 100644 --- a/src/telegram/token.ts +++ b/src/telegram/token.ts @@ -1,5 +1,4 @@ import fs from "node:fs"; - import type { OpenClawConfig } from "../config/config.js"; import type { TelegramAccountConfig } from "../config/types.telegram.js"; import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.js"; diff --git a/src/telegram/update-offset-store.test.ts b/src/telegram/update-offset-store.test.ts index f1dd6e8886b..4e3f5d9a3b5 100644 --- a/src/telegram/update-offset-store.test.ts +++ b/src/telegram/update-offset-store.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import { readTelegramUpdateOffset, writeTelegramUpdateOffset } from "./update-offset-store.js"; async function withTempStateDir(fn: (dir: string) => Promise) { diff --git a/src/telegram/update-offset-store.ts b/src/telegram/update-offset-store.ts index 3ea2e5ef986..6597fa25c3c 100644 --- a/src/telegram/update-offset-store.ts +++ b/src/telegram/update-offset-store.ts @@ -2,7 +2,6 @@ import crypto from "node:crypto"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { resolveStateDir } from "../config/paths.js"; const STORE_VERSION = 1; diff --git a/src/telegram/voice.test.ts b/src/telegram/voice.test.ts index e1e74caebc7..e2d96a971bc 100644 --- a/src/telegram/voice.test.ts +++ b/src/telegram/voice.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { resolveTelegramVoiceSend } from "./voice.js"; describe("resolveTelegramVoiceSend", () => { diff --git a/src/telegram/webhook-set.ts b/src/telegram/webhook-set.ts index 0d2e815fc67..1bee5248526 100644 --- a/src/telegram/webhook-set.ts +++ b/src/telegram/webhook-set.ts @@ -1,7 +1,7 @@ import { type ApiClientOptions, Bot } from "grammy"; import type { TelegramNetworkConfig } from "../config/types.telegram.js"; -import { resolveTelegramFetch } from "./fetch.js"; import { withTelegramApiErrorLogging } from "./api-logging.js"; +import { resolveTelegramFetch } from "./fetch.js"; export async function setTelegramWebhook(opts: { token: string; diff --git a/src/telegram/webhook.test.ts b/src/telegram/webhook.test.ts index 64b146b4875..5d9efe61074 100644 --- a/src/telegram/webhook.test.ts +++ b/src/telegram/webhook.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { startTelegramWebhook } from "./webhook.js"; const handlerSpy = vi.fn( diff --git a/src/telegram/webhook.ts b/src/telegram/webhook.ts index 582741f866b..b9dc070d18d 100644 --- a/src/telegram/webhook.ts +++ b/src/telegram/webhook.ts @@ -1,11 +1,9 @@ -import { createServer } from "node:http"; - import { webhookCallback } from "grammy"; +import { createServer } from "node:http"; import type { OpenClawConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; import { isDiagnosticsEnabled } from "../infra/diagnostic-events.js"; import { formatErrorMessage } from "../infra/errors.js"; -import type { RuntimeEnv } from "../runtime.js"; -import { defaultRuntime } from "../runtime.js"; import { logWebhookError, logWebhookProcessed, @@ -13,9 +11,10 @@ import { startDiagnosticHeartbeat, stopDiagnosticHeartbeat, } from "../logging/diagnostic.js"; +import { defaultRuntime } from "../runtime.js"; import { resolveTelegramAllowedUpdates } from "./allowed-updates.js"; -import { createTelegramBot } from "./bot.js"; import { withTelegramApiErrorLogging } from "./api-logging.js"; +import { createTelegramBot } from "./bot.js"; export async function startTelegramWebhook(opts: { token: string; diff --git a/src/terminal/stream-writer.test.ts b/src/terminal/stream-writer.test.ts index 429199a8309..5355ac59f92 100644 --- a/src/terminal/stream-writer.test.ts +++ b/src/terminal/stream-writer.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { createSafeStreamWriter } from "./stream-writer.js"; describe("createSafeStreamWriter", () => { diff --git a/src/terminal/table.test.ts b/src/terminal/table.test.ts index 39e9a31056e..3c0d22b35db 100644 --- a/src/terminal/table.test.ts +++ b/src/terminal/table.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { visibleWidth } from "./ansi.js"; import { renderTable } from "./table.js"; diff --git a/src/terminal/table.ts b/src/terminal/table.ts index f0279c3bd69..34d7b15dd05 100644 --- a/src/terminal/table.ts +++ b/src/terminal/table.ts @@ -1,5 +1,5 @@ -import { visibleWidth } from "./ansi.js"; import { displayString } from "../utils.js"; +import { visibleWidth } from "./ansi.js"; type Align = "left" | "right" | "center"; diff --git a/src/terminal/theme.ts b/src/terminal/theme.ts index 966f289d73a..e5a771ace5c 100644 --- a/src/terminal/theme.ts +++ b/src/terminal/theme.ts @@ -1,5 +1,4 @@ import chalk, { Chalk } from "chalk"; - import { LOBSTER_PALETTE } from "./palette.js"; const hasForceColor = diff --git a/src/test-utils/channel-plugins.ts b/src/test-utils/channel-plugins.ts index 01370c9a40e..783582b20de 100644 --- a/src/test-utils/channel-plugins.ts +++ b/src/test-utils/channel-plugins.ts @@ -1,4 +1,3 @@ -import { imessageOutbound } from "../channels/plugins/outbound/imessage.js"; import type { ChannelCapabilities, ChannelId, @@ -6,6 +5,7 @@ import type { ChannelPlugin, } from "../channels/plugins/types.js"; import type { PluginRegistry } from "../plugins/registry.js"; +import { imessageOutbound } from "../channels/plugins/outbound/imessage.js"; import { normalizeIMessageHandle } from "../imessage/targets.js"; export const createTestRegistry = (channels: PluginRegistry["channels"] = []): PluginRegistry => ({ diff --git a/src/tts/tts.test.ts b/src/tts/tts.test.ts index 996999bea21..0e94d5d8c1c 100644 --- a/src/tts/tts.test.ts +++ b/src/tts/tts.test.ts @@ -1,7 +1,5 @@ -import { describe, expect, it, vi, beforeEach } from "vitest"; - import { completeSimple } from "@mariozechner/pi-ai"; - +import { describe, expect, it, vi, beforeEach } from "vitest"; import { getApiKeyForModel } from "../agents/model-auth.js"; import { resolveModel } from "../agents/pi-embedded-runner/model.js"; import * as tts from "./tts.js"; diff --git a/src/tts/tts.ts b/src/tts/tts.ts index 008649f3b9d..0f47c02a972 100644 --- a/src/tts/tts.ts +++ b/src/tts/tts.ts @@ -1,3 +1,5 @@ +import { completeSimple, type TextContent } from "@mariozechner/pi-ai"; +import { EdgeTTS } from "node-edge-tts"; import { existsSync, mkdirSync, @@ -10,12 +12,7 @@ import { } from "node:fs"; import { tmpdir } from "node:os"; import path from "node:path"; - -import { completeSimple, type TextContent } from "@mariozechner/pi-ai"; -import { EdgeTTS } from "node-edge-tts"; - import type { ReplyPayload } from "../auto-reply/types.js"; -import { normalizeChannelId } from "../channels/plugins/index.js"; import type { ChannelId } from "../channels/plugins/types.js"; import type { OpenClawConfig } from "../config/config.js"; import type { @@ -25,9 +22,6 @@ import type { TtsProvider, TtsModelOverrideConfig, } from "../config/types.tts.js"; -import { logVerbose } from "../globals.js"; -import { isVoiceCompatibleAudio } from "../media/audio.js"; -import { CONFIG_DIR, resolveUserPath } from "../utils.js"; import { getApiKeyForModel, requireApiKey } from "../agents/model-auth.js"; import { buildModelAliasIndex, @@ -36,6 +30,10 @@ import { type ModelRef, } from "../agents/model-selection.js"; import { resolveModel } from "../agents/pi-embedded-runner/model.js"; +import { normalizeChannelId } from "../channels/plugins/index.js"; +import { logVerbose } from "../globals.js"; +import { isVoiceCompatibleAudio } from "../media/audio.js"; +import { CONFIG_DIR, resolveUserPath } from "../utils.js"; const DEFAULT_TIMEOUT_MS = 30_000; const DEFAULT_TTS_MAX_LENGTH = 1500; diff --git a/src/tui/commands.test.ts b/src/tui/commands.test.ts index 43be2073343..5bd02b87d9c 100644 --- a/src/tui/commands.test.ts +++ b/src/tui/commands.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { getSlashCommands, parseCommand } from "./commands.js"; describe("tui slash commands", () => { diff --git a/src/tui/commands.ts b/src/tui/commands.ts index 4f15841c9d9..66260d6a169 100644 --- a/src/tui/commands.ts +++ b/src/tui/commands.ts @@ -1,7 +1,7 @@ import type { SlashCommand } from "@mariozechner/pi-tui"; +import type { OpenClawConfig } from "../config/types.js"; import { listChatCommands, listChatCommandsForConfig } from "../auto-reply/commands-registry.js"; import { formatThinkingLevels, listThinkingLevelLabels } from "../auto-reply/thinking.js"; -import type { OpenClawConfig } from "../config/types.js"; const VERBOSE_LEVELS = ["on", "off"]; const REASONING_LEVELS = ["on", "off"]; diff --git a/src/tui/components/filterable-select-list.ts b/src/tui/components/filterable-select-list.ts index a7b197bf5ff..7a2834872f1 100644 --- a/src/tui/components/filterable-select-list.ts +++ b/src/tui/components/filterable-select-list.ts @@ -1,3 +1,4 @@ +import type { Component } from "@mariozechner/pi-tui"; import { Input, matchesKey, @@ -6,7 +7,6 @@ import { type SelectListTheme, getEditorKeybindings, } from "@mariozechner/pi-tui"; -import type { Component } from "@mariozechner/pi-tui"; import chalk from "chalk"; import { fuzzyFilterLower, prepareSearchItems } from "./fuzzy-filter.js"; diff --git a/src/tui/tui-command-handlers.test.ts b/src/tui/tui-command-handlers.test.ts index fc2ac4fa623..5ca9f9745b2 100644 --- a/src/tui/tui-command-handlers.test.ts +++ b/src/tui/tui-command-handlers.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { createCommandHandlers } from "./tui-command-handlers.js"; describe("tui command handlers", () => { diff --git a/src/tui/tui-command-handlers.ts b/src/tui/tui-command-handlers.ts index e71f9a0092b..136885b2af1 100644 --- a/src/tui/tui-command-handlers.ts +++ b/src/tui/tui-command-handlers.ts @@ -1,4 +1,12 @@ import type { Component, TUI } from "@mariozechner/pi-tui"; +import type { ChatLog } from "./components/chat-log.js"; +import type { GatewayChatClient } from "./gateway-chat.js"; +import type { + AgentSummary, + GatewayStatusSummary, + TuiOptions, + TuiStateAccess, +} from "./tui-types.js"; import { formatThinkingLevels, normalizeUsageDisplay, @@ -7,20 +15,12 @@ import { import { normalizeAgentId } from "../routing/session-key.js"; import { formatRelativeTime } from "../utils/time-format.js"; import { helpText, parseCommand } from "./commands.js"; -import type { ChatLog } from "./components/chat-log.js"; import { createFilterableSelectList, createSearchableSelectList, createSettingsList, } from "./components/selectors.js"; -import type { GatewayChatClient } from "./gateway-chat.js"; import { formatStatusSummary } from "./tui-status-summary.js"; -import type { - AgentSummary, - GatewayStatusSummary, - TuiOptions, - TuiStateAccess, -} from "./tui-types.js"; type CommandHandlerContext = { client: GatewayChatClient; diff --git a/src/tui/tui-event-handlers.test.ts b/src/tui/tui-event-handlers.test.ts index ee661da3900..3549cf4bba7 100644 --- a/src/tui/tui-event-handlers.test.ts +++ b/src/tui/tui-event-handlers.test.ts @@ -1,7 +1,6 @@ import { describe, expect, it, vi } from "vitest"; - -import { createEventHandlers } from "./tui-event-handlers.js"; import type { AgentEvent, ChatEvent, TuiStateAccess } from "./tui-types.js"; +import { createEventHandlers } from "./tui-event-handlers.js"; type MockChatLog = { startTool: ReturnType; diff --git a/src/tui/tui-event-handlers.ts b/src/tui/tui-event-handlers.ts index 0ca38e22365..111f1fafb28 100644 --- a/src/tui/tui-event-handlers.ts +++ b/src/tui/tui-event-handlers.ts @@ -1,8 +1,8 @@ import type { TUI } from "@mariozechner/pi-tui"; import type { ChatLog } from "./components/chat-log.js"; +import type { AgentEvent, ChatEvent, TuiStateAccess } from "./tui-types.js"; import { asString, extractTextFromMessage, isCommandMessage } from "./tui-formatters.js"; import { TuiStreamAssembler } from "./tui-stream-assembler.js"; -import type { AgentEvent, ChatEvent, TuiStateAccess } from "./tui-types.js"; type EventHandlerContext = { chatLog: ChatLog; diff --git a/src/tui/tui-formatters.test.ts b/src/tui/tui-formatters.test.ts index 3200b237a2c..74d574c5124 100644 --- a/src/tui/tui-formatters.test.ts +++ b/src/tui/tui-formatters.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { extractContentFromMessage, extractTextFromMessage, diff --git a/src/tui/tui-formatters.ts b/src/tui/tui-formatters.ts index f50e6ed0334..4c6693a6bcb 100644 --- a/src/tui/tui-formatters.ts +++ b/src/tui/tui-formatters.ts @@ -1,5 +1,5 @@ -import { formatTokenCount } from "../utils/usage-format.js"; import { formatRawAssistantErrorForUi } from "../agents/pi-embedded-helpers.js"; +import { formatTokenCount } from "../utils/usage-format.js"; export function resolveFinalAssistantText(params: { finalText?: string | null; diff --git a/src/tui/tui-input-history.test.ts b/src/tui/tui-input-history.test.ts index 858e599a0f2..5bcdbe5479d 100644 --- a/src/tui/tui-input-history.test.ts +++ b/src/tui/tui-input-history.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { createEditorSubmitHandler } from "./tui.js"; describe("createEditorSubmitHandler", () => { diff --git a/src/tui/tui-local-shell.test.ts b/src/tui/tui-local-shell.test.ts index 1e600ef6a14..7728478e721 100644 --- a/src/tui/tui-local-shell.test.ts +++ b/src/tui/tui-local-shell.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { createLocalShellRunner } from "./tui-local-shell.js"; const createSelector = () => { diff --git a/src/tui/tui-overlays.test.ts b/src/tui/tui-overlays.test.ts index a612c8c764f..c3842bd7020 100644 --- a/src/tui/tui-overlays.test.ts +++ b/src/tui/tui-overlays.test.ts @@ -1,6 +1,5 @@ import type { Component } from "@mariozechner/pi-tui"; import { describe, expect, it, vi } from "vitest"; - import { createOverlayHandlers } from "./tui-overlays.js"; class DummyComponent implements Component { diff --git a/src/tui/tui-session-actions.ts b/src/tui/tui-session-actions.ts index 7db5ed9ee0c..310acc74171 100644 --- a/src/tui/tui-session-actions.ts +++ b/src/tui/tui-session-actions.ts @@ -1,13 +1,13 @@ import type { TUI } from "@mariozechner/pi-tui"; +import type { ChatLog } from "./components/chat-log.js"; +import type { GatewayAgentsList, GatewayChatClient } from "./gateway-chat.js"; +import type { TuiOptions, TuiStateAccess } from "./tui-types.js"; import { normalizeAgentId, normalizeMainKey, parseAgentSessionKey, } from "../routing/session-key.js"; -import type { ChatLog } from "./components/chat-log.js"; -import type { GatewayAgentsList, GatewayChatClient } from "./gateway-chat.js"; import { asString, extractTextFromMessage, isCommandMessage } from "./tui-formatters.js"; -import type { TuiOptions, TuiStateAccess } from "./tui-types.js"; type SessionActionContext = { client: GatewayChatClient; diff --git a/src/tui/tui-status-summary.ts b/src/tui/tui-status-summary.ts index 62f1dcd6535..bda1b1b760f 100644 --- a/src/tui/tui-status-summary.ts +++ b/src/tui/tui-status-summary.ts @@ -1,7 +1,7 @@ +import type { GatewayStatusSummary } from "./tui-types.js"; import { formatAge } from "../infra/channel-summary.js"; import { formatTokenCount } from "../utils/usage-format.js"; import { formatContextUsageLine } from "./tui-formatters.js"; -import type { GatewayStatusSummary } from "./tui-types.js"; export function formatStatusSummary(summary: GatewayStatusSummary) { const lines: string[] = []; diff --git a/src/tui/tui-stream-assembler.test.ts b/src/tui/tui-stream-assembler.test.ts index 4a180a0d8ee..e56eb5699ec 100644 --- a/src/tui/tui-stream-assembler.test.ts +++ b/src/tui/tui-stream-assembler.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { TuiStreamAssembler } from "./tui-stream-assembler.js"; describe("TuiStreamAssembler", () => { diff --git a/src/tui/tui-waiting.test.ts b/src/tui/tui-waiting.test.ts index 12a3bc6c91d..d2a7aee871b 100644 --- a/src/tui/tui-waiting.test.ts +++ b/src/tui/tui-waiting.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { buildWaitingStatusMessage, pickWaitingPhrase } from "./tui-waiting.js"; const theme = { diff --git a/src/tui/tui.submit-handler.test.ts b/src/tui/tui.submit-handler.test.ts index 799f382e28a..a12d9f1145d 100644 --- a/src/tui/tui.submit-handler.test.ts +++ b/src/tui/tui.submit-handler.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { createEditorSubmitHandler } from "./tui.js"; describe("createEditorSubmitHandler", () => { diff --git a/src/tui/tui.test.ts b/src/tui/tui.test.ts index ade4239d382..789b9500994 100644 --- a/src/tui/tui.test.ts +++ b/src/tui/tui.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { resolveFinalAssistantText } from "./tui.js"; describe("resolveFinalAssistantText", () => { diff --git a/src/tui/tui.ts b/src/tui/tui.ts index 644146b9eb1..a2250746ea3 100644 --- a/src/tui/tui.ts +++ b/src/tui/tui.ts @@ -6,6 +6,13 @@ import { Text, TUI, } from "@mariozechner/pi-tui"; +import type { + AgentSummary, + SessionInfo, + SessionScope, + TuiOptions, + TuiStateAccess, +} from "./tui-types.js"; import { resolveDefaultAgentId } from "../agents/agent-scope.js"; import { loadConfig } from "../config/config.js"; import { @@ -23,16 +30,9 @@ import { createCommandHandlers } from "./tui-command-handlers.js"; import { createEventHandlers } from "./tui-event-handlers.js"; import { formatTokens } from "./tui-formatters.js"; import { createLocalShellRunner } from "./tui-local-shell.js"; -import { buildWaitingStatusMessage, defaultWaitingPhrases } from "./tui-waiting.js"; import { createOverlayHandlers } from "./tui-overlays.js"; import { createSessionActions } from "./tui-session-actions.js"; -import type { - AgentSummary, - SessionInfo, - SessionScope, - TuiOptions, - TuiStateAccess, -} from "./tui-types.js"; +import { buildWaitingStatusMessage, defaultWaitingPhrases } from "./tui-waiting.js"; export { resolveFinalAssistantText } from "./tui-formatters.js"; export type { TuiOptions } from "./tui-types.js"; diff --git a/src/utils/boolean.test.ts b/src/utils/boolean.test.ts index 00a2a66c353..04c1dd52f5e 100644 --- a/src/utils/boolean.test.ts +++ b/src/utils/boolean.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { parseBooleanValue } from "./boolean.js"; describe("parseBooleanValue", () => { diff --git a/src/utils/delivery-context.test.ts b/src/utils/delivery-context.test.ts index e0c7e71c4cb..6ab1abfce98 100644 --- a/src/utils/delivery-context.test.ts +++ b/src/utils/delivery-context.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { deliveryContextKey, deliveryContextFromSession, diff --git a/src/utils/message-channel.test.ts b/src/utils/message-channel.test.ts index 5651b97a397..460b51feb3d 100644 --- a/src/utils/message-channel.test.ts +++ b/src/utils/message-channel.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest"; - import type { ChannelPlugin } from "../channels/plugins/types.js"; import type { PluginRegistry } from "../plugins/registry.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; diff --git a/src/utils/message-channel.ts b/src/utils/message-channel.ts index da8205126d2..ed580960ad4 100644 --- a/src/utils/message-channel.ts +++ b/src/utils/message-channel.ts @@ -1,9 +1,9 @@ +import type { ChannelId } from "../channels/plugins/types.js"; import { CHANNEL_IDS, listChatChannelAliases, normalizeChatChannelId, } from "../channels/registry.js"; -import type { ChannelId } from "../channels/plugins/types.js"; import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES, diff --git a/src/web/accounts.ts b/src/web/accounts.ts index af45a414cab..88754b2a4d6 100644 --- a/src/web/accounts.ts +++ b/src/web/accounts.ts @@ -1,9 +1,8 @@ import fs from "node:fs"; import path from "node:path"; - import type { OpenClawConfig } from "../config/config.js"; -import { resolveOAuthDir } from "../config/paths.js"; import type { DmPolicy, GroupPolicy, WhatsAppAccountConfig } from "../config/types.js"; +import { resolveOAuthDir } from "../config/paths.js"; import { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js"; import { resolveUserPath } from "../utils.js"; import { hasWebCredsSync } from "./auth-store.js"; diff --git a/src/web/accounts.whatsapp-auth.test.ts b/src/web/accounts.whatsapp-auth.test.ts index cc288086501..c63ae12e56a 100644 --- a/src/web/accounts.whatsapp-auth.test.ts +++ b/src/web/accounts.whatsapp-auth.test.ts @@ -2,7 +2,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it } from "vitest"; - import { hasAnyWhatsAppAuth, listWhatsAppAuthDirs } from "./accounts.js"; describe("hasAnyWhatsAppAuth", () => { diff --git a/src/web/active-listener.ts b/src/web/active-listener.ts index d01372ed090..81170d3084f 100644 --- a/src/web/active-listener.ts +++ b/src/web/active-listener.ts @@ -1,5 +1,5 @@ -import { formatCliCommand } from "../cli/command-format.js"; import type { PollInput } from "../polls.js"; +import { formatCliCommand } from "../cli/command-format.js"; import { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js"; export type ActiveWebSendOptions = { diff --git a/src/web/auth-store.ts b/src/web/auth-store.ts index 0bf60ac3337..3b535eb82e8 100644 --- a/src/web/auth-store.ts +++ b/src/web/auth-store.ts @@ -1,14 +1,13 @@ import fsSync from "node:fs"; import fs from "node:fs/promises"; import path from "node:path"; - +import type { WebChannel } from "../utils.js"; +import { formatCliCommand } from "../cli/command-format.js"; import { resolveOAuthDir } from "../config/paths.js"; import { info, success } from "../globals.js"; import { getChildLogger } from "../logging.js"; import { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js"; import { defaultRuntime, type RuntimeEnv } from "../runtime.js"; -import { formatCliCommand } from "../cli/command-format.js"; -import type { WebChannel } from "../utils.js"; import { jidToE164, resolveUserPath } from "../utils.js"; export function resolveDefaultWebAuthDir(): string { diff --git a/src/web/auto-reply.broadcast-groups.broadcasts-sequentially-configured-order.test.ts b/src/web/auto-reply.broadcast-groups.broadcasts-sequentially-configured-order.test.ts index 2d31b7babb1..c3c2e26a122 100644 --- a/src/web/auto-reply.broadcast-groups.broadcasts-sequentially-configured-order.test.ts +++ b/src/web/auto-reply.broadcast-groups.broadcasts-sequentially-configured-order.test.ts @@ -13,8 +13,8 @@ vi.mock("../agents/pi-embedded.js", () => ({ resolveEmbeddedSessionLane: (key: string) => `session:${key.trim() || "main"}`, })); -import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js"; import type { OpenClawConfig } from "../config/config.js"; +import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js"; import { monitorWebChannel } from "./auto-reply.js"; import { resetLoadConfigMock, setLoadConfigMock } from "./test-helpers.js"; diff --git a/src/web/auto-reply.broadcast-groups.skips-unknown-broadcast-agent-ids-agents-list.test.ts b/src/web/auto-reply.broadcast-groups.skips-unknown-broadcast-agent-ids-agents-list.test.ts index bceb9041923..b7f47d6e49c 100644 --- a/src/web/auto-reply.broadcast-groups.skips-unknown-broadcast-agent-ids-agents-list.test.ts +++ b/src/web/auto-reply.broadcast-groups.skips-unknown-broadcast-agent-ids-agents-list.test.ts @@ -13,8 +13,8 @@ vi.mock("../agents/pi-embedded.js", () => ({ resolveEmbeddedSessionLane: (key: string) => `session:${key.trim() || "main"}`, })); -import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js"; import type { OpenClawConfig } from "../config/config.js"; +import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js"; import { monitorWebChannel } from "./auto-reply.js"; import { resetLoadConfigMock, setLoadConfigMock } from "./test-helpers.js"; diff --git a/src/web/auto-reply.partial-reply-gating.test.ts b/src/web/auto-reply.partial-reply-gating.test.ts index 14bb7b81b51..30ecf3e6278 100644 --- a/src/web/auto-reply.partial-reply-gating.test.ts +++ b/src/web/auto-reply.partial-reply-gating.test.ts @@ -13,10 +13,10 @@ vi.mock("../agents/pi-embedded.js", () => ({ resolveEmbeddedSessionLane: (key: string) => `session:${key.trim() || "main"}`, })); -import { runEmbeddedPiAgent } from "../agents/pi-embedded.js"; -import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js"; -import { getReplyFromConfig } from "../auto-reply/reply.js"; import type { OpenClawConfig } from "../config/config.js"; +import { runEmbeddedPiAgent } from "../agents/pi-embedded.js"; +import { getReplyFromConfig } from "../auto-reply/reply.js"; +import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js"; import { monitorWebChannel } from "./auto-reply.js"; import { resetLoadConfigMock, setLoadConfigMock } from "./test-helpers.js"; diff --git a/src/web/auto-reply.typing-controller-idle.test.ts b/src/web/auto-reply.typing-controller-idle.test.ts index d9ba0f46b1e..9df5e7e4de3 100644 --- a/src/web/auto-reply.typing-controller-idle.test.ts +++ b/src/web/auto-reply.typing-controller-idle.test.ts @@ -13,8 +13,8 @@ vi.mock("../agents/pi-embedded.js", () => ({ resolveEmbeddedSessionLane: (key: string) => `session:${key.trim() || "main"}`, })); -import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js"; import type { OpenClawConfig } from "../config/config.js"; +import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js"; import { monitorWebChannel } from "./auto-reply.js"; import { resetLoadConfigMock, setLoadConfigMock } from "./test-helpers.js"; diff --git a/src/web/auto-reply.web-auto-reply.supports-always-group-activation-silent-token-preserves.test.ts b/src/web/auto-reply.web-auto-reply.supports-always-group-activation-silent-token-preserves.test.ts index ddddad1ea79..d2b0de81ae7 100644 --- a/src/web/auto-reply.web-auto-reply.supports-always-group-activation-silent-token-preserves.test.ts +++ b/src/web/auto-reply.web-auto-reply.supports-always-group-activation-silent-token-preserves.test.ts @@ -14,8 +14,8 @@ vi.mock("../agents/pi-embedded.js", () => ({ resolveEmbeddedSessionLane: (key: string) => `session:${key.trim() || "main"}`, })); -import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js"; import { expectInboundContextContract } from "../../test/helpers/inbound-contract.js"; +import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js"; import { resetLogger, setLoggerOverride } from "../logging.js"; import { monitorWebChannel, SILENT_REPLY_TOKEN } from "./auto-reply.js"; import { resetBaileysMocks, resetLoadConfigMock, setLoadConfigMock } from "./test-helpers.js"; diff --git a/src/web/auto-reply/deliver-reply.ts b/src/web/auto-reply/deliver-reply.ts index 9b2bb807200..21ddc2d2a63 100644 --- a/src/web/auto-reply/deliver-reply.ts +++ b/src/web/auto-reply/deliver-reply.ts @@ -1,13 +1,13 @@ -import { chunkMarkdownTextWithMode, type ChunkMode } from "../../auto-reply/chunk.js"; -import type { MarkdownTableMode } from "../../config/types.base.js"; -import { convertMarkdownTables } from "../../markdown/tables.js"; import type { ReplyPayload } from "../../auto-reply/types.js"; +import type { MarkdownTableMode } from "../../config/types.base.js"; +import type { WebInboundMsg } from "./types.js"; +import { chunkMarkdownTextWithMode, type ChunkMode } from "../../auto-reply/chunk.js"; import { logVerbose, shouldLogVerbose } from "../../globals.js"; +import { convertMarkdownTables } from "../../markdown/tables.js"; import { loadWebMedia } from "../media.js"; import { newConnectionId } from "../reconnect.js"; import { formatError } from "../session.js"; import { whatsappOutboundLog } from "./loggers.js"; -import type { WebInboundMsg } from "./types.js"; import { elide } from "./util.js"; export async function deliverWebReply(params: { diff --git a/src/web/auto-reply/heartbeat-runner.ts b/src/web/auto-reply/heartbeat-runner.ts index 7badc6169c3..968e904fc81 100644 --- a/src/web/auto-reply/heartbeat-runner.ts +++ b/src/web/auto-reply/heartbeat-runner.ts @@ -1,11 +1,11 @@ +import type { ReplyPayload } from "../../auto-reply/types.js"; import { DEFAULT_HEARTBEAT_ACK_MAX_CHARS, resolveHeartbeatPrompt, stripHeartbeatToken, } from "../../auto-reply/heartbeat.js"; -import { HEARTBEAT_TOKEN } from "../../auto-reply/tokens.js"; import { getReplyFromConfig } from "../../auto-reply/reply.js"; -import type { ReplyPayload } from "../../auto-reply/types.js"; +import { HEARTBEAT_TOKEN } from "../../auto-reply/tokens.js"; import { resolveWhatsAppHeartbeatRecipients } from "../../channels/plugins/whatsapp-heartbeat.js"; import { loadConfig } from "../../config/config.js"; import { diff --git a/src/web/auto-reply/mentions.ts b/src/web/auto-reply/mentions.ts index f595bd2f0a2..7d5dcc22f29 100644 --- a/src/web/auto-reply/mentions.ts +++ b/src/web/auto-reply/mentions.ts @@ -1,7 +1,7 @@ -import { buildMentionRegexes, normalizeMentionText } from "../../auto-reply/reply/mentions.js"; import type { loadConfig } from "../../config/config.js"; -import { isSelfChatMode, jidToE164, normalizeE164 } from "../../utils.js"; import type { WebInboundMsg } from "./types.js"; +import { buildMentionRegexes, normalizeMentionText } from "../../auto-reply/reply/mentions.js"; +import { isSelfChatMode, jidToE164, normalizeE164 } from "../../utils.js"; export type MentionConfig = { mentionRegexes: RegExp[]; diff --git a/src/web/auto-reply/monitor.ts b/src/web/auto-reply/monitor.ts index 907bb79ed9c..5ca1dd8649c 100644 --- a/src/web/auto-reply/monitor.ts +++ b/src/web/auto-reply/monitor.ts @@ -1,7 +1,9 @@ -import { DEFAULT_GROUP_HISTORY_LIMIT } from "../../auto-reply/reply/history.js"; -import { getReplyFromConfig } from "../../auto-reply/reply.js"; +import type { WebChannelStatus, WebInboundMsg, WebMonitorTuning } from "./types.js"; import { hasControlCommand } from "../../auto-reply/command-detection.js"; import { resolveInboundDebounceMs } from "../../auto-reply/inbound-debounce.js"; +import { getReplyFromConfig } from "../../auto-reply/reply.js"; +import { DEFAULT_GROUP_HISTORY_LIMIT } from "../../auto-reply/reply/history.js"; +import { formatCliCommand } from "../../cli/command-format.js"; import { waitForever } from "../../cli/wait.js"; import { loadConfig } from "../../config/config.js"; import { logVerbose } from "../../globals.js"; @@ -11,7 +13,6 @@ import { registerUnhandledRejectionHandler } from "../../infra/unhandled-rejecti import { getChildLogger } from "../../logging.js"; import { resolveAgentRoute } from "../../routing/resolve-route.js"; import { defaultRuntime, type RuntimeEnv } from "../../runtime.js"; -import { formatCliCommand } from "../../cli/command-format.js"; import { resolveWhatsAppAccount } from "../accounts.js"; import { setActiveWebListener } from "../active-listener.js"; import { monitorWebInbox } from "../inbound.js"; @@ -28,7 +29,6 @@ import { whatsappHeartbeatLog, whatsappLog } from "./loggers.js"; import { buildMentionConfig } from "./mentions.js"; import { createEchoTracker } from "./monitor/echo.js"; import { createWebOnMessageHandler } from "./monitor/on-message.js"; -import type { WebChannelStatus, WebInboundMsg, WebMonitorTuning } from "./types.js"; import { isLikelyWhatsAppCryptoError } from "./util.js"; export async function monitorWebChannel( diff --git a/src/web/auto-reply/monitor/ack-reaction.ts b/src/web/auto-reply/monitor/ack-reaction.ts index bfc53f82358..13a2b76e2ed 100644 --- a/src/web/auto-reply/monitor/ack-reaction.ts +++ b/src/web/auto-reply/monitor/ack-reaction.ts @@ -1,9 +1,9 @@ import type { loadConfig } from "../../../config/config.js"; -import { logVerbose } from "../../../globals.js"; +import type { WebInboundMsg } from "../types.js"; import { shouldAckReactionForWhatsApp } from "../../../channels/ack-reactions.js"; +import { logVerbose } from "../../../globals.js"; import { sendReactionWhatsApp } from "../../outbound.js"; import { formatError } from "../../session.js"; -import type { WebInboundMsg } from "../types.js"; import { resolveGroupActivationFor } from "./group-activation.js"; export function maybeSendAckReaction(params: { diff --git a/src/web/auto-reply/monitor/broadcast.ts b/src/web/auto-reply/monitor/broadcast.ts index 52648cd97ad..f1ed5ac2110 100644 --- a/src/web/auto-reply/monitor/broadcast.ts +++ b/src/web/auto-reply/monitor/broadcast.ts @@ -1,5 +1,7 @@ import type { loadConfig } from "../../../config/config.js"; import type { resolveAgentRoute } from "../../../routing/resolve-route.js"; +import type { WebInboundMsg } from "../types.js"; +import type { GroupHistoryEntry } from "./process-message.js"; import { buildAgentSessionKey } from "../../../routing/resolve-route.js"; import { buildAgentMainSessionKey, @@ -8,8 +10,6 @@ import { } from "../../../routing/session-key.js"; import { formatError } from "../../session.js"; import { whatsappInboundLog } from "../loggers.js"; -import type { WebInboundMsg } from "../types.js"; -import type { GroupHistoryEntry } from "./process-message.js"; export async function maybeBroadcastMessage(params: { cfg: ReturnType; diff --git a/src/web/auto-reply/monitor/group-activation.ts b/src/web/auto-reply/monitor/group-activation.ts index aeb16428fbe..944ddeb46d4 100644 --- a/src/web/auto-reply/monitor/group-activation.ts +++ b/src/web/auto-reply/monitor/group-activation.ts @@ -1,5 +1,5 @@ -import { normalizeGroupActivation } from "../../../auto-reply/group-activation.js"; import type { loadConfig } from "../../../config/config.js"; +import { normalizeGroupActivation } from "../../../auto-reply/group-activation.js"; import { resolveChannelGroupPolicy, resolveChannelGroupRequireMention, diff --git a/src/web/auto-reply/monitor/group-gating.test.ts b/src/web/auto-reply/monitor/group-gating.test.ts index b0dc1e2f6a6..6eb1e2e2be7 100644 --- a/src/web/auto-reply/monitor/group-gating.test.ts +++ b/src/web/auto-reply/monitor/group-gating.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { applyGroupGating } from "./group-gating.js"; const baseConfig = { diff --git a/src/web/auto-reply/monitor/group-gating.ts b/src/web/auto-reply/monitor/group-gating.ts index 6a301ca1fa4..d6fadf83bbd 100644 --- a/src/web/auto-reply/monitor/group-gating.ts +++ b/src/web/auto-reply/monitor/group-gating.ts @@ -1,12 +1,12 @@ +import type { loadConfig } from "../../../config/config.js"; +import type { MentionConfig } from "../mentions.js"; +import type { WebInboundMsg } from "../types.js"; import { hasControlCommand } from "../../../auto-reply/command-detection.js"; import { parseActivationCommand } from "../../../auto-reply/group-activation.js"; -import type { loadConfig } from "../../../config/config.js"; -import { normalizeE164 } from "../../../utils.js"; -import { resolveMentionGating } from "../../../channels/mention-gating.js"; -import type { MentionConfig } from "../mentions.js"; -import { buildMentionConfig, debugMention, resolveOwnerList } from "../mentions.js"; -import type { WebInboundMsg } from "../types.js"; import { recordPendingHistoryEntryIfEnabled } from "../../../auto-reply/reply/history.js"; +import { resolveMentionGating } from "../../../channels/mention-gating.js"; +import { normalizeE164 } from "../../../utils.js"; +import { buildMentionConfig, debugMention, resolveOwnerList } from "../mentions.js"; import { stripMentionsForCommand } from "./commands.js"; import { resolveGroupActivationFor, resolveGroupPolicyFor } from "./group-activation.js"; import { noteGroupMember } from "./group-members.js"; diff --git a/src/web/auto-reply/monitor/message-line.test.ts b/src/web/auto-reply/monitor/message-line.test.ts index ad9bc475e0c..4bbdb883737 100644 --- a/src/web/auto-reply/monitor/message-line.test.ts +++ b/src/web/auto-reply/monitor/message-line.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { buildInboundLine } from "./message-line.js"; describe("buildInboundLine", () => { diff --git a/src/web/auto-reply/monitor/message-line.ts b/src/web/auto-reply/monitor/message-line.ts index 1416d8424ee..a0c104a9024 100644 --- a/src/web/auto-reply/monitor/message-line.ts +++ b/src/web/auto-reply/monitor/message-line.ts @@ -1,7 +1,7 @@ -import { resolveMessagePrefix } from "../../../agents/identity.js"; -import { formatInboundEnvelope, type EnvelopeFormatOptions } from "../../../auto-reply/envelope.js"; import type { loadConfig } from "../../../config/config.js"; import type { WebInboundMsg } from "../types.js"; +import { resolveMessagePrefix } from "../../../agents/identity.js"; +import { formatInboundEnvelope, type EnvelopeFormatOptions } from "../../../auto-reply/envelope.js"; export function formatReplyContext(msg: WebInboundMsg) { if (!msg.replyToBody) { diff --git a/src/web/auto-reply/monitor/on-message.ts b/src/web/auto-reply/monitor/on-message.ts index 93e68b6cf95..c34ded5d79f 100644 --- a/src/web/auto-reply/monitor/on-message.ts +++ b/src/web/auto-reply/monitor/on-message.ts @@ -1,15 +1,15 @@ -import type { MsgContext } from "../../../auto-reply/templating.js"; import type { getReplyFromConfig } from "../../../auto-reply/reply.js"; +import type { MsgContext } from "../../../auto-reply/templating.js"; import type { loadConfig } from "../../../config/config.js"; +import type { MentionConfig } from "../mentions.js"; +import type { WebInboundMsg } from "../types.js"; +import type { EchoTracker } from "./echo.js"; +import type { GroupHistoryEntry } from "./group-gating.js"; import { logVerbose } from "../../../globals.js"; import { resolveAgentRoute } from "../../../routing/resolve-route.js"; import { buildGroupHistoryKey } from "../../../routing/session-key.js"; import { normalizeE164 } from "../../../utils.js"; -import type { MentionConfig } from "../mentions.js"; -import type { WebInboundMsg } from "../types.js"; import { maybeBroadcastMessage } from "./broadcast.js"; -import type { EchoTracker } from "./echo.js"; -import type { GroupHistoryEntry } from "./group-gating.js"; import { applyGroupGating } from "./group-gating.js"; import { updateLastRouteInBackground } from "./last-route.js"; import { resolvePeerId } from "./peer.js"; diff --git a/src/web/auto-reply/monitor/peer.ts b/src/web/auto-reply/monitor/peer.ts index b41555ffa26..3bc91c5391e 100644 --- a/src/web/auto-reply/monitor/peer.ts +++ b/src/web/auto-reply/monitor/peer.ts @@ -1,5 +1,5 @@ -import { jidToE164, normalizeE164 } from "../../../utils.js"; import type { WebInboundMsg } from "../types.js"; +import { jidToE164, normalizeE164 } from "../../../utils.js"; export function resolvePeerId(msg: WebInboundMsg) { if (msg.chatType === "group") { diff --git a/src/web/auto-reply/monitor/process-message.inbound-contract.test.ts b/src/web/auto-reply/monitor/process-message.inbound-contract.test.ts index 33417976bb9..af080eefcae 100644 --- a/src/web/auto-reply/monitor/process-message.inbound-contract.test.ts +++ b/src/web/auto-reply/monitor/process-message.inbound-contract.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { expectInboundContextContract } from "../../../../test/helpers/inbound-contract.js"; let capturedCtx: unknown; diff --git a/src/web/auto-reply/monitor/process-message.ts b/src/web/auto-reply/monitor/process-message.ts index d4eba4f3b13..e8651529d19 100644 --- a/src/web/auto-reply/monitor/process-message.ts +++ b/src/web/auto-reply/monitor/process-message.ts @@ -1,5 +1,12 @@ +import type { getReplyFromConfig } from "../../../auto-reply/reply.js"; +import type { ReplyPayload } from "../../../auto-reply/types.js"; +import type { loadConfig } from "../../../config/config.js"; +import type { getChildLogger } from "../../../logging.js"; +import type { resolveAgentRoute } from "../../../routing/resolve-route.js"; +import type { WebInboundMsg } from "../types.js"; import { resolveIdentityNamePrefix } from "../../../agents/identity.js"; import { resolveChunkMode, resolveTextChunkLimit } from "../../../auto-reply/chunk.js"; +import { shouldComputeCommandAuthorized } from "../../../auto-reply/command-detection.js"; import { formatInboundEnvelope, resolveEnvelopeFormatOptions, @@ -8,30 +15,23 @@ import { buildHistoryContextFromEntries, type HistoryEntry, } from "../../../auto-reply/reply/history.js"; -import { dispatchReplyWithBufferedBlockDispatcher } from "../../../auto-reply/reply/provider-dispatcher.js"; -import type { getReplyFromConfig } from "../../../auto-reply/reply.js"; -import type { ReplyPayload } from "../../../auto-reply/types.js"; -import { shouldComputeCommandAuthorized } from "../../../auto-reply/command-detection.js"; import { finalizeInboundContext } from "../../../auto-reply/reply/inbound-context.js"; +import { dispatchReplyWithBufferedBlockDispatcher } from "../../../auto-reply/reply/provider-dispatcher.js"; import { toLocationContext } from "../../../channels/location.js"; import { createReplyPrefixContext } from "../../../channels/reply-prefix.js"; -import type { loadConfig } from "../../../config/config.js"; +import { resolveMarkdownTableMode } from "../../../config/markdown-tables.js"; import { readSessionUpdatedAt, recordSessionMetaFromInbound, resolveStorePath, } from "../../../config/sessions.js"; -import { resolveMarkdownTableMode } from "../../../config/markdown-tables.js"; import { logVerbose, shouldLogVerbose } from "../../../globals.js"; -import type { getChildLogger } from "../../../logging.js"; import { readChannelAllowFromStore } from "../../../pairing/pairing-store.js"; -import type { resolveAgentRoute } from "../../../routing/resolve-route.js"; import { jidToE164, normalizeE164 } from "../../../utils.js"; import { newConnectionId } from "../../reconnect.js"; import { formatError } from "../../session.js"; import { deliverWebReply } from "../deliver-reply.js"; import { whatsappInboundLog, whatsappOutboundLog } from "../loggers.js"; -import type { WebInboundMsg } from "../types.js"; import { elide } from "../util.js"; import { maybeSendAckReaction } from "./ack-reaction.js"; import { formatGroupMembers } from "./group-members.js"; diff --git a/src/web/auto-reply/session-snapshot.test.ts b/src/web/auto-reply/session-snapshot.test.ts index 112641a6e93..1f9d6dfc9f4 100644 --- a/src/web/auto-reply/session-snapshot.test.ts +++ b/src/web/auto-reply/session-snapshot.test.ts @@ -1,9 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it, vi } from "vitest"; - import { saveSessionStore } from "../../config/sessions.js"; import { getSessionSnapshot } from "./session-snapshot.js"; diff --git a/src/web/inbound.media.test.ts b/src/web/inbound.media.test.ts index c45287a05c5..91e37a5b4f3 100644 --- a/src/web/inbound.media.test.ts +++ b/src/web/inbound.media.test.ts @@ -2,7 +2,6 @@ import crypto from "node:crypto"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; const readAllowFromStoreMock = vi.fn().mockResolvedValue([]); diff --git a/src/web/inbound.test.ts b/src/web/inbound.test.ts index 97d17beabd9..70be8489df0 100644 --- a/src/web/inbound.test.ts +++ b/src/web/inbound.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { extractLocationData, extractMediaPlaceholder, extractText } from "./inbound.js"; describe("web inbound helpers", () => { diff --git a/src/web/inbound/access-control.pairing-history.test.ts b/src/web/inbound/access-control.pairing-history.test.ts index 795839bf29b..b5d5b721cda 100644 --- a/src/web/inbound/access-control.pairing-history.test.ts +++ b/src/web/inbound/access-control.pairing-history.test.ts @@ -1,5 +1,4 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; - import { checkInboundAccessControl } from "./access-control.js"; const sendMessageMock = vi.fn(); diff --git a/src/web/inbound/media.ts b/src/web/inbound/media.ts index a44c82c6ab2..b99721ffb2d 100644 --- a/src/web/inbound/media.ts +++ b/src/web/inbound/media.ts @@ -1,7 +1,7 @@ import type { proto, WAMessage } from "@whiskeysockets/baileys"; import { downloadMediaMessage, normalizeMessageContent } from "@whiskeysockets/baileys"; -import { logVerbose } from "../../globals.js"; import type { createWaSocket } from "../session.js"; +import { logVerbose } from "../../globals.js"; function unwrapMessage(message: proto.IMessage | undefined): proto.IMessage | undefined { const normalized = normalizeMessageContent(message); diff --git a/src/web/inbound/monitor.ts b/src/web/inbound/monitor.ts index b58782c0cba..c7cfabeba33 100644 --- a/src/web/inbound/monitor.ts +++ b/src/web/inbound/monitor.ts @@ -1,12 +1,13 @@ import type { AnyMessageContent, proto, WAMessage } from "@whiskeysockets/baileys"; import { DisconnectReason, isJidGroup } from "@whiskeysockets/baileys"; +import type { WebInboundMessage, WebListenerCloseReason } from "./types.js"; +import { createInboundDebouncer } from "../../auto-reply/inbound-debounce.js"; import { formatLocationText } from "../../channels/location.js"; import { logVerbose, shouldLogVerbose } from "../../globals.js"; import { recordChannelActivity } from "../../infra/channel-activity.js"; import { getChildLogger } from "../../logging/logger.js"; import { createSubsystemLogger } from "../../logging/subsystem.js"; import { saveMediaBuffer } from "../../media/store.js"; -import { createInboundDebouncer } from "../../auto-reply/inbound-debounce.js"; import { jidToE164, resolveJidToE164 } from "../../utils.js"; import { createWaSocket, getStatusCode, waitForWaConnection } from "../session.js"; import { checkInboundAccessControl } from "./access-control.js"; @@ -20,7 +21,6 @@ import { } from "./extract.js"; import { downloadInboundMedia } from "./media.js"; import { createWebSendApi } from "./send-api.js"; -import type { WebInboundMessage, WebListenerCloseReason } from "./types.js"; export async function monitorWebInbox(options: { verbose: boolean; diff --git a/src/web/inbound/send-api.ts b/src/web/inbound/send-api.ts index 06860e896f7..7deb9540dbd 100644 --- a/src/web/inbound/send-api.ts +++ b/src/web/inbound/send-api.ts @@ -1,7 +1,7 @@ import type { AnyMessageContent, WAPresence } from "@whiskeysockets/baileys"; +import type { ActiveWebSendOptions } from "../active-listener.js"; import { recordChannelActivity } from "../../infra/channel-activity.js"; import { toWhatsappJid } from "../../utils.js"; -import type { ActiveWebSendOptions } from "../active-listener.js"; export function createWebSendApi(params: { sock: { diff --git a/src/web/login-qr.ts b/src/web/login-qr.ts index c1d879e9fd9..323619be91b 100644 --- a/src/web/login-qr.ts +++ b/src/web/login-qr.ts @@ -1,6 +1,5 @@ -import { randomUUID } from "node:crypto"; - import { DisconnectReason } from "@whiskeysockets/baileys"; +import { randomUUID } from "node:crypto"; import { loadConfig } from "../config/config.js"; import { danger, info, success } from "../globals.js"; import { logInfo } from "../logger.js"; diff --git a/src/web/login.coverage.test.ts b/src/web/login.coverage.test.ts index 120dcff62e6..7fc3c39909b 100644 --- a/src/web/login.coverage.test.ts +++ b/src/web/login.coverage.test.ts @@ -1,8 +1,7 @@ +import { DisconnectReason } from "@whiskeysockets/baileys"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - -import { DisconnectReason } from "@whiskeysockets/baileys"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; const rmMock = vi.spyOn(fs, "rm"); diff --git a/src/web/login.test.ts b/src/web/login.test.ts index 99c90c18a8f..c3ed32e5210 100644 --- a/src/web/login.test.ts +++ b/src/web/login.test.ts @@ -1,7 +1,5 @@ import { EventEmitter } from "node:events"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import { resetLogger, setLoggerOverride } from "../logging.js"; vi.mock("./session.js", () => { @@ -18,8 +16,8 @@ vi.mock("./session.js", () => { }; }); -import { loginWeb } from "./login.js"; import type { waitForWaConnection } from "./session.js"; +import { loginWeb } from "./login.js"; const { createWaSocket } = await import("./session.js"); diff --git a/src/web/login.ts b/src/web/login.ts index d4c502ca2c5..b336f8ebe4f 100644 --- a/src/web/login.ts +++ b/src/web/login.ts @@ -1,9 +1,9 @@ import { DisconnectReason } from "@whiskeysockets/baileys"; +import { formatCliCommand } from "../cli/command-format.js"; import { loadConfig } from "../config/config.js"; import { danger, info, success } from "../globals.js"; import { logInfo } from "../logger.js"; import { defaultRuntime, type RuntimeEnv } from "../runtime.js"; -import { formatCliCommand } from "../cli/command-format.js"; import { resolveWhatsAppAccount } from "./accounts.js"; import { createWaSocket, formatError, logoutWeb, waitForWaConnection } from "./session.js"; diff --git a/src/web/logout.test.ts b/src/web/logout.test.ts index 54991d6b9c4..4f5cc64b138 100644 --- a/src/web/logout.test.ts +++ b/src/web/logout.test.ts @@ -1,8 +1,6 @@ import fs from "node:fs"; import path from "node:path"; - import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import { isPathWithinBase } from "../../test/helpers/paths.js"; import { withTempHome } from "../../test/helpers/temp-home.js"; diff --git a/src/web/media.test.ts b/src/web/media.test.ts index 0a47deecd69..21492db13a0 100644 --- a/src/web/media.test.ts +++ b/src/web/media.test.ts @@ -1,10 +1,8 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import sharp from "sharp"; import { afterEach, describe, expect, it, vi } from "vitest"; - import { optimizeImageToPng } from "../media/image-ops.js"; import { loadWebMedia, optimizeImageToJpeg } from "./media.js"; diff --git a/src/web/media.ts b/src/web/media.ts index 7daa4e355af..52d2ca6bf05 100644 --- a/src/web/media.ts +++ b/src/web/media.ts @@ -1,10 +1,8 @@ import fs from "node:fs/promises"; import path from "node:path"; import { fileURLToPath } from "node:url"; - import { logVerbose, shouldLogVerbose } from "../globals.js"; import { type MediaKind, maxBytesForKind, mediaKindFromMime } from "../media/constants.js"; -import { resolveUserPath } from "../utils.js"; import { fetchRemoteMedia } from "../media/fetch.js"; import { convertHeicToJpeg, @@ -13,6 +11,7 @@ import { resizeToJpeg, } from "../media/image-ops.js"; import { detectMime, extensionForMime } from "../media/mime.js"; +import { resolveUserPath } from "../utils.js"; export type WebMediaResult = { buffer: Buffer; diff --git a/src/web/monitor-inbox.allows-messages-from-senders-allowfrom-list.test.ts b/src/web/monitor-inbox.allows-messages-from-senders-allowfrom-list.test.ts index d341321902f..3c21832da7a 100644 --- a/src/web/monitor-inbox.allows-messages-from-senders-allowfrom-list.test.ts +++ b/src/web/monitor-inbox.allows-messages-from-senders-allowfrom-list.test.ts @@ -69,9 +69,7 @@ const _getSock = () => (createWaSocket as unknown as () => Promise (createWaSocket as unknown as () => Promise (createWaSocket as unknown as () => Promise { diff --git a/src/web/reconnect.test.ts b/src/web/reconnect.test.ts index 173c5d53a3b..6166a509e57 100644 --- a/src/web/reconnect.test.ts +++ b/src/web/reconnect.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import type { OpenClawConfig } from "../config/config.js"; import { computeBackoff, diff --git a/src/web/reconnect.ts b/src/web/reconnect.ts index 52982940c28..a0024810670 100644 --- a/src/web/reconnect.ts +++ b/src/web/reconnect.ts @@ -1,5 +1,4 @@ import { randomUUID } from "node:crypto"; - import type { OpenClawConfig } from "../config/config.js"; import type { BackoffPolicy } from "../infra/backoff.js"; import { computeBackoff, sleepWithAbort } from "../infra/backoff.js"; diff --git a/src/web/session.ts b/src/web/session.ts index ec601288a25..c25d6d793b4 100644 --- a/src/web/session.ts +++ b/src/web/session.ts @@ -1,5 +1,3 @@ -import { randomUUID } from "node:crypto"; -import fsSync from "node:fs"; import { DisconnectReason, fetchLatestBaileysVersion, @@ -7,13 +5,14 @@ import { makeWASocket, useMultiFileAuthState, } from "@whiskeysockets/baileys"; +import { randomUUID } from "node:crypto"; +import fsSync from "node:fs"; import qrcode from "qrcode-terminal"; +import { formatCliCommand } from "../cli/command-format.js"; import { danger, success } from "../globals.js"; import { getChildLogger, toPinoLikeLogger } from "../logging.js"; import { ensureDir, resolveUserPath } from "../utils.js"; import { VERSION } from "../version.js"; -import { formatCliCommand } from "../cli/command-format.js"; - import { maybeRestoreCredsFromBackup, resolveDefaultWebAuthDir, diff --git a/src/web/test-helpers.ts b/src/web/test-helpers.ts index 2738e68a5b3..78abd86a982 100644 --- a/src/web/test-helpers.ts +++ b/src/web/test-helpers.ts @@ -1,5 +1,4 @@ import { vi } from "vitest"; - import type { MockBaileysSocket } from "../../test/mocks/baileys.js"; import { createMockBaileys } from "../../test/mocks/baileys.js"; diff --git a/src/whatsapp/normalize.test.ts b/src/whatsapp/normalize.test.ts index 19dd0238100..330a1022588 100644 --- a/src/whatsapp/normalize.test.ts +++ b/src/whatsapp/normalize.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { isWhatsAppGroupJid, isWhatsAppUserTarget, normalizeWhatsAppTarget } from "./normalize.js"; describe("normalizeWhatsAppTarget", () => { diff --git a/src/wizard/clack-prompter.ts b/src/wizard/clack-prompter.ts index 469d80311a7..d04abf5b703 100644 --- a/src/wizard/clack-prompter.ts +++ b/src/wizard/clack-prompter.ts @@ -10,11 +10,11 @@ import { spinner, text, } from "@clack/prompts"; +import type { WizardProgress, WizardPrompter } from "./prompts.js"; import { createCliProgress } from "../cli/progress.js"; import { note as emitNote } from "../terminal/note.js"; import { stylePromptHint, stylePromptMessage, stylePromptTitle } from "../terminal/prompt-style.js"; import { theme } from "../terminal/theme.js"; -import type { WizardProgress, WizardPrompter } from "./prompts.js"; import { WizardCancelledError } from "./prompts.js"; function guardCancel(value: T | symbol): T { diff --git a/src/wizard/onboarding.finalize.ts b/src/wizard/onboarding.finalize.ts index 6c8e6d6102f..70b7f8430b6 100644 --- a/src/wizard/onboarding.finalize.ts +++ b/src/wizard/onboarding.finalize.ts @@ -1,13 +1,22 @@ import fs from "node:fs/promises"; import path from "node:path"; - +import type { OnboardOptions } from "../commands/onboard-types.js"; +import type { OpenClawConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; +import type { GatewayWizardSettings, WizardFlow } from "./onboarding.types.js"; +import type { WizardPrompter } from "./prompts.js"; import { DEFAULT_BOOTSTRAP_FILENAME } from "../agents/workspace.js"; +import { formatCliCommand } from "../cli/command-format.js"; +import { + buildGatewayInstallPlan, + gatewayInstallErrorHint, +} from "../commands/daemon-install-helpers.js"; import { DEFAULT_GATEWAY_DAEMON_RUNTIME, GATEWAY_DAEMON_RUNTIME_OPTIONS, } from "../commands/daemon-runtime.js"; -import { healthCommand } from "../commands/health.js"; import { formatHealthCheckFailure } from "../commands/health-format.js"; +import { healthCommand } from "../commands/health.js"; import { detectBrowserOpenSupport, formatControlUiSshHint, @@ -17,21 +26,11 @@ import { waitForGatewayReachable, resolveControlUiLinks, } from "../commands/onboard-helpers.js"; -import { formatCliCommand } from "../cli/command-format.js"; -import type { OnboardOptions } from "../commands/onboard-types.js"; -import type { OpenClawConfig } from "../config/config.js"; import { resolveGatewayService } from "../daemon/service.js"; import { isSystemdUserServiceAvailable } from "../daemon/systemd.js"; import { ensureControlUiAssetsBuilt } from "../infra/control-ui-assets.js"; -import type { RuntimeEnv } from "../runtime.js"; import { runTui } from "../tui/tui.js"; import { resolveUserPath } from "../utils.js"; -import { - buildGatewayInstallPlan, - gatewayInstallErrorHint, -} from "../commands/daemon-install-helpers.js"; -import type { GatewayWizardSettings, WizardFlow } from "./onboarding.types.js"; -import type { WizardPrompter } from "./prompts.js"; type FinalizeOnboardingOptions = { flow: WizardFlow; diff --git a/src/wizard/onboarding.gateway-config.test.ts b/src/wizard/onboarding.gateway-config.test.ts index dcd4a572525..42a474f979d 100644 --- a/src/wizard/onboarding.gateway-config.test.ts +++ b/src/wizard/onboarding.gateway-config.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import type { RuntimeEnv } from "../runtime.js"; import type { WizardPrompter } from "./prompts.js"; diff --git a/src/wizard/onboarding.gateway-config.ts b/src/wizard/onboarding.gateway-config.ts index 4f55aacb736..16f80135c1a 100644 --- a/src/wizard/onboarding.gateway-config.ts +++ b/src/wizard/onboarding.gateway-config.ts @@ -1,7 +1,5 @@ -import { normalizeGatewayTokenInput, randomToken } from "../commands/onboard-helpers.js"; import type { GatewayAuthChoice } from "../commands/onboard-types.js"; import type { GatewayBindMode, GatewayTailscaleMode, OpenClawConfig } from "../config/config.js"; -import { findTailscaleBinary } from "../infra/tailscale.js"; import type { RuntimeEnv } from "../runtime.js"; import type { GatewayWizardSettings, @@ -9,6 +7,8 @@ import type { WizardFlow, } from "./onboarding.types.js"; import type { WizardPrompter } from "./prompts.js"; +import { normalizeGatewayTokenInput, randomToken } from "../commands/onboard-helpers.js"; +import { findTailscaleBinary } from "../infra/tailscale.js"; type ConfigureGatewayOptions = { flow: WizardFlow; diff --git a/src/wizard/onboarding.test.ts b/src/wizard/onboarding.test.ts index 5c739c2141e..937f7b33cbf 100644 --- a/src/wizard/onboarding.test.ts +++ b/src/wizard/onboarding.test.ts @@ -2,11 +2,10 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { describe, expect, it, vi } from "vitest"; - -import { DEFAULT_BOOTSTRAP_FILENAME } from "../agents/workspace.js"; import type { RuntimeEnv } from "../runtime.js"; -import { runOnboardingWizard } from "./onboarding.js"; import type { WizardPrompter } from "./prompts.js"; +import { DEFAULT_BOOTSTRAP_FILENAME } from "../agents/workspace.js"; +import { runOnboardingWizard } from "./onboarding.js"; const setupChannels = vi.hoisted(() => vi.fn(async (cfg) => cfg)); const setupSkills = vi.hoisted(() => vi.fn(async (cfg) => cfg)); diff --git a/src/wizard/onboarding.ts b/src/wizard/onboarding.ts index dbabaf76895..de1c6c36f45 100644 --- a/src/wizard/onboarding.ts +++ b/src/wizard/onboarding.ts @@ -1,11 +1,22 @@ +import type { + GatewayAuthChoice, + OnboardMode, + OnboardOptions, + ResetScope, +} from "../commands/onboard-types.js"; +import type { OpenClawConfig } from "../config/config.js"; +import type { RuntimeEnv } from "../runtime.js"; +import type { QuickstartGatewayDefaults, WizardFlow } from "./onboarding.types.js"; import { ensureAuthProfileStore } from "../agents/auth-profiles.js"; import { listChannelPlugins } from "../channels/plugins/index.js"; +import { formatCliCommand } from "../cli/command-format.js"; +import { installCompletion } from "../cli/completion-cli.js"; +import { promptAuthChoiceGrouped } from "../commands/auth-choice-prompt.js"; import { applyAuthChoice, resolvePreferredProviderForAuthChoice, warnIfModelConfigLooksOff, } from "../commands/auth-choice.js"; -import { promptAuthChoiceGrouped } from "../commands/auth-choice-prompt.js"; import { applyPrimaryModel, promptDefaultModel } from "../commands/model-picker.js"; import { setupChannels } from "../commands/onboard-channels.js"; import { @@ -17,17 +28,9 @@ import { probeGatewayReachable, summarizeExistingConfig, } from "../commands/onboard-helpers.js"; +import { setupInternalHooks } from "../commands/onboard-hooks.js"; import { promptRemoteGatewayConfig } from "../commands/onboard-remote.js"; import { setupSkills } from "../commands/onboard-skills.js"; -import { setupInternalHooks } from "../commands/onboard-hooks.js"; -import type { - GatewayAuthChoice, - OnboardMode, - OnboardOptions, - ResetScope, -} from "../commands/onboard-types.js"; -import { formatCliCommand } from "../cli/command-format.js"; -import type { OpenClawConfig } from "../config/config.js"; import { DEFAULT_GATEWAY_PORT, readConfigFileSnapshot, @@ -35,14 +38,11 @@ import { writeConfigFile, } from "../config/config.js"; import { logConfigUpdated } from "../config/logging.js"; -import type { RuntimeEnv } from "../runtime.js"; import { defaultRuntime } from "../runtime.js"; import { resolveUserPath } from "../utils.js"; import { finalizeOnboardingWizard } from "./onboarding.finalize.js"; import { configureGatewayForOnboarding } from "./onboarding.gateway-config.js"; -import type { QuickstartGatewayDefaults, WizardFlow } from "./onboarding.types.js"; import { WizardCancelledError, type WizardPrompter } from "./prompts.js"; -import { installCompletion } from "../cli/completion-cli.js"; async function requireRiskAcknowledgement(params: { opts: OnboardOptions; diff --git a/src/wizard/session.test.ts b/src/wizard/session.test.ts index da8da0fd915..bc187f1bfd7 100644 --- a/src/wizard/session.test.ts +++ b/src/wizard/session.test.ts @@ -1,5 +1,4 @@ import { describe, expect, test } from "vitest"; - import { WizardSession } from "./session.js"; function noteRunner() { diff --git a/src/wizard/session.ts b/src/wizard/session.ts index 63a1a845582..5c4c760414f 100644 --- a/src/wizard/session.ts +++ b/src/wizard/session.ts @@ -1,5 +1,4 @@ import { randomUUID } from "node:crypto"; - import { WizardCancelledError, type WizardProgress, type WizardPrompter } from "./prompts.js"; export type WizardStepOption = { diff --git a/test/auto-reply.retry.test.ts b/test/auto-reply.retry.test.ts index 9a7a7b6233c..b3a773b2891 100644 --- a/test/auto-reply.retry.test.ts +++ b/test/auto-reply.retry.test.ts @@ -9,9 +9,9 @@ vi.mock("../src/web/media.js", () => ({ })), })); +import type { WebInboundMessage } from "../src/web/inbound.js"; import { defaultRuntime } from "../src/runtime.js"; import { deliverWebReply } from "../src/web/auto-reply.js"; -import type { WebInboundMessage } from "../src/web/inbound.js"; const noopLogger = { info: vi.fn(), diff --git a/test/gateway.multi.e2e.test.ts b/test/gateway.multi.e2e.test.ts index 809d3a855b7..7bbe7ecc305 100644 --- a/test/gateway.multi.e2e.test.ts +++ b/test/gateway.multi.e2e.test.ts @@ -6,8 +6,8 @@ import net from "node:net"; import os from "node:os"; import path from "node:path"; import { afterAll, describe, expect, it } from "vitest"; -import { loadOrCreateDeviceIdentity } from "../src/infra/device-identity.js"; import { GatewayClient } from "../src/gateway/client.js"; +import { loadOrCreateDeviceIdentity } from "../src/infra/device-identity.js"; import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../src/utils/message-channel.js"; type GatewayInstance = { diff --git a/test/helpers/inbound-contract.ts b/test/helpers/inbound-contract.ts index 3e969057f0c..4ac4c2cc516 100644 --- a/test/helpers/inbound-contract.ts +++ b/test/helpers/inbound-contract.ts @@ -1,9 +1,8 @@ import { expect } from "vitest"; - +import type { MsgContext } from "../../src/auto-reply/templating.js"; import { normalizeChatType } from "../../src/channels/chat-type.js"; import { resolveConversationLabel } from "../../src/channels/conversation-label.js"; import { validateSenderIdentity } from "../../src/channels/sender-identity.js"; -import type { MsgContext } from "../../src/auto-reply/templating.js"; export function expectInboundContextContract(ctx: MsgContext) { expect(validateSenderIdentity(ctx)).toEqual([]); diff --git a/test/inbound-contract.providers.test.ts b/test/inbound-contract.providers.test.ts index 81e6a0b4841..1e0100e1623 100644 --- a/test/inbound-contract.providers.test.ts +++ b/test/inbound-contract.providers.test.ts @@ -1,5 +1,4 @@ import { describe, it } from "vitest"; - import type { MsgContext } from "../src/auto-reply/templating.js"; import { finalizeInboundContext } from "../src/auto-reply/reply/inbound-context.js"; import { expectInboundContextContract } from "./helpers/inbound-contract.js"; diff --git a/test/media-understanding.auto.e2e.test.ts b/test/media-understanding.auto.e2e.test.ts index 505e5f04fc3..98e2c88c5e1 100644 --- a/test/media-understanding.auto.e2e.test.ts +++ b/test/media-understanding.auto.e2e.test.ts @@ -1,11 +1,9 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { afterEach, describe, expect, it, vi } from "vitest"; - -import type { OpenClawConfig } from "../src/config/config.js"; import type { MsgContext } from "../src/auto-reply/templating.js"; +import type { OpenClawConfig } from "../src/config/config.js"; const makeTempDir = async (prefix: string) => await fs.mkdtemp(path.join(os.tmpdir(), prefix)); diff --git a/test/mocks/baileys.ts b/test/mocks/baileys.ts index e4aacbf1a85..e04ef1a2d32 100644 --- a/test/mocks/baileys.ts +++ b/test/mocks/baileys.ts @@ -1,5 +1,4 @@ import { EventEmitter } from "node:events"; - import { vi } from "vitest"; export type MockBaileysSocket = { diff --git a/test/provider-timeout.e2e.test.ts b/test/provider-timeout.e2e.test.ts index 3b0cc350344..82779cb4983 100644 --- a/test/provider-timeout.e2e.test.ts +++ b/test/provider-timeout.e2e.test.ts @@ -2,9 +2,7 @@ import { randomUUID } from "node:crypto"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; - import { describe, expect, it } from "vitest"; - import { GatewayClient } from "../src/gateway/client.js"; import { startGatewayServer } from "../src/gateway/server.js"; import { getDeterministicFreePortBlock } from "../src/test-utils/ports.js"; diff --git a/ui/src/ui/app-channels.ts b/ui/src/ui/app-channels.ts index 75edeecb2a7..3f139ea5a8a 100644 --- a/ui/src/ui/app-channels.ts +++ b/ui/src/ui/app-channels.ts @@ -1,3 +1,5 @@ +import type { OpenClawApp } from "./app"; +import type { NostrProfile } from "./types"; import { loadChannels, logoutWhatsApp, @@ -5,8 +7,6 @@ import { waitWhatsAppLogin, } from "./controllers/channels"; import { loadConfig, saveConfig } from "./controllers/config"; -import type { OpenClawApp } from "./app"; -import type { NostrProfile } from "./types"; import { createNostrProfileFormState } from "./views/channels.nostr-profile-form"; export async function handleWhatsAppStart(host: OpenClawApp, force: boolean) { diff --git a/ui/src/ui/app-chat.ts b/ui/src/ui/app-chat.ts index e1fde29158e..cd2c8e8e066 100644 --- a/ui/src/ui/app-chat.ts +++ b/ui/src/ui/app-chat.ts @@ -1,14 +1,14 @@ -import { abortChatRun, loadChatHistory, sendChatMessage } from "./controllers/chat"; -import { loadSessions } from "./controllers/sessions"; -import { generateUUID } from "./uuid"; -import { resetToolStream } from "./app-tool-stream"; +import type { OpenClawApp } from "./app"; +import type { GatewayHelloOk } from "./gateway"; +import type { ChatAttachment, ChatQueueItem } from "./ui-types"; +import { parseAgentSessionKey } from "../../../src/sessions/session-key-utils.js"; import { scheduleChatScroll } from "./app-scroll"; import { setLastActiveSessionKey } from "./app-settings"; +import { resetToolStream } from "./app-tool-stream"; +import { abortChatRun, loadChatHistory, sendChatMessage } from "./controllers/chat"; +import { loadSessions } from "./controllers/sessions"; import { normalizeBasePath } from "./navigation"; -import type { GatewayHelloOk } from "./gateway"; -import { parseAgentSessionKey } from "../../../src/sessions/session-key-utils.js"; -import type { OpenClawApp } from "./app"; -import type { ChatAttachment, ChatQueueItem } from "./ui-types"; +import { generateUUID } from "./uuid"; type ChatHost = { connected: boolean; diff --git a/ui/src/ui/app-gateway.ts b/ui/src/ui/app-gateway.ts index 58842fee326..fab71247531 100644 --- a/ui/src/ui/app-gateway.ts +++ b/ui/src/ui/app-gateway.ts @@ -1,27 +1,27 @@ -import { loadChatHistory } from "./controllers/chat"; -import { loadDevices } from "./controllers/devices"; -import { loadNodes } from "./controllers/nodes"; -import { loadAgents } from "./controllers/agents"; -import type { GatewayEventFrame, GatewayHelloOk } from "./gateway"; -import { GatewayBrowserClient } from "./gateway"; +import type { OpenClawApp } from "./app"; import type { EventLogEntry } from "./app-events"; -import type { AgentsListResult, PresenceEntry, HealthSnapshot, StatusSummary } from "./types"; +import type { ExecApprovalRequest } from "./controllers/exec-approval"; +import type { GatewayEventFrame, GatewayHelloOk } from "./gateway"; import type { Tab } from "./navigation"; import type { UiSettings } from "./storage"; -import { handleAgentEvent, resetToolStream, type AgentEventPayload } from "./app-tool-stream"; +import type { AgentsListResult, PresenceEntry, HealthSnapshot, StatusSummary } from "./types"; import { CHAT_SESSIONS_ACTIVE_MINUTES, flushChatQueueForEvent } from "./app-chat"; import { applySettings, loadCron, refreshActiveTab, setLastActiveSessionKey } from "./app-settings"; +import { handleAgentEvent, resetToolStream, type AgentEventPayload } from "./app-tool-stream"; +import { loadAgents } from "./controllers/agents"; +import { loadAssistantIdentity } from "./controllers/assistant-identity"; +import { loadChatHistory } from "./controllers/chat"; import { handleChatEvent, type ChatEventPayload } from "./controllers/chat"; +import { loadDevices } from "./controllers/devices"; import { addExecApproval, parseExecApprovalRequested, parseExecApprovalResolved, removeExecApproval, } from "./controllers/exec-approval"; -import type { OpenClawApp } from "./app"; -import type { ExecApprovalRequest } from "./controllers/exec-approval"; -import { loadAssistantIdentity } from "./controllers/assistant-identity"; +import { loadNodes } from "./controllers/nodes"; import { loadSessions } from "./controllers/sessions"; +import { GatewayBrowserClient } from "./gateway"; type GatewayHost = { settings: UiSettings; diff --git a/ui/src/ui/app-lifecycle.ts b/ui/src/ui/app-lifecycle.ts index d6c2cfd392c..de025339904 100644 --- a/ui/src/ui/app-lifecycle.ts +++ b/ui/src/ui/app-lifecycle.ts @@ -1,14 +1,5 @@ import type { Tab } from "./navigation"; import { connectGateway } from "./app-gateway"; -import { - applySettingsFromUrl, - attachThemeListener, - detachThemeListener, - inferBasePath, - syncTabWithLocation, - syncThemeWithSettings, -} from "./app-settings"; -import { observeTopbar, scheduleChatScroll, scheduleLogsScroll } from "./app-scroll"; import { startLogsPolling, startNodesPolling, @@ -17,6 +8,15 @@ import { startDebugPolling, stopDebugPolling, } from "./app-polling"; +import { observeTopbar, scheduleChatScroll, scheduleLogsScroll } from "./app-scroll"; +import { + applySettingsFromUrl, + attachThemeListener, + detachThemeListener, + inferBasePath, + syncTabWithLocation, + syncThemeWithSettings, +} from "./app-settings"; type LifecycleHost = { basePath: string; diff --git a/ui/src/ui/app-polling.ts b/ui/src/ui/app-polling.ts index f35beef7232..c0aa7c9d1d0 100644 --- a/ui/src/ui/app-polling.ts +++ b/ui/src/ui/app-polling.ts @@ -1,7 +1,7 @@ +import type { OpenClawApp } from "./app"; +import { loadDebug } from "./controllers/debug"; import { loadLogs } from "./controllers/logs"; import { loadNodes } from "./controllers/nodes"; -import { loadDebug } from "./controllers/debug"; -import type { OpenClawApp } from "./app"; type PollingHost = { nodesPollInterval: number | null; diff --git a/ui/src/ui/app-render.helpers.ts b/ui/src/ui/app-render.helpers.ts index 299de7d705b..f2ff179616f 100644 --- a/ui/src/ui/app-render.helpers.ts +++ b/ui/src/ui/app-render.helpers.ts @@ -1,15 +1,14 @@ import { html } from "lit"; import { repeat } from "lit/directives/repeat.js"; - import type { AppViewState } from "./app-view-state"; -import { iconForTab, pathForTab, titleForTab, type Tab } from "./navigation"; -import { icons } from "./icons"; -import { loadChatHistory } from "./controllers/chat"; -import { refreshChat } from "./app-chat"; -import { syncUrlWithSessionKey } from "./app-settings"; -import type { SessionsListResult } from "./types"; import type { ThemeMode } from "./theme"; import type { ThemeTransitionContext } from "./theme-transition"; +import type { SessionsListResult } from "./types"; +import { refreshChat } from "./app-chat"; +import { syncUrlWithSessionKey } from "./app-settings"; +import { loadChatHistory } from "./controllers/chat"; +import { icons } from "./icons"; +import { iconForTab, pathForTab, titleForTab, type Tab } from "./navigation"; export function renderTab(state: AppViewState, tab: Tab) { const href = pathForTab(tab, state.basePath); diff --git a/ui/src/ui/app-render.ts b/ui/src/ui/app-render.ts index 52b57c5444f..dc52fd84b7e 100644 --- a/ui/src/ui/app-render.ts +++ b/ui/src/ui/app-render.ts @@ -1,17 +1,6 @@ import { html, nothing } from "lit"; - -import type { GatewayBrowserClient, GatewayHelloOk } from "./gateway"; import type { AppViewState } from "./app-view-state"; -import { parseAgentSessionKey } from "../../../src/routing/session-key.js"; -import { - TAB_GROUPS, - iconForTab, - pathForTab, - subtitleForTab, - titleForTab, - type Tab, -} from "./navigation"; -import { icons } from "./icons"; +import type { GatewayBrowserClient, GatewayHelloOk } from "./gateway"; import type { UiSettings } from "./storage"; import type { ThemeMode } from "./theme"; import type { ThemeTransitionContext } from "./theme-transition"; @@ -30,40 +19,10 @@ import type { StatusSummary, } from "./types"; import type { ChatQueueItem, CronFormState } from "./ui-types"; +import { parseAgentSessionKey } from "../../../src/routing/session-key.js"; import { refreshChatAvatar } from "./app-chat"; -import { renderChat } from "./views/chat"; -import { renderConfig } from "./views/config"; -import { renderChannels } from "./views/channels"; -import { renderCron } from "./views/cron"; -import { renderDebug } from "./views/debug"; -import { renderInstances } from "./views/instances"; -import { renderLogs } from "./views/logs"; -import { renderNodes } from "./views/nodes"; -import { renderOverview } from "./views/overview"; -import { renderSessions } from "./views/sessions"; -import { renderExecApprovalPrompt } from "./views/exec-approval"; -import { renderGatewayUrlConfirmation } from "./views/gateway-url-confirmation"; -import { - approveDevicePairing, - loadDevices, - rejectDevicePairing, - revokeDeviceToken, - rotateDeviceToken, -} from "./controllers/devices"; -import { renderSkills } from "./views/skills"; import { renderChatControls, renderTab, renderThemeToggle } from "./app-render.helpers"; import { loadChannels } from "./controllers/channels"; -import { loadPresence } from "./controllers/presence"; -import { deleteSession, loadSessions, patchSession } from "./controllers/sessions"; -import { - installSkill, - loadSkills, - saveSkillApiKey, - updateSkillEdit, - updateSkillEnabled, - type SkillMessage, -} from "./controllers/skills"; -import { loadNodes } from "./controllers/nodes"; import { loadChatHistory } from "./controllers/chat"; import { applyConfig, @@ -73,12 +32,6 @@ import { updateConfigFormValue, removeConfigFormValue, } from "./controllers/config"; -import { - loadExecApprovals, - removeExecApprovalsFormValue, - saveExecApprovals, - updateExecApprovalsFormValue, -} from "./controllers/exec-approvals"; import { loadCronRuns, toggleCronJob, @@ -87,7 +40,53 @@ import { addCronJob, } from "./controllers/cron"; import { loadDebug, callDebugMethod } from "./controllers/debug"; +import { + approveDevicePairing, + loadDevices, + rejectDevicePairing, + revokeDeviceToken, + rotateDeviceToken, +} from "./controllers/devices"; +import { + loadExecApprovals, + removeExecApprovalsFormValue, + saveExecApprovals, + updateExecApprovalsFormValue, +} from "./controllers/exec-approvals"; import { loadLogs } from "./controllers/logs"; +import { loadNodes } from "./controllers/nodes"; +import { loadPresence } from "./controllers/presence"; +import { deleteSession, loadSessions, patchSession } from "./controllers/sessions"; +import { + installSkill, + loadSkills, + saveSkillApiKey, + updateSkillEdit, + updateSkillEnabled, + type SkillMessage, +} from "./controllers/skills"; +import { icons } from "./icons"; +import { + TAB_GROUPS, + iconForTab, + pathForTab, + subtitleForTab, + titleForTab, + type Tab, +} from "./navigation"; +import { renderChannels } from "./views/channels"; +import { renderChat } from "./views/chat"; +import { renderConfig } from "./views/config"; +import { renderCron } from "./views/cron"; +import { renderDebug } from "./views/debug"; +import { renderExecApprovalPrompt } from "./views/exec-approval"; +import { renderGatewayUrlConfirmation } from "./views/gateway-url-confirmation"; +import { renderInstances } from "./views/instances"; +import { renderLogs } from "./views/logs"; +import { renderNodes } from "./views/nodes"; +import { renderOverview } from "./views/overview"; +import { renderSessions } from "./views/sessions"; +import { renderSkills } from "./views/skills"; const AVATAR_DATA_RE = /^data:/i; const AVATAR_HTTP_RE = /^https?:\/\//i; diff --git a/ui/src/ui/app-settings.test.ts b/ui/src/ui/app-settings.test.ts index aae48df6f4a..33c87cf37fb 100644 --- a/ui/src/ui/app-settings.test.ts +++ b/ui/src/ui/app-settings.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - import type { Tab } from "./navigation"; import { setTabFromRoute } from "./app-settings"; diff --git a/ui/src/ui/app-settings.ts b/ui/src/ui/app-settings.ts index fcfb96eb265..e821c6bfecc 100644 --- a/ui/src/ui/app-settings.ts +++ b/ui/src/ui/app-settings.ts @@ -1,11 +1,20 @@ +import type { OpenClawApp } from "./app"; +import { refreshChat } from "./app-chat"; +import { + startLogsPolling, + stopLogsPolling, + startDebugPolling, + stopDebugPolling, +} from "./app-polling"; +import { scheduleChatScroll, scheduleLogsScroll } from "./app-scroll"; +import { loadChannels } from "./controllers/channels"; import { loadConfig, loadConfigSchema } from "./controllers/config"; import { loadCronJobs, loadCronStatus } from "./controllers/cron"; -import { loadChannels } from "./controllers/channels"; import { loadDebug } from "./controllers/debug"; -import { loadLogs } from "./controllers/logs"; import { loadDevices } from "./controllers/devices"; -import { loadNodes } from "./controllers/nodes"; import { loadExecApprovals } from "./controllers/exec-approvals"; +import { loadLogs } from "./controllers/logs"; +import { loadNodes } from "./controllers/nodes"; import { loadPresence } from "./controllers/presence"; import { loadSessions } from "./controllers/sessions"; import { loadSkills } from "./controllers/skills"; @@ -20,15 +29,6 @@ import { import { saveSettings, type UiSettings } from "./storage"; import { resolveTheme, type ResolvedTheme, type ThemeMode } from "./theme"; import { startThemeTransition, type ThemeTransitionContext } from "./theme-transition"; -import { scheduleChatScroll, scheduleLogsScroll } from "./app-scroll"; -import { - startLogsPolling, - stopLogsPolling, - startDebugPolling, - stopDebugPolling, -} from "./app-polling"; -import { refreshChat } from "./app-chat"; -import type { OpenClawApp } from "./app"; type SettingsHost = { settings: UiSettings; diff --git a/ui/src/ui/app-view-state.ts b/ui/src/ui/app-view-state.ts index ed30f3b7555..7ccbf59d41b 100644 --- a/ui/src/ui/app-view-state.ts +++ b/ui/src/ui/app-view-state.ts @@ -1,3 +1,8 @@ +import type { EventLogEntry } from "./app-events"; +import type { DevicePairingList } from "./controllers/devices"; +import type { ExecApprovalRequest } from "./controllers/exec-approval"; +import type { ExecApprovalsFile, ExecApprovalsSnapshot } from "./controllers/exec-approvals"; +import type { SkillMessage } from "./controllers/skills"; import type { GatewayBrowserClient, GatewayHelloOk } from "./gateway"; import type { Tab } from "./navigation"; import type { UiSettings } from "./storage"; @@ -20,11 +25,6 @@ import type { StatusSummary, } from "./types"; import type { ChatAttachment, ChatQueueItem, CronFormState } from "./ui-types"; -import type { EventLogEntry } from "./app-events"; -import type { SkillMessage } from "./controllers/skills"; -import type { ExecApprovalsFile, ExecApprovalsSnapshot } from "./controllers/exec-approvals"; -import type { DevicePairingList } from "./controllers/devices"; -import type { ExecApprovalRequest } from "./controllers/exec-approval"; import type { NostrProfileFormState } from "./views/channels.nostr-profile-form"; export type AppViewState = { diff --git a/ui/src/ui/app.ts b/ui/src/ui/app.ts index daa7960da2a..54ba72498f2 100644 --- a/ui/src/ui/app.ts +++ b/ui/src/ui/app.ts @@ -1,10 +1,10 @@ import { LitElement, html, nothing } from "lit"; import { customElement, state } from "lit/decorators.js"; - +import type { EventLogEntry } from "./app-events"; +import type { DevicePairingList } from "./controllers/devices"; +import type { ExecApprovalRequest } from "./controllers/exec-approval"; +import type { ExecApprovalsFile, ExecApprovalsSnapshot } from "./controllers/exec-approvals"; import type { GatewayBrowserClient, GatewayHelloOk } from "./gateway"; -import { resolveInjectedAssistantIdentity } from "./assistant-identity"; -import { loadSettings, type UiSettings } from "./storage"; -import { renderApp } from "./app-render"; import type { Tab } from "./navigation"; import type { ResolvedTheme, ThemeMode } from "./theme"; import type { @@ -24,42 +24,7 @@ import type { StatusSummary, NostrProfile, } from "./types"; -import { type ChatAttachment, type ChatQueueItem, type CronFormState } from "./ui-types"; -import type { EventLogEntry } from "./app-events"; -import { DEFAULT_CRON_FORM, DEFAULT_LOG_LEVEL_FILTERS } from "./app-defaults"; -import type { ExecApprovalsFile, ExecApprovalsSnapshot } from "./controllers/exec-approvals"; -import type { DevicePairingList } from "./controllers/devices"; -import type { ExecApprovalRequest } from "./controllers/exec-approval"; -import { - resetToolStream as resetToolStreamInternal, - type ToolStreamEntry, -} from "./app-tool-stream"; -import { - exportLogs as exportLogsInternal, - handleChatScroll as handleChatScrollInternal, - handleLogsScroll as handleLogsScrollInternal, - resetChatScroll as resetChatScrollInternal, -} from "./app-scroll"; -import { connectGateway as connectGatewayInternal } from "./app-gateway"; -import { - handleConnected, - handleDisconnected, - handleFirstUpdated, - handleUpdated, -} from "./app-lifecycle"; -import { - applySettings as applySettingsInternal, - loadCron as loadCronInternal, - loadOverview as loadOverviewInternal, - setTab as setTabInternal, - setTheme as setThemeInternal, - onPopState as onPopStateInternal, -} from "./app-settings"; -import { - handleAbortChat as handleAbortChatInternal, - handleSendChat as handleSendChatInternal, - removeQueuedMessage as removeQueuedMessageInternal, -} from "./app-chat"; +import type { NostrProfileFormState } from "./views/channels.nostr-profile-form"; import { handleChannelConfigReload as handleChannelConfigReloadInternal, handleChannelConfigSave as handleChannelConfigSaveInternal, @@ -73,8 +38,42 @@ import { handleWhatsAppStart as handleWhatsAppStartInternal, handleWhatsAppWait as handleWhatsAppWaitInternal, } from "./app-channels"; -import type { NostrProfileFormState } from "./views/channels.nostr-profile-form"; +import { + handleAbortChat as handleAbortChatInternal, + handleSendChat as handleSendChatInternal, + removeQueuedMessage as removeQueuedMessageInternal, +} from "./app-chat"; +import { DEFAULT_CRON_FORM, DEFAULT_LOG_LEVEL_FILTERS } from "./app-defaults"; +import { connectGateway as connectGatewayInternal } from "./app-gateway"; +import { + handleConnected, + handleDisconnected, + handleFirstUpdated, + handleUpdated, +} from "./app-lifecycle"; +import { renderApp } from "./app-render"; +import { + exportLogs as exportLogsInternal, + handleChatScroll as handleChatScrollInternal, + handleLogsScroll as handleLogsScrollInternal, + resetChatScroll as resetChatScrollInternal, +} from "./app-scroll"; +import { + applySettings as applySettingsInternal, + loadCron as loadCronInternal, + loadOverview as loadOverviewInternal, + setTab as setTabInternal, + setTheme as setThemeInternal, + onPopState as onPopStateInternal, +} from "./app-settings"; +import { + resetToolStream as resetToolStreamInternal, + type ToolStreamEntry, +} from "./app-tool-stream"; +import { resolveInjectedAssistantIdentity } from "./assistant-identity"; import { loadAssistantIdentity as loadAssistantIdentityInternal } from "./controllers/assistant-identity"; +import { loadSettings, type UiSettings } from "./storage"; +import { type ChatAttachment, type ChatQueueItem, type CronFormState } from "./ui-types"; declare global { interface Window { diff --git a/ui/src/ui/chat-markdown.browser.test.ts b/ui/src/ui/chat-markdown.browser.test.ts index 30360cda2a9..86057f3544c 100644 --- a/ui/src/ui/chat-markdown.browser.test.ts +++ b/ui/src/ui/chat-markdown.browser.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest"; - import { OpenClawApp } from "./app"; const originalConnect = OpenClawApp.prototype.connect; diff --git a/ui/src/ui/chat/grouped-render.ts b/ui/src/ui/chat/grouped-render.ts index 75c27cf4bdd..97ad421f696 100644 --- a/ui/src/ui/chat/grouped-render.ts +++ b/ui/src/ui/chat/grouped-render.ts @@ -1,16 +1,15 @@ import { html, nothing } from "lit"; import { unsafeHTML } from "lit/directives/unsafe-html.js"; - import type { AssistantIdentity } from "../assistant-identity"; -import { toSanitizedMarkdownHtml } from "../markdown"; import type { MessageGroup } from "../types/chat-types"; +import { toSanitizedMarkdownHtml } from "../markdown"; import { renderCopyAsMarkdownButton } from "./copy-as-markdown"; -import { isToolResultMessage, normalizeRoleForGrouping } from "./message-normalizer"; import { extractTextCached, extractThinkingCached, formatReasoningMarkdown, } from "./message-extract"; +import { isToolResultMessage, normalizeRoleForGrouping } from "./message-normalizer"; import { extractToolCards, renderToolCardSidebar } from "./tool-cards"; type ImageBlock = { diff --git a/ui/src/ui/chat/message-extract.test.ts b/ui/src/ui/chat/message-extract.test.ts index 5dc0e5d358f..6b557daa1c7 100644 --- a/ui/src/ui/chat/message-extract.test.ts +++ b/ui/src/ui/chat/message-extract.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { extractText, extractTextCached, diff --git a/ui/src/ui/chat/tool-cards.ts b/ui/src/ui/chat/tool-cards.ts index f4ff8b35993..19e8cf82eb8 100644 --- a/ui/src/ui/chat/tool-cards.ts +++ b/ui/src/ui/chat/tool-cards.ts @@ -1,12 +1,11 @@ import { html, nothing } from "lit"; - -import { formatToolDetail, resolveToolDisplay } from "../tool-display"; -import { icons } from "../icons"; import type { ToolCard } from "../types/chat-types"; +import { icons } from "../icons"; +import { formatToolDetail, resolveToolDisplay } from "../tool-display"; import { TOOL_INLINE_THRESHOLD } from "./constants"; -import { formatToolOutputForSidebar, getTruncatedPreview } from "./tool-helpers"; -import { isToolResultMessage } from "./message-normalizer"; import { extractTextCached } from "./message-extract"; +import { isToolResultMessage } from "./message-normalizer"; +import { formatToolOutputForSidebar, getTruncatedPreview } from "./tool-helpers"; export function extractToolCards(message: unknown): ToolCard[] { const m = message as Record; diff --git a/ui/src/ui/config-form.browser.test.ts b/ui/src/ui/config-form.browser.test.ts index 848acddf41c..5f64ee7f200 100644 --- a/ui/src/ui/config-form.browser.test.ts +++ b/ui/src/ui/config-form.browser.test.ts @@ -1,6 +1,5 @@ import { render } from "lit"; import { describe, expect, it, vi } from "vitest"; - import { analyzeConfigSchema, renderConfigForm } from "./views/config-form"; const rootSchema = { diff --git a/ui/src/ui/controllers/chat.test.ts b/ui/src/ui/controllers/chat.test.ts index b4f16435fc9..3bd3aeb7f75 100644 --- a/ui/src/ui/controllers/chat.test.ts +++ b/ui/src/ui/controllers/chat.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { handleChatEvent, type ChatEventPayload, type ChatState } from "./chat"; function createState(overrides: Partial = {}): ChatState { diff --git a/ui/src/ui/controllers/chat.ts b/ui/src/ui/controllers/chat.ts index ed6ea961350..582105114e8 100644 --- a/ui/src/ui/controllers/chat.ts +++ b/ui/src/ui/controllers/chat.ts @@ -1,7 +1,7 @@ -import { extractText } from "../chat/message-extract"; import type { GatewayBrowserClient } from "../gateway"; -import { generateUUID } from "../uuid"; import type { ChatAttachment } from "../ui-types"; +import { extractText } from "../chat/message-extract"; +import { generateUUID } from "../uuid"; export type ChatState = { client: GatewayBrowserClient | null; diff --git a/ui/src/ui/controllers/config.test.ts b/ui/src/ui/controllers/config.test.ts index be7d2f955d4..d3b120f6107 100644 --- a/ui/src/ui/controllers/config.test.ts +++ b/ui/src/ui/controllers/config.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { applyConfigSnapshot, applyConfig, diff --git a/ui/src/ui/controllers/cron.ts b/ui/src/ui/controllers/cron.ts index 718de062bfc..ac128cab8a9 100644 --- a/ui/src/ui/controllers/cron.ts +++ b/ui/src/ui/controllers/cron.ts @@ -1,7 +1,7 @@ -import { toNumber } from "../format"; import type { GatewayBrowserClient } from "../gateway"; import type { CronJob, CronRunLogEntry, CronStatus } from "../types"; import type { CronFormState } from "../ui-types"; +import { toNumber } from "../format"; export type CronState = { client: GatewayBrowserClient | null; diff --git a/ui/src/ui/controllers/devices.ts b/ui/src/ui/controllers/devices.ts index f42b4fefd50..e63547ba72e 100644 --- a/ui/src/ui/controllers/devices.ts +++ b/ui/src/ui/controllers/devices.ts @@ -1,6 +1,6 @@ import type { GatewayBrowserClient } from "../gateway"; -import { loadOrCreateDeviceIdentity } from "../device-identity"; import { clearDeviceAuthToken, storeDeviceAuthToken } from "../device-auth"; +import { loadOrCreateDeviceIdentity } from "../device-identity"; export type DeviceTokenSummary = { role: string; diff --git a/ui/src/ui/controllers/sessions.ts b/ui/src/ui/controllers/sessions.ts index d64964c339f..82e8a8db170 100644 --- a/ui/src/ui/controllers/sessions.ts +++ b/ui/src/ui/controllers/sessions.ts @@ -1,6 +1,6 @@ import type { GatewayBrowserClient } from "../gateway"; -import { toNumber } from "../format"; import type { SessionsListResult } from "../types"; +import { toNumber } from "../format"; export type SessionsState = { client: GatewayBrowserClient | null; diff --git a/ui/src/ui/focus-mode.browser.test.ts b/ui/src/ui/focus-mode.browser.test.ts index 597ed1c6f08..1e8164d85bf 100644 --- a/ui/src/ui/focus-mode.browser.test.ts +++ b/ui/src/ui/focus-mode.browser.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest"; - import { OpenClawApp } from "./app"; const originalConnect = OpenClawApp.prototype.connect; diff --git a/ui/src/ui/format.test.ts b/ui/src/ui/format.test.ts index f8b1e8e5627..b52dc0e4fb8 100644 --- a/ui/src/ui/format.test.ts +++ b/ui/src/ui/format.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { stripThinkingTags } from "./format"; describe("stripThinkingTags", () => { diff --git a/ui/src/ui/gateway.ts b/ui/src/ui/gateway.ts index fc8dde08a0a..3336e09b508 100644 --- a/ui/src/ui/gateway.ts +++ b/ui/src/ui/gateway.ts @@ -1,13 +1,13 @@ -import { generateUUID } from "./uuid"; +import { buildDeviceAuthPayload } from "../../../src/gateway/device-auth.js"; import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES, type GatewayClientMode, type GatewayClientName, } from "../../../src/gateway/protocol/client-info.js"; -import { buildDeviceAuthPayload } from "../../../src/gateway/device-auth.js"; -import { loadOrCreateDeviceIdentity, signDevicePayload } from "./device-identity"; import { clearDeviceAuthToken, loadDeviceAuthToken, storeDeviceAuthToken } from "./device-auth"; +import { loadOrCreateDeviceIdentity, signDevicePayload } from "./device-identity"; +import { generateUUID } from "./uuid"; export type GatewayEventFrame = { type: "event"; diff --git a/ui/src/ui/markdown.test.ts b/ui/src/ui/markdown.test.ts index 396ff0fa51d..278485fe7a0 100644 --- a/ui/src/ui/markdown.test.ts +++ b/ui/src/ui/markdown.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { toSanitizedMarkdownHtml } from "./markdown"; describe("toSanitizedMarkdownHtml", () => { diff --git a/ui/src/ui/navigation.browser.test.ts b/ui/src/ui/navigation.browser.test.ts index a5c209fb38f..2e4246840a5 100644 --- a/ui/src/ui/navigation.browser.test.ts +++ b/ui/src/ui/navigation.browser.test.ts @@ -1,5 +1,4 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest"; - import { OpenClawApp } from "./app"; import "../styles.css"; diff --git a/ui/src/ui/navigation.test.ts b/ui/src/ui/navigation.test.ts index 40a2a5b6f20..3348ad4623e 100644 --- a/ui/src/ui/navigation.test.ts +++ b/ui/src/ui/navigation.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it } from "vitest"; - import { TAB_GROUPS, iconForTab, diff --git a/ui/src/ui/presenter.ts b/ui/src/ui/presenter.ts index ddb99d9c53c..0fd1533217d 100644 --- a/ui/src/ui/presenter.ts +++ b/ui/src/ui/presenter.ts @@ -1,5 +1,5 @@ -import { formatAgo, formatDurationMs, formatMs } from "./format"; import type { CronJob, GatewaySessionRow, PresenceEntry } from "./types"; +import { formatAgo, formatDurationMs, formatMs } from "./format"; export function formatPresenceSummary(entry: PresenceEntry): string { const host = entry.host ?? "unknown"; diff --git a/ui/src/ui/tool-display.ts b/ui/src/ui/tool-display.ts index 7426e33714a..4acbe0b473e 100644 --- a/ui/src/ui/tool-display.ts +++ b/ui/src/ui/tool-display.ts @@ -1,5 +1,5 @@ -import rawConfig from "./tool-display.json"; import type { IconName } from "./icons"; +import rawConfig from "./tool-display.json"; type ToolDisplayActionSpec = { label?: string; diff --git a/ui/src/ui/uuid.test.ts b/ui/src/ui/uuid.test.ts index 2d5421bdd55..946a1866d34 100644 --- a/ui/src/ui/uuid.test.ts +++ b/ui/src/ui/uuid.test.ts @@ -1,5 +1,4 @@ import { describe, expect, it, vi } from "vitest"; - import { generateUUID } from "./uuid"; describe("generateUUID", () => { diff --git a/ui/src/ui/views/channels.config.ts b/ui/src/ui/views/channels.config.ts index 73801b62dc2..5c2eb62099f 100644 --- a/ui/src/ui/views/channels.config.ts +++ b/ui/src/ui/views/channels.config.ts @@ -1,5 +1,4 @@ import { html } from "lit"; - import type { ConfigUiHints } from "../types"; import type { ChannelsProps } from "./channels.types"; import { analyzeConfigSchema, renderNode, schemaType, type JsonSchema } from "./config-form"; diff --git a/ui/src/ui/views/channels.discord.ts b/ui/src/ui/views/channels.discord.ts index e12d905c188..59d2e65b23b 100644 --- a/ui/src/ui/views/channels.discord.ts +++ b/ui/src/ui/views/channels.discord.ts @@ -1,8 +1,7 @@ import { html, nothing } from "lit"; - -import { formatAgo } from "../format"; import type { DiscordStatus } from "../types"; import type { ChannelsProps } from "./channels.types"; +import { formatAgo } from "../format"; import { renderChannelConfigSection } from "./channels.config"; export function renderDiscordCard(params: { diff --git a/ui/src/ui/views/channels.googlechat.ts b/ui/src/ui/views/channels.googlechat.ts index 90c0eaec409..fcfeffd2229 100644 --- a/ui/src/ui/views/channels.googlechat.ts +++ b/ui/src/ui/views/channels.googlechat.ts @@ -1,9 +1,8 @@ import { html, nothing } from "lit"; - -import { formatAgo } from "../format"; import type { GoogleChatStatus } from "../types"; -import { renderChannelConfigSection } from "./channels.config"; import type { ChannelsProps } from "./channels.types"; +import { formatAgo } from "../format"; +import { renderChannelConfigSection } from "./channels.config"; export function renderGoogleChatCard(params: { props: ChannelsProps; diff --git a/ui/src/ui/views/channels.imessage.ts b/ui/src/ui/views/channels.imessage.ts index ca468f978dc..6a67b148c86 100644 --- a/ui/src/ui/views/channels.imessage.ts +++ b/ui/src/ui/views/channels.imessage.ts @@ -1,8 +1,7 @@ import { html, nothing } from "lit"; - -import { formatAgo } from "../format"; import type { IMessageStatus } from "../types"; import type { ChannelsProps } from "./channels.types"; +import { formatAgo } from "../format"; import { renderChannelConfigSection } from "./channels.config"; export function renderIMessageCard(params: { diff --git a/ui/src/ui/views/channels.nostr-profile-form.ts b/ui/src/ui/views/channels.nostr-profile-form.ts index 36231e1840d..a18d1c981ec 100644 --- a/ui/src/ui/views/channels.nostr-profile-form.ts +++ b/ui/src/ui/views/channels.nostr-profile-form.ts @@ -5,7 +5,6 @@ */ import { html, nothing, type TemplateResult } from "lit"; - import type { NostrProfile as NostrProfileType } from "../types"; // ============================================================================ diff --git a/ui/src/ui/views/channels.nostr.ts b/ui/src/ui/views/channels.nostr.ts index 1a4a2cb090a..0792f804623 100644 --- a/ui/src/ui/views/channels.nostr.ts +++ b/ui/src/ui/views/channels.nostr.ts @@ -1,8 +1,7 @@ import { html, nothing } from "lit"; - -import { formatAgo } from "../format"; import type { ChannelAccountSnapshot, NostrStatus } from "../types"; import type { ChannelsProps } from "./channels.types"; +import { formatAgo } from "../format"; import { renderChannelConfigSection } from "./channels.config"; import { renderNostrProfileForm, diff --git a/ui/src/ui/views/channels.shared.ts b/ui/src/ui/views/channels.shared.ts index 9af0c2ea143..7da38a71394 100644 --- a/ui/src/ui/views/channels.shared.ts +++ b/ui/src/ui/views/channels.shared.ts @@ -1,5 +1,4 @@ import { html, nothing } from "lit"; - import type { ChannelAccountSnapshot } from "../types"; import type { ChannelKey, ChannelsProps } from "./channels.types"; diff --git a/ui/src/ui/views/channels.signal.ts b/ui/src/ui/views/channels.signal.ts index b2bbbae7817..050b14bb8cb 100644 --- a/ui/src/ui/views/channels.signal.ts +++ b/ui/src/ui/views/channels.signal.ts @@ -1,8 +1,7 @@ import { html, nothing } from "lit"; - -import { formatAgo } from "../format"; import type { SignalStatus } from "../types"; import type { ChannelsProps } from "./channels.types"; +import { formatAgo } from "../format"; import { renderChannelConfigSection } from "./channels.config"; export function renderSignalCard(params: { diff --git a/ui/src/ui/views/channels.slack.ts b/ui/src/ui/views/channels.slack.ts index a2ee1b2275d..d018f40efb5 100644 --- a/ui/src/ui/views/channels.slack.ts +++ b/ui/src/ui/views/channels.slack.ts @@ -1,8 +1,7 @@ import { html, nothing } from "lit"; - -import { formatAgo } from "../format"; import type { SlackStatus } from "../types"; import type { ChannelsProps } from "./channels.types"; +import { formatAgo } from "../format"; import { renderChannelConfigSection } from "./channels.config"; export function renderSlackCard(params: { diff --git a/ui/src/ui/views/channels.telegram.ts b/ui/src/ui/views/channels.telegram.ts index 097f89fed14..d2347c0f8c9 100644 --- a/ui/src/ui/views/channels.telegram.ts +++ b/ui/src/ui/views/channels.telegram.ts @@ -1,8 +1,7 @@ import { html, nothing } from "lit"; - -import { formatAgo } from "../format"; import type { ChannelAccountSnapshot, TelegramStatus } from "../types"; import type { ChannelsProps } from "./channels.types"; +import { formatAgo } from "../format"; import { renderChannelConfigSection } from "./channels.config"; export function renderTelegramCard(params: { diff --git a/ui/src/ui/views/channels.ts b/ui/src/ui/views/channels.ts index 78bb52983ae..444b22e59a6 100644 --- a/ui/src/ui/views/channels.ts +++ b/ui/src/ui/views/channels.ts @@ -1,6 +1,4 @@ import { html, nothing } from "lit"; - -import { formatAgo } from "../format"; import type { ChannelAccountSnapshot, ChannelUiMetaEntry, @@ -16,12 +14,13 @@ import type { WhatsAppStatus, } from "../types"; import type { ChannelKey, ChannelsChannelData, ChannelsProps } from "./channels.types"; -import { channelEnabled, renderChannelAccountCount } from "./channels.shared"; +import { formatAgo } from "../format"; import { renderChannelConfigSection } from "./channels.config"; import { renderDiscordCard } from "./channels.discord"; import { renderGoogleChatCard } from "./channels.googlechat"; import { renderIMessageCard } from "./channels.imessage"; import { renderNostrCard } from "./channels.nostr"; +import { channelEnabled, renderChannelAccountCount } from "./channels.shared"; import { renderSignalCard } from "./channels.signal"; import { renderSlackCard } from "./channels.slack"; import { renderTelegramCard } from "./channels.telegram"; diff --git a/ui/src/ui/views/channels.whatsapp.ts b/ui/src/ui/views/channels.whatsapp.ts index f18bb9b7ce1..ad1fcf7a91c 100644 --- a/ui/src/ui/views/channels.whatsapp.ts +++ b/ui/src/ui/views/channels.whatsapp.ts @@ -1,8 +1,7 @@ import { html, nothing } from "lit"; - -import { formatAgo } from "../format"; import type { WhatsAppStatus } from "../types"; import type { ChannelsProps } from "./channels.types"; +import { formatAgo } from "../format"; import { renderChannelConfigSection } from "./channels.config"; import { formatDuration } from "./channels.shared"; diff --git a/ui/src/ui/views/chat.test.ts b/ui/src/ui/views/chat.test.ts index 970adaad055..7d121e99f6e 100644 --- a/ui/src/ui/views/chat.test.ts +++ b/ui/src/ui/views/chat.test.ts @@ -1,6 +1,5 @@ import { render } from "lit"; import { describe, expect, it, vi } from "vitest"; - import type { SessionsListResult } from "../types"; import { renderChat, type ChatProps } from "./chat"; diff --git a/ui/src/ui/views/chat.ts b/ui/src/ui/views/chat.ts index 82b1f5dd4fd..070fb76a8c3 100644 --- a/ui/src/ui/views/chat.ts +++ b/ui/src/ui/views/chat.ts @@ -2,15 +2,15 @@ import { html, nothing } from "lit"; import { ref } from "lit/directives/ref.js"; import { repeat } from "lit/directives/repeat.js"; import type { SessionsListResult } from "../types"; -import type { ChatAttachment, ChatQueueItem } from "../ui-types"; import type { ChatItem, MessageGroup } from "../types/chat-types"; -import { icons } from "../icons"; -import { normalizeMessage, normalizeRoleForGrouping } from "../chat/message-normalizer"; +import type { ChatAttachment, ChatQueueItem } from "../ui-types"; import { renderMessageGroup, renderReadingIndicatorGroup, renderStreamingGroup, } from "../chat/grouped-render"; +import { normalizeMessage, normalizeRoleForGrouping } from "../chat/message-normalizer"; +import { icons } from "../icons"; import { renderMarkdownSidebar } from "./markdown-sidebar"; import "../components/resizable-divider"; diff --git a/ui/src/ui/views/config-form.render.ts b/ui/src/ui/views/config-form.render.ts index d58fba1c7ba..ec6eb5dd47e 100644 --- a/ui/src/ui/views/config-form.render.ts +++ b/ui/src/ui/views/config-form.render.ts @@ -1,8 +1,8 @@ import { html, nothing } from "lit"; import type { ConfigUiHints } from "../types"; import { icons } from "../icons"; -import { hintForPath, humanize, schemaType, type JsonSchema } from "./config-form.shared"; import { renderNode } from "./config-form.node"; +import { hintForPath, humanize, schemaType, type JsonSchema } from "./config-form.shared"; export type ConfigFormProps = { schema: JsonSchema | null; diff --git a/ui/src/ui/views/config.browser.test.ts b/ui/src/ui/views/config.browser.test.ts index 954a652fb8c..f101661e626 100644 --- a/ui/src/ui/views/config.browser.test.ts +++ b/ui/src/ui/views/config.browser.test.ts @@ -1,6 +1,5 @@ import { render } from "lit"; import { describe, expect, it, vi } from "vitest"; - import { renderConfig } from "./config"; describe("config view", () => { diff --git a/ui/src/ui/views/cron.test.ts b/ui/src/ui/views/cron.test.ts index 620a80a6f40..31a93b23bed 100644 --- a/ui/src/ui/views/cron.test.ts +++ b/ui/src/ui/views/cron.test.ts @@ -1,8 +1,7 @@ import { render } from "lit"; import { describe, expect, it, vi } from "vitest"; - -import { DEFAULT_CRON_FORM } from "../app-defaults"; import type { CronJob } from "../types"; +import { DEFAULT_CRON_FORM } from "../app-defaults"; import { renderCron, type CronProps } from "./cron"; function createJob(id: string): CronJob { diff --git a/ui/src/ui/views/cron.ts b/ui/src/ui/views/cron.ts index 1dda17c8a22..ede5fd0455e 100644 --- a/ui/src/ui/views/cron.ts +++ b/ui/src/ui/views/cron.ts @@ -1,5 +1,6 @@ import { html, nothing } from "lit"; - +import type { ChannelUiMetaEntry, CronJob, CronRunLogEntry, CronStatus } from "../types"; +import type { CronFormState } from "../ui-types"; import { formatMs } from "../format"; import { formatCronPayload, @@ -7,8 +8,6 @@ import { formatCronState, formatNextRun, } from "../presenter"; -import type { ChannelUiMetaEntry, CronJob, CronRunLogEntry, CronStatus } from "../types"; -import type { CronFormState } from "../ui-types"; export type CronProps = { loading: boolean; diff --git a/ui/src/ui/views/debug.ts b/ui/src/ui/views/debug.ts index 8b527b649c4..e37bb48d6ff 100644 --- a/ui/src/ui/views/debug.ts +++ b/ui/src/ui/views/debug.ts @@ -1,7 +1,6 @@ import { html, nothing } from "lit"; - -import { formatEventPayload } from "../presenter"; import type { EventLogEntry } from "../app-events"; +import { formatEventPayload } from "../presenter"; export type DebugProps = { loading: boolean; diff --git a/ui/src/ui/views/exec-approval.ts b/ui/src/ui/views/exec-approval.ts index 9583891aab1..33efc947ffd 100644 --- a/ui/src/ui/views/exec-approval.ts +++ b/ui/src/ui/views/exec-approval.ts @@ -1,5 +1,4 @@ import { html, nothing } from "lit"; - import type { AppViewState } from "../app-view-state"; function formatRemaining(ms: number): string { diff --git a/ui/src/ui/views/gateway-url-confirmation.ts b/ui/src/ui/views/gateway-url-confirmation.ts index 7d48c436779..39c6f9d0510 100644 --- a/ui/src/ui/views/gateway-url-confirmation.ts +++ b/ui/src/ui/views/gateway-url-confirmation.ts @@ -1,5 +1,4 @@ import { html, nothing } from "lit"; - import type { AppViewState } from "../app-view-state"; export function renderGatewayUrlConfirmation(state: AppViewState) { diff --git a/ui/src/ui/views/instances.ts b/ui/src/ui/views/instances.ts index 8a5dbce44f1..38425134301 100644 --- a/ui/src/ui/views/instances.ts +++ b/ui/src/ui/views/instances.ts @@ -1,7 +1,6 @@ import { html, nothing } from "lit"; - -import { formatPresenceAge, formatPresenceSummary } from "../presenter"; import type { PresenceEntry } from "../types"; +import { formatPresenceAge, formatPresenceSummary } from "../presenter"; export type InstancesProps = { loading: boolean; diff --git a/ui/src/ui/views/logs.ts b/ui/src/ui/views/logs.ts index dbb28f7a473..7962c0a1027 100644 --- a/ui/src/ui/views/logs.ts +++ b/ui/src/ui/views/logs.ts @@ -1,5 +1,4 @@ import { html, nothing } from "lit"; - import type { LogEntry, LogLevel } from "../types"; const LEVELS: LogLevel[] = ["trace", "debug", "info", "warn", "error", "fatal"]; diff --git a/ui/src/ui/views/markdown-sidebar.ts b/ui/src/ui/views/markdown-sidebar.ts index 11a34e5a31f..285e2bf1150 100644 --- a/ui/src/ui/views/markdown-sidebar.ts +++ b/ui/src/ui/views/markdown-sidebar.ts @@ -1,6 +1,5 @@ import { html, nothing } from "lit"; import { unsafeHTML } from "lit/directives/unsafe-html.js"; - import { icons } from "../icons"; import { toSanitizedMarkdownHtml } from "../markdown"; diff --git a/ui/src/ui/views/nodes.ts b/ui/src/ui/views/nodes.ts index 0b841641663..59228103640 100644 --- a/ui/src/ui/views/nodes.ts +++ b/ui/src/ui/views/nodes.ts @@ -1,17 +1,16 @@ import { html, nothing } from "lit"; - -import { clampText, formatAgo, formatList } from "../format"; -import type { - ExecApprovalsAllowlistEntry, - ExecApprovalsFile, - ExecApprovalsSnapshot, -} from "../controllers/exec-approvals"; import type { DevicePairingList, DeviceTokenSummary, PairedDevice, PendingDevice, } from "../controllers/devices"; +import type { + ExecApprovalsAllowlistEntry, + ExecApprovalsFile, + ExecApprovalsSnapshot, +} from "../controllers/exec-approvals"; +import { clampText, formatAgo, formatList } from "../format"; export type NodesProps = { loading: boolean; diff --git a/ui/src/ui/views/overview.ts b/ui/src/ui/views/overview.ts index 5778203e254..9e0d1da410e 100644 --- a/ui/src/ui/views/overview.ts +++ b/ui/src/ui/views/overview.ts @@ -1,9 +1,8 @@ import { html } from "lit"; - import type { GatewayHelloOk } from "../gateway"; +import type { UiSettings } from "../storage"; import { formatAgo, formatDurationMs } from "../format"; import { formatNextRun } from "../presenter"; -import type { UiSettings } from "../storage"; export type OverviewProps = { connected: boolean; diff --git a/ui/src/ui/views/sessions.ts b/ui/src/ui/views/sessions.ts index d8a9aa9d11f..fc6863a38c5 100644 --- a/ui/src/ui/views/sessions.ts +++ b/ui/src/ui/views/sessions.ts @@ -1,9 +1,8 @@ import { html, nothing } from "lit"; - -import { formatAgo } from "../format"; -import { formatSessionTokens } from "../presenter"; -import { pathForTab } from "../navigation"; import type { GatewaySessionRow, SessionsListResult } from "../types"; +import { formatAgo } from "../format"; +import { pathForTab } from "../navigation"; +import { formatSessionTokens } from "../presenter"; export type SessionsProps = { loading: boolean; diff --git a/ui/src/ui/views/skills.ts b/ui/src/ui/views/skills.ts index 4d951988295..b799518a78b 100644 --- a/ui/src/ui/views/skills.ts +++ b/ui/src/ui/views/skills.ts @@ -1,8 +1,7 @@ import { html, nothing } from "lit"; - -import { clampText } from "../format"; -import type { SkillStatusEntry, SkillStatusReport } from "../types"; import type { SkillMessageMap } from "../controllers/skills"; +import type { SkillStatusEntry, SkillStatusReport } from "../types"; +import { clampText } from "../format"; export type SkillsProps = { loading: boolean;