@vertesia/tools-sdk 1.3.0 → 1.4.0-dev.20260615.042549Z

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 (271) hide show
  1. package/lib/{types/ActivityCollection.d.ts → ActivityCollection.d.ts} +7 -7
  2. package/lib/ActivityCollection.d.ts.map +1 -0
  3. package/lib/{esm/ActivityCollection.js → ActivityCollection.js} +6 -6
  4. package/lib/ActivityCollection.js.map +1 -0
  5. package/lib/{types/ContentTypesCollection.d.ts → ContentTypesCollection.d.ts} +2 -2
  6. package/lib/ContentTypesCollection.d.ts.map +1 -0
  7. package/lib/{esm/ContentTypesCollection.js → ContentTypesCollection.js} +3 -3
  8. package/lib/ContentTypesCollection.js.map +1 -0
  9. package/lib/{types/InteractionCollection.d.ts → InteractionCollection.d.ts} +2 -2
  10. package/lib/InteractionCollection.d.ts.map +1 -0
  11. package/lib/{esm/InteractionCollection.js → InteractionCollection.js} +3 -3
  12. package/lib/InteractionCollection.js.map +1 -0
  13. package/lib/{types/RenderingTemplateCollection.d.ts → RenderingTemplateCollection.d.ts} +1 -1
  14. package/lib/RenderingTemplateCollection.d.ts.map +1 -0
  15. package/lib/{esm/RenderingTemplateCollection.js → RenderingTemplateCollection.js} +3 -3
  16. package/lib/RenderingTemplateCollection.js.map +1 -0
  17. package/lib/{types/SkillCollection.d.ts → SkillCollection.d.ts} +5 -5
  18. package/lib/SkillCollection.d.ts.map +1 -0
  19. package/lib/{esm/SkillCollection.js → SkillCollection.js} +68 -51
  20. package/lib/SkillCollection.js.map +1 -0
  21. package/lib/{types/ToolCollection.d.ts → ToolCollection.d.ts} +10 -10
  22. package/lib/ToolCollection.d.ts.map +1 -0
  23. package/lib/{esm/ToolCollection.js → ToolCollection.js} +21 -18
  24. package/lib/ToolCollection.js.map +1 -0
  25. package/lib/ToolRegistry.d.ts +22 -0
  26. package/lib/ToolRegistry.d.ts.map +1 -0
  27. package/lib/{esm/ToolRegistry.js → ToolRegistry.js} +6 -36
  28. package/lib/ToolRegistry.js.map +1 -0
  29. package/lib/{types/auth.d.ts → auth.d.ts} +5 -5
  30. package/lib/auth.d.ts.map +1 -0
  31. package/lib/{esm/auth.js → auth.js} +23 -17
  32. package/lib/auth.js.map +1 -0
  33. package/lib/build/validate.d.ts.map +1 -0
  34. package/lib/build/validate.js.map +1 -0
  35. package/lib/copy-assets.d.ts.map +1 -0
  36. package/lib/{esm/copy-assets.js → copy-assets.js} +4 -7
  37. package/lib/copy-assets.js.map +1 -0
  38. package/lib/index.d.ts +16 -0
  39. package/lib/index.d.ts.map +1 -0
  40. package/lib/index.js +15 -0
  41. package/lib/index.js.map +1 -0
  42. package/lib/server/activities.d.ts +4 -0
  43. package/lib/server/activities.d.ts.map +1 -0
  44. package/lib/{esm/server → server}/activities.js +12 -9
  45. package/lib/server/activities.js.map +1 -0
  46. package/lib/server/app-package.d.ts +12 -0
  47. package/lib/server/app-package.d.ts.map +1 -0
  48. package/lib/server/app-package.js +197 -0
  49. package/lib/server/app-package.js.map +1 -0
  50. package/lib/server/content-types.d.ts +4 -0
  51. package/lib/server/content-types.d.ts.map +1 -0
  52. package/lib/server/content-types.js +100 -0
  53. package/lib/server/content-types.js.map +1 -0
  54. package/lib/server/dashboards.d.ts +4 -0
  55. package/lib/server/dashboards.d.ts.map +1 -0
  56. package/lib/server/dashboards.js +25 -0
  57. package/lib/server/dashboards.js.map +1 -0
  58. package/lib/server/interactions.d.ts +4 -0
  59. package/lib/server/interactions.d.ts.map +1 -0
  60. package/lib/{esm/server → server}/interactions.js +16 -16
  61. package/lib/server/interactions.js.map +1 -0
  62. package/lib/server/mcp.d.ts +4 -0
  63. package/lib/server/mcp.d.ts.map +1 -0
  64. package/lib/{esm/server → server}/mcp.js +5 -4
  65. package/lib/server/mcp.js.map +1 -0
  66. package/lib/server/processes.d.ts +4 -0
  67. package/lib/server/processes.d.ts.map +1 -0
  68. package/lib/server/processes.js +26 -0
  69. package/lib/server/processes.js.map +1 -0
  70. package/lib/server/site.d.ts +4 -0
  71. package/lib/server/site.d.ts.map +1 -0
  72. package/lib/{esm/server → server}/site.js +4 -2
  73. package/lib/server/site.js.map +1 -0
  74. package/lib/server/skills.d.ts +4 -0
  75. package/lib/server/skills.d.ts.map +1 -0
  76. package/lib/{esm/server → server}/skills.js +14 -12
  77. package/lib/server/skills.js.map +1 -0
  78. package/lib/server/templates.d.ts +4 -0
  79. package/lib/server/templates.d.ts.map +1 -0
  80. package/lib/{esm/server → server}/templates.js +10 -10
  81. package/lib/server/templates.js.map +1 -0
  82. package/lib/server/tools.d.ts +4 -0
  83. package/lib/server/tools.d.ts.map +1 -0
  84. package/lib/{esm/server → server}/tools.js +7 -9
  85. package/lib/server/tools.js.map +1 -0
  86. package/lib/{types/server → server}/types.d.ts +21 -16
  87. package/lib/server/types.d.ts.map +1 -0
  88. package/lib/{cjs → server}/types.js.map +1 -1
  89. package/lib/server/widgets.d.ts +4 -0
  90. package/lib/server/widgets.d.ts.map +1 -0
  91. package/lib/server/widgets.js.map +1 -0
  92. package/lib/{types/server.d.ts → server.d.ts} +3 -3
  93. package/lib/server.d.ts.map +1 -0
  94. package/lib/{esm/server.js → server.js} +28 -22
  95. package/lib/server.js.map +1 -0
  96. package/lib/site/styles.d.ts.map +1 -0
  97. package/lib/{esm/site → site}/styles.js.map +1 -1
  98. package/lib/{types/site → site}/templates.d.ts +9 -9
  99. package/lib/site/templates.d.ts.map +1 -0
  100. package/lib/{esm/site → site}/templates.js +152 -98
  101. package/lib/site/templates.js.map +1 -0
  102. package/lib/{types/types.d.ts → types.d.ts} +29 -16
  103. package/lib/types.d.ts.map +1 -0
  104. package/lib/types.js.map +1 -0
  105. package/lib/utils.d.ts.map +1 -0
  106. package/lib/{esm/utils.js → utils.js} +11 -5
  107. package/lib/utils.js.map +1 -0
  108. package/package.json +20 -22
  109. package/src/ActivityCollection.test.ts +60 -59
  110. package/src/ActivityCollection.ts +27 -20
  111. package/src/ContentTypesCollection.ts +6 -9
  112. package/src/InteractionCollection.ts +6 -8
  113. package/src/RenderingTemplateCollection.ts +49 -51
  114. package/src/SkillCollection.ts +91 -72
  115. package/src/ToolCollection.ts +52 -43
  116. package/src/ToolRegistry.ts +20 -50
  117. package/src/auth.ts +35 -27
  118. package/src/copy-assets.ts +5 -12
  119. package/src/index.ts +15 -15
  120. package/src/server/activities.test.ts +70 -67
  121. package/src/server/activities.ts +17 -13
  122. package/src/server/app-package.test.ts +140 -0
  123. package/src/server/app-package.ts +115 -52
  124. package/src/server/content-types.test.ts +64 -0
  125. package/src/server/content-types.ts +53 -25
  126. package/src/server/dashboards.ts +31 -0
  127. package/src/server/interactions.ts +29 -28
  128. package/src/server/mcp.ts +16 -16
  129. package/src/server/processes.ts +35 -0
  130. package/src/server/site.ts +7 -15
  131. package/src/server/skills.ts +19 -18
  132. package/src/server/templates.ts +82 -80
  133. package/src/server/tools.ts +12 -16
  134. package/src/server/types.ts +29 -20
  135. package/src/server/widgets.ts +5 -9
  136. package/src/server.ts +55 -47
  137. package/src/site/styles.ts +1 -1
  138. package/src/site/templates.ts +259 -157
  139. package/src/types.ts +55 -31
  140. package/src/utils.ts +11 -6
  141. package/lib/cjs/ActivityCollection.js +0 -93
  142. package/lib/cjs/ActivityCollection.js.map +0 -1
  143. package/lib/cjs/ContentTypesCollection.js +0 -43
  144. package/lib/cjs/ContentTypesCollection.js.map +0 -1
  145. package/lib/cjs/InteractionCollection.js +0 -43
  146. package/lib/cjs/InteractionCollection.js.map +0 -1
  147. package/lib/cjs/RenderingTemplateCollection.js +0 -43
  148. package/lib/cjs/RenderingTemplateCollection.js.map +0 -1
  149. package/lib/cjs/SkillCollection.js +0 -384
  150. package/lib/cjs/SkillCollection.js.map +0 -1
  151. package/lib/cjs/ToolCollection.js +0 -221
  152. package/lib/cjs/ToolCollection.js.map +0 -1
  153. package/lib/cjs/ToolRegistry.js +0 -95
  154. package/lib/cjs/ToolRegistry.js.map +0 -1
  155. package/lib/cjs/auth.js +0 -131
  156. package/lib/cjs/auth.js.map +0 -1
  157. package/lib/cjs/build/validate.js +0 -7
  158. package/lib/cjs/build/validate.js.map +0 -1
  159. package/lib/cjs/copy-assets.js +0 -84
  160. package/lib/cjs/copy-assets.js.map +0 -1
  161. package/lib/cjs/index.js +0 -34
  162. package/lib/cjs/index.js.map +0 -1
  163. package/lib/cjs/package.json +0 -3
  164. package/lib/cjs/server/activities.js +0 -103
  165. package/lib/cjs/server/activities.js.map +0 -1
  166. package/lib/cjs/server/app-package.js +0 -154
  167. package/lib/cjs/server/app-package.js.map +0 -1
  168. package/lib/cjs/server/content-types.js +0 -73
  169. package/lib/cjs/server/content-types.js.map +0 -1
  170. package/lib/cjs/server/interactions.js +0 -101
  171. package/lib/cjs/server/interactions.js.map +0 -1
  172. package/lib/cjs/server/mcp.js +0 -45
  173. package/lib/cjs/server/mcp.js.map +0 -1
  174. package/lib/cjs/server/site.js +0 -48
  175. package/lib/cjs/server/site.js.map +0 -1
  176. package/lib/cjs/server/skills.js +0 -124
  177. package/lib/cjs/server/skills.js.map +0 -1
  178. package/lib/cjs/server/templates.js +0 -67
  179. package/lib/cjs/server/templates.js.map +0 -1
  180. package/lib/cjs/server/tools.js +0 -87
  181. package/lib/cjs/server/tools.js.map +0 -1
  182. package/lib/cjs/server/types.js +0 -3
  183. package/lib/cjs/server/types.js.map +0 -1
  184. package/lib/cjs/server/widgets.js +0 -27
  185. package/lib/cjs/server/widgets.js.map +0 -1
  186. package/lib/cjs/server.js +0 -142
  187. package/lib/cjs/server.js.map +0 -1
  188. package/lib/cjs/site/styles.js +0 -692
  189. package/lib/cjs/site/styles.js.map +0 -1
  190. package/lib/cjs/site/templates.js +0 -1320
  191. package/lib/cjs/site/templates.js.map +0 -1
  192. package/lib/cjs/types.js +0 -3
  193. package/lib/cjs/utils.js +0 -44
  194. package/lib/cjs/utils.js.map +0 -1
  195. package/lib/esm/ActivityCollection.js.map +0 -1
  196. package/lib/esm/ContentTypesCollection.js.map +0 -1
  197. package/lib/esm/InteractionCollection.js.map +0 -1
  198. package/lib/esm/RenderingTemplateCollection.js.map +0 -1
  199. package/lib/esm/SkillCollection.js.map +0 -1
  200. package/lib/esm/ToolCollection.js.map +0 -1
  201. package/lib/esm/ToolRegistry.js.map +0 -1
  202. package/lib/esm/auth.js.map +0 -1
  203. package/lib/esm/build/validate.js.map +0 -1
  204. package/lib/esm/copy-assets.js.map +0 -1
  205. package/lib/esm/index.js +0 -14
  206. package/lib/esm/index.js.map +0 -1
  207. package/lib/esm/server/activities.js.map +0 -1
  208. package/lib/esm/server/app-package.js +0 -151
  209. package/lib/esm/server/app-package.js.map +0 -1
  210. package/lib/esm/server/content-types.js +0 -70
  211. package/lib/esm/server/content-types.js.map +0 -1
  212. package/lib/esm/server/interactions.js.map +0 -1
  213. package/lib/esm/server/mcp.js.map +0 -1
  214. package/lib/esm/server/site.js.map +0 -1
  215. package/lib/esm/server/skills.js.map +0 -1
  216. package/lib/esm/server/templates.js.map +0 -1
  217. package/lib/esm/server/tools.js.map +0 -1
  218. package/lib/esm/server/types.js.map +0 -1
  219. package/lib/esm/server/widgets.js.map +0 -1
  220. package/lib/esm/server.js.map +0 -1
  221. package/lib/esm/site/templates.js.map +0 -1
  222. package/lib/esm/types.js.map +0 -1
  223. package/lib/esm/utils.js.map +0 -1
  224. package/lib/types/ActivityCollection.d.ts.map +0 -1
  225. package/lib/types/ContentTypesCollection.d.ts.map +0 -1
  226. package/lib/types/InteractionCollection.d.ts.map +0 -1
  227. package/lib/types/RenderingTemplateCollection.d.ts.map +0 -1
  228. package/lib/types/SkillCollection.d.ts.map +0 -1
  229. package/lib/types/ToolCollection.d.ts.map +0 -1
  230. package/lib/types/ToolRegistry.d.ts +0 -22
  231. package/lib/types/ToolRegistry.d.ts.map +0 -1
  232. package/lib/types/auth.d.ts.map +0 -1
  233. package/lib/types/build/validate.d.ts.map +0 -1
  234. package/lib/types/copy-assets.d.ts.map +0 -1
  235. package/lib/types/index.d.ts +0 -14
  236. package/lib/types/index.d.ts.map +0 -1
  237. package/lib/types/server/activities.d.ts +0 -4
  238. package/lib/types/server/activities.d.ts.map +0 -1
  239. package/lib/types/server/app-package.d.ts +0 -4
  240. package/lib/types/server/app-package.d.ts.map +0 -1
  241. package/lib/types/server/content-types.d.ts +0 -4
  242. package/lib/types/server/content-types.d.ts.map +0 -1
  243. package/lib/types/server/interactions.d.ts +0 -4
  244. package/lib/types/server/interactions.d.ts.map +0 -1
  245. package/lib/types/server/mcp.d.ts +0 -4
  246. package/lib/types/server/mcp.d.ts.map +0 -1
  247. package/lib/types/server/site.d.ts +0 -4
  248. package/lib/types/server/site.d.ts.map +0 -1
  249. package/lib/types/server/skills.d.ts +0 -4
  250. package/lib/types/server/skills.d.ts.map +0 -1
  251. package/lib/types/server/templates.d.ts +0 -4
  252. package/lib/types/server/templates.d.ts.map +0 -1
  253. package/lib/types/server/tools.d.ts +0 -4
  254. package/lib/types/server/tools.d.ts.map +0 -1
  255. package/lib/types/server/types.d.ts.map +0 -1
  256. package/lib/types/server/widgets.d.ts +0 -4
  257. package/lib/types/server/widgets.d.ts.map +0 -1
  258. package/lib/types/server.d.ts.map +0 -1
  259. package/lib/types/site/styles.d.ts.map +0 -1
  260. package/lib/types/site/templates.d.ts.map +0 -1
  261. package/lib/types/types.d.ts.map +0 -1
  262. package/lib/types/utils.d.ts.map +0 -1
  263. /package/lib/{types/build → build}/validate.d.ts +0 -0
  264. /package/lib/{esm/build → build}/validate.js +0 -0
  265. /package/lib/{types/copy-assets.d.ts → copy-assets.d.ts} +0 -0
  266. /package/lib/{esm/server → server}/types.js +0 -0
  267. /package/lib/{esm/server → server}/widgets.js +0 -0
  268. /package/lib/{types/site → site}/styles.d.ts +0 -0
  269. /package/lib/{esm/site → site}/styles.js +0 -0
  270. /package/lib/{esm/types.js → types.js} +0 -0
  271. /package/lib/{types/utils.d.ts → utils.d.ts} +0 -0
