docs: document outbound channel resolution · openclaw/openclaw@fc1848a
steipete
·
2026-06-05
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Covers lazy outbound channel bootstrap, retry guards, auto-enable config, and |
| 2 | +// send-capable active registry short-circuiting. |
1 | 3 | import { afterEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import type { OpenClawConfig } from "../../config/types.openclaw.js"; |
3 | 5 | import { createEmptyPluginRegistry } from "../../plugins/registry-empty.js"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Outbound channel bootstrap lazily loads runtime plugins for selected channels |
| 2 | +// when only setup-shell metadata is active. |
1 | 3 | import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../../agents/agent-scope.js"; |
2 | 4 | import { applyPluginAutoEnable } from "../../config/plugin-auto-enable.js"; |
3 | 5 | import type { OpenClawConfig } from "../../config/types.openclaw.js"; |
@@ -42,6 +44,8 @@ export function bootstrapOutboundChannelPlugin(params: {
|
42 | 44 | if (bootstrapAttempts.has(attemptKey)) { |
43 | 45 | return; |
44 | 46 | } |
| 47 | +// Retry once per registry version/channel; failed loads clear the guard below |
| 48 | +// so config fixes in the same process can try again. |
45 | 49 | bootstrapAttempts.add(attemptKey); |
46 | 50 | |
47 | 51 | const autoEnabled = applyPluginAutoEnable({ config: cfg }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Verifies outbound channel resolution fast paths, active-registry reads, |
| 2 | +// bootstrap fallback, and runtime facade projection. |
1 | 3 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | |
3 | 5 | const resolveDefaultAgentIdMock = vi.hoisted(() => vi.fn()); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Channel resolution exposes read-only outbound runtime facades and performs |
| 2 | +// optional bootstrap for deliverable channels that are not loaded yet. |
1 | 3 | import type { ChannelMessageAdapterShape } from "../../channels/message/types.js"; |
2 | 4 | import { getChannelPlugin, getLoadedChannelPlugin } from "../../channels/plugins/index.js"; |
3 | 5 | import { channelPluginHasNativeApprovalPromptUi } from "../../channels/plugins/native-approval-prompt.js"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Covers message channel selection from explicit input, tool context fallback, |
| 2 | +// configured accounts, and missing official external plugin repair hints. |
1 | 3 | import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | |
3 | 5 | const mocks = vi.hoisted(() => ({ |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Channel selection chooses a deliverable message channel from explicit input, |
| 2 | +// tool context fallback, or configured plugin accounts. |
1 | 3 | import { listChannelPlugins } from "../../channels/plugins/index.js"; |
2 | 4 | import type { ChannelPlugin } from "../../channels/plugins/types.plugin.js"; |
3 | 5 | import type { OpenClawConfig } from "../../config/types.openclaw.js"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Covers directory cache key dimensions, TTL expiration, config invalidation, |
| 2 | +// recency refresh, bounded eviction, and matching clears. |
1 | 3 | import { describe, expect, it, vi } from "vitest"; |
2 | 4 | import type { OpenClawConfig } from "../../config/config.js"; |
3 | 5 | import { DirectoryCache, buildDirectoryCacheKey } from "./directory-cache.js"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Directory cache stores short-lived channel directory lookups and invalidates |
| 2 | +// them on config-object changes or resolver signature updates. |
1 | 3 | import type { ChannelDirectoryEntryKind, ChannelId } from "../../channels/plugins/types.public.js"; |
2 | 4 | import type { OpenClawConfig } from "../../config/types.openclaw.js"; |
3 | 5 | import { resolveNonNegativeIntegerOption } from "../numeric-options.js"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Covers outbound target resolver id heuristics, directory cache/live fallback, |
| 2 | +// ambiguity modes, display formatting, and plugin normalized fallbacks. |
1 | 3 | import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 4 | import type { ChannelDirectoryEntry } from "../../channels/plugins/types.js"; |
3 | 5 | import type { OpenClawConfig } from "../../config/config.js"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Target resolver combines plugin id heuristics, cached directory searches, |
| 2 | +// live fallback lookups, and normalized fallback targets. |
1 | 3 | import { normalizeLowercaseStringOrEmpty } from "@openclaw/normalization-core/string-coerce"; |
2 | 4 | import { getChannelPlugin } from "../../channels/plugins/index.js"; |
3 | 5 | import type { |
@@ -295,6 +297,8 @@ async function getDirectoryEntries(params: {
|
295 | 297 | directoryCache.set(cacheKey, entries, params.cfg); |
296 | 298 | return entries; |
297 | 299 | } |
| 300 | +// Empty cached directory results may be stale; live lookup gets one chance |
| 301 | +// before both live and cache keys are updated. |
298 | 302 | const liveKey = buildDirectoryCacheKey({ |
299 | 303 | channel: params.channel, |
300 | 304 | accountId: params.accountId, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。