@nodetool-ai/agents 0.7.0-rc.11

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 (281) hide show
  1. package/dist/agent-executor.d.ts +62 -0
  2. package/dist/agent-executor.d.ts.map +1 -0
  3. package/dist/agent-executor.js +324 -0
  4. package/dist/agent-executor.js.map +1 -0
  5. package/dist/agent-step-executor.d.ts +28 -0
  6. package/dist/agent-step-executor.d.ts.map +1 -0
  7. package/dist/agent-step-executor.js +99 -0
  8. package/dist/agent-step-executor.js.map +1 -0
  9. package/dist/agent-workflow-runner.d.ts +31 -0
  10. package/dist/agent-workflow-runner.d.ts.map +1 -0
  11. package/dist/agent-workflow-runner.js +124 -0
  12. package/dist/agent-workflow-runner.js.map +1 -0
  13. package/dist/agent.d.ts +115 -0
  14. package/dist/agent.d.ts.map +1 -0
  15. package/dist/agent.js +587 -0
  16. package/dist/agent.js.map +1 -0
  17. package/dist/base-agent.d.ts +42 -0
  18. package/dist/base-agent.d.ts.map +1 -0
  19. package/dist/base-agent.js +29 -0
  20. package/dist/base-agent.js.map +1 -0
  21. package/dist/constants.d.ts +8 -0
  22. package/dist/constants.d.ts.map +1 -0
  23. package/dist/constants.js +8 -0
  24. package/dist/constants.js.map +1 -0
  25. package/dist/graph-builder.d.ts +49 -0
  26. package/dist/graph-builder.d.ts.map +1 -0
  27. package/dist/graph-builder.js +206 -0
  28. package/dist/graph-builder.js.map +1 -0
  29. package/dist/graph-planner.d.ts +56 -0
  30. package/dist/graph-planner.d.ts.map +1 -0
  31. package/dist/graph-planner.js +311 -0
  32. package/dist/graph-planner.js.map +1 -0
  33. package/dist/index.d.ts +79 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +81 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/js-sandbox.d.ts +84 -0
  38. package/dist/js-sandbox.d.ts.map +1 -0
  39. package/dist/js-sandbox.js +654 -0
  40. package/dist/js-sandbox.js.map +1 -0
  41. package/dist/multi-mode-agent.d.ts +86 -0
  42. package/dist/multi-mode-agent.d.ts.map +1 -0
  43. package/dist/multi-mode-agent.js +476 -0
  44. package/dist/multi-mode-agent.js.map +1 -0
  45. package/dist/output-format.d.ts +10 -0
  46. package/dist/output-format.d.ts.map +1 -0
  47. package/dist/output-format.js +17 -0
  48. package/dist/output-format.js.map +1 -0
  49. package/dist/parallel-task-executor.d.ts +87 -0
  50. package/dist/parallel-task-executor.d.ts.map +1 -0
  51. package/dist/parallel-task-executor.js +332 -0
  52. package/dist/parallel-task-executor.js.map +1 -0
  53. package/dist/prompts/graph-planner-prompt.d.ts +48 -0
  54. package/dist/prompts/graph-planner-prompt.d.ts.map +1 -0
  55. package/dist/prompts/graph-planner-prompt.js +180 -0
  56. package/dist/prompts/graph-planner-prompt.js.map +1 -0
  57. package/dist/reject-agentic-provider.d.ts +21 -0
  58. package/dist/reject-agentic-provider.d.ts.map +1 -0
  59. package/dist/reject-agentic-provider.js +32 -0
  60. package/dist/reject-agentic-provider.js.map +1 -0
  61. package/dist/simple-agent.d.ts +29 -0
  62. package/dist/simple-agent.d.ts.map +1 -0
  63. package/dist/simple-agent.js +54 -0
  64. package/dist/simple-agent.js.map +1 -0
  65. package/dist/step-executor.d.ts +162 -0
  66. package/dist/step-executor.d.ts.map +1 -0
  67. package/dist/step-executor.js +1114 -0
  68. package/dist/step-executor.js.map +1 -0
  69. package/dist/sub-agent-planner.d.ts +33 -0
  70. package/dist/sub-agent-planner.d.ts.map +1 -0
  71. package/dist/sub-agent-planner.js +203 -0
  72. package/dist/sub-agent-planner.js.map +1 -0
  73. package/dist/task-executor.d.ts +89 -0
  74. package/dist/task-executor.d.ts.map +1 -0
  75. package/dist/task-executor.js +359 -0
  76. package/dist/task-executor.js.map +1 -0
  77. package/dist/task-planner.d.ts +44 -0
  78. package/dist/task-planner.d.ts.map +1 -0
  79. package/dist/task-planner.js +532 -0
  80. package/dist/task-planner.js.map +1 -0
  81. package/dist/team/db-task-board.d.ts +54 -0
  82. package/dist/team/db-task-board.d.ts.map +1 -0
  83. package/dist/team/db-task-board.js +361 -0
  84. package/dist/team/db-task-board.js.map +1 -0
  85. package/dist/team/edge-message-bus.d.ts +51 -0
  86. package/dist/team/edge-message-bus.d.ts.map +1 -0
  87. package/dist/team/edge-message-bus.js +169 -0
  88. package/dist/team/edge-message-bus.js.map +1 -0
  89. package/dist/team/edge-task-board.d.ts +77 -0
  90. package/dist/team/edge-task-board.d.ts.map +1 -0
  91. package/dist/team/edge-task-board.js +140 -0
  92. package/dist/team/edge-task-board.js.map +1 -0
  93. package/dist/team/index.d.ts +16 -0
  94. package/dist/team/index.d.ts.map +1 -0
  95. package/dist/team/index.js +17 -0
  96. package/dist/team/index.js.map +1 -0
  97. package/dist/team/message-bus.d.ts +58 -0
  98. package/dist/team/message-bus.d.ts.map +1 -0
  99. package/dist/team/message-bus.js +151 -0
  100. package/dist/team/message-bus.js.map +1 -0
  101. package/dist/team/task-board.d.ts +106 -0
  102. package/dist/team/task-board.d.ts.map +1 -0
  103. package/dist/team/task-board.js +370 -0
  104. package/dist/team/task-board.js.map +1 -0
  105. package/dist/team/team-executor.d.ts +72 -0
  106. package/dist/team/team-executor.d.ts.map +1 -0
  107. package/dist/team/team-executor.js +466 -0
  108. package/dist/team/team-executor.js.map +1 -0
  109. package/dist/team/team-tools.d.ts +252 -0
  110. package/dist/team/team-tools.d.ts.map +1 -0
  111. package/dist/team/team-tools.js +412 -0
  112. package/dist/team/team-tools.js.map +1 -0
  113. package/dist/team/types.d.ts +198 -0
  114. package/dist/team/types.d.ts.map +1 -0
  115. package/dist/team/types.js +8 -0
  116. package/dist/team/types.js.map +1 -0
  117. package/dist/tools/add-edge-tool.d.ts +18 -0
  118. package/dist/tools/add-edge-tool.d.ts.map +1 -0
  119. package/dist/tools/add-edge-tool.js +92 -0
  120. package/dist/tools/add-edge-tool.js.map +1 -0
  121. package/dist/tools/add-node-tool.d.ts +22 -0
  122. package/dist/tools/add-node-tool.d.ts.map +1 -0
  123. package/dist/tools/add-node-tool.js +128 -0
  124. package/dist/tools/add-node-tool.js.map +1 -0
  125. package/dist/tools/asset-tools.d.ts +58 -0
  126. package/dist/tools/asset-tools.d.ts.map +1 -0
  127. package/dist/tools/asset-tools.js +191 -0
  128. package/dist/tools/asset-tools.js.map +1 -0
  129. package/dist/tools/base-tool.d.ts +25 -0
  130. package/dist/tools/base-tool.d.ts.map +1 -0
  131. package/dist/tools/base-tool.js +24 -0
  132. package/dist/tools/base-tool.js.map +1 -0
  133. package/dist/tools/browser-tools.d.ts +32 -0
  134. package/dist/tools/browser-tools.d.ts.map +1 -0
  135. package/dist/tools/browser-tools.js +208 -0
  136. package/dist/tools/browser-tools.js.map +1 -0
  137. package/dist/tools/calculator-tool.d.ts +24 -0
  138. package/dist/tools/calculator-tool.d.ts.map +1 -0
  139. package/dist/tools/calculator-tool.js +64 -0
  140. package/dist/tools/calculator-tool.js.map +1 -0
  141. package/dist/tools/claude-code-tools.d.ts +96 -0
  142. package/dist/tools/claude-code-tools.d.ts.map +1 -0
  143. package/dist/tools/claude-code-tools.js +463 -0
  144. package/dist/tools/claude-code-tools.js.map +1 -0
  145. package/dist/tools/code-tools.d.ts +26 -0
  146. package/dist/tools/code-tools.d.ts.map +1 -0
  147. package/dist/tools/code-tools.js +82 -0
  148. package/dist/tools/code-tools.js.map +1 -0
  149. package/dist/tools/control-tool.d.ts +47 -0
  150. package/dist/tools/control-tool.d.ts.map +1 -0
  151. package/dist/tools/control-tool.js +101 -0
  152. package/dist/tools/control-tool.js.map +1 -0
  153. package/dist/tools/create-plan-tool.d.ts +29 -0
  154. package/dist/tools/create-plan-tool.d.ts.map +1 -0
  155. package/dist/tools/create-plan-tool.js +355 -0
  156. package/dist/tools/create-plan-tool.js.map +1 -0
  157. package/dist/tools/create-task-tool.d.ts +28 -0
  158. package/dist/tools/create-task-tool.d.ts.map +1 -0
  159. package/dist/tools/create-task-tool.js +254 -0
  160. package/dist/tools/create-task-tool.js.map +1 -0
  161. package/dist/tools/dataseo-tools.d.ts +38 -0
  162. package/dist/tools/dataseo-tools.d.ts.map +1 -0
  163. package/dist/tools/dataseo-tools.js +329 -0
  164. package/dist/tools/dataseo-tools.js.map +1 -0
  165. package/dist/tools/email-tools.d.ts +76 -0
  166. package/dist/tools/email-tools.d.ts.map +1 -0
  167. package/dist/tools/email-tools.js +259 -0
  168. package/dist/tools/email-tools.js.map +1 -0
  169. package/dist/tools/filesystem-tools.d.ts +77 -0
  170. package/dist/tools/filesystem-tools.d.ts.map +1 -0
  171. package/dist/tools/filesystem-tools.js +334 -0
  172. package/dist/tools/filesystem-tools.js.map +1 -0
  173. package/dist/tools/find-model-tool.d.ts +25 -0
  174. package/dist/tools/find-model-tool.d.ts.map +1 -0
  175. package/dist/tools/find-model-tool.js +236 -0
  176. package/dist/tools/find-model-tool.js.map +1 -0
  177. package/dist/tools/finish-graph-tool.d.ts +23 -0
  178. package/dist/tools/finish-graph-tool.d.ts.map +1 -0
  179. package/dist/tools/finish-graph-tool.js +46 -0
  180. package/dist/tools/finish-graph-tool.js.map +1 -0
  181. package/dist/tools/finish-step-tool.d.ts +16 -0
  182. package/dist/tools/finish-step-tool.d.ts.map +1 -0
  183. package/dist/tools/finish-step-tool.js +68 -0
  184. package/dist/tools/finish-step-tool.js.map +1 -0
  185. package/dist/tools/google-tools.d.ts +44 -0
  186. package/dist/tools/google-tools.d.ts.map +1 -0
  187. package/dist/tools/google-tools.js +176 -0
  188. package/dist/tools/google-tools.js.map +1 -0
  189. package/dist/tools/http-tools.d.ts +56 -0
  190. package/dist/tools/http-tools.d.ts.map +1 -0
  191. package/dist/tools/http-tools.js +180 -0
  192. package/dist/tools/http-tools.js.map +1 -0
  193. package/dist/tools/js-code-tool.d.ts +30 -0
  194. package/dist/tools/js-code-tool.d.ts.map +1 -0
  195. package/dist/tools/js-code-tool.js +98 -0
  196. package/dist/tools/js-code-tool.js.map +1 -0
  197. package/dist/tools/local-get-node-info-tool.d.ts +19 -0
  198. package/dist/tools/local-get-node-info-tool.d.ts.map +1 -0
  199. package/dist/tools/local-get-node-info-tool.js +75 -0
  200. package/dist/tools/local-get-node-info-tool.js.map +1 -0
  201. package/dist/tools/local-list-nodes-tool.d.ts +19 -0
  202. package/dist/tools/local-list-nodes-tool.d.ts.map +1 -0
  203. package/dist/tools/local-list-nodes-tool.js +69 -0
  204. package/dist/tools/local-list-nodes-tool.js.map +1 -0
  205. package/dist/tools/local-search-nodes-tool.d.ts +21 -0
  206. package/dist/tools/local-search-nodes-tool.d.ts.map +1 -0
  207. package/dist/tools/local-search-nodes-tool.js +111 -0
  208. package/dist/tools/local-search-nodes-tool.js.map +1 -0
  209. package/dist/tools/math-tools.d.ts +156 -0
  210. package/dist/tools/math-tools.d.ts.map +1 -0
  211. package/dist/tools/math-tools.js +422 -0
  212. package/dist/tools/math-tools.js.map +1 -0
  213. package/dist/tools/mcp-tools.d.ts +413 -0
  214. package/dist/tools/mcp-tools.d.ts.map +1 -0
  215. package/dist/tools/mcp-tools.js +618 -0
  216. package/dist/tools/mcp-tools.js.map +1 -0
  217. package/dist/tools/media-tools.d.ts +277 -0
  218. package/dist/tools/media-tools.d.ts.map +1 -0
  219. package/dist/tools/media-tools.js +682 -0
  220. package/dist/tools/media-tools.js.map +1 -0
  221. package/dist/tools/model-tools.d.ts +25 -0
  222. package/dist/tools/model-tools.d.ts.map +1 -0
  223. package/dist/tools/model-tools.js +48 -0
  224. package/dist/tools/model-tools.js.map +1 -0
  225. package/dist/tools/openai-tools.d.ts +73 -0
  226. package/dist/tools/openai-tools.d.ts.map +1 -0
  227. package/dist/tools/openai-tools.js +193 -0
  228. package/dist/tools/openai-tools.js.map +1 -0
  229. package/dist/tools/pdf-tools.d.ts +152 -0
  230. package/dist/tools/pdf-tools.d.ts.map +1 -0
  231. package/dist/tools/pdf-tools.js +339 -0
  232. package/dist/tools/pdf-tools.js.map +1 -0
  233. package/dist/tools/plan-builder-tools.d.ts +72 -0
  234. package/dist/tools/plan-builder-tools.d.ts.map +1 -0
  235. package/dist/tools/plan-builder-tools.js +438 -0
  236. package/dist/tools/plan-builder-tools.js.map +1 -0
  237. package/dist/tools/search-tools.d.ts +39 -0
  238. package/dist/tools/search-tools.d.ts.map +1 -0
  239. package/dist/tools/search-tools.js +218 -0
  240. package/dist/tools/search-tools.js.map +1 -0
  241. package/dist/tools/serp-providers/dataforseo-provider.d.ts +14 -0
  242. package/dist/tools/serp-providers/dataforseo-provider.d.ts.map +1 -0
  243. package/dist/tools/serp-providers/dataforseo-provider.js +114 -0
  244. package/dist/tools/serp-providers/dataforseo-provider.js.map +1 -0
  245. package/dist/tools/serp-providers/index.d.ts +35 -0
  246. package/dist/tools/serp-providers/index.d.ts.map +1 -0
  247. package/dist/tools/serp-providers/index.js +14 -0
  248. package/dist/tools/serp-providers/index.js.map +1 -0
  249. package/dist/tools/serp-providers/serpapi-provider.d.ts +18 -0
  250. package/dist/tools/serp-providers/serpapi-provider.d.ts.map +1 -0
  251. package/dist/tools/serp-providers/serpapi-provider.js +66 -0
  252. package/dist/tools/serp-providers/serpapi-provider.js.map +1 -0
  253. package/dist/tools/tool-registry.d.ts +9 -0
  254. package/dist/tools/tool-registry.d.ts.map +1 -0
  255. package/dist/tools/tool-registry.js +17 -0
  256. package/dist/tools/tool-registry.js.map +1 -0
  257. package/dist/tools/vector-tools.d.ts +224 -0
  258. package/dist/tools/vector-tools.d.ts.map +1 -0
  259. package/dist/tools/vector-tools.js +582 -0
  260. package/dist/tools/vector-tools.js.map +1 -0
  261. package/dist/tools/workspace-tools.d.ts +58 -0
  262. package/dist/tools/workspace-tools.d.ts.map +1 -0
  263. package/dist/tools/workspace-tools.js +152 -0
  264. package/dist/tools/workspace-tools.js.map +1 -0
  265. package/dist/types.d.ts +65 -0
  266. package/dist/types.d.ts.map +1 -0
  267. package/dist/types.js +5 -0
  268. package/dist/types.js.map +1 -0
  269. package/dist/utils/json-parser.d.ts +15 -0
  270. package/dist/utils/json-parser.d.ts.map +1 -0
  271. package/dist/utils/json-parser.js +78 -0
  272. package/dist/utils/json-parser.js.map +1 -0
  273. package/dist/utils/remove-base64-images.d.ts +12 -0
  274. package/dist/utils/remove-base64-images.d.ts.map +1 -0
  275. package/dist/utils/remove-base64-images.js +20 -0
  276. package/dist/utils/remove-base64-images.js.map +1 -0
  277. package/dist/utils/wrap-generators-parallel.d.ts +11 -0
  278. package/dist/utils/wrap-generators-parallel.d.ts.map +1 -0
  279. package/dist/utils/wrap-generators-parallel.js +38 -0
  280. package/dist/utils/wrap-generators-parallel.js.map +1 -0
  281. package/package.json +65 -0