@@ -1,51 +1,49 @@
1
- import { CollectionProperties, ICollection, RenderingTemplateDefinition } from "./types.js";
2
- import { kebabCaseToTitle } from "./utils.js";
3
-
4
- export interface RenderingTemplateCollectionProps extends CollectionProperties {
5
- templates: RenderingTemplateDefinition[];
6
- }
7
-
8
- export class RenderingTemplateCollection implements ICollection<RenderingTemplateDefinition> {
9
- templates: RenderingTemplateDefinition[];
10
- name: string;
11
- title?: string;
12
- icon?: string;
13
- description?: string;
14
-
15
- constructor({
16
- name, title, icon, description, templates
17
- }: RenderingTemplateCollectionProps) {
18
- this.name = name;
19
- this.title = title || kebabCaseToTitle(name);
20
- this.icon = icon;
21
- this.description = description;
22
- this.templates = templates;
23
- }
24
-
25
- getTemplateDefinitions() {
26
- return this.templates;
27
- }
28
-
29
- getTemplate(name: string): RenderingTemplateDefinition | undefined {
30
- return this.templates.find(t => t.name === name);
31
- }
32
-
33
- [Symbol.iterator](): Iterator<RenderingTemplateDefinition> {
34
- let index = 0;
35
- const templates = this.templates;
36
-
37
- return {
38
- next(): IteratorResult<RenderingTemplateDefinition> {
39
- if (index < templates.length) {
40
- return { value: templates[index++], done: false };
41
- } else {
42
- return { done: true, value: undefined };
43
- }
44
- }
45
- };
46
- }
47
-
48
- map<U>(callback: (template: RenderingTemplateDefinition, index: number) => U): U[] {
49
- return this.templates.map(callback);
50
- }
51
- }
1
+ import type { CollectionProperties, ICollection, RenderingTemplateDefinition } from './types.js';
2
+ import { kebabCaseToTitle } from './utils.js';
3
+
4
+ export interface RenderingTemplateCollectionProps extends CollectionProperties {
5
+ templates: RenderingTemplateDefinition[];
6
+ }
7
+
8
+ export class RenderingTemplateCollection implements ICollection<RenderingTemplateDefinition> {
9
+ templates: RenderingTemplateDefinition[];
10
+ name: string;
11
+ title?: string;
12
+ icon?: string;
13
+ description?: string;
14
+
15
+ constructor({ name, title, icon, description, templates }: RenderingTemplateCollectionProps) {
16
+ this.name = name;
17
+ this.title = title || kebabCaseToTitle(name);
18
+ this.icon = icon;
19
+ this.description = description;
20
+ this.templates = templates;
21
+ }
22
+
23
+ getTemplateDefinitions() {
24
+ return this.templates;
25
+ }
26
+
27
+ getTemplate(name: string): RenderingTemplateDefinition | undefined {
28
+ return this.templates.find((t) => t.name === name);
29
+ }
30
+
31
+ [Symbol.iterator](): Iterator<RenderingTemplateDefinition> {
32
+ let index = 0;
33
+ const templates = this.templates;
34
+
35
+ return {
36
+ next(): IteratorResult<RenderingTemplateDefinition> {
37
+ if (index < templates.length) {
38
+ return { value: templates[index++], done: false };
39
+ } else {
40
+ return { done: true, value: undefined };
41
+ }
42
+ },
43
+ };
44
+ }
45
+
46
+ map<U>(callback: (template: RenderingTemplateDefinition, index: number) => U): U[] {
47
+ return this.templates.map(callback);
48
+ }
49
+ }
@@ -1,9 +1,10 @@
1
- import { ToolDefinition } from "@llumiverse/common";
2
- import { existsSync, readdirSync, readFileSync, statSync } from "fs";
3
- import { Context } from "hono";
4
- import { HTTPException } from "hono/http-exception";
5
- import { join } from "path";
6
- import { ToolContext } from "./server/types.js";
1
+ import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import type { ToolDefinition } from '@llumiverse/common';
4
+ import type { AgentToolDefinition } from '@vertesia/common';
5
+ import type { Context } from 'hono';
6
+ import { HTTPException } from 'hono/http-exception';
7
+ import type { ToolContext } from './server/types.js';
7
8
  import type {
8
9
  CollectionProperties,
9
10
  ICollection,
@@ -14,9 +15,8 @@ import type {
14
15
  ToolExecutionPayload,
15
16
  ToolExecutionResult,
16
17
  ToolUseContext,
17
- } from "./types.js";
18
- import { kebabCaseToTitle } from "./utils.js";
19
- import { AgentToolDefinition } from "@vertesia/common";
18
+ } from './types.js';
19
+ import { kebabCaseToTitle } from './utils.js';
20
20
 
