@thanh01.pmt/research-kit 1.2.1 → 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.
Files changed (61) hide show
  1. package/dist/academic/index.cjs +11 -2
  2. package/dist/academic/index.cjs.map +1 -1
  3. package/dist/academic/index.d.cts +3 -3
  4. package/dist/academic/index.d.ts +3 -3
  5. package/dist/academic/index.js +1 -1
  6. package/dist/{catalogBuilder-DHV6y1gD.d.ts → catalogBuilder-B4eiLS_S.d.cts} +20 -6
  7. package/dist/{catalogBuilder-BaVRvg-9.d.cts → catalogBuilder-BNB_gaWP.d.ts} +20 -6
  8. package/dist/{chunk-X3X26W2I.js → chunk-HESXWQEF.js} +12 -7
  9. package/dist/chunk-HESXWQEF.js.map +1 -0
  10. package/dist/{chunk-QFYM2NV4.js → chunk-KXJDQBSJ.js} +3 -3
  11. package/dist/{chunk-QFYM2NV4.js.map → chunk-KXJDQBSJ.js.map} +1 -1
  12. package/dist/{chunk-RW7VS7NI.js → chunk-P6RHBJY2.js} +88 -25
  13. package/dist/chunk-P6RHBJY2.js.map +1 -0
  14. package/dist/{chunk-ON6VFCJO.js → chunk-QQZQNBJC.js} +51 -2
  15. package/dist/chunk-QQZQNBJC.js.map +1 -0
  16. package/dist/{chunk-HZNSZDSM.js → chunk-SAHBBO3U.js} +99 -11
  17. package/dist/chunk-SAHBBO3U.js.map +1 -0
  18. package/dist/{chunk-UKGR45VZ.js → chunk-SDDZFFL6.js} +13 -4
  19. package/dist/chunk-SDDZFFL6.js.map +1 -0
  20. package/dist/chunk-YICMTZS5.js +527 -0
  21. package/dist/chunk-YICMTZS5.js.map +1 -0
  22. package/dist/config/index.cjs +10 -5
  23. package/dist/config/index.cjs.map +1 -1
  24. package/dist/config/index.d.cts +1 -1
  25. package/dist/config/index.d.ts +1 -1
  26. package/dist/config/index.js +1 -1
  27. package/dist/evidence/index.cjs.map +1 -1
  28. package/dist/evidence/index.d.cts +2 -2
  29. package/dist/evidence/index.d.ts +2 -2
  30. package/dist/evidence/index.js +2 -2
  31. package/dist/harvester/index.cjs +674 -9
  32. package/dist/harvester/index.cjs.map +1 -1
  33. package/dist/harvester/index.d.cts +87 -5
  34. package/dist/harvester/index.d.ts +87 -5
  35. package/dist/harvester/index.js +3 -3
  36. package/dist/{index-DlngvZBr.d.cts → index-9rDiFuR4.d.cts} +43 -12
  37. package/dist/{index-DlngvZBr.d.ts → index-9rDiFuR4.d.ts} +43 -12
  38. package/dist/index.cjs +783 -35
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.d.cts +13 -11
  41. package/dist/index.d.ts +13 -11
  42. package/dist/index.js +19 -12
  43. package/dist/index.js.map +1 -1
  44. package/dist/{literatureReview-C7hsjrn4.d.cts → literatureReview-BwidpYJo.d.cts} +2 -1
  45. package/dist/{literatureReview-DWl13r_3.d.ts → literatureReview-DOzgm9Q2.d.ts} +2 -1
  46. package/dist/pipeline/index.cjs +256 -32
  47. package/dist/pipeline/index.cjs.map +1 -1
  48. package/dist/pipeline/index.d.cts +10 -4
  49. package/dist/pipeline/index.d.ts +10 -4
  50. package/dist/pipeline/index.js +5 -5
  51. package/dist/{webScraper-yO9P-oLb.d.cts → webScraper-CAQjE46m.d.cts} +11 -2
  52. package/dist/{webScraper-DBFUIqoO.d.ts → webScraper-CXIpvyA6.d.ts} +11 -2
  53. package/package.json +9 -8
  54. package/LICENSE +0 -21
  55. package/dist/chunk-HZNSZDSM.js.map +0 -1
  56. package/dist/chunk-LSMSIPTZ.js +0 -3
  57. package/dist/chunk-LSMSIPTZ.js.map +0 -1
  58. package/dist/chunk-ON6VFCJO.js.map +0 -1
  59. package/dist/chunk-RW7VS7NI.js.map +0 -1
  60. package/dist/chunk-UKGR45VZ.js.map +0 -1
  61. package/dist/chunk-X3X26W2I.js.map +0 -1
