@vertesia/tools-sdk 1.5.0-dev.20260714.072725Z → 1.5.0-dev.20260717.131047Z
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/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/server/app-package.d.ts +8 -0
- package/lib/server/app-package.d.ts.map +1 -1
- package/lib/server/app-package.js +65 -30
- package/lib/server/app-package.js.map +1 -1
- package/lib/server/content-types.d.ts.map +1 -1
- package/lib/server/content-types.js +40 -10
- package/lib/server/content-types.js.map +1 -1
- 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/types.d.ts +5 -1
- package/lib/server/types.d.ts.map +1 -1
- package/lib/server.d.ts.map +1 -1
- package/lib/server.js +4 -1
- package/lib/server.js.map +1 -1
- package/package.json +6 -5
- package/src/index.ts +2 -0
- package/src/server/app-package.test.ts +140 -0
- package/src/server/app-package.ts +82 -34
- package/src/server/content-types.test.ts +64 -0
- package/src/server/content-types.ts +43 -10
- package/src/server/dashboards.ts +31 -0
- package/src/server/types.ts +10 -1
- package/src/server.ts +4 -0
package/lib/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export { copyRuntimeAssets } from './copy-assets.js';
|
|
|
5
5
|
export * from './InteractionCollection.js';
|
|
6
6
|
export * from './RenderingTemplateCollection.js';
|
|
7
7
|
export * from './SkillCollection.js';
|
|
8
|
+
export type { BuildAppPackageOptions } from './server/app-package.js';
|
|
9
|
+
export { buildAppPackage } from './server/app-package.js';
|
|
8
10
|
export * from './server/types.js';
|
|
9
11
|
export * from './server.js';
|
|
10
12
|
export * from './site/templates.js';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sBAAsB,CAAC;AACrC,YAAY,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { copyRuntimeAssets } from './copy-assets.js';
|
|
|
5
5
|
export * from './InteractionCollection.js';
|
|
6
6
|
export * from './RenderingTemplateCollection.js';
|
|
7
7
|
export * from './SkillCollection.js';
|
|
8
|
+
export { buildAppPackage } from './server/app-package.js';
|
|
8
9
|
export * from './server/types.js';
|
|
9
10
|
export * from './server.js';
|
|
10
11
|
export * from './site/templates.js';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sBAAsB,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
import type { AppPackage, AppPackageScope } from '@vertesia/common';
|
|
1
2
|
import type { Hono } from 'hono';
|
|
3
|
+
import type { ToolUseContext } from '../types.js';
|
|
2
4
|
import type { ToolServerConfig } from './types.js';
|
|
5
|
+
export interface BuildAppPackageOptions {
|
|
6
|
+
scope?: AppPackageScope | AppPackageScope[] | string;
|
|
7
|
+
origin?: string;
|
|
8
|
+
toolUseContext?: ToolUseContext;
|
|
9
|
+
}
|
|
10
|
+
export declare function buildAppPackage(config: ToolServerConfig, options?: BuildAppPackageOptions): Promise<AppPackage>;
|
|
3
11
|
export declare function createPackageRoute(app: Hono, basePath: string, config: ToolServerConfig): void;
|
|
4
12
|
//# sourceMappingURL=app-package.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-package.d.ts","sourceRoot":"","sources":["../../src/server/app-package.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app-package.d.ts","sourceRoot":"","sources":["../../src/server/app-package.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAER,UAAU,EACV,eAAe,EAMlB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAMnD,MAAM,WAAW,sBAAsB;IACnC,KAAK,CAAC,EAAE,eAAe,GAAG,eAAe,EAAE,GAAG,MAAM,CAAC;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,cAAc,CAAC;CACnC;AA8ID,wBAAsB,eAAe,CACjC,MAAM,EAAE,gBAAgB,EACxB,OAAO,GAAE,sBAA2B,GACrC,OAAO,CAAC,UAAU,CAAC,CAiDrB;AAWD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,QAQvF"}
|
|
@@ -2,9 +2,9 @@ function getRequestPayload(c) {
|
|
|
2
2
|
return c.req.method === 'POST' ? c.req.json() : Promise.resolve(undefined);
|
|
3
3
|
}
|
|
4
4
|
const builders = {
|
|
5
|
-
async tools(pkg, config,
|
|
5
|
+
async tools(pkg, config, options) {
|
|
6
6
|
const { tools: toolCollections = [], skills: skillCollections = [] } = config;
|
|
7
|
-
const filterContext =
|
|
7
|
+
const filterContext = options.toolUseContext;
|
|
8
8
|
// Aggregate all tools from all collections
|
|
9
9
|
const allTools = toolCollections.flatMap((collection) => collection.getToolDefinitions(filterContext));
|
|
10
10
|
// same for skills
|
|
@@ -38,13 +38,21 @@ const builders = {
|
|
|
38
38
|
pkg.interactions = allInteractions;
|
|
39
39
|
},
|
|
40
40
|
async types(pkg, config) {
|
|
41
|
+
// A type's public id is its BARE name: stored objects reference it as the portable
|
|
42
|
+
// `app:<app>:<type>` string, so the in-code collection (a code-organization grouping,
|
|
43
|
+
// unlike tool/skill collections which are semantic) must NOT leak into the id.
|
|
44
|
+
// Names must therefore be unique across collections — fail the package build otherwise.
|
|
41
45
|
const allTypes = [];
|
|
46
|
+
const seen = new Map();
|
|
42
47
|
for (const coll of config.types || []) {
|
|
43
48
|
for (const type of coll.types) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
const existing = seen.get(type.name);
|
|
50
|
+
if (existing) {
|
|
51
|
+
throw new Error(`Duplicate content type name '${type.name}' (collections '${existing}' and '${coll.name}'). ` +
|
|
52
|
+
`Type names must be unique across collections so the portable 'app:<app>:${type.name}' ref resolves.`);
|
|
53
|
+
}
|
|
54
|
+
seen.set(type.name, coll.name);
|
|
55
|
+
allTypes.push({ ...type, id: type.name });
|
|
48
56
|
}
|
|
49
57
|
}
|
|
50
58
|
pkg.types = allTypes;
|
|
@@ -63,6 +71,19 @@ const builders = {
|
|
|
63
71
|
path: `${basePath}/${coll.name}/${ref.name}`,
|
|
64
72
|
})));
|
|
65
73
|
},
|
|
74
|
+
async dashboards(pkg, config) {
|
|
75
|
+
const seen = new Set();
|
|
76
|
+
const dashboards = [];
|
|
77
|
+
for (const dashboard of config.dashboards || []) {
|
|
78
|
+
if (seen.has(dashboard.id)) {
|
|
79
|
+
console.warn(`[app-package] Duplicate dashboard id "${dashboard.id}", skipping`);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
seen.add(dashboard.id);
|
|
83
|
+
dashboards.push(dashboard);
|
|
84
|
+
}
|
|
85
|
+
pkg.dashboards = dashboards;
|
|
86
|
+
},
|
|
66
87
|
async widgets(pkg, config) {
|
|
67
88
|
const { skills: skillCollections = [] } = config;
|
|
68
89
|
const widgets = {};
|
|
@@ -79,10 +100,10 @@ const builders = {
|
|
|
79
100
|
}
|
|
80
101
|
pkg.widgets = widgets;
|
|
81
102
|
},
|
|
82
|
-
async ui(pkg, config,
|
|
103
|
+
async ui(pkg, config, options) {
|
|
83
104
|
if (config.uiConfig) {
|
|
84
105
|
pkg.ui = { ...config.uiConfig };
|
|
85
|
-
const origin =
|
|
106
|
+
const origin = options.origin || 'http://localhost';
|
|
86
107
|
pkg.ui.src = new URL(pkg.ui.src, origin).toString();
|
|
87
108
|
if (!pkg.ui.isolation) {
|
|
88
109
|
pkg.ui.isolation = 'shadow';
|
|
@@ -104,51 +125,65 @@ const builders = {
|
|
|
104
125
|
pkg.activities = allActivities;
|
|
105
126
|
},
|
|
106
127
|
};
|
|
107
|
-
|
|
108
|
-
const
|
|
128
|
+
function normalizeScopes(scope) {
|
|
129
|
+
const values = Array.isArray(scope) ? scope : typeof scope === 'string' ? scope.split(',') : [scope || 'all'];
|
|
130
|
+
return new Set(values.filter(Boolean));
|
|
131
|
+
}
|
|
132
|
+
export async function buildAppPackage(config, options = {}) {
|
|
109
133
|
const pkg = {};
|
|
110
|
-
const scopes =
|
|
111
|
-
// TODO build pkg based on the query param scope
|
|
134
|
+
const scopes = normalizeScopes(options.scope);
|
|
112
135
|
if (scopes.has('all')) {
|
|
113
|
-
await builders.tools(pkg, config,
|
|
114
|
-
await builders.interactions(pkg, config,
|
|
115
|
-
await builders.types(pkg, config,
|
|
116
|
-
await builders.processes(pkg, config,
|
|
117
|
-
await builders.templates(pkg, config,
|
|
118
|
-
await builders.
|
|
119
|
-
await builders.
|
|
120
|
-
await builders.
|
|
121
|
-
await builders.
|
|
136
|
+
await builders.tools(pkg, config, options);
|
|
137
|
+
await builders.interactions(pkg, config, options);
|
|
138
|
+
await builders.types(pkg, config, options);
|
|
139
|
+
await builders.processes(pkg, config, options);
|
|
140
|
+
await builders.templates(pkg, config, options);
|
|
141
|
+
await builders.dashboards(pkg, config, options);
|
|
142
|
+
await builders.widgets(pkg, config, options);
|
|
143
|
+
await builders.ui(pkg, config, options);
|
|
144
|
+
await builders.settings(pkg, config, options);
|
|
145
|
+
await builders.activities(pkg, config, options);
|
|
122
146
|
}
|
|
123
147
|
else {
|
|
124
148
|
if (scopes.has('tools')) {
|
|
125
|
-
await builders.tools(pkg, config,
|
|
149
|
+
await builders.tools(pkg, config, options);
|
|
126
150
|
}
|
|
127
151
|
if (scopes.has('interactions')) {
|
|
128
|
-
await builders.interactions(pkg, config,
|
|
152
|
+
await builders.interactions(pkg, config, options);
|
|
129
153
|
}
|
|
130
154
|
if (scopes.has('types')) {
|
|
131
|
-
await builders.types(pkg, config,
|
|
155
|
+
await builders.types(pkg, config, options);
|
|
132
156
|
}
|
|
133
157
|
if (scopes.has('processes')) {
|
|
134
|
-
await builders.processes(pkg, config,
|
|
158
|
+
await builders.processes(pkg, config, options);
|
|
135
159
|
}
|
|
136
160
|
if (scopes.has('templates')) {
|
|
137
|
-
await builders.templates(pkg, config,
|
|
161
|
+
await builders.templates(pkg, config, options);
|
|
162
|
+
}
|
|
163
|
+
if (scopes.has('dashboards')) {
|
|
164
|
+
await builders.dashboards(pkg, config, options);
|
|
138
165
|
}
|
|
139
166
|
if (scopes.has('widgets')) {
|
|
140
|
-
await builders.widgets(pkg, config,
|
|
167
|
+
await builders.widgets(pkg, config, options);
|
|
141
168
|
}
|
|
142
169
|
if (scopes.has('ui')) {
|
|
143
|
-
await builders.ui(pkg, config,
|
|
170
|
+
await builders.ui(pkg, config, options);
|
|
144
171
|
}
|
|
145
172
|
if (scopes.has('settings')) {
|
|
146
|
-
await builders.settings(pkg, config,
|
|
173
|
+
await builders.settings(pkg, config, options);
|
|
147
174
|
}
|
|
148
175
|
if (scopes.has('activities')) {
|
|
149
|
-
await builders.activities(pkg, config,
|
|
176
|
+
await builders.activities(pkg, config, options);
|
|
150
177
|
}
|
|
151
178
|
}
|
|
179
|
+
return pkg;
|
|
180
|
+
}
|
|
181
|
+
async function handlePackageRequest(c, config) {
|
|
182
|
+
const pkg = await buildAppPackage(config, {
|
|
183
|
+
scope: c.req.query('scope') || 'all',
|
|
184
|
+
origin: new URL(c.req.url).origin,
|
|
185
|
+
toolUseContext: await getRequestPayload(c),
|
|
186
|
+
});
|
|
152
187
|
return c.json(pkg);
|
|
153
188
|
}
|
|
154
189
|
export function createPackageRoute(app, basePath, config) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-package.js","sourceRoot":"","sources":["../../src/server/app-package.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app-package.js","sourceRoot":"","sources":["../../src/server/app-package.ts"],"names":[],"mappings":"AAcA,SAAS,iBAAiB,CAAI,CAAU;IACpC,OAAO,CAAC,CAAC,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAK,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClF,CAAC;AAUD,MAAM,QAAQ,GAA+D;IACzE,KAAK,CAAC,KAAK,CAAC,GAAe,EAAE,MAAwB,EAAE,OAA+B;QAClF,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,EAAE,EAAE,MAAM,EAAE,gBAAgB,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;QAE9E,MAAM,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;QAE7C,2CAA2C;QAC3C,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,CAAC;QAEvG,kBAAkB;QACl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,IAAI,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,GAAS,EAAE,QAAgB,EAAE,MAAwB;IACpF,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAU,EAAE,EAAE;QAC7B,OAAO,oBAAoB,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAU,EAAE,EAAE;QAC9B,OAAO,oBAAoB,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../src/server/content-types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,IAAI,EAAE,MAAM,MAAM,CAAC;AAI1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../src/server/content-types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,IAAI,EAAE,MAAM,MAAM,CAAC;AAI1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,QAmF5F"}
|
|
@@ -4,12 +4,14 @@ import { HTTPException } from 'hono/http-exception';
|
|
|
4
4
|
import { toPathName } from '../utils.js';
|
|
5
5
|
export function createContentTypesRoute(app, basePath, config) {
|
|
6
6
|
const { types = [] } = config;
|
|
7
|
-
// GET /api/types - Returns all
|
|
7
|
+
// GET /api/types - Returns all content types from all collections.
|
|
8
|
+
// A type's public id is its declared BARE name, verbatim (`app:<app>:<type>` once
|
|
9
|
+
// app-prefixed): collections organize code, they are not part of the type identity.
|
|
8
10
|
app.get(basePath, (c) => {
|
|
9
11
|
const allTypes = [];
|
|
10
12
|
for (const coll of types) {
|
|
11
13
|
for (const type of coll.types) {
|
|
12
|
-
allTypes.push({ ...type, id:
|
|
14
|
+
allTypes.push({ ...type, id: type.name });
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
return c.json({
|
|
@@ -27,20 +29,48 @@ export function createContentTypesRoute(app, basePath, config) {
|
|
|
27
29
|
for (const coll of types) {
|
|
28
30
|
app.route(`${basePath}/${coll.name}`, createContentTypeEndpoints(coll));
|
|
29
31
|
}
|
|
30
|
-
// GET /api/types/:name - Direct access to content type
|
|
32
|
+
// GET /api/types/:name - Direct access to content type.
|
|
33
|
+
// Canonical form is the BARE type name (`<type>`), matching the portable
|
|
34
|
+
// `app:<app>:<type>` ref convention used by objects.create/search — the
|
|
35
|
+
// collection is an in-code grouping, not part of the type's public id.
|
|
36
|
+
// `<collection>:<type>` is also accepted as a backward-compatible alias.
|
|
31
37
|
app.get(`${basePath}/:name`, async (c) => {
|
|
32
38
|
const name = c.req.param('name');
|
|
33
39
|
const parts = name.split(':');
|
|
40
|
+
if (parts.length === 1) {
|
|
41
|
+
// Match the declared name verbatim; fall back to the toPathName variant for
|
|
42
|
+
// leniency with legacy refs that used the path-mangled form.
|
|
43
|
+
const matches = types.flatMap((coll) => coll.types
|
|
44
|
+
.filter((t) => t.name === name || toPathName(t.name) === name)
|
|
45
|
+
.map((t) => ({ coll, type: t })));
|
|
46
|
+
if (matches.length === 1) {
|
|
47
|
+
return c.json({ ...matches[0].type, id: matches[0].type.name });
|
|
48
|
+
}
|
|
49
|
+
if (matches.length > 1) {
|
|
50
|
+
const colls = matches.map((m) => m.coll.name).join(', ');
|
|
51
|
+
throw new HTTPException(409, {
|
|
52
|
+
message: `Ambiguous content type name '${name}': defined in collections ${colls}. ` +
|
|
53
|
+
'Type names must be unique across collections so the portable ' +
|
|
54
|
+
`'app:<app>:${name}' ref resolves; rename one of them, or address it as '<collection>:<type>'.`,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
throw new HTTPException(404, {
|
|
58
|
+
message: `No content type found with name: ${name}`,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
34
61
|
if (parts.length !== 2) {
|
|
35
62
|
throw new HTTPException(400, {
|
|
36
|
-
message: "Invalid content type name. Expected
|
|
63
|
+
message: "Invalid content type name. Expected '<type>' or 'collection:type'",
|
|
37
64
|
});
|
|
38
65
|
}
|
|
39
66
|
const collName = parts[0];
|
|
40
|
-
const typeName =
|
|
41
|
-
const ctype = types
|
|
67
|
+
const typeName = parts[1];
|
|
68
|
+
const ctype = types
|
|
69
|
+
.find((t) => t.name === collName)
|
|
70
|
+
?.types.find((t) => t.name === typeName || toPathName(t.name) === toPathName(typeName));
|
|
42
71
|
if (ctype) {
|
|
43
|
-
|
|
72
|
+
// Alias lookup still returns the canonical bare id.
|
|
73
|
+
return c.json({ ...ctype, id: ctype.name });
|
|
44
74
|
}
|
|
45
75
|
throw new HTTPException(404, {
|
|
46
76
|
message: `No content type found with name: ${name}`,
|
|
@@ -50,11 +80,11 @@ export function createContentTypesRoute(app, basePath, config) {
|
|
|
50
80
|
function createContentTypeEndpoints(coll) {
|
|
51
81
|
const endpoint = new Hono();
|
|
52
82
|
endpoint.get('/', (c) => {
|
|
53
|
-
return c.json(coll.types.map((t) => ({ ...t, id:
|
|
83
|
+
return c.json(coll.types.map((t) => ({ ...t, id: t.name })));
|
|
54
84
|
});
|
|
55
85
|
endpoint.get('/:name', (c) => {
|
|
56
86
|
const name = c.req.param('name');
|
|
57
|
-
const ctype = coll.types.find((t) => toPathName(t.name) === name);
|
|
87
|
+
const ctype = coll.types.find((t) => t.name === name || toPathName(t.name) === name);
|
|
58
88
|
if (!ctype) {
|
|
59
89
|
throw new HTTPException(404, {
|
|
60
90
|
message: `No content type found with name: ${name}`,
|
|
@@ -62,7 +92,7 @@ function createContentTypeEndpoints(coll) {
|
|
|
62
92
|
}
|
|
63
93
|
return c.json({
|
|
64
94
|
...ctype,
|
|
65
|
-
id:
|
|
95
|
+
id: ctype.name,
|
|
66
96
|
});
|
|
67
97
|
});
|
|
68
98
|
return endpoint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-types.js","sourceRoot":"","sources":["../../src/server/content-types.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAG/D,OAAO,EAAgB,IAAI,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,UAAU,uBAAuB,CAAC,GAAS,EAAE,QAAgB,EAAE,MAAwB;IACzF,MAAM,EAAE,KAAK,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;IAE9B,
|
|
1
|
+
{"version":3,"file":"content-types.js","sourceRoot":"","sources":["../../src/server/content-types.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAG/D,OAAO,EAAgB,IAAI,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,UAAU,uBAAuB,CAAC,GAAS,EAAE,QAAgB,EAAE,MAAwB;IACzF,MAAM,EAAE,KAAK,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;IAE9B,mEAAmE;IACnE,kFAAkF;IAClF,oFAAoF;IACpF,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;QACpB,MAAM,QAAQ,GAA2B,EAAE,CAAC;QAE5C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAA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,KAAK,IAAI,CAAC,CAAC;QACrF,IAAI,CAAC,KAAK,EAAE,CAAC;YACT,MAAM,IAAI,aAAa,CAAC,GAAG,EAAE;gBACzB,OAAO,EAAE,oCAAoC,IAAI,EAAE;aACtD,CAAC,CAAC;QACP,CAAC;QACD,OAAO,CAAC,CAAC,IAAI,CAAC;YACV,GAAG,KAAK;YACR,EAAE,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboards.d.ts","sourceRoot":"","sources":["../../src/server/dashboards.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAEjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,QAqB1F"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { HTTPException } from 'hono/http-exception';
|
|
2
|
+
export function createDashboardsRoute(app, basePath, config) {
|
|
3
|
+
const { dashboards = [] } = config;
|
|
4
|
+
app.get(basePath, (c) => {
|
|
5
|
+
return c.json({
|
|
6
|
+
title: 'All Dashboards',
|
|
7
|
+
description: 'All available dashboard definitions',
|
|
8
|
+
dashboards,
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
app.get(`${basePath}/:id`, (c) => {
|
|
12
|
+
const id = c.req.param('id');
|
|
13
|
+
const dashboard = findDashboard(dashboards, id);
|
|
14
|
+
if (!dashboard) {
|
|
15
|
+
throw new HTTPException(404, {
|
|
16
|
+
message: `No dashboard found with id: ${id}`,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return c.json(dashboard);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function findDashboard(dashboards, id) {
|
|
23
|
+
return dashboards.find((dashboard) => dashboard.id === id || dashboard.name === id || dashboard.title === id);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=dashboards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboards.js","sourceRoot":"","sources":["../../src/server/dashboards.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,MAAM,UAAU,qBAAqB,CAAC,GAAS,EAAE,QAAgB,EAAE,MAAwB;IACvF,MAAM,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;IAEnC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;QACpB,OAAO,CAAC,CAAC,IAAI,CAAC;YACV,KAAK,EAAE,gBAAgB;YACvB,WAAW,EAAE,qCAAqC;YAClD,UAAU;SACb,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,GAAG,CAAC,GAAG,QAAQ,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE;QAC7B,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,MAAM,SAAS,GAAG,aAAa,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,MAAM,IAAI,aAAa,CAAC,GAAG,EAAE;gBACzB,OAAO,EAAE,+BAA+B,EAAE,EAAE;aAC/C,CAAC,CAAC;QACP,CAAC;QACD,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,aAAa,CAAC,UAAoC,EAAE,EAAU;IACnE,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,SAAS,CAAC,IAAI,KAAK,EAAE,IAAI,SAAS,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC;AAClH,CAAC"}
|
package/lib/server/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JSONSchema } from '@llumiverse/common';
|
|
2
|
-
import type { AppUIConfig, InCodeProcessDefinition, ProjectConfiguration } from '@vertesia/common';
|
|
2
|
+
import type { AppDashboardDefinition, AppUIConfig, InCodeProcessDefinition, ProjectConfiguration } from '@vertesia/common';
|
|
3
3
|
import type { Context } from 'hono';
|
|
4
4
|
import type { ActivityCollection } from '../ActivityCollection.js';
|
|
5
5
|
import type { AuthSession } from '../auth.js';
|
|
@@ -60,6 +60,10 @@ export interface ToolServerConfig {
|
|
|
60
60
|
* Process definitions to expose as app-contributed processes.
|
|
61
61
|
*/
|
|
62
62
|
processes?: InCodeProcessDefinition[];
|
|
63
|
+
/**
|
|
64
|
+
* Dashboard definitions to expose as app-contributed dashboards.
|
|
65
|
+
*/
|
|
66
|
+
dashboards?: AppDashboardDefinition[];
|
|
63
67
|
/**
|
|
64
68
|
* Skill collections to expose
|
|
65
69
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EACR,sBAAsB,EACtB,WAAW,EACX,uBAAuB,EACvB,oBAAoB,EACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACn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C;IACjC;;OAEG;IACH,SAAS,CAAC,EAAE,uBAAuB,EAAE,CAAC;IACtC;;OAEG;IACH,UAAU,CAAC,EAAE,sBAAsB,EAAE,CAAC;IACtC;;OAEG;IACH,MAAM,CAAC,EAAE,eAAe,EAAE,CAAC;IAC3B;;OAEG;IACH,SAAS,CAAC,EAAE,2BAA2B,EAAE,CAAC;IAC1C;;OAEG;IACH,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAEnC;;OAEG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,EAAE,WAAW,CAAC;IAEvB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,CAAC,aAAa,EAAE,oBAAoB,KAAK,OAAO,CAAC;CACjE"}
|
package/lib/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAe1C,OAAO,KAAK,EAAe,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAcvE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAmH/D;AAID;;;;GAIG;AACH,wBAAgB,eAAe,CAC3B,MAAM,EAAE,gBAAgB,GAAG;IACvB,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC;CAC5F,GACF,IAAI,CAQN"}
|
package/lib/server.js
CHANGED
|
@@ -5,6 +5,7 @@ import { z } from 'zod';
|
|
|
5
5
|
import { createActivitiesRoute } from './server/activities.js';
|
|
6
6
|
import { createPackageRoute } from './server/app-package.js';
|
|
7
7
|
import { createContentTypesRoute } from './server/content-types.js';
|
|
8
|
+
import { createDashboardsRoute } from './server/dashboards.js';
|
|
8
9
|
import { createInteractionsRoute } from './server/interactions.js';
|
|
9
10
|
import { createMcpRoute } from './server/mcp.js';
|
|
10
11
|
import { createProcessesRoute } from './server/processes.js';
|
|
@@ -38,7 +39,7 @@ const ToolExecutionPayloadSchema = z.object({
|
|
|
38
39
|
* ```
|
|
39
40
|
*/
|
|
40
41
|
export function createToolServer(config) {
|
|
41
|
-
const { prefix = '/api', tools = [], interactions = [], skills = [], templates = [], activities = [], mcpProviders = [], disableHtml = false, } = config;
|
|
42
|
+
const { prefix = '/api', tools = [], interactions = [], skills = [], templates = [], activities = [], dashboards = [], mcpProviders = [], disableHtml = false, } = config;
|
|
42
43
|
const app = new Hono();
|
|
43
44
|
// Add CORS middleware globally
|
|
44
45
|
app.use('*', cors({ origin: '*', allowMethods: ['GET', 'POST', 'OPTIONS'] }));
|
|
@@ -83,6 +84,7 @@ export function createToolServer(config) {
|
|
|
83
84
|
interactions: interactions.map((col) => `${prefix}/interactions/${col.name}`),
|
|
84
85
|
templates: templates.map((col) => `${prefix}/templates/${col.name}`),
|
|
85
86
|
processes: `${prefix}/processes`,
|
|
87
|
+
dashboards: dashboards.length > 0 ? `${prefix}/dashboards` : undefined,
|
|
86
88
|
activities: activities.map((col) => `${prefix}/activities/${col.name}`),
|
|
87
89
|
mcp: mcpProviders.map((p) => `${prefix}/mcp/${p.name}`),
|
|
88
90
|
},
|
|
@@ -97,6 +99,7 @@ export function createToolServer(config) {
|
|
|
97
99
|
createTemplatesRoute(app, `${prefix}/templates`, config);
|
|
98
100
|
createContentTypesRoute(app, `${prefix}/types`, config);
|
|
99
101
|
createProcessesRoute(app, `${prefix}/processes`, config);
|
|
102
|
+
createDashboardsRoute(app, `${prefix}/dashboards`, config);
|
|
100
103
|
createMcpRoute(app, `${prefix}/mcp`, config);
|
|
101
104
|
// Global error handler - returns ToolExecutionResponseError format
|
|
102
105
|
app.onError((err, c) => {
|
package/lib/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,IAAI,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGzD,oCAAoC;AACpC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,EAAE,E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;YACvC,MAAM,EAAE,GAAG;YACX,KAAK,EAAE,cAAc,CAAC,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE;YACjD,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS;SAC/D,EACD,GAAG,CACN,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACf,CAAC;AAED,yDAAyD;AAEzD;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC3B,MAEC;IAED,MAAM,GAAG,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAErC,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;QACvB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vertesia/tools-sdk",
|
|
3
|
-
"version": "1.5.0-dev.
|
|
3
|
+
"version": "1.5.0-dev.20260717.131047Z",
|
|
4
4
|
"description": "Tools SDK - utilities for building remote tools",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"@vertesia/tsconfig": "0.1.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"hono": "^4.12.
|
|
26
|
+
"hono": "^4.12.28"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"jose": "^6.2.3",
|
|
30
30
|
"zod": "^4.4.3",
|
|
31
|
-
"@
|
|
32
|
-
"@vertesia/common": "1.5.0-dev.
|
|
33
|
-
"@
|
|
31
|
+
"@vertesia/client": "1.5.0-dev.20260717.131047Z",
|
|
32
|
+
"@vertesia/common": "1.5.0-dev.20260717.131047Z",
|
|
33
|
+
"@llumiverse/common": "1.5.0-dev.20260713.114357Z"
|
|
34
34
|
},
|
|
35
35
|
"repository": {
|
|
36
36
|
"type": "git",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"agents",
|
|
47
47
|
"typescript"
|
|
48
48
|
],
|
|
49
|
+
"gitHead": "8aaad228827b2927db8e6aa75b27bfac90fec36f",
|
|
49
50
|
"scripts": {
|
|
50
51
|
"lint": "biome lint src",
|
|
51
52
|
"test": "vitest run",
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,8 @@ export { copyRuntimeAssets } from './copy-assets.js';
|
|
|
5
5
|
export * from './InteractionCollection.js';
|
|
6
6
|
export * from './RenderingTemplateCollection.js';
|
|
7
7
|
export * from './SkillCollection.js';
|
|
8
|
+
export type { BuildAppPackageOptions } from './server/app-package.js';
|
|
9
|
+
export { buildAppPackage } from './server/app-package.js';
|
|
8
10
|
export * from './server/types.js';
|
|
9
11
|
export * from './server.js';
|
|
10
12
|
export * from './site/templates.js';
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { PromptRole } from '@llumiverse/common';
|
|
2
|
+
import { PROCESS_DEFINITION_FORMAT_VERSION, TemplateType } from '@vertesia/common';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { ContentTypesCollection } from '../ContentTypesCollection.js';
|
|
5
|
+
import { InteractionCollection } from '../InteractionCollection.js';
|
|
6
|
+
import { buildAppPackage } from './app-package.js';
|
|
7
|
+
import type { ToolServerConfig } from './types.js';
|
|
8
|
+
|
|
9
|
+
describe('buildAppPackage', () => {
|
|
10
|
+
it('builds the same package artifact inventory used by the package route', async () => {
|
|
11
|
+
const config = {
|
|
12
|
+
interactions: [
|
|
13
|
+
new InteractionCollection({
|
|
14
|
+
name: 'claims',
|
|
15
|
+
interactions: [
|
|
16
|
+
{
|
|
17
|
+
name: 'review',
|
|
18
|
+
title: 'Review Claim',
|
|
19
|
+
prompts: [
|
|
20
|
+
{
|
|
21
|
+
role: PromptRole.user,
|
|
22
|
+
content: '{{user_prompt}}',
|
|
23
|
+
content_type: TemplateType.handlebars,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
types: [
|
|
31
|
+
new ContentTypesCollection({
|
|
32
|
+
name: 'claims',
|
|
33
|
+
types: [
|
|
34
|
+
{
|
|
35
|
+
name: 'claim',
|
|
36
|
+
object_schema: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {
|
|
39
|
+
status: { type: 'string' },
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
}),
|
|
45
|
+
],
|
|
46
|
+
processes: [
|
|
47
|
+
{
|
|
48
|
+
id: 'claims:intake',
|
|
49
|
+
name: 'Claims Intake',
|
|
50
|
+
definition: {
|
|
51
|
+
format_version: PROCESS_DEFINITION_FORMAT_VERSION,
|
|
52
|
+
process: 'claims_intake',
|
|
53
|
+
initial: 'done',
|
|
54
|
+
context: {
|
|
55
|
+
schema: {
|
|
56
|
+
type: 'object',
|
|
57
|
+
additionalProperties: true,
|
|
58
|
+
},
|
|
59
|
+
initial: {},
|
|
60
|
+
},
|
|
61
|
+
nodes: {
|
|
62
|
+
done: { type: 'final', title: 'Done' },
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
dashboards: [
|
|
68
|
+
{
|
|
69
|
+
id: 'claims:ops',
|
|
70
|
+
title: 'Claims Ops',
|
|
71
|
+
spec: {},
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
uiConfig: {
|
|
75
|
+
src: '/lib/plugin.js',
|
|
76
|
+
available_in: ['app_portal'],
|
|
77
|
+
},
|
|
78
|
+
} satisfies ToolServerConfig;
|
|
79
|
+
|
|
80
|
+
const pkg = await buildAppPackage(config, {
|
|
81
|
+
origin: 'https://apps.example.test',
|
|
82
|
+
scope: 'all',
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
expect(pkg.interactions?.map((interaction) => interaction.id)).toEqual(['claims:review']);
|
|
86
|
+
expect(pkg.types?.map((type) => type.id)).toEqual(['claim']);
|
|
87
|
+
expect(pkg.processes?.map((process) => process.id)).toEqual(['claims:intake']);
|
|
88
|
+
expect(pkg.dashboards?.map((dashboard) => dashboard.id)).toEqual(['claims:ops']);
|
|
89
|
+
expect(pkg.ui?.src).toBe('https://apps.example.test/lib/plugin.js');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('honors package scopes', async () => {
|
|
93
|
+
const config = {
|
|
94
|
+
interactions: [
|
|
95
|
+
new InteractionCollection({
|
|
96
|
+
name: 'claims',
|
|
97
|
+
interactions: [{ name: 'review', prompts: [] }],
|
|
98
|
+
}),
|
|
99
|
+
],
|
|
100
|
+
types: [
|
|
101
|
+
new ContentTypesCollection({
|
|
102
|
+
name: 'claims',
|
|
103
|
+
types: [{ name: 'claim' }],
|
|
104
|
+
}),
|
|
105
|
+
],
|
|
106
|
+
} satisfies ToolServerConfig;
|
|
107
|
+
|
|
108
|
+
const pkg = await buildAppPackage(config, { scope: 'types' });
|
|
109
|
+
|
|
110
|
+
expect(pkg.types?.map((type) => type.id)).toEqual(['claim']);
|
|
111
|
+
expect(pkg.interactions).toBeUndefined();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe('buildAppPackage type identity', () => {
|
|
116
|
+
it('exposes the bare type name as the public id (collections are code organization only)', async () => {
|
|
117
|
+
const config = {
|
|
118
|
+
types: [
|
|
119
|
+
new ContentTypesCollection({ name: 'claims', types: [{ name: 'claim' }] }),
|
|
120
|
+
new ContentTypesCollection({ name: 'audit', types: [{ name: 'audit_event' }] }),
|
|
121
|
+
],
|
|
122
|
+
} satisfies ToolServerConfig;
|
|
123
|
+
|
|
124
|
+
const pkg = await buildAppPackage(config, { scope: 'types' });
|
|
125
|
+
expect(pkg.types?.map((type) => type.id)).toEqual(['claim', 'audit_event']);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('fails the package build when a type name is duplicated across collections', async () => {
|
|
129
|
+
const config = {
|
|
130
|
+
types: [
|
|
131
|
+
new ContentTypesCollection({ name: 'claims', types: [{ name: 'claim' }] }),
|
|
132
|
+
new ContentTypesCollection({ name: 'legacy', types: [{ name: 'claim' }] }),
|
|
133
|
+
],
|
|
134
|
+
} satisfies ToolServerConfig;
|
|
135
|
+
|
|
136
|
+
await expect(buildAppPackage(config, { scope: 'types' })).rejects.toThrow(
|
|
137
|
+
/Duplicate content type name 'claim'/,
|
|
138
|
+
);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
AppDashboardDefinition,
|
|
2
3
|
AppPackage,
|
|
3
4
|
AppPackageScope,
|
|
4
5
|
AppWidgetInfo,
|
|
@@ -15,14 +16,19 @@ function getRequestPayload<T>(c: Context): Promise<T | undefined> {
|
|
|
15
16
|
return c.req.method === 'POST' ? c.req.json<T>() : Promise.resolve(undefined);
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
export interface BuildAppPackageOptions {
|
|
20
|
+
scope?: AppPackageScope | AppPackageScope[] | string;
|
|
21
|
+
origin?: string;
|
|
22
|
+
toolUseContext?: ToolUseContext;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type AppPackageBuilder = (pkg: AppPackage, config: ToolServerConfig, options: BuildAppPackageOptions) => Promise<void>;
|
|
26
|
+
|
|
27
|
+
const builders: Record<Exclude<AppPackageScope, 'all'>, AppPackageBuilder> = {
|
|
28
|
+
async tools(pkg: AppPackage, config: ToolServerConfig, options: BuildAppPackageOptions) {
|
|
23
29
|
const { tools: toolCollections = [], skills: skillCollections = [] } = config;
|
|
24
30
|
|
|
25
|
-
const filterContext =
|
|
31
|
+
const filterContext = options.toolUseContext;
|
|
26
32
|
|
|
27
33
|
// Aggregate all tools from all collections
|
|
28
34
|
const allTools = toolCollections.flatMap((collection) => collection.getToolDefinitions(filterContext));
|
|
@@ -59,13 +65,23 @@ const builders: Record<
|
|
|
59
65
|
pkg.interactions = allInteractions;
|
|
60
66
|
},
|
|
61
67
|
async types(pkg: AppPackage, config: ToolServerConfig) {
|
|
68
|
+
// A type's public id is its BARE name: stored objects reference it as the portable
|
|
69
|
+
// `app:<app>:<type>` string, so the in-code collection (a code-organization grouping,
|
|
70
|
+
// unlike tool/skill collections which are semantic) must NOT leak into the id.
|
|
71
|
+
// Names must therefore be unique across collections — fail the package build otherwise.
|
|
62
72
|
const allTypes: InCodeTypeDefinition[] = [];
|
|
73
|
+
const seen = new Map<string, string>();
|
|
63
74
|
for (const coll of config.types || []) {
|
|
64
75
|
for (const type of coll.types) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
const existing = seen.get(type.name);
|
|
77
|
+
if (existing) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
`Duplicate content type name '${type.name}' (collections '${existing}' and '${coll.name}'). ` +
|
|
80
|
+
`Type names must be unique across collections so the portable 'app:<app>:${type.name}' ref resolves.`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
seen.set(type.name, coll.name);
|
|
84
|
+
allTypes.push({ ...type, id: type.name });
|
|
69
85
|
}
|
|
70
86
|
}
|
|
71
87
|
pkg.types = allTypes;
|
|
@@ -86,6 +102,19 @@ const builders: Record<
|
|
|
86
102
|
})),
|
|
87
103
|
);
|
|
88
104
|
},
|
|
105
|
+
async dashboards(pkg: AppPackage, config: ToolServerConfig) {
|
|
106
|
+
const seen = new Set<string>();
|
|
107
|
+
const dashboards: AppDashboardDefinition[] = [];
|
|
108
|
+
for (const dashboard of config.dashboards || []) {
|
|
109
|
+
if (seen.has(dashboard.id)) {
|
|
110
|
+
console.warn(`[app-package] Duplicate dashboard id "${dashboard.id}", skipping`);
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
seen.add(dashboard.id);
|
|
114
|
+
dashboards.push(dashboard);
|
|
115
|
+
}
|
|
116
|
+
pkg.dashboards = dashboards;
|
|
117
|
+
},
|
|
89
118
|
async widgets(pkg: AppPackage, config: ToolServerConfig) {
|
|
90
119
|
const { skills: skillCollections = [] } = config;
|
|
91
120
|
const widgets: Record<string, AppWidgetInfo> = {};
|
|
@@ -102,10 +131,10 @@ const builders: Record<
|
|
|
102
131
|
}
|
|
103
132
|
pkg.widgets = widgets;
|
|
104
133
|
},
|
|
105
|
-
async ui(pkg: AppPackage, config: ToolServerConfig,
|
|
134
|
+
async ui(pkg: AppPackage, config: ToolServerConfig, options: BuildAppPackageOptions) {
|
|
106
135
|
if (config.uiConfig) {
|
|
107
136
|
pkg.ui = { ...config.uiConfig };
|
|
108
|
-
const origin =
|
|
137
|
+
const origin = options.origin || 'http://localhost';
|
|
109
138
|
pkg.ui.src = new URL(pkg.ui.src, origin).toString();
|
|
110
139
|
if (!pkg.ui.isolation) {
|
|
111
140
|
pkg.ui.isolation = 'shadow';
|
|
@@ -128,52 +157,71 @@ const builders: Record<
|
|
|
128
157
|
},
|
|
129
158
|
};
|
|
130
159
|
|
|
131
|
-
|
|
132
|
-
const
|
|
160
|
+
function normalizeScopes(scope: BuildAppPackageOptions['scope']): Set<AppPackageScope> {
|
|
161
|
+
const values = Array.isArray(scope) ? scope : typeof scope === 'string' ? scope.split(',') : [scope || 'all'];
|
|
162
|
+
return new Set(values.filter(Boolean) as AppPackageScope[]);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export async function buildAppPackage(
|
|
166
|
+
config: ToolServerConfig,
|
|
167
|
+
options: BuildAppPackageOptions = {},
|
|
168
|
+
): Promise<AppPackage> {
|
|
133
169
|
const pkg: AppPackage = {};
|
|
134
170
|
|
|
135
|
-
const scopes =
|
|
136
|
-
// TODO build pkg based on the query param scope
|
|
171
|
+
const scopes = normalizeScopes(options.scope);
|
|
137
172
|
if (scopes.has('all')) {
|
|
138
|
-
await builders.tools(pkg, config,
|
|
139
|
-
await builders.interactions(pkg, config,
|
|
140
|
-
await builders.types(pkg, config,
|
|
141
|
-
await builders.processes(pkg, config,
|
|
142
|
-
await builders.templates(pkg, config,
|
|
143
|
-
await builders.
|
|
144
|
-
await builders.
|
|
145
|
-
await builders.
|
|
146
|
-
await builders.
|
|
173
|
+
await builders.tools(pkg, config, options);
|
|
174
|
+
await builders.interactions(pkg, config, options);
|
|
175
|
+
await builders.types(pkg, config, options);
|
|
176
|
+
await builders.processes(pkg, config, options);
|
|
177
|
+
await builders.templates(pkg, config, options);
|
|
178
|
+
await builders.dashboards(pkg, config, options);
|
|
179
|
+
await builders.widgets(pkg, config, options);
|
|
180
|
+
await builders.ui(pkg, config, options);
|
|
181
|
+
await builders.settings(pkg, config, options);
|
|
182
|
+
await builders.activities(pkg, config, options);
|
|
147
183
|
} else {
|
|
148
184
|
if (scopes.has('tools')) {
|
|
149
|
-
await builders.tools(pkg, config,
|
|
185
|
+
await builders.tools(pkg, config, options);
|
|
150
186
|
}
|
|
151
187
|
if (scopes.has('interactions')) {
|
|
152
|
-
await builders.interactions(pkg, config,
|
|
188
|
+
await builders.interactions(pkg, config, options);
|
|
153
189
|
}
|
|
154
190
|
if (scopes.has('types')) {
|
|
155
|
-
await builders.types(pkg, config,
|
|
191
|
+
await builders.types(pkg, config, options);
|
|
156
192
|
}
|
|
157
193
|
if (scopes.has('processes')) {
|
|
158
|
-
await builders.processes(pkg, config,
|
|
194
|
+
await builders.processes(pkg, config, options);
|
|
159
195
|
}
|
|
160
196
|
if (scopes.has('templates')) {
|
|
161
|
-
await builders.templates(pkg, config,
|
|
197
|
+
await builders.templates(pkg, config, options);
|
|
198
|
+
}
|
|
199
|
+
if (scopes.has('dashboards')) {
|
|
200
|
+
await builders.dashboards(pkg, config, options);
|
|
162
201
|
}
|
|
163
202
|
if (scopes.has('widgets')) {
|
|
164
|
-
await builders.widgets(pkg, config,
|
|
203
|
+
await builders.widgets(pkg, config, options);
|
|
165
204
|
}
|
|
166
205
|
if (scopes.has('ui')) {
|
|
167
|
-
await builders.ui(pkg, config,
|
|
206
|
+
await builders.ui(pkg, config, options);
|
|
168
207
|
}
|
|
169
208
|
if (scopes.has('settings')) {
|
|
170
|
-
await builders.settings(pkg, config,
|
|
209
|
+
await builders.settings(pkg, config, options);
|
|
171
210
|
}
|
|
172
211
|
if (scopes.has('activities')) {
|
|
173
|
-
await builders.activities(pkg, config,
|
|
212
|
+
await builders.activities(pkg, config, options);
|
|
174
213
|
}
|
|
175
214
|
}
|
|
176
215
|
|
|
216
|
+
return pkg;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
async function handlePackageRequest(c: Context, config: ToolServerConfig) {
|
|
220
|
+
const pkg = await buildAppPackage(config, {
|
|
221
|
+
scope: c.req.query('scope') || 'all',
|
|
222
|
+
origin: new URL(c.req.url).origin,
|
|
223
|
+
toolUseContext: await getRequestPayload<ToolUseContext>(c),
|
|
224
|
+
});
|
|
177
225
|
return c.json(pkg);
|
|
178
226
|
}
|
|
179
227
|
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { ContentTypesCollection } from '../ContentTypesCollection.js';
|
|
4
|
+
import { createContentTypesRoute } from './content-types.js';
|
|
5
|
+
import type { ToolServerConfig } from './types.js';
|
|
6
|
+
|
|
7
|
+
function makeApp(config: ToolServerConfig): Hono {
|
|
8
|
+
const app = new Hono();
|
|
9
|
+
createContentTypesRoute(app, '/api/types', config);
|
|
10
|
+
return app;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const config = {
|
|
14
|
+
types: [
|
|
15
|
+
new ContentTypesCollection({
|
|
16
|
+
name: 'contracts',
|
|
17
|
+
types: [{ name: 'contract' }, { name: 'review_note' }],
|
|
18
|
+
}),
|
|
19
|
+
new ContentTypesCollection({
|
|
20
|
+
name: 'audit',
|
|
21
|
+
types: [{ name: 'audit_event' }],
|
|
22
|
+
}),
|
|
23
|
+
],
|
|
24
|
+
} satisfies ToolServerConfig;
|
|
25
|
+
|
|
26
|
+
describe('content types route', () => {
|
|
27
|
+
it('lists all types with bare ids (collection is not part of the type identity)', async () => {
|
|
28
|
+
const res = await makeApp(config).request('/api/types');
|
|
29
|
+
expect(res.status).toBe(200);
|
|
30
|
+
const body = (await res.json()) as { types: Array<{ id: string }> };
|
|
31
|
+
expect(body.types.map((t) => t.id)).toEqual(['contract', 'review_note', 'audit_event']);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('resolves the canonical bare type name (the app:<app>:<type> ref convention)', async () => {
|
|
35
|
+
const res = await makeApp(config).request('/api/types/contract');
|
|
36
|
+
expect(res.status).toBe(200);
|
|
37
|
+
const body = (await res.json()) as { id: string; name: string };
|
|
38
|
+
expect(body.id).toBe('contract');
|
|
39
|
+
expect(body.name).toBe('contract');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('still resolves the legacy collection:type alias, returning the bare id', async () => {
|
|
43
|
+
const res = await makeApp(config).request('/api/types/contracts:contract');
|
|
44
|
+
expect(res.status).toBe(200);
|
|
45
|
+
const body = (await res.json()) as { id: string };
|
|
46
|
+
expect(body.id).toBe('contract');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('409s on an ambiguous bare name so the collision is loud, not silent', async () => {
|
|
50
|
+
const ambiguous = {
|
|
51
|
+
types: [
|
|
52
|
+
new ContentTypesCollection({ name: 'a', types: [{ name: 'note' }] }),
|
|
53
|
+
new ContentTypesCollection({ name: 'b', types: [{ name: 'note' }] }),
|
|
54
|
+
],
|
|
55
|
+
} satisfies ToolServerConfig;
|
|
56
|
+
const res = await makeApp(ambiguous).request('/api/types/note');
|
|
57
|
+
expect(res.status).toBe(409);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('404s for an unknown type name', async () => {
|
|
61
|
+
const res = await makeApp(config).request('/api/types/nope');
|
|
62
|
+
expect(res.status).toBe(404);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -10,13 +10,15 @@ import type { ToolServerConfig } from './types.js';
|
|
|
10
10
|
export function createContentTypesRoute(app: Hono, basePath: string, config: ToolServerConfig) {
|
|
11
11
|
const { types = [] } = config;
|
|
12
12
|
|
|
13
|
-
// GET /api/types - Returns all
|
|
13
|
+
// GET /api/types - Returns all content types from all collections.
|
|
14
|
+
// A type's public id is its declared BARE name, verbatim (`app:<app>:<type>` once
|
|
15
|
+
// app-prefixed): collections organize code, they are not part of the type identity.
|
|
14
16
|
app.get(basePath, (c) => {
|
|
15
17
|
const allTypes: InCodeTypeDefinition[] = [];
|
|
16
18
|
|
|
17
19
|
for (const coll of types) {
|
|
18
20
|
for (const type of coll.types) {
|
|
19
|
-
allTypes.push({ ...type, id:
|
|
21
|
+
allTypes.push({ ...type, id: type.name });
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
|
|
@@ -37,20 +39,51 @@ export function createContentTypesRoute(app: Hono, basePath: string, config: Too
|
|
|
37
39
|
app.route(`${basePath}/${coll.name}`, createContentTypeEndpoints(coll));
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
// GET /api/types/:name - Direct access to content type
|
|
42
|
+
// GET /api/types/:name - Direct access to content type.
|
|
43
|
+
// Canonical form is the BARE type name (`<type>`), matching the portable
|
|
44
|
+
// `app:<app>:<type>` ref convention used by objects.create/search — the
|
|
45
|
+
// collection is an in-code grouping, not part of the type's public id.
|
|
46
|
+
// `<collection>:<type>` is also accepted as a backward-compatible alias.
|
|
41
47
|
app.get(`${basePath}/:name`, async (c) => {
|
|
42
48
|
const name = c.req.param('name');
|
|
43
49
|
const parts = name.split(':');
|
|
50
|
+
if (parts.length === 1) {
|
|
51
|
+
// Match the declared name verbatim; fall back to the toPathName variant for
|
|
52
|
+
// leniency with legacy refs that used the path-mangled form.
|
|
53
|
+
const matches = types.flatMap((coll) =>
|
|
54
|
+
coll.types
|
|
55
|
+
.filter((t) => t.name === name || toPathName(t.name) === name)
|
|
56
|
+
.map((t) => ({ coll, type: t })),
|
|
57
|
+
);
|
|
58
|
+
if (matches.length === 1) {
|
|
59
|
+
return c.json({ ...matches[0].type, id: matches[0].type.name });
|
|
60
|
+
}
|
|
61
|
+
if (matches.length > 1) {
|
|
62
|
+
const colls = matches.map((m) => m.coll.name).join(', ');
|
|
63
|
+
throw new HTTPException(409, {
|
|
64
|
+
message:
|
|
65
|
+
`Ambiguous content type name '${name}': defined in collections ${colls}. ` +
|
|
66
|
+
'Type names must be unique across collections so the portable ' +
|
|
67
|
+
`'app:<app>:${name}' ref resolves; rename one of them, or address it as '<collection>:<type>'.`,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
throw new HTTPException(404, {
|
|
71
|
+
message: `No content type found with name: ${name}`,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
44
74
|
if (parts.length !== 2) {
|
|
45
75
|
throw new HTTPException(400, {
|
|
46
|
-
message: "Invalid content type name. Expected
|
|
76
|
+
message: "Invalid content type name. Expected '<type>' or 'collection:type'",
|
|
47
77
|
});
|
|
48
78
|
}
|
|
49
79
|
const collName = parts[0];
|
|
50
|
-
const typeName =
|
|
51
|
-
const ctype = types
|
|
80
|
+
const typeName = parts[1];
|
|
81
|
+
const ctype = types
|
|
82
|
+
.find((t) => t.name === collName)
|
|
83
|
+
?.types.find((t) => t.name === typeName || toPathName(t.name) === toPathName(typeName));
|
|
52
84
|
if (ctype) {
|
|
53
|
-
|
|
85
|
+
// Alias lookup still returns the canonical bare id.
|
|
86
|
+
return c.json({ ...ctype, id: ctype.name });
|
|
54
87
|
}
|
|
55
88
|
|
|
56
89
|
throw new HTTPException(404, {
|
|
@@ -63,12 +96,12 @@ function createContentTypeEndpoints(coll: ContentTypesCollection): Hono {
|
|
|
63
96
|
const endpoint = new Hono();
|
|
64
97
|
|
|
65
98
|
endpoint.get('/', (c: Context) => {
|
|
66
|
-
return c.json(coll.types.map((t) => ({ ...t, id:
|
|
99
|
+
return c.json(coll.types.map((t) => ({ ...t, id: t.name })));
|
|
67
100
|
});
|
|
68
101
|
|
|
69
102
|
endpoint.get('/:name', (c: Context) => {
|
|
70
103
|
const name = c.req.param('name');
|
|
71
|
-
const ctype = coll.types.find((t) => toPathName(t.name) === name);
|
|
104
|
+
const ctype = coll.types.find((t) => t.name === name || toPathName(t.name) === name);
|
|
72
105
|
if (!ctype) {
|
|
73
106
|
throw new HTTPException(404, {
|
|
74
107
|
message: `No content type found with name: ${name}`,
|
|
@@ -76,7 +109,7 @@ function createContentTypeEndpoints(coll: ContentTypesCollection): Hono {
|
|
|
76
109
|
}
|
|
77
110
|
return c.json({
|
|
78
111
|
...ctype,
|
|
79
|
-
id:
|
|
112
|
+
id: ctype.name,
|
|
80
113
|
});
|
|
81
114
|
});
|
|
82
115
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AppDashboardDefinition } from '@vertesia/common';
|
|
2
|
+
import type { Hono } from 'hono';
|
|
3
|
+
import { HTTPException } from 'hono/http-exception';
|
|
4
|
+
import type { ToolServerConfig } from './types.js';
|
|
5
|
+
|
|
6
|
+
export function createDashboardsRoute(app: Hono, basePath: string, config: ToolServerConfig) {
|
|
7
|
+
const { dashboards = [] } = config;
|
|
8
|
+
|
|
9
|
+
app.get(basePath, (c) => {
|
|
10
|
+
return c.json({
|
|
11
|
+
title: 'All Dashboards',
|
|
12
|
+
description: 'All available dashboard definitions',
|
|
13
|
+
dashboards,
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
app.get(`${basePath}/:id`, (c) => {
|
|
18
|
+
const id = c.req.param('id');
|
|
19
|
+
const dashboard = findDashboard(dashboards, id);
|
|
20
|
+
if (!dashboard) {
|
|
21
|
+
throw new HTTPException(404, {
|
|
22
|
+
message: `No dashboard found with id: ${id}`,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return c.json(dashboard);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function findDashboard(dashboards: AppDashboardDefinition[], id: string): AppDashboardDefinition | undefined {
|
|
30
|
+
return dashboards.find((dashboard) => dashboard.id === id || dashboard.name === id || dashboard.title === id);
|
|
31
|
+
}
|
package/src/server/types.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { JSONSchema } from '@llumiverse/common';
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
AppDashboardDefinition,
|
|
4
|
+
AppUIConfig,
|
|
5
|
+
InCodeProcessDefinition,
|
|
6
|
+
ProjectConfiguration,
|
|
7
|
+
} from '@vertesia/common';
|
|
3
8
|
import type { Context } from 'hono';
|
|
4
9
|
import type { ActivityCollection } from '../ActivityCollection.js';
|
|
5
10
|
import type { AuthSession } from '../auth.js';
|
|
@@ -63,6 +68,10 @@ export interface ToolServerConfig {
|
|
|
63
68
|
* Process definitions to expose as app-contributed processes.
|
|
64
69
|
*/
|
|
65
70
|
processes?: InCodeProcessDefinition[];
|
|
71
|
+
/**
|
|
72
|
+
* Dashboard definitions to expose as app-contributed dashboards.
|
|
73
|
+
*/
|
|
74
|
+
dashboards?: AppDashboardDefinition[];
|
|
66
75
|
/**
|
|
67
76
|
* Skill collections to expose
|
|
68
77
|
*/
|
package/src/server.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { z } from 'zod';
|
|
|
5
5
|
import { createActivitiesRoute } from './server/activities.js';
|
|
6
6
|
import { createPackageRoute } from './server/app-package.js';
|
|
7
7
|
import { createContentTypesRoute } from './server/content-types.js';
|
|
8
|
+
import { createDashboardsRoute } from './server/dashboards.js';
|
|
8
9
|
import { createInteractionsRoute } from './server/interactions.js';
|
|
9
10
|
import { createMcpRoute } from './server/mcp.js';
|
|
10
11
|
import { createProcessesRoute } from './server/processes.js';
|
|
@@ -49,6 +50,7 @@ export function createToolServer(config: ToolServerConfig): Hono {
|
|
|
49
50
|
skills = [],
|
|
50
51
|
templates = [],
|
|
51
52
|
activities = [],
|
|
53
|
+
dashboards = [],
|
|
52
54
|
mcpProviders = [],
|
|
53
55
|
disableHtml = false,
|
|
54
56
|
} = config;
|
|
@@ -100,6 +102,7 @@ export function createToolServer(config: ToolServerConfig): Hono {
|
|
|
100
102
|
interactions: interactions.map((col) => `${prefix}/interactions/${col.name}`),
|
|
101
103
|
templates: templates.map((col) => `${prefix}/templates/${col.name}`),
|
|
102
104
|
processes: `${prefix}/processes`,
|
|
105
|
+
dashboards: dashboards.length > 0 ? `${prefix}/dashboards` : undefined,
|
|
103
106
|
activities: activities.map((col) => `${prefix}/activities/${col.name}`),
|
|
104
107
|
mcp: mcpProviders.map((p) => `${prefix}/mcp/${p.name}`),
|
|
105
108
|
},
|
|
@@ -115,6 +118,7 @@ export function createToolServer(config: ToolServerConfig): Hono {
|
|
|
115
118
|
createTemplatesRoute(app, `${prefix}/templates`, config);
|
|
116
119
|
createContentTypesRoute(app, `${prefix}/types`, config);
|
|
117
120
|
createProcessesRoute(app, `${prefix}/processes`, config);
|
|
121
|
+
createDashboardsRoute(app, `${prefix}/dashboards`, config);
|
|
118
122
|
createMcpRoute(app, `${prefix}/mcp`, config);
|
|
119
123
|
|
|
120
124
|
// Global error handler - returns ToolExecutionResponseError format
|