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

推荐订阅源

腾讯CDC
The Cloudflare Blog
IT之家
IT之家
V
V2EX
雷峰网
雷峰网
MyScale Blog
MyScale Blog
P
Proofpoint News Feed
Stack Overflow Blog
Stack Overflow Blog
博客园 - Franky
Engineering at Meta
Engineering at Meta
S
SegmentFault 最新的问题
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
小众软件
小众软件
博客园 - 叶小钗
Blog — PlanetScale
Blog — PlanetScale
C
Check Point Blog
A
About on SuperTechFans
B
Blog
月光博客
月光博客
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI

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
feat(copilot): mirror native plan and subagent events · o...
vincentkoc · 2026-06-23 · via Recent Commits to openclaw:main

@@ -41,6 +41,16 @@ export interface SessionLike {

41414242

export interface EventBridgeOptions {

4343

onAssistantDelta?: (payload: OnAssistantDeltaPayload) => void | Promise<void>;

44+

onAgentEvent?: (event: {

45+

stream: "item" | "plan";

46+

data: Record<string, unknown>;

47+

}) => void | Promise<void>;

48+

onNativeSubagentEvent?: (

49+

event: Extract<

50+

SessionEvent,

51+

{ type: "subagent.started" | "subagent.completed" | "subagent.failed" }

52+

>,

53+

) => void;

4454

onCompactionComplete?: (payload: {

4555

messagesRemoved?: number;

4656

success: boolean;

@@ -72,6 +82,7 @@ export interface EventBridgeController {

7282

awaitSessionIdle(): Promise<void>;

7383

settleCompactionWait(): void;

7484

awaitDeltaChain(): Promise<void>;

85+

awaitAgentEventChain(): Promise<void>;

7586

hasObservedCompaction(): boolean;

7687

hasObservedSessionIdle(): boolean;

7788

isCompacting(): boolean;

@@ -103,6 +114,7 @@ export function attachEventBridge(

103114

let observedCompaction = false;

104115

let deltaQueue = Promise.resolve();

105116

let deltaChain = Promise.resolve();

117+

let agentEventChain = Promise.resolve();

106118

let compactionChain = Promise.resolve();

107119

let compactionIdle = Promise.resolve();

108120

let resolveCompactionIdle: (() => void) | undefined;

@@ -191,6 +203,51 @@ export function attachEventBridge(

191203

}

192204

});

193205206+

registerListener(session, unsubscribeFns, "session.plan_changed", (event) => {

207+

enqueueAgentEvent({

208+

stream: "plan",

209+

data: {

210+

phase: "update",

211+

title: "Plan updated",

212+

source: "copilot-sdk",

213+

operation: event.data.operation,

214+

...(event.agentId ? { agentId: event.agentId } : {}),

215+

},

216+

});

217+

});

218+219+

registerListener(session, unsubscribeFns, "exit_plan_mode.requested", (event) => {

220+

const steps = splitPlanText(event.data.planContent);

221+

enqueueAgentEvent({

222+

stream: "plan",

223+

data: {

224+

phase: "update",

225+

title: "Plan updated",

226+

source: "copilot-sdk",

227+

...(event.data.summary ? { explanation: event.data.summary } : {}),

228+

...(steps.length > 0 ? { steps } : {}),

229+

...(event.data.actions.length > 0 ? { actions: event.data.actions } : {}),

230+

...(event.data.requestId ? { requestId: event.data.requestId } : {}),

231+

...(event.data.recommendedAction

232+

? { recommendedAction: event.data.recommendedAction }

233+

: {}),

234+

...(event.agentId ? { agentId: event.agentId } : {}),

235+

},

236+

});

237+

});

238+239+

registerListener(session, unsubscribeFns, "subagent.started", (event) => {

240+

forwardNativeSubagentEvent(event);

241+

});

242+243+

registerListener(session, unsubscribeFns, "subagent.completed", (event) => {

244+

forwardNativeSubagentEvent(event);

245+

});

246+247+

registerListener(session, unsubscribeFns, "subagent.failed", (event) => {

248+

forwardNativeSubagentEvent(event);

249+

});

250+194251

registerListener(session, unsubscribeFns, "session.compaction_start", (event) => {

195252

if (!isRootCompactionEvent(event)) {

196253

return;

@@ -276,6 +333,9 @@ export function attachEventBridge(

276333

awaitDeltaChain() {

277334

return deltaChain;

278335

},

336+

awaitAgentEventChain() {

337+

return agentEventChain;

338+

},

279339

hasObservedCompaction() {

280340

return observedCompaction;

281341

},

@@ -334,6 +394,31 @@ export function attachEventBridge(

334394

compactionChain = queued.catch(() => undefined);

335395

}

336396397+

function enqueueAgentEvent(event: {

398+

stream: "item" | "plan";

399+

data: Record<string, unknown>;

400+

}): void {

401+

const callback = options.onAgentEvent;

402+

if (!callback) {

403+

return;

404+

}

405+

const invoke = () => callback(event);

406+

agentEventChain = agentEventChain.then(invoke, invoke).catch(() => undefined);

407+

}

408+409+

function forwardNativeSubagentEvent(

410+

event: Extract<

411+

SessionEvent,

412+

{ type: "subagent.started" | "subagent.completed" | "subagent.failed" }

413+

>,

414+

): void {

415+

try {

416+

options.onNativeSubagentEvent?.(event);

417+

} catch {

418+

// Native task mirroring must not corrupt the Copilot turn.

419+

}

420+

}

421+337422

async function awaitStableCompaction(): Promise<void> {

338423

const idle = activeCompactionCount > 0 ? compactionIdle : undefined;

339424

if (idle) {

@@ -456,6 +541,13 @@ function joinReasoning(order: string[], reasoningById: Map<string, string>): str

456541

return order.map((reasoningId) => reasoningById.get(reasoningId) ?? "").join("");

457542

}

458543544+

function splitPlanText(text: string | undefined): string[] {

545+

return (text ?? "")

546+

.split(/\r?\n/)

547+

.map((line) => line.trim().replace(/^[-*]\s+/, ""))

548+

.filter((line) => line.length > 0);

549+

}

550+459551

function readString(value: unknown): string | undefined {

460552

return typeof value === "string" && value.length > 0 ? value : undefined;

461553

}