Skip to content

Commit 9b2eb44

Browse files
committed
Merge branch 'feat/mono' of https://github.com/ponderingdemocritus/eliza into HEAD
2 parents a34b983 + fd01b42 commit 9b2eb44

File tree

148 files changed

+24172
-19469
lines changed

Some content is hidden

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

148 files changed

+24172
-19469
lines changed

.bashrc

Whitespace-only changes.

.github/workflows/ci.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
check:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: pnpm/action-setup@v3
14+
with:
15+
version: 9.4.0
16+
17+
- name: Install dependencies
18+
run: pnpm i
19+
20+
- name: Run Prettier
21+
run: pnpm run prettier --check .
22+
23+
- name: Build packages
24+
run: pnpm run build

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/node_modules
1+
node_modules
22
/out
33

44
.env

.prettierignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
**/*/target
2+
**/*/dist
3+
packages/torii-client/wasm
4+
packages/torii-client/pkg
5+
packages/torii-wasm/pkg/
6+
packages/utils-wasm/pkg/
7+
8+
worlds/dojo-starter
9+
10+
# ignore lock files
11+
**/*-lock.yaml
12+
package-lock.json
13+
dev-dist
14+
15+
**/CHANGELOG.md

README.md

+6-8

.env.example core/.env.example

File renamed without changes.

.eslintignore core/.eslintignore

File renamed without changes.

.eslintrc.json core/.eslintrc.json

File renamed without changes.

core/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

jest.config.js core/jest.config.js

File renamed without changes.

nodemon.json core/nodemon.json

File renamed without changes.

core/package.json

