@codeany/open-agent-sdk 0.2.1 → 0.2.2

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 (232) hide show
  1. package/.env.example +8 -0
  2. package/examples/01-simple-query.ts +43 -0
  3. package/examples/02-multi-tool.ts +44 -0
  4. package/examples/03-multi-turn.ts +39 -0
  5. package/examples/04-prompt-api.ts +29 -0
  6. package/examples/05-custom-system-prompt.ts +26 -0
  7. package/examples/06-mcp-server.ts +49 -0
  8. package/examples/07-custom-tools.ts +87 -0
  9. package/examples/08-official-api-compat.ts +38 -0
  10. package/examples/09-subagents.ts +48 -0
  11. package/examples/10-permissions.ts +40 -0
  12. package/examples/11-custom-mcp-tools.ts +101 -0
  13. package/examples/12-skills.ts +88 -0
  14. package/examples/13-hooks.ts +88 -0
  15. package/examples/14-openai-compat.ts +71 -0
  16. package/examples/web/index.html +365 -0
  17. package/examples/web/server.ts +157 -0
  18. package/package.json +1 -7
  19. package/src/engine.ts +3 -0
  20. package/tsconfig.json +19 -0
  21. package/dist/agent.d.ts +0 -113
  22. package/dist/agent.d.ts.map +0 -1
  23. package/dist/agent.js +0 -446
  24. package/dist/agent.js.map +0 -1
  25. package/dist/engine.d.ts +0 -62
  26. package/dist/engine.d.ts.map +0 -1
  27. package/dist/engine.js +0 -494
  28. package/dist/engine.js.map +0 -1
  29. package/dist/hooks.d.ts +0 -111
  30. package/dist/hooks.d.ts.map +0 -1
  31. package/dist/hooks.js +0 -179
  32. package/dist/hooks.js.map +0 -1
  33. package/dist/index.d.ts +0 -66
  34. package/dist/index.d.ts.map +0 -1
  35. package/dist/index.js +0 -133
  36. package/dist/index.js.map +0 -1
  37. package/dist/mcp/client.d.ts +0 -19
  38. package/dist/mcp/client.d.ts.map +0 -1
  39. package/dist/mcp/client.js +0 -126
  40. package/dist/mcp/client.js.map +0 -1
  41. package/dist/providers/anthropic.d.ts +0 -17
  42. package/dist/providers/anthropic.d.ts.map +0 -1
  43. package/dist/providers/anthropic.js +0 -47
  44. package/dist/providers/anthropic.js.map +0 -1
  45. package/dist/providers/index.d.ts +0 -20
  46. package/dist/providers/index.d.ts.map +0 -1
  47. package/dist/providers/index.js +0 -26
  48. package/dist/providers/index.js.map +0 -1
  49. package/dist/providers/openai.d.ts +0 -26
  50. package/dist/providers/openai.d.ts.map +0 -1
  51. package/dist/providers/openai.js +0 -212
  52. package/dist/providers/openai.js.map +0 -1
  53. package/dist/providers/types.d.ts +0 -84
  54. package/dist/providers/types.d.ts.map +0 -1
  55. package/dist/providers/types.js +0 -11
  56. package/dist/providers/types.js.map +0 -1
  57. package/dist/sdk-mcp-server.d.ts +0 -52
  58. package/dist/sdk-mcp-server.d.ts.map +0 -1
  59. package/dist/sdk-mcp-server.js +0 -57
  60. package/dist/sdk-mcp-server.js.map +0 -1
  61. package/dist/session.d.ts +0 -73
  62. package/dist/session.d.ts.map +0 -1
  63. package/dist/session.js +0 -159
  64. package/dist/session.js.map +0 -1
  65. package/dist/skills/bundled/commit.d.ts +0 -7
  66. package/dist/skills/bundled/commit.d.ts.map +0 -1
  67. package/dist/skills/bundled/commit.js +0 -35
  68. package/dist/skills/bundled/commit.js.map +0 -1
  69. package/dist/skills/bundled/debug.d.ts +0 -7
  70. package/dist/skills/bundled/debug.d.ts.map +0 -1
  71. package/dist/skills/bundled/debug.js +0 -46
  72. package/dist/skills/bundled/debug.js.map +0 -1
  73. package/dist/skills/bundled/index.d.ts +0 -11
  74. package/dist/skills/bundled/index.d.ts.map +0 -1
  75. package/dist/skills/bundled/index.js +0 -26
  76. package/dist/skills/bundled/index.js.map +0 -1
  77. package/dist/skills/bundled/review.d.ts +0 -7
  78. package/dist/skills/bundled/review.d.ts.map +0 -1
  79. package/dist/skills/bundled/review.js +0 -38
  80. package/dist/skills/bundled/review.js.map +0 -1
  81. package/dist/skills/bundled/simplify.d.ts +0 -8
  82. package/dist/skills/bundled/simplify.d.ts.map +0 -1
  83. package/dist/skills/bundled/simplify.js +0 -48
  84. package/dist/skills/bundled/simplify.js.map +0 -1
  85. package/dist/skills/bundled/test.d.ts +0 -7
  86. package/dist/skills/bundled/test.d.ts.map +0 -1
  87. package/dist/skills/bundled/test.js +0 -40
  88. package/dist/skills/bundled/test.js.map +0 -1
  89. package/dist/skills/index.d.ts +0 -7
  90. package/dist/skills/index.d.ts.map +0 -1
  91. package/dist/skills/index.js +0 -8
  92. package/dist/skills/index.js.map +0 -1
  93. package/dist/skills/registry.d.ts +0 -43
  94. package/dist/skills/registry.d.ts.map +0 -1
  95. package/dist/skills/registry.js +0 -111
  96. package/dist/skills/registry.js.map +0 -1
  97. package/dist/skills/types.d.ts +0 -83
  98. package/dist/skills/types.d.ts.map +0 -1
  99. package/dist/skills/types.js +0 -8
  100. package/dist/skills/types.js.map +0 -1
  101. package/dist/tool-helper.d.ts +0 -73
  102. package/dist/tool-helper.d.ts.map +0 -1
  103. package/dist/tool-helper.js +0 -86
  104. package/dist/tool-helper.js.map +0 -1
  105. package/dist/tools/agent-tool.d.ts +0 -17
  106. package/dist/tools/agent-tool.d.ts.map +0 -1
  107. package/dist/tools/agent-tool.js +0 -146
  108. package/dist/tools/agent-tool.js.map +0 -1
  109. package/dist/tools/ask-user.d.ts +0 -18
  110. package/dist/tools/ask-user.d.ts.map +0 -1
  111. package/dist/tools/ask-user.js +0 -72
  112. package/dist/tools/ask-user.js.map +0 -1
  113. package/dist/tools/bash.d.ts +0 -5
  114. package/dist/tools/bash.d.ts.map +0 -1
  115. package/dist/tools/bash.js +0 -67
  116. package/dist/tools/bash.js.map +0 -1
  117. package/dist/tools/config-tool.d.ts +0 -20
  118. package/dist/tools/config-tool.d.ts.map +0 -1
  119. package/dist/tools/config-tool.js +0 -83
  120. package/dist/tools/config-tool.js.map +0 -1
  121. package/dist/tools/cron-tools.d.ts +0 -33
  122. package/dist/tools/cron-tools.d.ts.map +0 -1
  123. package/dist/tools/cron-tools.js +0 -128
  124. package/dist/tools/cron-tools.js.map +0 -1
  125. package/dist/tools/edit.d.ts +0 -5
  126. package/dist/tools/edit.d.ts.map +0 -1
  127. package/dist/tools/edit.js +0 -70
  128. package/dist/tools/edit.js.map +0 -1
  129. package/dist/tools/glob.d.ts +0 -5
  130. package/dist/tools/glob.d.ts.map +0 -1
  131. package/dist/tools/glob.js +0 -75
  132. package/dist/tools/glob.js.map +0 -1
  133. package/dist/tools/grep.d.ts +0 -5
  134. package/dist/tools/grep.d.ts.map +0 -1
  135. package/dist/tools/grep.js +0 -168
  136. package/dist/tools/grep.js.map +0 -1
  137. package/dist/tools/index.d.ts +0 -45
  138. package/dist/tools/index.d.ts.map +0 -1
  139. package/dist/tools/index.js +0 -162
  140. package/dist/tools/index.js.map +0 -1
  141. package/dist/tools/lsp-tool.d.ts +0 -9
  142. package/dist/tools/lsp-tool.d.ts.map +0 -1
  143. package/dist/tools/lsp-tool.js +0 -137
  144. package/dist/tools/lsp-tool.js.map +0 -1
  145. package/dist/tools/mcp-resource-tools.d.ts +0 -14
  146. package/dist/tools/mcp-resource-tools.d.ts.map +0 -1
  147. package/dist/tools/mcp-resource-tools.js +0 -117
  148. package/dist/tools/mcp-resource-tools.js.map +0 -1
  149. package/dist/tools/notebook-edit.d.ts +0 -5
  150. package/dist/tools/notebook-edit.d.ts.map +0 -1
  151. package/dist/tools/notebook-edit.js +0 -85
  152. package/dist/tools/notebook-edit.js.map +0 -1
  153. package/dist/tools/plan-tools.d.ts +0 -12
  154. package/dist/tools/plan-tools.d.ts.map +0 -1
  155. package/dist/tools/plan-tools.js +0 -77
  156. package/dist/tools/plan-tools.js.map +0 -1
  157. package/dist/tools/read.d.ts +0 -5
  158. package/dist/tools/read.d.ts.map +0 -1
  159. package/dist/tools/read.js +0 -66
  160. package/dist/tools/read.js.map +0 -1
  161. package/dist/tools/send-message.d.ts +0 -31
  162. package/dist/tools/send-message.d.ts.map +0 -1
  163. package/dist/tools/send-message.js +0 -77
  164. package/dist/tools/send-message.js.map +0 -1
  165. package/dist/tools/skill-tool.d.ts +0 -9
  166. package/dist/tools/skill-tool.d.ts.map +0 -1
  167. package/dist/tools/skill-tool.js +0 -115
  168. package/dist/tools/skill-tool.js.map +0 -1
  169. package/dist/tools/task-tools.d.ts +0 -48
  170. package/dist/tools/task-tools.d.ts.map +0 -1
  171. package/dist/tools/task-tools.js +0 -242
  172. package/dist/tools/task-tools.js.map +0 -1
  173. package/dist/tools/team-tools.d.ts +0 -34
  174. package/dist/tools/team-tools.d.ts.map +0 -1
  175. package/dist/tools/team-tools.js +0 -103
  176. package/dist/tools/team-tools.js.map +0 -1
  177. package/dist/tools/todo-tool.d.ts +0 -22
  178. package/dist/tools/todo-tool.d.ts.map +0 -1
  179. package/dist/tools/todo-tool.js +0 -93
  180. package/dist/tools/todo-tool.js.map +0 -1
  181. package/dist/tools/tool-search.d.ts +0 -13
  182. package/dist/tools/tool-search.d.ts.map +0 -1
  183. package/dist/tools/tool-search.js +0 -76
  184. package/dist/tools/tool-search.js.map +0 -1
  185. package/dist/tools/types.d.ts +0 -29
  186. package/dist/tools/types.d.ts.map +0 -1
  187. package/dist/tools/types.js +0 -52
  188. package/dist/tools/types.js.map +0 -1
  189. package/dist/tools/web-fetch.d.ts +0 -5
  190. package/dist/tools/web-fetch.d.ts.map +0 -1
  191. package/dist/tools/web-fetch.js +0 -60
  192. package/dist/tools/web-fetch.js.map +0 -1
  193. package/dist/tools/web-search.d.ts +0 -5
  194. package/dist/tools/web-search.d.ts.map +0 -1
  195. package/dist/tools/web-search.js +0 -77
  196. package/dist/tools/web-search.js.map +0 -1
  197. package/dist/tools/worktree-tools.d.ts +0 -10
  198. package/dist/tools/worktree-tools.d.ts.map +0 -1
  199. package/dist/tools/worktree-tools.js +0 -130
  200. package/dist/tools/worktree-tools.js.map +0 -1
  201. package/dist/tools/write.d.ts +0 -5
  202. package/dist/tools/write.d.ts.map +0 -1
  203. package/dist/tools/write.js +0 -40
  204. package/dist/tools/write.js.map +0 -1
  205. package/dist/types.d.ts +0 -423
  206. package/dist/types.d.ts.map +0 -1
  207. package/dist/types.js +0 -5
  208. package/dist/types.js.map +0 -1
  209. package/dist/utils/compact.d.ts +0 -44
  210. package/dist/utils/compact.d.ts.map +0 -1
  211. package/dist/utils/compact.js +0 -162
  212. package/dist/utils/compact.js.map +0 -1
  213. package/dist/utils/context.d.ts +0 -35
  214. package/dist/utils/context.d.ts.map +0 -1
  215. package/dist/utils/context.js +0 -174
  216. package/dist/utils/context.js.map +0 -1
  217. package/dist/utils/fileCache.d.ts +0 -64
  218. package/dist/utils/fileCache.d.ts.map +0 -1
  219. package/dist/utils/fileCache.js +0 -117
  220. package/dist/utils/fileCache.js.map +0 -1
  221. package/dist/utils/messages.d.ts +0 -57
  222. package/dist/utils/messages.d.ts.map +0 -1
  223. package/dist/utils/messages.js +0 -152
  224. package/dist/utils/messages.js.map +0 -1
  225. package/dist/utils/retry.d.ts +0 -48
  226. package/dist/utils/retry.d.ts.map +0 -1
  227. package/dist/utils/retry.js +0 -111
  228. package/dist/utils/retry.js.map +0 -1
  229. package/dist/utils/tokens.d.ts +0 -57
  230. package/dist/utils/tokens.d.ts.map +0 -1
  231. package/dist/utils/tokens.js +0 -134
  232. package/dist/utils/tokens.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"team-tools.js","sourceRoot":"","sources":["../../src/tools/team-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiBH;;GAEG;AACH,MAAM,SAAS,GAAG,IAAI,GAAG,EAAgB,CAAA;AACzC,IAAI,WAAW,GAAG,CAAC,CAAA;AAEnB;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAA;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,EAAU;IAChC,OAAO,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,SAAS,CAAC,KA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
- *
4
- * Manages a session-scoped todo list for tracking work items.
5
- */
6
- import type { ToolDefinition } from '../types.js';
7
- export interface TodoItem {
8
- id: number;
9
- text: string;
10
- done: boolean;
11
- priority?: 'high' | 'medium' | 'low';
12
- }
13
- /**
14
- * Get all todos.
15
- */
16
- export declare function getTodos(): TodoItem[];
17
- /**
18
- * Clear all todos.
19
- */
20
- export declare function clearTodos(): void;
21
- export declare const TodoWriteTool: ToolDefinition;
22
- //# sourceMappingURL=todo-tool.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"todo-tool.d.ts","sourceRoot":"","sources":["../../src/tools/todo-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,aAAa,CAAA;AAE7D,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAA;CACrC;AAKD;;GAEG;AACH,wBAAgB,QAAQ,IAAI,QAAQ,EAAE,CAErC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAGjC;AAED,eAAO,MAAM,aAAa,EAAE,cA8E3B,CAAA"}
@@ -1,93 +0,0 @@
1
- /**
2
- * TodoWriteTool - Session todo/checklist management
3
- *
4
- * Manages a session-scoped todo list for tracking work items.
5
- */
6
- const todoList = [];
7
- let todoCounter = 0;
8
- /**
9
- * Get all todos.
10
- */
11
- export function getTodos() {
12
- return [...todoList];
13
- }
14
- /**
15
- * Clear all todos.
16
- */
17
- export function clearTodos() {
18
- todoList.length = 0;
19
- todoCounter = 0;
20
- }
21
- export const TodoWriteTool = {
22
- name: 'TodoWrite',
23
- description: 'Manage a session todo/checklist. Supports add, toggle, remove, and list operations.',
24
- inputSchema: {
25
- type: 'object',
26
- properties: {
27
- action: {
28
- type: 'string',
29
- enum: ['add', 'toggle', 'remove', 'list', 'clear'],
30
- description: 'Operation to perform',
31
- },
32
- text: { type: 'string', description: 'Todo item text (for add)' },
33
- id: { type: 'number', description: 'Todo item ID (for toggle/remove)' },
34
- priority: {
35
- type: 'string',
36
- enum: ['high', 'medium', 'low'],
37
- description: 'Priority level (for add)',
38
- },
39
- },
40
- required: ['action'],
41
- },
42
- isReadOnly: () => false,
43
- isConcurrencySafe: () => true,
44
- isEnabled: () => true,
45
- async prompt() { return 'Manage session todo list.'; },
46
- async call(input) {
47
- switch (input.action) {
48
- case 'add': {
49
- if (!input.text) {
50
- return { type: 'tool_result', tool_use_id: '', content: 'text required', is_error: true };
51
- }
52
- const item = {
53
- id: ++todoCounter,
54
- text: input.text,
55
- done: false,
56
- priority: input.priority,
57
- };
58
- todoList.push(item);
59
- return { type: 'tool_result', tool_use_id: '', content: `Todo added: #${item.id} "${item.text}"` };
60
- }
61
- case 'toggle': {
62
- const item = todoList.find(t => t.id === input.id);
63
- if (!item) {
64
- return { type: 'tool_result', tool_use_id: '', content: `Todo #${input.id} not found`, is_error: true };
65
- }
66
- item.done = !item.done;
67
- return { type: 'tool_result', tool_use_id: '', content: `Todo #${item.id} ${item.done ? 'completed' : 'reopened'}` };
68
- }
69
- case 'remove': {
70
- const idx = todoList.findIndex(t => t.id === input.id);
71
- if (idx === -1) {
72
- return { type: 'tool_result', tool_use_id: '', content: `Todo #${input.id} not found`, is_error: true };
73
- }
74
- todoList.splice(idx, 1);
75
- return { type: 'tool_result', tool_use_id: '', content: `Todo #${input.id} removed` };
76
- }
77
- case 'list': {
78
- if (todoList.length === 0) {
79
- return { type: 'tool_result', tool_use_id: '', content: 'No todos.' };
80
- }
81
- const lines = todoList.map(t => `${t.done ? '[x]' : '[ ]'} #${t.id} ${t.text}${t.priority ? ` (${t.priority})` : ''}`);
82
- return { type: 'tool_result', tool_use_id: '', content: lines.join('\n') };
83
- }
84
- case 'clear': {
85
- todoList.length = 0;
86
- return { type: 'tool_result', tool_use_id: '', content: 'All todos cleared.' };
87
- }
88
- default:
89
- return { type: 'tool_result', tool_use_id: '', content: `Unknown action: ${input.action}`, is_error: true };
90
- }
91
- },
92
- };
93
- //# sourceMappingURL=todo-tool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"todo-tool.js","sourceRoot":"","sources":["../../src/tools/todo-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH,MAAM,QAAQ,GAAe,EAAE,CAAA;AAC/B,IAAI,WAAW,GAAG,CAAC,CAAA;AAEnB;;GAEG;AACH,MAAM,UAAU,QAAQ;IACtB,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAA;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAA;IACnB,WAAW,GAAG,CAAC,CAAA;AACjB,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAmB;IAC3C,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,qFAAqF;IAClG,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC;gBAClD,WAAW,EAAE,sBAAsB;aACpC;YACD,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,0BAA0B,EAAE;YACjE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kCAAkC,EAAE;YACvE,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC;gBAC/B,WAAW,EAAE,0BAA0B;aACxC;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;KACrB;IACD,UAAU,EAAE,GAAG,EAAE,CAAC,KAAK;IACvB,iBAAiB,EAA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QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACtF,CAAA;gBACD,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;YAC5E,CAAC;YAED,KAAK,OAAO,CAAC,CAAC,CAAC;gBACb,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAA;gBACnB,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAA;YAChF,CAAC;YAED;gBACE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,mBAAmB,KAAK,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;QAC/G,CAAC;IACH,CAAC;CACF,CAAA"}
@@ -1,13 +0,0 @@
1
- /**
2
- * ToolSearchTool - Discover deferred/lazy-loaded tools
3
- *
4
- * Allows the model to search for tools that haven't been loaded yet.
5
- * Supports keyword search and exact name selection.
6
- */
7
- import type { ToolDefinition } from '../types.js';
8
- /**
9
- * Set deferred tools available for search.
10
- */
11
- export declare function setDeferredTools(tools: ToolDefinition[]): void;
12
- export declare const ToolSearchTool: ToolDefinition;
13
- //# sourceMappingURL=tool-search.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool-search.d.ts","sourceRoot":"","sources":["../../src/tools/tool-search.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,aAAa,CAAA;AAK7D;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,IAAI,CAE9D;AAED,eAAO,MAAM,cAAc,EAAE,cAmE5B,CAAA"}
@@ -1,76 +0,0 @@
1
- /**
2
- * ToolSearchTool - Discover deferred/lazy-loaded tools
3
- *
4
- * Allows the model to search for tools that haven't been loaded yet.
5
- * Supports keyword search and exact name selection.
6
- */
7
- // Registry of deferred tools (set by the agent)
8
- let deferredTools = [];
9
- /**
10
- * Set deferred tools available for search.
11
- */
12
- export function setDeferredTools(tools) {
13
- deferredTools = tools;
14
- }
15
- export const ToolSearchTool = {
16
- name: 'ToolSearch',
17
- description: 'Search for additional tools that may be available but not yet loaded. Use keyword search or exact name selection.',
18
- inputSchema: {
19
- type: 'object',
20
- properties: {
21
- query: {
22
- type: 'string',
23
- description: 'Search query. Use "select:ToolName" for exact match or keywords for search.',
24
- },
25
- max_results: {
26
- type: 'number',
27
- description: 'Maximum results to return (default: 5)',
28
- },
29
- },
30
- required: ['query'],
31
- },
32
- isReadOnly: () => true,
33
- isConcurrencySafe: () => true,
34
- isEnabled: () => true,
35
- async prompt() { return 'Search for available tools.'; },
36
- async call(input) {
37
- const { query, max_results = 5 } = input;
38
- if (deferredTools.length === 0) {
39
- return {
40
- type: 'tool_result',
41
- tool_use_id: '',
42
- content: 'No deferred tools available.',
43
- };
44
- }
45
- let matches;
46
- if (query.startsWith('select:')) {
47
- // Exact name selection
48
- const names = query.slice(7).split(',').map((n) => n.trim());
49
- matches = deferredTools.filter(t => names.includes(t.name));
50
- }
51
- else {
52
- // Keyword search
53
- const keywords = query.toLowerCase().split(/\s+/);
54
- matches = deferredTools
55
- .filter(t => {
56
- const searchText = `${t.name} ${t.description}`.toLowerCase();
57
- return keywords.some((kw) => searchText.includes(kw));
58
- })
59
- .slice(0, max_results);
60
- }
61
- if (matches.length === 0) {
62
- return {
63
- type: 'tool_result',
64
- tool_use_id: '',
65
- content: `No tools found matching "${query}"`,
66
- };
67
- }
68
- const lines = matches.map(t => `- ${t.name}: ${t.description.slice(0, 200)}`);
69
- return {
70
- type: 'tool_result',
71
- tool_use_id: '',
72
- content: `Found ${matches.length} tool(s):\n${lines.join('\n')}`,
73
- };
74
- },
75
- };
76
- //# sourceMappingURL=tool-search.js.map
@@ -1 +0,0 @@
1
- {"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AA"}
@@ -1,29 +0,0 @@
1
- /**
2
- * Tool interface and helper utilities
3
- */
4
- import type { ToolDefinition, ToolInputSchema, ToolContext } from '../types.js';
5
- /**
6
- * Helper to create a tool definition with sensible defaults.
7
- */
8
- export declare function defineTool(config: {
9
- name: string;
10
- description: string;
11
- inputSchema: ToolInputSchema;
12
- call: (input: any, context: ToolContext) => Promise<string | {
13
- data: string;
14
- is_error?: boolean;
15
- }>;
16
- isReadOnly?: boolean;
17
- isConcurrencySafe?: boolean;
18
- prompt?: string | ((context: ToolContext) => Promise<string>);
19
- }): ToolDefinition;
20
- /**
21
- * Convert a ToolDefinition to API-compatible tool format.
22
- * Returns the normalized tool format used by providers.
23
- */
24
- export declare function toApiTool(tool: ToolDefinition): {
25
- name: string;
26
- description: string;
27
- input_schema: ToolInputSchema;
28
- };
29
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAc,MAAM,aAAa,CAAA;AAE3F;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,eAAe,CAAA;IAC5B,IAAI,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;IAClG,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;CAC9D,GAAG,cAAc,CAgCjB;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,cAAc,GAAG;IAC/C,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,eAAe,CAAA;CAC9B,CAMA"}
@@ -1,52 +0,0 @@
1
- /**
2
- * Tool interface and helper utilities
3
- */
4
- /**
5
- * Helper to create a tool definition with sensible defaults.
6
- */
7
- export function defineTool(config) {
8
- return {
9
- name: config.name,
10
- description: config.description,
11
- inputSchema: config.inputSchema,
12
- isReadOnly: () => config.isReadOnly ?? false,
13
- isConcurrencySafe: () => config.isConcurrencySafe ?? false,
14
- isEnabled: () => true,
15
- prompt: typeof config.prompt === 'function'
16
- ? config.prompt
17
- : async (_context) => config.prompt ?? config.description,
18
- async call(input, context) {
19
- try {
20
- const result = await config.call(input, context);
21
- const output = typeof result === 'string' ? result : result.data;
22
- const isError = typeof result === 'object' && result.is_error;
23
- return {
24
- type: 'tool_result',
25
- tool_use_id: '', // filled by engine
26
- content: output,
27
- is_error: isError || false,
28
- };
29
- }
30
- catch (err) {
31
- return {
32
- type: 'tool_result',
33
- tool_use_id: '',
34
- content: `Error: ${err.message}`,
35
- is_error: true,
36
- };
37
- }
38
- },
39
- };
40
- }
41
- /**
42
- * Convert a ToolDefinition to API-compatible tool format.
43
- * Returns the normalized tool format used by providers.
44
- */
45
- export function toApiTool(tool) {
46
- return {
47
- name: tool.name,
48
- description: tool.description,
49
- input_schema: tool.inputSchema,
50
- };
51
- }
52
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,MAQ1B;IACC,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,WAAW,EAAE,MAAM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EAAE,IAAI,CAAC,WAAW;QAC7B,YAAY,EAAE,IAAI,CAAC,WAAW;KAC/B,CAAA;AACH,CAAC"}
@@ -1,5 +0,0 @@
1
- /**
2
- * WebFetchTool - Fetch web content
3
- */
4
- export declare const WebFetchTool: import("../types.js").ToolDefinition;
5
- //# sourceMappingURL=web-fetch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-fetch.d.ts","sourceRoot":"","sources":["../../src/tools/web-fetch.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,eAAO,MAAM,YAAY,sCA2DvB,CAAA"}
@@ -1,60 +0,0 @@
1
- /**
2
- * WebFetchTool - Fetch web content
3
- */
4
- import { defineTool } from './types.js';
5
- export const WebFetchTool = defineTool({
6
- name: 'WebFetch',
7
- description: 'Fetch content from a URL and return it as text. Supports HTML pages, JSON APIs, and plain text. Strips HTML tags for readability.',
8
- inputSchema: {
9
- type: 'object',
10
- properties: {
11
- url: {
12
- type: 'string',
13
- description: 'The URL to fetch content from',
14
- },
15
- headers: {
16
- type: 'object',
17
- description: 'Optional HTTP headers',
18
- },
19
- },
20
- required: ['url'],
21
- },
22
- isReadOnly: true,
23
- isConcurrencySafe: true,
24
- async call(input, _context) {
25
- const { url, headers } = input;
26
- try {
27
- const response = await fetch(url, {
28
- headers: {
29
- 'User-Agent': 'Mozilla/5.0 (compatible; AgentSDK/1.0)',
30
- ...headers,
31
- },
32
- signal: AbortSignal.timeout(30000),
33
- });
34
- if (!response.ok) {
35
- return { data: `HTTP ${response.status}: ${response.statusText}`, is_error: true };
36
- }
37
- const contentType = response.headers.get('content-type') || '';
38
- let text = await response.text();
39
- // Strip HTML tags for readability
40
- if (contentType.includes('text/html')) {
41
- // Remove script and style blocks
42
- text = text.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, '');
43
- text = text.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, '');
44
- // Remove HTML tags
45
- text = text.replace(/<[^>]+>/g, ' ');
46
- // Clean up whitespace
47
- text = text.replace(/\s+/g, ' ').trim();
48
- }
49
- // Truncate very large responses
50
- if (text.length > 100000) {
51
- text = text.slice(0, 100000) + '\n...(truncated)';
52
- }
53
- return text || '(empty response)';
54
- }
55
- catch (err) {
56
- return { data: `Error fetching ${url}: ${err.message}`, is_error: true };
57
- }
58
- },
59
- });
60
- //# sourceMappingURL=web-fetch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-fetch.js","sourceRoot":"","sources":["../../src/tools/web-fetch.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;IACrC,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,mIAAmI;IAChJ,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,GAAG,EAAE;gBACH,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,+BAA+B;aAC7C;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uBAAuB;aACrC;SACF;QACD,QAAQ,EAAE,CAAC,KAAK,CAAC;KAClB;IACD,UAAU,EAAE,IAAI;IAChB,iBAAiB,EAAE,IAAI;IACvB,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ;QACxB,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,KAAK,CAAA;QAE9B,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;gBAChC,OAAO,EAAE;oBACP,YAAY,EAAE,wCAAwC;oBACtD,GAAG,OAAO;iBACX;gBACD,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC;aACnC,CAAC,CAAA;YAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,OAAO,EAAE,IAAI,EAAE,QAAQ,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;YACpF,CAAC;YAED,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAA;YAC9D,IAAI,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;YAEhC,kCAAkC;YAClC,IAAI,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBACtC,iCAAiC;gBACjC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,mCAAmC,EAAE,EAAE,CAAC,CAAA;gBAC5D,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,iCAAiC,EAAE,EAAE,CAAC,CAAA;gBAC1D,mBAAmB;gBACnB,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;gBACpC,sBAAsB;gBACtB,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;YACzC,CAAC;YAED,gCAAgC;YAChC,IAAI,IAAI,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;gBACzB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,kBAAkB,CAAA;YACnD,CAAC;YAED,OAAO,IAAI,IAAI,kBAAkB,CAAA;QACnC,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO,EAAE,IAAI,EAAE,kBAAkB,GAAG,KAAK,GAAG,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;QAC1E,CAAC;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -1,5 +0,0 @@
1
- /**
2
- * WebSearchTool - Web search (via web fetch of search engines)
3
- */
4
- export declare const WebSearchTool: import("../types.js").ToolDefinition;
5
- //# sourceMappingURL=web-search.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-search.d.ts","sourceRoot":"","sources":["../../src/tools/web-search.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,eAAO,MAAM,aAAa,sCA+ExB,CAAA"}
@@ -1,77 +0,0 @@
1
- /**
2
- * WebSearchTool - Web search (via web fetch of search engines)
3
- */
4
- import { defineTool } from './types.js';
5
- export const WebSearchTool = defineTool({
6
- name: 'WebSearch',
7
- description: 'Search the web for information. Returns search results with titles, URLs, and snippets.',
8
- inputSchema: {
9
- type: 'object',
10
- properties: {
11
- query: {
12
- type: 'string',
13
- description: 'The search query',
14
- },
15
- num_results: {
16
- type: 'number',
17
- description: 'Number of results to return (default: 5)',
18
- },
19
- },
20
- required: ['query'],
21
- },
22
- isReadOnly: true,
23
- isConcurrencySafe: true,
24
- async call(input, _context) {
25
- const { query } = input;
26
- try {
27
- // Use DuckDuckGo HTML search as a free fallback
28
- const encoded = encodeURIComponent(query);
29
- const url = `https://html.duckduckgo.com/html/?q=${encoded}`;
30
- const response = await fetch(url, {
31
- headers: {
32
- 'User-Agent': 'Mozilla/5.0 (compatible; AgentSDK/1.0)',
33
- },
34
- signal: AbortSignal.timeout(15000),
35
- });
36
- if (!response.ok) {
37
- return { data: `Search failed: HTTP ${response.status}`, is_error: true };
38
- }
39
- const html = await response.text();
40
- // Parse search results from DuckDuckGo HTML
41
- const results = [];
42
- const resultRegex = /<a rel="nofollow" class="result__a" href="([^"]*)"[^>]*>([\s\S]*?)<\/a>/gi;
43
- const snippetRegex = /<a class="result__snippet"[^>]*>([\s\S]*?)<\/a>/gi;
44
- let match;
45
- const links = [];
46
- while ((match = resultRegex.exec(html)) !== null) {
47
- const href = match[1];
48
- const title = match[2].replace(/<[^>]+>/g, '').trim();
49
- if (href && title && !href.includes('duckduckgo.com')) {
50
- links.push({ title, url: href });
51
- }
52
- }
53
- const snippets = [];
54
- while ((match = snippetRegex.exec(html)) !== null) {
55
- snippets.push(match[1].replace(/<[^>]+>/g, '').trim());
56
- }
57
- const numResults = Math.min(input.num_results || 5, links.length);
58
- for (let i = 0; i < numResults; i++) {
59
- const link = links[i];
60
- if (!link)
61
- continue;
62
- let entry = `${i + 1}. ${link.title}\n ${link.url}`;
63
- if (snippets[i]) {
64
- entry += `\n ${snippets[i]}`;
65
- }
66
- results.push(entry);
67
- }
68
- return results.length > 0
69
- ? results.join('\n\n')
70
- : `No results found for "${query}"`;
71
- }
72
- catch (err) {
73
- return { data: `Search error: ${err.message}`, is_error: true };
74
- }
75
- },
76
- });
77
- //# sourceMappingURL=web-search.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-search.js","sourceRoot":"","sources":["../../src/tools/web-search.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC;IACtC,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,yFAAyF;IACtG,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,kBAAkB;aAChC;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0CAA0C;aACxD;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,CAAC;KACpB;IACD,UAAU,EAAE,IAAI;IAChB,iBAAiB,EAAE,IAAI;IACvB,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ;QACxB,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAA;QAEvB,IAAI,CAAC;YACH,gDAAgD;YAChD,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAA;YACzC,MAAM,GAAG,GAAG,uCAAuC,OAAO,EAAE,CAAA;YAE5D,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;gBAChC,OAAO,EAAE;oBACP,YAAY,EAAE,wCAAwC;iBACvD;g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C;YAED,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;YACjE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;gBACpC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;gBACrB,IAAI,CAAC,IAAI;oBAAE,SAAQ;gBACnB,IAAI,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,GAAG,EAAE,CAAA;gBACrD,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;oBAChB,KAAK,IAAI,QAAQ,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAA;gBAChC,CAAC;gBACD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACrB,CAAC;YAED,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC;gBACvB,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;gBACtB,CAAC,CAAC,yBAAyB,KAAK,GAAG,CAAA;QACvC,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO,EAAE,IAAI,EAAE,iBAAiB,GAAG,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;QACjE,CAAC;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -1,10 +0,0 @@
1
- /**
2
- * Git Worktree Tools
3
- *
4
- * EnterWorktree / ExitWorktree - Isolated git worktree environments
5
- * for parallel work without affecting the main working tree.
6
- */
7
- import type { ToolDefinition } from '../types.js';
8
- export declare const EnterWorktreeTool: ToolDefinition;
9
- export declare const ExitWorktreeTool: ToolDefinition;
10
- //# sourceMappingURL=worktree-tools.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worktree-tools.d.ts","sourceRoot":"","sources":["../../src/tools/worktree-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,aAAa,CAAA;AAK7D,eAAO,MAAM,iBAAiB,EAAE,cAwD/B,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,cAkE9B,CAAA"}
@@ -1,130 +0,0 @@
1
- /**
2
- * Git Worktree Tools
3
- *
4
- * EnterWorktree / ExitWorktree - Isolated git worktree environments
5
- * for parallel work without affecting the main working tree.
6
- */
7
- import { execSync } from 'child_process';
8
- import { join } from 'path';
9
- // Track active worktrees
10
- const activeWorktrees = new Map();
11
- export const EnterWorktreeTool = {
12
- name: 'EnterWorktree',
13
- description: 'Create an isolated git worktree for parallel work. The agent will work in the worktree without affecting the main working tree.',
14
- inputSchema: {
15
- type: 'object',
16
- properties: {
17
- branch: { type: 'string', description: 'Branch name for the worktree (auto-generated if not provided)' },
18
- path: { type: 'string', description: 'Path for the worktree (auto-generated if not provided)' },
19
- },
20
- },
21
- isReadOnly: () => false,
22
- isConcurrencySafe: () => false,
23
- isEnabled: () => true,
24
- async prompt() { return 'Create an isolated git worktree for parallel work.'; },
25
- async call(input, context) {
26
- try {
27
- // Check if we're in a git repo
28
- execSync('git rev-parse --git-dir', { cwd: context.cwd, encoding: 'utf-8' });
29
- const branch = input.branch || `worktree-${Date.now()}`;
30
- const worktreePath = input.path || join(context.cwd, '..', `.worktree-${branch}`);
31
- // Create the branch if it doesn't exist
32
- try {
33
- execSync(`git branch ${branch}`, { cwd: context.cwd, encoding: 'utf-8', stdio: 'pipe' });
34
- }
35
- catch {
36
- // Branch might already exist
37
- }
38
- // Create worktree
39
- execSync(`git worktree add ${JSON.stringify(worktreePath)} ${branch}`, {
40
- cwd: context.cwd,
41
- encoding: 'utf-8',
42
- });
43
- const id = crypto.randomUUID();
44
- activeWorktrees.set(id, {
45
- path: worktreePath,
46
- branch,
47
- originalCwd: context.cwd,
48
- });
49
- return {
50
- type: 'tool_result',
51
- tool_use_id: '',
52
- content: `Worktree created:\n ID: ${id}\n Path: ${worktreePath}\n Branch: ${branch}\n\nYou are now working in the isolated worktree.`,
53
- };
54
- }
55
- catch (err) {
56
- return {
57
- type: 'tool_result',
58
- tool_use_id: '',
59
- content: `Error creating worktree: ${err.message}`,
60
- is_error: true,
61
- };
62
- }
63
- },
64
- };
65
- export const ExitWorktreeTool = {
66
- name: 'ExitWorktree',
67
- description: 'Exit and optionally remove a git worktree. Use "keep" to preserve changes or "remove" to clean up.',
68
- inputSchema: {
69
- type: 'object',
70
- properties: {
71
- id: { type: 'string', description: 'Worktree ID' },
72
- action: {
73
- type: 'string',
74
- enum: ['keep', 'remove'],
75
- description: 'Whether to keep or remove the worktree (default: remove)',
76
- },
77
- },
78
- required: ['id'],
79
- },
80
- isReadOnly: () => false,
81
- isConcurrencySafe: () => false,
82
- isEnabled: () => true,
83
- async prompt() { return 'Exit a git worktree.'; },
84
- async call(input) {
85
- const worktree = activeWorktrees.get(input.id);
86
- if (!worktree) {
87
- return {
88
- type: 'tool_result',
89
- tool_use_id: '',
90
- content: `Worktree not found: ${input.id}`,
91
- is_error: true,
92
- };
93
- }
94
- const action = input.action || 'remove';
95
- try {
96
- if (action === 'remove') {
97
- execSync(`git worktree remove ${JSON.stringify(worktree.path)} --force`, {
98
- cwd: worktree.originalCwd,
99
- encoding: 'utf-8',
100
- });
101
- // Clean up branch
102
- try {
103
- execSync(`git branch -D ${worktree.branch}`, {
104
- cwd: worktree.originalCwd,
105
- encoding: 'utf-8',
106
- stdio: 'pipe',
107
- });
108
- }
109
- catch {
110
- // Branch might have commits
111
- }
112
- }
113
- activeWorktrees.delete(input.id);
114
- return {
115
- type: 'tool_result',
116
- tool_use_id: '',
117
- content: `Worktree ${action === 'remove' ? 'removed' : 'kept'}: ${worktree.path}`,
118
- };
119
- }
120
- catch (err) {
121
- return {
122
- type: 'tool_result',
123
- tool_use_id: '',
124
- content: `Error: ${err.message}`,
125
- is_error: true,
126
- };
127
- }
128
- },
129
- };
130
- //# sourceMappingURL=worktree-tools.js.map