@@ -333,6 +333,8 @@ var MultiSourceSearchEngine = class {
333
333
  tavilyKey;
334
334
  exaKey;
335
335
  serperKey;
336
+ brightDataKey;
337
+ brightDataZone;
336
338
  searxngHost;
337
339
  searxngHeaders;
338
340
  allowEnvFallback;
@@ -343,6 +345,8 @@ var MultiSourceSearchEngine = class {
343
345
  this.tavilyKey = options.apiKeys?.tavily || options.tavilyKey || (this.allowEnvFallback ? process.env.TAVILY_API_KEY : void 0);
344
346
  this.exaKey = options.apiKeys?.exa || options.exaKey || (this.allowEnvFallback ? process.env.EXA_API_KEY : void 0);
345
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";
346
350
  this.searxngHost = options.searxngHost || (this.allowEnvFallback ? process.env.SEARXNG_URL || process.env.SEARXNG_HOST : void 0);
347
351
  const cfId = process.env.CF_ACCESS_CLIENT_ID;
348
352
  const cfSecret = process.env.CF_ACCESS_CLIENT_SECRET;
@@ -360,6 +364,12 @@ var MultiSourceSearchEngine = class {
360
364
  if (keys.tavily !== void 0) this.tavilyKey = keys.tavily;
361
365
  if (keys.exa !== void 0) this.exaKey = keys.exa;
362
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;
363
373
  }
364
374
  setSearxng(host, headers) {
365
375
  this.searxngHost = host;
@@ -406,11 +416,20 @@ var MultiSourceSearchEngine = class {
406
416
  const tavilyKey = options.apiKeys?.tavily || options.tavilyKey || this.tavilyKey;
407
417
  const exaKey = options.apiKeys?.exa || options.exaKey || this.exaKey;
408
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;
409
421
  const searxngHost = options.searxngHost || this.searxngHost;
410
422
  if (preferred === "searxng" && searxngHost) {
411
423
  const searxHits = await this.querySearxng(query, searxngHost, limit, options.searxngHeaders);
412
424
  if (searxHits.length > 0) return searxHits;
413
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
+ }
414
433
  if (preferred === "exa" && exaKey) {
415
434
  const exaHits = await this.queryExa(query, exaKey, limit, options.domainFilter);
416
435
  if (exaHits.length > 0) return exaHits;
@@ -432,6 +451,9 @@ var MultiSourceSearchEngine = class {
432
451
  include_answer: true,
433
452
  max_results: limit
434
453
  };
454
+ if (options.timeRange) {
455
+ body.time_range = options.timeRange;
456
+ }
435
457
  if (options.domainFilter && options.domainFilter.length > 0) {
436
458
  body.include_domains = options.domainFilter;
437
459
  }
@@ -458,25 +480,76 @@ var MultiSourceSearchEngine = class {
458
480
  }
459
481
  }
460
482
  if (exaKey) {
461
- const exaHits = await this.queryExa(query, exaKey, limit, options.domainFilter);
483
+ const exaHits = await this.queryExa(query, exaKey, limit, options.domainFilter, options.timeRange);
462
484
  if (exaHits.length > 0) return exaHits;
463
485
  }
464
486
  if (serperKey) {
465
- const serperHits = await this.querySerper(query, serperKey, limit);
487
+ const serperHits = await this.querySerper(query, serperKey, limit, options.timeRange);
466
488
  if (serperHits.length > 0) return serperHits;
467
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
+ }
468
497
  if (searxngHost) {
469
- const searxHits = await this.querySearxng(query, searxngHost, limit, options.searxngHeaders);
498
+ const searxHits = await this.querySearxng(query, searxngHost, limit, options.searxngHeaders, options.timeRange);
470
499
  if (searxHits.length > 0) return searxHits;
471
500
  }
472
501
  const ddgHits = await this.queryDuckDuckGo(query, limit);
473
502
  if (ddgHits.length > 0) return ddgHits;
474
503
  return [];
475
504
  }
476
- async querySearxng(query, searxngHost, limit, customHeaders) {
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) {
477
547
  try {
478
548
  const cleanHost = searxngHost.replace(/\/$/, "");
479
- const searchUrl = `${cleanHost}/search?q=${encodeURIComponent(query)}&format=json`;
549
+ let searchUrl = `${cleanHost}/search?q=${encodeURIComponent(query)}&format=json`;
550
+ if (timeRange) {
551
+ searchUrl += `&time_range=${encodeURIComponent(timeRange)}`;
552
+ }
480
553
  const headers = {
481
554
  "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)",
482
555
  ...this.searxngHeaders || {},
@@ -503,7 +576,7 @@ var MultiSourceSearchEngine = class {
503
576
  }
504
577
  return [];
505
578
  }
506
- async queryExa(query, exaKey, limit, domainFilter) {
579
+ async queryExa(query, exaKey, limit, domainFilter, timeRange) {
507
580
  try {
508
581
  const body = {
509
582
  query,
@@ -513,6 +586,14 @@ var MultiSourceSearchEngine = class {
513
586
  if (domainFilter && domainFilter.length > 0) {
514
587
  body.includeDomains = domainFilter;
515
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
+ }
516
597
  const res = await fetch("https://api.exa.ai/search", {
517
598
  method: "POST",
518
599
  headers: {
@@ -539,15 +620,22 @@ var MultiSourceSearchEngine = class {
539
620
  }
540
621
  return [];
541
622
  }
542
- async querySerper(query, serperKey, limit) {
623
+ async querySerper(query, serperKey, limit, timeRange) {
543
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
+ }
544
632
  const res = await fetch("https://google.serper.dev/search", {
545
633
  method: "POST",
546
634
  headers: {
547
635
  "X-API-KEY": serperKey,
548
636
  "Content-Type": "application/json"
549
637
  },
550
- body: JSON.stringify({ q: query, num: limit }),
638
+ body: JSON.stringify(body),
551
639
  signal: AbortSignal.timeout(1e4)
552
640
  });
553
641
  if (res.ok) {
@@ -796,6 +884,8 @@ function extractSubstantiveExcerpts(markdown, maxExcerpts = 6) {
796
884
  var WebScraper = class {
797
885
  crawl4aiHost;
798
886
  jinaKey;
887
+ brightDataKey;
888
+ brightDataZone;
799
889
  allowEnvFallback;
800
890
  customAdapter;
801
891
  youtubeService;
@@ -803,6 +893,8 @@ var WebScraper = class {
803
893
  this.allowEnvFallback = options.allowEnvFallback ?? true;
804
894
  this.crawl4aiHost = options.crawl4aiHost || (this.allowEnvFallback ? process.env.CRAWL4AI_HOST : void 0) || "http://localhost:11235";
805
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";
806
898
  this.customAdapter = options.customAdapter;
807
899
  this.youtubeService = new YouTubeIngestionService();
808
900
  }
@@ -812,8 +904,15 @@ var WebScraper = class {
812
904
  setJinaKey(key) {
813
905
  this.jinaKey = key;
814
906
  }
907
+ setBrightData(key, zone) {
908
+ if (key !== void 0) this.brightDataKey = key;
909
+ if (zone !== void 0) this.brightDataZone = zone;
910
+ }
815
911
  async scrapeUrl(targetUrl, options = {}) {
816
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;
817
916
  if (adapter) {
818
917
  try {
819
918
  const result = await adapter.crawl(targetUrl);
@@ -834,6 +933,13 @@ var WebScraper = class {
834
933
  console.warn(`[WebScraper] YouTube transcript extraction failed for ${targetUrl}:`, e?.message || e);
835
934
  }
836
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
+ }
837
943
  try {
838
944
  const jinaUrl = `https://r.jina.ai/${targetUrl}`;
839
945
  const jinaKey = options.jinaKey || this.jinaKey;
@@ -878,6 +984,13 @@ var WebScraper = class {
878
984
  } catch {
879
985
  }
880
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
+ }
881
994
  try {
882
995
  const res = await fetch(targetUrl, {
883
996
  headers: { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)" },
@@ -902,6 +1015,30 @@ ${p.replace(/<[^>]+>/g, " ").trim()}
902
1015
  }
903
1016
  throw new Error(`Unable to fetch content from URL: ${targetUrl}`);
904
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
+ }
905
1042
  packageDocument(url, markdown, provider, explicitTitle) {
906
1043
  const titleMatch = markdown.match(/^#\s+(.+)$/m) || markdown.match(/^Title:\s*(.+)$/im);
907
1044
  const title = (explicitTitle || (titleMatch ? titleMatch[1].trim() : url.split("/").filter(Boolean).pop() || "Document")).slice(0, 180);
@@ -1456,7 +1593,7 @@ ${corpusPreview}`,
1456
1593
  `
1457
1594
  Return ONLY a valid JSON array of 6 to 12 atomic pedagogical concepts ordered from foundational to advanced.`,
1458
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.`,
1459
- `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"]}`
1460
1597
  ].filter(Boolean).join("\n");
1461
1598
  const rawResponse = await options.llm(prompt, {
1462
1599
  system: "You are a Principal Computer Science Curriculum Architect & Bilingual Terminology Specialist (Vietnamese-English). Output strictly valid JSON array without markdown commentary.",
@@ -1656,12 +1793,540 @@ var HealthAuditor = class {
1656
1793
  }
1657
1794
  };
1658
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 ? `![preview](${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
+
1659
2320
  exports.CatalogBuilder = CatalogBuilder;
1660
2321
  exports.ECOMMERCE_AND_COMMERCIAL_PATTERNS = ECOMMERCE_AND_COMMERCIAL_PATTERNS;
1661
2322
  exports.ECOMMERCE_DOMAINS = ECOMMERCE_DOMAINS;
2323
+ exports.GitHubCurriculumClient = GitHubCurriculumClient;
1662
2324
  exports.HealthAuditor = HealthAuditor;
1663
2325
  exports.MultiSourceSearchEngine = MultiSourceSearchEngine;
2326
+ exports.NasaMediaClient = NasaMediaClient;
2327
+ exports.OpenverseClient = OpenverseClient;
1664
2328
  exports.PedagogicalTermExtractor = PedagogicalTermExtractor;
2329
+ exports.StemResourceResearcher = StemResourceResearcher;
1665
2330
  exports.WebScraper = WebScraper;
1666
2331
  exports.YouTubeIngestionService = YouTubeIngestionService;
1667
2332
  exports.classifyTechnicalDomain = classifyTechnicalDomain;