+180
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
{
2+
"name": "eliza",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "dist/index.js",
6+
"type": "module",
7+
"types": "dist/index.d.ts",
8+
"scripts": {
9+
"build": "tsc",
10+
"start": "node --loader ts-node/esm src/index.ts",
11+
"start:arok": "node --loader ts-node/esm src/index.ts --characters=\"characters/arok.character.json\"",
12+
"start:service:ruby": "pm2 start npm --name=\"ruby\" --restart-delay=3000 --max-restarts=10 -- run start:ruby",
13+
"stop:service:ruby": "pm2 stop ruby",
14+
"start:ruby": "node --loader ts-node/esm src/index.ts --characters=\"characters/ruby.character.json\"",
15+
"start:service:trump": "pm2 start npm --name=\"trump\" --restart-delay=3000 --max-restarts=10 -- run start:trump",
16+
"stop:service:trump": "pm2 stop trump",
17+
"start:service:degen": "pm2 start npm --name=\"degen\" --restart-delay=3000 --max-restarts=10 -- run start:degen",
18+
"stop:service:degen": "pm2 stop degen",
19+
"start:degen": "node --loader ts-node/esm src/index.ts --characters=\"characters/degenspartan.json\"",
20+
"start:service:all": "pm2 start npm --name=\"all\" --restart-delay=3000 --max-restarts=10 -- run start:degen",
21+
"stop:service:all": "pm2 stop all",
22+
"start:all": "node --loader ts-node/esm src/index.ts --characters=\"characters/degenspartan.json\",\"characters/ruby.character.json\"",
23+
"start:trump": "node --loader ts-node/esm src/index.ts --characters=\"characters/trump.character.json\"",
24+
"start:service:tate": "pm2 start npm --name=\"tate\" --restart-delay=3000 --max-restarts=10 -- run start:tate",
25+
"stop:service:tate": "pm2 stop tate",
26+
"start:tate": "node --loader ts-node/esm src/index.ts --characters=\"characters/tate.character.json\"",
27+
"watch": "tsc --watch",
28+
"dev": "nodemon",
29+
"build:docs": "cd docs && npm run build",
30+
"postinstall": "npx playwright install-deps && npx playwright install",
31+
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --runInBand --watch -f",
32+
"test:sqlite": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" TEST_DATABASE_CLIENT=sqlite jest --runInBand --watch -f",
33+
"test:sqljs": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" TEST_DATABASE_CLIENT=sqljs jest --runInBand --watch -f"
34+
},
35+
"author": "",
36+
"license": "MIT",
37+
"devDependencies": {
38+
"@rollup/plugin-commonjs": "25.0.8",
39+
"@rollup/plugin-json": "6.1.0",
40+
"@rollup/plugin-node-resolve": "15.3.0",
41+
"@rollup/plugin-replace": "5.0.7",
42+
"@rollup/plugin-terser": "0.1.0",
43+
"@rollup/plugin-typescript": "11.1.6",
44+
"@types/better-sqlite3": "7.6.11",
45+
"@types/fluent-ffmpeg": "2.1.27",
46+
"@types/jest": "29.5.14",
47+
"@types/node": "22.8.4",
48+
"@types/sql.js": "1.4.9",
49+
"@types/tar": "6.1.13",
50+
"@types/wav-encoder": "1.3.3",
51+
"@typescript-eslint/eslint-plugin": "8.12.2",
52+
"@typescript-eslint/parser": "8.12.2",
53+
"dotenv": "16.4.5",
54+
"eslint": "9.13.0",
55+
"eslint-config-prettier": "9.1.0",
56+
"eslint-plugin-prettier": "5.2.1",
57+
"itty-router": "5.0.18",
58+
"jest": "29.7.0",
59+
"lint-staged": "15.2.10",
60+
"npm-run-all2": "7.0.1",
61+
"prettier": "3.3.3",
62+
"rimraf": "6.0.1",
63+
"rollup": "2.79.2",
64+
"ts-jest": "29.2.5",
65+
"ts-node": "10.9.2",
66+
"tslib": "2.8.0",
67+
"typescript": "5.6.3",
68+
"wrangler": "3.84.0"
69+
},
70+
"dependencies": {
71+
"@ai-sdk/anthropic": "^0.0.53",
72+
"@ai-sdk/google": "^0.0.55",
73+
"@ai-sdk/google-vertex": "^0.0.42",
74+
"@ai-sdk/groq": "^0.0.3",
75+
"@ai-sdk/openai": "^0.0.70",
76+
"@anthropic-ai/sdk": "^0.30.1",
77+
"@cliqz/adblocker-playwright": "1.34.0",
78+
"@coral-xyz/anchor": "^0.30.1",
79+
"@discordjs/opus": "github:discordjs/opus",
80+
"@discordjs/rest": "2.4.0",
81+
"@discordjs/voice": "0.17.0",
82+
"@echogarden/espeak-ng-emscripten": "0.3.0",
83+
"@echogarden/kissfft-wasm": "0.2.0",
84+
"@echogarden/speex-resampler-wasm": "0.2.1",
85+
"@huggingface/transformers": "3.0.1",
86+
"@opendocsg/pdf2md": "0.1.31",
87+
"@solana/spl-token": "0.4.9",
88+
"@solana/web3.js": "1.95.4",
89+
"@supabase/supabase-js": "2.46.1",
90+
"@telegraf/types": "7.1.0",
91+
"@types/body-parser": "1.19.5",
92+
"@types/cors": "2.8.17",
93+
"@types/express": "5.0.0",
94+
"agent-twitter-client": "0.0.13",
95+
"ai": "^3.4.23",
96+
"alawmulaw": "6.0.0",
97+
"ansi-colors": "4.1.3",
98+
"anthropic-vertex-ai": "^1.0.0",
99+
"better-sqlite3": "11.5.0",
100+
"bignumber": "1.1.0",
101+
"bignumber.js": "9.1.2",
102+
"body-parser": "1.20.3",
103+
"capsolver-npm": "2.0.2",
104+
"cldr-segmentation": "2.2.1",
105+
"command-exists": "1.2.9",
106+
"commander": "12.1.0",
107+
"cors": "2.8.5",
108+
"cross-fetch": "4.0.0",
109+
"csv-writer": "1.6.0",
110+
"discord.js": "14.16.3",
111+
"espeak-ng": "1.0.2",
112+
"express": "4.21.1",
113+
"ffmpeg-static": "5.2.0",
114+
"figlet": "1.8.0",
115+
"fluent-ffmpeg": "2.1.3",
116+
"formdata-node": "6.0.3",
117+
"fs-extra": "11.2.0",
118+
"gaxios": "6.7.1",
119+
"gif-frames": "^0.4.1",
120+
"glob": "11.0.0",
121+
"graceful-fs": "4.2.11",
122+
"html-escaper": "3.0.3",
123+
"html-to-text": "9.0.5",
124+
"import-meta-resolve": "4.1.0",
125+
"jieba-wasm": "2.2.0",
126+
"js-sha1": "0.7.0",
127+
"json5": "2.2.3",
128+
"kuromoji": "0.1.2",
129+
"libsodium-wrappers": "0.7.15",
130+
"multer": "1.4.5-lts.1",
131+
"node-cache": "5.1.2",
132+
"node-llama-cpp": "3.1.1",
133+
"node-wav": "0.0.2",
134+
"nodejs-whisper": "0.1.18",
135+
"nodemon": "3.1.7",
136+
"onnxruntime-node": "1.20.0",
137+
"openai": "4.69.0",
138+
"pdfjs-dist": "4.7.76",
139+
"pg": "^8.13.1",
140+
"playwright": "1.48.2",
141+
"pm2": "5.4.2",
142+
"prism-media": "1.3.5",
143+
"pumpdotfun-sdk": "1.3.2",
144+
"puppeteer-extra": "3.3.6",
145+
"puppeteer-extra-plugin-capsolver": "2.0.1",
146+
"sql.js": "1.12.0",
147+
"sqlite-vec": "0.1.4-alpha.2",
148+
"srt": "0.0.3",
149+
"systeminformation": "5.23.5",
150+
"tar": "7.4.3",
151+
"telegraf": "4.16.3",
152+
"tiktoken": "1.0.17",
153+
"tinyld": "1.3.4",
154+
"together-ai": "^0.7.0",
155+
"unique-names-generator": "4.7.1",
156+
"uuid": "11.0.2",
157+
"uuidv4": "6.2.13",
158+
"wav": "1.0.2",
159+
"wav-encoder": "1.3.0",
160+
"wavefile": "11.0.0",
161+
"whisper-turbo": "0.11.0",
162+
"ws": "8.18.0",
163+
"yargs": "17.7.2",
164+
"youtube-dl-exec": "3.0.10"
165+
},
166+
"trustedDependencies": {
167+
"onnxruntime-node": "1.19.0",
168+
"@discordjs/opus": "github:discordjs/opus",
169+
"sharp": "^0.33.5"
170+
},
171+
"optionalDependencies": {
172+
"sharp": "0.33.5",
173+
"sqlite-vss-darwin-arm64": "0.1.2",
174+
"sqlite-vss-darwin-x64": "0.1.2",
175+
"sqlite-vss-linux-arm64": "^0.1.2",
176+
"sqlite-vss-linux-x64": "0.1.2",
177+
"sqlite-vss-win32-arm64": "^0.1.2",
178+
"sqlite-vss-win32-x64": "^0.1.2"
179+
}
180+
}

