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

推荐订阅源

MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
V
Visual Studio Blog
G
Google Developers Blog
Blog — PlanetScale
Blog — PlanetScale
Last Week in AI
Last Week in AI
C
Check Point Blog
D
Docker
M
MIT News - Artificial intelligence
P
Proofpoint News Feed
博客园 - 叶小钗
博客园 - 聂微东
The Cloudflare Blog
云风的 BLOG
云风的 BLOG
Martin Fowler
Martin Fowler
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
酷 壳 – CoolShell
酷 壳 – CoolShell
MyScale Blog
MyScale Blog
WordPress大学
WordPress大学
Engineering at Meta
Engineering at Meta
腾讯CDC
S
SegmentFault 最新的问题
博客园 - 【当耐特】

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
test: complete auto reply mock call helpers · openclaw/op...
steipete · 2026-05-13 · via Recent Commits to openclaw:main

@@ -702,12 +702,21 @@ function createMockAcpSessionManager() {

702702

};

703703

}

704704705-

function firstMockArg(mockFn: ReturnType<typeof vi.fn>, label: string, index = 0): unknown {

706-

const call = mockFn.mock.calls.at(index);

705+

function firstMockCall(mockFn: ReturnType<typeof vi.fn>, label: string, index = 0): unknown[] {

706+

const call = mockFn.mock.calls[index] as unknown[] | undefined;

707707

if (!call) {

708708

throw new Error(`expected ${label} call #${index + 1}`);

709709

}

710-

return call.at(0);

710+

return call;

711+

}

712+713+

function firstMockArg(

714+

mockFn: ReturnType<typeof vi.fn>,

715+

label: string,

716+

index = 0,

717+

argIndex = 0,

718+

): unknown {

719+

return firstMockCall(mockFn, label, index)[argIndex];

711720

}

712721713722

function firstToolResultPayload(dispatcher: ReplyDispatcher): ReplyPayload | undefined {

@@ -997,7 +1006,7 @@ describe("dispatchReplyFromConfig", () => {

9971006

.calls[0]?.[0] as { accountId?: unknown; messageProvider?: unknown } | undefined;

9981007

expect(normalizerOptions?.messageProvider).toBe("telegram");

9991008

expect(normalizerOptions?.accountId).toBe("acc-1");

1000-

const replyDispatchCall = hookMocks.runner.runReplyDispatch.mock.calls.at(0) as

1009+

const replyDispatchCall = firstMockCall(hookMocks.runner.runReplyDispatch, "reply dispatch") as

10011010

| [

10021011

{

10031012

originatingChannel?: unknown;

@@ -1082,7 +1091,7 @@ describe("dispatchReplyFromConfig", () => {

10821091

expect(mocks.routeReply).not.toHaveBeenCalled();

10831092

expect(dispatcher.sendFinalReply).not.toHaveBeenCalled();

10841093

expect(result.queuedFinal).toBe(false);

1085-

const replyDispatchCall = hookMocks.runner.runReplyDispatch.mock.calls.at(0) as

1094+

const replyDispatchCall = firstMockCall(hookMocks.runner.runReplyDispatch, "reply dispatch") as

10861095

| [

10871096

{

10881097

originatingChannel?: unknown;

@@ -2077,7 +2086,7 @@ describe("dispatchReplyFromConfig", () => {

20772086

await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });

2078208720792088

expect(replyResolver).not.toHaveBeenCalled();

2080-

const ensureSessionOptions = runtime.ensureSession.mock.calls.at(0)?.[0] as

2089+

const ensureSessionOptions = firstMockArg(runtime.ensureSession, "ensure session") as

20812090

| { agent?: unknown; mode?: unknown; sessionKey?: unknown }

20822091

| undefined;

20832092

expect(ensureSessionOptions?.sessionKey).toBe("agent:codex-acp:session-1");

@@ -2421,7 +2430,10 @@ describe("dispatchReplyFromConfig", () => {

2421243024222431

await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });

242324322424-

const bindingLookup = sessionBindingMocks.resolveByConversation.mock.calls.at(0)?.[0];

2433+

const bindingLookup = firstMockArg(

2434+

sessionBindingMocks.resolveByConversation,

2435+

"conversation binding lookup",

2436+

) as { accountId?: unknown; channel?: unknown; conversationId?: unknown } | undefined;

24252437

expect(bindingLookup?.channel).toBe("discord");

24262438

expect(bindingLookup?.accountId).toBe("work");

24272439

expect(bindingLookup?.conversationId).toBe("thread-1");

@@ -2506,17 +2518,20 @@ describe("dispatchReplyFromConfig", () => {

25062518

conversationId: "C123",

25072519

});

25082520

expect(sessionBindingMocks.touch).toHaveBeenCalledWith("binding-acp-current");

2509-

const ensureSessionOptions = runtime.ensureSession.mock.calls.at(0)?.[0] as

2521+

const ensureSessionOptions = firstMockArg(runtime.ensureSession, "ensure session") as

25102522

| { agent?: unknown; sessionKey?: unknown }

25112523

| undefined;

25122524

expect(ensureSessionOptions?.sessionKey).toBe(boundSessionKey);

25132525

expect(ensureSessionOptions?.agent).toBe("opencode");

2514-

const runTurnOptions = runtime.runTurn.mock.calls.at(0)?.[0] as { text?: unknown } | undefined;

2526+

const runTurnOptions = firstMockArg(runtime.runTurn, "run turn") as

2527+

| { text?: unknown }

2528+

| undefined;

25152529

expect(runTurnOptions?.text).toBe("continue");

25162530

expect(replyResolver).not.toHaveBeenCalled();

2517-

const blockPayload = (dispatcher.sendBlockReply as Mock).mock.calls.at(0)?.[0] as

2518-

| ReplyPayload

2519-

| undefined;

2531+

const blockPayload = firstMockArg(

2532+

dispatcher.sendBlockReply as ReturnType<typeof vi.fn>,

2533+

"block reply",

2534+

) as ReplyPayload | undefined;

25202535

expect(blockPayload?.text).toBe("Bound ACP reply");

25212536

});

25222537

@@ -2706,7 +2721,9 @@ describe("dispatchReplyFromConfig", () => {

2706272127072722

await dispatchReplyFromConfig({ ctx, cfg, dispatcher });

270827232709-

const closeOptions = runtime.close.mock.calls.at(0)?.[0] as { reason?: unknown } | undefined;

2724+

const closeOptions = firstMockArg(runtime.close, "runtime close") as

2725+

| { reason?: unknown }

2726+

| undefined;

27102727

expect(closeOptions?.reason).toBe("oneshot-complete");

27112728

});

27122729

@@ -2927,7 +2944,10 @@ describe("dispatchReplyFromConfig", () => {

29272944

const replyResolver = async () => ({ text: "hi" }) satisfies ReplyPayload;

29282945

await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });

292929462930-

const [event, hookContext] = hookMocks.runner.runMessageReceived.mock.calls.at(0) as

2947+

const [event, hookContext] = firstMockCall(

2948+

hookMocks.runner.runMessageReceived,

2949+

"message received hook",

2950+

) as

29312951

| [

29322952

{

29332953

content?: unknown;

@@ -2988,7 +3008,10 @@ describe("dispatchReplyFromConfig", () => {

2988300829893009

expect(result).toEqual({ queuedFinal: true, counts: { tool: 0, block: 0, final: 0 } });

29903010

expect(hookMocks.runner.runInboundClaim).not.toHaveBeenCalled();

2991-

const [event, hookContext] = hookMocks.runner.runMessageReceived.mock.calls.at(0) as

3011+

const [event, hookContext] = firstMockCall(

3012+

hookMocks.runner.runMessageReceived,

3013+

"message received hook",

3014+

) as

29923015

| [

29933016

{ content?: unknown; from?: unknown; metadata?: Record<string, unknown> },

29943017

{ accountId?: unknown; channelId?: unknown; conversationId?: unknown },

@@ -3034,7 +3057,10 @@ describe("dispatchReplyFromConfig", () => {

30343057

const replyResolver = async () => ({ text: "hi" }) satisfies ReplyPayload;

30353058

await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });

303630593037-

const createHookCall = internalHookMocks.createInternalHookEvent.mock.calls.at(0) as

3060+

const createHookCall = firstMockCall(

3061+

internalHookMocks.createInternalHookEvent,

3062+

"internal hook event",

3063+

) as

30383064

| [

30393065

unknown,

30403066

unknown,

@@ -3094,9 +3120,10 @@ describe("dispatchReplyFromConfig", () => {

30943120

const replyResolver = async () => ({ text: "reply" }) satisfies ReplyPayload;

30953121

await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });

309631223097-

const createHookCall = internalHookMocks.createInternalHookEvent.mock.calls.at(0) as

3098-

| [unknown, unknown, unknown, { content?: unknown; messageId?: unknown }]

3099-

| undefined;

3123+

const createHookCall = firstMockCall(

3124+

internalHookMocks.createInternalHookEvent,

3125+

"internal hook event",

3126+

) as [unknown, unknown, unknown, { content?: unknown; messageId?: unknown }] | undefined;

31003127

expect(createHookCall?.[0]).toBe("message");

31013128

expect(createHookCall?.[1]).toBe("received");

31023129

expect(createHookCall?.[2]).toBe("agent:main:discord:guild:123");

@@ -3126,9 +3153,10 @@ describe("dispatchReplyFromConfig", () => {

31263153

state: "processing",

31273154

reason: "message_start",

31283155

});

3129-

const processedEvent = diagnosticMocks.logMessageProcessed.mock.calls.at(0)?.[0] as

3130-

| { channel?: unknown; outcome?: unknown; sessionKey?: unknown }

3131-

| undefined;

3156+

const processedEvent = firstMockArg(

3157+

diagnosticMocks.logMessageProcessed,

3158+

"message processed",

3159+

) as { channel?: unknown; outcome?: unknown; sessionKey?: unknown } | undefined;

31323160

expect(processedEvent?.channel).toBe("slack");

31333161

expect(processedEvent?.outcome).toBe("completed");

31343162

expect(processedEvent?.sessionKey).toBe("agent:main:main");

@@ -3569,9 +3597,10 @@ describe("dispatchReplyFromConfig", () => {

35693597

replyResolver,

35703598

});

357135993572-

const notice = (dispatcher.sendToolResult as ReturnType<typeof vi.fn>).mock.calls.at(0)?.[0] as

3573-

| ReplyPayload

3574-

| undefined;

3600+

const notice = firstMockArg(

3601+

dispatcher.sendToolResult as ReturnType<typeof vi.fn>,

3602+

"tool result",

3603+

) as ReplyPayload | undefined;

35753604

expect(notice?.text).toContain("is not currently loaded.");

35763605

expect(replyResolver).toHaveBeenCalledTimes(1);

35773606

expect(hookMocks.runner.runInboundClaim).not.toHaveBeenCalled();

@@ -4165,7 +4194,10 @@ describe("before_dispatch hook", () => {

4165419441664195

const result = await dispatchReplyFromConfig({ ctx, cfg: emptyConfig, dispatcher });

416741964168-

const beforeDispatchCall = hookMocks.runner.runBeforeDispatch.mock.calls.at(0) as

4197+

const beforeDispatchCall = firstMockCall(

4198+

hookMocks.runner.runBeforeDispatch,

4199+

"before dispatch hook",

4200+

) as

41694201

| [

41704202

{

41714203

body?: unknown;