77 estimateTokens ,
88 SessionManager ,
99} from "@mariozechner/pi-coding-agent" ;
10- import type { ReasoningLevel , ThinkLevel } from "../../auto-reply/thinking.js" ;
10+ import type { ThinkLevel } from "../../auto-reply/thinking.js" ;
1111import { resolveChannelCapabilities } from "../../config/channel-capabilities.js" ;
1212import type { OpenClawConfig } from "../../config/config.js" ;
1313import {
@@ -33,7 +33,7 @@ import {
3333 transformProviderSystemPrompt ,
3434} from "../../plugins/provider-runtime.js" ;
3535import type { ProviderRuntimeModel } from "../../plugins/types.js" ;
36- import { type enqueueCommand , enqueueCommandInLane } from "../../process/command-queue.js" ;
36+ import { enqueueCommandInLane } from "../../process/command-queue.js" ;
3737import { isCronSessionKey , isSubagentSessionKey } from "../../routing/session-key.js" ;
3838import { normalizeOptionalLowercaseString } from "../../shared/string-coerce.js" ;
3939import { buildTtsSystemPromptHint } from "../../tts/tts.js" ;
@@ -42,7 +42,6 @@ import { normalizeMessageChannel } from "../../utils/message-channel.js";
4242import { isReasoningTagProvider } from "../../utils/provider-utils.js" ;
4343import { resolveOpenClawAgentDir } from "../agent-paths.js" ;
4444import { resolveSessionAgentIds } from "../agent-scope.js" ;
45- import type { ExecElevatedDefaults } from "../bash-tools.js" ;
4645import { makeBootstrapWarn , resolveBootstrapContextForRun } from "../bootstrap-files.js" ;
4746import {
4847 listChannelSupportedActions ,
@@ -95,11 +94,11 @@ import {
9594 applySkillEnvOverrides ,
9695 applySkillEnvOverridesFromSnapshot ,
9796 resolveSkillsPromptForRun ,
98- type SkillSnapshot ,
9997} from "../skills.js" ;
10098import { resolveSystemPromptOverride } from "../system-prompt-override.js" ;
10199import { resolveTranscriptPolicy } from "../transcript-policy.js" ;
102100import { classifyCompactionReason , resolveCompactionFailureReason } from "./compact-reasons.js" ;
101+ import type { CompactEmbeddedPiSessionParams , CompactionMessageMetrics } from "./compact.types.js" ;
103102import {
104103 asCompactionHookRunner ,
105104 buildBeforeCompactionHookMetrics ,
@@ -151,68 +150,7 @@ import { splitSdkTools } from "./tool-split.js";
151150import type { EmbeddedPiCompactResult } from "./types.js" ;
152151import { mapThinkingLevel } from "./utils.js" ;
153152import { flushPendingToolResultsAfterIdle } from "./wait-for-idle-before-flush.js" ;
154-
155- export type CompactEmbeddedPiSessionParams = {
156- sessionId : string ;
157- runId ?: string ;
158- sessionKey ?: string ;
159- messageChannel ?: string ;
160- messageProvider ?: string ;
161- agentAccountId ?: string ;
162- currentChannelId ?: string ;
163- currentThreadTs ?: string ;
164- currentMessageId ?: string | number ;
165- /** Trusted sender id from inbound context for scoped message-tool discovery. */
166- senderId ?: string ;
167- senderName ?: string ;
168- senderUsername ?: string ;
169- senderE164 ?: string ;
170- authProfileId ?: string ;
171- /** Group id for channel-level tool policy resolution. */
172- groupId ?: string | null ;
173- /** Group channel label (e.g. #general) for channel-level tool policy resolution. */
174- groupChannel ?: string | null ;
175- /** Group space label (e.g. guild/team id) for channel-level tool policy resolution. */
176- groupSpace ?: string | null ;
177- /** Parent session key for subagent policy inheritance. */
178- spawnedBy ?: string | null ;
179- /** Whether the sender is an owner (required for owner-only tools). */
180- senderIsOwner ?: boolean ;
181- sessionFile : string ;
182- /** Optional caller-observed live prompt tokens used for compaction diagnostics. */
183- currentTokenCount ?: number ;
184- workspaceDir : string ;
185- agentDir ?: string ;
186- config ?: OpenClawConfig ;
187- skillsSnapshot ?: SkillSnapshot ;
188- provider ?: string ;
189- model ?: string ;
190- thinkLevel ?: ThinkLevel ;
191- reasoningLevel ?: ReasoningLevel ;
192- bashElevated ?: ExecElevatedDefaults ;
193- customInstructions ?: string ;
194- tokenBudget ?: number ;
195- force ?: boolean ;
196- trigger ?: "budget" | "overflow" | "manual" ;
197- diagId ?: string ;
198- attempt ?: number ;
199- maxAttempts ?: number ;
200- lane ?: string ;
201- enqueue ?: typeof enqueueCommand ;
202- extraSystemPrompt ?: string ;
203- ownerNumbers ?: string [ ] ;
204- abortSignal ?: AbortSignal ;
205- /** Allow runtime plugins for this compaction to late-bind the gateway subagent. */
206- allowGatewaySubagentBinding ?: boolean ;
207- } ;
208-
209- type CompactionMessageMetrics = {
210- messages : number ;
211- historyTextChars : number ;
212- toolResultChars : number ;
213- estTokens ?: number ;
214- contributors : Array < { role : string ; chars : number ; tool ?: string } > ;
215- } ;
153+ export type { CompactEmbeddedPiSessionParams } from "./compact.types.js" ;
216154
217155function hasRealConversationContent (
218156 msg : AgentMessage ,
0 commit comments