mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 21:21:10 +00:00
fix(runtime): split approval and gateway client seams
This commit is contained in:
@@ -5,9 +5,9 @@ import { AgentSideConnection, ndJsonStream } from "@agentclientprotocol/sdk";
|
||||
import { loadConfig } from "../config/config.js";
|
||||
import { resolveGatewayClientBootstrap } from "../gateway/client-bootstrap.js";
|
||||
import { GatewayClient } from "../gateway/client.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../gateway/protocol/client-info.js";
|
||||
import { isMainModule } from "../infra/is-main.js";
|
||||
import { normalizeOptionalString } from "../shared/string-coerce.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
|
||||
import { readSecretFromFile } from "./secret-file.js";
|
||||
import { AcpGatewayAgent } from "./translator.js";
|
||||
import { normalizeAcpProvenanceMode, type AcpServerOptions } from "./types.js";
|
||||
|
||||
@@ -6,12 +6,12 @@ import {
|
||||
resolveLeastPrivilegeOperatorScopesForMethod,
|
||||
type OperatorScope,
|
||||
} from "../../gateway/method-scopes.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../gateway/protocol/client-info.js";
|
||||
import { formatErrorMessage } from "../../infra/errors.js";
|
||||
import {
|
||||
normalizeLowercaseStringOrEmpty,
|
||||
normalizeOptionalString,
|
||||
} from "../../shared/string-coerce.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../utils/message-channel.js";
|
||||
import { readStringParam } from "./common.js";
|
||||
|
||||
export const DEFAULT_GATEWAY_URL = "ws://127.0.0.1:18789";
|
||||
|
||||
@@ -3,12 +3,12 @@ import {
|
||||
resolveChannelApprovalCapability,
|
||||
} from "../../channels/plugins/index.js";
|
||||
import { callGateway } from "../../gateway/call.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../gateway/protocol/client-info.js";
|
||||
import { logVerbose } from "../../globals.js";
|
||||
import { isApprovalNotFoundError } from "../../infra/approval-errors.js";
|
||||
import { resolveApprovalCommandAuthorization } from "../../infra/channel-approval-auth.js";
|
||||
import { formatErrorMessage } from "../../infra/errors.js";
|
||||
import { normalizeLowercaseStringOrEmpty } from "../../shared/string-coerce.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../utils/message-channel.js";
|
||||
import { resolveChannelAccountId } from "./channel-context.js";
|
||||
import { requireGatewayClientScopeForInternalChannel } from "./command-gates.js";
|
||||
import type { CommandHandler } from "./commands-types.js";
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
getActivePluginChannelRegistryFromState,
|
||||
getPluginRegistryState,
|
||||
} from "../plugins/runtime-state.js";
|
||||
import { getActivePluginChannelRegistryFromState } from "../plugins/runtime-channel-state.js";
|
||||
import {
|
||||
normalizeOptionalLowercaseString,
|
||||
normalizeOptionalString,
|
||||
@@ -32,7 +29,7 @@ function listRegisteredChannelPluginEntries(): RegisteredChannelPluginEntry[] {
|
||||
if (channelRegistry && channelRegistry.channels && channelRegistry.channels.length > 0) {
|
||||
return channelRegistry.channels;
|
||||
}
|
||||
return getPluginRegistryState()?.activeRegistry?.channels ?? [];
|
||||
return [];
|
||||
}
|
||||
|
||||
function findRegisteredChannelPluginEntry(
|
||||
|
||||
@@ -17,6 +17,7 @@ import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import { callGateway, randomIdempotencyKey } from "../gateway/call.js";
|
||||
import { buildGatewayConnectionDetailsWithResolvers } from "../gateway/connection-details.js";
|
||||
import { isLoopbackHost } from "../gateway/net.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../gateway/protocol/client-info.js";
|
||||
import { generateImage, listRuntimeImageGenerationProviders } from "../image-generation/runtime.js";
|
||||
import { buildMediaUnderstandingRegistry } from "../media-understanding/provider-registry.js";
|
||||
import {
|
||||
@@ -54,7 +55,6 @@ import {
|
||||
setTtsProvider,
|
||||
textToSpeech,
|
||||
} from "../tts/tts.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
|
||||
import { generateVideo, listRuntimeVideoGenerationProviders } from "../video-generation/runtime.js";
|
||||
import {
|
||||
isWebFetchProviderConfigured,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import { resolveSecretInputRef } from "../config/types.secrets.js";
|
||||
import { callGateway } from "../gateway/call.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../gateway/protocol/client-info.js";
|
||||
import { validateSecretsResolveResult } from "../gateway/protocol/index.js";
|
||||
import { formatErrorMessage } from "../infra/errors.js";
|
||||
import { resolveManifestContractOwnerPluginId } from "../plugins/manifest-registry.js";
|
||||
@@ -19,7 +20,6 @@ import {
|
||||
type DiscoveredConfigSecretTarget,
|
||||
} from "../secrets/target-registry.js";
|
||||
import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
|
||||
|
||||
type ResolveCommandSecretsResult = {
|
||||
resolvedConfig: OpenClawConfig;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { Command } from "commander";
|
||||
import { buildGatewayConnectionDetails, callGateway } from "../gateway/call.js";
|
||||
import { isLoopbackHost } from "../gateway/net.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../gateway/protocol/client-info.js";
|
||||
import {
|
||||
approveDevicePairing,
|
||||
formatDevicePairingForbiddenMessage,
|
||||
@@ -17,7 +18,6 @@ import {
|
||||
} from "../shared/string-coerce.js";
|
||||
import { getTerminalTableWidth, 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 = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Command } from "commander";
|
||||
import type { OpenClawConfig } from "../../config/types.openclaw.js";
|
||||
import { callGateway } from "../../gateway/call.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../utils/message-channel.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../gateway/protocol/client-info.js";
|
||||
import { withProgress } from "../progress.js";
|
||||
|
||||
export type GatewayRpcOpts = {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { callGateway } from "../gateway/call.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../gateway/protocol/client-info.js";
|
||||
import type { GatewayRpcOpts } from "./gateway-rpc.types.js";
|
||||
import { withProgress } from "./progress.js";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { callGateway } from "../../gateway/call.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../utils/message-channel.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../gateway/protocol/client-info.js";
|
||||
import { withProgress } from "../progress.js";
|
||||
import type { NodesRpcOpts } from "./types.js";
|
||||
|
||||
|
||||
@@ -6,14 +6,11 @@ import { withProgress } from "../cli/progress.js";
|
||||
import { loadConfig } from "../config/config.js";
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import { callGateway, randomIdempotencyKey } from "../gateway/call.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../gateway/protocol/client-info.js";
|
||||
import { normalizeAgentId } from "../routing/session-key.js";
|
||||
import { type RuntimeEnv, writeRuntimeJson } from "../runtime.js";
|
||||
import { normalizeOptionalString } from "../shared/string-coerce.js";
|
||||
import {
|
||||
GATEWAY_CLIENT_MODES,
|
||||
GATEWAY_CLIENT_NAMES,
|
||||
normalizeMessageChannel,
|
||||
} from "../utils/message-channel.js";
|
||||
import { normalizeMessageChannel } from "../utils/message-channel.js";
|
||||
import { agentCommand } from "./agent.js";
|
||||
import { resolveSessionKeyForRequest } from "./agent/session.js";
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import { resolveMessageSecretScope } from "../cli/message-secret-scope.js";
|
||||
import { createOutboundSendDeps, type CliDeps } from "../cli/outbound-send-deps.js";
|
||||
import { withProgress } from "../cli/progress.js";
|
||||
import { loadConfig } from "../config/config.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../gateway/protocol/client-info.js";
|
||||
import type { OutboundSendDeps } from "../infra/outbound/deliver.js";
|
||||
import { runMessageAction } from "../infra/outbound/message-action-runner.js";
|
||||
import { type RuntimeEnv, writeRuntimeJson } from "../runtime.js";
|
||||
@@ -14,7 +15,6 @@ import {
|
||||
normalizeLowercaseStringOrEmpty,
|
||||
normalizeOptionalString,
|
||||
} from "../shared/string-coerce.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
|
||||
import { buildMessageCliJson, formatMessageCliText } from "./message-format.js";
|
||||
|
||||
export async function messageCommand(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
|
||||
import { resolveGatewayClientBootstrap } from "./client-bootstrap.js";
|
||||
import { GatewayClient, type GatewayClientOptions } from "./client.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "./protocol/client-info.js";
|
||||
|
||||
export async function createOperatorApprovalsGatewayClient(
|
||||
params: Pick<
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { formatErrorMessage } from "../infra/errors.js";
|
||||
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";
|
||||
import { READ_SCOPE } from "./method-scopes.js";
|
||||
import { isLoopbackHost } from "./net.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "./protocol/client-info.js";
|
||||
|
||||
export type GatewayProbeAuth = {
|
||||
token?: string;
|
||||
|
||||
@@ -3,7 +3,7 @@ import type {
|
||||
ChannelApprovalNativeAvailabilityAdapter,
|
||||
ChannelApprovalNativeRuntimeAdapter,
|
||||
} from "./approval-handler-runtime-types.js";
|
||||
import type { ExecApprovalChannelRuntimeEventKind } from "./exec-approval-channel-runtime.js";
|
||||
import type { ExecApprovalChannelRuntimeEventKind } from "./exec-approval-channel-runtime.types.js";
|
||||
|
||||
export const CHANNEL_APPROVAL_NATIVE_RUNTIME_CONTEXT_CAPABILITY = "approval.native";
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import type {
|
||||
PendingApprovalView,
|
||||
ResolvedApprovalView,
|
||||
} from "./approval-view-model.types.js";
|
||||
import type { ExecApprovalChannelRuntimeEventKind } from "./exec-approval-channel-runtime.js";
|
||||
import type { ExecApprovalChannelRuntimeEventKind } from "./exec-approval-channel-runtime.types.js";
|
||||
import type { ExecApprovalRequest, ExecApprovalResolved } from "./exec-approvals.js";
|
||||
import type { PluginApprovalRequest, PluginApprovalResolved } from "./plugin-approvals.js";
|
||||
|
||||
|
||||
@@ -35,10 +35,8 @@ import type {
|
||||
PendingApprovalView,
|
||||
ResolvedApprovalView,
|
||||
} from "./approval-view-model.types.js";
|
||||
import type {
|
||||
ExecApprovalChannelRuntime,
|
||||
ExecApprovalChannelRuntimeEventKind,
|
||||
} from "./exec-approval-channel-runtime.js";
|
||||
import type { ExecApprovalChannelRuntime } from "./exec-approval-channel-runtime.js";
|
||||
import type { ExecApprovalChannelRuntimeEventKind } from "./exec-approval-channel-runtime.types.js";
|
||||
|
||||
export type {
|
||||
ApprovalActionView,
|
||||
|
||||
@@ -11,8 +11,8 @@ import {
|
||||
createExecApprovalChannelRuntime,
|
||||
type ExecApprovalChannelRuntime,
|
||||
type ExecApprovalChannelRuntimeAdapter,
|
||||
type ExecApprovalChannelRuntimeEventKind,
|
||||
} from "./exec-approval-channel-runtime.js";
|
||||
import type { ExecApprovalChannelRuntimeEventKind } from "./exec-approval-channel-runtime.types.js";
|
||||
import type { ExecApprovalResolved } from "./exec-approvals.js";
|
||||
import type { ExecApprovalRequest } from "./exec-approvals.js";
|
||||
import type { PluginApprovalResolved } from "./plugin-approvals.js";
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import type { GatewayClient } from "../gateway/client.js";
|
||||
import { createOperatorApprovalsGatewayClient } from "../gateway/operator-approvals-client.js";
|
||||
import type { EventFrame } from "../gateway/protocol/index.js";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
import { formatErrorMessage } from "./errors.js";
|
||||
import type {
|
||||
ExecApprovalChannelRuntime,
|
||||
ExecApprovalChannelRuntimeAdapter,
|
||||
ExecApprovalChannelRuntimeEventKind,
|
||||
} from "./exec-approval-channel-runtime.types.js";
|
||||
import type { ExecApprovalRequest, ExecApprovalResolved } from "./exec-approvals.js";
|
||||
import type { PluginApprovalRequest, PluginApprovalResolved } from "./plugin-approvals.js";
|
||||
export type {
|
||||
ExecApprovalChannelRuntime,
|
||||
ExecApprovalChannelRuntimeAdapter,
|
||||
ExecApprovalChannelRuntimeEventKind,
|
||||
} from "./exec-approval-channel-runtime.types.js";
|
||||
|
||||
type ApprovalRequestEvent = ExecApprovalRequest | PluginApprovalRequest;
|
||||
type ApprovalResolvedEvent = ExecApprovalResolved | PluginApprovalResolved;
|
||||
|
||||
export type ExecApprovalChannelRuntimeEventKind = "exec" | "plugin";
|
||||
|
||||
type PendingApprovalEntry<
|
||||
TPending,
|
||||
TRequest extends ApprovalRequestEvent,
|
||||
@@ -24,42 +31,6 @@ type PendingApprovalEntry<
|
||||
pendingResolution: TResolved | null;
|
||||
};
|
||||
|
||||
export type ExecApprovalChannelRuntimeAdapter<
|
||||
TPending,
|
||||
TRequest extends ApprovalRequestEvent = ExecApprovalRequest,
|
||||
TResolved extends ApprovalResolvedEvent = ExecApprovalResolved,
|
||||
> = {
|
||||
label: string;
|
||||
clientDisplayName: string;
|
||||
cfg: OpenClawConfig;
|
||||
gatewayUrl?: string;
|
||||
eventKinds?: readonly ExecApprovalChannelRuntimeEventKind[];
|
||||
isConfigured: () => boolean;
|
||||
shouldHandle: (request: TRequest) => boolean;
|
||||
deliverRequested: (request: TRequest) => Promise<TPending[]>;
|
||||
beforeGatewayClientStart?: () => Promise<void> | void;
|
||||
finalizeResolved: (params: {
|
||||
request: TRequest;
|
||||
resolved: TResolved;
|
||||
entries: TPending[];
|
||||
}) => Promise<void>;
|
||||
finalizeExpired?: (params: { request: TRequest; entries: TPending[] }) => Promise<void>;
|
||||
onStopped?: () => Promise<void> | void;
|
||||
nowMs?: () => number;
|
||||
};
|
||||
|
||||
export type ExecApprovalChannelRuntime<
|
||||
TRequest extends ApprovalRequestEvent = ExecApprovalRequest,
|
||||
TResolved extends ApprovalResolvedEvent = ExecApprovalResolved,
|
||||
> = {
|
||||
start: () => Promise<void>;
|
||||
stop: () => Promise<void>;
|
||||
handleRequested: (request: TRequest) => Promise<void>;
|
||||
handleResolved: (resolved: TResolved) => Promise<void>;
|
||||
handleExpired: (approvalId: string) => Promise<void>;
|
||||
request: <T = unknown>(method: string, params: Record<string, unknown>) => Promise<T>;
|
||||
};
|
||||
|
||||
function resolveApprovalReplayMethods(
|
||||
eventKinds: ReadonlySet<ExecApprovalChannelRuntimeEventKind>,
|
||||
): string[] {
|
||||
|
||||
44
src/infra/exec-approval-channel-runtime.types.ts
Normal file
44
src/infra/exec-approval-channel-runtime.types.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import type { ExecApprovalRequest, ExecApprovalResolved } from "./exec-approvals.js";
|
||||
import type { PluginApprovalRequest, PluginApprovalResolved } from "./plugin-approvals.js";
|
||||
|
||||
type ApprovalRequestEvent = ExecApprovalRequest | PluginApprovalRequest;
|
||||
type ApprovalResolvedEvent = ExecApprovalResolved | PluginApprovalResolved;
|
||||
|
||||
export type ExecApprovalChannelRuntimeEventKind = "exec" | "plugin";
|
||||
|
||||
export type ExecApprovalChannelRuntimeAdapter<
|
||||
TPending,
|
||||
TRequest extends ApprovalRequestEvent = ExecApprovalRequest,
|
||||
TResolved extends ApprovalResolvedEvent = ExecApprovalResolved,
|
||||
> = {
|
||||
label: string;
|
||||
clientDisplayName: string;
|
||||
cfg: OpenClawConfig;
|
||||
gatewayUrl?: string;
|
||||
eventKinds?: readonly ExecApprovalChannelRuntimeEventKind[];
|
||||
isConfigured: () => boolean;
|
||||
shouldHandle: (request: TRequest) => boolean;
|
||||
deliverRequested: (request: TRequest) => Promise<TPending[]>;
|
||||
beforeGatewayClientStart?: () => Promise<void> | void;
|
||||
finalizeResolved: (params: {
|
||||
request: TRequest;
|
||||
resolved: TResolved;
|
||||
entries: TPending[];
|
||||
}) => Promise<void>;
|
||||
finalizeExpired?: (params: { request: TRequest; entries: TPending[] }) => Promise<void>;
|
||||
onStopped?: () => Promise<void> | void;
|
||||
nowMs?: () => number;
|
||||
};
|
||||
|
||||
export type ExecApprovalChannelRuntime<
|
||||
TRequest extends ApprovalRequestEvent = ExecApprovalRequest,
|
||||
TResolved extends ApprovalResolvedEvent = ExecApprovalResolved,
|
||||
> = {
|
||||
start: () => Promise<void>;
|
||||
stop: () => Promise<void>;
|
||||
handleRequested: (request: TRequest) => Promise<void>;
|
||||
handleResolved: (resolved: TResolved) => Promise<void>;
|
||||
handleExpired: (approvalId: string) => Promise<void>;
|
||||
request: <T = unknown>(method: string, params: Record<string, unknown>) => Promise<T>;
|
||||
};
|
||||
@@ -5,7 +5,7 @@ import { normalizeAnyChannelId } from "../../channels/registry.js";
|
||||
import { resolveStateDir } from "../../config/paths.js";
|
||||
import { loadJsonFile } from "../../infra/json-file.js";
|
||||
import { saveJsonFile } from "../../plugin-sdk/json-store.js";
|
||||
import { getActivePluginChannelRegistryFromState } from "../../plugins/runtime-state.js";
|
||||
import { getActivePluginChannelRegistryFromState } from "../../plugins/runtime-channel-state.js";
|
||||
import { normalizeOptionalLowercaseString } from "../../shared/string-coerce.js";
|
||||
import { normalizeConversationRef } from "./session-binding-normalization.js";
|
||||
import type {
|
||||
@@ -114,7 +114,10 @@ function resolveChannelSupportsCurrentConversationBinding(channel: string): bool
|
||||
if (!normalized) {
|
||||
return false;
|
||||
}
|
||||
const matchesPluginId = (plugin: { id: string; meta?: { aliases?: readonly string[] } | null }) =>
|
||||
const matchesPluginId = (plugin: {
|
||||
id?: string | null;
|
||||
meta?: { aliases?: readonly string[] } | null;
|
||||
}) =>
|
||||
plugin.id === normalized ||
|
||||
(plugin.meta?.aliases ?? []).some(
|
||||
(alias) => normalizeOptionalLowercaseString(alias) === normalized,
|
||||
|
||||
@@ -4,13 +4,13 @@ import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import { resolveGatewayClientBootstrap } from "../gateway/client-bootstrap.js";
|
||||
import { GatewayClient } from "../gateway/client.js";
|
||||
import { APPROVALS_SCOPE, READ_SCOPE, WRITE_SCOPE } from "../gateway/method-scopes.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../gateway/protocol/client-info.js";
|
||||
import type { EventFrame } from "../gateway/protocol/index.js";
|
||||
import { extractFirstTextBlock } from "../shared/chat-message-content.js";
|
||||
import {
|
||||
normalizeLowercaseStringOrEmpty,
|
||||
normalizeOptionalLowercaseString,
|
||||
} from "../shared/string-coerce.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
|
||||
import { VERSION } from "../version.js";
|
||||
import type {
|
||||
ApprovalDecision,
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { loadConfig, type OpenClawConfig } from "../config/config.js";
|
||||
import { GatewayClient } from "../gateway/client.js";
|
||||
import { resolveGatewayConnectionAuth } from "../gateway/connection-auth.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../gateway/protocol/client-info.js";
|
||||
import { loadOrCreateDeviceIdentity } from "../infra/device-identity.js";
|
||||
import type { SkillBinTrustEntry } from "../infra/exec-approvals.js";
|
||||
import { resolveExecutableFromPathEnv } from "../infra/executable-path.js";
|
||||
import { getMachineDisplayName } from "../infra/machine-name.js";
|
||||
import { NODE_EXEC_APPROVALS_COMMANDS, NODE_SYSTEM_RUN_COMMANDS } from "../infra/node-commands.js";
|
||||
import { ensureOpenClawCliOnPath } from "../infra/path-env.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 {
|
||||
|
||||
30
src/plugins/runtime-channel-state.ts
Normal file
30
src/plugins/runtime-channel-state.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
export const PLUGIN_REGISTRY_STATE = Symbol.for("openclaw.pluginRegistryState");
|
||||
|
||||
type RuntimeTrackedChannelRegistry = {
|
||||
channels?: Array<{
|
||||
plugin: {
|
||||
id?: string | null;
|
||||
meta?: {
|
||||
aliases?: readonly string[];
|
||||
markdownCapable?: boolean;
|
||||
} | null;
|
||||
conversationBindings?: {
|
||||
supportsCurrentConversationBinding?: boolean;
|
||||
} | null;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
|
||||
type GlobalChannelRegistryState = typeof globalThis & {
|
||||
[PLUGIN_REGISTRY_STATE]?: {
|
||||
activeRegistry?: RuntimeTrackedChannelRegistry | null;
|
||||
channel?: {
|
||||
registry: RuntimeTrackedChannelRegistry | null;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export function getActivePluginChannelRegistryFromState(): RuntimeTrackedChannelRegistry | null {
|
||||
const state = (globalThis as GlobalChannelRegistryState)[PLUGIN_REGISTRY_STATE];
|
||||
return state?.channel?.registry ?? state?.activeRegistry ?? null;
|
||||
}
|
||||
@@ -9,7 +9,11 @@ import {
|
||||
} from "../gateway/call.js";
|
||||
import { GatewayClient } from "../gateway/client.js";
|
||||
import { isLoopbackHost } from "../gateway/net.js";
|
||||
import { GATEWAY_CLIENT_CAPS } from "../gateway/protocol/client-info.js";
|
||||
import {
|
||||
GATEWAY_CLIENT_CAPS,
|
||||
GATEWAY_CLIENT_MODES,
|
||||
GATEWAY_CLIENT_NAMES,
|
||||
} from "../gateway/protocol/client-info.js";
|
||||
import {
|
||||
type HelloOk,
|
||||
PROTOCOL_VERSION,
|
||||
@@ -18,7 +22,6 @@ import {
|
||||
type SessionsPatchParams,
|
||||
} from "../gateway/protocol/index.js";
|
||||
import { formatErrorMessage } from "../infra/errors.js";
|
||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
|
||||
import { VERSION } from "../version.js";
|
||||
import type { ResponseUsageMode, SessionInfo, SessionScope } from "./tui-types.js";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user