Files
deepseek-harness/packages/core/agent-loop/tests/fixtures/serial-created.mjs
T
Tianyi Cui d5a109c60f fix(session): preserve direct V3 source kinds during wrapper conversion
Convert an unknown legacy plugin wrapper such as
{kind: 'plugin', plugin: 'acme'} into {kind: 'plugin:acme'}, retaining the
complete plugin name after one prefix. Keep the existing explicit
first-party producer renames and preserve all non-identity metadata.

A direct source already records its producer in kind. Reclassifying
unknown direct kinds into plugin:source:<name> needlessly changes that
attribution and forces plugin consumers to adopt new identifiers even
though V4 accepts their existing representation. Return every valid
direct source unchanged, including already-prefixed names. Remove the
obsolete direct-kind table and two-category identity helper rather than
adding collision classification or another mapping layer.

Update the source conversion examples, codec/restore regressions, and
native fixture producers together. Refresh only the owning Python
advanced scenario's unshipped V4 outputs; preserve historical V0-V3
recordings and their generation selection. Event names, content tags,
and ToolSchema migration remain separate concerns.

Refs #2692
2026-09-19 17:11:45 +08:00

25 lines
817 B
JavaScript

/** Awaited creation context shared by TypeScript and Python SDK snapshots. */
import { randomUUID } from 'node:crypto'
import { setImmediate } from 'node:timers/promises'
export const name = 'serial-created-fixture'
export const inject = ['agents']
/** Install ordered creation listeners whose context must precede the first turn. */
export function apply(ctx) {
const ready = new WeakSet()
ctx.on('agent/created', async ({ agent }) => {
await setImmediate()
agent.inject({
id: randomUUID(),
role: 'user',
content: [{ type: 'text', text: 'Serial agent creation completed.' }],
source: { kind: `plugin:${name}` },
})
ready.add(agent)
})
ctx.on('agent/created', ({ agent }) => {
if (!ready.has(agent)) throw new Error('creation listeners ran out of order')
})
}