mirror of
https://github.com/kevinthedang/discord-ollama.git
synced 2026-11-08 10:51:18 -05:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e808e3d5e0 | ||
|
|
7df5d14e28 | ||
|
|
288c0eb08f | ||
|
|
217291e531 |
@@ -23,6 +23,24 @@ These are guides to the features and capabilities of this app.
|
||||
* [User Slash Commands](./docs/commands-guide.md)
|
||||
* [Client Events](./docs/events-guide.md)
|
||||
|
||||
## Logging
|
||||
The application uses Pino child loggers with structured component metadata.
|
||||
Outside production, `pino-caller` adds the source file and line to each log
|
||||
entry. Set `LOG_LEVEL` to configure the minimum level (defaults to `info`).
|
||||
|
||||
```ts
|
||||
import { createLogger } from './components/index.js'
|
||||
|
||||
const logger = createLogger({ component: 'request', requestId })
|
||||
logger.info('Request started')
|
||||
```
|
||||
|
||||
Log entries are JSON and include the structured fields provided to the log
|
||||
method, along with `component` and (outside production) `caller`. The root Pino
|
||||
instance is shared; create one child when entering a context, then pass that
|
||||
same child logger through the context's work. Create another child only when
|
||||
you need to add more scoped bindings; child creation does not mutate its parent.
|
||||
|
||||
## Environment Setup
|
||||
* Clone this repo using `git clone https://github.com/kevinthedang/discord-ollama.git` or just use [GitHub Desktop](https://desktop.github.com/) to clone the repo.
|
||||
* You will need a `.env` file in the root of the project directory with the bot's token. There is a `.env.sample` is provided for you as a reference for what environment variables.
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ services:
|
||||
build: ./ # find docker file in designated path
|
||||
container_name: discord
|
||||
restart: always # rebuild container always
|
||||
image: kevinthedang/discord-ollama:0.9.2
|
||||
image: kevinthedang/discord-ollama:0.9.3
|
||||
environment:
|
||||
CLIENT_TOKEN: ${CLIENT_TOKEN}
|
||||
LLM_ENDPOINT: ${LLM_ENDPOINT:-${OLLAMA_IP}} # OLLAMA_IP is a deprecated alias
|
||||
|
||||
Generated
+321
-172
@@ -1,17 +1,19 @@
|
||||
{
|
||||
"name": "discord-ollama",
|
||||
"version": "0.9.2",
|
||||
"version": "0.9.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "discord-ollama",
|
||||
"version": "0.9.2",
|
||||
"version": "0.9.3",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"discord.js": "^14.20.0",
|
||||
"dotenv": "^16.5.0",
|
||||
"ollama": "^0.5.15"
|
||||
"ollama": "^0.5.15",
|
||||
"pino": "^10.4.0",
|
||||
"pino-caller": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.13.14",
|
||||
@@ -208,9 +210,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxc-project/types": {
|
||||
"version": "0.151.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.151.0.tgz",
|
||||
"integrity": "sha512-J1yXrIlNDZVzE3ada310xeAw7nH8yCAyLPuUIsjKatFPmfn5bS1oW+cM+QsGOtVWd5nhSpbwZWx/rue+r5Z+PA==",
|
||||
"version": "0.155.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.155.0.tgz",
|
||||
"integrity": "sha512-SeE8JPwW1xs1tHeNycjUtUBdhorRa8o4jlvjwk49R7/Z291i+4DQa7JJIgOm/TaYQZx+QrPQbVJ/9c8dMIZN8Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
@@ -218,10 +220,16 @@
|
||||
"url": "https://github.com/sponsors/oxc-project"
|
||||
}
|
||||
},
|
||||
"node_modules/@pinojs/redact": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@pinojs/redact/-/redact-0.4.0.tgz",
|
||||
"integrity": "sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@rolldown/binding-android-arm-eabi": {
|
||||
"version": "1.2.10",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.10.tgz",
|
||||
"integrity": "sha512-bp9svZb+QurZeh+8H4BhrZkifEB0YBNvTVzNSJnJQkj4NrRwmQoDUCGP0vSN7PbvLeM7l1tK6GXL8mrTiH2myg==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.15.tgz",
|
||||
"integrity": "sha512-aLcgK9gIJ3YRvrrtfSBbRa27F5WrpiTaPulnFpsHPxpUHgFlSgnU4854MHwoRGEBhfRJDWCS2WQ7lIjskE9Olw==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
@@ -237,9 +245,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-android-arm64": {
|
||||
"version": "1.2.10",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.10.tgz",
|
||||
"integrity": "sha512-wm6Dld3RXUAZ/gRWKyUy+4W1B5CB5UeFaOzsSWJWEdxZXHH8rCYiZ5dGe6oJmhsunAPWzL7FZV+VtvmN5Ye2eA==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.15.tgz",
|
||||
"integrity": "sha512-xD7DdZCrbThKuxNg7ooQmvp07ys4J/pnSEMTG3/OdOWl6daC67m/Q4fL78sRHMxTH/N4fGUbYhcPM0MF5WFHkg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -255,9 +263,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-darwin-arm64": {
|
||||
"version": "1.2.10",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.10.tgz",
|
||||
"integrity": "sha512-UbEfXq/AqGNgRTV3ik+X/iR6mUxu2QdYAadwRxJWquUGnW6gDqdP1FtLtFXRow7RJx0ssRwi80XAPr4r+4DtsA==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.15.tgz",
|
||||
"integrity": "sha512-m2WuQ6r0B4OTYxyPpNLtXaMRbRDUbG8YQV2Q3KTdSSK8Th6KHCnC8jVCJt8bvYeSB5WivkkNbc85mKadaSdOxA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -273,9 +281,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-darwin-x64": {
|
||||
"version": "1.2.10",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.10.tgz",
|
||||
"integrity": "sha512-7f5h17q5KZVx/ji1vb8OTq31ch1O2I7K8NPIr44GkyWTApXMIsmhWqZfgpOH10xeauqghDAvGlZktasCkcF6Eg==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.15.tgz",
|
||||
"integrity": "sha512-5RtnsHM36nodM9WbMy+zip0LGS/G+y5wro5RHrpOlr4ac24+1zSi9kiV2MP1myZeZ/ifEHfulQcWjnAXzc2C2A==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -291,9 +299,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-freebsd-x64": {
|
||||
"version": "1.2.10",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.10.tgz",
|
||||
"integrity": "sha512-ynOk/eEYhC6ZB2xCGvKrEOwE58oBy9LnrAqtkrDF9Fz1VTaNdGZTsV0VarJdhPwb+sOJTGjCLwcuyRJZ1dnMcQ==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.15.tgz",
|
||||
"integrity": "sha512-g3l09pyFqhu+135JKkbkwiKGQmwU5hUMUPJ4VdBADvuqR8d33L6H578rh8m7rtxbdp+VmX/+nzI7nvhSZlzpUQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -309,9 +317,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-arm-gnueabihf": {
|
||||
"version": "1.2.10",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.10.tgz",
|
||||
"integrity": "sha512-ERrAs185meZZhGan7a4l3RiiJK1ArSDlHdST++uvSxe+FDbR4TwUPahT/cbZJvaG6fIpDpF78surN+tX708Y4Q==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.15.tgz",
|
||||
"integrity": "sha512-nIe3VugI97nGQtspPxDqA4sXMUpeiocKIP/CqpY/u/vgbT+alX+cVxu1C/oVBPKg4feNTmYovE91v4DgXvXNwQ==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
@@ -327,9 +335,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-arm64-gnu": {
|
||||
"version": "1.2.10",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.10.tgz",
|
||||
"integrity": "sha512-KN7OHKD0J3jy1UzBwZWPxpwhODf9IARUIJcrH+yLYKOcmegZ8luEUM38lDP1bDVj40yP6PsSzCqOJF76vljFnQ==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.15.tgz",
|
||||
"integrity": "sha512-iTBjXx+B5QSvgI89lJfmqh4wTh8NabR1YZIIN3hNx4zSG0EVfVqkOvLulNpG4251pbd6/IAmZ/LefVk1Y4rPhw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -348,9 +356,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-arm64-musl": {
|
||||
"version": "1.2.10",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.10.tgz",
|
||||
"integrity": "sha512-8l9wP8O+wa8zD6iw6egSfzVtu7oZVfH3hlUsMM4MwbLMhxleqeoXbZzjddyK3YyNlwLhqznq3tF7PkNJ8T/V2w==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.15.tgz",
|
||||
"integrity": "sha512-uN26XOnVR7rqQupG3V9oAG2EGGatWjcJHOeDOHUFCh4TBWmP2tHTFoVN13aYbwfm0aHqJAEmcwhAu6sooIjfqQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -369,9 +377,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-ppc64-gnu": {
|
||||
"version": "1.2.10",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.10.tgz",
|
||||
"integrity": "sha512-SeXNKeQzA5kLhz/J0CH6ZP0/HJ3v1xm/0YbiYpE0kK7emfRC2OIGGIaE14xzkISEGv2aYuUSpiLiU5Gbq+OI0A==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.15.tgz",
|
||||
"integrity": "sha512-9nWkcdd+H+XhaA3fQIwpHnKIrfx/PQ6rO0pivr78Og07tXlUlctBBJoEYLPfhTmCR/QxEVdn6uPjHV5SymPhdw==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
@@ -390,9 +398,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-s390x-gnu": {
|
||||
"version": "1.2.10",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.10.tgz",
|
||||
"integrity": "sha512-mtht0nR+y8/hart4175Ll15w7lY8dg7CtQ+j2FDNTsDRspOWTK/2V3l0aj9sIj7XmvqxT8Yli/wq22e7feTTWg==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.15.tgz",
|
||||
"integrity": "sha512-Ggh0ciFjLwIusLSLz7LZYEaGdxOAUJXI+Qu5JCbhPJJHEt8vP+IjRATTJheiJsdzzTYgUiHUiw3X1Ea3ZpMBdA==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
@@ -411,9 +419,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-x64-gnu": {
|
||||
"version": "1.2.10",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.10.tgz",
|
||||
"integrity": "sha512-FSM94nGd55NYo48usCyM/nHfUKRnqc9+b0vJNuKV0oCCpIp/OGims7rO1Nv/DkFkt0S/s2rxsJ2kkS8J3HcpeA==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.15.tgz",
|
||||
"integrity": "sha512-FHg60rS6DBePAYZ9X9F67x+JObFdmgn6tupA1C/a3B+CufFmTD4mX+e8M75tCiAO3foR/6xwVBI0KQiI7sn/rw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -432,9 +440,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-x64-musl": {
|
||||
"version": "1.2.10",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.10.tgz",
|
||||
"integrity": "sha512-C3YxNB16myRLs7o+B+6PnQ6jBsdIS4+AE4Ah8glVGhDpEv9AOvxhZ/1duAb4B0UGczEK/lBbccksd8VI+p6zfw==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.15.tgz",
|
||||
"integrity": "sha512-/cvV/7v5VGz/moiz0XKRj2dE8DzsKyhIu1KpOvJGPjRywg3yscON889UGvAe8zfiJLHup7VLjBduoGWi3HusWQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -453,9 +461,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-openharmony-arm64": {
|
||||
"version": "1.2.10",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.10.tgz",
|
||||
"integrity": "sha512-571TlE/F1eeTjjdjYAMMMPs1Mfv3MtX6s3+ZKVU6HiUjZ5Njc6c/qzNy/8K3zALTZnaw3JQVYrHxvNfjm43KAg==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.15.tgz",
|
||||
"integrity": "sha512-MyzC5Hrv/sm+Z7TSGKP/j8001RO2xQm1zOpCNVL4j0cY/VhBZviludA2YFQ7i4lH6ZAXxQm0lcMdBzM+99mE7w==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -471,9 +479,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-win32-arm64-msvc": {
|
||||
"version": "1.2.10",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.10.tgz",
|
||||
"integrity": "sha512-QXW+ZWaiqs2c7Fi++D/SsW07LTPcUrncxcskJGfGNBoaLik1IU6fJymz4HsqwEO0u5Iq11yTO0B/mc4cPk7jrQ==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.15.tgz",
|
||||
"integrity": "sha512-+PgYiS+AH5omy6L45ZLxybasauJaj3M8buoT83D+nzPmCayXlxUV9hydhciCKVyIg0B/v0BtXPDE1uGqNwCPpg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -489,9 +497,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-win32-x64-msvc": {
|
||||
"version": "1.2.10",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.10.tgz",
|
||||
"integrity": "sha512-5FQFGgah17YeMtG1Yd5a+rMxQpTksyNXxRtKz06FVTaQw3RKYUJQbUoKk0/5jrXBpDo+7makNP7UHA2LQyH64A==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.15.tgz",
|
||||
"integrity": "sha512-HFZd2QNQYn1JbIi+Hpd7H+r/lkWxcfIu28nirZ6eCn2LafuvmExMlb/P96Sfx5tf7pPArw39IdhmCF8vmV+NhQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -618,38 +626,10 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@vitest/mocker": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.0.1.tgz",
|
||||
"integrity": "sha512-6K1DoBNAPGvuOcSsGA4D6x+5zEEff/KmOOP3uetT2TrGpVfI+HRHRnJJfKi5ib/g1vx8IYHQD8s0pbJz8WQI7Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/trace-mapping": "0.3.31",
|
||||
"@vitest/spy": "5.0.1",
|
||||
"estree-walker": "^3.0.3",
|
||||
"magic-string": "^1.2.3"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/vitest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"msw": "^2.4.9",
|
||||
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"msw": {
|
||||
"optional": true
|
||||
},
|
||||
"vite": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@vitest/spy": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.0.1.tgz",
|
||||
"integrity": "sha512-rbto/mF/SGERxEgYOek7Xm6B9b+y+mVoo+f4b2LymYO8zM1b7uB5nHuhVMTP2hxdzgxvGiZYGxGIaMvL5y180Q==",
|
||||
"version": "5.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.0.5.tgz",
|
||||
"integrity": "sha512-lwJRExuH417257Q5wv9QYugN9IMJkoxcrKrYxGPQkBzl7wlNpTUxD/5yNX4ESKVUIShKPgkGchYPFMWOOk0wzw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
@@ -709,10 +689,25 @@
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/atomic-sleep": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz",
|
||||
"integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/buffer-from": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
|
||||
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/chai": {
|
||||
"version": "6.2.2",
|
||||
"resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz",
|
||||
"integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==",
|
||||
"version": "6.3.0",
|
||||
"resolved": "https://registry.npmjs.org/chai/-/chai-6.3.0.tgz",
|
||||
"integrity": "sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -1175,9 +1170,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/magic-string": {
|
||||
"version": "1.4.2",
|
||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.2.tgz",
|
||||
"integrity": "sha512-vG+rjFRj1PqdIBozIxAGMjPlOhaVe+GXpbttY/iSK7rGcJRMlwNJO7dcUwmUqkymsFLJiNGI06t4D7Fr7yRC9g==",
|
||||
"version": "1.4.3",
|
||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.3.tgz",
|
||||
"integrity": "sha512-z12OxmaPGE0F4xlpGdjuAUckipLpQlTAuAmyGhNoD7ODpYUzvDfvtxUbjM/jwznyP178oju/KDdyi220wNJ0RQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -1192,9 +1187,9 @@
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/nanoid": {
|
||||
"version": "3.3.19",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.19.tgz",
|
||||
"integrity": "sha512-Y2tUNy4ouw6tq5oDSKeQYGOyhkUBhNOcGV/02KC+6kd9eDGqdZd++mjMiIDilrBYvjEnCYvVtsuHCuP+okSfug==",
|
||||
"version": "3.3.20",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz",
|
||||
"integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
@@ -1212,9 +1207,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/obug": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/obug/-/obug-2.2.1.tgz",
|
||||
"integrity": "sha512-XrsrhT5sybtKI6wakr2SPOlGZWWYbUXZ7a0jT8/QOeAPau+1X/bSegNe5YR75oJmEZQbKningirmGOEJCIk61Q==",
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/obug/-/obug-3.0.0.tgz",
|
||||
"integrity": "sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
"https://github.com/sponsors/sxzz",
|
||||
@@ -1234,6 +1229,15 @@
|
||||
"whatwg-fetch": "^3.6.20"
|
||||
}
|
||||
},
|
||||
"node_modules/on-exit-leak-free": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz",
|
||||
"integrity": "sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/picocolors": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
||||
@@ -1255,10 +1259,59 @@
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/pino": {
|
||||
"version": "10.4.0",
|
||||
"resolved": "https://registry.npmjs.org/pino/-/pino-10.4.0.tgz",
|
||||
"integrity": "sha512-bk1ZMTwG/Vymx+zPoa28MhNzucFvXJWp3csrSuxuHPSMeUettaCoQ5Jvg07mtC4JGNpcfTwz41oVCnNgBK9+vA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@pinojs/redact": "^0.4.0",
|
||||
"atomic-sleep": "^1.0.0",
|
||||
"on-exit-leak-free": "^2.1.0",
|
||||
"pino-abstract-transport": "^3.0.0",
|
||||
"pino-std-serializers": "^7.0.0",
|
||||
"process-warning": "^5.0.0",
|
||||
"quick-format-unescaped": "^4.0.3",
|
||||
"real-require": "^1.0.0",
|
||||
"safe-stable-stringify": "^2.3.1",
|
||||
"sonic-boom": "^4.0.1",
|
||||
"thread-stream": "^4.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"pino": "bin.js"
|
||||
}
|
||||
},
|
||||
"node_modules/pino-abstract-transport": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-3.0.0.tgz",
|
||||
"integrity": "sha512-wlfUczU+n7Hy/Ha5j9a/gZNy7We5+cXp8YL+X+PG8S0KXxw7n/JXA3c46Y0zQznIJ83URJiwy7Lh56WLokNuxg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"split2": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pino-caller": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pino-caller/-/pino-caller-4.0.0.tgz",
|
||||
"integrity": "sha512-z0i/iYp4zH02uIQG8LwFK5dMKTdAYgwZM9LSzoOATJ0H5LTeJ3OZeNBpGget9DpnNaewIt5NkN5YGNvkCZ+JbQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"source-map-support": "^0.5.13"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pino-std-serializers": {
|
||||
"version": "7.1.0",
|
||||
"resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-7.1.0.tgz",
|
||||
"integrity": "sha512-BndPH67/JxGExRgiX1dX0w1FvZck5Wa4aal9198SrRhZjH3GxKQUKIBnYJTdj2HDN3UQAS06HlfcSbQj2OHmaw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
"version": "8.5.28",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.28.tgz",
|
||||
"integrity": "sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A==",
|
||||
"version": "8.5.31",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.31.tgz",
|
||||
"integrity": "sha512-YUbWYCgErwnMAVkjUnYa+KlMBzGpHwiIt/DE7f0G33AuX2LH9UcTk6KgWxd3zRU+pN3u/C+Xl3EnMLM4Hea7Sg==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
@@ -1277,14 +1330,42 @@
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"nanoid": "^3.3.18",
|
||||
"nanoid": "^3.3.20",
|
||||
"picocolors": "^1.1.1",
|
||||
"source-map-js": "^1.2.1"
|
||||
"source-map-js": "^1.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10 || ^12 || >=14"
|
||||
}
|
||||
},
|
||||
"node_modules/process-warning": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/process-warning/-/process-warning-5.1.1.tgz",
|
||||
"integrity": "sha512-oCkNVj4OKnKEcocVBcDfiIugN1/cE6rgfT3nCtzeqZPA8+rIxMaQ0xXzIkGP8Gj2qUaP1UR7uhJ1VD8lUCpzCg==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/fastify"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/fastify"
|
||||
}
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/quick-format-unescaped": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz",
|
||||
"integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/real-require": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/real-require/-/real-require-1.0.0.tgz",
|
||||
"integrity": "sha512-P4nbQYQfePJxRSmY+v/KINxVucm4NF3p3s7pJveMTtom52FR4YGltUQLB8idDXwDDWW+eYrWDFbuzUnjoWHF7g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/resolve-pkg-maps": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz",
|
||||
@@ -1296,14 +1377,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/rolldown": {
|
||||
"version": "1.2.10",
|
||||
"resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.10.tgz",
|
||||
"integrity": "sha512-OxkA08pSryMK7B3XiFA09B4OJ1xJMPgIYCBMY2xchzpqgBGsV1o0DetPAE+Sl3N3L4oCPiEzmHVSOj7iR04Zog==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.15.tgz",
|
||||
"integrity": "sha512-6odND+fel5zVw3I4Yc2e69gvguDnX0CAAGiNDZSq4ik5WUcaLrkD2GLuog0XcODbor31hZ5ayEMgVDno+KPV5g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@oxc-project/types": "=0.151.0",
|
||||
"@oxc-project/types": "=0.155.0",
|
||||
"@rolldown/pluginutils": "^1.0.0"
|
||||
},
|
||||
"bin": {
|
||||
@@ -1313,34 +1394,54 @@
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@rolldown/binding-android-arm-eabi": "1.2.10",
|
||||
"@rolldown/binding-android-arm64": "1.2.10",
|
||||
"@rolldown/binding-darwin-arm64": "1.2.10",
|
||||
"@rolldown/binding-darwin-x64": "1.2.10",
|
||||
"@rolldown/binding-freebsd-x64": "1.2.10",
|
||||
"@rolldown/binding-linux-arm-gnueabihf": "1.2.10",
|
||||
"@rolldown/binding-linux-arm64-gnu": "1.2.10",
|
||||
"@rolldown/binding-linux-arm64-musl": "1.2.10",
|
||||
"@rolldown/binding-linux-ppc64-gnu": "1.2.10",
|
||||
"@rolldown/binding-linux-s390x-gnu": "1.2.10",
|
||||
"@rolldown/binding-linux-x64-gnu": "1.2.10",
|
||||
"@rolldown/binding-linux-x64-musl": "1.2.10",
|
||||
"@rolldown/binding-openharmony-arm64": "1.2.10",
|
||||
"@rolldown/binding-win32-arm64-msvc": "1.2.10",
|
||||
"@rolldown/binding-win32-x64-msvc": "1.2.10"
|
||||
"@rolldown/binding-android-arm-eabi": "1.2.15",
|
||||
"@rolldown/binding-android-arm64": "1.2.15",
|
||||
"@rolldown/binding-darwin-arm64": "1.2.15",
|
||||
"@rolldown/binding-darwin-x64": "1.2.15",
|
||||
"@rolldown/binding-freebsd-x64": "1.2.15",
|
||||
"@rolldown/binding-linux-arm-gnueabihf": "1.2.15",
|
||||
"@rolldown/binding-linux-arm64-gnu": "1.2.15",
|
||||
"@rolldown/binding-linux-arm64-musl": "1.2.15",
|
||||
"@rolldown/binding-linux-ppc64-gnu": "1.2.15",
|
||||
"@rolldown/binding-linux-s390x-gnu": "1.2.15",
|
||||
"@rolldown/binding-linux-x64-gnu": "1.2.15",
|
||||
"@rolldown/binding-linux-x64-musl": "1.2.15",
|
||||
"@rolldown/binding-openharmony-arm64": "1.2.15",
|
||||
"@rolldown/binding-win32-arm64-msvc": "1.2.15",
|
||||
"@rolldown/binding-win32-x64-msvc": "1.2.15"
|
||||
}
|
||||
},
|
||||
"node_modules/siginfo": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz",
|
||||
"integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
"node_modules/safe-stable-stringify": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz",
|
||||
"integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/sonic-boom": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-4.2.1.tgz",
|
||||
"integrity": "sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"atomic-sleep": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map-js": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
||||
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz",
|
||||
"integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"peer": true,
|
||||
@@ -1348,24 +1449,48 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/stackback": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz",
|
||||
"integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
"node_modules/source-map-support": {
|
||||
"version": "0.5.21",
|
||||
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
|
||||
"integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"buffer-from": "^1.0.0",
|
||||
"source-map": "^0.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/split2": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz",
|
||||
"integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">= 10.x"
|
||||
}
|
||||
},
|
||||
"node_modules/std-env": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/std-env/-/std-env-4.2.0.tgz",
|
||||
"integrity": "sha512-oCUKSupKTHX53EyjDtuZQ64pjLJ6yYCtpmEw0goYxtjG9KpbRe8KAsl2tBUGU9DyMcJ0RwJ8GqJAFzMXcXW1Rw==",
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/std-env/-/std-env-4.3.0.tgz",
|
||||
"integrity": "sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/thread-stream": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-4.2.0.tgz",
|
||||
"integrity": "sha512-e2zZ96wSChazBsbENf/Pcm/4swHt2cEKQ92rhUjkL9GCKiTDJIaTBenjE/m9DXi0QBmTMDkFDdOomUy20A1tDQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"real-require": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/tinybench": {
|
||||
"version": "6.1.4",
|
||||
"resolved": "https://registry.npmjs.org/tinybench/-/tinybench-6.1.4.tgz",
|
||||
"integrity": "sha512-9APumHG7r4yOk4X4WlkmE71aZcv1gvin1czO3OQ1U9iJcFA5Ja/ygyb0vPOVHTthFozUYs8CLoLUlM8grb2lTQ==",
|
||||
"version": "6.2.2",
|
||||
"resolved": "https://registry.npmjs.org/tinybench/-/tinybench-6.2.2.tgz",
|
||||
"integrity": "sha512-nIZ2N2dFpjBsg2hgitKu7mA+FvsIJuGJOwysRngmVRRmWgR/UyPjwJj8c/fT/dhm8EkHnF5EOogRf+0Z2qrimA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -1373,9 +1498,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/tinyexec": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.0.tgz",
|
||||
"integrity": "sha512-QKAl9m8gWWGHV8jZcPeym6j+XULi6tOf1mT83WYJ4Lk2ytW/uwAWkrP0uFsdoYMdueVJ0qs26wZ+23xeB4ibNQ==",
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.1.tgz",
|
||||
"integrity": "sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -1996,17 +2121,17 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "8.3.0",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-8.3.0.tgz",
|
||||
"integrity": "sha512-lhZBVvEHefgE+HQZC9O7EBJgCU/nVzFNl7vkS4RE0APtWLP02/8QVIkQtzBxPquh7lq5/78NHipTj7ODQ6XuyQ==",
|
||||
"version": "8.3.5",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-8.3.5.tgz",
|
||||
"integrity": "sha512-z1YpjieJ9g0ebTmQpLBv/oq9E3F9EIlOe+7LahW8SrE3LTiG3udBRUXQOlYXP9b+IC2q2phHeVxj9xGlw34OEQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"lightningcss": "^1.33.0",
|
||||
"picomatch": "^4.0.7",
|
||||
"postcss": "^8.5.28",
|
||||
"rolldown": "~1.2.6",
|
||||
"postcss": "^8.5.30",
|
||||
"rolldown": "~1.2.14",
|
||||
"tinyglobby": "^0.2.17"
|
||||
},
|
||||
"bin": {
|
||||
@@ -2023,7 +2148,7 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/node": "^20.19.0 || >=22.12.0",
|
||||
"@vitejs/devtools": "^0.7.1",
|
||||
"@vitejs/devtools": "^0.7.1 || ^0.8.0",
|
||||
"esbuild": "^0.27.0 || ^0.28.0",
|
||||
"jiti": ">=1.21.0",
|
||||
"less": "^4.0.0",
|
||||
@@ -2075,25 +2200,25 @@
|
||||
}
|
||||
},
|
||||
"node_modules/vitest": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/vitest/-/vitest-5.0.1.tgz",
|
||||
"integrity": "sha512-iA95lQbKEkvrtTkdAgnWbXfbipWiiWe/hDl2P5tMi6WFwD76G0NxXAGp/M9EOcYupeGJRr6wppMc7CoA41TQjg==",
|
||||
"version": "5.0.5",
|
||||
"resolved": "https://registry.npmjs.org/vitest/-/vitest-5.0.5.tgz",
|
||||
"integrity": "sha512-cPODOMF8YnkiiYtDdHo6n4wWmBrOBBbOIYH2d33M4l3CdNn72h+qMmO6uXffUN6A5AZFXNND/d+krS9mgkXRfg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/chai": "^5.2.2",
|
||||
"@vitest/mocker": "5.0.1",
|
||||
"chai": "^6.2.2",
|
||||
"@vitest/mocker": "5.0.5",
|
||||
"chai": "^6.3.0",
|
||||
"es-module-lexer": "^2.3.2",
|
||||
"expect-type": "^1.4.0",
|
||||
"magic-string": "^1.2.3",
|
||||
"obug": "^2.1.4",
|
||||
"magic-string": "^1.4.3",
|
||||
"obug": "^3.0.0",
|
||||
"picomatch": "^4.0.7",
|
||||
"std-env": "^4.2.0",
|
||||
"tinybench": "6.1.4",
|
||||
"tinyexec": "1.3.0",
|
||||
"std-env": "^4.3.0",
|
||||
"tinybench": "^6.2.2",
|
||||
"tinyexec": "^1.3.1",
|
||||
"tinyglobby": "^0.2.17",
|
||||
"why-is-node-running": "^2.3.0"
|
||||
"why-is-node-running": "3.2.1"
|
||||
},
|
||||
"bin": {
|
||||
"vitest": "vitest.mjs"
|
||||
@@ -2108,12 +2233,12 @@
|
||||
"@edge-runtime/vm": "*",
|
||||
"@opentelemetry/api": "^1.9.0",
|
||||
"@types/node": "^22.0.0 || >=24.0.0",
|
||||
"@vitest/browser-playwright": "5.0.1",
|
||||
"@vitest/browser-preview": "5.0.1",
|
||||
"@vitest/browser-playwright": "5.0.5",
|
||||
"@vitest/browser-preview": "5.0.5",
|
||||
"@vitest/browser-webdriverio": "^5.0.0-beta.5 || >=5.0.0",
|
||||
"@vitest/coverage-istanbul": "5.0.1",
|
||||
"@vitest/coverage-v8": "5.0.1",
|
||||
"@vitest/ui": "5.0.1",
|
||||
"@vitest/coverage-istanbul": "5.0.5",
|
||||
"@vitest/coverage-v8": "5.0.5",
|
||||
"@vitest/ui": "5.0.5",
|
||||
"happy-dom": "*",
|
||||
"jsdom": "*",
|
||||
"vite": "^6.4.0 || ^7.0.0 || ^8.0.0"
|
||||
@@ -2157,6 +2282,34 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/vitest/node_modules/@vitest/mocker": {
|
||||
"version": "5.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.0.5.tgz",
|
||||
"integrity": "sha512-xLL3lkDegJZw+MGoGaCCsFayDZthGgpAtr3Vziyfc4p7xH89K7KRPcRBBh/kEYm0Aqkt5DtTmkYpBtRV/FrHZg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/trace-mapping": "0.3.31",
|
||||
"@vitest/spy": "5.0.5",
|
||||
"estree-walker": "^3.0.3",
|
||||
"magic-string": "^1.4.3"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/vitest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"msw": "^2.4.9 || ^3.0.0",
|
||||
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"msw": {
|
||||
"optional": true
|
||||
},
|
||||
"vite": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/whatwg-fetch": {
|
||||
"version": "3.6.20",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.20.tgz",
|
||||
@@ -2164,20 +2317,16 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/why-is-node-running": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz",
|
||||
"integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==",
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-3.2.1.tgz",
|
||||
"integrity": "sha512-Tb2FUhB4vUsGQlfSquQLYkApkuPAFQXGFzxWKHHumVz2dK+X1RUm/HnID4+TfIGYJ1kTcwOaCk/buYCEJr6YjQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"siginfo": "^2.0.0",
|
||||
"stackback": "0.0.2"
|
||||
},
|
||||
"bin": {
|
||||
"why-is-node-running": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
"node": ">=20.11"
|
||||
}
|
||||
},
|
||||
"node_modules/ws": {
|
||||
|
||||
+5
-6
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "discord-ollama",
|
||||
"version": "0.9.2",
|
||||
"version": "0.9.3",
|
||||
"description": "Ollama Integration into discord",
|
||||
"main": "build/index.js",
|
||||
"exports": "./build/index.js",
|
||||
@@ -27,7 +27,9 @@
|
||||
"dependencies": {
|
||||
"discord.js": "^14.20.0",
|
||||
"dotenv": "^16.5.0",
|
||||
"ollama": "^0.5.15"
|
||||
"ollama": "^0.5.15",
|
||||
"pino": "^10.4.0",
|
||||
"pino-caller": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.13.14",
|
||||
@@ -40,8 +42,5 @@
|
||||
"engines": {
|
||||
"npm": ">=10.9.0",
|
||||
"node": ">=24.0.0"
|
||||
},
|
||||
"allowScripts": {
|
||||
"esbuild@0.25.12": true
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -1,10 +1,12 @@
|
||||
import { Client, GatewayIntentBits } from 'discord.js'
|
||||
import { Ollama } from 'ollama'
|
||||
import { Queue } from './components/index.js'
|
||||
import { Queue, createLogger } from './components/index.js'
|
||||
import { UserMessage, registerEvents } from './utils/index.js'
|
||||
import Events from './events/index.js'
|
||||
import Keys from './keys.js'
|
||||
|
||||
const logger = createLogger({ component: 'client' })
|
||||
|
||||
// initialize the client with the following permissions when logging in
|
||||
const client = new Client({
|
||||
intents: [
|
||||
@@ -32,7 +34,7 @@ registerEvents(client, Events, messageHistory, channelMessageHistory, ollama, Ke
|
||||
// Try to log in the client
|
||||
await client.login(Keys.clientToken)
|
||||
.catch((error) => {
|
||||
console.error('[Login Error]', error)
|
||||
logger.fatal({ err: error }, 'Client login failed')
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Client, ChatInputCommandInteraction, ApplicationCommandOptionType, MessageFlags } from 'discord.js'
|
||||
import { openConfig, SlashCommand, UserCommand } from '../utils/index.js'
|
||||
import type { Logger as PinoLogger } from 'pino'
|
||||
|
||||
export const Capacity: SlashCommand = {
|
||||
name: 'modify-capacity',
|
||||
@@ -16,13 +17,13 @@ export const Capacity: SlashCommand = {
|
||||
],
|
||||
|
||||
// Query for message information and set the style
|
||||
run: async (client: Client, interaction: ChatInputCommandInteraction) => {
|
||||
run: async (client: Client, interaction: ChatInputCommandInteraction, logger: PinoLogger) => {
|
||||
// fetch channel and message
|
||||
const channel = await client.channels.fetch(interaction.channelId)
|
||||
if (!channel || !UserCommand.includes(channel.type)) return
|
||||
|
||||
// set state of bot chat features
|
||||
openConfig(`${interaction.user.username}-config.json`, interaction.commandName,
|
||||
openConfig(logger, `${interaction.user.username}-config.json`, interaction.commandName,
|
||||
interaction.options.getNumber('context-capacity')
|
||||
)
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { Channel, Client, CommandInteraction, MessageFlags, TextChannel } from 'discord.js'
|
||||
import { clearChannelInfo, SlashCommand, UserCommand } from '../utils/index.js'
|
||||
import type { Logger as PinoLogger } from 'pino'
|
||||
|
||||
export const ClearUserChannelHistory: SlashCommand = {
|
||||
name: 'clear-user-channel-history',
|
||||
description: 'clears history for user in the current channel',
|
||||
|
||||
// Clear channel history for intended user
|
||||
run: async (client: Client, interaction: CommandInteraction) => {
|
||||
run: async (client: Client, interaction: CommandInteraction, logger: PinoLogger) => {
|
||||
// fetch current channel
|
||||
const channel: Channel | null = await client.channels.fetch(interaction.channelId)
|
||||
|
||||
@@ -15,6 +16,7 @@ export const ClearUserChannelHistory: SlashCommand = {
|
||||
|
||||
// clear channel info for user
|
||||
const successfulWipe = await clearChannelInfo(
|
||||
logger,
|
||||
interaction.channelId,
|
||||
interaction.channel as TextChannel,
|
||||
interaction.user.username
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ApplicationCommandOptionType, ChatInputCommandInteraction, Client, Comm
|
||||
import { UserCommand, SlashCommand } from '../utils/index.js'
|
||||
import { ollama } from '../client.js'
|
||||
import { ModelResponse } from 'ollama'
|
||||
import type { Logger as PinoLogger } from 'pino'
|
||||
|
||||
export const DeleteModel: SlashCommand = {
|
||||
name: 'delete-model',
|
||||
@@ -18,7 +19,7 @@ export const DeleteModel: SlashCommand = {
|
||||
],
|
||||
|
||||
// Delete Model locally stored
|
||||
run: async (client: Client, interaction: ChatInputCommandInteraction) => {
|
||||
run: async (client: Client, interaction: ChatInputCommandInteraction, logger: PinoLogger) => {
|
||||
// defer reply to avoid timeout
|
||||
await interaction.deferReply()
|
||||
const modelInput: string = interaction.options.getString('model-name') as string
|
||||
@@ -42,7 +43,7 @@ export const DeleteModel: SlashCommand = {
|
||||
.then(response => response.models.some((model: ModelResponse) => model.name.startsWith(modelInput)))
|
||||
.catch(error => {
|
||||
ollamaOffline = true
|
||||
console.error(`[Command: delete-model] Failed to connect with Ollama service. Error: ${error.message}`)
|
||||
logger.error({ err: error }, 'Failed to connect to Ollama service')
|
||||
})
|
||||
|
||||
// Validate for any issue or if service is running
|
||||
@@ -53,7 +54,6 @@ export const DeleteModel: SlashCommand = {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// call ollama to delete model
|
||||
if (modelExists) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Client, ChatInputCommandInteraction, ApplicationCommandOptionType, MessageFlags } from 'discord.js'
|
||||
import { AdminCommand, openConfig, SlashCommand } from '../utils/index.js'
|
||||
import type { Logger as PinoLogger } from 'pino'
|
||||
|
||||
export const Disable: SlashCommand = {
|
||||
name: 'toggle-chat',
|
||||
@@ -16,7 +17,7 @@ export const Disable: SlashCommand = {
|
||||
],
|
||||
|
||||
// Query for message information and set the style
|
||||
run: async (client: Client, interaction: ChatInputCommandInteraction) => {
|
||||
run: async (client: Client, interaction: ChatInputCommandInteraction, logger: PinoLogger) => {
|
||||
// fetch channel and message
|
||||
const channel = await client.channels.fetch(interaction.channelId)
|
||||
if (!channel || !AdminCommand.includes(channel.type)) return
|
||||
@@ -31,7 +32,7 @@ export const Disable: SlashCommand = {
|
||||
}
|
||||
|
||||
// set state of bot chat features
|
||||
openConfig(`${interaction.guildId}-config.json`, interaction.commandName,
|
||||
openConfig(logger, `${interaction.guildId}-config.json`, interaction.commandName,
|
||||
interaction.options.getBoolean('enabled')
|
||||
)
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ApplicationCommandOptionType, Client, ChatInputCommandInteraction, MessageFlags } from 'discord.js'
|
||||
import { openConfig, SlashCommand, UserCommand } from '../utils/index.js'
|
||||
import type { Logger as PinoLogger } from 'pino'
|
||||
|
||||
export const MessageStream: SlashCommand = {
|
||||
name: 'message-stream',
|
||||
@@ -16,13 +17,13 @@ export const MessageStream: SlashCommand = {
|
||||
],
|
||||
|
||||
// change preferences based on command
|
||||
run: async (client: Client, interaction: ChatInputCommandInteraction) => {
|
||||
run: async (client: Client, interaction: ChatInputCommandInteraction, logger: PinoLogger) => {
|
||||
// verify channel
|
||||
const channel = await client.channels.fetch(interaction.channelId)
|
||||
if (!channel || !UserCommand.includes(channel.type)) return
|
||||
|
||||
// save value to json and write to it
|
||||
openConfig(`${interaction.user.username}-config.json`, interaction.commandName,
|
||||
openConfig(logger, `${interaction.user.username}-config.json`, interaction.commandName,
|
||||
interaction.options.getBoolean('stream')
|
||||
)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ApplicationCommandOptionType, Client, ChatInputCommandInteraction, Mess
|
||||
import { ollama } from "../client.js"
|
||||
import { ModelResponse } from "ollama"
|
||||
import { UserCommand, SlashCommand } from "../utils/index.js"
|
||||
import type { Logger as PinoLogger } from 'pino'
|
||||
|
||||
export const PullModel: SlashCommand = {
|
||||
name: 'pull-model',
|
||||
@@ -18,7 +19,7 @@ export const PullModel: SlashCommand = {
|
||||
],
|
||||
|
||||
// Pull for model from Ollama library
|
||||
run: async (client: Client, interaction: ChatInputCommandInteraction) => {
|
||||
run: async (client: Client, interaction: ChatInputCommandInteraction, logger: PinoLogger) => {
|
||||
// defer reply to avoid timeout
|
||||
await interaction.deferReply()
|
||||
const modelInput: string = interaction.options.getString('model-to-pull') as string
|
||||
@@ -42,7 +43,7 @@ export const PullModel: SlashCommand = {
|
||||
.then(response => response.models.some((model: ModelResponse) => model.name.startsWith(modelInput)))
|
||||
.catch(error => {
|
||||
ollamaOffline = true
|
||||
console.error(`[Command: pull-model] Failed to connect with Ollama service. Error: ${error.message}`)
|
||||
logger.error({ err: error }, 'Failed to connect to Ollama service')
|
||||
})
|
||||
|
||||
// Validate for any issue or if service is running
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import { Client, CommandInteraction, MessageFlags } from 'discord.js'
|
||||
import { AdminCommand, SlashCommand } from '../utils/index.js'
|
||||
import type { Logger as PinoLogger } from 'pino'
|
||||
|
||||
export const Shutoff: SlashCommand = {
|
||||
name: 'shutoff',
|
||||
description: 'shutdown the bot. You will need to manually bring it online again. Administrator Only.',
|
||||
|
||||
// Query for message information and set the style
|
||||
run: async (client: Client, interaction: CommandInteraction) => {
|
||||
run: async (client: Client, interaction: CommandInteraction, logger: PinoLogger) => {
|
||||
// fetch channel and message
|
||||
const channel = await client.channels.fetch(interaction.channelId)
|
||||
if (!channel || !AdminCommand.includes(channel.type)) return
|
||||
|
||||
// log this, this will probably be improtant for logging who did this
|
||||
console.log(`[Command: shutoff] User ${interaction.user.tag} attempting to shutdown ${client.user!!.tag}`)
|
||||
logger.info({ actor: interaction.user.tag, bot: client.user!!.tag }, 'Shutdown requested')
|
||||
|
||||
// check if admin or false on shutdown
|
||||
if (!interaction.memberPermissions?.has('Administrator')) {
|
||||
@@ -29,7 +30,7 @@ export const Shutoff: SlashCommand = {
|
||||
flags: MessageFlags.Ephemeral
|
||||
})
|
||||
|
||||
console.log(`[Command: shutoff] ${client.user?.tag} is shutting down.`)
|
||||
logger.info({ bot: client.user?.tag }, 'Bot is shutting down')
|
||||
|
||||
// clean up client instance and stop
|
||||
client.destroy()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Client, CommandInteraction, MessageFlags } from "discord.js";
|
||||
import { accessChannelContext, SlashCommand, summarizeContextHistory, UserCommand, UserMessage } from "../utils/index.js";
|
||||
import type { Logger as PinoLogger } from 'pino'
|
||||
import { ollama } from "../client.js"
|
||||
|
||||
export const Summary: SlashCommand = {
|
||||
@@ -7,7 +8,7 @@ export const Summary: SlashCommand = {
|
||||
description: 'provides a summary of the chat history.',
|
||||
|
||||
// Generate Summary from additional context
|
||||
run: async (client: Client, interaction: CommandInteraction) => {
|
||||
run: async (client: Client, interaction: CommandInteraction, logger: PinoLogger) => {
|
||||
// fetch channel
|
||||
const channel = await client.channels.fetch(interaction.channelId)
|
||||
if (!channel || !UserCommand.includes(channel.type)) return
|
||||
@@ -41,9 +42,9 @@ export const Summary: SlashCommand = {
|
||||
})
|
||||
|
||||
// todo: instead of a default of codellama, we can user default model somehow. Look into later.
|
||||
const response: string = await summarizeContextHistory(ollama, "codellama", channelContext)
|
||||
const response: string = await summarizeContextHistory(logger, ollama, "codellama", channelContext)
|
||||
|
||||
console.log(response)
|
||||
logger.info({ response }, 'Generated channel summary')
|
||||
|
||||
interaction.editReply({ content: response })
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ApplicationCommandOptionType, Client, ChatInputCommandInteraction } fro
|
||||
import { ollama } from "../client.js"
|
||||
import { ModelResponse } from "ollama"
|
||||
import { openConfig, UserCommand, SlashCommand } from "../utils/index.js"
|
||||
import type { Logger as PinoLogger } from 'pino'
|
||||
|
||||
export const SwitchModel: SlashCommand = {
|
||||
name: 'switch-model',
|
||||
@@ -18,7 +19,7 @@ export const SwitchModel: SlashCommand = {
|
||||
],
|
||||
|
||||
// Switch user preferred model if available in local library
|
||||
run: async (client: Client, interaction: ChatInputCommandInteraction) => {
|
||||
run: async (client: Client, interaction: ChatInputCommandInteraction, logger: PinoLogger) => {
|
||||
await interaction.deferReply()
|
||||
|
||||
const modelInput: string = interaction.options.getString('model-to-use') as string
|
||||
@@ -35,7 +36,7 @@ export const SwitchModel: SlashCommand = {
|
||||
for (const model in response.models) {
|
||||
const currentModel: ModelResponse = response.models[model]
|
||||
if (currentModel.name.startsWith(modelInput)) {
|
||||
openConfig(`${interaction.user.username}-config.json`, interaction.commandName, modelInput)
|
||||
openConfig(logger, `${interaction.user.username}-config.json`, interaction.commandName, modelInput)
|
||||
|
||||
// successful switch
|
||||
interaction.editReply({
|
||||
@@ -46,12 +47,12 @@ export const SwitchModel: SlashCommand = {
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(`[Command: switch-model] Failed to connect with Ollama service. Error: ${error.message}`)
|
||||
logger.error({ err: error }, 'Failed to connect to Ollama service')
|
||||
})
|
||||
// todo: problem can be here if async messes up
|
||||
if (switchSuccess) {
|
||||
// set model now that it exists
|
||||
openConfig(`${interaction.user.username}-config.json`, interaction.commandName, modelInput)
|
||||
openConfig(logger, `${interaction.user.username}-config.json`, interaction.commandName, modelInput)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { ChannelType, Client, CommandInteraction, MessageFlags, TextChannel, ThreadChannel } from 'discord.js'
|
||||
import { AdminCommand, openChannelInfo, SlashCommand } from '../utils/index.js'
|
||||
import type { Logger as PinoLogger } from 'pino'
|
||||
|
||||
export const ThreadCreate: SlashCommand = {
|
||||
name: 'thread',
|
||||
description: 'creates a thread and mentions user',
|
||||
|
||||
// Query for server information
|
||||
run: async (client: Client, interaction: CommandInteraction) => {
|
||||
run: async (client: Client, interaction: CommandInteraction, logger: PinoLogger) => {
|
||||
// fetch the channel
|
||||
const channel = await client.channels.fetch(interaction.channelId)
|
||||
if (!channel || !AdminCommand.includes(channel.type)) return
|
||||
@@ -21,7 +22,7 @@ export const ThreadCreate: SlashCommand = {
|
||||
thread.send(`Hello ${interaction.user} and others! \n\nIt's nice to meet you. Please talk to me by typing **@${client.user?.username}** with your message.`)
|
||||
|
||||
// handle storing this chat channel
|
||||
openChannelInfo(thread.id, thread as ThreadChannel, interaction.user.tag)
|
||||
openChannelInfo(logger, thread.id, thread as ThreadChannel, interaction.user.tag)
|
||||
|
||||
// user only reply
|
||||
return interaction.reply({
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { ChannelType, Client, CommandInteraction, MessageFlags, TextChannel, ThreadChannel } from 'discord.js'
|
||||
import { AdminCommand, openChannelInfo, SlashCommand } from '../utils/index.js'
|
||||
import type { Logger as PinoLogger } from 'pino'
|
||||
|
||||
export const PrivateThreadCreate: SlashCommand = {
|
||||
name: 'private-thread',
|
||||
description: 'creates a private thread and mentions user',
|
||||
|
||||
// Query for server information
|
||||
run: async (client: Client, interaction: CommandInteraction) => {
|
||||
run: async (client: Client, interaction: CommandInteraction, logger: PinoLogger) => {
|
||||
// fetch the channel
|
||||
const channel = await client.channels.fetch(interaction.channelId)
|
||||
if (!channel || !AdminCommand.includes(channel.type)) return
|
||||
@@ -22,7 +23,7 @@ export const PrivateThreadCreate: SlashCommand = {
|
||||
|
||||
// handle storing this chat channel
|
||||
// store: thread.id, thread.name
|
||||
openChannelInfo(thread.id, thread as ThreadChannel, interaction.user.tag)
|
||||
openChannelInfo(logger, thread.id, thread as ThreadChannel, interaction.user.tag)
|
||||
|
||||
// user only reply
|
||||
return interaction.reply({
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
|
||||
/**
|
||||
* @class Logger
|
||||
* @description A class to handle logging messages
|
||||
* @method log
|
||||
*/
|
||||
export class Logger {
|
||||
private logPrefix: string = ''
|
||||
private type: string = 'log'
|
||||
|
||||
private constructPrefix(component?: string, method?: string): string {
|
||||
let prefix = this.type.toUpperCase()
|
||||
|
||||
if (component) {
|
||||
prefix += ` [${component}`
|
||||
if (method) prefix += `: ${method}`
|
||||
prefix += ']'
|
||||
}
|
||||
|
||||
return prefix
|
||||
}
|
||||
|
||||
public bind(component?: string, method?: string): CallableFunction {
|
||||
let tempPrefix = this.constructPrefix(component, method)
|
||||
|
||||
if (tempPrefix !== this.logPrefix) this.logPrefix = tempPrefix
|
||||
|
||||
switch (this.type) {
|
||||
case 'warn':
|
||||
return console.warn.bind(console, this.logPrefix)
|
||||
case 'error':
|
||||
return console.error.bind(console, this.logPrefix)
|
||||
case 'log':
|
||||
default:
|
||||
return console.log.bind(console, this.logPrefix)
|
||||
}
|
||||
}
|
||||
|
||||
public log(type: string, message: unknown, component?: string, method?: string): void {
|
||||
if (type && type !== this.type) this.type = type
|
||||
|
||||
let log = this.bind(component, method)
|
||||
|
||||
log(message)
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
export * from './queue.js'
|
||||
export * from './binder.js'
|
||||
export * from './logger.js'
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'dotenv/config'
|
||||
import pino, { type Logger as PinoLogger } from 'pino'
|
||||
import { pinoCaller } from 'pino-caller'
|
||||
|
||||
export const rootLogger = pino({
|
||||
level: process.env.LOG_LEVEL ?? 'info'
|
||||
})
|
||||
|
||||
export function createLogger(bindings: pino.Bindings, parent: PinoLogger = rootLogger): PinoLogger {
|
||||
const childLogger = parent.child(bindings)
|
||||
|
||||
return process.env.NODE_ENV === 'production'
|
||||
? childLogger
|
||||
: pinoCaller(childLogger, { relativeTo: process.cwd() })
|
||||
}
|
||||
@@ -1,19 +1,26 @@
|
||||
import { event, Events } from '../utils/index.js'
|
||||
import commands from '../commands/index.js'
|
||||
import { createLogger } from '../components/index.js'
|
||||
|
||||
/**
|
||||
* Interaction creation listener for the client
|
||||
* @param interaction the interaction received from the server
|
||||
*/
|
||||
export default event(Events.InteractionCreate, async ({ log, client }, interaction) => {
|
||||
export default event(Events.InteractionCreate, async ({ logger, client }, interaction) => {
|
||||
if (!interaction.isCommand() || !interaction.isChatInputCommand()) return
|
||||
|
||||
log(`Interaction called \'${interaction.commandName}\' from ${interaction.user.tag}.`)
|
||||
logger.info({ command: interaction.commandName, user: interaction.user.tag }, 'Interaction received')
|
||||
|
||||
// ensure command exists, otherwise kill event
|
||||
const command = commands.find(command => command.name === interaction.commandName)
|
||||
if (!command) return
|
||||
|
||||
// the command exists, execute it
|
||||
command.run(client, interaction)
|
||||
const commandLogger = createLogger({
|
||||
component: 'command',
|
||||
command: command.name
|
||||
}, logger)
|
||||
|
||||
void Promise.resolve(command.run(client, interaction, commandLogger))
|
||||
.catch(error => commandLogger.error({ err: error }, 'Command execution failed'))
|
||||
})
|
||||
+18
-19
@@ -11,10 +11,10 @@ import {
|
||||
*
|
||||
* @param message the message received from the channel
|
||||
*/
|
||||
export default event(Events.MessageCreate, async ({ log, msgHist, channelHistory, ollama, client, defaultModel }, message) => {
|
||||
export default event(Events.MessageCreate, async ({ logger, msgHist, channelHistory, ollama, client, defaultModel }, message) => {
|
||||
const clientId = client.user!!.id
|
||||
let cleanedMessage = clean(message.content, clientId)
|
||||
log(`Message \"${cleanedMessage}\" from ${message.author.tag} in channel/thread ${message.channelId}.`)
|
||||
logger.info({ author: message.author.tag, channelId: message.channelId, message: cleanedMessage }, 'Received message')
|
||||
|
||||
// Do not respond if bot talks in the chat
|
||||
if (message.author.username === message.client.user.username) return
|
||||
@@ -25,7 +25,7 @@ export default event(Events.MessageCreate, async ({ log, msgHist, channelHistory
|
||||
if (channelInfo?.messages)
|
||||
resolve(channelInfo.messages)
|
||||
else {
|
||||
log(`Channel/Thread ${message.channel}-context does not exist. File will be created shortly...`)
|
||||
logger.info({ channelId: message.channelId }, 'Channel context does not exist; creating it')
|
||||
resolve([])
|
||||
}
|
||||
})
|
||||
@@ -33,14 +33,14 @@ export default event(Events.MessageCreate, async ({ log, msgHist, channelHistory
|
||||
|
||||
if (channelContextHistory.length === 0) {
|
||||
channelContextHistory = await new Promise((resolve) => {
|
||||
addToChannelContext(message.channelId,
|
||||
addToChannelContext(logger, message.channelId,
|
||||
message.channel as TextChannel
|
||||
)
|
||||
getChannelInfo(`${message.channelId}-context.json`, (channelInfo) => {
|
||||
if (channelInfo?.messages)
|
||||
resolve(channelInfo.messages)
|
||||
else {
|
||||
log(`Channel/Thread ${message.channel}-context does not exist. File will be created shortly...`)
|
||||
logger.info({ channelId: message.channelId }, 'Channel context does not exist; creating it')
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -61,7 +61,6 @@ export default event(Events.MessageCreate, async ({ log, msgHist, channelHistory
|
||||
while (channelHistory.size() >= channelHistory.capacity) channelHistory.dequeue()
|
||||
|
||||
// push user response to channel history
|
||||
console.log
|
||||
channelHistory.enqueue({
|
||||
role: 'user',
|
||||
content: cleanedMessage,
|
||||
@@ -69,7 +68,7 @@ export default event(Events.MessageCreate, async ({ log, msgHist, channelHistory
|
||||
})
|
||||
|
||||
// Store in Channel Context
|
||||
addToChannelContext(message.channelId,
|
||||
addToChannelContext(logger, message.channelId,
|
||||
message.channel as TextChannel,
|
||||
channelHistory.getItems()
|
||||
)
|
||||
@@ -94,7 +93,7 @@ export default event(Events.MessageCreate, async ({ log, msgHist, channelHistory
|
||||
// check if config.json exists
|
||||
if (config === undefined) {
|
||||
// Allowing chat options to be available
|
||||
openConfig(`${message.guildId}-config.json`, 'toggle-chat', true)
|
||||
openConfig(logger, `${message.guildId}-config.json`, 'toggle-chat', true)
|
||||
reject(new Error('Failed to locate or create Server Preferences\n\nPlease try chatting again...'))
|
||||
}
|
||||
|
||||
@@ -109,7 +108,7 @@ export default event(Events.MessageCreate, async ({ log, msgHist, channelHistory
|
||||
} catch (error) {
|
||||
++attempt
|
||||
if (attempt < maxRetries) {
|
||||
log(`Attempt ${attempt} failed for Server Preferences. Retrying in ${delay}ms...`)
|
||||
logger.warn({ attempt, delay }, 'Failed to retrieve server preferences; retrying')
|
||||
await new Promise(ret => setTimeout(ret, delay))
|
||||
} else
|
||||
throw new Error(`Could not retrieve Server Preferences, please try chatting again...`)
|
||||
@@ -126,18 +125,18 @@ export default event(Events.MessageCreate, async ({ log, msgHist, channelHistory
|
||||
userConfig = await new Promise((resolve, reject) => {
|
||||
getUserConfig(`${message.author.username}-config.json`, (config) => {
|
||||
if (config === undefined) {
|
||||
openConfig(`${message.author.username}-config.json`, 'switch-model', defaultModel)
|
||||
openConfig(logger, `${message.author.username}-config.json`, 'switch-model', defaultModel)
|
||||
reject(new Error(`No User Preferences is set up.\n\nCreating new preferences file for ${message.author.username}\nPlease try chatting again.`))
|
||||
return
|
||||
}
|
||||
|
||||
// check if there is a set capacity in config
|
||||
else if (typeof config.options['modify-capacity'] !== 'number')
|
||||
log(`Capacity is undefined, using default capacity of ${msgHist.capacity}.`)
|
||||
logger.info({ capacity: msgHist.capacity }, 'Capacity is undefined; using default')
|
||||
else if (config.options['modify-capacity'] === msgHist.capacity)
|
||||
log(`Capacity matches config as ${msgHist.capacity}, no changes made.`)
|
||||
logger.info({ capacity: msgHist.capacity }, 'Configured capacity matches current capacity')
|
||||
else {
|
||||
log(`New Capacity found. Setting Context Capacity to ${config.options['modify-capacity']}.`)
|
||||
logger.info({ capacity: config.options['modify-capacity'] }, 'Updating context capacity')
|
||||
msgHist.capacity = config.options['modify-capacity']
|
||||
}
|
||||
|
||||
@@ -154,7 +153,7 @@ export default event(Events.MessageCreate, async ({ log, msgHist, channelHistory
|
||||
} catch (error) {
|
||||
++attempt
|
||||
if (attempt < maxRetries) {
|
||||
log(`Attempt ${attempt} failed for User Preferences. Retrying in ${delay}ms...`)
|
||||
logger.warn({ attempt, delay }, 'Failed to retrieve user preferences; retrying')
|
||||
await new Promise(ret => setTimeout(ret, delay))
|
||||
} else
|
||||
throw new Error(`Could not retrieve User Preferences, please try chatting again...`)
|
||||
@@ -168,7 +167,7 @@ export default event(Events.MessageCreate, async ({ log, msgHist, channelHistory
|
||||
if (channelInfo?.messages)
|
||||
resolve(channelInfo.messages)
|
||||
else {
|
||||
log(`Channel/Thread ${message.channel}-${message.author.username} does not exist. File will be created shortly...`)
|
||||
logger.info({ channelId: message.channelId, username: message.author.username }, 'User channel history does not exist; creating it')
|
||||
resolve([])
|
||||
}
|
||||
})
|
||||
@@ -176,7 +175,7 @@ export default event(Events.MessageCreate, async ({ log, msgHist, channelHistory
|
||||
|
||||
if (chatMessages.length === 0) {
|
||||
chatMessages = await new Promise((resolve, reject) => {
|
||||
openChannelInfo(message.channelId,
|
||||
openChannelInfo(logger, message.channelId,
|
||||
message.channel as TextChannel,
|
||||
message.author.tag
|
||||
)
|
||||
@@ -184,7 +183,7 @@ export default event(Events.MessageCreate, async ({ log, msgHist, channelHistory
|
||||
if (channelInfo?.messages)
|
||||
resolve(channelInfo.messages)
|
||||
else {
|
||||
log(`Channel/Thread ${message.channel}-${message.author.username} does not exist. File will be created shortly...`)
|
||||
logger.info({ channelId: message.channelId, username: message.author.username }, 'User channel history does not exist; creating it')
|
||||
reject(new Error(`Failed to find ${message.author.username}'s history. Try chatting again.`))
|
||||
}
|
||||
})
|
||||
@@ -210,7 +209,7 @@ export default event(Events.MessageCreate, async ({ log, msgHist, channelHistory
|
||||
})
|
||||
|
||||
// response string for ollama to put its response
|
||||
const response: string = await normalMessage(message, ollama, model, msgHist, shouldStream)
|
||||
const response: string = await normalMessage(logger, message, ollama, model, msgHist, shouldStream)
|
||||
|
||||
// If something bad happened, remove user query and stop
|
||||
if (response == undefined) { msgHist.pop(); return }
|
||||
@@ -226,7 +225,7 @@ export default event(Events.MessageCreate, async ({ log, msgHist, channelHistory
|
||||
})
|
||||
|
||||
// only update the json on success
|
||||
openChannelInfo(message.channelId,
|
||||
openChannelInfo(logger, message.channelId,
|
||||
message.channel as TextChannel,
|
||||
message.author.tag,
|
||||
msgHist.getItems()
|
||||
|
||||
+3
-3
@@ -3,9 +3,9 @@ import { event, Events, registerCommands } from '../utils/index.js'
|
||||
import commands from '../commands/index.js'
|
||||
|
||||
// Log when the bot successfully logs in and export it
|
||||
export default event(Events.ClientReady, ({ log }, client) => {
|
||||
export default event(Events.ClientReady, ({ logger }, client) => {
|
||||
// Register the commands associated with the bot upon loggin in
|
||||
registerCommands(client, commands)
|
||||
registerCommands(client, commands, logger)
|
||||
|
||||
// set status of the bot
|
||||
client.user.setActivity({
|
||||
@@ -13,5 +13,5 @@ export default event(Events.ClientReady, ({ log }, client) => {
|
||||
type: ActivityType.Custom
|
||||
})
|
||||
|
||||
log(`Logged in as ${client.user.username}.`)
|
||||
logger.info({ username: client.user.username }, 'Client ready')
|
||||
})
|
||||
@@ -5,16 +5,16 @@ import fs from 'fs'
|
||||
/**
|
||||
* Event to remove the associated .json file for a thread once deleted
|
||||
*/
|
||||
export default event(Events.ThreadDelete, async ({ log }, thread: ThreadChannel) => {
|
||||
export default event(Events.ThreadDelete, async ({ logger }, thread: ThreadChannel) => {
|
||||
// iterate through every guild member in the thread and delete their history, except the bot
|
||||
try {
|
||||
log(`Number of User Guild Members in Thread being deleted: ${thread.memberCount!! - 1}`)
|
||||
logger.info({ memberCount: thread.memberCount!! - 1 }, 'Deleting thread history')
|
||||
const dirPath = 'data/'
|
||||
|
||||
// read all files in data/
|
||||
fs.readdir(dirPath, (error, files) => {
|
||||
if (error) {
|
||||
log(`Error reading directory ${dirPath}`, error)
|
||||
logger.error({ err: error, directory: dirPath }, 'Failed to read history directory')
|
||||
return
|
||||
}
|
||||
|
||||
@@ -28,13 +28,13 @@ export default event(Events.ThreadDelete, async ({ log }, thread: ThreadChannel)
|
||||
const filePath = dirPath + file
|
||||
fs.unlink(filePath, error => {
|
||||
if (error)
|
||||
log(`Error deleting file ${filePath}`, error)
|
||||
logger.error({ err: error, file: filePath }, 'Failed to delete thread history file')
|
||||
else
|
||||
log(`Successfully deleted ${filePath} thread information`)
|
||||
logger.info({ file: filePath }, 'Deleted thread history file')
|
||||
})
|
||||
})
|
||||
})
|
||||
} catch (error) {
|
||||
log(`Issue deleting user history files from ${thread.id}`)
|
||||
logger.error({ err: error, threadId: thread.id }, 'Failed to delete user history files')
|
||||
}
|
||||
})
|
||||
+19
-8
@@ -1,4 +1,5 @@
|
||||
import { ChatInputCommandInteraction, ChatInputApplicationCommandData, Client, ApplicationCommandOption } from 'discord.js'
|
||||
import { ChatInputCommandInteraction, ChatInputApplicationCommandData, Client, type Awaitable } from 'discord.js'
|
||||
import type { Logger as PinoLogger } from 'pino'
|
||||
|
||||
/**
|
||||
* interface for how slash commands should be run
|
||||
@@ -7,8 +8,8 @@ export interface SlashCommand extends ChatInputApplicationCommandData {
|
||||
run: (
|
||||
client: Client,
|
||||
interaction: ChatInputCommandInteraction,
|
||||
options?: ApplicationCommandOption[]
|
||||
) => void
|
||||
logger: PinoLogger
|
||||
) => Awaitable<unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -16,7 +17,7 @@ export interface SlashCommand extends ChatInputApplicationCommandData {
|
||||
* @param client the bot reference
|
||||
* @param commands commands to register to the bot
|
||||
*/
|
||||
export function registerCommands(client: Client, commands: SlashCommand[]): void {
|
||||
export function registerCommands(client: Client, commands: SlashCommand[], logger: PinoLogger): void {
|
||||
// ensure the bot is online before registering
|
||||
if (!client.application) return
|
||||
|
||||
@@ -27,10 +28,15 @@ export function registerCommands(client: Client, commands: SlashCommand[]): void
|
||||
client.application.commands.fetch().then((fetchedCommands) => {
|
||||
for (const command of fetchedCommands.values()) {
|
||||
if (!commandsToRegister.includes(command.name)) {
|
||||
command.delete().catch(console.error)
|
||||
console.log(`[Command: ${command.name}] Removed from Discord`)
|
||||
command.delete().then(() => {
|
||||
logger.info({ command: command.name }, 'Removed command from Discord')
|
||||
}).catch(error => {
|
||||
logger.error({ err: error, command: command.name }, 'Failed to remove command from Discord')
|
||||
})
|
||||
}
|
||||
}
|
||||
}).catch(error => {
|
||||
logger.error({ err: error }, 'Failed to fetch registered commands')
|
||||
})
|
||||
|
||||
// clear the cache of the commands
|
||||
@@ -41,7 +47,12 @@ export function registerCommands(client: Client, commands: SlashCommand[]): void
|
||||
client.application.commands
|
||||
.create(command)
|
||||
.then((c) => {
|
||||
console.log(`[Command: ${c.name}] Registered on Discord`)
|
||||
c.options?.forEach((o) => console.log(` - ${o.name}`))
|
||||
logger.info({
|
||||
command: c.name,
|
||||
options: c.options?.map(option => option.name) ?? []
|
||||
}, 'Registered command on Discord')
|
||||
})
|
||||
.catch(error => {
|
||||
logger.error({ err: error, command: command.name }, 'Failed to register command on Discord')
|
||||
})
|
||||
}
|
||||
+8
-7
@@ -1,11 +1,12 @@
|
||||
import type { ClientEvents, Awaitable, Client } from 'discord.js'
|
||||
import { Ollama } from 'ollama'
|
||||
import { Queue } from '../components/index.js'
|
||||
import { Queue, createLogger } from '../components/index.js'
|
||||
import type { Logger as PinoLogger } from 'pino'
|
||||
|
||||
// Export events through here to reduce amount of imports
|
||||
export { Events } from 'discord.js'
|
||||
|
||||
export type LogMethod = (...args: unknown[]) => void
|
||||
export type LogMethod = PinoLogger
|
||||
export type EventKeys = keyof ClientEvents // only wants keys of ClientEvents object
|
||||
|
||||
/**
|
||||
@@ -35,7 +36,7 @@ export type UserMessage = {
|
||||
// Event properties
|
||||
export interface EventProps {
|
||||
client: Client,
|
||||
log: LogMethod,
|
||||
logger: LogMethod,
|
||||
msgHist: Queue<UserMessage>,
|
||||
channelHistory: Queue<UserMessage>,
|
||||
ollama: Ollama,
|
||||
@@ -85,14 +86,14 @@ export function registerEvents(
|
||||
): void {
|
||||
for (const { key, callback } of events) {
|
||||
client.on(key, (...args) => {
|
||||
// Create a new log method for this event
|
||||
const log = console.log.bind(console, `[Event: ${key}]`)
|
||||
const logger = createLogger({ component: 'event', event: key })
|
||||
|
||||
// Handle Errors, call callback, log errors as needed
|
||||
try {
|
||||
callback({ client, log, msgHist, channelHistory, ollama, defaultModel }, ...args)
|
||||
void Promise.resolve(callback({ client, logger, msgHist, channelHistory, ollama, defaultModel }, ...args))
|
||||
.catch(error => logger.error({ err: error }, 'Uncaught event error'))
|
||||
} catch (error) {
|
||||
log('[Uncaught Error]', error)
|
||||
logger.error({ err: error }, 'Uncaught event error')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { TextChannel, ThreadChannel } from 'discord.js'
|
||||
import { Configuration, Channel, UserMessage } from '../index.js'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import type { Logger as PinoLogger } from 'pino'
|
||||
|
||||
/**
|
||||
* Method to check if a thread history file exists
|
||||
@@ -29,7 +30,7 @@ async function checkChannelInfoExists(channel: TextChannel, user: string) {
|
||||
* @param user username of user
|
||||
* @returns nothing
|
||||
*/
|
||||
export async function clearChannelInfo(filename: string, channel: TextChannel, user: string): Promise<boolean> {
|
||||
export async function clearChannelInfo(logger: PinoLogger, filename: string, channel: TextChannel, user: string): Promise<boolean> {
|
||||
const channelInfoExists: boolean = await checkChannelInfoExists(channel, user)
|
||||
|
||||
// If thread does not exist, file can't be found
|
||||
@@ -40,7 +41,7 @@ export async function clearChannelInfo(filename: string, channel: TextChannel, u
|
||||
const cleanedHistory: boolean = await new Promise((resolve) => {
|
||||
fs.readFile(fullFileName, 'utf8', (error, data) => {
|
||||
if (error)
|
||||
console.log(`[Error: openChannelInfo] Incorrect file format`)
|
||||
logger.error({ err: error, file: fullFileName }, 'Failed to read channel history')
|
||||
else {
|
||||
const object = JSON.parse(data)
|
||||
if (object['messages'].length === 0) // already empty, let user know
|
||||
@@ -56,12 +57,12 @@ export async function clearChannelInfo(filename: string, channel: TextChannel, u
|
||||
return cleanedHistory
|
||||
}
|
||||
|
||||
export async function addToChannelContext(filename: string, channel : TextChannel | ThreadChannel, messages: UserMessage[] = []): Promise<void> {
|
||||
export async function addToChannelContext(logger: PinoLogger, filename: string, channel: TextChannel | ThreadChannel, messages: UserMessage[] = []): Promise<void> {
|
||||
const fullFileName = `data/${filename}-context.json`
|
||||
if (fs.existsSync(fullFileName)) {
|
||||
fs.readFile(fullFileName, 'utf8', (error, data) => {
|
||||
if (error)
|
||||
console.log(`[Error: addToChannelContext] Incorrect file format`)
|
||||
logger.error({ err: error, file: fullFileName }, 'Failed to read channel context')
|
||||
else {
|
||||
const object = JSON.parse(data)
|
||||
if (object['messages'].length === 0)
|
||||
@@ -85,7 +86,7 @@ export async function addToChannelContext(filename: string, channel : TextChanne
|
||||
fs.mkdirSync(directory, { recursive: true })
|
||||
|
||||
fs.writeFileSync(fullFileName, JSON.stringify(object, null, 2))
|
||||
console.log(`[Util: addToChannelContext] Created '${fullFileName}' in working directory`)
|
||||
logger.info({ file: fullFileName }, 'Created channel context')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,12 +113,12 @@ export async function accessChannelContext(filename: string, callback: (config:
|
||||
* @param user the user's name
|
||||
* @param messages their messages
|
||||
*/
|
||||
export async function openChannelInfo(this: any, filename: string, channel: TextChannel | ThreadChannel, user: string, messages: UserMessage[] = []): Promise<void> {
|
||||
export async function openChannelInfo(logger: PinoLogger, filename: string, channel: TextChannel | ThreadChannel, user: string, messages: UserMessage[] = []): Promise<void> {
|
||||
const fullFileName = `data/${filename}-${user}.json`
|
||||
if (fs.existsSync(fullFileName)) {
|
||||
fs.readFile(fullFileName, 'utf8', (error, data) => {
|
||||
if (error)
|
||||
console.log(`[Error: openChannelInfo] Incorrect file format`)
|
||||
logger.error({ err: error, file: fullFileName }, 'Failed to read channel history')
|
||||
else {
|
||||
const object = JSON.parse(data)
|
||||
if (object['messages'].length === 0)
|
||||
@@ -143,7 +144,7 @@ export async function openChannelInfo(this: any, filename: string, channel: Text
|
||||
|
||||
// only creating it, no need to add anything
|
||||
fs.writeFileSync(fullFileName, JSON.stringify(object, null, 2))
|
||||
console.log(`[Util: ${this.name}] Created '${fullFileName}' in working directory`)
|
||||
logger.info({ file: fullFileName }, 'Created channel history')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Configuration, ServerConfig, UserConfig, isServerConfigurationKey } from '../index.js'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import type { Logger as PinoLogger } from 'pino'
|
||||
|
||||
/**
|
||||
* Method to open a file in the working directory and modify/create it
|
||||
@@ -10,14 +11,14 @@ import path from 'path'
|
||||
* @param value new value to assign
|
||||
*/
|
||||
// add type of change (server, user)
|
||||
export function openConfig(this: any, filename: string, key: string, value: any) {
|
||||
export function openConfig(logger: PinoLogger, filename: string, key: string, value: any) {
|
||||
const fullFileName = `data/${filename}`
|
||||
|
||||
// check if the file exists, if not then make the config file
|
||||
if (fs.existsSync(fullFileName)) {
|
||||
fs.readFile(fullFileName, 'utf8', (error, data) => {
|
||||
if (error)
|
||||
console.log(`[Error: openConfig] Incorrect file format`)
|
||||
logger.error({ err: error, file: fullFileName }, 'Failed to read configuration file')
|
||||
else {
|
||||
const object = JSON.parse(data)
|
||||
object['options'][key] = value
|
||||
@@ -41,7 +42,7 @@ export function openConfig(this: any, filename: string, key: string, value: any)
|
||||
fs.mkdirSync(directory, { recursive: true })
|
||||
|
||||
fs.writeFileSync(`data/${filename}`, JSON.stringify(object, null, 2))
|
||||
console.log(`[Util: ${this.name}] Created '${filename}' in working directory`)
|
||||
logger.info({ file: fullFileName }, 'Created configuration file')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Message, SendableChannels } from 'discord.js'
|
||||
import { ChatResponse, Ollama, AbortableAsyncIterator } from 'ollama'
|
||||
import type { Logger as PinoLogger } from 'pino'
|
||||
import { ChatParams, UserMessage, streamResponse, blockResponse } from './index.js'
|
||||
import { Queue } from '../components/index.js'
|
||||
|
||||
@@ -10,7 +11,7 @@ import { Queue } from '../components/index.js'
|
||||
* @param msgHist message history between user and model
|
||||
*/
|
||||
export async function normalMessage(
|
||||
this: any,
|
||||
logger: PinoLogger,
|
||||
message: Message,
|
||||
ollama: Ollama,
|
||||
model: string,
|
||||
@@ -49,7 +50,7 @@ export async function normalMessage(
|
||||
if (result.length > 5)
|
||||
messageBlock.edit(result)
|
||||
}
|
||||
console.log(result)
|
||||
logger.debug({ response: result }, 'Received response chunk')
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -77,7 +78,7 @@ export async function normalMessage(
|
||||
sentMessage.edit(result)
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.log(`[Util: ${this.name}] Error creating message: ${error.message}`)
|
||||
logger.error({ err: error, model }, 'Failed to create message response')
|
||||
if (error.message.includes('try pulling it first'))
|
||||
sentMessage.edit(`**Response generation failed.**\n\nReason: You do not have the ${model} downloaded. Ask an admin to pull it using the \`pull-model\` command.`)
|
||||
else
|
||||
@@ -90,6 +91,7 @@ export async function normalMessage(
|
||||
}
|
||||
|
||||
export async function summarizeContextHistory(
|
||||
logger: PinoLogger,
|
||||
ollama: Ollama,
|
||||
model: string,
|
||||
msgHist: UserMessage[],
|
||||
@@ -109,7 +111,7 @@ export async function summarizeContextHistory(
|
||||
|
||||
return result
|
||||
} catch (error: any) {
|
||||
console.log(`[Util: messageNormal] Error creating message: ${error.message}`)
|
||||
logger.error({ err: error, model }, 'Failed to summarize channel history')
|
||||
if (error.message.includes('fetch failed'))
|
||||
error.message = 'Missing ollama service on machine'
|
||||
else if (error.message.includes('try pulling it first'))
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import { Writable } from 'node:stream'
|
||||
import pino from 'pino'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { createLogger } from '../src/components/logger.js'
|
||||
|
||||
describe('Pino logger', () => {
|
||||
let output = ''
|
||||
const destination = new Writable({
|
||||
write(chunk, _encoding, callback) {
|
||||
output += chunk.toString()
|
||||
callback()
|
||||
}
|
||||
})
|
||||
const parentLogger = pino({ level: 'trace' }, destination)
|
||||
|
||||
beforeEach(() => {
|
||||
vi.stubEnv('NODE_ENV', 'test')
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs()
|
||||
})
|
||||
|
||||
it('creates a child logger with component and caller metadata', () => {
|
||||
output = ''
|
||||
const logger = createLogger({ component: 'test' }, parentLogger)
|
||||
logger.info('bound message')
|
||||
|
||||
const entry = JSON.parse(output)
|
||||
expect(entry.msg).toBe('bound message')
|
||||
expect(entry.component).toBe('test')
|
||||
expect(entry.caller).toMatch(/logger\.test\.ts:\d+:\d+/)
|
||||
})
|
||||
|
||||
it('supports native Pino levels and structured log fields', () => {
|
||||
output = ''
|
||||
const logger = createLogger({ component: 'test' }, parentLogger)
|
||||
logger.warn({ answer: 42 }, 'warning')
|
||||
|
||||
const entry = JSON.parse(output)
|
||||
expect(entry.level).toBe(40)
|
||||
expect(entry.answer).toBe(42)
|
||||
expect(entry.msg).toBe('warning')
|
||||
})
|
||||
|
||||
it('preserves parent context when adding command bindings', () => {
|
||||
output = ''
|
||||
const eventLogger = createLogger({
|
||||
component: 'event',
|
||||
event: 'InteractionCreate'
|
||||
}, parentLogger)
|
||||
const commandLogger = createLogger({
|
||||
component: 'command',
|
||||
command: 'summary'
|
||||
}, eventLogger)
|
||||
|
||||
commandLogger.info('command started')
|
||||
|
||||
const entry = JSON.parse(output)
|
||||
expect(entry.component).toBe('command')
|
||||
expect(entry.event).toBe('InteractionCreate')
|
||||
expect(entry.command).toBe('summary')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,123 @@
|
||||
import { mkdtempSync, rmSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { Writable } from 'node:stream'
|
||||
import { ChannelType, type ChatInputCommandInteraction, type Client, type TextChannel } from 'discord.js'
|
||||
import pino from 'pino'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { createLogger } from '../src/components/logger.js'
|
||||
import { Capacity } from '../src/commands/capacity.js'
|
||||
import { openChannelInfo } from '../src/utils/handlers/chatHistoryHandler.js'
|
||||
import { registerCommands, type SlashCommand } from '../src/utils/commands.js'
|
||||
|
||||
describe('logger context integration', () => {
|
||||
let output = ''
|
||||
const destination = new Writable({
|
||||
write(chunk, _encoding, callback) {
|
||||
output += chunk.toString()
|
||||
callback()
|
||||
}
|
||||
})
|
||||
const parentLogger = pino({ level: 'trace' }, destination)
|
||||
let workingDirectory: string
|
||||
let tempDirectory: string | undefined
|
||||
|
||||
beforeEach(() => {
|
||||
output = ''
|
||||
workingDirectory = process.cwd()
|
||||
vi.stubEnv('NODE_ENV', 'test')
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
process.chdir(workingDirectory)
|
||||
if (tempDirectory)
|
||||
rmSync(tempDirectory, { recursive: true, force: true })
|
||||
vi.unstubAllEnvs()
|
||||
})
|
||||
|
||||
it('retains event and command context in registration and handler logs', async () => {
|
||||
const readyLogger = createLogger({
|
||||
component: 'event',
|
||||
event: 'ClientReady'
|
||||
}, parentLogger)
|
||||
const commandsApi = {
|
||||
fetch: vi.fn().mockResolvedValue(new Map()),
|
||||
cache: { clear: vi.fn() },
|
||||
create: vi.fn(async (command: SlashCommand) => ({
|
||||
name: command.name,
|
||||
options: []
|
||||
}))
|
||||
}
|
||||
const client = {
|
||||
application: { commands: commandsApi }
|
||||
} as unknown as Client
|
||||
const mockCommand = {
|
||||
name: 'test-command',
|
||||
description: 'test command',
|
||||
run: vi.fn()
|
||||
} as unknown as SlashCommand
|
||||
|
||||
registerCommands(client, [mockCommand], readyLogger)
|
||||
|
||||
const commandLogger = createLogger({
|
||||
component: 'command',
|
||||
command: 'modify-capacity'
|
||||
}, createLogger({
|
||||
component: 'event',
|
||||
event: 'InteractionCreate'
|
||||
}, parentLogger))
|
||||
const interaction = {
|
||||
channelId: 'test-channel',
|
||||
commandName: 'modify-capacity',
|
||||
user: { username: 'test-user' },
|
||||
options: {
|
||||
getNumber: () => 8,
|
||||
get: () => ({ value: 8 })
|
||||
},
|
||||
reply: vi.fn()
|
||||
} as unknown as ChatInputCommandInteraction
|
||||
const commandClient = {
|
||||
channels: {
|
||||
fetch: vi.fn().mockResolvedValue({ type: ChannelType.GuildText })
|
||||
}
|
||||
} as unknown as Client
|
||||
|
||||
tempDirectory = mkdtempSync(join(tmpdir(), 'discord-ollama-logger-'))
|
||||
process.chdir(tempDirectory)
|
||||
|
||||
await Capacity.run(commandClient, interaction, commandLogger)
|
||||
await openChannelInfo(commandLogger, 'test-channel', {
|
||||
id: 'test-channel',
|
||||
name: 'test'
|
||||
} as TextChannel, 'test-user')
|
||||
|
||||
await new Promise(resolve => setImmediate(resolve))
|
||||
const entries = output.trim().split('\n').map(line => JSON.parse(line))
|
||||
|
||||
const registration = entries.find(entry => entry.msg === 'Registered command on Discord')
|
||||
expect(registration).toMatchObject({
|
||||
event: 'ClientReady',
|
||||
command: 'test-command',
|
||||
msg: 'Registered command on Discord'
|
||||
})
|
||||
|
||||
const configuration = entries.find(entry => entry.msg === 'Created configuration file')
|
||||
expect(configuration).toMatchObject({
|
||||
event: 'InteractionCreate',
|
||||
component: 'command',
|
||||
command: 'modify-capacity',
|
||||
msg: 'Created configuration file'
|
||||
})
|
||||
expect(configuration.caller).toMatch(/configHandler\.ts:\d+:\d+/)
|
||||
|
||||
const history = entries.find(entry => entry.msg === 'Created channel history')
|
||||
expect(history).toMatchObject({
|
||||
event: 'InteractionCreate',
|
||||
component: 'command',
|
||||
command: 'modify-capacity',
|
||||
msg: 'Created channel history'
|
||||
})
|
||||
expect(history.caller).toMatch(/chatHistoryHandler\.ts:\d+:\d+/)
|
||||
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user