mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 01:28:27 +00:00
refactor: expand bootstrap helpers and tests
This commit is contained in:
@@ -16,14 +16,12 @@ import { isReasoningTagProvider } from "../../utils/provider-utils.js";
|
||||
import { resolveUserPath } from "../../utils.js";
|
||||
import { resolveClawdbotAgentDir } from "../agent-paths.js";
|
||||
import { resolveSessionAgentIds } from "../agent-scope.js";
|
||||
import { resolveBootstrapFilesForRun } from "../bootstrap-files.js";
|
||||
import { resolveBootstrapContextForRun } from "../bootstrap-files.js";
|
||||
import type { ExecElevatedDefaults } from "../bash-tools.js";
|
||||
import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../defaults.js";
|
||||
import { getApiKeyForModel, resolveModelAuthMode } from "../model-auth.js";
|
||||
import { ensureClawdbotModelsJson } from "../models-config.js";
|
||||
import {
|
||||
buildBootstrapContextFiles,
|
||||
type EmbeddedContextFile,
|
||||
ensureSessionHeader,
|
||||
resolveBootstrapMaxChars,
|
||||
validateAnthropicTurns,
|
||||
@@ -178,20 +176,14 @@ export async function compactEmbeddedPiSession(params: {
|
||||
workspaceDir: effectiveWorkspace,
|
||||
});
|
||||
|
||||
const hookAdjustedBootstrapFiles = await resolveBootstrapFilesForRun({
|
||||
const sessionLabel = params.sessionKey ?? params.sessionId;
|
||||
const { contextFiles } = await resolveBootstrapContextForRun({
|
||||
workspaceDir: effectiveWorkspace,
|
||||
config: params.config,
|
||||
sessionKey: params.sessionKey,
|
||||
sessionId: params.sessionId,
|
||||
warn: (message) => log.warn(`${message} (sessionKey=${sessionLabel})`),
|
||||
});
|
||||
const sessionLabel = params.sessionKey ?? params.sessionId;
|
||||
const contextFiles: EmbeddedContextFile[] = buildBootstrapContextFiles(
|
||||
hookAdjustedBootstrapFiles,
|
||||
{
|
||||
maxChars: resolveBootstrapMaxChars(params.config),
|
||||
warn: (message) => log.warn(`${message} (sessionKey=${sessionLabel})`),
|
||||
},
|
||||
);
|
||||
const runAbortController = new AbortController();
|
||||
const toolsRaw = createClawdbotCodingTools({
|
||||
exec: {
|
||||
|
||||
@@ -17,10 +17,9 @@ import { isSubagentSessionKey } from "../../../routing/session-key.js";
|
||||
import { resolveUserPath } from "../../../utils.js";
|
||||
import { resolveClawdbotAgentDir } from "../../agent-paths.js";
|
||||
import { resolveSessionAgentIds } from "../../agent-scope.js";
|
||||
import { resolveBootstrapFilesForRun } from "../../bootstrap-files.js";
|
||||
import { resolveBootstrapContextForRun } from "../../bootstrap-files.js";
|
||||
import { resolveModelAuthMode } from "../../model-auth.js";
|
||||
import {
|
||||
buildBootstrapContextFiles,
|
||||
isCloudCodeAssistFormatError,
|
||||
resolveBootstrapMaxChars,
|
||||
validateAnthropicTurns,
|
||||
@@ -120,17 +119,15 @@ export async function runEmbeddedAttempt(
|
||||
workspaceDir: effectiveWorkspace,
|
||||
});
|
||||
|
||||
const hookAdjustedBootstrapFiles = await resolveBootstrapFilesForRun({
|
||||
workspaceDir: effectiveWorkspace,
|
||||
config: params.config,
|
||||
sessionKey: params.sessionKey,
|
||||
sessionId: params.sessionId,
|
||||
});
|
||||
const sessionLabel = params.sessionKey ?? params.sessionId;
|
||||
const contextFiles = buildBootstrapContextFiles(hookAdjustedBootstrapFiles, {
|
||||
maxChars: resolveBootstrapMaxChars(params.config),
|
||||
warn: (message) => log.warn(`${message} (sessionKey=${sessionLabel})`),
|
||||
});
|
||||
const { bootstrapFiles: hookAdjustedBootstrapFiles, contextFiles } =
|
||||
await resolveBootstrapContextForRun({
|
||||
workspaceDir: effectiveWorkspace,
|
||||
config: params.config,
|
||||
sessionKey: params.sessionKey,
|
||||
sessionId: params.sessionId,
|
||||
warn: (message) => log.warn(`${message} (sessionKey=${sessionLabel})`),
|
||||
});
|
||||
|
||||
const agentDir = params.agentDir ?? resolveClawdbotAgentDir();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user