@trikhub/server 0.10.0 → 0.12.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@trikhub/server",
3
- "version": "0.10.0",
4
- "description": "HTTP server for TrikHub - secure skill execution gateway for AI agents",
3
+ "version": "0.12.0",
4
+ "description": "HTTP server for TrikHub - handoff routing gateway for AI agents",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -46,13 +46,12 @@
46
46
  "node": ">=18.0.0"
47
47
  },
48
48
  "dependencies": {
49
- "@anthropic-ai/sdk": "^0.39.0",
50
49
  "@fastify/swagger": "^9.4.2",
51
50
  "@fastify/swagger-ui": "^5.2.1",
52
51
  "fastify": "^5.2.1",
53
- "@trikhub/gateway": "0.10.0",
54
- "@trikhub/linter": "0.10.0",
55
- "@trikhub/manifest": "0.10.0"
52
+ "@trikhub/gateway": "0.12.0",
53
+ "@trikhub/linter": "0.12.0",
54
+ "@trikhub/manifest": "0.12.0"
56
55
  },
57
56
  "devDependencies": {
58
57
  "tsx": "^4.19.2"
@@ -1 +0,0 @@
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"}
@@ -1,67 +0,0 @@
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
@@ -1 +0,0 @@
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,EA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vB,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"}
@@ -1,4 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,81 +0,0 @@
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
@@ -1 +0,0 @@
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,EAAE,CAAC,EAAE,WAAW,EAAE,uCAAuC,EAAE;QAC5F,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,6CAA6C,EAAE;QACrF,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iDAAiD,EAAE;KAC9F;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,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,UAAU,EAAE,aAAa,CAAC,EAAE;QACnE,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC7B,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,6CAA6C,EAAE;QACxF,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,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