Merge pull request #8214 from deepseek-harness/split-exports-brand-strings

refactor(brand): migrate internal identity construction
This commit is contained in:
imccyu authored and GitHub committed 2026-11-11 15:15:26 +08:00
1 parent a660c1c048
commit 455f7a38a6
1171 files changed
+9709 -7987

No files matched your search

+1
View File
@@ -120,6 +120,7 @@
"@deepseek-ai/dsh-experimental-forge-bundle": "workspace:*"
},
"devDependencies": {
"@deepseek-ai/dsh-brand": "workspace:*",
"@deepseek-ai/dsh-skill-badge": "workspace:*",
"@deepseek-ai/dsh-webhook-github": "workspace:*",
"@deepseek-ai/dsh-webhook": "workspace:*",
+5 -4
View File
@@ -1,9 +1,10 @@
import { executeToolFixture } from '@deepseek-ai/dsh-tool-testkit'
import { fileURLToPath } from 'node:url'
import { agentEvents, type Agent } from '@deepseek-ai/dsh-agent'
import { ToolCallId } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { ToolCallId } from '@deepseek-ai/dsh-llm'
import { boot, loadOverlayPatches } from '@deepseek-ai/dsh-app-boot'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-skill'
import type {} from '@deepseek-ai/dsh-tools'
import { unsupportedModel, unsupportedInbox } from '@deepseek-ai/dsh-agent-loop-testkit'
@@ -25,7 +26,7 @@ const ctx = await boot('dsh-badge-snapshot', rootConfigPath, [
])
try {
const agentId = SessionId('dsh-badge-snapshot')
const agentId = brandString<SessionId>('dsh-badge-snapshot')
const session = ctx.sessions.create(agentId, { meta: { cwd: process.cwd() } })
const agent: Agent = {
ctx,
@@ -54,7 +55,7 @@ try {
: undefined
const summary = (await ctx.skills.list()).find(skill => skill.name === 'dsh-badge')
const result = await executeToolFixture(ctx, {
callId: ToolCallId('dsh-badge-snapshot'),
callId: brandString<ToolCallId>('dsh-badge-snapshot'),
name: 'skill',
arguments: { name: 'dsh-badge' },
signal: new AbortController().signal,
@@ -1,5 +1,5 @@
import z from '@deepseek-ai/schemastery'
import { WebhookRuleId } from '@deepseek-ai/dsh-webhook'
import { brandString } from '@deepseek-ai/dsh-brand'
export const name = 'github-webhook-real-e2e-rule'
export const inject = ['webhookRuntime']
@@ -14,8 +14,10 @@ export const Config = z.object({
})
export function apply(ctx, config) {
/** @type {import('@deepseek-ai/dsh-webhook/types').WebhookRuleId} */
const id = brandString('github-real-e2e')
ctx.effect(() => ctx.webhookRuntime.register({
id: WebhookRuleId('github-real-e2e'),
id,
kind: 'github',
run(delivery, signal) {
+3 -2
View File
@@ -6,7 +6,8 @@ import type {} from '@deepseek-ai/cordis-plugin-loader'
import type {} from '@deepseek-ai/dsh-agent'
import type {} from '@deepseek-ai/dsh-cmdline'
import { createUserMessage } from '@deepseek-ai/dsh-llm'
import { SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import type { SessionId, SessionEvent } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
/** Observations from one isolated Agent's run through the shipped headless profile. */
export interface SourceToolEvidence {
@@ -37,7 +38,7 @@ export function apply(ctx: Context, config: { cwd: string }): void {
const run = async (): Promise<void> => {
const handle = await ctx.agents.create({
sessionId: SessionId(randomUUID()),
sessionId: brandString<SessionId>(randomUUID()),
meta: { cwd: config.cwd },
agentOptions: { provider: 'cli-mock', model: 'cli-mock' },
})
@@ -10,9 +10,10 @@ import { fileURLToPath } from 'node:url'
import type { Context } from '@deepseek-ai/cordis'
import type { Agent, AgentHandle } from '@deepseek-ai/dsh-agent'
import type { ProfileContext } from '@deepseek-ai/dsh-app-boot'
import { LlmAdapter, ToolCallId, createUserMessage } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { LlmAdapter, type ToolCallId, createUserMessage } from '@deepseek-ai/dsh-llm'
import type { GenerateOptions, LlmResolvedModelInfo, StreamChunk } from '@deepseek-ai/dsh-llm'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-agent-preset-registry'
import type {} from '@deepseek-ai/dsh-hmr'
import type {} from '@deepseek-ai/dsh-plugin-manager'
@@ -140,7 +141,7 @@ describe.skipIf(!existsSync(join(root, 'apps/cli/lib/bin.js')))('Official option
async function agent(preset = 'standard', cwd = workspace): Promise<AgentHandle> {
const handle = await ctx.agents.create({
sessionId: SessionId(`optional-${preset}-${randomUUID()}`), meta: { cwd, agentPreset: preset },
sessionId: brandString<SessionId>(`optional-${preset}-${randomUUID()}`), meta: { cwd, agentPreset: preset },
agentOptions: { provider: 'bundle-test', model: 'scripted' },
setup: scoped => ctx.agentPresets.mount(scoped, preset).then(() => undefined),
})
@@ -234,7 +235,7 @@ describe.skipIf(!existsSync(join(root, 'apps/cli/lib/bin.js')))('Official option
it('loads the actual badge asset only while its bundle is selected', async () => {
const owner = await agent()
const load = (callId: string) => executeToolFixture(ctx, {
callId: ToolCallId(callId), name: 'skill', arguments: { name: 'dsh-badge' },
callId: brandString<ToolCallId>(callId), name: 'skill', arguments: { name: 'dsh-badge' },
agent: owner.agent, signal: new AbortController().signal,
})
expect((await load('badge-before')).isError).toBe(true)
@@ -1,10 +1,11 @@
/** Keyless two-model adapter for the generic ACP control-surface conformance test. */
import type { Context } from '@deepseek-ai/cordis'
import { brandString } from '@deepseek-ai/dsh-brand'
import {
ToolCallId,
type ToolCallId,
LlmAdapter,
ReasoningEffortId,
type ReasoningEffortId,
type GenerateOptions,
type LlmResolvedModelInfo,
type StreamChunk,
@@ -34,10 +35,10 @@ class ControlSurfaceAdapter extends LlmAdapter {
context: { contextWindow: 2_048 },
reasoning: {
efforts: [
{ id: ReasoningEffortId('low'), name: 'Low' },
{ id: ReasoningEffortId('high'), name: 'High' },
{ id: brandString<ReasoningEffortId>('low'), name: 'Low' },
{ id: brandString<ReasoningEffortId>('high'), name: 'High' },
],
defaultEffort: ReasoningEffortId('high'),
defaultEffort: brandString<ReasoningEffortId>('high'),
},
})
}
@@ -50,7 +51,7 @@ class ControlSurfaceAdapter extends LlmAdapter {
.join('')
const hasToolResult = current.some(message => message.role === 'tool')
if (!hasToolResult) {
const callId = ToolCallId(userText.includes('cancel') ? 'control-cancel-add' : 'control-add')
const callId = brandString<ToolCallId>(userText.includes('cancel') ? 'control-cancel-add' : 'control-add')
yield { type: 'block-start', index: 0, blockType: 'reasoning' }
yield { type: 'reasoning-delta', index: 0, text: 'checking the attached tool' }
yield { type: 'block-end', index: 0, block: { type: 'reasoning', text: 'checking the attached tool' } }
@@ -6,7 +6,8 @@ import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import type { Context } from '@deepseek-ai/cordis'
import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness.ts'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
/**
* The swebench-style smoke test: a real model fixes a real bug in a temp
@@ -55,7 +56,7 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY)('coding task: fix a failing test
expect(before.status).not.toBe(0)
ctx = await codingHarness(workdir, { personaPrefix: SYSTEM_PROMPT })
const agent = await ctx.agentLoop.create(SessionId('e2e-task'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
const agent = await ctx.agentLoop.create(brandString<SessionId>('e2e-task'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
agent.followup(createUserMessage({
content: [{
@@ -5,7 +5,8 @@ import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import type { Context } from '@deepseek-ai/cordis'
import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness.ts'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
/**
* Key-gated smoke for mid-session compaction. It verifies the compact event
@@ -49,7 +50,7 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY)('compaction: a long session compa
},
persistenceRoot: join(workdir, '.sessions'),
})
const agent = await ctx.agentLoop.create(SessionId('e2e-compaction'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
const agent = await ctx.agentLoop.create(brandString<SessionId>('e2e-compaction'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
// Completed read turns cannot collapse into one retained parallel tool group.
for (let i = 1; i <= 4; i++) {
@@ -1,6 +1,7 @@
/** Deterministic keyless Agent Teams adapter shared by profile snapshot and CLI e2e. */
import { ToolCallId, LlmAdapter } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { LlmAdapter } from '@deepseek-ai/dsh-llm'
let nextCall = 0
@@ -42,7 +43,8 @@ function latestToolText(messages) {
function toolChunks(specs) {
const chunks = []
for (const [index, spec] of specs.entries()) {
const id = ToolCallId(`team-fixture-${++nextCall}`)
/** @type {import('@deepseek-ai/dsh-llm/types').ToolCallId} */
const id = brandString(`team-fixture-${++nextCall}`)
const args = JSON.stringify(spec.args)
chunks.push(
{ type: 'block-start', index, blockType: 'tool-call' },
@@ -5,7 +5,8 @@ import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import type { Context } from '@deepseek-ai/cordis'
import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness.ts'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
/**
* The first place a REAL model meets the REAL bash tool: the cheap canary
@@ -29,7 +30,7 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY)('full loop: real model + real bas
it('runs a bash command on request and reports its output', async () => {
workdir = await mkdtemp(join(tmpdir(), 'dsh-full-loop-e2e-'))
ctx = await codingHarness(workdir, { personaPrefix: SYSTEM_PROMPT })
const agent = await ctx.agentLoop.create(SessionId('e2e-loop'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
const agent = await ctx.agentLoop.create(brandString<SessionId>('e2e-loop'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
agent.followup(createUserMessage({ content: [{ type: 'text', text: 'Run `echo e2e-ok` with the bash tool and tell me its exact output.' }], source: { kind: 'user' } }))
await waitForIdle(ctx, agent)
@@ -4,8 +4,9 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, describe, expect, it, onTestFinished, vi } from 'vitest'
import { Context } from '@deepseek-ai/cordis'
import { createUserMessage, ToolCallId, HarnessError } from '@deepseek-ai/dsh-llm'
import SessionStore, { SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { createUserMessage, type ToolCallId, HarnessError } from '@deepseek-ai/dsh-llm'
import SessionStore, { type SessionId } from '@deepseek-ai/dsh-session'
import type { SessionEvent } from '@deepseek-ai/dsh-session'
import { RUN_CODE_NAME, defineTool } from '@deepseek-ai/dsh-tools'
import type { ToolExecutionResult } from '@deepseek-ai/dsh-tools'
@@ -98,7 +99,7 @@ function runCode(
agent?: Agent,
): Promise<ToolExecutionResult> {
return executeModelToolFixture(harness, {
callId: ToolCallId(`keyless-code-${++keylessCall}`),
callId: brandString<ToolCallId>(`keyless-code-${++keylessCall}`),
name: RUN_CODE_NAME,
arguments: { code, description: 'Run the e2e program' },
signal,
@@ -299,8 +300,8 @@ describe('PTC mode typed values: keyless real-process contracts', () => {
await ctx.plugin(ToolCordis)
const agent = {
ctx,
id: SessionId('ptc-cordis'),
session: ctx.sessions.create(SessionId('ptc-cordis'), { meta: { cwd: process.cwd() } }),
id: brandString<SessionId>('ptc-cordis'),
session: ctx.sessions.create(brandString<SessionId>('ptc-cordis'), { meta: { cwd: process.cwd() } }),
} as Agent
const value = completion(await runCode(ctx, `
@@ -331,7 +332,7 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY)('PTC mode: real model writes a pr
it('collapses the wire tool list to [run_code], bridges sub-calls, and returns curated output', async () => {
workdir = await mkdtemp(join(tmpdir(), 'dsh-ptc-e2e-'))
ctx = await ptcModeHarness(workdir)
const agent = await ctx.agentLoop.create(SessionId('e2e-ptc'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
const agent = await ctx.agentLoop.create(brandString<SessionId>('e2e-ptc'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
agent.followup(createUserMessage({
content: [{
@@ -381,7 +382,7 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY)('PTC mode: real model writes a pr
await writeFile(join(workdir, 'pkg/deep/task.txt'), 'Touch this file to discover the nested instructions.\n')
ctx = await workspacePtcModeHarness()
const handle = await ctx.agents.create({
sessionId: SessionId('e2e-ptc-workspace-session'),
sessionId: brandString<SessionId>('e2e-ptc-workspace-session'),
meta: { cwd: workdir },
agentOptions: { provider: 'deepseek-official', model: 'deepseek-v4-flash' },
})
@@ -4,8 +4,9 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import type { Context } from '@deepseek-ai/cordis'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
/**
* Proves durable conversation continuity end-to-end: run 1 tells the REAL model
@@ -16,7 +17,7 @@ import { codingHarness, finalText, SYSTEM_PROMPT, waitForIdle } from './harness.
*/
const SECRET = 'plum-galaxy-1791'
const SESSION_ID = SessionId('resume-e2e-session')
const SESSION_ID = brandString<SessionId>('resume-e2e-session')
let ctx: Context | undefined
let root: string | undefined
@@ -9,8 +9,9 @@ import {
type NormalizeContext,
} from '@deepseek-ai/dsh-session-snapshot'
import { LOADER_SMOKE_TEST_TIMEOUT_MS, runLoaderSmoke } from '@deepseek-ai/dsh-loader-smoke'
import { createUserMessage, ToolCallId, createMessage } from '@deepseek-ai/dsh-llm'
import { SessionSeq, SESSION_FORMAT_VERSION, SessionId, type SessionEvent, type SessionHeader } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { createUserMessage, type ToolCallId, createMessage } from '@deepseek-ai/dsh-llm'
import { SessionSeq, SESSION_FORMAT_VERSION, type SessionId, type SessionEvent, type SessionHeader } from '@deepseek-ai/dsh-session'
import * as JsonlSessionPersistence from '@deepseek-ai/dsh-session-persistence-jsonl'
import { logPath } from '../../../../../../packages/session/session-persistence-jsonl/src/format.ts'
import { describe, expect, it } from 'vitest'
@@ -22,7 +23,7 @@ const sessionExpected = join(fixtureDir, 'session.expected.jsonl')
const configPath = fileURLToPath(new URL('../semantic-checkpoint-snapshot.patch.yml', import.meta.url))
const binScript = fileURLToPath(new URL('../../../../../../packages/test-support/loader-smoke/tests/fixtures/headless-driver.ts', import.meta.url))
const tsconfigPath = fileURLToPath(new URL('../../../../../../tsconfig.json', import.meta.url))
const sessionId = SessionId('semantic-checkpoint-unknown-outcome')
const sessionId = brandString<SessionId>('semantic-checkpoint-unknown-outcome')
const refreshing = process.env.DSH_SNAPSHOT === 'refresh'
const task = 'Continue safely from the interrupted operation.'
@@ -68,7 +69,7 @@ async function seedInterruptedSession(root: string, cwd: string): Promise<string
stream: [],
message: createMessage({
role: 'assistant',
content: [{ type: 'tool-call', id: ToolCallId('unknown-outcome-call'), name: 'write_remote', arguments: '{"value":1}' }],
content: [{ type: 'tool-call', id: brandString<ToolCallId>('unknown-outcome-call'), name: 'write_remote', arguments: '{"value":1}' }],
source: {
kind: 'model',
...{ provider: 'deepseek-official', model: 'deepseek-v4-flash' },
@@ -84,7 +85,7 @@ async function seedInterruptedSession(root: string, cwd: string): Promise<string
data: {
turn: 1,
step: 1,
callId: ToolCallId('unknown-outcome-call'),
callId: brandString<ToolCallId>('unknown-outcome-call'),
name: 'write_remote',
arguments: '{"value":1}',
},
@@ -12,7 +12,7 @@ import { Context } from '@deepseek-ai/cordis'
import { LOADER_SMOKE_TEST_TIMEOUT_MS, runLoaderSmoke } from '@deepseek-ai/dsh-loader-smoke'
import {
SESSION_FORMAT_VERSION,
SessionId,
type SessionId,
SessionSeq,
type SessionEvent,
type SessionHeader,
@@ -24,6 +24,7 @@ import {
logPath,
} from '../../../../../../packages/session/session-persistence-jsonl/src/format.ts'
import { describe, expect, it } from 'vitest'
import { brandString } from '@deepseek-ai/dsh-brand'
const fixtureDir = join(dirname(fileURLToPath(import.meta.url)), 'expected/workspace-context-resume/offline-edit')
const replayFixture = join(fixtureDir, 'replay.jsonl')
@@ -31,7 +32,7 @@ const configPath = fileURLToPath(new URL('../workspace-context-resume-snapshot.p
const binScript = fileURLToPath(new URL('../../../../../../packages/test-support/loader-smoke/tests/fixtures/headless-driver.ts', import.meta.url))
const tsconfigPath = fileURLToPath(new URL('../../../../../../tsconfig.json', import.meta.url))
// The resumed-agent fixture in the shared config resumes exactly this id.
const sessionId = SessionId('workspace-context-resume')
const sessionId = brandString<SessionId>('workspace-context-resume')
const fixtureEnv = {
DSH_SNAPSHOT_FILE: replayFixture,
DSH_LOADER_SMOKE_REQUIRED_ENTRY_ID: 'resumed-agent',
@@ -15,9 +15,10 @@ import {
} from '@deepseek-ai/dsh-session-snapshot'
import { LOADER_SMOKE_TEST_TIMEOUT_MS, runLoaderSmoke } from '@deepseek-ai/dsh-loader-smoke'
import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SessionSeq, SESSION_FORMAT_VERSION, SessionId, type SessionEvent, type SessionHeader } from '@deepseek-ai/dsh-session'
import { SessionSeq, SESSION_FORMAT_VERSION, type SessionId, type SessionEvent, type SessionHeader } from '@deepseek-ai/dsh-session'
import * as JsonlSessionPersistence from '@deepseek-ai/dsh-session-persistence-jsonl'
import { describe, expect, it } from 'vitest'
import { brandString } from '@deepseek-ai/dsh-brand'
const fixtureDir = fileURLToPath(new URL('./expected/subagent-diagnostic', import.meta.url))
const replayOverride = join(fixtureDir, 'replay.override.json')
@@ -25,8 +26,8 @@ const parentExpected = join(fixtureDir, 'parent.expected.jsonl')
const configPath = fileURLToPath(new URL('../subagent-diagnostic-snapshot.patch.yml', import.meta.url))
const binScript = fileURLToPath(new URL('../../../../../../packages/test-support/loader-smoke/tests/fixtures/headless-driver.ts', import.meta.url))
const tsconfigPath = fileURLToPath(new URL('../../../../../../tsconfig.json', import.meta.url))
const parentId = SessionId('subagent-diagnostic-parent')
const childId = SessionId('subagent-diagnostic-child')
const parentId = brandString<SessionId>('subagent-diagnostic-parent')
const childId = brandString<SessionId>('subagent-diagnostic-child')
const refreshing = process.env.DSH_SNAPSHOT === 'refresh'
const task = 'Call list_agents once and report what it shows.'
@@ -15,8 +15,9 @@ import {
type NormalizeContext,
} from '@deepseek-ai/dsh-session-snapshot'
import { LOADER_SMOKE_TEST_TIMEOUT_MS, runLoaderSmoke } from '@deepseek-ai/dsh-loader-smoke'
import { createMessage, createUserMessage, ReasoningEffortId } from '@deepseek-ai/dsh-llm'
import { SessionSeq, SESSION_FORMAT_VERSION, SessionId, type SessionEvent, type SessionHeader } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { createMessage, createUserMessage, type ReasoningEffortId } from '@deepseek-ai/dsh-llm'
import { SessionSeq, SESSION_FORMAT_VERSION, type SessionId, type SessionEvent, type SessionHeader } from '@deepseek-ai/dsh-session'
import * as JsonlSessionPersistence from '@deepseek-ai/dsh-session-persistence-jsonl'
import { describe, expect, it } from 'vitest'
@@ -30,7 +31,7 @@ const childExpected = join(fixtureDir, 'child.expected.jsonl')
const configPath = fileURLToPath(new URL('../subagent-inheritance-snapshot.patch.yml', import.meta.url))
const binScript = fileURLToPath(new URL('../../../../../../packages/test-support/loader-smoke/tests/fixtures/headless-driver.ts', import.meta.url))
const tsconfigPath = fileURLToPath(new URL('../../../../../../tsconfig.json', import.meta.url))
const sessionId = SessionId('subagent-inheritance-parent')
const sessionId = brandString<SessionId>('subagent-inheritance-parent')
const refreshing = process.env.DSH_SNAPSHOT === 'refresh'
const task = 'Delegate the write probe to a subagent.'
@@ -75,7 +76,7 @@ async function seedReadOnlyParent(root: string, cwd: string): Promise<void> {
config: {
provider: 'deepseek-official',
model: 'deepseek-v4-flash',
reasoningEffort: ReasoningEffortId('low'),
reasoningEffort: brandString<ReasoningEffortId>('low'),
},
},
reason: 'initial',
@@ -5,7 +5,8 @@ import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import type { Context } from '@deepseek-ai/cordis'
import { codingHarness, TODO_SYSTEM_PROMPT, waitForIdle } from './harness.ts'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
/**
* A REAL model drives the REAL todo_write tool: verify the WORLD (the session
@@ -27,7 +28,7 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY)('todo_write: real model records a
it('appends a todo/write event with the model-produced task list', async () => {
workdir = await mkdtemp(join(tmpdir(), 'dsh-todo-write-e2e-'))
ctx = await codingHarness(workdir, { personaPrefix: TODO_SYSTEM_PROMPT })
const agent = await ctx.agentLoop.create(SessionId('e2e-todo'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
const agent = await ctx.agentLoop.create(brandString<SessionId>('e2e-todo'), { provider: 'deepseek-official', model: 'deepseek-v4-flash' }, { cwd: workdir })
agent.followup(createUserMessage({
content: [{ type: 'text', text:
@@ -18,7 +18,7 @@ import { LOADER_SMOKE_TEST_TIMEOUT_MS, runLoaderSmoke } from '@deepseek-ai/dsh-l
import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import {
SESSION_FORMAT_VERSION,
SessionId,
type SessionId,
SessionSeq,
type SessionEvent,
type SessionHeader,
@@ -28,6 +28,7 @@ import { logPath } from '../../../../../../packages/session/session-persistence-
import { renderAgentInstructions } from '@deepseek-ai/dsh-agent-instructions'
import { resolveConfig, workspaceBaselineIdentity } from '@deepseek-ai/dsh-agent-instructions/src/config.ts'
import { describe, expect, it } from 'vitest'
import { brandString } from '@deepseek-ai/dsh-brand'
const fixtureDir = join(dirname(fileURLToPath(import.meta.url)), 'expected/workspace-context-resume/offline-edit')
const replayFixture = join(fixtureDir, 'replay.jsonl')
@@ -37,7 +38,7 @@ const precedenceExpected = join(dirname(fixtureDir), 'precedence-change/session.
const configPath = fileURLToPath(new URL('../workspace-context-resume-snapshot.patch.yml', import.meta.url))
const binScript = fileURLToPath(new URL('../../../../../../packages/test-support/loader-smoke/tests/fixtures/headless-driver.ts', import.meta.url))
const tsconfigPath = fileURLToPath(new URL('../../../../../../tsconfig.json', import.meta.url))
const sessionId = SessionId('workspace-context-resume')
const sessionId = brandString<SessionId>('workspace-context-resume')
const refreshing = process.env.DSH_SNAPSHOT === 'refresh'
const oldInstruction = 'Old workspace instruction.'
const newInstruction = 'New workspace instruction after offline edit.'
+56 -55
View File
@@ -18,7 +18,7 @@ import {
type Profile,
} from '@deepseek-ai/dsh-app-boot'
import { provideCmdline } from '@deepseek-ai/dsh-cmdline'
import { SessionId, SessionLogOffset } from '@deepseek-ai/dsh-session'
import { type SessionId, SessionLogOffset } from '@deepseek-ai/dsh-session'
import type { Agent } from '@deepseek-ai/dsh-agent'
import type { PatchOptions } from '@deepseek-ai/cordis-plugin-include'
import { afterAll, beforeAll, describe, expect, it, onTestFinished, vi } from 'vitest'
@@ -28,7 +28,8 @@ import { createPluginProfile } from '../../desktop/src/project-manager.ts'
const SETTINGS_NAMESPACE = 'agent-preset-registry'
const SUBAGENT_MODEL_SELECTION_SETTINGS_NAMESPACE = 'subagent-model-selection-settings'
import { applyChildComposition, childSessionMeta } from '@deepseek-ai/dsh-subagent'
import { ToolCallId, LlmAdapter, createUserMessage } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, LlmAdapter, createUserMessage } from '@deepseek-ai/dsh-llm'
import type { GenerateOptions, LlmResolvedModelInfo, StreamChunk } from '@deepseek-ai/dsh-llm'
import type {} from '@deepseek-ai/dsh-compaction-basic'
import { codePointLength } from '@deepseek-ai/dsh-compaction-tool-result-pruner'
@@ -87,7 +88,7 @@ class MinimalImageAdapter extends LlmAdapter {
const first = this.requests.length === 1
yield { type: 'block-start', index: 0, blockType: first ? 'tool-call' : 'text' }
yield { type: 'block-end', index: 0, block: first
? { type: 'tool-call', id: ToolCallId('minimal-image-read'), name: 'read_image', arguments: '{"file_path":"red.png"}' }
? { type: 'tool-call', id: brandString<ToolCallId>('minimal-image-read'), name: 'read_image', arguments: '{"file_path":"red.png"}' }
: { type: 'text', text: 'Image inspected.' } }
yield { type: 'finish', reason: { kind: first ? 'tool-calls' : 'stop' } }
}
@@ -268,7 +269,7 @@ describe('the shipped Web composition', () => {
const projections = ctx.get('sessionProjections')
if (projections === undefined) throw new Error('the Web composition must compose a projection registry')
const handle = await ctx.agents.create({
sessionId: SessionId('preset-minimal-meter'),
sessionId: brandString<SessionId>('preset-minimal-meter'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
try {
@@ -291,7 +292,7 @@ describe('the shipped Web composition', () => {
it.each(['standard', 'cordis', 'ptc'] as const)('keeps interruption disabled in %s with Team mode off or on', async (preset) => {
const handle = await ctx.agents.create({
sessionId: SessionId(`preset-interrupt-${preset}`),
sessionId: brandString<SessionId>(`preset-interrupt-${preset}`),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, preset).then(() => undefined),
})
try {
@@ -326,7 +327,7 @@ describe('the shipped Web composition', () => {
}])
try {
const handle = await configured.agents.create({
sessionId: SessionId(`preset-interrupt-enabled-${preset}`),
sessionId: brandString<SessionId>(`preset-interrupt-enabled-${preset}`),
setup: agentCtx => configured.agentPresets.mount(agentCtx, preset).then(() => undefined),
})
try {
@@ -340,7 +341,7 @@ describe('the shipped Web composition', () => {
it('composes the full agent from `standard`', async () => {
const handle = await ctx.agents.create({
sessionId: SessionId('preset-standard'),
sessionId: brandString<SessionId>('preset-standard'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
try {
@@ -369,7 +370,7 @@ describe('the shipped Web composition', () => {
allowedModels: [],
})
const disabled = await ctx.agents.create({
sessionId: SessionId('preset-model-selection-disabled'),
sessionId: brandString<SessionId>('preset-model-selection-disabled'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
await ctx.settings.update(SUBAGENT_MODEL_SELECTION_SETTINGS_NAMESPACE, {
@@ -377,7 +378,7 @@ describe('the shipped Web composition', () => {
allowedModels: [{ provider: 'deepseek-official', model: 'deepseek-v4-flash' }],
})
const enabled = await ctx.agents.create({
sessionId: SessionId('preset-model-selection-enabled'),
sessionId: brandString<SessionId>('preset-model-selection-enabled'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
const policy = await ctx.sessionProjections.register(subagentModelSelectionProjectionDefinition)
@@ -410,13 +411,13 @@ describe('the shipped Web composition', () => {
const unregister = ctx.llm.registerAdapter(['preset-round-trip'], adapter)
onTestFinished(unregister)
const direct = await ctx.agents.create({
sessionId: SessionId(`preset-direct-${target}-${randomUUID()}`),
sessionId: brandString<SessionId>(`preset-direct-${target}-${randomUUID()}`),
agentOptions: { provider: 'preset-round-trip', model: 'preset-round-trip' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, target).then(() => undefined),
})
onTestFinished(() => direct.dispose())
const handle = await ctx.agents.create({
sessionId: SessionId(`preset-round-trip-${target}-${randomUUID()}`),
sessionId: brandString<SessionId>(`preset-round-trip-${target}-${randomUUID()}`),
agentOptions: { provider: 'preset-round-trip', model: 'preset-round-trip' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, target).then(() => undefined),
})
@@ -450,7 +451,7 @@ describe('the shipped Web composition', () => {
it('composes the exact RL prompt and persistent shell from `minimal`', async () => {
const handle = await ctx.agents.create({
sessionId: SessionId('preset-minimal'),
sessionId: brandString<SessionId>('preset-minimal'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
try {
@@ -484,7 +485,7 @@ describe('the shipped Web composition', () => {
const unregister = ctx.llm.registerAdapter(['minimal-image-test'], adapter)
onTestFinished(unregister)
const handle = await ctx.agents.create({
sessionId: SessionId('preset-minimal-image'), meta: { cwd },
sessionId: brandString<SessionId>('preset-minimal-image'), meta: { cwd },
agentOptions: { provider: 'minimal-image-test', model: 'minimal-image-test' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
@@ -512,7 +513,7 @@ describe('the shipped Web composition', () => {
const unregister = ctx.llm.registerAdapter(['minimal-compaction-test'], adapter)
onTestFinished(unregister)
const handle = await ctx.agents.create({
sessionId: SessionId('preset-minimal-compaction'),
sessionId: brandString<SessionId>('preset-minimal-compaction'),
agentOptions: { provider: 'minimal-compaction-test', model: 'minimal-compaction-test' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
@@ -546,7 +547,7 @@ describe('the shipped Web composition', () => {
const unregister = ctx.llm.registerAdapter(['minimal-pressure-test'], adapter)
onTestFinished(unregister)
const handle = await ctx.agents.create({
sessionId: SessionId('preset-minimal-pressure'),
sessionId: brandString<SessionId>('preset-minimal-pressure'),
agentOptions: { provider: 'minimal-pressure-test', model: 'minimal-pressure-test' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
@@ -571,11 +572,11 @@ describe('the shipped Web composition', () => {
it('keeps two differently composed sessions independent', async () => {
const full = await ctx.agents.create({
sessionId: SessionId('preset-both-full'),
sessionId: brandString<SessionId>('preset-both-full'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
const minimal = await ctx.agents.create({
sessionId: SessionId('preset-both-minimal'),
sessionId: brandString<SessionId>('preset-both-minimal'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
try {
@@ -596,7 +597,7 @@ describe('the shipped Web composition', () => {
it('composes the cordis agent with its own toolset', async () => {
const handle = await ctx.agents.create({
sessionId: SessionId('preset-cordis'),
sessionId: brandString<SessionId>('preset-cordis'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'cordis').then(() => undefined),
})
try {
@@ -619,7 +620,7 @@ describe('the shipped Web composition', () => {
expect(shipped).toEqual(['dsh-doc'])
expect((await ctx.skills.list()).map(skill => skill.name)).not.toContain('dsh-doc')
const loaded = await executeToolFixture(ctx, {
callId: ToolCallId('preset-cordis-dsh-doc'),
callId: brandString<ToolCallId>('preset-cordis-dsh-doc'),
name: 'skill',
arguments: { name: 'dsh-doc' },
signal: new AbortController().signal,
@@ -636,7 +637,7 @@ describe('the shipped Web composition', () => {
for (const file of readdirSync(references).filter(entry => entry !== 'packages.md')) {
const path = join(references, file)
const result = await executeToolFixture(ctx, {
callId: ToolCallId(`preset-cordis-dsh-doc-${file}`),
callId: brandString<ToolCallId>(`preset-cordis-dsh-doc-${file}`),
name: 'read',
arguments: { file_path: path },
signal: new AbortController().signal,
@@ -650,7 +651,7 @@ describe('the shipped Web composition', () => {
// Creator adds its DSH customization intent to the shared coding persona.
const standard = await ctx.agents.create({
sessionId: SessionId('preset-cordis-standard-persona'),
sessionId: brandString<SessionId>('preset-cordis-standard-persona'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
try {
@@ -674,7 +675,7 @@ describe('the shipped Web composition', () => {
})
try {
const codingOnly = await ctx.agents.create({
sessionId: SessionId('preset-cordis-coding-only'),
sessionId: brandString<SessionId>('preset-cordis-coding-only'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'cordis-coding-only').then(() => undefined),
})
try {
@@ -692,11 +693,11 @@ describe('the shipped Web composition', () => {
it('presents `ptc` as PTC mode without disturbing a native session beside it', async () => {
const coded = await ctx.agents.create({
sessionId: SessionId('preset-ptc'),
sessionId: brandString<SessionId>('preset-ptc'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'ptc').then(() => undefined),
})
const native = await ctx.agents.create({
sessionId: SessionId('preset-ptc-native'),
sessionId: brandString<SessionId>('preset-ptc-native'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
try {
@@ -725,7 +726,7 @@ describe('the shipped Web composition', () => {
it('keeps the self-referential toolset out of every other preset', async () => {
const handle = await ctx.agents.create({
sessionId: SessionId('preset-no-cordis'),
sessionId: brandString<SessionId>('preset-no-cordis'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
try {
@@ -758,7 +759,7 @@ describe('the shipped Web composition', () => {
const handle = await ctx.agents.create({
// Unique per run: the composition persists into the ambient DSH home,
// and a fixed id would collide with a log an earlier run left there.
sessionId: SessionId(`preset-skills-standard-${randomUUID()}`),
sessionId: brandString<SessionId>(`preset-skills-standard-${randomUUID()}`),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
try {
@@ -776,7 +777,7 @@ describe('the shipped Web composition', () => {
// The preset's own loader tool resolves the global-layer skill.
const loaded = await executeToolFixture(ctx, {
callId: ToolCallId('preset-skills-load'),
callId: brandString<ToolCallId>('preset-skills-load'),
name: 'skill',
arguments: { name: 'dsh-badge' },
signal: new AbortController().signal,
@@ -791,7 +792,7 @@ describe('the shipped Web composition', () => {
it('shows a minimal agent the global layer but no loader tool', async () => {
const handle = await ctx.agents.create({
sessionId: SessionId(`preset-skills-minimal-${randomUUID()}`),
sessionId: brandString<SessionId>(`preset-skills-minimal-${randomUUID()}`),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
try {
@@ -813,7 +814,7 @@ describe('the shipped Web composition', () => {
const before = await Promise.all(WEB_PATCHES.map(file => readFile(file, 'utf8')))
const handle = await ctx.agents.create({
sessionId: SessionId('preset-readonly'),
sessionId: brandString<SessionId>('preset-readonly'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
await handle.dispose()
@@ -838,7 +839,7 @@ describe('preset-selected delegation through the Web Loader', () => {
const adapter = new MinimalCompactionAdapter()
configured.llm.registerAdapter(['preset-switch'], adapter)
const { agent } = await configured.agents.create({
sessionId: SessionId(`configured-switch-${randomUUID()}`),
sessionId: brandString<SessionId>(`configured-switch-${randomUUID()}`),
agentOptions: { provider: 'preset-switch', model: 'preset-switch' },
setup: owner => configured.agentPresets.mount(owner, 'delegate-a').then(() => undefined),
})
@@ -879,7 +880,7 @@ describe.each(['web', 'desktop'] as const)('%s native subagent bundles', (surfac
async function presetTools(productCtx: Context, preset: string): Promise<string[]> {
const handle = await productCtx.agents.create({
sessionId: SessionId(`native-${surface}-${preset}-${randomUUID()}`),
sessionId: brandString<SessionId>(`native-${surface}-${preset}-${randomUUID()}`),
setup: owner => productCtx.agentPresets.mount(owner, preset).then(() => undefined),
})
try {
@@ -899,7 +900,7 @@ describe.each(['web', 'desktop'] as const)('%s native subagent bundles', (surfac
expect(await presetTools(productCtx, preset)).toEqual(expected)
}
const handle = await productCtx.agents.create({
sessionId: SessionId(`native-${surface}-params-${randomUUID()}`),
sessionId: brandString<SessionId>(`native-${surface}-params-${randomUUID()}`),
setup: owner => productCtx.agentPresets.mount(owner, 'standard').then(() => undefined),
})
try {
@@ -961,12 +962,12 @@ describe('the standard preset documentation skill', () => {
const adapter = new MinimalCompactionAdapter()
testCtx.llm.registerAdapter(['standard-doc-test'], adapter)
const baseline = await testCtx.agents.create({
sessionId: SessionId('standard-doc-baseline'), meta: { cwd: root },
sessionId: brandString<SessionId>('standard-doc-baseline'), meta: { cwd: root },
agentOptions: { provider: 'standard-doc-test', model: 'standard-doc-test' },
setup: agentCtx => testCtx.agentPresets.mount(agentCtx, 'standard-without-doc').then(() => undefined),
})
const standardAgent = await testCtx.agents.create({
sessionId: SessionId('standard-doc-current'), meta: { cwd: root },
sessionId: brandString<SessionId>('standard-doc-current'), meta: { cwd: root },
agentOptions: { provider: 'standard-doc-test', model: 'standard-doc-test' },
setup: agentCtx => testCtx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
@@ -978,7 +979,7 @@ describe('the standard preset documentation skill', () => {
expect(definition?.path).toBe(await realpath(join(REPO_ROOT, 'packages/preset/agent-preset/skills/dsh-doc/SKILL.md')))
if (definition === undefined) throw new Error('standard has no packaged dsh-doc skill')
const creator = await testCtx.agents.create({
sessionId: SessionId('standard-doc-creator'), meta: { cwd: root },
sessionId: brandString<SessionId>('standard-doc-creator'), meta: { cwd: root },
setup: agentCtx => testCtx.agentPresets.mount(agentCtx, 'cordis').then(() => undefined),
})
expect((await testCtx.skills.get('dsh-doc', { cwd: root, scope: creator.agent }))?.path).toBe(definition.path)
@@ -1023,7 +1024,7 @@ describe('the standard preset documentation skill', () => {
const profileManifest = join(root, 'profiles/spec/package.json')
const before = await readFile(profileManifest, 'utf8')
const loaded = await executeToolFixture(testCtx, {
agent: standardAgent.agent, callId: ToolCallId('standard-doc-load'),
agent: standardAgent.agent, callId: brandString<ToolCallId>('standard-doc-load'),
name: 'skill', arguments: { name: 'dsh-doc' }, signal: new AbortController().signal,
})
expect(loaded.isError).toBe(false)
@@ -1065,7 +1066,7 @@ describe('the standard preset documentation skill', () => {
priorityCtx = await bootWeb(root)
const testCtx = priorityCtx
const handle = await testCtx.agents.create({
sessionId: SessionId('standard-doc-priority'), meta: { cwd: workspace },
sessionId: brandString<SessionId>('standard-doc-priority'), meta: { cwd: workspace },
setup: agentCtx => testCtx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
for (const [cwd, path] of [
@@ -1105,11 +1106,11 @@ describe('a user preset declared from the shipped cordis rows', () => {
}] }])
try {
const shipped = await copyCtx.agents.create({
sessionId: SessionId(`preset-cordis-shipped-${randomUUID()}`),
sessionId: brandString<SessionId>(`preset-cordis-shipped-${randomUUID()}`),
setup: agentCtx => copyCtx.agentPresets.mount(agentCtx, 'cordis').then(() => undefined),
})
const copied = await copyCtx.agents.create({
sessionId: SessionId(`preset-cordis-copy-${randomUUID()}`),
sessionId: brandString<SessionId>(`preset-cordis-copy-${randomUUID()}`),
setup: agentCtx => copyCtx.agentPresets.mount(agentCtx, 'cordis-copy').then(() => undefined),
})
try {
@@ -1120,7 +1121,7 @@ describe('a user preset declared from the shipped cordis rows', () => {
}
const signal = new AbortController().signal
const listed = await executeToolFixture(copyCtx, {
callId: ToolCallId('copied-preset-inspect-list'),
callId: brandString<ToolCallId>('copied-preset-inspect-list'),
name: 'cordis_inspect_list',
arguments: {},
signal,
@@ -1137,7 +1138,7 @@ describe('a user preset declared from the shipped cordis rows', () => {
const spills = vi.spyOn(copyCtx.spillStore, 'saveText')
onTestFinished(() => { spills.mockRestore() })
const queried = await executeToolFixture(copyCtx, {
callId: ToolCallId('copied-preset-inspect-tools'),
callId: brandString<ToolCallId>('copied-preset-inspect-tools'),
name: 'cordis_inspect_query',
arguments: { platform: 'host', provider: 'Tool', method: 'listTools' },
signal,
@@ -1156,7 +1157,7 @@ describe('a user preset declared from the shipped cordis rows', () => {
type ConfigPage = { data: { entries: ConfigRow[]; total: number; nextOffset: number | null } }
const listConfigs = async (input: Record<string, string | number>, callId: string): Promise<ConfigPage['data']> => {
const page = await executeToolFixture(copyCtx, {
callId: ToolCallId(callId),
callId: brandString<ToolCallId>(callId),
name: 'cordis_inspect_query',
arguments: { platform: 'host', provider: 'Config', method: 'listConfigs', input },
signal,
@@ -1175,7 +1176,7 @@ describe('a user preset declared from the shipped cordis rows', () => {
expect(firstPage.entries).toHaveLength(5)
expect(firstPage.nextOffset).toBe(5)
const projected = await executeToolFixture(copyCtx, {
callId: ToolCallId('copied-preset-inspect-config'),
callId: brandString<ToolCallId>('copied-preset-inspect-config'),
name: 'cordis_inspect_query',
arguments: { platform: 'host', provider: 'Config', method: 'listConfigs', input: { entry: toolsRow!.id } },
signal,
@@ -1201,7 +1202,7 @@ describe('a user preset declared from the shipped cordis rows', () => {
describe('a switch survives the session', () => {
it('records the choice so the log states what the agent runs', async () => {
const handle = await ctx.agents.create({
sessionId: SessionId('preset-switch-logged'),
sessionId: brandString<SessionId>('preset-switch-logged'),
meta: { agentPreset: 'standard' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
@@ -1225,18 +1226,18 @@ describe('a switch survives the session', () => {
describe('a forked session', () => {
it('inherits the composition its seeded history was produced under', async () => {
const parent = await ctx.agents.create({
sessionId: SessionId('preset-fork-parent'),
sessionId: brandString<SessionId>('preset-fork-parent'),
meta: { agentPreset: 'minimal' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
const projection = await ctx.sessionProjections.register(agentPresetProjectionDefinition)
const inherited = projection.stateOf(parent.agent.session) ?? undefined
const child = await ctx.agents.create({
sessionId: SessionId('preset-fork-child'),
sessionId: brandString<SessionId>('preset-fork-child'),
seed: [],
inheritedEventCount: SessionLogOffset(0),
meta: {
parentSession: SessionId('preset-fork-parent'),
parentSession: brandString<SessionId>('preset-fork-parent'),
isSeeded: true,
...inherited === undefined ? {} : { agentPreset: inherited },
},
@@ -1258,13 +1259,13 @@ describe('a forked session', () => {
describe('a delegated child', () => {
it.each([false, true])('inherits preset tools with seeded=%s and refuses child scheduled tasks', async (seeded) => {
const parent = await ctx.agents.create({
sessionId: SessionId(`preset-child-parent-${seeded}`),
sessionId: brandString<SessionId>(`preset-child-parent-${seeded}`),
meta: { agentPreset: 'standard' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
// Exactly what an in-process subagent driver's creation window does.
const child = await parent.agent.ctx.agents.create({
sessionId: SessionId(`preset-child-${seeded}`),
sessionId: brandString<SessionId>(`preset-child-${seeded}`),
meta: childSessionMeta(parent.agent, 1, seeded),
...(seeded ? { seed: [], inheritedEventCount: SessionLogOffset(0) } : {}),
setup: (agentCtx) => {
@@ -1288,7 +1289,7 @@ describe('a delegated child', () => {
for (const [name, args] of calls) {
expect(toolNames(ctx, child.agent)).toContain(name)
const result = await executeToolFixture(ctx, {
callId: ToolCallId(`child-${name}`), signal: new AbortController().signal,
callId: brandString<ToolCallId>(`child-${name}`), signal: new AbortController().signal,
name, arguments: args, agent: child.agent,
})
expect(result.value).toEqual({ code: 'subagent_session', message: 'A delegated subagent cannot use scheduled tasks.' })
@@ -1302,13 +1303,13 @@ describe('a delegated child', () => {
it('follows a parent that switched preset while blank', async () => {
const parent = await ctx.agents.create({
sessionId: SessionId('preset-child-switch-parent'),
sessionId: brandString<SessionId>('preset-child-switch-parent'),
meta: { agentPreset: 'standard' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'standard').then(() => undefined),
})
await ctx.agentPresets.recompose(parent.agent.ctx, 'minimal')
const child = await parent.agent.ctx.agents.create({
sessionId: SessionId('preset-child-switch'),
sessionId: brandString<SessionId>('preset-child-switch'),
meta: childSessionMeta(parent.agent, 1, false),
setup: (agentCtx) => {
return applyChildComposition(agentCtx, parent.agent, {})
@@ -1335,7 +1336,7 @@ describe('the default preset as a user setting', () => {
expect(ctx.agentPresets.defaultId).toBe('minimal')
const handle = await ctx.agents.create({
sessionId: SessionId('preset-user-default'),
sessionId: brandString<SessionId>('preset-user-default'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx).then(() => undefined),
})
try {
@@ -1382,7 +1383,7 @@ describe('a profile patch stored before Developer tools owned preset selection',
.toEqual({ selectedDefault: 'minimal' })
const handle = await legacy.agents.create({
sessionId: SessionId('preset-legacy-patch'),
sessionId: brandString<SessionId>('preset-legacy-patch'),
setup: agentCtx => legacy.agentPresets.mount(agentCtx).then(() => undefined),
})
try {
@@ -1396,7 +1397,7 @@ describe('a profile patch stored before Developer tools owned preset selection',
describe('a session keeps the preset it was created with', () => {
it('refuses to adopt a live session under a different preset', async () => {
const handle = await ctx.agents.create({
sessionId: SessionId('preset-locked'),
sessionId: brandString<SessionId>('preset-locked'),
meta: { agentPreset: 'minimal' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
+3 -2
View File
@@ -5,10 +5,11 @@ import { join } from 'node:path'
import { Context } from '@deepseek-ai/cordis'
import { LocalFileSystem } from '@deepseek-ai/dsh-fs-local'
import SessionStore from '@deepseek-ai/dsh-session'
import { SessionId } from '@deepseek-ai/dsh-session/types'
import type { SessionId } from '@deepseek-ai/dsh-session/types'
import { sessionFileAddress } from '@deepseek-ai/dsh-util-workspace-path'
import { expect, it, onTestFinished, vi } from 'vitest'
import { localDragResource } from '../src/file-drag.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
async function fixture() {
const root = await mkdtemp(join(tmpdir(), 'dsh-host-drag-'))
@@ -17,7 +18,7 @@ async function fixture() {
await ctx.plugin(LocalFileSystem, { cwd: root })
await ctx.plugin(SessionStore)
ctx.provide('sandboxPolicy', { workspaceRoot: root } as never)
const id = SessionId('file-drag-test')
const id = brandString<SessionId>('file-drag-test')
ctx.sessions.create(id, { meta: { cwd: root, origin: 'subagent' } })
const path = join(root, '报告.pdf')
const bytes = Buffer.from('%PDF-1.4\n原始内容\n%%EOF')
@@ -1,7 +1,8 @@
import { Context } from '@deepseek-ai/cordis'
import { JobId, JobRegistry } from '@deepseek-ai/dsh-jobs'
import { type JobId, JobRegistry } from '@deepseek-ai/dsh-jobs'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { JobStatus, JobView } from '@deepseek-ai/dsh-jobs'
import { SessionId } from '@deepseek-ai/dsh-session/types'
import type { SessionId } from '@deepseek-ai/dsh-session/types'
import type { SessionActivity } from '@deepseek-ai/dsh-workspace'
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { installDesktopQuitInspection } from '../src/quit-inspection.ts'
@@ -21,7 +22,7 @@ class RosterOnlyJobRegistry extends JobRegistry {
start(): never { throw new Error('unsupported') }
list(caller?: SessionId): JobView[] {
return (jobs.get(caller) ?? []).map((status, index) => ({
id: JobId(`bash-${index + 1}`),
id: brandString<JobId>(`bash-${index + 1}`),
kind: 'bash',
label: 'sleep 60',
...caller === undefined ? {} : { owner: caller },
@@ -40,7 +41,7 @@ class RosterOnlyJobRegistry extends JobRegistry {
}
function agent(id: string, status: 'idle' | 'running' = 'idle'): AgentState {
return { id: SessionId(id), status, inbox: { nextTurn: [], nextStep: [] } }
return { id: brandString<SessionId>(id), status, inbox: { nextTurn: [], nextStep: [] } }
}
beforeEach(() => {
@@ -60,7 +61,7 @@ afterEach(async () => { await ctx.fiber.dispose() })
describe('Desktop Host quit inspection', () => {
it('reports neither active nor scheduled work for idle loaded sessions', async () => {
agents.push(agent('quiet'))
activity.set(SessionId('quiet'), [{ kind: 'turn' }])
activity.set(brandString<SessionId>('quiet'), [{ kind: 'turn' }])
expect(await inspect()).toEqual({ activeTasks: false, scheduledTasks: false })
})
@@ -77,14 +78,14 @@ describe('Desktop Host quit inspection', () => {
const asked: SessionId[] = []
ctx.on('workspace/session-activity', async ({ sessionId }, next) => { asked.push(sessionId); return next() })
agents.push(agent('first'), agent('second'), agent('third'))
activity.set(SessionId('second'), [{ kind: 'schedule', items: [{ id: 'reminder-1', label: 'stand-up' }] }])
activity.set(brandString<SessionId>('second'), [{ kind: 'schedule', items: [{ id: 'reminder-1', label: 'stand-up' }] }])
expect(await inspect()).toEqual({ activeTasks: false, scheduledTasks: true })
expect(asked).toEqual([SessionId('first'), SessionId('second')])
expect(asked).toEqual([brandString<SessionId>('first'), brandString<SessionId>('second')])
})
it('reports both when a running session also holds a reminder', async () => {
agents.push(agent('both', 'running'))
activity.set(SessionId('both'), [{ kind: 'job', items: [{ id: 'bash-1' }] }, { kind: 'schedule', items: [{ id: 'reminder-2' }] }])
activity.set(brandString<SessionId>('both'), [{ kind: 'job', items: [{ id: 'bash-1' }] }, { kind: 'schedule', items: [{ id: 'reminder-2' }] }])
expect(await inspect()).toEqual({ activeTasks: true, scheduledTasks: true })
})
+1
View File
@@ -55,6 +55,7 @@
"@deepseek-ai/cordis": "workspace:~"
},
"devDependencies": {
"@deepseek-ai/dsh-brand": "workspace:*",
"@deepseek-ai/dsh-app-boot": "workspace:*",
"@deepseek-ai/dsh-client-ui-settings-general": "workspace:*",
"@deepseek-ai/dsh-client-ui-sidebar-browser": "workspace:*",
+5 -4
View File
@@ -1,7 +1,8 @@
import { Context } from '@deepseek-ai/cordis'
import { JobId, JobRegistry } from '@deepseek-ai/dsh-jobs'
import { type JobId, JobRegistry } from '@deepseek-ai/dsh-jobs'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { JobStatus, JobView } from '@deepseek-ai/dsh-jobs'
import { SessionId } from '@deepseek-ai/dsh-session/types'
import type { SessionId } from '@deepseek-ai/dsh-session/types'
import { Readable } from 'node:stream'
import type { IncomingMessage, ServerResponse } from 'node:http'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
@@ -20,7 +21,7 @@ class RosterOnlyJobRegistry extends JobRegistry {
start(): never { throw new Error('unsupported') }
list(caller?: SessionId): JobView[] {
return (jobs.get(caller) ?? []).map((status, index) => ({
id: JobId(`bash-${index + 1}`),
id: brandString<JobId>(`bash-${index + 1}`),
kind: 'bash',
label: 'sleep 60',
...caller === undefined ? {} : { owner: caller },
@@ -50,7 +51,7 @@ beforeEach(() => {
afterEach(async () => { await ctx.fiber.dispose() })
function idleAgent(): AgentState { return { id: SessionId('update-task-owner'), status: 'idle', inbox: { nextTurn: [], nextStep: [] } } }
function idleAgent(): AgentState { return { id: brandString<SessionId>('update-task-owner'), status: 'idle', inbox: { nextTurn: [], nextStep: [] } } }
function request(next: () => Promise<void>) {
const incoming = Readable.from([]) as IncomingMessage
+1
View File
@@ -31,6 +31,7 @@
},
"license": "MIT",
"devDependencies": {
"@deepseek-ai/dsh-brand": "workspace:*",
"@deepseek-ai/cordis-plugin-group": "workspace:~",
"@deepseek-ai/dsh-client-modules": "workspace:*",
"@deepseek-ai/dsh-client-store": "workspace:*",
+3 -2
View File
@@ -16,7 +16,7 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import {
SESSION_FORMAT_VERSION, SessionId as sessionId, type SessionEvent, type SessionHeader, type SessionId,
SESSION_FORMAT_VERSION, type SessionId as sessionId, type SessionEvent, type SessionHeader, type SessionId,
} from '@deepseek-ai/dsh-session'
import { SUBAGENT_DESCRIPTOR_VERSION } from '@deepseek-ai/dsh-subagent'
import { createSystemMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
@@ -27,6 +27,7 @@ import {
import { openSettings,
connectFreshWorkspace, newEnglishPage, saveFailureShot, writeComposerDraft,
} from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/agent-preset-selection', import.meta.url))
const HERO_EXPECTED = join(SNAPSHOT_DIR, 'hero.expected.md')
@@ -35,7 +36,7 @@ const HEADER_EXPECTED = join(SNAPSHOT_DIR, 'header.expected.md')
const MODE = webSnapshotMode()
const SEED_ID = 'agent-preset-selection-web-e2e'
const SEED_TIME = 1784974100000
const SEEDED_CHILD_ID = sessionId('agent-preset-selection-child')
const SEEDED_CHILD_ID = brandString<sessionId>('agent-preset-selection-child')
const SEEDED_CHILD_CREATED_AT = 1784974100100
/** A project skill only a preset that mounts `skill-filesystem` can discover. */
const SKILL_NAME = 'preset-catalog-demo'
+8 -7
View File
@@ -6,8 +6,9 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed, onTestFinished, vi } from 'vitest'
import type {} from '@deepseek-ai/dsh-agent-team'
import { SessionId } from '@deepseek-ai/dsh-session'
import { CommandId } from '@deepseek-ai/dsh-commands/brand'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { CommandId } from '@deepseek-ai/dsh-commands/brand'
import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import {
acknowledgeReloadConnectionLoss, assertFixtureInventory, captureStableAria, compareOrRefreshGolden,
@@ -193,7 +194,7 @@ describe('web e2e: agent teamwork panel', () => {
const agent = scaffold.ctx.agents.list()[0]!
expect(scaffold.ctx.commands.list(agent).some(command => command.name === 'team')).toBe(false)
expect(agent.session.ownEvents().filter(event => event.type === 'command/run' || event.type === 'command/done')).toEqual([])
const other = await scaffold.ctx.agents.create({ sessionId: SessionId('other-team-mode'), agentOptions: agent.options })
const other = await scaffold.ctx.agents.create({ sessionId: brandString<SessionId>('other-team-mode'), agentOptions: agent.options })
expect(scaffold.ctx.agentTeams.isEnabled(other.agent)).toBe(false)
await other.dispose()
const beforeReload = tripwire.warnings.length
@@ -268,7 +269,7 @@ describe('web e2e: agent teamwork panel', () => {
const projectionReads = vi.spyOn(scaffold.ctx.sessionController, 'projections')
onTestFinished(() => { projectionReads.mockRestore() })
const agent = scaffold.ctx.agents.list()[0]!
const memberId = SessionId('team-panel-researcher')
const memberId = brandString<SessionId>('team-panel-researcher')
agent.session.append('subagent/catalog', {
version: 2, childId: memberId, childCreatedAt: Date.now(), mode: 'external',
label: RESEARCHER_DESCRIPTION,
@@ -913,12 +914,12 @@ it.each(RECEIPT_LOCALES)('toggles teamwork in $language without command records
// Historical receipts are read-only fixtures, not invocations of a registered command.
for (const args of [' on', ' off']) {
const commandId = CommandId(`historical-team-${args.trim()}`)
const commandId = brandString<CommandId>(`historical-team-${args.trim()}`)
agent.session.append('command/run', { commandId, name: 'team', args, source: { kind: 'user' } })
agent.session.append('command/done', { commandId, kind: 'success', text: 'Team mode saved.' })
}
agent.session.append('command/run', {
commandId: CommandId('historical-team-pending'), name: 'team', args: ' on', source: { kind: 'user' },
commandId: brandString<CommandId>('historical-team-pending'), name: 'team', args: ' on', source: { kind: 'user' },
})
await scaffold.ctx.sessions.flush(agent.session)
const historicalCommands = commandEvents()
@@ -938,7 +939,7 @@ it.each(RECEIPT_LOCALES)('renders historical Team failures in $language without
await withTeamReceiptPage(locale, async (page, scaffold, tripwire) => {
const agent = scaffold.ctx.agents.list()[0]
if (agent === undefined) throw new Error('Team failure fixture has no Agent')
const commandId = CommandId('historical-team-error')
const commandId = brandString<CommandId>('historical-team-error')
agent.session.append('command/run', { commandId, name: 'team', args: ' invalid', source: { kind: 'user' } })
agent.session.append('command/done', { commandId, kind: 'error', text: 'Use /team on or /team off.' })
await scaffold.ctx.sessions.flush(agent.session)
+7 -6
View File
@@ -8,9 +8,10 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { Agent } from '@deepseek-ai/dsh-agent'
import { ToolCallId } from '@deepseek-ai/dsh-llm'
import { SessionId } from '@deepseek-ai/dsh-session'
import { JobId } from '@deepseek-ai/dsh-jobs'
import type { ToolCallId } from '@deepseek-ai/dsh-llm'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type { JobId } from '@deepseek-ai/dsh-jobs'
import { brandString } from '@deepseek-ai/dsh-brand'
import {
assertFixtureInventory, captureStableAria, compareOrRefreshGolden,
launchWebScaffold, seedSession, watchConsole, webSnapshotMode, type WebScaffold,
@@ -72,7 +73,7 @@ describe.skipIf(MODE === 'record')('web e2e: background job list', () => {
// Opening the session drives the Host's ordinary Agent resolution; the
// job owner must be that exact live instance, never a second one.
// `expect.poll` is test-scoped, so this hook polls by hand.
agent = await liveAgent(scaffold, SessionId(SEED_ID))
agent = await liveAgent(scaffold, brandString<SessionId>(SEED_ID))
}, 120_000)
afterAll(async () => {
@@ -90,7 +91,7 @@ describe.skipIf(MODE === 'record')('web e2e: background job list', () => {
const started = await executeToolFixture(scaffold.ctx, {
signal: new AbortController().signal,
callId: ToolCallId('background-job-list-e2e'),
callId: brandString<ToolCallId>('background-job-list-e2e'),
name: 'bash',
arguments: { command: COMMAND, description: 'Hold a background slot open', run_in_background: true },
agent,
@@ -98,7 +99,7 @@ describe.skipIf(MODE === 'record')('web e2e: background job list', () => {
const reported = started.content.map(block => block.type === 'text' ? block.text : '').join('')
const matched = /\bbash-[0-9a-f]{16}\b/.exec(reported)
if (matched === null) throw new Error(`background bash reported no job id: ${reported}`)
const jobId = JobId(matched[0])
const jobId = brandString<JobId>(matched[0])
await trigger.waitFor({ timeout: 15_000 })
expect(await trigger.locator('[data-state="ongoing"]').count()).toBe(1)
+5 -4
View File
@@ -4,10 +4,11 @@ import { mkdir } from 'node:fs/promises'
import { join } from 'node:path'
import { chromium, type Browser, type Page } from 'playwright'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionEvent } from '@deepseek-ai/dsh-session'
import { launchWebScaffold, watchConsole, type WebScaffold } from './scaffold.ts'
import { newEnglishPage } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
/** A preset these blank Sessions recorded that the deployment no longer declares. */
const UNDECLARED = 'liangshen'
@@ -91,7 +92,7 @@ describe('web e2e: blank Session reuse under the requested preset', () => {
}
it('reuses a blank recorded under an undeclared preset under the default when startup connects its Workspace', async () => {
const stale = SessionId('blank-undeclared')
const stale = brandString<SessionId>('blank-undeclared')
await storeBlank(stale, 'undeclared', UNDECLARED)
const page = await openPage()
@@ -105,7 +106,7 @@ describe('web e2e: blank Session reuse under the requested preset', () => {
})
it('restores a saved blank under the preset it recorded', async () => {
const picked = SessionId('blank-picked')
const picked = brandString<SessionId>('blank-picked')
await storeBlank(picked, 'picked', 'minimal')
const page = await openPage(picked)
@@ -115,7 +116,7 @@ describe('web e2e: blank Session reuse under the requested preset', () => {
})
it('restores a saved blank under the default once its recorded preset is undeclared', async () => {
const saved = SessionId('saved-undeclared')
const saved = brandString<SessionId>('saved-undeclared')
await storeBlank(saved, 'saved-undeclared', UNDECLARED)
const page = await openPage(saved)
+5 -4
View File
@@ -2,13 +2,14 @@
import { chromium, type Browser, type Page } from 'playwright'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionHandle } from '@deepseek-ai/dsh-session-persistence'
import { launchWebScaffold, watchConsole, type WebScaffold } from './scaffold.ts'
import { newEnglishPage } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const HELD = SessionId('blank-held')
const FREE = SessionId('blank-free')
const HELD = brandString<SessionId>('blank-held')
const FREE = brandString<SessionId>('blank-free')
describe.each([false, true])('web e2e: selected blank writer held: %s', (held) => {
let scaffold: WebScaffold
@@ -66,7 +67,7 @@ describe.each([false, true])('web e2e: selected blank writer held: %s', (held) =
const id = await selected(first)
return id !== undefined && (!held || id !== HELD)
}).toBe(true)
const selectedId = SessionId((await selected(first))!)
const selectedId = brandString<SessionId>((await selected(first))!)
expect(selectedId).not.toBe(FREE)
await expect.poll(() => scaffold.ctx.agents.get(selectedId)).toBeDefined()
if (!held) {
@@ -9,7 +9,8 @@ import { join } from 'node:path'
import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { ToolCallId, expandAssistantStream, type StreamChunk } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, expandAssistantStream, type StreamChunk } from '@deepseek-ai/dsh-llm'
import type { ReplayEntry, ReplayOverrideDoc } from '@deepseek-ai/dsh-llm-replay'
import type { SessionEvent, SessionId } from '@deepseek-ai/dsh-session'
import {
@@ -34,7 +35,7 @@ interface TurnSpec {
readonly firstMarker: string
readonly doneMarker: string
readonly deltas: readonly string[]
readonly callId?: ReturnType<typeof ToolCallId>
readonly callId?: ToolCallId
readonly toolResultMarker?: string
}
@@ -83,7 +84,7 @@ function turnSpec(index: number): TurnSpec {
firstMarker,
doneMarker,
deltas,
callId: ToolCallId(`continuous-chat-tool-${id}`),
callId: brandString<ToolCallId>(`continuous-chat-tool-${id}`),
toolResultMarker: `CONTINUOUS_CHAT_TOOL_RESULT_${id}`,
}
}
+3 -2
View File
@@ -19,10 +19,11 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import type { StreamChunk } from '@deepseek-ai/dsh-llm'
import { createAssistantMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import type { ReplayEntry } from '@deepseek-ai/dsh-llm-replay'
import { SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import type { SessionId, SessionEvent } from '@deepseek-ai/dsh-session'
import { createChatScrollFixture } from './chat-scroll-fixture.ts'
import { launchWebScaffold, parseSeedFixture, seedSession, watchConsole, webSnapshotMode, type WebScaffold } from './scaffold.ts'
import { newEnglishPage, openSettings } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
declare global {
interface Window {
@@ -248,7 +249,7 @@ async function sendFromOpenedGroup(browser: Browser, id: string, answerParagraph
const tripwire = watchConsole(page)
await page.setViewportSize({ width: 1170, height: 826 })
await page.emulateMedia({ reducedMotion: 'no-preference' })
const session = SessionId(`open-fold-${id}`)
const session = brandString<SessionId>(`open-fold-${id}`)
const { log, search } = seededLog(id, answerParagraphs)
await seedSession(scaffold, log, session)
await page.goto(scaffold.authenticatedUrl, { waitUntil: 'load' })
+4 -3
View File
@@ -10,7 +10,7 @@ import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { StreamChunk } from '@deepseek-ai/dsh-llm'
import type { ReplayEntry, ReplayOverrideDoc } from '@deepseek-ai/dsh-llm-replay'
import { SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import type { SessionId, SessionEvent } from '@deepseek-ai/dsh-session'
import { createChatScrollFixture } from './chat-scroll-fixture.ts'
import {
launchWebScaffold,
@@ -20,6 +20,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { conversationContextKey, expandOwningTurnProcess, loadEarlierChatPage, newEnglishPage, saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const MODE = webSnapshotMode()
const SESSION_ID = 'chat-long-interactions-e2e'
@@ -174,10 +175,10 @@ describe('web e2e: long Chat interaction contract', () => {
it.skipIf(MODE === 'record')('keeps heterogeneous rows and their actions bound to exact semantic identities', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-chat-long-interactions'))
await expect.poll(
() => scaffold.ctx.agents.get(SessionId(SESSION_ID)) !== undefined,
() => scaffold.ctx.agents.get(brandString<SessionId>(SESSION_ID)) !== undefined,
{ timeout: 10_000 },
).toBe(true)
const source = scaffold.ctx.agents.get(SessionId(SESSION_ID))
const source = scaffold.ctx.agents.get(brandString<SessionId>(SESSION_ID))
if (source === undefined) throw new Error('seeded long-history agent is not attached')
const toolUserMarker = FIXTURE.markers.user(TOOL_TURN)
+7 -6
View File
@@ -10,11 +10,12 @@ import type { Browser, Page, Route } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import type { StreamChunk } from '@deepseek-ai/dsh-llm'
import { ToolCallId, createAssistantMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createAssistantMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import type { AssistantStreamFrame } from '@deepseek-ai/dsh-agent'
import type { ReplayEntry, ReplayOverrideDoc } from '@deepseek-ai/dsh-llm-replay'
import type { SessionEvent } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, type SessionId } from '@deepseek-ai/dsh-session'
import { createChatScrollFixture, type ChatScrollFixture } from './chat-scroll-fixture.ts'
import {
launchWebScaffold,
@@ -28,7 +29,7 @@ import { expandOwningTurnProcess, newEnglishPage, openSettings, saveFailureShot
const MODE = webSnapshotMode()
const HISTORY_SESSION_ID = 'chat-scroll-history-e2e'
const TOOL_SESSION_ID = SessionId('chat-scroll-tool-e2e')
const TOOL_SESSION_ID = brandString<SessionId>('chat-scroll-tool-e2e')
const RESTORE_SESSION_A_ID = 'chat-scroll-restore-a-e2e'
const RESTORE_SESSION_B_ID = 'chat-scroll-restore-b-e2e'
const REPLAY_CONTEXT_WINDOW = 10_000_000
@@ -39,7 +40,7 @@ const LIVE_TEXT_PROMPT = 'CHAT_SCROLL_LIVE_USER Continue this long conversation
const LIVE_TEXT_FIRST = 'CHAT_SCROLL_LIVE_FIRST'
const LIVE_TEXT_DONE = 'CHAT_SCROLL_LIVE_DONE'
const LIVE_TOOL_PROMPT = 'CHAT_SCROLL_TOOL_USER Run the requested diagnostic and then summarize it.'
const LIVE_TOOL_CALL_ID = ToolCallId('chat-scroll-live-tool-call')
const LIVE_TOOL_CALL_ID = brandString<ToolCallId>('chat-scroll-live-tool-call')
const LIVE_TOOL_RESULT = 'CHAT_SCROLL_LIVE_TOOL_RESULT'
const LIVE_TOOL_FIRST = 'CHAT_SCROLL_TOOL_STREAM_FIRST'
const LIVE_TOOL_DONE = 'CHAT_SCROLL_TOOL_STREAM_DONE'
@@ -47,7 +48,7 @@ const TOOL_READY_FILE = '.chat-scroll-tool-ready'
const TOOL_RELEASE_FILE = '.chat-scroll-tool-release'
const INPUTS_SESSION_ID = 'chat-scroll-inputs-e2e'
const RAIL_SESSION_ID = 'chat-scroll-rail-e2e'
const FLING_SESSION_ID = SessionId('chat-scroll-fling-e2e')
const FLING_SESSION_ID = brandString<SessionId>('chat-scroll-fling-e2e')
const LIVE_FLING_PROMPT = 'CHAT_SCROLL_FLING_USER Keep streaming while I fling back through older output.'
const LIVE_FLING_FIRST = 'CHAT_SCROLL_FLING_STREAM_FIRST'
const LIVE_FLING_DONE = 'CHAT_SCROLL_FLING_STREAM_DONE'
@@ -749,7 +750,7 @@ describe('web e2e: long Chat scroll contract', () => {
yield chunk
}
})
const resolved = await world.scaffold.ctx.sessionController.resolveAgent(SessionId(`visible-fold-${scenario.name}`))
const resolved = await world.scaffold.ctx.sessionController.resolveAgent(brandString<SessionId>(`visible-fold-${scenario.name}`))
if ('error' in resolved) throw resolved.error
// Maintenance keeps the accepted message in the inbox, so its echo folds the earlier work before the Turn starts.
const promptGate = Promise.withResolvers<undefined>()
+5 -4
View File
@@ -2,8 +2,9 @@
// generated through Session so pagination exercises the same event shapes as
// persisted conversations, while unique markers identify semantic rows
// without depending on CSS-module names or virtualizer DOM positions.
import { brandString } from '@deepseek-ai/dsh-brand'
import {
ToolCallId,
type ToolCallId,
createAssistantMessage,
createSystemMessage,
createToolResultMessage,
@@ -12,7 +13,7 @@ import {
import {
SESSION_FORMAT_VERSION,
Session,
SessionId,
type SessionId,
} from '@deepseek-ai/dsh-session'
// Carries the session/title event declaration into this fixture builder.
import type {} from '@deepseek-ai/dsh-session-title'
@@ -114,7 +115,7 @@ function appendToolStep(
): void {
const calls = [1, 2].map((index) => {
const marker = markers.tool(turn, index)
const callId = ToolCallId(`chat-scroll-${suffix(turn)}-${String(index)}`)
const callId = brandString<ToolCallId>(`chat-scroll-${suffix(turn)}-${String(index)}`)
const args = JSON.stringify({
command: `printf '${marker}\\n'`,
description: marker,
@@ -190,7 +191,7 @@ function fixtureLog(session: Session): string {
export function createChatScrollFixture(options: ChatScrollFixtureOptions): ChatScrollFixture {
const turns = options.turns ?? DEFAULT_TURNS
const markers = markerHelpers(options.markerPrefix)
const session = Session.create(SessionId(`chat-scroll-${options.markerPrefix.toLowerCase()}-template`))
const session = Session.create(brandString<SessionId>(`chat-scroll-${options.markerPrefix.toLowerCase()}-template`))
for (let turn = 1; turn <= turns; turn += 1) {
session.append('turn/start', {
@@ -21,8 +21,9 @@ import { fileURLToPath } from 'node:url'
import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import type { JsonValue } from '@deepseek-ai/dsh-util-values'
import type {} from '@deepseek-ai/dsh-session-title'
import {
@@ -210,7 +211,7 @@ const CALLS: GalleryCall[] = [
* the tripwire stays clean; the varying origin is tokenized in the golden).
*/
function galleryFixture(imageUrl: string): string {
const session = Session.create(SessionId('clickable-links-gallery-source'))
const session = Session.create(brandString<SessionId>('clickable-links-gallery-source'))
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
content: text('Assemble the link gallery: write the report and styles, inspect the sources, and summarize.'),
@@ -224,7 +225,7 @@ function galleryFixture(imageUrl: string): string {
session.append('step/start', { turn: 1, step: 1 })
const calls = CALLS.map((call, index) => ({
...call,
callId: ToolCallId(`gallery-${String(index)}`),
callId: brandString<ToolCallId>(`gallery-${String(index)}`),
argsJson: JSON.stringify(call.args),
}))
session.append('assistant/message', {
+5 -4
View File
@@ -9,8 +9,9 @@ import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import * as yaml from 'js-yaml'
import { entryListSchema } from '@deepseek-ai/cordis-plugin-include'
import { brandString } from '@deepseek-ai/dsh-brand'
import {
createAssistantMessage, createMessage, createUserMessage, ToolCallId,
createAssistantMessage, createMessage, createUserMessage, type ToolCallId,
type AssistantStreamRecord, type TokenUsage,
} from '@deepseek-ai/dsh-llm'
import {
@@ -100,7 +101,7 @@ describe('web e2e: Statistics view', () => {
agent.session.append('tool/call', {
turn: 1,
step: 1,
callId: ToolCallId('call-1'),
callId: brandString<ToolCallId>('call-1'),
name: 'read',
arguments: JSON.stringify({ file_path: '/work/notes.md' }),
})
@@ -110,8 +111,8 @@ describe('web e2e: Statistics view', () => {
message: createMessage({
role: 'tool',
content: [{ type: 'text', text: 'one\ntwo' }],
source: { kind: 'tool', callId: ToolCallId('call-1') },
toolCallId: ToolCallId('call-1'),
source: { kind: 'tool', callId: brandString<ToolCallId>('call-1') },
toolCallId: brandString<ToolCallId>('call-1'),
}),
}, { surfaceOp: 'append' })
agent.session.append('step/end', { turn: 1, step: 1 })
+5 -4
View File
@@ -2,8 +2,9 @@
import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import type { JsonValue } from '@deepseek-ai/dsh-util-values'
import { launchWebScaffold, seedSession, watchConsole, type WebScaffold } from './scaffold.ts'
import { expandTurnProcesses, newEnglishPage, saveFailureShot } from './support.ts'
@@ -28,13 +29,13 @@ function layoutFixture(): string {
name: 'edit', args: { file_path: 'long.txt', old_string: oldText, new_string: newText },
result: 'Edited long.txt', meta: { diffs: [{ path: 'long.txt', oldText, newText }] },
})
const session = Session.create(SessionId('code-card-layout-source'))
const session = Session.create(brandString<SessionId>('code-card-layout-source'))
session.append('turn/start', { turn: 1 })
session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'Inspect the source windows and edit the long lines.' }], source: { kind: 'user' },
}), { surfaceOp: 'append' })
session.append('step/start', { turn: 1, step: 1 })
const namedCalls = calls.map((call, index) => ({ ...call, id: ToolCallId(`layout-${index}`), arguments: JSON.stringify(call.args) }))
const namedCalls = calls.map((call, index) => ({ ...call, id: brandString<ToolCallId>(`layout-${index}`), arguments: JSON.stringify(call.args) }))
session.append('assistant/message', {
stream: [], turn: 1, step: 1,
message: createAssistantMessage({
+3 -2
View File
@@ -4,14 +4,15 @@ import { fileURLToPath } from 'node:url'
import { chromium, type Browser, type Page } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, SessionId, SessionSeq } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, type SessionId, SessionSeq } from '@deepseek-ai/dsh-session'
import {
captureStableAria, compareOrRefreshGolden, launchWebScaffold,
watchConsole, webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SESSION_ID = SessionId('cold-inbox-web-e2e')
const SESSION_ID = brandString<SessionId>('cold-inbox-web-e2e')
const PENDING_TEXT = 'Accepted before the Host restarted'
const EXPECTED = fileURLToPath(new URL('./expected/cold-blank-session/queue.expected.md', import.meta.url))
+4 -3
View File
@@ -7,12 +7,13 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { deriveReplayScript } from '@deepseek-ai/dsh-llm-replay'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import {
assertFixtureInventory, captureStableAria, compareOrRefreshGolden, fixtureUserPrompts,
launchWebScaffold, parseSeedFixture, readPersistedEvents, seedSession, watchConsole, webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, openSettings, pinBrowserClock, pinHostClock, saveFailureShot, WEB_FIXTURE_TIME, writeComposerDraft } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('../../../snapshots/web/collapse-timing', import.meta.url))
const SEED = fileURLToPath(new URL('../../../snapshots/web/seeded-history/session.v3.jsonl', import.meta.url))
@@ -146,7 +147,7 @@ describe.skipIf(MODE === 'record')('web e2e: recorded collapse timing', () => {
const input = page.locator('[data-composer-input]').last()
await writeComposerDraft(page, input, prompt)
await expectProcess(1, true)
const resolved = await scaffold.ctx.sessionController.resolveAgent(SessionId(SEED_ID))
const resolved = await scaffold.ctx.sessionController.resolveAgent(brandString<SessionId>(SEED_ID))
if ('error' in resolved) throw resolved.error
// Maintenance keeps the accepted message in the inbox, so its echo stays before the Turn starts.
const release = Promise.withResolvers<undefined>()
@@ -168,7 +169,7 @@ describe.skipIf(MODE === 'record')('web e2e: recorded collapse timing', () => {
await expect.poll(() => page.locator('[data-streaming="true"]').count(), UI_WAIT).toBe(0)
await expectProcess(1, false)
await expectProcess(2, true)
const persisted = await readPersistedEvents(scaffold, SessionId(SEED_ID))
const persisted = await readPersistedEvents(scaffold, brandString<SessionId>(SEED_ID))
expect(persisted.filter(event => event.type === 'turn/end').map(event => event.data)).toEqual([
{ turn: 1, reason: { kind: 'completed' } },
{ turn: 2, reason: { kind: 'completed' } },
+9 -8
View File
@@ -10,8 +10,9 @@ import type { Browser, CDPSession, Locator, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import type { StreamChunk } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import {
ToolCallId,
type ToolCallId,
createAssistantMessage,
createSystemMessage,
createToolResultMessage,
@@ -23,7 +24,7 @@ import type { SessionEvent, SessionSeq } from '@deepseek-ai/dsh-session'
import {
SESSION_FORMAT_VERSION,
Session,
SessionId,
type SessionId,
} from '@deepseek-ai/dsh-session'
// Carries the session/title event declaration into the fixture builder.
import type {} from '@deepseek-ai/dsh-session-title'
@@ -243,7 +244,7 @@ function appendToolStep(
toolCount: number,
): void {
const calls = Array.from({ length: toolCount }, (_, index) => {
const callId = ToolCallId(`perf-call-${String(turn)}-${String(index)}`)
const callId = brandString<ToolCallId>(`perf-call-${String(turn)}-${String(index)}`)
const args = JSON.stringify({
turn,
index,
@@ -332,7 +333,7 @@ function fixtureLog(session: Session): string {
}
function smallSidebarFixture(): string {
const session = Session.create(SessionId('perf-small-template'))
const session = Session.create(brandString<SessionId>('perf-small-template'))
session.append('turn/start', {
turn: 1,
})
@@ -355,7 +356,7 @@ function smallSidebarFixture(): string {
}
function longHistoryFixture(): string {
const session = Session.create(SessionId(LONG_SESSION_ID))
const session = Session.create(brandString<SessionId>(LONG_SESSION_ID))
for (let turn = 1; turn <= LONG_HISTORY_TURNS; turn += 1) {
session.append('turn/start', {
turn,
@@ -482,7 +483,7 @@ function soakTurn(index: number): ConversationTurnSpec {
}
function toolStream(index: number, marker: string): StreamChunk[] {
const callId = ToolCallId(`performance-tool-${marker.toLowerCase()}-${String(index)}`)
const callId = brandString<ToolCallId>(`performance-tool-${marker.toLowerCase()}-${String(index)}`)
const args = JSON.stringify({
command: `printf '${marker}\\n'`,
description: `Emit performance marker ${String(index)}`,
@@ -1342,7 +1343,7 @@ describe('manual web performance: complex workspace and history', () => {
startingTurns: DEFAULT_HISTORY_TURNS,
turnCount: COMPARISON_TURNS,
turnSpec: comparisonTurn,
expectedSessionId: SessionId(LONG_SESSION_ID),
expectedSessionId: brandString<SessionId>(LONG_SESSION_ID),
})
expect(conversation.toolTurns).toBe(2)
console.info(`WEB_PERF_RESULT ${JSON.stringify({
@@ -1388,7 +1389,7 @@ describe('manual web performance: complex workspace and history', () => {
startingTurns: LONG_HISTORY_TURNS,
turnCount: COMPARISON_TURNS,
turnSpec: comparisonTurn,
expectedSessionId: SessionId(LONG_SESSION_ID),
expectedSessionId: brandString<SessionId>(LONG_SESSION_ID),
})
expect(conversation.toolTurns).toBe(2)
console.info(`WEB_PERF_RESULT ${JSON.stringify({
+3 -2
View File
@@ -6,10 +6,11 @@ import { chromium, type Browser, type Locator, type Page } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed, vi } from 'vitest'
import { createLaunchEnvironmentSnapshot } from '@deepseek-ai/dsh-launch-environment'
import { createAssistantMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
import { launchWebScaffold, seedSession, watchConsole, type WebScaffold } from './scaffold.ts'
import { saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const GIF = Buffer.from('R0lGODdhMAAgAIEAAEtu5gAAAAAAAAAAACwAAAAAMAAgAEAIQQABCBxIsKDBgwgTKlzIsKHDhxAjSpxIsaLFixgzatzIsaPHjyBDihxJsqTJkyhTqlzJsqXLlzBjypxJs6bNmQEBADs=', 'base64')
async function menuLabels(menu: Locator): Promise<string[]> {
@@ -20,7 +21,7 @@ async function menuLabels(menu: Locator): Promise<string[]> {
}))
}
function fixture(title: string): string {
const session = Session.create(SessionId('context-menus-source'))
const session = Session.create(brandString<SessionId>('context-menus-source'))
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({ content: [{ type: 'text', text: 'Show the output.' }], source: { kind: 'user' } }), { surfaceOp: 'append' })
session.append('session/title', { title, messageSeqs: [user.seq], source: { kind: 'fallback' } })
+3 -2
View File
@@ -3,13 +3,14 @@ import { readFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { SessionId } from '@deepseek-ai/dsh-session/types'
import type { SessionId } from '@deepseek-ai/dsh-session/types'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import {
captureStableAria, compareOrRefreshGolden, launchWebScaffold, seedSession, readPersistedEvents, parseSeedFixture, realizeSeedFixture,
watchConsole, webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { expandOwningTurnProcess, newEnglishPage } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const FIXTURE = fileURLToPath(new URL('../../../snapshots/web/cordis-tool-round/session.v3.jsonl', import.meta.url))
const UI_EXPECTED = fileURLToPath(new URL('./expected/cordis-history/ui.expected.md', import.meta.url))
@@ -39,7 +40,7 @@ describe.skipIf(MODE === 'record')('web e2e: historical Cordis cards', () => {
})
it('renders recorded definition source and lifecycle results without registering retired tools', async () => {
const persisted = await readPersistedEvents(scaffold, SessionId(SEED_ID))
const persisted = await readPersistedEvents(scaffold, brandString<SessionId>(SEED_ID))
const expected = parseSeedFixture(realizeSeedFixture(scaffold, await readFile(FIXTURE, 'utf8'), SEED_ID)).events
const tools = (events: typeof persisted) => events.filter(event => event.type === 'tool/call' || event.type === 'tool/result')
.map(event => ({ type: event.type, data: event.data }))
+7 -6
View File
@@ -5,13 +5,14 @@ import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { chromium, type Browser } from 'playwright'
import { readProfileManifest } from '@deepseek-ai/dsh-app-boot'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-ptc-runtime'
import type {} from '@deepseek-ai/dsh-agent-preset-registry'
import { load } from 'js-yaml'
import { expect, it, vi } from 'vitest'
import { captureStableAria, compareOrRefreshGolden, launchWebScaffold, webSnapshotMode, type WebScaffold } from './scaffold.ts'
import { connectFreshWorkspaceZh, ZH_BROWSER_LOCALE } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
// This fixture exercises the macOS provider’s permission setup.
it.skipIf(process.platform !== 'darwin').each([
@@ -62,7 +63,7 @@ it.skipIf(process.platform !== 'darwin').each([
let toggle = card.getByRole('switch', { name: '启用 Computer Use', exact: true })
const originalAgent = scaffold.ctx.agents.list()[0]!
const ptcAgent = (await scaffold.ctx.agents.create({
sessionId: SessionId('cua-existing-ptc'),
sessionId: brandString<SessionId>('cua-existing-ptc'),
setup: async (ctx) => { await scaffold.ctx.agentPresets.mount(ctx, 'ptc') },
})).agent
expect(scaffold.ctx.tools.schemas(ptcAgent).some(tool => tool.name === 'cua')).toBe(false)
@@ -136,7 +137,7 @@ it.skipIf(process.platform !== 'darwin').each([
expect(scaffold.ctx.tools.schemas(originalAgent).some(tool => tool.name === 'cua_run_code')).toBe(preset !== 'ptc')
}
const child = await scaffold.ctx.agents.create({
sessionId: SessionId('cua-child'),
sessionId: brandString<SessionId>('cua-child'),
setup: (ctx) => { scaffold.ctx.agentPresets.composeFrom(ctx, ptcAgent.ctx) },
})
expect(scaffold.ctx.tools.schemas(child.agent).some(tool => tool.name === 'cua')).toBe(true)
@@ -161,14 +162,14 @@ it.skipIf(process.platform !== 'darwin').each([
]))
}
const freshDefault = (await scaffold.ctx.agents.create({
sessionId: SessionId('cua-new-default'),
sessionId: brandString<SessionId>('cua-new-default'),
setup: async (ctx) => { await scaffold.ctx.agentPresets.mount(ctx) },
})).agent
expect(scaffold.ctx.agentPresets.composedPreset(freshDefault.ctx)).toBe(initialDefault)
expect(scaffold.ctx.tools.schemas(freshDefault).some(tool => tool.name === 'cua')).toBe(false)
expect(scaffold.ctx.tools.schemas(freshDefault).some(tool => tool.name === 'cua_run_code')).toBe(true)
const fresh = (await scaffold.ctx.agents.create({
sessionId: SessionId('cua-new-ptc'),
sessionId: brandString<SessionId>('cua-new-ptc'),
setup: async (ctx) => { await scaffold.ctx.agentPresets.mount(ctx, 'ptc') },
})).agent
expect(scaffold.ctx.agentPresets.composedPreset(fresh.ctx)).toBe('ptc')
@@ -253,7 +254,7 @@ it.skipIf(process.platform !== 'darwin').each([
expect(scaffold.ctx.agentPresets.composedPreset(originalAgent.ctx)).toBe(initialDefault)
expect(scaffold.ctx.agentPresets.composedPreset(freshDefault.ctx)).toBe(initialDefault)
const confirmed = (await scaffold.ctx.agents.create({
sessionId: SessionId('cua-confirmed-default'),
sessionId: brandString<SessionId>('cua-confirmed-default'),
setup: async (ctx) => { await scaffold.ctx.agentPresets.mount(ctx) },
})).agent
expect(scaffold.ctx.agentPresets.composedPreset(confirmed.ctx)).toBe('ptc')
+3 -2
View File
@@ -3,7 +3,8 @@ import { mkdir, mkdtemp, readFile, readdir, rm, writeFile } from 'node:fs/promis
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { ToolCallId } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { ToolCallId } from '@deepseek-ai/dsh-llm'
import type {} from '@deepseek-ai/dsh-user-approval'
import type {} from '@deepseek-ai/dsh-agent-preset-registry'
import { chromium, type Browser } from 'playwright'
@@ -54,7 +55,7 @@ it.skipIf(process.platform !== 'darwin')('keeps system requests pending until fr
scaffold.ctx.approval.setPolicy(agent, 'never')
// Application consent remains independent of the session's tool-approval policy.
const grant = scaffold.ctx.tools.execute({ agent, signal: new AbortController().signal,
calls: [{ type: 'tool-call', id: ToolCallId('cua-app-approval'), name: 'run_code',
calls: [{ type: 'tool-call', id: brandString<ToolCallId>('cua-app-approval'), name: 'run_code',
arguments: JSON.stringify({ code: 'return await tools.cua({ method: "getApp", params: { selector: "Fixture" } })',
description: 'Request application access' }) }] })
const approval = page.locator('[data-approval-key]')
+5 -4
View File
@@ -16,9 +16,10 @@ import { join } from 'node:path'
import type { Browser, Locator, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { launchWebScaffold, watchConsole, captureStableAria, compareOrRefreshGolden, webSnapshotMode, type WebScaffold } from './scaffold.ts'
import { ZH_BROWSER_LOCALE, connectFreshWorkspaceZh, saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
/** Points the shipped shared Agent default at this scenario's own route. */
const OVERLAY = fileURLToPath(new URL('./default-model.overlay.yml', import.meta.url))
@@ -39,7 +40,7 @@ describe('web e2e: the composer model switch is the default for later sessions',
/** Create one session and its agent through the same wire face the browser uses. */
const createSession = async (sessionId: string): Promise<string> => {
const response = await scaffold.ctx.sessionController.create({
sessionId: SessionId(sessionId),
sessionId: brandString<SessionId>(sessionId),
cwd: scaffold.workspaceCwd,
})
return response.sessionId
@@ -47,7 +48,7 @@ describe('web e2e: the composer model switch is the default for later sessions',
/** The route the Client derives from the Session projection and Host default. */
const currentOf = (sessionId: string): Promise<unknown> => {
const session = scaffold.ctx.sessions.get(SessionId(sessionId))
const session = scaffold.ctx.sessions.get(brandString<SessionId>(sessionId))
if (session === undefined) throw new Error(`session "${sessionId}" is not live`)
return Promise.resolve(
scaffold.ctx.sessionProjections.snapshot(session).values.modelSelection?.next
@@ -473,7 +474,7 @@ describe('web e2e: the composer model switch is the default for later sessions',
// A session that has already run a turn, spelled as the fact a turn
// leaves behind: its own logged route.
const loggedId = await createSession('default-model-logged')
scaffold.ctx.sessions.get(SessionId(loggedId))?.append('request/header', {
scaffold.ctx.sessions.get(brandString<SessionId>(loggedId))?.append('request/header', {
header: { config: { provider: START_ROUTE, model: START_MODEL } },
reason: 'initial',
})
+6 -5
View File
@@ -14,10 +14,11 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { StreamChunk } from '@deepseek-ai/dsh-llm'
import { ToolCallId, createAssistantMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createAssistantMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import type { ReplayEntry } from '@deepseek-ai/dsh-llm-replay'
import {
SESSION_FORMAT_VERSION, SessionId, SessionLogOffset, SessionSeq, type SessionEvent, type SessionHeader,
SESSION_FORMAT_VERSION, type SessionId, SessionLogOffset, SessionSeq, type SessionEvent, type SessionHeader,
} from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-system-prompt'
import { sessionFixtureName } from '@deepseek-ai/dsh-session-snapshot'
@@ -277,7 +278,7 @@ function replyEntry(marker: string): ReplayEntry {
function liveLongTurn(prefix: string): ReplayEntry[] {
const entries: ReplayEntry[] = []
for (let step = 1; step <= LIVE_STEPS; step++) {
const id = ToolCallId(`${prefix.toLowerCase()}-read-${step}`)
const id = brandString<ToolCallId>(`${prefix.toLowerCase()}-read-${step}`)
const args = JSON.stringify({ file_path: READ_FILE })
entries.push({ kind: 'chunks', chunks: [
...textChunks(paragraphs(`${prefix}_STEP_${step}`, 10, `${prefix} narration for step ${step}, paragraph`)),
@@ -525,7 +526,7 @@ function sessionKey(scenario: Case): string {
}
async function createChild(scaffold: WebScaffold, parentId: SessionId, scenario: Case): Promise<SessionId> {
const childId = SessionId(`${sessionKey(scenario)}-child`)
const childId = brandString<SessionId>(`${sessionKey(scenario)}-child`)
const createdAt = Date.now() - 30_000
const header: SessionHeader = {
version: SESSION_FORMAT_VERSION, id: childId, createdAt, isSeeded: false, cwd: scaffold.workspaceCwd,
@@ -598,7 +599,7 @@ async function prepareWorld(browser: Browser, scenario: Case, scaffold: WebScaff
await page.addInitScript(installMeasure)
await page.setViewportSize(scenario.surface === 'main' ? { width: 1280, height: 720 } : { width: 1680, height: 900 })
await page.emulateMedia({ reducedMotion: 'no-preference' })
const sessionId = SessionId(sessionKey(scenario))
const sessionId = brandString<SessionId>(sessionKey(scenario))
if (scenario.surface === 'main') {
const fixture = seededFixture(scenario.id, scenario.bodyParagraphs)
await seedSession(scaffold, fixture.log, sessionId)
+3 -2
View File
@@ -9,13 +9,14 @@ import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { StreamChunk } from '@deepseek-ai/dsh-llm'
import type { ReplayEntry } from '@deepseek-ai/dsh-llm-replay'
import { SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import type { SessionId, SessionEvent } from '@deepseek-ai/dsh-session'
import {
assertFixtureInventory, captureStableAria, compareOrRefreshGolden,
launchWebScaffold, parseSeedFixture, seedSession,
watchConsole, webSnapshotMode, selectedSessionFixture, type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot, writeComposerDraft } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/fork-mid-turn', import.meta.url))
// Borrowed read-only from its recorded-session owner.
@@ -110,7 +111,7 @@ describe('web e2e: exact-boundary fork seeds branch closers and continues', () =
expect(response.ok).toBe(true)
const body = await response.json() as { result: { ok: boolean; value?: { sessionId: string } } }
expect(body.result.ok).toBe(true)
childId = SessionId(body.result.value!.sessionId)
childId = brandString<SessionId>(body.result.value!.sessionId)
const child = scaffold.ctx.sessions.get(childId)
if (child === undefined) throw new Error('fork did not publish a live child session')
+7 -6
View File
@@ -7,9 +7,10 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { Agent } from '@deepseek-ai/dsh-agent'
import { ToolCallId } from '@deepseek-ai/dsh-llm'
import { SessionId } from '@deepseek-ai/dsh-session'
import { JobId } from '@deepseek-ai/dsh-jobs'
import type { ToolCallId } from '@deepseek-ai/dsh-llm'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type { JobId } from '@deepseek-ai/dsh-jobs'
import { brandString } from '@deepseek-ai/dsh-brand'
import {
assertFixtureInventory, compareOrRefreshGolden, launchWebScaffold, seedSession,
watchConsole, webSnapshotMode, type WebScaffold,
@@ -19,7 +20,7 @@ import { newEnglishPage, saveFailureShot } from './support.ts'
const FIXTURE = fileURLToPath(new URL('../../../snapshots/web/fresh-round-trip/session.v3.jsonl', import.meta.url))
const EXPECTED_DIR = fileURLToPath(new URL('./expected/jobs-menu-layering', import.meta.url))
const MODE = webSnapshotMode()
const SEED_ID = SessionId('jobs-menu-layering-web-e2e')
const SEED_ID = brandString<SessionId>('jobs-menu-layering-web-e2e')
// The private scaffold cwd owns the barrier; the loop bounds an orphan's lifetime.
const RELEASE = '.jobs-menu-layering.release'
const COMMAND = `printf 'jobs-menu-%s\\n' output; for _ in $(seq 1 3000); do [ -e ${RELEASE} ] && break; sleep 0.2; done`
@@ -120,7 +121,7 @@ describe.skipIf(MODE === 'record')('web e2e: jobs menu layering', () => {
agent = opened
const started = await executeToolFixture(scaffold.ctx, {
signal: new AbortController().signal,
callId: ToolCallId('jobs-menu-layering-e2e'),
callId: brandString<ToolCallId>('jobs-menu-layering-e2e'),
name: 'bash',
arguments: { command: COMMAND, description: 'Emit output and hold the jobs menu fixture', run_in_background: true },
agent,
@@ -128,7 +129,7 @@ describe.skipIf(MODE === 'record')('web e2e: jobs menu layering', () => {
const reported = started.content.map(block => block.type === 'text' ? block.text : '').join('')
const matched = /\bbash-[0-9a-f]{16}\b/.exec(reported)
if (matched === null) throw new Error(`background bash reported no job id: ${reported}`)
const startedJobId = JobId(matched[0])
const startedJobId = brandString<JobId>(matched[0])
jobId = startedJobId
// Registration precedes shell startup; inspect its output before depending on a live row.
await expect.poll(() => {
+7 -6
View File
@@ -10,9 +10,10 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { Agent } from '@deepseek-ai/dsh-agent'
import { ToolCallId } from '@deepseek-ai/dsh-llm'
import { SessionId } from '@deepseek-ai/dsh-session'
import { JobId } from '@deepseek-ai/dsh-jobs'
import type { ToolCallId } from '@deepseek-ai/dsh-llm'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type { JobId } from '@deepseek-ai/dsh-jobs'
import { brandString } from '@deepseek-ai/dsh-brand'
import {
assertFixtureInventory, captureStableAria, compareOrRefreshGolden,
launchWebScaffold, seedSession, watchConsole, webSnapshotMode, type WebScaffold,
@@ -73,7 +74,7 @@ describe.skipIf(MODE === 'record')('web e2e: live job stream', () => {
// Opening the session drives the Host's ordinary Agent resolution; the
// job owner must be that exact live instance, never a second one.
agent = await liveAgent(scaffold, SessionId(SEED_ID))
agent = await liveAgent(scaffold, brandString<SessionId>(SEED_ID))
}, 120_000)
afterAll(async () => {
@@ -90,7 +91,7 @@ describe.skipIf(MODE === 'record')('web e2e: live job stream', () => {
const started = await executeToolFixture(scaffold.ctx, {
signal: new AbortController().signal,
callId: ToolCallId('live-job-stream-e2e'),
callId: brandString<ToolCallId>('live-job-stream-e2e'),
name: 'bash',
arguments: { command: COMMAND, description: 'Emit one live line then hold', run_in_background: true },
agent,
@@ -98,7 +99,7 @@ describe.skipIf(MODE === 'record')('web e2e: live job stream', () => {
const reported = started.content.map(block => block.type === 'text' ? block.text : '').join('')
const matched = /\bbash-[0-9a-f]{16}\b/.exec(reported)
if (matched === null) throw new Error(`background bash reported no job id: ${reported}`)
const jobId = JobId(matched[0])
const jobId = brandString<JobId>(matched[0])
await expect.poll(() => {
const job = scaffold.ctx.jobs.get(jobId, agent.id)
const output = scaffold.ctx.jobs.readAt(jobId, 0, agent.id).chunks.map(chunk => chunk.text).join('')
+3 -2
View File
@@ -3,7 +3,7 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
import {
assertFixtureInventory,
@@ -16,6 +16,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot, WEB_FIXTURE_TIME } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/markdown-cjk-strong', import.meta.url))
const UI_EXPECTED = fileURLToPath(new URL('./expected/markdown-cjk-strong/ui.expected.md', import.meta.url))
@@ -35,7 +36,7 @@ const CASES = [
/** Build one settled assistant reply covering CJK-adjacent strong punctuation boundaries. */
function markdownFixture(): string {
const session = Session.create(SessionId('markdown-cjk-strong-source'))
const session = Session.create(brandString<SessionId>('markdown-cjk-strong-source'))
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'Render adjacent CJK strong emphasis.' }],
+6 -5
View File
@@ -4,8 +4,9 @@ import { basename, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { chromium, type Browser, type Locator, type Page } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import { sessionFileAddress } from '@deepseek-ai/dsh-util-workspace-path'
import type {} from '@deepseek-ai/dsh-session-title'
import {
@@ -26,14 +27,14 @@ async function reloadPreview(page: Page, column: Locator, absolutePath: string):
/** Build live test input with a parent-path link and a read result naming the same Host file. */
function parentPathFixture(path: string): string {
const session = Session.create(SessionId('parent-file-links-source'))
const session = Session.create(brandString<SessionId>('parent-file-links-source'))
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'Read the parent-path file and link lines 24 and 30.' }], source: { kind: 'user' },
}), { surfaceOp: 'append' })
session.append('session/title', { title: 'Parent file links', messageSeqs: [user.seq], source: { kind: 'fallback' } })
session.append('step/start', { turn: 1, step: 1 })
const callId = ToolCallId('parent-file-read')
const callId = brandString<ToolCallId>('parent-file-read')
const args = JSON.stringify({ file_path: path, offset: 24, limit: 7 })
session.append('assistant/message', {
turn: 1, step: 1, stream: [],
@@ -70,7 +71,7 @@ function parentPathFixture(path: string): string {
/** Build a settled turn whose relative link follows a directory change into a nested checkout. */
function changedDirectoryFixture(path: string): string {
const session = Session.create(SessionId('changed-directory-links-source'))
const session = Session.create(brandString<SessionId>('changed-directory-links-source'))
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'Enter the worktree and link its notes.' }], source: { kind: 'user' },
+3 -2
View File
@@ -6,10 +6,11 @@ import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { createLaunchEnvironmentSnapshot } from '@deepseek-ai/dsh-launch-environment'
import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
import { launchWebScaffold, seedSession, watchConsole, type WebScaffold } from './scaffold.ts'
import { newEnglishPage, saveFailureShot, WEB_FIXTURE_TIME } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const ALT = 'Rewritten chart'
const chart = (width: number, color: string): string =>
@@ -17,7 +18,7 @@ const chart = (width: number, color: string): string =>
/** Build one closed session whose reply shows `{{cwd}}/chart.svg`. */
function chartFixture(title: string): string {
const session = Session.create(SessionId('markdown-image-refresh-source'))
const session = Session.create(brandString<SessionId>('markdown-image-refresh-source'))
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'Draw the chart.' }],
+3 -2
View File
@@ -10,7 +10,7 @@ import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import {
SESSION_FORMAT_VERSION,
Session,
SessionId,
type SessionId,
} from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
import {
@@ -24,6 +24,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, pinBrowserClock, saveFailureShot, WEB_FIXTURE_TIME } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/markdown-images', import.meta.url))
const UI_EXPECTED = fileURLToPath(new URL('./expected/markdown-images/ui.expected.md', import.meta.url))
@@ -82,7 +83,7 @@ async function stopServer(server: Server): Promise<void> {
/** Build one closed session fixture with remote and local image Markdown. */
function markdownImageFixture(remoteUrl: string, outsidePath: string): string {
const session = Session.create(SessionId('markdown-image-source'))
const session = Session.create(brandString<SessionId>('markdown-image-source'))
const eventTimeOrigin = new Date().setHours(12, 0, 0, 0)
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
@@ -3,7 +3,7 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
import {
assertFixtureInventory,
@@ -16,6 +16,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot, WEB_FIXTURE_TIME } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/markdown-inline-code-links', import.meta.url))
const UI_EXPECTED = fileURLToPath(new URL('./expected/markdown-inline-code-links/ui.expected.md', import.meta.url))
@@ -26,7 +27,7 @@ const LINK_URL = 'http://127.0.0.1:3199/?demo=1'
/** Build a settled assistant reply with linkable URL code and inert code controls. */
function markdownFixture(linkUrl: string): string {
const session = Session.create(SessionId('markdown-inline-code-links-source'))
const session = Session.create(brandString<SessionId>('markdown-inline-code-links-source'))
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'Show the local preview URL.' }],
+3 -2
View File
@@ -26,7 +26,7 @@ import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import {
SESSION_FORMAT_VERSION,
Session,
SessionId,
type SessionId,
} from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
import {
@@ -39,6 +39,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/markdown-wide-table', import.meta.url))
const GEOMETRY_EXPECTED = fileURLToPath(
@@ -113,7 +114,7 @@ function tablesMarkdown(): string {
/** Build one closed session fixture carrying the tables. */
function wideTableFixture(): string {
const session = Session.create(SessionId('markdown-wide-table-source'))
const session = Session.create(brandString<SessionId>('markdown-wide-table-source'))
const eventTimeOrigin = new Date().setHours(12, 0, 0, 0)
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
+3 -2
View File
@@ -3,7 +3,7 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
import {
assertFixtureInventory,
@@ -16,6 +16,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot, WEB_FIXTURE_TIME } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/math-rendering', import.meta.url))
const UI_EXPECTED = fileURLToPath(new URL('./expected/math-rendering/ui.expected.md', import.meta.url))
@@ -25,7 +26,7 @@ const DONE = 'MATH_RENDERING_DONE'
/** Build a settled assistant reply that exercises every supported math delimiter. */
function mathFixture(): string {
const session = Session.create(SessionId('math-rendering-source'))
const session = Session.create(brandString<SessionId>('math-rendering-source'))
session.append('turn/start', {
turn: 1,
})
+4 -3
View File
@@ -10,12 +10,13 @@ import { zstdCompressSync } from 'node:zlib'
import type { Browser, Page, Request as BrowserRequest } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { SESSION_FORMAT_VERSION, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, type SessionId } from '@deepseek-ai/dsh-session'
import {
acknowledgeReloadConnectionLoss, assertFixtureInventory, captureStableAria, compareOrRefreshGolden, fixtureUserPrompts,
launchWebScaffold, parseSeedFixture, realizeSeedFixture, renderSeedFixture, seedSession, watchConsole, webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { openSettings, newEnglishPage, pinBrowserClock, pinHostClock, saveFailureShot, WEB_FIXTURE_TIME } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('../../../snapshots/web/message-actions', import.meta.url))
// Borrowed read-only: this scenario needs any settled user+assistant pair, not
@@ -439,7 +440,7 @@ describe('web e2e: message IconActions and clocks on settled history', () => {
it.skipIf(MODE === 'record')('forks an unopened current-format Session from its sidebar row', async () => {
onTestFailed(() => saveFailureShot(page, 'screenshots/non-migrating-session-reads/current-cold-fork'))
const id = SessionId('message-actions-current-cold')
const id = brandString<SessionId>('message-actions-current-cold')
await seedSession(scaffold, completedTailFixture(await readFile(SEED, 'utf8')), id)
const warningStart = tripwire.warnings.length
await page.reload({ waitUntil: 'load' })
@@ -459,7 +460,7 @@ describe('web e2e: message IconActions and clocks on settled history', () => {
it.skipIf(MODE === 'record')('guides only a migration-required sidebar fork to opening its source', async () => {
onTestFailed(() => saveFailureShot(page, 'screenshots/non-migrating-session-reads/migration-required-fork'))
const id = SessionId('message-actions-needs-migration')
const id = brandString<SessionId>('message-actions-needs-migration')
const [header, ...events] = realizeSeedFixture(scaffold, await readFile(SEED, 'utf8'), id).trimEnd().split('\n')
.map((line): Record<string, unknown> => JSON.parse(line) as Record<string, unknown>)
expect(header?.version).toBe(3)
+4 -3
View File
@@ -5,13 +5,14 @@ import { readFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import {
acknowledgeReloadConnectionLoss, launchWebScaffold,
seedSession, watchConsole, webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot, scrollIntoView } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
// Borrowed read-only: this scenario needs any settled assistant message to
// address, not a new recording (message-actions / sidebar-scrollbar pattern).
@@ -121,7 +122,7 @@ describe('web e2e: durable per-message feedback', () => {
await expect.poll(() => restored.getAttribute('aria-pressed'), { timeout: 15_000 }).toBe('true')
// The retract label sits on the Dislike side: the Like stays unpressed.
await expect.poll(() => cold.getAttribute('aria-pressed'), { timeout: 10_000 }).toBe('false')
const agent = scaffold.ctx.agents.get(SessionId(SEED_ID))
const agent = scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID))
if (agent === undefined) throw new Error('seeded session did not attach an agent')
const puts = agent.session.snapshotEvents().filter(event => event.type === 'feedback/message-put')
expect(puts.map(event => event.type === 'feedback/message-put' ? event.data.item : undefined)).toMatchObject([
@@ -148,7 +149,7 @@ describe('web e2e: durable per-message feedback', () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-header-feedback'))
await openSeededSession()
await page.getByText('DONE', { exact: true }).waitFor({ timeout: 30_000 })
const agent = scaffold.ctx.agents.get(SessionId(SEED_ID))
const agent = scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID))
if (agent === undefined) throw new Error('seeded session did not attach an agent')
const feedbackEvents = () => agent.session.snapshotEvents().filter(event => event.type.startsWith('feedback/'))
const before = feedbackEvents().length
+11 -10
View File
@@ -7,9 +7,10 @@ import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { AgentHandle } from '@deepseek-ai/dsh-agent'
import type { SessionAttachmentValue } from '@deepseek-ai/dsh-api-session-controller'
import { ToolCallId, createUserMessage } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createUserMessage } from '@deepseek-ai/dsh-llm'
import type { GenerateOptions } from '@deepseek-ai/dsh-llm'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type { Session } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-agent-preset-registry'
import type {} from '@deepseek-ai/dsh-system-prompt'
@@ -57,7 +58,7 @@ describe('minimal agent preset', () => {
text: 'THIS TEXT MUST NOT REACH THE MODEL.',
})
agentHandle = await scaffold.ctx.agents.create({
sessionId: SessionId('minimal-preset-smoke'),
sessionId: brandString<SessionId>('minimal-preset-smoke'),
meta: { cwd: scaffold.workspaceCwd, agentPreset: 'minimal' },
agentOptions: { provider: 'deepseek-official', model: 'deepseek-v4-flash' },
setup: agentCtx => scaffold.ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
@@ -105,14 +106,14 @@ describe('minimal agent preset', () => {
const signal = new AbortController().signal
await executeToolFixture(scaffold.ctx, {
signal,
callId: ToolCallId('minimal-bash-state-setup'),
callId: brandString<ToolCallId>('minimal-bash-state-setup'),
name: 'bash',
arguments: { command: `cd ${JSON.stringify(stateDir)} && export DSH_MINIMAL_STATE=PERSISTED` },
agent: agentHandle.agent,
})
const bash = await executeToolFixture(scaffold.ctx, {
signal,
callId: ToolCallId('minimal-bash-state-read'),
callId: brandString<ToolCallId>('minimal-bash-state-read'),
name: 'bash',
arguments: { command: 'printf \'%s:%s\n\' "$DSH_MINIMAL_STATE" "$PWD"' },
agent: agentHandle.agent,
@@ -226,7 +227,7 @@ describe('minimal manual compaction', () => {
yield* next()
})
handle = await scaffold.ctx.agents.create({
sessionId: SessionId('minimal-compact-smoke'),
sessionId: brandString<SessionId>('minimal-compact-smoke'),
meta: { cwd: scaffold.workspaceCwd, agentPreset: 'minimal' },
agentOptions: { provider: 'deepseek-official', model: 'deepseek-v4-flash' },
setup: agentCtx => scaffold.ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
@@ -370,7 +371,7 @@ describe('minimal image reading', () => {
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC', 'base64',
))
handle = await scaffold.ctx.agents.create({
sessionId: SessionId('minimal-image-smoke'),
sessionId: brandString<SessionId>('minimal-image-smoke'),
meta: { cwd: scaffold.workspaceCwd, agentPreset: 'minimal' },
agentOptions: { provider: 'deepseek-official', model: 'deepseek-v4-flash-vision-exp' },
setup: agentCtx => scaffold.ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
@@ -420,7 +421,7 @@ describe('minimal image reading', () => {
it.skipIf(MODE === 'record')('reads image bytes and preserves the supplied reference with another Session as the gateway scope', async () => {
const image = handle.agent.session.deriveMessages().flatMap(message => message.content).find(block => block.type === 'image')
if (image?.type !== 'image') throw new Error('minimal read_image produced no durable image')
const unrelated = await scaffold.ctx.agents.create({ sessionId: SessionId('minimal-image-unrelated') })
const unrelated = await scaffold.ctx.agents.create({ sessionId: brandString<SessionId>('minimal-image-unrelated') })
try {
expect(unrelated.agent.session.deriveMessages().flatMap(message => message.content).some(block => block.type === 'image')).toBe(false)
const read = async (attachment: unknown, rpcId: string) => {
@@ -473,7 +474,7 @@ describe('minimal image reading', () => {
// User-only interrupted turns move the recorded image beyond the 50-message initial page without inventing model output.
const laterTurns = Array.from({ length: 52 }, (_, index) =>
interruptedTurn(index + 2, `Later image-history message ${index + 2}`))
const historicalId = SessionId('minimal-image-cold')
const historicalId = brandString<SessionId>('minimal-image-cold')
await seedSession(scaffold, `${recorded}${laterTurns[0]}\n`, historicalId, 'minimal')
expect(scaffold.ctx.agents.get(historicalId)).toBeUndefined()
page = await openSession(historicalId)
@@ -500,7 +501,7 @@ describe('minimal image reading', () => {
const body = await response.json() as { result: { ok: boolean; value?: { sessionId: string } } }
expect(body.result.ok).toBe(true)
if (body.result.value === undefined) throw new Error('image fork did not return a Session ID')
page = await openSession(SessionId(body.result.value.sessionId))
page = await openSession(brandString<SessionId>(body.result.value.sessionId))
card = await imageCard(page)
await expect.poll(() => card.locator('img').first().evaluate(img => img instanceof HTMLImageElement && img.naturalWidth)).toBe(1)
})
+13 -12
View File
@@ -13,11 +13,12 @@ import type { Browser, Page, Response } from 'playwright'
import { chromium } from 'playwright'
import { strFromU8, unzipSync } from 'fflate'
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, onTestFailed, onTestFinished } from 'vitest'
import { ToolCallId, createToolResultMessage } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createToolResultMessage } from '@deepseek-ai/dsh-llm'
import type SessionToolResults from '@deepseek-ai/dsh-client-ui-trajectory'
import { defineTool } from '@deepseek-ai/dsh-tools'
import { parseSessionLog } from '@deepseek-ai/dsh-llm-replay'
import { SESSION_FORMAT_VERSION, SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, type SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import {
assertFixtureInventory, captureStableAria, compareOrRefreshGolden, fixtureUserPrompts,
launchWebScaffold, recordFixture, seedSession, watchConsole, webSnapshotMode, type WebScaffold,
@@ -500,7 +501,7 @@ describe('web e2e: navigation & panes over a rich seeded session', () => {
await page.getByText('Session copied as Markdown.', { exact: true }).waitFor({ timeout: 30_000 })
expect(await page.evaluate(() => Number(Reflect.get(globalThis, '__dshClipboardWrites')))).toBe(1)
const sourcePath = (await scaffold.ctx.sessionPersistence.stat(SessionId(SEED_ID)))?.location?.path
const sourcePath = (await scaffold.ctx.sessionPersistence.stat(brandString<SessionId>(SEED_ID)))?.location?.path
if (sourcePath === undefined) throw new Error('seeded Session has no materialized artifact location')
expect((await stat(sourcePath)).isFile()).toBe(true)
expect(sourcePath.startsWith(`${scaffold.persistenceRoot}/`)).toBe(true)
@@ -678,15 +679,15 @@ describe('web e2e: navigation & panes over a rich seeded session', () => {
})
it.skipIf(MODE === 'record')('inspects a live tool value without adding it to the Session journal', async () => {
await ensureSeedOpen(page)
await expect.poll(() => scaffold.ctx.agents.get(SessionId(SEED_ID)) !== undefined).toBe(true)
const agent = scaffold.ctx.agents.get(SessionId(SEED_ID))!
await expect.poll(() => scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID)) !== undefined).toBe(true)
const agent = scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID))!
const unregister = scaffold.ctx.tools.register(defineTool({
name: 'live_result_probe', description: 'Live result inspection fixture.', parameters: {},
output: { schema: { type: 'json' }, render: () => [{ type: 'text', text: 'LIVE_RESULT_RENDERED' }] },
execute: async () => ({ answer: 42 }),
}))
onTestFinished(unregister)
const callId = ToolCallId('live-result-probe')
const callId = brandString<ToolCallId>('live-result-probe')
let resultEvent: SessionEvent | undefined
const off = scaffold.ctx.on('session/event', (_session, event) => {
if (event.type === 'tool/result' && event.data.message.toolCallId === callId) resultEvent = event
@@ -728,7 +729,7 @@ describe('web e2e: navigation & panes over a rich seeded session', () => {
onTestFinished(unregisterJson)
const jsonBatch = await scaffold.ctx.tools.execute({
agent, signal: new AbortController().signal, log: { turn: 2, step: 1 },
calls: [{ type: 'tool-call', id: ToolCallId('json-result-probe'), name: 'json_result_probe', arguments: '{}' }],
calls: [{ type: 'tool-call', id: brandString<ToolCallId>('json-result-probe'), name: 'json_result_probe', arguments: '{}' }],
})
expect(jsonBatch.results[0]?.result.isError).toBe(false)
await page.locator('tr[data-kind="tool"]').filter({ hasText: 'json_result_probe' }).click()
@@ -767,7 +768,7 @@ describe('web e2e: navigation & panes over a rich seeded session', () => {
const newer = await scaffold.ctx.tools.execute({
agent, signal: new AbortController().signal,
calls: Array.from({ length: 1000 }, (_, index) => ({
type: 'tool-call' as const, id: ToolCallId(`newer-result-${index}`), name: 'live_result_probe', arguments: '{}',
type: 'tool-call' as const, id: brandString<ToolCallId>(`newer-result-${index}`), name: 'live_result_probe', arguments: '{}',
})),
})
expect(newer.results).toHaveLength(1000)
@@ -785,15 +786,15 @@ describe('web e2e: navigation & panes over a rich seeded session', () => {
it.skipIf(MODE === 'record')('keeps long raw strings and PTC output readable in one result scroller', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-long-tool-results'))
await ensureSeedOpen(page)
await expect.poll(() => scaffold.ctx.agents.get(SessionId(SEED_ID)) !== undefined).toBe(true)
const agent = scaffold.ctx.agents.get(SessionId(SEED_ID))!
await expect.poll(() => scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID)) !== undefined).toBe(true)
const agent = scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID))!
agent.session.append('turn/start', { turn: 3 })
onTestFinished(() => {
agent.session.append('step/end', { turn: 3, step: 1 })
agent.session.append('turn/end', { turn: 3, reason: { kind: 'completed' } })
})
agent.session.append('step/start', { turn: 3, step: 1 })
const callId = ToolCallId('long-ptc-result')
const callId = brandString<ToolCallId>('long-ptc-result')
const call = agent.session.append('tool/call', {
turn: 3, step: 1, callId, name: 'run_code',
arguments: JSON.stringify({ code: 'inspect("PTC output")', description: 'Long program output' }),
@@ -831,7 +832,7 @@ describe('web e2e: navigation & panes over a rich seeded session', () => {
onTestFinished(unregister)
const batch = await scaffold.ctx.tools.execute({
agent, signal: new AbortController().signal, log: { turn: 3, step: 1 },
calls: [{ type: 'tool-call', id: ToolCallId(probe.name), name: probe.name, arguments: '{}' }],
calls: [{ type: 'tool-call', id: brandString<ToolCallId>(probe.name), name: probe.name, arguments: '{}' }],
})
expect(batch.results[0]?.result.isError).toBe(false)
}
+5 -4
View File
@@ -8,8 +8,9 @@
import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type { SubagentSettledMessageSource } from '@deepseek-ai/dsh-subagent'
import { launchWebScaffold, watchConsole, type WebScaffold } from './scaffold.ts'
import { connectFreshWorkspace, newEnglishPage } from './support.ts'
@@ -111,7 +112,7 @@ describe('web e2e: notice Turn after a long Detailed Turn', () => {
source: { kind: 'user' },
}), { surfaceOp: 'append' })
for (let step = 1; step <= TOOL_STEPS; step += 1) {
const callId = ToolCallId(`notice-wake-${String(step)}`)
const callId = brandString<ToolCallId>(`notice-wake-${String(step)}`)
const args = JSON.stringify({ command: `diagnose ${String(step)}`, description: `Diagnostic ${String(step)}` })
session.append('assistant/message', {
stream: [],
@@ -171,7 +172,7 @@ describe('web e2e: notice Turn after a long Detailed Turn', () => {
form: 'notice',
summary: 'Background subagent finished.',
stopReason: 'completed',
senderSessionId: SessionId('notice-wake-child'),
senderSessionId: brandString<SessionId>('notice-wake-child'),
}
const notice = createUserMessage({
content: [{ type: 'text', text: 'Background subagent notice-wake-child finished.' }],
+6 -5
View File
@@ -5,13 +5,14 @@ import { dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import { zstdCompressSync, zstdDecompressSync } from 'node:zlib'
import { describe, expect, it } from 'vitest'
import { SESSION_FORMAT_VERSION, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, type SessionId } from '@deepseek-ai/dsh-session'
import { generationLogPath } from '../../../packages/session/session-persistence-jsonl/src/format.ts'
import { scanZstdFrames } from '../../../packages/session/session-persistence-jsonl/src/zstd.ts'
import type {} from '@deepseek-ai/dsh-agent-preset-registry'
import type {} from '@deepseek-ai/dsh-api-session-controller'
import { normalizeSessionSnapshots } from '@deepseek-ai/dsh-session-snapshot'
import { launchWebScaffold, webSnapshotMode } from './scaffold.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const childFixturePath = fileURLToPath(new URL('../../../snapshots/web/preset-migration/session.1.v2.jsonl', import.meta.url))
const fixturePath = fileURLToPath(new URL('../../../snapshots/web/preset-migration/session.v2.jsonl', import.meta.url))
@@ -20,7 +21,7 @@ describe.skipIf(webSnapshotMode() === 'record')('historical preset restoration t
it.each([false, true])('resumes code as PTC (selection events=%s)', async (withSelections) => {
const scaffold = await launchWebScaffold()
try {
const id = SessionId('preset-migration')
const id = brandString<SessionId>('preset-migration')
const fixture = await readFile(fixturePath, 'utf8')
const [fixtureHeader, ...fixtureEvents] = fixture.trimEnd().split('\n')
.map((line): Record<string, unknown> => JSON.parse(line) as Record<string, unknown>)
@@ -33,8 +34,8 @@ describe.skipIf(webSnapshotMode() === 'record')('historical preset restoration t
await mkdir(dirname(predecessor), { recursive: true })
await writeFile(predecessor, source)
const childId = SessionId('preset-migration-child')
const brokenId = SessionId('preset-migration-broken-child')
const childId = brandString<SessionId>('preset-migration-child')
const brokenId = brandString<SessionId>('preset-migration-broken-child')
const childFixture = (await readFile(childFixturePath, 'utf8')).trimEnd().split('\n')
.map((line): Record<string, unknown> => JSON.parse(line) as Record<string, unknown>)
const childRows: Record<string, unknown>[] = childFixture.slice(1).map((row, seq) => ({ ...row, seq, time: seq + 3 }))
@@ -51,7 +52,7 @@ describe.skipIf(webSnapshotMode() === 'record')('historical preset restoration t
data: { turn: 1, reason: { kind: 'completed' } } }) + '\n')),
]))
const brokenSource = await readFile(brokenPath)
const corruptHeaderId = SessionId('preset-migration-corrupt-header')
const corruptHeaderId = brandString<SessionId>('preset-migration-corrupt-header')
const corruptHeaderPath = generationLogPath(scaffold.persistenceRoot, scaffold.workspaceCwd, corruptHeaderId, 2, 'zstd')
const corruptHeaderSource = Buffer.from('invalid Zstandard header frame')
await mkdir(dirname(corruptHeaderPath), { recursive: true })
+6 -5
View File
@@ -4,8 +4,9 @@ import { join } from 'node:path'
import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
import {
launchWebScaffold, seedSession, watchConsole, webSnapshotMode, type WebScaffold,
@@ -26,7 +27,7 @@ const WRITES = ['site/report.html', 'a/style.css', 'b/style.css', 'report.txt']
/** Build a settled write turn whose closing prose mentions files in inline code. */
function mentionFixture(): string {
const session = Session.create(SessionId('produced-file-mentions-source'))
const session = Session.create(brandString<SessionId>('produced-file-mentions-source'))
const eventTimeOrigin = new Date().setHours(12, 0, 0, 0)
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
@@ -41,7 +42,7 @@ function mentionFixture(): string {
session.append('step/start', { turn: 1, step: 1 })
const calls = WRITES.map((path, index) => ({
path,
callId: ToolCallId(`file-mention-${String(index)}`),
callId: brandString<ToolCallId>(`file-mention-${String(index)}`),
args: JSON.stringify({ file_path: path, content: `content of ${path}\n` }),
}))
session.append('assistant/message', {
@@ -79,7 +80,7 @@ function mentionFixture(): string {
}, { surfaceOp: 'append', sourceEventSeqs: [source.seq] })
}
session.append('working-directory/change', { cwd: '{{cwd}}' })
session.append('deliverables/presented', { turn: 1, callId: ToolCallId('present-child'), files: [{ path: '{{cwd}}/child/report.txt' }] })
session.append('deliverables/presented', { turn: 1, callId: brandString<ToolCallId>('present-child'), files: [{ path: '{{cwd}}/child/report.txt' }] })
session.append('step/end', { turn: 1, step: 1 })
session.append('step/start', { turn: 1, step: 2 })
session.append('assistant/message', {
+4 -3
View File
@@ -5,7 +5,8 @@ import { join } from 'node:path'
import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { ToolCallId } from '@deepseek-ai/dsh-llm/brand'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { ToolCallId } from '@deepseek-ai/dsh-llm/brand'
import type { ReplayEntry } from '@deepseek-ai/dsh-llm-replay'
import type {} from '@deepseek-ai/dsh-tool-executor-ptc/types'
import type { SessionEvent } from '@deepseek-ai/dsh-session'
@@ -22,8 +23,8 @@ const args = JSON.stringify({
const script: ReplayEntry[] = [
{ kind: 'chunks', chunks: [
{ type: 'block-start', index: 0, blockType: 'tool-call' },
{ type: 'tool-call-delta', index: 0, id: ToolCallId('ptc-question'), name: 'run_code', argumentsDelta: args },
{ type: 'block-end', index: 0, block: { type: 'tool-call', id: ToolCallId('ptc-question'), name: 'run_code', arguments: args } },
{ type: 'tool-call-delta', index: 0, id: brandString<ToolCallId>('ptc-question'), name: 'run_code', argumentsDelta: args },
{ type: 'block-end', index: 0, block: { type: 'tool-call', id: brandString<ToolCallId>('ptc-question'), name: 'run_code', arguments: args } },
{ type: 'finish', reason: { kind: 'tool-calls' } },
] },
{ kind: 'chunks', chunks: [
+5 -4
View File
@@ -13,7 +13,7 @@ import { abbreviateHomePath } from '@deepseek-ai/dsh-util-workspace-path'
import {
SESSION_FORMAT_VERSION,
Session,
SessionId,
type SessionId,
SessionSeq,
} from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-reference/types'
@@ -30,6 +30,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { connectFreshWorkspace, newEnglishPage, pinBrowserClock, saveFailureShot, WEB_FIXTURE_TIME, writeComposerDraft } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/reference-composer', import.meta.url))
const MENU_EXPECTED = join(SNAPSHOT_DIR, 'menu.expected.md')
@@ -59,7 +60,7 @@ async function replaceReferenceQuery(page: Page, input: Locator, text: string):
/** Build one closed source session with a stable title for reference discovery. */
function sourceSessionFixture(): string {
const session = Session.create(SessionId(SOURCE_SESSION_ID))
const session = Session.create(brandString<SessionId>(SOURCE_SESSION_ID))
session.append('turn/start', {
turn: 1,
})
@@ -90,7 +91,7 @@ function sourceSessionFixture(): string {
/** Build one target log with the direct message durably before its recalled context. */
function targetSessionFixture(): string {
const session = Session.create(SessionId(TARGET_SESSION_ID))
const session = Session.create(brandString<SessionId>(TARGET_SESSION_ID))
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
content: [{ type: 'text', text: '@Research notes what changed?' }],
@@ -405,7 +406,7 @@ describe.skipIf(MODE === 'record')('web e2e: file and session references through
await target.waitFor({ timeout: 15_000 })
await target.click()
await page.locator('[data-chat-flow-kind="user"]').filter({ hasText: 'Research notes' }).waitFor({ timeout: 15_000 })
const events = await readPersistedEvents(scaffold, SessionId(TARGET_SESSION_ID))
const events = await readPersistedEvents(scaffold, brandString<SessionId>(TARGET_SESSION_ID))
const inputs = events.filter(event => event.type === 'user/message')
expect(inputs.map(event => event.data.source.kind)).toEqual(['user', 'session-reference'])
expect(inputs[0]?.seq).toBeLessThan(inputs[1]!.seq)
+5 -4
View File
@@ -19,8 +19,8 @@ import { fileURLToPath } from 'node:url'
import type { Browser, Page, Route, WebSocketRoute } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { ToolCallId, expandAssistantStream } from '@deepseek-ai/dsh-llm'
import { SessionId, type Session, type SessionEvent } from '@deepseek-ai/dsh-session'
import { type ToolCallId, expandAssistantStream } from '@deepseek-ai/dsh-llm'
import type { SessionId, Session, SessionEvent } from '@deepseek-ai/dsh-session'
import type { SessionListValue } from '@deepseek-ai/dsh-api-session-controller/types'
import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
import {
@@ -31,6 +31,7 @@ import {
import {
connectFreshWorkspace, expandTurnProcesses, newEnglishPage, REPO_ROOT, saveFailureShot,
} from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('../../../snapshots/web/fresh-round-trip', import.meta.url))
const FIXTURE = fileURLToPath(new URL('../../../snapshots/web/fresh-round-trip/session.v3.jsonl', import.meta.url))
@@ -263,13 +264,13 @@ describe('web e2e: fresh round trip through the real assembly', () => {
const probe = await launchWebScaffold()
try {
const handle = await probe.ctx.agents.create({
sessionId: SessionId('web-url-probe'),
sessionId: brandString<SessionId>('web-url-probe'),
setup: agentCtx => probe.ctx.agentPresets.mount(agentCtx).then(() => undefined),
})
try {
const result = await executeToolFixture(probe.ctx, {
signal: AbortSignal.timeout(5_000),
callId: ToolCallId('web-url-probe'),
callId: brandString<ToolCallId>('web-url-probe'),
name: 'bash',
arguments: {
command: 'printf \'%s\\n\' "$DSH_WEB_URL"',
+4 -3
View File
@@ -7,7 +7,7 @@ import type { Browser, Locator, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { ReplayOverrideDoc } from '@deepseek-ai/dsh-llm-replay'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { formatSessionReferenceMention } from '@deepseek-ai/dsh-session-reference'
import { formatQuoteText } from '@deepseek-ai/dsh-client-ui-primitives'
import {
@@ -16,6 +16,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, pinBrowserClock, pinHostClock, saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('../../../snapshots/web/rich-text-quotes', import.meta.url))
const BORROWED = fileURLToPath(new URL('../../../snapshots/web/seeded-history/session.jsonl', import.meta.url))
@@ -29,7 +30,7 @@ const LEGACY_DRAFT = JSON.stringify({ draft: 'Imported plain draft', view: 'chat
const SOURCE_TEXT = 'Durable source phrase selected from an earlier message and preserved as structured quote metadata.'
const THINKING_TEXT = 'Settled reasoning source'
const LITERAL_CREDENTIAL = 'sk-1234567890abcdefghijklmnopqrstuvwxyz'
const SESSION_MENTION = formatSessionReferenceMention({ sessionId: SessionId(OTHER_ID), label: 'Quote source' })
const SESSION_MENTION = formatSessionReferenceMention({ sessionId: brandString<SessionId>(OTHER_ID), label: 'Quote source' })
const DIRECT_SYNTAX_TEXT = [
`/quoted-demo ${SESSION_MENTION} ${LITERAL_CREDENTIAL} **literal Markdown**`,
...Array.from({ length: 80 }, (_, index) => `Quote line ${String(index + 1)} contains preserved text.`),
@@ -559,7 +560,7 @@ describe.skipIf(MODE === 'record')('web e2e: rich-text quotes', () => {
} finally {
await page.setViewportSize(viewport)
}
const beforeOffset = scaffold.ctx.agents.get(SessionId(SESSION_ID))!.session.seq
const beforeOffset = scaffold.ctx.agents.get(brandString<SessionId>(SESSION_ID))!.session.seq
const settled = scaffold.whenTurnSettled()
await page.getByRole('button', { name: 'Send message' }).click()
const settledSessionId = await settled
+3 -2
View File
@@ -3,9 +3,10 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { expect, it } from 'vitest'
import type {} from '@deepseek-ai/dsh-skill'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-agent-preset-registry'
import { launchWebScaffold, type WebScaffold } from './scaffold.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
async function writeSkill(root: string, name: string): Promise<void> {
const bundle = join(root, name)
@@ -45,7 +46,7 @@ it('isolates replay skill discovery from every ambient host root', async () => {
// agent's view — the same scope the `skills/list` Remote resolves for a
// browser request about a session.
const handle = await ctx.agents.create({
sessionId: SessionId('hermetic-skills'),
sessionId: brandString<SessionId>('hermetic-skills'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx).then(() => undefined),
})
try {
+3 -2
View File
@@ -75,7 +75,7 @@ import type { SessionFormatEvent } from '@deepseek-ai/dsh-session-format'
import { sessionFormatCatalog } from '@deepseek-ai/dsh-session-format-catalog'
import {
SESSION_FORMAT_VERSION,
SessionId,
type SessionId,
type Session,
type SessionEvent,
type SessionHeader,
@@ -87,6 +87,7 @@ import type {} from '@deepseek-ai/dsh-agent'
import { provideCmdline } from '@deepseek-ai/dsh-cmdline'
import { startPrefixProxy, type PrefixProxy } from './prefix-proxy.ts'
import { REPO_ROOT, requireBuilt, requireDist } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
type AppBoot = typeof import('@deepseek-ai/dsh-app-boot')
let builtAppBoot: AppBoot | undefined
@@ -1483,7 +1484,7 @@ export async function seedSession(
const createdAt = options.createdAt ?? Date.now() - 60_000
const meta: SessionHeader = {
version: SESSION_FORMAT_VERSION,
id: SessionId(id),
id: brandString<SessionId>(id),
createdAt,
isSeeded: false,
cwd: scaffold.workspaceCwd,
+22 -21
View File
@@ -13,18 +13,19 @@ import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { Agent, AgentHandle } from '@deepseek-ai/dsh-agent'
import { entryListSchema } from '@deepseek-ai/cordis-plugin-include'
import { bundlePatchPaths, composeEntries, loadOverlayPatches } from '@deepseek-ai/dsh-app-boot'
import { MessageId, ToolCallId, createUserMessage, LlmAdapter } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type MessageId, type ToolCallId, createUserMessage, LlmAdapter } from '@deepseek-ai/dsh-llm'
import { appendDelivery } from '../../../packages/schedule/schedule/src/delivery-history.ts'
import type { ScheduleTask } from '@deepseek-ai/dsh-schedule'
import type { ContextFormed, GenerateOptions, StreamChunk } from '@deepseek-ai/dsh-llm'
import { SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import type { SessionId, SessionEvent } from '@deepseek-ai/dsh-session'
import {
ScheduleId,
createAfterScheduleRecord,
createEveryScheduleRecord,
type EveryScheduleRecord,
type ScheduleRecord,
} from '@deepseek-ai/dsh-schedule'
import type { ScheduleId } from '@deepseek-ai/dsh-schedule/client'
import {
assertFixtureInventory,
captureStableAria,
@@ -105,7 +106,7 @@ async function writeEveryStepOverlay(dir: string): Promise<string> {
}
const CATALOG_NOW = Date.parse('2099-08-25T12:00:00.000Z')
const CATALOG_SESSION_ID = SessionId('schedule-catalog-web-e2e')
const CATALOG_SESSION_ID = brandString<SessionId>('schedule-catalog-web-e2e')
const CATALOG_TITLE = 'Active schedule catalog'
/**
* Task name seeded for each recorded catalog task.
@@ -219,7 +220,7 @@ class BrowserZoneAtAdapter extends LlmAdapter {
this.selectedAt = localAt(target, AT_BROWSER_ZONE)
this.scheduledAt = new Date(target).toISOString()
const argumentsJson = JSON.stringify({ prompt: AT_PROMPT, title: AT_PROMPT, rrule: oneOccurrence(this.selectedAt), target: 'this_session' })
const callId = ToolCallId('schedule-at-browser-zone')
const callId = brandString<ToolCallId>('schedule-at-browser-zone')
yield { type: 'block-start', index: 0, blockType: 'tool-call' }
yield {
type: 'tool-call-delta',
@@ -360,7 +361,7 @@ describe.skipIf(MODE === 'record')('web e2e: conversational reminders', () => {
if (workspace === undefined) throw new Error('connected Web workspace was not registered')
afterHandle = await scaffold.ctx.agents.create({
sessionId: SessionId('schedule-after-web-e2e'),
sessionId: brandString<SessionId>('schedule-after-web-e2e'),
meta: { cwd },
agentOptions: { provider: AFTER_PROVIDER, model: MODEL },
// The reminder tools are preset-level Consumers, so a directly created Agent
@@ -375,7 +376,7 @@ describe.skipIf(MODE === 'record')('web e2e: conversational reminders', () => {
await workspace.attachSession(afterHandle.agent.id)
const afterCreated = await executeToolFixture(scaffold.ctx, {
signal: AbortSignal.timeout(10_000),
callId: ToolCallId('schedule-after-create'),
callId: brandString<ToolCallId>('schedule-after-create'),
name: 'schedule_create',
arguments: { prompt: AFTER_PROMPT, title: AFTER_PROMPT,
rrule: oneOccurrence(localAt(Math.ceil((Date.now() + 5_000) / 1_000) * 1_000, 'UTC')), target: 'this_session' },
@@ -398,7 +399,7 @@ describe.skipIf(MODE === 'record')('web e2e: conversational reminders', () => {
await expect(scaffold.ctx.sessions.flush(afterHandle.agent.session)).resolves.toBe(true)
everyHandle = await scaffold.ctx.agents.create({
sessionId: SessionId('schedule-every-web-e2e'),
sessionId: brandString<SessionId>('schedule-every-web-e2e'),
meta: { cwd },
agentOptions: { provider: EVERY_PROVIDER, model: MODEL },
// The reminder tools are preset-level Consumers, so a directly created Agent
@@ -413,14 +414,14 @@ describe.skipIf(MODE === 'record')('web e2e: conversational reminders', () => {
const seededAt = Date.now()
everyRecords = [
createEveryScheduleRecord(
ScheduleId('schedule-every-primary'),
brandString<ScheduleId>('schedule-every-primary'),
EVERY_PROMPTS[0],
EVERY_INTERVAL_SECONDS,
seededAt - EVERY_FIXTURE_AGE_MS,
'Every primary',
),
createEveryScheduleRecord(
ScheduleId('schedule-every-secondary'),
brandString<ScheduleId>('schedule-every-secondary'),
EVERY_PROMPTS[1],
EVERY_INTERVAL_SECONDS,
seededAt - EVERY_FIXTURE_AGE_MS,
@@ -437,7 +438,7 @@ describe.skipIf(MODE === 'record')('web e2e: conversational reminders', () => {
await workspace.attachSession(everyHandle.agent.id)
const everyListed = await executeToolFixture(scaffold.ctx, {
signal: AbortSignal.timeout(10_000),
callId: ToolCallId('schedule-every-list'),
callId: brandString<ToolCallId>('schedule-every-list'),
name: 'schedule_list',
arguments: {},
agent: everyHandle.agent,
@@ -448,7 +449,7 @@ describe.skipIf(MODE === 'record')('web e2e: conversational reminders', () => {
await expect(scaffold.ctx.sessions.flush(everyHandle.agent.session)).resolves.toBe(true)
atHandle = await scaffold.ctx.agents.create({
sessionId: SessionId('schedule-at-web-e2e'),
sessionId: brandString<SessionId>('schedule-at-web-e2e'),
meta: { cwd },
agentOptions: { provider: AT_PROVIDER, model: MODEL },
// The reminder tools are preset-level Consumers, so a directly created Agent
@@ -843,7 +844,7 @@ describe.skipIf(MODE === 'record')('web e2e: active Schedule catalog', () => {
})
it('manages cross-Session tasks from the sidebar without activating their Sessions', async () => {
const otherSessionId = SessionId('schedule-manager-other-session')
const otherSessionId = brandString<SessionId>('schedule-manager-other-session')
await seedSession(scaffold, await readFile(CATALOG_FIXTURE, 'utf8'), otherSessionId, 'standard')
const other = await scaffold.ctx.schedule.create({ prompt: 'Inspect the second workspace deployment', title: 'Second workspace deployment', timing: { kind: 'at', at: '2099-08-25T12:08:00.000Z' }, target: { kind: 'session', sessionId: otherSessionId } }, otherSessionId)
await page.getByRole('button', { name: 'Automation tasks', exact: true }).click()
@@ -1181,7 +1182,7 @@ describe.skipIf(MODE === 'record')('web e2e: active Schedule catalog', () => {
const domain = scaffold.ctx.storageDomain.get('schedule')
if (domain === undefined) throw new Error('Schedule domain was not opened')
const instant = new Date().toISOString()
const receipt = { scheduledAt: instant, deliveredAt: instant, messageId: MessageId('retention-legacy'), targetSessionId: CATALOG_SESSION_ID }
const receipt = { scheduledAt: instant, deliveredAt: instant, messageId: brandString<MessageId>('retention-legacy'), targetSessionId: CATALOG_SESSION_ID }
await rulesTab.click()
await domain.table('tasks').put(record.id, {
...hostTask(record, CATALOG_SESSION_ID), status: 'ended', lastDelivery: receipt,
@@ -1202,7 +1203,7 @@ describe.skipIf(MODE === 'record')('web e2e: active Schedule catalog', () => {
for (let index = 0; index < 23; index++) {
const time = new Date(Date.now() - (index === 0 ? 40 * 86_400_000 : (23 - index) * 3_600_000)).toISOString()
task = { ...task, ...appendDelivery(task, {
scheduledAt: time, deliveredAt: time, messageId: MessageId(`retention-${index}`), targetSessionId: CATALOG_SESSION_ID,
scheduledAt: time, deliveredAt: time, messageId: brandString<MessageId>(`retention-${index}`), targetSessionId: CATALOG_SESSION_ID,
}, { days: 30, records: 200 }) }
}
expect(task.deliveryHistory?.records).toHaveLength(22)
@@ -1255,7 +1256,7 @@ describe.skipIf(MODE === 'record')('web e2e: active Schedule catalog', () => {
const rrule = `DTSTART;TZID=${timeZone}:${at.date.replaceAll('-', '')}T${time.replaceAll(':', '')}\nRRULE:FREQ=DAILY`
const prompt = 'Inspect the daily calendar rule'
const result = await executeToolFixture(scaffold.ctx, {
signal: AbortSignal.timeout(10_000), callId: ToolCallId('schedule-daily-catalog-create'),
signal: AbortSignal.timeout(10_000), callId: brandString<ToolCallId>('schedule-daily-catalog-create'),
name: 'schedule_create', arguments: { prompt, title: prompt, rrule, target: 'this_session' }, agent,
})
const created = (await scaffold.ctx.schedule.catalog()).find(task => (
@@ -1332,8 +1333,8 @@ describe.skipIf(MODE === 'record')('web e2e: active Schedule catalog', () => {
}, 60_000)
it('restores the latest linked Session after reviewing a concurrent destination change', async () => {
const before = SessionId('schedule-destination-before')
const after = SessionId('schedule-destination-after')
const before = brandString<SessionId>('schedule-destination-before')
const after = brandString<SessionId>('schedule-destination-after')
const fixture = await readFile(CATALOG_FIXTURE, 'utf8')
for (const id of [before, after]) await seedSession(scaffold, fixture, id, 'standard')
const created = await scaffold.ctx.schedule.create({ title: 'Destination recovery', prompt: 'Review the destination',
@@ -1366,10 +1367,10 @@ describe.skipIf(MODE === 'record')('web e2e: active Schedule catalog', () => {
it('removes every ended task from the page and keeps the active ones', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-schedule-clear-ended'))
const endedSession = SessionId('schedule-manager-ended-clear')
const endedSession = brandString<SessionId>('schedule-manager-ended-clear')
const domain = scaffold.ctx.storageDomain.get('schedule')
if (domain === undefined) throw new Error('Schedule domain was not opened')
const endedIds = [ScheduleId('schedule-ended-first'), ScheduleId('schedule-ended-second')]
const endedIds = [brandString<ScheduleId>('schedule-ended-first'), brandString<ScheduleId>('schedule-ended-second')]
const endedTitles = ['Ended release check', 'Ended metrics check'] as const
// An earlier scenario may leave an ended row behind; the confirmation states
// the whole ended set, so the lane starts from an empty one.
@@ -1380,7 +1381,7 @@ describe.skipIf(MODE === 'record')('web e2e: active Schedule catalog', () => {
const receipt = {
scheduledAt: record.scheduledAt,
deliveredAt: new Date(Date.parse(record.scheduledAt) + 1_000).toISOString(),
messageId: MessageId(`${id}-delivery`),
messageId: brandString<MessageId>(`${id}-delivery`),
targetSessionId: endedSession,
}
await domain.table('tasks').put(record.id, {
+11 -10
View File
@@ -18,7 +18,7 @@ import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { createLaunchEnvironmentSnapshot } from '@deepseek-ai/dsh-launch-environment'
import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import type { ContentBlock, ContextFormed, Message, MessageSource } from '@deepseek-ai/dsh-llm'
import { deriveEventMessage, SessionId } from '@deepseek-ai/dsh-session'
import { deriveEventMessage, type SessionId } from '@deepseek-ai/dsh-session'
import type { SessionEvent } from '@deepseek-ai/dsh-session'
import type { TokenMeter } from '@deepseek-ai/dsh-token-meter'
import type {} from '@deepseek-ai/dsh-api-terminal-controller'
@@ -30,6 +30,7 @@ import {
webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { expandOwningTurnProcess, newEnglishPage, pinBrowserClock, pinHostClock, saveFailureShot, WEB_FIXTURE_TIME } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
declare module '@deepseek-ai/dsh-llm' {
interface MessageSourceMap {
@@ -325,7 +326,7 @@ describe('web e2e: seeded history renders through cold resume', () => {
// production Session Controller against the booted real host.
const controller = new AbortController()
const stream = scaffold.ctx.sessionController.follow({
address: { kind: 'session', sessionId: SessionId(SEED_ID) },
address: { kind: 'session', sessionId: brandString<SessionId>(SEED_ID) },
}, controller.signal)[Symbol.asyncIterator]()
const first = await stream.next()
controller.abort()
@@ -399,10 +400,10 @@ describe('web e2e: seeded history renders through cold resume', () => {
expect(await page.getByText(PROMPT, { exact: true }).count()).toBe(1)
await expect.poll(
() => scaffold.ctx.agents.get(SessionId(SEED_ID)) !== undefined,
() => scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID)) !== undefined,
{ timeout: 10_000 },
).toBe(true)
const agent = scaffold.ctx.agents.get(SessionId(SEED_ID))
const agent = scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID))
if (agent === undefined) throw new Error('seeded session did not attach an agent')
const injected = agent.session.append('user/message', createUserMessage({
content: [{
@@ -488,7 +489,7 @@ describe('web e2e: seeded history renders through cold resume', () => {
})
it.skipIf(MODE === 'record')('shows ordinary instructions as one collapsed Context row that expands to their logged content', async () => {
const session = scaffold.ctx.sessions.get(SessionId(SEED_ID))
const session = scaffold.ctx.sessions.get(brandString<SessionId>(SEED_ID))
if (session === undefined) throw new Error('seeded session is unavailable')
const instructions = session.snapshotEvents().filter(event => event.type === 'user/message'
&& event.data.source.kind === 'agent-instructions')
@@ -763,7 +764,7 @@ describe('web e2e: seeded history renders through cold resume', () => {
await expect.poll(() => access.isEnabled(), { timeout: 10_000 }).toBe(true)
const row = page.locator('[data-variant="others"]').filter({ hasText: 'preset read-only' })
expect(await row.count()).toBe(0)
const agent = scaffold.ctx.agents.get(SessionId(SEED_ID))
const agent = scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID))
if (agent === undefined) throw new Error('seeded session did not attach an agent')
const events = agent.session.snapshotEvents()
const run = events.findLast(event => event.type === 'command/run' && event.data.name === 'permission')
@@ -792,7 +793,7 @@ describe('web e2e: seeded history renders through cold resume', () => {
await disclosure.click()
await expect.poll(() => disclosure.getAttribute('aria-expanded')).toBe('true')
const agent = scaffold.ctx.agents.get(SessionId(SEED_ID))
const agent = scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID))
if (agent === undefined) throw new Error('seeded session did not attach an agent')
const done = agent.session.snapshotEvents().filter(event => event.type === 'command/done').at(-1)
if (done?.type !== 'command/done') throw new Error('feedback command did not settle')
@@ -817,7 +818,7 @@ describe('web e2e: seeded history renders through cold resume', () => {
}, 60_000)
it.skipIf(MODE === 'record')('shows short injected context as a collapsed Context row without dropping the event', async () => {
const agent = scaffold.ctx.agents.get(SessionId(SEED_ID))
const agent = scaffold.ctx.agents.get(brandString<SessionId>(SEED_ID))
if (agent === undefined) throw new Error('seeded session did not attach an agent')
const contextRows = page.locator('[data-chat-flow-kind="context"]')
const before = await contextRows.count()
@@ -863,7 +864,7 @@ describe('web e2e: seeded history renders through cold resume', () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-seeded-terminal-unavailable'))
await page.locator('[data-dockkit-add-tab]').click()
await page.locator('[data-sidebar-right-guide-entry="terminal"]').getByRole('button', { name: /^New terminal/u }).click()
const sessionId = SessionId(SEED_ID)
const sessionId = brandString<SessionId>(SEED_ID)
const terminals = () => scaffold.ctx.terminalController.list(sessionId)
await expect.poll(() => terminals().length).toBe(1)
const previous = terminals()[0]!.id
@@ -889,7 +890,7 @@ describe('web e2e: seeded history renders through cold resume', () => {
it.skipIf(MODE === 'record')('omits blank reasoning rows around recorded text in an appended fixture turn', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-seeded-blank-reasoning'))
const session = scaffold.ctx.sessions.get(SessionId(SEED_ID))
const session = scaffold.ctx.sessions.get(brandString<SessionId>(SEED_ID))
if (session === undefined) throw new Error('seeded session is unavailable')
const events = session.snapshotEvents()
const recorded = events.flatMap(event => event.type === 'assistant/message' ? event.data.message.content : [])
+3 -2
View File
@@ -13,7 +13,8 @@ import { fileURLToPath } from 'node:url'
import type { Browser, Locator, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { ToolCallId, type StreamChunk } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { ToolCallId, StreamChunk } from '@deepseek-ai/dsh-llm'
import type { ReplayEntry } from '@deepseek-ai/dsh-llm-replay'
import type { SessionEvent, SessionId } from '@deepseek-ai/dsh-session'
import {
@@ -43,7 +44,7 @@ const WAIT_COMMAND = `node -e "const fs=require('node:fs'); fs.writeFileSync('st
*/
function script(): ReplayEntry[] {
const args = JSON.stringify({ command: WAIT_COMMAND, description: 'Wait a long time' })
const callId = ToolCallId('call_wait')
const callId = brandString<ToolCallId>('call_wait')
const first: StreamChunk[] = [
{ type: 'block-start', index: 0, blockType: 'tool-call' },
{ type: 'tool-call-delta', index: 0, id: callId, name: 'bash', argumentsDelta: args },
+5 -4
View File
@@ -5,11 +5,12 @@ import { fileURLToPath } from 'node:url'
import type { Browser, Locator, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import {
acknowledgeReloadConnectionLoss, launchWebScaffold, seedSession, watchConsole, type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
// The seed is another scenario's committed fixture, reused read-only: this
// spec needs any one cold Session row, not new recorded content.
@@ -83,7 +84,7 @@ describe('web e2e: archived sessions are restored from the sidebar filter', () =
await seededRow.click()
await expect.poll(() => seededRow.getAttribute('aria-selected'), { timeout: 10_000 }).toBe('true')
const { title } = await scaffold.ctx.sessionController.rename({
sessionId: SessionId(SEED_ID), title: `Unarchive target ${SEED_ID}`,
sessionId: brandString<SessionId>(SEED_ID), title: `Unarchive target ${SEED_ID}`,
})
const sessionRow = page.getByRole('treeitem').filter({ has: page.getByText(title, { exact: true }) })
await expect.poll(() => sessionRow.count(), { timeout: 10_000 }).toBe(1)
@@ -97,9 +98,9 @@ describe('web e2e: archived sessions are restored from the sidebar filter', () =
await expect.poll(() => page.getByText('Ungrouped', { exact: true }).count(), { timeout: 10_000 }).toBe(0)
// Durable on the host: the registry-global set carries the id while the
// Session log itself stays in persistence untouched.
expect([...scaffold.ctx.workspaceRegistry.archivedSessionIds]).toEqual([SessionId(SEED_ID)])
expect([...scaffold.ctx.workspaceRegistry.archivedSessionIds]).toEqual([brandString<SessionId>(SEED_ID)])
expect((await scaffold.ctx.sessionPersistence.list()).map(snapshot => snapshot.header.id))
.toContain(SessionId(SEED_ID))
.toContain(brandString<SessionId>(SEED_ID))
await page.getByRole('button', { name: 'View options' }).click()
await page.getByRole('menuitem', { name: 'All conversations (show archived)', exact: true }).click()
+3 -2
View File
@@ -14,12 +14,13 @@ import type { Browser, Locator, Page, Request } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed, onTestFinished } from 'vitest'
import { basename, join } from 'node:path'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import {
acknowledgeReloadConnectionLoss, assertFixtureInventory, captureStableAria, compareOrRefreshGolden,
launchWebScaffold, watchConsole, webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { openSettings, ZH_BROWSER_LOCALE, saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/settings-chrome', import.meta.url))
const DIALOG_EXPECTED = join(SNAPSHOT_DIR, 'dialog.expected.md')
@@ -367,7 +368,7 @@ describe('web e2e: settings modal and General preferences', () => {
it('stores Permission as the default for future sessions without changing an existing session', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-settings-permission'))
const createSession = async (id: string) => {
const handle = await scaffold.ctx.agents.create({ sessionId: SessionId(id) })
const handle = await scaffold.ctx.agents.create({ sessionId: brandString<SessionId>(id) })
onTestFinished(() => handle.dispose())
return handle.agent.session
}
+6 -5
View File
@@ -1,8 +1,9 @@
import { fileURLToPath } from 'node:url'
import { chromium } from 'playwright'
import { expect, it } from 'vitest'
import { ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import {
captureStableAria, compareOrRefreshGolden, launchWebScaffold,
seedSession, watchConsole, webSnapshotMode,
@@ -17,8 +18,8 @@ const LONG_ARGS = { ...ARGS, command: `${COMMAND} --token=${'x'.repeat(1024)}` }
/** A settled shell call rendered from durable arguments and its original result. */
function shellFixture(arguments_: typeof ARGS, output: string): string {
const session = Session.create(SessionId('shell-command-details-source'))
const callId = ToolCallId('shell-command-details-background')
const session = Session.create(brandString<SessionId>('shell-command-details-source'))
const callId = brandString<ToolCallId>('shell-command-details-background')
const args = JSON.stringify(arguments_)
session.append('turn/start', { turn: 1 })
session.append('user/message', createUserMessage({
@@ -162,7 +163,7 @@ it.each([
const resolved = await scaffold.ctx.sessionController.resolveAgent(id)
if ('error' in resolved) throw resolved.error
const session = resolved.agent.session
const callId = ToolCallId(`status-dot-${name}-${background ? 'background' : 'foreground'}`)
const callId = brandString<ToolCallId>(`status-dot-${name}-${background ? 'background' : 'foreground'}`)
const args = JSON.stringify({ command: LONG_ARGS.command, description: `Long ${name} command`, run_in_background: background })
session.append('turn/start', { turn: 2 })
session.append('user/message', createUserMessage({
+17 -16
View File
@@ -10,10 +10,11 @@ import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { afterEach, expect, it } from 'vitest'
import type { Agent } from '@deepseek-ai/dsh-agent'
import { LlmAdapter, ToolCallId } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { LlmAdapter, type ToolCallId } from '@deepseek-ai/dsh-llm'
import type { GenerateOptions, LlmResolvedModelInfo, StreamChunk } from '@deepseek-ai/dsh-llm'
import { canonicalPath, writableRoots } from '@deepseek-ai/dsh-sandbox'
import { SESSION_FORMAT_VERSION, SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, type SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import { auditStartupEntries, composeEntries, loadOverlayPatches } from '@deepseek-ai/dsh-app-boot'
// These imports carry the tools/sandboxPolicy/approval Context merges.
import { RUN_CODE_NAME } from '@deepseek-ai/dsh-tools'
@@ -35,7 +36,7 @@ const BASE_PATCH_PATH = join(REPO_ROOT, 'packages/bundle/base/cordis.patch.yml')
const HEADLESS_PATCH_PATH = join(REPO_ROOT, 'packages/bundle/headless/cordis.patch.yml')
const AUTO_PROVIDER = 'shipped-auto-review-test'
const AUTO_MODEL = 'same-route'
const AUTO_CALL_ID = ToolCallId('shipped-auto-review-denied-delete')
const AUTO_CALL_ID = brandString<ToolCallId>('shipped-auto-review-denied-delete')
const AUTO_RAW_REASON = ` direct user authorized inspection only\nTEST_ONLY_SECRET_${'x'.repeat(16_384)} `
const AUTO_FINAL_TEXT = 'SHIPPED_AUTO_REVIEW_REJECTION_OBSERVED'
const AUTO_CHILD_AUTHORIZED = 'AUTO_CHILD_AUTHORIZED'
@@ -173,7 +174,7 @@ function toolChunks(
name: string,
args: Readonly<Record<string, unknown>>,
): StreamChunk[] {
const callId = ToolCallId(id)
const callId = brandString<ToolCallId>(id)
const argumentsJson = JSON.stringify(args)
return [
{ type: 'block-start', index: 0, blockType: 'tool-call' },
@@ -604,7 +605,7 @@ it('assembles the shipped Web transport, catalog, guidance, and defaults', async
'working_directory', 'team_task_create', 'team_task_list', 'team_task_get', 'team_task_update',
])
const handle = await ctx.agents.create({
sessionId: SessionId('shipped-composition'),
sessionId: brandString<SessionId>('shipped-composition'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx).then(() => undefined),
})
try {
@@ -642,7 +643,7 @@ it('assembles the shipped Web transport, catalog, guidance, and defaults', async
expect(headlessRows.some(row => row.id === 'auto-review')).toBe(false)
const commandHandle = await scaffold.ctx.agents.create({
sessionId: SessionId('shipped-command-catalog'),
sessionId: brandString<SessionId>('shipped-command-catalog'),
meta: { cwd: scaffold.workspaceCwd },
agentOptions: { provider: 'deepseek-official', model: 'deepseek-v4-flash' },
})
@@ -662,7 +663,7 @@ it('ships PTC with run_code but without the general workflow SDK binding', async
scaffold = await launchWebScaffold({ deepSeekMissingCredential: true })
const ctx = scaffold.ctx
const handle = await ctx.agents.create({
sessionId: SessionId('shipped-ptc-composition'),
sessionId: brandString<SessionId>('shipped-ptc-composition'),
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'ptc').then(() => undefined),
})
try {
@@ -680,7 +681,7 @@ it('lets a preset producer reach the background-job registry', async () => {
scaffold = await launchWebScaffold()
const ctx = scaffold.ctx
const handle = await ctx.agents.create({
sessionId: SessionId('shipped-background-job'),
sessionId: brandString<SessionId>('shipped-background-job'),
meta: { cwd: scaffold.workspaceCwd },
setup: agentCtx => ctx.agentPresets.mount(agentCtx).then(() => undefined),
})
@@ -691,7 +692,7 @@ it('lets a preset producer reach the background-job registry', async () => {
// fails here — with every task control still listed in the catalog above.
const started = await executeModelToolFixture(ctx, {
signal,
callId: ToolCallId('shipped-bash-background'),
callId: brandString<ToolCallId>('shipped-bash-background'),
name: 'bash',
arguments: {
command: 'printf SHIPPED_BACKGROUND_OK',
@@ -713,7 +714,7 @@ it('lets a preset producer reach the background-job registry', async () => {
// owner. A per-preset registry would list nothing here even on success.
const listed = await executeToolFixture(ctx, {
signal,
callId: ToolCallId('shipped-task-list'),
callId: brandString<ToolCallId>('shipped-task-list'),
name: 'job_list',
arguments: {},
agent: handle.agent,
@@ -726,7 +727,7 @@ it('lets a preset producer reach the background-job registry', async () => {
// through a preset-plane control, which is the linkage the realm severed.
const collected = await executeToolFixture(ctx, {
signal,
callId: ToolCallId('shipped-task-output'),
callId: brandString<ToolCallId>('shipped-task-output'),
name: 'job_output',
arguments: { job_id: jobId, wait: true },
agent: handle.agent,
@@ -759,7 +760,7 @@ it('routes one browser-authored Auto request through the same model and asks the
const created = await remote<{ sessionId: string }>(scaffold, 'session/create', {
request: { cwd: scaffold.workspaceCwd },
})
const sessionId = SessionId(created.sessionId)
const sessionId = brandString<SessionId>(created.sessionId)
await remote(scaffold, 'session/selectModel', {
request: { sessionId, provider: AUTO_PROVIDER, model: AUTO_MODEL },
})
@@ -857,7 +858,7 @@ it('reviews initially authorized, restricted, and cold-resumed child calls indep
const created = await remote<{ sessionId: string }>(scaffold, 'session/create', {
request: { cwd: scaffold.workspaceCwd },
})
const parentId = SessionId(created.sessionId)
const parentId = brandString<SessionId>(created.sessionId)
adapter.setParent(parentId)
await remote(scaffold, 'session/selectModel', {
request: { sessionId: parentId, provider: AUTO_PROVIDER, model: AUTO_MODEL },
@@ -1035,7 +1036,7 @@ it('rolls back a failed shipped Auto initialization before publishing or interce
expect(warnings.join('\n')).toContain('preset "auto" is already registered')
const handle = await ctx.agents.create({
sessionId: SessionId('shipped-auto-init-rollback'),
sessionId: brandString<SessionId>('shipped-auto-init-rollback'),
meta: { cwd: scaffold.workspaceCwd },
setup: agentCtx => ctx.agentPresets.mount(agentCtx).then(() => undefined),
})
@@ -1048,7 +1049,7 @@ it('rolls back a failed shipped Auto initialization before publishing or interce
// Auto execution behavior.
const result = await executeToolFixture(ctx, {
signal: new AbortController().signal,
callId: ToolCallId('shipped-auto-init-rollback-write'),
callId: brandString<ToolCallId>('shipped-auto-init-rollback-write'),
name: 'write',
arguments: { file_path: targetPath, content: 'INITIALIZATION_ROLLED_BACK\n' },
agent: handle.agent,
@@ -1076,7 +1077,7 @@ it('withdraws Auto on shipped Loader unload and does not restore migrated live s
const autoEntry = [...ctx.loader.entries()].find(entry => entry.options.id === 'auto-review')
if (autoEntry === undefined) throw new Error('shipped Auto review Loader entry is missing')
const handle = await ctx.agents.create({
sessionId: SessionId('shipped-auto-hot-plug'),
sessionId: brandString<SessionId>('shipped-auto-hot-plug'),
meta: { cwd: scaffold.workspaceCwd, agentPreset: 'minimal' },
setup: agentCtx => ctx.agentPresets.mount(agentCtx, 'minimal').then(() => undefined),
})
+3 -2
View File
@@ -5,12 +5,13 @@ import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { chromium } from 'playwright'
import { expect, it } from 'vitest'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { initialShortcutConfig, parseShortcutDefinitions, parseShortcutEdit } from '@deepseek-ai/dsh-client-shortcuts/protocol'
import type { DesktopShortcutInput, DesktopShortcutsApi, ShortcutCommandId, ShortcutRevision } from '@deepseek-ai/dsh-client-shortcuts/protocol'
import { desktopKeybindings } from '../../desktop/src/keybindings.ts'
import { acknowledgeReloadConnectionLoss, compareOrRefreshGolden, launchWebScaffold, seedSession, watchConsole, webSnapshotMode } from './scaffold.ts'
import { writeComposerDraft } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
declare global {
interface Window {
@@ -34,7 +35,7 @@ it.each([
try {
const scaffold = await launchWebScaffold({ developerTools: false })
try {
await seedSession(scaffold, await readFile(seed, 'utf8'), SessionId('desktop-shortcuts-source'))
await seedSession(scaffold, await readFile(seed, 'utf8'), brandString<SessionId>('desktop-shortcuts-source'))
const browser = await chromium.launch()
try {
const page = await browser.newPage({ locale: 'en-US', viewport: { width: 1440, height: 1000 } })
+4 -3
View File
@@ -4,7 +4,7 @@ import { basename, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { chromium, type Browser, type Page } from 'playwright'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { createLaunchEnvironmentSnapshot } from '@deepseek-ai/dsh-launch-environment'
import { createUserMessage } from '@deepseek-ai/dsh-llm'
import {
@@ -12,10 +12,11 @@ import {
seedSession, watchConsole, webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { connectFreshWorkspace } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const root = fileURLToPath(new URL('./expected/shortcuts-workspace', import.meta.url))
const seed = fileURLToPath(new URL('../../../snapshots/web/seeded-history/session.v3.jsonl', import.meta.url))
const sourceId = SessionId('shortcuts-workspace-source')
const sourceId = brandString<SessionId>('shortcuts-workspace-source')
const mode = webSnapshotMode()
describe.skipIf(mode === 'record')('web e2e: workspace shortcuts', () => {
@@ -285,7 +286,7 @@ it.skipIf(mode === 'record').each([
const scaffold = await launchWebScaffold({ developerTools: false })
let browser: Browser | undefined
try {
await seedSession(scaffold, await readFile(seed, 'utf8'), SessionId('shortcut-defaults-source'))
await seedSession(scaffold, await readFile(seed, 'utf8'), brandString<SessionId>('shortcut-defaults-source'))
browser = await chromium.launch()
const context = await browser.newContext({ locale: 'en-US', viewport: { width: 1440, height: 1000 } })
await context.addInitScript((value) => { Object.defineProperty(navigator, 'platform', { value }) }, platform)
@@ -7,7 +7,7 @@ import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import type { AgentHandle } from '@deepseek-ai/dsh-agent'
import { createUserMessage, LlmAdapter } from '@deepseek-ai/dsh-llm'
import type { GenerateOptions, StreamChunk } from '@deepseek-ai/dsh-llm'
import { SessionId, type SessionId as SessionIdValue } from '@deepseek-ai/dsh-session'
import type { SessionId, SessionId as SessionIdValue } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-subagent'
import type {} from '@deepseek-ai/dsh-workspace'
import {
@@ -20,6 +20,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { connectFreshWorkspace, newEnglishPage, saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('./expected/sidebar-subagent-activity', import.meta.url))
const RUNNING_OWNER_EXPECTED = join(SNAPSHOT_DIR, 'owner-running.expected.md')
@@ -87,7 +88,7 @@ describe('web e2e: sidebar subagent activity', () => {
const cwd = join(scaffold.workspaceCwd, 'workspace')
await mkdir(cwd)
parentHandle = await scaffold.ctx.agents.create({
sessionId: SessionId('sidebar-activity-owner'),
sessionId: brandString<SessionId>('sidebar-activity-owner'),
meta: { cwd },
agentOptions: { provider: HOLD_PROVIDER, model: HOLD_MODEL },
})
+8 -7
View File
@@ -8,7 +8,7 @@ import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed, onTestFinished, vi } from 'vitest'
import { prepareSessionSnapshotFixtureForComparison } from '@deepseek-ai/dsh-llm-replay'
import {
SESSION_FORMAT_VERSION, SessionId as sessionId, SessionLogOffset, SessionSeq,
SESSION_FORMAT_VERSION, type SessionId as sessionId, SessionLogOffset, SessionSeq,
type SessionEvent, type SessionHeader, type SessionId,
} from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-agent'
@@ -21,6 +21,7 @@ import {
webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { connectFreshWorkspace, newEnglishPage, pinBrowserClock, pinHostClock, saveFailureShot, writeComposerDraft } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const BASE_FIXTURE = fileURLToPath(new URL('../../../snapshots/web/live-interactions/session.v3.jsonl', import.meta.url))
const AVAILABLE_CHILD_EXPECTED = fileURLToPath(new URL('../../../snapshots/web/subagent-conversation/ui.expected.md', import.meta.url))
@@ -168,7 +169,7 @@ describe('web e2e: persisted subagent conversation and human continuation', () =
liveReferenceOptions = await liveMenu.getByRole('option').allTextContents()
await page.keyboard.press('Escape')
await writeComposerDraft(page, liveInput, '')
oneShotId = sessionId('recorded-one-shot')
oneShotId = brandString<sessionId>('recorded-one-shot')
const oneShotDurationMs = 192 * 24 * 60 * 60 * 1_000
const oneShotAt = Date.now() - oneShotDurationMs
const oneShotHeader: SessionHeader = {
@@ -234,7 +235,7 @@ describe('web e2e: persisted subagent conversation and human continuation', () =
await pushedCount.waitFor({ timeout: 15_000 })
expect(apiCalls.filter(path => path === '/api/session/projections')).toHaveLength(catalogReads)
await compareOrRefreshGolden(CATALOG_PUSH_EXPECTED, await pushedCount.ariaSnapshot(), MODE)
grandchildId = sessionId('recorded-grandchild')
grandchildId = brandString<sessionId>('recorded-grandchild')
const authoredAt = Date.now()
const grandchildHeader: SessionHeader = {
version: SESSION_FORMAT_VERSION,
@@ -899,7 +900,7 @@ describe('web e2e: persisted subagent conversation and human continuation', () =
}
expect(forkReceipt.result).toMatchObject({ ok: true })
if (!forkReceipt.result.ok) return
const forkId = sessionId(forkReceipt.result.value.sessionId)
const forkId = brandString<sessionId>(forkReceipt.result.value.sessionId)
await expect.poll(() => scaffold.ctx.agents.get(forkId)).not.toBeUndefined()
await sessions.getByRole('treeitem', { name: /Ask a research subagent to/ }).click()
@@ -981,9 +982,9 @@ describe('web e2e: persisted subagent conversation and human continuation', () =
})
describe('web e2e: migration-required subagent catalog', () => {
const parentId = sessionId('migration-catalog-parent')
const childId = sessionId('migration-catalog-child')
const grandchildId = sessionId('migration-catalog-grandchild')
const parentId = brandString<sessionId>('migration-catalog-parent')
const childId = brandString<sessionId>('migration-catalog-child')
const grandchildId = brandString<sessionId>('migration-catalog-grandchild')
const childLabel = 'historical researcher'
const grandchildLabel = 'historical editor'
const predecessors: { id: SessionId; directory: string; path: string; source: Buffer }[] = []
+3 -2
View File
@@ -11,9 +11,10 @@ import { mkdtemp, rm, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { SessionId as sessionId, type SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId as sessionId, SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-agent'
import { launchWebScaffold, readPersistedEvents, webSnapshotMode, type WebScaffold } from './scaffold.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const MODE = webSnapshotMode()
const INITIAL = 'Explain event sourcing in one sentence.'
@@ -104,7 +105,7 @@ describe.skipIf(MODE === 'record')('web e2e: subagents/interruptByUser over the
cwd: scaffold.workspaceCwd,
})
if (!created.ok) throw new Error(`session.create failed: ${created.error.code}`)
parentId = sessionId(created.value.sessionId)
parentId = brandString<sessionId>(created.value.sessionId)
const parent = scaffold.ctx.agents.get(parentId)
if (parent === undefined) throw new Error('created parent session did not publish a live Agent')
+3 -2
View File
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'node:url'
import { chromium, type Browser, type BrowserContext } from 'playwright'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { createAssistantMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { createSettlementMessage } from '@deepseek-ai/dsh-subagent/src/continuation-messages.ts'
import type { SubagentStopReason } from '@deepseek-ai/dsh-subagent'
import {
@@ -13,6 +13,7 @@ import {
launchWebScaffold, watchConsole, webSnapshotMode,
} from './scaffold.ts'
import { connectFreshWorkspace, connectFreshWorkspaceZh } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const DIR = fileURLToPath(new URL('./expected/subagent-result-notice/', import.meta.url))
const MODE = webSnapshotMode()
@@ -60,7 +61,7 @@ describe.skipIf(MODE === 'record')('web e2e: subagent result notices', () => {
session.append('turn/end', { turn, reason: { kind: 'completed' } })
}
appendTurn(1, createUserMessage({ content: [{ type: 'text', text: 'Inspect child execution results.' }], source: { kind: 'user' } }))
const childId = SessionId('notice-result-child')
const childId = brandString<SessionId>('notice-result-child')
const notices: { title: string; message: ReturnType<typeof createUserMessage> }[] = OUTCOMES.map(outcome => ({
title: outcome[locale],
message: createSettlementMessage(childId, 'agent-1', {
+6 -5
View File
@@ -3,8 +3,9 @@ import { mkdir } from 'node:fs/promises'
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import type { Agent, AssistantStreamFrame } from '@deepseek-ai/dsh-agent'
import { brandString } from '@deepseek-ai/dsh-brand'
import {
AssistantStreamAccumulator, LlmAttemptId, ToolCallId,
AssistantStreamAccumulator, type LlmAttemptId, type ToolCallId,
createAssistantMessage, createToolResultMessage, createUserMessage,
type StreamChunk,
} from '@deepseek-ai/dsh-llm'
@@ -101,7 +102,7 @@ describe.skipIf(MODE === 'record')('web e2e: subagent task summary', () => {
})
it('streams the description and preserves it through creation and restored history', async () => {
const callId = ToolCallId('subagent-summary-described')
const callId = brandString<ToolCallId>('subagent-summary-described')
const selector = toolSelector(callId)
const card = page.locator(selector)
const snapshots: string[] = []
@@ -113,7 +114,7 @@ describe.skipIf(MODE === 'record')('web e2e: subagent task summary', () => {
await scaffold.ctx.sessions.flush(agent.session)
await page.locator('[data-chat-turn="1"]').getByText('Inspect subagent summary case 1.', { exact: true }).waitFor()
const attemptId = LlmAttemptId('subagent-summary-stream')
const attemptId = brandString<LlmAttemptId>('subagent-summary-stream')
const stream = new AssistantStreamAccumulator()
let revision = 0
let index = 0
@@ -190,7 +191,7 @@ describe.skipIf(MODE === 'record')('web e2e: subagent task summary', () => {
const snapshots: string[] = []
for (const [index, fixture] of cases.entries()) {
const turn = index + 2
const callId = ToolCallId(`subagent-summary-${fixture.id}`)
const callId = brandString<ToolCallId>(`subagent-summary-${fixture.id}`)
const selector = toolSelector(callId)
const card = page.locator(selector)
startTurn(agent, turn)
@@ -223,7 +224,7 @@ describe.skipIf(MODE === 'record')('web e2e: subagent task summary', () => {
it('presents fork creation with a distinct title, task summary, and restored receipt', async () => {
const name = 'subagent_fork'
const callId = ToolCallId('subagent-fork-summary')
const callId = brandString<ToolCallId>('subagent-fork-summary')
const selector = `[data-chat-call-id="${callId}"] [data-tool="${name}"]`
const card = page.locator(selector)
const description = 'Review inherited conversation context'
+3 -2
View File
@@ -4,7 +4,7 @@ import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, Session, type SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
import {
assertFixtureInventory,
@@ -17,6 +17,7 @@ import {
type WebScaffold,
} from './scaffold.ts'
import { expandTurnProcesses, newEnglishPage, saveFailureShot, scrollIntoView } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const EXPECTED_DIR = fileURLToPath(new URL('./expected/thinking-markdown', import.meta.url))
const UI_EXPECTED = fileURLToPath(new URL('./expected/thinking-markdown/ui.expected.md', import.meta.url))
@@ -27,7 +28,7 @@ const LONG_TOKEN = 'workspace/packages/client/secondary-markdown/'.repeat(12)
/** Closed Session using semantic Markdown and content wider than the message column. */
function thinkingFixture(): string {
const session = Session.create(SessionId('thinking-markdown-source'))
const session = Session.create(brandString<SessionId>('thinking-markdown-source'))
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'Show reasoning and a main answer.' }],
+3 -2
View File
@@ -20,7 +20,8 @@ import type { Browser, Locator, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { initialShortcutConfig } from '@deepseek-ai/dsh-client-shortcuts/protocol'
import { ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { type ToolCallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import type { Session } from '@deepseek-ai/dsh-session'
import {
INTERACTIVE_SELECTOR, RECALL_MARK, isDraggableAt, type RegionRect,
@@ -252,7 +253,7 @@ describe('web e2e: macOS window drag coverage', () => {
const { page, tripwire } = await desktopPage()
try {
const session = await connectWorkspaceSession(page, 'scrolled-drag-content')
const callId = ToolCallId('window-drag-scroll-command')
const callId = brandString<ToolCallId>('window-drag-scroll-command')
const args = JSON.stringify({ command: 'printf drag-fixture', description: 'Inspect scroll fixture' })
session.append('turn/start', { turn: 1 })
session.append('user/message', createUserMessage({
+11 -10
View File
@@ -17,13 +17,14 @@ import { join, sep } from 'node:path'
import type { Browser, Locator, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import { SessionId } from '@deepseek-ai/dsh-session'
import type { SessionId } from '@deepseek-ai/dsh-session'
import { logPath } from '../../../packages/session/session-persistence-jsonl/src/format.ts'
import {
acknowledgeReloadConnectionLoss, assertFixtureInventory, captureStableAria, compareOrRefreshGolden,
launchWebScaffold, readPersistedEvents, seedSession, watchConsole, webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot } from './support.ts'
import { brandString } from '@deepseek-ai/dsh-brand'
const SNAPSHOT_DIR = fileURLToPath(new URL('../../../snapshots/web/workspace-management', import.meta.url))
// The seed is another scenario's committed fixture, reused read-only: this
@@ -249,7 +250,7 @@ describe('web e2e: workspace management (create / rename / grouping / hover affo
const workspace = await scaffold.ctx.workspaceRegistry.resolveByPath(scaffold.workspaceCwd)
if (workspace === undefined) throw new Error('GUI did not register the existing project directory')
holdAttachment = true
await workspace.attachSession(SessionId(SEED_ID))
await workspace.attachSession(brandString<SessionId>(SEED_ID))
const header = (await scaffold.ctx.sessionPersistence.list())
.map(snapshot => snapshot.header)
.find(candidate => candidate.id === SEED_ID)
@@ -303,7 +304,7 @@ describe('web e2e: workspace management (create / rename / grouping / hover affo
).toBe(1)
expect(await readFile(join(scaffold.workspaceCwd, 'workspace', 'a.txt'), 'utf8')).toBe('alpha\n')
await stat(seededLogPath)
expect((await readPersistedEvents(scaffold, SessionId(SEED_ID))).length).toBeGreaterThan(0)
expect((await readPersistedEvents(scaffold, brandString<SessionId>(SEED_ID))).length).toBeGreaterThan(0)
// Re-registering the exact deleted path immediately, without a reload, is
// a supported reversible flow. It creates a fresh Workspace id and does
@@ -350,7 +351,7 @@ describe('web e2e: workspace management (create / rename / grouping / hover affo
expect(scaffold.ctx.workspaceRegistry.get(workspace.id)).toBeUndefined()
expect(await readFile(join(scaffold.workspaceCwd, 'workspace', 'a.txt'), 'utf8')).toBe('alpha\n')
await stat(seededLogPath)
expect((await readPersistedEvents(scaffold, SessionId(SEED_ID))).length).toBeGreaterThan(0)
expect((await readPersistedEvents(scaffold, brandString<SessionId>(SEED_ID))).length).toBeGreaterThan(0)
expect(transientSlotErrors).toEqual([])
expect(slotConsoleErrors).toEqual([])
@@ -654,7 +655,7 @@ describe('web e2e: workspace management (create / rename / grouping / hover affo
await mkdir(cwd, { recursive: true })
await hoverScaffold.ctx.workspaceRegistry.create(cwd, title)
}
const sessionId = SessionId('mixed-hover-session')
const sessionId = brandString<SessionId>('mixed-hover-session')
await seedSession(hoverScaffold, await readFile(SEED, 'utf8'), sessionId)
await hoverScaffold.ctx.sessionController.rename({ sessionId, title: 'Mixed hover session' })
const hoverPage = await newEnglishPage(browser)
@@ -716,8 +717,8 @@ describe('web e2e: workspace management (create / rename / grouping / hover affo
const seed = await readFile(SEED, 'utf8')
await seedSession(hoverScaffold, seed, 'hover-first')
await seedSession(hoverScaffold, seed, 'hover-second')
await hoverScaffold.ctx.sessionController.rename({ sessionId: SessionId('hover-first'), title: 'Hover first' })
await hoverScaffold.ctx.sessionController.rename({ sessionId: SessionId('hover-second'), title: 'Hover second' })
await hoverScaffold.ctx.sessionController.rename({ sessionId: brandString<SessionId>('hover-first'), title: 'Hover first' })
await hoverScaffold.ctx.sessionController.rename({ sessionId: brandString<SessionId>('hover-second'), title: 'Hover second' })
for (const layout of ['In one list', 'Workspace Tree']) {
// Each page owns a browser context, so layout preferences and paused clocks cannot leak between layouts.
const ui = await newEnglishPage(browser)
@@ -843,7 +844,7 @@ describe('web e2e: workspace management (create / rename / grouping / hover affo
// so archiving this last visible Ungrouped Session must remove the bucket.
await initialRow.click()
const { title } = await scaffold.ctx.sessionController.rename({
sessionId: SessionId(SEED_ID), title: `Archive target ${SEED_ID}`,
sessionId: brandString<SessionId>(SEED_ID), title: `Archive target ${SEED_ID}`,
})
// A user-owned title binds the locator to this seed across restoration.
const sessionRow = page.getByRole('treeitem').filter({
@@ -863,8 +864,8 @@ describe('web e2e: workspace management (create / rename / grouping / hover affo
await expect.poll(() => page.getByText('Ungrouped', { exact: true }).count(), { timeout: 10_000 }).toBe(0)
// Durable on the host: the registry-global set carries the id while the
// session log itself stays in persistence untouched.
expect([...scaffold.ctx.workspaceRegistry.archivedSessionIds]).toEqual([SessionId(SEED_ID)])
expect((await scaffold.ctx.sessionPersistence.list()).map(snapshot => snapshot.header.id)).toContain(SessionId(SEED_ID))
expect([...scaffold.ctx.workspaceRegistry.archivedSessionIds]).toEqual([brandString<SessionId>(SEED_ID)])
expect((await scaffold.ctx.sessionPersistence.list()).map(snapshot => snapshot.header.id)).toContain(brandString<SessionId>(SEED_ID))
// Reload: the hidden state is rebuilt from the workspace.list baseline.
const warningStart = tripwire.warnings.length
await page.reload({ waitUntil: 'load' })
+3 -2
View File
@@ -6,7 +6,8 @@ import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { promisify } from 'node:util'
import { FiberState } from '@deepseek-ai/cordis'
import { ToolCallId } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { ToolCallId } from '@deepseek-ai/dsh-llm'
import type {} from '@deepseek-ai/dsh-experimental-worktree'
import type {} from '@deepseek-ai/dsh-experimental-client-ui-forge'
import { chromium } from 'playwright'
@@ -94,7 +95,7 @@ it('persists the unified review and worktree switch and retains checkouts after
const created = { path: join(repository, '.agents/worktrees/gui-opt-in'), baseCommit: (await git('rev-parse', 'HEAD')).stdout.trim() }
const result = await scaffold.ctx.tools.execute({
agent, signal: new AbortController().signal,
calls: [{ type: 'tool-call', id: ToolCallId('gui-opt-in'), name: 'create_worktree', arguments: JSON.stringify({ name: 'gui-opt-in' }) }],
calls: [{ type: 'tool-call', id: brandString<ToolCallId>('gui-opt-in'), name: 'create_worktree', arguments: JSON.stringify({ name: 'gui-opt-in' }) }],
})
expect(result.results[0]?.result.isError).not.toBe(true)
expect(result.results[0]?.result.value).toEqual({ ...created, branch: 'gui-opt-in', repositoryRoot: repository })
@@ -1,7 +1,8 @@
/** Compiled production Client fold for a reconnect during a long Assistant attempt. */
import { performance } from 'node:perf_hooks'
import { AssistantStreamAccumulator } from '@deepseek-ai/dsh-llm/assistant-stream'
import { LlmAttemptId } from '@deepseek-ai/dsh-llm/brand'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { LlmAttemptId } from '@deepseek-ai/dsh-llm/brand'
import type { SessionAssistantStreamBaseline } from '@deepseek-ai/dsh-api-session-controller/types'
// The Client implementation has no plain-Node export; only this adapter is bundled.
import { ClientAssistantStream } from '../../packages/api/session-controller/src/client/sessions/assistant-stream.ts'
@@ -26,7 +27,7 @@ accumulator.push({ time: 1700000000000, chunk: { type: 'block-start', index: 0,
for (let index = 0; index < deltas; index++) {
accumulator.push({ time: 1700000000001 + index, chunk: { type: 'reasoning-delta', index: 0, text: 'token ' } })
}
const attemptId = LlmAttemptId('synthetic-reconnect')
const attemptId = brandString<LlmAttemptId>('synthetic-reconnect')
const nextIndex = deltas + 1
const baseline: SessionAssistantStreamBaseline = {
revision: nextIndex + 1,
@@ -3,7 +3,8 @@
import { performance } from 'node:perf_hooks'
import { Context } from '@deepseek-ai/cordis'
import { provideWorkingDirectoryFixture } from '@deepseek-ai/dsh-agent-loop-testkit'
import SessionStore, { SESSION_FORMAT_VERSION, SessionId, SessionLogOffset, SessionSeq } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import SessionStore, { SESSION_FORMAT_VERSION, type SessionId, SessionLogOffset, SessionSeq } from '@deepseek-ai/dsh-session'
import type { SessionEvent } from '@deepseek-ai/dsh-session'
import * as JsonlSessionPersistence from '@deepseek-ai/dsh-session-persistence-jsonl'
import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
@@ -36,7 +37,7 @@ async function seed(ctx: Context): Promise<void> {
const inherited = syntheticHistory(WORKLOAD.childHistoryTurns)
const catalog: SessionEvent[] = []
for (let child = 0; child < WORKLOAD.children; child++) {
const id = SessionId('bench-child-' + String(child))
const id = brandString<SessionId>('bench-child-' + String(child))
catalog.push({
type: 'subagent/catalog', seq: SessionSeq(child), time: TIME_ZERO + child,
data: { version: 0, childId: id, childCreatedAt: TIME_ZERO + child,
@@ -1,7 +1,8 @@
/** Compiled synthetic model for the shipped sdk-minimal profile; tools remain production plugins. */
import type { Context } from '@deepseek-ai/cordis'
import { LlmAdapter, ToolCallId } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { LlmAdapter, type ToolCallId } from '@deepseek-ai/dsh-llm'
import type { GenerateOptions, LlmResolvedModelInfo, StreamChunk } from '@deepseek-ai/dsh-llm'
import { response, WORKLOAD } from './workload.ts'
@@ -18,7 +19,7 @@ class ProfileAdapter extends LlmAdapter {
return
}
for (let index = 0; index < WORKLOAD.toolsPerLiveTurn; index++) {
const id = ToolCallId('profile-call-' + String(serial) + '-' + String(index))
const id = brandString<ToolCallId>('profile-call-' + String(serial) + '-' + String(index))
const args = JSON.stringify({ command: 'view', path: process.cwd() + '/synthetic.txt' })
yield { type: 'block-start', index, blockType: 'tool-call' }
yield { type: 'tool-call-delta', index, id, name: 'str_replace_editor', argumentsDelta: args }
@@ -2,7 +2,8 @@
import { expect, it } from 'vitest'
import { createSystemMessage } from '@deepseek-ai/dsh-llm'
import { parseSessionLog } from '@deepseek-ai/dsh-llm-replay'
import { Session, SessionId, SESSION_FORMAT_VERSION } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { Session, type SessionId, SESSION_FORMAT_VERSION } from '@deepseek-ai/dsh-session'
import { syntheticHistory as browserHistory } from '../long-session-browser/synthetic-history.ts'
import { syntheticHistory } from './workload.ts'
@@ -15,7 +16,7 @@ for (const [name, generate] of [
it(name + ' seed preserves a protected head when the next prompt replaces it', () => {
const events = parseSessionLog(generate())
expect(events.slice(0, 4).map(event => event.type)).toEqual(['turn/start', 'step/start', 'system/message', 'user/message'])
const session = Session.create(SessionId(header.id), events)
const session = Session.create(brandString<SessionId>(header.id), events)
const head = session.surface.nodes[0]!
expect(session.eventAt(head)).toMatchObject({ type: 'system/message', data: { turn: 1, step: 1, message: { role: 'system', content: [] } } })
const history = session.deriveMessages()
@@ -25,7 +26,7 @@ for (const [name, generate] of [
const replacement = session.append('system/message', {
turn, step: 1, message: createSystemMessage('Next synthetic prompt'),
}, { surfaceOp: { op: 'replace', startSeq: head, endSeq: head }, sourceEventSeqs: [head] })
const restored = Session.create(SessionId(header.id), parseSessionLog([
const restored = Session.create(brandString<SessionId>(header.id), parseSessionLog([
JSON.stringify(header), ...session.snapshotEvents().map(event => JSON.stringify(event)),
].join('\n')))
expect(restored.surface.nodes[0]).toBe(replacement.seq)
+9 -8
View File
@@ -1,9 +1,10 @@
/** Reviewed synthetic tool history shared by continuation and child-catalog measurements. */
import { AssistantStreamAccumulator } from '@deepseek-ai/dsh-llm/assistant-stream'
import { MessageId, ToolCallId } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { MessageId, ToolCallId } from '@deepseek-ai/dsh-llm'
import type { ContentBlock, StreamChunk } from '@deepseek-ai/dsh-llm'
import { Session, SessionId } from '@deepseek-ai/dsh-session'
import { Session, type SessionId } from '@deepseek-ai/dsh-session'
import type { SessionEvent } from '@deepseek-ai/dsh-session'
/** Workload dimensions, independent of environment and recorded user material. */
@@ -22,7 +23,7 @@ export const WORKLOAD = {
/** Fixed clock used only to author persisted synthetic input. */
export const TIME_ZERO = 1_700_000_000_000
/** Durable parent identity of the measured continuation. */
export const PARENT_ID = SessionId('bench-parent')
export const PARENT_ID = brandString<SessionId>('bench-parent')
/**
* Construct a deterministic model reply without retaining past requests.
@@ -35,7 +36,7 @@ export function response(serial: number, tools: number): { chunks: StreamChunk[]
{ type: 'reasoning', text: 'Inspect the synthetic result. '.repeat(8) },
{ type: 'text', text: 'Synthetic response. '.repeat(8) },
...Array.from({ length: tools }, (_, index): ContentBlock => ({
type: 'tool-call', id: ToolCallId('call-' + String(serial) + '-' + String(index)), name: 'bench_tool',
type: 'tool-call', id: brandString<ToolCallId>('call-' + String(serial) + '-' + String(index)), name: 'bench_tool',
arguments: JSON.stringify({ ordinal: serial * 100 + index }),
})),
]
@@ -69,10 +70,10 @@ export function syntheticHistory(turns: number): SessionEvent[] {
session.append('turn/start', { turn })
session.append('step/start', { turn, step: 1 })
if (turn === 1) session.append('system/message', {
turn, step: 1, message: { id: MessageId('system-head'), role: 'system', content: [], source: { kind: 'system-prompt' } },
turn, step: 1, message: { id: brandString<MessageId>('system-head'), role: 'system', content: [], source: { kind: 'system-prompt' } },
}, { surfaceOp: 'append' })
session.append('user/message', {
id: MessageId('prompt-' + String(turn)), role: 'user',
id: brandString<MessageId>('prompt-' + String(turn)), role: 'user',
content: [{ type: 'text', text: 'Inspect synthetic module ' + String(turn) }], source: { kind: 'user' },
}, { surfaceOp: 'append' })
for (const step of [1, 2]) {
@@ -82,7 +83,7 @@ export function syntheticHistory(turns: number): SessionEvent[] {
reply.chunks.forEach((chunk, index) => { stream.push({ time: TIME_ZERO + turn * 1_000 + step * 100 + index, chunk }) })
session.append('assistant/message', {
turn, step,
message: { id: MessageId('reply-' + String(turn) + '-' + String(step)), role: 'assistant', content: reply.content, source: { kind: 'model', provider: 'bench', model: 'bench' } },
message: { id: brandString<MessageId>('reply-' + String(turn) + '-' + String(step)), role: 'assistant', content: reply.content, source: { kind: 'model', provider: 'bench', model: 'bench' } },
stream: [...stream.snapshot()],
}, { surfaceOp: 'append' })
for (const block of reply.content) {
@@ -91,7 +92,7 @@ export function syntheticHistory(turns: number): SessionEvent[] {
session.append('tool/result', {
turn, step,
message: {
id: MessageId('result-' + block.id), role: 'tool', toolCallId: block.id, isError: false,
id: brandString<MessageId>('result-' + block.id), role: 'tool', toolCallId: block.id, isError: false,
source: { kind: 'tool', callId: block.id },
content: [{ type: 'text', text: resultText(turn) }],
},
@@ -3,7 +3,8 @@
import { performance } from 'node:perf_hooks'
import { Context } from '@deepseek-ai/cordis'
import { AssistantStreamAccumulator } from '@deepseek-ai/dsh-llm/assistant-stream'
import { LlmAttemptId, ToolCallId } from '@deepseek-ai/dsh-llm/brand'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { LlmAttemptId, ToolCallId } from '@deepseek-ai/dsh-llm/brand'
import type { StreamChunk } from '@deepseek-ai/dsh-llm'
import type { SessionEvent } from '@deepseek-ai/dsh-session/types'
import type { ChatNode, ChatSnapshot } from '@deepseek-ai/dsh-client-ui-chat/client'
@@ -204,8 +205,8 @@ function preparingTool(tool: 'write' | 'bash', characters: number, definitions:
const chunksPerPublication = 64
const payload = 'abcdefghijklmno '.repeat(Math.ceil(characters / chunkSize)).slice(0, characters)
const tail = `${payload}"}`
const callId = ToolCallId('preparing-benchmark')
const attemptId = LlmAttemptId('preparing-benchmark')
const callId = brandString<ToolCallId>('preparing-benchmark')
const attemptId = brandString<LlmAttemptId>('preparing-benchmark')
const delta = (index: number, argumentsDelta: string): SessionEventLikeEntry => ({
type: 'transient',
event: {
@@ -284,7 +285,7 @@ function streamingAssistant(
const payload = pattern === 'ordinary'
? 'abcdefghijklmno '.repeat(Math.ceil(characters / 16)).slice(0, characters)
: ' '.repeat(characters / 2) + 'abcdefghijklmno '.repeat(Math.ceil(characters / 32)).slice(0, characters / 2)
const attemptId = LlmAttemptId('streaming-benchmark')
const attemptId = brandString<LlmAttemptId>('streaming-benchmark')
const live = (index: number, chunk: StreamChunk): SessionEventLikeEntry => ({
type: 'transient',
event: {
@@ -1,8 +1,9 @@
/** Synthetic current-generation history and paced reply for browser measurements. */
import { createAssistantMessage, createSystemMessage, createUserMessage, createToolResultMessage, ToolCallId } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import { createAssistantMessage, createSystemMessage, createUserMessage, createToolResultMessage, type ToolCallId } from '@deepseek-ai/dsh-llm'
import type { StreamChunk } from '@deepseek-ai/dsh-llm'
import { AssistantStreamAccumulator } from '@deepseek-ai/dsh-llm/assistant-stream'
import { Session, SessionId, SESSION_FORMAT_VERSION } from '@deepseek-ai/dsh-session'
import { Session, type SessionId, SESSION_FORMAT_VERSION } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
/** Closed turns in the browser history workload. */
@@ -23,7 +24,7 @@ export const PACE_MS = 32
* @returns Current Session JSONL accepted by the shared Web seeder.
*/
export function syntheticHistory(): string {
const session = Session.create(SessionId(SESSION_ID))
const session = Session.create(brandString<SessionId>(SESSION_ID))
for (let turn = 1; turn <= HISTORY_TURNS; turn++) {
session.append('turn/start', { turn })
session.append('step/start', { turn, step: 1 })
@@ -35,7 +36,7 @@ export function syntheticHistory(): string {
source: { kind: 'user' },
}), { surfaceOp: 'append' })
if (turn === 1) session.append('session/title', { title: TITLE, messageSeqs: [user.seq], source: { kind: 'fallback' } })
const callId = ToolCallId('synthetic-tool-' + String(turn))
const callId = brandString<ToolCallId>('synthetic-tool-' + String(turn))
const tool = turn % 6 === 0
const code = turn % 12 === 0
? '\n\n```ts\n' + Array.from({ length: 60 }, (_, i) => 'const value' + String(i) + ' = ' + String(i)).join('\n') + '\n```'
@@ -9,7 +9,8 @@ import { Context } from '@deepseek-ai/cordis'
import AgentRegistry from '@deepseek-ai/dsh-agent'
import RemoteAccessService from '@deepseek-ai/dsh-api-remote-access'
import type SessionController from '@deepseek-ai/dsh-api-session-controller'
import SessionStore, { SESSION_FORMAT_VERSION, SessionId, SessionLogOffset, type SessionHeader } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import SessionStore, { SESSION_FORMAT_VERSION, type SessionId, SessionLogOffset, type SessionHeader } from '@deepseek-ai/dsh-session'
import * as JsonlSessionPersistence from '@deepseek-ai/dsh-session-persistence-jsonl'
import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
import SessionProjectionCache, { projectionCacheDomainSpec } from '@deepseek-ai/dsh-session-projection-cache'
@@ -96,7 +97,7 @@ interface ViewObservation {
}
function headerOf(ordinal: number): SessionHeader {
return { version: SESSION_FORMAT_VERSION, id: SessionId(`projection-bench-${ordinal}`),
return { version: SESSION_FORMAT_VERSION, id: brandString<SessionId>(`projection-bench-${ordinal}`),
createdAt: BASE_TIME + ordinal, cwd: CWD, isSeeded: false, delegationDepth: 0 }
}
+10 -9
View File
@@ -3,9 +3,10 @@
import { mkdir, readFile, writeFile } from 'node:fs/promises'
import { dirname, join } from 'node:path'
import { AssistantStreamAccumulator } from '@deepseek-ai/dsh-llm/assistant-stream'
import { MessageId, ToolCallId } from '@deepseek-ai/dsh-llm'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { MessageId, ToolCallId } from '@deepseek-ai/dsh-llm'
import type { ContentBlock, StreamChunk } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, SessionId } from '@deepseek-ai/dsh-session'
import { SESSION_FORMAT_VERSION, type SessionId } from '@deepseek-ai/dsh-session'
import type { SessionEvent, SessionEventMap, SessionEventType, SessionHeader } from '@deepseek-ai/dsh-session'
import {
eventLines,
@@ -68,7 +69,7 @@ export interface WrittenSession {
* @returns stable Session id.
*/
export function corpusSessionId(rank: number): SessionId {
return SessionId('bench-' + String(rank).padStart(5, '0'))
return brandString<SessionId>('bench-' + String(rank).padStart(5, '0'))
}
function vocabularyWord(rank: number): string {
@@ -213,18 +214,18 @@ function authorEvents(
if (turn === 1) log.append('system/message', {
turn, step: 1,
message: {
id: MessageId('system-head'), role: 'system',
id: brandString<MessageId>('system-head'), role: 'system',
content: [{ type: 'text', text: pool.slice(next, SYSTEM_PROMPT_CHARS) }],
source: { kind: 'system-prompt' },
},
}, { surfaceOp: 'append' })
log.append('user/message', {
id: MessageId('prompt-' + String(turn)), role: 'user',
id: brandString<MessageId>('prompt-' + String(turn)), role: 'user',
content: [{ type: 'text', text: pool.slice(next, plan.userChars) }], source: { kind: 'user' },
}, { surfaceOp: 'append' })
for (let step = 1; step <= turnSteps + 1; step++) {
if (step > 1) log.append('step/start', { turn, step })
const callId = step <= turnSteps ? ToolCallId(`call-${String(turn)}-${String(step)}`) : undefined
const callId = step <= turnSteps ? brandString<ToolCallId>(`call-${String(turn)}-${String(step)}`) : undefined
const content: ContentBlock[] = [
{ type: 'reasoning', text: pool.slice(next, plan.reasoningChars) },
{ type: 'text', text: pool.slice(next, plan.textChars) },
@@ -242,7 +243,7 @@ function authorEvents(
log.append('assistant/message', {
turn, step,
message: {
id: MessageId(`reply-${String(turn)}-${String(step)}`), role: 'assistant', content,
id: brandString<MessageId>(`reply-${String(turn)}-${String(step)}`), role: 'assistant', content,
source: { kind: 'model', provider: 'bench', model: 'bench' },
},
stream: [...stream.snapshot()],
@@ -256,7 +257,7 @@ function authorEvents(
log.append('tool/result', {
turn, step,
message: {
id: MessageId('result-' + callId), role: 'tool', toolCallId: callId, isError: false,
id: brandString<MessageId>('result-' + callId), role: 'tool', toolCallId: callId, isError: false,
source: { kind: 'tool', callId },
content: [{ type: 'text', text: pool.slice(next, plan.resultChars) }],
},
@@ -346,7 +347,7 @@ export function corpusHeader(rank: number, count: number): SessionHeader {
export function anchorHeader(anchor: number): SessionHeader {
return {
version: SESSION_FORMAT_VERSION,
id: SessionId(`bench-anchor-${String(anchor).padStart(2, '0')}`),
id: brandString<SessionId>(`bench-anchor-${String(anchor).padStart(2, '0')}`),
createdAt: TIME_ZERO - 60_000,
cwd: '/bench/anchors',
isSeeded: false,
@@ -5,7 +5,8 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { Context } from '@deepseek-ai/cordis'
import { Session, SessionId, SESSION_FORMAT_VERSION } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import { Session, type SessionId, SESSION_FORMAT_VERSION } from '@deepseek-ai/dsh-session'
import * as JsonlSessionPersistence from '@deepseek-ai/dsh-session-persistence-jsonl'
import {
runBuiltBenchmarkWorker,
@@ -364,7 +365,7 @@ describe('Session opening benchmark prerequisites', () => {
const original = await readFile(facts.path)
const directory = join(root, SYNTHETIC_SESSION_DIRECTORY)
const persistence = await mount()
const read = await persistence.open(SessionId(SYNTHETIC_SESSION_ID), 'read')
const read = await persistence.open(brandString<SessionId>(SYNTHETIC_SESSION_ID), 'read')
const initial = await read.read()
const session = Session.fromRestore(read.header.id, initial.events, read.header, read.inheritedEventCount, initial.eventState)
expect(read.header.version).toBe(SESSION_FORMAT_VERSION)
@@ -380,11 +381,11 @@ describe('Session opening benchmark prerequisites', () => {
)
await read.close()
expect(await readdir(directory)).toEqual([SYNTHETIC_V0_FILENAME])
const writer = await persistence.open(SessionId(SYNTHETIC_SESSION_ID), 'write')
const writer = await persistence.open(brandString<SessionId>(SYNTHETIC_SESSION_ID), 'write')
expect((await writer.read()).events).toEqual(initial.events)
await writer.close()
expect(await readdir(directory)).toContain(SYNTHETIC_CURRENT_FILENAME)
const reopened = await (await mount()).open(SessionId(SYNTHETIC_SESSION_ID), 'read')
const reopened = await (await mount()).open(brandString<SessionId>(SYNTHETIC_SESSION_ID), 'read')
expect((await reopened.read()).events).toEqual(initial.events)
await reopened.close()
expect(await readFile(facts.path)).toEqual(original)
@@ -1,5 +1,6 @@
/** Isolated worker for cold Session phase, first-history, and Agent-resume benchmarks. */
import { brandString } from '@deepseek-ai/dsh-brand'
import { performance } from 'node:perf_hooks'
import { scheduler } from 'node:timers/promises'
import { Context } from '@deepseek-ai/cordis'
@@ -8,7 +9,7 @@ import { mountAgentLoopTestDependencies } from '@deepseek-ai/dsh-agent-loop-test
import { agentPresetProjectionDefinition } from '@deepseek-ai/dsh-agent-preset-registry'
import SessionStore, {
interruptedTurnClosers,
SessionId,
type SessionId,
SessionLogOffset,
SessionPreparation,
} from '@deepseek-ai/dsh-session'
@@ -229,7 +230,7 @@ class SessionBenchmarkHost {
readonly phases: NonNullable<SessionOpenWorkerReport['phases']>
}> {
let phaseStarted = performance.now()
const handle = await this.ctx.sessionPersistence.open(SessionId(SYNTHETIC_SESSION_ID), 'read')
const handle = await this.ctx.sessionPersistence.open(brandString<SessionId>(SYNTHETIC_SESSION_ID), 'read')
const openMs = performance.now() - phaseStarted
phaseStarted = performance.now()
const read = await handle.read()
@@ -238,7 +239,7 @@ class SessionBenchmarkHost {
phaseStarted = performance.now()
const repaired = [...read.events, ...interruptedTurnClosers(read.events)]
const seed = repaired
const preparation = SessionPreparation.create(this.ctx.sessions.prepare(SessionId(SYNTHETIC_SESSION_ID), {
const preparation = SessionPreparation.create(this.ctx.sessions.prepare(brandString<SessionId>(SYNTHETIC_SESSION_ID), {
seed,
meta: structuredClone(handle.header),
inheritedEventCount: handle.inheritedEventCount,
@@ -267,7 +268,7 @@ class SessionBenchmarkHost {
const history = this.history
if (history === undefined) throw new Error('first-history benchmark did not initialize its controller')
const iterator = history.follow({
address: { kind: 'session', sessionId: SessionId(SYNTHETIC_SESSION_ID) },
address: { kind: 'session', sessionId: brandString<SessionId>(SYNTHETIC_SESSION_ID) },
}, abort.signal)[Symbol.asyncIterator]()
this.historyIterator = iterator as AsyncIterator<unknown>
const first = await iterator.next()
@@ -280,7 +281,7 @@ class SessionBenchmarkHost {
private async measureAgentResume(): Promise<{ readonly events: number }> {
const handle = await this.ctx.agents.resume({
resumeSessionId: SessionId(SYNTHETIC_SESSION_ID),
resumeSessionId: brandString<SessionId>(SYNTHETIC_SESSION_ID),
agentOptions: { provider: 'bench', model: 'bench' },
})
this.agentHandle = handle
+23 -23
View File
@@ -54,7 +54,7 @@ export type Config = z.infer<typeof Config>
## `@deepseek-ai/dsh-agent-default-model`
- `refs`: `Volatile` (`@deepseek-ai/cordis`)
- `source`: [`packages/core/agent-default-model/src/index.ts:24`](../packages/core/agent-default-model/src/index.ts)
- `source`: [`packages/core/agent-default-model/src/index.ts:25`](../packages/core/agent-default-model/src/index.ts)
```ts config-catalog
/** Default model selection supplied by plugin configuration. */
@@ -262,7 +262,7 @@ export interface Config {
## `@deepseek-ai/dsh-api-session-controller`
- `inject`: `agentDefaultModel` · `agents` · `attachments` · `fileUploads` · `fs` · `llm` · `remoteAccess` · `sessions` · `sessionProjections` · `sessionQuery` · `typert` · `typertGateway` · `workspaceRegistry`
- `source`: [`packages/api/session-controller/src/index.ts:110`](../packages/api/session-controller/src/index.ts)
- `source`: [`packages/api/session-controller/src/index.ts:111`](../packages/api/session-controller/src/index.ts)
```ts config-catalog
/** Session Controller deployment policy. */
@@ -851,7 +851,7 @@ export interface ToolResultPruneConfig {
## `@deepseek-ai/dsh-cordis-host-runner`
- `inject`: `tools`
- `source`: [`packages/extensions/cordis-host-runner/src/index.ts:103`](../packages/extensions/cordis-host-runner/src/index.ts)
- `source`: [`packages/extensions/cordis-host-runner/src/index.ts:104`](../packages/extensions/cordis-host-runner/src/index.ts)
```ts config-catalog
/** Runner configuration. */
@@ -1039,7 +1039,7 @@ export type Config = BrowserMcpConfig
- `inject`: `browserUse` · `agents` · `tools` · `systemPrompt`
- `refs`: `ModelConfig` (`@browserbasehq/stagehand`)
- `source`: [`packages/experimental/browser-use-stagehand-native/src/index.ts:28`](../packages/experimental/browser-use-stagehand-native/src/index.ts)
- `source`: [`packages/experimental/browser-use-stagehand-native/src/index.ts:29`](../packages/experimental/browser-use-stagehand-native/src/index.ts)
```ts config-catalog
/** Profile-owned browser connection and independent Stagehand model credentials. */
@@ -1078,7 +1078,7 @@ export interface StagehandModelConfig {
## `@deepseek-ai/dsh-experimental-claude-code-mods`
- `inject`: `workingDirectory` · `agents`
- `source`: [`packages/experimental/claude-code-mods/src/index.ts:53`](../packages/experimental/claude-code-mods/src/index.ts)
- `source`: [`packages/experimental/claude-code-mods/src/index.ts:54`](../packages/experimental/claude-code-mods/src/index.ts)
```ts config-catalog
/** Plugin config: the limits mod hooks run under. */
@@ -1199,7 +1199,7 @@ export interface Config {
- `inject`: `computerUse` · `tools`
- `refs`: [`McpClient`](../packages/mcp/mcp-client/src/index.ts)
- `source`: [`packages/experimental/computer-use-cua-driver-mcp/src/index.ts:20`](../packages/experimental/computer-use-cua-driver-mcp/src/index.ts)
- `source`: [`packages/experimental/computer-use-cua-driver-mcp/src/index.ts:21`](../packages/experimental/computer-use-cua-driver-mcp/src/index.ts)
```ts config-catalog
/** Installed executable and MCP connection overrides. */
@@ -1654,7 +1654,7 @@ export interface Config {
## `@deepseek-ai/dsh-fs-local`
- `source`: [`packages/fs/fs-local/src/index.ts:51`](../packages/fs/fs-local/src/index.ts)
- `source`: [`packages/fs/fs-local/src/index.ts:52`](../packages/fs/fs-local/src/index.ts)
```ts config-catalog
/** Configuration for the local filesystem backend. */
@@ -1696,7 +1696,7 @@ export type Config = LocalConfig
## `@deepseek-ai/dsh-goal`
- `inject`: `agents` · `sessionProjections`
- `source`: [`packages/goal/goal/src/index.ts:168`](../packages/goal/goal/src/index.ts)
- `source`: [`packages/goal/goal/src/index.ts:169`](../packages/goal/goal/src/index.ts)
```ts config-catalog
/** Deployment defaults for goal creation. */
@@ -1983,7 +1983,7 @@ export interface TlsConfig {
## `@deepseek-ai/dsh-jobs-local`
- `source`: [`packages/jobs/jobs-local/src/index.ts:46`](../packages/jobs/jobs-local/src/index.ts)
- `source`: [`packages/jobs/jobs-local/src/index.ts:47`](../packages/jobs/jobs-local/src/index.ts)
```ts config-catalog
/** Configuration for the process-local job registry. */
@@ -2337,7 +2337,7 @@ export type PiAiThinkingTokenBudgetField = NonNullable<OpenAICompletionsCompat['
- `inject`: `llm`
- `refs`: [`LlmModelBadge`](../packages/llm/llm/src/index.ts) · [`ModelModality`](../packages/llm/llm/src/index.ts) · [`RetryPolicyConfig`](../packages/llm/llm/src/index.ts) · [`SystemPromptUpdate`](../packages/llm/llm/src/index.ts) · [`ToolUpdate`](../packages/llm/llm/src/index.ts)
- `source`: [`packages/test-support/llm-replay/src/index.ts:1115`](../packages/test-support/llm-replay/src/index.ts)
- `source`: [`packages/test-support/llm-replay/src/index.ts:1116`](../packages/test-support/llm-replay/src/index.ts)
```ts config-catalog
/** Plugin config: the {@link ReplayConfig} inputs, each defaulting to its `DSH_SNAPSHOT_*` env var in `apply`. */
@@ -2419,7 +2419,7 @@ export interface ReplayModelConfig {
## `@deepseek-ai/dsh-llm-retry`
- `inject`: `agents` · `sessionProjections`
- `source`: [`packages/llm/llm-retry/src/index.ts:25`](../packages/llm/llm-retry/src/index.ts)
- `source`: [`packages/llm/llm-retry/src/index.ts:26`](../packages/llm/llm-retry/src/index.ts)
```ts config-catalog
/** This policy executor has no config; providers own `retryPolicy`. */
@@ -2433,7 +2433,7 @@ export type Config = Readonly<Record<string, never>>
## `@deepseek-ai/dsh-lsp-stdio`
- `inject`: `fs` · `lsp` · `subprocess`
- `source`: [`packages/lsp/lsp-stdio/src/index.ts:70`](../packages/lsp/lsp-stdio/src/index.ts)
- `source`: [`packages/lsp/lsp-stdio/src/index.ts:71`](../packages/lsp/lsp-stdio/src/index.ts)
```ts config-catalog
/** Plugin configuration: provider id → local language-server configuration. */
@@ -2693,7 +2693,7 @@ export interface Config {
- `inject`: `shell` · `approval` · `sessions` · `agents` · `sessionProjections`
- `refs`: [`ApprovalPolicy`](subsystems/approval.md) · [`SandboxMode`](subsystems/sandbox.md) · `Volatile` (`@deepseek-ai/cordis`)
- `source`: [`packages/interaction/permission-presets/src/index.ts:153`](../packages/interaction/permission-presets/src/index.ts)
- `source`: [`packages/interaction/permission-presets/src/index.ts:154`](../packages/interaction/permission-presets/src/index.ts)
```ts config-catalog
/** The {@link PermissionPresetService} config: preset table and composition default. */
@@ -3108,7 +3108,7 @@ export interface Config {
## `@deepseek-ai/dsh-schedule`
- `inject`: `agents` · `sessions` · `storageDomain` · `sessionPersistence`
- `source`: [`packages/schedule/schedule/src/index.ts:80`](../packages/schedule/schedule/src/index.ts)
- `source`: [`packages/schedule/schedule/src/index.ts:81`](../packages/schedule/schedule/src/index.ts)
```ts config-catalog
/** Configuration for the Host Schedule domain. */
@@ -3222,7 +3222,7 @@ export type SessionLogCompressionLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
## `@deepseek-ai/dsh-session-persistence-jsonl`
- `source`: [`packages/session/session-persistence-jsonl/src/index.ts:94`](../packages/session/session-persistence-jsonl/src/index.ts)
- `source`: [`packages/session/session-persistence-jsonl/src/index.ts:95`](../packages/session/session-persistence-jsonl/src/index.ts)
```ts config-catalog
/** Plugin config for the JSONL backend's root, physical encoding, and listing concurrency. */
@@ -3421,7 +3421,7 @@ export interface Config {
- `inject`: `sessionTitle` · `llm` · `sessions`
- `refs`: [`SessionTitleLlmConfig`](../packages/session/session-title-llm/src/index.ts)
- `source`: [`packages/experimental/session-title-all-prompts-llm/src/index.ts:28`](../packages/experimental/session-title-all-prompts-llm/src/index.ts)
- `source`: [`packages/experimental/session-title-all-prompts-llm/src/index.ts:29`](../packages/experimental/session-title-all-prompts-llm/src/index.ts)
```ts config-catalog
/** Required execution controls plus this provider's title-length targets; no defaults. */
@@ -3441,7 +3441,7 @@ export interface Config extends SessionTitleLlmConfig {
- `inject`: `sessionTitle` · `llm` · `sessions`
- `refs`: [`SessionTitleLlmConfig`](../packages/session/session-title-llm/src/index.ts)
- `source`: [`packages/session/session-title-first-prompt-llm/src/index.ts:28`](../packages/session/session-title-first-prompt-llm/src/index.ts)
- `source`: [`packages/session/session-title-first-prompt-llm/src/index.ts:29`](../packages/session/session-title-first-prompt-llm/src/index.ts)
```ts config-catalog
/** Required execution controls plus this provider's title-length targets; no defaults. */
@@ -3561,7 +3561,7 @@ export type PythonEnvironment = 'workspace-dependencies' | 'user'
## `@deepseek-ai/dsh-spill-local`
- `source`: [`packages/spill/spill-local/src/index.ts:31`](../packages/spill/spill-local/src/index.ts)
- `source`: [`packages/spill/spill-local/src/index.ts:32`](../packages/spill/spill-local/src/index.ts)
```ts config-catalog
/** Plugin config (all optional — `static Config` supplies the defaults). */
@@ -4338,7 +4338,7 @@ export interface Config {
## `@deepseek-ai/dsh-tool-jobs`
- `inject`: `tools` · `jobs` · `systemPrompt`
- `source`: [`packages/jobs/tool-jobs/src/index.ts:43`](../packages/jobs/tool-jobs/src/index.ts)
- `source`: [`packages/jobs/tool-jobs/src/index.ts:44`](../packages/jobs/tool-jobs/src/index.ts)
```ts config-catalog
/** Configures bounded `job_output` waits and completion-notice delivery. */
@@ -4403,7 +4403,7 @@ export interface Config {
## `@deepseek-ai/dsh-tool-office`
- `inject`: `tools` · `fs` · `workingDirectory` · `agents`
- `source`: [`packages/document/tool-office/src/index.ts:38`](../packages/document/tool-office/src/index.ts)
- `source`: [`packages/document/tool-office/src/index.ts:40`](../packages/document/tool-office/src/index.ts)
```ts config-catalog
/** Activation skills and render bounds; lower deployment attachment limits take precedence. */
@@ -4724,7 +4724,7 @@ export interface Config {
## `@deepseek-ai/dsh-tool-workflow`
- `inject`: `tools` · `workflowEngine` · `systemPrompt`
- `source`: [`packages/workflow/tool-workflow/src/index.ts:44`](../packages/workflow/tool-workflow/src/index.ts)
- `source`: [`packages/workflow/tool-workflow/src/index.ts:45`](../packages/workflow/tool-workflow/src/index.ts)
```ts config-catalog
/** Config: the model-facing tool name plus result rendering caps. */
@@ -4791,7 +4791,7 @@ export interface Config {
## `@deepseek-ai/dsh-user-approval`
- `inject`: `sessionProjections`
- `source`: [`packages/interaction/user-approval/src/index.ts:152`](../packages/interaction/user-approval/src/index.ts)
- `source`: [`packages/interaction/user-approval/src/index.ts:153`](../packages/interaction/user-approval/src/index.ts)
```ts config-catalog
/** Plugin config. All optional — `static Config` supplies the defaults. */
@@ -5014,7 +5014,7 @@ export interface Config {
## `@deepseek-ai/dsh-workflow-ptc`
- `inject`: `subagents` · `ptcRuntime` · `sandboxPolicy` · `workingDirectory`
- `source`: [`packages/workflow/workflow-ptc/src/index.ts:33`](../packages/workflow/workflow-ptc/src/index.ts)
- `source`: [`packages/workflow/workflow-ptc/src/index.ts:35`](../packages/workflow/workflow-ptc/src/index.ts)
```ts config-catalog
/** Plugin config (all optional — `static Config` supplies the defaults). */
+23 -23
View File
@@ -56,7 +56,7 @@ export type Config = z.infer<typeof Config>
## `@deepseek-ai/dsh-agent-default-model`
- `refs`: `Volatile` (`@deepseek-ai/cordis`)
- `source`: [`packages/core/agent-default-model/src/index.ts:24`](../packages/core/agent-default-model/src/index.ts)
- `source`: [`packages/core/agent-default-model/src/index.ts:25`](../packages/core/agent-default-model/src/index.ts)
```ts config-catalog
/** Default model selection supplied by plugin configuration. */
@@ -264,7 +264,7 @@ export interface Config {
## `@deepseek-ai/dsh-api-session-controller`
- `inject`: `agentDefaultModel` · `agents` · `attachments` · `fileUploads` · `fs` · `llm` · `remoteAccess` · `sessions` · `sessionProjections` · `sessionQuery` · `typert` · `typertGateway` · `workspaceRegistry`
- `source`: [`packages/api/session-controller/src/index.ts:110`](../packages/api/session-controller/src/index.ts)
- `source`: [`packages/api/session-controller/src/index.ts:111`](../packages/api/session-controller/src/index.ts)
```ts config-catalog
/** Session Controller deployment policy. */
@@ -853,7 +853,7 @@ export interface ToolResultPruneConfig {
## `@deepseek-ai/dsh-cordis-host-runner`
- `inject`: `tools`
- `source`: [`packages/extensions/cordis-host-runner/src/index.ts:103`](../packages/extensions/cordis-host-runner/src/index.ts)
- `source`: [`packages/extensions/cordis-host-runner/src/index.ts:104`](../packages/extensions/cordis-host-runner/src/index.ts)
```ts config-catalog
/** Runner configuration. */
@@ -1041,7 +1041,7 @@ export type Config = BrowserMcpConfig
- `inject`: `browserUse` · `agents` · `tools` · `systemPrompt`
- `refs`: `ModelConfig` (`@browserbasehq/stagehand`)
- `source`: [`packages/experimental/browser-use-stagehand-native/src/index.ts:28`](../packages/experimental/browser-use-stagehand-native/src/index.ts)
- `source`: [`packages/experimental/browser-use-stagehand-native/src/index.ts:29`](../packages/experimental/browser-use-stagehand-native/src/index.ts)
```ts config-catalog
/** Profile-owned browser connection and independent Stagehand model credentials. */
@@ -1080,7 +1080,7 @@ export interface StagehandModelConfig {
## `@deepseek-ai/dsh-experimental-claude-code-mods`
- `inject`: `workingDirectory` · `agents`
- `source`: [`packages/experimental/claude-code-mods/src/index.ts:53`](../packages/experimental/claude-code-mods/src/index.ts)
- `source`: [`packages/experimental/claude-code-mods/src/index.ts:54`](../packages/experimental/claude-code-mods/src/index.ts)
```ts config-catalog
/** Plugin config: the limits mod hooks run under. */
@@ -1201,7 +1201,7 @@ export interface Config {
- `inject`: `computerUse` · `tools`
- `refs`: [`McpClient`](../packages/mcp/mcp-client/src/index.ts)
- `source`: [`packages/experimental/computer-use-cua-driver-mcp/src/index.ts:20`](../packages/experimental/computer-use-cua-driver-mcp/src/index.ts)
- `source`: [`packages/experimental/computer-use-cua-driver-mcp/src/index.ts:21`](../packages/experimental/computer-use-cua-driver-mcp/src/index.ts)
```ts config-catalog
/** Installed executable and MCP connection overrides. */
@@ -1656,7 +1656,7 @@ export interface Config {
## `@deepseek-ai/dsh-fs-local`
- `source`: [`packages/fs/fs-local/src/index.ts:51`](../packages/fs/fs-local/src/index.ts)
- `source`: [`packages/fs/fs-local/src/index.ts:52`](../packages/fs/fs-local/src/index.ts)
```ts config-catalog
/** Configuration for the local filesystem backend. */
@@ -1698,7 +1698,7 @@ export type Config = LocalConfig
## `@deepseek-ai/dsh-goal`
- `inject`: `agents` · `sessionProjections`
- `source`: [`packages/goal/goal/src/index.ts:168`](../packages/goal/goal/src/index.ts)
- `source`: [`packages/goal/goal/src/index.ts:169`](../packages/goal/goal/src/index.ts)
```ts config-catalog
/** Deployment defaults for goal creation. */
@@ -1985,7 +1985,7 @@ export interface TlsConfig {
## `@deepseek-ai/dsh-jobs-local`
- `source`: [`packages/jobs/jobs-local/src/index.ts:46`](../packages/jobs/jobs-local/src/index.ts)
- `source`: [`packages/jobs/jobs-local/src/index.ts:47`](../packages/jobs/jobs-local/src/index.ts)
```ts config-catalog
/** Configuration for the process-local job registry. */
@@ -2339,7 +2339,7 @@ export type PiAiThinkingTokenBudgetField = NonNullable<OpenAICompletionsCompat['
- `inject`: `llm`
- `refs`: [`LlmModelBadge`](../packages/llm/llm/src/index.ts) · [`ModelModality`](../packages/llm/llm/src/index.ts) · [`RetryPolicyConfig`](../packages/llm/llm/src/index.ts) · [`SystemPromptUpdate`](../packages/llm/llm/src/index.ts) · [`ToolUpdate`](../packages/llm/llm/src/index.ts)
- `source`: [`packages/test-support/llm-replay/src/index.ts:1115`](../packages/test-support/llm-replay/src/index.ts)
- `source`: [`packages/test-support/llm-replay/src/index.ts:1116`](../packages/test-support/llm-replay/src/index.ts)
```ts config-catalog
/** Plugin config: the {@link ReplayConfig} inputs, each defaulting to its `DSH_SNAPSHOT_*` env var in `apply`. */
@@ -2421,7 +2421,7 @@ export interface ReplayModelConfig {
## `@deepseek-ai/dsh-llm-retry`
- `inject`: `agents` · `sessionProjections`
- `source`: [`packages/llm/llm-retry/src/index.ts:25`](../packages/llm/llm-retry/src/index.ts)
- `source`: [`packages/llm/llm-retry/src/index.ts:26`](../packages/llm/llm-retry/src/index.ts)
```ts config-catalog
/** This policy executor has no config; providers own `retryPolicy`. */
@@ -2435,7 +2435,7 @@ export type Config = Readonly<Record<string, never>>
## `@deepseek-ai/dsh-lsp-stdio`
- `inject`: `fs` · `lsp` · `subprocess`
- `source`: [`packages/lsp/lsp-stdio/src/index.ts:70`](../packages/lsp/lsp-stdio/src/index.ts)
- `source`: [`packages/lsp/lsp-stdio/src/index.ts:71`](../packages/lsp/lsp-stdio/src/index.ts)
```ts config-catalog
/** Plugin configuration: provider id → local language-server configuration. */
@@ -2695,7 +2695,7 @@ export interface Config {
- `inject`: `shell` · `approval` · `sessions` · `agents` · `sessionProjections`
- `refs`: [`ApprovalPolicy`](subsystems/approval.zh.md) · [`SandboxMode`](subsystems/sandbox.zh.md) · `Volatile` (`@deepseek-ai/cordis`)
- `source`: [`packages/interaction/permission-presets/src/index.ts:153`](../packages/interaction/permission-presets/src/index.ts)
- `source`: [`packages/interaction/permission-presets/src/index.ts:154`](../packages/interaction/permission-presets/src/index.ts)
```ts config-catalog
/** The {@link PermissionPresetService} config: preset table and composition default. */
@@ -3110,7 +3110,7 @@ export interface Config {
## `@deepseek-ai/dsh-schedule`
- `inject`: `agents` · `sessions` · `storageDomain` · `sessionPersistence`
- `source`: [`packages/schedule/schedule/src/index.ts:80`](../packages/schedule/schedule/src/index.ts)
- `source`: [`packages/schedule/schedule/src/index.ts:81`](../packages/schedule/schedule/src/index.ts)
```ts config-catalog
/** Configuration for the Host Schedule domain. */
@@ -3224,7 +3224,7 @@ export type SessionLogCompressionLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
## `@deepseek-ai/dsh-session-persistence-jsonl`
- `source`: [`packages/session/session-persistence-jsonl/src/index.ts:94`](../packages/session/session-persistence-jsonl/src/index.ts)
- `source`: [`packages/session/session-persistence-jsonl/src/index.ts:95`](../packages/session/session-persistence-jsonl/src/index.ts)
```ts config-catalog
/** Plugin config for the JSONL backend's root, physical encoding, and listing concurrency. */
@@ -3423,7 +3423,7 @@ export interface Config {
- `inject`: `sessionTitle` · `llm` · `sessions`
- `refs`: [`SessionTitleLlmConfig`](../packages/session/session-title-llm/src/index.ts)
- `source`: [`packages/experimental/session-title-all-prompts-llm/src/index.ts:28`](../packages/experimental/session-title-all-prompts-llm/src/index.ts)
- `source`: [`packages/experimental/session-title-all-prompts-llm/src/index.ts:29`](../packages/experimental/session-title-all-prompts-llm/src/index.ts)
```ts config-catalog
/** Required execution controls plus this provider's title-length targets; no defaults. */
@@ -3443,7 +3443,7 @@ export interface Config extends SessionTitleLlmConfig {
- `inject`: `sessionTitle` · `llm` · `sessions`
- `refs`: [`SessionTitleLlmConfig`](../packages/session/session-title-llm/src/index.ts)
- `source`: [`packages/session/session-title-first-prompt-llm/src/index.ts:28`](../packages/session/session-title-first-prompt-llm/src/index.ts)
- `source`: [`packages/session/session-title-first-prompt-llm/src/index.ts:29`](../packages/session/session-title-first-prompt-llm/src/index.ts)
```ts config-catalog
/** Required execution controls plus this provider's title-length targets; no defaults. */
@@ -3563,7 +3563,7 @@ export type PythonEnvironment = 'workspace-dependencies' | 'user'
## `@deepseek-ai/dsh-spill-local`
- `source`: [`packages/spill/spill-local/src/index.ts:31`](../packages/spill/spill-local/src/index.ts)
- `source`: [`packages/spill/spill-local/src/index.ts:32`](../packages/spill/spill-local/src/index.ts)
```ts config-catalog
/** Plugin config (all optional — `static Config` supplies the defaults). */
@@ -4340,7 +4340,7 @@ export interface Config {
## `@deepseek-ai/dsh-tool-jobs`
- `inject`: `tools` · `jobs` · `systemPrompt`
- `source`: [`packages/jobs/tool-jobs/src/index.ts:43`](../packages/jobs/tool-jobs/src/index.ts)
- `source`: [`packages/jobs/tool-jobs/src/index.ts:44`](../packages/jobs/tool-jobs/src/index.ts)
```ts config-catalog
/** Configures bounded `job_output` waits and completion-notice delivery. */
@@ -4405,7 +4405,7 @@ export interface Config {
## `@deepseek-ai/dsh-tool-office`
- `inject`: `tools` · `fs` · `workingDirectory` · `agents`
- `source`: [`packages/document/tool-office/src/index.ts:38`](../packages/document/tool-office/src/index.ts)
- `source`: [`packages/document/tool-office/src/index.ts:40`](../packages/document/tool-office/src/index.ts)
```ts config-catalog
/** Activation skills and render bounds; lower deployment attachment limits take precedence. */
@@ -4726,7 +4726,7 @@ export interface Config {
## `@deepseek-ai/dsh-tool-workflow`
- `inject`: `tools` · `workflowEngine` · `systemPrompt`
- `source`: [`packages/workflow/tool-workflow/src/index.ts:44`](../packages/workflow/tool-workflow/src/index.ts)
- `source`: [`packages/workflow/tool-workflow/src/index.ts:45`](../packages/workflow/tool-workflow/src/index.ts)
```ts config-catalog
/** Config: the model-facing tool name plus result rendering caps. */
@@ -4793,7 +4793,7 @@ export interface Config {
## `@deepseek-ai/dsh-user-approval`
- `inject`: `sessionProjections`
- `source`: [`packages/interaction/user-approval/src/index.ts:152`](../packages/interaction/user-approval/src/index.ts)
- `source`: [`packages/interaction/user-approval/src/index.ts:153`](../packages/interaction/user-approval/src/index.ts)
```ts config-catalog
/** Plugin config. All optional — `static Config` supplies the defaults. */
@@ -5016,7 +5016,7 @@ export interface Config {
## `@deepseek-ai/dsh-workflow-ptc`
- `inject`: `subagents` · `ptcRuntime` · `sandboxPolicy` · `workingDirectory`
- `source`: [`packages/workflow/workflow-ptc/src/index.ts:33`](../packages/workflow/workflow-ptc/src/index.ts)
- `source`: [`packages/workflow/workflow-ptc/src/index.ts:35`](../packages/workflow/workflow-ptc/src/index.ts)
```ts config-catalog
/** Plugin config (all optional — `static Config` supplies the defaults). */
Loaded 100 of 1171 files, more files were not shown because too many files have changed in this diff. Show more