shipped-composition.e2e.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. 'list_agents',
  33. 'ralph',
  34. 'read',
  35. 'send_message',
  36. 'skill',
  37. 'str_replace_editor',
  38. 'subagent',
  39. 'subagent_fork',
  40. 'task_kill',
  41. 'task_list',
  42. 'task_output',
  43. 'todo_write',
  44. 'update_goal',
  45. 'web_search',
  46. 'workflow',
  47. 'write',
  48. ]
  49. /**
  50. * `glob` and `grep` come from `dsh-tool-fs-search`, which spawns the PACKAGED
  51. * ripgrep binary (`@vscode/ripgrep`) through the subprocess seam, so the pair
  52. * is always present on every host — asserted as fixed members, not a host
  53. * dependency.
  54. */
  55. const RIPGREP_TOOLS = ['glob', 'grep']
  56. let scaffold: WebScaffold | undefined
  57. afterEach(async () => {
  58. await scaffold?.close()
  59. scaffold = undefined
  60. })
  61. it('assembles the shipped Web catalog with the confined access default', async () => {
  62. scaffold = await launchWebScaffold()
  63. const names = scaffold.ctx.tools.schemas().map(schema => schema.name).sort()
  64. expect(names.filter(name => !RIPGREP_TOOLS.includes(name))).toEqual(EXPECTED_TOOLS)
  65. // The packaged ripgrep binary ships with the dependency, so the pair is a
  66. // fixed roster member on every host.
  67. expect(names.filter(name => RIPGREP_TOOLS.includes(name))).toEqual(RIPGREP_TOOLS)
  68. // `workspace-write` is not "the workspace and nothing else": the shared roots
  69. // helper always admits the temp directories too. Pinning it against an
  70. // explicit mode keeps the claim independent of this surface's default, and
  71. // keeps a future boundary test from being run inside /tmp — where an
  72. // "escape" write succeeds by design and reads as a sandbox failure.
  73. expect(writableRoots(scaffold.ctx.sandboxPolicy.resolve({ mode: 'workspace-write' }))).toEqual(
  74. expect.arrayContaining([canonicalPath('/tmp'), canonicalPath(tmpdir())]),
  75. )
  76. expect(scaffold.ctx.sandboxPolicy.defaultMode).toBe('workspace-write')
  77. expect(scaffold.ctx.approval.config.policy).toBe('ask')
  78. expect(scaffold.ctx.permission.defaultPreset).toBe('workspace-write')
  79. const handle = await scaffold.ctx.agents.create({
  80. sessionId: SessionId('shipped-command-catalog'),
  81. meta: { cwd: scaffold.workspaceCwd },
  82. agentOptions: { provider: 'deepseek-official', model: 'deepseek-v4-flash' },
  83. })
  84. try {
  85. expect(scaffold.ctx.commands.list(handle.agent)).toContainEqual({
  86. name: 'feedback',
  87. description: 'record feedback about this session',
  88. input: { hint: '<text>' },
  89. })
  90. } finally {
  91. await handle.dispose()
  92. }
  93. }, 120_000)