dev: add puterexec module

This commit is contained in:
KernelDeimos 2025-01-27 15:38:29 -05:00
parent 4d826c0602
commit 81ee52b00f
3 changed files with 62 additions and 0 deletions

View File

@ -36,6 +36,7 @@ const { AppsModule } = require("./src/modules/apps/AppsModule.js");
const { DevelopmentModule } = require("./src/modules/development/DevelopmentModule.js");
const { HostOSModule } = require("./src/modules/hostos/HostOSModule.js");
const { InternetModule } = require("./src/modules/internet/InternetModule.js");
const { PuterExecModule } = require("./src/modules/puterexec/PuterExecModule.js");
module.exports = {
helloworld: () => {
@ -68,6 +69,7 @@ module.exports = {
SelfHostedModule,
TestDriversModule,
PuterAIModule,
PuterExecModule,
BroadcastModule,
InternetModule,

View File

@ -0,0 +1,44 @@
const BaseService = require("../../services/BaseService");
class ExecInterfaceService extends BaseService {
async ['__on_driver.register.interfaces'] () {
const svc_registry = this.services.get('registry');
const col_interfaces = svc_registry.get('interfaces');
col_interfaces.set('puter-exec', {
description: 'Execute code with various languages.',
methods: {
about: {
description: 'Get information about the execution service.',
parameters: {},
result: { type: 'json' },
},
supported: {
description: 'List supported languages and their details.',
parameters: {},
result: { type: 'json' },
},
exec: {
description: 'Execute code with a specific language.',
parameters: {
runtime: {
type: 'string',
description: 'Name of programming language or ID of runtime.',
},
code: {
type: 'string',
description: 'Code to execute.',
},
stdin: {
type: 'string',
description: 'Input to provide to the code.',
}
},
result: {},
},
}
});
}
}
module.exports = ExecInterfaceService;

View File

@ -0,0 +1,16 @@
const config = require("../../config");
const { AdvancedBase } = require("@heyputer/putility");
class PuterExecModule extends AdvancedBase {
async install (context) {
const services = context.get('services');
const ExecInterfaceService = require('./ExecInterfaceService');
services.registerService('__exec-interfaces', ExecInterfaceService);
}
}
module.exports = {
PuterExecModule
};