renovate.json core/renovate.json

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/actions/imageGenerationUtils.ts core/src/actions/imageGenerationUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// TODO: Replace with the vercel ai sdk and support all providers
22
import { Buffer } from 'buffer';
33
import Together from "together-ai";
4-
import { IAgentRuntime } from "../core/types";
4+
import { IAgentRuntime } from "../core/types.ts";
55
import { getModel, ImageGenModel } from "../core/imageGenModels.ts";
66
import OpenAI from "openai";
77

File renamed without changes.
File renamed without changes.

src/actions/pumpfun.ts core/src/actions/pumpfun.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from "pumpdotfun-sdk";
1414

1515
import { getAssociatedTokenAddressSync } from "@solana/spl-token";
16-
import settings from "../core/settings";
16+
import settings from "../core/settings.ts";
1717

1818
import {
1919
ActionExample,
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/adapters/sqlite.ts core/src/adapters/sqlite.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { v4 } from "uuid";
2-
import { load } from "../adapters/sqlite/sqlite_vec.ts";
2+
import { load } from "./sqlite/sqlite_vec.ts";
33

44
import { DatabaseAdapter } from "../core/database.ts";
55
import {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/core/defaultCharacter.ts core/src/core/defaultCharacter.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ const defaultCharacter: Character = {
99
],
1010
modelProvider: ModelProvider.OPENAI,
1111
settings: {
12-
secrets: {
13-
TWITTER_USERNAME: "eliza__v1",
14-
ELEVENLABS_VOICE_STABILITY: "0.5",
15-
ELEVENLABS_VOICE_SIMILARITY_BOOST: "0.9",
16-
ELEVENLABS_VOICE_STYLE: "0.66",
17-
},
12+
secrets: {},
1813
voice: {
1914
model: "en_US-hfc_female-medium",
2015
},
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/index.ts core/src/index.ts

File renamed without changes.

src/lib.ts core/src/lib.ts

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"data":{"schemaVersion":"1.0.0","pairs":[{"chainId":"solana","dexId":"raydium","url":"https://dexscreener.com/solana/9p8pi37msc1dwbvilujf4i82sbdf64invec1kcr1x5vk","pairAddress":"9P8Pi37MsC1dWBViLUJF4i82sbDf64iNVec1KCr1X5vk","baseToken":{"address":"2weMjPLLybRMMva1fM3U31goWWrCpF59CHWNhnCJ9Vyh","name":"SHARPEI","symbol":"SHAR"},"quoteToken":{"address":"So11111111111111111111111111111111111111112","name":"Wrapped SOL","symbol":"SOL"},"priceNative":"0.000000000003380","priceUsd":"0.0000000005930","txns":{"m5":{"buys":0,"sells":0},"h1":{"buys":0,"sells":0},"h6":{"buys":0,"sells":0},"h24":{"buys":0,"sells":1}},"volume":{"h24":1.17,"h6":0,"h1":0,"m5":0},"priceChange":{"m5":0,"h1":0,"h6":0,"h24":0},"liquidity":{"usd":73.41,"base":62816039761,"quote":0.2061},"fdv":59,"marketCap":59,"pairCreatedAt":1729700095000,"info":{"imageUrl":"https://dd.dexscreener.com/ds-data/tokens/solana/2weMjPLLybRMMva1fM3U31goWWrCpF59CHWNhnCJ9Vyh.png","websites":[{"label":"Website","url":"https://www.sharpei.xyz/"}],"socials":[{"type":"twitter","url":"https://x.com/SolanaKol"},{"type":"telegram","url":"https://t.me/sharsol"}]}}]},"expiry":1730420206609}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"data":[],"expiry":1730420207793}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"data":{"ownerBalance":null,"creatorBalance":0,"ownerPercentage":null,"creatorPercentage":0,"top10HolderBalance":97984326430.19872,"top10HolderPercent":0.9922779616670393},"expiry":1730420206118}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"data":{"address":"2weMjPLLybRMMva1fM3U31goWWrCpF59CHWNhnCJ9Vyh","holder":1407,"market":1,"last_trade_unix_time":1730353661,"last_trade_human_time":"2024-10-31T05:47:41","price":5.92913712012338e-10,"history_30m_price":5.92913712012338e-10,"price_change_30m_percent":0,"history_1h_price":5.92913712012338e-10,"price_change_1h_percent":0,"history_2h_price":5.92913712012338e-10,"price_change_2h_percent":0,"history_4h_price":5.92913712012338e-10,"price_change_4h_percent":0,"history_6h_price":5.92913712012338e-10,"price_change_6h_percent":0,"history_8h_price":5.92913712012338e-10,"price_change_8h_percent":0,"history_12h_price":5.92913712012338e-10,"price_change_12h_percent":0,"history_24h_price":5.797865002251019e-10,"price_change_24h_percent":2.2641458161132384,"unique_wallet_30m":null,"unique_wallet_history_30m":null,"unique_wallet_30m_change_percent":null,"unique_wallet_1h":null,"unique_wallet_history_1h":null,"unique_wallet_1h_change_percent":null,"unique_wallet_2h":null,"unique_wallet_history_2h":null,"unique_wallet_2h_change_percent":null,"unique_wallet_4h":null,"unique_wallet_history_4h":null,"unique_wallet_4h_change_percent":null,"unique_wallet_8h":null,"unique_wallet_history_8h":null,"unique_wallet_8h_change_percent":null,"unique_wallet_24h":3,"unique_wallet_history_24h":3,"unique_wallet_24h_change_percent":0,"trade_30m":0,"trade_history_30m":0,"trade_30m_change_percent":null,"sell_30m":0,"sell_history_30m":0,"sell_30m_change_percent":null,"buy_30m":0,"buy_history_30m":0,"buy_30m_change_percent":null,"volume_30m":0,"volume_30m_usd":0,"volume_history_30m":0,"volume_history_30m_usd":0,"volume_30m_change_percent":null,"volume_buy_30m":null,"volume_buy_30m_usd":null,"volume_buy_history_30m":null,"volume_buy_history_30m_usd":null,"volume_buy_30m_change_percent":null,"volume_sell_30m":null,"volume_sell_30m_usd":null,"volume_sell_history_30m":null,"volume_sell_history_30m_usd":null,"volume_sell_30m_change_percent":null,"trade_1h":0,"trade_history_1h":0,"trade_1h_change_percent":null,"sell_1h":0,"sell_history_1h":0,"sell_1h_change_percent":null,"buy_1h":0,"buy_history_1h":0,"buy_1h_change_percent":null,"volume_1h":0,"volume_1h_usd":0,"volume_history_1h":0,"volume_history_1h_usd":0,"volume_1h_change_percent":null,"volume_buy_1h":null,"volume_buy_1h_usd":null,"volume_buy_history_1h":null,"volume_buy_history_1h_usd":null,"volume_buy_1h_change_percent":null,"volume_sell_1h":null,"volume_sell_1h_usd":null,"volume_sell_history_1h":null,"volume_sell_history_1h_usd":null,"volume_sell_1h_change_percent":null,"trade_2h":0,"trade_history_2h":0,"trade_2h_change_percent":null,"sell_2h":0,"sell_history_2h":0,"sell_2h_change_percent":null,"buy_2h":0,"buy_history_2h":0,"buy_2h_change_percent":null,"volume_2h":0,"volume_2h_usd":0,"volume_history_2h":0,"volume_history_2h_usd":0,"volume_2h_change_percent":null,"volume_buy_2h":null,"volume_buy_2h_usd":null,"volume_buy_history_2h":null,"volume_buy_history_2h_usd":null,"volume_buy_2h_change_percent":null,"volume_sell_2h":null,"volume_sell_2h_usd":null,"volume_sell_history_2h":null,"volume_sell_history_2h_usd":null,"volume_sell_2h_change_percent":null,"trade_4h":0,"trade_history_4h":0,"trade_4h_change_percent":null,"sell_4h":0,"sell_history_4h":0,"sell_4h_change_percent":null,"buy_4h":0,"buy_history_4h":0,"buy_4h_change_percent":null,"volume_4h":0,"volume_4h_usd":0,"volume_history_4h":0,"volume_history_4h_usd":0,"volume_4h_change_percent":null,"volume_buy_4h":null,"volume_buy_4h_usd":null,"volume_buy_history_4h":null,"volume_buy_history_4h_usd":null,"volume_buy_4h_change_percent":null,"volume_sell_4h":null,"volume_sell_4h_usd":null,"volume_sell_history_4h":null,"volume_sell_history_4h_usd":null,"volume_sell_4h_change_percent":null,"trade_8h":0,"trade_history_8h":0,"trade_8h_change_percent":null,"sell_8h":0,"sell_history_8h":0,"sell_8h_change_percent":null,"buy_8h":0,"buy_history_8h":0,"buy_8h_change_percent":null,"volume_8h":0,"volume_8h_usd":0,"volume_history_8h":0,"volume_history_8h_usd":0,"volume_8h_change_percent":null,"volume_buy_8h":null,"volume_buy_8h_usd":null,"volume_buy_history_8h":null,"volume_buy_history_8h_usd":null,"volume_buy_8h_change_percent":null,"volume_sell_8h":null,"volume_sell_8h_usd":null,"volume_sell_history_8h":null,"volume_sell_history_8h_usd":null,"volume_sell_8h_change_percent":null,"trade_24h":1,"trade_history_24h":2,"trade_24h_change_percent":-50,"sell_24h":1,"sell_history_24h":1,"sell_24h_change_percent":0,"buy_24h":0,"buy_history_24h":1,"buy_24h_change_percent":-100,"volume_24h":1988689816.32415,"volume_24h_usd":1.179121460595915,"volume_history_24h":6255934028.790945,"volume_history_24h_usd":3.6796057811224863,"volume_24h_change_percent":-68.21114469603039,"volume_buy_24h":0.00019359588623046875,"volume_buy_24h_usd":3.49102080576813e-10,"volume_buy_history_24h":3169272907.791343,"volume_buy_history_24h_usd":1.8375016478157893,"volume_buy_24h_change_percent":-99.99999999999389,"volume_sell_24h":1988689816.3239565,"volume_sell_24h_usd":1.179121460246813,"volume_sell_history_24h":3086661120.999602,"volume_sell_history_24h_usd":1.8421041333066972,"volume_sell_24h_change_percent":-35.57148846712632},"expiry":1730420206358}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/providers/token.ts core/src/providers/token.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
ProcessedTokenData,
1212
TokenSecurityData,
1313
TokenTradeData
14-
} from "../types/token";
14+
} from "../types/token.ts";
1515
import { fileURLToPath } from "url";
1616

