apex-code 0.0.1-alpha.4 → 0.0.1-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +10 -1
  4. package/dist/cli.js.map +1 -1
  5. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  6. package/dist/core/agent-session-runtime.js +2 -2
  7. package/dist/core/agent-session-runtime.js.map +1 -1
  8. package/dist/core/agent-session-services.d.ts +20 -1
  9. package/dist/core/agent-session-services.d.ts.map +1 -1
  10. package/dist/core/agent-session-services.js +91 -1
  11. package/dist/core/agent-session-services.js.map +1 -1
  12. package/dist/core/agent-session.d.ts +17 -0
  13. package/dist/core/agent-session.d.ts.map +1 -1
  14. package/dist/core/agent-session.js +28 -4
  15. package/dist/core/agent-session.js.map +1 -1
  16. package/dist/core/lsp/client.d.ts +76 -0
  17. package/dist/core/lsp/client.d.ts.map +1 -0
  18. package/dist/core/lsp/client.js +469 -0
  19. package/dist/core/lsp/client.js.map +1 -0
  20. package/dist/core/lsp/diagnostics.d.ts +47 -0
  21. package/dist/core/lsp/diagnostics.d.ts.map +1 -0
  22. package/dist/core/lsp/diagnostics.js +224 -0
  23. package/dist/core/lsp/diagnostics.js.map +1 -0
  24. package/dist/core/lsp/pool.d.ts +48 -0
  25. package/dist/core/lsp/pool.d.ts.map +1 -0
  26. package/dist/core/lsp/pool.js +150 -0
  27. package/dist/core/lsp/pool.js.map +1 -0
  28. package/dist/core/lsp/registry.d.ts +49 -0
  29. package/dist/core/lsp/registry.d.ts.map +1 -0
  30. package/dist/core/lsp/registry.js +215 -0
  31. package/dist/core/lsp/registry.js.map +1 -0
  32. package/dist/core/lsp/status.d.ts +23 -0
  33. package/dist/core/lsp/status.d.ts.map +1 -0
  34. package/dist/core/lsp/status.js +35 -0
  35. package/dist/core/lsp/status.js.map +1 -0
  36. package/dist/core/lsp/sync.d.ts +13 -0
  37. package/dist/core/lsp/sync.d.ts.map +1 -0
  38. package/dist/core/lsp/sync.js +71 -0
  39. package/dist/core/lsp/sync.js.map +1 -0
  40. package/dist/core/package-manager.d.ts.map +1 -1
  41. package/dist/core/package-manager.js +15 -0
  42. package/dist/core/package-manager.js.map +1 -1
  43. package/dist/core/project-trust.d.ts.map +1 -1
  44. package/dist/core/project-trust.js +1 -1
  45. package/dist/core/project-trust.js.map +1 -1
  46. package/dist/core/sandbox/cli-launch.d.ts +43 -0
  47. package/dist/core/sandbox/cli-launch.d.ts.map +1 -1
  48. package/dist/core/sandbox/cli-launch.js +70 -3
  49. package/dist/core/sandbox/cli-launch.js.map +1 -1
  50. package/dist/core/sandbox/cli-supervisor.d.ts +2 -0
  51. package/dist/core/sandbox/cli-supervisor.d.ts.map +1 -1
  52. package/dist/core/sandbox/cli-supervisor.js +1 -0
  53. package/dist/core/sandbox/cli-supervisor.js.map +1 -1
  54. package/dist/core/sdk.d.ts +4 -0
  55. package/dist/core/sdk.d.ts.map +1 -1
  56. package/dist/core/sdk.js +10 -1
  57. package/dist/core/sdk.js.map +1 -1
  58. package/dist/core/settings-manager.d.ts +3 -0
  59. package/dist/core/settings-manager.d.ts.map +1 -1
  60. package/dist/core/settings-manager.js +3 -0
  61. package/dist/core/settings-manager.js.map +1 -1
  62. package/dist/core/skills.d.ts +19 -7
  63. package/dist/core/skills.d.ts.map +1 -1
  64. package/dist/core/skills.js +77 -19
  65. package/dist/core/skills.js.map +1 -1
  66. package/dist/core/slash-commands.d.ts.map +1 -1
  67. package/dist/core/slash-commands.js +1 -1
  68. package/dist/core/slash-commands.js.map +1 -1
  69. package/dist/core/system-prompt.d.ts.map +1 -1
  70. package/dist/core/system-prompt.js +3 -3
  71. package/dist/core/system-prompt.js.map +1 -1
  72. package/dist/core/tools/contract.d.ts +29 -2
  73. package/dist/core/tools/contract.d.ts.map +1 -1
  74. package/dist/core/tools/contract.js.map +1 -1
  75. package/dist/core/tools/diagnostics.d.ts +39 -0
  76. package/dist/core/tools/diagnostics.d.ts.map +1 -0
  77. package/dist/core/tools/diagnostics.js +62 -0
  78. package/dist/core/tools/diagnostics.js.map +1 -0
  79. package/dist/core/tools/edit.d.ts +10 -0
  80. package/dist/core/tools/edit.d.ts.map +1 -1
  81. package/dist/core/tools/edit.js +17 -8
  82. package/dist/core/tools/edit.js.map +1 -1
  83. package/dist/core/tools/index.d.ts +20 -3
  84. package/dist/core/tools/index.d.ts.map +1 -1
  85. package/dist/core/tools/index.js +18 -0
  86. package/dist/core/tools/index.js.map +1 -1
  87. package/dist/core/tools/lsp.d.ts +62 -0
  88. package/dist/core/tools/lsp.d.ts.map +1 -0
  89. package/dist/core/tools/lsp.js +216 -0
  90. package/dist/core/tools/lsp.js.map +1 -0
  91. package/dist/core/tools/skill-search.d.ts +32 -0
  92. package/dist/core/tools/skill-search.d.ts.map +1 -0
  93. package/dist/core/tools/skill-search.js +56 -0
  94. package/dist/core/tools/skill-search.js.map +1 -0
  95. package/dist/core/tools/write.d.ts +10 -0
  96. package/dist/core/tools/write.d.ts.map +1 -1
  97. package/dist/core/tools/write.js +16 -3
  98. package/dist/core/tools/write.js.map +1 -1
  99. package/dist/index.d.ts +1 -1
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js.map +1 -1
  102. package/dist/modes/interactive/components/custom-editor.d.ts +49 -1
  103. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  104. package/dist/modes/interactive/components/custom-editor.js +235 -1
  105. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  106. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
  107. package/dist/modes/interactive/components/first-time-setup.js +2 -1
  108. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  109. package/dist/modes/interactive/components/index.d.ts +1 -0
  110. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  111. package/dist/modes/interactive/components/index.js +1 -0
  112. package/dist/modes/interactive/components/index.js.map +1 -1
  113. package/dist/modes/interactive/components/model-selector.d.ts +19 -6
  114. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  115. package/dist/modes/interactive/components/model-selector.js +172 -89
  116. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  117. package/dist/modes/interactive/components/splash-header.d.ts +41 -0
  118. package/dist/modes/interactive/components/splash-header.d.ts.map +1 -0
  119. package/dist/modes/interactive/components/splash-header.js +145 -0
  120. package/dist/modes/interactive/components/splash-header.js.map +1 -0
  121. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  122. package/dist/modes/interactive/interactive-mode.js +19 -15
  123. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  124. package/dist/modes/interactive/theme/apex.json +94 -0
  125. package/dist/modes/interactive/theme/light.json +1 -1
  126. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  127. package/dist/modes/interactive/theme/theme.js +6 -1
  128. package/dist/modes/interactive/theme/theme.js.map +1 -1
  129. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  130. package/dist/modes/rpc/rpc-mode.js +2 -1
  131. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  132. package/dist/themes/apex-logo.d.ts +21 -0
  133. package/dist/themes/apex-logo.d.ts.map +1 -0
  134. package/dist/themes/apex-logo.js +31 -0
  135. package/dist/themes/apex-logo.js.map +1 -0
  136. package/dist/utils/changelog.d.ts +7 -2
  137. package/dist/utils/changelog.d.ts.map +1 -1
  138. package/dist/utils/changelog.js +82 -13
  139. package/dist/utils/changelog.js.map +1 -1
  140. package/docs/skills.md +54 -4
  141. package/npm-shrinkwrap.json +5 -5
  142. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AACvH,OAAO,EACN,KAAK,cAAc,EAC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AC,EAAE,oBAAoB,CAAC;IAClC,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAChC,QAAQ,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,wBAAwB,CAAA;KAAE,CAAC;IAClD,IAAI,CAAC,EAAE,eAAe,CAAC;CACvB;AAyBD,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAmCrG;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAmCxF;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,EAAE,CAO1F;AAED,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,EAAE,CAO5F;AAOD,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAyBvG;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO7E;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO/E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAuB1F","sourcesContent":["export { type AskUserDetails, type AskUserInput, createAskUserTool, createAskUserToolDefinition } from \"./ask-user.ts\";\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateDelegateTool,\n\tcreateDelegateToolDefinition,\n\ttype DelegateDetails,\n\ttype DelegateInput,\n} from \"./delegate.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreatePlanPresentTool,\n\tcreatePlanPresentToolDefinition,\n\ttype PlanPresentDetails,\n\ttype PlanPresentInput,\n} from \"./plan-present.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tcreateTestPermissionSpec,\n\tcreateTestTool,\n\tcreateTestToolDefinition,\n\ttype TestOperationResult,\n\ttype TestOperations,\n\ttype TestRunDetails,\n\ttype TestToolInput,\n\ttype TestToolOptions,\n} from \"./test.ts\";\nexport {\n\tcreateTodoWriteTool,\n\tcreateTodoWriteToolDefinition,\n\ttype TodoItem,\n\ttype TodoWriteDetails,\n\ttype TodoWriteInput,\n\ttype TodoWriteStore,\n} from \"./todo-write.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWebFetchTool,\n\tcreateWebFetchToolDefinition,\n\ttype WebFetchDetails,\n\ttype WebFetchInput,\n\ttype WebFetchOperations,\n\ttype WebFetchToolOptions,\n} from \"./web-fetch.ts\";\nexport {\n\tcreateWebSearchTool,\n\tcreateWebSearchToolDefinition,\n\ttype WebSearchDetails,\n\ttype WebSearchInput,\n\ttype WebSearchOperations,\n\ttype WebSearchResult,\n\ttype WebSearchToolOptions,\n} from \"./web-search.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolDetails,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"apex-code-agent-core\";\nimport type { DelegationRuntimeOptions } from \"../delegation/runtime.ts\";\nimport { createAskUserTool, createAskUserToolDefinition } from \"./ask-user.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport type { ApexToolDefinition } from \"./contract.ts\";\nimport { createDelegateTool, createDelegateToolDefinition } from \"./delegate.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createPlanPresentTool, createPlanPresentToolDefinition } from \"./plan-present.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createTestTool, createTestToolDefinition, type TestToolOptions } from \"./test.ts\";\nimport { createTodoWriteTool, createTodoWriteToolDefinition, type TodoWriteStore } from \"./todo-write.ts\";\nimport { createToolSchemaTool, createToolSchemaToolDefinition, type ToolSchemaResolver } from \"./tool-schema.ts\";\nimport { createWebFetchTool, createWebFetchToolDefinition, type WebFetchToolOptions } from \"./web-fetch.ts\";\nimport { createWebSearchTool, createWebSearchToolDefinition, type WebSearchToolOptions } from \"./web-search.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ApexToolDefinition<any, any>;\nexport type ToolName =\n\t| \"read\"\n\t| \"bash\"\n\t| \"edit\"\n\t| \"write\"\n\t| \"grep\"\n\t| \"find\"\n\t| \"ls\"\n\t| \"tool_schema\"\n\t| \"todo_write\"\n\t| \"web_search\"\n\t| \"web_fetch\"\n\t| \"ask_user\"\n\t| \"plan_present\"\n\t| \"delegate\"\n\t| \"test\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"tool_schema\",\n\t\"todo_write\",\n\t\"web_search\",\n\t\"web_fetch\",\n\t\"ask_user\",\n\t\"plan_present\",\n\t\"delegate\",\n\t\"test\",\n]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n\ttool_schema?: { resolver?: ToolSchemaResolver };\n\ttodo_write?: { store?: TodoWriteStore };\n\tweb_search?: WebSearchToolOptions;\n\tweb_fetch?: WebFetchToolOptions;\n\tdelegate?: { runtime?: DelegationRuntimeOptions };\n\ttest?: TestToolOptions;\n}\n\n/** Default store when no session/workspace context supplies one (mirrors emptyToolSchemaResolver below). */\nconst noopTodoWriteStore: TodoWriteStore = { write: () => {} };\n\n/**\n * Default runtime when no session supplies one (mirrors noopTodoWriteStore/\n * emptyToolSchemaResolver above): every agent type is unresolvable, so `delegate`\n * stays inert -- callable, but every call fails loudly with \"unknown agent type\"\n * rather than silently spawning a child with no real authority derivation behind\n * it. Real production wiring (a resolved parent capability set, a derived\n * permission store, and a `buildChildSession` that calls `createAgentSession`) is\n * supplied by `sdk.ts`'s `createAgentSession({ delegation })` option.\n */\nconst noopDelegationRuntime: DelegationRuntimeOptions = {\n\tresolveAgent: () => undefined,\n\tgetParentCapabilities: () => new Set(),\n\tgetToolCapabilities: () => undefined,\n\tgetDelegationDepth: () => 0,\n\tmaxDelegationDepth: 2,\n\tbuildChildSession: async () => {\n\t\tthrow new Error(\"delegate has no runtime configured in this context -- no agent types are resolvable.\");\n\t},\n};\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tcase \"tool_schema\":\n\t\t\treturn createToolSchemaToolDefinition(options?.tool_schema?.resolver ?? emptyToolSchemaResolver);\n\t\tcase \"todo_write\":\n\t\t\treturn createTodoWriteToolDefinition(options?.todo_write?.store ?? noopTodoWriteStore);\n\t\tcase \"web_search\":\n\t\t\treturn createWebSearchToolDefinition(options?.web_search);\n\t\tcase \"web_fetch\":\n\t\t\treturn createWebFetchToolDefinition(options?.web_fetch);\n\t\tcase \"ask_user\":\n\t\t\treturn createAskUserToolDefinition();\n\t\tcase \"plan_present\":\n\t\t\treturn createPlanPresentToolDefinition();\n\t\tcase \"delegate\":\n\t\t\treturn createDelegateToolDefinition(options?.delegate?.runtime ?? noopDelegationRuntime);\n\t\tcase \"test\":\n\t\t\treturn createTestToolDefinition(cwd, options?.test);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"tool_schema\":\n\t\t\treturn createToolSchemaTool(options?.tool_schema?.resolver ?? emptyToolSchemaResolver);\n\t\tcase \"todo_write\":\n\t\t\treturn createTodoWriteTool(options?.todo_write?.store ?? noopTodoWriteStore);\n\t\tcase \"web_search\":\n\t\t\treturn createWebSearchTool(options?.web_search);\n\t\tcase \"web_fetch\":\n\t\t\treturn createWebFetchTool(options?.web_fetch);\n\t\tcase \"ask_user\":\n\t\t\treturn createAskUserTool();\n\t\tcase \"plan_present\":\n\t\t\treturn createPlanPresentTool();\n\t\tcase \"delegate\":\n\t\t\treturn createDelegateTool(options?.delegate?.runtime ?? noopDelegationRuntime);\n\t\tcase \"test\":\n\t\t\treturn createTestTool(cwd, options?.test);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nconst emptyToolSchemaResolver: ToolSchemaResolver = {\n\tgetTool: () => undefined,\n\tmarkLoaded: () => {},\n};\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\tconst definitions = {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t};\n\tconst resolver = options?.tool_schema?.resolver ?? {\n\t\tgetTool: (name: string) => definitions[name as keyof typeof definitions],\n\t\tmarkLoaded: () => {},\n\t};\n\treturn {\n\t\t...definitions,\n\t\ttool_schema: createToolSchemaToolDefinition(resolver),\n\t\ttodo_write: createTodoWriteToolDefinition(options?.todo_write?.store ?? noopTodoWriteStore),\n\t\tweb_search: createWebSearchToolDefinition(options?.web_search),\n\t\tweb_fetch: createWebFetchToolDefinition(options?.web_fetch),\n\t\task_user: createAskUserToolDefinition(),\n\t\tplan_present: createPlanPresentToolDefinition(),\n\t\tdelegate: createDelegateToolDefinition(options?.delegate?.runtime ?? noopDelegationRuntime),\n\t\ttest: createTestToolDefinition(cwd, options?.test),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\tconst definitions = createAllToolDefinitions(cwd, options);\n\tconst resolver = options?.tool_schema?.resolver ?? {\n\t\tgetTool: (name: string) => definitions[name as ToolName],\n\t\tmarkLoaded: () => {},\n\t};\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\ttool_schema: createToolSchemaTool(resolver),\n\t\ttodo_write: createTodoWriteTool(options?.todo_write?.store ?? noopTodoWriteStore),\n\t\tweb_search: createWebSearchTool(options?.web_search),\n\t\tweb_fetch: createWebFetchTool(options?.web_fetch),\n\t\task_user: createAskUserTool(),\n\t\tplan_present: createPlanPresentTool(),\n\t\tdelegate: createDelegateTool(options?.delegate?.runtime ?? noopDelegationRuntime),\n\t\ttest: createTestTool(cwd, options?.test),\n\t};\n}\n"]}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AACvH,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB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AAQ,EAAE,OAAO,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,CA6B/C;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO7E;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO/E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,IAAI,CAAA;CAAE,CAyB3G","sourcesContent":["export { type AskUserDetails, type AskUserInput, createAskUserTool, createAskUserToolDefinition } from \"./ask-user.ts\";\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateDelegateTool,\n\tcreateDelegateToolDefinition,\n\ttype DelegateDetails,\n\ttype DelegateInput,\n} from \"./delegate.ts\";\nexport type {\n\tDiagnostic,\n\tDiagnosticEvidenceRecord,\n\tDiagnosticPosition,\n\tDiagnosticRange,\n\tDiagnosticSeverityCounts,\n\tDiagnosticsOperations,\n\tDiagnosticsOutcome,\n\tDiagnosticUnavailableKind,\n} from \"./diagnostics.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateLspTool,\n\tcreateLspToolDefinition,\n\ttype LspLocation,\n\ttype LspOperations,\n\ttype LspSymbol,\n\ttype LspToolDetails,\n\ttype LspToolInput,\n\ttype LspToolOptions,\n} from \"./lsp.ts\";\nexport {\n\tcreatePlanPresentTool,\n\tcreatePlanPresentToolDefinition,\n\ttype PlanPresentDetails,\n\ttype PlanPresentInput,\n} from \"./plan-present.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tcreateTestPermissionSpec,\n\tcreateTestTool,\n\tcreateTestToolDefinition,\n\ttype TestOperationResult,\n\ttype TestOperations,\n\ttype TestRunDetails,\n\ttype TestToolInput,\n\ttype TestToolOptions,\n} from \"./test.ts\";\nexport {\n\tcreateTodoWriteTool,\n\tcreateTodoWriteToolDefinition,\n\ttype TodoItem,\n\ttype TodoWriteDetails,\n\ttype TodoWriteInput,\n\ttype TodoWriteStore,\n} from \"./todo-write.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWebFetchTool,\n\tcreateWebFetchToolDefinition,\n\ttype WebFetchDetails,\n\ttype WebFetchInput,\n\ttype WebFetchOperations,\n\ttype WebFetchToolOptions,\n} from \"./web-fetch.ts\";\nexport {\n\tcreateWebSearchTool,\n\tcreateWebSearchToolDefinition,\n\ttype WebSearchDetails,\n\ttype WebSearchInput,\n\ttype WebSearchOperations,\n\ttype WebSearchResult,\n\ttype WebSearchToolOptions,\n} from \"./web-search.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolDetails,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"apex-code-agent-core\";\nimport type { DelegationRuntimeOptions } from \"../delegation/runtime.ts\";\nimport { createAskUserTool, createAskUserToolDefinition } from \"./ask-user.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport type { ApexToolDefinition } from \"./contract.ts\";\nimport { createDelegateTool, createDelegateToolDefinition } from \"./delegate.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createLspTool, createLspToolDefinition, type LspToolOptions } from \"./lsp.ts\";\nimport { createPlanPresentTool, createPlanPresentToolDefinition } from \"./plan-present.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createSkillSearchTool, createSkillSearchToolDefinition, type SkillSearchResolver } from \"./skill-search.ts\";\nimport { createTestTool, createTestToolDefinition, type TestToolOptions } from \"./test.ts\";\nimport { createTodoWriteTool, createTodoWriteToolDefinition, type TodoWriteStore } from \"./todo-write.ts\";\nimport { createToolSchemaTool, createToolSchemaToolDefinition, type ToolSchemaResolver } from \"./tool-schema.ts\";\nimport { createWebFetchTool, createWebFetchToolDefinition, type WebFetchToolOptions } from \"./web-fetch.ts\";\nimport { createWebSearchTool, createWebSearchToolDefinition, type WebSearchToolOptions } from \"./web-search.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ApexToolDefinition<any, any>;\nexport type ToolName =\n\t| \"read\"\n\t| \"bash\"\n\t| \"edit\"\n\t| \"write\"\n\t| \"grep\"\n\t| \"find\"\n\t| \"ls\"\n\t| \"tool_schema\"\n\t| \"todo_write\"\n\t| \"web_search\"\n\t| \"web_fetch\"\n\t| \"ask_user\"\n\t| \"plan_present\"\n\t| \"delegate\"\n\t| \"test\"\n\t| \"skill_search\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"tool_schema\",\n\t\"todo_write\",\n\t\"skill_search\",\n\t\"web_search\",\n\t\"web_fetch\",\n\t\"ask_user\",\n\t\"plan_present\",\n\t\"delegate\",\n\t\"test\",\n]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n\ttool_schema?: { resolver?: ToolSchemaResolver };\n\ttodo_write?: { store?: TodoWriteStore };\n\tskill_search?: { resolver?: SkillSearchResolver };\n\tweb_search?: WebSearchToolOptions;\n\tweb_fetch?: WebFetchToolOptions;\n\tdelegate?: { runtime?: DelegationRuntimeOptions };\n\ttest?: TestToolOptions;\n\t/**\n\t * The `lsp` navigation tool (LSP.5). Undefined by default -- the registry-building\n\t * functions below include the `lsp` key only when this is provided, which is what\n\t * keeps an unconfigured session's tool set (and static prompt prefix) unaffected.\n\t */\n\tlsp?: LspToolOptions;\n}\n\n/** Default store when no session/workspace context supplies one (mirrors emptyToolSchemaResolver below). */\nconst noopTodoWriteStore: TodoWriteStore = { write: () => {} };\n\n/**\n * Default runtime when no session supplies one (mirrors noopTodoWriteStore/\n * emptyToolSchemaResolver above): every agent type is unresolvable, so `delegate`\n * stays inert -- callable, but every call fails loudly with \"unknown agent type\"\n * rather than silently spawning a child with no real authority derivation behind\n * it. Real production wiring (a resolved parent capability set, a derived\n * permission store, and a `buildChildSession` that calls `createAgentSession`) is\n * supplied by `sdk.ts`'s `createAgentSession({ delegation })` option.\n */\nconst noopDelegationRuntime: DelegationRuntimeOptions = {\n\tresolveAgent: () => undefined,\n\tgetParentCapabilities: () => new Set(),\n\tgetToolCapabilities: () => undefined,\n\tgetDelegationDepth: () => 0,\n\tmaxDelegationDepth: 2,\n\tbuildChildSession: async () => {\n\t\tthrow new Error(\"delegate has no runtime configured in this context -- no agent types are resolvable.\");\n\t},\n};\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tcase \"tool_schema\":\n\t\t\treturn createToolSchemaToolDefinition(options?.tool_schema?.resolver ?? emptyToolSchemaResolver);\n\t\tcase \"todo_write\":\n\t\t\treturn createTodoWriteToolDefinition(options?.todo_write?.store ?? noopTodoWriteStore);\n\t\tcase \"skill_search\":\n\t\t\treturn createSkillSearchToolDefinition(options?.skill_search?.resolver ?? emptySkillSearchResolver);\n\t\tcase \"web_search\":\n\t\t\treturn createWebSearchToolDefinition(options?.web_search);\n\t\tcase \"web_fetch\":\n\t\t\treturn createWebFetchToolDefinition(options?.web_fetch);\n\t\tcase \"ask_user\":\n\t\t\treturn createAskUserToolDefinition();\n\t\tcase \"plan_present\":\n\t\t\treturn createPlanPresentToolDefinition();\n\t\tcase \"delegate\":\n\t\t\treturn createDelegateToolDefinition(options?.delegate?.runtime ?? noopDelegationRuntime);\n\t\tcase \"test\":\n\t\t\treturn createTestToolDefinition(cwd, options?.test);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"tool_schema\":\n\t\t\treturn createToolSchemaTool(options?.tool_schema?.resolver ?? emptyToolSchemaResolver);\n\t\tcase \"todo_write\":\n\t\t\treturn createTodoWriteTool(options?.todo_write?.store ?? noopTodoWriteStore);\n\t\tcase \"skill_search\":\n\t\t\treturn createSkillSearchTool(options?.skill_search?.resolver ?? emptySkillSearchResolver);\n\t\tcase \"web_search\":\n\t\t\treturn createWebSearchTool(options?.web_search);\n\t\tcase \"web_fetch\":\n\t\t\treturn createWebFetchTool(options?.web_fetch);\n\t\tcase \"ask_user\":\n\t\t\treturn createAskUserTool();\n\t\tcase \"plan_present\":\n\t\t\treturn createPlanPresentTool();\n\t\tcase \"delegate\":\n\t\t\treturn createDelegateTool(options?.delegate?.runtime ?? noopDelegationRuntime);\n\t\tcase \"test\":\n\t\t\treturn createTestTool(cwd, options?.test);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nconst emptyToolSchemaResolver: ToolSchemaResolver = {\n\tgetTool: () => undefined,\n\tmarkLoaded: () => {},\n};\n\n/** Default when no session supplies one (mirrors emptyToolSchemaResolver above): no skills known, so every search returns empty rather than throwing. */\nconst emptySkillSearchResolver: SkillSearchResolver = {\n\tgetSkills: () => [],\n};\n\nexport function createAllToolDefinitions(\n\tcwd: string,\n\toptions?: ToolsOptions,\n): Record<ToolName, ToolDef> & { lsp?: ToolDef } {\n\tconst definitions = {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t};\n\tconst resolver = options?.tool_schema?.resolver ?? {\n\t\tgetTool: (name: string) => definitions[name as keyof typeof definitions],\n\t\tmarkLoaded: () => {},\n\t};\n\treturn {\n\t\t...definitions,\n\t\ttool_schema: createToolSchemaToolDefinition(resolver),\n\t\ttodo_write: createTodoWriteToolDefinition(options?.todo_write?.store ?? noopTodoWriteStore),\n\t\tskill_search: createSkillSearchToolDefinition(options?.skill_search?.resolver ?? emptySkillSearchResolver),\n\t\tweb_search: createWebSearchToolDefinition(options?.web_search),\n\t\tweb_fetch: createWebFetchToolDefinition(options?.web_fetch),\n\t\task_user: createAskUserToolDefinition(),\n\t\tplan_present: createPlanPresentToolDefinition(),\n\t\tdelegate: createDelegateToolDefinition(options?.delegate?.runtime ?? noopDelegationRuntime),\n\t\ttest: createTestToolDefinition(cwd, options?.test),\n\t\t// Registered only when configured (LSP.5): an unconfigured session's registry,\n\t\t// and therefore its static prompt prefix, is unaffected by this subsystem.\n\t\t...(options?.lsp ? { lsp: createLspToolDefinition(cwd, options.lsp) } : {}),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> & { lsp?: Tool } {\n\tconst definitions = createAllToolDefinitions(cwd, options);\n\tconst resolver = options?.tool_schema?.resolver ?? {\n\t\tgetTool: (name: string) => definitions[name as ToolName],\n\t\tmarkLoaded: () => {},\n\t};\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\ttool_schema: createToolSchemaTool(resolver),\n\t\ttodo_write: createTodoWriteTool(options?.todo_write?.store ?? noopTodoWriteStore),\n\t\tskill_search: createSkillSearchTool(options?.skill_search?.resolver ?? emptySkillSearchResolver),\n\t\tweb_search: createWebSearchTool(options?.web_search),\n\t\tweb_fetch: createWebFetchTool(options?.web_fetch),\n\t\task_user: createAskUserTool(),\n\t\tplan_present: createPlanPresentTool(),\n\t\tdelegate: createDelegateTool(options?.delegate?.runtime ?? noopDelegationRuntime),\n\t\ttest: createTestTool(cwd, options?.test),\n\t\t...(options?.lsp ? { lsp: createLspTool(cwd, options.lsp) } : {}),\n\t};\n}\n"]}
