mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-10-26 16:55:08 +00:00
# Conflicts: # .agents/notes/implemented/feature/2026-08-08-web-background-job-display.i18n.yaml # docs/config-catalog.i18n.yaml # docs/event-producer-consumer.i18n.yaml # docs/module-graph.i18n.yaml # docs/subsystems/jobs.i18n.yaml # docs/subsystems/shell.i18n.yaml # docs/subsystems/shell.md # docs/subsystems/shell.zh.md # docs/tool-catalog.i18n.yaml # packages/api/session-controller/README.i18n.yaml # packages/context/tmux-context/tests/tmux-context.spec.ts # packages/e2b/e2b/tests/fixtures/composition/bin.ts # packages/extensions/tool-cordis/src/api-catalog.ts # packages/shell/bash-local/README.i18n.yaml # packages/shell/bash-local/README.md # packages/shell/bash-local/README.zh.md # packages/shell/bash-local/src/index.ts # packages/shell/bash-local/tests/executor.spec.ts # packages/shell/bash-sandbox/README.i18n.yaml # packages/shell/bash-sandbox/README.md # packages/shell/bash-sandbox/README.zh.md # packages/shell/bash-sandbox/src/index.ts # packages/shell/bash-sandbox/tests/bwrap.e2e.ts # packages/shell/bash-sandbox/tests/landlock.e2e.ts # packages/shell/bash-sandbox/tests/partial-landlock.spec.ts # packages/shell/bash-sandbox/tests/sandbox.spec.ts # packages/shell/bash-sandbox/tests/seatbelt.e2e.ts # packages/shell/pwsh-local/README.i18n.yaml # packages/shell/pwsh-local/README.md # packages/shell/pwsh-local/README.zh.md # packages/shell/pwsh-local/src/index.ts # packages/shell/pwsh-local/tests/executor.spec.ts # packages/shell/pwsh-sandbox/README.i18n.yaml # packages/shell/pwsh-sandbox/README.md # packages/shell/pwsh-sandbox/README.zh.md # packages/shell/pwsh-sandbox/src/index.ts # packages/shell/pwsh-sandbox/tests/sandbox.spec.ts # packages/shell/shell/README.i18n.yaml # packages/shell/shell/README.md # packages/shell/shell/README.zh.md # packages/shell/shell/src/index.ts # packages/shell/shell/tests/service.spec.ts # packages/shell/tool-bash/README.i18n.yaml # packages/shell/tool-bash/src/index.ts # packages/shell/tool-bash/tests/tools.spec.ts # packages/shell/tool-pwsh/README.i18n.yaml # packages/shell/tool-pwsh/src/index.ts # packages/shell/tool-pwsh/tests/background.spec.ts # packages/shell/tool-pwsh/tests/tools.spec.ts # packages/workflow/tool-workflow/README.i18n.yaml # packages/workflow/tool-workflow/package.json # packages/workflow/tool-workflow/tests/tool-workflow.spec.ts # snapshots/session/ptc-python-turn/system-prompt.expected.md
68 lines
3.3 KiB
TypeScript
68 lines
3.3 KiB
TypeScript
import { Context } from '@deepseek-ai/cordis'
|
|
import { LocalSpillStore } from '@deepseek-ai/dsh-spill-local'
|
|
import { LocalFileSystem } from '@deepseek-ai/dsh-fs-local'
|
|
import LocalSubprocessRuntime from '@deepseek-ai/dsh-subprocess-local'
|
|
import { LocalBashExecutor } from '@deepseek-ai/dsh-bash-local'
|
|
import { SessionId } from '@deepseek-ai/dsh-session'
|
|
import { ToolCallId } from '@deepseek-ai/dsh-llm'
|
|
import { mkdtemp, rm } from 'node:fs/promises'
|
|
import { tmpdir } from 'node:os'
|
|
import { join, resolve } from 'node:path'
|
|
import { expect, it } from 'vitest'
|
|
import * as locators from './snapshot-spill-locators.ts'
|
|
import * as commands from '../snapshots/session/session-query-spill/resolve-spill-command.mjs'
|
|
|
|
it.skipIf(process.platform === 'win32')('resolves the exact spill verifier, retains real failures, and restores the shell', async () => {
|
|
const root = await mkdtemp(join(tmpdir(), "query-spill-'quoted-"))
|
|
const ctx = new Context()
|
|
const disposers: (() => Promise<void>)[] = []
|
|
try {
|
|
for (const fiber of [
|
|
ctx.plugin(LocalSpillStore, { root, cleanupPeriodDays: 0 }),
|
|
ctx.plugin(LocalFileSystem, { cwd: root }),
|
|
ctx.plugin(LocalSubprocessRuntime),
|
|
ctx.plugin(LocalBashExecutor),
|
|
]) {
|
|
disposers.push(() => fiber.dispose())
|
|
await fiber
|
|
}
|
|
const logical = resolve('/tmp/dsh-acp-snap-query-verifier')
|
|
const mapping = ctx.plugin(locators, { root, locatorRoot: logical })
|
|
disposers.push(() => mapping.dispose())
|
|
await mapping
|
|
const saved = await ctx.spillStore.saveText({
|
|
owner: { sessionId: SessionId('query-verifier') },
|
|
source: { kind: 'tool', toolName: 'session_event_read', callId: ToolCallId('query'), label: 'result' },
|
|
suggestedName: 'session_event_read.txt', content: 'request/header session_event_search',
|
|
})
|
|
const adapter = ctx.plugin(commands)
|
|
disposers.push(() => adapter.dispose())
|
|
await adapter
|
|
const command = 'file="' + saved.locator + '"' + "; grep -Fq request/header \"$file\" && grep -Fq session_event_search \"$file\" && printf 'SPILL_CANONICAL_OK\\n'"
|
|
const spec = ctx.shell.resolve({ command })
|
|
const output = await (await ctx.shell.execute(spec)).result()
|
|
expect(output.timedOut).toBe(false)
|
|
expect(output.exitCode).toBe(0)
|
|
expect(output.stdout.text).toBe('SPILL_CANONICAL_OK\n')
|
|
expect(spec.command).toBe(command)
|
|
const other = await (await ctx.shell.execute(ctx.shell.resolve({ command: 'printf ordinary; exit 7' }))).result()
|
|
expect(other.exitCode).toBe(7)
|
|
expect(other.stdout.text).toBe('ordinary')
|
|
const unmatched = await (await ctx.shell.execute(ctx.shell.resolve({ command: command + '; exit 9' }))).result()
|
|
expect(unmatched.exitCode).toBe(9)
|
|
expect(unmatched.stderr.text).toContain('No such file')
|
|
const physical = ctx.fs.processPath(await ctx.fs.resolve(saved.locator))
|
|
await rm(physical)
|
|
const missing = await (await ctx.shell.execute(spec)).result()
|
|
expect(missing.exitCode).not.toBe(0)
|
|
expect(missing.stdout.text).toBe('')
|
|
await adapter.dispose()
|
|
const restored = await (await ctx.shell.execute(spec)).result()
|
|
expect(restored.exitCode).not.toBe(0)
|
|
expect(restored.stderr.text).toContain(saved.locator)
|
|
} finally {
|
|
for (const dispose of disposers.reverse()) await dispose()
|
|
await rm(root, { recursive: true, force: true })
|
|
}
|
|
})
|