nlobby-cli 1.4.3 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SKILLS.md +8 -0
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/SKILLS.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
| Command | Options / Arguments | Description |
|
|
6
6
|
| ------------------------------ | --------------------------------------------------------------------------------------------------- | ------------------------------------------ |
|
|
7
7
|
| `nlobby login` | | Open browser for interactive login |
|
|
8
|
+
| `nlobby login-help` | `--email <email>` | Get login help and troubleshooting tips |
|
|
8
9
|
| `nlobby cookies set <cookies>` | | Set cookies manually |
|
|
9
10
|
| `nlobby cookies check` | | Show current authentication status |
|
|
10
11
|
| `nlobby news` | `--limit <n>` `--category <cat>` `--sort newest\|oldest\|title-asc\|title-desc` `--unread` `--json` | List news (default: 10, newest first) |
|
|
@@ -15,6 +16,13 @@
|
|
|
15
16
|
| `nlobby courses` | `--grade <n>` `--semester <n>` `--json` | Show required courses |
|
|
16
17
|
| `nlobby profile` | `--json` | Show user profile / account info |
|
|
17
18
|
| `nlobby health` | `--json` | Check API connectivity and authentication |
|
|
19
|
+
| `nlobby exam check [date]` | `--json` | Check if a date is an exam day |
|
|
20
|
+
| `nlobby exam finish` | `--json` | Finish exam day mode |
|
|
21
|
+
| `nlobby exam otp` | `--json` | Get one-time password for exam |
|
|
22
|
+
| `nlobby nav menus` | `--json` | Show main navigation menu list |
|
|
23
|
+
| `nlobby nav notifications` | `--json` | Show notification messages |
|
|
24
|
+
| `nlobby nav interests` | `--with-icon` `--json` | Show user interest tags |
|
|
25
|
+
| `nlobby nav weights` | `--json` | Show interest weight scale definitions |
|
|
18
26
|
| `nlobby serve` / `nlobby mcp` | | Start MCP server (stdio transport) |
|
|
19
27
|
|
|
20
28
|
> All commands support `--json` to output raw JSON instead of formatted text.
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
var Ft=Object.defineProperty;var g=(o,e)=>()=>(o&&(e=o(o=0)),e);var j=(o,e)=>{for(var t in e)Ft(o,t,{get:e[t],enumerable:!0})};import jt from"node-fetch";var C,A,T=g(()=>{"use strict";C=class extends Error{response;config;code;constructor(e){super(e),this.name="HttpClientError"}},A=class{defaults;baseURL;requestInterceptors=[];responseSuccessInterceptors=[];responseErrorInterceptors=[];interceptors={request:{use:e=>{this.requestInterceptors.push(e)}},response:{use:(e,t)=>{this.responseSuccessInterceptors.push(e),t&&this.responseErrorInterceptors.push(t)}}};constructor(e){this.baseURL=e.baseURL??"",this.defaults={headers:{...e.headers??{}},timeout:e.timeout??3e4,baseURL:this.baseURL}}async get(e,t){return this.request("GET",e,void 0,t)}async post(e,t,n){return this.request("POST",e,t,n)}async parseBody(e){if((e.headers.get("content-type")??"").includes("application/json"))try{return await e.json()}catch{return await e.text()}return await e.text()}extractHeaders(e){let t={};return e.headers.forEach((n,r)=>{t[r]=n}),t}async runErrorInterceptors(e){for(let t of this.responseErrorInterceptors)await t(e)}async request(e,t,n,r){let s=t.startsWith("http")?t:`${this.baseURL}${t}`;if(r?.params&&Object.keys(r.params).length>0){let p={};for(let[O,N]of Object.entries(r.params))N!==void 0&&(p[O]=N);let f=new URLSearchParams(p).toString();s+=(s.includes("?")?"&":"?")+f}let a={...this.defaults.headers,...r?.headers??{}},c={url:s,method:e,headers:a,timeout:r?.timeout??this.defaults.timeout};for(let p of this.requestInterceptors)c=await p(c);let l={};for(let[p,f]of Object.entries(c.headers))f!==void 0&&(l[p]=f);let u=new AbortController,d=setTimeout(()=>u.abort(),c.timeout),h;try{let p={method:c.method,headers:l,signal:u.signal};n!==void 0&&(p.body=typeof n=="string"?n:JSON.stringify(n)),h=await jt(c.url,p),clearTimeout(d)}catch(p){clearTimeout(d);let f=new C(p instanceof Error?p.message:"Network error");throw f.config={url:c.url,method:c.method,headers:c.headers,timeout:c.timeout},p instanceof Error&&(p.name==="AbortError"?(f.code="ETIMEDOUT",f.message=`timeout of ${c.timeout}ms exceeded`):p.message.includes("ECONNREFUSED")?f.code="ECONNREFUSED":p.message.includes("ENOTFOUND")&&(f.code="ENOTFOUND")),await this.runErrorInterceptors(f),f}let w=await this.parseBody(h),y=this.extractHeaders(h);if(!h.ok){let p=new C(`Request failed with status code ${h.status}`);throw p.response={status:h.status,statusText:h.statusText,data:w,headers:y},p.config={url:c.url,method:c.method,headers:c.headers,timeout:c.timeout},await this.runErrorInterceptors(p),p}let b={data:w,status:h.status,statusText:h.statusText,headers:y};for(let p of this.responseSuccessInterceptors)b=await p(b);return b}}});import{config as Mt}from"dotenv";function Ht(){switch(process.platform){case"darwin":return"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36";case"win32":return"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36";case"linux":default:return"Mozilla/5.0 (X11; CrOS x86_64 10066.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"}}var m,E=g(()=>{"use strict";Mt();m={nlobby:{baseUrl:process.env.NLOBBY_BASE_URL||"https://nlobby.nnn.ed.jp"},mcp:{serverName:process.env.MCP_SERVER_NAME||"nlobby-cli",serverVersion:process.env.MCP_SERVER_VERSION||"1.3.0"},userAgent:process.env.USER_AGENT||Ht()}});var de={};j(de,{LogLevel:()=>K,Logger:()=>M,logger:()=>i});var K,M,i,S=g(()=>{"use strict";K=(r=>(r[r.DEBUG=0]="DEBUG",r[r.INFO=1]="INFO",r[r.WARN=2]="WARN",r[r.ERROR=3]="ERROR",r))(K||{}),M=class o{static instance;logLevel;constructor(){let e=process.env.NLOBBY_DEBUG==="true"||process.env.DEBUG==="true";this.logLevel=e?0:2}static getInstance(){return o.instance||(o.instance=new o),o.instance}setLogLevel(e){this.logLevel=e}forceProductionMode(){}log(e,t,...n){if(e<this.logLevel)return;let r=new Date().toISOString(),s=K[e],a=n.length>0?`[${r}] [${s}] ${t} ${n.map(c=>typeof c=="object"?JSON.stringify(c):String(c)).join(" ")}`:`[${r}] [${s}] ${t}`;process.stderr.write(a+`
|
|
3
|
-
`)}debug(e,...t){this.log(0,e,...t)}info(e,...t){this.log(1,e,...t)}warn(e,...t){this.log(2,e,...t)}error(e,...t){this.log(3,e,...t)}},i=M.getInstance()});var H,pe=g(()=>{"use strict";S();H=class{cookies={};constructor(){}parseCookies(e){let t={},n=e.split(";");for(let r of n){let[s,a]=r.trim().split("=");s&&a&&(s==="__Secure-next-auth.session-token"?t.sessionToken=decodeURIComponent(a):s==="__Host-next-auth.csrf-token"?t.csrfToken=decodeURIComponent(a):s==="__Secure-next-auth.callback-url"&&(t.callbackUrl=decodeURIComponent(a)))}return t}setCookies(e){this.cookies=this.parseCookies(e),i.debug("NextAuth cookies parsed:",{hasSessionToken:!!this.cookies.sessionToken,hasCsrfToken:!!this.cookies.csrfToken,hasCallbackUrl:!!this.cookies.callbackUrl})}getCookies(){return this.cookies}getCookieHeader(){let e=[];return this.cookies.sessionToken&&e.push(`__Secure-next-auth.session-token=${encodeURIComponent(this.cookies.sessionToken)}`),this.cookies.csrfToken&&e.push(`__Host-next-auth.csrf-token=${encodeURIComponent(this.cookies.csrfToken)}`),this.cookies.callbackUrl&&e.push(`__Secure-next-auth.callback-url=${encodeURIComponent(this.cookies.callbackUrl)}`),e.join("; ")}isAuthenticated(){return!!this.cookies.sessionToken}getSessionToken(){return this.cookies.sessionToken||null}async decodeSessionToken(){if(!this.cookies.sessionToken)return null;try{return{token:this.cookies.sessionToken}}catch(e){return i.error("Error decoding session token:",e),null}}clear(){this.cookies={}}}});var G,ge=g(()=>{"use strict";T();E();S();G=class{httpClient;nextAuth;requestId=1;allCookies="";constructor(e){this.nextAuth=e,this.httpClient=new A({baseURL:`${m.nlobby.baseUrl}/api/trpc`,timeout:15e3,headers:{"Content-Type":"application/json","User-Agent":m.userAgent,Accept:"application/json","Accept-Language":"ja,en-US;q=0.7,en;q=0.3","Accept-Encoding":"gzip, deflate, br",Connection:"keep-alive","Sec-Fetch-Dest":"empty","Sec-Fetch-Mode":"cors","Sec-Fetch-Site":"same-origin"},withCredentials:!0}),this.setupInterceptors()}setAllCookies(e){if(!e||e.trim()===""){i.warn("[WARNING] Empty cookies provided to tRPC client"),this.allCookies="";return}this.allCookies=e,i.info("[SUCCESS] tRPC client cookies updated"),i.info(`[SIZE] tRPC cookie string length: ${e.length}`),this.allCookies===e?i.info("[SUCCESS] tRPC cookie verification successful"):i.error("[ERROR] tRPC cookie verification failed")}setupInterceptors(){this.httpClient.interceptors.request.use(e=>{let t;if(this.allCookies&&this.allCookies.trim()!=="")t=this.allCookies,i.debug("[COOKIE] Using all cookies for tRPC request");else{let s=this.nextAuth.getCookieHeader();s&&s.trim()!==""?(t=s,i.debug("[COOKIE] Using NextAuth cookies for tRPC request")):i.warn("[WARNING] No cookies available for tRPC request")}t&&(e.headers.Cookie=t);let n=this.nextAuth.getSessionToken();n?(e.headers.Authorization=`Bearer ${n}`,i.debug("Added Authorization header with session token")):i.warn("[WARNING] No session token available for Authorization header");let r=this.nextAuth.getCookies().csrfToken;return r&&(e.headers["X-CSRF-Token"]=r,i.debug("Added CSRF token to tRPC request")),i.debug("[REQUEST] tRPC request details:",{url:e.url,method:e.method?.toUpperCase(),hasCookies:!!t,hasCSRF:!!r,hasAuth:!!n,cookieSource:this.allCookies?"allCookies":"nextAuth"}),e}),this.httpClient.interceptors.response.use(e=>(i.debug("[SUCCESS] tRPC response received:",{status:e.status,statusText:e.statusText,hasData:!!e.data}),e),async e=>{let t=e instanceof C?e:null;if(i.error("[ERROR] tRPC request failed:",{status:t?.response?.status,statusText:t?.response?.statusText,message:e instanceof Error?e.message:"Unknown error",url:t?.config?.url}),t?.response?.status===401)throw i.error("[BLOCKED] Authentication failed - NextAuth session may be expired"),new Error("Authentication expired. Please re-authenticate with NextAuth cookies.");if(t?.response?.status===403)throw i.error("[BLOCKED] Access forbidden - insufficient permissions"),new Error("Access forbidden. Check your permissions or re-authenticate.");if(t?.response?.status===404)throw i.error("[BLOCKED] tRPC endpoint not found"),new Error("tRPC endpoint not found. The API may have changed.");return Promise.reject(e)})}getNextRequestId(){return this.requestId++}async call(e,t){let n={id:this.getNextRequestId(),method:e,params:t};try{i.info(`[REQUEST] tRPC call: ${e}`,t?`with params: ${JSON.stringify(t)}`:"without params");let r=this.allCookies||this.nextAuth.getCookieHeader();i.debug(`[COOKIE] Request cookies: ${r?"present":"missing"}`),i.debug("Trying GET approach...");try{let s=this.buildTRPCUrl(e,t);i.debug(`[URL] tRPC GET URL: ${s}`);let a=await this.httpClient.get(s);if(i.debug(`[SUCCESS] tRPC ${e} GET response status: ${a.status}`),a.data.error)throw i.error(`[ERROR] tRPC ${e} GET returned error:`,a.data.error),new Error(`tRPC Error [${a.data.error.code}]: ${a.data.error.message}`);return i.debug(`[SUCCESS] tRPC ${e} GET succeeded`),a.data.result}catch(s){i.debug("[WARNING] GET approach failed, trying POST approach..."),i.debug("[DEBUG] GET error details:",s instanceof Error?s.message:"Unknown error");let a=e;i.debug(`[URL] tRPC POST URL: ${a}`);let c=await this.httpClient.post(a,n,{headers:{"Content-Type":"application/json"}});if(i.debug(`[SUCCESS] tRPC ${e} POST response status: ${c.status}`),c.data.error)throw i.error(`[ERROR] tRPC ${e} POST returned error:`,c.data.error),new Error(`tRPC Error [${c.data.error.code}]: ${c.data.error.message}`);return i.debug(`[SUCCESS] tRPC ${e} POST succeeded`),c.data.result}}catch(r){throw i.error(`[ERROR] tRPC call failed for ${e}:`,{message:r instanceof Error?r.message:"Unknown error",stack:r instanceof Error?r.stack:void 0}),r instanceof C&&(i.error(`[DEBUG] tRPC ${e} fetch error details:`,{status:r.response?.status,statusText:r.response?.statusText,headers:r.response?.headers,data:r.response?.data,url:r.config?.url,method:r.config?.method,timeout:r.config?.timeout,cookies:r.config?.headers?.Cookie?"present":"missing"}),r.response?.status===401?i.error("[BLOCKED] tRPC 401 Unauthorized - session may be expired or invalid"):r.response?.status===403?i.error("[BLOCKED] tRPC 403 Forbidden - insufficient permissions"):r.response?.status===404?i.error("[BLOCKED] tRPC 404 Not Found - endpoint may not exist"):r.response?.status&&r.response.status>=500&&i.error("[BLOCKED] tRPC Server Error - N Lobby backend issue"),r.code==="ECONNREFUSED"?i.error("[NETWORK] Network Error: Connection refused - N Lobby may be down"):r.code==="ETIMEDOUT"?i.error("[TIMEOUT] Network Error: Request timeout - slow network or server overload"):r.code==="ENOTFOUND"&&i.error("[NETWORK] Network Error: DNS lookup failed - check internet connection")),r}}buildTRPCUrl(e,t){let n=e,r=JSON.stringify(t||{}),s=new URLSearchParams({input:r}).toString();return`/${n}?${s}`}async getUnreadNewsCount(){return this.call("news.getUnreadNewsCount")}async getNotificationMessages(){return this.call("notification.getMessages")}async updateLastAccess(){return this.call("user.updateLastAccess")}async findMainNavigations(){return this.call("menu.findMainNavigations",{})}async readInterestsWithIcon(){return this.call("interest.readInterestsWithIcon")}async readInterests(){return this.call("interest.readInterests")}async readWeights(){return this.call("interest.readWeights")}async getLobbyCalendarEvents(e,t){return this.call("calendar.getLobbyCalendarEvents",{from:e,to:t})}async healthCheck(){i.info("Running tRPC health check...");let e=[{name:"updateLastAccess",method:()=>this.updateLastAccess()},{name:"getUnreadNewsCount",method:()=>this.getUnreadNewsCount()},{name:"findMainNavigations",method:()=>this.findMainNavigations()}];for(let{name:t,method:n}of e)try{return i.debug(`Trying tRPC method: ${t}`),await n(),i.info(`[SUCCESS] tRPC health check passed with method: ${t}`),!0}catch(r){i.debug(`[ERROR] tRPC method ${t} failed:`,r instanceof Error?r.message:"Unknown error");continue}return i.error("[ERROR] All tRPC health check methods failed"),!1}}});async function $(o,e){try{i.info("[NETWORK] Fetching HTML using HTTP client (proven method)..."),i.debug(`[URL] URL: ${m.nlobby.baseUrl+e}`),i.info("[COOKIE] Cookies:",o.httpClient.defaults.headers.Cookie?"present":"missing");let t=await o.httpClient.get(e,{headers:{Accept:"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8","Accept-Language":"ja,en-US;q=0.7,en;q=0.3","Accept-Encoding":"gzip, deflate, br",Connection:"keep-alive","Upgrade-Insecure-Requests":"1","Sec-Fetch-Dest":"document","Sec-Fetch-Mode":"navigate","Sec-Fetch-Site":"none","Cache-Control":"max-age=0","User-Agent":m.userAgent},withCredentials:!0});if(i.info(`[SUCCESS] HTTP response: ${t.status} ${t.statusText}`),i.info(`[DATA] Content length: ${typeof t.data=="string"?t.data.length:"unknown"}`),i.info(`[DATA] Content type: ${t.headers["content-type"]||"unknown"}`),typeof t.data=="string"){let n=t.data,r=n.toLowerCase();if(r.includes("\u30ED\u30B0\u30A4\u30F3")||r.includes("login")?i.warn("[WARNING] WARNING: Page contains login keywords - authentication may have failed"):(r.includes("news")||r.includes("\u304A\u77E5\u3089\u305B"))&&i.info("[SUCCESS] Page appears to contain news content"),r.includes("unauthorized")||r.includes("access denied"))throw new Error("Access denied - authentication failed");return i.info(`[TARGET] HTML retrieved successfully: ${n.length} characters`),n}else throw new Error(`Non-string response received: ${typeof t.data}`)}catch(t){throw i.error("[ERROR] HTTP fetch error:",t instanceof Error?t.message:"Unknown error"),t instanceof C&&i.debug("[DEBUG] HTTP Error Details:",{status:t.response?.status,statusText:t.response?.statusText,url:t.config?.url,hasData:!!t.response?.data}),t}}var V=g(()=>{"use strict";E();S();T()});import*as me from"cheerio";function Gt(o){if(!o)return"";try{return o.replace(/\\u003c/g,"<").replace(/\\u003e/g,">").replace(/\\u0026/g,"&").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}catch{return o}}function he(o,e=""){if(!o||typeof o!="object")return null;let t=o;if(t.id&&t.title&&(t.publishedAt||t.description||t.menuName))return i.info(`[INFO] Found news object at path: ${e}`),o;if(t.news&&typeof t.news=="object")return i.info(`[INFO] Found news property at path: ${e}.news`),t.news;for(let[n,r]of Object.entries(t))if(r&&typeof r=="object"){let s=e?`${e}.${n}`:n,a=he(r,s);if(a)return a}return null}function J(o,e=""){if(!o||typeof o!="object")return[];if(Array.isArray(o)){if(o.length>0){let n=o[0];if(n&&typeof n=="object"&&["title","name","content","publishedAt","menuName","createdAt","updatedAt","id"].some(a=>a in n))return i.info(`[INFO] Found potential news array at path: ${e}, length: ${o.length}`),o}return[]}let t=[];for(let[n,r]of Object.entries(o)){let s=["news","announcements","data","items","list","content","notifications","posts","feed","results"],a=e?`${e}.${n}`:n;s.includes(n.toLowerCase())&&i.info(`[INFO] Searching priority key: ${a}`);let c=J(r,a);t.push(...c)}return t}function q(o){return o.map((e,t)=>{let n=e,r=new Date;n.publishedAt?r=new Date(n.publishedAt):n.createdAt?r=new Date(n.createdAt):n.updatedAt?r=new Date(n.updatedAt):n.date&&(r=new Date(n.date));let s=n.title||n.name||n.subject||n.heading||`News Item ${t+1}`,a=n.content||n.description||n.body||n.text||n.summary||"",c=n.category||n.menuName||n.type||n.classification||"General",l="medium";n.isImportant===!0||n.important===!0||n.priority==="high"||n.urgent===!0?l="high":(n.priority==="low"||n.minor===!0)&&(l="low");let u=n.id||t,d=`${m.nlobby.baseUrl}/news/${u}`;return{id:n.id?.toString()||t.toString(),title:s,content:a,publishedAt:r,category:c,priority:l,targetAudience:n.targetAudience||["student"],url:d,menuName:n.menuName,isImportant:!!n.isImportant,isUnread:!!n.isUnread,...Object.fromEntries(Object.entries(n).filter(([w])=>!["id","title","content","publishedAt","category","priority","url"].includes(w)))}})}function qt(o){try{i.info("[TARGET] Starting Cheerio-based DOM parsing...");let e=me.load(o),t=e('div[role="presentation"]');if(i.info(`[INFO] Found ${t.length} div[role="presentation"] elements`),t.length<2)return i.info('[WARNING] Less than 2 div[role="presentation"] elements found'),[];let n=e(t[1]);i.info('[SUCCESS] Located second div[role="presentation"] element');let r=n.find('div[role="row"]');i.info(`[INFO] Found ${r.length} DataGrid rows`);let s=[];return r.each((a,c)=>{try{let l=e(c),u=l.attr("data-id");if(!u)return;let d=l.find('div[role="gridcell"]'),h="",w="",y=new Date,k=!1,b=!1,p="";if(d.each((f,O)=>{let N=e(O);switch(N.attr("data-field")){case"title":{let R=N.find("a");if(R.length>0){let x=R.attr("href");x&&x.startsWith("/news/")?p=`${m.nlobby.baseUrl}${x}`:p=`${m.nlobby.baseUrl}/news/${u}`;let ue=R.find("span");h=ue.length>0?ue.text().trim():R.text().trim()}else h=N.text().trim(),p=`${m.nlobby.baseUrl}/news/${u}`;break}case"menuName":w=N.text().trim();break;case"isImportant":{k=N.text().trim().length>0||N.find("*").length>0;break}case"isUnread":{let R=N.text().trim();b=R.includes("\u672A\u8AAD")||R.length>0;break}case"publishedAt":{let R=N.text().trim();if(R){let x=new Date(R.replace(/\//g,"-"));isNaN(x.getTime())||(y=x)}break}}}),h){let f=p||`${m.nlobby.baseUrl}/news/${u}`,O={id:u,title:h,content:"",publishedAt:y,category:w||"General",priority:k?"high":"medium",targetAudience:["student"],url:f,menuName:w,isImportant:k,isUnread:b};s.push(O)}}catch(l){i.error(`[ERROR] Error parsing row ${a}:`,l instanceof Error?l.message:"Unknown error")}}),i.info(`[TARGET] Cheerio parsing completed: ${s.length} news items extracted`),s}catch(e){return i.error("[ERROR] Cheerio parsing failed:",e instanceof Error?e.message:"Unknown error"),[]}}function Jt(o){let e=[];try{i.info("[INFO] Starting HTML parsing...");let t=o.match(/self\.__next_f\.push\((\[.*?\])\)/g);if(t&&t.length>0){i.info(`[SUCCESS] Found ${t.length} self.__next_f.push() calls`);for(let s=0;s<t.length;s++){let a=t[s];try{let c=a.match(/self\.__next_f\.push\((\[.*?\])\)/);if(!c)continue;let l=JSON.parse(c[1]);if(l.length>=2&&typeof l[1]=="string"){let d=l[1],h=d.match(/^(\d+):(.*)/);if(h)try{let w=h[2],y=JSON.parse(w);if(Array.isArray(y))for(let k=0;k<y.length;k++){let b=y[k];if(Array.isArray(b)&&b.length>=4&&b[3]&&typeof b[3]=="object"){let p=b[3];if(p.news&&Array.isArray(p.news)&&p.news.length>0){let f=p.news[0];if(f&&typeof f=="object"&&(f.id||f.title||f.microCmsId))return q(p.news)}}}}catch{}else try{let w=JSON.parse(d),y=J(w,`push_call_${s+1}_fallback`);if(y&&y.length>0)return q(y)}catch{}}let u=J(l,`push_call_${s+1}_direct`);if(u&&u.length>0)return q(u)}catch{}}}let n=qt(o);if(n&&n.length>0)return n;let r=[o.match(/window\.__NEXT_DATA__\s*=\s*({.*?})\s*(?:;|<\/script>)/s),o.match(/<script id="__NEXT_DATA__"[^>]*>([^<]*)<\/script>/s)];for(let s of r)if(s)try{let a=s[1]||s[0],c=JSON.parse(a),l=J(c,"__NEXT_DATA__");if(l&&l.length>0)return q(l)}catch{}}catch(t){i.error("[ERROR] Error parsing news from HTML:",t)}return e}function Bt(o,e){try{let t=o.match(/self\.__next_f\.push\((\[.*?\])\)/g);if(!t||t.length===0)return null;let n=null,r="",s=new Map;for(let c=0;c<t.length;c++){let l=t[c];try{let u=l.match(/self\.__next_f\.push\((\[.*?\])\)/);if(!u)continue;let d=JSON.parse(u[1]);if(d.length>=2&&typeof d[1]=="string"&&d[1].match(/^\d+:T\d+,?$/)){let h=d[1].replace(/,$/,"");if(c+1<t.length){let y=t[c+1].match(/self\.__next_f\.push\((\[.*?\])\)/);if(y){let k=JSON.parse(y[1]);k.length>=2&&typeof k[1]=="string"&&s.set(h,k[1])}}continue}if(d.length>=2&&typeof d[1]=="string"){let w=d[1].match(/^(\d+):(.*)/);if(w)try{let y=w[2],k=JSON.parse(y),b=he(k);b&&(n=b)}catch{}}}catch{}}if(!n)return null;if(n.description){for(let[c,l]of s)if(n.description.includes(c)){r=l;break}}return!r&&s.size>0&&(r=Array.from(s.values())[0]),{id:n.id||e,microCmsId:n.microCmsId,title:n.title||"No Title",content:Gt(r)||n.description||"",description:n.description,publishedAt:n.publishedAt?new Date(n.publishedAt):new Date,menuName:n.menuName||[],isImportant:n.isImportant||!1,isByMentor:n.isByMentor||!1,attachments:n.attachments||[],relatedEvents:n.relatedEvents||[],targetUserQueryId:n.targetUserQueryId,url:`${m.nlobby.baseUrl}/news/${e}`}}catch(t){return i.error("[ERROR] Error parsing news detail from HTML:",t),null}}async function fe(o){i.info("[INFO] Starting getNews with HTTP client..."),i.info("[STATUS] Current authentication status:",o.getCookieStatus());try{let e=await $(o,"/news"),t=Jt(e);if(t&&t.length>0)return i.info(`[SUCCESS] Retrieved ${t.length} news items from HTML`),t;{let n=`HTML scraping returned no data. Debug info:
|
|
3
|
+
`)}debug(e,...t){this.log(0,e,...t)}info(e,...t){this.log(1,e,...t)}warn(e,...t){this.log(2,e,...t)}error(e,...t){this.log(3,e,...t)}},i=M.getInstance()});var H,pe=g(()=>{"use strict";S();H=class{cookies={};constructor(){}parseCookies(e){let t={},n=e.split(";");for(let r of n){let[s,a]=r.trim().split("=");s&&a&&(s==="__Secure-next-auth.session-token"?t.sessionToken=decodeURIComponent(a):s==="__Host-next-auth.csrf-token"?t.csrfToken=decodeURIComponent(a):s==="__Secure-next-auth.callback-url"&&(t.callbackUrl=decodeURIComponent(a)))}return t}setCookies(e){this.cookies=this.parseCookies(e),i.debug("NextAuth cookies parsed:",{hasSessionToken:!!this.cookies.sessionToken,hasCsrfToken:!!this.cookies.csrfToken,hasCallbackUrl:!!this.cookies.callbackUrl})}getCookies(){return this.cookies}getCookieHeader(){let e=[];return this.cookies.sessionToken&&e.push(`__Secure-next-auth.session-token=${encodeURIComponent(this.cookies.sessionToken)}`),this.cookies.csrfToken&&e.push(`__Host-next-auth.csrf-token=${encodeURIComponent(this.cookies.csrfToken)}`),this.cookies.callbackUrl&&e.push(`__Secure-next-auth.callback-url=${encodeURIComponent(this.cookies.callbackUrl)}`),e.join("; ")}isAuthenticated(){return!!this.cookies.sessionToken}getSessionToken(){return this.cookies.sessionToken||null}async decodeSessionToken(){if(!this.cookies.sessionToken)return null;try{return{token:this.cookies.sessionToken}}catch(e){return i.error("Error decoding session token:",e),null}}clear(){this.cookies={}}}});var G,ge=g(()=>{"use strict";T();E();S();G=class{httpClient;nextAuth;requestId=1;allCookies="";constructor(e){this.nextAuth=e,this.httpClient=new A({baseURL:`${m.nlobby.baseUrl}/api/trpc`,timeout:15e3,headers:{"Content-Type":"application/json","User-Agent":m.userAgent,Accept:"application/json","Accept-Language":"ja,en-US;q=0.7,en;q=0.3","Accept-Encoding":"gzip, deflate, br",Connection:"keep-alive","Sec-Fetch-Dest":"empty","Sec-Fetch-Mode":"cors","Sec-Fetch-Site":"same-origin"},withCredentials:!0}),this.setupInterceptors()}setAllCookies(e){if(!e||e.trim()===""){i.warn("[WARNING] Empty cookies provided to tRPC client"),this.allCookies="";return}this.allCookies=e,i.info("[SUCCESS] tRPC client cookies updated"),i.info(`[SIZE] tRPC cookie string length: ${e.length}`),this.allCookies===e?i.info("[SUCCESS] tRPC cookie verification successful"):i.error("[ERROR] tRPC cookie verification failed")}setupInterceptors(){this.httpClient.interceptors.request.use(e=>{let t;if(this.allCookies&&this.allCookies.trim()!=="")t=this.allCookies,i.debug("[COOKIE] Using all cookies for tRPC request");else{let s=this.nextAuth.getCookieHeader();s&&s.trim()!==""?(t=s,i.debug("[COOKIE] Using NextAuth cookies for tRPC request")):i.warn("[WARNING] No cookies available for tRPC request")}t&&(e.headers.Cookie=t);let n=this.nextAuth.getSessionToken();n?(e.headers.Authorization=`Bearer ${n}`,i.debug("Added Authorization header with session token")):i.warn("[WARNING] No session token available for Authorization header");let r=this.nextAuth.getCookies().csrfToken;return r&&(e.headers["X-CSRF-Token"]=r,i.debug("Added CSRF token to tRPC request")),i.debug("[REQUEST] tRPC request details:",{url:e.url,method:e.method?.toUpperCase(),hasCookies:!!t,hasCSRF:!!r,hasAuth:!!n,cookieSource:this.allCookies?"allCookies":"nextAuth"}),e}),this.httpClient.interceptors.response.use(e=>(i.debug("[SUCCESS] tRPC response received:",{status:e.status,statusText:e.statusText,hasData:!!e.data}),e),async e=>{let t=e instanceof C?e:null;if(i.error("[ERROR] tRPC request failed:",{status:t?.response?.status,statusText:t?.response?.statusText,message:e instanceof Error?e.message:"Unknown error",url:t?.config?.url}),t?.response?.status===401)throw i.error("[BLOCKED] Authentication failed - NextAuth session may be expired"),new Error("Authentication expired. Please re-authenticate with NextAuth cookies.");if(t?.response?.status===403)throw i.error("[BLOCKED] Access forbidden - insufficient permissions"),new Error("Access forbidden. Check your permissions or re-authenticate.");if(t?.response?.status===404)throw i.error("[BLOCKED] tRPC endpoint not found"),new Error("tRPC endpoint not found. The API may have changed.");return Promise.reject(e)})}getNextRequestId(){return this.requestId++}async call(e,t){let n={id:this.getNextRequestId(),method:e,params:t};try{i.info(`[REQUEST] tRPC call: ${e}`,t?`with params: ${JSON.stringify(t)}`:"without params");let r=this.allCookies||this.nextAuth.getCookieHeader();i.debug(`[COOKIE] Request cookies: ${r?"present":"missing"}`),i.debug("Trying GET approach...");try{let s=this.buildTRPCUrl(e,t);i.debug(`[URL] tRPC GET URL: ${s}`);let a=await this.httpClient.get(s);if(i.debug(`[SUCCESS] tRPC ${e} GET response status: ${a.status}`),a.data.error)throw i.error(`[ERROR] tRPC ${e} GET returned error:`,a.data.error),new Error(`tRPC Error [${a.data.error.code}]: ${a.data.error.message}`);return i.debug(`[SUCCESS] tRPC ${e} GET succeeded`),a.data.result}catch(s){i.debug("[WARNING] GET approach failed, trying POST approach..."),i.debug("[DEBUG] GET error details:",s instanceof Error?s.message:"Unknown error");let a=`/${e}`;i.debug(`[URL] tRPC POST URL: ${a}`);let c=await this.httpClient.post(a,n,{headers:{"Content-Type":"application/json"}});if(i.debug(`[SUCCESS] tRPC ${e} POST response status: ${c.status}`),c.data.error)throw i.error(`[ERROR] tRPC ${e} POST returned error:`,c.data.error),new Error(`tRPC Error [${c.data.error.code}]: ${c.data.error.message}`);return i.debug(`[SUCCESS] tRPC ${e} POST succeeded`),c.data.result}}catch(r){throw i.error(`[ERROR] tRPC call failed for ${e}:`,{message:r instanceof Error?r.message:"Unknown error",stack:r instanceof Error?r.stack:void 0}),r instanceof C&&(i.error(`[DEBUG] tRPC ${e} fetch error details:`,{status:r.response?.status,statusText:r.response?.statusText,headers:r.response?.headers,data:r.response?.data,url:r.config?.url,method:r.config?.method,timeout:r.config?.timeout,cookies:r.config?.headers?.Cookie?"present":"missing"}),r.response?.status===401?i.error("[BLOCKED] tRPC 401 Unauthorized - session may be expired or invalid"):r.response?.status===403?i.error("[BLOCKED] tRPC 403 Forbidden - insufficient permissions"):r.response?.status===404?i.error("[BLOCKED] tRPC 404 Not Found - endpoint may not exist"):r.response?.status&&r.response.status>=500&&i.error("[BLOCKED] tRPC Server Error - N Lobby backend issue"),r.code==="ECONNREFUSED"?i.error("[NETWORK] Network Error: Connection refused - N Lobby may be down"):r.code==="ETIMEDOUT"?i.error("[TIMEOUT] Network Error: Request timeout - slow network or server overload"):r.code==="ENOTFOUND"&&i.error("[NETWORK] Network Error: DNS lookup failed - check internet connection")),r}}buildTRPCUrl(e,t){let n=e,r=JSON.stringify(t||{}),s=new URLSearchParams({input:r}).toString();return`/${n}?${s}`}async getUnreadNewsCount(){return this.call("news.getUnreadNewsCount")}async getNotificationMessages(){return this.call("notification.getMessages")}async updateLastAccess(){return this.call("user.updateLastAccess")}async findMainNavigations(){return this.call("menu.findMainNavigations",{})}async readInterestsWithIcon(){return this.call("interest.readInterestsWithIcon")}async readInterests(){return this.call("interest.readInterests")}async readWeights(){return this.call("interest.readWeights")}async getLobbyCalendarEvents(e,t){return this.call("calendar.getLobbyCalendarEvents",{from:e,to:t})}async healthCheck(){i.info("Running tRPC health check...");let e=[{name:"updateLastAccess",method:()=>this.updateLastAccess()},{name:"getUnreadNewsCount",method:()=>this.getUnreadNewsCount()},{name:"findMainNavigations",method:()=>this.findMainNavigations()}];for(let{name:t,method:n}of e)try{return i.debug(`Trying tRPC method: ${t}`),await n(),i.info(`[SUCCESS] tRPC health check passed with method: ${t}`),!0}catch(r){i.debug(`[ERROR] tRPC method ${t} failed:`,r instanceof Error?r.message:"Unknown error");continue}return i.error("[ERROR] All tRPC health check methods failed"),!1}}});async function $(o,e){try{i.info("[NETWORK] Fetching HTML using HTTP client (proven method)..."),i.debug(`[URL] URL: ${m.nlobby.baseUrl+e}`),i.info("[COOKIE] Cookies:",o.httpClient.defaults.headers.Cookie?"present":"missing");let t=await o.httpClient.get(e,{headers:{Accept:"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8","Accept-Language":"ja,en-US;q=0.7,en;q=0.3","Accept-Encoding":"gzip, deflate, br",Connection:"keep-alive","Upgrade-Insecure-Requests":"1","Sec-Fetch-Dest":"document","Sec-Fetch-Mode":"navigate","Sec-Fetch-Site":"none","Cache-Control":"max-age=0","User-Agent":m.userAgent},withCredentials:!0});if(i.info(`[SUCCESS] HTTP response: ${t.status} ${t.statusText}`),i.info(`[DATA] Content length: ${typeof t.data=="string"?t.data.length:"unknown"}`),i.info(`[DATA] Content type: ${t.headers["content-type"]||"unknown"}`),typeof t.data=="string"){let n=t.data,r=n.toLowerCase();if(r.includes("\u30ED\u30B0\u30A4\u30F3")||r.includes("login")?i.warn("[WARNING] WARNING: Page contains login keywords - authentication may have failed"):(r.includes("news")||r.includes("\u304A\u77E5\u3089\u305B"))&&i.info("[SUCCESS] Page appears to contain news content"),r.includes("unauthorized")||r.includes("access denied"))throw new Error("Access denied - authentication failed");return i.info(`[TARGET] HTML retrieved successfully: ${n.length} characters`),n}else throw new Error(`Non-string response received: ${typeof t.data}`)}catch(t){throw i.error("[ERROR] HTTP fetch error:",t instanceof Error?t.message:"Unknown error"),t instanceof C&&i.debug("[DEBUG] HTTP Error Details:",{status:t.response?.status,statusText:t.response?.statusText,url:t.config?.url,hasData:!!t.response?.data}),t}}var V=g(()=>{"use strict";E();S();T()});import*as me from"cheerio";function Gt(o){if(!o)return"";try{return o.replace(/\\u003c/g,"<").replace(/\\u003e/g,">").replace(/\\u0026/g,"&").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}catch{return o}}function he(o,e=""){if(!o||typeof o!="object")return null;let t=o;if(t.id&&t.title&&(t.publishedAt||t.description||t.menuName))return i.info(`[INFO] Found news object at path: ${e}`),o;if(t.news&&typeof t.news=="object")return i.info(`[INFO] Found news property at path: ${e}.news`),t.news;for(let[n,r]of Object.entries(t))if(r&&typeof r=="object"){let s=e?`${e}.${n}`:n,a=he(r,s);if(a)return a}return null}function J(o,e=""){if(!o||typeof o!="object")return[];if(Array.isArray(o)){if(o.length>0){let n=o[0];if(n&&typeof n=="object"&&["title","name","content","publishedAt","menuName","createdAt","updatedAt","id"].some(a=>a in n))return i.info(`[INFO] Found potential news array at path: ${e}, length: ${o.length}`),o}return[]}let t=[];for(let[n,r]of Object.entries(o)){let s=["news","announcements","data","items","list","content","notifications","posts","feed","results"],a=e?`${e}.${n}`:n;s.includes(n.toLowerCase())&&i.info(`[INFO] Searching priority key: ${a}`);let c=J(r,a);t.push(...c)}return t}function q(o){return o.map((e,t)=>{let n=e,r=new Date;n.publishedAt?r=new Date(n.publishedAt):n.createdAt?r=new Date(n.createdAt):n.updatedAt?r=new Date(n.updatedAt):n.date&&(r=new Date(n.date));let s=n.title||n.name||n.subject||n.heading||`News Item ${t+1}`,a=n.content||n.description||n.body||n.text||n.summary||"",c=n.category||n.menuName||n.type||n.classification||"General",l="medium";n.isImportant===!0||n.important===!0||n.priority==="high"||n.urgent===!0?l="high":(n.priority==="low"||n.minor===!0)&&(l="low");let u=n.id||t,d=`${m.nlobby.baseUrl}/news/${u}`;return{id:n.id?.toString()||t.toString(),title:s,content:a,publishedAt:r,category:c,priority:l,targetAudience:n.targetAudience||["student"],url:d,menuName:n.menuName,isImportant:!!n.isImportant,isUnread:!!n.isUnread,...Object.fromEntries(Object.entries(n).filter(([w])=>!["id","title","content","publishedAt","category","priority","url"].includes(w)))}})}function qt(o){try{i.info("[TARGET] Starting Cheerio-based DOM parsing...");let e=me.load(o),t=e('div[role="presentation"]');if(i.info(`[INFO] Found ${t.length} div[role="presentation"] elements`),t.length<2)return i.info('[WARNING] Less than 2 div[role="presentation"] elements found'),[];let n=e(t[1]);i.info('[SUCCESS] Located second div[role="presentation"] element');let r=n.find('div[role="row"]');i.info(`[INFO] Found ${r.length} DataGrid rows`);let s=[];return r.each((a,c)=>{try{let l=e(c),u=l.attr("data-id");if(!u)return;let d=l.find('div[role="gridcell"]'),h="",w="",y=new Date,k=!1,b=!1,p="";if(d.each((f,O)=>{let N=e(O);switch(N.attr("data-field")){case"title":{let R=N.find("a");if(R.length>0){let x=R.attr("href");x&&x.startsWith("/news/")?p=`${m.nlobby.baseUrl}${x}`:p=`${m.nlobby.baseUrl}/news/${u}`;let ue=R.find("span");h=ue.length>0?ue.text().trim():R.text().trim()}else h=N.text().trim(),p=`${m.nlobby.baseUrl}/news/${u}`;break}case"menuName":w=N.text().trim();break;case"isImportant":{k=N.text().trim().length>0||N.find("*").length>0;break}case"isUnread":{let R=N.text().trim();b=R.includes("\u672A\u8AAD")||R.length>0;break}case"publishedAt":{let R=N.text().trim();if(R){let x=new Date(R.replace(/\//g,"-"));isNaN(x.getTime())||(y=x)}break}}}),h){let f=p||`${m.nlobby.baseUrl}/news/${u}`,O={id:u,title:h,content:"",publishedAt:y,category:w||"General",priority:k?"high":"medium",targetAudience:["student"],url:f,menuName:w,isImportant:k,isUnread:b};s.push(O)}}catch(l){i.error(`[ERROR] Error parsing row ${a}:`,l instanceof Error?l.message:"Unknown error")}}),i.info(`[TARGET] Cheerio parsing completed: ${s.length} news items extracted`),s}catch(e){return i.error("[ERROR] Cheerio parsing failed:",e instanceof Error?e.message:"Unknown error"),[]}}function Jt(o){let e=[];try{i.info("[INFO] Starting HTML parsing...");let t=o.match(/self\.__next_f\.push\((\[.*?\])\)/g);if(t&&t.length>0){i.info(`[SUCCESS] Found ${t.length} self.__next_f.push() calls`);for(let s=0;s<t.length;s++){let a=t[s];try{let c=a.match(/self\.__next_f\.push\((\[.*?\])\)/);if(!c)continue;let l=JSON.parse(c[1]);if(l.length>=2&&typeof l[1]=="string"){let d=l[1],h=d.match(/^(\d+):(.*)/);if(h)try{let w=h[2],y=JSON.parse(w);if(Array.isArray(y))for(let k=0;k<y.length;k++){let b=y[k];if(Array.isArray(b)&&b.length>=4&&b[3]&&typeof b[3]=="object"){let p=b[3];if(p.news&&Array.isArray(p.news)&&p.news.length>0){let f=p.news[0];if(f&&typeof f=="object"&&(f.id||f.title||f.microCmsId))return q(p.news)}}}}catch{}else try{let w=JSON.parse(d),y=J(w,`push_call_${s+1}_fallback`);if(y&&y.length>0)return q(y)}catch{}}let u=J(l,`push_call_${s+1}_direct`);if(u&&u.length>0)return q(u)}catch{}}}let n=qt(o);if(n&&n.length>0)return n;let r=[o.match(/window\.__NEXT_DATA__\s*=\s*({.*?})\s*(?:;|<\/script>)/s),o.match(/<script id="__NEXT_DATA__"[^>]*>([^<]*)<\/script>/s)];for(let s of r)if(s)try{let a=s[1]||s[0],c=JSON.parse(a),l=J(c,"__NEXT_DATA__");if(l&&l.length>0)return q(l)}catch{}}catch(t){i.error("[ERROR] Error parsing news from HTML:",t)}return e}function Bt(o,e){try{let t=o.match(/self\.__next_f\.push\((\[.*?\])\)/g);if(!t||t.length===0)return null;let n=null,r="",s=new Map;for(let c=0;c<t.length;c++){let l=t[c];try{let u=l.match(/self\.__next_f\.push\((\[.*?\])\)/);if(!u)continue;let d=JSON.parse(u[1]);if(d.length>=2&&typeof d[1]=="string"&&d[1].match(/^\d+:T\d+,?$/)){let h=d[1].replace(/,$/,"");if(c+1<t.length){let y=t[c+1].match(/self\.__next_f\.push\((\[.*?\])\)/);if(y){let k=JSON.parse(y[1]);k.length>=2&&typeof k[1]=="string"&&s.set(h,k[1])}}continue}if(d.length>=2&&typeof d[1]=="string"){let w=d[1].match(/^(\d+):(.*)/);if(w)try{let y=w[2],k=JSON.parse(y),b=he(k);b&&(n=b)}catch{}}}catch{}}if(!n)return null;if(n.description){for(let[c,l]of s)if(n.description.includes(c)){r=l;break}}return!r&&s.size>0&&(r=Array.from(s.values())[0]),{id:n.id||e,microCmsId:n.microCmsId,title:n.title||"No Title",content:Gt(r)||n.description||"",description:n.description,publishedAt:n.publishedAt?new Date(n.publishedAt):new Date,menuName:n.menuName||[],isImportant:n.isImportant||!1,isByMentor:n.isByMentor||!1,attachments:n.attachments||[],relatedEvents:n.relatedEvents||[],targetUserQueryId:n.targetUserQueryId,url:`${m.nlobby.baseUrl}/news/${e}`}}catch(t){return i.error("[ERROR] Error parsing news detail from HTML:",t),null}}async function fe(o){i.info("[INFO] Starting getNews with HTTP client..."),i.info("[STATUS] Current authentication status:",o.getCookieStatus());try{let e=await $(o,"/news"),t=Jt(e);if(t&&t.length>0)return i.info(`[SUCCESS] Retrieved ${t.length} news items from HTML`),t;{let n=`HTML scraping returned no data. Debug info:
|
|
4
4
|
- Authentication status: ${o.nextAuth.isAuthenticated()?"authenticated":"not authenticated"}
|
|
5
5
|
- HTTP cookies: ${o.httpClient.defaults.headers.Cookie?"present":"missing"}
|
|
6
6
|
- HTML length: ${e.length} characters
|
|
@@ -140,4 +140,4 @@ Issue: ${s.message}`),n+=`
|
|
|
140
140
|
${n}`)}catch(n){console.error("[FAIL]",n instanceof Error?n.message:n),process.exit(1)}}),e.command("trpc <method>").description("Test a specific tRPC endpoint (e.g. news.getUnreadNewsCount)").option("--params <json>","JSON string of parameters").option("--json","Output raw JSON result").action(async(t,n)=>{try{let r=n.params?JSON.parse(n.params):{},s=await o.testTrpcEndpoint(t,r);n.json?console.log(JSON.stringify(s,null,2)):console.log(`Result of ${t} with params ${JSON.stringify(r)}:
|
|
141
141
|
|
|
142
142
|
${JSON.stringify(s,null,2)}`)}catch(r){console.error("[FAIL]",r instanceof Error?r.message:r),process.exit(1)}}),e.command("verify").description("Verify authentication status and cookie synchronization across all clients").action(async()=>{try{let t=o.getCookieStatus();console.log(t)}catch(t){console.error("[FAIL]",t instanceof Error?t.message:t),process.exit(1)}}),e}var Tt=g(()=>{"use strict";xt()});import{Command as kn}from"commander";function vt(){return new kn("serve").alias("mcp").description("Start the MCP server (stdio transport)").action(async()=>{let{logger:e}=await Promise.resolve().then(()=>(S(),de));e.forceProductionMode();let{NLobbyMCPServer:t}=await Promise.resolve().then(()=>(ae(),ie));await new t().start()})}var Dt=g(()=>{"use strict"});import{Command as Nn}from"commander";function It(o){let e=new Nn("exam").description("Exam day utilities");return e.command("check").description("Check if a date is an exam day (default: today)").argument("[date]","Date in YYYY-MM-DD format").option("--json","Output raw JSON").action(async(t,n)=>{try{let r=t?new Date(t):void 0,s=await o.isExamDay(r),a=(r??new Date).toISOString().split("T")[0];n.json?console.log(JSON.stringify({date:a,isExamDay:s},null,2)):console.log(s?`[EXAM] ${a} is an exam day.`:`[OK] ${a} is not an exam day.`)}catch(r){console.error("[FAIL]",r instanceof Error?r.message:r),process.exit(1)}}),e.command("finish").description("Finish exam day mode").option("--json","Output raw JSON").action(async t=>{try{let n=await o.finishExamDayMode();t.json?console.log(JSON.stringify({success:n},null,2)):console.log(n?"[OK] Exam day mode finished.":"[FAIL] Failed to finish exam day mode."),n||process.exit(1)}catch(n){console.error("[FAIL]",n instanceof Error?n.message:n),process.exit(1)}}),e.command("otp").description("Get one-time password for exam").option("--json","Output raw JSON").action(async t=>{try{let n=await o.getExamOneTimePassword();t.json,console.log(JSON.stringify(n,null,2))}catch(n){console.error("[FAIL]",n instanceof Error?n.message:n),process.exit(1)}}),e}var Lt=g(()=>{"use strict"});import{Command as Rn}from"commander";function Ot(o){let e=new Rn("nav").description("Navigation, notifications, and user interests");return e.command("menus").description("Show main navigation menu list").option("--json","Output raw JSON").action(async t=>{try{let n=await o.getMainNavigations();if(t.json)console.log(JSON.stringify(n,null,2));else if(n.length===0)console.log("No navigation menus found.");else for(let r of n){r.categoryName&&console.log(`
|
|
143
|
-
\u2500\u2500 ${r.categoryName} \u2500\u2500`);for(let{menu:s}of r.items)console.log(` ${s.label}${s.badgeContent?` (${s.badgeContent})`:""}`)}}catch(n){console.error("[FAIL]",n instanceof Error?n.message:n),process.exit(1)}}),e.command("notifications").description("Show notification messages").option("--json","Output raw JSON").action(async t=>{try{let n=await o.getNotificationMessages();if(t.json)console.log(JSON.stringify(n,null,2));else if(n.length===0)console.log("No notifications.");else for(let r of n)console.log(`[${r.id}] ${r.title??""}`),r.body&&console.log(` ${r.body}`)}catch(n){console.error("[FAIL]",n instanceof Error?n.message:n),process.exit(1)}}),e.command("interests").description("Show user interest tags").option("--with-icon","Include icon information").option("--json","Output raw JSON").action(async t=>{try{let n=await o.getUserInterests(t.withIcon??!1);if(t.json)console.log(JSON.stringify(n,null,2));else if(n.length===0)console.log("No interests found.");else for(let r of n){let s=t.withIcon&&r.iconName?` [${r.iconName}]`:"";console.log(` ${r.name}${s} (weight: ${r.weightId})`)}}catch(n){console.error("[FAIL]",n instanceof Error?n.message:n),process.exit(1)}}),e.command("weights").description("Show interest weight scale definitions").option("--json","Output raw JSON").action(async t=>{try{let n=await o.getInterestWeights();if(t.json)console.log(JSON.stringify(n,null,2));else if(n.length===0)console.log("No weight definitions found.");else for(let r of n)console.log(` [${r.id}] ${r.label} (value: ${r.value})`)}catch(n){console.error("[FAIL]",n instanceof Error?n.message:n),process.exit(1)}}),e}var $t=g(()=>{"use strict"});var Pt={};j(Pt,{buildProgram:()=>Ut,runCli:()=>xn});import{Command as En}from"commander";function Ut(){let o=new D,e=new En().name("nlobby").description("N Lobby CLI \u2014 access N Lobby from the command line").version("1.4.
|
|
143
|
+
\u2500\u2500 ${r.categoryName} \u2500\u2500`);for(let{menu:s}of r.items)console.log(` ${s.label}${s.badgeContent?` (${s.badgeContent})`:""}`)}}catch(n){console.error("[FAIL]",n instanceof Error?n.message:n),process.exit(1)}}),e.command("notifications").description("Show notification messages").option("--json","Output raw JSON").action(async t=>{try{let n=await o.getNotificationMessages();if(t.json)console.log(JSON.stringify(n,null,2));else if(n.length===0)console.log("No notifications.");else for(let r of n)console.log(`[${r.id}] ${r.title??""}`),r.body&&console.log(` ${r.body}`)}catch(n){console.error("[FAIL]",n instanceof Error?n.message:n),process.exit(1)}}),e.command("interests").description("Show user interest tags").option("--with-icon","Include icon information").option("--json","Output raw JSON").action(async t=>{try{let n=await o.getUserInterests(t.withIcon??!1);if(t.json)console.log(JSON.stringify(n,null,2));else if(n.length===0)console.log("No interests found.");else for(let r of n){let s=t.withIcon&&r.iconName?` [${r.iconName}]`:"";console.log(` ${r.name}${s} (weight: ${r.weightId})`)}}catch(n){console.error("[FAIL]",n instanceof Error?n.message:n),process.exit(1)}}),e.command("weights").description("Show interest weight scale definitions").option("--json","Output raw JSON").action(async t=>{try{let n=await o.getInterestWeights();if(t.json)console.log(JSON.stringify(n,null,2));else if(n.length===0)console.log("No weight definitions found.");else for(let r of n)console.log(` [${r.id}] ${r.label} (value: ${r.value})`)}catch(n){console.error("[FAIL]",n instanceof Error?n.message:n),process.exit(1)}}),e}var $t=g(()=>{"use strict"});var Pt={};j(Pt,{buildProgram:()=>Ut,runCli:()=>xn});import{Command as En}from"commander";function Ut(){let o=new D,e=new En().name("nlobby").description("N Lobby CLI \u2014 access N Lobby from the command line").version("1.4.4");return e.addCommand(et(o)),e.addCommand(nt(o)),e.addCommand(tt()),e.addCommand(at(o)),e.addCommand(mt(o)),e.addCommand(ht(o)),e.addCommand(bt(o)),e.addCommand(Nt(o)),e.addCommand(At(o)),e.addCommand(It(o)),e.addCommand(Ot(o)),e.addCommand(vt()),e}async function xn(){await Ut().parseAsync(process.argv)}var _t=g(()=>{"use strict";Y();rt();ct();ft();Ct();Rt();Tt();Dt();Lt();$t()});var le=process.argv.slice(2),An=le[0]==="serve"||le[0]==="mcp",Tn=le.length===0&&!process.stdin.isTTY;async function vn(){if(An||Tn){let{NLobbyMCPServer:o}=await Promise.resolve().then(()=>(ae(),ie));await new o().start()}else{let{runCli:o}=await Promise.resolve().then(()=>(_t(),Pt));await o()}}vn().catch(o=>{console.error("Fatal error:",o instanceof Error?o.message:o),process.exit(1)});
|