1717
const PROVIDER_CONFIG = {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

core/src/services/pdf.ts

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { getDocument, PDFDocumentProxy } from "pdfjs-dist";
2+
import { TextItem, TextMarkedContent } from "pdfjs-dist/types/src/display/api";
3+
4+
export class PdfService {
5+
async convertPdfToText(pdfBuffer: Buffer): Promise<string> {
6+
// Convert Buffer to Uint8Array
7+
const uint8Array = new Uint8Array(pdfBuffer);
8+
9+
const pdf: PDFDocumentProxy = await getDocument({ data: uint8Array })
10+
.promise;
11+
const numPages = pdf.numPages;
12+
const textPages: string[] = [];
13+
14+
for (let pageNum = 1; pageNum <= numPages; pageNum++) {
15+
const page = await pdf.getPage(pageNum);
16+
const textContent = await page.getTextContent();
17+
const pageText = textContent.items
18+
.filter(isTextItem)
19+
.map((item) => item.str)
20+
.join(" ");
21+
textPages.push(pageText);
22+
}
23+
24+
return textPages.join("\n");
25+
}
26+
}
27+
28+
// Type guard function
29+
function isTextItem(item: TextItem | TextMarkedContent): item is TextItem {
30+
return "str" in item;
31+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

core/tsconfig.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2022",
4+
"module": "es2022",
5+
"lib": ["es2023", "dom"],
6+
"moduleResolution": "bundler",
7+
"outDir": "./dist",
8+
"rootDir": "./src",
9+
"strict": false,
10+
"esModuleInterop": true,
11+
"skipLibCheck": true,
12+
"forceConsistentCasingInFileNames": false,
13+
"allowImportingTsExtensions": true,
14+
"declaration": true,
15+
"emitDeclarationOnly": true,
16+
"resolveJsonModule": true,
17+
"noImplicitAny": false,
18+
"allowJs": true,
19+
"checkJs": false,
20+
"noEmitOnError": false,
21+
"moduleDetection": "force",
22+
"allowArbitraryExtensions": true,
23+
"typeRoots": ["./node_modules/@types", "./types"]
24+
},
25+
"include": ["src/**/*"],
26+
"exclude": ["node_modules", "dist"]
27+
}

core/types/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare global {
2+
interface Buffer extends Uint8Array {}
3+
}
4+
5+
export {};

0 commit comments

Comments
 (0)