@codeany/open-agent-sdk 0.2.2 → 0.2.3

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 (280) hide show
  1. package/dist/agent.d.ts +113 -0
  2. package/dist/agent.d.ts.map +1 -0
  3. package/dist/agent.js +446 -0
  4. package/dist/agent.js.map +1 -0
  5. package/dist/engine.d.ts +62 -0
  6. package/dist/engine.d.ts.map +1 -0
  7. package/dist/engine.js +496 -0
  8. package/dist/engine.js.map +1 -0
  9. package/dist/hooks.d.ts +111 -0
  10. package/dist/hooks.d.ts.map +1 -0
  11. package/dist/hooks.js +179 -0
  12. package/dist/hooks.js.map +1 -0
  13. package/dist/index.d.ts +66 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +133 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/mcp/client.d.ts +19 -0
  18. package/dist/mcp/client.d.ts.map +1 -0
  19. package/dist/mcp/client.js +126 -0
  20. package/dist/mcp/client.js.map +1 -0
  21. package/dist/providers/anthropic.d.ts +17 -0
  22. package/dist/providers/anthropic.d.ts.map +1 -0
  23. package/dist/providers/anthropic.js +47 -0
  24. package/dist/providers/anthropic.js.map +1 -0
  25. package/dist/providers/index.d.ts +20 -0
  26. package/dist/providers/index.d.ts.map +1 -0
  27. package/dist/providers/index.js +26 -0
  28. package/dist/providers/index.js.map +1 -0
  29. package/dist/providers/openai.d.ts +26 -0
  30. package/dist/providers/openai.d.ts.map +1 -0
  31. package/dist/providers/openai.js +212 -0
  32. package/dist/providers/openai.js.map +1 -0
  33. package/dist/providers/types.d.ts +84 -0
  34. package/dist/providers/types.d.ts.map +1 -0
  35. package/dist/providers/types.js +11 -0
  36. package/dist/providers/types.js.map +1 -0
  37. package/dist/sdk-mcp-server.d.ts +52 -0
  38. package/dist/sdk-mcp-server.d.ts.map +1 -0
  39. package/dist/sdk-mcp-server.js +57 -0
  40. package/dist/sdk-mcp-server.js.map +1 -0
  41. package/dist/session.d.ts +73 -0
  42. package/dist/session.d.ts.map +1 -0
  43. package/dist/session.js +159 -0
  44. package/dist/session.js.map +1 -0
  45. package/dist/skills/bundled/commit.d.ts +7 -0
  46. package/dist/skills/bundled/commit.d.ts.map +1 -0
  47. package/dist/skills/bundled/commit.js +35 -0
  48. package/dist/skills/bundled/commit.js.map +1 -0
  49. package/dist/skills/bundled/debug.d.ts +7 -0
  50. package/dist/skills/bundled/debug.d.ts.map +1 -0
  51. package/{src/skills/bundled/debug.ts → dist/skills/bundled/debug.js} +20 -22
  52. package/dist/skills/bundled/debug.js.map +1 -0
  53. package/dist/skills/bundled/index.d.ts +11 -0
  54. package/dist/skills/bundled/index.d.ts.map +1 -0
  55. package/dist/skills/bundled/index.js +26 -0
  56. package/dist/skills/bundled/index.js.map +1 -0
  57. package/dist/skills/bundled/review.d.ts +7 -0
  58. package/dist/skills/bundled/review.d.ts.map +1 -0
  59. package/{src/skills/bundled/review.ts → dist/skills/bundled/review.js} +18 -21
  60. package/dist/skills/bundled/review.js.map +1 -0
  61. package/dist/skills/bundled/simplify.d.ts +8 -0
  62. package/dist/skills/bundled/simplify.d.ts.map +1 -0
  63. package/{src/skills/bundled/simplify.ts → dist/skills/bundled/simplify.js} +16 -19
  64. package/dist/skills/bundled/simplify.js.map +1 -0
  65. package/dist/skills/bundled/test.d.ts +7 -0
  66. package/dist/skills/bundled/test.d.ts.map +1 -0
  67. package/{src/skills/bundled/test.ts → dist/skills/bundled/test.js} +18 -21
  68. package/dist/skills/bundled/test.js.map +1 -0
  69. package/dist/skills/index.d.ts +7 -0
  70. package/dist/skills/index.d.ts.map +1 -0
  71. package/dist/skills/index.js +8 -0
  72. package/dist/skills/index.js.map +1 -0
  73. package/dist/skills/registry.d.ts +43 -0
  74. package/dist/skills/registry.d.ts.map +1 -0
  75. package/dist/skills/registry.js +111 -0
  76. package/dist/skills/registry.js.map +1 -0
  77. package/dist/skills/types.d.ts +83 -0
  78. package/dist/skills/types.d.ts.map +1 -0
  79. package/dist/skills/types.js +8 -0
  80. package/dist/skills/types.js.map +1 -0
  81. package/dist/tool-helper.d.ts +73 -0
  82. package/dist/tool-helper.d.ts.map +1 -0
  83. package/dist/tool-helper.js +86 -0
  84. package/dist/tool-helper.js.map +1 -0
  85. package/dist/tools/agent-tool.d.ts +17 -0
  86. package/dist/tools/agent-tool.d.ts.map +1 -0
  87. package/dist/tools/agent-tool.js +146 -0
  88. package/dist/tools/agent-tool.js.map +1 -0
  89. package/dist/tools/ask-user.d.ts +18 -0
  90. package/dist/tools/ask-user.d.ts.map +1 -0
  91. package/dist/tools/ask-user.js +72 -0
  92. package/dist/tools/ask-user.js.map +1 -0
  93. package/dist/tools/bash.d.ts +5 -0
  94. package/dist/tools/bash.d.ts.map +1 -0
  95. package/dist/tools/bash.js +67 -0
  96. package/dist/tools/bash.js.map +1 -0
  97. package/dist/tools/config-tool.d.ts +20 -0
  98. package/dist/tools/config-tool.d.ts.map +1 -0
  99. package/dist/tools/config-tool.js +83 -0
  100. package/dist/tools/config-tool.js.map +1 -0
  101. package/dist/tools/cron-tools.d.ts +33 -0
  102. package/dist/tools/cron-tools.d.ts.map +1 -0
  103. package/dist/tools/cron-tools.js +128 -0
  104. package/dist/tools/cron-tools.js.map +1 -0
  105. package/dist/tools/edit.d.ts +5 -0
  106. package/dist/tools/edit.d.ts.map +1 -0
  107. package/dist/tools/edit.js +70 -0
  108. package/dist/tools/edit.js.map +1 -0
  109. package/dist/tools/glob.d.ts +5 -0
  110. package/dist/tools/glob.d.ts.map +1 -0
  111. package/dist/tools/glob.js +75 -0
  112. package/dist/tools/glob.js.map +1 -0
  113. package/dist/tools/grep.d.ts +5 -0
  114. package/dist/tools/grep.d.ts.map +1 -0
  115. package/dist/tools/grep.js +168 -0
  116. package/dist/tools/grep.js.map +1 -0
  117. package/dist/tools/index.d.ts +45 -0
  118. package/dist/tools/index.d.ts.map +1 -0
  119. package/dist/tools/index.js +162 -0
  120. package/dist/tools/index.js.map +1 -0
  121. package/dist/tools/lsp-tool.d.ts +9 -0
  122. package/dist/tools/lsp-tool.d.ts.map +1 -0
  123. package/dist/tools/lsp-tool.js +137 -0
  124. package/dist/tools/lsp-tool.js.map +1 -0
  125. package/dist/tools/mcp-resource-tools.d.ts +14 -0
  126. package/dist/tools/mcp-resource-tools.d.ts.map +1 -0
  127. package/dist/tools/mcp-resource-tools.js +117 -0
  128. package/dist/tools/mcp-resource-tools.js.map +1 -0
  129. package/dist/tools/notebook-edit.d.ts +5 -0
  130. package/dist/tools/notebook-edit.d.ts.map +1 -0
  131. package/dist/tools/notebook-edit.js +85 -0
  132. package/dist/tools/notebook-edit.js.map +1 -0
  133. package/dist/tools/plan-tools.d.ts +12 -0
  134. package/dist/tools/plan-tools.d.ts.map +1 -0
  135. package/dist/tools/plan-tools.js +77 -0
  136. package/dist/tools/plan-tools.js.map +1 -0
  137. package/dist/tools/read.d.ts +5 -0
  138. package/dist/tools/read.d.ts.map +1 -0
  139. package/dist/tools/read.js +66 -0
  140. package/dist/tools/read.js.map +1 -0
  141. package/dist/tools/send-message.d.ts +31 -0
  142. package/dist/tools/send-message.d.ts.map +1 -0
  143. package/dist/tools/send-message.js +77 -0
  144. package/dist/tools/send-message.js.map +1 -0
  145. package/dist/tools/skill-tool.d.ts +9 -0
  146. package/dist/tools/skill-tool.d.ts.map +1 -0
  147. package/dist/tools/skill-tool.js +115 -0
  148. package/dist/tools/skill-tool.js.map +1 -0
  149. package/dist/tools/task-tools.d.ts +48 -0
  150. package/dist/tools/task-tools.d.ts.map +1 -0
  151. package/dist/tools/task-tools.js +242 -0
  152. package/dist/tools/task-tools.js.map +1 -0
  153. package/dist/tools/team-tools.d.ts +34 -0
  154. package/dist/tools/team-tools.d.ts.map +1 -0
  155. package/dist/tools/team-tools.js +103 -0
  156. package/dist/tools/team-tools.js.map +1 -0
  157. package/dist/tools/todo-tool.d.ts +22 -0
  158. package/dist/tools/todo-tool.d.ts.map +1 -0
  159. package/dist/tools/todo-tool.js +93 -0
  160. package/dist/tools/todo-tool.js.map +1 -0
  161. package/dist/tools/tool-search.d.ts +13 -0
  162. package/dist/tools/tool-search.d.ts.map +1 -0
  163. package/dist/tools/tool-search.js +76 -0
  164. package/dist/tools/tool-search.js.map +1 -0
  165. package/dist/tools/types.d.ts +29 -0
  166. package/dist/tools/types.d.ts.map +1 -0
  167. package/dist/tools/types.js +52 -0
  168. package/dist/tools/types.js.map +1 -0
  169. package/dist/tools/web-fetch.d.ts +5 -0
  170. package/dist/tools/web-fetch.d.ts.map +1 -0
  171. package/dist/tools/web-fetch.js +60 -0
  172. package/dist/tools/web-fetch.js.map +1 -0
  173. package/dist/tools/web-search.d.ts +5 -0
  174. package/dist/tools/web-search.d.ts.map +1 -0
  175. package/dist/tools/web-search.js +77 -0
  176. package/dist/tools/web-search.js.map +1 -0
  177. package/dist/tools/worktree-tools.d.ts +10 -0
  178. package/dist/tools/worktree-tools.d.ts.map +1 -0
  179. package/dist/tools/worktree-tools.js +130 -0
  180. package/dist/tools/worktree-tools.js.map +1 -0
  181. package/dist/tools/write.d.ts +5 -0
  182. package/dist/tools/write.d.ts.map +1 -0
  183. package/dist/tools/write.js +40 -0
  184. package/dist/tools/write.js.map +1 -0
  185. package/dist/types.d.ts +423 -0
  186. package/dist/types.d.ts.map +1 -0
  187. package/dist/types.js +5 -0
  188. package/dist/types.js.map +1 -0
  189. package/dist/utils/compact.d.ts +44 -0
  190. package/dist/utils/compact.d.ts.map +1 -0
  191. package/dist/utils/compact.js +162 -0
  192. package/dist/utils/compact.js.map +1 -0
  193. package/dist/utils/context.d.ts +35 -0
  194. package/dist/utils/context.d.ts.map +1 -0
  195. package/dist/utils/context.js +174 -0
  196. package/dist/utils/context.js.map +1 -0
  197. package/dist/utils/fileCache.d.ts +64 -0
  198. package/dist/utils/fileCache.d.ts.map +1 -0
  199. package/dist/utils/fileCache.js +117 -0
  200. package/dist/utils/fileCache.js.map +1 -0
  201. package/dist/utils/messages.d.ts +57 -0
  202. package/dist/utils/messages.d.ts.map +1 -0
  203. package/dist/utils/messages.js +152 -0
  204. package/dist/utils/messages.js.map +1 -0
  205. package/dist/utils/retry.d.ts +48 -0
  206. package/dist/utils/retry.d.ts.map +1 -0
  207. package/dist/utils/retry.js +111 -0
  208. package/dist/utils/retry.js.map +1 -0
  209. package/dist/utils/tokens.d.ts +57 -0
  210. package/dist/utils/tokens.d.ts.map +1 -0
  211. package/dist/utils/tokens.js +134 -0
  212. package/dist/utils/tokens.js.map +1 -0
  213. package/package.json +6 -1
  214. package/.env.example +0 -8
  215. package/examples/01-simple-query.ts +0 -43
  216. package/examples/02-multi-tool.ts +0 -44
  217. package/examples/03-multi-turn.ts +0 -39
  218. package/examples/04-prompt-api.ts +0 -29
  219. package/examples/05-custom-system-prompt.ts +0 -26
  220. package/examples/06-mcp-server.ts +0 -49
  221. package/examples/07-custom-tools.ts +0 -87
  222. package/examples/08-official-api-compat.ts +0 -38
  223. package/examples/09-subagents.ts +0 -48
  224. package/examples/10-permissions.ts +0 -40
  225. package/examples/11-custom-mcp-tools.ts +0 -101
  226. package/examples/12-skills.ts +0 -88
  227. package/examples/13-hooks.ts +0 -88
  228. package/examples/14-openai-compat.ts +0 -71
  229. package/examples/web/index.html +0 -365
  230. package/examples/web/server.ts +0 -157
  231. package/src/agent.ts +0 -516
  232. package/src/engine.ts +0 -633
  233. package/src/hooks.ts +0 -261
  234. package/src/index.ts +0 -426
  235. package/src/mcp/client.ts +0 -150
  236. package/src/providers/anthropic.ts +0 -60
  237. package/src/providers/index.ts +0 -34
  238. package/src/providers/openai.ts +0 -315
  239. package/src/providers/types.ts +0 -85
  240. package/src/sdk-mcp-server.ts +0 -78
  241. package/src/session.ts +0 -227
  242. package/src/skills/bundled/commit.ts +0 -38
  243. package/src/skills/bundled/index.ts +0 -28
  244. package/src/skills/index.ts +0 -25
  245. package/src/skills/registry.ts +0 -133
  246. package/src/skills/types.ts +0 -99
  247. package/src/tool-helper.ts +0 -127
  248. package/src/tools/agent-tool.ts +0 -164
  249. package/src/tools/ask-user.ts +0 -79
  250. package/src/tools/bash.ts +0 -75
  251. package/src/tools/config-tool.ts +0 -89
  252. package/src/tools/cron-tools.ts +0 -153
  253. package/src/tools/edit.ts +0 -74
  254. package/src/tools/glob.ts +0 -77
  255. package/src/tools/grep.ts +0 -168
  256. package/src/tools/index.ts +0 -240
  257. package/src/tools/lsp-tool.ts +0 -163
  258. package/src/tools/mcp-resource-tools.ts +0 -125
  259. package/src/tools/notebook-edit.ts +0 -93
  260. package/src/tools/plan-tools.ts +0 -88
  261. package/src/tools/read.ts +0 -73
  262. package/src/tools/send-message.ts +0 -96
  263. package/src/tools/skill-tool.ts +0 -133
  264. package/src/tools/task-tools.ts +0 -290
  265. package/src/tools/team-tools.ts +0 -128
  266. package/src/tools/todo-tool.ts +0 -112
  267. package/src/tools/tool-search.ts +0 -87
  268. package/src/tools/types.ts +0 -66
  269. package/src/tools/web-fetch.ts +0 -66
  270. package/src/tools/web-search.ts +0 -86
  271. package/src/tools/worktree-tools.ts +0 -140
  272. package/src/tools/write.ts +0 -42
  273. package/src/types.ts +0 -486
  274. package/src/utils/compact.ts +0 -207
  275. package/src/utils/context.ts +0 -191
  276. package/src/utils/fileCache.ts +0 -148
  277. package/src/utils/messages.ts +0 -195
  278. package/src/utils/retry.ts +0 -140
  279. package/src/utils/tokens.ts +0 -145
  280. package/tsconfig.json +0 -19
