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 36e66c4e60..50da0e7c8d 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 44eebf914d..f7208b4da3 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 433eec31a2..44b09e2459 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 444ac6e002..8dc55b1eff 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 4d03d980d1..c3c2832a21 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 9611f09fd5..9bc0e4d217 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 8a9bce52e0..6ce8342d8a 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 d48f4313ac..74ea0b7598 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 6e89c05d81..39ac3ba325 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 9ca3fa5074..374c5a896e 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 f57421d73d..ab75721056 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 cfb39cdb8b..902828ece2 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 5f96d9d48b..00a5f36e24 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 c0d4e92222..1d68ace62f 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 c9d3a18d0e..643a926b88 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 64a55ac0d5..5b59eda0d8 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 84aa0ebf2b..c2ee393c7f 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 ee3aa9d4ec..63333556f0 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 ae2851ef91..cb159b1fb7 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 cf12a26427..0b9c5318de 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 f1b5dadc79..fca5467304 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 7598cb7f45..fe05fe4bd4 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 81c38c9e4e..ab639cbaff 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 f28f7483bf..e989795dc9 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 2ceac45e05..e66071ccab 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 fad1bc0150..5831b8b1e0 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 659175058d..1ade57f1e7 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 e81c86ff76..c3210c35a1 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 b62a53517b..011eaa2918 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 959b396dfa..b98b247a66 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 013b239f3f..a0cf0acf57 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 221d36f9e9..bee093315c 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 8c329c4476..cc1cdf2256 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 56e31235de..5223ba9c9f 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 144896de44..b5167878b8 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 4e16b0159b..263f1029bc 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 798deec487..bb49bd0ec1 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 3ccd0bf8b7..7eb0e80b07 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 15a887d939..3903226140 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 c4d9bf9710..3d90029c27 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 4b191d95a2..b7107d07ca 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 22002e1644..94bbe9e8c4 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 a8f31cb4d0..780183c560 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 9b15819641..e42634dad0 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 370faec8c5..7f6f15fb09 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 c2864c7332..3b01680165 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 bbab896ef9..0817771d4f 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 dd510e2992..b24670eef4 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 9a1e24a5b6..10df32f7f7 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 2af7e951b8..a7c219536f 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 4c309f8997..eb2aeacac7 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 a0dd393733..eb67c49ce6 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 6870079ed2..e43a7c099a 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 d75ac529ce..d5b970021b 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 2f1cfdb100..d453684756 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 514fb49ca1..d9fe477db8 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 736c3ed53a..d9cfe37225 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 3dbff7373e..7d466db652 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 9df5f45390..fe80239609 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 a16dff6193..e1770c7bc8 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 b01168b173..d200e99273 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 f806f9c81a..69de112dbd 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 d18826913c..3c6c0da66b 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 20e532f211..d2dc7eaf84 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 aa56e7150e..201eb5bbdb 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 fbc069e0e4..1c9dfbf337 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 faebc8fda7..04072dc72f 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 d838f4d4dc..67fb5244a1 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 5ae98c97c0..4538c2792e 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 f49405037a..6fb36b93f1 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 be52be00be..1faeffc819 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 27cb5e3a5d..6f45f5ed38 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 8572064575..4ac87b2518 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 319490a4f3..41c91aecc1 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 eabbc0d4c5..590dd5148a 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 631e3813ae..c88bfc0613 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 4aef77b745..1193d59f80 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 7cbf3069b3..ed705e8371 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 f2d885622f..7f1797d99c 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 2bba70e6cc..0ebfc826f8 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 51eb11060d..b9bfae4fe0 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 359d126724..aa0f3badb7 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 52f229d188..3189d1e908 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 93598847e2..c4339d9005 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 39949473c7..0bc90327cc 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 ee697c3f78..b3de224eb6 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 2a31aa6ce8..c85f3a25ac 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 91a6ced80c..86e660e663 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 ccb790e426..a184247e1b 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 7e3c031585..83ccecd7a8 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 0f911713d5..276c5d0187 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 8f6c08355f..118d6dfb67 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 75521d6ead..a658dbb04e 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 885451827e..4f184f3802 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 416d368529..c92da2000c 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 e56084316e..d4fbd34a21 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 9e7e2a1658..9e483f6a46 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 b132d57601..8d10b13f6b 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 eccec06003..2384558e14 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 02692cc280..f90bf95ec0 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 54200295ab..5e4def80fa 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 2aa76ca8df..6c436163b7 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 31fae9d08d..6bab472367 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 67013c818c..ac8b635569 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 ab9410bfbe..9446a259ae 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 e1b7d2c67d..c1f594641f 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 33c5d28a86..a1983d452d 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 f0d7e29639..e334edf999 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 4442f45190..5bd16bc3ab 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 59c30897d0..aa8feb8541 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 6608b9b700..e885cdcbc6 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 3b4751caee..6890e1a1d2 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 9396cfb948..ecee5835b1 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 eaec41e0f0..27a9c08ec2 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 da1464258a..c4368fb4d6 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 7aa47907a9..bd49e4e816 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 c293235603..4186d55719 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 2fba001721..6781324ae6 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 a7b8b82050..701e713014 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 ba9c55b16b..df93c081d3 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 eb379bda3a..d1f055dcfe 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 d10f9f76e7..48f5d0c61a 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 0c00b6f5cb..90ee1f3cd2 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 eca022c9f6..ff70f13d4a 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 a3b84cd847..0508a25bb0 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 2159b4fcce..f538c2091f 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 59fae64e07..b9c18019ac 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 01b657ae99..517f849412 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 b718eb8128..deefe21c0b 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 04836708c0..43725ee15d 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 f617825386..6892c0e176 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 94ccbf900a..3ae04de0f6 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 08d53f355b..fdeb4c663c 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 54b371fe56..1dc9c2d646 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 975d8212d2..c286994463 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 10f6636cad..3355ec116f 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 7fcadddab3..a7fe45b9f4 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 6fa4cbe906..0981fa4cf4 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 751949211c..ecfebaa7dd 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 a38d307fc8..5d9b8cffdc 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 191c423d18..b2ff6a1763 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 0bece021c4..2ac71f461c 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 ad5351d36a..c7d957806c 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 c762ce3c12..881af8c225 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 3fa07064e9..c8c71c99dd 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 2f1d67611a..811cf7df5c 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 b145b3ef37..6082351dd9 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 eb4abfccbf..bc19348fa8 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 a328960199..4ccee61ef8 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 6a8efb0c82..499c4c8a90 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 6488195e23..57bee0e7fd 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 b839f825e6..e5a107c18c 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 e082830c43..1e67b66a45 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 9b1001d913..0d90efa754 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 7e8f3623f1..a58802af7c 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 08a2235de5..0b07139765 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 f094294c58..84640b9343 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 ddff6807e9..37994fa4bd 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 00856fece0..e1069e466e 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 99856ceedd..3fba7bc6f2 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 13b94eec1d..6f5945616c 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 d71aef81b5..e55e43dcd2 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 2faf35fbf3..e96fe1585f 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 0a923529c8..a375281e40 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 8649825b54..2a31956dd3 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 a170e62cf4..1eb07c79eb 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 6a5b52439d..fa53233197 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 12839ecc1f..831e786574 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 28bb74aafc..906e6580d9 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 f9fc39962a..3e26e5be81 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 6b4af5a7c5..03f28a1ff0 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 2dd99fff98..0085569044 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 22bfb45081..e15e5e5925 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 9b67f6bfb3..f194aafc2f 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 7abca0afb8..66b2ed4615 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 1200f72dbc..94c7e5533c 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 d6029b7f6b..faeb329177 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 1b7ae23f21..4daceb4794 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 cdef1c4c83..4ead8984b4 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 c78b6f9e6d..c47d7a52b3 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 ce34816e7b..20b6920b51 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 2768afd44b..a3fe02ef10 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 6190e8bcf0..10705ef135 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 76700f42fd..c9dd4324ef 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 1cd1a86dc2..1e76d2e620 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 800994c62b..b47d286280 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 5972cdaf0a..3a54fb1698 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 4747625ac1..8afef78202 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 6bae3526f2..d8a9cc3b0c 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 8f7cd55abb..6c841f6ec1 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 827fec79b2..fdc560950d 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 a75541ddf4..7935d582b5 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 76adfa7b9c..07dd95d624 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 ff064de5ca..b19345dcd0 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 ab69bf0bb0..150ebd1078 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 1e5c9c8042..e21ca6f873 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 bb42dc3fc9..207ee546cc 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 5971d5f68f..68bfe18838 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 b8f57a5d2b..c4bdd7e308 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 6f409667d4..88ea664852 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 8ffbf855f6..2851a6e8ce 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 846dd74503..334570ab8c 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 76c6f17022..7f131eb6d3 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 e681ad0ac3..2f810fec60 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 b6da22f707..888381c334 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 8fcb89f0ce..b8723ebcaa 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 7734451214..8b5f700c59 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 6a63fa5a65..64fe69c3e8 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 260bf3516e..bc6a52efa7 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 e2aa6289bc..1f46e2d47a 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 9131dc3a65..601ea6cdd6 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 113daae3ff..14a4b76a4d 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 8a30720135..98e5ddbb86 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 be0b18f7b4..b40ec5f4b9 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 3c78a3042a..f2f2a671e8 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 23c2123aae..a13ebc3723 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 639caa5e1d..93a2c756a5 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 be16fae1d4..dde2fbc289 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 6ea2d224fb..829a68aea8 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 68cca11e62..38091baa4d 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 f893bee081..253b5904ec 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 ebefea9644..26fb7a1c99 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 77fcd9c16b..58a39c0f0d 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 689670f3ba..1b19ff6775 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 056371d904..3f127e1e1c 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 5eeb06d498..20e0ea83c8 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 5a49091a1c..01e6fa7474 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 1a9d5d29db..318220f8c1 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 327d16a30d..91660c6b57 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 4ea0e0aaf9..6bf61bf68e 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 36c85dadc0..cd8c34f125 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 fcfbd0ceec..60d042e2e8 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 7590fb27d1..36fd7db037 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 0a6a39b968..4c59f16aa1 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 ca5c7398e3..9b98759eeb 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 5955350112..480f66c8fa 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 39465e5b11..fd27aba276 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 e218a7e33b..d70c4247dd 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 a5ba68f954..65b759b226 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 c901a19ca8..e0fd6f8d5f 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 bbea88ecd9..3d94585146 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 2d0d1fe832..7c70250510 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 9ef290133d..bfeb92ec58 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 8e592c59be..b84d15d6f2 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 963f70a0e2..2f4d7be4cb 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 55272afa9c..3e20984aca 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 969da2047f..88b9a0d477 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 210d13e0fa..556360c394 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 8230824c52..4c5249dd89 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 aa0d0c3fc6..e5adce74e7 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 decce5feba..a9023b9dc1 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 d7833a990b..bb691dde22 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 a418dc8d1c..71e9e34384 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 db84c5eb96..e1b8697902 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 cbb72c2798..0b7682ef35 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 5cc366b199..4a2c835b54 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 d92315db93..859b1da738 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 6fa8b047e8..5688761895 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 619df3b5e9..a38b58f170 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 ecec6fb8d0..3214b08c30 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 7475cff226..d120794e6d 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 45a812f04c..b6c713442b 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 a19dfab95e..f455f82862 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 d5ce3dd86f..cfb874d311 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 0d8c637c6b..57237c4de5 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 415159ada1..fbc0f254e7 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 8ff3d6f33f..6415bb7996 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 6ee1cb9a86..0e71fbc7c5 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 275e623187..ffce0d5055 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 80b38a6c6f..35b56303d7 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 01affcdebf..317ce9c771 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 ee743a0600..cd79fed43a 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 56ca400cf1..998e5dc3f0 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 90197b991c..9379d38791 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 faeb063a43..bb5944a2f5 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 5f26f23f73..31b7814b5f 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 3b4ca0a69d..edb795d126 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 ed9204e7bf..94ce600fd7 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 f7d2fa0583..f2ccf2ec61 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 671053102b..cae0d86f54 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 5ed395820c..55cc34adbd 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 c8a3162215..65c133384d 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 216c977faa..4d08d301d8 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 1839637d5d..8028a7f08a 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 686a30217b..a3d69f327f 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 18455a1b16..8b4df5dd4e 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 8ada2eccad..699e0ac65b 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 23fa6fd26b..2f8b026ac4 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 765265a300..d12adbb284 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 b498537b3b..d7222dc398 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 d3965e8bc1..e0f68c613b 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 e0e6bce26e..f4f2a938c4 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 43411e42ae..7dd514a9c3 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 69892ff583..4cf0941e6a 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 99692c7ac6..30e825171e 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 dc6b54bfc2..46f61ea4bd 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 4d5af07746..5662d2c655 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 4d58b9f914..c2aae1455b 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 bde9ac7cce..d27c81d1d3 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 b2e9222745..c9e125ab3c 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 30fdb1bbad..b6b7c2dc0d 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 55f90e4461..5ac270699c 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 8207e9dc85..63ba4e26cb 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 6ec758e76b..5cf82fe1e5 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 18fbbf41a1..c6c9bb4816 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 19a4fd4b56..53b3352072 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 ca3ea0b908..2293648e2e 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 910a9da00f..4b4c108e41 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 7a39eaa974..f40fdd92d9 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 b2d3dac46d..9663b8a520 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 1cebfe28d9..baa101be8e 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 2225e2df0d..e60c55b918 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 61fdfdabc3..2227d3e722 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 957f56b52c..bb9404395f 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 f70e271a0b..1c9a822589 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 7ebad4114a..b42806a7a8 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 8b9ca21399..5942589a2b 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 fcde19f6c8..c2fd298578 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 c3165815f2..538b185986 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 50f3f302dd..658771a11b 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 d5ce433490..4f12290b9d 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 e55cdd127f..4a4b5702cc 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 bfdf09879b..3e90d8ee48 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 497e08756c..2b40307217 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 2ad35b3993..c5ee529c43 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 d694453242..574ad51224 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 8d38d91a09..532936b8c6 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 82a4537946..2f16963917 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 360ad79349..199ba0ca89 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 7117785874..6f5371c509 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 35f8779b49..cafc01a4eb 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 765d5b4d6f..d881a6acfa 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 d9e51c9c52..da7c3f373e 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 471c477652..6ad93813dd 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 306622dca9..671a814a80 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 8270a7a0c9..b322f7d611 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 fe5321d648..3e321dc0b1 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 77ce14eb27..accd8215f8 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 54b8301230..2a038b5d51 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 c93bbb8539..4604ae0975 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 19734a78da..69c6a0497f 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 ae48f38441..9af9f2c0b4 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 9dbadf7777..137bf8536e 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 d56f662a20..2c92ed6812 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 75b165d8d8..d69a3c381a 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 9283c666a6..725324be9f 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 473628202c..0df9ac02a2 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 1e4af24b0d..9162bb812b 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 a272186dd0..44600c957b 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 f74ce5a325..0ca26b5467 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 8c94d1a9aa..f5a29ec8eb 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 e9ccfa753c..1a10d806c1 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 abff9de20a..c5ce797947 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 7621ab9d90..51cfc40ac8 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 3eb1b9ef23..258d10b683 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 3e86deae12..8db5994d99 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 ac1fa1e671..ea50e21653 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 26a40b2c58..0364d880ca 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 911c67565c..f2a3e1935d 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 ed872ce579..30c8c7f8da 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 764772fe3c..5bfdaf8662 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 5ece1a8f2f..e34ee4ab89 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 315cd73529..7d8c21ed56 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 8865eb2ded..802c5edc0b 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 7f571e4a32..e7c9ad44a6 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 c94c657365..0b5da8979c 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 692401da92..a839c10a08 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 71c0d91c99..e37846e83a 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 9cd32940da..4bd6a35ba0 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 ac5753bf6d..d98a425f40 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 bc4263d51c..7f58a2c3d6 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 3205b62938..471f4111c3 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 4d81086c0f..99dd340496 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 c452e1f059..16ff41db7b 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 13e440a20c..26eb08667d 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 27ccfa64ea..9b6c349162 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 1c84024650..de8c8bd6ae 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 bbaa3276d4..840d5c74b7 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 c8017c18d0..39dc8d8fa5 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 9856b57e05..8352bf3b10 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 e7029845eb..e9758ba8fc 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 308d488999..eaf156b64d 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 60e0a87430..d526ac6fd3 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 a979d8723a..d5fe8aaf9e 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 f74164fa37..e985377506 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 766ff7f180..5f7ebb7095 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 23ab1efda6..8a7c00a5a4 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 bf0bad5fd1..4bc5afc156 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 8f68c3f238..2a4063ae78 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 dd66c454cc..acfa631661 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 584d6f2e54..e6726cf4cc 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 6a55dce2af..dc0f034155 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 e773a874c2..e54ec613a9 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 f515c4014c..b3b0367af0 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 cab315ec52..2ec219f614 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 bbc8ebc406..dffd98d497 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 0d27702032..d218add330 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 371868ee14..1aa45c51d3 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 0e7e1bc9d5..f6388c8841 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 f2c629cfe4..a71f95c026 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 f7464e5ca3..a295a11b8b 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 c005d29cf1..0bc8de62fc 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 0a26a1c68e..a7140ebc78 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 604168d79b..3106643434 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 b07ec715eb..9619ccd905 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 80a5e0fe09..7f565eb644 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 c6f3ffa089..9f654dc298 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 a0031b5505..2392bb5367 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 a106df2aa5..de3616f7e4 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 c0b2d4b9ae..2fa34eeef9 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 4489d3c3d6..92d3761327 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 1cff3525e9..0c9bc849c4 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 a853e2ff01..ea632a3946 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 023f5cdce3..e2ce3008ce 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 956247a24e..8b6bb21a4f 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 1bfcb31ed4..65a51cfb40 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 77228da906..0e54c665cc 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 2a8fb2f27d..44d4cf13c3 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 27e793d5af..16c28ae7aa 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 00aae55eaa..8bf9edc82e 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 f0dcea620d..4b0482dc22 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 db7e4ff2f7..03c962044b 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 ca0d67c6d8..dd9a5cc371 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 9e7a74c05e..6e08e49c69 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 5acebaf3da..4d6e97a2e3 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 82a9cdd756..2801409632 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 c82f9eb39c..a2c2901696 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 14e2adc67d..ca799fe05d 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 cf114686ff..141271ae20 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 51ef238f6c..c02701653a 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 5bfc0f0eff..5145d8b703 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 cd2ee9fadc..f97312a885 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 a72b223223..510268e522 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 ab73eb3c4b..a4215d3a86 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 f450768d09..d269253223 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 4ce7ece563..4f4b43fb06 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 b75082551b..dc4f1332a8 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 5ce554e428..37128fc3d1 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 380c93c18a..040a935bea 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 7d97f57f38..760ef591a4 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 f656c13ae8..e5dff0a9e9 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 8b8ec4e3d3..897c82ef4c 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 7964519aab..d0d19b7d4d 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 927ebf0ad9..5193fe519b 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 ee4c5d964f..1782484a30 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 30cf3cc0f5..53a482d6d7 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 575ca46094..d434d48adf 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 d112fe1917..44ddea30fc 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 c8a572b887..67c6b23c0e 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 732144163d..c656c77b07 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 1c6bbc1630..a3f8de89ee 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 9d2029ca9f..3a39cc248d 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 c676a94f15..a36de127f1 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 4c2037bf0d..ea83faf00c 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 7827a79470..5b3b8495b7 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 9fc366f90d..ae98e40ba2 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 39c21ab3cf..e9e4661fd0 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 d6968fc735..fd87ad3105 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 172ce75e17..40dca26961 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 97c34c9ceb..accff1d945 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 3896590524..ebb70c162a 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 7d6b7aeacd..4fce2a7f38 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 d1cf333ce2..798cf6bada 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 80ba138dd1..4a339e7fbd 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 076fc341af..f4119e033d 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 cc6d1fbc7b..34c85d6466 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 b951fe9a85..30a287e88f 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 b1e54488a0..091d8051c8 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 1e666fd961..41b7681541 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 94dc3fe0c6..ef8b4c1df0 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 b0650f372b..2157e8461b 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 5a792818a4..de97e2a368 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 c9bf851f3a..c1abe004a9 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 a8ac103d15..6ce3c8b950 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 88834c3eeb..e4de2472ad 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 9c1acb97c7..397edf036f 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 8853cfa8d0..56ebcdd56c 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 fed7bd90cb..1add5054db 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 b5c1936b1c..3ff36a65d0 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 b40f33c2bc..94b6776878 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 c6d2b64057..ca836f8216 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 4e0cc9f0ea..1d891fbd5e 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 41d44b12dc..f9cdc2539f 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 15b9bd2ee9..9fad21f83b 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 75728bdeeb..e907f16fa9 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 a3a976307d..907c29e519 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 9e55e5bb6e..d3b7fedb9c 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 6f1b167c7f..6d74c3832b 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 f0b0d53b4d..8250f2488e 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 5619ae44f5..39012e48b9 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 c55e1d8ed3..ba5c012531 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 f8962b8ab1..282883e4d5 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 3c7ffc0370..f130a836af 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 e1417d18c0..fc846fb922 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 aad616424e..f08c9a6be6 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 72b6b788e9..c06d81aa73 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 e9395347ed..076541d98a 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 f8209039c0..87fc8cd6ab 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 7c0b099eb9..bff1c37645 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 b17dacc635..d018623c7e 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 7860ecb497..ecb35f0dd9 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 6c1d83a913..96b81b6b0f 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 dd952e0373..5763d16261 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 40bc2be8e4..a1b6b35e6c 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 340f04de0c..5a1f97d1d4 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 545c5e1697..bbaa3f0d0f 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 25ceca37db..3b374ec485 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 7c62fbf9b3..d864addc8b 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 b8fbab6f7a..5630046c9b 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 dcf2bbc5ca..92e6b15df8 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 cd17bb340a..4fdf420d13 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 78c1d1c829..cd453e969b 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 a911263757..a6511f9e1e 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 053f5890b0..42b4f1708a 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 6db986835f..2cb64459d4 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 6f3658b743..8e302841cc 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 1c2bb26005..867ba42f92 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 614c1d7d04..e8aad67063 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 98da5e1581..145b93bd61 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 164e6dfb8e..b7c7153c70 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 313f8916c6..8e6f036a13 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 8b624f947a..11b1425336 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 6d6ac8fb3f..9caaccf649 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 244ae5440e..7f63443dfa 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 810fb6d172..34a2ab73e1 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 d9e8466129..4279dbff35 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 a93b3a1373..0a93669a3a 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 30d69d8550..df3de6b375 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 b93a9227c8..7cdb9286e5 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 2859439f94..657b860dbe 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 27511f3122..5b53ed7eff 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 c6ead849c2..51655ea178 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 f57afeb616..9d0449de83 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 e6ed2a056f..0bdf2fd9ff 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 b9e9392716..28b12d6962 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 fd4f371319..a57c739f45 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 b5fae963a3..a4e2301b7e 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 35f3400c75..30695ab7b5 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 de884241e6..541f342da6 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 d9b63d4fbd..59dcbcd8b6 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 c81be681cf..e5f42c78a4 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 20968f0941..f23575f7ac 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 d5dd7d0b95..bacff2edd7 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 27fdad40b4..4c20d8f66b 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 b3bfcd7ae9..d10bd5af60 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 0759c881f3..dcef33d42a 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 7325f260a1..908cf7ca43 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 933576aad2..6cfc4f0f1f 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 daab2f1576..20c3f6828d 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 ff361a6a41..a6c794cee2 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 256512f0df..d9a5176a25 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 12e15140a4..7d0d47e62b 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 7ecee9b7e5..b31c5d1d76 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 4c2fa69600..69689f6e98 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 d0d52520fb..cef3e5149e 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 a0eb43f134..1b9ae92f8b 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 39cec02d21..df183b16b5 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 76eda2d9bf..a4ebc46a4d 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 0c2bcaf61e..f95c7141ba 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 cf4cc19b63..4588908d15 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 eca6ae0ee8..c517b5cb1d 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 b09d5c553b..dbef035b3b 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 a96ea20870..0e700238b3 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 f380d3a753..04d7ad0f64 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 c9084666a0..01c9646696 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 3192f4d516..a903300a20 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 e4876e1e0c..3ae3e318cf 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 8204c8184d..1ca51d0f4b 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 a7a9f6174d..2ad4d153f0 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 153dba1e12..4b926240f6 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 67641efa2f..4ab24e97cc 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 92bb25d0f7..d3bb1f72cd 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 d9c7d19cd0..3ffd3c25f2 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 67b0c308ed..c5cccf4b83 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 b947be7da1..6839720337 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 353e2b41d1..3e82fca0d3 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 191e4c4f47..fa6ecd5675 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 6c6cc41b9e..c3e052972c 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 6d04b21e31..ce3a792952 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 ad271f64c2..e337cfd93d 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 f22b22d83d..07def8de98 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 f93146ee08..f0d72e2353 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 027791546c..5a4329790d 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 b9547c2b1e..2686689266 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 9b1d24eb95..ec44416842 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 f28e19c20b..6bcdca7424 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 04e4b19a76..215cffdae2 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 c906d82615..9621d2fafc 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 addc91b4a6..4340650c3c 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 f5444c0a96..16f6bdf2ed 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 4aec6d2375..9bf0619cde 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 3c5f3ec9d1..8fee200592 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 090571a2e9..52b363797d 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 04372f0a04..4b66fc63a9 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 0bc7e63a08..231bfb9bad 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 b4f1fbb3bd..6637c6c140 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 140e2837dc..e745f16561 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 b048deb96c..41c28e23ed 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 3f6483a9ff..e2eecad16a 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 9500a294a3..df21524d8a 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 34364d6bbe..eed6f05429 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 652896458f..b53d44aa6b 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 7787603a6c..36cd0a02ce 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 db420ce322..6d6b93d5f8 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 fff056516f..895c4d07e0 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 43d289da5e..2cd882ea0c 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 c3a0cec758..0a933f6962 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 a7496a16d0..bec83a8a23 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 2bbef29adc..4c30ae6756 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 37805ef3be..554754bea1 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 06e9003c59..edefc57f8e 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 1b00d2077f..16ba7b8705 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 5c6a7b4bf8..69fe129448 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 dc74c192bf..0b3f842d01 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 517e249203..9cc89087d9 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 6447effd9a..293a340ea6 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 66373c5b0f..513258406c 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 e479c054b9..b41864ee43 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 f7cc4bab50..f34e16edda 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 46faaa7945..979ff4af55 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 9abfb4368f..729127c9df 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 fe6fece723..8739860e2a 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 5f53742431..471218a1c7 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 8a9b0b76f4..f30d4e6e96 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 50d0948683..13ac92b05b 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 848c53d180..c406c57640 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 5c384e59a7..ec8572acf3 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 2abdb1847e..87f1fe449d 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 8ca3061f8c..6c9164f0f0 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 3e2372a19c..e7ac6a6315 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 d39c67b986..72a36b2bf5 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 6f5d3ca8d8..bfded2b94b 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 28af3c7ac2..7fdce9a179 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 1832120a5f..a472cda6fc 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 c63b6d9eb8..60788d8fbd 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 b7b0e146b6..aeeb8859d8 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 1fc40e72d0..b3e97ccba8 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 5650cbf838..62056de8c0 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 fbe50f4c44..7d3ddac4e8 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 315b7a83a0..fb65f0e64c 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 24f8994e11..e1ba311466 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 dc5e65433a..218d378e2d 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 f677affd4f..598ff8c97d 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 d7dd6a6d65..8610a6138c 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 3c20ef1c64..27c8732d65 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 2769ff59f5..42e469fa03 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 72bd18cc6d..4f7762a944 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 23ab7f20ac..1bd03c9ed2 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 802dbdfd26..f317376bf1 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 4cfe2298a7..95d3f9c076 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 d4c7ce7ab7..0d35ccd221 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 80a6228588..7957b3bfaa 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 7fa6d273a1..62a8ae0286 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 8bbcc78a71..a8b8a38744 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 e8892f6597..ab8c70317d 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 1b99f8d8af..70fa7bfefb 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 dbb6a01bc3..e2c75a85f0 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 e879b4ce10..df9deed4a5 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 c02fad6fb8..7caa3b292c 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 1c71a0803c..8be214654b 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 120e782777..a63b6aedbf 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 f6efcc952c..5dcecbb106 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 9d89cd84a9..bea0548648 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 4f007e1e00..e59651aa12 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 ecec8bb92b..2ba0fcf893 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 41e89ed52b..0c52598c3e 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 ed018ba5ab..862dff9f29 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 984a486c0d..9af6cedc13 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 c7ceef7e93..e5893419a7 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 8d922c4cd8..5ea0614e28 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 72adb35a7b..7e261e1c55 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 632f725fb2..e30a10b3c5 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 2b0085126b..d6eade8585 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 5c205b3121..e4c7c54aba 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 966520126d..7c41cda9d6 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 9720d4f0bf..5d33a62dfd 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 1be557648c..bcffb7e97c 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 bf8736dd1e..bccc7fac24 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 bf9515bbdf..613b725f77 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 7a7ec55bd7..b9dd4b5c59 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 1ccc1e628e..21922905e5 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 6a0b5751b7..a4af24e46f 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 d2ec963f56..d62fac8a8f 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 57d7add8dc..e5774fba72 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 f5b4f8b80c..50b81e83b9 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 107f422216..00fe9164f8 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 2afd45df44..5c25993a50 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 b274312166..708b4d3c19 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 9e7499c237..f4eea63740 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 ffa00b20a1..ef9870a3d9 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 d2cea25e1b..f3daf0543c 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 565b0a5671..6b0d6e90b4 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 491d76abb7..806d2985d5 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 afb2ec358f..a3cbf0501e 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 6f4aee049a..29a8c5d42b 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 79c80b41eb..96047ac3e4 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 6469eaa4e4..951f4522a8 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 573e3f3aec..61167fe700 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 ed594e9ed8..3f5b969e5d 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 860534209c..0919a35bf6 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 0923d5d40a..d84a1aded5 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 c337ce9a45..761f2f8cb2 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 b3dca39e86..bc8126d4d3 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 03dd072229..2cfd122bd6 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 b4697b052b..c3b2ba068d 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 c2f0710cfd..8f880745fe 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 0f33b16b51..08d27bd707 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 1b14056f3c..7981addf56 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 a42550292d..25e3301b45 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 303a015da6..cf1f7b3ab7 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 f179ae6983..ea5e5451c0 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 51a7390fc6..a6644e3965 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 13fef01155..60601f4fdf 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 99ed65a000..66e23a61de 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 a4eeaa0dd9..f1f0720b0b 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 ba19747577..0710ab15e3 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 c5da14e9a1..5101519b98 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 b6fae79627..07cc4edc27 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 c20a402b79..7c93821efb 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 bcd17db3b1..256c60bc43 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 42080b3c10..5df7e02aa0 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 23f2dc5113..8f62849579 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 ea3772db0b..1be77e71fc 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 01b0a50bba..207a28caef 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 270d59d682..10e3b6497c 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 fd1182e1db..efbc40363d 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 f5e90c1321..4a574e68d0 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 63abd357d7..22c5fbd37d 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 25ebab5a48..58ae72cdf3 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 6b3df4b8d5..60750e6eeb 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 a8cc25f163..a3b0d6a68c 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 8b398e510d..f4223a1d06 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 e36b5c7971..31846e2106 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 a9db259cfb..47b4eec752 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 81e21162ca..b9cbccdc7a 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 bf61942257..91865a5642 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 97ba059887..357133f1d6 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 dd60016d43..e859bfc125 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 8fd4e64ea4..cc9477b5aa 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 a88ea70de0..7eabdef994 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 588669655f..0254a8188c 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 b8dbe02f6b..340bf64bad 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 9481e51002..884610dcf2 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 54c9c5a394..1838d09a20 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 55458b6f23..ef3574b53a 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 98de30c095..cab26213d6 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 afa39143ec..f4b323ad08 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 2af5a1977e..aa24d2ee61 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 f14013a0f6..1f0e8e587f 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 3633774a78..8e0b8bd3d5 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 5bb9bad9ce..54ef51b015 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 8de558cdfa..9dfc1b0d16 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 d2c90d64b9..dc10090845 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 725c922d92..924778e57e 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 bd574c8d0a..9ab872a6c3 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 971334e2c4..3ec90bb526 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 358d9a3cb1..9cdcf18652 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 d5e1f4eaab..e3a30bb52a 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 aa5c25f7f4..e75dff0ea9 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 b29e1b822a..f6e53bd736 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 38b45e0794..58557eec65 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 653acc127d..d3be2d6c13 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 db5bf394f9..271ea318f8 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 53030c4f3e..1ecdaa503c 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 f5bf2f2ea8..7ad14aa390 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 dab98b3819..a3b7a39458 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 577c20560c..eb7a90236c 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 58ca330eb7..d1c711f489 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 5a328c23e5..5883953eb4 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 2f75bff35c..022907fa85 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 c4dd02356e..89028feaec 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 25952a2d8a..9843eb7695 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 1746ef944d..65b361cffc 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 7dca7dd1c6..60ff4ec971 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 241dc94f01..e8cdd52720 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 742e581125..e5593fd679 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 6ca516114f..5aa6dfe836 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 0ca537fec7..5d167e2f1e 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 b0362dc1b5..e576d1b572 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 c26bcc114c..ad9d6a3a60 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 ce7af63e15..5ce740437b 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 87ab458f11..a3832d8c9d 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 ac3e965d5d..8eea8310c5 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 917ee53f34..4feff385f9 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 70f0dc1969..7d7de6bfb8 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 89e6183997..7737de03cc 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 109c4270a1..17b041e2d2 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 2173bb0540..803c064e93 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 bfdd1ebeeb..9550571f5f 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 221a386585..dd2e04eac0 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 4aeb7103ed..75b8882fbf 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 a113bdcc69..522055823c 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 d38c688c68..8fb1b7b531 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 9997906fd7..7d114591dd 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 b8bc57a893..5a1026b376 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 086c8fd9d8..94d46fda37 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 44fe931c7e..ec580a2344 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 e696f71261..2f9004ee40 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 64974e5c86..0f4f50df4b 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 808140497f..efeb1807a9 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 7b78c18584..7b16e59c2c 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 39a34d9864..7a1ddf15ae 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 65bc2bf0b4..5013b076cb 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 92944937ef..bad3f91a21 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 5396c3a3f1..57b4d82ab8 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 a2570b1ce9..bcaa9cf0be 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 ca644698a2..70e7aa06f9 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 2cc95412e3..b4c92e98ad 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 8810b48fd3..09948cfdf2 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 237fcf5c73..56a8daafb6 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 99b5278060..5af1ba32a6 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 58ca9c502b..c9c49a2b1b 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 2ee4a7a96d..d0513b6ccb 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 49270a9f07..ef1e8e97ba 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 f34373af48..a97ace67b1 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 96a7221899..914bde96fc 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 675ab39ed0..e8818495b3 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 79ef7ca743..5f5cb66924 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 fcf8d0845b..445e03a5db 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 5680af5ea5..2c97d3ddf7 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 e2fd1a7521..889e8e5594 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 b4bed020fb..3175cd3fd1 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 f0eaf959e1..31d0f4bce1 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 4e17386459..7917b27db2 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 9ee3c3742b..8a9fde8fb3 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 b5bd935736..6d45834a4e 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 e93ab74b19..2e150a405c 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 e9571c2365..3af388de41 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 5647ea990f..fe0907c04c 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 50348f1ccd..7956d8dec3 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 0d53a62051..1309011966 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 2af9ef5b7a..83e7c6cd68 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 c85cc0b4dd..df00d6afe7 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 fcb5554cac..3fbacdfdb4 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 b28b8ebee1..545efc201e 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 001517b4b0..ef059e3de4 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 cd67ae1cbd..b31a5be5e7 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 562d855bb2..1dd75dcdb0 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 5ae0da301d..ca5a855875 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 9ecf42f079..2022d5d0dd 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 098e2fff36..5555c17266 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 5abd026f44..37dc0f272e 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 b1579ea348..378a6a9fd8 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 5013ccca1d..c034b6144a 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 66e603a759..a9539141be 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 268393df9b..0b4af8bd3d 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 1ec280cfc1..b081ed3312 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 524f86ceee..89e44a015f 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 68d3073e53..0112a62e7d 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 968108ac1c..86df733372 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 06caefb3d9..5c589479b8 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 4a910efd40..2682f170e4 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 9bcd633a0e..0891a56ef5 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 e6855cbf06..145187c141 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 0d94d1c4dc..9a0e49d0f6 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 5e98e05721..91f56fd51b 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 f4d235fac7..a1c8dbb7c5 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 7170fa88eb..8829b15738 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 991c7c1178..e519a7d45e 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 3cf45b66e7..b6cc796051 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 26a3729f2d..50c6635778 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 01ac0d9a0d..f99499b20b 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 b2d2257d5b..b22f4668bf 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 398321c605..6e92a94a08 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 bc89529d8c..9377c06f4b 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 0bc2290b79..a3f8ffd4d1 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 3182fe17b4..8f9ff2fc9f 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 6584671423..6a6df53fa2 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 062dd26ac5..7e50a459e7 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 19efccc2c5..bd47237df2 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 b72498e466..20509fc592 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 38d01e8bab..170becdca0 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 c735c350cd..c3eb7399ce 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 6d775f6f14..548a77f9ff 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 516bba716c..fa53910df4 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 6eecd7f7cb..a99a155aa2 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 e859903ddd..4600794283 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 a8c83447b0..e728f67a7f 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 ac6b6af0be..b2861681e9 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 ca493c95bc..4b83c61447 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 23a9601755..87db2a508b 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 aea8f03b2f..e88aff7751 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 940b80e8ca..8bfe94f8f4 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 e1cb27de8f..0755fe8e3b 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 d39b5353ec..9d0e060c9c 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 66a595b402..f948f2617a 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 5c7b8f0ef0..9815656211 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 20d58b09ea..7637877b27 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 e9fe16f1ba..ed89975c9c 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 92c6125288..718ed4a8f6 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 ad62ec4b6c..e0beaa7743 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 34cffe1809..9830d5a7f7 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 5f991ca79c..fb0d46a56e 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 fcc006b8d3..6ac387a08a 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 3933fe91b2..bee6db0217 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 d935d966e8..9959642d6f 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 2181d00628..daf9ab7364 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 3107730f27..82df89bc78 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 a34abf73a8..bc3a732fd5 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 996e75161a..794f9adb58 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 734b4d39a1..ff94d695a7 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 0cea428bfc..289af11bb7 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 8a54fabc20..99b3613ab3 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 5554782690..2a9b51daeb 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 1711a95a92..81d9269c43 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 caf7e6d63c..d10733706e 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 4b06dfd6f4..692aa445a6 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 83c4ad7f9e..c0e0a3ea77 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 5a84721d2d..d719ee7bc4 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 2e4611a08c..b8f373eaaa 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 060c7835c0..8f685d8988 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 4311885b9e..afd14667b2 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 19a9d98fbc..e4beb1adf2 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 3a36d4bafc..7bd4014e2b 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 a4300ea563..d2d3f76855 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 b7c30e1d66..a5c5e98744 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 ad3c1c4d49..ee7a874fe8 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 3ca02d3127..00f14643c4 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 ccb68eaf70..66f830b2f5 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 3211ce57b1..b8f52f0bea 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 a4a402483d..ae4ff1a1b5 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 0f8f9d641c..82531414ef 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 12e683c4e7..83db6723fb 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 85f852c638..99c64dff78 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 ef8007f8e5..750b681406 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 c8dbdcc978..cd74eb590b 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 38741cb20a..fd3a77076d 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 0aa080336c..366aaeae38 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 786f0a62f9..978b8b5150 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 9628daa396..f8bc726674 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 e64a7cd1cb..d351c21527 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 ff2a8ce7b3..55dcaa8582 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 8b1227e1fb..1ab2b47cae 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 c5428664ee..403e1369c5 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 29c457ce90..2c534f0cfa 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 7bace3b86a..a154724517 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 bd5c46ed57..1397ea2f73 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 69b2e25c53..bcbe2c221b 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 4b4d122322..f65abdfd0f 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 43c73f0825..0e81746e42 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 5a4edf6856..5546e9d286 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 dfc36a5cc5..98d11b002c 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 9d994bfed5..984113226c 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 a786838cef..4f509bb203 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 a24e5c66d6..2384d6e71c 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 5647e0c07d..eb020503f3 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 57b93a8270..1ecea324e4 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 6432de0f85..b39bdf5251 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 915097d838..5b730c7488 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 aea7f9cda4..6faa7b5849 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 3e55657349..235a64f3af 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 d3fdbef2ce..f305e295b8 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 de0e4ee8c9..eed5979a11 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 b4f1b915fe..67fbc5b9d8 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 3b49867d70..0717544a43 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 82493a8bbb..ea0c4fbb47 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 f91ab07c81..8e79688fe9 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 7377568235..d8bf8383a8 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 00200182b5..83900c7f55 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 b087033a19..9fca4206a3 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 ce67371595..4d181d0d6a 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 0c091267c9..54235086cd 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 df3323d348..70e595599b 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 b795a3085a..e5b492a36f 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 c194c53e32..8f04e985b8 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 caf1ae03ed..a30f65e128 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 8b7d22fe45..d7be6ad75c 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 eb2cce8d1d..b7bb8bdf12 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 af0305d75f..a82cd6b0df 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 91cbab7698..e1fd4820b6 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 cea7b8feb9..d936dddf2b 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 6699847587..f045540f43 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 ec326b32f5..2e865d654a 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 6010f2fe6b..9d3215995d 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 f810f5c250..ef0356f8f8 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 1843edc6e1..6f9e9941e3 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 1860230587..6ba4c875de 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 7af4c32010..ca67fdd8f1 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 7e5bd75461..9754decb1d 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 1271a09e41..7a248faad2 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 61d613f256..a4dc7192ec 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 c7785d5033..166deed0dc 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 61751e27ea..0f3ab8865f 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 caeddf201a..35e4b9a8a5 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 3295281e6d..c039821964 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 cb21cd86dc..8b6a8a4b60 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 aea4f02d98..ac800b060c 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 a91c0f438d..a0f1c6acde 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 686b4c09c8..e944d82115 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 8fad707112..cb9924e52c 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 7472d39081..2adc60f9bc 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 d55c299bfc..4c7f6b6be9 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 1817e47e36..5f7982b337 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 0d69470a7d..4618f639f1 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 bb9956a0ab..d4b9938c31 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 fedb59c2d6..15617f1980 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 4f34fb9563..c5ba7d02fc 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 8815a90b13..d74ee20d7d 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 82bff85dad..b0fb9ac6b3 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 f2e2569cd8..c3059495b3 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 187815f5da..165c715a94 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 247cdeb510..1b5c803e68 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 a7b8184f34..800e7634d5 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 2f859e10be..3dfdf4457c 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 5bfae75af3..fb3fe585a4 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 c6525ad820..f7f90f37e4 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 606e0984ea..1a0d204350 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 d02726a004..76ff191cc5 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 b9e4ef1642..ea90fc8bb7 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 c532b862be..c85624f0cb 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 c438fd60f2..b250951b35 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 7987631971..f4a1e35e97 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 5ae0ca680a..ca856fb788 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 3244f5c7c6..08c645f3cf 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 8f1833257e..ae239ae880 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 0f67a7f2c9..864825f0b6 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 5ec81a8ab4..ec0fadf7c0 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 ec30479a25..baa1283e3f 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 ce25a5f421..8a678afdc1 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 82b39d5f13..5831c0665d 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 9c6ce0211f..319a6f9fc9 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 77f4f1bc3a..b6319f3a53 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 9865e0e93c..6483a0c812 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 2a5946f729..2ad57e6d0d 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 228bfc70ac..aec597c54b 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 8f2fcf6f11..627a898733 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 a1ca83f7de..9f0582fdc1 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 108a731ee4..9a54925042 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 0a7ec9db86..f227fccf65 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 4412f55150..a5fd889da0 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 044dbf54d3..c9691e0e16 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 49a6d644e8..7745fe828a 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 ca211554e1..078893563a 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 8f5a450798..3340225d93 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 a3cfe88ae3..75d5853a64 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 88bee00da6..c0d6ae3cdb 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 733d499555..8428efeb4f 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 b7823e5375..12bd6e587d 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 427ba02831..13b5cb2898 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 8b308f4f9b..cef09acfe2 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 b0d4fcace1..262e776c52 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 9f22450a22..dac1ad634b 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 44aa7b682f..3bf9f2f5f0 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 10f9120342..aa20ba36ad 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 748fd038d3..8f82a2e694 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 74e23a4128..e0d566ce35 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 2712a9f86b..15198c2610 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 8e734ea18d..d145976569 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 6b2f041332..d1d15ad045 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 9344cdf73e..d7672c0d24 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 f74308156f..5fb296153a 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 9592347c23..ab89796469 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 e8a4d9a3a8..63970351a9 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 dd5c1b45e2..c3e094bfdd 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 5832bde7f7..273d2e31a2 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 3ef03ad8a3..da4ac8e87d 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 a4b62f57ae..5bcdb22cf6 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 fd8895f7ca..4b2621f92a 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 1d3d31a8df..c2c74b82fc 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 a7e703161b..5855951f2b 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 41766accb2..3d85855965 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 7a83f3259e..d340b599c2 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 45fe2f638a..615e8193ef 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 d8cb1a8f73..c671763409 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 6d98e3cf17..692a445e5a 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 2c2d3bbc95..7b314dd38a 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 d06f94bf3e..557f794239 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 c35b86e63f..674d2cd63e 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 3797f70e08..73222843c9 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 958c42b705..ef95aff631 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 027ea1df89..e1f8fcf258 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 f052e0f00e..95c3f9e232 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 0777063d48..44f2589148 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 66fb8fd83f..29e0c66660 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 044b3eb97d..9b39acd679 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 014b35b1ed..4b6fc546b6 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 14e7d86e21..a7cd9ce333 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 b21392daba..cceab2ea3d 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 1f9ec0b725..17124cabf8 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 9514bb866e..534eede87a 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 6d502be21e..68a9a09e49 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 ab04ab051d..5945e719a2 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 1e6ad76603..f396831241 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 ab40850abb..35890f004b 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 007d0548af..e7dd04d080 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 dbc2ee1e14..8e907e0d9d 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 6a1a5635b7..c0bee55075 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 e2b01beaef..f3513aad60 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 e87205408e..3117639c57 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 34377869ff..b4a1c42f6c 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 8ffa264fda..b862efff01 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 39a88c2a70..9712219573 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 885f898fe3..b34597324e 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 7b13e1445d..e832470604 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 90284df140..3bd2d4a04b 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 c0297437d0..a56b47bccc 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 fab1aff9ac..bb6abc4012 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 0a2d065815..f0899bbe9d 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 22b402ae37..f994c02a87 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 23ca5ac069..a360622f35 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 4ec224b29a..3aef057ff7 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 ada991d6b7..ebe2a3f7aa 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 7b88c9c405..ea666913d1 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 c199a24be6..1a31d42ace 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 223dacbaf9..654c59d1f7 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 e4e6cdd522..02c5890d21 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 316c137802..eae2e7794e 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 39de4e1b42..87e5bc7024 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 151c890548..d58bbae282 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 72e643ac17..f91619baf8 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 812a090d5c..52c4cc7c39 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 7e10221246..7910adeff7 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 98d603686f..294b2c94bb 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 a680a8d73b..9e6ead765b 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 32cb6ec861..d02e81fd27 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 bd563dcd24..bb196883a5 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 764cb253bf..4355604725 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 88498bcad7..2b7978b19d 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 55d37282ca..cf2e6984a2 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 3ad545855f..9259de73a8 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 b31e504cd5..5bfd6c5753 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 06719d2764..9ae2267ed5 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 fde3218f72..b223e9f87e 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 2eb32d84ab..3c33aac4d5 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 88a4153d27..431658a8af 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 3099292724..d941c1d262 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 4a5619518b..bb9e152d59 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 872edfaca6..d7b9924ed4 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 d3a14b47ab..abcea54f67 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 970acde4d2..550ba9caf3 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 26b44c8de0..543faf747a 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 993a3ac364..c7abc82860 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 f857a6caac..95be8d2210 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 46c426d63f..2cbd75a2ef 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 dd9c2ccc3d..e7730428b9 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 e29b55fe53..c29737ebb0 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 99698ca729..713ab5e7ff 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 15f361ab33..9a623d75ee 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 548fa179f4..b79aa55a89 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 be8f5bbd5a..adbc49e6b3 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 a57e23774d..c2593e0410 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 8289513660..c74e7361db 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 3f1a5b5a8f..9e11a63415 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 c3b39257f1..564fa68a2b 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 76c6ac4d8c..cbbaaa1922 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 beeaac5d51..eb7389a4d1 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 63ed0c209c..47c26ec91e 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 ec32f381b2..8163be27a3 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 e6f7ce9068..a88cdffcdc 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 dc04a29d52..b8d0fe1ba4 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 7762f30b8d..4eaccb8d7f 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 e92f114e29..11eb6e2ba9 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 67156a5de7..ab6bbb12a7 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 6965037212..193784bc81 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 1ceaa0b9a9..2a5f75e2e1 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 44d164cf0e..0dcec9e097 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 7b1567b43b..73a6a11cd7 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 14657464a7..43761af11a 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 da9f5a39e9..ea0323587a 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 46d335c390..68b0bc095e 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 f725c2abf5..d2dcdef958 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 0c440eee87..898e8ef74f 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 fac38858be..f76a637fa6 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 9ac3f7d131..1b291ca8f4 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 51b6d1907d..715262de28 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 669a8aa075..797309d21c 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 b2e524d327..8377699ccd 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 444efbe9d8..a700e495ed 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 24adf8af0e..42e53e8598 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 ad71d593af..529fba686f 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 d2cfc51ed3..ba5347dc3f 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 8984a5ca7a..0ac9bf9ee1 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 309693782a..bd7d70072e 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 68bbd228c2..82591dd35a 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 ebf7d7f947..b57cfd6d9f 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 6a9fdb720a..0a80b9e9d2 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 572afc58f9..beb3f03725 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 7fdda35570..df01574599 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 d03a468eef..b4e0ae8ae9 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 67d6f473da..fd9a46f920 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 97091386d6..e3c1af75f3 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 ec2f5a0aa5..68eca48a12 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 2c1ffae4ef..5f77112e14 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 dd39784938..b4ad29ba4c 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 8c50da881a..e581aed2c5 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 8981acc8cf..246ee27e27 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 cb71accfb2..3fdb4ee75a 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 d9ecb3a8c2..0bdda27f8f 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 b9c5e64ca0..fa440a29a7 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 491ed1401b..78f354b949 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 5e4e8254eb..4535149bb5 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 c23459a2d5..e6b944f75a 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 672f54a5f7..5f7bdcee3e 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 1774e9d8fc..550217a5db 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 3f43488aa9..aa1355dc7f 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 e55f5f2fb5..18cf2e2fd0 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 e3a3fca26e..8585a066cb 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 25372dabbb..f21bb2fe2f 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 2913f263b6..10933485bb 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 e879310c30..39d1d4773e 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 4d11492699..393a38cf77 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 969e0c577d..2600a0b638 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 24dd043f5b..5e5d2d78c5 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 cf6d2575c7..a62adaf882 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 8cd30e338c..1971ef8a2d 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 6f12748e72..563caf89f4 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 9e6511ef85..ceb01d498e 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 5adcf3ec8d..cc8533f43f 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 dd6c39bcf8..6caefbe001 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 c3e77a7323..59c0bec18b 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 4505ef7fbd..2172555fbd 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 982a28f29f..0ce19ebe38 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 2faf7bb3f2..797e3b646c 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 da190eb655..9e5142f135 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 3c00d23fb1..f612bdcf09 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 828067da43..27ae4237a5 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 52f73e898e..36a7972e38 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 0fe6daec4e..406ba342c2 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 c21472f345..90cd4dcc51 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 6eee1ecd8c..8bc481dfc8 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 18d46368f3..8b4c107b5d 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 b890a14d26..c2ae20a879 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 0308ebe316..b373a23df9 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 7d72adfc23..8140be67d9 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 5bcf698fae..661ed17a24 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 070e996ef4..3ddcb72536 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 f604b37df7..daeda9a292 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 fbb8a33abc..936ad94198 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 670742fda5..ec3b147f84 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 f2d693b342..36fe85e3a3 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 62db8923f0..3a5fe38ff6 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 8539d8e824..792a644c98 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 a8a5ba2362..99317df449 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 e61cdff01b..d24654d917 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 0b97fe17af..c0f8374723 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 2716fe3a03..7c540267ce 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 b2a70f97dd..569f9fcbbd 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 6d41a144b4..4084d17987 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 c292c68f79..16cd071ed4 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 9c558789ed..5561a812a5 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 28082c1d7e..dd99839d22 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 c7a2844e7b..8cb4be14c4 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 553ac68b0f..04d4beac68 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 18a20bf647..a213d04870 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 4922040764..b8fbd4aba1 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 2038261475..1876dd8ea4 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 daa1a0e113..4a95b10ab1 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 67bb003e09..16512e3550 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 9907f802b8..5b3c890324 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 9ceef9972d..0a8018e11d 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 212c15cc00..97bc7682ab 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 7fe7b5eaaa..4594f99dfb 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 c52627176e..95161b66b4 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 634bf6f367..7bf4e11fa5 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 9f0899a97a..2b7bc5395e 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 5e98d130c4..faf34323b5 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 db13f24035..b6d41904c3 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 0e60c92dc4..fc1591737d 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 3c75968af6..e476279fe2 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 47ed058686..9811de0838 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 08656d482c..099e8508da 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 8573de0223..96123bd58f 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 84ee848e5a..eb5b72dd38 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 7896650ace..08fb36aea6 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 5a3e030e74..3faa7cb2af 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 7eb37c1b5d..92d131565c 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 8b8395460f..adc7052c34 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 6350167a30..3a01182152 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 8c2ffc7b9b..61d96ccee3 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 81f986a132..10ea1a601e 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 64133b7200..305b8f1471 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 50b48d3726..4deee7bd01 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 17df4e78cc..878997c620 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 b3d859f53f..c58a4eeed3 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 6057fb57c9..a9320e0217 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 e265d7bf00..87e34a3a9b 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 fa84c1b241..a12d47bfb6 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 8701cea400..d95a3adfe1 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 6ec5d19672..b5e5a610b0 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 7f3e99d4c7..1936e5af68 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 867485f5cd..97a8508859 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 3d41938a4c..366f0d52fc 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 6776d23af2..62a27c97af 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 2235c9c8a8..50fa72e00d 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 0d02a8314b..b2d94a8dae 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 5cd76416fe..c9cab5456b 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 b93c7a7af6..e6474b4074 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 55a5cd1825..c20222a6cc 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 97ba6440ac..c035103717 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 71368d3132..60f8ad1485 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 c1b663ec89..8ce0748cc5 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 16a9cfc987..091f34e144 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 2254cba4b6..61a757ba8a 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 f69bd601d1..6fb471106d 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 2a6d073799..fc8d4ce526 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 f40dd62b16..12a93fd585 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 aec746a2d4..ef89f42a10 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 773cc5342c..88c6b98e8e 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 5c52332b03..a43ff68340 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 d55bb712a8..405d41877b 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 754b05eeaa..9b6b77aa51 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 5a0eaaab04..a94c2a8162 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 954270e0c9..653996083e 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 49cb2e57c2..0261137067 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 8f95a29a82..55683eaba8 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 4091e61bc2..c2398943d8 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 a8ba2b699e..6ef5d16171 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 abae530bb5..417e037f03 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 ca3b5fd6a9..de7931a649 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 e0e6a928f5..71effdee80 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 e913301433..950bb3e5fd 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 d74f5939a6..4772ee9172 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 6445292f6a..ed432b0704 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 0a6ca44e9e..b467823ddc 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 16718adf47..e19ae85288 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 eebd53d974..9bd8f0d1b7 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 3175d251ce..1efcf601de 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 9d47a79262..8cac1f8c39 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 d6d3e4c894..809c523dcf 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 650eb62979..cc9cb9476b 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 b06864d2c2..944dbf8692 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 cd58048351..c31b18aca5 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 9165abed90..be3f66daf3 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 888f3624e1..a44fdf2f1a 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 9964ff90e9..5077404466 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 62e9ab84a5..3b9c37486d 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 c8eb7de85b..d2bac1e9dd 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 1040f0c65c..a8b45af313 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 8937896cf6..f2703e2b80 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 c731389f8e..49d577ce3e 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 469dca5da7..dc7458789b 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 d8c45dfe27..54fb75b66c 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 4daf1c0cd4..970a1c11ce 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 9a70d049e0..96a9294a4b 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 697b74325f..cdbc395fe5 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 53479f563d..6be3753d8b 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 fe4fd9de10..e739458c94 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 9093bc6ef9..e0d0b67e43 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 6078c95e13..fa433586a2 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 3782982aa2..bcdd9a4317 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 39a5806417..7ec96651da 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 ffcd644ebe..0ff4c680ec 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 97a7a9a90e..1a8fc2ea8f 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 3b02828f49..7733d81210 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 519b67c0c4..ea3a5b4348 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 763eca4e8a..2f66a7403f 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 50525f9ea4..638d389f56 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 e62b4e58fe..1f3b13094f 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 010f712392..d9d09696e0 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 02aedb0870..00962367ef 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 bdd1790a5c..d0a2321792 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 e5f450447c..ed4b43feaa 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 07bd429d14..1e3d4ef223 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 c6bde581d7..c15668ebf5 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 7da3e65e98..bb598bcb76 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 9d5fba2fdd..3e592825a7 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 5e584d8979..1ae19f0bea 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 3dc48b7713..c2391fb963 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 1d9c778f46..7082db2ca2 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 0e6d100994..5854810d36 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 dd55ef635e..fe3c26f01d 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 d31f25d1a5..10aeb21a34 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 095af81060..a86169c8b6 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 d9e6992477..0fab215976 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 73752dda68..1f105d8cdb 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 fa7f1aecb1..39e601fd31 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 eb394a87fe..03a39cd9e7 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 1068d1098e..15c18368f8 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 cc31c3ca9f..0e30c1f729 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 ff6a070e66..bf74306bfc 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 f1412d7474..7e0f99ec6d 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 e722496841..5e5d4eca7c 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 66100a30a5..3768908e00 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 42c1476c20..6c1225079c 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 e991c67c95..76cc225682 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 1ec144ba1a..150e644ea4 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 c60da1ff54..c2e8d935cf 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 a259c07c57..faa3482efc 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 f8aadd74d0..c4be8d5da2 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 6492ad37d5..fea01b88f1 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 e03c3466d2..2ca0fcbada 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 85041f99bc..1d0aafd26f 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 d24652f655..4f9e7e42d1 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 ce3a110a47..55665b7ea7 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 820aa29c5d..409c5cc428 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 6829b96619..40cf936b74 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 b4db274308..585e181bca 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 a4658d29d2..3330d05239 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 48a7bf7249..1acab3a8a8 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 bbb0012c37..c303382f9b 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 00f0082ed6..695c318c2f 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 5884e0a2c6..757c8c180e 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 2960cc081e..b75300dc09 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 2de94fd75c..f11729adef 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 ecea6ef79f..b78a667e19 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 e48cb0e719..9219025cc4 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 6017c01684..8880e4a778 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 0c844b1fb9..874a7ea419 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 74c0cfde17..b2e9806fad 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 17ab6c249c..f2bd97981d 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 07545f4038..f65280b8b7 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 bc6dc2bd9f..f77f0f85cf 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 96e4591383..9f87d4b379 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 ed7a11167b..5706787cd0 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 7a98126909..a421453477 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 c9581bd37b..638332ddf9 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 2fd3bf091d..3bc3b13df9 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 fe33876964..986bf89ace 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 231802f21c..819a14a8ab 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 272ce176e9..cf1fb6058b 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 5b3ecbfb87..3e8b754dd7 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 5adb892dd2..f79bed7e07 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 d0e80194b1..a1ec00abc2 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 033c1dded9..dfc822c86b 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 3fe985766c..2fd3a5a0c6 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 3dad57023c..238293d5ef 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 3c9103038b..000439a0d8 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 54dd90ed99..97b3b5ac5b 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 140c949e86..75a4cb872c 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 0635da66fa..98c268e12e 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 5b776438c9..4d05a8e047 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 a4e876b314..371f7dc470 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 bbc40baf81..5fc5bd02ed 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 a9df11c977..43c6be6faa 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 fb9cd90a02..35eab2f1e8 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 d06a777f87..9898794b40 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 add62cbde3..0a05ad9eae 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 a28e7b73e5..fa437011f9 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 460e808356..ac7082adbf 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 36a2519554..6bbcf304b4 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 0859cc1072..8a289b845e 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 3f9bff48a5..0607c4bf2c 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 46445b1bb0..2af4f46632 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 539d2e9e38..b47213da75 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 d229d5ee0b..c67ccea5c4 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 b70b6bc12f..d2032192c3 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 6a71e03b92..3973d45283 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 0481ff5e2d..677bba74fe 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 92325a62e7..df9f9c4f00 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 73f6a9b9ab..154bd3ba40 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 77b302477f..5475ae2815 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 34182c5f2b..6273f1d8a7 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 ab1574f3c9..6f7543b1b2 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 97c54e7aeb..f940c6052b 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 169f35ba49..5e7f510a82 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 8ab481d6cb..43b8c5851d 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 698a517306..60c8c7e9a8 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 ac12f8bd1f..292730704b 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 bb11dda134..95f8137ea3 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 7efe3290e2..d125fa816b 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 55a261a1cc..de0081b3a9 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 00f674354e..a8926fe939 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 294dc99500..7105e9ecf2 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 a772700e32..3f01ab8559 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 7530d8e444..0f5199892a 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 1b03fcd674..0ab15a1372 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 3880c1e360..f77751a618 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 020639b9e2..7f60ef0ea9 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 14ab997dfd..4f4f0dc32b 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 a2116529d0..60586d2ec5 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 6070adb20b..3c4019d366 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 c907384f86..faa56cc11f 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 08b1925ea5..684a460b8a 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 6778f92dec..eb15fb481e 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 09485c0f2e..494e2445a1 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 8a953ffcaf..1823e96690 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 98b006941e..bbda48dd20 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 7ed92d80de..e282bba7cf 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 b55108a7f0..efcf1b4aa3 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 42d59d4c49..ebb1161451 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 9d89a00970..932f811ed4 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 d3da92d405..e0a425c6b6 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 a7a5145434..b230cd2d38 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 30586ee8a0..d8994e88c9 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 7055145cfe..86e3b471a7 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 f4c47b7131..f858d0f3f6 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 c6fd63a284..c394a1f76a 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 920e2af2ac..ae085b00d9 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 0d1da1b0c1..fe13718554 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 c5c4924eb3..9a0cdf4f59 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 fc6e2ce656..72344daa33 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 41b45d813a..fd9ca62c27 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 368d766847..28d741c79c 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 ae84fc91c4..4234d3c2b7 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 412165fc7c..22bd0990bf 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 a0d0287327..fa27dad2a4 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 8610a4b495..cd27cc69ef 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 f1b28ac3f5..6ea8a2215b 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 c7dfd250a1..4980ddad61 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 952035d322..023dc28d4d 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 7ab2d1848e..0236a5d4d9 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 958f43da80..ef76391003 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 23e5ed2d50..4f3618a76e 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 8c71300c20..09e96634c7 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 6fc1a2c838..bc1cca8d96 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 b5d444cc3b..9077602a4d 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 53efdc1d0c..1f15eec90e 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 eebc92cabe..4284c87d60 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 8bc887068b..4dbab48ff1 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 6e9a288080..df312dc1e0 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 6cf2fed810..f5cf5d200a 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 9e6a2df856..2d3f6c1681 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 6dec88bd29..0a37ac7504 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 4e5404aa66..f9f2f0093f 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 7515f60d40..ae8a865ad1 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 74a0413b2a..43b92ed53b 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 d290d59387..cb3e0dc1dc 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 be81164a03..e0f1cf55ce 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 eb794ed27e..37ec22a3f7 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 c8d6a604f9..f3ecc5d34e 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 576f5f5b53..f7f3781ed9 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 eac7616337..0abe4eddbc 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 44f428edfb..fadd193628 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 51094e1257..cd38a496ba 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 e034d24ca4..0dca0e1888 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 abf277f67d..207c36e233 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 35669055b1..c784dc853b 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 10b5dd1ab8..7d6d6130f6 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 38fbb9a77c..d12b54744c 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 8ee915d74b..583d9130f1 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 ac975081b1..4347f99380 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 972c333812..0ecfc1e7d0 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 b0b0445076..01d2c6ef9c 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 29add6f195..f0016fa439 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 59d4541ca4..1551183f14 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 396713ef4a..b83208654b 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 7c66e3013b..40e509fa89 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 51c9516fa5..f310b75a6e 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 0012166b4e..a15956ce11 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 489b6a8670..c64f2cd106 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 a8d55db668..5d29bee6d1 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 a96d6f4eb0..aabe0021b4 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 d073357ff4..f2a833bc7c 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 4c1ae1be97..34e21dc410 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 5a0c699d01..5b813b8599 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 f119388f3d..c6dfd5d8a9 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 cfd72d61cf..af9f61a3fa 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 a8ef335d65..f6ef345bd9 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 b2837b5542..86cc115422 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 1f2265bf6f..05387ee2ec 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 6e090a7d7b..7ccda8e875 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 69e2ebe4d4..97fbed7d1e 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 eb34784171..a17c678b78 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 58d3353493..9a1e5e991d 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 c20ed94141..31b95b0de5 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 4626bbe1ed..1906c74788 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 384db1a7c4..eae8fad0e0 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 a24656331c..c0143355c1 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 c4a3700e0f..2bfbbed59e 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 d090d8ac50..9303605a99 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 87b1fe425e..0afde23461 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 8c8f9cc9a8..57f5fbc255 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 a4130d67bb..90ad3e16ff 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 2ab9b00e06..94492da248 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 2491ed6595..cf7b5b03ec 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 03ba506714..3aacb80c0a 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 7005ecb79e..c1259179ef 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 21f8781299..0844fddd84 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 561fefb066..161237edcd 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 42ba9b2f11..f87c14ccc8 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 52f911ae20..0028b1c3be 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 1a614d6c58..178f12d4df 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 f7aa2df526..79983a7c81 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 c84c825a13..2a9eceea64 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 e7b4b08078..8fbf4a939d 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 2bf8e0b071..ee440d5655 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 1c55daaa53..c759ca0b50 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 3b27e7e8a7..ebf40aeca3 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 bac3e81d82..72606e7552 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 6eb9351c02..4519ce6383 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 e670f1ee65..3016f82d97 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 ecbe99b5c2..87e9978f09 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 27ea0f4ed5..17e04d80a7 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 4003a9c108..2112a2a3c2 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 24c25a5023..66f101d322 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 a64a5bd29e..7c49ff3059 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 57ed292b73..6bdf4ab2ff 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 5b5cfe849b..a15906884c 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 fae665dc3c..9975a818c3 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 837d3ddbcc..a9f107254e 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 79273611dd..e04284ca89 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 4534b3f826..6dc2776c2a 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 2caa1bddec..878b5c5d96 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 6162e1cb1b..24dc73ad7a 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 03c4dbb9a8..c93e8df89d 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 06b6dc0aa4..1427e6ec50 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 03a448dd74..4bc6b18236 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 533f5fda3c..60e315e8db 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 dc6b94dccf..1226ec701c 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 cde1656cd9..a64d261a5a 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 662cb92df2..c59e9ac219 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 3516588f79..ab79c7adab 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 f4416ca307..2a83c32293 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 3cf1b25348..0fb388a35e 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 2fca5dc723..5583fec541 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 aed680682e..7035a670a6 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 1ee479be30..4e059c8798 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 6625cbcf5a..5738877ca1 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 4c8dae7633..1885efd94c 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 e73a76ae8c..8c594cb654 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 920951e861..b67e13fca9 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 9ae004e806..96cb092772 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 e267719a83..7dedc2c6fa 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 26a003c2e3..e3d7e4c430 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 f6cc03360c..4d4ca9758a 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 687d29bddc..5828e3d1e7 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 66c47f112c..20ffd4e1bc 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 c39eb5e59e..7a3a796b52 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 1766fac71f..ed4aa8a013 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 4e85601056..4a8fb1ef1b 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 db582355f4..462932bd20 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 74db8ee41a..08ef7bdb26 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 7fddd7d2df..a90f49f204 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 ec279e6e07..cf5f802987 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 d03276a233..d49877b605 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 f0b28fef1d..e25e38b2c3 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 8be3fd6a6f..ad5a389ddc 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 710a764a06..ed11d3f747 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 f1dd6e8886..4e3f5d9a3b 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 3ea2e5ef98..6597fa25c3 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 e1e74caebc..e2d96a971b 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 0d2e815fc6..1bee524852 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 64b146b487..5d9efe6107 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 582741f866..b9dc070d18 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 429199a830..5355ac59f9 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 39e9a31056..3c0d22b35d 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 f0279c3bd6..34d7b15dd0 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 966f289d73..e5a771ace5 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 01370c9a40..783582b20d 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 996999bea2..0e94d5d8c1 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 008649f3b9..0f47c02a97 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 43be207334..5bd02b87d9 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 4f15841c9d..66260d6a16 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 a7b197bf5f..7a2834872f 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 fc2ac4fa62..5ca9f9745b 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 e71f9a0092..136885b2af 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 ee661da390..3549cf4bba 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 0ca38e2236..111f1fafb2 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 3200b237a2..74d574c512 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 f50e6ed033..4c6693a6bc 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 858e599a0f..5bcdbe5479 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 1e600ef6a1..7728478e72 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 a612c8c764..c3842bd702 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 7db5ed9ee0..310acc7417 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 62f1dcd653..bda1b1b760 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 4a180a0d8e..e56eb5699e 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 12a3bc6c91..d2a7aee871 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 799f382e28..a12d9f1145 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 ade4239d38..789b950099 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 644146b9eb..a2250746ea 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 00a2a66c35..04c1dd52f5 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 e0c7e71c4c..6ab1abfce9 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 5651b97a39..460b51feb3 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 da8205126d..ed580960ad 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 af45a414ca..88754b2a4d 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 cc28808650..c63ae12e56 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 d01372ed09..81170d3084 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 0bf60ac333..3b535eb82e 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 2d31b7babb..c3c2e26a12 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 bceb904192..b7f47d6e49 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 14bb7b81b5..30ecf3e627 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 d9ba0f46b1..9df5e7e4de 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 ddddad1ea7..d2b0de81ae 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 9b2bb80720..21ddc2d2a6 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 7badc6169c..968e904fc8 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 f595bd2f0a..7d5dcc22f2 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 907bb79ed9..5ca1dd8649 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 bfc53f8235..13a2b76e2e 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 52648cd97a..f1ed5ac211 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 aeb16428fb..944ddeb46d 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 b0dc1e2f6a..6eb1e2e2be 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 6a301ca1fa..d6fadf83bb 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 ad9bc475e0..4bbdb88373 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 1416d8424e..a0c104a902 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 93e68b6cf9..c34ded5d79 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 b41555ffa2..3bc91c5391 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 33417976bb..af080eefca 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 d4eba4f3b1..e8651529d1 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 112641a6e9..1f9d6dfc9f 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 c45287a05c..91e37a5b4f 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 97d17beabd..70be8489df 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 795839bf29..b5d5b721cd 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 a44c82c6ab..b99721ffb2 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 b58782c0cb..c7cfabeba3 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 06860e896f..7deb9540db 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 c1d879e9fd..323619be91 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 120dcff62e..7fc3c39909 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 99c90c18a8..c3ed32e521 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 d4c502ca2c..b336f8ebe4 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 54991d6b9c..4f5cc64b13 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 0a47deecd6..21492db13a 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 7daa4e355a..52d2ca6bf0 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 d341321902..3c21832da7 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 173c5d53a3..6166a509e5 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 52982940c2..a002481067 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 ec601288a2..c25d6d793b 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 2738e68a5b..78abd86a98 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 19dd023810..330a102258 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 469d80311a..d04abf5b70 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 6c8e6d6102..70b7f8430b 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 dcd4a57252..42a474f979 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 4f55aacb73..16f80135c1 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 5c739c2141..937f7b33cb 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 dbabaf7689..de1c6c36f4 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 da8da0fd91..bc187f1bfd 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 63a1a84558..5c4c760414 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 9a7a7b6233..b3a773b289 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 809d3a855b..7bbe7ecc30 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 3e969057f0..4ac4c2cc51 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 81e6a0b484..1e0100e162 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 505e5f04fc..98e2c88c5e 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 e4aacbf1a8..e04ef1a2d3 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 3b0cc35034..82779cb498 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 75edeecb2a..3f139ea5a8 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 e1fde29158..cd2c8e8e06 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 58842fee32..fab7124753 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 d6c2cfd392..de02533990 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 f35beef723..c0aa7c9d1d 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 299de7d705..f2ff179616 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 52b57c5444..dc52fd84b7 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 aae48df6f4..33c87cf37f 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 fcfb96eb26..e821c6bfec 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 ed30f3b755..7ccbf59d41 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 daa7960da2..54ba72498f 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 30360cda2a..86057f3544 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 75c27cf4bd..97ad421f69 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 5dc0e5d358..6b557daa1c 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 f4ff8b3599..19e8cf82eb 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 848acddf41..5f64ee7f20 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 b4f16435fc..3bd3aeb7f7 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 ed6ea96135..582105114e 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 be7d2f955d..d3b120f610 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 718de062bf..ac128cab8a 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 f42b4fefd5..e63547ba72 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 d64964c339..82e8a8db17 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 597ed1c6f0..1e8164d85b 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 f8b1e8e562..b52dc0e4fb 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 fc8dde08a0..3336e09b50 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 396ff0fa51..278485fe7a 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 a5c209fb38..2e4246840a 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 40a2a5b6f2..3348ad4623 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 ddb99d9c53..0fd1533217 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 7426e33714..4acbe0b473 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 2d5421bdd5..946a1866d3 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 73801b62dc..5c2eb62099 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 e12d905c18..59d2e65b23 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 90c0eaec40..fcfeffd222 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 ca468f978d..6a67b148c8 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 36231e1840..a18d1c981e 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 1a4a2cb090..0792f80462 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 9af0c2ea14..7da38a7139 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 b2bbbae781..050b14bb8c 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 a2ee1b2275..d018f40efb 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 097f89fed1..d2347c0f8c 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 78bb52983a..444b22e59a 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 f18bb9b7ce..ad1fcf7a91 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 970adaad05..7d121e99f6 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 82b1f5dd4f..070fb76a8c 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 d58fba1c7b..ec6eb5dd47 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 954a652fb8..f101661e62 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 620a80a6f4..31a93b23be 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 1dda17c8a2..ede5fd0455 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 8b527b649c..e37bb48d6f 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 9583891aab..33efc947ff 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 7d48c43677..39c6f9d051 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 8a5dbce44f..3842513430 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 dbb28f7a47..7962c0a102 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 11a34e5a31..285e2bf115 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 0b84164166..5922810364 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 5778203e25..9e0d1da410 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 d8a9aa9d11..fc6863a38c 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 4d95198829..b799518a78 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;