Skip to content
Merged

. #7

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions mods/mods_available/kdmod/CustomPuterService.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ const path = require('path');

class CustomPuterService extends use.Service {
async _init () {
const svc_commands = this.services.get('commands');
this._register_commands(svc_commands);

const svc_puterHomepage = this.services.get('puter-homepage');
svc_puterHomepage.register_script('/custom-gui/main.js');
}
Expand All @@ -36,17 +33,6 @@ class CustomPuterService extends use.Service {
express.static(path.join(__dirname, 'gui')),
);
}
_register_commands (commands) {
commands.registerCommands('o', [
{
id: 'k',
description: '',
handler: async (_, log) => {
log.log('kdmod is enabled');
},
},
]);
}
}

module.exports = { CustomPuterService };
61 changes: 20 additions & 41 deletions mods/mods_available/kdmod/ShareTestService.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,13 @@ class ShareTestService extends use.Service {
};

async _init () {
const svc_commands = this.services.get('commands');
this._register_commands(svc_commands);

this.scenarios = require('./data/sharetest_scenarios');

const svc_db = this.services.get('database');
this.db = svc_db.get(svc_db.DB_WRITE, 'share-test');
}

_register_commands (commands) {
commands.registerCommands('share-test', [
{
id: 'start',
description: '',
handler: async (_, log) => {
const results = await this.runit();

for ( const result of results ) {
log.log(`=== ${result.title} ===`);
if ( ! result.report ) {
log.log('\x1B[32;1mSUCCESS\x1B[0m');
continue;
}
log.log('\x1B[31;1mSTOPPED\x1B[0m at ' +
`${result.report.step}: ${
result.report.report.message}`);
}
},
},
]);
}