@@ -0,0 +1,117 @@
1
+ /**
2
+ * MCP Resource Tools
3
+ *
4
+ * ListMcpResources / ReadMcpResource - Access resources from MCP servers.
5
+ */
6
+ // Registry of MCP connections (set by the agent)
7
+ let mcpConnections = [];
8
+ /**
9
+ * Set MCP connections for resource access.
10
+ */
11
+ export function setMcpConnections(connections) {
12
+ mcpConnections = connections;
13
+ }
14
+ export const ListMcpResourcesTool = {
15
+ name: 'ListMcpResources',
16
+ description: 'List available resources from connected MCP servers. Resources can include files, databases, and other data sources.',
17
+ inputSchema: {
18
+ type: 'object',
19
+ properties: {
20
+ server: { type: 'string', description: 'Filter by MCP server name' },
21
+ },
22
+ },
23
+ isReadOnly: () => true,
24
+ isConcurrencySafe: () => true,
25
+ isEnabled: () => true,
26
+ async prompt() { return 'List MCP resources.'; },
27
+ async call(input) {
28
+ const connections = input.server
29
+ ? mcpConnections.filter(c => c.name === input.server)
30
+ : mcpConnections;
31
+ if (connections.length === 0) {
32
+ return {
33
+ type: 'tool_result',
34
+ tool_use_id: '',
35
+ content: 'No MCP servers connected.',
36
+ };
37
+ }
38
+ const results = [];
39
+ for (const conn of connections) {
40
+ if (conn.status !== 'connected')
41
+ continue;
42
+ try {
43
+ // Access the underlying client to list resources
44
+ const resources = conn._client?.listResources?.();
45
+ if (resources) {
46
+ results.push(`Server: ${conn.name}`);
47
+ for (const r of resources) {
48
+ results.push(` - ${r.name}: ${r.description || r.uri || ''}`);
49
+ }
50
+ }
51
+ else {
52
+ results.push(`Server: ${conn.name} (${conn.tools.length} tools available)`);
53
+ }
54
+ }
55
+ catch {
56
+ results.push(`Server: ${conn.name} (resource listing not supported)`);
57
+ }
58
+ }
59
+ return {
60
+ type: 'tool_result',
61
+ tool_use_id: '',
62
+ content: results.join('\n') || 'No resources found.',
63
+ };
64
+ },
65
+ };
66
+ export const ReadMcpResourceTool = {
67
+ name: 'ReadMcpResource',
68
+ description: 'Read a specific resource from an MCP server.',
69
+ inputSchema: {
70
+ type: 'object',
71
+ properties: {
72
+ server: { type: 'string', description: 'MCP server name' },
73
+ uri: { type: 'string', description: 'Resource URI to read' },
74
+ },
75
+ required: ['server', 'uri'],
76
+ },
77
+ isReadOnly: () => true,
78
+ isConcurrencySafe: () => true,
79
+ isEnabled: () => true,
80
+ async prompt() { return 'Read an MCP resource.'; },
81
+ async call(input) {
82
+ const conn = mcpConnections.find(c => c.name === input.server);
83
+ if (!conn) {
84
+ return {
85
+ type: 'tool_result',
86
+ tool_use_id: '',
87
+ content: `MCP server not found: ${input.server}`,
88
+ is_error: true,
89
+ };
90
+ }
91
+ try {
92
+ const result = await conn._client?.readResource?.({ uri: input.uri });
93
+ if (result?.contents) {
94
+ const texts = result.contents.map((c) => c.text || JSON.stringify(c)).join('\n');
95
+ return {
96
+ type: 'tool_result',
97
+ tool_use_id: '',
98
+ content: texts,
99
+ };
100
+ }
101
+ return {
102
+ type: 'tool_result',
103
+ tool_use_id: '',
104
+ content: 'Resource read returned no content.',
105
+ };
106
+ }
107
+ catch (err) {
108
+ return {
109
+ type: 'tool_result',
110
+ tool_use_id: '',
111
+ content: `Error reading resource: ${err.message}`,
112
+ is_error: true,
113
+ };
114
+ }
115
+ },
116
+ };
117
+ //# sourceMappingURL=mcp-resource-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-resource-tools.js","sourceRoot":"","sources":["../../src/tools/mcp-resource-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,iDAAiD;AACjD,IAAI,cAAc,GAAoB,EAAE,CAAA;AAExC;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAA4B;IAC5D,cAAc,GAAG,WAAW,CAAA;AAC9B,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAmB;IAClD,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,sHAAsH;IACnI,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,2BAA2B,EAAE;SACrE;KACF;IACD,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI;IACtB,iBAAiB,EAAE,GAAG,EAAE,CAAC,IAAI;IAC7B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI;IACrB,KAAK,CAAC,MAAM,KAAK,OAAO,qBAAqB,CAAA,CAAC,CAAC;IAC/C,KAAK,CAAC,IAAI,CAAC,KAAU;QACnB,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM;YAC9B,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,I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AC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBACrF,OAAO;oBACL,IAAI,EAAE,aAAa;oBACnB,WAAW,EAAE,EAAE;oBACf,OAAO,EAAE,KAAK;iBACf,CAAA;YACH,CAAC;YACD,OAAO;gBACL,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,EAAE;gBACf,OAAO,EAAE,oCAAoC;aAC9C,CAAA;QACH,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO;gBACL,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,EAAE;gBACf,OAAO,EAAE,2BAA2B,GAAG,CAAC,OAAO,EAAE;gBACjD,QAAQ,EAAE,IAAI;aACf,CAAA;QACH,CAAC;IACH,CAAC;CACF,CAAA"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * NotebookEditTool - Edit Jupyter notebooks
3
+ */
4
+ export declare const NotebookEditTool: import("../types.js").ToolDefinition;
5
+ //# sourceMappingURL=notebook-edit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook-edit.d.ts","sourceRoot":"","sources":["../../src/tools/notebook-edit.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,eAAO,MAAM,gBAAgB,sCAoF3B,CAAA"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * NotebookEditTool - Edit Jupyter notebooks
3
+ */
4
+ import { readFile, writeFile } from 'fs/promises';
5
+ import { resolve } from 'path';
6
+ import { defineTool } from './types.js';
7
+ export const NotebookEditTool = defineTool({
8
+ name: 'NotebookEdit',
9
+ description: 'Edit Jupyter notebook (.ipynb) cells. Can insert, replace, or delete cells.',
10
+ inputSchema: {
11
+ type: 'object',
12
+ properties: {
13
+ file_path: {
14
+ type: 'string',
15
+ description: 'Path to the .ipynb file',
16
+ },
17
+ command: {
18
+ type: 'string',
19
+ enum: ['insert', 'replace', 'delete'],
20
+ description: 'The edit operation to perform',
21
+ },
22
+ cell_number: {
23
+ type: 'number',
24
+ description: 'Cell index (0-based) to operate on',
25
+ },
26
+ cell_type: {
27
+ type: 'string',
28
+ enum: ['code', 'markdown'],
29
+ description: 'Type of cell (for insert/replace)',
30
+ },
31
+ source: {
32
+ type: 'string',
33
+ description: 'Cell content (for insert/replace)',
34
+ },
35
+ },
36
+ required: ['file_path', 'command', 'cell_number'],
37
+ },
38
+ isReadOnly: false,
39
+ isConcurrencySafe: false,
40
+ async call(input, context) {
41
+ const filePath = resolve(context.cwd, input.file_path);
42
+ try {
43
+ const content = await readFile(filePath, 'utf-8');
44
+ const notebook = JSON.parse(content);
45
+ if (!notebook.cells || !Array.isArray(notebook.cells)) {
46
+ return { data: 'Error: Invalid notebook format', is_error: true };
47
+ }
48
+ const { command, cell_number, cell_type, source } = input;
49
+ switch (command) {
50
+ case 'insert': {
51
+ const newCell = {
52
+ cell_type: cell_type || 'code',
53
+ source: (source || '').split('\n').map((l, i, arr) => i < arr.length - 1 ? l + '\n' : l),
54
+ metadata: {},
55
+ ...(cell_type !== 'markdown' ? { outputs: [], execution_count: null } : {}),
56
+ };
57
+ notebook.cells.splice(cell_number, 0, newCell);
58
+ break;
59
+ }
60
+ case 'replace': {
61
+ if (cell_number >= notebook.cells.length) {
62
+ return { data: `Error: Cell ${cell_number} does not exist`, is_error: true };
63
+ }
64
+ notebook.cells[cell_number].source = (source || '').split('\n').map((l, i, arr) => i < arr.length - 1 ? l + '\n' : l);
65
+ if (cell_type)
66
+ notebook.cells[cell_number].cell_type = cell_type;
67
+ break;
68
+ }
69
+ case 'delete': {
70
+ if (cell_number >= notebook.cells.length) {
71
+ return { data: `Error: Cell ${cell_number} does not exist`, is_error: true };
72
+ }
73
+ notebook.cells.splice(cell_number, 1);
74
+ break;
75
+ }
76
+ }
77
+ await writeFile(filePath, JSON.stringify(notebook, null, 1), 'utf-8');
78
+ return `Notebook ${command}: cell ${cell_number} in ${filePath}`;
79
+ }
80
+ catch (err) {
81
+ return { data: `Error: ${err.message}`, is_error: true };
82
+ }
83
+ },
84
+ });
85
+ //# sourceMappingURL=notebook-edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook-edit.js","sourceRoot":"","sources":["../../src/tools/notebook-edit.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC;IACzC,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,6EAA6E;IAC1F,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yBAAyB;aACvC;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC;gBACrC,WAAW,EAAE,+BAA+B;aAC7C;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,oCAAoC;aAClD;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC;gBAC1B,WAAW,EAAE,mCAAmC;aACjD;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,mCAAmC;aACjD;SACF;QACD,QAAQ,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,aAAa,CAAC;KAClD;IACD,UAAU,EAAE,KAAK;IACjB,iBAAiB,EAAE,KAAK;IACxB,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO;QACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;QAEtD,IAAI,CAAC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plan Mode Tools
3
+ *
4
+ * EnterPlanMode / ExitPlanMode - Structured planning workflow.
5
+ * Allows the agent to enter a design/planning phase before execution.
6
+ */
7
+ import type { ToolDefinition } from '../types.js';
8
+ export declare function isPlanModeActive(): boolean;
9
+ export declare function getCurrentPlan(): string | null;
10
+ export declare const EnterPlanModeTool: ToolDefinition;
11
+ export declare const ExitPlanModeTool: ToolDefinition;
12
+ //# sourceMappingURL=plan-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-tools.d.ts","sourceRoot":"","sources":["../../src/tools/plan-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,aAAa,CAAA;AAM7D,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAED,wBAAgB,cAAc,IAAI,MAAM,GAAG,IAAI,CAE9C;AAED,eAAO,MAAM,iBAAiB,EAAE,cA6B/B,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,cAmC9B,CAAA"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Plan Mode Tools
3
+ *
4
+ * EnterPlanMode / ExitPlanMode - Structured planning workflow.
5
+ * Allows the agent to enter a design/planning phase before execution.
6
+ */
7
+ // Track plan mode state
8
+ let planModeActive = false;
9
+ let currentPlan = null;
10
+ export function isPlanModeActive() {
11
+ return planModeActive;
12
+ }
13
+ export function getCurrentPlan() {
14
+ return currentPlan;
15
+ }
16
+ export const EnterPlanModeTool = {
17
+ name: 'EnterPlanMode',
18
+ description: 'Enter plan/design mode for complex tasks. In plan mode, the agent focuses on designing the approach before executing.',
19
+ inputSchema: {
20
+ type: 'object',
21
+ properties: {},
22
+ },
23
+ isReadOnly: () => false,
24
+ isConcurrencySafe: () => false,
25
+ isEnabled: () => true,
26
+ async prompt() { return 'Enter plan mode for structured planning.'; },
27
+ async call() {
28
+ if (planModeActive) {
29
+ return {
30
+ type: 'tool_result',
31
+ tool_use_id: '',
32
+ content: 'Already in plan mode.',
33
+ };
34
+ }
35
+ planModeActive = true;
36
+ currentPlan = null;
37
+ return {
38
+ type: 'tool_result',
39
+ tool_use_id: '',
40
+ content: 'Entered plan mode. Design your approach before executing. Use ExitPlanMode when the plan is ready.',
41
+ };
42
+ },
43
+ };
44
+ export const ExitPlanModeTool = {
45
+ name: 'ExitPlanMode',
46
+ description: 'Exit plan mode with a completed plan. The plan will be recorded and execution can proceed.',
47
+ inputSchema: {
48
+ type: 'object',
49
+ properties: {
50
+ plan: { type: 'string', description: 'The completed plan' },
51
+ approved: { type: 'boolean', description: 'Whether the plan is approved for execution' },
52
+ },
53
+ },
54
+ isReadOnly: () => false,
55
+ isConcurrencySafe: () => false,
56
+ isEnabled: () => true,
57
+ async prompt() { return 'Exit plan mode with a completed plan.'; },
58
+ async call(input) {
59
+ if (!planModeActive) {
60
+ return {
61
+ type: 'tool_result',
62
+ tool_use_id: '',
63
+ content: 'Not in plan mode.',
64
+ is_error: true,
65
+ };
66
+ }
67
+ planModeActive = false;
68
+ currentPlan = input.plan || null;
69
+ const status = input.approved !== false ? 'approved' : 'pending approval';
70
+ return {
71
+ type: 'tool_result',
72
+ tool_use_id: '',
73
+ content: `Plan mode exited. Plan status: ${status}.${currentPlan ? `\n\nPlan:\n${currentPlan}` : ''}`,
74
+ };
75
+ },
76
+ };
77
+ //# sourceMappingURL=plan-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-tools.js","sourceRoot":"","sources":["../../src/tools/plan-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,wBAAwB;AACxB,IAAI,cAAc,GAAG,KAAK,CAAA;AAC1B,IAAI,WAAW,GAAkB,IAAI,CAAA;AAErC,MAAM,UAAU,gBAAgB;IAC9B,OAAO,cAAc,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAmB;IAC/C,IAAI,EAAE,eAAe;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E,aAAa;gBACnB,WAAW,EAAE,EAAE;gBACf,OAAO,EAAE,mBAAmB;gBAC5B,QAAQ,EAAE,IAAI;aACf,CAAA;QACH,CAAC;QAED,cAAc,GAAG,KAAK,CAAA;QACtB,WAAW,GAAG,KAAK,CAAC,IAAI,IAAI,IAAI,CAAA;QAEhC,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,kBAAkB,CAAA;QAEzE,OAAO;YACL,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,EAAE;YACf,OAAO,EAAE,kCAAkC,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,cAAc,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;SACtG,CAAA;IACH,CAAC;CACF,CAAA"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * FileReadTool - Read file contents with line numbers
3
+ */
4
+ export declare const FileReadTool: import("../types.js").ToolDefinition;
5
+ //# sourceMappingURL=read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/tools/read.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,eAAO,MAAM,YAAY,sCAgEvB,CAAA"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * FileReadTool - Read file contents with line numbers
3
+ */
4
+ import { readFile, stat } from 'fs/promises';
5
+ import { resolve } from 'path';
6
+ import { defineTool } from './types.js';
7
+ export const FileReadTool = defineTool({
8
+ name: 'Read',
9
+ description: 'Read a file from the filesystem. Returns content with line numbers. Supports text files, images (returns visual content), and PDFs.',
10
+ inputSchema: {
11
+ type: 'object',
12
+ properties: {
13
+ file_path: {
14
+ type: 'string',
15
+ description: 'The absolute path to the file to read',
16
+ },
17
+ offset: {
18
+ type: 'number',
19
+ description: 'Line number to start reading from (0-based)',
20
+ },
21
+ limit: {
22
+ type: 'number',
23
+ description: 'Maximum number of lines to read',
24
+ },
25
+ },
26
+ required: ['file_path'],
27
+ },
28
+ isReadOnly: true,
29
+ isConcurrencySafe: true,
30
+ async call(input, context) {
31
+ const filePath = resolve(context.cwd, input.file_path);
32
+ try {
33
+ const fileStat = await stat(filePath);
34
+ if (fileStat.isDirectory()) {
35
+ return { data: `Error: ${filePath} is a directory, not a file. Use Bash with 'ls' to list directory contents.`, is_error: true };
36
+ }
37
+ // Check for binary/image files
38
+ const ext = filePath.split('.').pop()?.toLowerCase();
39
+ if (['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'svg'].includes(ext || '')) {
40
+ return `[Image file: ${filePath} (${fileStat.size} bytes)]`;
41
+ }
42
+ const content = await readFile(filePath, 'utf-8');
43
+ const lines = content.split('\n');
44
+ const offset = input.offset || 0;
45
+ const limit = input.limit || 2000;
46
+ const selectedLines = lines.slice(offset, offset + limit);
47
+ // Format with line numbers (cat -n style)
48
+ const numbered = selectedLines.map((line, i) => {
49
+ const lineNum = offset + i + 1;
50
+ return `${lineNum}\t${line}`;
51
+ }).join('\n');
52
+ let result = numbered;
53
+ if (lines.length > offset + limit) {
54
+ result += `\n\n(${lines.length - offset - limit} more lines not shown)`;
55
+ }
56
+ return result || '(empty file)';
57
+ }
58
+ catch (err) {
59
+ if (err.code === 'ENOENT') {
60
+ return { data: `Error: File not found: ${filePath}`, is_error: true };
61
+ }
62
+ return { data: `Error reading file: ${err.message}`, is_error: true };
63
+ }
64
+ },
65
+ });
66
+ //# sourceMappingURL=read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/tools/read.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;IACrC,IAAI,EAA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
+ import type { ToolDefinition } from '../types.js';
8
+ /**
9
+ * Message inbox for inter-agent communication.
10
+ */
11
+ export interface AgentMessage {
12
+ from: string;
13
+ to: string;
14
+ content: string;
15
+ timestamp: string;
16
+ type: 'text' | 'shutdown_request' | 'shutdown_response' | 'plan_approval_response';
17
+ }
18
+ /**
19
+ * Read messages from a mailbox.
20
+ */
21
+ export declare function readMailbox(agentName: string): AgentMessage[];
22
+ /**
23
+ * Write to a mailbox.
24
+ */
25
+ export declare function writeToMailbox(agentName: string, message: AgentMessage): void;
26
+ /**
27
+ * Clear all mailboxes.
28
+ */
29
+ export declare function clearMailboxes(): void;
30
+ export declare const SendMessageTool: ToolDefinition;
31
+ //# sourceMappingURL=send-message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-message.d.ts","sourceRoot":"","sources":["../../src/tools/send-message.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,aAAa,CAAA;AAE7D;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,mBAAmB,GAAG,wBAAwB,CAAA;CACnF;AAID;;GAEG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,EAAE,CAI7D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAI7E;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAErC;AAED,eAAO,MAAM,eAAe,EAAE,cAgD7B,CAAA"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * SendMessageTool - Inter-agent messaging
3
+ *
4
+ * Supports plain text and structured protocol messages
5
+ * between teammates in a multi-agent setup.
6
+ */
7
+ const mailboxes = new Map();
8
+ /**
9
+ * Read messages from a mailbox.
10
+ */
11
+ export function readMailbox(agentName) {
12
+ const messages = mailboxes.get(agentName) || [];
13
+ mailboxes.set(agentName, []); // Clear after reading
14
+ return messages;
15
+ }
16
+ /**
17
+ * Write to a mailbox.
18
+ */
19
+ export function writeToMailbox(agentName, message) {
20
+ const messages = mailboxes.get(agentName) || [];
21
+ messages.push(message);
22
+ mailboxes.set(agentName, messages);
23
+ }
24
+ /**
25
+ * Clear all mailboxes.
26
+ */
27
+ export function clearMailboxes() {
28
+ mailboxes.clear();
29
+ }
30
+ export const SendMessageTool = {
31
+ name: 'SendMessage',
32
+ description: 'Send a message to another agent or teammate. Supports plain text and structured protocol messages.',
33
+ inputSchema: {
34
+ type: 'object',
35
+ properties: {
36
+ to: { type: 'string', description: 'Recipient agent name or ID. Use "*" for broadcast.' },
37
+ content: { type: 'string', description: 'Message content' },
38
+ type: {
39
+ type: 'string',
40
+ enum: ['text', 'shutdown_request', 'shutdown_response', 'plan_approval_response'],
41
+ description: 'Message type (default: text)',
42
+ },
43
+ },
44
+ required: ['to', 'content'],
45
+ },
46
+ isReadOnly: () => false,
47
+ isConcurrencySafe: () => true,
48
+ isEnabled: () => true,
49
+ async prompt() { return 'Send a message to another agent.'; },
50
+ async call(input) {
51
+ const message = {
52
+ from: 'self',
53
+ to: input.to,
54
+ content: input.content,
55
+ timestamp: new Date().toISOString(),
56
+ type: input.type || 'text',
57
+ };
58
+ if (input.to === '*') {
59
+ // Broadcast to all known mailboxes
60
+ for (const [name] of mailboxes) {
61
+ writeToMailbox(name, { ...message, to: name });
62
+ }
63
+ return {
64
+ type: 'tool_result',
65
+ tool_use_id: '',
66
+ content: `Message broadcast to all agents`,
67
+ };
68
+ }
69
+ writeToMailbox(input.to, message);
70
+ return {
71
+ type: 'tool_result',
72
+ tool_use_id: '',
73
+ content: `Message sent to ${input.to}`,
74
+ };
75
+ },
76
+ };
77
+ //# sourceMappingURL=send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AE,CAAC,IAAI,EAAE,SAAS,CAAC;KAC5B;IACD,UAAU,EAAE,GAAG,EAAE,CAAC,KAAK;IACvB,iBAAiB,EAAE,GAAG,EAAE,CAAC,IAAI;IAC7B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI;IACrB,KAAK,CAAC,MAAM,KAAK,OAAO,kCAAkC,CAAA,CAAC,CAAC;IAC5D,KAAK,CAAC,IAAI,CAAC,KAAU;QACnB,MAAM,OAAO,GAAiB;YAC5B,IAAI,EAAE,MAAM;YACZ,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,MAAM;SAC3B,CAAA;QAED,IAAI,KAAK,CAAC,EAAE,KAAK,GAAG,EAAE,CAAC;YACrB,mCAAmC;YACnC,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,SAAS,EAAE,CAAC;gBAC/B,cAAc,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;YAChD,CAAC;YACD,OAAO;gBACL,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,EAAE;gBACf,OAAO,EAAE,iCAAiC;aAC3C,CAAA;QACH,CAAC;QAED,cAAc,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;QACjC,OAAO;YACL,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,EAAE;YACf,OAAO,EAAE,mBAAmB,KAAK,CAAC,EAAE,EAAE;SACvC,CAAA;IACH,CAAC;CACF,CAAA"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Skill Tool
3
+ *
4
+ * Allows the model to invoke registered skills by name.
5
+ * Skills are prompt templates that provide specialized capabilities.
6
+ */
7
+ import type { ToolDefinition } from '../types.js';
8
+ export declare const SkillTool: ToolDefinition;
9
+ //# sourceMappingURL=skill-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-tool.d.ts","sourceRoot":"","sources":["../../src/tools/skill-tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,aAAa,CAAA;AAG1E,eAAO,MAAM,SAAS,EAAE,cA0HvB,CAAA"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Skill Tool
3
+ *
4
+ * Allows the model to invoke registered skills by name.
5
+ * Skills are prompt templates that provide specialized capabilities.
6
+ */
7
+ import { getSkill, getUserInvocableSkills } from '../skills/registry.js';
8
+ export const SkillTool = {
9
+ name: 'Skill',
10
+ description: 'Execute a skill within the current conversation. ' +
11
+ 'Skills provide specialized capabilities and domain knowledge. ' +
12
+ 'Use this tool with the skill name and optional arguments. ' +
13
+ 'Available skills are listed in system-reminder messages.',
14
+ inputSchema: {
15
+ type: 'object',
16
+ properties: {
17
+ skill: {
18
+ type: 'string',
19
+ description: 'The skill name to execute (e.g., "commit", "review", "simplify")',
20
+ },
21
+ args: {
22
+ type: 'string',
23
+ description: 'Optional arguments for the skill',
24
+ },
25
+ },
26
+ required: ['skill'],
27
+ },
28
+ isReadOnly: () => false,
29
+ isConcurrencySafe: () => false,
30
+ isEnabled: () => getUserInvocableSkills().length > 0,
31
+ async prompt() {
32
+ const skills = getUserInvocableSkills();
33
+ if (skills.length === 0)
34
+ return '';
35
+ const lines = skills.map((s) => {
36
+ const desc = s.description.length > 200
37
+ ? s.description.slice(0, 200) + '...'
38
+ : s.description;
39
+ return `- ${s.name}: ${desc}`;
40
+ });
41
+ return ('Execute a skill within the main conversation.\n\n' +
42
+ 'Available skills:\n' +
43
+ lines.join('\n') +
44
+ '\n\nWhen a skill matches the user\'s request, invoke it using the Skill tool.');
45
+ },
46
+ async call(input, context) {
47
+ const skillName = input.skill;
48
+ const args = input.args || '';
49
+ if (!skillName) {
50
+ return {
51
+ type: 'tool_result',
52
+ tool_use_id: '',
53
+ content: 'Error: skill name is required',
54
+ is_error: true,
55
+ };
56
+ }
57
+ const skill = getSkill(skillName);
58
+ if (!skill) {
59
+ const available = getUserInvocableSkills()
60
+ .map((s) => s.name)
61
+ .join(', ');
62
+ return {
63
+ type: 'tool_result',
64
+ tool_use_id: '',
65
+ content: `Error: Unknown skill "${skillName}". Available skills: ${available || 'none'}`,
66
+ is_error: true,
67
+ };
68
+ }
69
+ // Check if skill is enabled
70
+ if (skill.isEnabled && !skill.isEnabled()) {
71
+ return {
72
+ type: 'tool_result',
73
+ tool_use_id: '',
74
+ content: `Error: Skill "${skillName}" is currently disabled`,
75
+ is_error: true,
76
+ };
77
+ }
78
+ try {
79
+ // Get skill prompt
80
+ const contentBlocks = await skill.getPrompt(args, context);
81
+ // Convert content blocks to text
82
+ const promptText = contentBlocks
83
+ .filter((b) => b.type === 'text')
84
+ .map((b) => b.text)
85
+ .join('\n\n');
86
+ // Build result with metadata
87
+ const result = {
88
+ success: true,
89
+ commandName: skill.name,
90
+ status: skill.context === 'fork' ? 'forked' : 'inline',
91
+ prompt: promptText,
92
+ };
93
+ if (skill.allowedTools) {
94
+ result.allowedTools = skill.allowedTools;
95
+ }
96
+ if (skill.model) {
97
+ result.model = skill.model;
98
+ }
99
+ return {
100
+ type: 'tool_result',
101
+ tool_use_id: '',
102
+ content: JSON.stringify(result),
103
+ };
104
+ }
105
+ catch (err) {
106
+ return {
107
+ type: 'tool_result',
108
+ tool_use_id: '',
109
+ content: `Error executing skill "${skillName}": ${err.message}`,
110
+ is_error: true,
111
+ };
112
+ }
113
+ },
114
+ };
115
+ //# sourceMappingURL=skill-tool.js.map