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

推荐订阅源

V
Visual Studio Blog
Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
小众软件
小众软件
Last Week in AI
Last Week in AI
月光博客
月光博客
博客园 - 聂微东
Recent Announcements
Recent Announcements
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
博客园 - Franky
云风的 BLOG
云风的 BLOG
量子位
N
Netflix TechBlog - Medium
Hugging Face - Blog
Hugging Face - Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
博客园 - 司徒正美
S
SegmentFault 最新的问题
有赞技术团队
有赞技术团队
Google DeepMind News
Google DeepMind News
宝玉的分享
宝玉的分享

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
Project Codex hook notifications into agent events (#7096...
pashpashpash · 2026-04-24 · via Recent Commits to openclaw:main

@@ -86,7 +86,14 @@ export class CodexAppServerEventProjector {

86868787

async handleNotification(notification: CodexServerNotification): Promise<void> {

8888

const params = isJsonObject(notification.params) ? notification.params : undefined;

89-

if (!params || !this.isNotificationForTurn(params)) {

89+

if (!params) {

90+

return;

91+

}

92+

if (isHookNotificationMethod(notification.method)) {

93+

if (!this.isHookNotificationForCurrentThread(params)) {

94+

return;

95+

}

96+

} else if (!this.isNotificationForTurn(params)) {

9097

return;

9198

}

9299

@@ -120,6 +127,10 @@ export class CodexAppServerEventProjector {

120127

case "item/autoApprovalReview/completed":

121128

this.handleGuardianReviewNotification(notification.method, params);

122129

break;

130+

case "hook/started":

131+

case "hook/completed":

132+

this.handleHookNotification(notification.method, params);

133+

break;

123134

case "thread/tokenUsage/updated":

124135

this.handleTokenUsage(params);

125136

break;

@@ -413,6 +424,35 @@ export class CodexAppServerEventProjector {

413424

});

414425

}

415426427+

private handleHookNotification(method: string, params: JsonObject): void {

428+

const run = isJsonObject(params.run) ? params.run : undefined;

429+

if (!run) {

430+

return;

431+

}

432+

const durationMs = readNumber(run, "durationMs");

433+

const entries = readHookOutputEntries(run.entries);

434+

const hookTurnId = readNullableString(params, "turnId");

435+

this.emitAgentEvent({

436+

stream: "codex_app_server.hook",

437+

data: {

438+

phase: method === "hook/started" ? "started" : "completed",

439+

threadId: this.threadId,

440+

turnId: hookTurnId === undefined ? this.turnId : hookTurnId,

441+

hookRunId: readString(run, "id"),

442+

eventName: readString(run, "eventName"),

443+

handlerType: readString(run, "handlerType"),

444+

executionMode: readString(run, "executionMode"),

445+

scope: readString(run, "scope"),

446+

source: readString(run, "source"),

447+

sourcePath: readString(run, "sourcePath"),

448+

status: readString(run, "status"),

449+

statusMessage: readNullableString(run, "statusMessage"),

450+

...(durationMs !== undefined ? { durationMs } : {}),

451+

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

452+

},

453+

});

454+

}

455+416456

private async handleTurnCompleted(params: JsonObject): Promise<void> {

417457

const turn = readTurn(params.turn);

418458

if (!turn || turn.id !== this.turnId) {

@@ -690,6 +730,16 @@ export class CodexAppServerEventProjector {

690730

const turnId = readNotificationTurnId(params);

691731

return threadId === this.threadId && turnId === this.turnId;

692732

}

733+734+

private isHookNotificationForCurrentThread(params: JsonObject): boolean {

735+

const threadId = readString(params, "threadId");

736+

const turnId = params.turnId;

737+

return threadId === this.threadId && (turnId === this.turnId || turnId === null);

738+

}

739+

}

740+741+

function isHookNotificationMethod(method: string): method is "hook/started" | "hook/completed" {

742+

return method === "hook/started" || method === "hook/completed";

693743

}

694744695745

function readNotificationTurnId(record: JsonObject): string | undefined {

@@ -719,6 +769,25 @@ function readNumber(record: JsonObject, key: string): number | undefined {

719769

return typeof value === "number" && Number.isFinite(value) ? value : undefined;

720770

}

721771772+

function readHookOutputEntries(

773+

value: JsonValue | undefined,

774+

): Array<{ kind?: string; text: string }> {

775+

if (!Array.isArray(value)) {

776+

return [];

777+

}

778+

return value.flatMap((entry) => {

779+

if (!isJsonObject(entry)) {

780+

return [];

781+

}

782+

const text = readString(entry, "text");

783+

if (!text) {

784+

return [];

785+

}

786+

const kind = readString(entry, "kind");

787+

return [{ ...(kind ? { kind } : {}), text }];

788+

});

789+

}

790+722791

function readFirstJsonObject(record: JsonObject, keys: readonly string[]): JsonObject | undefined {

723792

for (const key of keys) {

724793

const value = record[key];