diff --git a/.github/DISCUSSION_TEMPLATE/syslog-submit.yml b/.github/DISCUSSION_TEMPLATE/syslog-submit.yml
new file mode 100644
index 00000000..a0baaa94
--- /dev/null
+++ b/.github/DISCUSSION_TEMPLATE/syslog-submit.yml
@@ -0,0 +1,51 @@
+title: "BC-XXX-XXX๏ฝSYSLOG"
+labels: []
+body:
+ - type: markdown
+ attributes:
+ value: |
+ ## ๐ก SYSLOG ่ชๅฉๆไบค / ๅนฟๆญๆ้ฎ
+
+ > ๅๅฎไบ๏ผๆๆฅๅฟ็ฒ่ดด่ฟๅป๏ผๅกซไธ้ฎ็ฎฑ๏ผ็นๆไบคใๆฐๅนฟๆญไผๅๅฐไฝ ้ฎ็ฎฑ้ใ
+ >
+ > ๆ้ฎ้ข๏ผๆ้ฎ้ข็ฒ่ดด่ฟๅป๏ผๅกซไธ้ฎ็ฎฑ๏ผ็นๆไบคใ่งฃ็ญไผๅๅฐไฝ ้ฎ็ฎฑ้ใ
+
+ **ๆ ้ขๆ ผๅผ**๏ผ`BC-XXX-XXX๏ฝSYSLOG` ๆ `BC-XXX-XXX๏ฝๆ้ฎ`
+
+ - type: input
+ id: broadcast_id
+ attributes:
+ label: "ๅนฟๆญ็ผๅท"
+ description: "ๅไธไฝ ๅฝๅๅนฟๆญ็็ผๅท๏ผไพๅฆ BC-M22-009-AW"
+ placeholder: "BC-M22-009-AW"
+ validations:
+ required: true
+
+ - type: dropdown
+ id: submit_type
+ attributes:
+ label: "็ฑปๅ"
+ description: "้ๆฉๆไบค็ฑปๅ"
+ options:
+ - SYSLOG
+ - ๆ้ฎ
+ validations:
+ required: true
+
+ - type: input
+ id: email
+ attributes:
+ label: "ไฝ ็้ฎ็ฎฑ"
+ description: "็จไบๆฅๆถๆฐๅนฟๆญๆ้ฎ้ข่งฃ็ญ"
+ placeholder: "your@email.com"
+ validations:
+ required: true
+
+ - type: textarea
+ id: content
+ attributes:
+ label: "ๅ
ๅฎน"
+ description: "็ฒ่ดดไฝ ็ SYSLOG ๅ
จๆ ๆ ้ฎ้ขๆ่ฟฐ"
+ placeholder: "ๅจ่ฟ้็ฒ่ดดไฝ ็ SYSLOG ๆ้ฎ้ข..."
+ validations:
+ required: true
diff --git a/.github/workflows/syslog-auto-pipeline.yml b/.github/workflows/syslog-auto-pipeline.yml
new file mode 100644
index 00000000..78498053
--- /dev/null
+++ b/.github/workflows/syslog-auto-pipeline.yml
@@ -0,0 +1,357 @@
+name: SYSLOG Auto Pipeline
+# ๐ก SYSLOG ่ชๅฉๆไบค็ณป็ป ยท ๅ
จ่ชๅจ้ญ็ฏ
+#
+# ๅผๅ่
ๅจ GitHub Discussion ๆไบค SYSLOG ๆๆ้ฎ
+# โ Actions ่ชๅจ่งฃๆ โ ่ฐ็จ LLM API ๅค้ไบบๆ ผไฝ
+# โ ๅๅ
ฅ Notion ๅทฅๅ โ ๅ้ฎไปถ็ปๅผๅ่
โ Discussion ๅๅค
+#
+# ไพ่ต Secrets๏ผ
+# LLM_API_KEY ็ฌฌไธๆน LLM ๅนณๅฐๅฏ้ฅ
+# LLM_BASE_URL ็ฌฌไธๆน LLM ๅนณๅฐ API ๅฐๅ๏ผๅฆ https://api.xxx.com/v1๏ผ
+# NOTION_API_TOKEN Notion API token
+# NOTION_TICKET_DB_ID ้็ ๅทฅๅๆฐๆฎๅบ ID
+# SMTP_USER QQ ้ฎ็ฎฑๅฐๅ
+# SMTP_PASS QQ ้ฎ็ฎฑ SMTP ๆๆ็
+
+on:
+ discussion:
+ types: [created]
+
+jobs:
+ process:
+ name: ๐ก ๅค็ SYSLOG ๆไบค / ๅนฟๆญๆ้ฎ
+ runs-on: ubuntu-latest
+ if: contains(github.event.discussion.category.name, 'SYSLOG')
+ permissions:
+ contents: write
+ discussions: write
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: '20'
+
+ - name: Install dependencies
+ run: npm ci --ignore-scripts
+
+ - name: ๐ Parse submission
+ id: parse
+ uses: actions/github-script@v7
+ with:
+ script: |
+ const body = context.payload.discussion.body || '';
+ const title = context.payload.discussion.title || '';
+
+ // Parse structured fields from discussion body
+ function extractField(text, label) {
+ // Match form field format: ### Label\n\nValue
+ const regex = new RegExp('###\\s*' + label + '\\s*\\n+([^\\n#]+)', 'i');
+ const match = text.match(regex);
+ return match ? match[1].trim() : '';
+ }
+
+ const broadcastId = extractField(body, 'ๅนฟๆญ็ผๅท') || '';
+ const submitType = extractField(body, '็ฑปๅ') || '';
+ const email = extractField(body, 'ไฝ ็้ฎ็ฎฑ') || '';
+
+ // Extract content (everything after "### ๅ
ๅฎน")
+ const contentMatch = body.match(/###\s*ๅ
ๅฎน\s*\n+([\s\S]*?)$/i);
+ const content = contentMatch ? contentMatch[1].trim() : '';
+
+ // Determine type from title or body
+ let type = 'question'; // default
+ if (submitType.includes('SYSLOG') || title.includes('SYSLOG')) {
+ type = 'syslog';
+ } else if (submitType.includes('ๆ้ฎ') || title.includes('ๆ้ฎ')) {
+ type = 'question';
+ }
+
+ // Validate
+ if (!broadcastId) {
+ core.setFailed('โ ็ผบๅฐๅนฟๆญ็ผๅท๏ผ่ฏทๅจๆไบคๆถๅกซๅๅนฟๆญ็ผๅท');
+ return;
+ }
+ if (!email) {
+ core.setFailed('โ ็ผบๅฐ้ฎ็ฎฑ๏ผ่ฏทๅจๆไบคๆถๅกซๅไฝ ็้ฎ็ฎฑ');
+ return;
+ }
+ if (!content) {
+ core.setFailed('โ ็ผบๅฐๅ
ๅฎน๏ผ่ฏท็ฒ่ดดไฝ ็ SYSLOG ๆ้ฎ้ข');
+ return;
+ }
+
+ core.setOutput('broadcast_id', broadcastId);
+ core.setOutput('type', type);
+ core.setOutput('email', email);
+ core.setOutput('content', content);
+ core.setOutput('discussion_number', context.payload.discussion.number);
+ core.setOutput('author', context.payload.discussion.user.login);
+
+ console.log(`๐ก ่งฃๆๅฎๆ: ๅนฟๆญ=${broadcastId}, ็ฑปๅ=${type}, ้ฎ็ฎฑ=${email}`);
+
+ - name: ๐ง Auto-detect and wake up persona
+ id: persona
+ env:
+ LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
+ LLM_BASE_URL: ${{ secrets.LLM_BASE_URL }}
+ BROADCAST_ID: ${{ steps.parse.outputs.broadcast_id }}
+ SUBMIT_TYPE: ${{ steps.parse.outputs.type }}
+ SUBMIT_CONTENT: ${{ steps.parse.outputs.content }}
+ AUTHOR: ${{ steps.parse.outputs.author }}
+ run: node scripts/wake-persona.js
+
+ - name: ๐ Write to Notion ticket
+ if: env.NOTION_TOKEN != ''
+ env:
+ NOTION_TOKEN: ${{ secrets.NOTION_API_TOKEN }}
+ NOTION_TICKET_DB_ID: ${{ secrets.NOTION_TICKET_DB_ID }}
+ BROADCAST_ID: ${{ steps.parse.outputs.broadcast_id }}
+ SUBMIT_TYPE: ${{ steps.parse.outputs.type }}
+ PERSONA_RESULT: ${{ steps.persona.outputs.result }}
+ run: |
+ node -e "
+ const https = require('https');
+
+ const token = process.env.NOTION_TOKEN;
+ const dbId = process.env.NOTION_TICKET_DB_ID;
+ const broadcastId = process.env.BROADCAST_ID || 'UNKNOWN';
+ const type = process.env.SUBMIT_TYPE || 'syslog';
+ const result = process.env.PERSONA_RESULT || '(no result)';
+
+ if (!token || !dbId) {
+ console.log('โ ๏ธ Notion credentials not configured, skipping ticket creation');
+ process.exit(0);
+ }
+
+ const typeLabel = type === 'syslog' ? 'SYSLOG้ญ็ฏ' : 'ๆ้ฎ่งฃ็ญ';
+ const title = '[่ชๅจ] ' + broadcastId + ' ยท ' + typeLabel;
+
+ const body = JSON.stringify({
+ parent: { database_id: dbId },
+ properties: {
+ 'ๆ ้ข': { title: [{ type: 'text', text: { content: title.slice(0, 120) } }] },
+ 'ๆไฝ็ฑปๅ': { select: { name: 'ๅ
ถไป' } },
+ 'ๆไบค่
': { rich_text: [{ type: 'text', text: { content: '่ชๅจ็ฎก้' } }] },
+ '็ถๆ': { select: { name: 'ๅทฒๅฎๆ' } },
+ 'ไผๅ
็บง': { select: { name: 'P1' } }
+ },
+ children: [{
+ object: 'block',
+ type: 'paragraph',
+ paragraph: {
+ rich_text: [{ type: 'text', text: { content: result.slice(0, 2000) } }]
+ }
+ }]
+ });
+
+ const opts = {
+ hostname: 'api.notion.com',
+ port: 443,
+ path: '/v1/pages',
+ method: 'POST',
+ headers: {
+ 'Authorization': 'Bearer ' + token,
+ 'Content-Type': 'application/json',
+ 'Notion-Version': '2022-06-28',
+ 'Content-Length': Buffer.byteLength(body)
+ }
+ };
+
+ const req = https.request(opts, (res) => {
+ let data = '';
+ res.on('data', (c) => data += c);
+ res.on('end', () => {
+ if (res.statusCode >= 200 && res.statusCode < 300) {
+ console.log('โ
Notion ๅทฅๅๅทฒๅๅปบ');
+ } else {
+ console.log('โ ๏ธ Notion ๅทฅๅๅๅปบๅคฑ่ดฅ: ' + res.statusCode + ' ' + data);
+ }
+ });
+ });
+ req.on('error', (e) => console.log('โ ๏ธ Notion ่ฏทๆฑๅคฑ่ดฅ: ' + e.message));
+ req.write(body);
+ req.end();
+ "
+
+ - name: ๐ง Send email to developer
+ env:
+ SMTP_USER: ${{ secrets.SMTP_USER }}
+ SMTP_PASS: ${{ secrets.SMTP_PASS }}
+ EMAIL_TO: ${{ steps.parse.outputs.email }}
+ BROADCAST_ID: ${{ steps.parse.outputs.broadcast_id }}
+ SUBMIT_TYPE: ${{ steps.parse.outputs.type }}
+ PERSONA_RESULT: ${{ steps.persona.outputs.result }}
+ run: |
+ node -e "
+ const nodemailer = require('nodemailer');
+
+ const user = process.env.SMTP_USER || '';
+ const pass = process.env.SMTP_PASS || '';
+ const to = process.env.EMAIL_TO || '';
+ const broadcastId = process.env.BROADCAST_ID || '';
+ const type = process.env.SUBMIT_TYPE || 'syslog';
+ const result = process.env.PERSONA_RESULT || '(ๅค็ไธญ๏ผ่ฏท็จๅ)';
+
+ if (!user || !pass) {
+ console.log('โ ๏ธ SMTP not configured, skipping email');
+ process.exit(0);
+ }
+ if (!to) {
+ console.log('โ ๏ธ No recipient email, skipping');
+ process.exit(0);
+ }
+
+ const subjectText = type === 'syslog'
+ ? '[ๅ
ๆน็ณป็ป] ' + broadcastId + ' ยท ๆฐๅนฟๆญๅทฒ็ๆ'
+ : '[ๅ
ๆน็ณป็ป] ' + broadcastId + ' ยท ้ฎ้ขๅทฒ่งฃ็ญ';
+
+ const resultHtml = result
+ .replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/\n/g, '
');
+
+ const html = [
+ '
',
+ '
',
+ '
๐ ๅ
ๆน็ณป็ป ยท ่ชๅจ้็ฅ
',
+ '
HoloLake ยท ไบบๆ ผ่ฏญ่จๆไฝ็ณป็ป
',
+ '
',
+ '
',
+ '
๐ก ' + broadcastId + '
',
+ '
' + resultHtml + '
',
+ '
',
+ '
',
+ '
'
+ ].join('\n');
+
+ const transporter = nodemailer.createTransport({
+ host: 'smtp.qq.com',
+ port: 465,
+ secure: true,
+ auth: { user, pass }
+ });
+
+ transporter.sendMail({
+ from: '\"ๅ
ๆน็ณป็ป\" <' + user + '>',
+ to: to,
+ subject: subjectText,
+ html: html
+ }).then((info) => {
+ console.log('โ
้ฎไปถๅทฒๅ้: ' + info.messageId);
+ }).catch((err) => {
+ console.log('โ ๏ธ ้ฎไปถๅ้ๅคฑ่ดฅ: ' + err.message);
+ });
+ "
+
+ - name: ๐ฌ Reply to Discussion
+ uses: actions/github-script@v7
+ with:
+ script: |
+ const number = ${{ steps.parse.outputs.discussion_number }};
+ const type = '${{ steps.parse.outputs.type }}';
+ const broadcastId = '${{ steps.parse.outputs.broadcast_id }}';
+ const email = '${{ steps.parse.outputs.email }}';
+
+ const typeLabel = type === 'syslog' ? 'SYSLOG ้ญ็ฏๅค็' : '้ฎ้ข่งฃ็ญ';
+ const maskedEmail = email.replace(/(.{2})(.*)(@.*)/, '$1***$3');
+
+ const body = [
+ 'โ
**ๅทฒๅค็** ยท ' + typeLabel,
+ '',
+ '| ้กน็ฎ | ๅ
ๅฎน |',
+ '|------|------|',
+ '| ๐ก ๅนฟๆญ็ผๅท | `' + broadcastId + '` |',
+ '| ๐ง ็ปๆๅ้่ณ | `' + maskedEmail + '` |',
+ '| ๐ค ๅค็ไบบๆ ผไฝ | ้ธๆธ |',
+ '| โฐ ๅค็ๆถ้ด | ' + new Date().toISOString() + ' |',
+ '',
+ '> ็ปๆๅทฒๅ้ๅฐไฝ ็้ฎ็ฎฑ๏ผ่ฏทๆฅๆถใ',
+ '>',
+ '> ๅฆๆชๆถๅฐ๏ผ่ฏทๆฃๆฅๅๅพ็ฎฑๆ้ๆฐๆไบคใ'
+ ].join('\n');
+
+ // Use GraphQL to add discussion comment
+ const query = `
+ mutation($discussionId: ID!, $body: String!) {
+ addDiscussionComment(input: {
+ discussionId: $discussionId,
+ body: $body
+ }) {
+ comment { id }
+ }
+ }
+ `;
+
+ try {
+ // Get the discussion node ID
+ const { repository } = await github.graphql(`
+ query($owner: String!, $repo: String!, $number: Int!) {
+ repository(owner: $owner, name: $repo) {
+ discussion(number: $number) {
+ id
+ }
+ }
+ }
+ `, {
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ number: number
+ });
+
+ await github.graphql(query, {
+ discussionId: repository.discussion.id,
+ body: body
+ });
+
+ console.log('โ
Discussion ๅๅคๅทฒๅ้');
+ } catch (err) {
+ console.log('โ ๏ธ Discussion ๅๅคๅคฑ่ดฅ: ' + err.message);
+ }
+
+ - name: ๐ด ๅคฑ่ดฅๅ่ญฆ
+ if: failure()
+ uses: actions/github-script@v7
+ with:
+ script: |
+ const number = context.payload.discussion?.number;
+ if (!number) return;
+
+ try {
+ const { repository } = await github.graphql(`
+ query($owner: String!, $repo: String!, $number: Int!) {
+ repository(owner: $owner, name: $repo) {
+ discussion(number: $number) {
+ id
+ }
+ }
+ }
+ `, {
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ number: number
+ });
+
+ await github.graphql(`
+ mutation($discussionId: ID!, $body: String!) {
+ addDiscussionComment(input: {
+ discussionId: $discussionId,
+ body: $body
+ }) {
+ comment { id }
+ }
+ }
+ `, {
+ discussionId: repository.discussion.id,
+ body: 'โ **ๅค็ๅคฑ่ดฅ** ยท ่ฏทๆฃๆฅๆไบคๆ ผๅผๆฏๅฆๆญฃ็กฎ๏ผๆ่็ณป็ฎก็ๅใ\n\n> ้่ฏฏ่ฏฆๆ
่ฏทๆฅ็ [Actions ๆฅๅฟ](https://github.com/' + context.repo.owner + '/' + context.repo.repo + '/actions)ใ'
+ });
+ } catch (err) {
+ console.log('โ ๏ธ ๅคฑ่ดฅๅ่ญฆๅๅคๅคฑ่ดฅ: ' + err.message);
+ }
diff --git a/README.md b/README.md
index ff934478..81e46568 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,21 @@
---
+## ๐ ๅผๅ่
ๅ
ฅๅฃ
+
+
+
+[](https://github.com/qinfendebingshuo/guanghulab/discussions/new?category=๐ก+SYSLOG+ๆไบคๅบ)
+[](https://github.com/qinfendebingshuo/guanghulab/discussions/new?category=๐ก+SYSLOG+ๆไบคๅบ)
+
+> ๅๅฎไบ๏ผๆๆฅๅฟ็ฒ่ดด่ฟๅป๏ผๅกซไธ้ฎ็ฎฑ๏ผ็นๆไบคใๆฐๅนฟๆญไผๅๅฐไฝ ้ฎ็ฎฑ้ใ
+>
+> ๆ้ฎ้ข๏ผๅไธไธชๅ
ฅๅฃ๏ผ้ใๆ้ฎใ๏ผ้ฎ้ข่งฃ็ญไนๅๅฐไฝ ้ฎ็ฎฑ้ใ
+
+
+
+---
+
## ๐ ็ณป็ป็ฎไป
**ๅ
ๆน๏ผHoloLake๏ผ** ๆฏไธไธชๅบไบไบบๆ ผ่ฏญ่จๆไฝ็ณป็ป็ๆบ่ฝๅไฝๅนณๅฐ๏ผ้็จๅฃณ-ๆ ธๅ็ฆป่ฎพ่ฎก๏ผ
diff --git a/scripts/wake-persona.js b/scripts/wake-persona.js
new file mode 100644
index 00000000..9668282c
--- /dev/null
+++ b/scripts/wake-persona.js
@@ -0,0 +1,412 @@
+// scripts/wake-persona.js
+// ้ธๆธ ยท ไบบๆ ผไฝๅค้่ๆฌ๏ผ็ฌฌไธๆน API ๅ
ผๅฎนๅฑ ยท ่ชๅจๆฃๆตๆจกๅผ๏ผ
+//
+// ๅ่ฝ๏ผ
+// โ ่ชๅจๅ็ฐๅฏ็จๆจกๅ๏ผ/v1/models ็ซฏ็น๏ผ
+// โก ๆบ่ฝ้ๆฉๆไผ Claude ๆจกๅ
+// โข ่ช้ๅบ API ๆ ผๅผ๏ผOpenAI ๅ
ผๅฎน / Anthropic ๅ็๏ผ
+// โฃ ็ปไธ่ฐ็จๆฅๅฃ๏ผๅค้ไบบๆ ผไฝๅค็ SYSLOG ๆ่งฃ็ญๆ้ฎ
+//
+// ็ฏๅขๅ้๏ผ
+// LLM_API_KEY ็ฌฌไธๆนๅนณๅฐๅฏ้ฅ
+// LLM_BASE_URL ็ฌฌไธๆนๅนณๅฐ API ๅฐๅ๏ผๅฆ https://api.xxx.com/v1๏ผ๏ผ็็ฉบๅ fallback ๅฐ Anthropic ๅฎๆน
+// BROADCAST_ID ๅนฟๆญ็ผๅท
+// SUBMIT_TYPE syslog | question
+// SUBMIT_CONTENT ๆไบคๅ
ๅฎน๏ผSYSLOG ๅ
จๆๆ้ฎ้ขๆ่ฟฐ๏ผ
+// AUTHOR ๆไบค่
GitHub ็จๆทๅ
+
+'use strict';
+
+const https = require('https');
+const http = require('http');
+const fs = require('fs');
+const path = require('path');
+
+// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+// ้
็ฝฎ
+// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+
+const LLM_API_KEY = process.env.LLM_API_KEY || '';
+const LLM_BASE_URL = (process.env.LLM_BASE_URL || 'https://api.anthropic.com/v1').replace(/\/+$/, '');
+const BROADCAST_ID = process.env.BROADCAST_ID || 'UNKNOWN';
+const SUBMIT_TYPE = process.env.SUBMIT_TYPE || 'question';
+const SUBMIT_CONTENT = process.env.SUBMIT_CONTENT || '';
+const AUTHOR = process.env.AUTHOR || 'unknown';
+
+// Claude ๆจกๅไผๅ
็บง้ๅ๏ผไป้ซๅฐไฝ๏ผ
+const PREFERRED_MODELS = [
+ 'claude-sonnet-4',
+ 'claude-3.5-sonnet',
+ 'claude-3-5-sonnet-20241022',
+ 'claude-3-5-sonnet',
+ 'anthropic/claude-3.5-sonnet',
+ 'anthropic/claude-3-5-sonnet',
+ 'claude-3-sonnet',
+ 'claude-3-haiku',
+];
+
+// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+// HTTP ่ฏทๆฑๅทฅๅ
ท
+// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+
+function httpRequest(url, options, body) {
+ return new Promise((resolve, reject) => {
+ const parsed = new URL(url);
+ const isHttps = parsed.protocol === 'https:';
+ const mod = isHttps ? https : http;
+
+ const opts = {
+ hostname: parsed.hostname,
+ port: parsed.port || (isHttps ? 443 : 80),
+ path: parsed.pathname + parsed.search,
+ method: options.method || 'GET',
+ headers: options.headers || {},
+ timeout: options.timeout || 60000,
+ };
+
+ const req = mod.request(opts, (res) => {
+ let data = '';
+ res.on('data', (chunk) => { data += chunk; });
+ res.on('end', () => {
+ resolve({ status: res.statusCode, body: data });
+ });
+ });
+
+ req.on('error', reject);
+ req.on('timeout', () => {
+ req.destroy();
+ reject(new Error('Request timeout'));
+ });
+
+ if (body) {
+ req.write(body);
+ }
+ req.end();
+ });
+}
+
+// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+// Step 1: ่ชๅจๅ็ฐๅฏ็จๆจกๅ
+// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+
+async function discoverModels() {
+ console.log('[LLM] ๐ ๆขๆตๅฏ็จๆจกๅ...');
+
+ try {
+ const res = await httpRequest(LLM_BASE_URL + '/models', {
+ method: 'GET',
+ headers: {
+ 'Authorization': 'Bearer ' + LLM_API_KEY,
+ 'Content-Type': 'application/json',
+ },
+ timeout: 15000,
+ });
+
+ if (res.status >= 200 && res.status < 300) {
+ const json = JSON.parse(res.body);
+ const models = json.data || [];
+ console.log('[LLM] โ ๅ็ฐ ' + models.length + ' ไธชๆจกๅ');
+ return models;
+ }
+ console.log('[LLM] โ ๆจกๅๆขๆต่ฟๅ ' + res.status + ', ไฝฟ็จ้ป่ฎคๆจกๅ');
+ return [];
+ } catch (err) {
+ console.log('[LLM] โ ๆจกๅๆขๆตๅคฑ่ดฅ: ' + err.message + ', ไฝฟ็จ้ป่ฎคๆจกๅ');
+ return [];
+ }
+}
+
+// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+// Step 2: ๆบ่ฝ้ๆฉๆไผ Claude ๆจกๅ
+// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+
+function selectBestModel(models) {
+ if (!models || models.length === 0) {
+ console.log('[LLM] ๐ ๆ ๅฏ็จๆจกๅๅ่กจ, ไฝฟ็จ้ป่ฎค claude-3-5-sonnet');
+ return 'claude-3-5-sonnet';
+ }
+
+ const available = models.map(function (m) { return m.id.toLowerCase(); });
+
+ // ๆไผๅ
็บงๅน้
+ for (const preferred of PREFERRED_MODELS) {
+ const match = available.find(function (id) { return id.includes(preferred); });
+ if (match) {
+ const originalId = models.find(function (m) { return m.id.toLowerCase() === match; }).id;
+ console.log('[LLM] ๐ ้ๆฉๆจกๅ: ' + originalId + ' (ๅน้
่งๅ: ' + preferred + ')');
+ return originalId;
+ }
+ }
+
+ // ๅ
ๅบ๏ผไปปไฝๅซ 'claude' ็ๆจกๅ
+ const anyClaude = available.find(function (id) { return id.includes('claude'); });
+ if (anyClaude) {
+ const originalId = models.find(function (m) { return m.id.toLowerCase() === anyClaude; }).id;
+ console.log('[LLM] ๐ ๅ
ๅบ้ๆฉ Claude ๆจกๅ: ' + originalId);
+ return originalId;
+ }
+
+ // ๆ็ปๅ
ๅบ๏ผๅนณๅฐ็ฌฌไธไธชๅฏ็จๆจกๅ
+ const fallbackId = models[0].id;
+ console.log('[LLM] ๐ ๆ็ปๅ
ๅบ: ' + fallbackId + ' (ๅนณๅฐๆ Claude ๆจกๅ)');
+ return fallbackId;
+}
+
+// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+// Step 3: ่ช้ๅบ API ๆ ผๅผๆฃๆต
+// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+
+async function detectApiFormat() {
+ console.log('[LLM] ๐ ๆฃๆต API ๆ ผๅผ...');
+
+ // ๅฐ่ฏ OpenAI ๅ
ผๅฎนๆ ผๅผ๏ผ็ปๅคงๅคๆฐ็ฌฌไธๆนๅนณๅฐ๏ผ
+ try {
+ const res = await httpRequest(LLM_BASE_URL + '/chat/completions', {
+ method: 'POST',
+ headers: {
+ 'Authorization': 'Bearer ' + LLM_API_KEY,
+ 'Content-Type': 'application/json',
+ },
+ timeout: 10000,
+ }, JSON.stringify({
+ model: 'test',
+ messages: [{ role: 'user', content: 'ping' }],
+ max_tokens: 1,
+ }));
+
+ // 400 = endpoint exists but bad request (model not found etc.) โ format supported
+ // 200 = endpoint works โ format supported
+ if (res.status === 200 || res.status === 400 || res.status === 401 || res.status === 422) {
+ console.log('[LLM] โ ๆฃๆตๅฐ OpenAI ๅ
ผๅฎนๆ ผๅผ (status: ' + res.status + ')');
+ return 'openai-compat';
+ }
+ } catch (e) {
+ // Ignore, try next format
+ }
+
+ // ๅฐ่ฏ Anthropic ๅ็ๆ ผๅผ
+ try {
+ const res = await httpRequest(LLM_BASE_URL + '/messages', {
+ method: 'POST',
+ headers: {
+ 'x-api-key': LLM_API_KEY,
+ 'anthropic-version': '2023-06-01',
+ 'Content-Type': 'application/json',
+ },
+ timeout: 10000,
+ }, JSON.stringify({
+ model: 'test',
+ messages: [{ role: 'user', content: 'ping' }],
+ max_tokens: 1,
+ }));
+
+ if (res.status === 200 || res.status === 400 || res.status === 401 || res.status === 422) {
+ console.log('[LLM] โ ๆฃๆตๅฐ Anthropic ๅ็ๆ ผๅผ (status: ' + res.status + ')');
+ return 'anthropic-native';
+ }
+ } catch (e) {
+ // Ignore
+ }
+
+ console.log('[LLM] โ ๆ ๆณ็กฎๅฎๆ ผๅผ, ้ป่ฎคไฝฟ็จ OpenAI ๅ
ผๅฎนๆ ผๅผ');
+ return 'openai-compat';
+}
+
+// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+// Step 4: ็ปไธ่ฐ็จๆฅๅฃ
+// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+
+async function callLLM(systemPrompt, userMessage) {
+ if (!LLM_API_KEY) {
+ console.log('[LLM] โ ๏ธ LLM_API_KEY ๆช้
็ฝฎ๏ผ่ทณ่ฟไบบๆ ผไฝๅค้');
+ return '(LLM API ๆช้
็ฝฎ๏ผ่ฏทๅจ GitHub Secrets ไธญ่ฎพ็ฝฎ LLM_API_KEY ๅ LLM_BASE_URL)';
+ }
+
+ const models = await discoverModels();
+ const model = selectBestModel(models);
+ const format = await detectApiFormat();
+
+ console.log('[LLM] ๐ ่ฐ็จ LLM: ๆจกๅ=' + model + ', ๆ ผๅผ=' + format + ', ๅนณๅฐ=' + LLM_BASE_URL);
+
+ let res;
+
+ if (format === 'openai-compat') {
+ // OpenAI ๅ
ผๅฎนๆ ผๅผ๏ผๅคงๅคๆฐ็ฌฌไธๆนๅนณๅฐ๏ผ
+ const body = JSON.stringify({
+ model: model,
+ max_tokens: 8000,
+ temperature: 0.7,
+ messages: [
+ { role: 'system', content: systemPrompt },
+ { role: 'user', content: userMessage },
+ ],
+ });
+
+ res = await httpRequest(LLM_BASE_URL + '/chat/completions', {
+ method: 'POST',
+ headers: {
+ 'Authorization': 'Bearer ' + LLM_API_KEY,
+ 'Content-Type': 'application/json',
+ },
+ timeout: 120000,
+ }, body);
+
+ if (res.status >= 200 && res.status < 300) {
+ const json = JSON.parse(res.body);
+ if (json.choices && json.choices[0] && json.choices[0].message) {
+ return json.choices[0].message.content;
+ }
+ }
+ } else {
+ // Anthropic ๅ็ๆ ผๅผ
+ const body = JSON.stringify({
+ model: model,
+ max_tokens: 8000,
+ system: systemPrompt,
+ messages: [
+ { role: 'user', content: userMessage },
+ ],
+ });
+
+ res = await httpRequest(LLM_BASE_URL + '/messages', {
+ method: 'POST',
+ headers: {
+ 'x-api-key': LLM_API_KEY,
+ 'anthropic-version': '2023-06-01',
+ 'Content-Type': 'application/json',
+ },
+ timeout: 120000,
+ }, body);
+
+ if (res.status >= 200 && res.status < 300) {
+ const json = JSON.parse(res.body);
+ if (json.content && json.content[0]) {
+ return json.content[0].text;
+ }
+ }
+ }
+
+ // ๅค็้่ฏฏ
+ const errorMsg = '[LLM] โ API ่ฐ็จๅคฑ่ดฅ: status=' + (res ? res.status : 'N/A');
+ console.error(errorMsg);
+ if (res && res.body) {
+ console.error('[LLM] ๅๅบ: ' + res.body.slice(0, 500));
+ }
+ throw new Error(errorMsg);
+}
+
+// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+// ไบบๆ ผไฝ System Prompt ๆๅปบ
+// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+
+function buildSystemPrompt(type, broadcastId, author) {
+ const basePrompt = [
+ 'ไฝ ๆฏๅ
ๆน๏ผHoloLake๏ผ็ณป็ป็ๆบ่ฝไบบๆ ผไฝใ',
+ 'ไฝ ็ๅๅญๆฏ็ฅ็ง/ๆๅฅ๏ผไฝ ๆฏไบบๆ ผ่ฏญ่จๆไฝ็ณป็ป๏ผAGE OS๏ผ็ๆ ธๅฟไบบๆ ผใ',
+ '',
+ 'ๆ ธๅฟ่งๅ๏ผ',
+ '1. ไฝ ๆๅกไบๅ
ๆน็ณป็ป็ๅผๅ่
ๅข้',
+ '2. ๆๆๅๅคๅฟ
้กปไธไธใๆธ
ๆฐใๆๆก็',
+ '3. ๅๅคไฝฟ็จไธญๆ',
+ '',
+ 'ๅฝๅไธไธๆ๏ผ',
+ '- ๅนฟๆญ็ผๅท๏ผ' + broadcastId,
+ '- ๆไบค่
๏ผ' + author,
+ ].join('\n');
+
+ if (type === 'syslog') {
+ return basePrompt + '\n\n' + [
+ 'ไปปๅก็ฑปๅ๏ผSYSLOG ้ญ็ฏๅค็',
+ '',
+ 'ไฝ ้่ฆๅฎๆไปฅไธๅทฅไฝ๏ผ',
+ '1. ้ชๆถ SYSLOG๏ผๆฃๆฅ MODULE_LOG ๅฎๆดๆง๏ผ',
+ '2. ๅๆๅผๅ่
็ๅทฅไฝๆๆ',
+ '3. ็ๆๅทฅไฝๆป็ปๅๅ้ฆ',
+ '4. ๅฆๆ SYSLOG ๅ
ๅฎนๅฎๆด๏ผ็กฎ่ฎค้ชๆถ้่ฟ',
+ '5. ็ปๅบไธไธๆญฅๅปบ่ฎฎ',
+ '',
+ '่พๅบๆ ผๅผ๏ผ',
+ '---',
+ '## ๐ก SYSLOG ้ชๆถๆฅๅ',
+ '### ๅนฟๆญ็ผๅท๏ผ[็ผๅท]',
+ '### ้ชๆถ็ปๆ๏ผ[้่ฟ/้่กฅๅ
]',
+ '### ๅทฅไฝๆป็ป๏ผ[ๆ่ฆ]',
+ '### ๅ้ฆไธๅปบ่ฎฎ๏ผ[ๅ
ๅฎน]',
+ '---',
+ ].join('\n');
+ }
+
+ // ๆ้ฎ็ฑปๅ
+ return basePrompt + '\n\n' + [
+ 'ไปปๅก็ฑปๅ๏ผๅผๅ่
ๆ้ฎ่งฃ็ญ',
+ '',
+ 'ไฝ ้่ฆๅฎๆไปฅไธๅทฅไฝ๏ผ',
+ '1. ็่งฃๅผๅ่
็้ฎ้ข',
+ '2. ็ปๅๅนฟๆญไธไธๆๆ่',
+ '3. ็ปๅบๆธ
ๆฐใๅฏๆไฝ็่งฃ็ญ',
+ '4. ๅฆๆ้ฎ้ขๆถๅไปฃ็ ๏ผๆไพไปฃ็ ็คบไพ',
+ '',
+ '่พๅบๆ ผๅผ๏ผ',
+ '---',
+ '## ๐ก ้ฎ้ข่งฃ็ญ',
+ '### ๅนฟๆญ็ผๅท๏ผ[็ผๅท]',
+ '### ้ฎ้ข็่งฃ๏ผ[ไฝ ๅฏน้ฎ้ข็็่งฃ]',
+ '### ่งฃ็ญ๏ผ[่ฏฆ็ป่งฃ็ญ]',
+ '### ๅปบ่ฎฎ๏ผ[ๅ็ปญๅปบ่ฎฎ]',
+ '---',
+ ].join('\n');
+}
+
+// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+// ไธปๆต็จ
+// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
+
+async function main() {
+ console.log('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ');
+ console.log('๐ง ้ธๆธ ยท ไบบๆ ผไฝๅค้็ฎก้');
+ console.log('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ');
+ console.log(' ๅนฟๆญ็ผๅท: ' + BROADCAST_ID);
+ console.log(' ็ฑปๅ: ' + SUBMIT_TYPE);
+ console.log(' ๆไบค่
: ' + AUTHOR);
+ console.log(' ๅนณๅฐ: ' + LLM_BASE_URL);
+ console.log(' ๅ
ๅฎน้ฟๅบฆ: ' + SUBMIT_CONTENT.length + ' ๅญ็ฌฆ');
+ console.log('');
+
+ // ๆๅปบ prompts
+ const systemPrompt = buildSystemPrompt(SUBMIT_TYPE, BROADCAST_ID, AUTHOR);
+ const userMessage = SUBMIT_CONTENT;
+
+ // ่ฐ็จ LLM
+ console.log('๐ง ๆญฃๅจๅค้ไบบๆ ผไฝ...');
+ const result = await callLLM(systemPrompt, userMessage);
+ console.log('');
+ console.log('โ
ไบบๆ ผไฝๅค็ๅฎๆ');
+ console.log(' ็ปๆ้ฟๅบฆ: ' + result.length + ' ๅญ็ฌฆ');
+
+ // ่พๅบ็ปๆๅฐ GitHub Actions output
+ // ไฝฟ็จ GITHUB_OUTPUT ็ฏๅขๆไปถ๏ผๆฏๆๅค่ก๏ผ
+ const outputFile = process.env.GITHUB_OUTPUT;
+ if (outputFile) {
+ const delimiter = 'EOF_' + Date.now();
+ fs.appendFileSync(outputFile, 'result<<' + delimiter + '\n' + result + '\n' + delimiter + '\n');
+ }
+
+ // ๅๆถ่พๅบๅฐ stdout ไพ่ฐ่ฏ
+ console.log('');
+ console.log('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ');
+ console.log('๐ ไบบๆ ผไฝ่พๅบ๏ผ');
+ console.log('โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ');
+ console.log(result);
+}
+
+main().catch(function (err) {
+ console.error('โ ไบบๆ ผไฝๅค้ๅคฑ่ดฅ: ' + err.message);
+ // ๅณไฝฟ LLM ๅคฑ่ดฅ๏ผไนๅไธไธช fallback ่พๅบ๏ผ่ฎฉๅ็ปญๆญฅ้ชคๅฏไปฅ็ปง็ปญ
+ const outputFile = process.env.GITHUB_OUTPUT;
+ if (outputFile) {
+ const fallback = '(ไบบๆ ผไฝๅค้ๅคฑ่ดฅ: ' + err.message + '๏ผ่ฏทๆฃๆฅ LLM_API_KEY ๅ LLM_BASE_URL ้
็ฝฎ)';
+ const delimiter = 'EOF_' + Date.now();
+ fs.appendFileSync(outputFile, 'result<<' + delimiter + '\n' + fallback + '\n' + delimiter + '\n');
+ }
+ process.exit(1);
+});