@vertesia/tools-sdk 1.3.0 → 1.4.0-dev.20260615.051508Z
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 +20 -22
- 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
package/src/server/types.ts
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
1
|
+
import type { JSONSchema } from '@llumiverse/common';
|
|
2
|
+
import type {
|
|
3
|
+
AppDashboardDefinition,
|
|
4
|
+
AppUIConfig,
|
|
5
|
+
InCodeProcessDefinition,
|
|
6
|
+
ProjectConfiguration,
|
|
7
|
+
} from '@vertesia/common';
|
|
8
|
+
import type { Context } from 'hono';
|
|
9
|
+
import type { ActivityCollection } from '../ActivityCollection.js';
|
|
10
|
+
import type { AuthSession } from '../auth.js';
|
|
11
|
+
import type { ContentTypesCollection } from '../ContentTypesCollection.js';
|
|
12
|
+
import type { InteractionCollection } from '../InteractionCollection.js';
|
|
13
|
+
import type { RenderingTemplateCollection } from '../RenderingTemplateCollection.js';
|
|
14
|
+
import type { SkillCollection } from '../SkillCollection.js';
|
|
15
|
+
import type { ToolCollection } from '../ToolCollection.js';
|
|
16
|
+
import type { MCPConnectionDetails, ToolExecutionPayload } from '../types.js';
|
|
11
17
|
|
|
12
18
|
/**
|
|
13
19
|
* Extended context with parsed payload for tool/skill execution
|
|
14
20
|
*/
|
|
15
21
|
export interface ToolContext extends Context {
|
|
16
22
|
/** The parsed request payload */
|
|
17
|
-
payload?: ToolExecutionPayload
|
|
23
|
+
payload?: ToolExecutionPayload;
|
|
18
24
|
/** The tool_use.id from the payload */
|
|
19
25
|
toolUseId?: string;
|
|
20
26
|
/** The tool_use.tool_name from the payload */
|
|
@@ -27,11 +33,7 @@ export interface ToolContext extends Context {
|
|
|
27
33
|
export interface MCPProviderConfig {
|
|
28
34
|
name: string;
|
|
29
35
|
description?: string;
|
|
30
|
-
createMCPConnection: (session:
|
|
31
|
-
name: string;
|
|
32
|
-
url: string;
|
|
33
|
-
token: string;
|
|
34
|
-
}>;
|
|
36
|
+
createMCPConnection: (session: AuthSession, config: Record<string, unknown>) => Promise<MCPConnectionDetails>;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
/**
|
|
@@ -62,6 +64,14 @@ export interface ToolServerConfig {
|
|
|
62
64
|
* Content type collections to expose
|
|
63
65
|
*/
|
|
64
66
|
types?: ContentTypesCollection[];
|
|
67
|
+
/**
|
|
68
|
+
* Process definitions to expose as app-contributed processes.
|
|
69
|
+
*/
|
|
70
|
+
processes?: InCodeProcessDefinition[];
|
|
71
|
+
/**
|
|
72
|
+
* Dashboard definitions to expose as app-contributed dashboards.
|
|
73
|
+
*/
|
|
74
|
+
dashboards?: AppDashboardDefinition[];
|
|
65
75
|
/**
|
|
66
76
|
* Skill collections to expose
|
|
67
77
|
*/
|
|
@@ -95,11 +105,10 @@ export interface ToolServerConfig {
|
|
|
95
105
|
hideUILinks?: boolean;
|
|
96
106
|
|
|
97
107
|
/**
|
|
98
|
-
* If a filter is provided, it will be called with the project configuration when requesting tool definitions, and can be used to filter which tools are returned based on the project configuration.
|
|
108
|
+
* If a filter is provided, it will be called with the project configuration when requesting tool definitions, and can be used to filter which tools are returned based on the project configuration.
|
|
99
109
|
* This allows for dynamic enabling/disabling of tools based on project settings.
|
|
100
|
-
* @param projectConfig
|
|
101
|
-
* @returns
|
|
110
|
+
* @param projectConfig
|
|
111
|
+
* @returns
|
|
102
112
|
*/
|
|
103
113
|
toolFilter?: (projectConfig: ProjectConfiguration) => boolean;
|
|
104
114
|
}
|
|
105
|
-
|
package/src/server/widgets.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { AppWidgetInfo } from
|
|
2
|
-
import { Hono } from
|
|
3
|
-
import { ToolServerConfig } from
|
|
4
|
-
|
|
1
|
+
import type { AppWidgetInfo } from '@vertesia/common';
|
|
2
|
+
import type { Hono } from 'hono';
|
|
3
|
+
import type { ToolServerConfig } from './types.js';
|
|
5
4
|
|
|
6
5
|
export function createWidgetsRoute(app: Hono, basePath: string, config: ToolServerConfig) {
|
|
7
|
-
|
|
8
6
|
const { skills = [] } = config;
|
|
9
7
|
|
|
10
8
|
// GET /api/widgets - Returns all widgets from all skill collections
|
|
@@ -19,7 +17,7 @@ export function createWidgetsRoute(app: Hono, basePath: string, config: ToolServ
|
|
|
19
17
|
collection: coll.name,
|
|
20
18
|
skill: widget.skill,
|
|
21
19
|
url: `${url.origin}/widgets/${widget.name}.js`,
|
|
22
|
-
}
|
|
20
|
+
};
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
|
|
@@ -28,7 +26,5 @@ export function createWidgetsRoute(app: Hono, basePath: string, config: ToolServ
|
|
|
28
26
|
description: 'All available widgets across all skill collections',
|
|
29
27
|
widgets,
|
|
30
28
|
});
|
|
31
|
-
|
|
32
29
|
});
|
|
33
|
-
|
|
34
|
-
}
|
|
30
|
+
}
|
package/src/server.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { Context, Hono } from
|
|
2
|
-
import { cors } from
|
|
3
|
-
import { HTTPException } from
|
|
4
|
-
import { z } from
|
|
5
|
-
import { createActivitiesRoute } from
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
1
|
+
import { type Context, Hono } from 'hono';
|
|
2
|
+
import { cors } from 'hono/cors';
|
|
3
|
+
import { HTTPException } from 'hono/http-exception';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { createActivitiesRoute } from './server/activities.js';
|
|
6
|
+
import { createPackageRoute } from './server/app-package.js';
|
|
7
|
+
import { createContentTypesRoute } from './server/content-types.js';
|
|
8
|
+
import { createDashboardsRoute } from './server/dashboards.js';
|
|
9
|
+
import { createInteractionsRoute } from './server/interactions.js';
|
|
10
|
+
import { createMcpRoute } from './server/mcp.js';
|
|
11
|
+
import { createProcessesRoute } from './server/processes.js';
|
|
12
|
+
import { createSiteRoute } from './server/site.js';
|
|
13
|
+
import { createSkillsRoute } from './server/skills.js';
|
|
14
|
+
import { createTemplatesRoute } from './server/templates.js';
|
|
15
|
+
import { createToolsRoute } from './server/tools.js';
|
|
16
|
+
import type { ToolContext, ToolServerConfig } from './server/types.js';
|
|
17
|
+
import { createWidgetsRoute } from './server/widgets.js';
|
|
18
|
+
import type { ToolExecutionPayload } from './types.js';
|
|
17
19
|
|
|
18
20
|
// Schema for tool execution payload
|
|
19
21
|
const ToolExecutionPayloadSchema = z.object({
|
|
@@ -25,8 +27,6 @@ const ToolExecutionPayloadSchema = z.object({
|
|
|
25
27
|
metadata: z.record(z.string(), z.any()).optional(),
|
|
26
28
|
});
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
30
|
/**
|
|
31
31
|
* Create a Hono server for tools, interactions, and skills.
|
|
32
32
|
*
|
|
@@ -50,6 +50,7 @@ export function createToolServer(config: ToolServerConfig): Hono {
|
|
|
50
50
|
skills = [],
|
|
51
51
|
templates = [],
|
|
52
52
|
activities = [],
|
|
53
|
+
dashboards = [],
|
|
53
54
|
mcpProviders = [],
|
|
54
55
|
disableHtml = false,
|
|
55
56
|
} = config;
|
|
@@ -68,7 +69,7 @@ export function createToolServer(config: ToolServerConfig): Hono {
|
|
|
68
69
|
const body = JSON.parse(text);
|
|
69
70
|
const result = ToolExecutionPayloadSchema.safeParse(body);
|
|
70
71
|
if (result.success) {
|
|
71
|
-
ctx.payload = result.data as ToolExecutionPayload
|
|
72
|
+
ctx.payload = result.data as ToolExecutionPayload;
|
|
72
73
|
ctx.toolUseId = result.data.tool_use.id;
|
|
73
74
|
ctx.toolName = result.data.tool_use.tool_name;
|
|
74
75
|
}
|
|
@@ -90,23 +91,24 @@ export function createToolServer(config: ToolServerConfig): Hono {
|
|
|
90
91
|
app.get(prefix, (c) => {
|
|
91
92
|
// Skills are exposed as tools, so include them in the tools list
|
|
92
93
|
const allToolEndpoints = [
|
|
93
|
-
...tools.map(col => `${prefix}/tools/${col.name}`),
|
|
94
|
-
...skills.map(col => `${prefix}/skills/${col.name}`),
|
|
94
|
+
...tools.map((col) => `${prefix}/tools/${col.name}`),
|
|
95
|
+
...skills.map((col) => `${prefix}/skills/${col.name}`),
|
|
95
96
|
];
|
|
96
97
|
return c.json({
|
|
97
98
|
message: 'Vertesia Tools API',
|
|
98
99
|
version: '1.0.0',
|
|
99
100
|
endpoints: {
|
|
100
101
|
tools: allToolEndpoints,
|
|
101
|
-
interactions: interactions.map(col => `${prefix}/interactions/${col.name}`),
|
|
102
|
-
templates: templates.map(col => `${prefix}/templates/${col.name}`),
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
interactions: interactions.map((col) => `${prefix}/interactions/${col.name}`),
|
|
103
|
+
templates: templates.map((col) => `${prefix}/templates/${col.name}`),
|
|
104
|
+
processes: `${prefix}/processes`,
|
|
105
|
+
dashboards: dashboards.length > 0 ? `${prefix}/dashboards` : undefined,
|
|
106
|
+
activities: activities.map((col) => `${prefix}/activities/${col.name}`),
|
|
107
|
+
mcp: mcpProviders.map((p) => `${prefix}/mcp/${p.name}`),
|
|
108
|
+
},
|
|
106
109
|
});
|
|
107
110
|
});
|
|
108
111
|
|
|
109
|
-
|
|
110
112
|
createPackageRoute(app, `${prefix}/package`, config);
|
|
111
113
|
createToolsRoute(app, `${prefix}/tools`, config);
|
|
112
114
|
createSkillsRoute(app, `${prefix}/skills`, config);
|
|
@@ -115,9 +117,10 @@ export function createToolServer(config: ToolServerConfig): Hono {
|
|
|
115
117
|
createInteractionsRoute(app, `${prefix}/interactions`, config);
|
|
116
118
|
createTemplatesRoute(app, `${prefix}/templates`, config);
|
|
117
119
|
createContentTypesRoute(app, `${prefix}/types`, config);
|
|
120
|
+
createProcessesRoute(app, `${prefix}/processes`, config);
|
|
121
|
+
createDashboardsRoute(app, `${prefix}/dashboards`, config);
|
|
118
122
|
createMcpRoute(app, `${prefix}/mcp`, config);
|
|
119
123
|
|
|
120
|
-
|
|
121
124
|
// Global error handler - returns ToolExecutionResponseError format
|
|
122
125
|
app.onError((err, c) => {
|
|
123
126
|
const ctx = c as unknown as ToolContext;
|
|
@@ -128,40 +131,46 @@ export function createToolServer(config: ToolServerConfig): Hono {
|
|
|
128
131
|
console.error('Uncaught Error:', err);
|
|
129
132
|
}
|
|
130
133
|
|
|
131
|
-
return c.json(
|
|
132
|
-
|
|
134
|
+
return c.json(
|
|
135
|
+
{
|
|
136
|
+
tool_use_id: ctx.toolUseId || 'unknown',
|
|
137
|
+
status,
|
|
138
|
+
error: errorMessage,
|
|
139
|
+
data: ctx.toolName ? { tool_name: ctx.toolName } : undefined,
|
|
140
|
+
},
|
|
133
141
|
status,
|
|
134
|
-
|
|
135
|
-
data: ctx.toolName ? { tool_name: ctx.toolName } : undefined,
|
|
136
|
-
}, status);
|
|
142
|
+
);
|
|
137
143
|
});
|
|
138
144
|
|
|
139
145
|
// Not found handler - returns ToolExecutionResponseError format
|
|
140
146
|
app.notFound((c) => {
|
|
141
147
|
const ctx = c as unknown as ToolContext;
|
|
142
|
-
return c.json(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
+
return c.json(
|
|
149
|
+
{
|
|
150
|
+
tool_use_id: ctx.toolUseId || 'unknown',
|
|
151
|
+
status: 404,
|
|
152
|
+
error: `Not found: ${c.req.method} ${c.req.path}`,
|
|
153
|
+
data: ctx.toolName ? { tool_name: ctx.toolName } : undefined,
|
|
154
|
+
},
|
|
155
|
+
404,
|
|
156
|
+
);
|
|
148
157
|
});
|
|
149
158
|
|
|
150
159
|
return app;
|
|
151
160
|
}
|
|
152
161
|
|
|
153
|
-
|
|
154
|
-
|
|
155
162
|
// ================== Server Utilities ==================
|
|
156
163
|
|
|
157
164
|
/**
|
|
158
165
|
* Simple development server with static fimesale handling
|
|
159
|
-
*
|
|
160
|
-
* @deprecated Use tools server template
|
|
166
|
+
*
|
|
167
|
+
* @deprecated Use tools server template
|
|
161
168
|
*/
|
|
162
|
-
export function createDevServer(
|
|
163
|
-
|
|
164
|
-
|
|
169
|
+
export function createDevServer(
|
|
170
|
+
config: ToolServerConfig & {
|
|
171
|
+
staticHandler?: (c: Context, next: () => Promise<void>) => Promise<Response | undefined>;
|
|
172
|
+
},
|
|
173
|
+
): Hono {
|
|
165
174
|
const app = createToolServer(config);
|
|
166
175
|
|
|
167
176
|
if (config.staticHandler) {
|
|
@@ -170,4 +179,3 @@ export function createDevServer(config: ToolServerConfig & {
|
|
|
170
179
|
|
|
171
180
|
return app;
|
|
172
181
|
}
|
|
173
|
-
|