mirror of
https://github.com/HeyPuter/puter.git
synced 2025-02-02 14:18:43 +08:00
dev: add puterexec module
This commit is contained in:
parent
4d826c0602
commit
81ee52b00f
@ -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,
|
||||
|
||||
|
44
src/backend/src/modules/puterexec/ExecInterfaceService.js
Normal file
44
src/backend/src/modules/puterexec/ExecInterfaceService.js
Normal 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;
|
16
src/backend/src/modules/puterexec/PuterExecModule.js
Normal file
16
src/backend/src/modules/puterexec/PuterExecModule.js
Normal 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
|
||||
};
|
Loading…
Reference in New Issue
Block a user