shipped-composition.e2e.ts 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 spawns the PACKAGED
  49. * ripgrep binary (`@vscode/ripgrep`) through the subprocess seam, so the pair
  50. * is always present on every host — asserted as fixed members, not a host
  51. * dependency.
  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. // The packaged ripgrep binary ships with the dependency, so the pair is a
  64. // fixed roster member on every host.
  65. expect(names.filter(name => RIPGREP_TOOLS.includes(name))).toEqual(RIPGREP_TOOLS)
  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. expect(scaffold.ctx.sandboxPolicy.defaultMode).toBe('workspace-write')
  75. expect(scaffold.ctx.approval.config.policy).toBe('ask')
  76. expect(scaffold.ctx.permission.defaultPreset).toBe('workspace-write')
  77. }, 120_000)