Skip to content

Commit

Permalink
OmniTool 1.0.0 Update
Browse files Browse the repository at this point in the history
1. API updates
   - Generate jwt token script now takes multiple recipe ids
   - generateJwtToken script workflowId payload is optional

2. Stability Fixes and Documentation
   - Moved to stable release v1.0!
   - Fixed null assertion on recipe export
   - Updated README.md
   - Add GitHub Actions for automatic release
  • Loading branch information
weiyi committed Jan 10, 2024
1 parent c4034c2 commit 923d677
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 16 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Currently supported (v. 0.6.0) :

Currently supported Local APIs:
* LM-studio
* Ollama
* Oobabooga Text Generation UI
* Automatic1111/SD-Next
* Paperless-ng
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "omnitool",
"version": "0.6.3",
"version": "1.0.0",
"packageManager": "yarn@4.0.2",
"private": true,
"workspaces": [
Expand Down
2 changes: 1 addition & 1 deletion packages/omni-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "omni-sdk",
"packageManager": "yarn@4.0.2",
"version": "0.6.3",
"version": "1.0.0",
"type": "module",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down
26 changes: 24 additions & 2 deletions packages/omni-server/dist/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -7582,6 +7582,7 @@ var loadServerConfig = (defaultFile) => {
import { exec } from "child_process";
import os3 from "os";
import fs8 from "node:fs";
import assert3 from "node:assert";

// src/services/APIService.ts
import { APIService } from "omni-shared";
Expand Down Expand Up @@ -15199,7 +15200,7 @@ var WorkflowIntegration = class extends APIIntegration {
}
const exportFile = new KVStorage(this, {
// @ts-ignore
dbPath: this.config.tempExportDir ?? this.config.settings.paths?.tmpPath ?? "./data.local/tmp",
dbPath: this.config.tempExportDir ?? this.config.settings?.paths?.tmpPath ?? "./data.local/tmp",
dbName: fileName
});
await exportFile.init();
Expand Down Expand Up @@ -15293,7 +15294,7 @@ var bootstrap = async () => {
"--fastifyopt <fastifyopt>",
"Advanced Fastify options - JSON Object",
JSON.stringify({ bodyLimit: 32 * 1024 * 1024 })
).option("-p, --port <port>", "Overwrite the listening port", "1688").option("--openBrowser").option("-nx, --noExtensions", "Disable all (non core) extensions").option("-s, --secure <secure>", "Enforce secure connection", false).option("--dburl <url>", "Connection URL to the DB").option("--dbuser <user>", "DB admin user", "admin@local.host").option("--viteProxy <url>", "Specify vite debugger URL").option("--autologin", "Autologin user").option("--uncensored", "Disable NSFW protections").option("--flushLogs", "Flush logs to DB").requiredOption("-l, --listen <addr>", "Sets the interface the host listens on");
).option("-p, --port <port>", "Overwrite the listening port", "1688").option("--openBrowser").option("-nx, --noExtensions", "Disable all (non core) extensions").option("-s, --secure <secure>", "Enforce secure connection", false).option("--dburl <url>", "Connection URL to the DB").option("--dbuser <user>", "DB admin user", "admin@local.host").option("--viteProxy <url>", "Specify vite debugger URL").option("--autologin", "Autologin user").option("--uncensored", "Disable NSFW protections").option("--flushLogs", "Flush logs to DB").option("--noupdate", "Disable update checks").option("--createUser <userpass>", "Create a user with the given username and password in the format username:password").requiredOption("-l, --listen <addr>", "Sets the interface the host listens on");
program.action((options) => {
omnilog.setCustomLevel("emittery", options.emittery ? OmniLogLevels.verbose : OmniLogLevels.silent);
omnilog.level = options.verbose ? OmniLogLevels.verbose : Number.parseInt(options.loglevel);
Expand Down Expand Up @@ -15453,6 +15454,9 @@ var boot = async (options) => {
await server.start();
omnilog.status_success(`Server has started and is ready to accept connections on ${listenOn.origin}`);
omnilog.status_success("Ctrl-C to quit.");
if (await headlesscommands(server, options)) {
process.exit(0);
}
if (options.openBrowser) {
switch (os3.platform()) {
case "win32":
Expand All @@ -15464,6 +15468,24 @@ var boot = async (options) => {
}
}
};
var headlesscommands = async (server, options) => {
if (options.createUser) {
omnilog.status_start("--- Running Command - CreateUser -----");
const authService = server.integrations.get("auth");
const tokens = options.createUser.split(":");
assert3(tokens.length === 2, "Invalid username:password format. Expecting format <username:password>");
omnilog.status_start(`Creating ${tokens[0]}`);
const existUser = await authService.getUserByUsername(tokens[0]);
if (existUser !== null) {
omnilog.status_success(`User ${tokens[0]} already exists`);
return true;
}
const user = await authService.handleRegister(tokens[0], tokens[1]);
omnilog.status_success(`Created ${user.username} with ID ${user.id}`);
return true;
}
return false;
};
bootstrap().catch((err) => {
omnilog.trace();
omnilog.error("Caught unhandled exception during bootstrap: ", err);
Expand Down
2 changes: 1 addition & 1 deletion packages/omni-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "omni-server",
"version": "0.6.3",
"version": "1.0.0",
"packageManager": "yarn@4.0.2",
"main": "./dist/run.js",
"engines": {
Expand Down
20 changes: 16 additions & 4 deletions packages/omni-server/scripts/generateJwtToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,26 @@ const script = {
// throw new Error('Action not permitted')
// }
// }
const [action, subject, /*workflowId*/, expiresIn] = payload
const [action, subject, expiresIn, ...id] = payload
let conditions
if (id) {
if (Array.isArray(id)) {
conditions = {
id: {
$in: id
}
}
} else {
conditions = {
id
}
}
}
const scopes = [
{
action,
subject,
//conditions: {
// id: workflowId
//}
conditions
}
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
type IntegrationsManager,
type User
} from 'omni-shared';
import * as Rete from 'rete';
import { v4 as uuidv4 } from 'uuid';
import { OMNITOOL_DOCUMENT_TYPES, type DBService, type QueryResult } from '../../services/DBService.js';
import { APIIntegration, type IAPIIntegrationConfig } from '../APIIntegration.js';
Expand Down Expand Up @@ -402,7 +401,7 @@ class WorkflowIntegration extends APIIntegration {
const exportFile = new KVStorage(this, {

// @ts-ignore
dbPath: this.config.tempExportDir ?? this.config.settings.paths?.tmpPath ?? './data.local/tmp',
dbPath: this.config.tempExportDir ?? this.config.settings?.paths?.tmpPath ?? './data.local/tmp',
dbName: fileName
});
await exportFile.init();
Expand Down
27 changes: 27 additions & 0 deletions packages/omni-server/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { loadServerConfig, type IServerConfig } from './loadConfig.js';
import { exec } from 'child_process';
import os from 'os';
import fs from 'node:fs';
import assert from 'node:assert';

// Services
import { APIServerService, type IAPIServerServiceConfig } from './services/APIService.js';
Expand Down Expand Up @@ -108,6 +109,8 @@ const bootstrap = async (): Promise<void> => {
.option('--autologin', 'Autologin user')
.option('--uncensored', 'Disable NSFW protections')
.option('--flushLogs', 'Flush logs to DB')
.option('--noupdate', 'Disable update checks')
.option('--createUser <userpass>', 'Create a user with the given username and password in the format username:password')
.requiredOption('-l, --listen <addr>', 'Sets the interface the host listens on');

program.action((options) => {
Expand Down Expand Up @@ -321,6 +324,11 @@ const boot = async (options: OptionValues) => {
omnilog.status_success(`Server has started and is ready to accept connections on ${listenOn.origin}`);
omnilog.status_success('Ctrl-C to quit.');

// headless commands mode
if (await headlesscommands(server, options)) {
process.exit(0);
}

// open default browser
if (options.openBrowser) {
switch (os.platform()) {
Expand All @@ -334,6 +342,25 @@ const boot = async (options: OptionValues) => {
}
};

const headlesscommands = async (server:Server, options: OptionValues) => {
if (options.createUser) {
omnilog.status_start('--- Running Command - CreateUser -----');
const authService = server.integrations.get('auth') as AuthIntegration;
const tokens = options.createUser.split(':');
assert(tokens.length === 2, 'Invalid username:password format. Expecting format <username:password>');
omnilog.status_start(`Creating ${tokens[0]}`);
const existUser = await authService.getUserByUsername(tokens[0]);
if (existUser !== null) {
omnilog.status_success(`User ${tokens[0]} already exists`);
return true;
}
const user = await authService.handleRegister(tokens[0], tokens[1]);
omnilog.status_success(`Created ${user.username} with ID ${user.id}`);
return true;
}
return false;
}

bootstrap().catch((err) => {
omnilog.trace();
omnilog.error('Caught unhandled exception during bootstrap: ', err);
Expand Down
2 changes: 1 addition & 1 deletion packages/omni-shared/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "omni-shared",
"packageManager": "yarn@4.0.2",
"version": "0.0.1",
"version": "1.0.0",
"type": "module",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/omni-sockets/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "omni-sockets",
"packageManager": "yarn@4.0.2",
"version": "0.0.1",
"version": "1.0.0",
"private": true,
"type": "module",
"main": "./lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/omni-ui/omni-client-services/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "omni-client-services",
"version": "0.0.1",
"version": "1.0.0",
"packageManager": "yarn@4.0.2",
"private": true,
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/omni-ui/omni-web/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "omni-web",
"private": true,
"version": "0.0.1",
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "vite --host",
Expand Down
10 changes: 9 additions & 1 deletion setup/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,15 @@ async function run() {
break;
case NodeProcessEnv.production:
server_entry = 'dist/run.js';
await check_for_updates();
// Only check for updates if --noupdate is not present in args
if (!args.includes('--noupdate'))
{
await check_for_updates();
}
else
{
console.log('Skipping update check...');
}
ensure_wasm();
run_production([]);
break;
Expand Down

0 comments on commit 923d677

Please sign in to comment.