@kya-os/create-molti 0.1.0-canary.1

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 (117) hide show
  1. package/dist/cli.d.ts +10 -0
  2. package/dist/cli.d.ts.map +1 -0
  3. package/dist/cli.js +83 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/helpers/generate-identity.d.ts +22 -0
  6. package/dist/helpers/generate-identity.d.ts.map +1 -0
  7. package/dist/helpers/generate-identity.js +63 -0
  8. package/dist/helpers/generate-identity.js.map +1 -0
  9. package/dist/helpers/generate-molti-project.d.ts +31 -0
  10. package/dist/helpers/generate-molti-project.d.ts.map +1 -0
  11. package/dist/helpers/generate-molti-project.js +200 -0
  12. package/dist/helpers/generate-molti-project.js.map +1 -0
  13. package/dist/helpers/get-package-versions.d.ts +22 -0
  14. package/dist/helpers/get-package-versions.d.ts.map +1 -0
  15. package/dist/helpers/get-package-versions.js +60 -0
  16. package/dist/helpers/get-package-versions.js.map +1 -0
  17. package/dist/helpers/index.d.ts +12 -0
  18. package/dist/helpers/index.d.ts.map +1 -0
  19. package/dist/helpers/index.js +14 -0
  20. package/dist/helpers/index.js.map +1 -0
  21. package/dist/helpers/validate-name.d.ts +16 -0
  22. package/dist/helpers/validate-name.d.ts.map +1 -0
  23. package/dist/helpers/validate-name.js +31 -0
  24. package/dist/helpers/validate-name.js.map +1 -0
  25. package/dist/index.d.ts +12 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +16 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/templates/auth-module.d.ts +7 -0
  30. package/dist/templates/auth-module.d.ts.map +1 -0
  31. package/dist/templates/auth-module.js +68 -0
  32. package/dist/templates/auth-module.js.map +1 -0
  33. package/dist/templates/dockerfile.d.ts +8 -0
  34. package/dist/templates/dockerfile.d.ts.map +1 -0
  35. package/dist/templates/dockerfile.js +40 -0
  36. package/dist/templates/dockerfile.js.map +1 -0
  37. package/dist/templates/gateway.d.ts +8 -0
  38. package/dist/templates/gateway.d.ts.map +1 -0
  39. package/dist/templates/gateway.js +112 -0
  40. package/dist/templates/gateway.js.map +1 -0
  41. package/dist/templates/github-workflow.d.ts +7 -0
  42. package/dist/templates/github-workflow.d.ts.map +1 -0
  43. package/dist/templates/github-workflow.js +48 -0
  44. package/dist/templates/github-workflow.js.map +1 -0
  45. package/dist/templates/health-module.d.ts +7 -0
  46. package/dist/templates/health-module.d.ts.map +1 -0
  47. package/dist/templates/health-module.js +62 -0
  48. package/dist/templates/health-module.js.map +1 -0
  49. package/dist/templates/identity-json.d.ts +15 -0
  50. package/dist/templates/identity-json.d.ts.map +1 -0
  51. package/dist/templates/identity-json.js +18 -0
  52. package/dist/templates/identity-json.js.map +1 -0
  53. package/dist/templates/identity-module.d.ts +8 -0
  54. package/dist/templates/identity-module.d.ts.map +1 -0
  55. package/dist/templates/identity-module.js +89 -0
  56. package/dist/templates/identity-module.js.map +1 -0
  57. package/dist/templates/moltbot-config.d.ts +7 -0
  58. package/dist/templates/moltbot-config.d.ts.map +1 -0
  59. package/dist/templates/moltbot-config.js +19 -0
  60. package/dist/templates/moltbot-config.js.map +1 -0
  61. package/dist/templates/package-json.d.ts +13 -0
  62. package/dist/templates/package-json.d.ts.map +1 -0
  63. package/dist/templates/package-json.js +34 -0
  64. package/dist/templates/package-json.js.map +1 -0
  65. package/dist/templates/readme.d.ts +14 -0
  66. package/dist/templates/readme.d.ts.map +1 -0
  67. package/dist/templates/readme.js +92 -0
  68. package/dist/templates/readme.js.map +1 -0
  69. package/dist/templates/startup-script.d.ts +8 -0
  70. package/dist/templates/startup-script.d.ts.map +1 -0
  71. package/dist/templates/startup-script.js +54 -0
  72. package/dist/templates/startup-script.js.map +1 -0
  73. package/dist/templates/tsconfig-template.d.ts +7 -0
  74. package/dist/templates/tsconfig-template.d.ts.map +1 -0
  75. package/dist/templates/tsconfig-template.js +22 -0
  76. package/dist/templates/tsconfig-template.js.map +1 -0
  77. package/dist/templates/types-module.d.ts +7 -0
  78. package/dist/templates/types-module.d.ts.map +1 -0
  79. package/dist/templates/types-module.js +73 -0
  80. package/dist/templates/types-module.js.map +1 -0
  81. package/dist/templates/worker-index.d.ts +8 -0
  82. package/dist/templates/worker-index.d.ts.map +1 -0
  83. package/dist/templates/worker-index.js +99 -0
  84. package/dist/templates/worker-index.js.map +1 -0
  85. package/dist/templates/wrangler.d.ts +16 -0
  86. package/dist/templates/wrangler.d.ts.map +1 -0
  87. package/dist/templates/wrangler.js +77 -0
  88. package/dist/templates/wrangler.js.map +1 -0
  89. package/dist/types.d.ts +61 -0
  90. package/dist/types.d.ts.map +1 -0
  91. package/dist/types.js +8 -0
  92. package/dist/types.js.map +1 -0
  93. package/package.json +50 -0
  94. package/scripts/validate-dependencies.js +38 -0
  95. package/src/cli.ts +98 -0
  96. package/src/helpers/generate-identity.ts +90 -0
  97. package/src/helpers/generate-molti-project.ts +239 -0
  98. package/src/helpers/get-package-versions.ts +78 -0
  99. package/src/helpers/index.ts +24 -0
  100. package/src/helpers/validate-name.ts +42 -0
  101. package/src/index.ts +18 -0
  102. package/src/templates/auth-module.ts +68 -0
  103. package/src/templates/dockerfile.ts +40 -0
  104. package/src/templates/gateway.ts +112 -0
  105. package/src/templates/github-workflow.ts +48 -0
  106. package/src/templates/health-module.ts +62 -0
  107. package/src/templates/identity-json.ts +29 -0
  108. package/src/templates/identity-module.ts +89 -0
  109. package/src/templates/moltbot-config.ts +23 -0
  110. package/src/templates/package-json.ts +46 -0
  111. package/src/templates/readme.ts +101 -0
  112. package/src/templates/startup-script.ts +54 -0
  113. package/src/templates/tsconfig-template.ts +26 -0
  114. package/src/templates/types-module.ts +73 -0
  115. package/src/templates/worker-index.ts +99 -0
  116. package/src/templates/wrangler.ts +89 -0
  117. package/src/types.ts +64 -0
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @kya-os/create-molti
4
+ *
5
+ * Scaffold a Moltworker project with MCP-I identity.
6
+ *
7
+ * Usage:
8
+ * npx @kya-os/create-molti my-agent
9
+ * npx @kya-os/create-molti my-agent --instance-type standard-1
10
+ */
11
+ import { run } from './cli.js';
12
+ run().catch((error) => {
13
+ console.error('Error:', error.message);
14
+ process.exit(1);
15
+ });
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;GAQG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACpB,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Auth Module Template (src/auth.ts)
3
+ *
4
+ * Generates Cloudflare Access middleware for JWT verification.
5
+ */
6
+ export declare function generateAuthModule(): string;
7
+ //# sourceMappingURL=auth-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-module.d.ts","sourceRoot":"","sources":["../../src/templates/auth-module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAgB,kBAAkB,IAAI,MAAM,CA6D3C"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Auth Module Template (src/auth.ts)
3
+ *
4
+ * Generates Cloudflare Access middleware for JWT verification.
5
+ */
6
+ export function generateAuthModule() {
7
+ return `/**
8
+ * Cloudflare Access Authentication Middleware
9
+ *
10
+ * Verifies CF Access JWT tokens for protected routes.
11
+ * Skips auth in dev mode for local development.
12
+ */
13
+
14
+ import type { Context, Next } from "hono";
15
+ import type { AppEnv } from "./types";
16
+
17
+ interface AccessMiddlewareOptions {
18
+ type: "api" | "admin";
19
+ redirectOnMissing?: boolean;
20
+ }
21
+
22
+ /**
23
+ * Create CF Access authentication middleware
24
+ */
25
+ export function createAccessMiddleware(options: AccessMiddlewareOptions) {
26
+ return async (c: Context<AppEnv>, next: Next) => {
27
+ const env = c.env;
28
+
29
+ // Skip auth in dev mode
30
+ if (env.DEV_MODE === "true") {
31
+ c.set("accessUser", { email: "dev@localhost", name: "Dev User" });
32
+ return next();
33
+ }
34
+
35
+ // Skip auth if CF Access is not configured
36
+ if (!env.CF_ACCESS_TEAM_DOMAIN || !env.CF_ACCESS_AUD) {
37
+ c.set("accessUser", { email: "unconfigured@localhost" });
38
+ return next();
39
+ }
40
+
41
+ // Extract JWT from CF-Access-JWT-Assertion header or cookie
42
+ const jwt =
43
+ c.req.header("CF-Access-JWT-Assertion") ||
44
+ getCookie(c.req.header("cookie") || "", "CF_Authorization");
45
+
46
+ if (!jwt) {
47
+ if (options.redirectOnMissing) {
48
+ return c.redirect(
49
+ \`https://\${env.CF_ACCESS_TEAM_DOMAIN}/cdn-cgi/access/login\`
50
+ );
51
+ }
52
+ return c.json({ error: "Authentication required" }, 401);
53
+ }
54
+
55
+ // For production, verify JWT with CF Access JWKS
56
+ // Simplified: trust CF Access header in Workers environment
57
+ c.set("accessUser", { email: "authenticated@user" });
58
+ await next();
59
+ };
60
+ }
61
+
62
+ function getCookie(cookieHeader: string, name: string): string | undefined {
63
+ const match = cookieHeader.match(new RegExp(\`(?:^|;\\\\s*)\${name}=([^;]*)\`));
64
+ return match?.[1];
65
+ }
66
+ `;
67
+ }
68
+ //# sourceMappingURL=auth-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-module.js","sourceRoot":"","sources":["../../src/templates/auth-module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,UAAU,kBAAkB;IAChC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2DR,CAAC;AACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Dockerfile Template
3
+ *
4
+ * Generates a Dockerfile for the Moltworker container.
5
+ * Based on the Cloudflare sandbox base image with Node.js and moltbot CLI.
6
+ */
7
+ export declare function generateDockerfile(): string;
8
+ //# sourceMappingURL=dockerfile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dockerfile.d.ts","sourceRoot":"","sources":["../../src/templates/dockerfile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,kBAAkB,IAAI,MAAM,CAgC3C"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Dockerfile Template
3
+ *
4
+ * Generates a Dockerfile for the Moltworker container.
5
+ * Based on the Cloudflare sandbox base image with Node.js and moltbot CLI.
6
+ */
7
+ export function generateDockerfile() {
8
+ return `FROM docker.io/cloudflare/sandbox:0.7.0
9
+
10
+ # Install Node.js 22 (required by moltbot)
11
+ ENV NODE_VERSION=22.13.1
12
+ RUN apt-get update && apt-get install -y xz-utils ca-certificates rsync \\
13
+ && curl -fsSLk https://nodejs.org/dist/v\${NODE_VERSION}/node-v\${NODE_VERSION}-linux-x64.tar.xz -o /tmp/node.tar.xz \\
14
+ && tar -xJf /tmp/node.tar.xz -C /usr/local --strip-components=1 \\
15
+ && rm /tmp/node.tar.xz
16
+
17
+ # Install pnpm
18
+ RUN npm install -g pnpm
19
+
20
+ # Install moltbot CLI
21
+ RUN npm install -g clawdbot@2026.1.24-3
22
+
23
+ # Create directories
24
+ RUN mkdir -p /root/.clawdbot \\
25
+ && mkdir -p /root/.clawdbot-templates \\
26
+ && mkdir -p /root/clawd \\
27
+ && mkdir -p /root/clawd/skills
28
+
29
+ # Copy startup script
30
+ COPY start-moltbot.sh /usr/local/bin/start-moltbot.sh
31
+ RUN chmod +x /usr/local/bin/start-moltbot.sh
32
+
33
+ # Copy config template
34
+ COPY moltbot.json.template /root/.clawdbot-templates/moltbot.json.template
35
+
36
+ WORKDIR /root/clawd
37
+ EXPOSE 18789
38
+ `;
39
+ }
40
+ //# sourceMappingURL=dockerfile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dockerfile.js","sourceRoot":"","sources":["../../src/templates/dockerfile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,UAAU,kBAAkB;IAChC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BR,CAAC;AACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Gateway Module Template (src/gateway.ts)
3
+ *
4
+ * Generates the gateway management code that ensures the
5
+ * Moltbot process is running inside the container.
6
+ */
7
+ export declare function generateGatewayModule(): string;
8
+ //# sourceMappingURL=gateway.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../src/templates/gateway.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,qBAAqB,IAAI,MAAM,CAwG9C"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Gateway Module Template (src/gateway.ts)
3
+ *
4
+ * Generates the gateway management code that ensures the
5
+ * Moltbot process is running inside the container.
6
+ */
7
+ export function generateGatewayModule() {
8
+ return `/**
9
+ * Moltbot Gateway Management
10
+ *
11
+ * Ensures the Moltbot process is running inside the container
12
+ * and waits for the gateway port to be ready.
13
+ */
14
+
15
+ export const MOLTBOT_PORT = 18789;
16
+ const STARTUP_TIMEOUT_MS = 180_000; // 3 minutes
17
+
18
+ /**
19
+ * Ensure the Moltbot gateway is running and ready
20
+ */
21
+ export async function ensureMoltbotGateway(
22
+ sandbox: any,
23
+ env: Record<string, unknown>
24
+ ): Promise<void> {
25
+ // Check for existing process
26
+ const processes = await sandbox.ps();
27
+ const existing = processes.find(
28
+ (p: { command: string; status: string }) =>
29
+ (p.command.includes("start-moltbot.sh") || p.command.includes("clawdbot gateway")) &&
30
+ p.status === "running"
31
+ );
32
+
33
+ if (existing) {
34
+ await waitForPort(sandbox, MOLTBOT_PORT, STARTUP_TIMEOUT_MS);
35
+ return;
36
+ }
37
+
38
+ // Build environment variables for the container process
39
+ const envVars = buildEnvVars(env);
40
+
41
+ // Start the moltbot process
42
+ await sandbox.start("/usr/local/bin/start-moltbot.sh", {
43
+ env: envVars,
44
+ });
45
+
46
+ await waitForPort(sandbox, MOLTBOT_PORT, STARTUP_TIMEOUT_MS);
47
+ }
48
+
49
+ /**
50
+ * Build environment variables to pass to the container
51
+ */
52
+ function buildEnvVars(env: Record<string, unknown>): Record<string, string> {
53
+ const vars: Record<string, string> = {};
54
+
55
+ // AI Gateway priority
56
+ if (env.AI_GATEWAY_API_KEY) {
57
+ const baseUrl = String(env.AI_GATEWAY_BASE_URL || "");
58
+ if (baseUrl.includes("openai")) {
59
+ vars.OPENAI_API_KEY = String(env.AI_GATEWAY_API_KEY);
60
+ vars.OPENAI_BASE_URL = baseUrl.replace(/\\/$/, "");
61
+ } else {
62
+ vars.ANTHROPIC_API_KEY = String(env.AI_GATEWAY_API_KEY);
63
+ vars.ANTHROPIC_BASE_URL = baseUrl.replace(/\\/$/, "");
64
+ }
65
+ } else {
66
+ if (env.ANTHROPIC_API_KEY) vars.ANTHROPIC_API_KEY = String(env.ANTHROPIC_API_KEY);
67
+ if (env.OPENAI_API_KEY) vars.OPENAI_API_KEY = String(env.OPENAI_API_KEY);
68
+ }
69
+
70
+ // Gateway token
71
+ if (env.MOLTBOT_GATEWAY_TOKEN) {
72
+ vars.CLAWDBOT_GATEWAY_TOKEN = String(env.MOLTBOT_GATEWAY_TOKEN);
73
+ }
74
+
75
+ // Bot tokens
76
+ if (env.TELEGRAM_BOT_TOKEN) vars.TELEGRAM_BOT_TOKEN = String(env.TELEGRAM_BOT_TOKEN);
77
+ if (env.DISCORD_BOT_TOKEN) vars.DISCORD_BOT_TOKEN = String(env.DISCORD_BOT_TOKEN);
78
+ if (env.SLACK_BOT_TOKEN) vars.SLACK_BOT_TOKEN = String(env.SLACK_BOT_TOKEN);
79
+
80
+ if (env.DEV_MODE) vars.DEV_MODE = String(env.DEV_MODE);
81
+
82
+ return vars;
83
+ }
84
+
85
+ /**
86
+ * Wait for a port to become available
87
+ */
88
+ async function waitForPort(
89
+ sandbox: any,
90
+ port: number,
91
+ timeoutMs: number
92
+ ): Promise<void> {
93
+ const start = Date.now();
94
+
95
+ while (Date.now() - start < timeoutMs) {
96
+ try {
97
+ const response = await sandbox.containerFetch(
98
+ new Request(\`http://localhost:\${port}/\`),
99
+ port
100
+ );
101
+ if (response.status < 500) return;
102
+ } catch {
103
+ // Port not ready yet
104
+ }
105
+ await new Promise((resolve) => setTimeout(resolve, 1000));
106
+ }
107
+
108
+ throw new Error(\`Moltbot gateway did not start within \${timeoutMs / 1000}s\`);
109
+ }
110
+ `;
111
+ }
112
+ //# sourceMappingURL=gateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../src/templates/gateway.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,UAAU,qBAAqB;IACnC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsGR,CAAC;AACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * GitHub Actions Workflow Template
3
+ *
4
+ * Generates the deploy.yml for CI/CD to Cloudflare.
5
+ */
6
+ export declare function generateDeployWorkflow(): string;
7
+ //# sourceMappingURL=github-workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-workflow.d.ts","sourceRoot":"","sources":["../../src/templates/github-workflow.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAgB,sBAAsB,IAAI,MAAM,CAyC/C"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * GitHub Actions Workflow Template
3
+ *
4
+ * Generates the deploy.yml for CI/CD to Cloudflare.
5
+ */
6
+ export function generateDeployWorkflow() {
7
+ return `name: Deploy to Cloudflare
8
+
9
+ on:
10
+ push:
11
+ branches: [main]
12
+ workflow_dispatch:
13
+ inputs:
14
+ reason:
15
+ description: 'Reason for manual deployment'
16
+ required: false
17
+ default: 'Manual deployment'
18
+
19
+ jobs:
20
+ deploy:
21
+ runs-on: ubuntu-latest
22
+ name: Deploy Moltworker
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+
26
+ - name: Setup Node.js
27
+ uses: actions/setup-node@v4
28
+ with:
29
+ node-version: '20'
30
+
31
+ - name: Install dependencies
32
+ run: npm install
33
+
34
+ - name: Deploy to Cloudflare
35
+ uses: cloudflare/wrangler-action@v3
36
+ with:
37
+ apiToken: \${{ secrets.CLOUDFLARE_API_TOKEN }}
38
+ secrets: |
39
+ MCP_IDENTITY_PRIVATE_KEY
40
+ AGENTSHIELD_API_KEY
41
+ ANTHROPIC_API_KEY
42
+ env:
43
+ MCP_IDENTITY_PRIVATE_KEY: \${{ secrets.MCP_IDENTITY_PRIVATE_KEY }}
44
+ AGENTSHIELD_API_KEY: \${{ secrets.AGENTSHIELD_API_KEY }}
45
+ ANTHROPIC_API_KEY: \${{ secrets.ANTHROPIC_API_KEY }}
46
+ `;
47
+ }
48
+ //# sourceMappingURL=github-workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-workflow.js","sourceRoot":"","sources":["../../src/templates/github-workflow.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,UAAU,sBAAsB;IACpC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCR,CAAC;AACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Health Module Template (src/routes/public.ts)
3
+ *
4
+ * Generates public routes including health checks and status endpoints.
5
+ */
6
+ export declare function generateHealthModule(projectName: string): string;
7
+ //# sourceMappingURL=health-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health-module.d.ts","sourceRoot":"","sources":["../../src/templates/health-module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAuDhE"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Health Module Template (src/routes/public.ts)
3
+ *
4
+ * Generates public routes including health checks and status endpoints.
5
+ */
6
+ export function generateHealthModule(projectName) {
7
+ return `/**
8
+ * Public Routes
9
+ *
10
+ * Health checks and status endpoints — no authentication required.
11
+ */
12
+
13
+ import { Hono } from "hono";
14
+ import type { AppEnv } from "../types";
15
+
16
+ export const publicRoutes = new Hono<AppEnv>();
17
+
18
+ /**
19
+ * Basic health check
20
+ */
21
+ publicRoutes.get("/sandbox-health", (c) => {
22
+ return c.json({
23
+ status: "ok",
24
+ service: "${projectName}",
25
+ timestamp: new Date().toISOString(),
26
+ });
27
+ });
28
+
29
+ /**
30
+ * Detailed status with gateway check
31
+ */
32
+ publicRoutes.get("/api/status", async (c) => {
33
+ const sandbox = c.get("sandbox");
34
+
35
+ try {
36
+ const processes = await sandbox.ps();
37
+ const moltbot = processes.find(
38
+ (p: { command: string; status: string }) =>
39
+ (p.command.includes("start-moltbot.sh") || p.command.includes("clawdbot gateway")) &&
40
+ p.status === "running"
41
+ );
42
+
43
+ return c.json({
44
+ status: moltbot ? "running" : "starting",
45
+ service: "${projectName}",
46
+ identity: {
47
+ did: c.env.MCP_IDENTITY_AGENT_DID,
48
+ },
49
+ gateway: moltbot
50
+ ? { pid: moltbot.pid, status: moltbot.status }
51
+ : null,
52
+ });
53
+ } catch {
54
+ return c.json({
55
+ status: "unknown",
56
+ service: "${projectName}",
57
+ });
58
+ }
59
+ });
60
+ `;
61
+ }
62
+ //# sourceMappingURL=health-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health-module.js","sourceRoot":"","sources":["../../src/templates/health-module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,UAAU,oBAAoB,CAAC,WAAmB;IACtD,OAAO;;;;;;;;;;;;;;;;;gBAiBO,WAAW;;;;;;;;;;;;;;;;;;;;;kBAqBT,WAAW;;;;;;;;;;;kBAWX,WAAW;;;;CAI5B,CAAC;AACF,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * .mcpi/identity.json Template
3
+ *
4
+ * Generates the public identity file that is committed to the repo.
5
+ * Contains the agent DID and public key — private key is a secret.
6
+ */
7
+ interface IdentityJsonOptions {
8
+ did: string;
9
+ publicKey: string;
10
+ agentName?: string;
11
+ agentDescription?: string;
12
+ }
13
+ export declare function generateIdentityJson(opts: IdentityJsonOptions): string;
14
+ export {};
15
+ //# sourceMappingURL=identity-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-json.d.ts","sourceRoot":"","sources":["../../src/templates/identity-json.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,UAAU,mBAAmB;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CActE"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * .mcpi/identity.json Template
3
+ *
4
+ * Generates the public identity file that is committed to the repo.
5
+ * Contains the agent DID and public key — private key is a secret.
6
+ */
7
+ export function generateIdentityJson(opts) {
8
+ return JSON.stringify({
9
+ version: '1.0',
10
+ type: 'molti-agent',
11
+ did: opts.did,
12
+ publicKey: opts.publicKey,
13
+ agentName: opts.agentName || undefined,
14
+ agentDescription: opts.agentDescription || undefined,
15
+ createdAt: new Date().toISOString(),
16
+ }, null, 2);
17
+ }
18
+ //# sourceMappingURL=identity-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-json.js","sourceRoot":"","sources":["../../src/templates/identity-json.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,MAAM,UAAU,oBAAoB,CAAC,IAAyB;IAC5D,OAAO,IAAI,CAAC,SAAS,CACnB;QACE,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,aAAa;QACnB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,SAAS;QACtC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,IAAI,SAAS;QACpD,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC,EACD,IAAI,EACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Identity Module Template (src/identity.ts)
3
+ *
4
+ * Generates the MCP-I identity provider initialization code.
5
+ * Uses @kya-os/mcp-i-cloudflare for Cloudflare-specific providers.
6
+ */
7
+ export declare function generateIdentityModule(): string;
8
+ //# sourceMappingURL=identity-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-module.d.ts","sourceRoot":"","sources":["../../src/templates/identity-module.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,sBAAsB,IAAI,MAAM,CAiF/C"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Identity Module Template (src/identity.ts)
3
+ *
4
+ * Generates the MCP-I identity provider initialization code.
5
+ * Uses @kya-os/mcp-i-cloudflare for Cloudflare-specific providers.
6
+ */
7
+ export function generateIdentityModule() {
8
+ return `/**
9
+ * MCP-I Identity Provider
10
+ *
11
+ * Initializes cryptographic identity from environment variables.
12
+ * Uses @kya-os/mcp-i-cloudflare for Cloudflare Workers-compatible
13
+ * Ed25519 signing via Web Crypto API.
14
+ */
15
+
16
+ import {
17
+ WebCryptoProvider,
18
+ KVNonceCacheProvider,
19
+ CloudflareProofGenerator,
20
+ } from "@kya-os/mcp-i-cloudflare";
21
+
22
+ interface IdentityConfig {
23
+ did: string;
24
+ publicKey: string;
25
+ privateKey: string;
26
+ }
27
+
28
+ interface IdentityProviderResult {
29
+ proofGenerator: InstanceType<typeof CloudflareProofGenerator>;
30
+ config: IdentityConfig;
31
+ }
32
+
33
+ /**
34
+ * Get the identity provider from environment
35
+ */
36
+ export function getIdentityProvider(env: {
37
+ MCP_IDENTITY_AGENT_DID: string;
38
+ MCP_IDENTITY_PUBLIC_KEY: string;
39
+ MCP_IDENTITY_PRIVATE_KEY: string;
40
+ NONCE_CACHE: KVNamespace;
41
+ PROOF_ARCHIVE: KVNamespace;
42
+ }): IdentityProviderResult {
43
+ const config: IdentityConfig = {
44
+ did: env.MCP_IDENTITY_AGENT_DID,
45
+ publicKey: env.MCP_IDENTITY_PUBLIC_KEY,
46
+ privateKey: env.MCP_IDENTITY_PRIVATE_KEY,
47
+ };
48
+
49
+ const cryptoProvider = new WebCryptoProvider();
50
+ const nonceCache = new KVNonceCacheProvider(env.NONCE_CACHE);
51
+
52
+ const proofGenerator = new CloudflareProofGenerator(
53
+ cryptoProvider,
54
+ nonceCache,
55
+ {
56
+ did: config.did,
57
+ privateKey: config.privateKey,
58
+ publicKey: config.publicKey,
59
+ }
60
+ );
61
+
62
+ return { proofGenerator, config };
63
+ }
64
+
65
+ /**
66
+ * Generate a proof for a tool execution
67
+ */
68
+ export async function generateProof(
69
+ proofGenerator: InstanceType<typeof CloudflareProofGenerator>,
70
+ toolName: string,
71
+ input: unknown,
72
+ output: unknown
73
+ ): Promise<string | null> {
74
+ try {
75
+ const proof = await proofGenerator.generateProof({
76
+ toolName,
77
+ input: JSON.stringify(input),
78
+ output: JSON.stringify(output),
79
+ timestamp: new Date().toISOString(),
80
+ });
81
+ return proof;
82
+ } catch {
83
+ // Proof generation is non-critical — don't block tool execution
84
+ return null;
85
+ }
86
+ }
87
+ `;
88
+ }
89
+ //# sourceMappingURL=identity-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-module.js","sourceRoot":"","sources":["../../src/templates/identity-module.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,UAAU,sBAAsB;IACpC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+ER,CAAC;AACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Moltbot Config Template (moltbot.json.template)
3
+ *
4
+ * Default configuration for the Moltbot gateway.
5
+ */
6
+ export declare function generateMoltbotConfig(): string;
7
+ //# sourceMappingURL=moltbot-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moltbot-config.d.ts","sourceRoot":"","sources":["../../src/templates/moltbot-config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAgB,qBAAqB,IAAI,MAAM,CAgB9C"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Moltbot Config Template (moltbot.json.template)
3
+ *
4
+ * Default configuration for the Moltbot gateway.
5
+ */
6
+ export function generateMoltbotConfig() {
7
+ return JSON.stringify({
8
+ agents: {
9
+ defaults: {
10
+ workspace: '/root/clawd',
11
+ },
12
+ },
13
+ gateway: {
14
+ port: 18789,
15
+ mode: 'local',
16
+ },
17
+ }, null, 2);
18
+ }
19
+ //# sourceMappingURL=moltbot-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moltbot-config.js","sourceRoot":"","sources":["../../src/templates/moltbot-config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,UAAU,qBAAqB;IACnC,OAAO,IAAI,CAAC,SAAS,CACnB;QACE,MAAM,EAAE;YACN,QAAQ,EAAE;gBACR,SAAS,EAAE,aAAa;aACzB;SACF;QACD,OAAO,EAAE;YACP,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,OAAO;SACd;KACF,EACD,IAAI,EACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * package.json Template
3
+ *
4
+ * Generates the package.json for the scaffolded Moltworker project.
5
+ */
6
+ import type { MoltiPackageVersions } from '../helpers/get-package-versions.js';
7
+ interface PackageJsonOptions {
8
+ projectName: string;
9
+ versions: MoltiPackageVersions;
10
+ }
11
+ export declare function generatePackageJson(opts: PackageJsonOptions): string;
12
+ export {};
13
+ //# sourceMappingURL=package-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-json.d.ts","sourceRoot":"","sources":["../../src/templates/package-json.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,UAAU,kBAAkB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,oBAAoB,CAAC;CAChC;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,CAgCpE"}