shipped-composition.e2e.ts 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. // Empty type imports carry the tools/sandboxPolicy/approval Context merges.
  10. import type {} from '@deepseek-ai/dsh-tools'
  11. import type {} from '@deepseek-ai/dsh-sandbox-policy'
  12. import type {} from '@deepseek-ai/dsh-user-approval'
  13. import { launchWebScaffold, type WebScaffold } from './scaffold.ts'
  14. /**
  15. * The catalog the shipped Web composition puts in front of the model, minus the
  16. * ripgrep-dependent pair below. The absences are deliberate, not incidental
  17. * gaps: the `cordis_*` toolset executes model-written JavaScript that no
  18. * sandbox row confines, `web_fetch` chooses its own request target, and
  19. * `mcp_*` servers spawn outside `ctx.bash`. The composition Agent Note owns the
  20. * rationale and its sources.
  21. */
  22. const EXPECTED_TOOLS = [
  23. 'ask_user_question',
  24. 'bash',
  25. 'create_goal',
  26. 'edit',
  27. 'exit_plan_mode',
  28. 'get_goal',
  29. 'ralph',
  30. 'read',
  31. 'session_event_read',
  32. 'session_event_search',
  33. 'session_event_trace',
  34. 'session_search',
  35. 'session_trace',
  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 probes `command -v rg`
  51. * through the mounted bash executor at load and registers neither tool when
  52. * ripgrep is absent. That is a host dependency, not a composition decision, so the
  53. * pair is asserted separately — present together or absent together.
  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 and keeps its 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. expect([[], RIPGREP_TOOLS]).toContainEqual(names.filter(name => RIPGREP_TOOLS.includes(name)))
  66. // `workspace-write` is not "the workspace and nothing else": the shared roots
  67. // helper always admits the temp directories too. Pinning it against an
  68. // explicit mode keeps the claim independent of this surface's default, and
  69. // keeps a future boundary test from being run inside /tmp — where an
  70. // "escape" write succeeds by design and reads as a sandbox failure.
  71. expect(writableRoots(scaffold.ctx.sandboxPolicy.resolve({ mode: 'workspace-write' }))).toEqual(
  72. expect.arrayContaining([canonicalPath('/tmp'), canonicalPath(tmpdir())]),
  73. )
  74. // The Web surface keeps its shipped access default; the base's confined one
  75. // reaches the TUI. Pinning both keeps a base change from moving Web silently.
  76. expect(scaffold.ctx.sandboxPolicy.defaultMode).toBe('danger-full-access')
  77. expect(scaffold.ctx.approval.config.policy).toBe('never')
  78. }, 120_000)