mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
docs: document runtime config helpers
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* Projects enabled bundle MCP servers into Codex app-server thread config.
|
||||
* The projection keeps loopback approval defaults and header env placeholders
|
||||
* compatible with Codex's MCP config shape.
|
||||
*/
|
||||
import crypto from "node:crypto";
|
||||
import { normalizeOptionalLowercaseString } from "@openclaw/normalization-core/string-coerce";
|
||||
import {
|
||||
@@ -18,9 +23,6 @@ import type {
|
||||
} from "./codex-mcp-config.types.js";
|
||||
import { shouldCreateBundleMcpRuntimeForAttempt } from "./embedded-agent-runner/run/attempt-tool-construction-plan.js";
|
||||
|
||||
// Projects enabled bundle MCP servers into Codex app-server thread config.
|
||||
// The projection keeps loopback approval defaults and header env placeholders
|
||||
// compatible with Codex's MCP config shape.
|
||||
export type {
|
||||
CodexBundleMcpThreadConfig,
|
||||
CodexMcpServersConfig,
|
||||
@@ -64,6 +66,7 @@ function resolveCodexDefaultToolsApprovalMode(
|
||||
);
|
||||
}
|
||||
|
||||
/** Normalizes one bundle MCP server into Codex's mcp_servers shape. */
|
||||
export function normalizeCodexMcpServerConfig(
|
||||
name: string,
|
||||
server: BundleMcpServerConfig,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
/**
|
||||
* Exponential backoff helpers for command-output polling. Session diagnostics
|
||||
* use this state to slow no-output polls while resetting promptly on output.
|
||||
*/
|
||||
import type { SessionState } from "../logging/diagnostic-session-state.js";
|
||||
|
||||
// Exponential backoff schedule for command polling
|
||||
const BACKOFF_SCHEDULE_MS = [5000, 10000, 30000, 60000];
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
/**
|
||||
* Structured logging for model fallback decisions. The log payload carries
|
||||
* sanitized error observations plus step fields that make fallback chains
|
||||
* auditable.
|
||||
*/
|
||||
import { sanitizeForLog } from "../../packages/terminal-core/src/ansi.js";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
import { buildTextObservationFields } from "./embedded-agent-error-observation.js";
|
||||
import type { FailoverReason } from "./embedded-agent-helpers.js";
|
||||
import type { FallbackAttempt, ModelCandidate } from "./model-fallback.types.js";
|
||||
|
||||
// Structured logging for model fallback decisions. The log payload carries
|
||||
// sanitized error observations plus step fields that make fallback chains auditable.
|
||||
const decisionLog = createSubsystemLogger("model-fallback").child("decision");
|
||||
|
||||
/** Return whether fallback decision logging is enabled for warn-level events. */
|
||||
@@ -36,6 +39,7 @@ function buildErrorObservationFields(error?: string): {
|
||||
|
||||
type FallbackStepOutcome = "next_fallback" | "succeeded" | "chain_exhausted";
|
||||
|
||||
/** Structured fields that describe one fallback-chain transition. */
|
||||
export type ModelFallbackStepFields = {
|
||||
fallbackStepType: "fallback_step";
|
||||
fallbackStepFromModel: string;
|
||||
@@ -46,6 +50,7 @@ export type ModelFallbackStepFields = {
|
||||
fallbackStepFinalOutcome: FallbackStepOutcome;
|
||||
};
|
||||
|
||||
/** Input payload for logging one model fallback decision. */
|
||||
export type ModelFallbackDecisionParams = {
|
||||
decision:
|
||||
| "skip_candidate"
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
/**
|
||||
* Shared model-registry loader for agent paths that need auth storage and
|
||||
* plugin metadata resolved together before model discovery.
|
||||
*/
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import { discoverAuthStorage, discoverModels } from "./agent-model-discovery.js";
|
||||
import { resolveDefaultAgentDir } from "./agent-scope.js";
|
||||
import { resolveModelPluginMetadataSnapshot } from "./model-discovery-context.js";
|
||||
import type { ModelRegistry } from "./sessions/index.js";
|
||||
|
||||
// Shared model-registry loader for agent paths that need auth storage and plugin
|
||||
// metadata resolved together before model discovery.
|
||||
/** Options controlling model discovery, credential reads, and normalization. */
|
||||
export type LoadAgentModelRegistryOptions = {
|
||||
providerFilter?: string;
|
||||
normalizeModels?: boolean;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// OpenAI Chat Completions compatibility helpers. Some providers only accept
|
||||
// role/content messages with plain string content instead of text block arrays.
|
||||
/**
|
||||
* OpenAI Chat Completions compatibility helpers. Some providers only accept
|
||||
* role/content messages with plain string content instead of text block arrays.
|
||||
*/
|
||||
function flattenStringOnlyCompletionContent(content: unknown): unknown {
|
||||
if (!Array.isArray(content)) {
|
||||
return content;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* Ensures runtime plugin registries are loaded for agent execution. Startup
|
||||
* plugin IDs from metadata scope the load when available.
|
||||
*/
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import { normalizePluginsConfig } from "../plugins/config-state.js";
|
||||
import { getCurrentPluginMetadataSnapshot } from "../plugins/current-plugin-metadata-snapshot.js";
|
||||
@@ -5,8 +9,6 @@ import { getActivePluginRuntimeSubagentMode } from "../plugins/runtime.js";
|
||||
import { ensureStandaloneRuntimePluginRegistryLoaded } from "../plugins/runtime/standalone-runtime-registry-loader.js";
|
||||
import { resolveUserPath } from "../utils.js";
|
||||
|
||||
// Ensures runtime plugin registries are loaded for agent execution. Startup
|
||||
// plugin IDs from metadata scope the load when available.
|
||||
type StartupScopedPluginSnapshot = NonNullable<
|
||||
ReturnType<typeof getCurrentPluginMetadataSnapshot>
|
||||
> & {
|
||||
|
||||
Reference in New Issue
Block a user