Skip to content

Commit 91cdb3d

Browse files
committed
📦 NEW: CLI
1 parent 06c083b commit 91cdb3d

34 files changed

+2777
-1
lines changed

examples/nodejs/agents/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {Langbase} from 'langbase';
2+
3+
// Placeholder for user code
4+
export default async function Route(request, env) {
5+
const langbase = new Langbase({
6+
apiKey: 'API_KEY',
7+
});
8+
9+
const pipes = await langbase.pipe.list();
10+
11+
// User code will be injected here
12+
return new Response(JSON.stringify(pipes), {status: 200});
13+
}

examples/nodejs/agents/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {Langbase} from 'langbase';
2+
3+
// Placeholder for user code
4+
export default async function Route(request, env) {
5+
const langbase = new Langbase({
6+
apiKey: 'API_KEY',
7+
});
8+
9+
const pipes = await langbase.pipe.list();
10+
11+
// User code will be injected here
12+
return new Response(JSON.stringify(pipes), {status: 200});
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {Langbase} from 'langbase';
2+
3+
// Placeholder for user code
4+
export default async function Route(request, env) {
5+
const langbase = new Langbase({
6+
apiKey: 'API_KEY',
7+
});
8+
9+
const pipes = await langbase.pipe.list();
10+
11+
// User code will be injected here
12+
return new Response(JSON.stringify(pipes), {status: 200});
13+
}

examples/nodejs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"dependencies": {
4646
"dotenv": "^16.4.5",
4747
"langbase": "^1.1.35",
48-
"uuid": "^11.1.0"
48+
"uuid": "^11.1.0",
49+
"@langbase/cli": "workspace:*"
4950
}
5051
}

