shipped-composition.e2e.ts 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 type {} from '@deepseek-ai/dsh-permission'
  14. import { launchWebScaffold, type WebScaffold } from './scaffold.ts'
  15. /**
  16. * The catalog the shipped Web composition puts in front of the model, minus the
  17. * ripgrep-dependent pair below. The absences are deliberate, not incidental
  18. * gaps: the `cordis_*` toolset executes model-written JavaScript that no
  19. * sandbox row confines, `web_fetch` chooses its own request target, and
  20. * `mcp_*` servers spawn outside `ctx.bash`. The composition Agent Note owns the
  21. * rationale and its sources.
  22. */
  23. const EXPECTED_TOOLS = [
  24. 'ask_user_question',
  25. 'bash',
  26. 'create_goal',
  27. 'edit',
  28. 'exit_plan_mode',
  29. 'get_goal',
  30. 'list_agents',
  31. 'ralph',
  32. 'read',
  33. 'send_message',
  34. 'skill',
  35. 'str_replace_editor',
  36. 'subagent',
  37. 'subagent_fork',
  38. 'task_kill',
  39. 'task_list',
  40. 'task_output',
  41. 'todo_write',
  42. 'update_goal',
  43. 'web_search',
  44. 'workflow',
  45. 'write',
  46. ]
  47. /**
  48. * `glob` and `grep` come from `dsh-tool-fs-search`, which probes `command -v rg`
  49. * through the mounted bash executor at load and registers neither tool when
  50. * ripgrep is absent. That is a host dependency, not a composition decision, so the
  51. * pair is asserted separately — present together or absent together.
  52. */
  53. const RIPGREP_TOOLS = ['glob', 'grep']
  54. let scaffold: WebScaffold | undefined
  55. afterEach(async () => {
  56. await scaffold?.close()
  57. scaffold = undefined
  58. })
  59. it('assembles the shipped Web catalog with the confined access default', async () => {
  60. scaffold = await launchWebScaffold()
  61. const names = scaffold.ctx.tools.schemas().map(schema => schema.name).sort()
  62. expect(names.filter(name => !RIPGREP_TOOLS.includes(name))).toEqual(EXPECTED_TOOLS)
  63. expect([[], RIPGREP_TOOLS]).toContainEqual(names.filter(name => RIPGREP_TOOLS.includes(name)))
  64. // `workspace-write` is not "the workspace and nothing else": the shared roots
  65. // helper always admits the temp directories too. Pinning it against an
  66. // explicit mode keeps the claim independent of this surface's default, and
  67. // keeps a future boundary test from being run inside /tmp — where an
  68. // "escape" write succeeds by design and reads as a sandbox failure.
  69. expect(writableRoots(scaffold.ctx.sandboxPolicy.resolve({ mode: 'workspace-write' }))).toEqual(
  70. expect.arrayContaining([canonicalPath('/tmp'), canonicalPath(tmpdir())]),
  71. )
  72. expect(scaffold.ctx.sandboxPolicy.defaultMode).toBe('workspace-write')
  73. expect(scaffold.ctx.approval.config.policy).toBe('ask')
  74. expect(scaffold.ctx.permission.defaultPreset).toBe('workspace-write')
  75. }, 120_000)