@@ -0,0 +1,191 @@
1
+ /**
2
+ * Asset management tools for the agent system.
3
+ *
4
+ * Port of src/nodetool/agents/tools/asset_tools.py
5
+ *
6
+ * Provides:
7
+ * - SaveAssetTool: Save text or binary (base64) content as an asset.
8
+ * Prefers `context.createAsset` (DB + storage, returns asset:// URI) and
9
+ * falls back to the lower-level storage adapter for plain text/key-value.
10
+ * - ReadAssetTool: Read content from a stored asset file.
11
+ */
12
+ import { Buffer } from "node:buffer";
13
+ import { Tool } from "./base-tool.js";
14
+ export class SaveAssetTool extends Tool {
15
+ name = "save_asset";
16
+ description = "Save content as an asset. Use this for any artifact you want to surface in the chat (text reports, JSON, manifests, images, audio). Pass `content_base64` for binary data and `content` for text. Returns an asset_id and asset:// URI you can reference in later steps.";
17
+ inputSchema = {
18
+ type: "object",
19
+ properties: {
20
+ name: {
21
+ type: "string",
22
+ description: "Display name of the asset (e.g. 'summary.md', 'report.json', 'cover.png')."
23
+ },
24
+ content: {
25
+ type: "string",
26
+ description: "Text content. Use this for text/markdown/JSON. Mutually exclusive with content_base64."
27
+ },
28
+ content_base64: {
29
+ type: "string",
30
+ description: "Binary content as a base64 string. Use this for images/audio/video bytes returned by other tools."
31
+ },
32
+ content_type: {
33
+ type: "string",
34
+ description: "MIME type (e.g. 'text/markdown', 'application/json', 'image/png'). Defaults to text/plain for text and application/octet-stream for binary."
35
+ }
36
+ },
37
+ required: ["name"]
38
+ };
39
+ async process(context, params) {
40
+ try {
41
+ const name = params.name;
42
+ const content = params.content;
43
+ const contentBase64 = params.content_base64;
44
+ const contentTypeArg = params.content_type;
45
+ if (typeof name !== "string" || !name) {
46
+ return {
47
+ success: false,
48
+ error: "name is required and must be a string"
49
+ };
50
+ }
51
+ const hasText = typeof content === "string";
52
+ const hasBinary = typeof contentBase64 === "string" && contentBase64;
53
+ if (!hasText && !hasBinary) {
54
+ return {
55
+ success: false,
56
+ error: "Either `content` (text) or `content_base64` (binary) is required"
57
+ };
58
+ }
59
+ const data = hasBinary
60
+ ? new Uint8Array(Buffer.from(contentBase64, "base64"))
61
+ : new TextEncoder().encode(content);
62
+ const mime = typeof contentTypeArg === "string" && contentTypeArg
63
+ ? contentTypeArg
64
+ : hasBinary
65
+ ? "application/octet-stream"
66
+ : "text/plain";
67
+ // Prefer the model interface (DB + storage). This is what the chat
68
+ // UI surfaces in the asset browser and what other tools can reference
69
+ // by `asset://<id>.<ext>` URIs.
70
+ if (typeof context.createAsset === "function") {
71
+ const asset = (await context.createAsset({
72
+ name,
73
+ contentType: mime,
74
+ content: data
75
+ }));
76
+ if (asset && typeof asset.id === "string") {
77
+ return {
78
+ success: true,
79
+ name,
80
+ asset_id: asset.id,
81
+ asset_uri: `asset://${asset.id}`,
82
+ content_type: mime,
83
+ size: data.byteLength
84
+ };
85
+ }
86
+ }
87
+ // Fallback: write to the storage adapter directly.
88
+ if (!context.storage) {
89
+ return {
90
+ success: false,
91
+ error: "No storage adapter or createAsset interface available — cannot persist asset"
92
+ };
93
+ }
94
+ const key = `assets/${name}`;
95
+ const uri = await context.storage.store(key, data, mime);
96
+ return {
97
+ success: true,
98
+ name,
99
+ uri,
100
+ content_type: mime,
101
+ size: data.byteLength
102
+ };
103
+ }
104
+ catch (e) {
105
+ return {
106
+ success: false,
107
+ error: e instanceof Error ? e.message : String(e)
108
+ };
109
+ }
110
+ }
111
+ userMessage(params) {
112
+ const name = params.name;
113
+ if (typeof name === "string" && name) {
114
+ const msg = `Saving asset as ${name}...`;
115
+ return msg.length > 80 ? "Saving asset..." : msg;
116
+ }
117
+ return "Saving asset...";
118
+ }
119
+ }
120
+ export class ReadAssetTool extends Tool {
121
+ name = "read_asset";
122
+ description = "Read an asset file";
123
+ inputSchema = {
124
+ type: "object",
125
+ properties: {
126
+ name: {
127
+ type: "string",
128
+ description: "Name of the asset file to read"
129
+ }
130
+ },
131
+ required: ["name"]
132
+ };
133
+ async process(context, params) {
134
+ try {
135
+ const name = params.name;
136
+ if (typeof name !== "string" || !name) {
137
+ return {
138
+ success: false,
139
+ error: "name is required and must be a string"
140
+ };
141
+ }
142
+ if (!context.storage) {
143
+ return { success: false, error: "No storage adapter configured" };
144
+ }
145
+ // Build the expected URI from the asset key
146
+ const key = `assets/${name}`;
147
+ // Try common URI schemes that the storage adapter may use
148
+ const schemes = [`memory://${key}`, `file://${key}`, `s3://${key}`];
149
+ let data = null;
150
+ let matchedUri = null;
151
+ // First try storing nothing - just check if we can retrieve by key directly
152
+ for (const uri of schemes) {
153
+ const result = await context.storage.retrieve(uri);
154
+ if (result) {
155
+ data = result;
156
+ matchedUri = uri;
157
+ break;
158
+ }
159
+ }
160
+ if (!data) {
161
+ return {
162
+ success: false,
163
+ error: `Asset not found: ${name}`
164
+ };
165
+ }
166
+ const content = new TextDecoder().decode(data);
167
+ return {
168
+ success: true,
169
+ name,
170
+ content,
171
+ uri: matchedUri,
172
+ size: data.byteLength
173
+ };
174
+ }
175
+ catch (e) {
176
+ return {
177
+ success: false,
178
+ error: e instanceof Error ? e.message : String(e)
179
+ };
180
+ }
181
+ }
182
+ userMessage(params) {
183
+ const name = params.name;
184
+ if (typeof name === "string" && name) {
185
+ const msg = `Reading asset ${name}...`;
186
+ return msg.length > 80 ? "Reading an asset..." : msg;
187
+ }
188
+ return "Reading an asset...";
189
+ }
190
+ }
191
+ //# sourceMappingURL=asset-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-tools.js","sourceRoot":"","sources":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AAC,EAAE,CAAC;YACX,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;aAClD,CAAC;QACJ,CAAC;IACH,CAAC;IAED,WAAW,CAAC,MAA+B;QACzC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACzB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,EAAE,CAAC;YACrC,MAAM,GAAG,GAAG,iBAAiB,IAAI,KAAK,CAAC;YACvC,OAAO,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,GAAG,CAAC;QACvD,CAAC;QACD,OAAO,qBAAqB,CAAC;IAC/B,CAAC;CACF"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Abstract base class for all agent tools.
3
+ *
4
+ * Port of src/nodetool/agents/tools/base.py
5
+ */
6
+ import type { ProcessingContext } from "@nodetool-ai/runtime";
7
+ import type { ProviderTool } from "@nodetool-ai/runtime";
8
+ export declare abstract class Tool {
9
+ abstract readonly name: string;
10
+ abstract readonly description: string;
11
+ abstract readonly inputSchema: Record<string, unknown>;
12
+ /**
13
+ * Execute the tool with the given parameters.
14
+ */
15
+ abstract process(context: ProcessingContext, params: Record<string, unknown>): Promise<unknown>;
16
+ /**
17
+ * Convert this tool to the provider tool format expected by BaseProvider.
18
+ */
19
+ toProviderTool(): ProviderTool;
20
+ /**
21
+ * Return a user-facing message describing this tool call.
22
+ */
23
+ userMessage(_params: Record<string, unknown>): string;
24
+ }
25
+ //# sourceMappingURL=base-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-tool.d.ts","sourceRoot":"","sources":["../../src/tools/base-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,8BAAsB,IAAI;IACxB,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEvD;;OAEG;IACH,QAAQ,CAAC,OAAO,CACd,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,OAAO,CAAC;IAEnB;;OAEG;IACH,cAAc,IAAI,YAAY;IAQ9B;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;CAGtD"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Abstract base class for all agent tools.
3
+ *
4
+ * Port of src/nodetool/agents/tools/base.py
5
+ */
6
+ export class Tool {
7
+ /**
8
+ * Convert this tool to the provider tool format expected by BaseProvider.
9
+ */
10
+ toProviderTool() {
11
+ return {
12
+ name: this.name,
13
+ description: this.description,
14
+ inputSchema: this.inputSchema
15
+ };
16
+ }
17
+ /**
18
+ * Return a user-facing message describing this tool call.
19
+ */
20
+ userMessage(_params) {
21
+ return `Running ${this.name}`;
22
+ }
23
+ }
24
+ //# sourceMappingURL=base-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-tool.js","sourceRoot":"","sources":["../../src/tools/base-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,MAAM,OAAgB,IAAI;IAaxB;;OAEG;IACH,cAAc;QACZ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,OAAgC;QAC1C,OAAO,WAAW,IAAI,CAAC,IAAI,EAAE,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Browser interaction tools.
3
+ *
4
+ * Port of src/nodetool/agents/tools/browser_tools.py (BrowserTool & ScreenshotTool)
5
+ */
6
+ import type { ProcessingContext } from "@nodetool-ai/runtime";
7
+ import { Tool } from "./base-tool.js";
8
+ /**
9
+ * Convert raw HTML to readable plain text.
10
+ *
11
+ * - Strips `<script>` and `<style>` blocks
12
+ * - Removes remaining HTML tags
13
+ * - Decodes common HTML entities and numeric character references
14
+ * - Collapses whitespace
15
+ * - Truncates to `maxLength` characters
16
+ */
17
+ export declare function htmlToText(html: string, maxLength?: number): string;
18
+ export declare class BrowserTool extends Tool {
19
+ readonly name = "browser";
20
+ readonly description = "Fetch content from a web page";
21
+ readonly inputSchema: Record<string, unknown>;
22
+ userMessage(params: Record<string, unknown>): string;
23
+ process(_context: ProcessingContext, params: Record<string, unknown>): Promise<unknown>;
24
+ }
25
+ export declare class ScreenshotTool extends Tool {
26
+ readonly name = "take_screenshot";
27
+ readonly description = "Take a screenshot of a web page. Requires a remote browser service (BROWSER_URL).";
28
+ readonly inputSchema: Record<string, unknown>;
29
+ userMessage(params: Record<string, unknown>): string;
30
+ process(_context: ProcessingContext, params: Record<string, unknown>): Promise<unknown>;
31
+ }
32
+ //# sourceMappingURL=browser-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-tools.d.ts","sourceRoot":"","sources":["../../src/tools/browser-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAuBtC;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,SAAS,GAAG,MAAM,CAmCnE;AA0BD,qBAAa,WAAY,SAAQ,IAAI;IACnC,QAAQ,CAAC,IAAI,aAAa;IAC1B,QAAQ,CAAC,WAAW,mCAAmC;IACvD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAS3C;IAEF,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;IAM9C,OAAO,CACX,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,OAAO,CAAC;CAoDpB;AAMD,qBAAa,cAAe,SAAQ,IAAI;IACtC,QAAQ,CAAC,IAAI,qBAAqB;IAClC,QAAQ,CAAC,WAAW,uFACkE;IACtF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAc3C;IAEF,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;IAS9C,OAAO,CACX,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,OAAO,CAAC;CAuCpB"}
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Browser interaction tools.
3
+ *
4
+ * Port of src/nodetool/agents/tools/browser_tools.py (BrowserTool & ScreenshotTool)
5
+ */
6
+ import { Tool } from "./base-tool.js";
7
+ // ---------------------------------------------------------------------------
8
+ // HTML-to-text helpers
9
+ // ---------------------------------------------------------------------------
10
+ const ENTITY_MAP = {
11
+ "&amp;": "&",
12
+ "&lt;": "<",
13
+ "&gt;": ">",
14
+ "&quot;": '"',
15
+ "&#39;": "'",
16
+ "&apos;": "'",
17
+ "&nbsp;": " "
18
+ };
19
+ const ENTITY_RE = new RegExp(Object.keys(ENTITY_MAP).join("|"), "gi");
20
+ /**
21
+ * Numeric character references: &#123; or &#x1a;
22
+ */
23
+ const NUMERIC_ENTITY_RE = /&#(?:x([0-9a-fA-F]+)|(\d+));/g;
24
+ /**
25
+ * Convert raw HTML to readable plain text.
26
+ *
27
+ * - Strips `<script>` and `<style>` blocks
28
+ * - Removes remaining HTML tags
29
+ * - Decodes common HTML entities and numeric character references
30
+ * - Collapses whitespace
31
+ * - Truncates to `maxLength` characters
32
+ */
33
+ export function htmlToText(html, maxLength = 50_000) {
34
+ let text = html;
35
+ // Remove script and style blocks (including content)
36
+ text = text.replace(/<script[\s\S]*?<\/script>/gi, "");
37
+ text = text.replace(/<style[\s\S]*?<\/style>/gi, "");
38
+ // Replace <br>, <p>, <div>, <li>, <tr> boundaries with newlines for readability
39
+ text = text.replace(/<(?:br|\/p|\/div|\/li|\/tr|\/h[1-6])\s*\/?>/gi, "\n");
40
+ // Strip remaining HTML tags
41
+ text = text.replace(/<[^>]+>/g, "");
42
+ // Decode named entities
43
+ text = text.replace(ENTITY_RE, (match) => ENTITY_MAP[match.toLowerCase()] ?? match);
44
+ // Decode numeric entities
45
+ text = text.replace(NUMERIC_ENTITY_RE, (_match, hex, dec) => {
46
+ const code = hex ? parseInt(hex, 16) : parseInt(dec, 10);
47
+ return String.fromCharCode(code);
48
+ });
49
+ // Collapse whitespace (preserve single newlines)
50
+ text = text.replace(/[^\S\n]+/g, " ");
51
+ text = text.replace(/\n{3,}/g, "\n\n");
52
+ text = text.trim();
53
+ if (text.length > maxLength) {
54
+ text = text.slice(0, maxLength);
55
+ }
56
+ return text;
57
+ }
58
+ // ---------------------------------------------------------------------------
59
+ // Search-engine host list (block direct browsing of SERPs)
60
+ // ---------------------------------------------------------------------------
61
+ const SEARCH_ENGINE_HOSTS = [
62
+ "google.",
63
+ "bing.",
64
+ "search.yahoo",
65
+ "duckduckgo",
66
+ "yandex",
67
+ "baidu",
68
+ "ask.",
69
+ "jina.ai"
70
+ ];
71
+ function isSearchEngine(hostname) {
72
+ const lower = hostname.toLowerCase();
73
+ return SEARCH_ENGINE_HOSTS.some((h) => lower.includes(h));
74
+ }
75
+ // ---------------------------------------------------------------------------
76
+ // BrowserTool
77
+ // ---------------------------------------------------------------------------
78
+ export class BrowserTool extends Tool {
79
+ name = "browser";
80
+ description = "Fetch content from a web page";
81
+ inputSchema = {
82
+ type: "object",
83
+ properties: {
84
+ url: {
85
+ type: "string",
86
+ description: "URL to navigate to"
87
+ }
88
+ },
89
+ required: ["url"]
90
+ };
91
+ userMessage(params) {
92
+ const url = params.url ?? "a specific URL";
93
+ const msg = `Browsing ${url}...`;
94
+ return msg.length > 160 ? "Browsing a specified URL..." : msg;
95
+ }
96
+ async process(_context, params) {
97
+ const url = params.url;
98
+ if (!url) {
99
+ return { error: "URL is required" };
100
+ }
101
+ // Block search-engine result pages
102
+ try {
103
+ const hostname = new URL(url).hostname;
104
+ if (isSearchEngine(hostname)) {
105
+ return {
106
+ error: "Direct browsing of search engine result pages is disabled. Use a SERP tool (e.g., google_search) instead.",
107
+ url
108
+ };
109
+ }
110
+ }
111
+ catch {
112
+ return { error: `Invalid URL: ${url}` };
113
+ }
114
+ try {
115
+ const response = await fetch(url, {
116
+ headers: {
117
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36",
118
+ Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
119
+ "Accept-Language": "en-US,en;q=0.5"
120
+ },
121
+ signal: AbortSignal.timeout(30_000)
122
+ });
123
+ if (!response.ok) {
124
+ return {
125
+ error: `HTTP ${response.status}: ${response.statusText}`,
126
+ url
127
+ };
128
+ }
129
+ const html = await response.text();
130
+ const content = htmlToText(html);
131
+ return {
132
+ success: true,
133
+ url,
134
+ content
135
+ };
136
+ }
137
+ catch (e) {
138
+ const message = e instanceof Error ? e.message : String(e);
139
+ return { error: `Error fetching page: ${message}` };
140
+ }
141
+ }
142
+ }
143
+ // ---------------------------------------------------------------------------
144
+ // ScreenshotTool
145
+ // ---------------------------------------------------------------------------
146
+ export class ScreenshotTool extends Tool {
147
+ name = "take_screenshot";
148
+ description = "Take a screenshot of a web page. Requires a remote browser service (BROWSER_URL).";
149
+ inputSchema = {
150
+ type: "object",
151
+ properties: {
152
+ url: {
153
+ type: "string",
154
+ description: "URL to navigate to before taking screenshot"
155
+ },
156
+ output_file: {
157
+ type: "string",
158
+ description: "Workspace relative path to save the screenshot",
159
+ default: "screenshot.png"
160
+ }
161
+ },
162
+ required: ["url", "output_file"]
163
+ };
164
+ userMessage(params) {
165
+ const url = params.url ?? "a page";
166
+ const output = params.output_file ?? "screenshot.png";
167
+ const msg = `Taking screenshot of ${url} and saving to ${output}.`;
168
+ return msg.length > 160
169
+ ? `Taking screenshot of a page and saving to ${output}.`
170
+ : msg;
171
+ }
172
+ async process(_context, params) {
173
+ const url = params.url;
174
+ if (!url) {
175
+ return { error: "URL is required for taking a screenshot" };
176
+ }
177
+ const browserUrl = process.env.BROWSER_URL;
178
+ if (!browserUrl) {
179
+ return {
180
+ error: "Screenshots require a remote browser service. Set the BROWSER_URL environment variable to the browser service endpoint.",
181
+ url
182
+ };
183
+ }
184
+ // If a BROWSER_URL is configured, attempt to call it as a screenshot API.
185
+ try {
186
+ const outputFile = params.output_file ?? "screenshot.png";
187
+ const response = await fetch(browserUrl, {
188
+ method: "POST",
189
+ headers: { "Content-Type": "application/json" },
190
+ body: JSON.stringify({ url, output_file: outputFile }),
191
+ signal: AbortSignal.timeout(30_000)
192
+ });
193
+ if (!response.ok) {
194
+ return {
195
+ error: `Browser service returned HTTP ${response.status}: ${response.statusText}`,
196
+ url
197
+ };
198
+ }
199
+ const result = await response.json();
200
+ return { success: true, ...result };
201
+ }
202
+ catch (e) {
203
+ const message = e instanceof Error ? e.message : String(e);
204
+ return { error: `Error taking screenshot: ${message}` };
205
+ }
206
+ }
207
+ }
208
+ //# sourceMappingURL=browser-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-tools.js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CAAC;QAAC,OAAO,CAAU,EAAE,CAAC;YACpB,MAAM,OAAO,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC3D,OAAO,EAAE,KAAK,EAAE,4BAA4B,OAAO,EAAE,EAAE,CAAC;QAC1D,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Calculator tool for safe mathematical expression evaluation.
3
+ *
4
+ * Port of src/nodetool/agents/tools/math_tools.py (CalculatorTool)
5
+ */
6
+ import type { ProcessingContext } from "@nodetool-ai/runtime";
7
+ import { Tool } from "./base-tool.js";
8
+ export declare class CalculatorTool extends Tool {
9
+ readonly name = "calculate";
10
+ readonly description = "Evaluate a mathematical expression safely.";
11
+ readonly inputSchema: {
12
+ type: "object";
13
+ properties: {
14
+ expression: {
15
+ type: "string";
16
+ description: string;
17
+ };
18
+ };
19
+ required: string[];
20
+ };
21
+ process(_context: ProcessingContext, params: Record<string, unknown>): Promise<unknown>;
22
+ userMessage(params: Record<string, unknown>): string;
23
+ }
24
+ //# sourceMappingURL=calculator-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculator-tool.d.ts","sourceRoot":"","sources":["../../src/tools/calculator-tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAuBtC,qBAAa,cAAe,SAAQ,IAAI;IACtC,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,WAAW,gDAAgD;IACpE,QAAQ,CAAC,WAAW;;;;;;;;;MASlB;IAEI,OAAO,CACX,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,OAAO,CAAC;IAyBnB,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM;CAGrD"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Calculator tool for safe mathematical expression evaluation.
3
+ *
4
+ * Port of src/nodetool/agents/tools/math_tools.py (CalculatorTool)
5
+ */
6
+ import { Tool } from "./base-tool.js";
7
+ const MATH_SCOPE = {
8
+ sqrt: Math.sqrt,
9
+ abs: Math.abs,
10
+ sin: Math.sin,
11
+ cos: Math.cos,
12
+ tan: Math.tan,
13
+ log: Math.log,
14
+ log10: Math.log10,
15
+ exp: Math.exp,
16
+ floor: Math.floor,
17
+ ceil: Math.ceil,
18
+ round: Math.round,
19
+ min: Math.min,
20
+ max: Math.max,
21
+ pow: Math.pow,
22
+ PI: Math.PI,
23
+ E: Math.E,
24
+ pi: Math.PI,
25
+ e: Math.E
26
+ };
27
+ export class CalculatorTool extends Tool {
28
+ name = "calculate";
29
+ description = "Evaluate a mathematical expression safely.";
30
+ inputSchema = {
31
+ type: "object",
32
+ properties: {
33
+ expression: {
34
+ type: "string",
35
+ description: "The mathematical expression to evaluate"
36
+ }
37
+ },
38
+ required: ["expression"]
39
+ };
40
+ async process(_context, params) {
41
+ const expression = params["expression"];
42
+ if (typeof expression !== "string") {
43
+ return { error: "expression must be a string" };
44
+ }
45
+ try {
46
+ // Use Function constructor with a restricted scope
47
+ const fn = new Function("scope", `with(scope) { return (${expression}) }`);
48
+ const result = fn(MATH_SCOPE);
49
+ if (typeof result !== "number" || !isFinite(result)) {
50
+ return {
51
+ error: `Expression did not evaluate to a finite number: ${String(result)}`
52
+ };
53
+ }
54
+ return { result };
55
+ }
56
+ catch (e) {
57
+ return { error: `Failed to evaluate expression: ${String(e)}` };
58
+ }
59
+ }
60
+ userMessage(params) {
61
+ return `Calculating: ${String(params["expression"] ?? "")}`;
62
+ }
63
+ }
64
+ //# sourceMappingURL=calculator-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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