05-tools.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Tools Configuration
  3. *
  4. * Use tool names to choose which built-in tools are enabled.
  5. *
  6. * Tool names are matched against all available tools. If you use a custom `cwd`,
  7. * createAgentSession() applies that cwd when it builds the actual built-in tools.
  8. *
  9. * For custom tools, see 06-extensions.ts - custom tools are registered via the
  10. * extensions system using pi.registerTool().
  11. */
  12. import { createAgentSession, SessionManager } from "@earendil-works/pi-coding-agent";
  13. // Read-only mode (no edit/write)
  14. const { session: readOnlySession } = await createAgentSession({
  15. tools: ["read", "grep", "find", "ls"],
  16. sessionManager: SessionManager.inMemory(),
  17. });
  18. console.log("Read-only session created");
  19. readOnlySession.dispose();
  20. // Custom tool selection
  21. const { session: customToolsSession } = await createAgentSession({
  22. tools: ["read", "bash", "grep"],
  23. sessionManager: SessionManager.inMemory(),
  24. });
  25. console.log("Custom tools session created");
  26. customToolsSession.dispose();
  27. // With custom cwd
  28. const customCwd = "/path/to/project";
  29. const { session: customCwdSession } = await createAgentSession({
  30. cwd: customCwd,
  31. tools: ["read", "bash", "edit", "write"],
  32. sessionManager: SessionManager.inMemory(customCwd),
  33. });
  34. console.log("Custom cwd session created");
  35. customCwdSession.dispose();
  36. // Or pick specific tools for custom cwd
  37. const { session: specificToolsSession } = await createAgentSession({
  38. cwd: customCwd,
  39. tools: ["read", "bash", "grep"],
  40. sessionManager: SessionManager.inMemory(customCwd),
  41. });
  42. console.log("Specific tools with custom cwd session created");
  43. specificToolsSession.dispose();