async runit () {
await this.teardown_();
await this.setup_();
Expand Down Expand Up @@ -127,17 +102,19 @@ class ShareTestService extends use.Service {
}

async create_test_user_ (username) {
await this.db.write(`
await this.db.write(
`
INSERT INTO user (uuid, username, email, free_storage, password)
VALUES (?, ?, ?, ?, ?)
`,
[
this.modules.uuidv4(),
username,
`${username}@example.com`,
1024 * 1024 * 500, // 500 MiB
this.modules.uuidv4(),
]);
[
this.modules.uuidv4(),
username,
`${username}@example.com`,
1024 * 1024 * 500, // 500 MiB
this.modules.uuidv4(),
],
);
const user = await get_user({ username });
const svc_user = this.services.get('user');
await svc_user.generate_default_fsentries({ user });
Expand All @@ -152,16 +129,18 @@ class ShareTestService extends use.Service {
}

// API for scenarios
async ['__scenario:create-example-file'] (
async '__scenario:create-example-file' (
{ actor, user },
{ name, contents },
) {
const svc_fs = this.services.get('filesystem');
const parent = await svc_fs.node(new NodePathSelector(`/${user.username}/Desktop`));
console.log('test -> create-example-file',
user,
name,
contents);
console.log(
'test -> create-example-file',
user,
name,
contents,
);
const buffer = Buffer.from(contents);
const file = {
size: buffer.length,
Expand All @@ -178,7 +157,7 @@ class ShareTestService extends use.Service {
file,
});
}
async ['__scenario:assert-no-access'] (
async '__scenario:assert-no-access' (
{ actor, user },
{ path },
) {
Expand All @@ -197,14 +176,14 @@ class ShareTestService extends use.Service {
return { message: 'expected error, got none' };
}
}
async ['__scenario:grant'] (
async '__scenario:grant' (
{ actor, user },
{ to, permission },
) {
const svc_permission = this.services.get('permission');
await svc_permission.grant_user_user_permission(actor, to, permission, {}, {});
}
async ['__scenario:assert-access'] (
async '__scenario:assert-access' (
{ actor, user },
{ path, level },
) {
Expand Down
7 changes: 0 additions & 7 deletions src/backend/src/modules/core/AlarmService.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ class AlarmService extends BaseService {

}

/**
* AlarmService registers its commands at the consolidation phase because
* the '_init' method of CommandService may not have been called yet.
*/
'__on_boot.consolidation' () {
}

adapt_id_ (id) {
let shorten = true;

Expand Down
7 changes: 0 additions & 7 deletions src/backend/src/modules/core/PagerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ class PagerService extends BaseService {

}

/**
* PagerService registers its commands at the consolidation phase because
* the '_init' method of CommandService may not have been called yet.
*/
'__on_boot.consolidation' () {
}

/**
* Initializes the PagerService instance by setting the configuration and
* initializing an empty alert handler array.
Expand Down
1 change: 0 additions & 1 deletion src/backend/src/modules/test-core/TestCoreModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { AuthService } from '../../services/auth/AuthService.js';
import { GroupService } from '../../services/auth/GroupService.js';
import { PermissionService } from '../../services/auth/PermissionService.js';
import { TokenService } from '../../services/auth/TokenService.js';
import { CommandService } from '../../services/CommandService.js';
import { SqliteDatabaseAccessService } from '../../services/database/SqliteDatabaseAccessService.js';
import { DetailProviderService } from '../../services/DetailProviderService.js';
import { DynamoKVStoreWrapper } from '../../services/DynamoKVStore/DynamoKVStoreWrapper.js';
Expand Down
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -158,48 +158,47 @@ export class OpenRouterProvider implements IChatProvider {
}

async models () {
return [] as IChatModel[];
// let models = kv.get('openrouterChat:models');
// if ( ! models ) {
// try {
// const resp = await axios.request({
// method: 'GET',
// url: `${this.#apiBaseUrl}/models`,
// });

// models = resp.data.data;
// kv.set('openrouterChat:models', models);
// } catch (e) {
// console.log(e);
// }
// }
// const coerced_models: IChatModel[] = [];
// for ( const model of models ) {
// if ( (model.id as string).includes('openrouter/auto') ) {
// continue;
// }
// const overridenModel = OPEN_ROUTER_MODEL_OVERRIDES.find(m => m.id === `openrouter:${model.id}`);
// const microcentCosts = Object.fromEntries(Object.entries(model.pricing).map(([k, v]) => [k, Math.round((v as number < 0 ? 1 : v as number) * 1_000_000 * 100)])) ;
// if ( ! microcentCosts.request ) {
// microcentCosts.request = 0;
// }
// coerced_models.push({
// id: `openrouter:${model.id}`,
// name: `${model.name} (OpenRouter)`,
// aliases: [model.id, model.name, `openrouter/${model.id}`, model.id.split('/').slice(1).join('/')],
// context: model.context_length,
// max_tokens: model.top_provider.max_completion_tokens,
// costs_currency: 'usd-cents',
// input_cost_key: 'prompt',
// output_cost_key: 'completion',
// costs: {
// tokens: 1_000_000,
// ...microcentCosts,
// },
// ...overridenModel,
// });
// }
// return coerced_models;
let models = kv.get('openrouterChat:models');
if ( ! models ) {
try {
const resp = await axios.request({
method: 'GET',
url: `${this.#apiBaseUrl}/models`,
});

models = resp.data.data;
kv.set('openrouterChat:models', models);
} catch (e) {
console.log(e);
}
}
const coerced_models: IChatModel[] = [];
for ( const model of models ) {
if ( (model.id as string).includes('openrouter/auto') ) {
continue;
}
const overridenModel = OPEN_ROUTER_MODEL_OVERRIDES.find(m => m.id === `openrouter:${model.id}`);
const microcentCosts = Object.fromEntries(Object.entries(model.pricing).map(([k, v]) => [k, Math.round((v as number < 0 ? 1 : v as number) * 1_000_000 * 100)])) ;
if ( ! microcentCosts.request ) {
microcentCosts.request = 0;
}
coerced_models.push({
id: `openrouter:${model.id}`,
name: `${model.name} (OpenRouter)`,
aliases: [model.id, model.name, `openrouter/${model.id}`, model.id.split('/').slice(1).join('/')],
context: model.context_length,
max_tokens: model.top_provider.max_completion_tokens,
costs_currency: 'usd-cents',
input_cost_key: 'prompt',
output_cost_key: 'completion',
costs: {
tokens: 1_000_000,
...microcentCosts,
},
...overridenModel,
});
}
return coerced_models;
}
checkModeration (_text: string): ReturnType<IChatProvider['checkModeration']> {
throw new Error('Method not implemented.');
Expand Down
Loading
Loading