Skip to content

Commit cd5dec5

Browse files
Merge pull request #24 from lloyal-ai/feat/agents
Agents
2 parents 7977984 + 188d4f1 commit cd5dec5

75 files changed

Lines changed: 7483 additions & 4684 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docs.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ on:
44
push:
55
branches: [main]
66
paths:
7-
- 'lib/index.d.ts'
8-
- 'lib/Branch.js'
7+
- 'src/**'
98
- 'package.json'
109
- 'typedoc.json'
1110
- 'README.md'

.github/workflows/gpu-test.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
paths:
77
- 'liblloyal'
88
- 'llama.cpp'
9-
- 'lib/**'
109
- 'src/**'
1110
- 'test/**'
1211
- 'CMakeLists.txt'
@@ -108,6 +107,18 @@ jobs:
108107
- name: Configure Docker for Artifact Registry
109108
run: gcloud auth configure-docker ${{ secrets.GCP_REGION }}-docker.pkg.dev --quiet
110109

110+
- name: Setup Node.js
111+
uses: actions/setup-node@v4
112+
with:
113+
node-version: 24
114+
cache: 'npm'
115+
116+
- name: Compile TypeScript (src + tests)
117+
run: |
118+
npm ci --ignore-scripts
119+
npm run build:ts
120+
npm run build:test
121+
111122
- name: Download package artifact
112123
uses: actions/download-artifact@v4
113124
with:

.github/workflows/release.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ jobs:
218218
export LD_LIBRARY_PATH="${PKG_BIN}:${LD_LIBRARY_PATH:-}"
219219
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
220220
node -e "
221-
const { loadBinary } = require('./lib');
221+
const { loadBinary } = require('./dist');
222222
const addon = loadBinary();
223223
console.log('✓ Platform package loaded successfully');
224224
console.log(' Exports:', Object.keys(addon));
@@ -255,7 +255,7 @@ jobs:
255255
Write-Host "VULKAN_SDK: $env:VULKAN_SDK"
256256
Write-Host "CUDA_PATH: $env:CUDA_PATH"
257257
node -e "
258-
const { loadBinary } = require('./lib');
258+
const { loadBinary } = require('./dist');
259259
const addon = loadBinary();
260260
console.log('✓ Platform package loaded successfully');
261261
console.log(' Exports:', Object.keys(addon));
@@ -385,7 +385,13 @@ jobs:
385385
env:
386386
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
387387

388-
# Publish main package
388+
# Build TypeScript before publishing main package
389+
- name: Install dependencies
390+
run: npm install --ignore-scripts
391+
392+
- name: Build TypeScript
393+
run: npm run build:ts
394+
389395
- name: Sync package versions
390396
run: node scripts/sync-versions.js
391397

.github/workflows/tests.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ jobs:
132132
with:
133133
node-version: 24
134134

135+
- name: Install dependencies
136+
run: npm install --ignore-scripts
137+
138+
- name: Build TypeScript
139+
run: npm run build:ts
140+
135141
- name: Pack package
136142
run: npm pack
137143

@@ -141,9 +147,9 @@ jobs:
141147
echo "📦 Package contents:"
142148
cat package-contents.txt
143149
144-
# Verify lib/ JavaScript is included
145-
if ! grep -q "package/lib/index.js" package-contents.txt; then
146-
echo "❌ ERROR: lib/index.js not in package!"
150+
# Verify dist/ JavaScript is included
151+
if ! grep -q "package/dist/index.js" package-contents.txt; then
152+
echo "❌ ERROR: dist/index.js not in package!"
147153
exit 1
148154
fi
149155

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Build outputs
22
build/
3+
dist/
34
prebuilds/
45
*.node
56
/include/
@@ -40,5 +41,8 @@ tmp/
4041
dist/
4142
packages/darwin-arm64
4243

44+
# Compiled test artifacts (built by tsconfig.test.json for GPU CI)
45+
test/*.js
46+
4347
# CI infra scripts (injected from lloyal-infra during CI)
4448
ci/

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ tests/
3434
examples/
3535
docs/
3636

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

4041
# Test models (too large for npm)
4142
models/

CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ endif()
116116
# This also sets up the llama/llama.h include structure automatically
117117
add_subdirectory(${LIBLLOYAL_DIR} liblloyal)
118118

119+
# =============================================================================
120+
# md4c (Markdown parser for structure extraction)
121+
# =============================================================================
122+
123+
include(FetchContent)
124+
FetchContent_Declare(
125+
md4c
126+
GIT_REPOSITORY https://github.com/mity/md4c
127+
GIT_TAG release-0.5.2
128+
)
129+
set(BUILD_MD2HTML_EXECUTABLE OFF CACHE BOOL "" FORCE)
130+
FetchContent_MakeAvailable(md4c)
131+
FetchContent_GetProperties(md4c)
132+
set(MD4C_INCLUDE_DIR "${md4c_SOURCE_DIR}/src")
133+
119134
# =============================================================================
120135
# Addon Sources
121136
# =============================================================================
@@ -124,6 +139,7 @@ set(ADDON_SOURCES
124139
src/binding.cpp
125140
src/BackendManager.cpp
126141
src/SessionContext.cpp
142+
src/Util.cpp
127143
)
128144

129145
# =============================================================================
@@ -136,6 +152,7 @@ add_library(${PROJECT_NAME} MODULE ${ADDON_SOURCES} ${CMAKE_JS_SRC})
136152
target_include_directories(${PROJECT_NAME} PRIVATE
137153
${CMAKE_JS_INC}
138154
${NODE_ADDON_API_DIR}
155+
${MD4C_INCLUDE_DIR}
139156
src
140157
)
141158

@@ -147,6 +164,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE
147164
target_link_libraries(${PROJECT_NAME} PRIVATE
148165
liblloyal::liblloyal
149166
common
167+
md4c
150168
${CMAKE_JS_LIB}
151169
)
152170

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ See [`examples/grammar/`](./examples/grammar/) for the full branch fork pattern.
218218

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

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

223223
---
224224

examples/best-of-n/README.md

Lines changed: 0 additions & 118 deletions
This file was deleted.

0 commit comments

Comments
 (0)