@vertesia/tools-sdk 1.2.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 +21 -23
  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,11 +1,11 @@
1
1
  // ================== Interaction Endpoints ==================
2
2
 
3
- import { CatalogInteractionRef } from "@vertesia/common";
4
- import { Context, Hono } from "hono";
5
- import { HTTPException } from "hono/http-exception";
6
- import { authorize } from "../auth.js";
7
- import { InteractionCollection } from "../InteractionCollection.js";
8
- import { ToolServerConfig } from "./types.js";
3
+ import type { CatalogInteractionRef } from '@vertesia/common';
4
+ import { type Context, Hono } from 'hono';
5
+ import { HTTPException } from 'hono/http-exception';
6
+ import { authorize } from '../auth.js';
7
+ import type { InteractionCollection } from '../InteractionCollection.js';
8
+ import type { ToolServerConfig } from './types.js';
9
9
 
10
10
  export function createInteractionsRoute(app: Hono, basePath: string, config: ToolServerConfig) {
11
11
  const { interactions = [] } = config;
@@ -17,8 +17,8 @@ export function createInteractionsRoute(app: Hono, basePath: string, config: Too
17
17
  for (const coll of interactions) {
18
18
  for (const inter of coll.interactions) {
19
19
  allInteractions.push({
20
- type: "app",
21
- id: coll.name + ":" + inter.name,
20
+ type: 'app',
21
+ id: `${coll.name}:${inter.name}`,
22
22
  name: inter.name,
23
23
  title: inter.title || inter.name,
24
24
  description: inter.description,
@@ -31,7 +31,7 @@ export function createInteractionsRoute(app: Hono, basePath: string, config: Too
31
31
  title: 'All Interactions',
32
32
  description: 'All available interactions across all collections',
33
33
  interactions: allInteractions,
34
- collections: interactions.map(i => ({
34
+ collections: interactions.map((i) => ({
35
35
  name: i.name,
36
36
  title: i.title,
37
37
  description: i.description,
@@ -54,42 +54,43 @@ export function createInteractionsRoute(app: Hono, basePath: string, config: Too
54
54
  // Explicit collection:interaction format
55
55
  const collName = parts[0];
56
56
  const interName = parts[1];
57
- const inter = interactions.find(t => t.name === collName)?.getInteractionByName(interName);
57
+ const inter = interactions.find((t) => t.name === collName)?.getInteractionByName(interName);
58
58
  if (inter) {
59
- return c.json({ ...inter, id: collName + ":" + interName });
59
+ return c.json({ ...inter, id: `${collName}:${interName}` });
60
60
  }
61
61
  } else {
62
62
  // Search all collections for the interaction by name
63
63
  for (const coll of interactions) {
64
64
  const inter = coll.getInteractionByName(name);
65
65
  if (inter) {
66
- return c.json({ ...inter, id: coll.name + ":" + name });
66
+ return c.json({ ...inter, id: `${coll.name}:${name}` });
67
67
  }
68
68
  }
69
69
  }
70
70
 
71
71
  throw new HTTPException(404, {
72
- message: "No interaction found with name: " + name
72
+ message: `No interaction found with name: ${name}`,
73
73
  });
74
74
  });
75
-
76
75
  }
77
76
 
78
-
79
-
80
-
81
77
  function createInteractionEndpoints(coll: InteractionCollection): Hono {
82
78
  const endpoint = new Hono();
83
79
 
84
80
  endpoint.get('/', (c: Context) => {
85
- return c.json(coll.interactions.map(inter => ({
86
- type: "app",
87
- id: coll.name + ":" + inter.name,
88
- name: inter.name,
89
- title: inter.title || inter.name,
90
- description: inter.description,
91
- tags: inter.tags || [],
92
- } satisfies CatalogInteractionRef)));
81
+ return c.json(
82
+ coll.interactions.map(
83
+ (inter) =>
84
+ ({
85
+ type: 'app',
86
+ id: `${coll.name}:${inter.name}`,
87
+ name: inter.name,
88
+ title: inter.title || inter.name,
89
+ description: inter.description,
90
+ tags: inter.tags || [],
91
+ }) satisfies CatalogInteractionRef,
92
+ ),
93
+ );
93
94
  });
94
95
 
95
96
  endpoint.get('/:name', async (c: Context) => {
@@ -97,18 +98,18 @@ function createInteractionEndpoints(coll: InteractionCollection): Hono {
97
98
  const name = c.req.param('name');
98
99
  if (!name) {
99
100
  throw new HTTPException(400, {
100
- message: 'Interaction name is required'
101
+ message: 'Interaction name is required',
101
102
  });
102
103
  }
103
104
  const inter = coll.getInteractionByName(name);
104
105
  if (!inter) {
105
106
  throw new HTTPException(404, {
106
- message: "No interaction found with name: " + name
107
+ message: `No interaction found with name: ${name}`,
107
108
  });
108
109
  }
109
110
  return c.json({
110
111
  ...inter,
111
- id: coll.name + ":" + inter.name,
112
+ id: `${coll.name}:${inter.name}`,
112
113
  });
113
114
  });
114
115
 
package/src/server/mcp.ts CHANGED
@@ -1,12 +1,10 @@
1
1
  // ================== MCP Endpoints ==================
2
2
 
3
- import { Context, Hono } from "hono";
4
- import { HTTPException } from "hono/http-exception";
5
- import { authorize } from "../auth.js";
6
- import { ToolServerConfig } from "../index.js";
7
- import { MCPProviderConfig } from "./types.js";
8
-
9
-
3
+ import { type Context, Hono } from 'hono';
4
+ import { HTTPException } from 'hono/http-exception';
5
+ import { authorize } from '../auth.js';
6
+ import type { ToolServerConfig } from '../index.js';
7
+ import type { MCPProviderConfig } from './types.js';
10
8
 
11
9
  export function createMcpRoute(app: Hono, basePath: string, config: ToolServerConfig) {
12
10
  const { mcpProviders = [] } = config;
@@ -14,7 +12,6 @@ export function createMcpRoute(app: Hono, basePath: string, config: ToolServerCo
14
12
  if (mcpProviders.length > 0) {
15
13
  app.route(basePath, createMCPEndpoints(mcpProviders));
16
14
  }
17
-
18
15
  }
19
16
 
20
17
  function createMCPEndpoints(providers: MCPProviderConfig[]): Hono {
@@ -28,24 +25,27 @@ function createMCPEndpoints(providers: MCPProviderConfig[]): Hono {
28
25
  return c.json(info);
29
26
  });
30
27
 
31
- endpoint.get(`/${p.name}`, (c: Context) => c.json({
32
- name: p.name,
33
- description: p.description,
34
- }));
28
+ endpoint.get(`/${p.name}`, (c: Context) =>
29
+ c.json({
30
+ name: p.name,
31
+ description: p.description,
32
+ }),
33
+ );
35
34
  }
36
35
 
37
36
  return endpoint;
38
37
  }
39
38
 
40
- async function readJsonBody(ctx: Context): Promise<Record<string, any>> {
39
+ async function readJsonBody(ctx: Context): Promise<Record<string, unknown>> {
41
40
  try {
42
41
  const text = await ctx.req.text();
43
42
  const jsonContent = text?.trim() || '';
44
43
  if (!jsonContent) return {};
45
- return JSON.parse(jsonContent) as Record<string, any>;
46
- } catch (err: any) {
44
+ return JSON.parse(jsonContent) as Record<string, unknown>;
45
+ } catch (err: unknown) {
46
+ const message = err instanceof Error ? err.message : String(err);
47
47
  throw new HTTPException(400, {
48
- message: "Failed to parse JSON body: " + err.message
48
+ message: `Failed to parse JSON body: ${message}`,
49
49
  });
50
50
  }
51
51
  }
@@ -0,0 +1,35 @@
1
+ // ================== Process Definition Endpoints ==================
2
+
3
+ import type { InCodeProcessDefinition } from '@vertesia/common';
4
+ import type { Hono } from 'hono';
5
+ import { HTTPException } from 'hono/http-exception';
6
+ import type { ToolServerConfig } from './types.js';
7
+
8
+ export function createProcessesRoute(app: Hono, basePath: string, config: ToolServerConfig) {
9
+ const { processes = [] } = config;
10
+
11
+ app.get(basePath, (c) => {
12
+ return c.json({
13
+ title: 'All Processes',
14
+ description: 'All available process definitions',
15
+ processes,
16
+ });
17
+ });
18
+
19
+ app.get(`${basePath}/:name`, (c) => {
20
+ const name = c.req.param('name');
21
+ const process = findProcess(processes, name);
22
+ if (!process) {
23
+ throw new HTTPException(404, {
24
+ message: `No process found with name: ${name}`,
25
+ });
26
+ }
27
+ return c.json(process);
28
+ });
29
+ }
30
+
31
+ function findProcess(processes: InCodeProcessDefinition[], name: string): InCodeProcessDefinition | undefined {
32
+ return processes.find(
33
+ (process) => process.id === name || process.name === name || process.definition.process === name,
34
+ );
35
+ }
@@ -1,25 +1,18 @@
1
- import { Hono } from "hono";
1
+ import type { Hono } from 'hono';
2
2
  import {
3
3
  activityCollectionPage,
4
4
  contentTypeCollectionPage,
5
+ // biome-ignore lint/suspicious/noDeprecatedImports: index page is still served alongside the React site until that migration completes
5
6
  indexPage,
6
7
  interactionCollectionPage,
7
8
  skillCollectionPage,
8
9
  templateCollectionPage,
9
- toolCollectionPage
10
- } from "../site/templates.js";
11
- import { ToolServerConfig } from "./types.js";
12
-
10
+ toolCollectionPage,
11
+ } from '../site/templates.js';
12
+ import type { ToolServerConfig } from './types.js';
13
13
 
14
14
  export function createSiteRoute(app: Hono, basePath: string, config: ToolServerConfig) {
15
- const {
16
- tools = [],
17
- activities = [],
18
- interactions = [],
19
- types = [],
20
- skills = [],
21
- templates = [],
22
- } = config;
15
+ const { tools = [], activities = [], interactions = [], types = [], skills = [], templates = [] } = config;
23
16
 
24
17
  // Index page
25
18
  app.get(`${basePath}/`, (c) => {
@@ -67,5 +60,4 @@ export function createSiteRoute(app: Hono, basePath: string, config: ToolServerC
67
60
  return c.html(contentTypeCollectionPage(coll));
68
61
  });
69
62
  }
70
-
71
- }
63
+ }
@@ -1,11 +1,11 @@
1
1
  // ================== Skill Endpoints ==================
2
2
 
3
- import { Context, Hono } from "hono";
4
- import { HTTPException } from "hono/http-exception";
5
- import { SkillCollection } from "../SkillCollection.js";
6
- import { SkillDefinition, ToolCollectionDefinition, ToolDefinition } from "../types.js";
7
- import { makeScriptUrl } from "../utils.js";
8
- import { ToolContext, ToolServerConfig } from "./types.js";
3
+ import { type Context, Hono } from 'hono';
4
+ import { HTTPException } from 'hono/http-exception';
5
+ import type { SkillCollection } from '../SkillCollection.js';
6
+ import type { SkillDefinition, ToolCollectionDefinition, ToolDefinition } from '../types.js';
7
+ import { makeScriptUrl } from '../utils.js';
8
+ import type { ToolContext, ToolServerConfig } from './types.js';
9
9
 
10
10
  export function createSkillsRoute(app: Hono, basePath: string, config: ToolServerConfig) {
11
11
  const { skills = [] } = config;
@@ -34,12 +34,12 @@ export function createSkillsRoute(app: Hono, basePath: string, config: ToolServe
34
34
  title: 'All Skills',
35
35
  description: 'All available skills across all collections',
36
36
  tools: allSkills,
37
- collections: skills.map(s => ({
37
+ collections: skills.map((s) => ({
38
38
  name: s.name,
39
39
  title: s.title,
40
40
  description: s.description,
41
41
  })),
42
- } satisfies ToolCollectionDefinition & { collections: any[] });
42
+ } satisfies ToolCollectionDefinition & { collections: unknown[] });
43
43
  });
44
44
 
45
45
  // POST /api/skills - Route to the correct collection based on tool_name
@@ -49,7 +49,8 @@ export function createSkillsRoute(app: Hono, basePath: string, config: ToolServe
49
49
  // Payload is already parsed and validated by middleware
50
50
  if (!ctx.payload) {
51
51
  throw new HTTPException(400, {
52
- message: 'Invalid or missing skill execution payload. Expected { tool_use: { id, tool_name, tool_input? }, metadata? }'
52
+ message:
53
+ 'Invalid or missing skill execution payload. Expected { tool_use: { id, tool_name, tool_input? }, metadata? }',
53
54
  });
54
55
  }
55
56
 
@@ -61,7 +62,9 @@ export function createSkillsRoute(app: Hono, basePath: string, config: ToolServe
61
62
  // Extract skill name for better error message
62
63
  const skillName = toolName.startsWith('learn_') ? toolName.slice(6) : toolName;
63
64
  throw new HTTPException(404, {
64
- message: `Skill not found: ${skillName}. Available skills: ${Array.from(skillToCollection.keys()).filter(k => !k.startsWith('learn_')).join(', ')}`
65
+ message: `Skill not found: ${skillName}. Available skills: ${Array.from(skillToCollection.keys())
66
+ .filter((k) => !k.startsWith('learn_'))
67
+ .join(', ')}`,
65
68
  });
66
69
  }
67
70
 
@@ -73,7 +76,6 @@ export function createSkillsRoute(app: Hono, basePath: string, config: ToolServe
73
76
  for (const coll of skills) {
74
77
  app.route(`${basePath}/${coll.name}`, createSkillEndpoints(coll));
75
78
  }
76
-
77
79
  }
78
80
 
79
81
  function createSkillEndpoints(coll: SkillCollection): Hono {
@@ -87,7 +89,7 @@ function createSkillEndpoints(coll: SkillCollection): Hono {
87
89
  src: `${url.origin}${url.pathname}`,
88
90
  title: coll.title || coll.name,
89
91
  description: coll.description || '',
90
- tools: coll.getToolDefinitions()
92
+ tools: coll.getToolDefinitions(),
91
93
  } satisfies ToolCollectionDefinition);
92
94
  });
93
95
 
@@ -97,30 +99,29 @@ function createSkillEndpoints(coll: SkillCollection): Hono {
97
99
  const name = c.req.param('name');
98
100
  if (!name) {
99
101
  throw new HTTPException(400, {
100
- message: 'Skill name is required'
102
+ message: 'Skill name is required',
101
103
  });
102
104
  }
103
105
  const skillName = name.startsWith('learn_') ? name.slice(6) : name;
104
106
  const skill = coll.getSkill(skillName);
105
107
  if (!skill) {
106
108
  throw new HTTPException(404, {
107
- message: `Skill not found: ${skillName}`
109
+ message: `Skill not found: ${skillName}`,
108
110
  });
109
111
  }
110
112
  const url = new URL(c.req.url);
111
113
  return c.json({
112
114
  skill_name: skill.name,
113
- scripts: skill.scripts ? skill.scripts.map(s => makeScriptUrl(url.origin, s)) : []
115
+ scripts: skill.scripts ? skill.scripts.map((s) => makeScriptUrl(url.origin, s)) : [],
114
116
  });
115
117
  });
116
118
 
117
-
118
119
  // Get a specific skill by name
119
120
  endpoint.get('/:name', (c: Context) => {
120
121
  const name = c.req.param('name');
121
122
  if (!name) {
122
123
  throw new HTTPException(400, {
123
- message: 'Skill name is required'
124
+ message: 'Skill name is required',
124
125
  });
125
126
  }
126
127
  // Handle both "learn_name" and "name" formats
@@ -128,7 +129,7 @@ function createSkillEndpoints(coll: SkillCollection): Hono {
128
129
  const skill = coll.getSkill(skillName);
129
130
  if (!skill) {
130
131
  throw new HTTPException(404, {
131
- message: `Skill not found: ${skillName}`
132
+ message: `Skill not found: ${skillName}`,
132
133
  });
133
134
  }
134
135
  return c.json(skill satisfies SkillDefinition);
@@ -1,80 +1,82 @@
1
- // ================== Template Endpoints ==================
2
-
3
- import { RenderingTemplateDefinition, RenderingTemplateDefinitionRef } from "@vertesia/common";
4
- import { Context, Hono } from "hono";
5
- import { HTTPException } from "hono/http-exception";
6
- import { RenderingTemplateCollection } from "../RenderingTemplateCollection.js";
7
- import { ToolServerConfig } from "./types.js";
8
-
9
- function toRef(basePath: string, collectionName: string, { instructions: _, ...ref }: RenderingTemplateDefinition): RenderingTemplateDefinitionRef {
10
- return { ...ref, path: `${basePath}/${collectionName}/${ref.name}` };
11
- }
12
-
13
- export function createTemplatesRoute(app: Hono, basePath: string, config: ToolServerConfig) {
14
- const { templates = [] } = config;
15
-
16
- // GET /api/templates - Returns all templates from all collections (without instructions)
17
- app.get(basePath, (c) => {
18
- const allTemplates = templates.flatMap(coll =>
19
- coll.templates.map(t => toRef(basePath, coll.name, t))
20
- );
21
-
22
- return c.json({
23
- title: 'All Templates',
24
- description: 'All available templates across all collections',
25
- templates: allTemplates,
26
- collections: templates.map(t => ({
27
- name: t.name,
28
- title: t.title,
29
- description: t.description,
30
- })),
31
- });
32
- });
33
-
34
- // Create template collection endpoints
35
- for (const coll of templates) {
36
- app.route(`${basePath}/${coll.name}`, createTemplateEndpoints(basePath, coll));
37
- }
38
-
39
- // GET /api/templates/:name - Direct access by "collection:name" id format
40
- app.get(`${basePath}/:id`, async (c) => {
41
- const id = c.req.param('id');
42
- const parts = id.split(':');
43
- if (parts.length !== 2) {
44
- throw new HTTPException(400, {
45
- message: "Invalid template id. Expected format 'collection:name'"
46
- });
47
- }
48
- const collName = parts[0];
49
- const templateName = parts[1];
50
- const template = templates.find(t => t.name === collName)?.getTemplate(templateName);
51
- if (template) {
52
- return c.json(template);
53
- }
54
-
55
- throw new HTTPException(404, {
56
- message: "No template found with id: " + id
57
- });
58
- });
59
- }
60
-
61
- function createTemplateEndpoints(basePath: string, coll: RenderingTemplateCollection): Hono {
62
- const endpoint = new Hono();
63
-
64
- endpoint.get('/', (c: Context) => {
65
- return c.json(coll.templates.map(t => toRef(basePath, coll.name, t)));
66
- });
67
-
68
- endpoint.get('/:name', (c: Context) => {
69
- const name = c.req.param('name');
70
- const template = coll.templates.find(t => t.name === name);
71
- if (!template) {
72
- throw new HTTPException(404, {
73
- message: "No template found with name: " + name
74
- });
75
- }
76
- return c.json(template);
77
- });
78
-
79
- return endpoint;
80
- }
1
+ // ================== Template Endpoints ==================
2
+
3
+ import type { RenderingTemplateDefinition, RenderingTemplateDefinitionRef } from '@vertesia/common';
4
+ import { type Context, Hono } from 'hono';
5
+ import { HTTPException } from 'hono/http-exception';
6
+ import type { RenderingTemplateCollection } from '../RenderingTemplateCollection.js';
7
+ import type { ToolServerConfig } from './types.js';
8
+
9
+ function toRef(
10
+ basePath: string,
11
+ collectionName: string,
12
+ { instructions: _, ...ref }: RenderingTemplateDefinition,
13
+ ): RenderingTemplateDefinitionRef {
14
+ return { ...ref, path: `${basePath}/${collectionName}/${ref.name}` };
15
+ }
16
+
17
+ export function createTemplatesRoute(app: Hono, basePath: string, config: ToolServerConfig) {
18
+ const { templates = [] } = config;
19
+
20
+ // GET /api/templates - Returns all templates from all collections (without instructions)
21
+ app.get(basePath, (c) => {
22
+ const allTemplates = templates.flatMap((coll) => coll.templates.map((t) => toRef(basePath, coll.name, t)));
23
+
24
+ return c.json({
25
+ title: 'All Templates',
26
+ description: 'All available templates across all collections',
27
+ templates: allTemplates,
28
+ collections: templates.map((t) => ({
29
+ name: t.name,
30
+ title: t.title,
31
+ description: t.description,
32
+ })),
33
+ });
34
+ });
35
+
36
+ // Create template collection endpoints
37
+ for (const coll of templates) {
38
+ app.route(`${basePath}/${coll.name}`, createTemplateEndpoints(basePath, coll));
39
+ }
40
+
41
+ // GET /api/templates/:name - Direct access by "collection:name" id format
42
+ app.get(`${basePath}/:id`, async (c) => {
43
+ const id = c.req.param('id');
44
+ const parts = id.split(':');
45
+ if (parts.length !== 2) {
46
+ throw new HTTPException(400, {
47
+ message: "Invalid template id. Expected format 'collection:name'",
48
+ });
49
+ }
50
+ const collName = parts[0];
51
+ const templateName = parts[1];
52
+ const template = templates.find((t) => t.name === collName)?.getTemplate(templateName);
53
+ if (template) {
54
+ return c.json(template);
55
+ }
56
+
57
+ throw new HTTPException(404, {
58
+ message: `No template found with id: ${id}`,
59
+ });
60
+ });
61
+ }
62
+
63
+ function createTemplateEndpoints(basePath: string, coll: RenderingTemplateCollection): Hono {
64
+ const endpoint = new Hono();
65
+
66
+ endpoint.get('/', (c: Context) => {
67
+ return c.json(coll.templates.map((t) => toRef(basePath, coll.name, t)));
68
+ });
69
+
70
+ endpoint.get('/:name', (c: Context) => {
71
+ const name = c.req.param('name');
72
+ const template = coll.templates.find((t) => t.name === name);
73
+ if (!template) {
74
+ throw new HTTPException(404, {
75
+ message: `No template found with name: ${name}`,
76
+ });
77
+ }
78
+ return c.json(template);
79
+ });
80
+
81
+ return endpoint;
82
+ }
@@ -1,8 +1,8 @@
1
- import { Context, Hono } from "hono";
2
- import { HTTPException } from "hono/http-exception";
3
- import { ToolCollection } from "../ToolCollection.js";
4
- import { ToolCollectionDefinition, ToolDefinition } from "../types.js";
5
- import { ToolContext, ToolServerConfig } from "./types.js";
1
+ import { type Context, Hono } from 'hono';
2
+ import { HTTPException } from 'hono/http-exception';
3
+ import type { ToolCollection } from '../ToolCollection.js';
4
+ import type { ToolCollectionDefinition, ToolDefinition } from '../types.js';
5
+ import type { ToolContext, ToolServerConfig } from './types.js';
6
6
 
7
7
  export function createToolsRoute(app: Hono, basePath: string, config: ToolServerConfig) {
8
8
  const { tools = [] } = config;
@@ -34,12 +34,12 @@ export function createToolsRoute(app: Hono, basePath: string, config: ToolServer
34
34
  title: 'All Tools',
35
35
  description: 'All available tools across all collections',
36
36
  tools: allTools,
37
- collections: tools.map(t => ({
37
+ collections: tools.map((t) => ({
38
38
  name: t.name,
39
39
  title: t.title,
40
40
  description: t.description,
41
41
  })),
42
- } satisfies ToolCollectionDefinition & { collections: any[]; reserveToolCount?: number });
42
+ } satisfies ToolCollectionDefinition & { collections: unknown[]; reserveToolCount?: number });
43
43
  });
44
44
 
45
45
  // POST /api/tools - Route to the correct collection based on tool_name
@@ -49,7 +49,8 @@ export function createToolsRoute(app: Hono, basePath: string, config: ToolServer
49
49
  // Payload is already parsed and validated by middleware
50
50
  if (!ctx.payload) {
51
51
  throw new HTTPException(400, {
52
- message: 'Invalid or missing tool execution payload. Expected { tool_use: { id, tool_name, tool_input? }, metadata? }'
52
+ message:
53
+ 'Invalid or missing tool execution payload. Expected { tool_use: { id, tool_name, tool_input? }, metadata? }',
53
54
  });
54
55
  }
55
56
 
@@ -59,7 +60,7 @@ export function createToolsRoute(app: Hono, basePath: string, config: ToolServer
59
60
  const collection = toolToCollection.get(toolName);
60
61
  if (!collection) {
61
62
  throw new HTTPException(404, {
62
- message: `Tool not found: ${toolName}. Available tools: ${Array.from(toolToCollection.keys()).join(', ')}`
63
+ message: `Tool not found: ${toolName}. Available tools: ${Array.from(toolToCollection.keys()).join(', ')}`,
63
64
  });
64
65
  }
65
66
 
@@ -91,12 +92,10 @@ function createToolEndpoints(coll: ToolCollection): Hono {
91
92
  const url = new URL(c.req.url);
92
93
 
93
94
  const response: ToolCollectionDefinition = {
94
- src: importSourceUrl
95
- ? `${url.origin}/libs/vertesia-tools-${coll.name}.js`
96
- : `${url.origin}${url.pathname}`,
95
+ src: importSourceUrl ? `${url.origin}/libs/vertesia-tools-${coll.name}.js` : `${url.origin}${url.pathname}`,
97
96
  title: coll.title || coll.name,
98
97
  description: coll.description || '',
99
- tools: coll.getToolDefinitions()
98
+ tools: coll.getToolDefinitions(),
100
99
  };
101
100
 
102
101
  return c.json(response);
@@ -104,6 +103,3 @@ function createToolEndpoints(coll: ToolCollection): Hono {
104
103
 
105
104
  return endpoint;
106
105
  }
107
-
108
-
109
-