@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.
- package/lib/{types/ActivityCollection.d.ts → ActivityCollection.d.ts} +7 -7
- package/lib/ActivityCollection.d.ts.map +1 -0
- package/lib/{esm/ActivityCollection.js → ActivityCollection.js} +6 -6
- package/lib/ActivityCollection.js.map +1 -0
- package/lib/{types/ContentTypesCollection.d.ts → ContentTypesCollection.d.ts} +2 -2
- package/lib/ContentTypesCollection.d.ts.map +1 -0
- package/lib/{esm/ContentTypesCollection.js → ContentTypesCollection.js} +3 -3
- package/lib/ContentTypesCollection.js.map +1 -0
- package/lib/{types/InteractionCollection.d.ts → InteractionCollection.d.ts} +2 -2
- package/lib/InteractionCollection.d.ts.map +1 -0
- package/lib/{esm/InteractionCollection.js → InteractionCollection.js} +3 -3
- package/lib/InteractionCollection.js.map +1 -0
- package/lib/{types/RenderingTemplateCollection.d.ts → RenderingTemplateCollection.d.ts} +1 -1
- package/lib/RenderingTemplateCollection.d.ts.map +1 -0
- package/lib/{esm/RenderingTemplateCollection.js → RenderingTemplateCollection.js} +3 -3
- package/lib/RenderingTemplateCollection.js.map +1 -0
- package/lib/{types/SkillCollection.d.ts → SkillCollection.d.ts} +5 -5
- package/lib/SkillCollection.d.ts.map +1 -0
- package/lib/{esm/SkillCollection.js → SkillCollection.js} +68 -51
- package/lib/SkillCollection.js.map +1 -0
- package/lib/{types/ToolCollection.d.ts → ToolCollection.d.ts} +10 -10
- package/lib/ToolCollection.d.ts.map +1 -0
- package/lib/{esm/ToolCollection.js → ToolCollection.js} +21 -18
- package/lib/ToolCollection.js.map +1 -0
- package/lib/ToolRegistry.d.ts +22 -0
- package/lib/ToolRegistry.d.ts.map +1 -0
- package/lib/{esm/ToolRegistry.js → ToolRegistry.js} +6 -36
- package/lib/ToolRegistry.js.map +1 -0
- package/lib/{types/auth.d.ts → auth.d.ts} +5 -5
- package/lib/auth.d.ts.map +1 -0
- package/lib/{esm/auth.js → auth.js} +23 -17
- package/lib/auth.js.map +1 -0
- package/lib/build/validate.d.ts.map +1 -0
- package/lib/build/validate.js.map +1 -0
- package/lib/copy-assets.d.ts.map +1 -0
- package/lib/{esm/copy-assets.js → copy-assets.js} +4 -7
- package/lib/copy-assets.js.map +1 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +15 -0
- package/lib/index.js.map +1 -0
- package/lib/server/activities.d.ts +4 -0
- package/lib/server/activities.d.ts.map +1 -0
- package/lib/{esm/server → server}/activities.js +12 -9
- package/lib/server/activities.js.map +1 -0
- package/lib/server/app-package.d.ts +12 -0
- package/lib/server/app-package.d.ts.map +1 -0
- package/lib/server/app-package.js +197 -0
- package/lib/server/app-package.js.map +1 -0
- package/lib/server/content-types.d.ts +4 -0
- package/lib/server/content-types.d.ts.map +1 -0
- package/lib/server/content-types.js +100 -0
- package/lib/server/content-types.js.map +1 -0
- package/lib/server/dashboards.d.ts +4 -0
- package/lib/server/dashboards.d.ts.map +1 -0
- package/lib/server/dashboards.js +25 -0
- package/lib/server/dashboards.js.map +1 -0
- package/lib/server/interactions.d.ts +4 -0
- package/lib/server/interactions.d.ts.map +1 -0
- package/lib/{esm/server → server}/interactions.js +16 -16
- package/lib/server/interactions.js.map +1 -0
- package/lib/server/mcp.d.ts +4 -0
- package/lib/server/mcp.d.ts.map +1 -0
- package/lib/{esm/server → server}/mcp.js +5 -4
- package/lib/server/mcp.js.map +1 -0
- package/lib/server/processes.d.ts +4 -0
- package/lib/server/processes.d.ts.map +1 -0
- package/lib/server/processes.js +26 -0
- package/lib/server/processes.js.map +1 -0
- package/lib/server/site.d.ts +4 -0
- package/lib/server/site.d.ts.map +1 -0
- package/lib/{esm/server → server}/site.js +4 -2
- package/lib/server/site.js.map +1 -0
- package/lib/server/skills.d.ts +4 -0
- package/lib/server/skills.d.ts.map +1 -0
- package/lib/{esm/server → server}/skills.js +14 -12
- package/lib/server/skills.js.map +1 -0
- package/lib/server/templates.d.ts +4 -0
- package/lib/server/templates.d.ts.map +1 -0
- package/lib/{esm/server → server}/templates.js +10 -10
- package/lib/server/templates.js.map +1 -0
- package/lib/server/tools.d.ts +4 -0
- package/lib/server/tools.d.ts.map +1 -0
- package/lib/{esm/server → server}/tools.js +7 -9
- package/lib/server/tools.js.map +1 -0
- package/lib/{types/server → server}/types.d.ts +21 -16
- package/lib/server/types.d.ts.map +1 -0
- package/lib/{cjs → server}/types.js.map +1 -1
- package/lib/server/widgets.d.ts +4 -0
- package/lib/server/widgets.d.ts.map +1 -0
- package/lib/server/widgets.js.map +1 -0
- package/lib/{types/server.d.ts → server.d.ts} +3 -3
- package/lib/server.d.ts.map +1 -0
- package/lib/{esm/server.js → server.js} +28 -22
- package/lib/server.js.map +1 -0
- package/lib/site/styles.d.ts.map +1 -0
- package/lib/{esm/site → site}/styles.js.map +1 -1
- package/lib/{types/site → site}/templates.d.ts +9 -9
- package/lib/site/templates.d.ts.map +1 -0
- package/lib/{esm/site → site}/templates.js +152 -98
- package/lib/site/templates.js.map +1 -0
- package/lib/{types/types.d.ts → types.d.ts} +29 -16
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js.map +1 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/{esm/utils.js → utils.js} +11 -5
- package/lib/utils.js.map +1 -0
- package/package.json +21 -23
- package/src/ActivityCollection.test.ts +60 -59
- package/src/ActivityCollection.ts +27 -20
- package/src/ContentTypesCollection.ts +6 -9
- package/src/InteractionCollection.ts +6 -8
- package/src/RenderingTemplateCollection.ts +49 -51
- package/src/SkillCollection.ts +91 -72
- package/src/ToolCollection.ts +52 -43
- package/src/ToolRegistry.ts +20 -50
- package/src/auth.ts +35 -27
- package/src/copy-assets.ts +5 -12
- package/src/index.ts +15 -15
- package/src/server/activities.test.ts +70 -67
- package/src/server/activities.ts +17 -13
- package/src/server/app-package.test.ts +140 -0
- package/src/server/app-package.ts +115 -52
- package/src/server/content-types.test.ts +64 -0
- package/src/server/content-types.ts +53 -25
- package/src/server/dashboards.ts +31 -0
- package/src/server/interactions.ts +29 -28
- package/src/server/mcp.ts +16 -16
- package/src/server/processes.ts +35 -0
- package/src/server/site.ts +7 -15
- package/src/server/skills.ts +19 -18
- package/src/server/templates.ts +82 -80
- package/src/server/tools.ts +12 -16
- package/src/server/types.ts +29 -20
- package/src/server/widgets.ts +5 -9
- package/src/server.ts +55 -47
- package/src/site/styles.ts +1 -1
- package/src/site/templates.ts +259 -157
- package/src/types.ts +55 -31
- package/src/utils.ts +11 -6
- package/lib/cjs/ActivityCollection.js +0 -93
- package/lib/cjs/ActivityCollection.js.map +0 -1
- package/lib/cjs/ContentTypesCollection.js +0 -43
- package/lib/cjs/ContentTypesCollection.js.map +0 -1
- package/lib/cjs/InteractionCollection.js +0 -43
- package/lib/cjs/InteractionCollection.js.map +0 -1
- package/lib/cjs/RenderingTemplateCollection.js +0 -43
- package/lib/cjs/RenderingTemplateCollection.js.map +0 -1
- package/lib/cjs/SkillCollection.js +0 -384
- package/lib/cjs/SkillCollection.js.map +0 -1
- package/lib/cjs/ToolCollection.js +0 -221
- package/lib/cjs/ToolCollection.js.map +0 -1
- package/lib/cjs/ToolRegistry.js +0 -95
- package/lib/cjs/ToolRegistry.js.map +0 -1
- package/lib/cjs/auth.js +0 -131
- package/lib/cjs/auth.js.map +0 -1
- package/lib/cjs/build/validate.js +0 -7
- package/lib/cjs/build/validate.js.map +0 -1
- package/lib/cjs/copy-assets.js +0 -84
- package/lib/cjs/copy-assets.js.map +0 -1
- package/lib/cjs/index.js +0 -34
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/server/activities.js +0 -103
- package/lib/cjs/server/activities.js.map +0 -1
- package/lib/cjs/server/app-package.js +0 -154
- package/lib/cjs/server/app-package.js.map +0 -1
- package/lib/cjs/server/content-types.js +0 -73
- package/lib/cjs/server/content-types.js.map +0 -1
- package/lib/cjs/server/interactions.js +0 -101
- package/lib/cjs/server/interactions.js.map +0 -1
- package/lib/cjs/server/mcp.js +0 -45
- package/lib/cjs/server/mcp.js.map +0 -1
- package/lib/cjs/server/site.js +0 -48
- package/lib/cjs/server/site.js.map +0 -1
- package/lib/cjs/server/skills.js +0 -124
- package/lib/cjs/server/skills.js.map +0 -1
- package/lib/cjs/server/templates.js +0 -67
- package/lib/cjs/server/templates.js.map +0 -1
- package/lib/cjs/server/tools.js +0 -87
- package/lib/cjs/server/tools.js.map +0 -1
- package/lib/cjs/server/types.js +0 -3
- package/lib/cjs/server/types.js.map +0 -1
- package/lib/cjs/server/widgets.js +0 -27
- package/lib/cjs/server/widgets.js.map +0 -1
- package/lib/cjs/server.js +0 -142
- package/lib/cjs/server.js.map +0 -1
- package/lib/cjs/site/styles.js +0 -692
- package/lib/cjs/site/styles.js.map +0 -1
- package/lib/cjs/site/templates.js +0 -1320
- package/lib/cjs/site/templates.js.map +0 -1
- package/lib/cjs/types.js +0 -3
- package/lib/cjs/utils.js +0 -44
- package/lib/cjs/utils.js.map +0 -1
- package/lib/esm/ActivityCollection.js.map +0 -1
- package/lib/esm/ContentTypesCollection.js.map +0 -1
- package/lib/esm/InteractionCollection.js.map +0 -1
- package/lib/esm/RenderingTemplateCollection.js.map +0 -1
- package/lib/esm/SkillCollection.js.map +0 -1
- package/lib/esm/ToolCollection.js.map +0 -1
- package/lib/esm/ToolRegistry.js.map +0 -1
- package/lib/esm/auth.js.map +0 -1
- package/lib/esm/build/validate.js.map +0 -1
- package/lib/esm/copy-assets.js.map +0 -1
- package/lib/esm/index.js +0 -14
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/server/activities.js.map +0 -1
- package/lib/esm/server/app-package.js +0 -151
- package/lib/esm/server/app-package.js.map +0 -1
- package/lib/esm/server/content-types.js +0 -70
- package/lib/esm/server/content-types.js.map +0 -1
- package/lib/esm/server/interactions.js.map +0 -1
- package/lib/esm/server/mcp.js.map +0 -1
- package/lib/esm/server/site.js.map +0 -1
- package/lib/esm/server/skills.js.map +0 -1
- package/lib/esm/server/templates.js.map +0 -1
- package/lib/esm/server/tools.js.map +0 -1
- package/lib/esm/server/types.js.map +0 -1
- package/lib/esm/server/widgets.js.map +0 -1
- package/lib/esm/server.js.map +0 -1
- package/lib/esm/site/templates.js.map +0 -1
- package/lib/esm/types.js.map +0 -1
- package/lib/esm/utils.js.map +0 -1
- package/lib/types/ActivityCollection.d.ts.map +0 -1
- package/lib/types/ContentTypesCollection.d.ts.map +0 -1
- package/lib/types/InteractionCollection.d.ts.map +0 -1
- package/lib/types/RenderingTemplateCollection.d.ts.map +0 -1
- package/lib/types/SkillCollection.d.ts.map +0 -1
- package/lib/types/ToolCollection.d.ts.map +0 -1
- package/lib/types/ToolRegistry.d.ts +0 -22
- package/lib/types/ToolRegistry.d.ts.map +0 -1
- package/lib/types/auth.d.ts.map +0 -1
- package/lib/types/build/validate.d.ts.map +0 -1
- package/lib/types/copy-assets.d.ts.map +0 -1
- package/lib/types/index.d.ts +0 -14
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/server/activities.d.ts +0 -4
- package/lib/types/server/activities.d.ts.map +0 -1
- package/lib/types/server/app-package.d.ts +0 -4
- package/lib/types/server/app-package.d.ts.map +0 -1
- package/lib/types/server/content-types.d.ts +0 -4
- package/lib/types/server/content-types.d.ts.map +0 -1
- package/lib/types/server/interactions.d.ts +0 -4
- package/lib/types/server/interactions.d.ts.map +0 -1
- package/lib/types/server/mcp.d.ts +0 -4
- package/lib/types/server/mcp.d.ts.map +0 -1
- package/lib/types/server/site.d.ts +0 -4
- package/lib/types/server/site.d.ts.map +0 -1
- package/lib/types/server/skills.d.ts +0 -4
- package/lib/types/server/skills.d.ts.map +0 -1
- package/lib/types/server/templates.d.ts +0 -4
- package/lib/types/server/templates.d.ts.map +0 -1
- package/lib/types/server/tools.d.ts +0 -4
- package/lib/types/server/tools.d.ts.map +0 -1
- package/lib/types/server/types.d.ts.map +0 -1
- package/lib/types/server/widgets.d.ts +0 -4
- package/lib/types/server/widgets.d.ts.map +0 -1
- package/lib/types/server.d.ts.map +0 -1
- package/lib/types/site/styles.d.ts.map +0 -1
- package/lib/types/site/templates.d.ts.map +0 -1
- package/lib/types/types.d.ts.map +0 -1
- package/lib/types/utils.d.ts.map +0 -1
- /package/lib/{types/build → build}/validate.d.ts +0 -0
- /package/lib/{esm/build → build}/validate.js +0 -0
- /package/lib/{types/copy-assets.d.ts → copy-assets.d.ts} +0 -0
- /package/lib/{esm/server → server}/types.js +0 -0
- /package/lib/{esm/server → server}/widgets.js +0 -0
- /package/lib/{types/site → site}/styles.d.ts +0 -0
- /package/lib/{esm/site → site}/styles.js +0 -0
- /package/lib/{esm/types.js → types.js} +0 -0
- /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
|
|
4
|
-
import { Context, Hono } from
|
|
5
|
-
import { HTTPException } from
|
|
6
|
-
import { authorize } from
|
|
7
|
-
import { InteractionCollection } from
|
|
8
|
-
import { ToolServerConfig } from
|
|
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:
|
|
21
|
-
id: coll.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
|
|
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
|
|
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:
|
|
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(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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:
|
|
107
|
+
message: `No interaction found with name: ${name}`,
|
|
107
108
|
});
|
|
108
109
|
}
|
|
109
110
|
return c.json({
|
|
110
111
|
...inter,
|
|
111
|
-
id: coll.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
|
|
4
|
-
import { HTTPException } from
|
|
5
|
-
import { authorize } from
|
|
6
|
-
import { ToolServerConfig } from
|
|
7
|
-
import { MCPProviderConfig } from
|
|
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) =>
|
|
32
|
-
|
|
33
|
-
|
|
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,
|
|
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,
|
|
46
|
-
} catch (err:
|
|
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:
|
|
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
|
+
}
|
package/src/server/site.ts
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
import { Hono } from
|
|
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
|
|
11
|
-
import { ToolServerConfig } from
|
|
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
|
+
}
|
package/src/server/skills.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// ================== Skill Endpoints ==================
|
|
2
2
|
|
|
3
|
-
import { Context, Hono } from
|
|
4
|
-
import { HTTPException } from
|
|
5
|
-
import { SkillCollection } from
|
|
6
|
-
import { SkillDefinition, ToolCollectionDefinition, ToolDefinition } from
|
|
7
|
-
import { makeScriptUrl } from
|
|
8
|
-
import { ToolContext, ToolServerConfig } from
|
|
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:
|
|
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:
|
|
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())
|
|
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);
|
package/src/server/templates.ts
CHANGED
|
@@ -1,80 +1,82 @@
|
|
|
1
|
-
// ================== Template Endpoints ==================
|
|
2
|
-
|
|
3
|
-
import { RenderingTemplateDefinition, RenderingTemplateDefinitionRef } from
|
|
4
|
-
import { Context, Hono } from
|
|
5
|
-
import { HTTPException } from
|
|
6
|
-
import { RenderingTemplateCollection } from
|
|
7
|
-
import { ToolServerConfig } from
|
|
8
|
-
|
|
9
|
-
function toRef(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
endpoint
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
+
}
|
package/src/server/tools.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Context, Hono } from
|
|
2
|
-
import { HTTPException } from
|
|
3
|
-
import { ToolCollection } from
|
|
4
|
-
import { ToolCollectionDefinition, ToolDefinition } from
|
|
5
|
-
import { ToolContext, ToolServerConfig } from
|
|
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:
|
|
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:
|
|
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
|
-
|