Skip to content

Commit c7e428d

Browse files
committed
style: biome format unify-PR files
1 parent e8e5f93 commit c7e428d

4 files changed

Lines changed: 59 additions & 24 deletions

File tree

src/hooks/task-session-manager/board-injection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import {
2020
renderTaskCompletedWithText,
2121
renderTaskTerminalFromBoard,
2222
} from '../../utils';
23-
import { extractSessionResult } from '../../utils/session';
2423
import { isRecord } from '../../utils/guards';
2524
import { log } from '../../utils/logger';
25+
import { extractSessionResult } from '../../utils/session';
2626
import {
2727
appendTrailingVolatileMessage,
2828
createTaggedSyntheticPart,

src/hooks/task-session-manager/fallback-false-cancel.test.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ const PARENT = 'parent-1';
66
const CHILD = 'child-1';
77

88
function createHook(board: BackgroundJobBoard) {
9-
return createTaskSessionManagerHook(
10-
{ client: { session: {} } } as never,
11-
{
12-
maxSessionsPerAgent: 2,
13-
maxRetainedSnapshots: 2,
14-
backgroundJobBoard: board,
15-
shouldManageSession: () => true,
16-
},
17-
);
9+
return createTaskSessionManagerHook({ client: { session: {} } } as never, {
10+
maxSessionsPerAgent: 2,
11+
maxRetainedSnapshots: 2,
12+
backgroundJobBoard: board,
13+
shouldManageSession: () => true,
14+
});
1815
}
1916

2017
/**
@@ -62,15 +59,22 @@ function userMessage(id: string, text: string) {
6259
function findTaskPart(messages: unknown[], callID: string) {
6360
for (const message of messages as { parts?: any[] }[]) {
6461
for (const part of message?.parts ?? []) {
65-
if (part?.type === 'tool' && part?.tool === 'task' && part?.callID === callID) {
62+
if (
63+
part?.type === 'tool' &&
64+
part?.tool === 'task' &&
65+
part?.callID === callID
66+
) {
6667
return part;
6768
}
6869
}
6970
}
7071
return undefined;
7172
}
7273

73-
async function transform(hook: ReturnType<typeof createTaskSessionManagerHook>, history: unknown[]) {
74+
async function transform(
75+
hook: ReturnType<typeof createTaskSessionManagerHook>,
76+
history: unknown[],
77+
) {
7478
const request = { messages: structuredClone(history) };
7579
await hook['experimental.chat.messages.transform']({}, request as never);
7680
return request.messages;
@@ -237,7 +241,12 @@ describe('reconcileFallbackFalseCancel', () => {
237241
const history = [
238242
userMessage('u1', 'fix the bug'),
239243
{
240-
info: { role: 'assistant', agent: 'orchestrator', sessionID: PARENT, id: 'call-2' },
244+
info: {
245+
role: 'assistant',
246+
agent: 'orchestrator',
247+
sessionID: PARENT,
248+
id: 'call-2',
249+
},
241250
parts: [
242251
{ type: 'text', text: ' ' },
243252
{

src/hooks/task-session-manager/false-complete-fallback.test.ts

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, test, mock } from 'bun:test';
1+
import { describe, expect, mock, test } from 'bun:test';
22
import { BackgroundJobBoard } from '../../utils';
33
import { createTaskSessionManagerHook } from './index';
44

@@ -50,7 +50,11 @@ function userMessage(id: string, text: string) {
5050
function findTaskPart(messages: unknown[], callID: string) {
5151
for (const message of messages as { parts?: any[] }[]) {
5252
for (const part of message?.parts ?? []) {
53-
if (part?.type === 'tool' && part?.tool === 'task' && part?.callID === callID) {
53+
if (
54+
part?.type === 'tool' &&
55+
part?.tool === 'task' &&
56+
part?.callID === callID
57+
) {
5458
return part;
5559
}
5660
}
@@ -67,7 +71,10 @@ async function transform(
6771
return request.messages;
6872
}
6973

70-
function setupCompletedBoard(board: BackgroundJobBoard, description = 'test task') {
74+
function setupCompletedBoard(
75+
board: BackgroundJobBoard,
76+
description = 'test task',
77+
) {
7178
board.registerLaunch({
7279
taskID: CHILD,
7380
parentSessionID: PARENT,
@@ -85,7 +92,10 @@ function setupCompletedBoard(board: BackgroundJobBoard, description = 'test task
8592

8693
function mockClient(
8794
childMessages:
88-
| Array<{ info?: { role: string }; parts?: Array<{ type: string; text?: string }> }>
95+
| Array<{
96+
info?: { role: string };
97+
parts?: Array<{ type: string; text?: string }>;
98+
}>
8999
| (() => Promise<unknown>),
90100
) {
91101
const messages =
@@ -132,7 +142,9 @@ describe('reconcileFalseCompleteFallback', () => {
132142

133143
expect(part.state.status).toBe('completed');
134144
expect(part.state.output).toContain('state="completed"');
135-
expect(part.state.output).toContain('Background task completed: audit DATA.md');
145+
expect(part.state.output).toContain(
146+
'Background task completed: audit DATA.md',
147+
);
136148
expect(part.state.output).toContain('# Audit Report');
137149
expect(part.state.output).toContain('All claims verified.');
138150
});
@@ -141,7 +153,10 @@ describe('reconcileFalseCompleteFallback', () => {
141153
const board = new BackgroundJobBoard();
142154
setupCompletedBoard(board, 'test task');
143155
const childMessages = [
144-
{ info: { role: 'assistant' }, parts: [{ type: 'text', text: 'real output' }] },
156+
{
157+
info: { role: 'assistant' },
158+
parts: [{ type: 'text', text: 'real output' }],
159+
},
145160
];
146161
const hook = createTaskSessionManagerHook(
147162
{ client: mockClient(childMessages), directory: '/tmp' } as never,
@@ -204,7 +219,10 @@ describe('reconcileFalseCompleteFallback', () => {
204219
const board = new BackgroundJobBoard();
205220
setupCompletedBoard(board, 'test task');
206221
const childMessages = [
207-
{ info: { role: 'assistant' }, parts: [{ type: 'text', text: 'real output' }] },
222+
{
223+
info: { role: 'assistant' },
224+
parts: [{ type: 'text', text: 'real output' }],
225+
},
208226
];
209227
const hook = createTaskSessionManagerHook(
210228
{ client: mockClient(childMessages), directory: '/tmp' } as never,
@@ -249,7 +267,12 @@ describe('reconcileFalseCompleteFallback', () => {
249267
const history = [
250268
userMessage('u1', 'run task'),
251269
{
252-
info: { role: 'assistant', agent: 'orchestrator', sessionID: PARENT, id: 'call-2' },
270+
info: {
271+
role: 'assistant',
272+
agent: 'orchestrator',
273+
sessionID: PARENT,
274+
id: 'call-2',
275+
},
253276
parts: [
254277
{ type: 'text', text: ' ' },
255278
{
@@ -258,7 +281,8 @@ describe('reconcileFalseCompleteFallback', () => {
258281
callID: 'call-2',
259282
state: {
260283
status: 'completed',
261-
output: '<task id="child-1" state="completed"><task_result></task_result></task>',
284+
output:
285+
'<task id="child-1" state="completed"><task_result></task_result></task>',
262286
metadata: { sessionId: CHILD },
263287
},
264288
},
@@ -282,7 +306,10 @@ describe('reconcileFalseCompleteFallback', () => {
282306
description: 'still running',
283307
});
284308
const childMessages = [
285-
{ info: { role: 'assistant' }, parts: [{ type: 'text', text: 'partial draft' }] },
309+
{
310+
info: { role: 'assistant' },
311+
parts: [{ type: 'text', text: 'partial draft' }],
312+
},
286313
];
287314
const hook = createTaskSessionManagerHook(
288315
{ client: mockClient(childMessages), directory: '/tmp' } as never,

src/hooks/task-session-manager/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ export function createTaskSessionManagerHook(
301301
_ctx.directory,
302302
);
303303

304-
305304
for (const [messageIndex, message] of messages.entries()) {
306305
if (!isUserMessageWithParts(message)) continue;
307306
if (message.info.agent && message.info.agent !== 'orchestrator') {

0 commit comments

Comments
 (0)