|
| 1 | +--- |
| 2 | +name: Driver Request |
| 3 | +about: Request a driver on Puter |
| 4 | +title: '' |
| 5 | +labels: '' |
| 6 | +assignees: '' |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## Name of Driver |
| 11 | + |
| 12 | +Description of driver |
| 13 | + |
| 14 | +### What is a Puter Driver? |
| 15 | + |
| 16 | +Let's call the operating system on your computer/phone/etc a "Low-Level Device Operating System" or LLDOS. Puter is a "High-Level Distributed Operating System" or HLDOS. Where an LLDOS coordinates access to hardware, an HLDOS coordinates access to services and network resources. In Puter, **drivers** are integrations with third-party services, network devices, or even the underlying LLDOS where a Puter node is hosted. |
| 17 | + |
| 18 | +Puter drivers have two parts: |
| 19 | +- a driver interface |
| 20 | +- a driver implementation |
| 21 | + |
| 22 | +Driver interfaces are the "types" of drivers. For example, an LLDOS may have multiple different drivers that are recognized as "printers". "printer" is the interface or type. Some examples of driver interfaces on Puter include: |
| 23 | +- Chat completion interface for AI / LLMs (`puter-chat-completion`) |
| 24 | +- Providers of OCR (optical character recognition) (`puter-ocr`) |
| 25 | +- Providers of voice synthesis / text-to-speech (`puter-tts`) |
| 26 | +- Key-value storage (`puter-kv`) |
| 27 | +- CRUD (+ Query) interface for Puter-native data types (`crud-q`) |
| 28 | +- Execute code on external interpreters/compilers (`puter-exec`) |
| 29 | + |
| 30 | +Driver implementations are [backend services](https://github.com/HeyPuter/puter/wiki/src-backend-contributors-modules) that define a static member called `IMPLEMENTS`, where this member contains an entry for a registered interface. (this may sound confusing at first - it will be more clear after reading the resources below) |
| 31 | + |
| 32 | +### Building Drivers |
| 33 | + |
| 34 | +- [Written documentation on building drivers](https://github.com/HeyPuter/puter/wiki/src-backend-howto_make_driver) |
| 35 | +- [Video tutorial on building drivers](https://www.youtube.com/watch?v=8znQmrKgNxA&t=78s) |
| 36 | + |
| 37 | +Note: some of this documentation may tell you to add an interface to `interfaces.js` inside the drivers directory. Don't do this; instead register interfaces as is done [here](https://github.com/HeyPuter/puter/blob/f0434435c4c12ba70bb86437428f82c72bb35bd0/src/backend/src/modules/puterai/AIInterfaceService.js), [here](https://github.com/HeyPuter/puter/blob/ce0ab02f39f16cbb99f4b7e8ee90196d443040ff/src/backend/src/modules/convert/ConvertAPIService.js#L14), [here](https://github.com/HeyPuter/puter/blob/feb2ca126f50d9642c08ce7800259b49b9ecb0db/src/backend/src/modules/mail/UserSendMailService.js#L12), and [here](https://github.com/HeyPuter/puter/blob/81ee52b00fea4b58b5e97ccec59b049a251c440a/src/backend/src/modules/puterexec/ExecInterfaceService.js). |
| 38 | + |
| 39 | +### Examples of Drivers |
| 40 | + |
| 41 | +- The [puterai module](https://github.com/HeyPuter/puter/blob/ec0a72114382a78d82bc7d0156daf1a2a003d567/src/backend/src/modules/puterai) registers a number of driver interfaces and implementations. |
| 42 | +- The [`hello-world` service](https://github.com/HeyPuter/puter/blob/6a184d52b47d80f23babaa94f9ccc32ed6ea14be/src/backend/src/services/HelloWorldService.js) implements the `hello-world` driver interface as an example. This is a little outdated because: |
| 43 | + - HelloWorldService should probably be in a separate module. (ex: a module called `examples`) |
| 44 | + - The `hello-world` interface is defined in this legacy [interfaces.js](https://github.com/HeyPuter/puter/blob/6a184d52b47d80f23babaa94f9ccc32ed6ea14be/src/backend/src/services/drivers/interfaces.js) file, but it should be registered by HelloWorldService instead like we do in [AIInterfaceService](https://github.com/HeyPuter/puter/blob/f0434435c4c12ba70bb86437428f82c72bb35bd0/src/backend/src/modules/puterai/AIInterfaceService.js). |
| 45 | +- For some drivers it makes sense to put them in a separate module. [here is a template for modules](https://github.com/HeyPuter/puter/blob/6a184d52b47d80f23babaa94f9ccc32ed6ea14be/src/backend/src/modules/template). |
| 46 | + - Driver interfaces of a similar nature are often placed in the same module. For example, the `puterai` module has interfaces for LLMs, TTS, etc. It is assumed that AI service providers will often provide multiple of these types of services, so if you already have an API key you should be able to access all the provider's services with just this module. |
0 commit comments