shipped-composition.e2e.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Boots the shipped Web composition over the built dist this lane already uses
  2. // and asserts what that composition produces: the model-visible tool catalog
  3. // and the sandbox/approval knobs it ships with. No browser and no model call —
  4. // these are composition facts, and the browser scenarios in this lane cover the
  5. // surface itself.
  6. import { tmpdir } from 'node:os'
  7. import { afterEach, expect, it } from 'vitest'
  8. import { canonicalPath, writableRoots } from '@deepseek-ai/dsh-sandbox'
  9. import { SessionId } from '@deepseek-ai/dsh-session'
  10. // Empty type imports carry the tools/sandboxPolicy/approval Context merges.
  11. import type {} from '@deepseek-ai/dsh-tools'
  12. import type {} from '@deepseek-ai/dsh-sandbox-policy'
  13. import type {} from '@deepseek-ai/dsh-user-approval'
  14. import type {} from '@deepseek-ai/dsh-permission'
  15. import type {} from '@deepseek-ai/dsh-commands'
  16. import { launchWebScaffold, type WebScaffold } from './scaffold.ts'
  17. /**
  18. * The catalog the shipped Web composition puts in front of the model, minus the
  19. * ripgrep-dependent pair below. The absences are deliberate, not incidental
  20. * gaps: the `cordis_*` toolset executes model-written JavaScript that no
  21. * sandbox row confines, `web_fetch` chooses its own request target, and
  22. * `mcp_*` servers spawn outside `ctx.bash`. The composition Agent Note owns the
  23. * rationale and its sources.
  24. */
  25. const EXPECTED_TOOLS = [
  26. 'ask_user_question',
  27. 'bash',
  28. 'create_goal',
  29. 'edit',
  30. 'exit_plan_mode',
  31. 'get_goal',
  32. 'interrupt_agent',
  33. 'list_agents',
  34. 'ralph',
  35. 'read',
  36. 'send_message',
  37. 'skill',
  38. 'str_replace_editor',
  39. 'subagent',
  40. 'subagent_fork',
  41. 'task_kill',
  42. 'task_list',
  43. 'task_output',
  44. 'todo_write',
  45. 'update_goal',
  46. 'web_search',
  47. 'workflow',
  48. 'write',
  49. ]
  50. /**
  51. * `glob` and `grep` come from `dsh-tool-fs-search`, which spawns the PACKAGED
  52. * ripgrep binary (`@vscode/ripgrep`) through the subprocess seam, so the pair
  53. * is always present on every host — asserted as fixed members, not a host
  54. * dependency.
  55. */
  56. const RIPGREP_TOOLS = ['glob', 'grep']
  57. let scaffold: WebScaffold | undefined
  58. afterEach(async () => {
  59. await scaffold?.close()
  60. scaffold = undefined
  61. })
  62. it('assembles the shipped Web catalog with the confined access default', async () => {
  63. scaffold = await launchWebScaffold()
  64. const names = scaffold.ctx.tools.schemas().map(schema => schema.name).sort()
  65. expect(names.filter(name => !RIPGREP_TOOLS.includes(name))).toEqual(EXPECTED_TOOLS)
  66. // The packaged ripgrep binary ships with the dependency, so the pair is a
  67. // fixed roster member on every host.
  68. expect(names.filter(name => RIPGREP_TOOLS.includes(name))).toEqual(RIPGREP_TOOLS)
  69. // `workspace-write` is not "the workspace and nothing else": the shared roots
  70. // helper always admits the temp directories too. Pinning it against an
  71. // explicit mode keeps the claim independent of this surface's default, and
  72. // keeps a future boundary test from being run inside /tmp — where an
  73. // "escape" write succeeds by design and reads as a sandbox failure.
  74. expect(writableRoots(scaffold.ctx.sandboxPolicy.resolve({ mode: 'workspace-write' }))).toEqual(
  75. expect.arrayContaining([canonicalPath('/tmp'), canonicalPath(tmpdir())]),
  76. )
  77. expect(scaffold.ctx.sandboxPolicy.defaultMode).toBe('workspace-write')
  78. expect(scaffold.ctx.approval.config.policy).toBe('ask')
  79. expect(scaffold.ctx.permission.defaultPreset).toBe('workspace-write')
  80. const handle = await scaffold.ctx.agents.create({
  81. sessionId: SessionId('shipped-command-catalog'),
  82. meta: { cwd: scaffold.workspaceCwd },
  83. agentOptions: { provider: 'deepseek-official', model: 'deepseek-v4-flash' },
  84. })
  85. try {
  86. expect(scaffold.ctx.commands.list(handle.agent)).toContainEqual({
  87. name: 'feedback',
  88. description: 'record feedback about this session',
  89. input: { hint: '<text>' },
  90. })
  91. } finally {
  92. await handle.dispose()
  93. }
  94. }, 120_000)