Skip to content

Commit f08998a

Browse files
Merge pull request #5 from trycortexai/cleanups/faster-build/strict-typing
chore: beautiful base for scalability, cleanups, awesome release dx, …
2 parents bc3ba07 + f1901c8 commit f08998a

34 files changed

+5588
-8128
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
ci:
1010
strategy:
1111
matrix:
12-
os: [ubuntu-latest, macos-latest, windows-latest]
12+
os: [ubuntu-latest, macos-latest]
1313
node-version: [20.x]
1414
runs-on: ${{ matrix.os }}
1515
steps:
@@ -26,8 +26,13 @@ jobs:
2626
with:
2727
version: latest
2828

29+
- name: Install Bun
30+
uses: oven-sh/setup-bun@v1
31+
with:
32+
bun-version: latest
33+
2934
- name: Install dependencies
3035
run: pnpm install --frozen-lockfile
3136

32-
- name: Run validation
33-
run: pnpm validate
37+
- name: Run CI
38+
run: pnpm build && pnpm tsc && pnpm lint

.github/workflows/release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release
2+
3+
permissions:
4+
contents: write
5+
id-token: write
6+
7+
on:
8+
push:
9+
tags:
10+
- 'v*'
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: lts/*
22+
registry-url: https://registry.npmjs.org/
23+
- uses: oven-sh/setup-bun@v1
24+
with:
25+
bun-version: latest
26+
- uses: pnpm/action-setup@v4
27+
- run: pnpm install
28+
- run: pnpm build
29+
- run: npx changelogithub
30+
continue-on-error: true
31+
env:
32+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
33+
- run: pnpm run publish:ci
34+
env:
35+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
36+
NPM_CONFIG_PROVENANCE: true

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pnpm validate
1+
pnpm tsc && pnpm lint

.release-it.json

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

CHANGELOG.md

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

bump.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {defineConfig} from 'bumpp';
2+
3+
export default defineConfig({
4+
files: ['package.json', 'examples/**/package.json'],
5+
});
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import {defineConfig} from 'tsup';
1+
import {defineConfig} from 'bunup';
22

33
export default defineConfig({
44
outDir: 'build',
55
entry: ['src/index.ts'],
6-
target: 'es2021',
76
minify: true,
87
format: ['esm', 'cjs'],
9-
clean: true,
108
dts: true,
11-
treeshake: true,
9+
splitting: false,
1210
});

examples/hono/.env.example

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
BASE_URL=
21
CORTEX_API_KEY=
3-
WORKFLOW_ID=
2+
WORKFLOW_ID=

examples/hono/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
{
22
"name": "cortex-sdk-hono-example",
33
"type": "module",
4+
"version": "0.6.2",
45
"scripts": {
5-
"dev": "tsx watch src/index.ts"
6+
"dev": "bun run src/index.ts"
67
},
78
"dependencies": {
89
"@cortex-ai/sdk": "workspace:*",
9-
"@hono/node-server": "^1.13.7",
10-
"dotenv": "^16.4.5",
11-
"hono": "^4.6.11"
10+
"@hono/node-server": "^1.14.0",
11+
"dotenv": "^16.4.7",
12+
"hono": "^4.7.5"
1213
},
1314
"devDependencies": {
14-
"@types/node": "^20.11.17",
15-
"tsx": "^4.7.1"
15+
"@types/node": "^20.17.30",
16+
"tsx": "^4.19.3"
1617
}
1718
}

examples/hono/src/index.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@ const PORT = 8085;
1313
const app = new Hono();
1414

1515
const createCortex = (ctx: Context) => {
16-
const {CORTEX_API_KEY, BASE_URL} = env<{
16+
const {CORTEX_API_KEY} = env<{
1717
CORTEX_API_KEY: string;
18-
BASE_URL: string;
1918
}>(ctx);
2019

2120
const cortex = new Cortex({
2221
apiKey: CORTEX_API_KEY,
23-
baseUrl: BASE_URL,
22+
baseUrl: 'https://api.dev.withcortex.ai',
2423
});
2524

2625
return cortex;
@@ -56,6 +55,18 @@ app.get('/stream/workflow', async ctx => {
5655
return ctx.text(response);
5756
});
5857

58+
app.get('/model-calls', async ctx => {
59+
const {WORKFLOW_ID} = env<{WORKFLOW_ID: string}>(ctx);
60+
61+
const cortex = createCortex(ctx);
62+
63+
const result = await cortex.apps.workflows.runs.create(WORKFLOW_ID);
64+
65+
console.log('run finished', result);
66+
67+
return ctx.json(result);
68+
});
69+
5970
console.log(`Server is running on http://localhost:${PORT}`);
6071

6172
serve({

0 commit comments

Comments
 (0)