惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
博客园 - Franky
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog
有赞技术团队
有赞技术团队
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
阮一峰的网络日志
阮一峰的网络日志
C
Check Point Blog
爱范儿
爱范儿
T
The Blog of Author Tim Ferriss
aimingoo的专栏
aimingoo的专栏
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LangChain Blog
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
Microsoft Security Blog
Microsoft Security Blog
The Cloudflare Blog
博客园 - 三生石上(FineUI控件)

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(build): avoid stale agent-core dts warnings (#87915) ...
keshavbotage · 2026-05-31 · via Recent Commits to openclaw:main

@@ -12,10 +12,12 @@ import {

1212

} from "../../runtime-deps.js";

1313

import type { AgentMessage, ThinkingLevel } from "../../types.js";

1414

import {

15+

asAgentMessage,

1516

convertToLlm,

1617

createBranchSummaryMessage,

1718

createCompactionSummaryMessage,

1819

createCustomMessage,

20+

type HarnessMessage,

1921

} from "../messages.js";

2022

import { buildSessionContext } from "../session/session.js";

2123

import {

@@ -83,19 +85,23 @@ function getMessageFromEntry(entry: SessionTreeEntry): AgentMessage | undefined

8385

return entry.message;

8486

}

8587

if (entry.type === "custom_message") {

86-

return createCustomMessage(

87-

entry.customType,

88-

entry.content,

89-

entry.display,

90-

entry.details,

91-

entry.timestamp,

88+

return asAgentMessage(

89+

createCustomMessage(

90+

entry.customType,

91+

entry.content,

92+

entry.display,

93+

entry.details,

94+

entry.timestamp,

95+

),

9296

);

9397

}

9498

if (entry.type === "branch_summary") {

95-

return createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp);

99+

return asAgentMessage(createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp));

96100

}

97101

if (entry.type === "compaction") {

98-

return createCompactionSummaryMessage(entry.summary, entry.tokensBefore, entry.timestamp);

102+

return asAgentMessage(

103+

createCompactionSummaryMessage(entry.summary, entry.tokensBefore, entry.timestamp),

104+

);

99105

}

100106

return undefined;

101107

}

@@ -238,11 +244,13 @@ export function shouldCompact(

238244

/** Estimate token count for one message using a conservative character heuristic. */

239245

export function estimateTokens(message: AgentMessage): number {

240246

let chars = 0;

247+

const harnessMessage = message as HarnessMessage;

241248242-

switch (message.role) {

249+

switch (harnessMessage.role) {

243250

case "user": {

244-

const content = (message as { content: string | Array<{ type: string; text?: string }> })

245-

.content;

251+

const content = (

252+

harnessMessage as { content: string | Array<{ type: string; text?: string }> }

253+

).content;

246254

if (typeof content === "string") {

247255

chars = content.length;

248256

} else if (Array.isArray(content)) {

@@ -255,7 +263,7 @@ export function estimateTokens(message: AgentMessage): number {

255263

return Math.ceil(chars / 4);

256264

}

257265

case "assistant": {

258-

const assistant = message;

266+

const assistant = harnessMessage;

259267

for (const block of assistant.content) {

260268

if (block.type === "text") {

261269

chars += block.text.length;

@@ -269,10 +277,10 @@ export function estimateTokens(message: AgentMessage): number {

269277

}

270278

case "custom":

271279

case "toolResult": {

272-

if (typeof message.content === "string") {

273-

chars = message.content.length;

280+

if (typeof harnessMessage.content === "string") {

281+

chars = harnessMessage.content.length;

274282

} else {

275-

for (const block of message.content) {

283+

for (const block of harnessMessage.content) {

276284

if (block.type === "text" && block.text) {

277285

chars += block.text.length;

278286

}

@@ -284,12 +292,12 @@ export function estimateTokens(message: AgentMessage): number {

284292

return Math.ceil(chars / 4);

285293

}

286294

case "bashExecution": {

287-

chars = message.command.length + message.output.length;

295+

chars = harnessMessage.command.length + harnessMessage.output.length;

288296

return Math.ceil(chars / 4);

289297

}

290298

case "branchSummary":

291299

case "compactionSummary": {

292-

chars = message.summary.length;

300+

chars = harnessMessage.summary.length;

293301

return Math.ceil(chars / 4);

294302

}

295303

}

@@ -306,7 +314,7 @@ function findValidCutPoints(

306314

const entry = entries[i];

307315

switch (entry.type) {

308316

case "message": {

309-

const role = entry.message.role;

317+

const role = (entry.message as HarnessMessage).role;

310318

switch (role) {

311319

case "bashExecution":

312320

case "custom":

@@ -351,7 +359,7 @@ export function findTurnStartIndex(

351359

return i;

352360

}

353361

if (entry.type === "message") {

354-

const role = entry.message.role;

362+

const role = (entry.message as HarnessMessage).role;

355363

if (role === "user" || role === "bashExecution") {

356364

return i;

357365

}