refactor(native-chat): group tool attribution modules (#33482)

This commit is contained in:
Neil
2026-10-25 02:45:52 -07:00
committed by GitHub
parent 0b28553093
commit 3e950ca049
45 changed files with 149 additions and 85 deletions
+2 -2
View File
@@ -18,8 +18,8 @@ on:
# without these a rename lands green and only breaks the next nightly.
- 'src/main/sqlite/sync-database.test.ts'
- 'src/main/runtime/orchestration/db/row-column-lists.test.ts'
- 'src/shared/native-chat-tool-attribution-allocation.test.ts'
- 'src/shared/native-chat-tool-pairing.performance.test.ts'
- 'src/shared/native-chat/tools/native-chat-tool-attribution-allocation.test.ts'
- 'src/shared/native-chat/tools/native-chat-tool-pairing.performance.test.ts'
- 'src/main/codex-usage/codex-rollout-file-lifetime.test.ts'
- 'src/main/codex-usage/scanner-incremental-append.test.ts'
- 'src/main/usage/jsonl-file-reader.test.ts'
+3 -3
View File
@@ -11585,13 +11585,13 @@
"src/shared/native-chat-subagent-summary.test.ts": 54,
"src/shared/native-chat-task-list.test.ts": 45,
"src/shared/native-chat-tool-activity.test.ts": 49,
"src/shared/native-chat-tool-attribution-allocation.test.ts": 112,
"src/shared/native-chat/tools/native-chat-tool-attribution-allocation.test.ts": 112,
"src/shared/native-chat-tool-fold-attribution.test.ts": 39,
"src/shared/native-chat-tool-icon.test.ts": 83,
"src/shared/native-chat-tool-identity.test.ts": 64,
"src/shared/native-chat-tool-line-identity.test.ts": 33,
"src/shared/native-chat-tool-pair-limit.test.ts": 75,
"src/shared/native-chat-tool-pairing.performance.test.ts": 463,
"src/shared/native-chat/tools/native-chat-tool-pairing.performance.test.ts": 463,
"src/shared/native-chat-tool-pairing.test.ts": 41,
"src/shared/native-chat-tool-preview-prefix.test.ts": 31,
"src/shared/native-chat-tool-preview-scan.test.ts": 37,
@@ -11604,7 +11604,7 @@
"src/shared/native-chat-turn-activity.test.ts": 216,
"src/shared/native-chat-turn-fold.test.ts": 42,
"src/shared/native-chat-turn-grouping.test.ts": 212,
"src/shared/native-chat-turn-membership-derived-tool-row.test.ts": 328,
"src/shared/native-chat/tools/native-chat-turn-membership-derived-tool-row.test.ts": 328,
"src/shared/native-chat-turn-membership.test.ts": 253,
"src/shared/native-chat-turn-status.test.ts": 69,
"src/shared/native-chat-unverifiable-turn-status.test.ts": 245,
+45 -4
View File
@@ -22,11 +22,11 @@ const refs = {
published: 'b1e44269d655608447dc535f0a4d7d05c37c80b7',
current: null
}
const entry = `
export { foldToolMessages as fold } from './src/shared/native-chat-tool-fold'
const entry = (ref) => `
export { foldToolMessages as fold } from '${ref ? './src/shared/native-chat-tool-fold' : './src/shared/native-chat/tools/native-chat-tool-fold'}'
import { createNativeChatMessageListProjection } from './src/renderer/src/components/native-chat/native-chat-message-list-projection'
import { deriveNativeChatRowContent } from './src/shared/native-chat-row-content'
import { pairNativeChatToolResults } from './src/shared/native-chat-tool-pairing'
import { pairNativeChatToolResults } from '${ref ? './src/shared/native-chat-tool-pairing' : './src/shared/native-chat/tools/native-chat-tool-pairing'}'
export function createPipeline() {
const project = createNativeChatMessageListProjection()
return (messages) => {
@@ -74,10 +74,25 @@ if (process.argv.includes('--memory-control')) {
}
async function load(ref) {
let snapshotFiles
if (ref) {
const listed = runProcessSync({
program: 'git',
args: ['ls-tree', '-r', '--name-only', ref, '--', 'src'],
cwd: root,
env: { ...process.env, ORCA_BACKGROUND_LAUNCH: '1' },
timeoutMs: 30_000,
maxOutputBytes: 2 * 1024 * 1024
})
if (listed.code !== 0 || listed.timedOut || listed.outputTruncated) {
throw new Error(describeProcessFailure(listed))
}
snapshotFiles = new Set(listed.stdout.trim().split('\n'))
}
const modules = new Map()
const built = await build({
stdin: {
contents: entry,
contents: entry(ref),
resolveDir: root,
sourcefile: 'fold-benchmark-entry.ts',
loader: 'ts'
@@ -90,6 +105,32 @@ async function load(ref) {
{
name: 'exact-chat-source-snapshot',
setup(builder) {
builder.onResolve({ filter: /^\./ }, (args) => {
if (!ref) {
return undefined
}
const target = path
.relative(root, path.resolve(args.resolveDir, args.path))
.split(path.sep)
.join('/')
if (!target.startsWith('src/')) {
return undefined
}
const candidates = [
target,
...['.tsx', '.ts', '.jsx', '.js', '.css', '.json'].map(
(extension) => target + extension
),
...['.tsx', '.ts', '.jsx', '.js', '.css', '.json'].map(
(extension) => `${target}/index${extension}`
)
]
const file = candidates.find((candidate) => snapshotFiles.has(candidate))
if (!file) {
throw new Error(`Missing snapshot source: ${ref}:${target}`)
}
return { path: path.join(root, file) }
})
builder.onLoad({ filter: /\.[cm]?[jt]sx?$/ }, ({ path: file }) => {
const relative = path.relative(root, file).split(path.sep).join('/')
if (!relative.startsWith('src/')) {
@@ -9,18 +9,35 @@ import { summarizeBenchmarkSamples } from './benchmark-sample-summary.mjs'
// git show <baseline>:src/shared/native-chat-tool-fold.ts | node config/scripts/native-chat-tool-pairing-benchmark.mjs
const root = path.resolve(import.meta.dirname, '../..')
async function load(source) {
async function load(source, sourcefile = 'src/shared/native-chat-tool-fold.ts') {
const built = await build({
stdin: {
contents: source,
sourcefile: 'native-chat-tool-fold.ts',
resolveDir: path.join(root, 'src/shared'),
sourcefile: path.basename(sourcefile),
resolveDir: path.dirname(path.join(root, sourcefile)),
loader: 'ts'
},
bundle: true,
write: false,
platform: 'node',
format: 'esm'
format: 'esm',
plugins: [
{
name: 'relocated-current-pairing-dependencies',
setup(builder) {
builder.onResolve({ filter: /^\./ }, (args) => {
const target = path.resolve(args.resolveDir, args.path)
for (const name of ['native-chat-tool-pairs', 'native-chat-folded-tool-results']) {
const previous = path.join(root, 'src/shared', name)
if (target === previous || target === `${previous}.ts`) {
return { path: path.join(root, 'src/shared/native-chat/tools', `${name}.ts`) }
}
}
return undefined
})
}
}
]
})
const code = built.outputFiles[0].text
return {
@@ -32,7 +49,10 @@ async function load(source) {
const loaded = {
before: await load(readFileSync(0, 'utf8')),
after: await load(readFileSync(path.join(root, 'src/shared/native-chat-tool-fold.ts'), 'utf8'))
after: await load(
readFileSync(path.join(root, 'src/shared/native-chat/tools/native-chat-tool-pairs.ts'), 'utf8'),
'src/shared/native-chat/tools/native-chat-tool-pairs.ts'
)
}
const call = (callId) => ({ type: 'tool-call', name: 'Bash', input: {}, callId })
const result = (callId) => ({ type: 'tool-result', output: 'done', callId })
+2 -2
View File
@@ -11,8 +11,8 @@ const contracts = [
'src/renderer/src/components/tab-bar/use-new-tab-agent-menu-host-preferences.test.tsx',
'src/main/sqlite/sync-database.test.ts',
'src/main/runtime/orchestration/db/row-column-lists.test.ts',
'src/shared/native-chat-tool-attribution-allocation.test.ts',
'src/shared/native-chat-tool-pairing.performance.test.ts',
'src/shared/native-chat/tools/native-chat-tool-attribution-allocation.test.ts',
'src/shared/native-chat/tools/native-chat-tool-pairing.performance.test.ts',
'src/main/codex-usage/codex-rollout-file-lifetime.test.ts',
'src/main/codex-usage/scanner-incremental-append.test.ts',
'src/main/usage/jsonl-file-reader.test.ts',
@@ -6,7 +6,7 @@ import type {
AgentJournalItemBody,
AgentJournalRenderItem
} from '../../../src/shared/agent-session-journal-types'
import * as toolFold from '../../../src/shared/native-chat-tool-fold'
import * as toolFold from '../../../src/shared/native-chat/tools/native-chat-tool-pairs'
import { projectStructuredItemsToNativeChat } from '../../../src/shared/structured-agent-session-projection'
import { foldMobileNativeChatMessages } from './mobile-native-chat-render-data'
import { useMobileNativeChatTurnDisclosure } from './use-mobile-native-chat-turn-disclosure'
@@ -2,7 +2,7 @@ import { memo, useCallback, useContext, useLayoutEffect, useMemo, useRef } from
import { Text, View } from 'react-native'
import { INLINE_TEXT_SELECTION } from '../components/inline-text-selection'
import { MobileNativeChatLongPressContent as Content } from './MobileNativeChatLongPressContent'
import { splitNativeChatBlocks } from '../../../src/shared/native-chat-tool-fold'
import { splitNativeChatBlocks } from '../../../src/shared/native-chat/tools/native-chat-tool-fold'
import { selectActiveToolCall } from '../../../src/shared/native-chat-tool-activity'
import {
isImageRefBlock,
@@ -26,7 +26,7 @@ import {
} from '../../../src/shared/native-chat-tool-activity'
import { nativeChatToolRunIconName } from '../../../src/shared/native-chat-tool-icon'
import { nativeChatToolLineIdentity } from '../../../src/shared/native-chat-tool-line-identity'
import { pairNativeChatToolResults } from '../../../src/shared/native-chat-tool-pairing'
import { pairNativeChatToolResults } from '../../../src/shared/native-chat/tools/native-chat-tool-pairing'
import { nativeChatToolRunOutcome } from '../../../src/shared/native-chat-tool-run-outcome'
import {
NATIVE_CHAT_TOOL_RUN_SENTENCE_ENGLISH,
@@ -1,5 +1,6 @@
import { describe, expect, it } from 'vitest'
import { foldToolMessages, pairToolBlocks } from '../../../src/shared/native-chat-tool-fold'
import { foldToolMessages } from '../../../src/shared/native-chat/tools/native-chat-tool-fold'
import { pairToolBlocks } from '../../../src/shared/native-chat/tools/native-chat-tool-pairs'
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
function msg(
@@ -6,7 +6,7 @@ import {
type ReactTestRendererJSON as Node
} from 'react-test-renderer'
import { afterEach, expect, it, vi } from 'vitest'
import { splitNativeChatBlocks } from '../../../src/shared/native-chat-tool-fold'
import { splitNativeChatBlocks } from '../../../src/shared/native-chat/tools/native-chat-tool-fold'
import type { NativeChatBlock, NativeChatMessage } from '../../../src/shared/native-chat-types'
import { foldMobileNativeChatMessages } from './mobile-native-chat-render-data'
import {
@@ -10,7 +10,7 @@ import { isWordlessProviderFrameMessage } from '../../../src/shared/native-chat/
import {
foldToolMessages,
isUndrawnProviderFrameMessage
} from '../../../src/shared/native-chat-tool-fold'
} from '../../../src/shared/native-chat/tools/native-chat-tool-fold'
import { projectNativeChatTaskListFrames } from '../../../src/shared/native-chat-task-list-frames'
import { foldSubagentItems } from '../../../src/shared/native-chat-subagent-items'
import { prepareNativeChatMessages } from '../../../src/shared/native-chat-message-preparation'
@@ -1,6 +1,6 @@
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
import type { NativeChatResolvedPrompt } from '../../../src/shared/native-chat-resolution-receipt'
import { splitNativeChatBlocks } from '../../../src/shared/native-chat-tool-fold'
import { splitNativeChatBlocks } from '../../../src/shared/native-chat/tools/native-chat-tool-fold'
import { nativeChatWorkRunEntries } from '../../../src/shared/native-chat-work-run'
import { nativeChatAskRunBlocks } from '../../../src/shared/native-chat-ask-row'
import type { MobileNativeChatWorkRuns } from './use-mobile-native-chat-transcript-rows'
@@ -12,7 +12,7 @@ import {
import { createRoot, type Root } from 'react-dom/client'
import { afterEach, expect, it, vi } from 'vitest'
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
import { foldToolMessages } from '../../../src/shared/native-chat-tool-fold'
import { foldToolMessages } from '../../../src/shared/native-chat/tools/native-chat-tool-fold'
import { MobileNativeChatMessage } from './MobileNativeChatMessage'
import { MobileNativeChatScrollRootsBoundary } from './MobileNativeChatScrollRootsBoundary'
import { MobileNativeChatScrollMotion } from './mobile-native-chat-scroll-motion'
@@ -1,7 +1,7 @@
import { createElement } from 'react'
import { act, create, type ReactTestRenderer } from 'react-test-renderer'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { pairToolBlocks } from '../../../src/shared/native-chat-tool-fold'
import { pairToolBlocks } from '../../../src/shared/native-chat/tools/native-chat-tool-pairs'
import { nativeChatTurnMembership } from '../../../src/shared/native-chat-turn-membership'
import type { NativeChatMessage } from '../../../src/shared/native-chat-types'
import type { RpcClient } from '../transport/rpc-client'
@@ -5,8 +5,8 @@ import type {
AgentJournalItemBody,
AgentJournalRenderItem
} from '../../shared/agent-session-journal-types'
import { pairToolBlocks } from '../../shared/native-chat-tool-fold'
import { pairNativeChatToolResults } from '../../shared/native-chat-tool-pairing'
import { pairToolBlocks } from '../../shared/native-chat/tools/native-chat-tool-pairs'
import { pairNativeChatToolResults } from '../../shared/native-chat/tools/native-chat-tool-pairing'
import { projectNativeChatTranscript } from '../../shared/native-chat-transcript-projection'
import type { NativeChatBlock, NativeChatMessage } from '../../shared/native-chat-types'
import { projectStructuredAgentSessionMessages } from '../../shared/structured-agent-session-message-projection'
@@ -4,7 +4,8 @@ import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import { agentJournalItemKey } from '../../../shared/agent-session-journal-item-key'
import type { AgentJournalRenderItem } from '../../../shared/agent-session-journal-types'
import { foldToolMessages, pairToolBlocks } from '../../../shared/native-chat-tool-fold'
import { foldToolMessages } from '../../../shared/native-chat/tools/native-chat-tool-fold'
import { pairToolBlocks } from '../../../shared/native-chat/tools/native-chat-tool-pairs'
import { projectNativeChatTranscriptMessages } from '../../../shared/native-chat-transcript-projection'
import { projectStructuredItemsToNativeChat } from '../../../shared/structured-agent-session-projection'
import { prepareLegacyTranscriptImport } from './journal-legacy-import'
@@ -2,7 +2,8 @@ import { mkdtemp, rm, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import { foldToolMessages, pairToolBlocks } from '../../shared/native-chat-tool-fold'
import { foldToolMessages } from '../../shared/native-chat/tools/native-chat-tool-fold'
import { pairToolBlocks } from '../../shared/native-chat/tools/native-chat-tool-pairs'
import type { NativeChatMessage } from '../../shared/native-chat-types'
import { decodeClaudeTranscriptLine } from './transcript-line-decoders-claude'
import { decodeCodexTranscriptLine } from './transcript-line-decoders-codex'
@@ -4,7 +4,8 @@ import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import { stripNoiseMessages } from '../../shared/native-chat-noise'
import { mergeNativeChatMessages } from '../../shared/native-chat-merge'
import { foldToolMessages, pairToolBlocks } from '../../shared/native-chat-tool-fold'
import { foldToolMessages } from '../../shared/native-chat/tools/native-chat-tool-fold'
import { pairToolBlocks } from '../../shared/native-chat/tools/native-chat-tool-pairs'
import { isToolCallBlock, isToolResultBlock } from '../../shared/native-chat-types'
import type { NativeChatMessage } from '../../shared/native-chat-types'
import { decodeClaudeTranscriptLine } from './transcript-line-decoders-claude'
@@ -2,7 +2,8 @@ import { describe, expect, it } from 'vitest'
import type { AgentJournalRenderItem } from '../../../shared/agent-session-journal-types'
import type { NativeChatMessage } from '../../../shared/native-chat-types'
import { buildStructuredJournalArchive } from './structured-worker-journal-archive'
import { foldToolMessages, pairToolBlocks } from '../../../shared/native-chat-tool-fold'
import { foldToolMessages } from '../../../shared/native-chat/tools/native-chat-tool-fold'
import { pairToolBlocks } from '../../../shared/native-chat/tools/native-chat-tool-pairs'
const STRUCTURED_ARCHIVE_MAX_BYTES = 262_144
@@ -1,7 +1,7 @@
import { useMemo } from 'react'
import type { CommentMarkdownLinkClickHandler } from '@/components/sidebar/CommentMarkdown'
import type { NativeChatBlock, NativeChatToolCallBlock } from '../../../../shared/native-chat-types'
import { pairNativeChatToolResults } from '../../../../shared/native-chat-tool-pairing'
import { pairNativeChatToolResults } from '../../../../shared/native-chat/tools/native-chat-tool-pairing'
import { nativeChatToolLineIdentity } from '../../../../shared/native-chat-tool-line-identity'
import { NativeChatDiffCard } from './NativeChatDiffCard'
import { NativeChatTaskList } from './NativeChatTaskList'
@@ -3,8 +3,8 @@ import type { NativeChatMessage } from '../../../../shared/native-chat-types'
import { createNativeChatMessageListProjection } from './native-chat-message-list-projection'
import { orderNativeChatMessages } from './native-chat-message-grouping'
import { stripNoiseMessages } from './native-chat-noise'
import { foldToolMessages } from './native-chat-tool-fold'
import { pairToolBlocks } from '../../../../shared/native-chat-tool-pairs'
import { foldToolMessages } from '../../../../shared/native-chat/tools/native-chat-tool-fold'
import { pairToolBlocks } from '../../../../shared/native-chat/tools/native-chat-tool-pairs'
function message(
id: string,
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import type { NativeChatBlock, NativeChatMessage } from '../../../../shared/native-chat-types'
import { foldToolMessages } from './native-chat-tool-fold'
import { foldToolMessages } from '../../../../shared/native-chat/tools/native-chat-tool-fold'
import { nativeChatTaskListState } from './native-chat-task-list-state'
function message(id: string, blocks: NativeChatBlock[]): NativeChatMessage {
@@ -3,7 +3,7 @@ import {
type NativeChatTaskList
} from '../../../../shared/native-chat-task-list'
import type { NativeChatMessage } from '../../../../shared/native-chat-types'
import { pairToolBlocks } from './native-chat-tool-fold'
import { pairToolBlocks } from '../../../../shared/native-chat/tools/native-chat-tool-pairs'
const snapshots = new WeakMap<NativeChatMessage, NativeChatTaskList | null>()
@@ -1,7 +1,10 @@
import { describe, it, expect } from 'vitest'
import type { NativeChatMessage } from '../../../../shared/native-chat-types'
import { stripNoiseMessages } from './native-chat-noise'
import { foldToolMessages, splitNativeChatBlocks } from './native-chat-tool-fold'
import {
foldToolMessages,
splitNativeChatBlocks
} from '../../../../shared/native-chat/tools/native-chat-tool-fold'
function msg(
overrides: Partial<NativeChatMessage> & Pick<NativeChatMessage, 'id'>
@@ -1,6 +0,0 @@
export {
foldToolMessages,
pairToolBlocks,
splitNativeChatBlocks,
type NativeChatToolPair
} from '../../../../shared/native-chat-tool-fold'
@@ -1,7 +1,7 @@
import { MAX_EDIT_LINES } from '../../../../shared/native-chat-edit-model'
import { describe, expect, it } from 'vitest'
import type { NativeChatBlock, NativeChatMessage } from '../../../../shared/native-chat-types'
import { foldToolMessages } from './native-chat-tool-fold'
import { foldToolMessages } from '../../../../shared/native-chat/tools/native-chat-tool-fold'
import { buildDiffSummaries, buildEditCards } from '../../../../shared/native-chat-edit-cards'
import { nativeChatTurnDiffEditFile, nativeChatTurnDiffs } from './native-chat-turn-diffs'
@@ -1,7 +1,8 @@
import { describe, expect, it } from 'vitest'
import type { AgentJournalRenderItem } from '../../../../shared/agent-session-journal-types'
import type { NativeChatMessage } from '../../../../shared/native-chat-types'
import { foldToolMessages, pairToolBlocks } from '../../../../shared/native-chat-tool-fold'
import { foldToolMessages } from '../../../../shared/native-chat/tools/native-chat-tool-fold'
import { pairToolBlocks } from '../../../../shared/native-chat/tools/native-chat-tool-pairs'
import {
nativeChatWorkRunEditKey,
nativeChatWorkRunEntries
+1 -1
View File
@@ -6,7 +6,7 @@ import { isAskUserQuestionTool } from './agent-question-answered-intent'
import { CODEX_ASYNC_QUESTION_TOOL } from './codex-async-question-input'
import { parseAskFromToolInput } from './native-chat-ask'
import { isToolCallBlock, type NativeChatBlock } from './native-chat-types'
import { pairToolBlocks } from './native-chat-tool-fold'
import { pairToolBlocks } from './native-chat/tools/native-chat-tool-pairs'
export const NATIVE_CHAT_ASK_ROW_COPY = {
awaiting: 'Awaiting user input:',
+1 -1
View File
@@ -9,7 +9,7 @@ import {
editFilesFromPatchText,
type NativeChatEditFileSummary
} from './native-chat-edit-patch-files'
import { pairToolBlocks } from './native-chat-tool-fold'
import { pairToolBlocks } from './native-chat/tools/native-chat-tool-pairs'
/** A diff card's own words. Desktop maps these onto `translate`; mobile renders them. */
export const NATIVE_CHAT_DIFF_CARD_COPY = {
+1 -1
View File
@@ -14,7 +14,7 @@ import {
isSubagentGroupBlock,
type NativeChatBlock
} from './native-chat-types'
import { splitNativeChatBlocks } from './native-chat-tool-fold'
import { splitNativeChatBlocks } from './native-chat/tools/native-chat-tool-fold'
import { nativeChatProseToMarkdown } from './native-chat-prose'
/** Inferred from `derive` so the shape cannot drift from what it returns. */
+1 -1
View File
@@ -9,7 +9,7 @@ import type {
NativeChatMessage,
NativeChatToolCallBlock
} from './native-chat-types'
import { pairToolBlocks } from './native-chat-tool-fold'
import { pairToolBlocks } from './native-chat/tools/native-chat-tool-pairs'
export type NativeChatTaskListPredecessors = Partial<
Record<NativeChatTaskListTool, NativeChatToolCallBlock>
@@ -1,14 +1,14 @@
import './native-chat-reasoning-row.spec'
import './native-chat-reasoning-order.spec'
import './native-chat-tool-activity.spec'
import './native-chat-tool-pair-limit.spec'
import './native-chat-tool-fold-attribution.spec'
import './native-chat/tools/native-chat-tool-pair-limit.spec'
import './native-chat/tools/native-chat-tool-fold-attribution.spec'
import './native-chat-turn-grouping.spec'
import './native-chat-ask-row.spec'
import './native-chat-tool-pairing.spec'
import './native-chat/tools/native-chat-tool-pairing.spec'
import './native-chat-live-line.spec'
import './native-chat-merge-pairs.spec'
import './native-chat/native-chat-command-envelope.spec'
import './native-chat/native-chat-streaming.spec'
import './native-chat-subagent-group-header.spec'
import './native-chat-tool-result-orphans.spec'
import './native-chat/tools/native-chat-tool-result-orphans.spec'
@@ -11,7 +11,7 @@ import { nativeChatSemanticRowId, type NativeChatMessage } from './native-chat-t
import { compareAgentJournalPositions } from './agent-session-journal-position'
import { agentJournalItemSubagentId } from './agent-session-journal-producer'
import { stripNoiseMessages } from './native-chat-noise'
import { foldToolMessages } from './native-chat-tool-fold'
import { foldToolMessages } from './native-chat/tools/native-chat-tool-fold'
import { foldSubagentItems } from './native-chat-subagent-items'
import { nativeChatTurnMembership, type NativeChatTurnJournal } from './native-chat-turn-membership'
+1 -1
View File
@@ -5,7 +5,7 @@
import { isNativeChatAskCall } from './native-chat-ask-row'
import { deriveNativeChatRowContent } from './native-chat-row-content'
import { isStoppedBeforeStartBlock } from './native-chat-stopped-before-start'
import { pairToolBlocks } from './native-chat-tool-fold'
import { pairToolBlocks } from './native-chat/tools/native-chat-tool-pairs'
import type { NativeChatBlock, NativeChatMessage } from './native-chat-types'
/** `lead`: the agent's words with calls already folded under them, which may head a run but
@@ -1,5 +1,5 @@
import { unpairedToolResultIndices } from './native-chat-tool-pairs'
import type { NativeChatBlock, NativeChatMessage } from './native-chat-types'
import type { NativeChatBlock, NativeChatMessage } from '../../native-chat-types'
type ToolContribution = {
source: NativeChatMessage
@@ -5,7 +5,7 @@ import type {
NativeChatBackgroundTaskBlock,
NativeChatBlock,
NativeChatMessage
} from './native-chat-types'
} from '../../native-chat-types'
function message(id: string, blocks: NativeChatBlock[]): NativeChatMessage {
return {
@@ -1,6 +1,7 @@
import { expect, it } from 'vitest'
import { foldToolMessages, pairToolBlocks } from './native-chat-tool-fold'
import type { NativeChatBlock, NativeChatMessage } from './native-chat-types'
import { foldToolMessages } from './native-chat-tool-fold'
import { pairToolBlocks } from './native-chat-tool-pairs'
import type { NativeChatBlock, NativeChatMessage } from '../../native-chat-types'
function message(id: string, blocks: NativeChatBlock[]): NativeChatMessage {
return { id, role: 'assistant', source: 'transcript', timestamp: 1, blocks }
@@ -5,17 +5,15 @@ import {
isToolResultBlock,
type NativeChatBlock,
type NativeChatMessage
} from './native-chat-types'
import { isKnownHarnessInjectedUserTurnText } from './harness-injected-user-turns'
import { isNoiseMessage } from './native-chat-noise'
} from '../../native-chat-types'
import { isKnownHarnessInjectedUserTurnText } from '../../harness-injected-user-turns'
import { isNoiseMessage } from '../../native-chat-noise'
import {
CODEX_PLAN_UPDATED_FRAME_KIND,
isWordlessProviderFrameMessage
} from './native-chat/native-chat-provider-frame-summary'
} from '../native-chat-provider-frame-summary'
import { FoldedToolResultSources } from './native-chat-folded-tool-results'
export { pairToolBlocks, type NativeChatToolPair } from './native-chat-tool-pairs'
function isToolOnlyMessage(message: NativeChatMessage): boolean {
return (
message.blocks.length > 0 &&
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import { pairToolBlocks, type NativeChatToolPair } from './native-chat-tool-fold'
import type { NativeChatBlock } from './native-chat-types'
import { pairToolBlocks, type NativeChatToolPair } from './native-chat-tool-pairs'
import type { NativeChatBlock } from '../../native-chat-types'
function original(blocks: readonly NativeChatBlock[], limit: number): NativeChatToolPair[] {
const pairs: NativeChatToolPair[] = []
@@ -1,10 +1,10 @@
import { describe, expect, it } from 'vitest'
import { pairToolBlocks, type NativeChatToolPair } from './native-chat-tool-fold'
import { pairToolBlocks, type NativeChatToolPair } from './native-chat-tool-pairs'
import type {
NativeChatBlock,
NativeChatToolCallBlock,
NativeChatToolResultBlock
} from './native-chat-types'
} from '../../native-chat-types'
function call(callId?: string): NativeChatToolCallBlock {
return { type: 'tool-call', name: 'Bash', input: {}, ...(callId !== undefined ? { callId } : {}) }
@@ -4,7 +4,7 @@ import type {
NativeChatBlock,
NativeChatToolCallBlock,
NativeChatToolResultBlock
} from './native-chat-types'
} from '../../native-chat-types'
const call = (name: string): NativeChatToolCallBlock => ({ type: 'tool-call', name, input: {} })
const result = (output: string): NativeChatToolResultBlock => ({ type: 'tool-result', output })
@@ -14,12 +14,12 @@
// that has not been answered yet. Position alone misattributes every later result once
// one call finishes with no output, which is why a producer that knows the call names it.
import { pairToolBlocks } from './native-chat-tool-fold'
import { pairToolBlocks } from './native-chat-tool-pairs'
import type {
NativeChatBlock,
NativeChatToolCallBlock,
NativeChatToolResultBlock
} from './native-chat-types'
} from '../../native-chat-types'
export type NativeChatToolPairing = {
/** The result each call owns. A call still running has none. */
@@ -2,7 +2,7 @@ import type {
NativeChatBlock,
NativeChatToolCallBlock,
NativeChatToolResultBlock
} from './native-chat-types'
} from '../../native-chat-types'
export type NativeChatToolPair = {
call?: NativeChatToolCallBlock
@@ -1,14 +1,15 @@
import { describe, expect, it } from 'vitest'
import { foldToolMessages, pairToolBlocks } from './native-chat-tool-fold'
import { nativeChatToolRunOutcome } from './native-chat-tool-run-outcome'
import { nativeChatWorkRunMember } from './native-chat-work-run'
import { nativeChatMessagesShareTranscriptRow } from './native-chat-types'
import { foldToolMessages } from './native-chat-tool-fold'
import { pairToolBlocks } from './native-chat-tool-pairs'
import { nativeChatToolRunOutcome } from '../../native-chat-tool-run-outcome'
import { nativeChatWorkRunMember } from '../../native-chat-work-run'
import { nativeChatMessagesShareTranscriptRow } from '../../native-chat-types'
import type {
NativeChatBlock,
NativeChatMessage,
NativeChatToolCallBlock,
NativeChatToolResultBlock
} from './native-chat-types'
} from '../../native-chat-types'
function row(
id: string,
@@ -1,14 +1,14 @@
import { describe, expect, it } from 'vitest'
import type {
AgentJournalItemBody,
AgentJournalRenderItem,
AgentJournalTurnScope
} from './agent-session-journal-types'
AgentJournalRenderItem
} from '../../agent-session-journal-types'
import type { AgentJournalTurnScope } from '../../agent-session-journal-turn-scope'
import { foldToolMessages } from './native-chat-tool-fold'
import { nativeChatRowsInDrawOrder } from './native-chat-turn-grouping'
import { nativeChatTurnMembership } from './native-chat-turn-membership'
import type { NativeChatMessage, NativeChatRole } from './native-chat-types'
import { projectStructuredItemsToNativeChat } from './structured-agent-session-projection'
import { nativeChatRowsInDrawOrder } from '../../native-chat-turn-grouping'
import { nativeChatTurnMembership } from '../../native-chat-turn-membership'
import type { NativeChatMessage, NativeChatRole } from '../../native-chat-types'
import { projectStructuredItemsToNativeChat } from '../../structured-agent-session-projection'
const THREAD: AgentJournalTurnScope = { kind: 'thread' }
const inTurn = (turnItemId: string): AgentJournalTurnScope => ({ kind: 'turn', turnItemId })