@cmodjs/core 8.2.0 → 8.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/commands.md +1 -1
- package/docs/dependencies.md +9 -2
- package/docs/session.md +7 -2
- package/docs/testing.md +2 -0
- package/jobs/program.d.ts.map +1 -1
- package/jobs/program.js +10 -7
- package/mod.d.ts +282 -0
- package/mod.d.ts.map +1 -1
- package/package.json +1 -1
- package/records.d.ts +1 -1
- package/records.js +1 -1
- package/register.d.ts.map +1 -1
- package/register.js +1 -0
- package/runtime/before.d.ts +1 -1
- package/runtime/before.d.ts.map +1 -1
- package/runtime/before.js +8 -13
- package/runtime/claude.d.ts +2 -1
- package/runtime/claude.d.ts.map +1 -1
- package/runtime/conversations.d.ts.map +1 -1
- package/runtime/conversations.js +19 -9
- package/runtime/interfaces.d.ts +17 -2
- package/runtime/interfaces.d.ts.map +1 -1
- package/runtime/interfaces.js +64 -15
- package/runtime/lifecycle.js +3 -3
- package/runtime/permission-check.d.ts +1 -0
- package/runtime/permission-check.d.ts.map +1 -1
- package/runtime/permission-check.js +20 -2
- package/runtime/rpc.d.ts.map +1 -1
- package/runtime/rpc.js +49 -28
- package/runtime/sessions.d.ts +3 -1
- package/runtime/sessions.d.ts.map +1 -1
- package/runtime/sessions.js +8 -3
- package/session/context/turn/message/message.d.ts +2 -1
- package/session/context/turn/message/message.d.ts.map +1 -1
- package/session/context/turn/turn.d.ts +1 -0
- package/session/context/turn/turn.d.ts.map +1 -1
- package/session/conversation.d.ts +6 -1
- package/session/conversation.d.ts.map +1 -1
- package/session/conversation.js +15 -2
- package/session/session.d.ts +6 -1
- package/session/session.d.ts.map +1 -1
- package/src/jobs/program.ts +8 -4
- package/src/mod.ts +55 -0
- package/src/records.ts +1 -1
- package/src/register.ts +1 -0
- package/src/runtime/before.ts +9 -14
- package/src/runtime/claude.ts +2 -0
- package/src/runtime/conversations.ts +20 -11
- package/src/runtime/interfaces.ts +70 -11
- package/src/runtime/lifecycle.ts +3 -3
- package/src/runtime/permission-check.ts +20 -2
- package/src/runtime/rpc.ts +49 -31
- package/src/runtime/sessions.ts +11 -4
- package/src/session/context/turn/message/message.ts +2 -1
- package/src/session/context/turn/turn.ts +1 -0
- package/src/session/conversation.ts +22 -3
- package/src/session/session.ts +2 -1
- package/src/testing/fake-claude.ts +1 -0
- package/src/testing/fake-serve.ts +14 -5
- package/src/testing/fake-sessions.ts +2 -4
- package/src/testing.ts +33 -15
- package/testing/fake-claude.d.ts.map +1 -1
- package/testing/fake-claude.js +1 -0
- package/testing/fake-serve.d.ts.map +1 -1
- package/testing/fake-serve.js +15 -7
- package/testing/fake-sessions.d.ts.map +1 -1
- package/testing/fake-sessions.js +2 -4
- package/testing.d.ts +4 -1
- package/testing.d.ts.map +1 -1
- package/testing.js +31 -8
package/src/runtime/rpc.ts
CHANGED
|
@@ -262,7 +262,7 @@ export function rpcRoutes({
|
|
|
262
262
|
}
|
|
263
263
|
return { status: 405, json: { error: `cmod has no ${request.method} ${request.path}.` } }
|
|
264
264
|
} catch (error) {
|
|
265
|
-
if (error instanceof GoneError) return { status:
|
|
265
|
+
if (error instanceof GoneError) return { status: goneStatus, json: { error: error.message } }
|
|
266
266
|
throw error
|
|
267
267
|
}
|
|
268
268
|
}
|
|
@@ -299,6 +299,8 @@ export function rpcRoutes({
|
|
|
299
299
|
|
|
300
300
|
export class RpcUnreached extends Error {}
|
|
301
301
|
|
|
302
|
+
const goneStatus = 410
|
|
303
|
+
|
|
302
304
|
export function isConnectionGone(error: unknown): boolean {
|
|
303
305
|
return error instanceof RpcUnreached || (error instanceof RpcError && error.code === rpcCodes.closed)
|
|
304
306
|
}
|
|
@@ -344,46 +346,49 @@ export function connectRpc({
|
|
|
344
346
|
readonly retryMs?: number
|
|
345
347
|
readonly keepsConnecting?: boolean
|
|
346
348
|
}): RpcClient {
|
|
347
|
-
|
|
348
|
-
let
|
|
349
|
+
type Link = { readonly id: string; readonly peer: Peer; lastAsked: RpcId | undefined; readonly undelivered: Set<RpcId> }
|
|
350
|
+
let current: Link | undefined
|
|
351
|
+
let connecting: Promise<Link> | undefined
|
|
349
352
|
let isClosed = false
|
|
350
353
|
let queued: RpcMessage[] = []
|
|
351
354
|
let flushing: Promise<void> | undefined
|
|
352
355
|
|
|
353
|
-
const
|
|
356
|
+
const asked = (messages: readonly RpcMessage[]) => messages.flatMap((message) => ('method' in message && 'id' in message ? [message.id] : []))
|
|
357
|
+
|
|
358
|
+
const flush = (link: Link) => {
|
|
354
359
|
flushing ??= (async () => {
|
|
355
360
|
await Promise.resolve()
|
|
356
|
-
while (queued.length > 0 && current
|
|
361
|
+
while (queued.length > 0 && current === link) {
|
|
357
362
|
const batch = queued
|
|
358
363
|
queued = []
|
|
359
|
-
const answer = await call(`${rpcPath}/${id}`, { method: 'POST', body: JSON.stringify(batch) }).catch((error: unknown) => ({ status: 0, text: String(error) }))
|
|
364
|
+
const answer = await call(`${rpcPath}/${link.id}`, { method: 'POST', body: JSON.stringify(batch) }).catch((error: unknown) => ({ status: 0, text: String(error) }))
|
|
360
365
|
if (answer.status !== 204) {
|
|
361
|
-
|
|
366
|
+
if (answer.status === goneStatus) for (const id of asked(batch)) link.undelivered.add(id)
|
|
367
|
+
lose(link, new RpcUnreached(`cmod serve answered ${answer.status}: ${answer.text}`))
|
|
362
368
|
return
|
|
363
369
|
}
|
|
364
370
|
}
|
|
365
371
|
})().finally(() => {
|
|
366
372
|
flushing = undefined
|
|
367
|
-
if (queued.length > 0 && current
|
|
373
|
+
if (queued.length > 0 && current === link) flush(link)
|
|
368
374
|
})
|
|
369
375
|
}
|
|
370
376
|
|
|
371
|
-
const lose = (
|
|
372
|
-
if (current
|
|
377
|
+
const lose = (link: Link, reason: Error) => {
|
|
378
|
+
if (current !== link) return
|
|
373
379
|
current = undefined
|
|
380
|
+
for (const id of asked(queued)) link.undelivered.add(id)
|
|
374
381
|
queued = []
|
|
375
|
-
peer.close(reason)
|
|
382
|
+
link.peer.close(reason)
|
|
376
383
|
reconnect()
|
|
377
384
|
}
|
|
378
385
|
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
if (answer.status !== 200) return lose(id, peer, new RpcUnreached(`cmod serve answered the poll with ${answer.status}: ${answer.text}`))
|
|
386
|
-
peer.receive(JSON.parse(answer.text))
|
|
386
|
+
const pollLoop = async (link: Link) => {
|
|
387
|
+
while (current === link && !isClosed) {
|
|
388
|
+
const answer = await call(`${rpcPath}/${link.id}`, { method: 'GET' }).catch((error: unknown) => ({ status: 0, text: String(error) }))
|
|
389
|
+
if (current !== link) return
|
|
390
|
+
if (answer.status !== 200) return lose(link, new RpcUnreached(`cmod serve answered the poll with ${answer.status}: ${answer.text}`))
|
|
391
|
+
link.peer.receive(JSON.parse(answer.text))
|
|
387
392
|
}
|
|
388
393
|
}
|
|
389
394
|
|
|
@@ -403,16 +408,22 @@ export function connectRpc({
|
|
|
403
408
|
const answer = await call(`${rpcPath}/connect`, { method: 'POST' })
|
|
404
409
|
if (answer.status !== 200) throw new Error(`cmod serve answered the connect with ${answer.status}: ${answer.text}`)
|
|
405
410
|
const { connection: id } = JSON.parse(answer.text) as { readonly connection: string }
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
411
|
+
const link: Link = {
|
|
412
|
+
id,
|
|
413
|
+
peer: createPeer({
|
|
414
|
+
send: (message) => {
|
|
415
|
+
link.lastAsked = asked([message])[0] ?? link.lastAsked
|
|
416
|
+
queued.push(message)
|
|
417
|
+
flush(link)
|
|
418
|
+
},
|
|
419
|
+
handle,
|
|
420
|
+
}),
|
|
421
|
+
lastAsked: undefined,
|
|
422
|
+
undelivered: new Set(),
|
|
423
|
+
}
|
|
424
|
+
current = link
|
|
414
425
|
hasConnected = true
|
|
415
|
-
void pollLoop(
|
|
426
|
+
void pollLoop(link)
|
|
416
427
|
void (async () => onConnect?.(client))().catch((error: unknown) => onError?.(error))
|
|
417
428
|
return current
|
|
418
429
|
} catch (error) {
|
|
@@ -434,9 +445,16 @@ export function connectRpc({
|
|
|
434
445
|
get isConnected() {
|
|
435
446
|
return current !== undefined
|
|
436
447
|
},
|
|
437
|
-
async request<Result>(method: string, params?: unknown, signal?: AbortSignal) {
|
|
438
|
-
const
|
|
439
|
-
|
|
448
|
+
async request<Result>(method: string, params?: unknown, signal?: AbortSignal): Promise<Result> {
|
|
449
|
+
const link = await connection()
|
|
450
|
+
const answer = link.peer.request<Result>(method, params, signal)
|
|
451
|
+
const sent = link.lastAsked
|
|
452
|
+
try {
|
|
453
|
+
return await answer
|
|
454
|
+
} catch (error) {
|
|
455
|
+
if (sent === undefined || !link.undelivered.has(sent) || !isConnectionGone(error)) throw error
|
|
456
|
+
return client.request<Result>(method, params, signal)
|
|
457
|
+
}
|
|
440
458
|
},
|
|
441
459
|
notify(method, params) {
|
|
442
460
|
void connection()
|
package/src/runtime/sessions.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Args, CommandRunResult, SessionCompactResult } from 'claude-code'
|
|
1
|
+
import type { Args, CommandRunResult, EventResult, SessionCompactResult } from 'claude-code'
|
|
2
2
|
import type { Subscription } from '../utils/subscription.js'
|
|
3
3
|
import { ContextEnd, ContextStart, type Context } from '../session/context/context.js'
|
|
4
4
|
import { Message, noFiles } from '../session/context/turn/message/message.js'
|
|
@@ -46,7 +46,11 @@ export type SessionColor = { readonly session: string; readonly color?: string }
|
|
|
46
46
|
|
|
47
47
|
const resetColors: readonly string[] = ['default', 'reset', 'none', 'gray', 'grey']
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
export function subagentTranscript(sessionTranscript: string | undefined, task: string): string | undefined {
|
|
50
|
+
return sessionTranscript?.endsWith('.jsonl') === true ? `${sessionTranscript.slice(0, -'.jsonl'.length)}/subagents/agent-${task}.jsonl` : undefined
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const sessionFields: Readonly<Record<keyof SessionData, true>> = { id: true, title: true, color: true, project: true, cwd: true, transcriptPath: true, model: true, startedAt: true, lastAt: true, forkedFrom: true, isRunning: true, agentType: true, visitedAt: true, device: true, status: true, waitingFor: true, contextPercent: true, lastTurn: true }
|
|
50
54
|
|
|
51
55
|
export function pickedColor(args: string): string | undefined {
|
|
52
56
|
const picked = args.trim().toLowerCase()
|
|
@@ -439,6 +443,7 @@ export function createSessionsClient({ name, claude, report, hookOn, routeOn, pe
|
|
|
439
443
|
const ownerOf = (session: string, data: TaskData): TaskOwner => {
|
|
440
444
|
const parent = session === current.id ? current : known.get(session)
|
|
441
445
|
const isBackground = data.isBackground === true
|
|
446
|
+
const transcriptPath = isBackground ? known.get(data.id)?.transcriptPath : subagentTranscript(parent?.transcriptPath, data.id)
|
|
442
447
|
return sessionOf(
|
|
443
448
|
() => ({
|
|
444
449
|
id: data.id,
|
|
@@ -447,6 +452,7 @@ export function createSessionsClient({ name, claude, report, hookOn, routeOn, pe
|
|
|
447
452
|
...(data.agentType === undefined ? {} : { agentType: data.agentType }),
|
|
448
453
|
model: data.model ?? '',
|
|
449
454
|
cwd: parent?.cwd ?? '',
|
|
455
|
+
...(transcriptPath === undefined ? {} : { transcriptPath }),
|
|
450
456
|
isRunning: data.closedAt === undefined && (isBackground || (parent?.isRunning ?? true)),
|
|
451
457
|
startedAt: data.openedAt,
|
|
452
458
|
lastAt: data.closedAt ?? data.openedAt,
|
|
@@ -505,7 +511,7 @@ export function createSessionsClient({ name, claude, report, hookOn, routeOn, pe
|
|
|
505
511
|
if (named === 'PermissionCheck' || named === 'PermissionRequest') {
|
|
506
512
|
const routes = permissionRoutes?.()
|
|
507
513
|
if (routes === undefined) throw new Error(withoutPermissionCheck(name, method))
|
|
508
|
-
return routes(method, { raise, refusalFor, hookOn, routeOn, current: () => current })
|
|
514
|
+
return routes(method, { name, raise, refusalFor, hookOn, routeOn, current: () => current })
|
|
509
515
|
}
|
|
510
516
|
const event: { readonly on: string; readonly before?: string } = processEvents[named as ProcessName]
|
|
511
517
|
const hook = (isBefore ? event.before : undefined) ?? event.on
|
|
@@ -655,6 +661,7 @@ export type ToolCheck = { readonly tool: string; readonly input: unknown; readon
|
|
|
655
661
|
export type RouteOn = {
|
|
656
662
|
(event: 'tool.check', hook: (e: ToolCheck, next: ((e: ToolCheck) => Promise<unknown>) & { readonly signal: AbortSignal }) => Promise<unknown>, failed?: (e: ToolCheck, error: Error, next: (e: ToolCheck) => Promise<unknown>) => Promise<{ readonly decision: 'deny'; readonly reason: string } | undefined>): Subscription
|
|
657
663
|
(event: 'command.run', hook: (e: Args<'command.run'>, next: ((e: Args<'command.run'>) => Promise<CommandRunResult>) & { readonly signal: AbortSignal }) => Promise<CommandRunResult>, failed?: (e: Args<'command.run'>, error: Error) => Promise<CommandRunResult | undefined>): Subscription
|
|
664
|
+
(event: 'tool.call', hook: (e: Args<'tool.call'>, next: (e: Args<'tool.call'>) => Promise<EventResult<'tool.call'>>) => Promise<EventResult<'tool.call'>>): Subscription
|
|
658
665
|
(event: 'session.compact', hook: (e: Args<'session.compact'>, next: (e: Args<'session.compact'>) => Promise<SessionCompactResult>) => Promise<SessionCompactResult>): Subscription
|
|
659
666
|
}
|
|
660
667
|
|
|
@@ -686,7 +693,7 @@ const answerKeys: Readonly<Record<string, readonly string[]>> = {
|
|
|
686
693
|
WorktreeCreate: ['result'],
|
|
687
694
|
Elicitation: ['refuse'],
|
|
688
695
|
ElicitationResponse: ['refuse'],
|
|
689
|
-
PermissionCheck: ['allow', 'ask', 'refuse'],
|
|
696
|
+
PermissionCheck: ['allow', 'ask', 'refuse', 'note'],
|
|
690
697
|
PermissionRequest: ['allow', 'input', 'updates', 'refuse', 'interrupt'],
|
|
691
698
|
PermissionDenial: ['retry'],
|
|
692
699
|
ToolBatch: ['note'],
|
|
@@ -23,11 +23,12 @@ export type MessageOf<Type extends MessageType> = {
|
|
|
23
23
|
readonly context: number
|
|
24
24
|
readonly turn?: string
|
|
25
25
|
readonly task?: string
|
|
26
|
+
readonly agentType?: string
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export type Message = Prompt | Note | Reply | ToolCall | ToolResult | Skill | InstructionFile | AttachedFile | Notice
|
|
29
30
|
|
|
30
|
-
export type Placed = 'session' | 'context' | 'turn' | 'task'
|
|
31
|
+
export type Placed = 'session' | 'context' | 'turn' | 'task' | 'agentType'
|
|
31
32
|
|
|
32
33
|
export type Unplaced<M extends Message = Message> = M extends Message ? Omit<M, Placed> : never
|
|
33
34
|
|
|
@@ -16,6 +16,7 @@ export type Turn = RecordPart & {
|
|
|
16
16
|
readonly reason?: 'answer' | 'error'
|
|
17
17
|
readonly failure?: { readonly type: string; readonly text: string }
|
|
18
18
|
readonly device?: Device
|
|
19
|
+
readonly isAfterRefusal?: true
|
|
19
20
|
messages(): Promise<Message[]>
|
|
20
21
|
abort(): Promise<void>
|
|
21
22
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ContextEnd, ContextStart, type Context } from './context/context.js'
|
|
2
2
|
import { deviceOf, type Device } from './context/turn/device.js'
|
|
3
|
-
import { Message, messagesOf, tagOf, textOf, type Row } from './context/turn/message/message.js'
|
|
3
|
+
import { Message, messagesOf, tagOf, textOf, type Row, type Unplaced } from './context/turn/message/message.js'
|
|
4
4
|
import { Note } from './context/turn/message/note.js'
|
|
5
5
|
import { Prompt } from './context/turn/message/prompt.js'
|
|
6
6
|
import { ToolCall } from './context/turn/message/tool-call.js'
|
|
@@ -16,6 +16,7 @@ export type SessionData = {
|
|
|
16
16
|
readonly color?: string
|
|
17
17
|
readonly project: string
|
|
18
18
|
readonly cwd: string
|
|
19
|
+
readonly transcriptPath?: string
|
|
19
20
|
readonly model: string
|
|
20
21
|
readonly startedAt: string
|
|
21
22
|
readonly lastAt: string
|
|
@@ -68,6 +69,7 @@ export type SessionChange =
|
|
|
68
69
|
|
|
69
70
|
export type ConversationState = {
|
|
70
71
|
readonly session: string
|
|
72
|
+
readonly agentType?: string
|
|
71
73
|
readonly context: number
|
|
72
74
|
readonly contextOpenedAt: string
|
|
73
75
|
readonly turn?: TurnData
|
|
@@ -89,9 +91,19 @@ export type Conversation = {
|
|
|
89
91
|
startContext(at: string): SessionChange[]
|
|
90
92
|
endTurn(at: string, ending: TurnEnding, task?: string): SessionChange[]
|
|
91
93
|
changeGoal(text: string): SessionChange[]
|
|
94
|
+
changeAgentType(agentType: string): void
|
|
92
95
|
readonly state: ConversationState
|
|
93
96
|
}
|
|
94
97
|
|
|
98
|
+
export type MessagePlace = Pick<ConversationState, 'session' | 'agentType' | 'context' | 'turn' | 'tasks' | 'taskTurns' | 'openCalls'>
|
|
99
|
+
|
|
100
|
+
export function placedMessage(where: MessagePlace, unplaced: Unplaced, task: string | undefined, isInTurn = true, agentType = task === undefined ? where.agentType : where.tasks[task]?.agentType): Message {
|
|
101
|
+
const turn = isInTurn ? (task === undefined ? where.turn : where.taskTurns[task]) : undefined
|
|
102
|
+
const context = task === undefined ? where.context : (where.tasks[task]?.context ?? where.context)
|
|
103
|
+
const call = unplaced.type === ToolResult ? where.openCalls?.[unplaced.callId] : undefined
|
|
104
|
+
return { ...unplaced, ...call, session: where.session, context, ...(turn === undefined ? {} : { turn: turn.prompt.id }), ...(task === undefined ? {} : { task }), ...(agentType === undefined ? {} : { agentType }) }
|
|
105
|
+
}
|
|
106
|
+
|
|
95
107
|
export const searchLimit = 50
|
|
96
108
|
|
|
97
109
|
const agentTools: readonly string[] = ['Agent', 'Task']
|
|
@@ -103,7 +115,7 @@ export function emptyConversation(session: string): ConversationState {
|
|
|
103
115
|
}
|
|
104
116
|
|
|
105
117
|
export function createConversation(start: ConversationState): Conversation {
|
|
106
|
-
let { context, contextOpenedAt, turn, goal, device } = start
|
|
118
|
+
let { agentType, context, contextOpenedAt, turn, goal, device } = start
|
|
107
119
|
const agentCalls = new Set(start.agentCalls)
|
|
108
120
|
const endedCalls = new Map(Object.entries(start.endedCalls))
|
|
109
121
|
const tasks = new Map(Object.entries(start.tasks))
|
|
@@ -171,12 +183,14 @@ export function createConversation(start: ConversationState): Conversation {
|
|
|
171
183
|
if (row.type === 'system' && row.name === 'compact_boundary') return [...changes, ...(task === undefined ? [...endContext(row.at), ...startContext(row.at)] : compactTask(task, row.at))]
|
|
172
184
|
const owner = task === undefined ? undefined : tasks.get(task)
|
|
173
185
|
const placedIn = owner?.context ?? context
|
|
186
|
+
const agent = task === undefined ? agentType : owner?.agentType
|
|
187
|
+
const ofAgent = agent === undefined ? {} : { agentType: agent }
|
|
174
188
|
for (const unplaced of messagesOf(row, task !== undefined)) {
|
|
175
189
|
if (task === undefined && unplaced.type === Note) device = deviceOf(unplaced) ?? device
|
|
176
190
|
if (unplaced.type === Prompt) {
|
|
177
191
|
changes.push(...(task === undefined ? endTurn(row.at) : endTaskTurn(task, row.at)))
|
|
178
192
|
const ranOn = task === undefined ? device : owner?.device
|
|
179
|
-
const opened: TurnData = { prompt: { ...unplaced, session: start.session, context: placedIn, turn: unplaced.id, ...(task === undefined ? {} : { task }) }, context: placedIn, openedAt: row.at, ...(owner?.closedAt === undefined ? {} : { closedAt: owner.closedAt }), ...(ranOn === undefined ? {} : { device: ranOn }) }
|
|
193
|
+
const opened: TurnData = { prompt: { ...unplaced, session: start.session, context: placedIn, turn: unplaced.id, ...(task === undefined ? {} : { task }), ...ofAgent }, context: placedIn, openedAt: row.at, ...(owner?.closedAt === undefined ? {} : { closedAt: owner.closedAt }), ...(ranOn === undefined ? {} : { device: ranOn }) }
|
|
180
194
|
if (task === undefined) turn = opened
|
|
181
195
|
else taskTurns.set(task, opened)
|
|
182
196
|
changes.push({ type: TurnStart, turn: opened })
|
|
@@ -193,6 +207,7 @@ export function createConversation(start: ConversationState): Conversation {
|
|
|
193
207
|
context: placedIn,
|
|
194
208
|
...(open === undefined ? {} : { turn: open.prompt.id }),
|
|
195
209
|
...(task === undefined ? {} : { task }),
|
|
210
|
+
...ofAgent,
|
|
196
211
|
} as Message
|
|
197
212
|
changes.push({ type: Message, message: placed })
|
|
198
213
|
if (placed.type === ToolCall && agentTools.includes(placed.name)) agentCalls.add(placed.callId)
|
|
@@ -224,9 +239,13 @@ export function createConversation(start: ConversationState): Conversation {
|
|
|
224
239
|
startContext,
|
|
225
240
|
endTurn: (at, ending, task) => (task === undefined ? endTurn(at, ending) : endTaskTurn(task, at, ending)),
|
|
226
241
|
changeGoal,
|
|
242
|
+
changeAgentType(next) {
|
|
243
|
+
agentType = next
|
|
244
|
+
},
|
|
227
245
|
get state() {
|
|
228
246
|
return {
|
|
229
247
|
session: start.session,
|
|
248
|
+
...(agentType === undefined ? {} : { agentType }),
|
|
230
249
|
context,
|
|
231
250
|
contextOpenedAt,
|
|
232
251
|
...(turn === undefined ? {} : { turn }),
|
package/src/session/session.ts
CHANGED
|
@@ -165,6 +165,7 @@ export type Session = Pick<RecordPart, 'search'> & {
|
|
|
165
165
|
readonly agentType?: string
|
|
166
166
|
readonly model: string
|
|
167
167
|
readonly cwd: string
|
|
168
|
+
readonly transcriptPath?: string
|
|
168
169
|
readonly isRunning: boolean
|
|
169
170
|
readonly startedAt: string
|
|
170
171
|
readonly lastAt: string
|
|
@@ -336,7 +337,7 @@ export type ProcessAnswer = {
|
|
|
336
337
|
readonly WorktreeCreate: { readonly result: string }
|
|
337
338
|
readonly Elicitation: Refusal
|
|
338
339
|
readonly ElicitationResponse: Refusal
|
|
339
|
-
readonly PermissionCheck: { readonly allow: true } | { readonly ask: string } | Refusal
|
|
340
|
+
readonly PermissionCheck: { readonly allow: true; readonly note?: string } | { readonly ask: string; readonly note?: string } | Refusal | { readonly note: string }
|
|
340
341
|
readonly PermissionRequest: { readonly allow: true; readonly input?: Readonly<Record<string, unknown>>; readonly updates?: readonly PermissionUpdate[] } | (Refusal & { readonly interrupt?: true })
|
|
341
342
|
readonly PermissionDenial: { readonly retry: true }
|
|
342
343
|
readonly ToolBatch: { readonly note: string }
|
|
@@ -230,6 +230,7 @@ export function fakeClaude(plugin: { readonly name: string; readonly root: strin
|
|
|
230
230
|
usage: () => fakes.session.usage?.() ?? Promise.resolve({ startedAt: Date.parse('2026-01-01T00:00:00.000Z'), context: { window: 200000 }, rateLimits: [], cost: { usd: 0 } }),
|
|
231
231
|
surfaces: () => fakes.session.surfaces?.() ?? Promise.resolve(['terminal']),
|
|
232
232
|
version: async () => '2.1.317',
|
|
233
|
+
info: async () => ({ transcriptPath: '/test/transcripts/test-session.jsonl' }),
|
|
233
234
|
messages: rejected('session.messages', () => fakes.session.messages as ((args?: unknown) => Promise<unknown>) | undefined) as Claude['session']['messages'],
|
|
234
235
|
append: rejected('session.append', () => fakes.session.append ?? appendNote),
|
|
235
236
|
send: rejected('session.send', () => fakes.session.send ?? (async () => ({ isDelivered: true as const }))),
|
|
@@ -55,6 +55,8 @@ export function fakeServe(
|
|
|
55
55
|
): FakeServe {
|
|
56
56
|
const answer = <Key extends keyof SessionComputer>(key: Key): SessionComputer[Key] => (fakes()[key] ?? unfaked[key])
|
|
57
57
|
const linked = new Map<string, FakeServe>()
|
|
58
|
+
const reached = new Map<string, Here>()
|
|
59
|
+
let devices: Provided | undefined
|
|
58
60
|
let requests = 0
|
|
59
61
|
const routing = routeSessions({
|
|
60
62
|
device,
|
|
@@ -93,8 +95,11 @@ export function fakeServe(
|
|
|
93
95
|
async provide(given, connection) {
|
|
94
96
|
if (given.length === 0) return []
|
|
95
97
|
const here = await device()
|
|
96
|
-
const
|
|
97
|
-
for (const on of
|
|
98
|
+
const added = new Map(given.flatMap(({ device: on }) => (on === undefined || on.id === here.id || reached.has(on.id) ? [] : [[on.id, on] as const])))
|
|
99
|
+
for (const on of added.values()) {
|
|
100
|
+
reached.set(on.id, on)
|
|
101
|
+
linked.set(socketOf(on.id), fakeServe(() => ({}), { device: async () => on, clock }))
|
|
102
|
+
}
|
|
98
103
|
const provided = await Promise.all(
|
|
99
104
|
given.map(async ({ name, mod, program, device: on, methods }) => {
|
|
100
105
|
const { client, served } = connectTo((on === undefined ? undefined : linked.get(socketOf(on.id))) ?? serve, { ...connection, provider: { mod, program } })
|
|
@@ -103,10 +108,14 @@ export function fakeServe(
|
|
|
103
108
|
return each
|
|
104
109
|
}),
|
|
105
110
|
)
|
|
106
|
-
if (
|
|
111
|
+
if (added.size === 0) return provided
|
|
112
|
+
if (devices !== undefined) {
|
|
113
|
+
for (const on of added.keys()) devices.tell('Change', { device: on })
|
|
114
|
+
return provided
|
|
115
|
+
}
|
|
107
116
|
const { client, served } = connectTo(serve, { ...connection, provider: deviceLink })
|
|
108
|
-
served.provide(devicesInterface, {
|
|
109
|
-
devices: () => [...
|
|
117
|
+
devices = served.provide(devicesInterface, {
|
|
118
|
+
devices: () => [...reached.values()].map(({ id, name }) => ({ id, name, address: socketOf(id) })),
|
|
110
119
|
send: (to: string) => {
|
|
111
120
|
throw new Error(`The test kit reaches device ${to} at its address, so it carries no message.`)
|
|
112
121
|
},
|
|
@@ -12,7 +12,7 @@ import { Task, TaskStart } from '../session/goal/task.js'
|
|
|
12
12
|
import { Skill } from '../session/context/turn/message/skill.js'
|
|
13
13
|
import { ToolCall } from '../session/context/turn/message/tool-call.js'
|
|
14
14
|
import { ToolResult } from '../session/context/turn/message/tool-result.js'
|
|
15
|
-
import { createConversation, emptyConversation, searchLimit, tasksWithAgents, type ContextData, type Conversation, type SessionChange, type SessionData, type TaskData, type TurnData, type TurnEnding } from '../session/conversation.js'
|
|
15
|
+
import { createConversation, emptyConversation, placedMessage, searchLimit, tasksWithAgents, type ContextData, type Conversation, type SessionChange, type SessionData, type TaskData, type TurnData, type TurnEnding } from '../session/conversation.js'
|
|
16
16
|
import type { Decide, Place } from '../runtime/before.js'
|
|
17
17
|
import type { Claude } from '../runtime/claude.js'
|
|
18
18
|
import { testDevice } from './fake-claude.js'
|
|
@@ -300,9 +300,7 @@ export function fakeSessions({ project, cwd, given, push, callTool, listAgents,
|
|
|
300
300
|
const where = place()
|
|
301
301
|
const [unplaced] = messagesOf(rowOf(draft, `message-${(ids += 1)}`, now(), cwd()), task !== undefined)
|
|
302
302
|
if (unplaced === undefined) throw new Error(`A ${draft.type} draft makes no message.`)
|
|
303
|
-
|
|
304
|
-
const turn = task === undefined ? where.turn : where.taskTurns[task]
|
|
305
|
-
return { ...unplaced, ...call, session: where.session, context: task === undefined ? where.context : (where.tasks[task]?.context ?? where.context), ...(turn === undefined ? {} : { turn: turn.prompt.id }), ...(task === undefined ? {} : { task }) }
|
|
303
|
+
return placedMessage(where, unplaced, task)
|
|
306
304
|
},
|
|
307
305
|
place,
|
|
308
306
|
wants: wantsBefore,
|
package/src/testing.ts
CHANGED
|
@@ -79,7 +79,7 @@ export type ShownPart = {
|
|
|
79
79
|
export type Shown = ShownByClaude & { readonly toasts: readonly ShownToast[]; readonly sent: FakeSessions['sent']; readonly pane: ShownPart; readonly view: ShownPart; readonly page: ShownPart }
|
|
80
80
|
|
|
81
81
|
export type FakeProvider = {
|
|
82
|
-
readonly [Name in InterfaceName]: { readonly name: Name; readonly mod: string; readonly program?: string; readonly device?: { readonly id: string; readonly name: string }; readonly methods: InterfaceMethods<Name> }
|
|
82
|
+
readonly [Name in InterfaceName]: { readonly name: Name; readonly mod: string; readonly program?: string; readonly device?: { readonly id: string; readonly name: string }; readonly isStarted?: false; readonly methods: InterfaceMethods<Name> }
|
|
83
83
|
}[InterfaceName]
|
|
84
84
|
|
|
85
85
|
export type TestOptions<State extends object, Declared extends Options = Options, Given extends readonly FakeProvider[] = readonly FakeProvider[]> = {
|
|
@@ -143,7 +143,7 @@ export type TestedMod<State extends object, Given extends readonly FakeProvider[
|
|
|
143
143
|
readonly calls: readonly TestCall[]
|
|
144
144
|
readonly fakes: Fakes
|
|
145
145
|
readonly shown: Shown
|
|
146
|
-
readonly providers: { readonly [Index in keyof Given]: Provided<Given[Index]['name']> }
|
|
146
|
+
readonly providers: { readonly [Index in keyof Given]: Provided<Given[Index]['name']> & { start(): void } }
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
const defaultColumns = 80
|
|
@@ -185,6 +185,7 @@ export function testMod<State extends object, Declared extends Options = Options
|
|
|
185
185
|
let toolUses = 0
|
|
186
186
|
let slotDraws = 0
|
|
187
187
|
fake.claude.session.id = async () => answeredId
|
|
188
|
+
fake.claude.session.info = async () => ({ transcriptPath: `/test/transcripts/${answeredId}.jsonl` })
|
|
188
189
|
fake.claude.session.root = async () => projectRoot
|
|
189
190
|
fake.claude.session.cwd = async () => cwd
|
|
190
191
|
const conversations = fakeSessions({
|
|
@@ -336,29 +337,46 @@ export function testMod<State extends object, Declared extends Options = Options
|
|
|
336
337
|
after,
|
|
337
338
|
report,
|
|
338
339
|
})
|
|
339
|
-
const
|
|
340
|
-
|
|
340
|
+
const inSession = (index: number) => {
|
|
341
|
+
const { name: named, mod, methods } = given[index] as FakeProvider
|
|
341
342
|
const made = sessionMods.get(mod) ?? createProviders({ name: mod, call: (_to, method, input) => served.answer(method, input, mod) ?? Promise.reject(new Error(`${mod} reaches no ${method} in the test kit.`)), changed: () => undefined, after, report })
|
|
342
343
|
sessionMods.set(mod, made)
|
|
343
344
|
return made.provide(named, methods)
|
|
344
|
-
}
|
|
345
|
-
|
|
345
|
+
}
|
|
346
|
+
const asProgram = (index: number) => {
|
|
347
|
+
const { name: named, mod, program, device, methods } = given[index] as FakeProvider
|
|
348
|
+
return { name: named, mod, program: program as string, ...(device === undefined ? {} : { device }), methods }
|
|
349
|
+
}
|
|
350
|
+
const isFirst = (index: number) => given[index]?.isStarted !== false
|
|
351
|
+
const providedInSession = given.map((each, index) => (each.program === undefined && isFirst(index) ? inSession(index) : undefined))
|
|
352
|
+
const late = new Map<number, Promise<ProvidedHandle>>()
|
|
353
|
+
const startLate = (index: number) => {
|
|
354
|
+
const known = late.get(index)
|
|
355
|
+
if (known !== undefined) return known
|
|
356
|
+
const started = fakeProviders().then(async () => (given[index]?.program === undefined ? inSession(index) : ((await fake.serve.provide([asProgram(index)], { after, report }))[0] as ProvidedHandle)))
|
|
357
|
+
late.set(index, started)
|
|
358
|
+
return started
|
|
359
|
+
}
|
|
360
|
+
let fakesReady: Promise<readonly (ProvidedHandle | undefined)[]> | undefined
|
|
346
361
|
const fakeProviders = () =>
|
|
347
362
|
(fakesReady ??= (async () => {
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
)
|
|
352
|
-
let next = 0
|
|
353
|
-
return providedInSession.map((inSession) => inSession ?? (programs[next++] as ProvidedHandle))
|
|
363
|
+
const first = given.flatMap((each, index) => (each.program !== undefined && isFirst(index) ? [index] : []))
|
|
364
|
+
const programs = await fake.serve.provide(first.map(asProgram), { after, report })
|
|
365
|
+
return given.map((_each, index) => providedInSession[index] ?? (first.includes(index) ? programs[first.indexOf(index)] : undefined))
|
|
354
366
|
})())
|
|
355
|
-
const fakeProvider = (index: number): ProvidedHandle => {
|
|
356
|
-
const reached = async () => {
|
|
357
|
-
const
|
|
367
|
+
const fakeProvider = (index: number): ProvidedHandle & { start(): void } => {
|
|
368
|
+
const reached = async (): Promise<ProvidedHandle> => {
|
|
369
|
+
const started = late.get(index)
|
|
370
|
+
const each = (await fakeProviders())[index] ?? (started === undefined ? undefined : await started)
|
|
371
|
+
if (each === undefined) throw new Error(`The test kit's fake provider ${index} has isStarted: false, so start() it before it tells, asks, or leaves.`)
|
|
358
372
|
await fake.settle()
|
|
359
373
|
return each
|
|
360
374
|
}
|
|
361
375
|
return {
|
|
376
|
+
start: () => {
|
|
377
|
+
if (isFirst(index)) throw new Error(`The test kit's fake provider ${index} runs from the start. Give it isStarted: false to start it later.`)
|
|
378
|
+
void modeling(startLate(index).then(() => fake.settle()))
|
|
379
|
+
},
|
|
362
380
|
remove: () => void modeling(reached().then((each) => each.remove())),
|
|
363
381
|
tell: (event, payload) => void modeling(reached().then((each) => each.tell(event, payload))),
|
|
364
382
|
ask: (event, payload) => modeling(reached().then((each) => each.ask(event, payload))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fake-claude.d.ts","sourceRoot":"","sources":["../src/testing/fake-claude.ts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AAC,MAAM,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAqN/F"}
|
package/testing/fake-claude.js
CHANGED
|
@@ -176,6 +176,7 @@ export function fakeClaude(plugin) {
|
|
|
176
176
|
usage: () => fakes.session.usage?.() ?? Promise.resolve({ startedAt: Date.parse('2026-01-01T00:00:00.000Z'), context: { window: 200000 }, rateLimits: [], cost: { usd: 0 } }),
|
|
177
177
|
surfaces: () => fakes.session.surfaces?.() ?? Promise.resolve(['terminal']),
|
|
178
178
|
version: async () => '2.1.317',
|
|
179
|
+
info: async () => ({ transcriptPath: '/test/transcripts/test-session.jsonl' }),
|
|
179
180
|
messages: rejected('session.messages', () => fakes.session.messages),
|
|
180
181
|
append: rejected('session.append', () => fakes.session.append ?? appendNote),
|
|
181
182
|
send: rejected('session.send', () => fakes.session.send ?? (async () => ({ isDelivered: true }))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fake-serve.d.ts","sourceRoot":"","sources":["../src/testing/fake-serve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAqF,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAE/R,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AAE/D,KAAK,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,MAAM,CAAC,CAAA;AAEvC,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAA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E,CAAA;AAuBvF,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,EACrC,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAiB,EAAE,EAAE;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,CAAA;CAAE,GAC/I,SAAS,CA6EX"}
|
package/testing/fake-serve.js
CHANGED
|
@@ -16,6 +16,8 @@ const socketOf = (device) => `/test/devices/${device}/serve.sock`;
|
|
|
16
16
|
export function fakeServe(fakes, { device, programs, clock = realClock }) {
|
|
17
17
|
const answer = (key) => (fakes()[key] ?? unfaked[key]);
|
|
18
18
|
const linked = new Map();
|
|
19
|
+
const reached = new Map();
|
|
20
|
+
let devices;
|
|
19
21
|
let requests = 0;
|
|
20
22
|
const routing = routeSessions({
|
|
21
23
|
device,
|
|
@@ -56,21 +58,27 @@ export function fakeServe(fakes, { device, programs, clock = realClock }) {
|
|
|
56
58
|
if (given.length === 0)
|
|
57
59
|
return [];
|
|
58
60
|
const here = await device();
|
|
59
|
-
const
|
|
60
|
-
for (const on of
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
const added = new Map(given.flatMap(({ device: on }) => (on === undefined || on.id === here.id || reached.has(on.id) ? [] : [[on.id, on]])));
|
|
62
|
+
for (const on of added.values()) {
|
|
63
|
+
reached.set(on.id, on);
|
|
64
|
+
linked.set(socketOf(on.id), fakeServe(() => ({}), { device: async () => on, clock }));
|
|
65
|
+
}
|
|
63
66
|
const provided = await Promise.all(given.map(async ({ name, mod, program, device: on, methods }) => {
|
|
64
67
|
const { client, served } = connectTo((on === undefined ? undefined : linked.get(socketOf(on.id))) ?? serve, { ...connection, provider: { mod, program } });
|
|
65
68
|
const each = served.provide(name, methods);
|
|
66
69
|
await client.request(providerActs.providers, { interface: name });
|
|
67
70
|
return each;
|
|
68
71
|
}));
|
|
69
|
-
if (
|
|
72
|
+
if (added.size === 0)
|
|
70
73
|
return provided;
|
|
74
|
+
if (devices !== undefined) {
|
|
75
|
+
for (const on of added.keys())
|
|
76
|
+
devices.tell('Change', { device: on });
|
|
77
|
+
return provided;
|
|
78
|
+
}
|
|
71
79
|
const { client, served } = connectTo(serve, { ...connection, provider: deviceLink });
|
|
72
|
-
served.provide(devicesInterface, {
|
|
73
|
-
devices: () => [...
|
|
80
|
+
devices = served.provide(devicesInterface, {
|
|
81
|
+
devices: () => [...reached.values()].map(({ id, name }) => ({ id, name, address: socketOf(id) })),
|
|
74
82
|
send: (to) => {
|
|
75
83
|
throw new Error(`The test kit reaches device ${to} at its address, so it carries no message.`);
|
|
76
84
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fake-sessions.d.ts","sourceRoot":"","sources":["../src/testing/fake-sessions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAoB,KAAK,cAAc,EAAE,MAAM,kDAAkD,CAAA;AACtH,OAAO,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAA;AACrF,OAAO,EAAE,OAAO,EAA0D,MAAM,4CAA4C,CAAA;AAC5H,OAAO,EAAE,IAAI,EAAE,MAAM,yCAAyC,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,0CAA0C,CAAA;AAChE,OAAO,EAAyB,KAAK,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAG9F,OAAO,EAAE,KAAK,EAAE,MAAM,0CAA0C,CAAA;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,8CAA8C,CAAA;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,gDAAgD,CAAA;AAC3E,OAAO,
|
|
1
|
+
{"version":3,"file":"fake-sessions.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MAAM,GAAG,IAAI,CAAA;IACvB,KAAK,IAAI,YAAY,CAAA;IACrB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,YAAY,CAAA;IAChD,QAAQ,IAAI,QAAQ,GAAG,SAAS,CAAA;IAChC,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAC1I,CAAA;AAED,wBAAgB,YAAY,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,YAAY,CA6Q9Y"}
|
package/testing/fake-sessions.js
CHANGED
|
@@ -12,7 +12,7 @@ import { Task, TaskStart } from '../session/goal/task.js';
|
|
|
12
12
|
import { Skill } from '../session/context/turn/message/skill.js';
|
|
13
13
|
import { ToolCall } from '../session/context/turn/message/tool-call.js';
|
|
14
14
|
import { ToolResult } from '../session/context/turn/message/tool-result.js';
|
|
15
|
-
import { createConversation, emptyConversation, searchLimit, tasksWithAgents } from '../session/conversation.js';
|
|
15
|
+
import { createConversation, emptyConversation, placedMessage, searchLimit, tasksWithAgents } from '../session/conversation.js';
|
|
16
16
|
import { testDevice } from './fake-claude.js';
|
|
17
17
|
import { conversationMethods, isHeardBy, resultOf } from '../runtime/sessions.js';
|
|
18
18
|
import { receivedMatcher } from '../utils/matcher.js';
|
|
@@ -263,9 +263,7 @@ export function fakeSessions({ project, cwd, given, push, callTool, listAgents,
|
|
|
263
263
|
const [unplaced] = messagesOf(rowOf(draft, `message-${(ids += 1)}`, now(), cwd()), task !== undefined);
|
|
264
264
|
if (unplaced === undefined)
|
|
265
265
|
throw new Error(`A ${draft.type} draft makes no message.`);
|
|
266
|
-
|
|
267
|
-
const turn = task === undefined ? where.turn : where.taskTurns[task];
|
|
268
|
-
return { ...unplaced, ...call, session: where.session, context: task === undefined ? where.context : (where.tasks[task]?.context ?? where.context), ...(turn === undefined ? {} : { turn: turn.prompt.id }), ...(task === undefined ? {} : { task }) };
|
|
266
|
+
return placedMessage(where, unplaced, task);
|
|
269
267
|
},
|
|
270
268
|
place,
|
|
271
269
|
wants: wantsBefore,
|