Skip to content
Merged
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
3 changes: 1 addition & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ on:
push:
branches: [main]
paths:
- 'lib/index.d.ts'
- 'lib/Branch.js'
- 'src/**'
- 'package.json'
- 'typedoc.json'
- 'README.md'
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/gpu-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
paths:
- 'liblloyal'
- 'llama.cpp'
- 'lib/**'
- 'src/**'
- 'test/**'
- 'CMakeLists.txt'
Expand Down Expand Up @@ -108,6 +107,18 @@ jobs:
- name: Configure Docker for Artifact Registry
run: gcloud auth configure-docker ${{ secrets.GCP_REGION }}-docker.pkg.dev --quiet

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: 'npm'

- name: Compile TypeScript (src + tests)
run: |
npm ci --ignore-scripts
npm run build:ts
npm run build:test

- name: Download package artifact
uses: actions/download-artifact@v4
with:
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ jobs:
export LD_LIBRARY_PATH="${PKG_BIN}:${LD_LIBRARY_PATH:-}"
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
node -e "
const { loadBinary } = require('./lib');
const { loadBinary } = require('./dist');
const addon = loadBinary();
console.log('✓ Platform package loaded successfully');
console.log(' Exports:', Object.keys(addon));
Expand Down Expand Up @@ -255,7 +255,7 @@ jobs:
Write-Host "VULKAN_SDK: $env:VULKAN_SDK"
Write-Host "CUDA_PATH: $env:CUDA_PATH"
node -e "
const { loadBinary } = require('./lib');
const { loadBinary } = require('./dist');
const addon = loadBinary();
console.log('✓ Platform package loaded successfully');
console.log(' Exports:', Object.keys(addon));
Expand Down Expand Up @@ -385,7 +385,13 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

# Publish main package
# Build TypeScript before publishing main package
- name: Install dependencies
run: npm install --ignore-scripts

- name: Build TypeScript
run: npm run build:ts

- name: Sync package versions
run: node scripts/sync-versions.js

Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ jobs:
with:
node-version: 24

- name: Install dependencies
run: npm install --ignore-scripts

- name: Build TypeScript
run: npm run build:ts

- name: Pack package
run: npm pack

Expand All @@ -141,9 +147,9 @@ jobs:
echo "📦 Package contents:"
cat package-contents.txt

# Verify lib/ JavaScript is included
if ! grep -q "package/lib/index.js" package-contents.txt; then
echo "❌ ERROR: lib/index.js not in package!"
# Verify dist/ JavaScript is included
if ! grep -q "package/dist/index.js" package-contents.txt; then
echo "❌ ERROR: dist/index.js not in package!"
exit 1
fi

Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Build outputs
build/
dist/
prebuilds/
*.node
/include/
Expand Down Expand Up @@ -40,5 +41,8 @@ tmp/
dist/
packages/darwin-arm64

# Compiled test artifacts (built by tsconfig.test.json for GPU CI)
test/*.js

# CI infra scripts (injected from lloyal-infra during CI)
ci/
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ tests/
examples/
docs/

# C++ source files (users get prebuilt binaries, not source)
# C++ and TS source files (users get prebuilt binaries + compiled JS, not source)
src/
tsconfig.json

# Test models (too large for npm)
models/
Expand Down
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,21 @@ endif()
# This also sets up the llama/llama.h include structure automatically
add_subdirectory(${LIBLLOYAL_DIR} liblloyal)

# =============================================================================
# md4c (Markdown parser for structure extraction)
# =============================================================================

include(FetchContent)
FetchContent_Declare(
md4c
GIT_REPOSITORY https://github.com/mity/md4c
GIT_TAG release-0.5.2
)
Comment on lines +123 to +128
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FetchContent_Declare block for md4c pulls third-party C code directly from GitHub using a mutable tag (release-0.5.2), so a compromised or rewritten tag could silently inject malicious code into your native addon during CI/build and at runtime. To harden the supply chain, pin md4c to an immutable reference (e.g., a specific commit SHA or content hash) and/or vendor or mirror the source in a controlled location for builds that have access to secrets or produce production artifacts.

Copilot uses AI. Check for mistakes.
set(BUILD_MD2HTML_EXECUTABLE OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(md4c)
FetchContent_GetProperties(md4c)
set(MD4C_INCLUDE_DIR "${md4c_SOURCE_DIR}/src")

# =============================================================================
# Addon Sources
# =============================================================================
Expand All @@ -124,6 +139,7 @@ set(ADDON_SOURCES
src/binding.cpp
src/BackendManager.cpp
src/SessionContext.cpp
src/Util.cpp
)

# =============================================================================
Expand All @@ -136,6 +152,7 @@ add_library(${PROJECT_NAME} MODULE ${ADDON_SOURCES} ${CMAKE_JS_SRC})
target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_JS_INC}
${NODE_ADDON_API_DIR}
${MD4C_INCLUDE_DIR}
src
)

Expand All @@ -147,6 +164,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE
target_link_libraries(${PROJECT_NAME} PRIVATE
liblloyal::liblloyal
common
md4c
${CMAKE_JS_LIB}
)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ See [`examples/grammar/`](./examples/grammar/) for the full branch fork pattern.

Full API documentation: **[lloyal-ai.github.io/lloyal.node](https://lloyal-ai.github.io/lloyal.node/)**

Generated from [`lib/index.d.ts`](./lib/index.d.ts) with TypeDoc.
Generated from [`src/index.ts`](./src/index.ts) with TypeDoc.

---

Expand Down
118 changes: 0 additions & 118 deletions examples/best-of-n/README.md

This file was deleted.

Loading
Loading