diff --git a/README.md b/README.md index 489b958..26cf9fc 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/package.json b/package.json index ec3bd61..04bd4bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "omnitool", - "version": "0.6.3", + "version": "1.0.0", "packageManager": "yarn@4.0.2", "private": true, "workspaces": [ diff --git a/packages/omni-sdk/package.json b/packages/omni-sdk/package.json index 17e721b..5ac7433 100644 --- a/packages/omni-sdk/package.json +++ b/packages/omni-sdk/package.json @@ -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", diff --git a/packages/omni-server/dist/run.js b/packages/omni-server/dist/run.js index 5ca586f..c2fb983 100644 --- a/packages/omni-server/dist/run.js +++ b/packages/omni-server/dist/run.js @@ -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"; @@ -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(); @@ -15293,7 +15294,7 @@ var bootstrap = async () => { "--fastifyopt ", "Advanced Fastify options - JSON Object", JSON.stringify({ bodyLimit: 32 * 1024 * 1024 }) - ).option("-p, --port ", "Overwrite the listening port", "1688").option("--openBrowser").option("-nx, --noExtensions", "Disable all (non core) extensions").option("-s, --secure ", "Enforce secure connection", false).option("--dburl ", "Connection URL to the DB").option("--dbuser ", "DB admin user", "admin@local.host").option("--viteProxy ", "Specify vite debugger URL").option("--autologin", "Autologin user").option("--uncensored", "Disable NSFW protections").option("--flushLogs", "Flush logs to DB").requiredOption("-l, --listen ", "Sets the interface the host listens on"); + ).option("-p, --port ", "Overwrite the listening port", "1688").option("--openBrowser").option("-nx, --noExtensions", "Disable all (non core) extensions").option("-s, --secure ", "Enforce secure connection", false).option("--dburl ", "Connection URL to the DB").option("--dbuser ", "DB admin user", "admin@local.host").option("--viteProxy ", "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 ", "Create a user with the given username and password in the format username:password").requiredOption("-l, --listen ", "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); @@ -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": @@ -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 "); + 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); diff --git a/packages/omni-server/package.json b/packages/omni-server/package.json index 3161fdc..f37942c 100644 --- a/packages/omni-server/package.json +++ b/packages/omni-server/package.json @@ -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": { diff --git a/packages/omni-server/scripts/generateJwtToken.js b/packages/omni-server/scripts/generateJwtToken.js index 3722e1d..c8da96a 100644 --- a/packages/omni-server/scripts/generateJwtToken.js +++ b/packages/omni-server/scripts/generateJwtToken.js @@ -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 } ] diff --git a/packages/omni-server/src/integrations/WorkflowIntegration/WorkflowIntegration.ts b/packages/omni-server/src/integrations/WorkflowIntegration/WorkflowIntegration.ts index f8e7dc3..49ef8aa 100644 --- a/packages/omni-server/src/integrations/WorkflowIntegration/WorkflowIntegration.ts +++ b/packages/omni-server/src/integrations/WorkflowIntegration/WorkflowIntegration.ts @@ -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'; @@ -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(); diff --git a/packages/omni-server/src/run.ts b/packages/omni-server/src/run.ts index 8b5aa75..b6bb2cb 100644 --- a/packages/omni-server/src/run.ts +++ b/packages/omni-server/src/run.ts @@ -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'; @@ -108,6 +109,8 @@ const bootstrap = async (): Promise => { .option('--autologin', 'Autologin user') .option('--uncensored', 'Disable NSFW protections') .option('--flushLogs', 'Flush logs to DB') + .option('--noupdate', 'Disable update checks') + .option('--createUser ', 'Create a user with the given username and password in the format username:password') .requiredOption('-l, --listen ', 'Sets the interface the host listens on'); program.action((options) => { @@ -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()) { @@ -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 '); + 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); diff --git a/packages/omni-shared/package.json b/packages/omni-shared/package.json index 42e947a..a2b365f 100644 --- a/packages/omni-shared/package.json +++ b/packages/omni-shared/package.json @@ -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", diff --git a/packages/omni-sockets/package.json b/packages/omni-sockets/package.json index 9ec9c27..89f9eb2 100644 --- a/packages/omni-sockets/package.json +++ b/packages/omni-sockets/package.json @@ -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", diff --git a/packages/omni-ui/omni-client-services/package.json b/packages/omni-ui/omni-client-services/package.json index fa8ec0d..78dc6ac 100644 --- a/packages/omni-ui/omni-client-services/package.json +++ b/packages/omni-ui/omni-client-services/package.json @@ -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", diff --git a/packages/omni-ui/omni-web/package.json b/packages/omni-ui/omni-web/package.json index b79a894..eece547 100644 --- a/packages/omni-ui/omni-web/package.json +++ b/packages/omni-ui/omni-web/package.json @@ -1,7 +1,7 @@ { "name": "omni-web", "private": true, - "version": "0.0.1", + "version": "1.0.0", "type": "module", "scripts": { "dev": "vite --host", diff --git a/setup/launcher.js b/setup/launcher.js index ee81beb..da172d0 100644 --- a/setup/launcher.js +++ b/setup/launcher.js @@ -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;