21
21
  export interface SkillCollectionProperties extends CollectionProperties {
22
22
  /**
@@ -57,7 +57,7 @@ export class SkillCollection implements ICollection<SkillDefinition> {
57
57
  this.title = title || kebabCaseToTitle(name);
58
58
  this.icon = icon;
59
59
  this.description = description;
60
- this.skills = new Map(skills.map(s => [s.name, s]));
60
+ this.skills = new Map(skills.map((s) => [s.name, s]));
61
61
  }
62
62
 
63
63
  [Symbol.iterator](): Iterator<SkillDefinition> {
@@ -86,31 +86,31 @@ export class SkillCollection implements ICollection<SkillDefinition> {
86
86
  * Get skills exposed as tool definitions.
87
87
  * This allows skills to appear alongside regular tools.
88
88
  * When called, they return rendered instructions.
89
- * Includes related_tools for dynamic tool discovery.
89
+ * Includes tools for dynamic tool discovery.
90
90
  */
91
91
  getToolDefinitions(filterContext?: ToolUseContext): AgentToolDefinition[] {
92
92
  const defaultSchema: ToolDefinition['input_schema'] = {
93
93
  type: 'object',
94
94
  properties: {
95
95
  context: {
96
- type: "string",
97
- description: "Additional context or specific requirements for this task"
98
- }
99
- }
96
+ type: 'string',
97
+ description: 'Additional context or specific requirements for this task',
98
+ },
99
+ },
100
100
  };
