@trikhub/server 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +219 -0
  3. package/dist/.tsbuildinfo +1 -0
  4. package/dist/cli.d.ts +3 -0
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +126 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/config.d.ts +14 -0
  9. package/dist/config.d.ts.map +1 -0
  10. package/dist/config.js +15 -0
  11. package/dist/config.js.map +1 -0
  12. package/dist/index.d.ts +2 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +69 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/routes/content.d.ts +4 -0
  17. package/dist/routes/content.d.ts.map +1 -0
  18. package/dist/routes/content.js +67 -0
  19. package/dist/routes/content.js.map +1 -0
  20. package/dist/routes/execute.d.ts +4 -0
  21. package/dist/routes/execute.d.ts.map +1 -0
  22. package/dist/routes/execute.js +81 -0
  23. package/dist/routes/execute.js.map +1 -0
  24. package/dist/routes/health.d.ts +4 -0
  25. package/dist/routes/health.d.ts.map +1 -0
  26. package/dist/routes/health.js +42 -0
  27. package/dist/routes/health.js.map +1 -0
  28. package/dist/routes/tools.d.ts +4 -0
  29. package/dist/routes/tools.d.ts.map +1 -0
  30. package/dist/routes/tools.js +43 -0
  31. package/dist/routes/tools.js.map +1 -0
  32. package/dist/routes/triks.d.ts +4 -0
  33. package/dist/routes/triks.d.ts.map +1 -0
  34. package/dist/routes/triks.js +208 -0
  35. package/dist/routes/triks.js.map +1 -0
  36. package/dist/server.d.ts +5 -0
  37. package/dist/server.d.ts.map +1 -0
  38. package/dist/server.js +92 -0
  39. package/dist/server.js.map +1 -0
  40. package/dist/services/skill-loader.d.ts +33 -0
  41. package/dist/services/skill-loader.d.ts.map +1 -0
  42. package/dist/services/skill-loader.js +130 -0
  43. package/dist/services/skill-loader.js.map +1 -0
  44. package/dist/services/skill-validator.d.ts +12 -0
  45. package/dist/services/skill-validator.d.ts.map +1 -0
  46. package/dist/services/skill-validator.js +17 -0
  47. package/dist/services/skill-validator.js.map +1 -0
  48. package/package.json +66 -0
