@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
@@ -0,0 +1,34 @@
1
+ /**
2
+ * package.json Template
3
+ *
4
+ * Generates the package.json for the scaffolded Moltworker project.
5
+ */
6
+ export function generatePackageJson(opts) {
7
+ const { projectName, versions } = opts;
8
+ return JSON.stringify({
9
+ name: projectName,
10
+ version: '0.1.0',
11
+ private: true,
12
+ scripts: {
13
+ deploy: 'wrangler deploy',
14
+ dev: 'wrangler dev',
15
+ start: 'wrangler dev',
16
+ 'type-check': 'tsc --noEmit',
17
+ 'cf-typegen': 'wrangler types',
18
+ },
19
+ dependencies: {
20
+ '@cloudflare/sandbox': 'latest',
21
+ '@kya-os/mcp-i-core': versions['@kya-os/mcp-i-core'],
22
+ '@kya-os/mcp-i-cloudflare': versions['@kya-os/mcp-i-cloudflare'],
23
+ '@kya-os/contracts': versions['@kya-os/contracts'],
24
+ hono: '^4.11.6',
25
+ jose: '^6.0.0',
26
+ },
27
+ devDependencies: {
28
+ '@cloudflare/workers-types': '^4.20251126.0',
29
+ typescript: '^5.6.2',
30
+ wrangler: '^4.61.1',
31
+ },
32
+ }, null, 2);
33
+ }
34
+ //# sourceMappingURL=package-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-json.js","sourceRoot":"","sources":["../../src/templates/package-json.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,MAAM,UAAU,mBAAmB,CAAC,IAAwB;IAC1D,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAEvC,OAAO,IAAI,CAAC,SAAS,CACnB;QACE,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE,IAAI;QACb,OAAO,EAAE;YACP,MAAM,EAAE,iBAAiB;YACzB,GAAG,EAAE,cAAc;YACnB,KAAK,EAAE,cAAc;YACrB,YAAY,EAAE,cAAc;YAC5B,YAAY,EAAE,gBAAgB;SAC/B;QACD,YAAY,EAAE;YACZ,qBAAqB,EAAE,QAAQ;YAC/B,oBAAoB,EAAE,QAAQ,CAAC,oBAAoB,CAAC;YACpD,0BAA0B,EAAE,QAAQ,CAAC,0BAA0B,CAAC;YAChE,mBAAmB,EAAE,QAAQ,CAAC,mBAAmB,CAAC;YAClD,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,QAAQ;SACf;QACD,eAAe,EAAE;YACf,2BAA2B,EAAE,eAAe;YAC5C,UAAU,EAAE,QAAQ;YACpB,QAAQ,EAAE,SAAS;SACpB;KACF,EACD,IAAI,EACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * README.md Template
3
+ *
4
+ * Generates documentation for the scaffolded project.
5
+ */
6
+ interface ReadmeOptions {
7
+ projectName: string;
8
+ agentName?: string;
9
+ agentDescription?: string;
10
+ agentShieldProjectId?: string;
11
+ }
12
+ export declare function generateReadme(opts: ReadmeOptions): string;
13
+ export {};
14
+ //# sourceMappingURL=readme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readme.d.ts","sourceRoot":"","sources":["../../src/templates/readme.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,UAAU,aAAa;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAuF1D"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * README.md Template
3
+ *
4
+ * Generates documentation for the scaffolded project.
5
+ */
6
+ export function generateReadme(opts) {
7
+ const { projectName, agentName, agentDescription, agentShieldProjectId } = opts;
8
+ const displayName = agentName || projectName;
9
+ const description = agentDescription || 'AI agent running on Cloudflare Workers with MCP-I identity';
10
+ const dashboardUrl = agentShieldProjectId
11
+ ? `https://kya.vouched.id/dashboard/bouncer/${agentShieldProjectId}`
12
+ : 'https://kya.vouched.id/dashboard/bouncer';
13
+ return `# ${displayName}
14
+
15
+ ${description}
16
+
17
+ Built with [Moltworker](https://github.com/cloudflare/moltworker) + [MCP-I Identity](https://github.com/modelcontextprotocol-identity/xmcp-i).
18
+
19
+ ## Quick Start
20
+
21
+ 1. **Install dependencies**
22
+ \`\`\`bash
23
+ npm install
24
+ \`\`\`
25
+
26
+ 2. **Configure secrets**
27
+ \`\`\`bash
28
+ # Add your AI provider key
29
+ wrangler secret put ANTHROPIC_API_KEY
30
+ # or
31
+ wrangler secret put OPENAI_API_KEY
32
+
33
+ # Identity private key (already set if deployed via AgentShield)
34
+ wrangler secret put MCP_IDENTITY_PRIVATE_KEY
35
+
36
+ # AgentShield API key (for proof reporting)
37
+ wrangler secret put AGENTSHIELD_API_KEY
38
+ \`\`\`
39
+
40
+ 3. **Deploy**
41
+ \`\`\`bash
42
+ npm run deploy
43
+ \`\`\`
44
+
45
+ ## Architecture
46
+
47
+ \`\`\`
48
+ Cloudflare Worker (Hono)
49
+ \u251c\u2500\u2500 /sandbox-health \u2192 Health check (public)
50
+ \u251c\u2500\u2500 /api/status \u2192 Detailed status (public)
51
+ \u251c\u2500\u2500 /api/* \u2192 Protected API (CF Access)
52
+ \u251c\u2500\u2500 /_admin/* \u2192 Admin UI (CF Access)
53
+ \u2514\u2500\u2500 /* \u2192 Proxy to Moltbot container (port 18789)
54
+
55
+ Container (Cloudflare Sandbox)
56
+ \u251c\u2500\u2500 OpenClaw runtime (clawdbot)
57
+ \u251c\u2500\u2500 Node.js 22
58
+ \u2514\u2500\u2500 R2-backed persistent storage
59
+ \`\`\`
60
+
61
+ ## MCP-I Identity
62
+
63
+ This agent has a cryptographic identity:
64
+ - **DID**: See \`.mcpi/identity.json\`
65
+ - **Proof Generation**: Tool executions are signed with Ed25519
66
+ - **Nonce Replay Prevention**: Via KV-backed nonce cache
67
+ - **Proof Archive**: Historical proofs stored in KV
68
+
69
+ ## AgentShield Dashboard
70
+
71
+ Monitor and configure your agent: ${dashboardUrl}
72
+
73
+ ## Environment Variables
74
+
75
+ | Variable | Description | Required |
76
+ |----------|-------------|----------|
77
+ | \`MCP_IDENTITY_PRIVATE_KEY\` | Agent's Ed25519 private key | Yes |
78
+ | \`ANTHROPIC_API_KEY\` | Anthropic API key | Yes* |
79
+ | \`OPENAI_API_KEY\` | OpenAI API key | Yes* |
80
+ | \`AGENTSHIELD_API_KEY\` | AgentShield API key | Recommended |
81
+ | \`CLOUDFLARE_API_TOKEN\` | Wrangler deployment token | For CI/CD |
82
+ | \`CF_ACCESS_TEAM_DOMAIN\` | CF Access team domain | For auth |
83
+ | \`CF_ACCESS_AUD\` | CF Access audience tag | For auth |
84
+
85
+ *At least one AI provider key is required.
86
+
87
+ ## License
88
+
89
+ MIT
90
+ `;
91
+ }
92
+ //# sourceMappingURL=readme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readme.js","sourceRoot":"","sources":["../../src/templates/readme.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,MAAM,UAAU,cAAc,CAAC,IAAmB;IAChD,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,GAAG,IAAI,CAAC;IAChF,MAAM,WAAW,GAAG,SAAS,IAAI,WAAW,CAAC;IAC7C,MAAM,WAAW,GAAG,gBAAgB,IAAI,4DAA4D,CAAC;IAErG,MAAM,YAAY,GAAG,oBAAoB;QACvC,CAAC,CAAC,4CAA4C,oBAAoB,EAAE;QACpE,CAAC,CAAC,0CAA0C,CAAC;IAE/C,OAAO,KAAK,WAAW;;EAEvB,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAwDuB,YAAY;;;;;;;;;;;;;;;;;;;CAmB/C,CAAC;AACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Startup Script Template (start-moltbot.sh)
3
+ *
4
+ * Generates the bash script that runs inside the container
5
+ * to initialize config and start the Moltbot gateway.
6
+ */
7
+ export declare function generateStartupScript(): string;
8
+ //# sourceMappingURL=startup-script.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startup-script.d.ts","sourceRoot":"","sources":["../../src/templates/startup-script.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,qBAAqB,IAAI,MAAM,CA8C9C"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Startup Script Template (start-moltbot.sh)
3
+ *
4
+ * Generates the bash script that runs inside the container
5
+ * to initialize config and start the Moltbot gateway.
6
+ */
7
+ export function generateStartupScript() {
8
+ return `#!/bin/bash
9
+ set -e
10
+
11
+ CONFIG_DIR="/root/.clawdbot"
12
+ CONFIG_FILE="\${CONFIG_DIR}/moltbot.json"
13
+ TEMPLATE_FILE="/root/.clawdbot-templates/moltbot.json.template"
14
+ BACKUP_DIR="/data/moltbot/.clawdbot"
15
+
16
+ # Exit early if already running
17
+ if pgrep -f 'clawdbot gateway' > /dev/null 2>&1; then
18
+ echo "Moltbot gateway is already running, exiting."
19
+ exit 0
20
+ fi
21
+
22
+ # Restore from R2 backup if newer
23
+ if [ -d "\${BACKUP_DIR}" ] && [ -f "\${BACKUP_DIR}/moltbot.json" ]; then
24
+ BACKUP_MTIME=\$(stat -c %Y "\${BACKUP_DIR}/moltbot.json" 2>/dev/null || echo 0)
25
+ CONFIG_MTIME=\$(stat -c %Y "\${CONFIG_FILE}" 2>/dev/null || echo 0)
26
+
27
+ if [ "\${BACKUP_MTIME}" -gt "\${CONFIG_MTIME}" ]; then
28
+ echo "Restoring config from R2 backup..."
29
+ rsync -a "\${BACKUP_DIR}/" "\${CONFIG_DIR}/"
30
+ fi
31
+ fi
32
+
33
+ # Initialize config from template if needed
34
+ if [ ! -f "\${CONFIG_FILE}" ]; then
35
+ if [ -f "\${TEMPLATE_FILE}" ]; then
36
+ cp "\${TEMPLATE_FILE}" "\${CONFIG_FILE}"
37
+ echo "Initialized config from template"
38
+ else
39
+ echo '{"agents":{"defaults":{"workspace":"/root/clawd"}},"gateway":{"port":18789,"mode":"local"}}' > "\${CONFIG_FILE}"
40
+ echo "Initialized config with defaults"
41
+ fi
42
+ fi
43
+
44
+ echo "Starting Moltbot gateway on port 18789..."
45
+
46
+ # Start gateway with or without token
47
+ if [ -n "\${CLAWDBOT_GATEWAY_TOKEN}" ]; then
48
+ exec clawdbot gateway --port 18789 --verbose --bind 0.0.0.0 --token "\${CLAWDBOT_GATEWAY_TOKEN}"
49
+ else
50
+ exec clawdbot gateway --port 18789 --verbose --bind 0.0.0.0 --allow-unconfigured
51
+ fi
52
+ `;
53
+ }
54
+ //# sourceMappingURL=startup-script.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startup-script.js","sourceRoot":"","sources":["../../src/templates/startup-script.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,UAAU,qBAAqB;IACnC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CR,CAAC;AACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * tsconfig.json Template
3
+ *
4
+ * Generates TypeScript configuration for the scaffolded project.
5
+ */
6
+ export declare function generateTsconfig(): string;
7
+ //# sourceMappingURL=tsconfig-template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsconfig-template.d.ts","sourceRoot":"","sources":["../../src/templates/tsconfig-template.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAgB,gBAAgB,IAAI,MAAM,CAmBzC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * tsconfig.json Template
3
+ *
4
+ * Generates TypeScript configuration for the scaffolded project.
5
+ */
6
+ export function generateTsconfig() {
7
+ return JSON.stringify({
8
+ compilerOptions: {
9
+ target: 'ES2022',
10
+ module: 'ESNext',
11
+ moduleResolution: 'bundler',
12
+ lib: ['ES2022', 'DOM', 'DOM.Iterable'],
13
+ types: ['@cloudflare/workers-types'],
14
+ strict: true,
15
+ noEmit: true,
16
+ skipLibCheck: true,
17
+ },
18
+ include: ['src/**/*'],
19
+ exclude: ['node_modules'],
20
+ }, null, 2);
21
+ }
22
+ //# sourceMappingURL=tsconfig-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsconfig-template.js","sourceRoot":"","sources":["../../src/templates/tsconfig-template.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,CAAC,SAAS,CACnB;QACE,eAAe,EAAE;YACf,MAAM,EAAE,QAAQ;YAChB,MAAM,EAAE,QAAQ;YAChB,gBAAgB,EAAE,SAAS;YAC3B,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,cAAc,CAAC;YACtC,KAAK,EAAE,CAAC,2BAA2B,CAAC;YACpC,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,IAAI;YACZ,YAAY,EAAE,IAAI;SACnB;QACD,OAAO,EAAE,CAAC,UAAU,CAAC;QACrB,OAAO,EAAE,CAAC,cAAc,CAAC;KAC1B,EACD,IAAI,EACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Types Module Template (src/types.ts)
3
+ *
4
+ * Generates the TypeScript type definitions for the Worker environment.
5
+ */
6
+ export declare function generateTypesModule(): string;
7
+ //# sourceMappingURL=types-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-module.d.ts","sourceRoot":"","sources":["../../src/templates/types-module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAgB,mBAAmB,IAAI,MAAM,CAkE5C"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Types Module Template (src/types.ts)
3
+ *
4
+ * Generates the TypeScript type definitions for the Worker environment.
5
+ */
6
+ export function generateTypesModule() {
7
+ return `/**
8
+ * Moltworker Environment Types
9
+ */
10
+
11
+ export interface MoltbotEnv {
12
+ // Cloudflare bindings
13
+ Sandbox: DurableObjectNamespace;
14
+ ASSETS: Fetcher;
15
+ MOLTBOT_BUCKET: R2Bucket;
16
+ BROWSER: Fetcher;
17
+
18
+ // KV bindings (MCP-I identity)
19
+ NONCE_CACHE: KVNamespace;
20
+ PROOF_ARCHIVE: KVNamespace;
21
+
22
+ // MCP-I Identity
23
+ MCP_IDENTITY_AGENT_DID: string;
24
+ MCP_IDENTITY_PUBLIC_KEY: string;
25
+ MCP_IDENTITY_PRIVATE_KEY: string;
26
+
27
+ // AI Configuration
28
+ AI_GATEWAY_API_KEY?: string;
29
+ AI_GATEWAY_BASE_URL?: string;
30
+ ANTHROPIC_API_KEY?: string;
31
+ OPENAI_API_KEY?: string;
32
+
33
+ // Bot tokens
34
+ TELEGRAM_BOT_TOKEN?: string;
35
+ DISCORD_BOT_TOKEN?: string;
36
+ SLACK_BOT_TOKEN?: string;
37
+
38
+ // Cloudflare Access
39
+ CF_ACCESS_TEAM_DOMAIN?: string;
40
+ CF_ACCESS_AUD?: string;
41
+ MOLTBOT_GATEWAY_TOKEN?: string;
42
+
43
+ // R2 Storage
44
+ R2_ACCESS_KEY_ID?: string;
45
+ R2_SECRET_ACCESS_KEY?: string;
46
+ CF_ACCOUNT_ID?: string;
47
+
48
+ // AgentShield
49
+ AGENTSHIELD_API_KEY?: string;
50
+ AGENTSHIELD_API_URL?: string;
51
+ AGENTSHIELD_PROJECT_ID?: string;
52
+
53
+ // Runtime
54
+ DEV_MODE?: string;
55
+ SANDBOX_SLEEP_AFTER?: string;
56
+ MCPI_ENV?: string;
57
+ }
58
+
59
+ export interface AccessUser {
60
+ email: string;
61
+ name?: string;
62
+ }
63
+
64
+ export type AppEnv = {
65
+ Bindings: MoltbotEnv;
66
+ Variables: {
67
+ sandbox: any; // Sandbox type from @cloudflare/sandbox
68
+ accessUser?: AccessUser;
69
+ };
70
+ };
71
+ `;
72
+ }
73
+ //# sourceMappingURL=types-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-module.js","sourceRoot":"","sources":["../../src/templates/types-module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,UAAU,mBAAmB;IACjC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgER,CAAC;AACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Worker Entry Point Template (src/index.ts)
3
+ *
4
+ * Generates the main Hono Worker that handles routing, auth,
5
+ * sandbox lifecycle, and proxy to the container.
6
+ */
7
+ export declare function generateWorkerIndex(projectName: string): string;
8
+ //# sourceMappingURL=worker-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-index.d.ts","sourceRoot":"","sources":["../../src/templates/worker-index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CA2F/D"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Worker Entry Point Template (src/index.ts)
3
+ *
4
+ * Generates the main Hono Worker that handles routing, auth,
5
+ * sandbox lifecycle, and proxy to the container.
6
+ */
7
+ export function generateWorkerIndex(projectName) {
8
+ return `/**
9
+ * ${projectName} — Moltworker with MCP-I Identity
10
+ *
11
+ * Hono Worker that manages:
12
+ * - Sandbox (Container) lifecycle
13
+ * - CF Access authentication
14
+ * - Proxy to Moltbot gateway on port 18789
15
+ * - MCP-I identity proof generation
16
+ * - Health checks and status endpoints
17
+ */
18
+
19
+ import { Hono } from "hono";
20
+ import { getSandbox, buildSandboxOptions } from "@cloudflare/sandbox";
21
+ import type { MoltbotEnv, AppEnv } from "./types";
22
+ import { publicRoutes } from "./routes/public";
23
+ import { createAccessMiddleware } from "./auth";
24
+ import { ensureMoltbotGateway, MOLTBOT_PORT } from "./gateway";
25
+ import { getIdentityProvider } from "./identity";
26
+
27
+ const app = new Hono<AppEnv>();
28
+
29
+ // Initialize sandbox for all requests
30
+ app.use("*", async (c, next) => {
31
+ const options = buildSandboxOptions({
32
+ sleepAfter: Number(c.env.SANDBOX_SLEEP_AFTER) || 300,
33
+ });
34
+ const sandbox = getSandbox(c.env.Sandbox, "moltbot", options);
35
+ c.set("sandbox", sandbox);
36
+ await next();
37
+ });
38
+
39
+ // Public routes (no auth required)
40
+ app.route("/", publicRoutes);
41
+
42
+ // CF Access auth for protected routes
43
+ app.use("/api/*", createAccessMiddleware({ type: "api" }));
44
+ app.use("/_admin/*", createAccessMiddleware({ type: "admin" }));
45
+
46
+ // Proxy all other requests to Moltbot container
47
+ app.all("*", async (c) => {
48
+ const sandbox = c.get("sandbox");
49
+
50
+ try {
51
+ await ensureMoltbotGateway(sandbox, c.env as unknown as MoltbotEnv);
52
+ } catch {
53
+ return c.html(loadingPage(), 503);
54
+ }
55
+
56
+ // WebSocket upgrade
57
+ if (c.req.header("upgrade")?.toLowerCase() === "websocket") {
58
+ const ws = await sandbox.wsConnect(c.req.raw, MOLTBOT_PORT);
59
+ return new Response(null, {
60
+ status: 101,
61
+ webSocket: ws,
62
+ } as ResponseInit);
63
+ }
64
+
65
+ // HTTP proxy
66
+ const response = await sandbox.containerFetch(c.req.raw, MOLTBOT_PORT);
67
+ return response;
68
+ });
69
+
70
+ function loadingPage(): string {
71
+ return \`<!DOCTYPE html>
72
+ <html>
73
+ <head><title>${projectName} — Starting</title></head>
74
+ <body style="font-family:system-ui;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;background:#0a0a0a;color:#e5e5e5">
75
+ <div style="text-align:center">
76
+ <h2>Starting ${projectName}...</h2>
77
+ <p>The agent container is warming up. This page will refresh automatically.</p>
78
+ <script>setTimeout(() => location.reload(), 3000)</script>
79
+ </div>
80
+ </body>
81
+ </html>\`;
82
+ }
83
+
84
+ // Export for scheduled handler (R2 backup)
85
+ export default {
86
+ fetch: app.fetch,
87
+ async scheduled(_event: ScheduledEvent, env: MoltbotEnv, _ctx: ExecutionContext) {
88
+ const options = buildSandboxOptions({ sleepAfter: 300 });
89
+ const sandbox = getSandbox(env.Sandbox, "moltbot", options);
90
+ // Scheduled backup can be added here
91
+ void sandbox;
92
+ },
93
+ };
94
+
95
+ // Export Durable Object class
96
+ export { Sandbox } from "@cloudflare/sandbox";
97
+ `;
98
+ }
99
+ //# sourceMappingURL=worker-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-index.js","sourceRoot":"","sources":["../../src/templates/worker-index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,UAAU,mBAAmB,CAAC,WAAmB;IACrD,OAAO;KACJ,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAgED,WAAW;;;mBAGP,WAAW;;;;;;;;;;;;;;;;;;;;;CAqB7B,CAAC;AACF,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * wrangler.jsonc Template
3
+ *
4
+ * Generates Cloudflare Workers configuration with Container binding,
5
+ * R2 storage, Browser binding, and MCP-I identity vars.
6
+ */
7
+ interface WranglerOptions {
8
+ projectName: string;
9
+ agentDid: string;
10
+ publicKey: string;
11
+ agentShieldProjectId?: string;
12
+ instanceType: string;
13
+ }
14
+ export declare function generateWranglerJsonc(opts: WranglerOptions): string;
15
+ export {};
16
+ //# sourceMappingURL=wrangler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrangler.d.ts","sourceRoot":"","sources":["../../src/templates/wrangler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,UAAU,eAAe;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAuEnE"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * wrangler.jsonc Template
3
+ *
4
+ * Generates Cloudflare Workers configuration with Container binding,
5
+ * R2 storage, Browser binding, and MCP-I identity vars.
6
+ */
7
+ export function generateWranglerJsonc(opts) {
8
+ const { projectName, agentDid, publicKey, agentShieldProjectId, instanceType } = opts;
9
+ const agentShieldLine = agentShieldProjectId
10
+ ? ` // AgentShield Integration
11
+ "AGENTSHIELD_PROJECT_ID": "${agentShieldProjectId}",
12
+ "AGENTSHIELD_API_URL": "https://kya.vouched.id",`
13
+ : ` // AgentShield Integration (uncomment when configured)
14
+ // "AGENTSHIELD_PROJECT_ID": "your-project-id",
15
+ // "AGENTSHIELD_API_URL": "https://kya.vouched.id",`;
16
+ return `{
17
+ "name": "${projectName}",
18
+ "main": "src/index.ts",
19
+ "compatibility_date": "2025-05-06",
20
+ "compatibility_flags": ["nodejs_compat"],
21
+ "observability": { "enabled": true },
22
+
23
+ // Sandbox (Container) binding
24
+ "containers": [
25
+ {
26
+ "class_name": "Sandbox",
27
+ "image": "./Dockerfile",
28
+ "instance_type": "${instanceType}",
29
+ "max_instances": 1
30
+ }
31
+ ],
32
+
33
+ // Durable Object for Sandbox state
34
+ "durable_objects": {
35
+ "bindings": [
36
+ { "name": "Sandbox", "class_name": "Sandbox" }
37
+ ]
38
+ },
39
+
40
+ // R2 bucket for persistent storage
41
+ "r2_buckets": [
42
+ { "binding": "MOLTBOT_BUCKET", "bucket_name": "${projectName}-data" }
43
+ ],
44
+
45
+ // Browser binding for CDP
46
+ "browser": { "binding": "BROWSER" },
47
+
48
+ // KV for identity (nonce cache + proof archive)
49
+ "kv_namespaces": [
50
+ { "binding": "NONCE_CACHE" },
51
+ { "binding": "PROOF_ARCHIVE" }
52
+ ],
53
+
54
+ // Scheduled backup (every 5 minutes)
55
+ "triggers": {
56
+ "crons": ["*/5 * * * *"]
57
+ },
58
+
59
+ "vars": {
60
+ // MCP-I Identity (public — safe to commit)
61
+ "MCP_IDENTITY_AGENT_DID": "${agentDid}",
62
+ "MCP_IDENTITY_PUBLIC_KEY": "${publicKey}",
63
+
64
+ ${agentShieldLine}
65
+
66
+ "MCPI_ENV": "development"
67
+ }
68
+
69
+ // SECRETS (via wrangler secret or GitHub Secrets):
70
+ // - MCP_IDENTITY_PRIVATE_KEY
71
+ // - AGENTSHIELD_API_KEY
72
+ // - ANTHROPIC_API_KEY or OPENAI_API_KEY
73
+ // - CLOUDFLARE_API_TOKEN (for CI/CD)
74
+ }
75
+ `;
76
+ }
77
+ //# sourceMappingURL=wrangler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrangler.js","sourceRoot":"","sources":["../../src/templates/wrangler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,MAAM,UAAU,qBAAqB,CAAC,IAAqB;IACzD,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,oBAAoB,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAEtF,MAAM,eAAe,GAAG,oBAAoB;QAC1C,CAAC,CAAC;+BACyB,oBAAoB;mDACA;QAC/C,CAAC,CAAC;;sDAEgD,CAAC;IAErD,OAAO;aACI,WAAW;;;;;;;;;;;0BAWE,YAAY;;;;;;;;;;;;;;qDAce,WAAW;;;;;;;;;;;;;;;;;;;iCAmB/B,QAAQ;kCACP,SAAS;;EAEzC,eAAe;;;;;;;;;;;CAWhB,CAAC;AACF,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Types for @kya-os/create-molti
3
+ *
4
+ * Defines the configuration options and result types
5
+ * for scaffolding Moltworker projects with MCP-I identity.
6
+ */
7
+ /**
8
+ * Represents a generated file with its content
9
+ */
10
+ export interface GeneratedFile {
11
+ /** Relative path from project root (e.g., "src/index.ts") */
12
+ path: string;
13
+ /** File content as string */
14
+ content: string;
15
+ /** Encoding type */
16
+ encoding: 'utf-8' | 'base64';
17
+ }
18
+ /**
19
+ * Options for generating a Molti project
20
+ */
21
+ export interface MoltiProjectOptions {
22
+ /** Project name (used for package.json, wrangler config, container name) */
23
+ projectName: string;
24
+ /** Human-readable agent name (defaults to projectName) */
25
+ agentName?: string;
26
+ /** Agent description for metadata */
27
+ agentDescription?: string;
28
+ /** AgentShield project ID (for proof reporting) */
29
+ agentShieldProjectId?: string;
30
+ /** AgentShield API key (stored as GitHub Secret) */
31
+ agentShieldApiKey?: string;
32
+ /** Enable KTA reputation tracking */
33
+ enableReputation?: boolean;
34
+ /** Cloudflare Container instance type */
35
+ instanceType?: 'lite' | 'basic' | 'standard-1' | 'standard-2' | 'standard-3' | 'standard-4';
36
+ /** Skip identity generation (for testing) */
37
+ skipIdentity?: boolean;
38
+ }
39
+ /**
40
+ * Generated identity from Ed25519 keypair
41
+ */
42
+ export interface MoltiIdentity {
43
+ /** DID:key identifier (e.g., "did:key:z6Mk...") */
44
+ did: string;
45
+ /** Base64-encoded Ed25519 public key */
46
+ publicKey: string;
47
+ /** Base64-encoded Ed25519 private key */
48
+ privateKey: string;
49
+ }
50
+ /**
51
+ * Result of project generation
52
+ */
53
+ export interface MoltiGenerateResult {
54
+ /** All generated files */
55
+ files: GeneratedFile[];
56
+ /** Generated identity (DID, keys) */
57
+ identity: MoltiIdentity;
58
+ /** Secrets that should be added to GitHub Secrets (not committed to repo) */
59
+ secrets: Record<string, string>;
60
+ }
61
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB;IACpB,QAAQ,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,4EAA4E;IAC5E,WAAW,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mDAAmD;IACnD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qCAAqC;IACrC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,yCAAyC;IACzC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,YAAY,GAAG,YAAY,GAAG,YAAY,GAAG,YAAY,CAAC;IAC5F,6CAA6C;IAC7C,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,0BAA0B;IAC1B,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,qCAAqC;IACrC,QAAQ,EAAE,aAAa,CAAC;IACxB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC"}
package/dist/types.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Types for @kya-os/create-molti
3
+ *
4
+ * Defines the configuration options and result types
5
+ * for scaffolding Moltworker projects with MCP-I identity.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}