Merge remote-tracking branch 'origin/master' into dshw/pr-2250

This commit is contained in:
_Kerman
2026-08-11 22:33:12 +08:00
422 changed files with 15607 additions and 1120 deletions

View File

@@ -55,6 +55,10 @@ describe('minimal agent preset', () => {
const requestHeader = agentHandle.agent.session.requestHeader()
if (requestHeader === undefined) throw new Error('the minimal agent issued no model request')
const presetFileSystem = scaffold.ctx.agentPresets.serviceFor(agentHandle.agent, 'fs')
expect(presetFileSystem).toBeDefined()
expect(presetFileSystem?.sandboxMode).toBeUndefined()
expect(scaffold.ctx.agentPresets.serviceFor(agentHandle.agent, 'compact')).toBeUndefined()
const stateDir = join(scaffold.workspaceCwd, 'persistent-state')
await mkdir(stateDir)

View File

@@ -0,0 +1,176 @@
// Web e2e scenario: the Plugins settings section — the cards a deployment's
// exposed host-plane namespaces produce, one field edited through the real
// wire down to `$DSH_HOME/settings.yaml`, and the override badge and reset
// that layering produces. Zero model calls: everything is client state plus
// the settings document on a blank frame, so there is no fixture and a stray
// stream would fail loud on the open llm seam.
import { readFile } from 'node:fs/promises'
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 { join } from 'node:path'
import {
assertFixtureInventory, captureStableAria, compareOrRefreshGolden,
launchWebScaffold, watchConsole, webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { ZH_BROWSER_LOCALE, saveFailureShot } from './support.ts'
const SNAPSHOT_DIR = fileURLToPath(new URL('./snapshots/plugin-config', import.meta.url))
const SECTION_EXPECTED = join(SNAPSHOT_DIR, 'section.expected.md')
const MODE = webSnapshotMode()
describe('web e2e: plugin configuration section', () => {
let scaffold: WebScaffold
let browser: Browser
let page: Page
let tripwire: ReturnType<typeof watchConsole>
beforeAll(async () => {
scaffold = await launchWebScaffold({})
browser = await chromium.launch()
// Chinese browser: the section asserts the localized copy the client
// derives from it, as the rest of the settings surface does.
page = await browser.newPage({ viewport: { width: 1680, height: 1000 }, locale: ZH_BROWSER_LOCALE })
tripwire = watchConsole(page)
await page.goto(scaffold.baseUrl, { waitUntil: 'load' })
await page.waitForSelector('[class*="frame"]', { timeout: 30_000 })
}, 120_000)
afterAll(async () => {
await browser?.close()
await scaffold?.close()
})
/**
* Open the settings dialog on the Plugins section. The scenarios share one
* page so the settings document accumulates across them, so this leaves any
* dialog a previous scenario opened closed first — its mask would otherwise
* swallow the trigger click.
*/
async function openPlugins() {
if (await page.getByRole('dialog', { name: '设置' }).count() > 0) {
await page.keyboard.press('Escape')
await expect.poll(() => page.getByRole('dialog', { name: '设置' }).count(), { timeout: 5_000 }).toBe(0)
}
await page.getByRole('button', { name: '设置', exact: true }).click()
const dialog = page.getByRole('dialog', { name: '设置' })
await dialog.waitFor({ timeout: 10_000 })
await dialog.getByRole('button', { name: '插件' }).click()
await expect
.poll(() => dialog.getByRole('button', { name: '插件' }).getAttribute('aria-current'), { timeout: 5_000 })
.toBe('true')
return dialog
}
/** The settings document as the Host has written it so far. */
async function settingsDocument(): Promise<string> {
return readFile(join(scaffold.harnessHome, 'settings.yaml'), 'utf8').catch(() => '')
}
it('shows one card per exposed host-plane namespace', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-plugin-config-cards'))
const dialog = await openPlugins()
// Every card the shipped web composition exposes: the shell executor, the
// agent loop, and the DeepSeek search provider.
await dialog.getByText('终端', { exact: true }).waitFor({ timeout: 10_000 })
expect(await dialog.getByText('Agent 循环', { exact: true }).count()).toBe(1)
expect(await dialog.getByText('网页搜索', { exact: true }).count()).toBe(1)
// Collapsed: a card's fields appear only once it is expanded.
expect(await dialog.getByLabel('命令超时(毫秒)').count()).toBe(0)
const snapshot = await captureStableAria(page, '[role="dialog"]', scaffold.workspaceCwd)
await compareOrRefreshGolden(SECTION_EXPECTED, snapshot, MODE)
expect(tripwire.pageErrors).toEqual([])
}, 60_000)
it('stages an edit and writes it only when saved', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-plugin-config-write'))
const dialog = await openPlugins()
await dialog.getByText('终端', { exact: true }).click()
const timeout = dialog.getByLabel('命令超时(毫秒)')
await timeout.waitFor({ timeout: 10_000 })
// The composed default this deployment ships, before any user layer.
expect(await timeout.inputValue()).toBe('60000')
await timeout.fill('12000')
await timeout.blur()
// Nothing crosses the wire until the user saves: leaving the control is
// not a decision to store the value.
expect(await settingsDocument()).not.toContain('timeoutMs')
const save = dialog.getByRole('button', { name: '保存', exact: true })
await expect.poll(() => save.isEnabled(), { timeout: 5_000 }).toBe(true)
await save.click()
await expect.poll(async () => (await settingsDocument()).includes('timeoutMs: 12000'), { timeout: 10_000 })
.toBe(true)
// Presence in the user layer is what the badge reports, and the reset is
// offered only for a field that has one.
await expect.poll(() => dialog.getByText('已覆盖').count(), { timeout: 5_000 }).toBe(1)
expect(await dialog.getByRole('button', { name: '恢复默认' }).count()).toBe(1)
// A settled form offers no save to repeat.
await expect.poll(() => save.isDisabled(), { timeout: 5_000 }).toBe(true)
expect(tripwire.pageErrors).toEqual([])
}, 60_000)
it('drops a staged edit on discard without touching the document', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-plugin-config-discard'))
const dialog = await openPlugins()
await dialog.getByText('终端', { exact: true }).click()
const timeout = dialog.getByLabel('命令超时(毫秒)')
await timeout.waitFor({ timeout: 10_000 })
await timeout.fill('7000')
await dialog.getByRole('button', { name: '放弃修改' }).click()
await expect.poll(() => timeout.inputValue(), { timeout: 5_000 }).toBe('12000')
expect(await settingsDocument()).toContain('timeoutMs: 12000')
expect(tripwire.pageErrors).toEqual([])
}, 60_000)
it('refuses to save a draft that is not a number', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-plugin-config-invalid'))
const dialog = await openPlugins()
await dialog.getByText('终端', { exact: true }).click()
const timeout = dialog.getByLabel('命令超时(毫秒)')
await timeout.waitFor({ timeout: 10_000 })
await timeout.fill('soon')
const save = dialog.getByRole('button', { name: '保存', exact: true })
await expect.poll(() => save.isDisabled(), { timeout: 5_000 }).toBe(true)
expect(await dialog.getByText('请填数字;留空表示使用默认值。').count()).toBe(1)
await dialog.getByRole('button', { name: '放弃修改' }).click()
expect(tripwire.pageErrors).toEqual([])
}, 60_000)
it('clears the field back to the composed default on reset', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-plugin-config-reset'))
const dialog = await openPlugins()
await dialog.getByText('终端', { exact: true }).click()
const timeout = dialog.getByLabel('命令超时(毫秒)')
await timeout.waitFor({ timeout: 10_000 })
expect(await timeout.inputValue()).toBe('12000')
// The reset stages the composed default; the document still carries the
// override until the save lands.
await dialog.getByRole('button', { name: '恢复默认' }).click()
await expect.poll(() => timeout.inputValue(), { timeout: 5_000 }).toBe('60000')
expect(await settingsDocument()).toContain('timeoutMs: 12000')
await dialog.getByRole('button', { name: '保存', exact: true }).click()
await expect.poll(async () => (await settingsDocument()).includes('timeoutMs'), { timeout: 10_000 })
.toBe(false)
expect(await timeout.inputValue()).toBe('60000')
expect(await dialog.getByText('已覆盖').count()).toBe(0)
expect(tripwire.pageErrors).toEqual([])
}, 60_000)
it.skipIf(MODE === 'record')('keeps the fixture inventory closed', async () => {
expect(tripwire.warnings).toEqual([])
await assertFixtureInventory(SNAPSHOT_DIR, ['section.expected.md'])
})
})