package/dist/index.js ADDED
@@ -0,0 +1,69 @@
1
+ import { loadConfig } from './config.js';
2
+ import { SkillLoader } from './services/skill-loader.js';
3
+ import { createServer } from './server.js';
4
+ let server = null;
5
+ let isShuttingDown = false;
6
+ async function shutdown(signal) {
7
+ if (isShuttingDown)
8
+ return;
9
+ isShuttingDown = true;
10
+ if (server) {
11
+ server.log.info({ signal }, 'Received shutdown signal, closing server...');
12
+ try {
13
+ await server.close();
14
+ server.log.info('Server closed gracefully');
15
+ }
16
+ catch (err) {
17
+ server.log.error({ err }, 'Error during shutdown');
18
+ process.exit(1);
19
+ }
20
+ }
21
+ process.exit(0);
22
+ }
23
+ async function main() {
24
+ const config = loadConfig();
25
+ // Initialize skill loader
26
+ const skillLoader = new SkillLoader({
27
+ skillsDirectory: config.skillsDirectory,
28
+ lintBeforeLoad: config.lintOnLoad,
29
+ lintWarningsAsErrors: config.lintWarningsAsErrors,
30
+ allowedSkills: config.allowedSkills,
31
+ });
32
+ // Create server first so we can use its logger
33
+ const gateway = skillLoader.getGateway();
34
+ server = await createServer(config, gateway);
35
+ const log = server.log;
36
+ log.info({
37
+ skillsDirectory: config.skillsDirectory,
38
+ lintOnLoad: config.lintOnLoad,
39
+ auth: config.authToken ? 'enabled' : 'disabled',
40
+ }, 'Starting skill-server');
41
+ // Load skills at startup
42
+ log.info('Discovering skills...');
43
+ const loadResult = await skillLoader.discoverAndLoad();
44
+ log.info({ loaded: loadResult.loaded, failed: loadResult.failed }, 'Skills discovery complete');
45
+ for (const skill of loadResult.skills) {
46
+ if (skill.status === 'loaded') {
47
+ log.info({ skillId: skill.skillId }, 'Skill loaded');
48
+ }
49
+ else {
50
+ log.warn({ skillId: skill.skillId, path: skill.path, error: skill.error }, 'Skill failed to load');
51
+ }
52
+ }
53
+ // Register shutdown handlers
54
+ process.on('SIGTERM', () => shutdown('SIGTERM'));
55
+ process.on('SIGINT', () => shutdown('SIGINT'));
56
+ // Start listening
57
+ await server.listen({ port: config.port, host: config.host });
58
+ log.info({ url: `http://${config.host}:${config.port}` }, 'Server listening');
59
+ }
60
+ main().catch((err) => {
61
+ if (server) {
62
+ server.log.fatal({ err }, 'Fatal error');
63
+ }
64
+ else {
65
+ console.error('[skill-server] Fatal error:', err);
66
+ }
67
+ process.exit(1);
68
+ });
69
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,IAAI,MAAM,GAA2B,IAAI,CAAC;AAC1C,IAAI,cAAc,GAAG,KAAK,CAAC;AAE3B,KAAK,UAAU,QAAQ,CAAC,MAAc;IACpC,IAAI,cAAc;QAAE,OAAO;IAC3B,cAAc,GAAG,IAAI,CAAC;IAEtB,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,6CAA6C,CAAC,CAAC;QAC3E,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;YACrB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,uBAAuB,CAAC,CAAC;YACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;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,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,sBAAsB,CAAC,CAAC;QACrG,CAAC;IACH,CAAC;IAED,6BAA6B;IAC7B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;IACjD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE/C,kBAAkB;IAClB,MAAM,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9D,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,UAAU,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,kBAAkB,CAAC,CAAC;AAChF,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,aAAa,CAAC,CAAC;IAC3C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { FastifyInstance } from 'fastify';
2
+ import type { TrikGateway } from '@trikhub/gateway';
3
+ export declare function contentRoutes(fastify: FastifyInstance, gateway: TrikGateway): Promise<void>;
4
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/routes/content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAkD,MAAM,kBAAkB,CAAC;AA4DpG,wBAAsB,aAAa,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCjG"}
@@ -0,0 +1,67 @@
1
+ const contentParamsSchema = {
2
+ type: 'object',
3
+ required: ['ref'],
4
+ properties: {
5
+ ref: { type: 'string', description: 'Content reference ID from execute response' },
6
+ },
7
+ };
8
+ const contentSuccessResponseSchema = {
9
+ type: 'object',
10
+ properties: {
11
+ success: { type: 'boolean', const: true },
12
+ content: {
13
+ type: 'object',
14
+ properties: {
15
+ content: { type: 'string', description: 'The actual content to display to user' },
16
+ contentType: { type: 'string', description: 'MIME type of the content' },
17
+ metadata: { type: 'object', description: 'Additional metadata about the content' },
18
+ },
19
+ },
20
+ receipt: {
21
+ type: 'object',
22
+ properties: {
23
+ delivered: { type: 'boolean' },
24
+ contentType: { type: 'string' },
25
+ metadata: { type: 'object' },
26
+ },
27
+ },
28
+ },
29
+ };
30
+ const contentErrorResponseSchema = {
31
+ type: 'object',
32
+ properties: {
33
+ success: { type: 'boolean', const: false },
34
+ code: { type: 'string' },
35
+ error: { type: 'string' },
36
+ },
37
+ };
38
+ export async function contentRoutes(fastify, gateway) {
39
+ fastify.get('/api/v1/content/:ref', {
40
+ schema: {
41
+ tags: ['content'],
42
+ summary: 'Fetch passthrough content',
43
+ description: 'Retrieves passthrough content by reference. Content is one-time delivery and will be deleted after retrieval.',
44
+ params: contentParamsSchema,
45
+ response: {
46
+ 200: contentSuccessResponseSchema,
47
+ 404: contentErrorResponseSchema,
48
+ },
49
+ },
50
+ }, async (request, reply) => {
51
+ const { ref } = request.params;
52
+ const result = gateway.deliverContent(ref);
53
+ if (!result) {
54
+ return reply.status(404).send({
55
+ success: false,
56
+ code: 'CONTENT_NOT_FOUND',
57
+ error: 'Content reference not found or expired',
58
+ });
59
+ }
60
+ return {
61
+ success: true,
62
+ content: result.content,
63
+ receipt: result.receipt,
64
+ };
65
+ });
66
+ }
67
+ //# sourceMappingURL=content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/routes/content.ts"],"names":[],"mappings":"AAqBA,MAAM,mBAAmB,GAAG;IAC1B,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,KAAK,CAAC;IACjB,UAAU,EAAE;QACV,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,4CAA4C,EAAE;KACnF;CACO,CAAC;AAEX,MAAM,4BAA4B,GAAG;IACnC,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE;QACzC,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,uCAAuC,EAAE;gBACjF,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,0BAA0B,EAAE;gBACxE,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,uCAAuC,EAAE;aACnF;SACF;QACD,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;gBAC9B,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC/B,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;aAC7B;SACF;KACF;CACO,CAAC;AAEX,MAAM,0BAA0B,GAAG;IACjC,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE;QAC1C,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACxB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC1B;CACO,CAAC;AAEX,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAwB,EAAE,OAAoB;IAChF,OAAO,CAAC,GAAG,CACT,sBAAsB,EACtB;QACE,MAAM,EAAE;YACN,IAAI,EAAE,CAAC,SAAS,CAAC;YACjB,OAAO,EAAE,2BAA2B;YACpC,WAAW,EAAE,+GAA+G;YAC5H,MAAM,EAAE,mBAAmB;YAC3B,QAAQ,EAAE;gBACR,GAAG,EAAE,4BAA4B;gBACjC,GAAG,EAAE,0BAA0B;aAChC;SACF;KACF,EACD,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QACvB,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;QAE/B,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAE3C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBAC5B,OAAO,EAAE,KAAK;gBACd,IAAI,EAAE,mBAAmB;gBACzB,KAAK,EAAE,wCAAwC;aAChD,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { FastifyInstance } from 'fastify';
2
+ import type { TrikGateway } from '@trikhub/gateway';
3
+ export declare function executeRoutes(fastify: FastifyInstance, gateway: TrikGateway): Promise<void>;
4
+ //# sourceMappingURL=execute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/routes/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAA4B,MAAM,kBAAkB,CAAC;AA8C9E,wBAAsB,aAAa,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CA4DjG"}
@@ -0,0 +1,81 @@
1
+ const executeBodySchema = {
2
+ type: 'object',
3
+ required: ['tool', 'input'],
4
+ properties: {
5
+ tool: { type: 'string', minLength: 1, description: 'Tool name in format trikId:actionName' },
6
+ input: { type: 'object', description: 'Tool input matching the tool\'s inputSchema' },
7
+ sessionId: { type: 'string', description: 'Optional session ID for multi-turn interactions' },
8
+ },
9
+ };
10
+ const executeSuccessResponseSchema = {
11
+ type: 'object',
12
+ properties: {
13
+ success: { type: 'boolean', const: true },
14
+ responseMode: { type: 'string', enum: ['template', 'passthrough'] },
15
+ sessionId: { type: 'string' },
16
+ response: { type: 'string', description: 'Resolved template text (template mode only)' },
17
+ agentData: { type: 'object', description: 'Structured data for the agent (template mode)' },
18
+ templateText: { type: 'string', description: 'Raw template text before resolution' },
19
+ userContentRef: { type: 'string', description: 'Content reference ID (passthrough mode)' },
20
+ contentType: { type: 'string', description: 'Content MIME type (passthrough mode)' },
21
+ },
22
+ };
23
+ const executeErrorResponseSchema = {
24
+ type: 'object',
25
+ properties: {
26
+ success: { type: 'boolean', const: false },
27
+ code: { type: 'string', enum: ['TRIK_NOT_FOUND', 'INVALID_INPUT', 'TIMEOUT', 'CLARIFICATION_NEEDED', 'INVALID_OUTPUT', 'EXECUTION_ERROR'] },
28
+ error: { type: 'string' },
29
+ },
30
+ };
31
+ export async function executeRoutes(fastify, gateway) {
32
+ fastify.post('/api/v1/execute', {
33
+ schema: {
34
+ tags: ['execute'],
35
+ summary: 'Execute a trik action',
36
+ description: 'Executes a trik action with the given input. Returns either template data or a passthrough content reference.',
37
+ body: executeBodySchema,
38
+ response: {
39
+ 200: executeSuccessResponseSchema,
40
+ 400: executeErrorResponseSchema,
41
+ 404: executeErrorResponseSchema,
42
+ 408: executeErrorResponseSchema,
43
+ 422: executeErrorResponseSchema,
44
+ 500: executeErrorResponseSchema,
45
+ },
46
+ },
47
+ }, async (request, reply) => {
48
+ const { tool, input, sessionId } = request.body;
49
+ // Parse tool name: "trikId:actionName" or just "trikId" (uses default action)
50
+ const colonIndex = tool.indexOf(':');
51
+ const trikId = colonIndex > 0 ? tool.slice(0, colonIndex) : tool;
52
+ const actionName = colonIndex > 0 ? tool.slice(colonIndex + 1) : 'default';
53
+ const result = await gateway.execute(trikId, actionName, input, { sessionId });
54
+ // Map error codes to HTTP status codes
55
+ if (!result.success) {
56
+ const statusMap = {
57
+ TRIK_NOT_FOUND: 404,
58
+ INVALID_INPUT: 400,
59
+ TIMEOUT: 408,
60
+ CLARIFICATION_NEEDED: 422,
61
+ INVALID_OUTPUT: 500,
62
+ EXECUTION_ERROR: 500,
63
+ };
64
+ const status = statusMap[result.code] || 500;
65
+ return reply.status(status).send(result);
66
+ }
67
+ // For template mode, resolve the template and include as 'response'
68
+ if (result.responseMode === 'template' && result.templateText) {
69
+ const agentData = result.agentData || {};
70
+ const templates = gateway.getActionTemplates(trikId, actionName);
71
+ const templateId = agentData.template;
72
+ const template = templateId && templates?.[templateId];
73
+ const response = template
74
+ ? gateway.resolveTemplate(template, agentData)
75
+ : result.templateText;
76
+ return { ...result, response };
77
+ }
78
+ return result;
79
+ });
80
+ }
81
+ //# sourceMappingURL=execute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/routes/execute.ts"],"names":[],"mappings":"AAcA,MAAM,iBAAiB,GAAG;IACxB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3B,UAAU,EAAE;QACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EA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B,OAAO,EAAE,GAAG;gBACZ,oBAAoB,EAAE,GAAG;gBACzB,cAAc,EAAE,GAAG;gBACnB,eAAe,EAAE,GAAG;aACrB,CAAC;YACF,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;YAC7C,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;QAED,oEAAoE;QACpE,IAAI,MAAM,CAAC,YAAY,KAAK,UAAU,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YAC9D,MAAM,SAAS,GAAI,MAAM,CAAC,SAAqC,IAAI,EAAE,CAAC;YACtE,MAAM,SAAS,GAAG,OAAO,CAAC,kBAAkB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YACjE,MAAM,UAAU,GAAG,SAAS,CAAC,QAA8B,CAAC;YAC5D,MAAM,QAAQ,GAAG,UAAU,IAAI,SAAS,EAAE,CAAC,UAAU,CAAC,CAAC;YAEvD,MAAM,QAAQ,GAAG,QAAQ;gBACvB,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,EAAE,SAAS,CAAC;gBAC9C,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;YAExB,OAAO,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,CAAC;QACjC,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { FastifyInstance } from 'fastify';
2
+ import type { TrikGateway } from '@trikhub/gateway';
3
+ export declare function healthRoutes(fastify: FastifyInstance, gateway: TrikGateway): Promise<void>;
4
+ //# sourceMappingURL=health.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/routes/health.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA+BpD,wBAAsB,YAAY,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BhG"}
@@ -0,0 +1,42 @@
1
+ import { createRequire } from 'module';
2
+ // Read version from package.json
3
+ const require = createRequire(import.meta.url);
4
+ const pkg = require('../../package.json');
5
+ const healthResponseSchema = {
6
+ type: 'object',
7
+ properties: {
8
+ status: { type: 'string', enum: ['ok', 'degraded', 'error'] },
9
+ version: { type: 'string' },
10
+ uptime: { type: 'number', description: 'Uptime in seconds' },
11
+ triks: {
12
+ type: 'object',
13
+ properties: {
14
+ loaded: { type: 'number' },
15
+ },
16
+ },
17
+ },
18
+ };
19
+ export async function healthRoutes(fastify, gateway) {
20
+ const startTime = Date.now();
21
+ fastify.get('/api/v1/health', {
22
+ schema: {
23
+ tags: ['health'],
24
+ summary: 'Health check',
25
+ description: 'Returns server health status, version, uptime, and loaded trik count',
26
+ response: {
27
+ 200: healthResponseSchema,
28
+ },
29
+ },
30
+ }, async () => {
31
+ const loadedTriks = gateway.getLoadedTriks();
32
+ return {
33
+ status: 'ok',
34
+ version: pkg.version,
35
+ uptime: Math.floor((Date.now() - startTime) / 1000),
36
+ triks: {
37
+ loaded: loadedTriks.length,
38
+ },
39
+ };
40
+ });
41
+ }
42
+ //# sourceMappingURL=health.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/routes/health.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,iCAAiC;AACjC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAW1C,MAAM,oBAAoB,GAAG;IAC3B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE;QAC7D,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,mBAAmB,EAAE;QAC5D,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;aAC3B;SACF;KACF;CACO,CAAC;AAEX,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAwB,EAAE,OAAoB;IAC/E,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,OAAO,CAAC,GAAG,CACT,gBAAgB,EAChB;QACE,MAAM,EAAE;YACN,IAAI,EAAE,CAAC,QAAQ,CAAC;YAChB,OAAO,EAAE,cAAc;YACvB,WAAW,EAAE,sEAAsE;YACnF,QAAQ,EAAE;gBACR,GAAG,EAAE,oBAAoB;aAC1B;SACF;KACF,EACD,KAAK,IAAI,EAAE;QACT,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;QAE7C,OAAO;YACL,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC;YACnD,KAAK,EAAE;gBACL,MAAM,EAAE,WAAW,CAAC,MAAM;aAC3B;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { FastifyInstance } from 'fastify';
2
+ import type { TrikGateway } from '@trikhub/gateway';
3
+ export declare function toolsRoutes(fastify: FastifyInstance, gateway: TrikGateway): Promise<void>;
4
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/routes/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAA4B,MAAM,kBAAkB,CAAC;AAoC9E,wBAAsB,WAAW,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB/F"}
@@ -0,0 +1,43 @@
1
+ const toolDefinitionSchema = {
2
+ type: 'object',
3
+ properties: {
4
+ name: { type: 'string', description: 'Tool name in format trikId:actionName' },
5
+ description: { type: 'string' },
6
+ inputSchema: { type: 'object', additionalProperties: true, description: 'JSON Schema for tool input' },
7
+ responseMode: { type: 'string', enum: ['template', 'passthrough'] },
8
+ },
9
+ };
10
+ const trikInfoSchema = {
11
+ type: 'object',
12
+ properties: {
13
+ id: { type: 'string' },
14
+ name: { type: 'string' },
15
+ description: { type: 'string' },
16
+ sessionEnabled: { type: 'boolean' },
17
+ tools: { type: 'array', items: toolDefinitionSchema },
18
+ },
19
+ };
20
+ const toolsResponseSchema = {
21
+ type: 'object',
22
+ properties: {
23
+ tools: { type: 'array', items: toolDefinitionSchema },
24
+ triks: { type: 'array', items: trikInfoSchema },
25
+ },
26
+ };
27
+ export async function toolsRoutes(fastify, gateway) {
28
+ fastify.get('/api/v1/tools', {
29
+ schema: {
30
+ tags: ['tools'],
31
+ summary: 'List available tools',
32
+ description: 'Returns all available tools and triks loaded in the gateway',
33
+ response: {
34
+ 200: toolsResponseSchema,
35
+ },
36
+ },
37
+ }, async () => {
38
+ const tools = gateway.getToolDefinitions();
39
+ const triks = gateway.getAvailableTriks();
40
+ return { tools, triks };
41
+ });
42
+ }
43
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/routes/tools.ts"],"names":[],"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;gBACR,GAAG,EAAE,mBAAmB;aACzB;SACF;KACF,EACD,KAAK,IAAI,EAAE;QACT,MAAM,KAAK,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAC3C,MAAM,KAAK,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;QAE1C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC1B,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { FastifyInstance } from 'fastify';
2
+ import type { TrikGateway } from '@trikhub/gateway';
3
+ export declare function triksRoutes(fastify: FastifyInstance, gateway: TrikGateway, configPath?: string): Promise<void>;
4
+ //# sourceMappingURL=triks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"triks.d.ts","sourceRoot":"","sources":["../../src/routes/triks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAkFpD,wBAAsB,WAAW,CAC/B,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,WAAW,EACpB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAmMf"}
@@ -0,0 +1,208 @@
1
+ import { exec } from 'node:child_process';
2
+ import { promisify } from 'node:util';
3
+ import { readFile } from 'node:fs/promises';
4
+ const execAsync = promisify(exec);
5
+ const installRequestSchema = {
6
+ type: 'object',
7
+ required: ['package'],
8
+ properties: {
9
+ package: { type: 'string', description: 'Package name to install (e.g., @muffles/article-search)' },
10
+ },
11
+ };
12
+ const installResponseSchema = {
13
+ type: 'object',
14
+ properties: {
15
+ success: { type: 'boolean' },
16
+ message: { type: 'string' },
17
+ package: { type: 'string' },
18
+ error: { type: 'string' },
19
+ },
20
+ };
21
+ const listResponseSchema = {
22
+ type: 'object',
23
+ properties: {
24
+ triks: {
25
+ type: 'array',
26
+ items: {
27
+ type: 'object',
28
+ properties: {
29
+ name: { type: 'string' },
30
+ version: { type: 'string' },
31
+ },
32
+ },
33
+ },
34
+ },
35
+ };
36
+ const reloadResponseSchema = {
37
+ type: 'object',
38
+ properties: {
39
+ success: { type: 'boolean' },
40
+ message: { type: 'string' },
41
+ loaded: { type: 'number' },
42
+ },
43
+ };
44
+ export async function triksRoutes(fastify, gateway, configPath) {
45
+ // List installed triks
46
+ fastify.get('/api/v1/triks', {
47
+ schema: {
48
+ tags: ['triks'],
49
+ summary: 'List installed triks',
50
+ description: 'Returns all triks installed via the CLI',
51
+ response: {
52
+ 200: listResponseSchema,
53
+ },
54
+ },
55
+ }, async () => {
56
+ const triks = [];
57
+ if (configPath) {
58
+ try {
59
+ const configContent = await readFile(configPath, 'utf-8');
60
+ const config = JSON.parse(configContent);
61
+ if (Array.isArray(config.triks)) {
62
+ for (const name of config.triks) {
63
+ triks.push({ name });
64
+ }
65
+ }
66
+ }
67
+ catch {
68
+ // Config file doesn't exist or is invalid
69
+ }
70
+ }
71
+ return { triks };
72
+ });
73
+ // Install a trik
74
+ fastify.post('/api/v1/triks/install', {
75
+ schema: {
76
+ tags: ['triks'],
77
+ summary: 'Install a trik',
78
+ description: 'Installs a trik package using the trik CLI',
79
+ body: installRequestSchema,
80
+ response: {
81
+ 200: installResponseSchema,
82
+ 500: installResponseSchema,
83
+ },
84
+ },
85
+ }, async (request, reply) => {
86
+ const { package: packageName } = request.body;
87
+ if (!packageName || typeof packageName !== 'string') {
88
+ return reply.status(400).send({
89
+ success: false,
90
+ message: 'Invalid package name',
91
+ error: 'Package name is required',
92
+ });
93
+ }
94
+ // Validate package name (basic sanitization)
95
+ if (!/^[@a-z0-9][\w\-./]*$/i.test(packageName)) {
96
+ return reply.status(400).send({
97
+ success: false,
98
+ message: 'Invalid package name format',
99
+ error: 'Package name contains invalid characters',
100
+ });
101
+ }
102
+ try {
103
+ // Run trik install command
104
+ const { stdout, stderr } = await execAsync(`trik install ${packageName}`, {
105
+ timeout: 120000, // 2 minute timeout
106
+ cwd: '/app',
107
+ });
108
+ fastify.log.info({ stdout, stderr }, `Installed trik: ${packageName}`);
109
+ // Reload skills after install
110
+ if (configPath) {
111
+ await gateway.loadTriksFromConfig({ configPath });
112
+ }
113
+ return {
114
+ success: true,
115
+ message: `Successfully installed ${packageName}`,
116
+ package: packageName,
117
+ };
118
+ }
119
+ catch (error) {
120
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
121
+ fastify.log.error({ error }, `Failed to install trik: ${packageName}`);
122
+ return reply.status(500).send({
123
+ success: false,
124
+ message: `Failed to install ${packageName}`,
125
+ error: errorMessage,
126
+ });
127
+ }
128
+ });
129
+ // Uninstall a trik
130
+ fastify.delete('/api/v1/triks/:name', {
131
+ schema: {
132
+ tags: ['triks'],
133
+ summary: 'Uninstall a trik',
134
+ description: 'Uninstalls a trik package using the trik CLI',
135
+ params: {
136
+ type: 'object',
137
+ properties: {
138
+ name: { type: 'string', description: 'Package name to uninstall' },
139
+ },
140
+ },
141
+ response: {
142
+ 200: installResponseSchema,
143
+ 500: installResponseSchema,
144
+ },
145
+ },
146
+ }, async (request, reply) => {
147
+ const { name } = request.params;
148
+ try {
149
+ const { stdout, stderr } = await execAsync(`trik uninstall ${name}`, {
150
+ timeout: 60000,
151
+ cwd: '/app',
152
+ });
153
+ fastify.log.info({ stdout, stderr }, `Uninstalled trik: ${name}`);
154
+ // Reload skills after uninstall
155
+ if (configPath) {
156
+ await gateway.loadTriksFromConfig({ configPath });
157
+ }
158
+ return {
159
+ success: true,
160
+ message: `Successfully uninstalled ${name}`,
161
+ };
162
+ }
163
+ catch (error) {
164
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
165
+ fastify.log.error({ error }, `Failed to uninstall trik: ${name}`);
166
+ return reply.status(500).send({
167
+ success: false,
168
+ message: `Failed to uninstall ${name}`,
169
+ error: errorMessage,
170
+ });
171
+ }
172
+ });
173
+ // Reload skills
174
+ fastify.post('/api/v1/triks/reload', {
175
+ schema: {
176
+ tags: ['triks'],
177
+ summary: 'Reload skills',
178
+ description: 'Reloads all skills from the config without restarting the server',
179
+ response: {
180
+ 200: reloadResponseSchema,
181
+ 500: reloadResponseSchema,
182
+ },
183
+ },
184
+ }, async (request, reply) => {
185
+ try {
186
+ let loaded = 0;
187
+ if (configPath) {
188
+ const manifests = await gateway.loadTriksFromConfig({ configPath });
189
+ loaded = manifests.length;
190
+ }
191
+ return {
192
+ success: true,
193
+ message: `Reloaded ${loaded} triks`,
194
+ loaded,
195
+ };
196
+ }
197
+ catch (error) {
198
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
199
+ fastify.log.error({ error }, 'Failed to reload triks');
200
+ return reply.status(500).send({
201
+ success: false,
202
+ message: 'Failed to reload triks',
203
+ loaded: 0,
204
+ });
205
+ }
206
+ });
207
+ }
208
+ //# sourceMappingURL=triks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"triks.js","sourceRoot":"","sources":["../../src/routes/triks.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAkClC,MAAM,oBAAoB,GAAG;IAC3B,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,SAAS,CAAC;IACrB,UAAU,EAAE;QACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,yDAAyD,EAAE;KACpG;CACO,CAAC;AAEX,MAAM,qBAAqB,GAAG;IAC5B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;QAC5B,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ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AAI,CACV,sBAAsB,EACtB;QACE,MAAM,EAAE;YACN,IAAI,EAAE,CAAC,OAAO,CAAC;YACf,OAAO,EAAE,eAAe;YACxB,WAAW,EAAE,kEAAkE;YAC/E,QAAQ,EAAE;gBACR,GAAG,EAAE,oBAAoB;gBACzB,GAAG,EAAE,oBAAoB;aAC1B;SACF;KACF,EACD,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QACvB,IAAI,CAAC;YACH,IAAI,MAAM,GAAG,CAAC,CAAC;YAEf,IAAI,UAAU,EAAE,CAAC;gBACf,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,mBAAmB,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;gBACpE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;YAC5B,CAAC;YAED,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,YAAY,MAAM,QAAQ;gBACnC,MAAM;aACP,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;YAC9E,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,wBAAwB,CAAC,CAAC;YAEvD,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBAC5B,OAAO,EAAE,KAAK;gBACd,OAAO,EAAE,wBAAwB;gBACjC,MAAM,EAAE,CAAC;aACV,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { type FastifyInstance } from 'fastify';
2
+ import type { TrikGateway } from '@trikhub/gateway';
3
+ import type { ServerConfig } from './config.js';
4
+ export declare function createServer(config: ServerConfig, gateway: TrikGateway): Promise<FastifyInstance>;
5
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAIxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAWhD,wBAAsB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAoFvG"}