scientify 1.13.6 → 2.0.0

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 (100) hide show
  1. package/README.en.md +350 -0
  2. package/README.md +148 -358
  3. package/dist/index.d.ts +8 -2
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +131 -122
  6. package/dist/index.js.map +1 -1
  7. package/dist/src/cli/research.d.ts +1 -6
  8. package/dist/src/cli/research.d.ts.map +1 -1
  9. package/dist/src/cli/research.js +227 -123
  10. package/dist/src/cli/research.js.map +1 -1
  11. package/dist/src/commands/metabolism-status.d.ts +3 -3
  12. package/dist/src/commands/metabolism-status.d.ts.map +1 -1
  13. package/dist/src/commands/metabolism-status.js +72 -75
  14. package/dist/src/commands/metabolism-status.js.map +1 -1
  15. package/dist/src/commands.d.ts +1 -1
  16. package/dist/src/commands.d.ts.map +1 -1
  17. package/dist/src/commands.js +0 -55
  18. package/dist/src/commands.js.map +1 -1
  19. package/dist/src/hooks/cron-skill-inject.d.ts +6 -7
  20. package/dist/src/hooks/cron-skill-inject.d.ts.map +1 -1
  21. package/dist/src/hooks/cron-skill-inject.js +6 -15
  22. package/dist/src/hooks/cron-skill-inject.js.map +1 -1
  23. package/dist/src/hooks/research-mode.d.ts +1 -1
  24. package/dist/src/hooks/research-mode.d.ts.map +1 -1
  25. package/dist/src/hooks/research-mode.js +24 -101
  26. package/dist/src/hooks/research-mode.js.map +1 -1
  27. package/dist/src/hooks/scientify-signature.d.ts +1 -1
  28. package/dist/src/hooks/scientify-signature.d.ts.map +1 -1
  29. package/dist/src/hooks/scientify-signature.js +2 -5
  30. package/dist/src/hooks/scientify-signature.js.map +1 -1
  31. package/dist/src/knowledge-state/render.d.ts +1 -9
  32. package/dist/src/knowledge-state/render.d.ts.map +1 -1
  33. package/dist/src/knowledge-state/render.js +33 -187
  34. package/dist/src/knowledge-state/render.js.map +1 -1
  35. package/dist/src/knowledge-state/store.d.ts.map +1 -1
  36. package/dist/src/knowledge-state/store.js +65 -1100
  37. package/dist/src/knowledge-state/store.js.map +1 -1
  38. package/dist/src/knowledge-state/types.d.ts +0 -76
  39. package/dist/src/knowledge-state/types.d.ts.map +1 -1
  40. package/dist/src/literature/subscription-state.d.ts +0 -2
  41. package/dist/src/literature/subscription-state.d.ts.map +1 -1
  42. package/dist/src/literature/subscription-state.js +7 -1375
  43. package/dist/src/literature/subscription-state.js.map +1 -1
  44. package/dist/src/research-subscriptions/constants.d.ts +1 -1
  45. package/dist/src/research-subscriptions/constants.js +1 -1
  46. package/dist/src/research-subscriptions/cron-client.d.ts +1 -1
  47. package/dist/src/research-subscriptions/cron-client.d.ts.map +1 -1
  48. package/dist/src/research-subscriptions/delivery.d.ts +1 -1
  49. package/dist/src/research-subscriptions/delivery.d.ts.map +1 -1
  50. package/dist/src/research-subscriptions/handlers.d.ts +1 -1
  51. package/dist/src/research-subscriptions/handlers.d.ts.map +1 -1
  52. package/dist/src/research-subscriptions/handlers.js +10 -20
  53. package/dist/src/research-subscriptions/handlers.js.map +1 -1
  54. package/dist/src/research-subscriptions/parse.d.ts.map +1 -1
  55. package/dist/src/research-subscriptions/parse.js +0 -25
  56. package/dist/src/research-subscriptions/parse.js.map +1 -1
  57. package/dist/src/research-subscriptions/prompt.d.ts +1 -1
  58. package/dist/src/research-subscriptions/prompt.d.ts.map +1 -1
  59. package/dist/src/research-subscriptions/prompt.js +195 -244
  60. package/dist/src/research-subscriptions/prompt.js.map +1 -1
  61. package/dist/src/research-subscriptions/types.d.ts +1 -3
  62. package/dist/src/research-subscriptions/types.d.ts.map +1 -1
  63. package/dist/src/templates/bootstrap.d.ts.map +1 -1
  64. package/dist/src/templates/bootstrap.js +32 -19
  65. package/dist/src/templates/bootstrap.js.map +1 -1
  66. package/dist/src/tools/arxiv-download.d.ts +1 -2
  67. package/dist/src/tools/arxiv-download.d.ts.map +1 -1
  68. package/dist/src/tools/arxiv-search.d.ts +1 -2
  69. package/dist/src/tools/arxiv-search.d.ts.map +1 -1
  70. package/dist/src/tools/github-search-tool.d.ts +1 -2
  71. package/dist/src/tools/github-search-tool.d.ts.map +1 -1
  72. package/dist/src/tools/openalex-search.d.ts +1 -2
  73. package/dist/src/tools/openalex-search.d.ts.map +1 -1
  74. package/dist/src/tools/openreview-lookup.d.ts +1 -2
  75. package/dist/src/tools/openreview-lookup.d.ts.map +1 -1
  76. package/dist/src/tools/paper-browser.d.ts +1 -2
  77. package/dist/src/tools/paper-browser.d.ts.map +1 -1
  78. package/dist/src/tools/result.d.ts +3 -5
  79. package/dist/src/tools/result.d.ts.map +1 -1
  80. package/dist/src/tools/result.js +5 -7
  81. package/dist/src/tools/result.js.map +1 -1
  82. package/dist/src/tools/scientify-cron.d.ts +4 -11
  83. package/dist/src/tools/scientify-cron.d.ts.map +1 -1
  84. package/dist/src/tools/scientify-cron.js +19 -524
  85. package/dist/src/tools/scientify-cron.js.map +1 -1
  86. package/dist/src/tools/scientify-literature-state.d.ts +1 -76
  87. package/dist/src/tools/scientify-literature-state.d.ts.map +1 -1
  88. package/dist/src/tools/scientify-literature-state.js +46 -363
  89. package/dist/src/tools/scientify-literature-state.js.map +1 -1
  90. package/dist/src/tools/unpaywall-download.d.ts +1 -2
  91. package/dist/src/tools/unpaywall-download.d.ts.map +1 -1
  92. package/dist/src/types.d.ts +16 -0
  93. package/dist/src/types.d.ts.map +1 -0
  94. package/dist/src/types.js +2 -0
  95. package/dist/src/types.js.map +1 -0
  96. package/openclaw.plugin.json +4 -2
  97. package/package.json +1 -1
  98. package/skills/metabolism/SKILL.md +2 -0
  99. package/skills/research-subscription/SKILL.md +1 -29
  100. package/README.zh.md +0 -494
