Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 5e7004c

Browse files
committed
feat: cortex single executable binary
1 parent e421676 commit 5e7004c

17 files changed

+21
-13
lines changed

cortex-js/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"scripts": {
1212
"dev": "nest dev",
1313
"build": "yarn build:extensions && nest build && cpx \"cpuinfo/bin/**\" dist/bin",
14+
"build:binary": "yarn build && nexe dist/src/command.js --build --python=$(which python3) -o dist/cortex",
1415
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
1516
"build:extensions": "run-script-os",
1617
"build:extensions:windows": "powershell -command \"$jobs = Get-ChildItem -Path './src/extensions' -Directory | ForEach-Object { Start-Job -Name ($_.Name) -ScriptBlock { param($_dir); try { Set-Location $_dir; yarn; yarn build; Write-Output 'Build successful in ' + $_dir } catch { Write-Error 'Error in ' + $_dir; throw } } -ArgumentList $_.FullName }; $jobs | Wait-Job; $jobs | ForEach-Object { Receive-Job -Job $_ -Keep } | ForEach-Object { Write-Host $_ }; $failed = $jobs | Where-Object { $_.State -ne 'Completed' -or $_.ChildJobs[0].JobStateInfo.State -ne 'Completed' }; if ($failed) { Exit 1 }\"",
@@ -86,6 +87,7 @@
8687
"hanbi": "^1.0.3",
8788
"jest": "^29.5.0",
8889
"nest-commander-testing": "^3.3.0",
90+
"nexe": "^4.0.0-rc.6",
8991
"prettier": "^3.0.0",
9092
"run-script-os": "^1.1.6",
9193
"source-map-support": "^0.5.21",

cortex-js/src/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { ModelsController } from './infrastructure/controllers/models.controller
2626
import { ThreadsController } from './infrastructure/controllers/threads.controller';
2727
import { StatusController } from './infrastructure/controllers/status.controller';
2828
import { ProcessController } from './infrastructure/controllers/process.controller';
29-
import { DownloadManagerModule } from './download-manager/download-manager.module';
29+
import { DownloadManagerModule } from './infrastructure/services/download-manager/download-manager.module';
3030

3131
@Module({
3232
imports: [

cortex-js/src/command.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { UtilModule } from './util/util.module';
3333
import { EmbeddingCommand } from './infrastructure/commanders/embeddings.command';
3434
import { BenchmarkCommand } from './infrastructure/commanders/benchmark.command';
3535
import { EventEmitterModule } from '@nestjs/event-emitter';
36-
import { DownloadManagerModule } from './download-manager/download-manager.module';
36+
import { DownloadManagerModule } from './infrastructure/services/download-manager/download-manager.module';
3737
import { ServeStopCommand } from './infrastructure/commanders/sub-commands/serve-stop.command';
3838

3939
@Module({

cortex-js/src/infrastructure/controllers/chat.controller.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { DatabaseModule } from '../database/database.module';
55
import { ExtensionModule } from '../repositories/extensions/extension.module';
66
import { ModelRepositoryModule } from '../repositories/models/model.module';
77
import { HttpModule } from '@nestjs/axios';
8-
import { DownloadManagerModule } from '@/download-manager/download-manager.module';
8+
import { DownloadManagerModule } from '@/infrastructure/services/download-manager/download-manager.module';
99
import { EventEmitterModule } from '@nestjs/event-emitter';
1010
import { TelemetryModule } from '@/usecases/telemetry/telemetry.module';
1111

cortex-js/src/infrastructure/controllers/embeddings.controller.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { DatabaseModule } from '../database/database.module';
55
import { ModelRepositoryModule } from '../repositories/models/model.module';
66
import { ExtensionModule } from '../repositories/extensions/extension.module';
77
import { HttpModule } from '@nestjs/axios';
8-
import { DownloadManagerModule } from '@/download-manager/download-manager.module';
8+
import { DownloadManagerModule } from '@/infrastructure/services/download-manager/download-manager.module';
99
import { EventEmitterModule } from '@nestjs/event-emitter';
1010
import { TelemetryModule } from '@/usecases/telemetry/telemetry.module';
1111

cortex-js/src/infrastructure/controllers/events.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
ModelStatus,
1010
ModelStatusAndEvent,
1111
} from '@/domain/models/model.event';
12-
import { DownloadManagerService } from '@/download-manager/download-manager.service';
12+
import { DownloadManagerService } from '@/infrastructure/services/download-manager/download-manager.service';
1313
import { ModelsUsecases } from '@/usecases/models/models.usecases';
1414
import { Controller, Sse } from '@nestjs/common';
1515
import { EventEmitter2 } from '@nestjs/event-emitter';

cortex-js/src/infrastructure/controllers/models.controller.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { FileManagerModule } from '@/infrastructure/services/file-manager/file-m
77
import { HttpModule } from '@nestjs/axios';
88
import { CortexUsecases } from '@/usecases/cortex/cortex.usecases';
99
import { ModelRepositoryModule } from '../repositories/models/model.module';
10-
import { DownloadManagerModule } from '@/download-manager/download-manager.module';
10+
import { DownloadManagerModule } from '@/infrastructure/services/download-manager/download-manager.module';
1111
import { EventEmitterModule } from '@nestjs/event-emitter';
1212
import { TelemetryModule } from '@/usecases/telemetry/telemetry.module';
1313
import { UtilModule } from '@/util/util.module';

cortex-js/src/infrastructure/database/mysql-database.providers.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { databaseName } from '@/infrastructure/constants/cortex';
22
import { DataSource } from 'typeorm';
3+
import { ThreadEntity } from '../entities/thread.entity';
4+
import { AssistantEntity } from '../entities/assistant.entity';
5+
import { MessageEntity } from '../entities/message.entity';
36

47
export const mysqlDatabaseProviders = [
58
{
@@ -12,7 +15,7 @@ export const mysqlDatabaseProviders = [
1215
username: 'root',
1316
password: '',
1417
database: databaseName,
15-
entities: [__dirname + '/../**/*.entity{.ts,.js}'],
18+
entities: [ThreadEntity, AssistantEntity, MessageEntity],
1619
synchronize: process.env.NODE_ENV !== 'production',
1720
});
1821

cortex-js/src/infrastructure/database/sqlite-database.providers.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { FileManagerService } from '@/infrastructure/services/file-manager/file-
22
import { databaseFile } from '@/infrastructure/constants/cortex';
33
import { join } from 'path';
44
import { DataSource } from 'typeorm';
5+
import { ThreadEntity } from '../entities/thread.entity';
6+
import { AssistantEntity } from '../entities/assistant.entity';
7+
import { MessageEntity } from '../entities/message.entity';
58

69
export const sqliteDatabaseProviders = [
710
{
@@ -14,7 +17,7 @@ export const sqliteDatabaseProviders = [
1417
type: 'sqlite',
1518
database: sqlitePath,
1619
synchronize: process.env.NODE_ENV !== 'production',
17-
entities: [__dirname + '/../**/*.entity{.ts,.js}'],
20+
entities: [ThreadEntity, AssistantEntity, MessageEntity],
1821
});
1922

2023
return dataSource.initialize();

cortex-js/src/infrastructure/repositories/models/model.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { HttpModule } from '@nestjs/axios';
44
import { ModelRepository } from '@/domain/repositories/model.interface';
55
import { ModelRepositoryImpl } from './model.repository';
66
import { FileManagerModule } from '@/infrastructure/services/file-manager/file-manager.module';
7-
import { DownloadManagerModule } from '@/download-manager/download-manager.module';
7+
import { DownloadManagerModule } from '@/infrastructure/services/download-manager/download-manager.module';
88

99
@Module({
1010
imports: [

0 commit comments

Comments
 (0)