Папка приёма Google Drive <id чата>: опрос раз в 10 секунд, файлы = сообщения менеджера; swap 32 ГБ; docs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { join } from "node:path";
|
||||
import { createLogger, createPool, itNotify, loadServiceSettings } from "khb_common";
|
||||
import { createCliRunner } from "./agents/cli-runner.js";
|
||||
import { KeyedMutex, Semaphore } from "./agents/pool.js";
|
||||
@@ -8,6 +9,7 @@ import { assistantPrepSchema } from "./settings.js";
|
||||
import { createSlackApi, startSocketMode } from "./slack/api.js";
|
||||
import { handleManagerMessages, type ChatDeps, type ManagerInfo } from "./slack/chat.js";
|
||||
import { createRcloneDrive } from "./slack/drive.js";
|
||||
import { DriveInbox } from "./slack/drive-inbox.js";
|
||||
import { SlackIntake } from "./slack/intake.js";
|
||||
|
||||
const { common, service } = loadServiceSettings("khbuild_assistant_prep", assistantPrepSchema);
|
||||
@@ -91,4 +93,20 @@ log.info({ port: service.http.port }, "khbuild_assistant_prep запущен");
|
||||
if (service.slack && chatDeps) {
|
||||
const intake = new SlackIntake(chatDeps, { channelIds: service.slack.channelIds, debounceMs: service.slack.debounceSeconds * 1000, followupMs: service.slack.followupMinutes * 60_000 });
|
||||
startSocketMode({ appToken: service.slack.appToken, log, onEvent: (ev) => void intake.onEvent(ev).catch((e) => log.error({ err: String(e) }, "ошибка приёма события Slack")) });
|
||||
if (service.drive && service.drive.inboxScanSeconds > 0) {
|
||||
const d = service.drive;
|
||||
const slackChannels = service.slack.channelIds;
|
||||
const inbox = new DriveInbox({
|
||||
rcloneBin: d.rcloneBin, remote: d.remote, folder: d.folder,
|
||||
localRoot: join(service.agent.workRoot, "_drive_inbox"),
|
||||
channels: async () => {
|
||||
const { rows } = await pool.query("select distinct slack_channel_id from construction_manager where is_active and slack_channel_id is not null");
|
||||
return [...new Set([...slackChannels, ...rows.map((r) => String(r.slack_channel_id))])];
|
||||
},
|
||||
accept: (f) => intake.onDriveFile(f),
|
||||
onError: (e) => log.error({ err: String(e) }, "ошибка опроса папки приёма Drive"),
|
||||
});
|
||||
inbox.start(d.inboxScanSeconds * 1000);
|
||||
log.info({ everySeconds: d.inboxScanSeconds }, "опрос папок приёма Drive запущен");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user