@@ -84,24 +84,7 @@ const KnowledgeHypothesisSchema = Type.Object({
84
84
  id: Type.Optional(Type.String({ description: "Optional hypothesis ID." })),
85
85
  statement: Type.String({ description: "Hypothesis statement." }),
86
86
  trigger: Type.String({ description: "Trigger type: GAP|BRIDGE|TREND|CONTRADICTION." }),
87
- problem_gap: Type.Optional(Type.String({ description: "Problem gap this hypothesis targets." })),
88
- proposed_mechanism: Type.Optional(Type.String({ description: "Mechanism that explains why the hypothesis should work." })),
89
- novelty_rationale: Type.Optional(Type.String({ description: "Why this hypothesis is novel vs prior work." })),
90
87
  dependency_path: Type.Optional(Type.Array(Type.String({ description: "Dependency path steps." }))),
91
- falsifiable_predictions: Type.Optional(Type.Array(Type.String({ description: "Testable predictions that can falsify the hypothesis." }))),
92
- critical_assumptions: Type.Optional(Type.Array(Type.String({ description: "Critical assumptions that must hold for this hypothesis." }))),
93
- failure_modes: Type.Optional(Type.Array(Type.String({ description: "Likely failure modes or invalidity conditions." }))),
94
- success_criteria: Type.Optional(Type.Array(Type.String({ description: "Measurable criteria for success/failure decision." }))),
95
- strengths: Type.Optional(Type.Array(Type.String({ description: "Hypothesis strengths based on current evidence." }))),
96
- weaknesses: Type.Optional(Type.Array(Type.String({ description: "Hypothesis weaknesses, risks, or uncertainty points." }))),
97
- plan_steps: Type.Optional(Type.Array(Type.String({ description: "Actionable research plan steps for execution." }))),
98
- strict_evaluation: Type.Optional(Type.Object({
99
- overall_score: Type.Optional(Type.Number({ description: "Strict overall score (0-100)." })),
100
- decision: Type.Optional(Type.String({
101
- description: "Strict decision: accept | revise | reject.",
102
- })),
103
- reason: Type.Optional(Type.String({ description: "Why this decision is made." })),
104
- })),
105
88
  novelty: Type.Optional(Type.Number({ description: "Optional novelty score." })),
106
89
  feasibility: Type.Optional(Type.Number({ description: "Optional feasibility score." })),
107
90
  impact: Type.Optional(Type.Number({ description: "Optional impact score." })),
@@ -114,15 +97,10 @@ const KnowledgeHypothesisSchema = Type.Object({
114
97
  });
115
98
  const KnowledgeRunLogSchema = Type.Object({
116
99
  model: Type.Optional(Type.String({ description: "Optional model name." })),
117
- run_profile: Type.Optional(Type.String({
118
- description: "Optional run profile: fast | strict.",
119
- })),
120
100
  duration_ms: Type.Optional(Type.Number({ description: "Optional run duration in ms." })),
121
101
  error: Type.Optional(Type.String({ description: "Optional run error text." })),
122
102
  degraded: Type.Optional(Type.Boolean({ description: "Whether this run used degraded behavior." })),
123
103
  notes: Type.Optional(Type.String({ description: "Optional extra notes." })),
124
- required_core_papers: Type.Optional(Type.Number({ description: "Optional hard requirement for minimum core papers in this run." })),
125
- required_full_text_coverage_pct: Type.Optional(Type.Number({ description: "Optional hard requirement for minimum full-text coverage percentage." })),
126
104
  temp_full_text_dir: Type.Optional(Type.String({ description: "Temporary local directory for full-text files." })),
127
105
  temp_files_downloaded: Type.Optional(Type.Number({ description: "Number of temporary full-text files downloaded." })),
128
106
  temp_cleanup_status: Type.Optional(Type.String({
@@ -131,22 +109,6 @@ const KnowledgeRunLogSchema = Type.Object({
131
109
  temp_cleanup_note: Type.Optional(Type.String({ description: "Optional cleanup note/error." })),
132
110
  full_text_attempted: Type.Optional(Type.Number({ description: "Number of papers attempted for full-text read." })),
133
111
  full_text_completed: Type.Optional(Type.Number({ description: "Number of papers successfully full-text read." })),
134
- recall_tier_stats: Type.Optional(Type.Object({
135
- tier_a: Type.Optional(Type.Object({
136
- candidates: Type.Number(),
137
- selected: Type.Number(),
138
- })),
139
- tier_b: Type.Optional(Type.Object({
140
- candidates: Type.Number(),
141
- selected: Type.Number(),
142
- })),
143
- tier_c: Type.Optional(Type.Object({
144
- candidates: Type.Number(),
145
- selected: Type.Number(),
146
- })),
147
- })),
148
- reflection_step_executed: Type.Optional(Type.Boolean({ description: "Whether one reflection follow-up query was executed." })),
149
- reflection_step_result_count: Type.Optional(Type.Number({ description: "Number of papers added by reflection step." })),
150
112
  });
151
113
  const KnowledgeStateSchema = Type.Optional(Type.Object({
152
114
  core_papers: Type.Optional(Type.Array(KnowledgePaperSchema)),
@@ -180,15 +142,6 @@ export const ScientifyLiteratureStateToolSchema = Type.Object({
180
142
  run_id: Type.Optional(Type.String({
181
143
  description: "Optional cron run/session id for traceability.",
182
144
  })),
183
- run_profile: Type.Optional(Type.String({
184
- description: "Optional run profile override: fast | strict.",
185
- })),
186
- required_core_papers: Type.Optional(Type.Number({
187
- description: "Optional hard requirement for minimum core papers in this run.",
188
- })),
189
- required_full_text_coverage_pct: Type.Optional(Type.Number({
190
- description: "Optional hard requirement for minimum core full-text coverage in this run.",
191
- })),
192
145
  note: Type.Optional(Type.String({
193
146
  description: "Optional note for this record.",
194
147
  })),
@@ -215,12 +168,6 @@ function readStringParam(params, key) {
215
168
  const trimmed = value.trim();
216
169
  return trimmed.length > 0 ? trimmed : undefined;
217
170
  }
218
- function readNumberParam(params, key) {
219
- const value = params[key];
220
- if (typeof value !== "number" || !Number.isFinite(value))
221
- return undefined;
222
- return value;
223
- }
224
171
  function readPreferences(params) {
225
172
  const raw = params.preferences;
226
173
  if (!raw || typeof raw !== "object" || Array.isArray(raw))
@@ -602,86 +549,6 @@ function readKnowledgeStatePayload(params) {
602
549
  .map((v) => v.trim())
603
550
  .filter((v) => v.length > 0)
604
551
  : undefined;
605
- const problemGap = typeof (row.problem_gap ?? row.problemGap) === "string"
606
- ? String(row.problem_gap ?? row.problemGap).trim()
607
- : undefined;
608
- const proposedMechanism = typeof (row.proposed_mechanism ?? row.proposedMechanism) === "string"
609
- ? String(row.proposed_mechanism ?? row.proposedMechanism).trim()
610
- : undefined;
611
- const noveltyRationale = typeof (row.novelty_rationale ?? row.noveltyRationale) === "string"
612
- ? String(row.novelty_rationale ?? row.noveltyRationale).trim()
613
- : undefined;
614
- const falsifiablePredictionsRaw = row.falsifiable_predictions ?? row.falsifiablePredictions;
615
- const falsifiablePredictions = Array.isArray(falsifiablePredictionsRaw)
616
- ? falsifiablePredictionsRaw
617
- .filter((v) => typeof v === "string")
618
- .map((v) => v.trim())
619
- .filter((v) => v.length > 0)
620
- : undefined;
621
- const criticalAssumptionsRaw = row.critical_assumptions ?? row.criticalAssumptions;
622
- const criticalAssumptions = Array.isArray(criticalAssumptionsRaw)
623
- ? criticalAssumptionsRaw
624
- .filter((v) => typeof v === "string")
625
- .map((v) => v.trim())
626
- .filter((v) => v.length > 0)
627
- : undefined;
628
- const failureModesRaw = row.failure_modes ?? row.failureModes;
629
- const failureModes = Array.isArray(failureModesRaw)
630
- ? failureModesRaw
631
- .filter((v) => typeof v === "string")
632
- .map((v) => v.trim())
633
- .filter((v) => v.length > 0)
634
- : undefined;
635
- const successCriteriaRaw = row.success_criteria ?? row.successCriteria;
636
- const successCriteria = Array.isArray(successCriteriaRaw)
637
- ? successCriteriaRaw
638
- .filter((v) => typeof v === "string")
639
- .map((v) => v.trim())
640
- .filter((v) => v.length > 0)
641
- : undefined;
642
- const strengthsRaw = row.strengths;
643
- const strengths = Array.isArray(strengthsRaw)
644
- ? strengthsRaw
645
- .filter((v) => typeof v === "string")
646
- .map((v) => v.trim())
647
- .filter((v) => v.length > 0)
648
- : undefined;
649
- const weaknessesRaw = row.weaknesses;
650
- const weaknesses = Array.isArray(weaknessesRaw)
651
- ? weaknessesRaw
652
- .filter((v) => typeof v === "string")
653
- .map((v) => v.trim())
654
- .filter((v) => v.length > 0)
655
- : undefined;
656
- const planStepsRaw = row.plan_steps ?? row.planSteps;
657
- const planSteps = Array.isArray(planStepsRaw)
658
- ? planStepsRaw
659
- .filter((v) => typeof v === "string")
660
- .map((v) => v.trim())
661
- .filter((v) => v.length > 0)
662
- : undefined;
663
- const strictEvaluationRaw = row.strict_evaluation ?? row.strictEvaluation;
664
- const strictEvaluation = strictEvaluationRaw && typeof strictEvaluationRaw === "object" && !Array.isArray(strictEvaluationRaw)
665
- ? (() => {
666
- const evalRow = strictEvaluationRaw;
667
- const overallScoreRaw = evalRow.overall_score ?? evalRow.overallScore;
668
- const overallScore = typeof overallScoreRaw === "number" && Number.isFinite(overallScoreRaw)
669
- ? Math.max(0, Math.min(100, Number(overallScoreRaw.toFixed(2))))
670
- : undefined;
671
- const decisionRaw = typeof evalRow.decision === "string" ? String(evalRow.decision).trim().toLowerCase() : undefined;
672
- const decision = decisionRaw === "accept" || decisionRaw === "revise" || decisionRaw === "reject"
673
- ? decisionRaw
674
- : undefined;
675
- const reason = typeof evalRow.reason === "string" ? evalRow.reason.trim() : undefined;
676
- if (overallScore === undefined && !decision && !reason)
677
- return undefined;
678
- return {
679
- ...(overallScore !== undefined ? { overallScore } : {}),
680
- ...(decision ? { decision } : {}),
681
- ...(reason ? { reason } : {}),
682
- };
683
- })()
684
- : undefined;
685
552
  const evidenceRaw = row.evidence_ids ?? row.evidenceIds;
686
553
  const evidenceIds = Array.isArray(evidenceRaw)
687
554
  ? evidenceRaw
@@ -713,18 +580,7 @@ function readKnowledgeStatePayload(params) {
713
580
  ...(id ? { id } : {}),
714
581
  statement,
715
582
  trigger,
716
- ...(problemGap ? { problemGap } : {}),
717
- ...(proposedMechanism ? { proposedMechanism } : {}),
718
- ...(noveltyRationale ? { noveltyRationale } : {}),
719
583
  ...(dependencyPath && dependencyPath.length > 0 ? { dependencyPath } : {}),
720
- ...(falsifiablePredictions && falsifiablePredictions.length > 0 ? { falsifiablePredictions } : {}),
721
- ...(criticalAssumptions && criticalAssumptions.length > 0 ? { criticalAssumptions } : {}),
722
- ...(failureModes && failureModes.length > 0 ? { failureModes } : {}),
723
- ...(successCriteria && successCriteria.length > 0 ? { successCriteria } : {}),
724
- ...(strengths && strengths.length > 0 ? { strengths } : {}),
725
- ...(weaknesses && weaknesses.length > 0 ? { weaknesses } : {}),
726
- ...(planSteps && planSteps.length > 0 ? { planSteps } : {}),
727
- ...(strictEvaluation ? { strictEvaluation } : {}),
728
584
  ...(evidenceIds && evidenceIds.length > 0 ? { evidenceIds } : {}),
729
585
  ...(validationStatus ? { validationStatus } : {}),
730
586
  ...(validationNotes ? { validationNotes } : {}),
@@ -740,25 +596,11 @@ function readKnowledgeStatePayload(params) {
740
596
  ? (() => {
741
597
  const runLogRecord = runLogRaw;
742
598
  const model = typeof runLogRecord.model === "string" ? runLogRecord.model.trim() : undefined;
743
- const runProfileRaw = typeof (runLogRecord.run_profile ?? runLogRecord.runProfile) === "string"
744
- ? String(runLogRecord.run_profile ?? runLogRecord.runProfile).trim().toLowerCase()
745
- : undefined;
746
- const runProfile = runProfileRaw === "fast" || runProfileRaw === "strict"
747
- ? runProfileRaw
748
- : undefined;
749
599
  const durationMsRaw = runLogRecord.duration_ms ?? runLogRecord.durationMs;
750
600
  const durationMs = typeof durationMsRaw === "number" && Number.isFinite(durationMsRaw) ? durationMsRaw : undefined;
751
601
  const error = typeof runLogRecord.error === "string" ? runLogRecord.error.trim() : undefined;
752
602
  const degraded = runLogRecord.degraded === true;
753
603
  const notes = typeof runLogRecord.notes === "string" ? runLogRecord.notes.trim() : undefined;
754
- const requiredCorePapersRaw = runLogRecord.required_core_papers ?? runLogRecord.requiredCorePapers;
755
- const requiredCorePapers = typeof requiredCorePapersRaw === "number" && Number.isFinite(requiredCorePapersRaw)
756
- ? Math.max(0, Math.floor(requiredCorePapersRaw))
757
- : undefined;
758
- const requiredFullTextCoveragePctRaw = runLogRecord.required_full_text_coverage_pct ?? runLogRecord.requiredFullTextCoveragePct;
759
- const requiredFullTextCoveragePct = typeof requiredFullTextCoveragePctRaw === "number" && Number.isFinite(requiredFullTextCoveragePctRaw)
760
- ? Math.max(0, Math.min(100, Number(requiredFullTextCoveragePctRaw.toFixed(2))))
761
- : undefined;
762
604
  const tempFullTextDir = typeof (runLogRecord.temp_full_text_dir ?? runLogRecord.tempFullTextDir) === "string"
763
605
  ? String(runLogRecord.temp_full_text_dir ?? runLogRecord.tempFullTextDir).trim()
764
606
  : undefined;
@@ -783,85 +625,31 @@ function readKnowledgeStatePayload(params) {
783
625
  const fullTextCompleted = typeof fullTextCompletedRaw === "number" && Number.isFinite(fullTextCompletedRaw)
784
626
  ? fullTextCompletedRaw
785
627
  : undefined;
786
- const recallTierStatsRaw = runLogRecord.recall_tier_stats ?? runLogRecord.recallTierStats;
787
- const normalizeTierStat = (raw) => {
788
- if (!raw || typeof raw !== "object" || Array.isArray(raw))
789
- return undefined;
790
- const record = raw;
791
- const candidatesRaw = record.candidates;
792
- const selectedRaw = record.selected;
793
- const candidates = typeof candidatesRaw === "number" && Number.isFinite(candidatesRaw)
794
- ? Math.max(0, Math.floor(candidatesRaw))
795
- : undefined;
796
- const selected = typeof selectedRaw === "number" && Number.isFinite(selectedRaw)
797
- ? Math.max(0, Math.floor(selectedRaw))
798
- : undefined;
799
- if (candidates === undefined && selected === undefined)
800
- return undefined;
801
- return {
802
- candidates: candidates ?? 0,
803
- selected: selected ?? 0,
804
- };
805
- };
806
- const recallTierStats = recallTierStatsRaw && typeof recallTierStatsRaw === "object" && !Array.isArray(recallTierStatsRaw)
807
- ? (() => {
808
- const record = recallTierStatsRaw;
809
- const tierA = normalizeTierStat(record.tier_a ?? record.tierA);
810
- const tierB = normalizeTierStat(record.tier_b ?? record.tierB);
811
- const tierC = normalizeTierStat(record.tier_c ?? record.tierC);
812
- if (!tierA && !tierB && !tierC)
813
- return undefined;
814
- return {
815
- ...(tierA ? { tierA } : {}),
816
- ...(tierB ? { tierB } : {}),
817
- ...(tierC ? { tierC } : {}),
818
- };
819
- })()
820
- : undefined;
821
- const reflectionStepExecuted = typeof (runLogRecord.reflection_step_executed ?? runLogRecord.reflectionStepExecuted) === "boolean"
822
- ? Boolean(runLogRecord.reflection_step_executed ?? runLogRecord.reflectionStepExecuted)
823
- : undefined;
824
- const reflectionStepResultCountRaw = runLogRecord.reflection_step_result_count ?? runLogRecord.reflectionStepResultCount;
825
- const reflectionStepResultCount = typeof reflectionStepResultCountRaw === "number" && Number.isFinite(reflectionStepResultCountRaw)
826
- ? Math.max(0, Math.floor(reflectionStepResultCountRaw))
827
- : undefined;
828
628
  if (!model &&
829
- !runProfile &&
830
629
  durationMs === undefined &&
831
630
  !error &&
832
631
  !degraded &&
833
632
  !notes &&
834
- requiredCorePapers === undefined &&
835
- requiredFullTextCoveragePct === undefined &&
836
633
  !tempFullTextDir &&
837
634
  tempFilesDownloaded === undefined &&
838
635
  !tempCleanupStatus &&
839
636
  !tempCleanupNote &&
840
637
  fullTextAttempted === undefined &&
841
- fullTextCompleted === undefined &&
842
- !recallTierStats &&
843
- reflectionStepExecuted === undefined &&
844
- reflectionStepResultCount === undefined) {
638
+ fullTextCompleted === undefined) {
845
639
  return undefined;
846
640
  }
847
641
  return {
848
642
  ...(model ? { model } : {}),
849
- ...(runProfile ? { runProfile } : {}),
850
643
  ...(durationMs !== undefined ? { durationMs } : {}),
851
644
  ...(error ? { error } : {}),
852
645
  ...(degraded ? { degraded } : {}),
853
646
  ...(notes ? { notes } : {}),
854
- ...(requiredCorePapers !== undefined ? { requiredCorePapers } : {}),
855
- ...(requiredFullTextCoveragePct !== undefined ? { requiredFullTextCoveragePct } : {}),
856
647
  ...(tempFullTextDir ? { tempFullTextDir } : {}),
857
648
  ...(tempFilesDownloaded !== undefined ? { tempFilesDownloaded } : {}),
858
649
  ...(tempCleanupStatus ? { tempCleanupStatus } : {}),
859
650
  ...(tempCleanupNote ? { tempCleanupNote } : {}),
860
651
  ...(fullTextAttempted !== undefined ? { fullTextAttempted } : {}),
861
652
  ...(fullTextCompleted !== undefined ? { fullTextCompleted } : {}),
862
- ...(recallTierStats ? { recallTierStats } : {}),
863
- ...(reflectionStepExecuted !== undefined ? { reflectionStepExecuted } : {}),
864
- ...(reflectionStepResultCount !== undefined ? { reflectionStepResultCount } : {}),
865
653
  };
866
654
  })()
867
655
  : undefined;
@@ -919,95 +707,6 @@ function serializeKnowledgePaper(paper) {
919
707
  })),
920
708
  };
921
709
  }
922
- function serializeKnowledgeSummaryPayload(summary) {
923
- return {
924
- project_id: summary.projectId,
925
- stream_key: summary.streamKey,
926
- run_profile: summary.runProfile,
927
- total_runs: summary.totalRuns,
928
- total_hypotheses: summary.totalHypotheses,
929
- knowledge_topics_count: summary.knowledgeTopicsCount,
930
- paper_notes_count: summary.paperNotesCount,
931
- trigger_state: {
932
- consecutive_new_revise_days: summary.triggerState.consecutiveNewReviseDays,
933
- bridge_count_7d: summary.triggerState.bridgeCount7d,
934
- unread_core_backlog: summary.triggerState.unreadCoreBacklog,
935
- last_updated_at_ms: summary.triggerState.lastUpdatedAtMs,
936
- },
937
- recent_full_text_read_count: summary.recentFullTextReadCount,
938
- recent_not_full_text_read_count: summary.recentNotFullTextReadCount,
939
- quality_gate: {
940
- mode: summary.qualityGate.mode,
941
- severity: summary.qualityGate.severity,
942
- warnings: summary.qualityGate.warnings,
943
- fatal_reasons: summary.qualityGate.fatalReasons,
944
- blocking: summary.qualityGate.blocking,
945
- passed: summary.qualityGate.passed,
946
- full_text_coverage_pct: summary.qualityGate.fullTextCoveragePct,
947
- evidence_binding_rate_pct: summary.qualityGate.evidenceBindingRatePct,
948
- citation_error_rate_pct: summary.qualityGate.citationErrorRatePct,
949
- reasons: summary.qualityGate.reasons,
950
- },
951
- hypothesis_gate: {
952
- accepted: summary.hypothesisGate.accepted,
953
- rejected: summary.hypothesisGate.rejected,
954
- rejection_reasons: summary.hypothesisGate.rejectionReasons,
955
- },
956
- unread_core_paper_ids: summary.unreadCorePaperIds,
957
- last_run_at_ms: summary.lastRunAtMs ?? null,
958
- last_status: summary.lastStatus ?? null,
959
- last_reflection_tasks: summary.lastReflectionTasks.map((task) => ({
960
- id: task.id,
961
- trigger: task.trigger,
962
- reason: task.reason,
963
- query: task.query,
964
- priority: task.priority,
965
- status: task.status,
966
- })),
967
- recent_papers: summary.recentPapers.map(serializeKnowledgePaper),
968
- };
969
- }
970
- function defaultKnowledgeSummaryPayload(args) {
971
- return {
972
- project_id: args.projectId ?? null,
973
- stream_key: args.streamKey ?? null,
974
- run_profile: "strict",
975
- total_runs: 0,
976
- total_hypotheses: 0,
977
- knowledge_topics_count: 0,
978
- paper_notes_count: 0,
979
- trigger_state: {
980
- consecutive_new_revise_days: 0,
981
- bridge_count_7d: 0,
982
- unread_core_backlog: 0,
983
- last_updated_at_ms: null,
984
- },
985
- recent_full_text_read_count: 0,
986
- recent_not_full_text_read_count: 0,
987
- quality_gate: {
988
- mode: "soft",
989
- severity: "warn",
990
- warnings: ["knowledge_state_summary_missing"],
991
- fatal_reasons: [],
992
- blocking: false,
993
- passed: false,
994
- full_text_coverage_pct: 0,
995
- evidence_binding_rate_pct: 0,
996
- citation_error_rate_pct: 0,
997
- reasons: ["knowledge_state_summary_missing"],
998
- },
999
- hypothesis_gate: {
1000
- accepted: 0,
1001
- rejected: 0,
1002
- rejection_reasons: [],
1003
- },
1004
- unread_core_paper_ids: [],
1005
- last_run_at_ms: null,
1006
- last_status: null,
1007
- last_reflection_tasks: [],
1008
- recent_papers: [],
1009
- };
1010
- }
1011
710
  export function createScientifyLiteratureStateTool() {
1012
711
  return {
1013
712
  label: "Scientify Literature State",
@@ -1054,38 +753,8 @@ export function createScientifyLiteratureStateTool() {
1054
753
  const papers = readPapers(params);
1055
754
  const status = readStringParam(params, "status");
1056
755
  const runId = readStringParam(params, "run_id");
1057
- const runProfileRaw = readStringParam(params, "run_profile")?.toLowerCase();
1058
- const requiredCorePapers = readNumberParam(params, "required_core_papers");
1059
- const requiredFullTextCoveragePct = readNumberParam(params, "required_full_text_coverage_pct");
1060
- const runProfile = runProfileRaw === "fast" || runProfileRaw === "strict"
1061
- ? runProfileRaw
1062
- : undefined;
1063
756
  const note = readStringParam(params, "note");
1064
757
  const knowledgeState = readKnowledgeStatePayload(params);
1065
- const mergedRunLog = runProfile !== undefined ||
1066
- requiredCorePapers !== undefined ||
1067
- requiredFullTextCoveragePct !== undefined ||
1068
- knowledgeState?.runLog
1069
- ? {
1070
- ...(knowledgeState?.runLog ?? {}),
1071
- ...(!knowledgeState?.runLog?.runProfile && runProfile !== undefined
1072
- ? { runProfile }
1073
- : {}),
1074
- ...(knowledgeState?.runLog?.requiredCorePapers === undefined && requiredCorePapers !== undefined
1075
- ? { requiredCorePapers }
1076
- : {}),
1077
- ...(knowledgeState?.runLog?.requiredFullTextCoveragePct === undefined &&
1078
- requiredFullTextCoveragePct !== undefined
1079
- ? { requiredFullTextCoveragePct }
1080
- : {}),
1081
- }
1082
- : undefined;
1083
- const mergedKnowledgeState = knowledgeState || mergedRunLog
1084
- ? {
1085
- ...(knowledgeState ?? {}),
1086
- ...(mergedRunLog ? { runLog: mergedRunLog } : {}),
1087
- }
1088
- : undefined;
1089
758
  const recorded = await recordIncrementalPush({
1090
759
  scope,
1091
760
  topic,
@@ -1095,14 +764,13 @@ export function createScientifyLiteratureStateTool() {
1095
764
  note,
1096
765
  papers,
1097
766
  ...(projectId ? { projectId } : {}),
1098
- ...(mergedKnowledgeState ? { knowledgeState: mergedKnowledgeState } : {}),
767
+ ...(knowledgeState ? { knowledgeState } : {}),
1099
768
  });
1100
769
  return Result.ok({
1101
770
  action,
1102
771
  scope: recorded.scope,
1103
772
  topic: recorded.topic,
1104
773
  topic_key: recorded.topicKey,
1105
- run_id: recorded.runId,
1106
774
  preferences: {
1107
775
  max_papers: recorded.preferences.maxPapers,
1108
776
  recency_days: recorded.preferences.recencyDays,
@@ -1121,8 +789,28 @@ export function createScientifyLiteratureStateTool() {
1121
789
  pushed_at_ms: recorded.pushedAtMs,
1122
790
  project_id: recorded.projectId ?? null,
1123
791
  knowledge_state_summary: recorded.knowledgeStateSummary
1124
- ? serializeKnowledgeSummaryPayload(recorded.knowledgeStateSummary)
1125
- : defaultKnowledgeSummaryPayload({ projectId: recorded.projectId, streamKey: recorded.streamKey }),
792
+ ? {
793
+ project_id: recorded.knowledgeStateSummary.projectId,
794
+ stream_key: recorded.knowledgeStateSummary.streamKey,
795
+ total_runs: recorded.knowledgeStateSummary.totalRuns,
796
+ total_hypotheses: recorded.knowledgeStateSummary.totalHypotheses,
797
+ knowledge_topics_count: recorded.knowledgeStateSummary.knowledgeTopicsCount,
798
+ paper_notes_count: recorded.knowledgeStateSummary.paperNotesCount,
799
+ recent_full_text_read_count: recorded.knowledgeStateSummary.recentFullTextReadCount,
800
+ recent_not_full_text_read_count: recorded.knowledgeStateSummary.recentNotFullTextReadCount,
801
+ quality_gate: {
802
+ passed: recorded.knowledgeStateSummary.qualityGate.passed,
803
+ full_text_coverage_pct: recorded.knowledgeStateSummary.qualityGate.fullTextCoveragePct,
804
+ evidence_binding_rate_pct: recorded.knowledgeStateSummary.qualityGate.evidenceBindingRatePct,
805
+ citation_error_rate_pct: recorded.knowledgeStateSummary.qualityGate.citationErrorRatePct,
806
+ reasons: recorded.knowledgeStateSummary.qualityGate.reasons,
807
+ },
808
+ unread_core_paper_ids: recorded.knowledgeStateSummary.unreadCorePaperIds,
809
+ last_run_at_ms: recorded.knowledgeStateSummary.lastRunAtMs ?? null,
810
+ last_status: recorded.knowledgeStateSummary.lastStatus ?? null,
811
+ recent_papers: recorded.knowledgeStateSummary.recentPapers.map(serializeKnowledgePaper),
812
+ }
813
+ : null,
1126
814
  });
1127
815
  }
1128
816
  if (action === "feedback") {
@@ -1176,18 +864,11 @@ export function createScientifyLiteratureStateTool() {
1176
864
  topic,
1177
865
  ...(projectId ? { projectId } : {}),
1178
866
  });
1179
- const detailedPaperById = new Map((status.knowledgeStateSummary?.recentPapers ?? [])
1180
- .map((paper) => [paper.id, paper])
1181
- .filter((entry) => {
1182
- const [id] = entry;
1183
- return typeof id === "string" && id.trim().length > 0;
1184
- }));
1185
867
  return Result.ok({
1186
868
  action,
1187
869
  scope: status.scope,
1188
870
  topic: status.topic,
1189
871
  topic_key: status.topicKey,
1190
- latest_run_id: status.recentChangeStats[0]?.runId ?? null,
1191
872
  preferences: {
1192
873
  max_papers: status.preferences.maxPapers,
1193
874
  recency_days: status.preferences.recencyDays,
@@ -1206,20 +887,35 @@ export function createScientifyLiteratureStateTool() {
1206
887
  total_runs: status.totalRuns,
1207
888
  last_status: status.lastStatus ?? null,
1208
889
  last_pushed_at_ms: status.lastPushedAtMs ?? null,
1209
- knowledge_state_missing_reason: status.knowledgeStateSummary
1210
- ? null
1211
- : status.knowledgeStateMissingReason ?? "project_or_stream_not_found",
1212
890
  knowledge_state_summary: status.knowledgeStateSummary
1213
- ? serializeKnowledgeSummaryPayload(status.knowledgeStateSummary)
1214
- : defaultKnowledgeSummaryPayload({ projectId }),
891
+ ? {
892
+ project_id: status.knowledgeStateSummary.projectId,
893
+ stream_key: status.knowledgeStateSummary.streamKey,
894
+ total_runs: status.knowledgeStateSummary.totalRuns,
895
+ total_hypotheses: status.knowledgeStateSummary.totalHypotheses,
896
+ knowledge_topics_count: status.knowledgeStateSummary.knowledgeTopicsCount,
897
+ paper_notes_count: status.knowledgeStateSummary.paperNotesCount,
898
+ recent_full_text_read_count: status.knowledgeStateSummary.recentFullTextReadCount,
899
+ recent_not_full_text_read_count: status.knowledgeStateSummary.recentNotFullTextReadCount,
900
+ quality_gate: {
901
+ passed: status.knowledgeStateSummary.qualityGate.passed,
902
+ full_text_coverage_pct: status.knowledgeStateSummary.qualityGate.fullTextCoveragePct,
903
+ evidence_binding_rate_pct: status.knowledgeStateSummary.qualityGate.evidenceBindingRatePct,
904
+ citation_error_rate_pct: status.knowledgeStateSummary.qualityGate.citationErrorRatePct,
905
+ reasons: status.knowledgeStateSummary.qualityGate.reasons,
906
+ },
907
+ unread_core_paper_ids: status.knowledgeStateSummary.unreadCorePaperIds,
908
+ last_run_at_ms: status.knowledgeStateSummary.lastRunAtMs ?? null,
909
+ last_status: status.knowledgeStateSummary.lastStatus ?? null,
910
+ recent_papers: status.knowledgeStateSummary.recentPapers.map(serializeKnowledgePaper),
911
+ }
912
+ : null,
1215
913
  recent_hypotheses: status.recentHypotheses.map((item) => ({
1216
914
  id: item.id,
1217
915
  statement: item.statement,
1218
916
  trigger: item.trigger,
1219
917
  created_at_ms: item.createdAtMs,
1220
918
  file: item.file,
1221
- strict_overall_score: typeof item.strictOverallScore === "number" ? item.strictOverallScore : null,
1222
- strict_decision: item.strictDecision ?? null,
1223
919
  })),
1224
920
  recent_change_stats: status.recentChangeStats.map((item) => ({
1225
921
  day: item.day,
@@ -1247,19 +943,6 @@ export function createScientifyLiteratureStateTool() {
1247
943
  first_pushed_at_ms: paper.firstPushedAtMs,
1248
944
  last_pushed_at_ms: paper.lastPushedAtMs,
1249
945
  push_count: paper.pushCount,
1250
- ...(detailedPaperById.has(paper.id)
1251
- ? {
1252
- full_text_read: detailedPaperById.get(paper.id)?.fullTextRead ?? null,
1253
- read_status: detailedPaperById.get(paper.id)?.readStatus ?? null,
1254
- unread_reason: detailedPaperById.get(paper.id)?.unreadReason ?? null,
1255
- evidence_anchors: (detailedPaperById.get(paper.id)?.evidenceAnchors ?? []).map((anchor) => ({
1256
- section: anchor.section ?? null,
1257
- locator: anchor.locator ?? null,
1258
- claim: anchor.claim,
1259
- quote: anchor.quote ?? null,
1260
- })),
1261
- }
1262
- : {}),
1263
946
  })),
1264
947
  });
1265
948
  }