mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
# Conflicts: # .agents/notes/implemented/feature/2026-07-25-session-list-browsing-and-manual-order.i18n.yaml # .agents/notes/implemented/feature/2026-07-25-workspace-ui-product-flow.i18n.yaml # .agents/notes/implemented/feature/2026-07-25-workspace-ui-product-flow.zh.md # .agents/notes/implemented/simplification/2026-07-31-one-route-to-add-a-workspace.i18n.yaml # .agents/notes/implemented/simplification/2026-07-31-one-route-to-add-a-workspace.md # .agents/notes/implemented/simplification/2026-07-31-one-route-to-add-a-workspace.zh.md # apps/cli/reference/README.i18n.yaml # docs/config-catalog.md # packages/host/apiproxy/README.i18n.yaml # packages/host/apiproxy/README.md # packages/host/apiproxy/README.zh.md # packages/host/apiproxy/src/api-proxy.ts # packages/host/apiproxy/src/index.ts # packages/host/apiproxy/tests/api-proxy-approval.spec.ts # packages/host/apiproxy/tests/api-proxy-blank.spec.ts # packages/host/apiproxy/tests/api-proxy-cold.spec.ts # packages/host/apiproxy/tests/api-proxy-commands.spec.ts # packages/host/apiproxy/tests/api-proxy-config.spec.ts # packages/host/apiproxy/tests/api-proxy-models.spec.ts # packages/host/apiproxy/tests/api-proxy-projections.spec.ts # packages/host/apiproxy/tests/api-proxy-question.spec.ts # packages/host/apiproxy/tests/api-proxy-rename.spec.ts # packages/host/apiproxy/tests/api-proxy-search.spec.ts # packages/host/apiproxy/tests/api-proxy-subagents.spec.ts # packages/host/apiproxy/tests/api-proxy-view.spec.ts # packages/host/apiproxy/tests/api-proxy-workspace.spec.ts # packages/todo/tool-todo/tests/projection.spec.ts # scripts/hero-composer-dom-continuity.mjs
86 lines
3.7 KiB
TypeScript
86 lines
3.7 KiB
TypeScript
/**
|
|
* The summary blank bit means "conversation not started" (no turn has run),
|
|
* not "log empty": standalone plugin events — command lifecycle records,
|
|
* plan/mode, permission knob events, session titles — never flip it, so running /plan or /goal on a
|
|
* fresh session keeps it list-hidden and reusable, while the first accepted
|
|
* prompt's turn/start clears it. The host/session-added frame shares the
|
|
* same predicate function (covered by the workspace spec's frame assertion).
|
|
*/
|
|
|
|
import { describe, expect, it } from 'vitest'
|
|
import { Context } from 'cordis'
|
|
import AgentRegistry from '@deepseek-ai/dsh-agent'
|
|
import type { Agent } from '@deepseek-ai/dsh-agent'
|
|
import SessionStore from '@deepseek-ai/dsh-session'
|
|
import type { Session } from '@deepseek-ai/dsh-session'
|
|
import UserInteractionService from '@deepseek-ai/dsh-user-interaction'
|
|
import { CommandId } from '@deepseek-ai/dsh-commands/brand'
|
|
// Side-effect type imports: the knob-event SessionEventMap merges.
|
|
import type {} from '@deepseek-ai/dsh-permission'
|
|
import type {} from '@deepseek-ai/dsh-sandbox-policy'
|
|
import type {} from '@deepseek-ai/dsh-user-approval'
|
|
import type { ApiProxy, RpcRequest } from '@deepseek-ai/dsh-host-apiproxy/api'
|
|
import { RpcId } from '@deepseek-ai/dsh-host-apiproxy/api/rpc'
|
|
import { createApiProxy } from '@deepseek-ai/dsh-host-apiproxy'
|
|
|
|
let nextRpc = 1
|
|
function request<P>(payload: P): RpcRequest<P> {
|
|
return { rpcId: RpcId(`blank-${String(nextRpc++)}`), payload }
|
|
}
|
|
|
|
async function harness(): Promise<{ ctx: Context; api: ApiProxy; attach: (session: Session) => void }> {
|
|
const ctx = new Context()
|
|
await ctx.plugin(SessionStore)
|
|
await ctx.plugin(UserInteractionService)
|
|
await ctx.plugin(AgentRegistry)
|
|
return {
|
|
ctx,
|
|
api: createApiProxy(ctx, { defaultModelSelection: () => ({ provider: 'p', model: 'm' }), cwd: '/tmp' }),
|
|
attach: (session) => {
|
|
ctx.agents.register({ id: session.id, session, status: 'idle', ctx } as Agent)
|
|
},
|
|
}
|
|
}
|
|
|
|
/** Append the standalone (non-conversation) event family a fresh session can accumulate. */
|
|
function appendStandalone(session: Session): void {
|
|
session.append('command/run', {
|
|
commandId: CommandId('blank-cmd-1'), name: 'plan', args: '', source: { kind: 'user' },
|
|
})
|
|
session.append('plan/mode', { active: true })
|
|
session.append('command/done', { commandId: CommandId('blank-cmd-1'), kind: 'success', text: 'Plan mode on.' })
|
|
session.append('session/title', {
|
|
title: 'standalone title', messageSeqs: [], source: { kind: 'fallback' },
|
|
})
|
|
// The three permission knob events (a /permission switch on a fresh session).
|
|
session.append('permission/preset', { preset: 'danger-full-access' })
|
|
session.append('sandbox/mode', { mode: 'danger-full-access' })
|
|
session.append('approval/policy', { policy: 'never' })
|
|
}
|
|
|
|
async function listBlank(api: ApiProxy, id: string): Promise<boolean | undefined> {
|
|
const response = await api.sessions.list(request({}))
|
|
if (!response.result.ok) throw new Error('list failed')
|
|
return response.result.value.items.find(item => item.sessionId === id)?.blank
|
|
}
|
|
|
|
describe('summary blank = conversation not started', () => {
|
|
it('standalone events (command lifecycle, plan/mode, title) keep the session blank', async () => {
|
|
const { ctx, api, attach } = await harness()
|
|
const session = ctx.sessions.create()
|
|
attach(session)
|
|
expect(await listBlank(api, session.id)).toBe(true)
|
|
appendStandalone(session)
|
|
expect(await listBlank(api, session.id)).toBe(true)
|
|
})
|
|
|
|
it('the first turn clears blank', async () => {
|
|
const { ctx, api, attach } = await harness()
|
|
const session = ctx.sessions.create()
|
|
attach(session)
|
|
appendStandalone(session)
|
|
session.append('turn/start', { turn: 0 })
|
|
expect(await listBlank(api, session.id)).toBe(false)
|
|
})
|
|
})
|