@@ -6,6 +6,7 @@ export { withFileMutationQueue } from "./file-mutation-queue.js";
6
6
  export { createFindTool, createFindToolDefinition, } from "./find.js";
7
7
  export { createGrepTool, createGrepToolDefinition, } from "./grep.js";
8
8
  export { createLsTool, createLsToolDefinition, } from "./ls.js";
9
+ export { createLspTool, createLspToolDefinition, } from "./lsp.js";
9
10
  export { createPlanPresentTool, createPlanPresentToolDefinition, } from "./plan-present.js";
10
11
  export { createReadTool, createReadToolDefinition, } from "./read.js";
11
12
  export { createTestPermissionSpec, createTestTool, createTestToolDefinition, } from "./test.js";
@@ -21,8 +22,10 @@ import { createEditTool, createEditToolDefinition } from "./edit.js";
21
22
  import { createFindTool, createFindToolDefinition } from "./find.js";
22
23
  import { createGrepTool, createGrepToolDefinition } from "./grep.js";
23
24
  import { createLsTool, createLsToolDefinition } from "./ls.js";
25
+ import { createLspTool, createLspToolDefinition } from "./lsp.js";
24
26
  import { createPlanPresentTool, createPlanPresentToolDefinition } from "./plan-present.js";
25
27
  import { createReadTool, createReadToolDefinition } from "./read.js";
