@thanh01.pmt/research-kit 1.2.0 → 1.2.3
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/dist/academic/index.cjs +11 -2
- package/dist/academic/index.cjs.map +1 -1
- package/dist/academic/index.d.cts +3 -3
- package/dist/academic/index.d.ts +3 -3
- package/dist/academic/index.js +2 -1
- package/dist/{catalogBuilder-nrGYEY4b.d.cts → catalogBuilder-B4eiLS_S.d.cts} +27 -5
- package/dist/{catalogBuilder-2i5KASUF.d.ts → catalogBuilder-BNB_gaWP.d.ts} +27 -5
- package/dist/chunk-AKEI7H2C.js +223 -0
- package/dist/chunk-AKEI7H2C.js.map +1 -0
- package/dist/{chunk-X3X26W2I.js → chunk-HESXWQEF.js} +12 -7
- package/dist/chunk-HESXWQEF.js.map +1 -0
- package/dist/{chunk-QFYM2NV4.js → chunk-KXJDQBSJ.js} +3 -3
- package/dist/{chunk-QFYM2NV4.js.map → chunk-KXJDQBSJ.js.map} +1 -1
- package/dist/{chunk-XDDTHWJW.js → chunk-P6RHBJY2.js} +89 -25
- package/dist/chunk-P6RHBJY2.js.map +1 -0
- package/dist/{chunk-ON6VFCJO.js → chunk-QQZQNBJC.js} +51 -2
- package/dist/chunk-QQZQNBJC.js.map +1 -0
- package/dist/{chunk-QK3LVGI7.js → chunk-SAHBBO3U.js} +170 -8
- package/dist/chunk-SAHBBO3U.js.map +1 -0
- package/dist/{chunk-DOXSPRSP.js → chunk-SDDZFFL6.js} +14 -225
- package/dist/chunk-SDDZFFL6.js.map +1 -0
- package/dist/chunk-YICMTZS5.js +527 -0
- package/dist/chunk-YICMTZS5.js.map +1 -0
- package/dist/config/index.cjs +10 -5
- package/dist/config/index.cjs.map +1 -1
- package/dist/config/index.d.cts +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +1 -1
- package/dist/evidence/index.cjs.map +1 -1
- package/dist/evidence/index.d.cts +2 -2
- package/dist/evidence/index.d.ts +2 -2
- package/dist/evidence/index.js +2 -2
- package/dist/harvester/index.cjs +965 -6
- package/dist/harvester/index.cjs.map +1 -1
- package/dist/harvester/index.d.cts +87 -5
- package/dist/harvester/index.d.ts +87 -5
- package/dist/harvester/index.js +4 -3
- package/dist/{index-DlngvZBr.d.ts → index-9rDiFuR4.d.cts} +43 -12
- package/dist/{index-DlngvZBr.d.cts → index-9rDiFuR4.d.ts} +43 -12
- package/dist/index.cjs +852 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -11
- package/dist/index.d.ts +13 -11
- package/dist/index.js +21 -12
- package/dist/index.js.map +1 -1
- package/dist/{literatureReview-C7hsjrn4.d.cts → literatureReview-BwidpYJo.d.cts} +2 -1
- package/dist/{literatureReview-DWl13r_3.d.ts → literatureReview-DOzgm9Q2.d.ts} +2 -1
- package/dist/pipeline/index.cjs +545 -249
- package/dist/pipeline/index.cjs.map +1 -1
- package/dist/pipeline/index.d.cts +10 -4
- package/dist/pipeline/index.d.ts +10 -4
- package/dist/pipeline/index.js +6 -5
- package/dist/{webScraper-yO9P-oLb.d.cts → webScraper-CAQjE46m.d.cts} +11 -2
- package/dist/{webScraper-DBFUIqoO.d.ts → webScraper-CXIpvyA6.d.ts} +11 -2
- package/package.json +1 -1
- package/dist/chunk-DOXSPRSP.js.map +0 -1
- package/dist/chunk-LSMSIPTZ.js +0 -3
- package/dist/chunk-LSMSIPTZ.js.map +0 -1
- package/dist/chunk-ON6VFCJO.js.map +0 -1
- package/dist/chunk-QK3LVGI7.js.map +0 -1
- package/dist/chunk-X3X26W2I.js.map +0 -1
- package/dist/chunk-XDDTHWJW.js.map +0 -1
package/dist/harvester/index.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
3
5
|
// src/harvester/domainClassifier.ts
|
|
4
6
|
var HARDWARE_PATTERNS = [
|
|
5
7
|
/\b(esp32|esp8266|arduino|raspberry\s*pi|stm32|micro:?bit|mblock|makecode|lego|spike\s*prime|mindstorms|ev3|wedo|vex)\b/i,
|
|
@@ -106,19 +108,254 @@ function getExtractorsForDomain(domain) {
|
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
110
|
|
|
111
|
+
// src/academic/arxivClient.ts
|
|
112
|
+
var ArXivSearchEngine = class {
|
|
113
|
+
/**
|
|
114
|
+
* Search ArXiv repository using the public atom XML API
|
|
115
|
+
*/
|
|
116
|
+
async search(query, maxResults = 5) {
|
|
117
|
+
const papers = [];
|
|
118
|
+
try {
|
|
119
|
+
const url = `https://export.arxiv.org/api/query?search_query=all:${encodeURIComponent(query)}&start=0&max_results=${maxResults}&sortBy=relevance&sortOrder=descending`;
|
|
120
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(1e4) });
|
|
121
|
+
if (res.ok) {
|
|
122
|
+
const xmlText = await res.text();
|
|
123
|
+
const entryMatches = xmlText.match(/<entry>[\s\S]*?<\/entry>/g) || [];
|
|
124
|
+
for (const entry of entryMatches) {
|
|
125
|
+
const idMatch = entry.match(/<id>([\s\S]*?)<\/id>/);
|
|
126
|
+
const titleMatch = entry.match(/<title>([\s\S]*?)<\/title>/);
|
|
127
|
+
const summaryMatch = entry.match(/<summary>([\s\S]*?)<\/summary>/);
|
|
128
|
+
const publishedMatch = entry.match(/<published>(\d{4})/);
|
|
129
|
+
const authorMatches = [...entry.matchAll(/<author>\s*<name>([\s\S]*?)<\/name>/g)].map((m) => m[1]?.trim()).filter(Boolean);
|
|
130
|
+
const arxivUrl = idMatch ? idMatch[1]?.trim() : "";
|
|
131
|
+
const pdfUrl = arxivUrl ? arxivUrl.replace("/abs/", "/pdf/") + ".pdf" : void 0;
|
|
132
|
+
if (titleMatch) {
|
|
133
|
+
papers.push({
|
|
134
|
+
id: arxivUrl || `arxiv-${Math.random().toString(36).substring(7)}`,
|
|
135
|
+
title: titleMatch[1]?.trim().replace(/\s+/g, " ") || "Untitled ArXiv Paper",
|
|
136
|
+
abstract: summaryMatch ? summaryMatch[1]?.trim().replace(/\s+/g, " ") : "",
|
|
137
|
+
authors: authorMatches,
|
|
138
|
+
year: publishedMatch ? parseInt(publishedMatch[1], 10) : (/* @__PURE__ */ new Date()).getFullYear(),
|
|
139
|
+
citationCount: 0,
|
|
140
|
+
venue: "arXiv preprint",
|
|
141
|
+
url: arxivUrl,
|
|
142
|
+
pdfUrl,
|
|
143
|
+
fieldsOfStudy: ["Computer Science", "AI & Machine Learning"]
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
} catch (e) {
|
|
149
|
+
console.warn("[ArXivSearchEngine] ArXiv search failed:", e?.message || e);
|
|
150
|
+
}
|
|
151
|
+
return papers;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// src/academic/semanticScholar.ts
|
|
156
|
+
zod.z.object({
|
|
157
|
+
id: zod.z.string(),
|
|
158
|
+
title: zod.z.string(),
|
|
159
|
+
abstract: zod.z.string().optional(),
|
|
160
|
+
authors: zod.z.array(zod.z.string()).default([]),
|
|
161
|
+
year: zod.z.number().optional(),
|
|
162
|
+
citationCount: zod.z.number().default(0),
|
|
163
|
+
venue: zod.z.string().optional(),
|
|
164
|
+
doi: zod.z.string().optional(),
|
|
165
|
+
url: zod.z.string().optional(),
|
|
166
|
+
pdfUrl: zod.z.string().optional(),
|
|
167
|
+
tldr: zod.z.string().optional(),
|
|
168
|
+
fieldsOfStudy: zod.z.array(zod.z.string()).default([])
|
|
169
|
+
});
|
|
170
|
+
function reconstructOpenAlexAbstract(invertedIndex) {
|
|
171
|
+
if (!invertedIndex || typeof invertedIndex !== "object") return void 0;
|
|
172
|
+
const entries = Object.entries(invertedIndex);
|
|
173
|
+
if (entries.length === 0) return void 0;
|
|
174
|
+
let maxIndex = 0;
|
|
175
|
+
for (const [, positions] of entries) {
|
|
176
|
+
if (Array.isArray(positions)) {
|
|
177
|
+
for (const p of positions) {
|
|
178
|
+
if (typeof p === "number" && p > maxIndex) maxIndex = p;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (maxIndex > 5e3) maxIndex = 5e3;
|
|
183
|
+
const words = new Array(maxIndex + 1);
|
|
184
|
+
for (const [word, positions] of entries) {
|
|
185
|
+
if (Array.isArray(positions)) {
|
|
186
|
+
for (const p of positions) {
|
|
187
|
+
if (typeof p === "number" && p >= 0 && p <= maxIndex) {
|
|
188
|
+
words[p] = word;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const reconstructed = words.filter(Boolean).join(" ").trim();
|
|
194
|
+
return reconstructed.length > 0 ? reconstructed : void 0;
|
|
195
|
+
}
|
|
196
|
+
var AcademicSearchEngine = class {
|
|
197
|
+
apiKey;
|
|
198
|
+
allowEnvFallback;
|
|
199
|
+
customAdapter;
|
|
200
|
+
arxivEngine;
|
|
201
|
+
constructor(options = {}) {
|
|
202
|
+
this.arxivEngine = new ArXivSearchEngine();
|
|
203
|
+
if (typeof options === "string") {
|
|
204
|
+
this.apiKey = options;
|
|
205
|
+
this.allowEnvFallback = true;
|
|
206
|
+
} else {
|
|
207
|
+
this.allowEnvFallback = options.allowEnvFallback ?? true;
|
|
208
|
+
this.apiKey = options.apiKey || (this.allowEnvFallback ? process.env.SEMANTIC_SCHOLAR_API_KEY : void 0);
|
|
209
|
+
this.customAdapter = options.customAdapter;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
setCustomAdapter(adapter) {
|
|
213
|
+
this.customAdapter = adapter;
|
|
214
|
+
}
|
|
215
|
+
setApiKey(apiKey) {
|
|
216
|
+
this.apiKey = apiKey;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Search academic papers across Semantic Scholar with OpenAlex and ArXiv fallback or Custom Adapter
|
|
220
|
+
*/
|
|
221
|
+
async searchPapers(query, options = {}) {
|
|
222
|
+
const adapter = options.customAdapter || this.customAdapter;
|
|
223
|
+
if (adapter) {
|
|
224
|
+
try {
|
|
225
|
+
const customPapers = await adapter.searchPapers(query, { limit: options.limit, yearRange: options.yearRange });
|
|
226
|
+
if (Array.isArray(customPapers) && customPapers.length > 0) {
|
|
227
|
+
return customPapers;
|
|
228
|
+
}
|
|
229
|
+
} catch (e) {
|
|
230
|
+
console.warn("[AcademicSearchEngine] Custom academic adapter failed:", e?.message || e);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
const limit = options.limit ?? 5;
|
|
234
|
+
const papers = [];
|
|
235
|
+
const seenTitles = /* @__PURE__ */ new Set();
|
|
236
|
+
const pushUnique = (p) => {
|
|
237
|
+
const normTitle = p.title.toLowerCase().replace(/[^a-z0-9\u00C0-\u1EF9]+/g, "");
|
|
238
|
+
if (!normTitle || seenTitles.has(normTitle)) return;
|
|
239
|
+
seenTitles.add(normTitle);
|
|
240
|
+
papers.push(p);
|
|
241
|
+
};
|
|
242
|
+
try {
|
|
243
|
+
const apiKey = options.apiKey || this.apiKey;
|
|
244
|
+
const headers = { "Content-Type": "application/json" };
|
|
245
|
+
if (apiKey) {
|
|
246
|
+
headers["x-api-key"] = apiKey;
|
|
247
|
+
}
|
|
248
|
+
const params = new URLSearchParams({
|
|
249
|
+
query,
|
|
250
|
+
limit: limit.toString(),
|
|
251
|
+
fields: "paperId,title,abstract,authors,year,citationCount,venue,externalIds,url,openAccessPdf,tldr,fieldsOfStudy"
|
|
252
|
+
});
|
|
253
|
+
if (options.yearRange) {
|
|
254
|
+
params.append("year", options.yearRange);
|
|
255
|
+
}
|
|
256
|
+
const res = await fetch(`https://api.semanticscholar.org/graph/v1/paper/search?${params.toString()}`, {
|
|
257
|
+
headers,
|
|
258
|
+
signal: AbortSignal.timeout(6e3)
|
|
259
|
+
});
|
|
260
|
+
if (res.ok) {
|
|
261
|
+
const data = await res.json();
|
|
262
|
+
if (Array.isArray(data?.data)) {
|
|
263
|
+
for (const item of data.data) {
|
|
264
|
+
pushUnique({
|
|
265
|
+
id: item.paperId || `s2-${Math.random().toString(36).slice(2, 8)}`,
|
|
266
|
+
title: item.title || "Untitled",
|
|
267
|
+
abstract: item.abstract || void 0,
|
|
268
|
+
authors: Array.isArray(item.authors) ? item.authors.map((a) => a.name).filter(Boolean) : [],
|
|
269
|
+
year: item.year,
|
|
270
|
+
citationCount: item.citationCount || 0,
|
|
271
|
+
venue: item.venue || void 0,
|
|
272
|
+
doi: item.externalIds?.DOI,
|
|
273
|
+
url: item.url || (item.externalIds?.DOI ? `https://doi.org/${item.externalIds.DOI}` : void 0),
|
|
274
|
+
pdfUrl: item.openAccessPdf?.url,
|
|
275
|
+
tldr: item.tldr?.text,
|
|
276
|
+
fieldsOfStudy: Array.isArray(item.fieldsOfStudy) && item.fieldsOfStudy.length > 0 ? item.fieldsOfStudy : ["Computer Science"]
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
if (papers.length >= limit) return papers.slice(0, limit);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
} catch (e) {
|
|
283
|
+
console.warn("[AcademicSearchEngine] Semantic Scholar failed:", e?.message || e);
|
|
284
|
+
}
|
|
285
|
+
if (papers.length < limit) {
|
|
286
|
+
try {
|
|
287
|
+
const res = await fetch(`https://api.openalex.org/works?search=${encodeURIComponent(query)}&per-page=${limit}`, {
|
|
288
|
+
headers: { "User-Agent": "OrchableComposer/1.0 (mailto:team@orchable.app)" },
|
|
289
|
+
signal: AbortSignal.timeout(6e3)
|
|
290
|
+
});
|
|
291
|
+
if (res.ok) {
|
|
292
|
+
const data = await res.json();
|
|
293
|
+
if (Array.isArray(data?.results)) {
|
|
294
|
+
for (const item of data.results) {
|
|
295
|
+
const abstractText = reconstructOpenAlexAbstract(item.abstract_inverted_index);
|
|
296
|
+
const concepts = Array.isArray(item.concepts) ? item.concepts.slice(0, 3).map((c) => c.display_name).filter(Boolean) : ["Computer Science"];
|
|
297
|
+
pushUnique({
|
|
298
|
+
id: item.id || `oa-${Math.random().toString(36).slice(2, 8)}`,
|
|
299
|
+
title: item.title || "Untitled",
|
|
300
|
+
abstract: abstractText,
|
|
301
|
+
authors: Array.isArray(item.authorships) ? item.authorships.map((a) => a.author?.display_name).filter(Boolean) : [],
|
|
302
|
+
year: item.publication_year,
|
|
303
|
+
citationCount: item.cited_by_count || 0,
|
|
304
|
+
venue: item.primary_location?.source?.display_name,
|
|
305
|
+
doi: item.doi ? String(item.doi).replace(/^https?:\/\/doi\.org\//i, "") : void 0,
|
|
306
|
+
url: item.doi || item.id,
|
|
307
|
+
pdfUrl: item.open_access?.oa_url,
|
|
308
|
+
fieldsOfStudy: concepts.length > 0 ? concepts : ["Computer Science"]
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
} catch (e) {
|
|
314
|
+
console.warn("[AcademicSearchEngine] OpenAlex failed:", e?.message || e);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (papers.length < limit && options.includeArxivFallback !== false) {
|
|
318
|
+
try {
|
|
319
|
+
const arxivPapers = await this.arxivEngine.search(query, limit - papers.length);
|
|
320
|
+
for (const p of arxivPapers) {
|
|
321
|
+
pushUnique(p);
|
|
322
|
+
}
|
|
323
|
+
} catch (e) {
|
|
324
|
+
console.warn("[AcademicSearchEngine] ArXiv fallback failed:", e?.message || e);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return papers.slice(0, limit);
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
|
|
109
331
|
// src/harvester/multiSourceSearch.ts
|
|
110
332
|
var MultiSourceSearchEngine = class {
|
|
111
333
|
tavilyKey;
|
|
112
334
|
exaKey;
|
|
113
335
|
serperKey;
|
|
336
|
+
brightDataKey;
|
|
337
|
+
brightDataZone;
|
|
338
|
+
searxngHost;
|
|
339
|
+
searxngHeaders;
|
|
114
340
|
allowEnvFallback;
|
|
115
341
|
customAdapter;
|
|
342
|
+
academicEngine;
|
|
116
343
|
constructor(options = {}) {
|
|
117
344
|
this.allowEnvFallback = options.allowEnvFallback ?? true;
|
|
118
345
|
this.tavilyKey = options.apiKeys?.tavily || options.tavilyKey || (this.allowEnvFallback ? process.env.TAVILY_API_KEY : void 0);
|
|
119
346
|
this.exaKey = options.apiKeys?.exa || options.exaKey || (this.allowEnvFallback ? process.env.EXA_API_KEY : void 0);
|
|
120
347
|
this.serperKey = options.apiKeys?.serper || options.serperKey || (this.allowEnvFallback ? process.env.SERPER_API_KEY : void 0);
|
|
348
|
+
this.brightDataKey = options.apiKeys?.brightdata || options.apiKeys?.brightData || options.brightDataKey || (this.allowEnvFallback ? process.env.BRIGHTDATA_API_KEY || process.env.BRIGHT_DATA_KEY : void 0);
|
|
349
|
+
this.brightDataZone = options.brightDataZone || (this.allowEnvFallback ? process.env.BRIGHTDATA_SERP_ZONE || process.env.BRIGHTDATA_UNLOCKER_ZONE : void 0) || "cli_unlocker";
|
|
350
|
+
this.searxngHost = options.searxngHost || (this.allowEnvFallback ? process.env.SEARXNG_URL || process.env.SEARXNG_HOST : void 0);
|
|
351
|
+
const cfId = process.env.CF_ACCESS_CLIENT_ID;
|
|
352
|
+
const cfSecret = process.env.CF_ACCESS_CLIENT_SECRET;
|
|
353
|
+
this.searxngHeaders = {
|
|
354
|
+
...options.searxngHeaders || {},
|
|
355
|
+
...cfId && cfSecret ? { "CF-Access-Client-Id": cfId, "CF-Access-Client-Secret": cfSecret } : {}
|
|
356
|
+
};
|
|
121
357
|
this.customAdapter = options.customAdapter;
|
|
358
|
+
this.academicEngine = new AcademicSearchEngine({ allowEnvFallback: this.allowEnvFallback });
|
|
122
359
|
}
|
|
123
360
|
setCustomAdapter(adapter) {
|
|
124
361
|
this.customAdapter = adapter;
|
|
@@ -127,6 +364,18 @@ var MultiSourceSearchEngine = class {
|
|
|
127
364
|
if (keys.tavily !== void 0) this.tavilyKey = keys.tavily;
|
|
128
365
|
if (keys.exa !== void 0) this.exaKey = keys.exa;
|
|
129
366
|
if (keys.serper !== void 0) this.serperKey = keys.serper;
|
|
367
|
+
if (keys.brightdata !== void 0) this.brightDataKey = keys.brightdata;
|
|
368
|
+
if (keys.brightData !== void 0) this.brightDataKey = keys.brightData;
|
|
369
|
+
}
|
|
370
|
+
setBrightData(key, zone) {
|
|
371
|
+
if (key !== void 0) this.brightDataKey = key;
|
|
372
|
+
if (zone !== void 0) this.brightDataZone = zone;
|
|
373
|
+
}
|
|
374
|
+
setSearxng(host, headers) {
|
|
375
|
+
this.searxngHost = host;
|
|
376
|
+
if (headers) {
|
|
377
|
+
this.searxngHeaders = { ...this.searxngHeaders, ...headers };
|
|
378
|
+
}
|
|
130
379
|
}
|
|
131
380
|
async search(query, options = {}) {
|
|
132
381
|
const limit = options.limit ?? 5;
|
|
@@ -148,9 +397,39 @@ var MultiSourceSearchEngine = class {
|
|
|
148
397
|
console.warn("[MultiSourceSearchEngine] Custom search adapter failed:", e?.message || e);
|
|
149
398
|
}
|
|
150
399
|
}
|
|
400
|
+
if (preferred === "academic") {
|
|
401
|
+
try {
|
|
402
|
+
const papers = await this.academicEngine.searchPapers(query, { limit });
|
|
403
|
+
if (papers.length > 0) {
|
|
404
|
+
return papers.map((p) => ({
|
|
405
|
+
title: p.title,
|
|
406
|
+
url: p.url || p.pdfUrl || (p.doi ? `https://doi.org/${p.doi}` : `https://openalex.org/${p.id}`),
|
|
407
|
+
content: p.tldr || p.abstract || "",
|
|
408
|
+
score: p.citationCount,
|
|
409
|
+
engine: "academic"
|
|
410
|
+
}));
|
|
411
|
+
}
|
|
412
|
+
} catch (e) {
|
|
413
|
+
console.warn("[MultiSourceSearchEngine] Academic search failed:", e?.message || e);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
151
416
|
const tavilyKey = options.apiKeys?.tavily || options.tavilyKey || this.tavilyKey;
|
|
152
417
|
const exaKey = options.apiKeys?.exa || options.exaKey || this.exaKey;
|
|
153
418
|
const serperKey = options.apiKeys?.serper || options.serperKey || this.serperKey;
|
|
419
|
+
const brightDataKey = options.apiKeys?.brightdata || options.apiKeys?.brightData || options.brightDataKey || this.brightDataKey;
|
|
420
|
+
const brightDataZone = options.brightDataZone || this.brightDataZone;
|
|
421
|
+
const searxngHost = options.searxngHost || this.searxngHost;
|
|
422
|
+
if (preferred === "searxng" && searxngHost) {
|
|
423
|
+
const searxHits = await this.querySearxng(query, searxngHost, limit, options.searxngHeaders);
|
|
424
|
+
if (searxHits.length > 0) return searxHits;
|
|
425
|
+
}
|
|
426
|
+
if (preferred === "brightdata" && brightDataKey) {
|
|
427
|
+
const bdHits = await this.queryBrightData(query, brightDataKey, limit, {
|
|
428
|
+
zone: brightDataZone,
|
|
429
|
+
engine: options.brightDataEngine
|
|
430
|
+
});
|
|
431
|
+
if (bdHits.length > 0) return bdHits;
|
|
432
|
+
}
|
|
154
433
|
if (preferred === "exa" && exaKey) {
|
|
155
434
|
const exaHits = await this.queryExa(query, exaKey, limit, options.domainFilter);
|
|
156
435
|
if (exaHits.length > 0) return exaHits;
|
|
@@ -172,6 +451,9 @@ var MultiSourceSearchEngine = class {
|
|
|
172
451
|
include_answer: true,
|
|
173
452
|
max_results: limit
|
|
174
453
|
};
|
|
454
|
+
if (options.timeRange) {
|
|
455
|
+
body.time_range = options.timeRange;
|
|
456
|
+
}
|
|
175
457
|
if (options.domainFilter && options.domainFilter.length > 0) {
|
|
176
458
|
body.include_domains = options.domainFilter;
|
|
177
459
|
}
|
|
@@ -198,18 +480,103 @@ var MultiSourceSearchEngine = class {
|
|
|
198
480
|
}
|
|
199
481
|
}
|
|
200
482
|
if (exaKey) {
|
|
201
|
-
const exaHits = await this.queryExa(query, exaKey, limit, options.domainFilter);
|
|
483
|
+
const exaHits = await this.queryExa(query, exaKey, limit, options.domainFilter, options.timeRange);
|
|
202
484
|
if (exaHits.length > 0) return exaHits;
|
|
203
485
|
}
|
|
204
486
|
if (serperKey) {
|
|
205
|
-
const serperHits = await this.querySerper(query, serperKey, limit);
|
|
487
|
+
const serperHits = await this.querySerper(query, serperKey, limit, options.timeRange);
|
|
206
488
|
if (serperHits.length > 0) return serperHits;
|
|
207
489
|
}
|
|
490
|
+
if (brightDataKey) {
|
|
491
|
+
const bdHits = await this.queryBrightData(query, brightDataKey, limit, {
|
|
492
|
+
zone: brightDataZone,
|
|
493
|
+
engine: options.brightDataEngine
|
|
494
|
+
});
|
|
495
|
+
if (bdHits.length > 0) return bdHits;
|
|
496
|
+
}
|
|
497
|
+
if (searxngHost) {
|
|
498
|
+
const searxHits = await this.querySearxng(query, searxngHost, limit, options.searxngHeaders, options.timeRange);
|
|
499
|
+
if (searxHits.length > 0) return searxHits;
|
|
500
|
+
}
|
|
208
501
|
const ddgHits = await this.queryDuckDuckGo(query, limit);
|
|
209
502
|
if (ddgHits.length > 0) return ddgHits;
|
|
210
503
|
return [];
|
|
211
504
|
}
|
|
212
|
-
async
|
|
505
|
+
async queryBrightData(query, key, limit = 5, options = {}) {
|
|
506
|
+
try {
|
|
507
|
+
const zone = options.zone || this.brightDataZone || "cli_unlocker";
|
|
508
|
+
const engine = options.engine || "bing";
|
|
509
|
+
let searchUrl = `https://www.bing.com/search?q=${encodeURIComponent(query)}&brd_json=1`;
|
|
510
|
+
if (engine === "google") {
|
|
511
|
+
searchUrl = `https://www.google.com/search?q=${encodeURIComponent(query)}&brd_json=1&hl=en&gl=us`;
|
|
512
|
+
} else if (engine === "yandex") {
|
|
513
|
+
searchUrl = `https://www.yandex.com/search?q=${encodeURIComponent(query)}&brd_json=1`;
|
|
514
|
+
}
|
|
515
|
+
const res = await fetch("https://api.brightdata.com/request", {
|
|
516
|
+
method: "POST",
|
|
517
|
+
headers: {
|
|
518
|
+
Authorization: `Bearer ${key}`,
|
|
519
|
+
"Content-Type": "application/json"
|
|
520
|
+
},
|
|
521
|
+
body: JSON.stringify({
|
|
522
|
+
zone,
|
|
523
|
+
url: searchUrl,
|
|
524
|
+
format: "raw"
|
|
525
|
+
}),
|
|
526
|
+
signal: AbortSignal.timeout(15e3)
|
|
527
|
+
});
|
|
528
|
+
if (res.ok) {
|
|
529
|
+
const data = await res.json();
|
|
530
|
+
const organic = Array.isArray(data?.organic) ? data.organic : [];
|
|
531
|
+
if (organic.length > 0) {
|
|
532
|
+
return organic.slice(0, limit).map((r, idx) => ({
|
|
533
|
+
title: r.title || "Untitled",
|
|
534
|
+
url: r.link,
|
|
535
|
+
content: r.description || r.snippet || "",
|
|
536
|
+
score: r.rank ? 1 / r.rank : 1 / (idx + 1),
|
|
537
|
+
engine: "brightdata"
|
|
538
|
+
}));
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
} catch (e) {
|
|
542
|
+
console.warn("[MultiSourceSearchEngine] Bright Data attempt failed:", e?.message || e);
|
|
543
|
+
}
|
|
544
|
+
return [];
|
|
545
|
+
}
|
|
546
|
+
async querySearxng(query, searxngHost, limit, customHeaders, timeRange) {
|
|
547
|
+
try {
|
|
548
|
+
const cleanHost = searxngHost.replace(/\/$/, "");
|
|
549
|
+
let searchUrl = `${cleanHost}/search?q=${encodeURIComponent(query)}&format=json`;
|
|
550
|
+
if (timeRange) {
|
|
551
|
+
searchUrl += `&time_range=${encodeURIComponent(timeRange)}`;
|
|
552
|
+
}
|
|
553
|
+
const headers = {
|
|
554
|
+
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)",
|
|
555
|
+
...this.searxngHeaders || {},
|
|
556
|
+
...customHeaders || {}
|
|
557
|
+
};
|
|
558
|
+
const res = await fetch(searchUrl, {
|
|
559
|
+
headers,
|
|
560
|
+
signal: AbortSignal.timeout(1e4)
|
|
561
|
+
});
|
|
562
|
+
if (res.ok) {
|
|
563
|
+
const data = await res.json();
|
|
564
|
+
if (Array.isArray(data?.results) && data.results.length > 0) {
|
|
565
|
+
return data.results.slice(0, limit).map((r) => ({
|
|
566
|
+
title: r.title || "Untitled",
|
|
567
|
+
url: r.url,
|
|
568
|
+
content: r.content || r.snippet || "",
|
|
569
|
+
score: r.score,
|
|
570
|
+
engine: "searxng"
|
|
571
|
+
}));
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
} catch (e) {
|
|
575
|
+
console.warn("[MultiSourceSearchEngine] SearXNG attempt failed:", e?.message || e);
|
|
576
|
+
}
|
|
577
|
+
return [];
|
|
578
|
+
}
|
|
579
|
+
async queryExa(query, exaKey, limit, domainFilter, timeRange) {
|
|
213
580
|
try {
|
|
214
581
|
const body = {
|
|
215
582
|
query,
|
|
@@ -219,6 +586,14 @@ var MultiSourceSearchEngine = class {
|
|
|
219
586
|
if (domainFilter && domainFilter.length > 0) {
|
|
220
587
|
body.includeDomains = domainFilter;
|
|
221
588
|
}
|
|
589
|
+
if (timeRange) {
|
|
590
|
+
const now = /* @__PURE__ */ new Date();
|
|
591
|
+
if (timeRange === "day") now.setDate(now.getDate() - 1);
|
|
592
|
+
else if (timeRange === "week") now.setDate(now.getDate() - 7);
|
|
593
|
+
else if (timeRange === "month") now.setMonth(now.getMonth() - 1);
|
|
594
|
+
else if (timeRange === "year") now.setFullYear(now.getFullYear() - 1);
|
|
595
|
+
body.startPublishedDate = now.toISOString();
|
|
596
|
+
}
|
|
222
597
|
const res = await fetch("https://api.exa.ai/search", {
|
|
223
598
|
method: "POST",
|
|
224
599
|
headers: {
|
|
@@ -245,15 +620,22 @@ var MultiSourceSearchEngine = class {
|
|
|
245
620
|
}
|
|
246
621
|
return [];
|
|
247
622
|
}
|
|
248
|
-
async querySerper(query, serperKey, limit) {
|
|
623
|
+
async querySerper(query, serperKey, limit, timeRange) {
|
|
249
624
|
try {
|
|
625
|
+
const body = { q: query, num: limit };
|
|
626
|
+
if (timeRange) {
|
|
627
|
+
const tbsMap = { day: "qdr:d", week: "qdr:w", month: "qdr:m", year: "qdr:y" };
|
|
628
|
+
if (tbsMap[timeRange]) {
|
|
629
|
+
body.tbs = tbsMap[timeRange];
|
|
630
|
+
}
|
|
631
|
+
}
|
|
250
632
|
const res = await fetch("https://google.serper.dev/search", {
|
|
251
633
|
method: "POST",
|
|
252
634
|
headers: {
|
|
253
635
|
"X-API-KEY": serperKey,
|
|
254
636
|
"Content-Type": "application/json"
|
|
255
637
|
},
|
|
256
|
-
body: JSON.stringify(
|
|
638
|
+
body: JSON.stringify(body),
|
|
257
639
|
signal: AbortSignal.timeout(1e4)
|
|
258
640
|
});
|
|
259
641
|
if (res.ok) {
|
|
@@ -502,6 +884,8 @@ function extractSubstantiveExcerpts(markdown, maxExcerpts = 6) {
|
|
|
502
884
|
var WebScraper = class {
|
|
503
885
|
crawl4aiHost;
|
|
504
886
|
jinaKey;
|
|
887
|
+
brightDataKey;
|
|
888
|
+
brightDataZone;
|
|
505
889
|
allowEnvFallback;
|
|
506
890
|
customAdapter;
|
|
507
891
|
youtubeService;
|
|
@@ -509,6 +893,8 @@ var WebScraper = class {
|
|
|
509
893
|
this.allowEnvFallback = options.allowEnvFallback ?? true;
|
|
510
894
|
this.crawl4aiHost = options.crawl4aiHost || (this.allowEnvFallback ? process.env.CRAWL4AI_HOST : void 0) || "http://localhost:11235";
|
|
511
895
|
this.jinaKey = options.jinaKey || (this.allowEnvFallback ? process.env.JINA_API_KEY : void 0);
|
|
896
|
+
this.brightDataKey = options.brightDataKey || (this.allowEnvFallback ? process.env.BRIGHTDATA_API_KEY || process.env.BRIGHT_DATA_KEY : void 0);
|
|
897
|
+
this.brightDataZone = options.brightDataZone || (this.allowEnvFallback ? process.env.BRIGHTDATA_UNLOCKER_ZONE : void 0) || "cli_unlocker";
|
|
512
898
|
this.customAdapter = options.customAdapter;
|
|
513
899
|
this.youtubeService = new YouTubeIngestionService();
|
|
514
900
|
}
|
|
@@ -518,8 +904,15 @@ var WebScraper = class {
|
|
|
518
904
|
setJinaKey(key) {
|
|
519
905
|
this.jinaKey = key;
|
|
520
906
|
}
|
|
907
|
+
setBrightData(key, zone) {
|
|
908
|
+
if (key !== void 0) this.brightDataKey = key;
|
|
909
|
+
if (zone !== void 0) this.brightDataZone = zone;
|
|
910
|
+
}
|
|
521
911
|
async scrapeUrl(targetUrl, options = {}) {
|
|
522
912
|
const adapter = options.customAdapter || this.customAdapter;
|
|
913
|
+
const bdKey = options.brightDataKey || this.brightDataKey;
|
|
914
|
+
const bdZone = options.brightDataZone || this.brightDataZone;
|
|
915
|
+
const preferred = options.preferredProvider;
|
|
523
916
|
if (adapter) {
|
|
524
917
|
try {
|
|
525
918
|
const result = await adapter.crawl(targetUrl);
|
|
@@ -540,6 +933,13 @@ var WebScraper = class {
|
|
|
540
933
|
console.warn(`[WebScraper] YouTube transcript extraction failed for ${targetUrl}:`, e?.message || e);
|
|
541
934
|
}
|
|
542
935
|
}
|
|
936
|
+
if (preferred === "brightdata" && bdKey) {
|
|
937
|
+
try {
|
|
938
|
+
return await this.scrapeWithBrightData(targetUrl, bdKey, bdZone);
|
|
939
|
+
} catch (e) {
|
|
940
|
+
console.warn(`[WebScraper] Preferred Bright Data failed for ${targetUrl}:`, e?.message || e);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
543
943
|
try {
|
|
544
944
|
const jinaUrl = `https://r.jina.ai/${targetUrl}`;
|
|
545
945
|
const jinaKey = options.jinaKey || this.jinaKey;
|
|
@@ -584,6 +984,13 @@ var WebScraper = class {
|
|
|
584
984
|
} catch {
|
|
585
985
|
}
|
|
586
986
|
}
|
|
987
|
+
if (bdKey) {
|
|
988
|
+
try {
|
|
989
|
+
return await this.scrapeWithBrightData(targetUrl, bdKey, bdZone);
|
|
990
|
+
} catch (e) {
|
|
991
|
+
console.warn(`[WebScraper] Bright Data fallback failed for ${targetUrl}:`, e?.message || e);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
587
994
|
try {
|
|
588
995
|
const res = await fetch(targetUrl, {
|
|
589
996
|
headers: { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)" },
|
|
@@ -608,6 +1015,30 @@ ${p.replace(/<[^>]+>/g, " ").trim()}
|
|
|
608
1015
|
}
|
|
609
1016
|
throw new Error(`Unable to fetch content from URL: ${targetUrl}`);
|
|
610
1017
|
}
|
|
1018
|
+
async scrapeWithBrightData(targetUrl, key, zone) {
|
|
1019
|
+
const reqZone = zone || this.brightDataZone || "cli_unlocker";
|
|
1020
|
+
const res = await fetch("https://api.brightdata.com/request", {
|
|
1021
|
+
method: "POST",
|
|
1022
|
+
headers: {
|
|
1023
|
+
Authorization: `Bearer ${key}`,
|
|
1024
|
+
"Content-Type": "application/json"
|
|
1025
|
+
},
|
|
1026
|
+
body: JSON.stringify({
|
|
1027
|
+
zone: reqZone,
|
|
1028
|
+
url: targetUrl,
|
|
1029
|
+
format: "raw",
|
|
1030
|
+
data_format: "markdown"
|
|
1031
|
+
}),
|
|
1032
|
+
signal: AbortSignal.timeout(2e4)
|
|
1033
|
+
});
|
|
1034
|
+
if (res.ok) {
|
|
1035
|
+
const markdown = await res.text();
|
|
1036
|
+
if (markdown && markdown.length > 30) {
|
|
1037
|
+
return this.packageDocument(targetUrl, markdown, "brightdata");
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
throw new Error(`Bright Data Web Unlocker failed with HTTP ${res.status}`);
|
|
1041
|
+
}
|
|
611
1042
|
packageDocument(url, markdown, provider, explicitTitle) {
|
|
612
1043
|
const titleMatch = markdown.match(/^#\s+(.+)$/m) || markdown.match(/^Title:\s*(.+)$/im);
|
|
613
1044
|
const title = (explicitTitle || (titleMatch ? titleMatch[1].trim() : url.split("/").filter(Boolean).pop() || "Document")).slice(0, 180);
|
|
@@ -1162,7 +1593,7 @@ ${corpusPreview}`,
|
|
|
1162
1593
|
`
|
|
1163
1594
|
Return ONLY a valid JSON array of 6 to 12 atomic pedagogical concepts ordered from foundational to advanced.`,
|
|
1164
1595
|
`IMPORTANT FOR VIETNAMESE TERMS: Keep multi-syllable Vietnamese compound terms intact (e.g. "Bi\u1EBFn tr\u1EA1ng th\xE1i", "C\u1EA3m bi\u1EBFn \xE1nh s\xE1ng", "V\xF2ng l\u1EB7p s\u1EF1 ki\u1EC7n") and pair them with accurate English canonical terms.`,
|
|
1165
|
-
`Each item in the JSON array must have: {"id": "C_01", "term": "Display Name", "termVi": "Thu\u1EADt ng\u1EEF Ti\u1EBFng Vi\u1EC7t chu\u1EA9n", "termEn": "Canonical English Term", "category": "core_concept"|"api_syntax"|"hardware_component"|"pedagogical_pattern", "marrLayer": "ULO"|"CIO"|"SIO", "bloomLevel": "understand"|"apply"|"analyze", "salienceScore": 9.0, "definition": "1-sentence clear definition grounded in sources", "prerequisites": ["C_01"], "sourceIds": ["RES-01"], "facets": {"computationalPrinciple": "...", "mentalModel": "...", "syntaxAndTools": ["..."]}, "commonMisconceptions": ["..."]}`
|
|
1596
|
+
`Each item in the JSON array must have: {"id": "C_01", "term": "Display Name", "termVi": "Thu\u1EADt ng\u1EEF Ti\u1EBFng Vi\u1EC7t chu\u1EA9n", "termEn": "Canonical English Term", "category": "core_concept"|"api_syntax"|"hardware_component"|"pedagogical_pattern", "marrLayer": "ULO"|"CIO"|"SIO", "bloomLevel": "understand"|"apply"|"analyze", "salienceScore": 9.0, "definition": "1-sentence clear definition grounded in sources", "prerequisites": ["C_01"], "sourceIds": ["RES-01"], "facets": {"computationalPrinciple": "...", "mentalModel": "...", "syntaxAndTools": ["..."]}, "commonMisconceptions": ["..."], "troubleshootingHints": ["2-minute quick fix for common student pitfall"]}`
|
|
1166
1597
|
].filter(Boolean).join("\n");
|
|
1167
1598
|
const rawResponse = await options.llm(prompt, {
|
|
1168
1599
|
system: "You are a Principal Computer Science Curriculum Architect & Bilingual Terminology Specialist (Vietnamese-English). Output strictly valid JSON array without markdown commentary.",
|
|
@@ -1362,12 +1793,540 @@ var HealthAuditor = class {
|
|
|
1362
1793
|
}
|
|
1363
1794
|
};
|
|
1364
1795
|
|
|
1796
|
+
// src/harvester/stemResources.ts
|
|
1797
|
+
var PHET_SIMULATIONS = [
|
|
1798
|
+
{
|
|
1799
|
+
id: "phet-circuit-construction-kit-dc",
|
|
1800
|
+
titleEn: "Circuit Construction Kit: DC",
|
|
1801
|
+
titleVi: "B\u1ED9 L\u1EAFp R\xE1p M\u1EA1ch \u0110i\u1EC7n M\u1ED9t Chi\u1EC1u (DC)",
|
|
1802
|
+
descriptionEn: "Build circuits with batteries, light bulbs, resistors, switches, and conductors. Measure voltage and current with voltmeter and ammeter.",
|
|
1803
|
+
descriptionVi: "X\xE2y d\u1EF1ng m\u1EA1ch \u0111i\u1EC7n m\u1ED9t chi\u1EC1u v\u1EDBi pin, b\xF3ng \u0111\xE8n, \u0111i\u1EC7n tr\u1EDF, c\xF4ng t\u1EAFc. \u0110o \u0111i\u1EC7n \xE1p v\xE0 d\xF2ng \u0111i\u1EC7n b\u1EB1ng v\xF4n k\u1EBF v\xE0 ampe k\u1EBF.",
|
|
1804
|
+
simUrl: "https://phet.colorado.edu/sims/html/circuit-construction-kit-dc/latest/circuit-construction-kit-dc_all.html",
|
|
1805
|
+
thumbnailUrl: "https://phet.colorado.edu/sims/html/circuit-construction-kit-dc/latest/circuit-construction-kit-dc-600.png",
|
|
1806
|
+
subject: "electronics",
|
|
1807
|
+
targetLevel: "all",
|
|
1808
|
+
keywords: ["circuit", "m\u1EA1ch \u0111i\u1EC7n", "\u0111i\u1EC7n tr\u1EDF", "resistor", "pin", "battery", "led", "voltage", "current", "d\xF2ng \u0111i\u1EC7n", "hi\u1EC7u \u0111i\u1EC7n th\u1EBF", "ohm", "\u0111o \u0111i\u1EC7n"]
|
|
1809
|
+
},
|
|
1810
|
+
{
|
|
1811
|
+
id: "phet-wave-on-a-string",
|
|
1812
|
+
titleEn: "Wave on a String",
|
|
1813
|
+
titleVi: "S\xF3ng Tr\xEAn D\xE2y",
|
|
1814
|
+
descriptionEn: "Simulate mechanical wave pulse and periodic oscillations. Adjust frequency, amplitude, tension, and damping.",
|
|
1815
|
+
descriptionVi: "M\xF4 ph\u1ECFng s\xF3ng c\u01A1 h\u1ECDc tr\xEAn d\xE2y. \u0110i\u1EC1u ch\u1EC9nh t\u1EA7n s\u1ED1, bi\xEAn \u0111\u1ED9, l\u1EF1c c\u0103ng v\xE0 \u0111\u1ED9 suy gi\u1EA3m.",
|
|
1816
|
+
simUrl: "https://phet.colorado.edu/sims/html/wave-on-a-string/latest/wave-on-a-string_all.html",
|
|
1817
|
+
thumbnailUrl: "https://phet.colorado.edu/sims/html/wave-on-a-string/latest/wave-on-a-string-600.png",
|
|
1818
|
+
subject: "physics",
|
|
1819
|
+
targetLevel: "lower_secondary",
|
|
1820
|
+
keywords: ["wave", "s\xF3ng", "t\u1EA7n s\u1ED1", "frequency", "bi\xEAn \u0111\u1ED9", "amplitude", "sound", "\xE2m thanh", "si\xEAu \xE2m", "ultrasonic"]
|
|
1821
|
+
},
|
|
1822
|
+
{
|
|
1823
|
+
id: "phet-balloons-and-static-electricity",
|
|
1824
|
+
titleEn: "Balloons and Static Electricity",
|
|
1825
|
+
titleVi: "B\xF3ng Bay v\xE0 T\u0129nh \u0110i\u1EC7n",
|
|
1826
|
+
descriptionEn: "Explore electrical charges, attraction, repulsion, and static electricity by rubbing a balloon on a sweater.",
|
|
1827
|
+
descriptionVi: "Kh\xE1m ph\xE1 \u0111i\u1EC7n t\xEDch, l\u1EF1c h\xFAt, l\u1EF1c \u0111\u1EA9y v\xE0 hi\u1EC7n t\u01B0\u1EE3ng t\u0129nh \u0111i\u1EC7n qua qu\u1EA3 b\xF3ng bay v\xE0 \xE1o len.",
|
|
1828
|
+
simUrl: "https://phet.colorado.edu/sims/html/balloons-and-static-electricity/latest/balloons-and-static-electricity_all.html",
|
|
1829
|
+
thumbnailUrl: "https://phet.colorado.edu/sims/html/balloons-and-static-electricity/latest/balloons-and-static-electricity-600.png",
|
|
1830
|
+
subject: "physics",
|
|
1831
|
+
targetLevel: "primary",
|
|
1832
|
+
keywords: ["static electricity", "t\u0129nh \u0111i\u1EC7n", "\u0111i\u1EC7n t\xEDch", "electron", "charge", "l\u1EF1c \u0111i\u1EC7n", "h\xFAt \u0111\u1EA9y"]
|
|
1833
|
+
},
|
|
1834
|
+
{
|
|
1835
|
+
id: "phet-faradays-law",
|
|
1836
|
+
titleEn: "Faraday's Law & Electromagnetic Induction",
|
|
1837
|
+
titleVi: "\u0110\u1ECBnh Lu\u1EADt Faraday & C\u1EA3m \u1EE8ng \u0110i\u1EC7n T\u1EEB",
|
|
1838
|
+
descriptionEn: "Move a bar magnet through a coil of wire to generate an electric current and illuminate a bulb. Observe magnet direction and voltage.",
|
|
1839
|
+
descriptionVi: "Di chuy\u1EC3n nam ch\xE2m qua cu\u1ED9n d\xE2y \u0111\u1EC3 t\u1EA1o ra d\xF2ng \u0111i\u1EC7n c\u1EA3m \u1EE9ng l\xE0m s\xE1ng b\xF3ng \u0111\xE8n. Quan s\xE1t chi\u1EC1u d\xF2ng \u0111i\u1EC7n v\xE0 c\u1EF1c t\u1EEB.",
|
|
1840
|
+
simUrl: "https://phet.colorado.edu/sims/html/faradays-law/latest/faradays-law_all.html",
|
|
1841
|
+
thumbnailUrl: "https://phet.colorado.edu/sims/html/faradays-law/latest/faradays-law-600.png",
|
|
1842
|
+
subject: "electronics",
|
|
1843
|
+
targetLevel: "upper_secondary",
|
|
1844
|
+
keywords: ["faraday", "c\u1EA3m \u1EE9ng \u0111i\u1EC7n t\u1EEB", "nam ch\xE2m", "magnet", "cu\u1ED9n d\xE2y", "coil", "\u0111\u1ED9ng c\u01A1", "motor", "m\xE1y ph\xE1t \u0111i\u1EC7n", "generator"]
|
|
1845
|
+
},
|
|
1846
|
+
{
|
|
1847
|
+
id: "phet-color-vision",
|
|
1848
|
+
titleEn: "Color Vision (RGB & Light Filters)",
|
|
1849
|
+
titleVi: "Th\u1ECB Gi\xE1c M\xE0u (Ph\u1ED1i M\xE0u RGB & B\u1ED9 L\u1ECDc \xC1nh S\xE1ng)",
|
|
1850
|
+
descriptionEn: "Combine red, green, and blue light sources to create full spectrum colors. Ideal for teaching RGB LEDs, sensors, and display screens.",
|
|
1851
|
+
descriptionVi: "K\u1EBFt h\u1EE3p c\xE1c ngu\u1ED3n s\xE1ng \u0110\u1ECF (Red), Xanh l\u1EE5c (Green), Xanh lam (Blue) \u0111\u1EC3 t\u1EA1o ra c\xE1c d\u1EA3i m\xE0u. R\u1EA5t ph\xF9 h\u1EE3p khi d\u1EA1y LED RGB v\xE0 c\u1EA3m bi\u1EBFn m\xE0u.",
|
|
1852
|
+
simUrl: "https://phet.colorado.edu/sims/html/color-vision/latest/color-vision_all.html",
|
|
1853
|
+
thumbnailUrl: "https://phet.colorado.edu/sims/html/color-vision/latest/color-vision-600.png",
|
|
1854
|
+
subject: "physics",
|
|
1855
|
+
targetLevel: "all",
|
|
1856
|
+
keywords: ["color", "m\xE0u s\u1EAFc", "rgb", "led rgb", "\xE1nh s\xE1ng", "light", "c\u1EA3m bi\u1EBFn \xE1nh s\xE1ng", "ldr", "quang h\u1ECDc", "optics"]
|
|
1857
|
+
},
|
|
1858
|
+
{
|
|
1859
|
+
id: "phet-forces-and-motion-basics",
|
|
1860
|
+
titleEn: "Forces and Motion: Basics",
|
|
1861
|
+
titleVi: "L\u1EF1c v\xE0 Chuy\u1EC3n \u0110\u1ED9ng C\u01A1 B\u1EA3n",
|
|
1862
|
+
descriptionEn: "Explore the forces at work when tugging a crate, sliding on ice, or pushing objects. Observe friction, acceleration, and Newton laws.",
|
|
1863
|
+
descriptionVi: "Kh\xE1m ph\xE1 c\xE1c l\u1EF1c t\xE1c d\u1EE5ng khi k\xE9o th\xF9ng h\xE0ng, ma s\xE1t, gia t\u1ED1c v\xE0 \u0111\u1ECBnh lu\u1EADt Newton. C\u1ED1t l\xF5i cho robot di \u0111\u1ED9ng v\xE0 xe t\u1EF1 h\xE0nh.",
|
|
1864
|
+
simUrl: "https://phet.colorado.edu/sims/html/forces-and-motion-basics/latest/forces-and-motion-basics_all.html",
|
|
1865
|
+
thumbnailUrl: "https://phet.colorado.edu/sims/html/forces-and-motion-basics/latest/forces-and-motion-basics-600.png",
|
|
1866
|
+
subject: "physics",
|
|
1867
|
+
targetLevel: "all",
|
|
1868
|
+
keywords: ["force", "l\u1EF1c", "motion", "chuy\u1EC3n \u0111\u1ED9ng", "friction", "ma s\xE1t", "robotics", "xe t\u1EF1 h\xE0nh", "newton", "v\u1EADn t\u1ED1c", "gia t\u1ED1c"]
|
|
1869
|
+
},
|
|
1870
|
+
{
|
|
1871
|
+
id: "phet-gravity-and-orbits",
|
|
1872
|
+
titleEn: "Gravity and Orbits",
|
|
1873
|
+
titleVi: "L\u1EF1c H\u1EA5p D\u1EABn v\xE0 Qu\u1EF9 \u0110\u1EA1o V\u1EC7 Tinh",
|
|
1874
|
+
descriptionEn: "Move the sun, earth, moon and space station to see how gravity controls orbital velocity and gravitational pull.",
|
|
1875
|
+
descriptionVi: "Di chuy\u1EC3n M\u1EB7t Tr\u1EDDi, Tr\xE1i \u0110\u1EA5t, M\u1EB7t Tr\u0103ng v\xE0 tr\u1EA1m kh\xF4ng gian \u0111\u1EC3 xem l\u1EF1c h\u1EA5p d\u1EABn \u0111i\u1EC1u khi\u1EC3n qu\u1EF9 \u0111\u1EA1o v\xE0 v\u1EADn t\u1ED1c.",
|
|
1876
|
+
simUrl: "https://phet.colorado.edu/sims/html/gravity-and-orbits/latest/gravity-and-orbits_all.html",
|
|
1877
|
+
thumbnailUrl: "https://phet.colorado.edu/sims/html/gravity-and-orbits/latest/gravity-and-orbits-600.png",
|
|
1878
|
+
subject: "physics",
|
|
1879
|
+
targetLevel: "lower_secondary",
|
|
1880
|
+
keywords: ["gravity", "tr\u1ECDng l\u1EF1c", "l\u1EF1c h\u1EA5p d\u1EABn", "qu\u1EF9 \u0111\u1EA1o", "orbit", "nasa", "kh\xF4ng gian", "space", "v\u1EC7 tinh", "satellite", "earth", "moon"]
|
|
1881
|
+
},
|
|
1882
|
+
{
|
|
1883
|
+
id: "phet-projectile-motion",
|
|
1884
|
+
titleEn: "Projectile Motion",
|
|
1885
|
+
titleVi: "Chuy\u1EC3n \u0110\u1ED9ng N\xE9m Ngang & N\xE9m Xi\xEAn",
|
|
1886
|
+
descriptionEn: "Blast cannonballs, baseballs, or pianos. Adjust launch angle, initial speed, mass, and air resistance to hit targets.",
|
|
1887
|
+
descriptionVi: "B\u1EAFn \u0111\u1EA1i b\xE1c, b\xF3ng ch\xE0y ho\u1EB7c \u0111\xE0n piano. \u0110i\u1EC1u ch\u1EC9nh g\xF3c b\u1EAFn, v\u1EADn t\u1ED1c \u0111\u1EA7u v\xE0 l\u1EF1c c\u1EA3n kh\xF4ng kh\xED. C\u1EF1c k\u1EF3 h\u1EEFu \xEDch cho l\u1EADp tr\xECnh game v\u1EADt l\xFD.",
|
|
1888
|
+
simUrl: "https://phet.colorado.edu/sims/html/projectile-motion/latest/projectile-motion_all.html",
|
|
1889
|
+
thumbnailUrl: "https://phet.colorado.edu/sims/html/projectile-motion/latest/projectile-motion-600.png",
|
|
1890
|
+
subject: "physics",
|
|
1891
|
+
targetLevel: "upper_secondary",
|
|
1892
|
+
keywords: ["projectile", "n\xE9m xi\xEAn", "qu\u1EF9 \u0111\u1EA1o", "trajectory", "game physics", "v\u1EADt l\xFD tr\xF2 ch\u01A1i", "v\u1EADn t\u1ED1c", "g\xF3c b\u1EAFn"]
|
|
1893
|
+
}
|
|
1894
|
+
];
|
|
1895
|
+
var OpenverseClient = class {
|
|
1896
|
+
baseUrl = "https://api.openverse.org/v1";
|
|
1897
|
+
async searchImages(query, options = {}) {
|
|
1898
|
+
try {
|
|
1899
|
+
const limit = Math.min(options.limit ?? 5, 20);
|
|
1900
|
+
const params = new URLSearchParams({
|
|
1901
|
+
q: query,
|
|
1902
|
+
page_size: String(limit)
|
|
1903
|
+
});
|
|
1904
|
+
if (options.license) {
|
|
1905
|
+
params.set("license", options.license);
|
|
1906
|
+
}
|
|
1907
|
+
const res = await fetch(`${this.baseUrl}/images/?${params.toString()}`, {
|
|
1908
|
+
headers: {
|
|
1909
|
+
"User-Agent": "CurriculumStudio-ResearchKit/1.2.2",
|
|
1910
|
+
Accept: "application/json"
|
|
1911
|
+
},
|
|
1912
|
+
signal: AbortSignal.timeout(8e3)
|
|
1913
|
+
});
|
|
1914
|
+
if (!res.ok) return [];
|
|
1915
|
+
const data = await res.json();
|
|
1916
|
+
const results = Array.isArray(data?.results) ? data.results : [];
|
|
1917
|
+
return results.map((item) => {
|
|
1918
|
+
const licenseType = (item.license || "CC").toUpperCase();
|
|
1919
|
+
const licenseVer = item.license_version ? ` ${item.license_version}` : "";
|
|
1920
|
+
const creator = item.creator ? ` b\u1EDFi ${item.creator}` : "";
|
|
1921
|
+
return {
|
|
1922
|
+
id: `openverse-${item.id}`,
|
|
1923
|
+
title: item.title || `H\xECnh \u1EA3nh minh h\u1ECDa: ${query}`,
|
|
1924
|
+
url: item.foreign_landing_url || item.url,
|
|
1925
|
+
description: `H\xECnh \u1EA3nh gi\u1EA5y ph\xE9p m\u1EDF (${licenseType}${licenseVer})${creator} t\u1EEB ngu\u1ED3n ${item.source || item.provider || "Openverse"}.`,
|
|
1926
|
+
type: "media_image",
|
|
1927
|
+
provider: "openverse",
|
|
1928
|
+
thumbnailUrl: item.thumbnail || item.url,
|
|
1929
|
+
mediaType: "image",
|
|
1930
|
+
license: {
|
|
1931
|
+
type: `${licenseType}${licenseVer}`,
|
|
1932
|
+
attributionText: `\u1EA2nh: "${item.title || query}"${creator} (${licenseType}${licenseVer}) via Openverse.`,
|
|
1933
|
+
url: item.license_url,
|
|
1934
|
+
commercialUseAllowed: !licenseType.includes("NC")
|
|
1935
|
+
},
|
|
1936
|
+
subject: "general_stem",
|
|
1937
|
+
targetLevel: "all",
|
|
1938
|
+
tags: Array.isArray(item.tags) ? item.tags.slice(0, 5).map((t) => t.name || String(t)) : [query],
|
|
1939
|
+
relevanceScore: 8.5
|
|
1940
|
+
};
|
|
1941
|
+
});
|
|
1942
|
+
} catch (e) {
|
|
1943
|
+
console.warn("[OpenverseClient] Kh\xF4ng th\u1EC3 t\xECm ki\u1EBFm media Openverse:", e?.message || e);
|
|
1944
|
+
return [];
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
};
|
|
1948
|
+
var NasaMediaClient = class {
|
|
1949
|
+
baseUrl = "https://images-api.nasa.gov";
|
|
1950
|
+
async search(query, options = {}) {
|
|
1951
|
+
try {
|
|
1952
|
+
const limit = Math.min(options.limit ?? 5, 20);
|
|
1953
|
+
const mediaType = options.mediaType || "image";
|
|
1954
|
+
const params = new URLSearchParams({
|
|
1955
|
+
q: query,
|
|
1956
|
+
media_type: mediaType,
|
|
1957
|
+
page_size: String(limit)
|
|
1958
|
+
});
|
|
1959
|
+
const res = await fetch(`${this.baseUrl}/search?${params.toString()}`, {
|
|
1960
|
+
headers: {
|
|
1961
|
+
"User-Agent": "CurriculumStudio-ResearchKit/1.2.2",
|
|
1962
|
+
Accept: "application/json"
|
|
1963
|
+
},
|
|
1964
|
+
signal: AbortSignal.timeout(8e3)
|
|
1965
|
+
});
|
|
1966
|
+
if (!res.ok) return [];
|
|
1967
|
+
const data = await res.json();
|
|
1968
|
+
const items = Array.isArray(data?.collection?.items) ? data.collection.items : [];
|
|
1969
|
+
return items.slice(0, limit).map((item) => {
|
|
1970
|
+
const meta = Array.isArray(item.data) && item.data[0] ? item.data[0] : {};
|
|
1971
|
+
const link = Array.isArray(item.links) && item.links[0] ? item.links[0] : {};
|
|
1972
|
+
const title = meta.title || `NASA Media: ${query}`;
|
|
1973
|
+
const desc = (meta.description || meta.caption || "").slice(0, 220);
|
|
1974
|
+
const nasaId = meta.nasa_id || item.href;
|
|
1975
|
+
const actualMediaType = meta.media_type === "video" ? "video" : "image";
|
|
1976
|
+
return {
|
|
1977
|
+
id: `nasa-${nasaId}`,
|
|
1978
|
+
title,
|
|
1979
|
+
url: `https://images.nasa.gov/details/${encodeURIComponent(nasaId)}`,
|
|
1980
|
+
description: desc || `T\u01B0 li\u1EC7u khoa h\u1ECDc v\u0169 tr\u1EE5, v\u1EC7 tinh v\xE0 k\u1EF9 thu\u1EADt kh\xF4ng gian t\u1EEB NASA.`,
|
|
1981
|
+
type: actualMediaType === "video" ? "media_video" : "media_image",
|
|
1982
|
+
provider: "nasa",
|
|
1983
|
+
thumbnailUrl: link.href,
|
|
1984
|
+
mediaType: actualMediaType,
|
|
1985
|
+
license: {
|
|
1986
|
+
type: "Public Domain (NASA Media Guidelines)",
|
|
1987
|
+
attributionText: `T\u01B0 li\u1EC7u khoa h\u1ECDc t\u1EEB NASA (ID: ${nasaId}). S\u1EED d\u1EE5ng t\u1EF1 do cho m\u1EE5c \u0111\xEDch gi\xE1o d\u1EE5c.`,
|
|
1988
|
+
url: "https://www.nasa.gov/multimedia/guidelines/index.html",
|
|
1989
|
+
commercialUseAllowed: true
|
|
1990
|
+
},
|
|
1991
|
+
subject: "physics",
|
|
1992
|
+
targetLevel: "all",
|
|
1993
|
+
tags: Array.isArray(meta.keywords) ? meta.keywords.slice(0, 5) : ["nasa", "space", "stem"],
|
|
1994
|
+
relevanceScore: 9
|
|
1995
|
+
};
|
|
1996
|
+
});
|
|
1997
|
+
} catch (e) {
|
|
1998
|
+
console.warn("[NasaMediaClient] L\u1ED7i t\xECm ki\u1EBFm NASA media:", e?.message || e);
|
|
1999
|
+
return [];
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
};
|
|
2003
|
+
var GitHubCurriculumClient = class {
|
|
2004
|
+
baseUrl = "https://api.github.com";
|
|
2005
|
+
async searchCurricula(query, options = {}) {
|
|
2006
|
+
try {
|
|
2007
|
+
const limit = Math.min(options.limit ?? 5, 10);
|
|
2008
|
+
const q = `${query} curriculum in:name,description,topics`;
|
|
2009
|
+
const params = new URLSearchParams({
|
|
2010
|
+
q,
|
|
2011
|
+
sort: "stars",
|
|
2012
|
+
order: "desc",
|
|
2013
|
+
per_page: String(limit)
|
|
2014
|
+
});
|
|
2015
|
+
const headers = {
|
|
2016
|
+
"User-Agent": "CurriculumStudio-ResearchKit/1.2.2",
|
|
2017
|
+
Accept: "application/vnd.github.v3+json"
|
|
2018
|
+
};
|
|
2019
|
+
if (options.token || process.env.GITHUB_TOKEN) {
|
|
2020
|
+
headers["Authorization"] = `token ${options.token || process.env.GITHUB_TOKEN}`;
|
|
2021
|
+
}
|
|
2022
|
+
const res = await fetch(`${this.baseUrl}/search/repositories?${params.toString()}`, {
|
|
2023
|
+
headers,
|
|
2024
|
+
signal: AbortSignal.timeout(8e3)
|
|
2025
|
+
});
|
|
2026
|
+
if (!res.ok) return [];
|
|
2027
|
+
const data = await res.json();
|
|
2028
|
+
const items = Array.isArray(data?.items) ? data.items : [];
|
|
2029
|
+
return items.map((repo) => {
|
|
2030
|
+
const licenseName = repo.license?.name || repo.license?.spdx_id || "Open Source";
|
|
2031
|
+
return {
|
|
2032
|
+
id: `github-${repo.id}`,
|
|
2033
|
+
title: `${repo.name} (${repo.stargazers_count.toLocaleString()} \u2B50)`,
|
|
2034
|
+
url: repo.html_url,
|
|
2035
|
+
description: repo.description || `Gi\xE1o tr\xECnh v\xE0 m\xE3 ngu\u1ED3n m\u1EDF tr\xEAn GitHub b\u1EDFi ${repo.owner?.login}.`,
|
|
2036
|
+
type: "curriculum",
|
|
2037
|
+
provider: "github",
|
|
2038
|
+
mediaType: "code",
|
|
2039
|
+
license: {
|
|
2040
|
+
type: licenseName,
|
|
2041
|
+
attributionText: `Gi\xE1o tr\xECnh m\u1EDF t\u1EEB repo "${repo.full_name}" tr\xEAn GitHub (${licenseName}).`,
|
|
2042
|
+
url: repo.license?.url || repo.html_url,
|
|
2043
|
+
commercialUseAllowed: !licenseName.toLowerCase().includes("non-commercial")
|
|
2044
|
+
},
|
|
2045
|
+
subject: "computer_science",
|
|
2046
|
+
targetLevel: "upper_secondary",
|
|
2047
|
+
tags: Array.isArray(repo.topics) ? repo.topics.slice(0, 5) : ["curriculum", "education", "programming"],
|
|
2048
|
+
relevanceScore: Math.min(10, 7 + Math.log10(Math.max(1, repo.stargazers_count)) * 0.7)
|
|
2049
|
+
};
|
|
2050
|
+
});
|
|
2051
|
+
} catch (e) {
|
|
2052
|
+
console.warn("[GitHubCurriculumClient] L\u1ED7i t\xECm ki\u1EBFm GitHub curriculum:", e?.message || e);
|
|
2053
|
+
return [];
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
};
|
|
2057
|
+
var CURATED_OER_PROGRAMS = [
|
|
2058
|
+
{
|
|
2059
|
+
id: "cs-unplugged-algorithms",
|
|
2060
|
+
title: "CS Unplugged: H\u1ECDc Khoa H\u1ECDc M\xE1y T\xEDnh Kh\xF4ng C\u1EA7n M\xE1y T\xEDnh",
|
|
2061
|
+
url: "https://www.csunplugged.org/en/",
|
|
2062
|
+
description: "B\u1ED9 ho\u1EA1t \u0111\u1ED9ng offline gi\u1EA3ng d\u1EA1y thu\u1EADt to\xE1n, h\u1EC7 nh\u1ECB ph\xE2n, c\u1EA5u tr\xFAc d\u1EEF li\u1EC7u qua tr\xF2 ch\u01A1i \u0111\xF3ng vai, x\u1EBFp h\xECnh v\xE0 b\xE0i t\u1EADp nh\xF3m.",
|
|
2063
|
+
type: "hands_on_lab",
|
|
2064
|
+
provider: "cs_unplugged",
|
|
2065
|
+
subject: "computer_science",
|
|
2066
|
+
targetLevel: "primary",
|
|
2067
|
+
keywords: ["unplugged", "kh\xF4ng d\xF9ng m\xE1y", "thu\u1EADt to\xE1n", "nh\u1ECB ph\xE2n", "binary", "sorting", "s\u1EAFp x\u1EBFp", "tr\u1EBB em", "kids", "logic"],
|
|
2068
|
+
licenseType: "Creative Commons CC BY-NC-SA 4.0"
|
|
2069
|
+
},
|
|
2070
|
+
{
|
|
2071
|
+
id: "scratch-mit-studio",
|
|
2072
|
+
title: "Scratch MIT: M\xF4i Tr\u01B0\u1EDDng L\u1EADp Tr\xECnh Kh\u1ED1i & S\xE1ng T\u1EA1o Tr\u1EF1c Quan",
|
|
2073
|
+
url: "https://scratch.mit.edu/",
|
|
2074
|
+
description: "N\u1EC1n t\u1EA3ng l\u1EADp tr\xECnh kh\u1ED1i do MIT Media Lab ph\xE1t tri\u1EC3n, th\xEDch h\u1EE3p l\xE0m quen v\u1EDBi t\u01B0 duy bi\u1EBFn s\u1ED1, r\u1EBD nh\xE1nh, v\xF2ng l\u1EB7p v\xE0 s\u1EF1 ki\u1EC7n \xE2m thanh/h\xECnh \u1EA3nh.",
|
|
2075
|
+
type: "curriculum",
|
|
2076
|
+
provider: "scratch",
|
|
2077
|
+
subject: "computer_science",
|
|
2078
|
+
targetLevel: "primary",
|
|
2079
|
+
keywords: ["scratch", "blockly", "l\u1EADp tr\xECnh kh\u1ED1i", "k\xE9o th\u1EA3", "game 2d", "ho\u1EA1t h\xECnh", "tr\u1EBB em", "mit scratch"],
|
|
2080
|
+
licenseType: "Free & Open Educational Platform"
|
|
2081
|
+
},
|
|
2082
|
+
{
|
|
2083
|
+
id: "freecodecamp-responsive-web",
|
|
2084
|
+
title: "freeCodeCamp: L\u1ED9 Tr\xECnh L\u1EADp Tr\xECnh D\u1EF1 \xC1n Th\u1EF1c Chi\u1EBFn Mi\u1EC5n Ph\xED",
|
|
2085
|
+
url: "https://www.freecodecamp.org/learn",
|
|
2086
|
+
description: "H\xE0ng ng\xE0n gi\u1EDD b\xE0i h\u1ECDc t\u01B0\u01A1ng t\xE1c t\u1EEB c\u01A1 b\u1EA3n \u0111\u1EBFn n\xE2ng cao: HTML/CSS, JavaScript, Python, C\u1EA5u tr\xFAc d\u1EEF li\u1EC7u v\xE0 AI.",
|
|
2087
|
+
type: "curriculum",
|
|
2088
|
+
provider: "web",
|
|
2089
|
+
subject: "computer_science",
|
|
2090
|
+
targetLevel: "upper_secondary",
|
|
2091
|
+
keywords: ["freecodecamp", "web", "javascript", "python", "html", "css", "l\u1EADp tr\xECnh web", "ch\u1EE9ng ch\u1EC9 mi\u1EC5n ph\xED"],
|
|
2092
|
+
licenseType: "Creative Commons CC BY-SA 4.0 / Open Source"
|
|
2093
|
+
},
|
|
2094
|
+
{
|
|
2095
|
+
id: "the-odin-project-fullstack",
|
|
2096
|
+
title: "The Odin Project: L\u1ED9 Tr\xECnh Full-Stack Web Open Source",
|
|
2097
|
+
url: "https://www.theodinproject.com/",
|
|
2098
|
+
description: "Curriculum h\u1ECDc ph\xE1t tri\u1EC3n web b\xE0i b\u1EA3n theo chu\u1EA9n c\xF4ng nghi\u1EC7p: Git, CLI, HTML/CSS, JavaScript hi\u1EC7n \u0111\u1EA1i, Node.js v\xE0 React.",
|
|
2099
|
+
type: "curriculum",
|
|
2100
|
+
provider: "web",
|
|
2101
|
+
subject: "computer_science",
|
|
2102
|
+
targetLevel: "developer",
|
|
2103
|
+
keywords: ["odin project", "fullstack", "git", "github", "frontend", "backend", "react", "web developer"],
|
|
2104
|
+
licenseType: "Open Source Curriculum"
|
|
2105
|
+
},
|
|
2106
|
+
{
|
|
2107
|
+
id: "openstax-physics-volume-1",
|
|
2108
|
+
title: "OpenStax: S\xE1ch Gi\xE1o Tr\xECnh V\u1EADt L\xFD \u0110\u1EA1i H\u1ECDc & Ph\u1ED5 Th\xF4ng M\u1EDF",
|
|
2109
|
+
url: "https://openstax.org/subjects/science",
|
|
2110
|
+
description: "S\xE1ch gi\xE1o khoa s\u1ED1 chu\u1EA9n h\u1ECDc thu\u1EADt \u0111\u01B0\u1EE3c b\xECnh duy\u1EC7t \u0111\u1ED9c l\u1EADp, bao g\u1ED3m C\u01A1 h\u1ECDc, S\xF3ng, \u0110i\u1EC7n t\u1EEB h\u1ECDc v\xE0 Quang h\u1ECDc.",
|
|
2111
|
+
type: "textbook",
|
|
2112
|
+
provider: "openstax",
|
|
2113
|
+
subject: "physics",
|
|
2114
|
+
targetLevel: "upper_secondary",
|
|
2115
|
+
keywords: ["openstax", "gi\xE1o tr\xECnh", "s\xE1ch gi\xE1o khoa", "v\u1EADt l\xFD", "physics", "c\u01A1 h\u1ECDc", "\u0111i\u1EC7n t\u1EEB", "s\xE1ch m\u1EDF"],
|
|
2116
|
+
licenseType: "Creative Commons CC BY 4.0"
|
|
2117
|
+
},
|
|
2118
|
+
{
|
|
2119
|
+
id: "exercism-coding-practice",
|
|
2120
|
+
title: "Exercism: Luy\u1EC7n T\u1EADp T\u01B0 Duy Thu\u1EADt To\xE1n & Code Review \u0110a Ng\xF4n Ng\u1EEF",
|
|
2121
|
+
url: "https://exercism.org/",
|
|
2122
|
+
description: "H\u01A1n 70 ng\xF4n ng\u1EEF l\u1EADp tr\xECnh (Python, C++, Rust, Swift, JavaScript) v\u1EDBi l\u1ED9 tr\xECnh b\xE0i t\u1EADp r\xE8n luy\u1EC7n c\xFA ph\xE1p v\xE0 phong c\xE1ch m\xE3 ngu\u1ED3n chu\u1EA9n.",
|
|
2123
|
+
type: "problem_set",
|
|
2124
|
+
provider: "exercism",
|
|
2125
|
+
subject: "computer_science",
|
|
2126
|
+
targetLevel: "developer",
|
|
2127
|
+
keywords: ["exercism", "thu\u1EADt to\xE1n", "luy\u1EC7n code", "b\xE0i t\u1EADp l\u1EADp tr\xECnh", "c++", "python", "swift", "clean code"],
|
|
2128
|
+
licenseType: "Open Source & Free Non-profit Education"
|
|
2129
|
+
}
|
|
2130
|
+
];
|
|
2131
|
+
var StemResourceResearcher = class {
|
|
2132
|
+
openverse = new OpenverseClient();
|
|
2133
|
+
nasa = new NasaMediaClient();
|
|
2134
|
+
github = new GitHubCurriculumClient();
|
|
2135
|
+
async findResources(query, options = {}) {
|
|
2136
|
+
const limit = options.limit ?? 10;
|
|
2137
|
+
const rawTypes = options.types && options.types.length > 0 ? options.types : ["simulation", "curriculum", "media_image", "media_video", "hands_on_lab", "textbook", "problem_set"];
|
|
2138
|
+
const requestedTypes = /* @__PURE__ */ new Set();
|
|
2139
|
+
for (const t of rawTypes) {
|
|
2140
|
+
if (t === "interactive") {
|
|
2141
|
+
requestedTypes.add("simulation");
|
|
2142
|
+
requestedTypes.add("hands_on_lab");
|
|
2143
|
+
} else if (t === "open_media") {
|
|
2144
|
+
requestedTypes.add("media_image");
|
|
2145
|
+
requestedTypes.add("media_video");
|
|
2146
|
+
} else {
|
|
2147
|
+
requestedTypes.add(t);
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
const lowerQuery = query.toLowerCase();
|
|
2151
|
+
const queryTokens = lowerQuery.split(/\s+/).filter((t) => t.length > 1);
|
|
2152
|
+
const matches = [];
|
|
2153
|
+
if (requestedTypes.has("simulation")) {
|
|
2154
|
+
for (const sim of PHET_SIMULATIONS) {
|
|
2155
|
+
let score = 0;
|
|
2156
|
+
for (const token of queryTokens) {
|
|
2157
|
+
if (sim.keywords.some((k) => k.toLowerCase().includes(token))) score += 2;
|
|
2158
|
+
if (sim.titleEn.toLowerCase().includes(token) || sim.titleVi.toLowerCase().includes(token)) score += 3;
|
|
2159
|
+
if (sim.descriptionEn.toLowerCase().includes(token) || sim.descriptionVi.toLowerCase().includes(token)) score += 1;
|
|
2160
|
+
}
|
|
2161
|
+
if (score > 0) {
|
|
2162
|
+
matches.push({
|
|
2163
|
+
id: sim.id,
|
|
2164
|
+
title: `${sim.titleVi} (${sim.titleEn})`,
|
|
2165
|
+
url: sim.simUrl,
|
|
2166
|
+
description: sim.descriptionVi,
|
|
2167
|
+
type: "simulation",
|
|
2168
|
+
provider: "phet",
|
|
2169
|
+
thumbnailUrl: sim.thumbnailUrl,
|
|
2170
|
+
embedUrl: sim.simUrl,
|
|
2171
|
+
mediaType: "interactive",
|
|
2172
|
+
license: {
|
|
2173
|
+
type: "Creative Commons CC BY 4.0",
|
|
2174
|
+
attributionText: `M\xF4 ph\u1ECFng PhET Interactive Simulations, University of Colorado Boulder (https://phet.colorado.edu). CC BY 4.0.`,
|
|
2175
|
+
url: "https://phet.colorado.edu/en/licensing",
|
|
2176
|
+
commercialUseAllowed: true
|
|
2177
|
+
},
|
|
2178
|
+
subject: sim.subject,
|
|
2179
|
+
targetLevel: sim.targetLevel,
|
|
2180
|
+
tags: ["phet", "simulation", sim.subject, ...sim.keywords.slice(0, 3)],
|
|
2181
|
+
relevanceScore: Math.min(10, 7.5 + score * 0.4)
|
|
2182
|
+
});
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
for (const prog of CURATED_OER_PROGRAMS) {
|
|
2187
|
+
if (!requestedTypes.has(prog.type)) continue;
|
|
2188
|
+
let score = 0;
|
|
2189
|
+
for (const token of queryTokens) {
|
|
2190
|
+
if (prog.keywords.some((k) => k.toLowerCase().includes(token))) score += 2;
|
|
2191
|
+
if (prog.title.toLowerCase().includes(token)) score += 3;
|
|
2192
|
+
if (prog.description.toLowerCase().includes(token)) score += 1;
|
|
2193
|
+
}
|
|
2194
|
+
if (score > 0) {
|
|
2195
|
+
matches.push({
|
|
2196
|
+
id: prog.id,
|
|
2197
|
+
title: prog.title,
|
|
2198
|
+
url: prog.url,
|
|
2199
|
+
description: prog.description,
|
|
2200
|
+
type: prog.type,
|
|
2201
|
+
provider: prog.provider,
|
|
2202
|
+
mediaType: prog.type === "hands_on_lab" || prog.type === "curriculum" ? "text" : "code",
|
|
2203
|
+
license: {
|
|
2204
|
+
type: prog.licenseType,
|
|
2205
|
+
attributionText: `T\xE0i nguy\xEAn gi\xE1o d\u1EE5c m\u1EDF t\u1EEB ${prog.provider.toUpperCase()} (${prog.licenseType}).`,
|
|
2206
|
+
commercialUseAllowed: !prog.licenseType.includes("NC")
|
|
2207
|
+
},
|
|
2208
|
+
subject: prog.subject,
|
|
2209
|
+
targetLevel: prog.targetLevel,
|
|
2210
|
+
tags: [prog.provider, prog.type, ...prog.keywords.slice(0, 3)],
|
|
2211
|
+
relevanceScore: Math.min(10, 7 + score * 0.4)
|
|
2212
|
+
});
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
const asyncTasks = [];
|
|
2216
|
+
if (requestedTypes.has("media_image")) {
|
|
2217
|
+
asyncTasks.push(this.openverse.searchImages(query, { limit: 4 }));
|
|
2218
|
+
}
|
|
2219
|
+
if (requestedTypes.has("media_image") || requestedTypes.has("media_video")) {
|
|
2220
|
+
const isSpaceOrPhysics = /(vũ trụ|space|physics|vật lý|quỹ đạo|orbit|sensor|cảm biến|robot|nasa|trọng lực|gravity|earth|solar)/i.test(query);
|
|
2221
|
+
if (isSpaceOrPhysics) {
|
|
2222
|
+
asyncTasks.push(this.nasa.search(query, { limit: 3 }));
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
if (requestedTypes.has("curriculum")) {
|
|
2226
|
+
asyncTasks.push(this.github.searchCurricula(query, { limit: 3, token: options.githubToken }));
|
|
2227
|
+
}
|
|
2228
|
+
const asyncResults = await Promise.allSettled(asyncTasks);
|
|
2229
|
+
for (const r of asyncResults) {
|
|
2230
|
+
if (r.status === "fulfilled" && Array.isArray(r.value)) {
|
|
2231
|
+
matches.push(...r.value);
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
let filtered = matches;
|
|
2235
|
+
if (options.licenseFilter === "creative_commons") {
|
|
2236
|
+
filtered = filtered.filter((item) => /cc\s*by|creative\s*commons|cc0/i.test(item.license.type));
|
|
2237
|
+
} else if (options.licenseFilter === "public_domain") {
|
|
2238
|
+
filtered = filtered.filter((item) => /public\s*domain|cc0/i.test(item.license.type));
|
|
2239
|
+
}
|
|
2240
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2241
|
+
const deduped = [];
|
|
2242
|
+
for (const item of filtered) {
|
|
2243
|
+
const key = item.url || item.id;
|
|
2244
|
+
if (seen.has(key)) continue;
|
|
2245
|
+
seen.add(key);
|
|
2246
|
+
deduped.push(item);
|
|
2247
|
+
}
|
|
2248
|
+
deduped.sort((a, b) => b.relevanceScore - a.relevanceScore);
|
|
2249
|
+
const topResults = deduped.slice(0, limit);
|
|
2250
|
+
const categoryCounts = {
|
|
2251
|
+
simulation: 0,
|
|
2252
|
+
curriculum: 0,
|
|
2253
|
+
media_image: 0,
|
|
2254
|
+
media_video: 0,
|
|
2255
|
+
hands_on_lab: 0,
|
|
2256
|
+
textbook: 0,
|
|
2257
|
+
problem_set: 0
|
|
2258
|
+
};
|
|
2259
|
+
for (const item of topResults) {
|
|
2260
|
+
if (categoryCounts[item.type] !== void 0) {
|
|
2261
|
+
categoryCounts[item.type]++;
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
const markdownSummary = this.generateMarkdownSummary(query, topResults);
|
|
2265
|
+
return {
|
|
2266
|
+
query,
|
|
2267
|
+
totalFound: topResults.length,
|
|
2268
|
+
categoryCounts,
|
|
2269
|
+
resources: topResults,
|
|
2270
|
+
items: topResults,
|
|
2271
|
+
markdownSummary,
|
|
2272
|
+
markdownReport: markdownSummary
|
|
2273
|
+
};
|
|
2274
|
+
}
|
|
2275
|
+
async searchAndCatalog(query, options = {}) {
|
|
2276
|
+
return this.findResources(query, options);
|
|
2277
|
+
}
|
|
2278
|
+
generateMarkdown(catalog) {
|
|
2279
|
+
return catalog.markdownSummary;
|
|
2280
|
+
}
|
|
2281
|
+
generateMarkdownSummary(query, items) {
|
|
2282
|
+
if (items.length === 0) {
|
|
2283
|
+
return `Kh\xF4ng t\xECm th\u1EA5y t\xE0i nguy\xEAn gi\xE1o d\u1EE5c m\u1EDF ph\xF9 h\u1EE3p cho ch\u1EE7 \u0111\u1EC1: "${query}".`;
|
|
2284
|
+
}
|
|
2285
|
+
const sections = [`### \u{1F52C} Danh m\u1EE5c T\xE0i nguy\xEAn STEM & L\u1EADp tr\xECnh cho "${query}"
|
|
2286
|
+
`];
|
|
2287
|
+
const typeLabels = {
|
|
2288
|
+
simulation: "\u{1F3AE} M\xF4 ph\u1ECFng T\u01B0\u01A1ng t\xE1c (PhET / Labs)",
|
|
2289
|
+
curriculum: "\u{1F4DA} Gi\xE1o tr\xECnh & L\u1ED9 tr\xECnh M\u1EDF",
|
|
2290
|
+
media_image: "\u{1F5BC}\uFE0F H\xECnh \u1EA3nh & S\u01A1 \u0111\u1ED3 Gi\u1EA5y ph\xE9p M\u1EDF (CC / Public Domain)",
|
|
2291
|
+
media_video: "\u{1F3AC} Video & T\u01B0 li\u1EC7u Khoa h\u1ECDc",
|
|
2292
|
+
hands_on_lab: "\u{1F9EA} Ho\u1EA1t \u0111\u1ED9ng Th\u1EF1c h\xE0nh & Kh\xE1m ph\xE1 (Hands-on)",
|
|
2293
|
+
textbook: "\u{1F4D6} S\xE1ch Gi\xE1o tr\xECnh M\u1EDF (OpenStax / OER)",
|
|
2294
|
+
problem_set: "\u{1F4A1} B\xE0i t\u1EADp & Th\u1EED th\xE1ch L\u1EADp tr\xECnh"
|
|
2295
|
+
};
|
|
2296
|
+
const grouped = {};
|
|
2297
|
+
for (const it of items) {
|
|
2298
|
+
if (!grouped[it.type]) grouped[it.type] = [];
|
|
2299
|
+
grouped[it.type].push(it);
|
|
2300
|
+
}
|
|
2301
|
+
for (const [type, groupItems] of Object.entries(grouped)) {
|
|
2302
|
+
sections.push(`#### ${typeLabels[type] || type}`);
|
|
2303
|
+
for (const it of groupItems) {
|
|
2304
|
+
it.thumbnailUrl ? `
|
|
2305
|
+
` : "";
|
|
2306
|
+
const embed = it.embedUrl ? `> \u{1F517} **T\u01B0\u01A1ng t\xE1c tr\u1EF1c ti\u1EBFp**: [M\u1EDF Simulation To\xE0n m\xE0n h\xECnh](${it.embedUrl})
|
|
2307
|
+
` : "";
|
|
2308
|
+
sections.push(
|
|
2309
|
+
`- **[${it.title}](${it.url})** \u2014 *${it.provider.toUpperCase()}* (${it.license.type})
|
|
2310
|
+
${it.description}
|
|
2311
|
+
${embed} *Tr\xEDch d\u1EABn b\u1EA3n quy\u1EC1n*: \`${it.license.attributionText}\``
|
|
2312
|
+
);
|
|
2313
|
+
}
|
|
2314
|
+
sections.push("");
|
|
2315
|
+
}
|
|
2316
|
+
return sections.join("\n");
|
|
2317
|
+
}
|
|
2318
|
+
};
|
|
2319
|
+
|
|
1365
2320
|
exports.CatalogBuilder = CatalogBuilder;
|
|
1366
2321
|
exports.ECOMMERCE_AND_COMMERCIAL_PATTERNS = ECOMMERCE_AND_COMMERCIAL_PATTERNS;
|
|
1367
2322
|
exports.ECOMMERCE_DOMAINS = ECOMMERCE_DOMAINS;
|
|
2323
|
+
exports.GitHubCurriculumClient = GitHubCurriculumClient;
|
|
1368
2324
|
exports.HealthAuditor = HealthAuditor;
|
|
1369
2325
|
exports.MultiSourceSearchEngine = MultiSourceSearchEngine;
|
|
2326
|
+
exports.NasaMediaClient = NasaMediaClient;
|
|
2327
|
+
exports.OpenverseClient = OpenverseClient;
|
|
1370
2328
|
exports.PedagogicalTermExtractor = PedagogicalTermExtractor;
|
|
2329
|
+
exports.StemResourceResearcher = StemResourceResearcher;
|
|
1371
2330
|
exports.WebScraper = WebScraper;
|
|
1372
2331
|
exports.YouTubeIngestionService = YouTubeIngestionService;
|
|
1373
2332
|
exports.classifyTechnicalDomain = classifyTechnicalDomain;
|