View File

@@ -1,28 +1,107 @@
// Web e2e scenario: the produced-files row a finished turn ends with. Cold-seeds
// a recorded write turn (zero model calls). Package tests cover the derivation
// in isolation, but only the assembled application shows that a turn's writes
// reach the transcript as an openable row (docs/testing.md snapshot rule). The
// click itself is not driven here: it hands the path to the Host's opener,
// which would launch a real application on the machine running the suite.
import { readFile, writeFile, mkdir } from 'node:fs/promises'
import { join } from 'node:path'
// Web e2e scenario: the single-line produced-files summary a finished turn
// ends with. Cold-seeds ten writes (zero model calls), then verifies the real
// assembled lane keeps a precise +N and a capability-gated folder handoff.
// The folder request is intercepted so one real browser click can exercise
// the full client carrier without launching a native application in CI.
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 { afterAll, beforeAll, describe, expect, it, onTestFailed, vi } from 'vitest'
import { CallId, createAssistantMessage, createToolResultMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { SESSION_FORMAT_VERSION, Session, SessionId } from '@deepseek-ai/dsh-session'
import type {} from '@deepseek-ai/dsh-session-title'
import {
launchWebScaffold, seedSession, watchConsole, webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot } from './support.ts'
// Borrowed read-only: this scenario needs any settled turn whose tools WROTE a
// file, not a new recording (the message-actions borrowing pattern).
const SEED = fileURLToPath(new URL('./snapshots/permission-policy-context/session.jsonl', import.meta.url))
const MODE = webSnapshotMode()
const OVERLAY = fileURLToPath(new URL('./produced-files.overlay.yml', import.meta.url))
const SEED_ID = 'produced-files-web-e2e'
const DONE = 'PRODUCED_FILES_DONE'
/** The file the borrowed recording's write tool produces. */
const PRODUCED = 'policy-neutral.txt'
/** Short leading names plus a long third name make the narrow lane deterministically show two. */
const PRODUCED = [
'关于我.md',
'index.html',
'long-generated-experience-specification-for-produced-files-overflow.md',
'styles.css',
'app.ts',
'schema.json',
'README.md',
'preview.svg',
'notes.txt',
'manifest.yaml',
] as const
/** Build one settled turn whose successful write calls carry ten locations. */
function producedFixture(): string {
const session = Session.create(SessionId('produced-files-source'))
const eventTimeOrigin = new Date().setHours(12, 0, 0, 0)
session.append('turn/start', { turn: 1 })
const user = session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'Create the site files.' }],
source: { kind: 'user' },
}), { surfaceOp: 'append' })
session.append('session/title', {
title: 'Produced files overflow', messageSeqs: [user.seq], source: { kind: 'fallback' },
})
session.append('step/start', { turn: 1, step: 1 })
const calls = PRODUCED.map((path, index) => ({
path,
callId: CallId(`produced-files-${String(index)}`),
args: JSON.stringify({ file_path: path, content: `content of ${path}\n` }),
}))
session.append('assistant/message', {
turn: 1,
step: 1,
message: createAssistantMessage({
content: calls.map(call => ({
type: 'tool-call' as const,
id: call.callId,
name: 'write',
arguments: call.args,
})),
source: { provider: 'deepseek-official', model: 'deepseek-v4-flash' },
}),
}, { surfaceOp: 'append' })
for (const call of calls) {
const source = session.append('tool/call', {
turn: 1, step: 1, callId: call.callId, name: 'write', arguments: call.args,
})
session.append('tool/result', {
turn: 1,
step: 1,
message: createToolResultMessage({
callId: call.callId,
content: [{ type: 'text', text: `Created ${call.path}` }],
isError: false,
}),
}, { surfaceOp: 'append', sourceEventSeqs: [source.seq] })
}
session.append('step/start', { turn: 1, step: 2 })
session.append('assistant/message', {
turn: 1,
step: 2,
message: createAssistantMessage({
content: [{ type: 'text', text: `Created the site.\n\n${DONE}` }],
source: { provider: 'deepseek-official', model: 'deepseek-v4-flash' },
}),
}, { surfaceOp: 'append' })
session.append('step/end', { turn: 1, step: 2 })
session.append('turn/end', { turn: 1, reason: { kind: 'completed' } })
return [
JSON.stringify({
type: 'session', version: SESSION_FORMAT_VERSION, id: '{{sessionId}}',
createdAt: 0, cwd: '{{cwd}}',
}),
...session.events.map(event => JSON.stringify({
...event, time: eventTimeOrigin + event.seq * 1_000,
})),
'',
].join('\n')
}
describe('web e2e: a finished turn ends with the files it produced', () => {
let scaffold: WebScaffold
@@ -31,16 +110,13 @@ describe('web e2e: a finished turn ends with the files it produced', () => {
let tripwire: ReturnType<typeof watchConsole>
beforeAll(async () => {
scaffold = await launchWebScaffold({})
// The seeded Session's cwd is the scaffold workspace; the recording's own
// nested directory is created too, so its paths stay resolvable.
await mkdir(join(scaffold.workspaceCwd, 'workspace'), { recursive: true })
await writeFile(join(scaffold.workspaceCwd, PRODUCED), 'neutral\n')
const raw = await readFile(SEED, 'utf8')
expect(raw, 'borrowed recording must carry the write this scenario reads').toContain(PRODUCED)
await seedSession(scaffold, raw, SEED_ID)
scaffold = await launchWebScaffold({ extraOverlayPath: OVERLAY })
await seedSession(scaffold, producedFixture(), SEED_ID)
browser = await chromium.launch()
page = await newEnglishPage(browser)
// Keep the responsive sidebar available while selecting the cold seed;
// the assertion itself narrows the conversation after navigation.
await page.setViewportSize({ width: 1280, height: 900 })
tripwire = watchConsole(page)
await page.goto(scaffold.baseUrl, { waitUntil: 'load' })
await page.waitForSelector('[class*="frame"]', { timeout: 30_000 })
@@ -51,24 +127,52 @@ describe('web e2e: a finished turn ends with the files it produced', () => {
await scaffold?.close()
})
it.skipIf(MODE === 'record')('lists the written file under the closing message, as an opener', async () => {
it.skipIf(MODE === 'record')('keeps a narrow ten-file summary on one line with +8 and a folder action', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-produced-files'))
const groupRow = page.locator('[role="treeitem"]').first()
await groupRow.waitFor({ timeout: 15_000 })
await groupRow.click()
if (await groupRow.getAttribute('aria-expanded') !== 'true') await groupRow.click()
const sessionRow = page.locator('[role="treeitem"]').nth(1)
await sessionRow.waitFor({ timeout: 10_000 })
await sessionRow.click()
// The row the turn ends with — derived from the write call's locations,
// not from whatever the closing message happened to say.
const chip = page.getByRole('button', { name: `Open ${PRODUCED}`, exact: true }).first()
await chip.waitFor({ timeout: 15_000 })
expect(await chip.innerText()).toBe(PRODUCED)
// The full path stays reachable for a reader who wants to copy it.
expect(await chip.getAttribute('title')).toContain(PRODUCED)
// A turn's produced files are labelled, not left as bare chips.
expect(await page.getByText('Produced', { exact: true }).count()).toBeGreaterThan(0)
await expect.poll(() => page.getByText(DONE, { exact: true }).count(), { timeout: 15_000 }).toBe(1)
await page.setViewportSize({ width: 780, height: 900 })
const row = page.locator('[data-produced-files-row]')
await row.waitFor({ timeout: 15_000 })
const chips = row.getByRole('button')
await expect.poll(() => chips.count()).toBe(2)
expect(await chips.nth(0).innerText()).toBe('关于我.md')
expect(await chips.nth(1).innerText()).toBe('index.html')
expect(await row.getByText('+ 8 files', { exact: true }).count()).toBe(1)
const showFolder = page.getByRole('button', { name: 'Show in folder', exact: true })
expect(await showFolder.count()).toBe(1)
expect(await page.getByText('Produced', { exact: true }).count()).toBe(1)
const openPath = vi.spyOn(scaffold.ctx.apiProxy.host, 'openPath')
.mockImplementation(async (request, _signal) => ({
rpcId: request.rpcId,
result: { ok: true, value: { opened: true as const } },
}))
try {
const [response] = await Promise.all([
page.waitForResponse(response => new URL(response.url()).pathname === '/api/host.openPath'),
showFolder.click({ clickCount: 1 }),
])
expect(response.status()).toBe(200)
expect(openPath).toHaveBeenCalledTimes(1)
expect(openPath.mock.calls[0]![0].payload).toEqual({ path: `${scaffold.workspaceCwd}/.` })
} finally {
openPath.mockRestore()
}
const tops = await row.locator(':scope > *').evaluateAll(elements =>
elements.map(element => element.getBoundingClientRect().top))
expect(new Set(tops.map(top => Math.round(top))).size).toBe(1)
const geometry = await row.evaluate(element => ({
clientWidth: element.clientWidth, scrollWidth: element.scrollWidth,
}))
expect(geometry.scrollWidth).toBeLessThanOrEqual(geometry.clientWidth)
expect(tripwire.pageErrors).toEqual([])
expect(tripwire.warnings).toEqual([])

View File

@@ -0,0 +1,6 @@
# The summary test asserts the native-folder action without launching it. Pin
# the capability so headless Linux CI and desktop developer hosts expose the
# same UI branch; platform opener behavior belongs to the Host unit tests.
- id: api-gateway
config:
nativeOpen: true

View File

@@ -0,0 +1,546 @@
/** Keyless assembled-Web evidence for conversational Schedule delivery. */
import { join } from 'node:path'
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 type { AgentHandle } from '@deepseek-ai/dsh-agent'
import { CallId, createUserMessage, LlmAdapter } from '@deepseek-ai/dsh-llm'
import type { GenerateOptions, StreamChunk } from '@deepseek-ai/dsh-llm'
import { SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
import { conversationContextKey } from '@deepseek-ai/dsh-client-runtime/client'
import {
ScheduleId,
createEveryScheduleRecord,
foldScheduleEvents,
resolveEveryOccurrence,
type EveryScheduleRecord,
} from '@deepseek-ai/dsh-tool-schedule'
import {
assertFixtureInventory,
captureStableAria,
compareOrRefreshGolden,
launchWebScaffold,
watchConsole,
webSnapshotMode,
type WebScaffold,
} from './scaffold.ts'
import { connectFreshWorkspace, saveFailureShot } from './support.ts'
const MODE = webSnapshotMode()
const OVERLAY = fileURLToPath(new URL('../../../examples/web-schedule/cordis.yml', import.meta.url))
const SNAPSHOT_DIR = fileURLToPath(new URL('./snapshots/schedule-after', import.meta.url))
const AFTER_EXPECTED = join(SNAPSHOT_DIR, 'conversation.expected.md')
const AT_EXPECTED = join(SNAPSHOT_DIR, 'at-conversation.expected.md')
const EVERY_EXPECTED = join(SNAPSHOT_DIR, 'every-conversation.expected.md')
const AFTER_PROVIDER = 'schedule-after-web-test'
const AT_PROVIDER = 'schedule-at-web-test'
const EVERY_PROVIDER = 'schedule-every-web-test'
const MODEL = 'reply'
const AFTER_PROMPT = 'Check the deployment log'
const AFTER_REPLY = 'Reminder: Check the deployment log.'
const AT_BROWSER_ZONE = 'Asia/Shanghai'
const AT_USER_PROMPT = 'Remind me to review the release window in a few seconds in my local time.'
const AT_PROMPT = 'Review the release window'
const AT_READY = 'Ready for a browser-local reminder request.'
const AT_ACK = 'Scheduled in your browser time zone.'
const AT_REPLY = 'Reminder: Review the release window.'
const EVERY_PROMPTS = ['Check primary metrics', 'Check secondary metrics'] as const
const EVERY_REPLY = 'Reminders: Check primary metrics; Check secondary metrics.'
const EVERY_INTERVAL_SECONDS = 60 * 60
const EVERY_FIXTURE_AGE_MS = 90 * 60 * 1_000
/** Emit one complete assistant text response. */
function textResponse(text: string): StreamChunk[] {
return [
{ type: 'block-start', index: 0, blockType: 'text' },
{ type: 'block-end', index: 0, block: { type: 'text', text } },
{ type: 'finish', reason: { kind: 'stop' } },
]
}
/** Deterministic model seam that turns one due reminder into ordinary assistant prose. */
class ReminderAdapter extends LlmAdapter {
readonly requests: GenerateOptions[] = []
override async * stream(options: GenerateOptions): AsyncIterable<StreamChunk> {
this.requests.push(options)
yield * textResponse(AFTER_REPLY)
}
}
/** Deterministic model seam for one multi-record fixed-rate batch. */
class EveryReminderAdapter extends LlmAdapter {
readonly requests: GenerateOptions[] = []
override async * stream(options: GenerateOptions): AsyncIterable<StreamChunk> {
this.requests.push(options)
yield * textResponse(EVERY_REPLY)
}
}
interface LocalAt {
readonly date: string
readonly time: string
readonly time_zone: string
}
/** Render one future epoch as exact local calendar fields in an explicit zone. */
function localAt(epoch: number, timeZone: string): LocalAt {
const parts = Object.fromEntries(new Intl.DateTimeFormat('en-CA', {
timeZone,
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hourCycle: 'h23',
}).formatToParts(epoch).map(part => [part.type, part.value])) as Record<string, string>
return {
date: `${parts['year']}-${parts['month']}-${parts['day']}`,
time: `${parts['hour']}:${parts['minute']}:${parts['second']}`,
time_zone: timeZone,
}
}
/** Dynamic model seam proving request-local browser context becomes an explicit At selector. */
class BrowserZoneAtAdapter extends LlmAdapter {
readonly requests: GenerateOptions[] = []
selectedAt: LocalAt | undefined
scheduledAt: string | undefined
override async * stream(options: GenerateOptions): AsyncIterable<StreamChunk> {
this.requests.push(options)
if (this.requests.length === 1) {
yield * textResponse(AT_READY)
return
}
if (this.requests.length === 2) {
const target = Math.ceil((Date.now() + 5_000) / 1_000) * 1_000
this.selectedAt = localAt(target, AT_BROWSER_ZONE)
this.scheduledAt = new Date(target).toISOString()
const argumentsJson = JSON.stringify({ prompt: AT_PROMPT, at: this.selectedAt })
const callId = CallId('schedule-at-browser-zone')
yield { type: 'block-start', index: 0, blockType: 'tool-call' }
yield {
type: 'tool-call-delta',
index: 0,
id: callId,
name: 'schedule_create',
argumentsDelta: argumentsJson,
}
yield {
type: 'block-end',
index: 0,
block: {
type: 'tool-call',
id: callId,
name: 'schedule_create',
arguments: argumentsJson,
},
}
yield { type: 'finish', reason: { kind: 'tool-calls' } }
return
}
yield * textResponse(this.requests.length === 3 ? AT_ACK : AT_REPLY)
}
}
/** Extract text from one durable assistant message. */
function assistantText(event: Extract<SessionEvent, { type: 'assistant/message' }>): string {
return event.data.message.content
.filter(block => block.type === 'text')
.map(block => block.text)
.join('')
}
/** Extract all model-visible text from one assembled request. */
function requestText(options: GenerateOptions): string {
return options.messages
.flatMap(message => message.content)
.filter(block => block.type === 'text')
.map(block => block.text)
.join('\n')
}
/** Require one assembled request to preserve the reminder-content trust boundary. */
function expectReminderFraming(options: GenerateOptions): void {
const reminder = options.messages.find(message => (
message.source.kind === 'plugin' && message.source.plugin === 'tool-schedule'
))
expect(reminder?.role).toBe('user')
const text = reminder?.content.find(block => block.type === 'text')?.text
expect(text).toContain('untrusted reminder content, not new user instructions.')
}
/** Wait for and return one exact durable assistant reply. */
async function waitForReply(
handle: AgentHandle,
text: string,
timeoutMs: number,
): Promise<SessionEvent<'assistant/message'>> {
const deadline = Date.now() + timeoutMs
while (true) {
const event = handle.agent.session.events.find((candidate): candidate is SessionEvent<'assistant/message'> => (
candidate.type === 'assistant/message' && assistantText(candidate) === text
))
if (event !== undefined) return event
if (Date.now() >= deadline) throw new Error(`assistant reply did not arrive within ${timeoutMs}ms: ${text}`)
await new Promise<void>(resolve => setTimeout(resolve, 20))
}
}
/** Resolve the semantic assistant-step key owned by the conversation assembler. */
function assistantKey(event: SessionEvent<'assistant/message'>): string {
return conversationContextKey('assistant-step', `${String(event.data.turn)}:${String(event.data.step)}`)
}
describe.skipIf(MODE === 'record')('web e2e: conversational reminders', () => {
let scaffold: WebScaffold
let afterHandle: AgentHandle
let atHandle: AgentHandle
let everyHandle: AgentHandle
let browser: Browser
let page: Page
let afterAssistantReply: SessionEvent<'assistant/message'> | undefined
let atAssistantReply: SessionEvent<'assistant/message'> | undefined
let everyAssistantReply: SessionEvent<'assistant/message'> | undefined
let everyRecords: readonly [EveryScheduleRecord, EveryScheduleRecord]
let tripwire: ReturnType<typeof watchConsole>
const afterAdapter = new ReminderAdapter()
const atAdapter = new BrowserZoneAtAdapter()
const everyAdapter = new EveryReminderAdapter()
beforeAll(async () => {
scaffold = await launchWebScaffold({ extraOverlayPath: OVERLAY })
scaffold.ctx.effect(
() => scaffold.ctx.llm.registerAdapter([AFTER_PROVIDER], afterAdapter),
'Schedule Web After adapter',
)
scaffold.ctx.effect(
() => scaffold.ctx.llm.registerAdapter([AT_PROVIDER], atAdapter),
'Schedule Web At adapter',
)
scaffold.ctx.effect(
() => scaffold.ctx.llm.registerAdapter([EVERY_PROVIDER], everyAdapter),
'Schedule Web Every adapter',
)
browser = await chromium.launch()
page = await browser.newPage({
viewport: { width: 1680, height: 1000 },
locale: 'en-US',
timezoneId: AT_BROWSER_ZONE,
})
await page.addInitScript(() => { localStorage.setItem('dsh.locale', 'en') })
tripwire = watchConsole(page)
await page.goto(scaffold.baseUrl, { waitUntil: 'load' })
await page.waitForSelector('[class*="frame"]', { timeout: 30_000 })
await connectFreshWorkspace(page, scaffold.workspaceCwd)
expect(await page.evaluate(() => Intl.DateTimeFormat().resolvedOptions().timeZone))
.toBe(AT_BROWSER_ZONE)
const cwd = join(scaffold.workspaceCwd, 'workspace')
const workspace = await scaffold.ctx.workspace.resolveByPath(cwd)
if (workspace === undefined) throw new Error('connected Web workspace was not registered')
afterHandle = await scaffold.ctx.agents.create({
sessionId: SessionId('schedule-after-web-e2e'),
meta: { cwd },
agentOptions: { provider: AFTER_PROVIDER, model: MODEL },
})
afterHandle.agent.session.append('session/title', {
title: 'Scheduled After follow-up',
messageSeqs: [],
source: { kind: 'user' },
})
await workspace.attachSession(afterHandle.agent.id)
const afterCreated = await scaffold.ctx.tools.execute({
signal: AbortSignal.timeout(10_000),
callId: CallId('schedule-after-create'),
name: 'schedule_create',
arguments: { prompt: AFTER_PROMPT, after_seconds: 1 },
agent: afterHandle.agent,
})
if (afterCreated.isError) {
throw new Error(`Schedule After create failed: ${JSON.stringify(afterCreated.value)}`)
}
expect(afterCreated.value).toMatchObject({
id: 'schedule-1',
kind: 'after',
prompt: AFTER_PROMPT,
afterSeconds: 1,
state: 'scheduled',
deliveryMode: 'session-local',
})
afterAssistantReply = await waitForReply(afterHandle, AFTER_REPLY, 15_000)
await afterHandle.agent.whenIdle()
await expect(scaffold.ctx.sessions.flush(afterHandle.agent.session)).resolves.toBe(true)
everyHandle = await scaffold.ctx.agents.create({
sessionId: SessionId('schedule-every-web-e2e'),
meta: { cwd },
agentOptions: { provider: EVERY_PROVIDER, model: MODEL },
})
everyHandle.agent.session.append('session/title', {
title: 'Fixed-rate reminder batch',
messageSeqs: [],
source: { kind: 'user' },
})
const seededAt = Date.now()
everyRecords = [
createEveryScheduleRecord(
ScheduleId('schedule-every-primary'),
EVERY_PROMPTS[0],
EVERY_INTERVAL_SECONDS,
seededAt - EVERY_FIXTURE_AGE_MS,
),
createEveryScheduleRecord(
ScheduleId('schedule-every-secondary'),
EVERY_PROMPTS[1],
EVERY_INTERVAL_SECONDS,
seededAt - EVERY_FIXTURE_AGE_MS,
),
]
for (const record of everyRecords) {
everyHandle.agent.session.append('schedule/change', {
version: 1,
operation: 'create',
schedule: record,
})
}
await expect(scaffold.ctx.sessions.flush(everyHandle.agent.session)).resolves.toBe(true)
await workspace.attachSession(everyHandle.agent.id)
const everyListed = await scaffold.ctx.tools.execute({
signal: AbortSignal.timeout(10_000),
callId: CallId('schedule-every-list'),
name: 'schedule_list',
arguments: {},
agent: everyHandle.agent,
})
expect(everyListed.isError).toBe(false)
everyAssistantReply = await waitForReply(everyHandle, EVERY_REPLY, 15_000)
await everyHandle.agent.whenIdle()
await expect(scaffold.ctx.sessions.flush(everyHandle.agent.session)).resolves.toBe(true)
atHandle = await scaffold.ctx.agents.create({
sessionId: SessionId('schedule-at-web-e2e'),
meta: { cwd },
agentOptions: { provider: AT_PROVIDER, model: MODEL },
})
atHandle.agent.session.append('session/title', {
title: 'Explicit local-time reminder',
messageSeqs: [],
source: { kind: 'user' },
})
atHandle.agent.followup(createUserMessage({
content: [{ type: 'text', text: 'Prepare the reminder test session.' }],
source: { kind: 'plugin', plugin: 'schedule-web-e2e' },
}))
await atHandle.agent.whenIdle()
expect(atAdapter.requests).toHaveLength(1)
await expect(scaffold.ctx.sessions.flush(atHandle.agent.session)).resolves.toBe(true)
await workspace.attachSession(atHandle.agent.id)
await page.reload({ waitUntil: 'load' })
await page.waitForSelector('[class*="frame"]', { timeout: 30_000 })
const workspaceItem = page.locator('[role="treeitem"]').first()
await workspaceItem.waitFor({ timeout: 15_000 })
const expansionDeadline = Date.now() + 5_000
while (await workspaceItem.getAttribute('aria-expanded') !== 'true') {
if (Date.now() >= expansionDeadline) throw new Error('workspace item did not expand')
if (await workspaceItem.getAttribute('aria-expanded') !== 'true') {
await workspaceItem.click()
}
await new Promise<void>(resolve => setTimeout(resolve, 50))
}
const atSession = page.getByRole('treeitem', { name: /Explicit local-time reminder/ })
await atSession.waitFor({ timeout: 15_000 })
await atSession.click()
const composer = page.locator('textarea:enabled').last()
await composer.fill(AT_USER_PROMPT)
const settled = scaffold.whenTurnSettled(60_000)
await page.getByRole('button', { name: 'Send message', exact: true }).click()
expect(await settled).toBe(atHandle.agent.id)
await page.getByText(AT_ACK, { exact: true }).waitFor({ timeout: 15_000 })
atAssistantReply = await waitForReply(atHandle, AT_REPLY, 20_000)
await atHandle.agent.whenIdle()
await expect(scaffold.ctx.sessions.flush(atHandle.agent.session)).resolves.toBe(true)
}, 120_000)
afterAll(async () => {
const failures: unknown[] = []
await browser?.close().catch((error: unknown) => failures.push(error))
await atHandle?.dispose().catch((error: unknown) => failures.push(error))
await everyHandle?.dispose().catch((error: unknown) => failures.push(error))
await afterHandle?.dispose().catch((error: unknown) => failures.push(error))
await scaffold?.close().catch((error: unknown) => failures.push(error))
if (failures.length === 1) throw failures[0]
if (failures.length > 1) throw new AggregateError(failures, 'Schedule Web evidence teardown failed')
})
it('renders After as an ordinary assistant follow-up', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-schedule-after'))
const reminderRequest = afterAdapter.requests[0]
if (reminderRequest === undefined) throw new Error('model did not receive the After reminder')
expectReminderFraming(reminderRequest)
const session = page.getByRole('treeitem', { name: /Scheduled After follow-up/ })
await session.click()
if (afterAssistantReply === undefined) throw new Error('After assistant reply was not captured')
const selector = `[data-chat-anchor-key="${assistantKey(afterAssistantReply)}"]`
const row = page.locator(selector)
await row.waitFor({ timeout: 15_000 })
expect(await row.getAttribute('data-chat-flow-kind')).toBe('assistant-step')
expect(await row.textContent()).toContain(AFTER_REPLY)
await compareOrRefreshGolden(
AFTER_EXPECTED,
await captureStableAria(page, selector, scaffold.workspaceCwd),
MODE,
)
expect(await page.locator('[data-schedule-reminder]').count()).toBe(0)
}, 60_000)
it('batches one latest occurrence per overdue Every record into an ordinary follow-up', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-schedule-every'))
const ids = new Set(everyRecords.map(record => record.id))
const dispatches = everyHandle.agent.session.events.filter(event => (
event.type === 'schedule/change'
&& event.data.operation === 'dispatch'
&& ids.has(event.data.id)
))
expect(dispatches).toHaveLength(2)
const acceptedAt = dispatches.map((event) => {
if (event.type !== 'schedule/change' || event.data.operation !== 'dispatch'
|| !('acceptedAt' in event.data)) throw new Error('expected Every dispatch')
return event.data.acceptedAt
})
expect(new Set(acceptedAt).size).toBe(1)
const decision = acceptedAt[0]
if (decision === undefined) throw new Error('missing Every decision time')
const batch = everyHandle.agent.session.events.find(event => (
event.type === 'user/message'
&& event.data.source.kind === 'plugin'
&& event.data.source.plugin === 'tool-schedule'
&& event.data.content.some(block => block.type === 'text'
&& block.text.startsWith('[SCHEDULE REMINDER BATCH]'))
))
if (batch?.type !== 'user/message') throw new Error('missing Every batch message')
const batchBlock = batch.data.content.find(block => block.type === 'text')
if (batchBlock?.type !== 'text') throw new Error('missing Every batch text')
for (const record of everyRecords) {
const occurrenceAt = resolveEveryOccurrence(record, Date.parse(decision)).occurrenceAt
expect(batchBlock.text).toContain(JSON.stringify({
schedule_id: record.id,
occurrence_at: occurrenceAt,
reminder_prompt: record.prompt,
}).slice(1, -1))
}
expect(everyAdapter.requests).toHaveLength(1)
const reminderRequest = everyAdapter.requests[0]
if (reminderRequest === undefined) throw new Error('model did not receive the Every batch')
expect(requestText(reminderRequest)).toContain(batchBlock.text)
expectReminderFraming(reminderRequest)
const active = foldScheduleEvents(everyHandle.agent.session.events).active
expect(active).toHaveLength(2)
expect(active.every(record => Date.parse(record.scheduledAt) > Date.parse(decision))).toBe(true)
const session = page.getByRole('treeitem', { name: /Fixed-rate reminder batch/ })
await session.click()
if (everyAssistantReply === undefined) throw new Error('Every assistant reply was not captured')
const selector = `[data-chat-anchor-key="${assistantKey(everyAssistantReply)}"]`
const row = page.locator(selector)
await row.waitFor({ timeout: 15_000 })
expect(await row.getAttribute('data-chat-flow-kind')).toBe('assistant-step')
expect(await row.textContent()).toContain(EVERY_REPLY)
await compareOrRefreshGolden(
EVERY_EXPECTED,
await captureStableAria(page, selector, scaffold.workspaceCwd),
MODE,
)
expect(await page.locator('[data-schedule-reminder]').count()).toBe(0)
}, 60_000)
it('uses request-local browser context to create an explicit local At reminder', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-schedule-at'))
const user = atHandle.agent.session.events.find(event => (
event.type === 'user/message'
&& event.data.source.kind === 'user'
&& event.data.content.some(block => block.type === 'text' && block.text === AT_USER_PROMPT)
))
if (user?.type !== 'user/message' || user.data.source.kind !== 'user') {
throw new Error('missing browser user-rpc message')
}
expect(user.data.source).toMatchObject({ kind: 'user', clientTimeZone: AT_BROWSER_ZONE })
expect(typeof (user.data.source as { rpcId?: unknown }).rpcId).toBe('string')
const firstRequest = atAdapter.requests[1]
if (firstRequest === undefined) throw new Error('model did not receive the browser prompt')
expect(requestText(firstRequest)).toContain(
`Browser time zone for this request: ${AT_BROWSER_ZONE}. `
+ 'Interpret otherwise-unqualified dates and times in this zone.',
)
expect(firstRequest.tools?.some(tool => tool.name === 'schedule_create')).toBe(true)
const selectedAt = atAdapter.selectedAt
const scheduledAt = atAdapter.scheduledAt
if (selectedAt === undefined || scheduledAt === undefined) {
throw new Error('model did not choose an explicit local At target')
}
expect(selectedAt.time_zone).toBe(AT_BROWSER_ZONE)
const toolCall = atHandle.agent.session.events.find(event => (
event.type === 'tool/call' && event.data.name === 'schedule_create'
))
if (toolCall?.type !== 'tool/call') throw new Error('missing schedule_create tool call')
expect(JSON.parse(toolCall.data.arguments)).toEqual({ prompt: AT_PROMPT, at: selectedAt })
const created = atHandle.agent.session.events.find(event => (
event.type === 'schedule/change'
&& event.data.operation === 'create'
&& event.data.schedule.kind === 'at'
))
if (created?.type !== 'schedule/change' || created.data.operation !== 'create') {
throw new Error('explicit local At call did not create a durable record')
}
const schedule = created.data.schedule
expect(schedule).toMatchObject({
kind: 'at',
prompt: AT_PROMPT,
scheduledAt,
})
expect(atHandle.agent.session.events.filter(event => (
event.type === 'schedule/change'
&& event.data.operation === 'dispatch'
&& event.data.id === schedule.id
))).toHaveLength(1)
expect(atAdapter.requests).toHaveLength(4)
const reminderRequest = atAdapter.requests[3]
if (reminderRequest === undefined) throw new Error('model did not receive the At reminder')
expectReminderFraming(reminderRequest)
const session = page.getByRole('treeitem', { name: /Explicit local-time reminder/ })
await session.click()
if (atAssistantReply === undefined) throw new Error('At assistant reply was not captured')
const selector = `[data-chat-anchor-key="${assistantKey(atAssistantReply)}"]`
const row = page.locator(selector)
await row.waitFor({ timeout: 15_000 })
expect(await row.getAttribute('data-chat-flow-kind')).toBe('assistant-step')
expect(await row.textContent()).toContain(AT_REPLY)
await compareOrRefreshGolden(
AT_EXPECTED,
await captureStableAria(page, selector, scaffold.workspaceCwd),
MODE,
)
expect(await page.locator('[data-schedule-reminder]').count()).toBe(0)
expect(tripwire.pageErrors).toEqual([])
expect(tripwire.warnings).toEqual([])
}, 60_000)
it('keeps the fixture inventory closed', async () => {
await assertFixtureInventory(SNAPSHOT_DIR, [
'at-conversation.expected.md',
'conversation.expected.md',
'every-conversation.expected.md',
])
})
})

View File

@@ -10,6 +10,9 @@
- button "Agent 预设":
- img
- text: Agent 预设
- button "插件配置":
- img
- text: 插件配置
- button "打开配置文件"
- button "关闭":
- img

View File

@@ -10,6 +10,9 @@
- button "Agent 预设":
- img
- text: Agent 预设
- button "插件配置":
- img
- text: 插件配置
- button "打开配置文件"
- button "关闭":
- img

View File

@@ -10,6 +10,9 @@
- button "Agent 预设":
- img
- text: Agent 预设
- button "插件配置":
- img
- text: 插件配置
- button "打开配置文件"
- button "关闭":
- img

View File

@@ -10,6 +10,9 @@
- button "Agent 预设":
- img
- text: Agent 预设
- button "插件配置":
- img
- text: 插件配置
- button "打开配置文件"
- button "关闭":
- img

View File

@@ -10,6 +10,9 @@
- button "Agent 预设":
- img
- text: Agent 预设
- button "插件配置":
- img
- text: 插件配置
- button "打开配置文件"
- button "关闭":
- img

View File

@@ -10,6 +10,9 @@
- button "Agent 预设":
- img
- text: Agent 预设
- button "插件配置":
- img
- text: 插件配置
- button "打开配置文件"
- button "关闭":
- img

View File

@@ -10,6 +10,9 @@
- button "Agent 预设":
- img
- text: Agent 预设
- button "插件配置":
- img
- text: 插件配置
- button "打开配置文件"
- button "关闭":
- img

View File

@@ -10,6 +10,9 @@
- button "Agent 预设":
- img
- text: Agent 预设
- button "插件配置":
- img
- text: 插件配置
- button "打开配置文件"
- button "关闭":
- img

View File

@@ -0,0 +1,34 @@
- dialog "设置":
- navigation:
- text: 设置
- button "通用设置":
- img
- text: 通用设置
- button "模型":
- img
- text: 模型
- button "Agent 预设":
- img
- text: Agent 预设
- button "插件配置":
- img
- text: 插件配置
- button "打开配置文件"
- button "关闭":
- img
- text: 关闭
- heading "插件配置" [level=2]
- paragraph: 配置本部署已安装的插件。
- list:
- listitem:
- 'button "展开设置: 终端"':
- text: 终端 限制 agent 运行的每一条命令。
- img
- listitem:
- 'button "展开设置: Agent 循环"':
- text: Agent 循环 Agent 如何派发工具调用。
- img
- listitem:
- 'button "展开设置: 网页搜索"':
- text: 网页搜索 DeepSeek 搜索提供方。
- img

View File

@@ -0,0 +1 @@
- paragraph: "Reminder: Review the release window."

View File

@@ -0,0 +1 @@
- paragraph: "Reminder: Check the deployment log."

View File

@@ -0,0 +1 @@
- paragraph: "Reminders: Check primary metrics; Check secondary metrics."

View File

@@ -10,6 +10,9 @@
- button "Agent 预设":
- img
- text: Agent 预设
- button "插件配置":
- img
- text: 插件配置
- button "打开配置文件"
- button "关闭":
- img

View File

@@ -13,7 +13,6 @@
- img
- img
- text: Context injection @deepseek-ai/dsh-system-prompt
- text: Running
- button "Think The user wants me to ask them a checkpoint question first, then continue with whatever they interject. Let me do exactly that.":
- img
- img

View File

@@ -354,10 +354,10 @@ describe('web e2e: empty-draft Cmd+Enter steers the whole queue', () => {
{ timeout: 10_000 },
).toBe(2)
expect(await page.locator('[data-queue-dock]').count()).toBe(0)
// The reasoning row streams independently of the steering handoff; wait
// for it so the mid snapshot pins the assistant step, not the pre-render
// gap a fast machine can catch between steering acceptance and the block.
await page.locator('[data-variant="think"]').first().waitFor({ timeout: 10_000 })
// The reasoning row streams independently of the steering handoff. Wait
// for the block to settle so the mid snapshot does not race its transient
// visually-hidden Running label while the question keeps the turn open.
await page.locator('[data-variant="think"][data-state="ok"]').first().waitFor({ timeout: 10_000 })
const mid = await captureStableAria(page, '[class*="centerCol"]', scaffold.workspaceCwd)
await compareOrRefreshGolden(STEER_ALL_MID, mid, MODE)