dsh-ustc-campus 0.2.14 → 0.2.15

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/src/host.mjs CHANGED
@@ -3,7 +3,8 @@ import { CampusInputError, MAX_ICS, openCampus } from './state.mjs';
3
3
  import { createSchool } from './school.mjs';
4
4
  import { localMidnight } from './calendar.mjs';
5
5
  import { createSchoolVault } from './school-vault.mjs';
6
- import { createYouth } from './youth.mjs';
6
+ import { createYouth, YOUTH_SERVICE } from './youth.mjs';
7
+ import { shanghaiEpoch } from './public-fetch.mjs';
7
8
  import { createYouthActions } from './youth-actions.mjs';
8
9
  import { BbError, createBb } from './bb.mjs';
9
10
  import { createBbActions, openBbSession } from './bb-actions.mjs';
@@ -66,6 +67,8 @@ export function apply(ctx) {
66
67
  const libraryApprovals = new Map();
67
68
  let accountSignal = new AbortController();
68
69
  const youthWeeks = new Map();
70
+ let youthEnrollingCache = { at: 0, items: [], source: null, inFlight: null };
71
+ let cachedSchoolCourseTitles = [];
69
72
  let accountEpoch = 0;
70
73
  function invalidateAccountData() {
71
74
  accountEpoch++;
@@ -74,10 +77,83 @@ export function apply(ctx) {
74
77
  schoolWeeks.clear();
75
78
  examWeeks.clear();
76
79
  youthWeeks.clear();
80
+ youthEnrollingCache = { at: 0, items: [], source: null, inFlight: null };
81
+ cachedSchoolCourseTitles = [];
77
82
  bbActions.clear();
78
83
  libraryApprovals.clear();
79
84
  hsLibrary.clear();
80
85
  }
86
+ function parseHoldDateTime(raw) {
87
+ if (typeof raw !== 'string') return { date: null, time: null, epoch: null };
88
+ const m = raw.trim().match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})(?::(\d{2}))?$/);
89
+ if (!m) return { date: null, time: null, epoch: null };
90
+ const [y, mo, d] = m[1].split('-').map(Number);
91
+ const [h, mi] = m[2].split(':').map(Number);
92
+ const epoch = shanghaiEpoch(y, mo, d, h, mi, m[3] ? Number(m[3]) : 0);
93
+ return { date: m[1], time: m[2], epoch };
94
+ }
95
+ async function getYouthEnrollingFeed(forceRefresh = false) {
96
+ if (school.status().state !== 'connected') {
97
+ return { extraItems: [], extraSources: [] };
98
+ }
99
+ const nowMs = Date.now();
100
+ if (!forceRefresh && youthEnrollingCache.source && nowMs - youthEnrollingCache.at < 5 * 60_000) {
101
+ return { extraItems: youthEnrollingCache.items, extraSources: [youthEnrollingCache.source] };
102
+ }
103
+ if (youthEnrollingCache.inFlight) return youthEnrollingCache.inFlight;
104
+ const epoch = accountEpoch;
105
+ youthEnrollingCache.inFlight = youth.listActivities({ mode: 'enrolling', page: 1, pageSize: 50 })
106
+ .then((res) => {
107
+ if (epoch !== accountEpoch || !res || res.state !== 'ok' || !Array.isArray(res.activities)) {
108
+ return { extraItems: youthEnrollingCache.items, extraSources: youthEnrollingCache.source ? [youthEnrollingCache.source] : [] };
109
+ }
110
+ const items = res.activities.map((act) => {
111
+ const st = parseHoldDateTime(act.holdStart);
112
+ const et = parseHoldDateTime(act.holdEnd);
113
+ const timeStr = st.time ? (et.time ? `${st.time}-${et.time}` : st.time) : null;
114
+ return {
115
+ id: `youth-enrolling:${act.id}`,
116
+ youthItemId: act.id,
117
+ source: 'youth-enrolling',
118
+ category: 'activity',
119
+ intent: 'activity',
120
+ requiresRegistration: true,
121
+ title: act.title,
122
+ url: YOUTH_SERVICE,
123
+ date: st.date,
124
+ time: timeStr,
125
+ location: act.location ?? null,
126
+ start: st.epoch,
127
+ end: et.epoch,
128
+ secondClassroom: true,
129
+ organizer: act.organizer ?? null,
130
+ enrollmentRatio: act.enrollmentRatio ?? null,
131
+ remainingSlots: act.remainingSlots ?? null,
132
+ hours: act.hours ?? null,
133
+ registered: act.registered ?? null,
134
+ reason: '',
135
+ past: false
136
+ };
137
+ });
138
+ const source = {
139
+ id: 'youth-enrolling',
140
+ label: '青春科大 · 报名中二课',
141
+ category: 'activity',
142
+ fetchedAt: Date.now(),
143
+ error: null
144
+ };
145
+ youthEnrollingCache = { at: Date.now(), items, source, inFlight: null };
146
+ return { extraItems: items, extraSources: [source] };
147
+ })
148
+ .catch(() => ({
149
+ extraItems: youthEnrollingCache.items,
150
+ extraSources: youthEnrollingCache.source ? [youthEnrollingCache.source] : []
151
+ }))
152
+ .finally(() => {
153
+ if (youthEnrollingCache) youthEnrollingCache.inFlight = null;
154
+ });
155
+ return youthEnrollingCache.inFlight;
156
+ }
81
157
  function youthAgenda(from, through, refresh=false) {
82
158
  const key = `${from}/${through}`;
83
159
  const cached = youthWeeks.get(key);
@@ -115,6 +191,10 @@ export function apply(ctx) {
115
191
  if (schoolWeeks.size >= 8) schoolWeeks.delete(schoolWeeks.keys().next().value);
116
192
  const request = school.agenda({from,through}).then(out => {
117
193
  if(out.state!=='ok' && schoolWeeks.get(key)?.request === request) schoolWeeks.delete(key);
194
+ if(out.state==='ok' && Array.isArray(out.entries)) {
195
+ const titles = out.entries.map(e => typeof e?.title === 'string' ? e.title.trim() : '').filter(Boolean);
196
+ if (titles.length > 0) cachedSchoolCourseTitles = [...new Set([...cachedSchoolCourseTitles, ...titles])].slice(0, 40);
197
+ }
118
198
  const state = school.status().state === 'pending' ? 'pending' : out.state;
119
199
  return {schoolEntries:out.entries,state,complete:out.complete};
120
200
  });
@@ -229,9 +309,33 @@ export function apply(ctx) {
229
309
  if(op==='library-booking-status') return bookingStatus(data);
230
310
  if(op==='library-booking-reservations') return reservations(data);
231
311
  if(op==='library-booking-unresolved') return readBooking(libraryBooking.unresolved);
312
+ if(op==='feed') {
313
+ const extra = await getYouthEnrollingFeed(false);
314
+ return campus.queryFeed({ ...data, courseTitles: cachedSchoolCourseTitles, ...extra });
315
+ }
316
+ if(op==='refresh') {
317
+ const [_, extra] = await Promise.all([
318
+ campus.refresh({ force: data.force === true }),
319
+ getYouthEnrollingFeed(data.force === true)
320
+ ]);
321
+ return campus.queryFeed({ ...data, courseTitles: cachedSchoolCourseTitles, ...extra });
322
+ }
323
+ if(op==='feed-feedback') return campus.recordFeedFeedback(data);
324
+ if(op==='feed-profile') return campus.feedProfile();
325
+ if(op==='feed-custom-list') return campus.listCustomFeeds();
326
+ if(op==='feed-custom-add') {
327
+ const added = campus.addCustomFeed(data);
328
+ await campus.refresh({ force: false }).catch(() => {});
329
+ return { ...added, subscriptions: campus.listCustomFeeds() };
330
+ }
331
+ if(op==='feed-custom-remove') return { ...campus.removeCustomFeed(data), subscriptions: campus.listCustomFeeds() };
232
332
  return dispatch(campus,school,op,data);
233
333
  }
234
- ctx.provide('ustcCampus', campus);
334
+ ctx.provide('ustcCampus', {
335
+ ...campus,
336
+ cachedCourseTitles: () => [...cachedSchoolCourseTitles],
337
+ getExtraFeedData: (force = false) => getYouthEnrollingFeed(force)
338
+ });
235
339
  ctx.provide('ustcSchool', school);
236
340
  ctx.provide('ustcBb', {listCourses:bb.listCourses,listAssignments:bb.listAssignments,inspectAssignment:bb.inspectAssignment,request:bbActions.request,status:bbActions.status,
237
341
  confirm:(data,approve,signal)=>bbActions.confirm(data,approve,AbortSignal.any([signal,accountSignal.signal])),
package/src/mcp-host.mjs CHANGED
@@ -700,6 +700,61 @@ export function createHostHandlers(ctx) {
700
700
  };
701
701
  }
702
702
  if (ctx?.ustcTransit) handlers['campus-shuttle'] = ({fromCampus,toCampus,date,scheduleType}) => ctx.ustcTransit.read({fromCampus,toCampus,date,scheduleType});
703
+ if (ctx?.ustcCampus && typeof ctx.ustcCampus.queryFeed === 'function') {
704
+ handlers['feed-query'] = async (args = {}) => {
705
+ const courseTitles = typeof ctx.ustcCampus.cachedCourseTitles === 'function' ? ctx.ustcCampus.cachedCourseTitles() : [];
706
+ const extra = typeof ctx.ustcCampus.getExtraFeedData === 'function'
707
+ ? await ctx.ustcCampus.getExtraFeedData(false)
708
+ : { extraItems: [], extraSources: [] };
709
+ const queryArgs = {
710
+ source: args.source,
711
+ category: args.category,
712
+ intent: args.intent,
713
+ keyword: args.keyword,
714
+ sort: args.sort,
715
+ interests: args.interests,
716
+ courseTitles,
717
+ ...extra
718
+ };
719
+ let feed = ctx.ustcCampus.queryFeed(queryArgs);
720
+ if (feed.sources.length > 0 && feed.sources.every((entry) => entry.fetchedAt == null)) {
721
+ await ctx.ustcCampus.refresh();
722
+ const refreshedExtra = typeof ctx.ustcCampus.getExtraFeedData === 'function'
723
+ ? await ctx.ustcCampus.getExtraFeedData(true)
724
+ : extra;
725
+ feed = ctx.ustcCampus.queryFeed({ ...queryArgs, ...refreshedExtra });
726
+ }
727
+ const limit = Math.min(30, Math.max(1, Math.trunc(Number(args.limit) || 10)));
728
+ const offset = Math.min(feed.items.length, Math.max(0, Math.trunc(Number(args.offset) || 0)));
729
+ const items = feed.items.slice(offset, offset + limit);
730
+ return {
731
+ items,
732
+ total: feed.items.length,
733
+ offset,
734
+ nextOffset: offset + items.length < feed.items.length ? offset + items.length : null,
735
+ truncated: offset + items.length < feed.items.length,
736
+ sources: feed.sources
737
+ };
738
+ };
739
+ }
740
+ if (ctx?.ustcCampus && typeof ctx.ustcCampus.recordFeedFeedback === 'function') {
741
+ handlers['feed-feedback'] = (args = {}) => ctx.ustcCampus.recordFeedFeedback(args);
742
+ }
743
+ if (ctx?.ustcCampus && typeof ctx.ustcCampus.feedProfile === 'function') {
744
+ handlers['feed-profile'] = () => ctx.ustcCampus.feedProfile();
745
+ }
746
+ if (ctx?.ustcCampus && typeof ctx.ustcCampus.listCustomFeeds === 'function') {
747
+ handlers['feed-custom-list'] = () => ctx.ustcCampus.listCustomFeeds();
748
+ handlers['feed-custom-add'] = async (args = {}) => {
749
+ const added = ctx.ustcCampus.addCustomFeed(args);
750
+ await ctx.ustcCampus.refresh?.({ force: false }).catch(() => {});
751
+ return { ...added, subscriptions: ctx.ustcCampus.listCustomFeeds() };
752
+ };
753
+ handlers['feed-custom-remove'] = (args = {}) => ({
754
+ ...ctx.ustcCampus.removeCustomFeed(args),
755
+ subscriptions: ctx.ustcCampus.listCustomFeeds()
756
+ });
757
+ }
703
758
  return handlers;
704
759
  }
705
760
 
@@ -956,6 +1011,7 @@ export async function apply(ctx) {
956
1011
  if(handlers['youth-enroll-prepare']) registration.env.CAMPUS_MCP_YOUTH_ACTIONS='1';
957
1012
  if(handlers['school-exams']) registration.env.CAMPUS_MCP_EXAMS='1';
958
1013
  if(handlers['campus-shuttle']) registration.env.CAMPUS_MCP_TRANSIT='1';
1014
+ if(handlers['feed-feedback']) registration.env.CAMPUS_MCP_FEED_FEEDBACK='1';
959
1015
  ctx.mcpManager.register('ustc_campus', registration);
960
1016
  } catch (error) {
961
1017
  await pipe.close();
package/src/mcp.mjs CHANGED
@@ -24,7 +24,8 @@ import { z } from 'zod';
24
24
 
25
25
  import { DAY, localMidnight } from './calendar.mjs';
26
26
  import { openCampus } from './state.mjs';
27
- import { FEED_SOURCES } from './feed.mjs';
27
+ import { FEED_CATEGORIES, FEED_SOURCES } from './feed.mjs';
28
+ import { TOPIC_IDS } from './recommender.mjs';
28
29
  import { sanitizeText } from './public-fetch.mjs';
29
30
  import { bbMaterialsLink, bbResultLink, calendarReceiptLink, HS_LIBRARY_RESULT_LINK, localResultLink, LIBRARY_RESULT_LINK, YOUTH_ENROLLED_LINK, YOUTH_PORTAL_LINK } from './result-links.mjs';
30
31
 
@@ -284,6 +285,9 @@ function feedItem(item) {
284
285
  return {
285
286
  id: item.id,
286
287
  source: item.source,
288
+ ...(item.category ? { category: item.category } : {}),
289
+ ...(item.intent ? { intent: item.intent } : {}),
290
+ ...(item.requiresRegistration !== undefined ? { requiresRegistration: item.requiresRegistration === true } : {}),
287
291
  title: item.title,
288
292
  url: clickableUrl(item.url),
289
293
  date: item.date ?? null,
@@ -292,7 +296,17 @@ function feedItem(item) {
292
296
  start: item.start ?? null,
293
297
  end: item.end ?? null,
294
298
  reason: item.reason ?? '',
295
- past: item.past === true
299
+ past: item.past === true,
300
+ ...(item.organizer ? { organizer: item.organizer } : {}),
301
+ ...(item.enrollmentRatio ? { enrollmentRatio: item.enrollmentRatio } : {}),
302
+ ...(item.remainingSlots !== undefined && item.remainingSlots !== null ? { remainingSlots: item.remainingSlots } : {}),
303
+ ...(item.hours !== undefined && item.hours !== null ? { hours: item.hours } : {}),
304
+ ...(item.youthItemId ? { youthItemId: item.youthItemId } : {}),
305
+ ...(item.registered !== undefined && item.registered !== null ? { registered: item.registered } : {}),
306
+ ...(Number.isFinite(item.score) ? { score: item.score } : {}),
307
+ ...(Array.isArray(item.topics) && item.topics.length ? { topics: item.topics } : {}),
308
+ ...(Array.isArray(item.channels) && item.channels.length ? { channels: item.channels } : {}),
309
+ ...(Array.isArray(item.alsoIn) && item.alsoIn.length ? { alsoIn: item.alsoIn } : {})
296
310
  };
297
311
  }
298
312
 
@@ -873,7 +887,7 @@ function registerTools(server) {
873
887
  {
874
888
  title: '科大公开资讯与资料',
875
889
  description:
876
- '检索科大公开资讯、校园活动及也西书架课程资料索引。查课程资料传 query,查校内通知/活动传 keyword/source/sort;可用 scope 只返回其中一类。',
890
+ '检索科大公开资讯(25 个官方来源,已登录时自动融合青春科大报名中二课活动及自定义订阅)、校园活动及也西书架课程资料索引。查课程资料传 query,查校内通知/活动传 keyword/source/category/intent/sort(推荐排序结合本地偏好与课表方向);可用 scope 只返回其中一类。',
877
891
  inputSchema: {
878
892
  scope: z.enum(['all', 'feed', 'materials']).optional().describe('查询范围:all、feed(仅校园资讯)或 materials(仅课程资料)'),
879
893
  query: z
@@ -882,8 +896,10 @@ function registerTools(server) {
882
896
  .optional()
883
897
  .describe('课程名或课号,用于查询也西书架公开资料索引'),
884
898
  keyword: z.string().max(120).optional().describe('资讯标题/地点关键词'),
885
- source: z.enum(Object.keys(FEED_SOURCES)).optional().describe('按具体来源筛选;省略则全部'),
886
- sort: z.enum(['time', 'recommended']).optional().describe('按时间或推荐排序'),
899
+ source: z.string().max(80).optional().describe('按具体来源筛选(如 news/teach/lug/youth-enrolling/custom:*);省略则全部'),
900
+ category: z.enum(FEED_CATEGORIES).optional().describe('按分类筛选(campus/academic/research/student/activity/lecture/tech/service/exchange/college)'),
901
+ intent: z.enum(['all', 'activity', 'notice']).optional().describe('按内容意图筛选:all(全部)、activity(活动/讲座/二课)或 notice(通知/新闻)'),
902
+ sort: z.enum(['time', 'recommended']).optional().describe('按时间或个性化推荐排序'),
887
903
  interests: z
888
904
  .array(z.string().max(64))
889
905
  .max(12)
@@ -898,35 +914,47 @@ function registerTools(server) {
898
914
  idempotentHint: true
899
915
  }
900
916
  },
901
- async ({ scope, query, keyword, source, sort, interests, offset = 0, limit = 10 }) => {
917
+ async ({ scope, query, keyword, source, category, intent, sort, interests, offset = 0, limit = 10 }) => {
902
918
  try {
903
- const store = getCampus();
904
919
  const hasQuery = typeof query === 'string' && Boolean(query.trim());
905
- const effectiveScope = scope ?? (hasQuery && !keyword && !source && !sort && !interests?.length ? 'materials' : 'all');
920
+ const effectiveScope = scope ?? (hasQuery && !keyword && !source && !category && !intent && !sort && !interests?.length ? 'materials' : 'all');
906
921
  const result = {
907
922
  timezone: 'Asia/Shanghai',
908
923
  feed: null,
909
924
  materials: null
910
925
  };
911
926
  if (effectiveScope !== 'materials') {
912
- let feed = store.queryFeed({ source, keyword, sort, interests });
913
- if (feed.sources.every(entry => entry.fetchedAt == null)) {
914
- await store.refresh();
915
- feed = store.queryFeed({ source, keyword, sort, interests });
927
+ const hostReply = await requestHost('feed-query', { source, category, intent, keyword, sort, interests, offset, limit });
928
+ if (hostReply.ok && hostReply.value && Array.isArray(hostReply.value.items)) {
929
+ result.feed = {
930
+ items: hostReply.value.items.map(feedItem),
931
+ total: hostReply.value.total,
932
+ offset: hostReply.value.offset,
933
+ nextOffset: hostReply.value.nextOffset,
934
+ truncated: hostReply.value.truncated,
935
+ sources: hostReply.value.sources
936
+ };
937
+ } else {
938
+ const store = getCampus();
939
+ let feed = store.queryFeed({ source, category, intent, keyword, sort, interests });
940
+ if (feed.sources.every(entry => entry.fetchedAt == null)) {
941
+ await store.refresh();
942
+ feed = store.queryFeed({ source, category, intent, keyword, sort, interests });
943
+ }
944
+ const from = Math.min(feed.items.length, Math.max(0, Math.trunc(offset)));
945
+ const items = feed.items.slice(from, from + limit).map(feedItem);
946
+ result.feed = {
947
+ items,
948
+ total: feed.items.length,
949
+ offset: from,
950
+ nextOffset: from + items.length < feed.items.length ? from + items.length : null,
951
+ truncated: from + items.length < feed.items.length,
952
+ sources: feed.sources
953
+ };
916
954
  }
917
- const from = Math.min(feed.items.length, Math.max(0, Math.trunc(offset)));
918
- const items = feed.items.slice(from, from + limit).map(feedItem);
919
- result.feed = {
920
- items,
921
- total: feed.items.length,
922
- offset: from,
923
- nextOffset: from + items.length < feed.items.length ? from + items.length : null,
924
- truncated: from + items.length < feed.items.length,
925
- sources: feed.sources
926
- };
927
955
  }
928
956
  if (effectiveScope !== 'feed' && hasQuery) {
929
- result.materials = materialsResult(await store.lookup(query.trim()));
957
+ result.materials = materialsResult(await getCampus().lookup(query.trim()));
930
958
  }
931
959
  return textResult(result);
932
960
  } catch {
@@ -934,6 +962,87 @@ function registerTools(server) {
934
962
  }
935
963
  }
936
964
  );
965
+
966
+ if (process.env.CAMPUS_MCP_FEED_FEEDBACK === '1') {
967
+ server.registerTool(
968
+ 'campus_feed_feedback',
969
+ {
970
+ title: '校园资讯推荐偏好与反馈',
971
+ description:
972
+ '记录对校园资讯的反馈(like/dislike/open/屏蔽或恢复来源或话题/设置兴趣词/重置)或查看当前学到的推荐偏好画像(action: profile)。',
973
+ inputSchema: {
974
+ action: z.enum([
975
+ 'like', 'dislike', 'open', 'impression',
976
+ 'mute_source', 'unmute_source',
977
+ 'mute_topic', 'unmute_topic',
978
+ 'set_interests', 'reset', 'profile'
979
+ ]).describe('操作类型'),
980
+ itemId: z.string().max(200).optional().describe('资讯 ID(用于 like/dislike/open)'),
981
+ itemIds: z.array(z.string().max(200)).max(30).optional().describe('批量曝光 ID(用于 impression)'),
982
+ dwellMs: z.number().int().min(0).max(3_600_000).optional().describe('阅读停留毫秒数(可选)'),
983
+ source: z.string().max(80).optional().describe('来源 ID(用于 mute_source/unmute_source)'),
984
+ topic: z.enum(TOPIC_IDS).optional().describe('话题 ID(用于 mute_topic/unmute_topic)'),
985
+ interests: z.array(z.string().max(64)).max(24).optional().describe('固定兴趣关键词列表(用于 set_interests)')
986
+ },
987
+ annotations: {
988
+ readOnlyHint: false,
989
+ openWorldHint: false,
990
+ idempotentHint: false
991
+ }
992
+ },
993
+ async (args) => {
994
+ if (args.action === 'profile') {
995
+ const reply = await requestHost('feed-profile', {});
996
+ if (reply.ok && reply.value) return textResult(reply.value);
997
+ return textResult(getCampus().feedProfile());
998
+ }
999
+ const reply = await requestHost('feed-feedback', args);
1000
+ if (reply.ok && reply.value) return textResult(reply.value);
1001
+ if (reply.code === 'invalid' && reply.message) return errorResult(reply.message);
1002
+ return textResult(getCampus().recordFeedFeedback(args));
1003
+ }
1004
+ );
1005
+
1006
+ server.registerTool(
1007
+ 'campus_custom_feeds',
1008
+ {
1009
+ title: '自定义校园 RSS / JSON 订阅源',
1010
+ description:
1011
+ '查看、添加或移除用户自定义的公开 RSS / Atom / 静态 JSON 订阅源(仅限 https:// 公开网址,可用于接入外部社团或公众号聚合源)。',
1012
+ inputSchema: {
1013
+ action: z.enum(['list', 'add', 'remove']).describe('操作类型'),
1014
+ id: z.string().max(100).optional().describe('订阅源 ID(用于 remove)'),
1015
+ label: z.string().max(80).optional().describe('显示名称(用于 add)'),
1016
+ url: z.string().max(500).optional().describe('订阅地址(必须 https:// 开头,用于 add)'),
1017
+ format: z.enum(['auto', 'xml', 'json']).optional().describe('订阅格式,默认 auto'),
1018
+ defaultIntent: z.enum(['auto', 'activity', 'notice']).optional().describe('默认意图分类,默认 auto'),
1019
+ category: z.string().max(32).optional().describe('分类名称,默认 activity')
1020
+ },
1021
+ annotations: {
1022
+ readOnlyHint: false,
1023
+ openWorldHint: true,
1024
+ idempotentHint: false
1025
+ }
1026
+ },
1027
+ async (args) => {
1028
+ if (args.action === 'list') {
1029
+ const reply = await requestHost('feed-custom-list', {});
1030
+ if (reply.ok) return textResult({ subscriptions: reply.value });
1031
+ return textResult({ subscriptions: getCampus().listCustomFeeds() });
1032
+ }
1033
+ if (args.action === 'add') {
1034
+ const reply = await requestHost('feed-custom-add', args);
1035
+ if (reply.ok) return textResult(reply.value);
1036
+ if (reply.code === 'invalid' && reply.message) return errorResult(reply.message);
1037
+ return textResult(getCampus().addCustomFeed(args));
1038
+ }
1039
+ const reply = await requestHost('feed-custom-remove', { id: args.id });
1040
+ if (reply.ok) return textResult(reply.value);
1041
+ if (reply.code === 'invalid' && reply.message) return errorResult(reply.message);
1042
+ return textResult(getCampus().removeCustomFeed({ id: args.id }));
1043
+ }
1044
+ );
1045
+ }
937
1046
  }
938
1047
 
939
1048
  async function main() {