packages/cli/.gitignore

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# NPM #
2+
##########
3+
# Ignore all directories called node_modules in current folder and any subfolders.
4+
node_modules/
5+
/node_modules/
6+
7+
# Packages #
8+
############
9+
*.7z
10+
*.dmg
11+
*.gz
12+
*.bz2
13+
*.iso
14+
*.jar
15+
*.rar
16+
*.tar
17+
*.zip
18+
*.tgz
19+
*.map
20+
21+
# Logs and databases #
22+
######################
23+
*.log
24+
*.sql
25+
*.env
26+
27+
# OS generated files #
28+
######################
29+
**.DS_Store*
30+
ehthumbs.db
31+
Icon?
32+
Thumbs.db
33+
._*
34+
**settings.dat*
35+
36+
# Vim generated files #
37+
######################
38+
*.un~
39+
40+
# SASS #
41+
##########
42+
**/.sass-cache
43+
**/.sass-cache/*
44+
**/.map
45+
46+
# Composer #
47+
##########
48+
!assets/js/vendor/
49+
wpcs/
50+
/vendor/
51+
52+
# Bower #
53+
##########
54+
assets/bower_components/*
55+
56+
# Codekit #
57+
##########
58+
/codekit-config.json
59+
*.codekit
60+
**.codekit-cache/*
61+
62+
# Compiled Files and Build Dirs #
63+
##########
64+
/README.html
65+
66+
# PhpStrom Project Files #
67+
.idea/
68+
library/vendors/composer
69+
assets/img/.DS_Store
70+
71+
# VSCode related files #
72+
# .vscode

packages/cli/.prettierrc.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"trailingComma": "none",
3+
"arrowParens": "avoid",
4+
"singleQuote": true,
5+
"printWidth": 80,
6+
"useTabs": true,
7+
"tabWidth": 4,
8+
"semi": true
9+
}

packages/cli/CONTRIBUTING.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Contributing
2+
3+
We welcome contributions to this project.
4+
5+
---
6+
7+
## Releasing a snapshot version
8+
9+
To release a snapshot version to test changes, run the following command:
10+
11+
```bash
12+
npx run snapshot
13+
```
14+
15+
## Releasing a new version
16+
17+
```bash
18+
pnpm changeset
19+
pnpm version-packages
20+
grlz 'new version'
21+
pnpm release
22+
pnpm update-examples
23+
```
24+
25+
## Testing locally
26+
27+
To test the changes locally, you can run the following command:
28+
29+
- Navigate to an example's folder like the Node.js one in `examples/nodejs`.
30+
31+
- Change the `package.json` to point to the local package for `@langbase/cli` package.
32+
33+
```json
34+
{
35+
"devDependencies": {
36+
"@langbase/cli": "workspace:*"
37+
},
38+
}
39+
```
40+
41+
- Now run in the root:
42+
43+
```bash
44+
pnpm clean-all && pnpm install
45+
```
46+
47+
Then run the development server:
48+
49+
```bash
50+
pnpm dev
51+
```
52+
53+
- Run the Node.js example:
54+
55+
```bash
56+
# 1. Authenticate first
57+
npx lb auth
58+
59+
# 2. Deploy the agent
60+
npx lb deploy --agent owner/agentName --file ./src/index.ts
61+
```
62+
63+
By doing this, the Node.js example will use the local packages instead of the published ones.

packages/cli/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## Langbase CLI

packages/cli/bin/langbase.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env node
2+
3+
import { install } from 'source-map-support';
4+
import { fileURLToPath } from 'url';
5+
6+
install();
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const distPath = new URL('../dist/index.js', import.meta.url).pathname;
10+
11+
import(distPath);

packages/cli/package.json

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{
2+
"name": "@langbase/cli",
3+
"description": "Langbase CLI",
4+
"version": "0.0.0",
5+
"license": "UNLICENSED",
6+
"type": "module",
7+
"main": "./dist/index.js",
8+
"module": "./dist/index.mjs",
9+
"types": "./dist/index.d.ts",
10+
"bin": {
11+
"lb": "dist/index.js"
12+
},
13+
"author": {
14+
"name": "Langbase",
15+
"url": "https://langbase.com"
16+
},
17+
"repository": {
18+
"type": "git",
19+
"url": "https://github.com/LangbaseInc/components.git",
20+
"directory": "packages/cli"
21+
},
22+
"bugs": {
23+
"url": "https://github.com/LangbaseInc/components/issues"
24+
},
25+
"homepage": "https://langbase.com",
26+
"files": [
27+
"dist/**"
28+
],
29+
"scripts": {
30+
"build": "tsup",
31+
"dev": "tsup --watch",
32+
"lint": "eslint \"src/**/*.ts*\"",
33+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
34+
"type-check": "tsc --noEmit",
35+
"prettier-check": "prettier --check \"./**/*.ts*\"",
36+
"test": "pnpm test:node && pnpm test:edge",
37+
"#test": "pnpm test:node && pnpm test:edge && pnpm test:ui && pnpm test:e2e",
38+
"test:edge": "vitest --config vitest.edge.config.js --run",
39+
"test:node": "vitest --config vitest.node.config.js --run",
40+
"test:ui": "pnpm test:ui:react",
41+
"test:ui:react": "vitest --config vitest.ui.react.config.js --run",
42+
"test:e2e": "playwright test",
43+
"test:edge:watch": "vitest --config vitest.edge.config.js",
44+
"test:node:watch": "vitest --config vitest.node.config.js",
45+
"test:ui:react:watch": "vitest --config vitest.ui.react.config.js"
46+
},
47+
"dependencies": {
48+
"@antfu/ni": "^0.23.0",
49+
"@clack/core": "^0.3.4",
50+
"@clack/prompts": "^0.7.0",
51+
"@hono/node-server": "^1.13.1",
52+
"@hono/zod-openapi": "^0.16.0",
53+
"@sindresorhus/slugify": "^2.2.1",
54+
"camelcase": "^8.0.0",
55+
"chalk": "^5.3.0",
56+
"cli-alerts": "^2.0.0",
57+
"cli-handle-error": "^4.4.0",
58+
"cli-handle-unhandled": "^1.1.1",
59+
"cli-meow-help": "^4.0.0",
60+
"cli-table3": "^0.6.5",
61+
"cli-welcome": "^3.0.0",
62+
"compute-cosine-similarity": "^1.1.0",
63+
"cosmiconfig": "^9.0.0",
64+
"cosmiconfig-typescript-loader": "^5.0.0",
65+
"dotenv": "^16.4.5",
66+
"esbuild": "^0.24.2",
67+
"execa": "^9.4.0",
68+
"fast-glob": "^3.3.2",
69+
"figures": "^6.1.0",
70+
"get-package-json-file": "^2.0.0",
71+
"hono": "^4.5.11",
72+
"js-tiktoken": "^1.0.14",
73+
"log-symbols": "^7.0.0",
74+
"lowdb": "^7.0.1",
75+
"meow": "^13.2.0",
76+
"node-fetch": "^3.3.2",
77+
"open": "^10.1.0",
78+
"openai": "^4.63.0",
79+
"p-map": "^7.0.2",
80+
"picocolors": "^1.1.0",
81+
"prettier": "^3.3.3",
82+
"source-map-support": "^0.5.21",
83+
"unpdf": "^0.11.0",
84+
"uuid": "^10.0.0",
85+
"xlsx": "^0.18.5",
86+
"zod": "^3.23.8",
87+
"zod-error": "^1.5.0"
88+
},
89+
"devDependencies": {
90+
"@langbase/eslint-config": "workspace:*",
91+
"@langbase/tsconfig": "workspace:*",
92+
"@types/node": "^22.6.1",
93+
"tsup": "^8.3.0",
94+
"tsx": "^4.19.1",
95+
"typescript": "^5.6.2",
96+
"vitest": "1.6.0"
97+
},
98+
"keywords": [
99+
"langbase",
100+
"langbase.com",
101+
"generative AI"
102+
]
103+
}

0 commit comments

Comments
 (0)