101
101
 
102
102
  let skills = Array.from(this.skills.values());
103
103
  if (filterContext) {
104
- skills = skills.filter(skill => {
104
+ skills = skills.filter((skill) => {
105
105
  return skill.isEnabled ? skill.isEnabled(filterContext) : true;
106
106
  });
107
107
  }
108
108
 
109
- return skills.map(skill => {
109
+ return skills.map((skill) => {
110
110
  // Build description with related tools info if available
111
111
  let description = `[Skill] ${skill.description}. Returns contextual instructions for this task.`;
112
- if (skill.related_tools && skill.related_tools.length > 0) {
113
- description += ` Unlocks tools: ${skill.related_tools.join(', ')}.`;
112
+ if (skill.tools && skill.tools.length > 0) {
113
+ description += ` Unlocks tools: ${skill.tools.join(', ')}.`;
114
114
  }
115
115
 
116
116
  return {
@@ -118,7 +118,7 @@ export class SkillCollection implements ICollection<SkillDefinition> {
118
118
  name: `learn_${skill.name}`,
119
119
  description,
120
120
  input_schema: skill.input_schema || defaultSchema,
121
- related_tools: skill.related_tools,
121
+ tools: skill.tools,
122
122
  category: this.name,
123
123
  };
124
124
  });
@@ -132,7 +132,7 @@ export class SkillCollection implements ICollection<SkillDefinition> {
132
132
  title: this.title || this.name,
133
133
  description: this.description || `Skills: ${this.name}`,
134
134
  src: `${baseUrl}/api/skills/${this.name}`,
135
- tools: this.getToolDefinitions()
135
+ tools: this.getToolDefinitions(),
136
136
  };
137
137
  }
138
138
 
@@ -164,43 +164,41 @@ export class SkillCollection implements ICollection<SkillDefinition> {
164
164
  * @param ctx - Hono context
165
165
  * @param preParsedPayload - Optional pre-parsed payload (used when routing from root endpoint)
166
166
  */
167
- async execute(ctx: Context, preParsedPayload?: ToolExecutionPayload<Record<string, any>>): Promise<Response> {
167
+ async execute(ctx: Context, preParsedPayload?: ToolExecutionPayload): Promise<Response> {
168
168
  const toolCtx = ctx as ToolContext;
169
- let payload: ToolExecutionPayload<Record<string, any>> | undefined = preParsedPayload;
169
+ const payload = preParsedPayload ?? toolCtx.payload;
170
170
  try {
171
171
  if (!payload) {
172
- // Check if body was already parsed and validated by middleware
173
- if (toolCtx.payload) {
174
- payload = toolCtx.payload;
175
- } else {
176
- throw new HTTPException(400, {
177
- message: 'Invalid or missing skill execution payload. Expected { tool_use: { id, tool_name, tool_input? }, metadata? }'
178
- });
179
- }
172
+ throw new HTTPException(400, {
173
+ message:
174
+ 'Invalid or missing skill execution payload. Expected { tool_use: { id, tool_name, tool_input? }, metadata? }',
175
+ });
180
176
  }
181
177
 
182
178
  const toolName = payload.tool_use.tool_name;
183
179
 
184
180
  // Extract skill name from tool name (remove "learn_" prefix if present)
185
- const skillName = toolName.startsWith('learn_')
186
- ? toolName.replace('learn_', '')
187
- : toolName;
181
+ const skillName = toolName.startsWith('learn_') ? toolName.replace('learn_', '') : toolName;
188
182
 
189
183
  const skill = this.skills.get(skillName);
190
184
 
191
185
  if (!skill) {
192
- console.warn("[SkillCollection] Skill not found", {
186
+ console.warn('[SkillCollection] Skill not found', {
193
187
  collection: this.name,
194
188
  requestedSkill: skillName,
195
189
  toolName,
196
190
  availableSkills: Array.from(this.skills.keys()),
197
191
  });
198
192
  throw new HTTPException(404, {
199
- message: `Skill not found: ${skillName}`
193
+ message: `Skill not found: ${skillName}`,
200
194
  });
201
195
  }
202
196
 
203
- const data = payload.tool_use.tool_input || {};
197
+ const input = payload.tool_use.tool_input;
198
+ const data =
199
+ typeof input === 'object' && input !== null && !Array.isArray(input)
200
+ ? (input as Record<string, unknown>)
201
+ : {};
204
202
  const result = await this.renderSkill(skill, data);
205
203
 
206
204
  // TODO: If skill.execution is set, run via Daytona
@@ -214,46 +212,48 @@ export class SkillCollection implements ICollection<SkillDefinition> {
214
212
  skill_name: skill.name,
215
213
  content_type: skill.content_type,
216
214
  execution: skill.execution,
217
- }
215
+ },
218
216
  } satisfies ToolExecutionResult & { tool_use_id: string });
219
- } catch (err: any) {
220
- const status = err.status || 500;
217
+ } catch (err: unknown) {
218
+ const status = err instanceof HTTPException ? err.status : 500;
219
+ const message = err instanceof Error ? err.message : 'Error executing skill';
220
+ const stack = err instanceof Error ? err.stack : undefined;
221
221
  const toolName = payload?.tool_use?.tool_name;
222
222
  const toolUseId = payload?.tool_use?.id;
223
223
 
224
224
  if (status >= 500) {
225
- console.error("[SkillCollection] Skill execution failed", {
225
+ console.error('[SkillCollection] Skill execution failed', {
226
226
  collection: this.name,
227
227
  skill: toolName,
228
228
  toolUseId,
229
- error: err.message,
229
+ error: message,
230
230
  status,
231
231
  toolInput: payload?.tool_use?.tool_input,
232
- stack: err.stack,
232
+ stack,
233
233
  });
234
234
  }
235
235
 
236
- return ctx.json({
237
- tool_use_id: toolUseId || "unknown",
238
- is_error: true,
239
- content: err.message || "Error executing skill",
240
- }, status);
236
+ return ctx.json(
237
+ {
238
+ tool_use_id: toolUseId || 'unknown',
239
+ is_error: true,
240
+ content: message,
241
+ },
242
+ status,
243
+ );
241
244
  }
242
245
  }
243
246
 
244
247
  /**
245
248
  * Render skill instructions (static or dynamic)
246
249
  */
247
- private async renderSkill(
248
- skill: SkillDefinition,
249
- _data: Record<string, unknown>
250
- ): Promise<SkillExecutionResult> {
250
+ private async renderSkill(skill: SkillDefinition, _data: Record<string, unknown>): Promise<SkillExecutionResult> {
251
251
  const instructions = skill.instructions;
252
252
 
253
253
  if (skill.content_type === 'jst') {
254
254
  // JST templates are not currently supported
255
255
  throw new HTTPException(501, {
256
- message: `JST templates are not currently supported. Use 'md' content type instead.`
256
+ message: `JST templates are not currently supported. Use 'md' content type instead.`,
257
257
  });
258
258
  }
259
259
 
@@ -267,9 +267,9 @@ export class SkillCollection implements ICollection<SkillDefinition> {
267
267
  // ================== Skill Parser ==================
268
268
 
269
269
  interface SkillFrontmatter {
270
- name: string;
270
+ name?: string;
271
271
  title?: string;
272
- description: string;
272
+ description?: string;
273
273
  keywords?: string[];
274
274
  tools?: string[];
275
275
  data_patterns?: string[];
@@ -299,15 +299,12 @@ interface SkillFrontmatter {
299
299
  * Your markdown/jst content here...
300
300
  * ```
301
301
  */
302
- export function parseSkillFile(
303
- content: string,
304
- contentType: SkillContentType
305
- ): SkillDefinition {
302
+ export function parseSkillFile(content: string, contentType: SkillContentType): SkillDefinition {
306
303
  // Parse YAML frontmatter
307
304
  const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
308
305
 
309
306
  if (!frontmatterMatch) {
310
- throw new Error("Invalid skill file: missing YAML frontmatter");
307
+ throw new Error('Invalid skill file: missing YAML frontmatter');
311
308
  }
312
309
 
313
310
  const [, yamlContent, body] = frontmatterMatch;
@@ -357,7 +354,7 @@ export function parseSkillFile(
357
354
 
358
355
  // Related tools from frontmatter
359
356
  if (frontmatter.tools) {
360
- skill.related_tools = frontmatter.tools;
357
+ skill.tools = frontmatter.tools;
361
358
  }
362
359
 
363
360
  return skill;
@@ -367,7 +364,7 @@ export function parseSkillFile(
367
364
  * Simple YAML frontmatter parser (handles basic key: value and arrays)
368
365
  */
369
366
  function parseYamlFrontmatter(yaml: string): SkillFrontmatter {
370
- const result: Record<string, any> = {};
367
+ const result: Record<string, unknown> = {};
371
368
  const lines = yaml.split('\n');
372
369
 
373
370
  for (const line of lines) {
@@ -382,19 +379,41 @@ function parseYamlFrontmatter(yaml: string): SkillFrontmatter {
382
379
 
383
380
  // Handle array syntax: [item1, item2]
384
381
  if (value.startsWith('[') && value.endsWith(']')) {
385
- const items = value.slice(1, -1).split(',').map(s => s.trim());
386
- result[key] = items.filter(s => s.length > 0);
382
+ const items = value
383
+ .slice(1, -1)
384
+ .split(',')
385
+ .map((s) => s.trim());
386
+ result[key] = items.filter((s) => s.length > 0);
387
387
  } else {
388
388
  // Remove quotes if present
389
- if ((value.startsWith('"') && value.endsWith('"')) ||
390
- (value.startsWith("'") && value.endsWith("'"))) {
389
+ if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
391
390
  value = value.slice(1, -1);
392
391
  }
393
392
  result[key] = value;
394
393
  }
395
394
  }
396
395
 
397
- return result as SkillFrontmatter;
396
+ return {
397
+ name: asString(result.name),
398
+ title: asString(result.title),
399
+ description: asString(result.description),
400
+ keywords: asStringArray(result.keywords),
401
+ tools: asStringArray(result.tools),
402
+ data_patterns: asStringArray(result.data_patterns),
403
+ language: asString(result.language),
404
+ packages: asStringArray(result.packages),
405
+ system_packages: asStringArray(result.system_packages),
406
+ widgets: asStringArray(result.widgets),
407
+ scripts: asStringArray(result.scripts),
408
+ };
409
+ }
410
+
411
+ function asString(value: unknown): string | undefined {
412
+ return typeof value === 'string' ? value : undefined;
413
+ }
414
+
415
+ function asStringArray(value: unknown): string[] | undefined {
416
+ return Array.isArray(value) && value.every((item) => typeof item === 'string') ? value : undefined;
398
417
  }
399
418
 
400
419
  /**
@@ -402,7 +421,7 @@ function parseYamlFrontmatter(yaml: string): SkillFrontmatter {
402
421
  */
403
422
  export async function loadSkillFromFile(
404
423
  filePath: string,
405
- fs: { readFile: (path: string, encoding: string) => Promise<string> }
424
+ fs: { readFile: (path: string, encoding: string) => Promise<string> },
406
425
  ): Promise<SkillDefinition> {
407
426
  const content = await fs.readFile(filePath, 'utf-8');
408
427
  const contentType: SkillContentType = filePath.endsWith('.jst') ? 'jst' : 'md';
@@ -445,17 +464,17 @@ export function loadSkillsFromDirectory(dirPath: string): SkillDefinition[] {
445
464
  if (!stat.isDirectory()) continue;
446
465
 
447
466
  // Look for SKILL.md or SKILL.jst
448
- const mdPath = join(entryPath, "SKILL.md");
449
- const jstPath = join(entryPath, "SKILL.jst");
467
+ const mdPath = join(entryPath, 'SKILL.md');
468
+ const jstPath = join(entryPath, 'SKILL.jst');
450
469
 
451
470
  let content: string | undefined;
452
471
  let contentType: SkillContentType = 'md';
453
472
 
454
473
  if (existsSync(mdPath)) {
455
- content = readFileSync(mdPath, "utf-8");
474
+ content = readFileSync(mdPath, 'utf-8');
456
475
  contentType = 'md';
457
476
  } else if (existsSync(jstPath)) {
458
- content = readFileSync(jstPath, "utf-8");
477
+ content = readFileSync(jstPath, 'utf-8');
459
478
  contentType = 'jst';
460
479
  }
461
480
 
@@ -1,27 +1,34 @@
1
- import { AgentToolDefinition } from "@vertesia/common";
2
- import { existsSync, readdirSync, statSync } from "fs";
3
- import { Context } from "hono";
4
- import { HTTPException } from "hono/http-exception";
5
- import { join } from "path";
6
- import { pathToFileURL } from "url";
7
- import { authorize } from "./auth.js";
8
- import { ToolContext } from "./server/types.js";
9
- import { ToolRegistry } from "./ToolRegistry.js";
10
- import type { CollectionProperties, ICollection, Tool, ToolExecutionPayload, ToolExecutionResponse, ToolExecutionResponseError, ToolUseContext } from "./types.js";
11
- import { kebabCaseToTitle } from "./utils.js";
1
+ import { existsSync, readdirSync, statSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { pathToFileURL } from 'node:url';
4
+ import type { AgentToolDefinition } from '@vertesia/common';
5
+ import type { Context } from 'hono';
6
+ import { HTTPException } from 'hono/http-exception';
7
+ import { authorize } from './auth.js';
8
+ import type { ToolContext } from './server/types.js';
9
+ import { ToolRegistry } from './ToolRegistry.js';
10
+ import type {
11
+ CollectionProperties,
12
+ ICollection,
13
+ Tool,
14
+ ToolExecutionPayload,
15
+ ToolExecutionResponse,
16
+ ToolExecutionResponseError,
17
+ ToolUseContext,
18
+ } from './types.js';
19
+ import { kebabCaseToTitle } from './utils.js';
12
20
 
13
21
  export interface ToolCollectionProperties extends CollectionProperties {
14
22
  /**
15
23
  * The tools
16
24
  */
17
- tools: Tool<any>[];
25
+ tools: Tool[];
18
26
  }
19
27
 
20
28
  /**
21
29
  * Implements a tools collection endpoint
22
30
  */
23
- export class ToolCollection implements ICollection<Tool<any>> {
24
-
31
+ export class ToolCollection implements ICollection<Tool> {
25
32
  /**
26
33
  * A kebab case collection name. Must only contains alphanumeric and dash characters,
27
34
  * The name can be used to generate the path where the collection is exposed.
@@ -29,7 +36,7 @@ export class ToolCollection implements ICollection<Tool<any>> {
29
36
  */
30
37
  name: string;
31
38
  /**
32
- * Optional title for UI display.
39
+ * Optional title for UI display.
33
40
  * If not provided the title will be generated form the kebab case name by replacing - with spaces and upper casing first letter in words.
34
41
  */
35
42
  title?: string;
@@ -38,7 +45,7 @@ export class ToolCollection implements ICollection<Tool<any>> {
38
45
  */
39
46
  icon?: string;
40
47
  /**
41
- * A short description
48
+ * A short description
42
49
  */
43
50
  description?: string;
44
51
  /**
@@ -46,9 +53,7 @@ export class ToolCollection implements ICollection<Tool<any>> {
46
53
  */
47
54
  tools: ToolRegistry;
48
55
 
49
- constructor({
50
- name, title, icon, description, tools
51
- }: ToolCollectionProperties) {
56
+ constructor({ name, title, icon, description, tools }: ToolCollectionProperties) {
52
57
  this.name = name;
53
58
  this.title = title || kebabCaseToTitle(name);
54
59
  this.icon = icon;
@@ -57,27 +62,27 @@ export class ToolCollection implements ICollection<Tool<any>> {
57
62
  this.tools = new ToolRegistry(name, tools);
58
63
  }
59
64
 
60
- [Symbol.iterator](): Iterator<Tool<any>> {
65
+ [Symbol.iterator](): Iterator<Tool> {
61
66
  let index = 0;
62
67
  const tools = this.tools.getTools();
63
68
 
64
69
  return {
65
- next(): IteratorResult<Tool<any>> {
70
+ next(): IteratorResult<Tool> {
66
71
  if (index < tools.length) {
67
72
  return { value: tools[index++], done: false };
68
73
  } else {
69
74
  return { done: true, value: undefined };
70
75
  }
71
- }
76
+ },
72
77
  };
73
78
  }
74
79
 
75
- map<U>(callback: (tool: Tool<any>, index: number) => U): U[] {
80
+ map<U>(callback: (tool: Tool, index: number) => U): U[] {
76
81
  return this.tools.getTools().map(callback);
77
82
  }
78
83
 
79
- async execute(ctx: Context, preParsedPayload?: ToolExecutionPayload<any>): Promise<Response> {
80
- let payload: ToolExecutionPayload<any> | undefined = preParsedPayload;
84
+ async execute(ctx: Context, preParsedPayload?: ToolExecutionPayload): Promise<Response> {
85
+ let payload: ToolExecutionPayload | undefined = preParsedPayload;
81
86
  try {
82
87
  if (!payload) {
83
88
  payload = await readPayload(ctx);
@@ -99,27 +104,33 @@ export class ToolCollection implements ICollection<Tool<any>> {
99
104
  const r = await this.tools.runTool(payload, session);
100
105
  return ctx.json({
101
106
  ...r,
102
- tool_use_id: payload.tool_use.id
107
+ tool_use_id: payload.tool_use.id,
103
108
  } satisfies ToolExecutionResponse);
104
- } catch (err: any) { // HTTPException ?
105
- const status = err.status || 500;
109
+ } catch (err: unknown) {
110
+ // HTTPException ?
111
+ const status = err instanceof HTTPException ? err.status : 500;
112
+ const message = err instanceof Error ? err.message : 'Error executing tool';
113
+ const stack = err instanceof Error ? err.stack : undefined;
106
114
  const toolName = payload?.tool_use?.tool_name;
107
115
  const toolUseId = payload?.tool_use?.id;
108
116
 
109
- console.error("[ToolCollection] Tool execution failed", {
117
+ console.error('[ToolCollection] Tool execution failed', {
110
118
  collection: this.name,
111
119
  tool: toolName,
112
120
  toolUseId,
113
- error: err.message,
121
+ error: message,
114
122
  status,
115
- stack: err.stack,
123
+ stack,
116
124
  });
117
125
 
118
- return ctx.json({
119
- tool_use_id: toolUseId || "undefined",
120
- error: err.message || "Error executing tool",
121
- status
122
- } satisfies ToolExecutionResponseError, status)
126
+ return ctx.json(
127
+ {
128
+ tool_use_id: toolUseId || 'undefined',
129
+ error: message,
130
+ status,
131
+ } satisfies ToolExecutionResponseError,
132
+ status,
133
+ );
123
134
  }
124
135
  }
125
136
 
@@ -131,11 +142,9 @@ export class ToolCollection implements ICollection<Tool<any>> {
131
142
  getToolDefinitions(context?: ToolUseContext): AgentToolDefinition[] {
132
143
  return this.tools.getDefinitions(context);
133
144
  }
134
-
135
145
  }
136
146
 
137
-
138
- function readPayload(ctx: Context): ToolExecutionPayload<any> {
147
+ function readPayload(ctx: Context): ToolExecutionPayload {
139
148
  const toolCtx = ctx as ToolContext;
140
149
 
141
150
  // Check if body was already parsed and validated by middleware
@@ -145,7 +154,8 @@ function readPayload(ctx: Context): ToolExecutionPayload<any> {
145
154
 
146
155
  // If no payload, middleware couldn't parse/validate - return error
147
156
  throw new HTTPException(400, {
148
- message: 'Invalid or missing tool execution payload. Expected { tool_use: { id, tool_name, tool_input? }, metadata? }'
157
+ message:
158
+ 'Invalid or missing tool execution payload. Expected { tool_use: { id, tool_name, tool_input? }, metadata? }',
149
159
  });
150
160
  }
151
161
 
@@ -166,8 +176,8 @@ function readPayload(ctx: Context): ToolExecutionPayload<any> {
166
176
  * @param toolsDir - Path to the tools directory (e.g., /path/to/collection/tools)
167
177
  * @returns Promise resolving to array of Tool objects
168
178
  */
169
- export async function loadToolsFromDirectory(toolsDir: string): Promise<Tool<any>[]> {
170
- const tools: Tool<any>[] = [];
179
+ export async function loadToolsFromDirectory(toolsDir: string): Promise<Tool[]> {
180
+ const tools: Tool[] = [];
171
181
 
172
182
  if (!existsSync(toolsDir)) {
173
183
  console.warn(`Tools directory not found: ${toolsDir}`);
@@ -213,4 +223,3 @@ export async function loadToolsFromDirectory(toolsDir: string): Promise<Tool<any
213
223
 
214
224
  return tools;
215
225
  }
216
-