@infilectai/cortex 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +97 -2
- package/bin/cortex-bin +0 -0
- package/bin/cortex.js +49 -0
- package/bin/libswiftCompatibilitySpan.dylib +0 -0
- package/bin/llama.framework/Versions/Current/Resources/Info.plist +32 -0
- package/bin/llama.framework/Versions/Current/_CodeSignature/CodeResources +128 -0
- package/bin/llama.framework/Versions/Current/llama +0 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +210 -0
- package/dist/index.js.map +1 -0
- package/package.json +68 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Infilect AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,98 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@infilectai/cortex`
|
|
2
|
+
|
|
3
|
+
On-device Apple Silicon neural runtime for speech-to-text, speaker diarization, text-to-speech, LLM chat completion, and embeddings.
|
|
4
|
+
|
|
5
|
+
Cortex runs a single native macOS (`arm64`) server on Core ML / Apple Neural Engine and Metal. Use it as a standalone local server (`npx @infilectai/cortex`) or embed it directly inside your Node.js / Electron app.
|
|
6
|
+
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
- **macOS 14+** on Apple Silicon (`arm64`)
|
|
10
|
+
- **Node.js 20+**
|
|
11
|
+
|
|
12
|
+
## Quickstart (CLI Server)
|
|
13
|
+
|
|
14
|
+
Start Cortex directly on `http://127.0.0.1:8000`:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npx @infilectai/cortex
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or install globally:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install -g @infilectai/cortex
|
|
24
|
+
cortex --port 8000
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quickstart (Node.js / Electron SDK)
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @infilectai/cortex
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { Cortex } from '@infilectai/cortex'
|
|
35
|
+
|
|
36
|
+
// Spawns the native Cortex server (pass port: 0 for an OS-assigned free port)
|
|
37
|
+
const cortex = await Cortex.start({ port: 8000 })
|
|
38
|
+
|
|
39
|
+
console.log('Cortex running at:', cortex.url)
|
|
40
|
+
console.log('Health:', await cortex.health())
|
|
41
|
+
|
|
42
|
+
// Pair with @infilectai/aira:
|
|
43
|
+
// const aira = await Aira.create({
|
|
44
|
+
// stt: { url: cortex.sttUrl },
|
|
45
|
+
// diarize: { url: cortex.diarizeUrl },
|
|
46
|
+
// })
|
|
47
|
+
|
|
48
|
+
await cortex.stop()
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Bundling in Electron (`electron-builder`)
|
|
52
|
+
|
|
53
|
+
Unpack `@infilectai/cortex/bin` from ASAR so macOS can execute the native binary:
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"build": {
|
|
58
|
+
"asarUnpack": [
|
|
59
|
+
"node_modules/@infilectai/cortex/bin/**"
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`Cortex.binaryPath` automatically resolves `app.asar.unpacked` at runtime.
|
|
66
|
+
|
|
67
|
+
## HTTP & WebSocket Endpoints
|
|
68
|
+
|
|
69
|
+
| Route | Method | Description |
|
|
70
|
+
| --- | --- | --- |
|
|
71
|
+
| `/health` | `GET` | Per-primitive status (`stt`, `diarize`, `tts`, `chat`, `embed`) |
|
|
72
|
+
| `/v1/audio/transcriptions` (`/v1/transcribe`) | `POST` | Multipart audio transcription (`file=@audio.wav`) via WhisperKit |
|
|
73
|
+
| `/v1/audio/transcriptions/ws` (`/v1/audio/stream`) | `WS` | Live streaming STT over 16 kHz mono PCM16 frames |
|
|
74
|
+
| `/v1/audio/diarize` (`/v1/diarize`) | `POST` | Multipart speaker diarization (`file=@audio.wav`) via SpeakerKit |
|
|
75
|
+
| `/v1/audio/speech` (`/v1/speech`) | `POST` | On-device neural TTS (`{ "input": "Hello", "format": "wav" \| "stream" }`) |
|
|
76
|
+
| `/v1/chat/completions` | `POST` | OpenAI-compatible chat completions (`stream: true \| false`) |
|
|
77
|
+
| `/v1/embeddings` | `POST` | OpenAI-compatible text embeddings (`{ "input": "..." }`) |
|
|
78
|
+
|
|
79
|
+
## Configuration
|
|
80
|
+
|
|
81
|
+
| Flag / Environment Variable | Default | Description |
|
|
82
|
+
| --- | --- | --- |
|
|
83
|
+
| `--port`, `CORTEX_PORT` | `8000` | Port to bind (`0` for an OS-assigned port) |
|
|
84
|
+
| `--host`, `CORTEX_HOST` | `127.0.0.1` | Hostname to bind |
|
|
85
|
+
| `--models-dir`, `CORTEX_MODELS_DIR` | `~/.cortex/models` | Directory searched for local GGUF models |
|
|
86
|
+
| `--llm-model`, `CORTEX_LLM_GGUF` | `google_gemma-4-E2B-it-Q4_K_M.gguf` | Path to the chat completion GGUF model |
|
|
87
|
+
| `--embed-model`, `CORTEX_EMBED_GGUF` | `embeddinggemma-300M-Q8_0.gguf` | Path to the embedding GGUF model |
|
|
88
|
+
|
|
89
|
+
Whisper, SpeakerKit, and TTSKit Core ML models download automatically on first request.
|
|
90
|
+
|
|
91
|
+
## Built With
|
|
92
|
+
|
|
93
|
+
[Argmax](https://github.com/argmaxinc/argmax-oss-swift) | [llama.cpp](https://github.com/ggml-org/llama.cpp) | [Vapor](https://github.com/vapor/vapor)
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
MIT
|
|
2
98
|
|
|
3
|
-
This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
|
package/bin/cortex-bin
ADDED
|
Binary file
|
package/bin/cortex.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from 'node:child_process'
|
|
3
|
+
import * as fs from 'node:fs'
|
|
4
|
+
import * as path from 'node:path'
|
|
5
|
+
import { fileURLToPath } from 'node:url'
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
8
|
+
const __dirname = path.dirname(__filename)
|
|
9
|
+
|
|
10
|
+
const binPath = path.join(__dirname, 'cortex-bin')
|
|
11
|
+
const llamaBinPath = path.join(__dirname, 'llama.framework', 'Versions', 'Current', 'llama')
|
|
12
|
+
|
|
13
|
+
if (!fs.existsSync(binPath)) {
|
|
14
|
+
console.error(`[cortex] Native binary not found at ${binPath}`)
|
|
15
|
+
process.exit(1)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
for (const target of [binPath, llamaBinPath]) {
|
|
19
|
+
try {
|
|
20
|
+
const st = fs.statSync(target)
|
|
21
|
+
if ((st.mode & 0o111) === 0) {
|
|
22
|
+
fs.chmodSync(target, 0o755)
|
|
23
|
+
}
|
|
24
|
+
} catch {
|
|
25
|
+
// ignore read-only fs
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const child = spawn(binPath, process.argv.slice(2), {
|
|
30
|
+
stdio: 'inherit',
|
|
31
|
+
env: process.env,
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const forwardSignal = (sig) => {
|
|
35
|
+
if (!child.killed) {
|
|
36
|
+
child.kill(sig)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
process.on('SIGINT', () => forwardSignal('SIGINT'))
|
|
41
|
+
process.on('SIGTERM', () => forwardSignal('SIGTERM'))
|
|
42
|
+
|
|
43
|
+
child.on('exit', (code, signal) => {
|
|
44
|
+
if (signal) {
|
|
45
|
+
process.kill(process.pid, signal)
|
|
46
|
+
} else {
|
|
47
|
+
process.exit(code ?? 0)
|
|
48
|
+
}
|
|
49
|
+
})
|
|
Binary file
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>en</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>llama</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>org.ggml.llama</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>llama</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0</string>
|
|
19
|
+
<key>CFBundleVersion</key>
|
|
20
|
+
<string>1</string>
|
|
21
|
+
<key>MinimumOSVersion</key>
|
|
22
|
+
<string>13.3</string>
|
|
23
|
+
<key>CFBundleSupportedPlatforms</key>
|
|
24
|
+
<array>
|
|
25
|
+
<string>MacOSX</string>
|
|
26
|
+
</array>
|
|
27
|
+
<key>DTPlatformName</key>
|
|
28
|
+
<string>macosx</string>
|
|
29
|
+
<key>DTSDKName</key>
|
|
30
|
+
<string>macosx13.3</string>
|
|
31
|
+
</dict>
|
|
32
|
+
</plist>
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>files</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>Resources/Info.plist</key>
|
|
8
|
+
<data>
|
|
9
|
+
TKcCMoMv25EhV9PqUd3TA8jkHfg=
|
|
10
|
+
</data>
|
|
11
|
+
</dict>
|
|
12
|
+
<key>files2</key>
|
|
13
|
+
<dict>
|
|
14
|
+
<key>Resources/Info.plist</key>
|
|
15
|
+
<dict>
|
|
16
|
+
<key>hash2</key>
|
|
17
|
+
<data>
|
|
18
|
+
UYycuqlb+iHyrK0B/h0pvYpr39eXAhorOd48UUW0isA=
|
|
19
|
+
</data>
|
|
20
|
+
</dict>
|
|
21
|
+
</dict>
|
|
22
|
+
<key>rules</key>
|
|
23
|
+
<dict>
|
|
24
|
+
<key>^Resources/</key>
|
|
25
|
+
<true/>
|
|
26
|
+
<key>^Resources/.*\.lproj/</key>
|
|
27
|
+
<dict>
|
|
28
|
+
<key>optional</key>
|
|
29
|
+
<true/>
|
|
30
|
+
<key>weight</key>
|
|
31
|
+
<real>1000</real>
|
|
32
|
+
</dict>
|
|
33
|
+
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
|
34
|
+
<dict>
|
|
35
|
+
<key>omit</key>
|
|
36
|
+
<true/>
|
|
37
|
+
<key>weight</key>
|
|
38
|
+
<real>1100</real>
|
|
39
|
+
</dict>
|
|
40
|
+
<key>^Resources/Base\.lproj/</key>
|
|
41
|
+
<dict>
|
|
42
|
+
<key>weight</key>
|
|
43
|
+
<real>1010</real>
|
|
44
|
+
</dict>
|
|
45
|
+
<key>^version.plist$</key>
|
|
46
|
+
<true/>
|
|
47
|
+
</dict>
|
|
48
|
+
<key>rules2</key>
|
|
49
|
+
<dict>
|
|
50
|
+
<key>.*\.dSYM($|/)</key>
|
|
51
|
+
<dict>
|
|
52
|
+
<key>weight</key>
|
|
53
|
+
<real>11</real>
|
|
54
|
+
</dict>
|
|
55
|
+
<key>^(.*/)?\.DS_Store$</key>
|
|
56
|
+
<dict>
|
|
57
|
+
<key>omit</key>
|
|
58
|
+
<true/>
|
|
59
|
+
<key>weight</key>
|
|
60
|
+
<real>2000</real>
|
|
61
|
+
</dict>
|
|
62
|
+
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
|
|
63
|
+
<dict>
|
|
64
|
+
<key>nested</key>
|
|
65
|
+
<true/>
|
|
66
|
+
<key>weight</key>
|
|
67
|
+
<real>10</real>
|
|
68
|
+
</dict>
|
|
69
|
+
<key>^.*</key>
|
|
70
|
+
<true/>
|
|
71
|
+
<key>^Info\.plist$</key>
|
|
72
|
+
<dict>
|
|
73
|
+
<key>omit</key>
|
|
74
|
+
<true/>
|
|
75
|
+
<key>weight</key>
|
|
76
|
+
<real>20</real>
|
|
77
|
+
</dict>
|
|
78
|
+
<key>^PkgInfo$</key>
|
|
79
|
+
<dict>
|
|
80
|
+
<key>omit</key>
|
|
81
|
+
<true/>
|
|
82
|
+
<key>weight</key>
|
|
83
|
+
<real>20</real>
|
|
84
|
+
</dict>
|
|
85
|
+
<key>^Resources/</key>
|
|
86
|
+
<dict>
|
|
87
|
+
<key>weight</key>
|
|
88
|
+
<real>20</real>
|
|
89
|
+
</dict>
|
|
90
|
+
<key>^Resources/.*\.lproj/</key>
|
|
91
|
+
<dict>
|
|
92
|
+
<key>optional</key>
|
|
93
|
+
<true/>
|
|
94
|
+
<key>weight</key>
|
|
95
|
+
<real>1000</real>
|
|
96
|
+
</dict>
|
|
97
|
+
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
|
98
|
+
<dict>
|
|
99
|
+
<key>omit</key>
|
|
100
|
+
<true/>
|
|
101
|
+
<key>weight</key>
|
|
102
|
+
<real>1100</real>
|
|
103
|
+
</dict>
|
|
104
|
+
<key>^Resources/Base\.lproj/</key>
|
|
105
|
+
<dict>
|
|
106
|
+
<key>weight</key>
|
|
107
|
+
<real>1010</real>
|
|
108
|
+
</dict>
|
|
109
|
+
<key>^[^/]+$</key>
|
|
110
|
+
<dict>
|
|
111
|
+
<key>nested</key>
|
|
112
|
+
<true/>
|
|
113
|
+
<key>weight</key>
|
|
114
|
+
<real>10</real>
|
|
115
|
+
</dict>
|
|
116
|
+
<key>^embedded\.provisionprofile$</key>
|
|
117
|
+
<dict>
|
|
118
|
+
<key>weight</key>
|
|
119
|
+
<real>20</real>
|
|
120
|
+
</dict>
|
|
121
|
+
<key>^version\.plist$</key>
|
|
122
|
+
<dict>
|
|
123
|
+
<key>weight</key>
|
|
124
|
+
<real>20</real>
|
|
125
|
+
</dict>
|
|
126
|
+
</dict>
|
|
127
|
+
</dict>
|
|
128
|
+
</plist>
|
|
Binary file
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type ChildProcess } from 'node:child_process';
|
|
2
|
+
export interface CortexOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Port to bind to. Pass `0` to let macOS pick a free ephemeral port.
|
|
5
|
+
* Defaults to `8000`.
|
|
6
|
+
*/
|
|
7
|
+
port?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Hostname to bind to. Defaults to `'127.0.0.1'`.
|
|
10
|
+
*/
|
|
11
|
+
host?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Directory containing local GGUF models (`~/.cortex/models` by default).
|
|
14
|
+
*/
|
|
15
|
+
modelsDir?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Explicit path to the chat completion GGUF model.
|
|
18
|
+
*/
|
|
19
|
+
llmModel?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Explicit path to the embedding GGUF model.
|
|
22
|
+
*/
|
|
23
|
+
embedModel?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Override path to the native `cortex-bin` executable.
|
|
26
|
+
*/
|
|
27
|
+
binaryPath?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Max time in milliseconds to wait for the server to become healthy.
|
|
30
|
+
* Defaults to `30000`.
|
|
31
|
+
*/
|
|
32
|
+
startupTimeoutMs?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Forward server stdout/stderr to the parent process. Defaults to `false`.
|
|
35
|
+
*/
|
|
36
|
+
stdio?: 'inherit' | 'pipe';
|
|
37
|
+
}
|
|
38
|
+
export interface CortexHealth {
|
|
39
|
+
status: 'ok' | string;
|
|
40
|
+
primitives: {
|
|
41
|
+
stt?: 'unloaded' | 'loading' | 'loaded' | 'error';
|
|
42
|
+
diarize?: 'unloaded' | 'loading' | 'loaded' | 'error';
|
|
43
|
+
tts?: 'unloaded' | 'loading' | 'loaded' | 'error';
|
|
44
|
+
chat?: 'unloaded' | 'loading' | 'loaded' | 'error';
|
|
45
|
+
embed?: 'unloaded' | 'loading' | 'loaded' | 'error';
|
|
46
|
+
[key: string]: string | undefined;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns the absolute path to the bundled native `cortex-bin` executable.
|
|
51
|
+
* Automatically rewrites `app.asar` to `app.asar.unpacked` when bundled in Electron.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getBinaryPath(): string;
|
|
54
|
+
export declare class CortexServer {
|
|
55
|
+
readonly host: string;
|
|
56
|
+
readonly port: number;
|
|
57
|
+
readonly url: string;
|
|
58
|
+
readonly wsUrl: string;
|
|
59
|
+
readonly process: ChildProcess;
|
|
60
|
+
constructor(host: string, port: number, child: ChildProcess);
|
|
61
|
+
/** PID of the running Cortex native process. */
|
|
62
|
+
get pid(): number | undefined;
|
|
63
|
+
/** Batch STT endpoint (`POST /v1/audio/transcriptions`). */
|
|
64
|
+
get sttUrl(): string;
|
|
65
|
+
/** Streaming WebSocket STT endpoint (`WS /v1/audio/transcriptions/ws`). */
|
|
66
|
+
get sttStreamUrl(): string;
|
|
67
|
+
/** Speaker diarization endpoint (`POST /v1/audio/diarize`). */
|
|
68
|
+
get diarizeUrl(): string;
|
|
69
|
+
/** Speech synthesis endpoint (`POST /v1/audio/speech`). */
|
|
70
|
+
get ttsUrl(): string;
|
|
71
|
+
/** OpenAI-compatible chat completions endpoint (`POST /v1/chat/completions`). */
|
|
72
|
+
get chatUrl(): string;
|
|
73
|
+
/** OpenAI-compatible embeddings endpoint (`POST /v1/embeddings`). */
|
|
74
|
+
get embeddingsUrl(): string;
|
|
75
|
+
/** Queries `/health` for per-primitive readiness. */
|
|
76
|
+
health(): Promise<CortexHealth>;
|
|
77
|
+
/** Gracefully stops the Cortex child process. */
|
|
78
|
+
stop(): Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
export declare class Cortex {
|
|
81
|
+
/**
|
|
82
|
+
* Returns the absolute path to the native `cortex-bin` executable.
|
|
83
|
+
*/
|
|
84
|
+
static get binaryPath(): string;
|
|
85
|
+
/**
|
|
86
|
+
* Spawns a local Cortex server instance and waits until it is ready to accept requests.
|
|
87
|
+
*/
|
|
88
|
+
static start(opts?: CortexOptions): Promise<CortexServer>;
|
|
89
|
+
}
|
|
90
|
+
export declare const startCortex: typeof Cortex.start;
|
|
91
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAU7D,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,MAAM,CAAA;CAC3B;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,UAAU,EAAE;QACV,GAAG,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;QACjD,OAAO,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;QACrD,GAAG,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;QACjD,IAAI,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;QAClD,KAAK,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;QACnD,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;KAClC,CAAA;CACF;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAWtC;AAED,qBAAa,YAAY;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAA;gBAElB,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY;IAQ3D,gDAAgD;IAChD,IAAI,GAAG,IAAI,MAAM,GAAG,SAAS,CAE5B;IAED,4DAA4D;IAC5D,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,2EAA2E;IAC3E,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,+DAA+D;IAC/D,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,2DAA2D;IAC3D,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,iFAAiF;IACjF,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,qEAAqE;IACrE,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED,qDAAqD;IAC/C,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC;IAQrC,iDAAiD;IAC3C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAgB5B;AAED,qBAAa,MAAM;IACjB;;OAEG;IACH,MAAM,KAAK,UAAU,IAAI,MAAM,CAE9B;IAED;;OAEG;WACU,KAAK,CAAC,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;CAkDpE;AAED,eAAO,MAAM,WAAW,qBAA4B,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
7
|
+
const ANNOUNCE_RE = /^(?:cortex|aira-engine) listening on (\S+?):(\d+)/m;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the absolute path to the bundled native `cortex-bin` executable.
|
|
10
|
+
* Automatically rewrites `app.asar` to `app.asar.unpacked` when bundled in Electron.
|
|
11
|
+
*/
|
|
12
|
+
export function getBinaryPath() {
|
|
13
|
+
const rawPath = path.resolve(__dirname, '..', 'bin', 'cortex-bin');
|
|
14
|
+
const resolved = rawPath.includes('app.asar') && !rawPath.includes('app.asar.unpacked')
|
|
15
|
+
? rawPath.replace('app.asar', 'app.asar.unpacked')
|
|
16
|
+
: rawPath;
|
|
17
|
+
ensureExecutable(resolved);
|
|
18
|
+
ensureExecutable(path.join(path.dirname(resolved), 'llama.framework', 'Versions', 'Current', 'llama'));
|
|
19
|
+
return resolved;
|
|
20
|
+
}
|
|
21
|
+
export class CortexServer {
|
|
22
|
+
host;
|
|
23
|
+
port;
|
|
24
|
+
url;
|
|
25
|
+
wsUrl;
|
|
26
|
+
process;
|
|
27
|
+
constructor(host, port, child) {
|
|
28
|
+
this.host = host;
|
|
29
|
+
this.port = port;
|
|
30
|
+
this.url = `http://${host}:${port}`;
|
|
31
|
+
this.wsUrl = `ws://${host}:${port}`;
|
|
32
|
+
this.process = child;
|
|
33
|
+
}
|
|
34
|
+
/** PID of the running Cortex native process. */
|
|
35
|
+
get pid() {
|
|
36
|
+
return this.process.pid;
|
|
37
|
+
}
|
|
38
|
+
/** Batch STT endpoint (`POST /v1/audio/transcriptions`). */
|
|
39
|
+
get sttUrl() {
|
|
40
|
+
return `${this.url}/v1/audio/transcriptions`;
|
|
41
|
+
}
|
|
42
|
+
/** Streaming WebSocket STT endpoint (`WS /v1/audio/transcriptions/ws`). */
|
|
43
|
+
get sttStreamUrl() {
|
|
44
|
+
return `${this.wsUrl}/v1/audio/transcriptions/ws`;
|
|
45
|
+
}
|
|
46
|
+
/** Speaker diarization endpoint (`POST /v1/audio/diarize`). */
|
|
47
|
+
get diarizeUrl() {
|
|
48
|
+
return `${this.url}/v1/audio/diarize`;
|
|
49
|
+
}
|
|
50
|
+
/** Speech synthesis endpoint (`POST /v1/audio/speech`). */
|
|
51
|
+
get ttsUrl() {
|
|
52
|
+
return `${this.url}/v1/audio/speech`;
|
|
53
|
+
}
|
|
54
|
+
/** OpenAI-compatible chat completions endpoint (`POST /v1/chat/completions`). */
|
|
55
|
+
get chatUrl() {
|
|
56
|
+
return `${this.url}/v1/chat/completions`;
|
|
57
|
+
}
|
|
58
|
+
/** OpenAI-compatible embeddings endpoint (`POST /v1/embeddings`). */
|
|
59
|
+
get embeddingsUrl() {
|
|
60
|
+
return `${this.url}/v1/embeddings`;
|
|
61
|
+
}
|
|
62
|
+
/** Queries `/health` for per-primitive readiness. */
|
|
63
|
+
async health() {
|
|
64
|
+
const res = await fetch(`${this.url}/health`);
|
|
65
|
+
if (!res.ok) {
|
|
66
|
+
throw new Error(`Cortex health check failed with HTTP ${res.status}`);
|
|
67
|
+
}
|
|
68
|
+
return (await res.json());
|
|
69
|
+
}
|
|
70
|
+
/** Gracefully stops the Cortex child process. */
|
|
71
|
+
async stop() {
|
|
72
|
+
if (this.process.exitCode !== null || this.process.killed)
|
|
73
|
+
return;
|
|
74
|
+
this.process.kill('SIGTERM');
|
|
75
|
+
await new Promise((resolve) => {
|
|
76
|
+
const timer = setTimeout(() => {
|
|
77
|
+
if (this.process.exitCode === null) {
|
|
78
|
+
this.process.kill('SIGKILL');
|
|
79
|
+
}
|
|
80
|
+
resolve();
|
|
81
|
+
}, 5_000);
|
|
82
|
+
this.process.once('exit', () => {
|
|
83
|
+
clearTimeout(timer);
|
|
84
|
+
resolve();
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export class Cortex {
|
|
90
|
+
/**
|
|
91
|
+
* Returns the absolute path to the native `cortex-bin` executable.
|
|
92
|
+
*/
|
|
93
|
+
static get binaryPath() {
|
|
94
|
+
return getBinaryPath();
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Spawns a local Cortex server instance and waits until it is ready to accept requests.
|
|
98
|
+
*/
|
|
99
|
+
static async start(opts = {}) {
|
|
100
|
+
const binPath = opts.binaryPath ?? getBinaryPath();
|
|
101
|
+
if (!fs.existsSync(binPath)) {
|
|
102
|
+
throw new Error(`Cortex native binary not found at ${binPath}`);
|
|
103
|
+
}
|
|
104
|
+
const host = opts.host ?? process.env.CORTEX_HOST ?? '127.0.0.1';
|
|
105
|
+
const requestedPort = opts.port ?? (process.env.CORTEX_PORT ? Number(process.env.CORTEX_PORT) : 8000);
|
|
106
|
+
const timeoutMs = opts.startupTimeoutMs ?? 30_000;
|
|
107
|
+
const env = {
|
|
108
|
+
...process.env,
|
|
109
|
+
CORTEX_HOST: host,
|
|
110
|
+
CORTEX_PORT: String(requestedPort),
|
|
111
|
+
};
|
|
112
|
+
if (opts.modelsDir)
|
|
113
|
+
env.CORTEX_MODELS_DIR = opts.modelsDir;
|
|
114
|
+
if (opts.llmModel)
|
|
115
|
+
env.CORTEX_LLM_GGUF = opts.llmModel;
|
|
116
|
+
if (opts.embedModel)
|
|
117
|
+
env.CORTEX_EMBED_GGUF = opts.embedModel;
|
|
118
|
+
const child = spawn(binPath, ['--host', host, '--port', String(requestedPort)], {
|
|
119
|
+
env,
|
|
120
|
+
stdio: ['ignore', 'pipe', opts.stdio === 'inherit' ? 'inherit' : 'pipe'],
|
|
121
|
+
});
|
|
122
|
+
if (!child.pid || !child.stdout) {
|
|
123
|
+
throw new Error(`Failed to spawn Cortex binary at ${binPath}`);
|
|
124
|
+
}
|
|
125
|
+
if (opts.stdio === 'inherit') {
|
|
126
|
+
child.stdout.on('data', (chunk) => process.stdout.write(chunk));
|
|
127
|
+
}
|
|
128
|
+
let boundPort;
|
|
129
|
+
try {
|
|
130
|
+
boundPort = await waitForAnnouncedPort(child, timeoutMs);
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
child.kill('SIGTERM');
|
|
134
|
+
throw err;
|
|
135
|
+
}
|
|
136
|
+
const server = new CortexServer(host, boundPort, child);
|
|
137
|
+
try {
|
|
138
|
+
await waitForHealth(server, timeoutMs);
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
await server.stop();
|
|
142
|
+
throw err;
|
|
143
|
+
}
|
|
144
|
+
return server;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
export const startCortex = Cortex.start.bind(Cortex);
|
|
148
|
+
function ensureExecutable(filePath) {
|
|
149
|
+
try {
|
|
150
|
+
const st = fs.statSync(filePath);
|
|
151
|
+
if ((st.mode & 0o111) === 0) {
|
|
152
|
+
fs.chmodSync(filePath, 0o755);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
// ignore missing or read-only files
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function waitForAnnouncedPort(child, timeoutMs) {
|
|
160
|
+
return new Promise((resolve, reject) => {
|
|
161
|
+
let buf = '';
|
|
162
|
+
let settled = false;
|
|
163
|
+
const stdout = child.stdout;
|
|
164
|
+
const timer = setTimeout(() => {
|
|
165
|
+
if (settled)
|
|
166
|
+
return;
|
|
167
|
+
settled = true;
|
|
168
|
+
stdout.off('data', onData);
|
|
169
|
+
reject(new Error(`Cortex did not announce listening port within ${timeoutMs}ms`));
|
|
170
|
+
}, timeoutMs);
|
|
171
|
+
const onExit = (code) => {
|
|
172
|
+
if (settled)
|
|
173
|
+
return;
|
|
174
|
+
settled = true;
|
|
175
|
+
clearTimeout(timer);
|
|
176
|
+
reject(new Error(`Cortex exited prematurely with code ${code}`));
|
|
177
|
+
};
|
|
178
|
+
const onData = (chunk) => {
|
|
179
|
+
if (settled)
|
|
180
|
+
return;
|
|
181
|
+
buf += chunk.toString('utf8');
|
|
182
|
+
const m = buf.match(ANNOUNCE_RE);
|
|
183
|
+
if (m) {
|
|
184
|
+
settled = true;
|
|
185
|
+
clearTimeout(timer);
|
|
186
|
+
child.off('exit', onExit);
|
|
187
|
+
stdout.off('data', onData);
|
|
188
|
+
resolve(parseInt(m[2], 10));
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
stdout.on('data', onData);
|
|
192
|
+
child.once('exit', onExit);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
async function waitForHealth(server, timeoutMs) {
|
|
196
|
+
const deadline = Date.now() + timeoutMs;
|
|
197
|
+
let lastErr;
|
|
198
|
+
while (Date.now() < deadline) {
|
|
199
|
+
try {
|
|
200
|
+
await server.health();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
catch (err) {
|
|
204
|
+
lastErr = err;
|
|
205
|
+
await new Promise((r) => setTimeout(r, 150));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
throw new Error(`Cortex health check timed out after ${timeoutMs}ms: ${String(lastErr)}`);
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAA;AAC7D,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACjD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AAE1C,MAAM,WAAW,GAAG,oDAAoD,CAAA;AAmDxE;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,OAAO,GAAG,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C,CAAA;AAC3F,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infilectai/cortex",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "On-device Apple Silicon neural runtime for speech-to-text, speaker diarization, TTS, LLM chat, and embeddings.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"private": false,
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/InfilectAI/Cortex.git"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/InfilectAI/Cortex#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/InfilectAI/Cortex/issues"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"cortex",
|
|
20
|
+
"aira",
|
|
21
|
+
"synapse",
|
|
22
|
+
"apple-silicon",
|
|
23
|
+
"coreml",
|
|
24
|
+
"whisperkit",
|
|
25
|
+
"speakerkit",
|
|
26
|
+
"diarization",
|
|
27
|
+
"transcription",
|
|
28
|
+
"tts",
|
|
29
|
+
"llama-cpp",
|
|
30
|
+
"embeddings",
|
|
31
|
+
"macos"
|
|
32
|
+
],
|
|
33
|
+
"type": "module",
|
|
34
|
+
"os": [
|
|
35
|
+
"darwin"
|
|
36
|
+
],
|
|
37
|
+
"cpu": [
|
|
38
|
+
"arm64"
|
|
39
|
+
],
|
|
40
|
+
"bin": {
|
|
41
|
+
"cortex": "bin/cortex.js"
|
|
42
|
+
},
|
|
43
|
+
"main": "./dist/index.js",
|
|
44
|
+
"types": "./dist/index.d.ts",
|
|
45
|
+
"exports": {
|
|
46
|
+
".": {
|
|
47
|
+
"types": "./dist/index.d.ts",
|
|
48
|
+
"default": "./dist/index.js"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"bin",
|
|
53
|
+
"dist",
|
|
54
|
+
"README.md",
|
|
55
|
+
"LICENSE"
|
|
56
|
+
],
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build:native": "node scripts/build-native.cjs",
|
|
59
|
+
"build:js": "tsc",
|
|
60
|
+
"build": "node scripts/build-native.cjs && tsc",
|
|
61
|
+
"prepublishOnly": "npm run build"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@types/node": "^22.0.0",
|
|
65
|
+
"typescript": "^5.6.0"
|
|
66
|
+
},
|
|
67
|
+
"engines": {
|
|
68
|
+
"node": ">=20"
|
|
69
|
+
}
|
|
70
|
+
}
|