@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/lib/cjs/ToolRegistry.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ToolNotFoundError = exports.ToolRegistry = void 0;
|
|
4
|
-
const http_exception_1 = require("hono/http-exception");
|
|
5
|
-
class ToolRegistry {
|
|
6
|
-
// The category name usinfg this registry
|
|
7
|
-
category;
|
|
8
|
-
registry = {};
|
|
9
|
-
constructor(category, tools = []) {
|
|
10
|
-
this.category = category;
|
|
11
|
-
for (const tool of tools) {
|
|
12
|
-
this.registry[tool.name] = tool;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Get tool definitions with optional filtering.
|
|
17
|
-
* @param options - Filtering options
|
|
18
|
-
* @returns Filtered tool definitions
|
|
19
|
-
*/
|
|
20
|
-
getDefinitions(context) {
|
|
21
|
-
const mapTool = (tool) => ({
|
|
22
|
-
url: `tools/${this.category}`,
|
|
23
|
-
name: tool.name,
|
|
24
|
-
description: tool.description,
|
|
25
|
-
input_schema: tool.input_schema,
|
|
26
|
-
category: this.category,
|
|
27
|
-
default: tool.default,
|
|
28
|
-
});
|
|
29
|
-
let tools = Object.values(this.registry);
|
|
30
|
-
if (context) {
|
|
31
|
-
tools = tools.filter(tool => {
|
|
32
|
-
return tool.isEnabled ? tool.isEnabled(context) : true;
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
return tools.map(mapTool);
|
|
36
|
-
}
|
|
37
|
-
getTool(name) {
|
|
38
|
-
const tool = this.registry[name];
|
|
39
|
-
if (tool === undefined) {
|
|
40
|
-
throw new ToolNotFoundError(name);
|
|
41
|
-
}
|
|
42
|
-
return tool;
|
|
43
|
-
}
|
|
44
|
-
getTools() {
|
|
45
|
-
return Object.values(this.registry);
|
|
46
|
-
}
|
|
47
|
-
registerTool(tool) {
|
|
48
|
-
this.registry[tool.name] = tool;
|
|
49
|
-
}
|
|
50
|
-
runTool(payload, context) {
|
|
51
|
-
const toolName = payload.tool_use.tool_name;
|
|
52
|
-
const toolUseId = payload.tool_use.id;
|
|
53
|
-
const runId = payload.metadata?.run_id;
|
|
54
|
-
console.log(`[ToolRegistry] Executing tool: ${toolName}`, {
|
|
55
|
-
toolUseId,
|
|
56
|
-
runId,
|
|
57
|
-
input: sanitizeInput(payload.tool_use.tool_input),
|
|
58
|
-
});
|
|
59
|
-
return this.getTool(toolName).run(payload, context);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.ToolRegistry = ToolRegistry;
|
|
63
|
-
class ToolNotFoundError extends http_exception_1.HTTPException {
|
|
64
|
-
constructor(name) {
|
|
65
|
-
super(404, { message: "Tool function not found: " + name });
|
|
66
|
-
this.name = "ToolNotFoundError";
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.ToolNotFoundError = ToolNotFoundError;
|
|
70
|
-
const SENSITIVE_KEYS = new Set([
|
|
71
|
-
'apikey', 'api_key', 'token', 'secret', 'password', 'credential', 'credentials',
|
|
72
|
-
'authorization', 'auth', 'key', 'private_key', 'access_token', 'refresh_token'
|
|
73
|
-
]);
|
|
74
|
-
function sanitizeInput(input) {
|
|
75
|
-
if (!input)
|
|
76
|
-
return null;
|
|
77
|
-
const sanitized = {};
|
|
78
|
-
for (const [key, value] of Object.entries(input)) {
|
|
79
|
-
const lowerKey = key.toLowerCase();
|
|
80
|
-
if (SENSITIVE_KEYS.has(lowerKey) || lowerKey.includes('key') || lowerKey.includes('token') || lowerKey.includes('secret')) {
|
|
81
|
-
sanitized[key] = '[REDACTED]';
|
|
82
|
-
}
|
|
83
|
-
else if (typeof value === 'string' && value.length > 50) {
|
|
84
|
-
sanitized[key] = value.slice(0, 50) + '...';
|
|
85
|
-
}
|
|
86
|
-
else if (typeof value === 'object' && value !== null) {
|
|
87
|
-
sanitized[key] = Array.isArray(value) ? `[Array(${value.length})]` : '[Object]';
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
sanitized[key] = value;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return sanitized;
|
|
94
|
-
}
|
|
95
|
-
//# sourceMappingURL=ToolRegistry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToolRegistry.js","sourceRoot":"","sources":["../../src/ToolRegistry.ts"],"names":[],"mappings":";;;AACA,wDAAoD;AAIpD,MAAa,YAAY;IAErB,yCAAyC;IACzC,QAAQ,CAAS;IACjB,QAAQ,GAA8B,EAAE,CAAC;IAEzC,YAAY,QAAgB,EAAE,QAAqB,EAAE;QACjD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACpC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,OAAwB;QACnC,MAAM,OAAO,GAAG,CAAC,IAAe,EAAuB,EAAE,CAAC,CAAC;YACvD,GAAG,EAAE,SAAS,IAAI,CAAC,QAAQ,EAAE;YAC7B,IAAI,EAAE,IAAI,CAAC,IAA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QAClC,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;YACxD,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC;QAChD,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACrD,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;QACpF,CAAC;aAAM,CAAC;YACJ,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC3B,CAAC;IACL,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
package/lib/cjs/auth.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AuthSession = void 0;
|
|
4
|
-
exports.getJwks = getJwks;
|
|
5
|
-
exports.verifyToken = verifyToken;
|
|
6
|
-
exports.authorize = authorize;
|
|
7
|
-
const client_1 = require("@vertesia/client");
|
|
8
|
-
const http_exception_1 = require("hono/http-exception");
|
|
9
|
-
const jose_1 = require("jose");
|
|
10
|
-
const cache = {};
|
|
11
|
-
async function getJwks(url) {
|
|
12
|
-
if (!cache[url]) {
|
|
13
|
-
console.log('JWKS cache miss for: ', url);
|
|
14
|
-
const jwks = await fetch(url).then(r => {
|
|
15
|
-
if (r.ok) {
|
|
16
|
-
return r.json();
|
|
17
|
-
}
|
|
18
|
-
throw new Error("Fetching jwks failed with code: " + r.status);
|
|
19
|
-
}).catch(err => {
|
|
20
|
-
throw new Error("Failed to fetch jwks: " + err.message);
|
|
21
|
-
});
|
|
22
|
-
cache[url] = (0, jose_1.createLocalJWKSet)(jwks);
|
|
23
|
-
}
|
|
24
|
-
return cache[url];
|
|
25
|
-
}
|
|
26
|
-
async function verifyToken(token) {
|
|
27
|
-
const decodedJwt = (0, jose_1.decodeJwt)(token);
|
|
28
|
-
if (!decodedJwt.iss) {
|
|
29
|
-
throw new Error("No issuer URL found in JWT");
|
|
30
|
-
}
|
|
31
|
-
if (!isAllowedIssuer(decodedJwt.iss)) {
|
|
32
|
-
throw new Error("Issuer is not allowed: " + decodedJwt.iss);
|
|
33
|
-
}
|
|
34
|
-
const jwks = await getJwks(`${decodedJwt.iss}/.well-known/jwks`);
|
|
35
|
-
return await (0, jose_1.jwtVerify)(token, jwks);
|
|
36
|
-
}
|
|
37
|
-
async function authorize(ctx, endpointOverrides, toolContext) {
|
|
38
|
-
const auth = ctx.req.header('Authorization');
|
|
39
|
-
if (!auth) {
|
|
40
|
-
throw new http_exception_1.HTTPException(401, {
|
|
41
|
-
message: `Missing Authorization header`
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
const [scheme, value] = auth.trim().split(' ');
|
|
45
|
-
if (scheme.toLowerCase() !== 'bearer') {
|
|
46
|
-
throw new http_exception_1.HTTPException(401, {
|
|
47
|
-
message: `Authorization scheme ${scheme} is not supported`
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
if (!value) {
|
|
51
|
-
throw new http_exception_1.HTTPException(401, {
|
|
52
|
-
message: `Missing bearer token value`
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
try {
|
|
56
|
-
const { payload } = await verifyToken(value);
|
|
57
|
-
assertAllowedOrg(payload);
|
|
58
|
-
const session = new AuthSession(value, payload, endpointOverrides, toolContext);
|
|
59
|
-
ctx.set("auth", session);
|
|
60
|
-
return session;
|
|
61
|
-
}
|
|
62
|
-
catch (err) {
|
|
63
|
-
if (err instanceof http_exception_1.HTTPException)
|
|
64
|
-
throw err;
|
|
65
|
-
throw new http_exception_1.HTTPException(401, {
|
|
66
|
-
message: err.message,
|
|
67
|
-
cause: err
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
class AuthSession {
|
|
72
|
-
token;
|
|
73
|
-
payload;
|
|
74
|
-
_client;
|
|
75
|
-
endpoints;
|
|
76
|
-
toolContext;
|
|
77
|
-
constructor(token, payload, endpointOverrides, toolContext) {
|
|
78
|
-
this.token = token;
|
|
79
|
-
this.payload = payload;
|
|
80
|
-
const decoded = (0, client_1.decodeEndpoints)(payload.endpoints);
|
|
81
|
-
// Use overrides from workflow config if provided, falling back to JWT endpoints
|
|
82
|
-
this.endpoints = {
|
|
83
|
-
studio: endpointOverrides?.studio || decoded.studio,
|
|
84
|
-
store: endpointOverrides?.store || decoded.store,
|
|
85
|
-
token: endpointOverrides?.token || decoded.token || payload.iss,
|
|
86
|
-
};
|
|
87
|
-
this.toolContext = toolContext;
|
|
88
|
-
}
|
|
89
|
-
async getClient() {
|
|
90
|
-
if (!this._client) {
|
|
91
|
-
const toolInfo = this.toolContext?.toolName ? ` for ${this.toolContext.toolName}` : '';
|
|
92
|
-
console.log(`[VertesiaClient] Initializing client${toolInfo}`, {
|
|
93
|
-
tool: this.toolContext?.toolName,
|
|
94
|
-
toolUseId: this.toolContext?.toolUseId,
|
|
95
|
-
runId: this.toolContext?.runId,
|
|
96
|
-
endpoints: this.endpoints,
|
|
97
|
-
});
|
|
98
|
-
this._client = await client_1.VertesiaClient.fromAuthToken(this.token, this.payload, this.endpoints);
|
|
99
|
-
}
|
|
100
|
-
return this._client;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
exports.AuthSession = AuthSession;
|
|
104
|
-
function isAllowedIssuer(iss) {
|
|
105
|
-
return iss.endsWith(".vertesia.io") || iss.endsWith(".becomposable.com");
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* If VERTESIA_ALLOWED_ORGS is set (comma-separated org IDs), restrict access
|
|
109
|
-
* to only those organizations. If not set, all authenticated orgs are allowed.
|
|
110
|
-
*/
|
|
111
|
-
let _allowedOrgs;
|
|
112
|
-
function getAllowedOrgs() {
|
|
113
|
-
if (_allowedOrgs === undefined) {
|
|
114
|
-
const raw = process.env.VERTESIA_ALLOWED_ORGS;
|
|
115
|
-
_allowedOrgs = raw
|
|
116
|
-
? new Set(raw.split(',').map(s => s.trim()).filter(Boolean))
|
|
117
|
-
: null;
|
|
118
|
-
}
|
|
119
|
-
return _allowedOrgs;
|
|
120
|
-
}
|
|
121
|
-
function assertAllowedOrg(payload) {
|
|
122
|
-
const allowed = getAllowedOrgs();
|
|
123
|
-
if (!allowed)
|
|
124
|
-
return;
|
|
125
|
-
if (!allowed.has(payload.account.id)) {
|
|
126
|
-
throw new http_exception_1.HTTPException(403, {
|
|
127
|
-
message: `Organization ${payload.account.name} is not authorized to access this server`,
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
//# sourceMappingURL=auth.js.map
|
package/lib/cjs/auth.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":";;;AAQA,0BAcC;AAED,kCAUC;AAeD,8BA+BC;AAhFD,6CAAmE;AAGnE,wDAAoD;AACpD,+BAA+F;AAE/F,MAAM,KAAK,GAAoC,EAAE,CAAC;AAE3C,KAAK,UAAU,OAAO,CAAC,GAAW;IACrC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACnC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC;gBACP,OAAO,CAAC,CAAC,IAAI,EAA4B,CAAC;YAC9C,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,kCAAkC,GAAG,CAAC,CAAC,MAAM,CAAC,CAA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AAG;YACd,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC5D,CAAC,CAAC,IAAI,CAAC;IACf,CAAC;IACD,OAAO,YAAY,CAAC;AACxB,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAyB;IAC/C,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,8BAAa,CAAC,GAAG,EAAE;YACzB,OAAO,EAAE,gBAAgB,OAAO,CAAC,OAAO,CAAC,IAAI,0CAA0C;SAC1F,CAAC,CAAC;IACP,CAAC;AACL,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/build/validate.ts"],"names":[],"mappings":";;AAAA,4BAEC;AAFD,SAAgB,QAAQ;IACpB,MAAM;AACV,CAAC"}
|
package/lib/cjs/copy-assets.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.copyRuntimeAssets = copyRuntimeAssets;
|
|
5
|
-
/**
|
|
6
|
-
* Copy runtime assets (skill files, prompt files, scripts) to dist folder
|
|
7
|
-
* These files are read from disk at runtime and need to be deployed with the app
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* npx tools-sdk-copy-assets [srcDir] [distDir]
|
|
11
|
-
*
|
|
12
|
-
* Or import and call directly:
|
|
13
|
-
* import { copyRuntimeAssets } from '@vertesia/tools-sdk';
|
|
14
|
-
* copyRuntimeAssets('./src', './dist');
|
|
15
|
-
*/
|
|
16
|
-
const fs_1 = require("fs");
|
|
17
|
-
const path_1 = require("path");
|
|
18
|
-
/**
|
|
19
|
-
* Recursively copy files matching a filter
|
|
20
|
-
*/
|
|
21
|
-
function copyFilesRecursive(src, dest, fileFilter) {
|
|
22
|
-
if (!(0, fs_1.existsSync)(src))
|
|
23
|
-
return;
|
|
24
|
-
const entries = (0, fs_1.readdirSync)(src);
|
|
25
|
-
for (const entry of entries) {
|
|
26
|
-
const srcPath = (0, path_1.join)(src, entry);
|
|
27
|
-
const destPath = (0, path_1.join)(dest, entry);
|
|
28
|
-
const stat = (0, fs_1.statSync)(srcPath);
|
|
29
|
-
if (stat.isDirectory()) {
|
|
30
|
-
// Recurse into directories
|
|
31
|
-
copyFilesRecursive(srcPath, destPath, fileFilter);
|
|
32
|
-
}
|
|
33
|
-
else if (fileFilter(entry)) {
|
|
34
|
-
// Copy matching files
|
|
35
|
-
(0, fs_1.mkdirSync)((0, path_1.dirname)(destPath), { recursive: true });
|
|
36
|
-
(0, fs_1.copyFileSync)(srcPath, destPath);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Copy runtime assets (skills, interactions) from src to dist
|
|
42
|
-
*/
|
|
43
|
-
function copyRuntimeAssets(options = {}) {
|
|
44
|
-
const { srcDir = './src', distDir = './dist', verbose = true } = options;
|
|
45
|
-
if (verbose) {
|
|
46
|
-
console.log('Copying runtime assets to dist...');
|
|
47
|
-
}
|
|
48
|
-
// Copy skill files (SKILL.md, SKILL.jst, *.py)
|
|
49
|
-
const skillsSrc = (0, path_1.join)(srcDir, 'skills');
|
|
50
|
-
const skillsDest = (0, path_1.join)(distDir, 'skills');
|
|
51
|
-
if ((0, fs_1.existsSync)(skillsSrc)) {
|
|
52
|
-
copyFilesRecursive(skillsSrc, skillsDest, (filename) => {
|
|
53
|
-
return filename === 'SKILL.md' ||
|
|
54
|
-
filename === 'SKILL.jst' ||
|
|
55
|
-
filename.endsWith('.py');
|
|
56
|
-
});
|
|
57
|
-
if (verbose) {
|
|
58
|
-
console.log(' ✓ Skills assets (SKILL.md, SKILL.jst, *.py)');
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
// Copy interaction prompt files (prompt.jst, prompt.md)
|
|
62
|
-
const interactionsSrc = (0, path_1.join)(srcDir, 'interactions');
|
|
63
|
-
const interactionsDest = (0, path_1.join)(distDir, 'interactions');
|
|
64
|
-
if ((0, fs_1.existsSync)(interactionsSrc)) {
|
|
65
|
-
copyFilesRecursive(interactionsSrc, interactionsDest, (filename) => {
|
|
66
|
-
return filename === 'prompt.jst' ||
|
|
67
|
-
filename === 'prompt.md';
|
|
68
|
-
});
|
|
69
|
-
if (verbose) {
|
|
70
|
-
console.log(' ✓ Interaction assets (prompt.jst, prompt.md)');
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (verbose) {
|
|
74
|
-
console.log('Runtime assets copied successfully!');
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// CLI entry point
|
|
78
|
-
if (typeof process !== 'undefined' && process.argv[1]?.includes('copy-assets')) {
|
|
79
|
-
const args = process.argv.slice(2);
|
|
80
|
-
const srcDir = args[0] || './src';
|
|
81
|
-
const distDir = args[1] || './dist';
|
|
82
|
-
copyRuntimeAssets({ srcDir, distDir });
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=copy-assets.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"copy-assets.js","sourceRoot":"","sources":["../../src/copy-assets.ts"],"names":[],"mappings":";;;AAmDA,8CA2CC;AA7FD;;;;;;;;;;GAUG;AACH,2BAAgF;AAChF,+BAAqC;AAErC;;GAEG;AACH,SAAS,kBAAkB,CAAC,GAAW,EAAE,IAAY,EAAE,UAAyC;IAC5F,IAAI,CAAC,IAAA,eAAU,EAAC,GAAG,CAAC;QAAE,OAAO;IAE7B,MAAM,OA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CAAC;AAC3C,CAAC"}
|
package/lib/cjs/index.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.copyRuntimeAssets = exports.AuthSession = exports.authorize = void 0;
|
|
18
|
-
__exportStar(require("./ActivityCollection.js"), exports);
|
|
19
|
-
var auth_js_1 = require("./auth.js");
|
|
20
|
-
Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return auth_js_1.authorize; } });
|
|
21
|
-
Object.defineProperty(exports, "AuthSession", { enumerable: true, get: function () { return auth_js_1.AuthSession; } });
|
|
22
|
-
__exportStar(require("./ContentTypesCollection.js"), exports);
|
|
23
|
-
__exportStar(require("./RenderingTemplateCollection.js"), exports);
|
|
24
|
-
var copy_assets_js_1 = require("./copy-assets.js");
|
|
25
|
-
Object.defineProperty(exports, "copyRuntimeAssets", { enumerable: true, get: function () { return copy_assets_js_1.copyRuntimeAssets; } });
|
|
26
|
-
__exportStar(require("./InteractionCollection.js"), exports);
|
|
27
|
-
__exportStar(require("./server.js"), exports);
|
|
28
|
-
__exportStar(require("./server/types.js"), exports);
|
|
29
|
-
__exportStar(require("./site/templates.js"), exports);
|
|
30
|
-
__exportStar(require("./SkillCollection.js"), exports);
|
|
31
|
-
__exportStar(require("./ToolCollection.js"), exports);
|
|
32
|
-
__exportStar(require("./ToolRegistry.js"), exports);
|
|
33
|
-
__exportStar(require("./types.js"), exports);
|
|
34
|
-
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,qCAAmD;AAA1C,oGAAA,SAAS,OAAA;AAAE,sGAAA,WAAW,OAAA;AAC/B,8DAA4C;AAC5C,mEAAiD;AACjD,mDAAqD;AAA5C,mHAAA,iBAAiB,OAAA;AAC1B,6DAA2C;AAC3C,8CAA4B;AAC5B,oDAAkC;AAClC,sDAAoC;AACpC,uDAAqC;AACrC,sDAAoC;AACpC,oDAAkC;AAClC,6CAA2B"}
|
package/lib/cjs/package.json
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createActivitiesRoute = createActivitiesRoute;
|
|
4
|
-
const hono_1 = require("hono");
|
|
5
|
-
const http_exception_1 = require("hono/http-exception");
|
|
6
|
-
/**
|
|
7
|
-
* Safely parse JSON from a request body. Throws HTTPException(400) on invalid JSON.
|
|
8
|
-
*/
|
|
9
|
-
async function safeParseJson(c) {
|
|
10
|
-
try {
|
|
11
|
-
return await c.req.json();
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
throw new http_exception_1.HTTPException(400, {
|
|
15
|
-
message: 'Invalid JSON in request body.'
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Validates the structure of a RemoteActivityExecutionPayload.
|
|
21
|
-
* Returns the parsed payload or throws HTTPException(400).
|
|
22
|
-
*/
|
|
23
|
-
function parseActivityPayload(body) {
|
|
24
|
-
if (!body || typeof body !== 'object') {
|
|
25
|
-
throw new http_exception_1.HTTPException(400, {
|
|
26
|
-
message: 'Invalid or missing activity execution payload.'
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
const obj = body;
|
|
30
|
-
if (typeof obj.activity_name !== 'string' || !obj.activity_name) {
|
|
31
|
-
throw new http_exception_1.HTTPException(400, {
|
|
32
|
-
message: 'Missing required field: activity_name'
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
activity_name: obj.activity_name,
|
|
37
|
-
params: obj.params || {},
|
|
38
|
-
metadata: obj.metadata || {},
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function createActivitiesRoute(app, basePath, config) {
|
|
42
|
-
const { activities = [] } = config;
|
|
43
|
-
// Build a map of activity name -> collection for routing
|
|
44
|
-
const activityToCollection = new Map();
|
|
45
|
-
for (const coll of activities) {
|
|
46
|
-
for (const def of coll.getActivityDefinitions()) {
|
|
47
|
-
activityToCollection.set(def.name, coll);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// GET /api/activities - List all activities across all collections
|
|
51
|
-
app.get(basePath, (c) => {
|
|
52
|
-
const allActivities = [];
|
|
53
|
-
for (const coll of activities) {
|
|
54
|
-
allActivities.push(...coll.getActivityDefinitions());
|
|
55
|
-
}
|
|
56
|
-
return c.json({
|
|
57
|
-
title: 'All Activities',
|
|
58
|
-
description: 'All available remote activities across all collections',
|
|
59
|
-
activities: allActivities,
|
|
60
|
-
collections: activities.map(a => ({
|
|
61
|
-
name: a.name,
|
|
62
|
-
title: a.title,
|
|
63
|
-
description: a.description,
|
|
64
|
-
})),
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
// POST /api/activities - Execute an activity by name (routes to correct collection)
|
|
68
|
-
app.post(basePath, async (c) => {
|
|
69
|
-
const body = await safeParseJson(c);
|
|
70
|
-
const payload = parseActivityPayload(body);
|
|
71
|
-
const collection = activityToCollection.get(payload.activity_name);
|
|
72
|
-
if (!collection) {
|
|
73
|
-
throw new http_exception_1.HTTPException(404, {
|
|
74
|
-
message: `Activity not found: ${payload.activity_name}. Available: ${Array.from(activityToCollection.keys()).join(', ')}`
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
return collection.execute(c, payload);
|
|
78
|
-
});
|
|
79
|
-
// Per-collection endpoints
|
|
80
|
-
for (const coll of activities) {
|
|
81
|
-
app.route(`${basePath}/${coll.name}`, createActivityEndpoints(coll));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
function createActivityEndpoints(coll) {
|
|
85
|
-
const endpoint = new hono_1.Hono();
|
|
86
|
-
// GET /api/activities/{collection} - List activities in this collection
|
|
87
|
-
endpoint.get('/', (c) => {
|
|
88
|
-
return c.json({
|
|
89
|
-
name: coll.name,
|
|
90
|
-
title: coll.title,
|
|
91
|
-
description: coll.description,
|
|
92
|
-
activities: coll.getActivityDefinitions(),
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
// POST /api/activities/{collection} - Execute activity in this collection
|
|
96
|
-
endpoint.post('/', async (c) => {
|
|
97
|
-
const body = await safeParseJson(c);
|
|
98
|
-
const payload = parseActivityPayload(body);
|
|
99
|
-
return coll.execute(c, payload);
|
|
100
|
-
});
|
|
101
|
-
return endpoint;
|
|
102
|
-
}
|
|
103
|
-
//# sourceMappingURL=activities.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"activities.js","sourceRoot":"","sources":["../../../src/server/activities.ts"],"names":[],"mappings":";;AA0CA,sDAgDC;AAzFD,+BAAqC;AACrC,wDAAoD;AAIpD;;GAEG;AACH,KAAK,UAAU,aAAa,CAAC,CAAU;IACnC,IAAI,CAAC;QACD,OAAO,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IAC9B,CAAC;IAAC,MAAM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GAAG,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAC;IACzE,CAAC;AACL,CAAC;AAED,SAAS,uBAAuB,CAAC,IAAwB;IACrD,MAAM,QAAQ,GAAG,IAAI,WAAI,EAAE,CAAC;IAE5B,wEAAwE;IACxE,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE;QACpB,OAAO,CAAC,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,sBAAsB,EAAE;SAC5C,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,CAAU,EAAE,EAAE;QACpC,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,CAAC,CAAC,CAAC;QACpC,MAAM,OAAO,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AACpB,CAAC"}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPackageRoute = createPackageRoute;
|
|
4
|
-
function getRequestPayload(c) {
|
|
5
|
-
return c.req.method === "POST" ? c.req.json() : Promise.resolve(undefined);
|
|
6
|
-
}
|
|
7
|
-
const builders = {
|
|
8
|
-
async tools(pkg, config, c) {
|
|
9
|
-
const { tools: toolCollections = [], skills: skillCollections = [] } = config;
|
|
10
|
-
const filterContext = await getRequestPayload(c);
|
|
11
|
-
// Aggregate all tools from all collections
|
|
12
|
-
const allTools = toolCollections.flatMap(collection => collection.getToolDefinitions(filterContext));
|
|
13
|
-
// same for skills
|
|
14
|
-
const allSkills = skillCollections.flatMap(collection => collection.getToolDefinitions(filterContext));
|
|
15
|
-
// Deduplicate by tool name (skills listed first take priority)
|
|
16
|
-
const seen = new Set();
|
|
17
|
-
const combined = allSkills.concat(allTools);
|
|
18
|
-
pkg.tools = combined.filter(tool => {
|
|
19
|
-
if (seen.has(tool.name)) {
|
|
20
|
-
console.warn(`[app-package] Duplicate tool name "${tool.name}", skipping`);
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
seen.add(tool.name);
|
|
24
|
-
return true;
|
|
25
|
-
});
|
|
26
|
-
},
|
|
27
|
-
async interactions(pkg, config) {
|
|
28
|
-
const allInteractions = [];
|
|
29
|
-
for (const coll of (config.interactions || [])) {
|
|
30
|
-
for (const inter of coll.interactions) {
|
|
31
|
-
allInteractions.push({
|
|
32
|
-
type: "app",
|
|
33
|
-
id: coll.name + ":" + inter.name,
|
|
34
|
-
name: inter.name,
|
|
35
|
-
title: inter.title || inter.name,
|
|
36
|
-
description: inter.description,
|
|
37
|
-
tags: inter.tags || [],
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
pkg.interactions = allInteractions;
|
|
42
|
-
},
|
|
43
|
-
async types(pkg, config) {
|
|
44
|
-
const allTypes = [];
|
|
45
|
-
for (const coll of config.types || []) {
|
|
46
|
-
for (const type of coll.types) {
|
|
47
|
-
allTypes.push({
|
|
48
|
-
...type,
|
|
49
|
-
id: coll.name + ":" + type.name
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
pkg.types = allTypes;
|
|
54
|
-
},
|
|
55
|
-
async templates(pkg, config) {
|
|
56
|
-
const basePath = `${config.prefix || '/api'}/templates`;
|
|
57
|
-
pkg.templates = (config.templates || []).flatMap(coll => coll.templates.map(({ instructions: _, ...ref }) => ({
|
|
58
|
-
...ref,
|
|
59
|
-
path: `${basePath}/${coll.name}/${ref.name}`,
|
|
60
|
-
})));
|
|
61
|
-
},
|
|
62
|
-
async widgets(pkg, config) {
|
|
63
|
-
const { skills: skillCollections = [] } = config;
|
|
64
|
-
const widgets = {};
|
|
65
|
-
for (const coll of skillCollections) {
|
|
66
|
-
for (const skill of coll.getSkillDefinitions()) {
|
|
67
|
-
if (skill.widgets && skill.widgets.length > 0) {
|
|
68
|
-
widgets[skill.name] = {
|
|
69
|
-
skill: skill.name,
|
|
70
|
-
collection: coll.name,
|
|
71
|
-
url: `/widgets/${skill.widgets[0]}.js`
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
pkg.widgets = widgets;
|
|
77
|
-
},
|
|
78
|
-
async ui(pkg, config, c) {
|
|
79
|
-
if (config.uiConfig) {
|
|
80
|
-
pkg.ui = { ...config.uiConfig };
|
|
81
|
-
const origin = new URL(c.req.url).origin;
|
|
82
|
-
pkg.ui.src = new URL(pkg.ui.src, origin).toString();
|
|
83
|
-
if (!pkg.ui.isolation) {
|
|
84
|
-
pkg.ui.isolation = "shadow";
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
async settings(pkg, config) {
|
|
89
|
-
if (config.settings) {
|
|
90
|
-
pkg.settings_schema = { ...config.settings };
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
async activities(pkg, config) {
|
|
94
|
-
const allActivities = [];
|
|
95
|
-
for (const coll of config.activities || []) {
|
|
96
|
-
for (const def of coll.getActivityDefinitions()) {
|
|
97
|
-
allActivities.push({ ...def, collection: coll.name });
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
pkg.activities = allActivities;
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
async function handlePackageRequest(c, config) {
|
|
104
|
-
const scope = c.req.query('scope') || 'all';
|
|
105
|
-
const pkg = {};
|
|
106
|
-
const scopes = new Set(scope.split(','));
|
|
107
|
-
// TODO build pkg based on the query param scope
|
|
108
|
-
if (scopes.has('all')) {
|
|
109
|
-
await builders.tools(pkg, config, c);
|
|
110
|
-
await builders.interactions(pkg, config, c);
|
|
111
|
-
await builders.types(pkg, config, c);
|
|
112
|
-
await builders.templates(pkg, config, c);
|
|
113
|
-
await builders.widgets(pkg, config, c);
|
|
114
|
-
await builders.ui(pkg, config, c);
|
|
115
|
-
await builders.settings(pkg, config, c);
|
|
116
|
-
await builders.activities(pkg, config, c);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
if (scopes.has('tools')) {
|
|
120
|
-
await builders.tools(pkg, config, c);
|
|
121
|
-
}
|
|
122
|
-
if (scopes.has('interactions')) {
|
|
123
|
-
await builders.interactions(pkg, config, c);
|
|
124
|
-
}
|
|
125
|
-
if (scopes.has('types')) {
|
|
126
|
-
await builders.types(pkg, config, c);
|
|
127
|
-
}
|
|
128
|
-
if (scopes.has('templates')) {
|
|
129
|
-
await builders.templates(pkg, config, c);
|
|
130
|
-
}
|
|
131
|
-
if (scopes.has('widgets')) {
|
|
132
|
-
await builders.widgets(pkg, config, c);
|
|
133
|
-
}
|
|
134
|
-
if (scopes.has('ui')) {
|
|
135
|
-
await builders.ui(pkg, config, c);
|
|
136
|
-
}
|
|
137
|
-
if (scopes.has('settings')) {
|
|
138
|
-
await builders.settings(pkg, config, c);
|
|
139
|
-
}
|
|
140
|
-
if (scopes.has('activities')) {
|
|
141
|
-
await builders.activities(pkg, config, c);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return c.json(pkg);
|
|
145
|
-
}
|
|
146
|
-
function createPackageRoute(app, basePath, config) {
|
|
147
|
-
app.get(basePath, (c) => {
|
|
148
|
-
return handlePackageRequest(c, config);
|
|
149
|
-
});
|
|
150
|
-
app.post(basePath, (c) => {
|
|
151
|
-
return handlePackageRequest(c, config);
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
//# sourceMappingURL=app-package.js.map
|