Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/web-app/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ NUXT_AI_BASE_URL=
NUXT_AI_MODEL=
NUXT_AI_MODEL_PRO=
NUXT_AI_SERVICE_TOKEN=
NUXT_AI_DAILY_REPORT_PROMPT=

# Telegram
NUXT_TELEGRAM_ADMIN_ID=
Expand Down
1 change: 1 addition & 0 deletions apps/web-app/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default defineNuxtConfig({
baseUrl: '',
apiKey: '',
serviceToken: '',
dailyReportPrompt: '',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Good addition; server-only placement is correct.

Adding ai.dailyReportPrompt under runtimeConfig (server-side) avoids leaking prompt text to the client. One follow-up: because it defaults to an empty string, make sure the task guards against empty/whitespace prompts (see task review).

If not already done, ensure .env.example includes the matching key and casing:


🏁 Script executed:

#!/bin/bash
# Verify example env contains the new key
rg -n --line-number -C1 '^NUXT_AI_DAILY_REPORT_PROMPT=' apps/web-app/.env.example

Length of output: 145


Verify .env.example and enforce non-empty dailyReportPrompt

  • ✅ Confirmed that NUXT_AI_DAILY_REPORT_PROMPT is defined in apps/web-app/.env.example (line 23).
  • ⚠️ Please add validation around runtimeConfig.ai.dailyReportPrompt to ensure it isn’t empty or whitespace-only (e.g. throw a clear error or fallback to a safe default) before sending it to the AI.
🤖 Prompt for AI Agents
In apps/web-app/nuxt.config.ts around line 21,
runtimeConfig.ai.dailyReportPrompt is currently allowed to be empty; add a
validation step during config/build initialization to trim the value and ensure
it is not empty or whitespace-only, and if it is invalid either throw a clear
error (with guidance to set NUXT_AI_DAILY_REPORT_PROMPT) or assign a safe
default prompt before any code sends it to the AI; implement the check where
runtimeConfig is constructed so downstream consumers always receive a validated,
non-empty string.

},
telegram: {
wasabiBotId: '',
Expand Down
10 changes: 9 additions & 1 deletion apps/web-app/server/tasks/ai/daily-report.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import process from 'node:process'
import { repository } from '@roll-stack/database'
import OpenAI from 'openai'
import { useAtriumBot } from '~~/server/services/telegram/atrium-bot'

const logger = useLogger('task:ai:daily-report')

export default defineTask({
meta: {
name: 'ai:daily-report',
description: 'Prepare and post daily report to Telegram group',
},
async run() {
if (process.env.NODE_ENV !== 'production') {
logger.info('Skipping task in non-production environment')
return { result: true }
}

try {
const { ai, telegram } = useRuntimeConfig()

Expand All @@ -29,7 +37,7 @@ export default defineTask({
messages: [
{
role: 'system',
content: 'Ты работаешь в компании "Суши Love", которая является сетью доставки суши. В 3-5 абзацах расскажи что сегодня было сделано, лучшие моменты. Отвечай на русском. Не бойся использовать emoji',
content: ai.dailyReportPrompt,
},
{
role: 'user',
Expand Down
8 changes: 8 additions & 0 deletions apps/web-app/server/tasks/kitchen/average-update.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import process from 'node:process'
import { repository } from '@roll-stack/database'

const logger = useLogger('kitchen:average-update')

export default defineTask({
meta: {
name: 'kitchen:average-update',
description: 'Update average data of kitchens',
},
async run() {
try {
if (process.env.NODE_ENV !== 'production') {
logger.info('Skipping task in non-production environment')
return { result: true }
}

const metrics = await repository.network.listMetrics()

for (const m of metrics) {
Expand Down
6 changes: 6 additions & 0 deletions apps/web-app/server/tasks/kitchen/rating-update.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import process from 'node:process'
import { repository } from '@roll-stack/database'

const logger = useLogger('kitchen:rating-update')
Expand All @@ -9,6 +10,11 @@ export default defineTask({
},
async run() {
try {
if (process.env.NODE_ENV !== 'production') {
logger.info('Skipping task in non-production environment')
return { result: true }
}

const kitchens = await repository.kitchen.list()

for (const kitchen of kitchens) {
Expand Down
8 changes: 8 additions & 0 deletions apps/web-app/server/tasks/kitchen/revenue-update.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import process from 'node:process'
import { repository } from '@roll-stack/database'
import { endOfWeek, startOfWeek } from 'date-fns'

const logger = useLogger('kitchen:revenue-update')

export default defineTask({
meta: {
name: 'kitchen:revenue-update',
description: 'Update weekly revenue of kitchens',
},
async run() {
try {
if (process.env.NODE_ENV !== 'production') {
logger.info('Skipping task in non-production environment')
return { result: true }
}

const kitchens = await repository.kitchen.list()

// From this monday to sunday (use UTC+0 time zone)
Expand Down
6 changes: 6 additions & 0 deletions apps/web-app/server/tasks/task/auto-create.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import process from 'node:process'
import { repository } from '@roll-stack/database'

const logger = useLogger('task:auto-create')
Expand All @@ -8,6 +9,11 @@ export default defineTask({
description: 'Check if it is time to create a task',
},
async run() {
if (process.env.NODE_ENV !== 'production') {
logger.info('Skipping task in non-production environment')
return { result: true }
}

// Wait 5 seconds
await new Promise((resolve) => setTimeout(resolve, 5000))

Expand Down