28
+ import { createSkillSearchTool, createSkillSearchToolDefinition } from "./skill-search.js";
26
29
  import { createTestTool, createTestToolDefinition } from "./test.js";
27
30
  import { createTodoWriteTool, createTodoWriteToolDefinition } from "./todo-write.js";
28
31
  import { createToolSchemaTool, createToolSchemaToolDefinition } from "./tool-schema.js";
@@ -39,6 +42,7 @@ export const allToolNames = new Set([
39
42
  "ls",
40
43
  "tool_schema",
41
44
  "todo_write",
45
+ "skill_search",
42
46
  "web_search",
43
47
  "web_fetch",
44
48
  "ask_user",
@@ -87,6 +91,8 @@ export function createToolDefinition(toolName, cwd, options) {
87
91
  return createToolSchemaToolDefinition(options?.tool_schema?.resolver ?? emptyToolSchemaResolver);
88
92
  case "todo_write":
89
93
  return createTodoWriteToolDefinition(options?.todo_write?.store ?? noopTodoWriteStore);
94
+ case "skill_search":
95
+ return createSkillSearchToolDefinition(options?.skill_search?.resolver ?? emptySkillSearchResolver);
90
96
  case "web_search":
91
97
  return createWebSearchToolDefinition(options?.web_search);
92
98
  case "web_fetch":
@@ -123,6 +129,8 @@ export function createTool(toolName, cwd, options) {
123
129
  return createToolSchemaTool(options?.tool_schema?.resolver ?? emptyToolSchemaResolver);
124
130
  case "todo_write":
125
131
  return createTodoWriteTool(options?.todo_write?.store ?? noopTodoWriteStore);
132
+ case "skill_search":
133
+ return createSkillSearchTool(options?.skill_search?.resolver ?? emptySkillSearchResolver);
126
134
  case "web_search":
127
135
  return createWebSearchTool(options?.web_search);
128
136
  case "web_fetch":
@@ -159,6 +167,10 @@ const emptyToolSchemaResolver = {
159
167
  getTool: () => undefined,
160
168
  markLoaded: () => { },
161
169
  };
170
+ /** Default when no session supplies one (mirrors emptyToolSchemaResolver above): no skills known, so every search returns empty rather than throwing. */
171
+ const emptySkillSearchResolver = {
172
+ getSkills: () => [],
173
+ };
162
174
  export function createAllToolDefinitions(cwd, options) {
163
175
  const definitions = {
164
176
  read: createReadToolDefinition(cwd, options?.read),
@@ -177,12 +189,16 @@ export function createAllToolDefinitions(cwd, options) {
177
189
  ...definitions,
178
190
  tool_schema: createToolSchemaToolDefinition(resolver),
179
191
  todo_write: createTodoWriteToolDefinition(options?.todo_write?.store ?? noopTodoWriteStore),
192
+ skill_search: createSkillSearchToolDefinition(options?.skill_search?.resolver ?? emptySkillSearchResolver),
180
193
  web_search: createWebSearchToolDefinition(options?.web_search),
181
194
  web_fetch: createWebFetchToolDefinition(options?.web_fetch),
182
195
  ask_user: createAskUserToolDefinition(),
183
196
  plan_present: createPlanPresentToolDefinition(),
184
197
  delegate: createDelegateToolDefinition(options?.delegate?.runtime ?? noopDelegationRuntime),
185
198
  test: createTestToolDefinition(cwd, options?.test),
199
+ // Registered only when configured (LSP.5): an unconfigured session's registry,
200
+ // and therefore its static prompt prefix, is unaffected by this subsystem.
201
+ ...(options?.lsp ? { lsp: createLspToolDefinition(cwd, options.lsp) } : {}),
186
202
  };
187
203
  }
188
204
  export function createCodingTools(cwd, options) {
@@ -217,12 +233,14 @@ export function createAllTools(cwd, options) {
217
233
  ls: createLsTool(cwd, options?.ls),
218
234
  tool_schema: createToolSchemaTool(resolver),
219
235
  todo_write: createTodoWriteTool(options?.todo_write?.store ?? noopTodoWriteStore),
236
+ skill_search: createSkillSearchTool(options?.skill_search?.resolver ?? emptySkillSearchResolver),
220
237
  web_search: createWebSearchTool(options?.web_search),
221
238
  web_fetch: createWebFetchTool(options?.web_fetch),
222
239
  ask_user: createAskUserTool(),
223
240
  plan_present: createPlanPresentTool(),
224
241
  delegate: createDelegateTool(options?.delegate?.runtime ?? noopDelegationRuntime),
225
242
  test: createTestTool(cwd, options?.test),
243
+ ...(options?.lsp ? { lsp: createLspTool(cwd, options.lsp) } : {}),
226
244
  };
227
245
  }
228
246
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AACvH,OAAO,EAON,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,kBAAkB,EAClB,4BAA4B,GAG5B,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACn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Ae,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC;QAC3C,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,EAAE,EAAE,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;QAClC,WAAW,EAAE,oBAAoB,CAAC,QAAQ,CAAC;QAC3C,UAAU,EAAE,mBAAmB,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,IAAI,kBAAkB,CAAC;QACjF,UAAU,EAAE,mBAAmB,CAAC,OAAO,EAAE,UAAU,CAAC;QACpD,SAAS,EAAE,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAC;QACjD,QAAQ,EAAE,iBAAiB,EAAE;QAC7B,YAAY,EAAE,qBAAqB,EAAE;QACrC,QAAQ,EAAE,kBAAkB,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,IAAI,qBAAqB,CAAC;QACjF,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;KACxC,CAAC;AAAA,CACF","sourcesContent":["export { type AskUserDetails, type AskUserInput, createAskUserTool, createAskUserToolDefinition } from \"./ask-user.ts\";\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateDelegateTool,\n\tcreateDelegateToolDefinition,\n\ttype DelegateDetails,\n\ttype DelegateInput,\n} from \"./delegate.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreatePlanPresentTool,\n\tcreatePlanPresentToolDefinition,\n\ttype PlanPresentDetails,\n\ttype PlanPresentInput,\n} from \"./plan-present.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tcreateTestPermissionSpec,\n\tcreateTestTool,\n\tcreateTestToolDefinition,\n\ttype TestOperationResult,\n\ttype TestOperations,\n\ttype TestRunDetails,\n\ttype TestToolInput,\n\ttype TestToolOptions,\n} from \"./test.ts\";\nexport {\n\tcreateTodoWriteTool,\n\tcreateTodoWriteToolDefinition,\n\ttype TodoItem,\n\ttype TodoWriteDetails,\n\ttype TodoWriteInput,\n\ttype TodoWriteStore,\n} from \"./todo-write.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWebFetchTool,\n\tcreateWebFetchToolDefinition,\n\ttype WebFetchDetails,\n\ttype WebFetchInput,\n\ttype WebFetchOperations,\n\ttype WebFetchToolOptions,\n} from \"./web-fetch.ts\";\nexport {\n\tcreateWebSearchTool,\n\tcreateWebSearchToolDefinition,\n\ttype WebSearchDetails,\n\ttype WebSearchInput,\n\ttype WebSearchOperations,\n\ttype WebSearchResult,\n\ttype WebSearchToolOptions,\n} from \"./web-search.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolDetails,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"apex-code-agent-core\";\nimport type { DelegationRuntimeOptions } from \"../delegation/runtime.ts\";\nimport { createAskUserTool, createAskUserToolDefinition } from \"./ask-user.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport type { ApexToolDefinition } from \"./contract.ts\";\nimport { createDelegateTool, createDelegateToolDefinition } from \"./delegate.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createPlanPresentTool, createPlanPresentToolDefinition } from \"./plan-present.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createTestTool, createTestToolDefinition, type TestToolOptions } from \"./test.ts\";\nimport { createTodoWriteTool, createTodoWriteToolDefinition, type TodoWriteStore } from \"./todo-write.ts\";\nimport { createToolSchemaTool, createToolSchemaToolDefinition, type ToolSchemaResolver } from \"./tool-schema.ts\";\nimport { createWebFetchTool, createWebFetchToolDefinition, type WebFetchToolOptions } from \"./web-fetch.ts\";\nimport { createWebSearchTool, createWebSearchToolDefinition, type WebSearchToolOptions } from \"./web-search.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ApexToolDefinition<any, any>;\nexport type ToolName =\n\t| \"read\"\n\t| \"bash\"\n\t| \"edit\"\n\t| \"write\"\n\t| \"grep\"\n\t| \"find\"\n\t| \"ls\"\n\t| \"tool_schema\"\n\t| \"todo_write\"\n\t| \"web_search\"\n\t| \"web_fetch\"\n\t| \"ask_user\"\n\t| \"plan_present\"\n\t| \"delegate\"\n\t| \"test\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"tool_schema\",\n\t\"todo_write\",\n\t\"web_search\",\n\t\"web_fetch\",\n\t\"ask_user\",\n\t\"plan_present\",\n\t\"delegate\",\n\t\"test\",\n]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n\ttool_schema?: { resolver?: ToolSchemaResolver };\n\ttodo_write?: { store?: TodoWriteStore };\n\tweb_search?: WebSearchToolOptions;\n\tweb_fetch?: WebFetchToolOptions;\n\tdelegate?: { runtime?: DelegationRuntimeOptions };\n\ttest?: TestToolOptions;\n}\n\n/** Default store when no session/workspace context supplies one (mirrors emptyToolSchemaResolver below). */\nconst noopTodoWriteStore: TodoWriteStore = { write: () => {} };\n\n/**\n * Default runtime when no session supplies one (mirrors noopTodoWriteStore/\n * emptyToolSchemaResolver above): every agent type is unresolvable, so `delegate`\n * stays inert -- callable, but every call fails loudly with \"unknown agent type\"\n * rather than silently spawning a child with no real authority derivation behind\n * it. Real production wiring (a resolved parent capability set, a derived\n * permission store, and a `buildChildSession` that calls `createAgentSession`) is\n * supplied by `sdk.ts`'s `createAgentSession({ delegation })` option.\n */\nconst noopDelegationRuntime: DelegationRuntimeOptions = {\n\tresolveAgent: () => undefined,\n\tgetParentCapabilities: () => new Set(),\n\tgetToolCapabilities: () => undefined,\n\tgetDelegationDepth: () => 0,\n\tmaxDelegationDepth: 2,\n\tbuildChildSession: async () => {\n\t\tthrow new Error(\"delegate has no runtime configured in this context -- no agent types are resolvable.\");\n\t},\n};\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tcase \"tool_schema\":\n\t\t\treturn createToolSchemaToolDefinition(options?.tool_schema?.resolver ?? emptyToolSchemaResolver);\n\t\tcase \"todo_write\":\n\t\t\treturn createTodoWriteToolDefinition(options?.todo_write?.store ?? noopTodoWriteStore);\n\t\tcase \"web_search\":\n\t\t\treturn createWebSearchToolDefinition(options?.web_search);\n\t\tcase \"web_fetch\":\n\t\t\treturn createWebFetchToolDefinition(options?.web_fetch);\n\t\tcase \"ask_user\":\n\t\t\treturn createAskUserToolDefinition();\n\t\tcase \"plan_present\":\n\t\t\treturn createPlanPresentToolDefinition();\n\t\tcase \"delegate\":\n\t\t\treturn createDelegateToolDefinition(options?.delegate?.runtime ?? noopDelegationRuntime);\n\t\tcase \"test\":\n\t\t\treturn createTestToolDefinition(cwd, options?.test);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"tool_schema\":\n\t\t\treturn createToolSchemaTool(options?.tool_schema?.resolver ?? emptyToolSchemaResolver);\n\t\tcase \"todo_write\":\n\t\t\treturn createTodoWriteTool(options?.todo_write?.store ?? noopTodoWriteStore);\n\t\tcase \"web_search\":\n\t\t\treturn createWebSearchTool(options?.web_search);\n\t\tcase \"web_fetch\":\n\t\t\treturn createWebFetchTool(options?.web_fetch);\n\t\tcase \"ask_user\":\n\t\t\treturn createAskUserTool();\n\t\tcase \"plan_present\":\n\t\t\treturn createPlanPresentTool();\n\t\tcase \"delegate\":\n\t\t\treturn createDelegateTool(options?.delegate?.runtime ?? noopDelegationRuntime);\n\t\tcase \"test\":\n\t\t\treturn createTestTool(cwd, options?.test);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nconst emptyToolSchemaResolver: ToolSchemaResolver = {\n\tgetTool: () => undefined,\n\tmarkLoaded: () => {},\n};\n\nexport function createAllToolDefinitions(cwd: string, options?: ToolsOptions): Record<ToolName, ToolDef> {\n\tconst definitions = {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t};\n\tconst resolver = options?.tool_schema?.resolver ?? {\n\t\tgetTool: (name: string) => definitions[name as keyof typeof definitions],\n\t\tmarkLoaded: () => {},\n\t};\n\treturn {\n\t\t...definitions,\n\t\ttool_schema: createToolSchemaToolDefinition(resolver),\n\t\ttodo_write: createTodoWriteToolDefinition(options?.todo_write?.store ?? noopTodoWriteStore),\n\t\tweb_search: createWebSearchToolDefinition(options?.web_search),\n\t\tweb_fetch: createWebFetchToolDefinition(options?.web_fetch),\n\t\task_user: createAskUserToolDefinition(),\n\t\tplan_present: createPlanPresentToolDefinition(),\n\t\tdelegate: createDelegateToolDefinition(options?.delegate?.runtime ?? noopDelegationRuntime),\n\t\ttest: createTestToolDefinition(cwd, options?.test),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\tconst definitions = createAllToolDefinitions(cwd, options);\n\tconst resolver = options?.tool_schema?.resolver ?? {\n\t\tgetTool: (name: string) => definitions[name as ToolName],\n\t\tmarkLoaded: () => {},\n\t};\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\ttool_schema: createToolSchemaTool(resolver),\n\t\ttodo_write: createTodoWriteTool(options?.todo_write?.store ?? noopTodoWriteStore),\n\t\tweb_search: createWebSearchTool(options?.web_search),\n\t\tweb_fetch: createWebFetchTool(options?.web_fetch),\n\t\task_user: createAskUserTool(),\n\t\tplan_present: createPlanPresentTool(),\n\t\tdelegate: createDelegateTool(options?.delegate?.runtime ?? noopDelegationRuntime),\n\t\ttest: createTestTool(cwd, options?.test),\n\t};\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AACvH,OAAO,EAON,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,kBAAkB,EAClB,4BAA4B,GAG5B,MAAM,eAAe,CAAC;AAWvB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,sBAAsB,GAKtB,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,aAAa,EACb,uBAAuB,GAOvB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;QACjF,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACjE,CAAC;AAAA,CACF","sourcesContent":["export { type AskUserDetails, type AskUserInput, createAskUserTool, createAskUserToolDefinition } from \"./ask-user.ts\";\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateDelegateTool,\n\tcreateDelegateToolDefinition,\n\ttype DelegateDetails,\n\ttype DelegateInput,\n} from \"./delegate.ts\";\nexport type {\n\tDiagnostic,\n\tDiagnosticEvidenceRecord,\n\tDiagnosticPosition,\n\tDiagnosticRange,\n\tDiagnosticSeverityCounts,\n\tDiagnosticsOperations,\n\tDiagnosticsOutcome,\n\tDiagnosticUnavailableKind,\n} from \"./diagnostics.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateLspTool,\n\tcreateLspToolDefinition,\n\ttype LspLocation,\n\ttype LspOperations,\n\ttype LspSymbol,\n\ttype LspToolDetails,\n\ttype LspToolInput,\n\ttype LspToolOptions,\n} from \"./lsp.ts\";\nexport {\n\tcreatePlanPresentTool,\n\tcreatePlanPresentToolDefinition,\n\ttype PlanPresentDetails,\n\ttype PlanPresentInput,\n} from \"./plan-present.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tcreateTestPermissionSpec,\n\tcreateTestTool,\n\tcreateTestToolDefinition,\n\ttype TestOperationResult,\n\ttype TestOperations,\n\ttype TestRunDetails,\n\ttype TestToolInput,\n\ttype TestToolOptions,\n} from \"./test.ts\";\nexport {\n\tcreateTodoWriteTool,\n\tcreateTodoWriteToolDefinition,\n\ttype TodoItem,\n\ttype TodoWriteDetails,\n\ttype TodoWriteInput,\n\ttype TodoWriteStore,\n} from \"./todo-write.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWebFetchTool,\n\tcreateWebFetchToolDefinition,\n\ttype WebFetchDetails,\n\ttype WebFetchInput,\n\ttype WebFetchOperations,\n\ttype WebFetchToolOptions,\n} from \"./web-fetch.ts\";\nexport {\n\tcreateWebSearchTool,\n\tcreateWebSearchToolDefinition,\n\ttype WebSearchDetails,\n\ttype WebSearchInput,\n\ttype WebSearchOperations,\n\ttype WebSearchResult,\n\ttype WebSearchToolOptions,\n} from \"./web-search.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolDetails,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"apex-code-agent-core\";\nimport type { DelegationRuntimeOptions } from \"../delegation/runtime.ts\";\nimport { createAskUserTool, createAskUserToolDefinition } from \"./ask-user.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport type { ApexToolDefinition } from \"./contract.ts\";\nimport { createDelegateTool, createDelegateToolDefinition } from \"./delegate.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createLspTool, createLspToolDefinition, type LspToolOptions } from \"./lsp.ts\";\nimport { createPlanPresentTool, createPlanPresentToolDefinition } from \"./plan-present.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createSkillSearchTool, createSkillSearchToolDefinition, type SkillSearchResolver } from \"./skill-search.ts\";\nimport { createTestTool, createTestToolDefinition, type TestToolOptions } from \"./test.ts\";\nimport { createTodoWriteTool, createTodoWriteToolDefinition, type TodoWriteStore } from \"./todo-write.ts\";\nimport { createToolSchemaTool, createToolSchemaToolDefinition, type ToolSchemaResolver } from \"./tool-schema.ts\";\nimport { createWebFetchTool, createWebFetchToolDefinition, type WebFetchToolOptions } from \"./web-fetch.ts\";\nimport { createWebSearchTool, createWebSearchToolDefinition, type WebSearchToolOptions } from \"./web-search.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ApexToolDefinition<any, any>;\nexport type ToolName =\n\t| \"read\"\n\t| \"bash\"\n\t| \"edit\"\n\t| \"write\"\n\t| \"grep\"\n\t| \"find\"\n\t| \"ls\"\n\t| \"tool_schema\"\n\t| \"todo_write\"\n\t| \"web_search\"\n\t| \"web_fetch\"\n\t| \"ask_user\"\n\t| \"plan_present\"\n\t| \"delegate\"\n\t| \"test\"\n\t| \"skill_search\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"tool_schema\",\n\t\"todo_write\",\n\t\"skill_search\",\n\t\"web_search\",\n\t\"web_fetch\",\n\t\"ask_user\",\n\t\"plan_present\",\n\t\"delegate\",\n\t\"test\",\n]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n\ttool_schema?: { resolver?: ToolSchemaResolver };\n\ttodo_write?: { store?: TodoWriteStore };\n\tskill_search?: { resolver?: SkillSearchResolver };\n\tweb_search?: WebSearchToolOptions;\n\tweb_fetch?: WebFetchToolOptions;\n\tdelegate?: { runtime?: DelegationRuntimeOptions };\n\ttest?: TestToolOptions;\n\t/**\n\t * The `lsp` navigation tool (LSP.5). Undefined by default -- the registry-building\n\t * functions below include the `lsp` key only when this is provided, which is what\n\t * keeps an unconfigured session's tool set (and static prompt prefix) unaffected.\n\t */\n\tlsp?: LspToolOptions;\n}\n\n/** Default store when no session/workspace context supplies one (mirrors emptyToolSchemaResolver below). */\nconst noopTodoWriteStore: TodoWriteStore = { write: () => {} };\n\n/**\n * Default runtime when no session supplies one (mirrors noopTodoWriteStore/\n * emptyToolSchemaResolver above): every agent type is unresolvable, so `delegate`\n * stays inert -- callable, but every call fails loudly with \"unknown agent type\"\n * rather than silently spawning a child with no real authority derivation behind\n * it. Real production wiring (a resolved parent capability set, a derived\n * permission store, and a `buildChildSession` that calls `createAgentSession`) is\n * supplied by `sdk.ts`'s `createAgentSession({ delegation })` option.\n */\nconst noopDelegationRuntime: DelegationRuntimeOptions = {\n\tresolveAgent: () => undefined,\n\tgetParentCapabilities: () => new Set(),\n\tgetToolCapabilities: () => undefined,\n\tgetDelegationDepth: () => 0,\n\tmaxDelegationDepth: 2,\n\tbuildChildSession: async () => {\n\t\tthrow new Error(\"delegate has no runtime configured in this context -- no agent types are resolvable.\");\n\t},\n};\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tcase \"tool_schema\":\n\t\t\treturn createToolSchemaToolDefinition(options?.tool_schema?.resolver ?? emptyToolSchemaResolver);\n\t\tcase \"todo_write\":\n\t\t\treturn createTodoWriteToolDefinition(options?.todo_write?.store ?? noopTodoWriteStore);\n\t\tcase \"skill_search\":\n\t\t\treturn createSkillSearchToolDefinition(options?.skill_search?.resolver ?? emptySkillSearchResolver);\n\t\tcase \"web_search\":\n\t\t\treturn createWebSearchToolDefinition(options?.web_search);\n\t\tcase \"web_fetch\":\n\t\t\treturn createWebFetchToolDefinition(options?.web_fetch);\n\t\tcase \"ask_user\":\n\t\t\treturn createAskUserToolDefinition();\n\t\tcase \"plan_present\":\n\t\t\treturn createPlanPresentToolDefinition();\n\t\tcase \"delegate\":\n\t\t\treturn createDelegateToolDefinition(options?.delegate?.runtime ?? noopDelegationRuntime);\n\t\tcase \"test\":\n\t\t\treturn createTestToolDefinition(cwd, options?.test);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"tool_schema\":\n\t\t\treturn createToolSchemaTool(options?.tool_schema?.resolver ?? emptyToolSchemaResolver);\n\t\tcase \"todo_write\":\n\t\t\treturn createTodoWriteTool(options?.todo_write?.store ?? noopTodoWriteStore);\n\t\tcase \"skill_search\":\n\t\t\treturn createSkillSearchTool(options?.skill_search?.resolver ?? emptySkillSearchResolver);\n\t\tcase \"web_search\":\n\t\t\treturn createWebSearchTool(options?.web_search);\n\t\tcase \"web_fetch\":\n\t\t\treturn createWebFetchTool(options?.web_fetch);\n\t\tcase \"ask_user\":\n\t\t\treturn createAskUserTool();\n\t\tcase \"plan_present\":\n\t\t\treturn createPlanPresentTool();\n\t\tcase \"delegate\":\n\t\t\treturn createDelegateTool(options?.delegate?.runtime ?? noopDelegationRuntime);\n\t\tcase \"test\":\n\t\t\treturn createTestTool(cwd, options?.test);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nconst emptyToolSchemaResolver: ToolSchemaResolver = {\n\tgetTool: () => undefined,\n\tmarkLoaded: () => {},\n};\n\n/** Default when no session supplies one (mirrors emptyToolSchemaResolver above): no skills known, so every search returns empty rather than throwing. */\nconst emptySkillSearchResolver: SkillSearchResolver = {\n\tgetSkills: () => [],\n};\n\nexport function createAllToolDefinitions(\n\tcwd: string,\n\toptions?: ToolsOptions,\n): Record<ToolName, ToolDef> & { lsp?: ToolDef } {\n\tconst definitions = {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t};\n\tconst resolver = options?.tool_schema?.resolver ?? {\n\t\tgetTool: (name: string) => definitions[name as keyof typeof definitions],\n\t\tmarkLoaded: () => {},\n\t};\n\treturn {\n\t\t...definitions,\n\t\ttool_schema: createToolSchemaToolDefinition(resolver),\n\t\ttodo_write: createTodoWriteToolDefinition(options?.todo_write?.store ?? noopTodoWriteStore),\n\t\tskill_search: createSkillSearchToolDefinition(options?.skill_search?.resolver ?? emptySkillSearchResolver),\n\t\tweb_search: createWebSearchToolDefinition(options?.web_search),\n\t\tweb_fetch: createWebFetchToolDefinition(options?.web_fetch),\n\t\task_user: createAskUserToolDefinition(),\n\t\tplan_present: createPlanPresentToolDefinition(),\n\t\tdelegate: createDelegateToolDefinition(options?.delegate?.runtime ?? noopDelegationRuntime),\n\t\ttest: createTestToolDefinition(cwd, options?.test),\n\t\t// Registered only when configured (LSP.5): an unconfigured session's registry,\n\t\t// and therefore its static prompt prefix, is unaffected by this subsystem.\n\t\t...(options?.lsp ? { lsp: createLspToolDefinition(cwd, options.lsp) } : {}),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> & { lsp?: Tool } {\n\tconst definitions = createAllToolDefinitions(cwd, options);\n\tconst resolver = options?.tool_schema?.resolver ?? {\n\t\tgetTool: (name: string) => definitions[name as ToolName],\n\t\tmarkLoaded: () => {},\n\t};\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\ttool_schema: createToolSchemaTool(resolver),\n\t\ttodo_write: createTodoWriteTool(options?.todo_write?.store ?? noopTodoWriteStore),\n\t\tskill_search: createSkillSearchTool(options?.skill_search?.resolver ?? emptySkillSearchResolver),\n\t\tweb_search: createWebSearchTool(options?.web_search),\n\t\tweb_fetch: createWebFetchTool(options?.web_fetch),\n\t\task_user: createAskUserTool(),\n\t\tplan_present: createPlanPresentTool(),\n\t\tdelegate: createDelegateTool(options?.delegate?.runtime ?? noopDelegationRuntime),\n\t\ttest: createTestTool(cwd, options?.test),\n\t\t...(options?.lsp ? { lsp: createLspTool(cwd, options.lsp) } : {}),\n\t};\n}\n"]}
@@ -0,0 +1,62 @@
1
+ import type { AgentTool } from "apex-code-agent-core";
2
+ import { type Static, Type } from "typebox";
3
+ import type { ApexToolDefinition } from "./contract.ts";
4
+ declare const lspSchema: Type.TUnion<[Type.TObject<{
5
+ operation: Type.TUnion<[Type.TLiteral<"definition">, Type.TLiteral<"references">]>;
6
+ path: Type.TString;
7
+ line: Type.TNumber;
8
+ character: Type.TNumber;
9
+ }>, Type.TObject<{
10
+ operation: Type.TLiteral<"document_symbols">;
11
+ path: Type.TString;
12
+ }>]>;
13
+ export type LspToolInput = Static<typeof lspSchema>;
14
+ export interface LspPosition {
15
+ readonly line: number;
16
+ readonly character: number;
17
+ }
18
+ export interface LspRange {
19
+ readonly start: LspPosition;
20
+ readonly end: LspPosition;
21
+ }
22
+ /** A navigation result normalized to a workspace-relative path and one-based range. */
23
+ export interface LspLocation {
24
+ readonly path: string;
25
+ readonly range: LspRange;
26
+ }
27
+ /** A flattened document symbol normalized to a workspace-relative path and one-based ranges. */
28
+ export interface LspSymbol {
29
+ readonly name: string;
30
+ readonly kind: number;
31
+ readonly path: string;
32
+ readonly range: LspRange;
33
+ readonly selectionRange: LspRange;
34
+ readonly detail?: string;
35
+ }
36
+ export type LspToolDetails = {
37
+ operation: "definition" | "references";
38
+ locations: LspLocation[];
39
+ omitted: number;
40
+ truncated: number;
41
+ } | {
42
+ operation: "document_symbols";
43
+ symbols: LspSymbol[];
44
+ omitted: number;
45
+ truncated: number;
46
+ };
47
+ /**
48
+ * Pluggable transport for the `lsp` tool. The executable, its arguments, and the
49
+ * closed JSON-RPC method set are all fixed by configuration the tool never chooses
50
+ * itself -- see contract.capabilities below for why that keeps this `{fs.read}`
51
+ * rather than `{exec}`.
52
+ */
53
+ export interface LspOperations {
54
+ request(absolutePath: string, method: string, params: unknown, signal?: AbortSignal): Promise<unknown>;
55
+ }
56
+ export interface LspToolOptions {
57
+ operations: LspOperations;
58
+ }
59
+ export declare function createLspToolDefinition(cwd: string, options: LspToolOptions): ApexToolDefinition<typeof lspSchema, LspToolDetails>;
60
+ export declare function createLspTool(cwd: string, options: LspToolOptions): AgentTool<typeof lspSchema>;
61
+ export {};
62
+ //# sourceMappingURL=lsp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lsp.d.ts","sourceRoot":"","sources":["../../../src/core/tools/lsp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAsBxD,QAAA,MAAM,SAAS;;;;;;;;IAA8D,CAAC;AAE9E,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC;AAEpD,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;CAC1B;AAED,uFAAuF;AACvF,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;CACzB;AAED,gGAAgG;AAChG,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,cAAc,GACvB;IAAE,SAAS,EAAE,YAAY,GAAG,YAAY,CAAC;IAAC,SAAS,EAAE,WAAW,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACxG;IAAE,SAAS,EAAE,kBAAkB,CAAC;IAAC,OAAO,EAAE,SAAS,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/F;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC7B,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACvG;AAED,MAAM,WAAW,cAAc;IAC9B,UAAU,EAAE,aAAa,CAAC;CAC1B;AAwJD,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,cAAc,GACrB,kBAAkB,CAAC,OAAO,SAAS,EAAE,cAAc,CAAC,CAwDtD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,SAAS,CAAC,OAAO,SAAS,CAAC,CAE/F","sourcesContent":["import { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { AgentTool } from \"apex-code-agent-core\";\nimport { type Static, Type } from \"typebox\";\nimport { formatPathRelativeToCwdOrAbsolute } from \"../../utils/paths.ts\";\nimport type { ApexToolDefinition } from \"./contract.ts\";\nimport { createPathPermissionSpec } from \"./path-permission.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst MAX_LOCATIONS = 1_000;\nconst MAX_SYMBOLS = 2_000;\n\nconst lspNavigationSchema = Type.Object({\n\toperation: Type.Union([Type.Literal(\"definition\"), Type.Literal(\"references\")], {\n\t\tdescription: \"Which navigation query to run.\",\n\t}),\n\tpath: Type.String({ description: \"Path to the file (relative or absolute).\" }),\n\tline: Type.Number({ description: \"One-based line number.\" }),\n\tcharacter: Type.Number({ description: \"One-based UTF-16 character offset within the line.\" }),\n});\n\nconst lspDocumentSymbolsSchema = Type.Object({\n\toperation: Type.Literal(\"document_symbols\", { description: \"List the symbols declared in a file.\" }),\n\tpath: Type.String({ description: \"Path to the file (relative or absolute).\" }),\n});\n\nconst lspSchema = Type.Union([lspNavigationSchema, lspDocumentSymbolsSchema]);\n\nexport type LspToolInput = Static<typeof lspSchema>;\n\nexport interface LspPosition {\n\treadonly line: number;\n\treadonly character: number;\n}\n\nexport interface LspRange {\n\treadonly start: LspPosition;\n\treadonly end: LspPosition;\n}\n\n/** A navigation result normalized to a workspace-relative path and one-based range. */\nexport interface LspLocation {\n\treadonly path: string;\n\treadonly range: LspRange;\n}\n\n/** A flattened document symbol normalized to a workspace-relative path and one-based ranges. */\nexport interface LspSymbol {\n\treadonly name: string;\n\treadonly kind: number;\n\treadonly path: string;\n\treadonly range: LspRange;\n\treadonly selectionRange: LspRange;\n\treadonly detail?: string;\n}\n\nexport type LspToolDetails =\n\t| { operation: \"definition\" | \"references\"; locations: LspLocation[]; omitted: number; truncated: number }\n\t| { operation: \"document_symbols\"; symbols: LspSymbol[]; omitted: number; truncated: number };\n\n/**\n * Pluggable transport for the `lsp` tool. The executable, its arguments, and the\n * closed JSON-RPC method set are all fixed by configuration the tool never chooses\n * itself -- see contract.capabilities below for why that keeps this `{fs.read}`\n * rather than `{exec}`.\n */\nexport interface LspOperations {\n\trequest(absolutePath: string, method: string, params: unknown, signal?: AbortSignal): Promise<unknown>;\n}\n\nexport interface LspToolOptions {\n\toperations: LspOperations;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isPosition(value: unknown): value is LspPosition {\n\treturn isRecord(value) && typeof value.line === \"number\" && typeof value.character === \"number\";\n}\n\nfunction isRange(value: unknown): value is LspRange {\n\treturn isRecord(value) && isPosition(value.start) && isPosition(value.end);\n}\n\nfunction toOneBasedPosition(position: LspPosition): LspPosition {\n\treturn { line: position.line + 1, character: position.character + 1 };\n}\n\nfunction toOneBasedRange(range: LspRange): LspRange {\n\treturn { start: toOneBasedPosition(range.start), end: toOneBasedPosition(range.end) };\n}\n\nfunction fileUriToAbsolutePath(uri: string): string | undefined {\n\tif (!uri.startsWith(\"file:\")) return undefined;\n\ttry {\n\t\treturn fileURLToPath(uri);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction rawLocationUriAndRange(value: unknown): { uri: string; range: LspRange } | undefined {\n\tif (!isRecord(value)) return undefined;\n\tif (typeof value.uri === \"string\" && isRange(value.range)) return { uri: value.uri, range: value.range };\n\tif (typeof value.targetUri === \"string\" && isRange(value.targetRange)) {\n\t\treturn { uri: value.targetUri, range: value.targetRange };\n\t}\n\treturn undefined;\n}\n\nfunction normalizeLocations(raw: unknown, cwd: string): { locations: LspLocation[]; omitted: number } {\n\tconst items = Array.isArray(raw) ? raw : raw === undefined || raw === null ? [] : [raw];\n\tconst locations: LspLocation[] = [];\n\tlet omitted = 0;\n\tfor (const item of items) {\n\t\tconst parsed = rawLocationUriAndRange(item);\n\t\tconst absolutePath = parsed ? fileUriToAbsolutePath(parsed.uri) : undefined;\n\t\tif (!parsed || !absolutePath) {\n\t\t\tomitted++;\n\t\t\tcontinue;\n\t\t}\n\t\tlocations.push({\n\t\t\tpath: formatPathRelativeToCwdOrAbsolute(absolutePath, cwd),\n\t\t\trange: toOneBasedRange(parsed.range),\n\t\t});\n\t}\n\treturn { locations, omitted };\n}\n\nfunction compareLocations(a: LspLocation, b: LspLocation): number {\n\tif (a.path !== b.path) return a.path < b.path ? -1 : 1;\n\tif (a.range.start.line !== b.range.start.line) return a.range.start.line - b.range.start.line;\n\tif (a.range.start.character !== b.range.start.character) return a.range.start.character - b.range.start.character;\n\tif (a.range.end.line !== b.range.end.line) return a.range.end.line - b.range.end.line;\n\treturn a.range.end.character - b.range.end.character;\n}\n\nfunction dedupeSortAndCap(locations: LspLocation[], max: number): { locations: LspLocation[]; truncated: number } {\n\tconst seen = new Set<string>();\n\tconst unique: LspLocation[] = [];\n\tfor (const location of locations) {\n\t\tconst key = JSON.stringify(location);\n\t\tif (seen.has(key)) continue;\n\t\tseen.add(key);\n\t\tunique.push(location);\n\t}\n\tunique.sort(compareLocations);\n\tconst capped = unique.slice(0, max);\n\treturn { locations: capped, truncated: unique.length - capped.length };\n}\n\nfunction isRawDocumentSymbol(value: unknown): value is Record<string, unknown> {\n\treturn isRecord(value) && typeof value.name === \"string\" && isRange(value.range) && isRange(value.selectionRange);\n}\n\nfunction flattenSymbols(raw: unknown, path: string): { symbols: LspSymbol[]; omitted: number } {\n\tconst symbols: LspSymbol[] = [];\n\tlet omitted = 0;\n\tconst visit = (value: unknown): void => {\n\t\tif (!Array.isArray(value)) return;\n\t\tfor (const item of value) {\n\t\t\tif (!isRawDocumentSymbol(item)) {\n\t\t\t\tomitted++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tsymbols.push({\n\t\t\t\tname: item.name as string,\n\t\t\t\tkind: typeof item.kind === \"number\" ? item.kind : 0,\n\t\t\t\tpath,\n\t\t\t\trange: toOneBasedRange(item.range as LspRange),\n\t\t\t\tselectionRange: toOneBasedRange(item.selectionRange as LspRange),\n\t\t\t\t...(typeof item.detail === \"string\" ? { detail: item.detail } : {}),\n\t\t\t});\n\t\t\tif (Array.isArray(item.children)) visit(item.children);\n\t\t}\n\t};\n\tvisit(Array.isArray(raw) ? raw : []);\n\treturn { symbols, omitted };\n}\n\nfunction compareSymbols(a: LspSymbol, b: LspSymbol): number {\n\tif (a.range.start.line !== b.range.start.line) return a.range.start.line - b.range.start.line;\n\tif (a.range.start.character !== b.range.start.character) return a.range.start.character - b.range.start.character;\n\treturn a.name === b.name ? 0 : a.name < b.name ? -1 : 1;\n}\n\nfunction capSymbols(symbols: LspSymbol[], max: number): { symbols: LspSymbol[]; truncated: number } {\n\tconst sorted = [...symbols].sort(compareSymbols);\n\tconst capped = sorted.slice(0, max);\n\treturn { symbols: capped, truncated: sorted.length - capped.length };\n}\n\nfunction formatNotices(omitted: number, truncated: number): string {\n\tconst notices: string[] = [];\n\tif (omitted > 0) notices.push(`${omitted} non-file result(s) omitted`);\n\tif (truncated > 0) notices.push(`${truncated} result(s) truncated`);\n\treturn notices.length > 0 ? `\\n\\n[${notices.join(\", \")}]` : \"\";\n}\n\nfunction formatLocationsText(\n\toperation: \"definition\" | \"references\",\n\tlocations: LspLocation[],\n\tomitted: number,\n\ttruncated: number,\n): string {\n\tif (locations.length === 0) {\n\t\treturn operation === \"definition\" ? \"No definition found.\" : \"No references found.\";\n\t}\n\tconst lines = locations.map(\n\t\t(location) => `${location.path}:${location.range.start.line}:${location.range.start.character}`,\n\t);\n\treturn `${lines.join(\"\\n\")}${formatNotices(omitted, truncated)}`;\n}\n\nfunction formatSymbolsText(symbols: LspSymbol[], omitted: number, truncated: number): string {\n\tif (symbols.length === 0) return \"No symbols found.\";\n\tconst lines = symbols.map(\n\t\t(symbol) => `${symbol.path}:${symbol.range.start.line}:${symbol.range.start.character} ${symbol.name}`,\n\t);\n\treturn `${lines.join(\"\\n\")}${formatNotices(omitted, truncated)}`;\n}\n\nexport function createLspToolDefinition(\n\tcwd: string,\n\toptions: LspToolOptions,\n): ApexToolDefinition<typeof lspSchema, LspToolDetails> {\n\tconst { operations } = options;\n\treturn {\n\t\tname: \"lsp\",\n\t\tlabel: \"lsp\",\n\t\tdescription: \"Query the configured language server for definitions, references, or symbols.\",\n\t\tparameters: lspSchema,\n\t\tcontract: {\n\t\t\t// `grep` spawns `rg` and declares {fs.read}, not {exec}, because the caller\n\t\t\t// never chooses what runs -- the executable, args, and closed JSON-RPC\n\t\t\t// method set all come from settings.json / this tool's own code. Same\n\t\t\t// reasoning here: {exec} would silently widen a delegation ceiling for no\n\t\t\t// capability the model can actually reach through this tool.\n\t\t\tcapabilities: new Set([\"fs.read\"]),\n\t\t\tpermission: createPathPermissionSpec({\n\t\t\t\tcwd,\n\t\t\t\tdefaultBehavior: \"allow\",\n\t\t\t\tverb: \"Query\",\n\t\t\t\tgetPath: (params) => params.path,\n\t\t\t}),\n\t\t\tcontext: { resultRecoverable: true, deferSchema: true },\n\t\t\tevidence: { emits: new Set(), capture: () => [] },\n\t\t},\n\t\tasync execute(_toolCallId, input: LspToolInput, signal?: AbortSignal) {\n\t\t\tconst absolutePath = resolveToCwd(input.path, cwd);\n\t\t\tconst uri = pathToFileURL(absolutePath).href;\n\n\t\t\tif (input.operation === \"document_symbols\") {\n\t\t\t\tconst raw = await operations.request(\n\t\t\t\t\tabsolutePath,\n\t\t\t\t\t\"textDocument/documentSymbol\",\n\t\t\t\t\t{ textDocument: { uri } },\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t\tconst relativePath = formatPathRelativeToCwdOrAbsolute(absolutePath, cwd);\n\t\t\t\tconst { symbols, omitted } = flattenSymbols(raw, relativePath);\n\t\t\t\tconst { symbols: capped, truncated } = capSymbols(symbols, MAX_SYMBOLS);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: formatSymbolsText(capped, omitted, truncated) }],\n\t\t\t\t\tdetails: { operation: \"document_symbols\", symbols: capped, omitted, truncated },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst position = { line: input.line - 1, character: input.character - 1 };\n\t\t\tconst method = input.operation === \"definition\" ? \"textDocument/definition\" : \"textDocument/references\";\n\t\t\tconst params: Record<string, unknown> = { textDocument: { uri }, position };\n\t\t\tif (input.operation === \"references\") params.context = { includeDeclaration: true };\n\t\t\tconst raw = await operations.request(absolutePath, method, params, signal);\n\t\t\tconst { locations, omitted } = normalizeLocations(raw, cwd);\n\t\t\tconst { locations: capped, truncated } = dedupeSortAndCap(locations, MAX_LOCATIONS);\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: formatLocationsText(input.operation, capped, omitted, truncated) }],\n\t\t\t\tdetails: { operation: input.operation, locations: capped, omitted, truncated },\n\t\t\t};\n\t\t},\n\t};\n}\n\nexport function createLspTool(cwd: string, options: LspToolOptions): AgentTool<typeof lspSchema> {\n\treturn wrapToolDefinition(createLspToolDefinition(cwd, options));\n}\n"]}
@@ -0,0 +1,216 @@
1
+ import { fileURLToPath, pathToFileURL } from "node:url";
2
+ import { Type } from "typebox";
3
+ import { formatPathRelativeToCwdOrAbsolute } from "../../utils/paths.js";
4
+ import { createPathPermissionSpec } from "./path-permission.js";
5
+ import { resolveToCwd } from "./path-utils.js";
6
+ import { wrapToolDefinition } from "./tool-definition-wrapper.js";
7
+ const MAX_LOCATIONS = 1_000;
8
+ const MAX_SYMBOLS = 2_000;
9
+ const lspNavigationSchema = Type.Object({
10
+ operation: Type.Union([Type.Literal("definition"), Type.Literal("references")], {
11
+ description: "Which navigation query to run.",
12
+ }),
13
+ path: Type.String({ description: "Path to the file (relative or absolute)." }),
14
+ line: Type.Number({ description: "One-based line number." }),
15
+ character: Type.Number({ description: "One-based UTF-16 character offset within the line." }),
16
+ });
17
+ const lspDocumentSymbolsSchema = Type.Object({
18
+ operation: Type.Literal("document_symbols", { description: "List the symbols declared in a file." }),
19
+ path: Type.String({ description: "Path to the file (relative or absolute)." }),
20
+ });
21
+ const lspSchema = Type.Union([lspNavigationSchema, lspDocumentSymbolsSchema]);
22
+ function isRecord(value) {
23
+ return typeof value === "object" && value !== null && !Array.isArray(value);
24
+ }
25
+ function isPosition(value) {
26
+ return isRecord(value) && typeof value.line === "number" && typeof value.character === "number";
27
+ }
28
+ function isRange(value) {
29
+ return isRecord(value) && isPosition(value.start) && isPosition(value.end);
30
+ }
31
+ function toOneBasedPosition(position) {
32
+ return { line: position.line + 1, character: position.character + 1 };
33
+ }
34
+ function toOneBasedRange(range) {
35
+ return { start: toOneBasedPosition(range.start), end: toOneBasedPosition(range.end) };
36
+ }
37
+ function fileUriToAbsolutePath(uri) {
38
+ if (!uri.startsWith("file:"))
39
+ return undefined;
40
+ try {
41
+ return fileURLToPath(uri);
42
+ }
43
+ catch {
44
+ return undefined;
45
+ }
46
+ }
47
+ function rawLocationUriAndRange(value) {
48
+ if (!isRecord(value))
49
+ return undefined;
50
+ if (typeof value.uri === "string" && isRange(value.range))
51
+ return { uri: value.uri, range: value.range };
52
+ if (typeof value.targetUri === "string" && isRange(value.targetRange)) {
53
+ return { uri: value.targetUri, range: value.targetRange };
54
+ }
55
+ return undefined;
56
+ }
57
+ function normalizeLocations(raw, cwd) {
58
+ const items = Array.isArray(raw) ? raw : raw === undefined || raw === null ? [] : [raw];
59
+ const locations = [];
60
+ let omitted = 0;
61
+ for (const item of items) {
62
+ const parsed = rawLocationUriAndRange(item);
63
+ const absolutePath = parsed ? fileUriToAbsolutePath(parsed.uri) : undefined;
64
+ if (!parsed || !absolutePath) {
65
+ omitted++;
66
+ continue;
67
+ }
68
+ locations.push({
69
+ path: formatPathRelativeToCwdOrAbsolute(absolutePath, cwd),
70
+ range: toOneBasedRange(parsed.range),
71
+ });
72
+ }
73
+ return { locations, omitted };
74
+ }
75
+ function compareLocations(a, b) {
76
+ if (a.path !== b.path)
77
+ return a.path < b.path ? -1 : 1;
78
+ if (a.range.start.line !== b.range.start.line)
79
+ return a.range.start.line - b.range.start.line;
80
+ if (a.range.start.character !== b.range.start.character)
81
+ return a.range.start.character - b.range.start.character;
82
+ if (a.range.end.line !== b.range.end.line)
83
+ return a.range.end.line - b.range.end.line;
84
+ return a.range.end.character - b.range.end.character;
85
+ }
86
+ function dedupeSortAndCap(locations, max) {
87
+ const seen = new Set();
88
+ const unique = [];
89
+ for (const location of locations) {
90
+ const key = JSON.stringify(location);
91
+ if (seen.has(key))
92
+ continue;
93
+ seen.add(key);
94
+ unique.push(location);
95
+ }
96
+ unique.sort(compareLocations);
97
+ const capped = unique.slice(0, max);
98
+ return { locations: capped, truncated: unique.length - capped.length };
99
+ }
100
+ function isRawDocumentSymbol(value) {
101
+ return isRecord(value) && typeof value.name === "string" && isRange(value.range) && isRange(value.selectionRange);
102
+ }
103
+ function flattenSymbols(raw, path) {
104
+ const symbols = [];
105
+ let omitted = 0;
106
+ const visit = (value) => {
107
+ if (!Array.isArray(value))
108
+ return;
109
+ for (const item of value) {
110
+ if (!isRawDocumentSymbol(item)) {
111
+ omitted++;
112
+ continue;
113
+ }
114
+ symbols.push({
115
+ name: item.name,
116
+ kind: typeof item.kind === "number" ? item.kind : 0,
117
+ path,
118
+ range: toOneBasedRange(item.range),
119
+ selectionRange: toOneBasedRange(item.selectionRange),
120
+ ...(typeof item.detail === "string" ? { detail: item.detail } : {}),
121
+ });
122
+ if (Array.isArray(item.children))
123
+ visit(item.children);
124
+ }
125
+ };
126
+ visit(Array.isArray(raw) ? raw : []);
127
+ return { symbols, omitted };
128
+ }
129
+ function compareSymbols(a, b) {
130
+ if (a.range.start.line !== b.range.start.line)
131
+ return a.range.start.line - b.range.start.line;
132
+ if (a.range.start.character !== b.range.start.character)
133
+ return a.range.start.character - b.range.start.character;
134
+ return a.name === b.name ? 0 : a.name < b.name ? -1 : 1;
135
+ }
136
+ function capSymbols(symbols, max) {
137
+ const sorted = [...symbols].sort(compareSymbols);
138
+ const capped = sorted.slice(0, max);
139
+ return { symbols: capped, truncated: sorted.length - capped.length };
140
+ }
141
+ function formatNotices(omitted, truncated) {
142
+ const notices = [];
143
+ if (omitted > 0)
144
+ notices.push(`${omitted} non-file result(s) omitted`);
145
+ if (truncated > 0)
146
+ notices.push(`${truncated} result(s) truncated`);
147
+ return notices.length > 0 ? `\n\n[${notices.join(", ")}]` : "";
148
+ }
149
+ function formatLocationsText(operation, locations, omitted, truncated) {
150
+ if (locations.length === 0) {
151
+ return operation === "definition" ? "No definition found." : "No references found.";
152
+ }
153
+ const lines = locations.map((location) => `${location.path}:${location.range.start.line}:${location.range.start.character}`);
154
+ return `${lines.join("\n")}${formatNotices(omitted, truncated)}`;
155
+ }
156
+ function formatSymbolsText(symbols, omitted, truncated) {
157
+ if (symbols.length === 0)
158
+ return "No symbols found.";
159
+ const lines = symbols.map((symbol) => `${symbol.path}:${symbol.range.start.line}:${symbol.range.start.character} ${symbol.name}`);
160
+ return `${lines.join("\n")}${formatNotices(omitted, truncated)}`;
161
+ }
162
+ export function createLspToolDefinition(cwd, options) {
163
+ const { operations } = options;
164
+ return {
165
+ name: "lsp",
166
+ label: "lsp",
167
+ description: "Query the configured language server for definitions, references, or symbols.",
168
+ parameters: lspSchema,
169
+ contract: {
170
+ // `grep` spawns `rg` and declares {fs.read}, not {exec}, because the caller
171
+ // never chooses what runs -- the executable, args, and closed JSON-RPC
172
+ // method set all come from settings.json / this tool's own code. Same
173
+ // reasoning here: {exec} would silently widen a delegation ceiling for no
174
+ // capability the model can actually reach through this tool.
175
+ capabilities: new Set(["fs.read"]),
176
+ permission: createPathPermissionSpec({
177
+ cwd,
178
+ defaultBehavior: "allow",
179
+ verb: "Query",
180
+ getPath: (params) => params.path,
181
+ }),
182
+ context: { resultRecoverable: true, deferSchema: true },
183
+ evidence: { emits: new Set(), capture: () => [] },
184
+ },
185
+ async execute(_toolCallId, input, signal) {
186
+ const absolutePath = resolveToCwd(input.path, cwd);
187
+ const uri = pathToFileURL(absolutePath).href;
188
+ if (input.operation === "document_symbols") {
189
+ const raw = await operations.request(absolutePath, "textDocument/documentSymbol", { textDocument: { uri } }, signal);
190
+ const relativePath = formatPathRelativeToCwdOrAbsolute(absolutePath, cwd);
191
+ const { symbols, omitted } = flattenSymbols(raw, relativePath);
192
+ const { symbols: capped, truncated } = capSymbols(symbols, MAX_SYMBOLS);
193
+ return {
194
+ content: [{ type: "text", text: formatSymbolsText(capped, omitted, truncated) }],
195
+ details: { operation: "document_symbols", symbols: capped, omitted, truncated },
196
+ };
197
+ }
198
+ const position = { line: input.line - 1, character: input.character - 1 };
199
+ const method = input.operation === "definition" ? "textDocument/definition" : "textDocument/references";
200
+ const params = { textDocument: { uri }, position };
201
+ if (input.operation === "references")
202
+ params.context = { includeDeclaration: true };
203
+ const raw = await operations.request(absolutePath, method, params, signal);
204
+ const { locations, omitted } = normalizeLocations(raw, cwd);
205
+ const { locations: capped, truncated } = dedupeSortAndCap(locations, MAX_LOCATIONS);
206
+ return {
207
+ content: [{ type: "text", text: formatLocationsText(input.operation, capped, omitted, truncated) }],
208
+ details: { operation: input.operation, locations: capped, omitted, truncated },
209
+ };
210
+ },
211
+ };
212
+ }
213
+ export function createLspTool(cwd, options) {
214
+ return wrapToolDefinition(createLspToolDefinition(cwd, options));
215
+ }
216
+ //# sourceMappingURL=lsp.js.map