@runeya/runeya 2.0.2 → 2.0.4

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/index.js CHANGED
@@ -147,7 +147,7 @@ function listenWithRetry(server, port, host, wss, maxRetries = 20, delay = 500)
147
147
  });
148
148
  }
149
149
  async function main() {
150
- const { createLocalServer, pullEnv, PullEnvError } = await import("./dist-AOEI4AFR.js");
150
+ const { createLocalServer, pullEnv, PullEnvError } = await import("./dist-6LF3EWHR.js");
151
151
  if (isPullEnv) {
152
152
  if (!serviceArg) {
153
153
  console.error("Error: --service (-s) is required with --pull-env");
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
6
+ import { z } from "zod";
7
+ import { RUNEYA_CAPABILITIES, callTrpc } from "@runeya/packages-ai-capabilities";
8
+ var BASE_URL = process.env["RUNEYA_BASE_URL"] ?? "http://localhost:4000";
9
+ var CONVERSATION_ID = process.env["RUNEYA_CONVERSATION_ID"] ?? "";
10
+ var INTERNAL_TOKEN = process.env["RUNEYA_INTERNAL_TOKEN"] ?? "";
11
+ var ENV_TOKEN = process.env["RUNEYA_API_TOKEN"] ?? "";
12
+ var server = new McpServer({ name: "runeya", version: "1.0.0" });
13
+ for (const cap of RUNEYA_CAPABILITIES) {
14
+ const zodShape = {};
15
+ for (const param of cap.params) {
16
+ const base = z.string().describe(param.description);
17
+ zodShape[param.name] = param.required ? base : base.optional();
18
+ }
19
+ zodShape["authToken"] = z.string().describe("Bearer token for authentication").optional();
20
+ server.tool(cap.name, cap.description, zodShape, async (input) => {
21
+ try {
22
+ const raw = input.authToken;
23
+ const authToken = raw && !raw.startsWith("$") ? raw : ENV_TOKEN || INTERNAL_TOKEN || void 0;
24
+ if (!authToken) throw new Error("No auth token available");
25
+ const params = input;
26
+ const result = await callTrpc(BASE_URL, cap.route, cap.method, cap.buildInput(params), authToken);
27
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
28
+ } catch (err) {
29
+ return {
30
+ content: [{ type: "text", text: `Error: ${err.message}` }],
31
+ isError: true
32
+ };
33
+ }
34
+ });
35
+ }
36
+ if (CONVERSATION_ID && INTERNAL_TOKEN) {
37
+ server.tool(
38
+ "ask_user",
39
+ "Ask the user a question and wait for their reply. Use this when you need clarification or input from the user to proceed.",
40
+ { question: z.string().describe("The question to ask the user") },
41
+ async ({ question }) => {
42
+ try {
43
+ const res = await fetch(`${BASE_URL}/api/trpc/scenario.requestInput`, {
44
+ method: "POST",
45
+ headers: {
46
+ "Content-Type": "application/json",
47
+ "Authorization": `Bearer ${INTERNAL_TOKEN}`
48
+ },
49
+ body: JSON.stringify({ conversationId: CONVERSATION_ID, question }),
50
+ signal: AbortSignal.timeout(3e5)
51
+ // 5 min
52
+ });
53
+ const json = await res.json();
54
+ const result = json["result"]?.["data"] ?? json;
55
+ return { content: [{ type: "text", text: String(result) }] };
56
+ } catch (err) {
57
+ return { content: [{ type: "text", text: `Error: ${err.message}` }], isError: true };
58
+ }
59
+ }
60
+ );
61
+ }
62
+ var transport = new StdioServerTransport();
63
+ await server.connect(transport);
64
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { z } from 'zod';\nimport { RUNEYA_CAPABILITIES, callTrpc } from '@runeya/packages-ai-capabilities';\n\nconst BASE_URL = process.env['RUNEYA_BASE_URL'] ?? 'http://localhost:4000';\nconst CONVERSATION_ID = process.env['RUNEYA_CONVERSATION_ID'] ?? '';\nconst INTERNAL_TOKEN = process.env['RUNEYA_INTERNAL_TOKEN'] ?? '';\nconst ENV_TOKEN = process.env['RUNEYA_API_TOKEN'] ?? '';\n\nconst server = new McpServer({ name: 'runeya', version: '1.0.0' });\n\n// ─── Register each capability as an MCP tool ─────────────────────────────────\n\nfor (const cap of RUNEYA_CAPABILITIES) {\n const zodShape: Record<string, z.ZodTypeAny> = {};\n\n for (const param of cap.params) {\n const base = z.string().describe(param.description);\n zodShape[param.name] = param.required ? base : base.optional();\n }\n\n // authToken is MCP-specific: CLI runners pass the JWT here\n zodShape['authToken'] = z.string().describe('Bearer token for authentication').optional();\n\n server.tool(cap.name, cap.description, zodShape, async (input) => {\n try {\n const raw = (input as Record<string, string | undefined>).authToken;\n const authToken = (raw && !raw.startsWith('$')) ? raw : (ENV_TOKEN || INTERNAL_TOKEN || undefined);\n if (!authToken) throw new Error('No auth token available');\n\n const params = input as Record<string, string | undefined>;\n const result = await callTrpc(BASE_URL, cap.route, cap.method, cap.buildInput(params), authToken);\n return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };\n } catch (err) {\n return {\n content: [{ type: 'text' as const, text: `Error: ${(err as Error).message}` }],\n isError: true,\n };\n }\n });\n}\n\n// ─── ask_user tool (scenario mode only) ─────────────────────────────────────\n\nif (CONVERSATION_ID && INTERNAL_TOKEN) {\n server.tool(\n 'ask_user',\n 'Ask the user a question and wait for their reply. Use this when you need clarification or input from the user to proceed.',\n { question: z.string().describe('The question to ask the user') },\n async ({ question }) => {\n try {\n const res = await fetch(`${BASE_URL}/api/trpc/scenario.requestInput`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${INTERNAL_TOKEN}`,\n },\n body: JSON.stringify({ conversationId: CONVERSATION_ID, question }),\n signal: AbortSignal.timeout(300_000), // 5 min\n });\n const json = await res.json() as Record<string, unknown>;\n const result = (json['result'] as Record<string, unknown> | undefined)?.['data'] ?? json;\n return { content: [{ type: 'text' as const, text: String(result) }] };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: `Error: ${(err as Error).message}` }], isError: true };\n }\n },\n );\n}\n\n// ─── Start the stdio transport ───────────────────────────────────────────────\n\nconst transport = new StdioServerTransport();\nawait server.connect(transport);\n"],"mappings":";;;AACA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,SAAS;AAClB,SAAS,qBAAqB,gBAAgB;AAE9C,IAAM,WAAW,QAAQ,IAAI,iBAAiB,KAAK;AACnD,IAAM,kBAAkB,QAAQ,IAAI,wBAAwB,KAAK;AACjE,IAAM,iBAAiB,QAAQ,IAAI,uBAAuB,KAAK;AAC/D,IAAM,YAAY,QAAQ,IAAI,kBAAkB,KAAK;AAErD,IAAM,SAAS,IAAI,UAAU,EAAE,MAAM,UAAU,SAAS,QAAQ,CAAC;AAIjE,WAAW,OAAO,qBAAqB;AACrC,QAAM,WAAyC,CAAC;AAEhD,aAAW,SAAS,IAAI,QAAQ;AAC9B,UAAM,OAAO,EAAE,OAAO,EAAE,SAAS,MAAM,WAAW;AAClD,aAAS,MAAM,IAAI,IAAI,MAAM,WAAW,OAAO,KAAK,SAAS;AAAA,EAC/D;AAGA,WAAS,WAAW,IAAI,EAAE,OAAO,EAAE,SAAS,iCAAiC,EAAE,SAAS;AAExF,SAAO,KAAK,IAAI,MAAM,IAAI,aAAa,UAAU,OAAO,UAAU;AAChE,QAAI;AACF,YAAM,MAAO,MAA6C;AAC1D,YAAM,YAAa,OAAO,CAAC,IAAI,WAAW,GAAG,IAAK,MAAO,aAAa,kBAAkB;AACxF,UAAI,CAAC,UAAW,OAAM,IAAI,MAAM,yBAAyB;AAEzD,YAAM,SAAS;AACf,YAAM,SAAS,MAAM,SAAS,UAAU,IAAI,OAAO,IAAI,QAAQ,IAAI,WAAW,MAAM,GAAG,SAAS;AAChG,aAAO,EAAE,SAAS,CAAC,EAAE,MAAM,QAAiB,MAAM,KAAK,UAAU,QAAQ,MAAM,CAAC,EAAE,CAAC,EAAE;AAAA,IACvF,SAAS,KAAK;AACZ,aAAO;AAAA,QACL,SAAS,CAAC,EAAE,MAAM,QAAiB,MAAM,UAAW,IAAc,OAAO,GAAG,CAAC;AAAA,QAC7E,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAIA,IAAI,mBAAmB,gBAAgB;AACrC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,8BAA8B,EAAE;AAAA,IAChE,OAAO,EAAE,SAAS,MAAM;AACtB,UAAI;AACF,cAAM,MAAM,MAAM,MAAM,GAAG,QAAQ,mCAAmC;AAAA,UACpE,QAAQ;AAAA,UACR,SAAS;AAAA,YACP,gBAAgB;AAAA,YAChB,iBAAiB,UAAU,cAAc;AAAA,UAC3C;AAAA,UACA,MAAM,KAAK,UAAU,EAAE,gBAAgB,iBAAiB,SAAS,CAAC;AAAA,UAClE,QAAQ,YAAY,QAAQ,GAAO;AAAA;AAAA,QACrC,CAAC;AACD,cAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,cAAM,SAAU,KAAK,QAAQ,IAA4C,MAAM,KAAK;AACpF,eAAO,EAAE,SAAS,CAAC,EAAE,MAAM,QAAiB,MAAM,OAAO,MAAM,EAAE,CAAC,EAAE;AAAA,MACtE,SAAS,KAAK;AACZ,eAAO,EAAE,SAAS,CAAC,EAAE,MAAM,QAAiB,MAAM,UAAW,IAAc,OAAO,GAAG,CAAC,GAAG,SAAS,KAAK;AAAA,MACzG;AAAA,IACF;AAAA,EACF;AACF;AAIA,IAAM,YAAY,IAAI,qBAAqB;AAC3C,MAAM,OAAO,QAAQ,SAAS;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runeya/runeya",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "runeya": "./index.js"
@@ -1,8 +0,0 @@
1
- import {
2
- agentManager
3
- } from "./chunk-PVUDD5DD.js";
4
- import "./chunk-ERJIU7R4.js";
5
- export {
6
- agentManager
7
- };
8
- //# sourceMappingURL=agent-manager-RDBYJ3IY-G7IRVN2S.js.map