refactor: apply repository naming contract
Apply the accepted pre-release package, service, type, directory, and role renames as one repository-wide change.
This commit is contained in:
@@ -2,7 +2,7 @@ import type { Context } from '@deepseek-ai/cordis'
|
||||
import type {
|
||||
ConversationMatch, ConversationNodeDefinition, RequestView,
|
||||
} from '@deepseek-ai/dsh-client-runtime/client'
|
||||
import type {} from '@deepseek-ai/dsh-compact/types'
|
||||
import type {} from '@deepseek-ai/dsh-compaction/types'
|
||||
import { trajectoryNode } from './trajectory-definition-common.ts'
|
||||
|
||||
interface CompactionState {
|
||||
@@ -30,9 +30,9 @@ function checkpointId(
|
||||
function eventCompactionId(
|
||||
event: Parameters<ConversationNodeDefinition['match']>[0],
|
||||
): string | undefined {
|
||||
if (event.type !== 'compact/start'
|
||||
&& event.type !== 'compact/summary'
|
||||
&& event.type !== 'compact/end') return undefined
|
||||
if (event.type !== 'compaction/start'
|
||||
&& event.type !== 'compaction/summary'
|
||||
&& event.type !== 'compaction/end') return undefined
|
||||
const value: unknown = event.data.compactionId
|
||||
return typeof value === 'string' && value !== '' ? value : undefined
|
||||
}
|
||||
@@ -41,7 +41,7 @@ function requestFromState(
|
||||
state: CompactionState,
|
||||
): Extract<RequestView, { purpose: 'compaction' }> | undefined {
|
||||
const start = state.start.event
|
||||
if (start.type !== 'compact/start') return undefined
|
||||
if (start.type !== 'compaction/start') return undefined
|
||||
const summary = state.summary?.event
|
||||
const end = state.end?.event
|
||||
const checkpoint = state.checkpoint?.event
|
||||
@@ -51,14 +51,14 @@ function requestFromState(
|
||||
turn: start.data.turn,
|
||||
step: 0,
|
||||
startedAt: start.time,
|
||||
completedAt: end?.type === 'compact/end' ? end.time : null,
|
||||
status: end?.type !== 'compact/end'
|
||||
completedAt: end?.type === 'compaction/end' ? end.time : null,
|
||||
status: end?.type !== 'compaction/end'
|
||||
? 'running'
|
||||
: end.data.error === undefined ? 'complete' : 'error',
|
||||
...(end?.type === 'compact/end' && end.data.error !== undefined
|
||||
...(end?.type === 'compaction/end' && end.data.error !== undefined
|
||||
? { error: end.data.error }
|
||||
: {}),
|
||||
...(summary?.type !== 'compact/summary'
|
||||
...(summary?.type !== 'compaction/summary'
|
||||
? {}
|
||||
: {
|
||||
resultSeq: summary.seq,
|
||||
@@ -83,20 +83,20 @@ const trajectoryCompactionDefinition: ConversationNodeDefinition<CompactionState
|
||||
match: (event) => {
|
||||
const compactId = eventCompactionId(event)
|
||||
if (compactId !== undefined) {
|
||||
return { id: compactId, role: event.type === 'compact/start' ? 'start' : 'update' }
|
||||
return { id: compactId, role: event.type === 'compaction/start' ? 'start' : 'update' }
|
||||
}
|
||||
const checkpoint = checkpointId(event)
|
||||
return checkpoint === undefined ? null : { id: checkpoint, role: 'update' }
|
||||
},
|
||||
start: (_context, match) => {
|
||||
if (match.event.type !== 'compact/start') {
|
||||
throw new Error('trajectory-compaction start requires compact/start')
|
||||
if (match.event.type !== 'compaction/start') {
|
||||
throw new Error('trajectory-compaction start requires compaction/start')
|
||||
}
|
||||
return { start: match }
|
||||
},
|
||||
update: (context, match) => {
|
||||
if (match.event.type === 'compact/summary') return { ...context.state, summary: match }
|
||||
if (match.event.type === 'compact/end') return { ...context.state, end: match }
|
||||
if (match.event.type === 'compaction/summary') return { ...context.state, summary: match }
|
||||
if (match.event.type === 'compaction/end') return { ...context.state, end: match }
|
||||
return checkpointId(match.event) === undefined
|
||||
? context.state
|
||||
: { ...context.state, checkpoint: match }
|
||||
|
||||
Reference in New Issue
Block a user