scientify 1.13.5 → 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.
- package/README.en.md +350 -0
- package/README.md +148 -358
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +131 -122
- package/dist/index.js.map +1 -1
- package/dist/src/cli/research.d.ts +1 -6
- package/dist/src/cli/research.d.ts.map +1 -1
- package/dist/src/cli/research.js +227 -123
- package/dist/src/cli/research.js.map +1 -1
- package/dist/src/commands/metabolism-status.d.ts +3 -3
- package/dist/src/commands/metabolism-status.d.ts.map +1 -1
- package/dist/src/commands/metabolism-status.js +72 -75
- package/dist/src/commands/metabolism-status.js.map +1 -1
- package/dist/src/commands.d.ts +1 -1
- package/dist/src/commands.d.ts.map +1 -1
- package/dist/src/commands.js +0 -55
- package/dist/src/commands.js.map +1 -1
- package/dist/src/hooks/cron-skill-inject.d.ts +6 -7
- package/dist/src/hooks/cron-skill-inject.d.ts.map +1 -1
- package/dist/src/hooks/cron-skill-inject.js +6 -15
- package/dist/src/hooks/cron-skill-inject.js.map +1 -1
- package/dist/src/hooks/research-mode.d.ts +1 -1
- package/dist/src/hooks/research-mode.d.ts.map +1 -1
- package/dist/src/hooks/research-mode.js +24 -72
- package/dist/src/hooks/research-mode.js.map +1 -1
- package/dist/src/hooks/scientify-signature.d.ts +1 -1
- package/dist/src/hooks/scientify-signature.d.ts.map +1 -1
- package/dist/src/hooks/scientify-signature.js +2 -5
- package/dist/src/hooks/scientify-signature.js.map +1 -1
- package/dist/src/knowledge-state/render.d.ts +1 -9
- package/dist/src/knowledge-state/render.d.ts.map +1 -1
- package/dist/src/knowledge-state/render.js +33 -158
- package/dist/src/knowledge-state/render.js.map +1 -1
- package/dist/src/knowledge-state/store.d.ts.map +1 -1
- package/dist/src/knowledge-state/store.js +65 -884
- package/dist/src/knowledge-state/store.js.map +1 -1
- package/dist/src/knowledge-state/types.d.ts +0 -69
- package/dist/src/knowledge-state/types.d.ts.map +1 -1
- package/dist/src/literature/subscription-state.d.ts +0 -2
- package/dist/src/literature/subscription-state.d.ts.map +1 -1
- package/dist/src/literature/subscription-state.js +7 -1199
- package/dist/src/literature/subscription-state.js.map +1 -1
- package/dist/src/research-subscriptions/constants.d.ts +1 -1
- package/dist/src/research-subscriptions/constants.js +1 -1
- package/dist/src/research-subscriptions/cron-client.d.ts +1 -1
- package/dist/src/research-subscriptions/cron-client.d.ts.map +1 -1
- package/dist/src/research-subscriptions/delivery.d.ts +1 -1
- package/dist/src/research-subscriptions/delivery.d.ts.map +1 -1
- package/dist/src/research-subscriptions/handlers.d.ts +1 -1
- package/dist/src/research-subscriptions/handlers.d.ts.map +1 -1
- package/dist/src/research-subscriptions/handlers.js +9 -9
- package/dist/src/research-subscriptions/handlers.js.map +1 -1
- package/dist/src/research-subscriptions/parse.d.ts.map +1 -1
- package/dist/src/research-subscriptions/parse.js +0 -10
- package/dist/src/research-subscriptions/parse.js.map +1 -1
- package/dist/src/research-subscriptions/prompt.d.ts +1 -1
- package/dist/src/research-subscriptions/prompt.d.ts.map +1 -1
- package/dist/src/research-subscriptions/prompt.js +196 -191
- package/dist/src/research-subscriptions/prompt.js.map +1 -1
- package/dist/src/research-subscriptions/types.d.ts +1 -2
- package/dist/src/research-subscriptions/types.d.ts.map +1 -1
- package/dist/src/templates/bootstrap.d.ts.map +1 -1
- package/dist/src/templates/bootstrap.js +32 -19
- package/dist/src/templates/bootstrap.js.map +1 -1
- package/dist/src/tools/arxiv-download.d.ts +1 -2
- package/dist/src/tools/arxiv-download.d.ts.map +1 -1
- package/dist/src/tools/arxiv-search.d.ts +1 -2
- package/dist/src/tools/arxiv-search.d.ts.map +1 -1
- package/dist/src/tools/github-search-tool.d.ts +1 -2
- package/dist/src/tools/github-search-tool.d.ts.map +1 -1
- package/dist/src/tools/openalex-search.d.ts +1 -2
- package/dist/src/tools/openalex-search.d.ts.map +1 -1
- package/dist/src/tools/openreview-lookup.d.ts +1 -2
- package/dist/src/tools/openreview-lookup.d.ts.map +1 -1
- package/dist/src/tools/paper-browser.d.ts +1 -2
- package/dist/src/tools/paper-browser.d.ts.map +1 -1
- package/dist/src/tools/result.d.ts +3 -5
- package/dist/src/tools/result.d.ts.map +1 -1
- package/dist/src/tools/result.js +5 -7
- package/dist/src/tools/result.js.map +1 -1
- package/dist/src/tools/scientify-cron.d.ts +4 -9
- package/dist/src/tools/scientify-cron.d.ts.map +1 -1
- package/dist/src/tools/scientify-cron.js +19 -441
- package/dist/src/tools/scientify-cron.js.map +1 -1
- package/dist/src/tools/scientify-literature-state.d.ts +1 -62
- package/dist/src/tools/scientify-literature-state.d.ts.map +1 -1
- package/dist/src/tools/scientify-literature-state.js +46 -312
- package/dist/src/tools/scientify-literature-state.js.map +1 -1
- package/dist/src/tools/unpaywall-download.d.ts +1 -2
- package/dist/src/tools/unpaywall-download.d.ts.map +1 -1
- package/dist/src/types.d.ts +16 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/openclaw.plugin.json +4 -2
- package/package.json +1 -1
- package/skills/metabolism/SKILL.md +2 -0
- package/skills/research-subscription/SKILL.md +1 -29
- package/README.zh.md +0 -494
|
@@ -85,16 +85,6 @@ const KnowledgeHypothesisSchema = Type.Object({
|
|
|
85
85
|
statement: Type.String({ description: "Hypothesis statement." }),
|
|
86
86
|
trigger: Type.String({ description: "Trigger type: GAP|BRIDGE|TREND|CONTRADICTION." }),
|
|
87
87
|
dependency_path: Type.Optional(Type.Array(Type.String({ description: "Dependency path steps." }))),
|
|
88
|
-
strengths: Type.Optional(Type.Array(Type.String({ description: "Hypothesis strengths based on current evidence." }))),
|
|
89
|
-
weaknesses: Type.Optional(Type.Array(Type.String({ description: "Hypothesis weaknesses, risks, or uncertainty points." }))),
|
|
90
|
-
plan_steps: Type.Optional(Type.Array(Type.String({ description: "Actionable research plan steps for execution." }))),
|
|
91
|
-
strict_evaluation: Type.Optional(Type.Object({
|
|
92
|
-
overall_score: Type.Optional(Type.Number({ description: "Strict overall score (0-100)." })),
|
|
93
|
-
decision: Type.Optional(Type.String({
|
|
94
|
-
description: "Strict decision: accept | revise | reject.",
|
|
95
|
-
})),
|
|
96
|
-
reason: Type.Optional(Type.String({ description: "Why this decision is made." })),
|
|
97
|
-
})),
|
|
98
88
|
novelty: Type.Optional(Type.Number({ description: "Optional novelty score." })),
|
|
99
89
|
feasibility: Type.Optional(Type.Number({ description: "Optional feasibility score." })),
|
|
100
90
|
impact: Type.Optional(Type.Number({ description: "Optional impact score." })),
|
|
@@ -107,15 +97,10 @@ const KnowledgeHypothesisSchema = Type.Object({
|
|
|
107
97
|
});
|
|
108
98
|
const KnowledgeRunLogSchema = Type.Object({
|
|
109
99
|
model: Type.Optional(Type.String({ description: "Optional model name." })),
|
|
110
|
-
run_profile: Type.Optional(Type.String({
|
|
111
|
-
description: "Optional run profile: fast | strict.",
|
|
112
|
-
})),
|
|
113
100
|
duration_ms: Type.Optional(Type.Number({ description: "Optional run duration in ms." })),
|
|
114
101
|
error: Type.Optional(Type.String({ description: "Optional run error text." })),
|
|
115
102
|
degraded: Type.Optional(Type.Boolean({ description: "Whether this run used degraded behavior." })),
|
|
116
103
|
notes: Type.Optional(Type.String({ description: "Optional extra notes." })),
|
|
117
|
-
required_core_papers: Type.Optional(Type.Number({ description: "Optional hard requirement for minimum core papers in this run." })),
|
|
118
|
-
required_full_text_coverage_pct: Type.Optional(Type.Number({ description: "Optional hard requirement for minimum full-text coverage percentage." })),
|
|
119
104
|
temp_full_text_dir: Type.Optional(Type.String({ description: "Temporary local directory for full-text files." })),
|
|
120
105
|
temp_files_downloaded: Type.Optional(Type.Number({ description: "Number of temporary full-text files downloaded." })),
|
|
121
106
|
temp_cleanup_status: Type.Optional(Type.String({
|
|
@@ -124,22 +109,6 @@ const KnowledgeRunLogSchema = Type.Object({
|
|
|
124
109
|
temp_cleanup_note: Type.Optional(Type.String({ description: "Optional cleanup note/error." })),
|
|
125
110
|
full_text_attempted: Type.Optional(Type.Number({ description: "Number of papers attempted for full-text read." })),
|
|
126
111
|
full_text_completed: Type.Optional(Type.Number({ description: "Number of papers successfully full-text read." })),
|
|
127
|
-
recall_tier_stats: Type.Optional(Type.Object({
|
|
128
|
-
tier_a: Type.Optional(Type.Object({
|
|
129
|
-
candidates: Type.Number(),
|
|
130
|
-
selected: Type.Number(),
|
|
131
|
-
})),
|
|
132
|
-
tier_b: Type.Optional(Type.Object({
|
|
133
|
-
candidates: Type.Number(),
|
|
134
|
-
selected: Type.Number(),
|
|
135
|
-
})),
|
|
136
|
-
tier_c: Type.Optional(Type.Object({
|
|
137
|
-
candidates: Type.Number(),
|
|
138
|
-
selected: Type.Number(),
|
|
139
|
-
})),
|
|
140
|
-
})),
|
|
141
|
-
reflection_step_executed: Type.Optional(Type.Boolean({ description: "Whether one reflection follow-up query was executed." })),
|
|
142
|
-
reflection_step_result_count: Type.Optional(Type.Number({ description: "Number of papers added by reflection step." })),
|
|
143
112
|
});
|
|
144
113
|
const KnowledgeStateSchema = Type.Optional(Type.Object({
|
|
145
114
|
core_papers: Type.Optional(Type.Array(KnowledgePaperSchema)),
|
|
@@ -173,15 +142,6 @@ export const ScientifyLiteratureStateToolSchema = Type.Object({
|
|
|
173
142
|
run_id: Type.Optional(Type.String({
|
|
174
143
|
description: "Optional cron run/session id for traceability.",
|
|
175
144
|
})),
|
|
176
|
-
run_profile: Type.Optional(Type.String({
|
|
177
|
-
description: "Optional run profile override: fast | strict.",
|
|
178
|
-
})),
|
|
179
|
-
required_core_papers: Type.Optional(Type.Number({
|
|
180
|
-
description: "Optional hard requirement for minimum core papers in this run.",
|
|
181
|
-
})),
|
|
182
|
-
required_full_text_coverage_pct: Type.Optional(Type.Number({
|
|
183
|
-
description: "Optional hard requirement for minimum core full-text coverage in this run.",
|
|
184
|
-
})),
|
|
185
145
|
note: Type.Optional(Type.String({
|
|
186
146
|
description: "Optional note for this record.",
|
|
187
147
|
})),
|
|
@@ -208,12 +168,6 @@ function readStringParam(params, key) {
|
|
|
208
168
|
const trimmed = value.trim();
|
|
209
169
|
return trimmed.length > 0 ? trimmed : undefined;
|
|
210
170
|
}
|
|
211
|
-
function readNumberParam(params, key) {
|
|
212
|
-
const value = params[key];
|
|
213
|
-
if (typeof value !== "number" || !Number.isFinite(value))
|
|
214
|
-
return undefined;
|
|
215
|
-
return value;
|
|
216
|
-
}
|
|
217
171
|
function readPreferences(params) {
|
|
218
172
|
const raw = params.preferences;
|
|
219
173
|
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
@@ -595,49 +549,6 @@ function readKnowledgeStatePayload(params) {
|
|
|
595
549
|
.map((v) => v.trim())
|
|
596
550
|
.filter((v) => v.length > 0)
|
|
597
551
|
: undefined;
|
|
598
|
-
const strengthsRaw = row.strengths;
|
|
599
|
-
const strengths = Array.isArray(strengthsRaw)
|
|
600
|
-
? strengthsRaw
|
|
601
|
-
.filter((v) => typeof v === "string")
|
|
602
|
-
.map((v) => v.trim())
|
|
603
|
-
.filter((v) => v.length > 0)
|
|
604
|
-
: undefined;
|
|
605
|
-
const weaknessesRaw = row.weaknesses;
|
|
606
|
-
const weaknesses = Array.isArray(weaknessesRaw)
|
|
607
|
-
? weaknessesRaw
|
|
608
|
-
.filter((v) => typeof v === "string")
|
|
609
|
-
.map((v) => v.trim())
|
|
610
|
-
.filter((v) => v.length > 0)
|
|
611
|
-
: undefined;
|
|
612
|
-
const planStepsRaw = row.plan_steps ?? row.planSteps;
|
|
613
|
-
const planSteps = Array.isArray(planStepsRaw)
|
|
614
|
-
? planStepsRaw
|
|
615
|
-
.filter((v) => typeof v === "string")
|
|
616
|
-
.map((v) => v.trim())
|
|
617
|
-
.filter((v) => v.length > 0)
|
|
618
|
-
: undefined;
|
|
619
|
-
const strictEvaluationRaw = row.strict_evaluation ?? row.strictEvaluation;
|
|
620
|
-
const strictEvaluation = strictEvaluationRaw && typeof strictEvaluationRaw === "object" && !Array.isArray(strictEvaluationRaw)
|
|
621
|
-
? (() => {
|
|
622
|
-
const evalRow = strictEvaluationRaw;
|
|
623
|
-
const overallScoreRaw = evalRow.overall_score ?? evalRow.overallScore;
|
|
624
|
-
const overallScore = typeof overallScoreRaw === "number" && Number.isFinite(overallScoreRaw)
|
|
625
|
-
? Math.max(0, Math.min(100, Number(overallScoreRaw.toFixed(2))))
|
|
626
|
-
: undefined;
|
|
627
|
-
const decisionRaw = typeof evalRow.decision === "string" ? String(evalRow.decision).trim().toLowerCase() : undefined;
|
|
628
|
-
const decision = decisionRaw === "accept" || decisionRaw === "revise" || decisionRaw === "reject"
|
|
629
|
-
? decisionRaw
|
|
630
|
-
: undefined;
|
|
631
|
-
const reason = typeof evalRow.reason === "string" ? evalRow.reason.trim() : undefined;
|
|
632
|
-
if (overallScore === undefined && !decision && !reason)
|
|
633
|
-
return undefined;
|
|
634
|
-
return {
|
|
635
|
-
...(overallScore !== undefined ? { overallScore } : {}),
|
|
636
|
-
...(decision ? { decision } : {}),
|
|
637
|
-
...(reason ? { reason } : {}),
|
|
638
|
-
};
|
|
639
|
-
})()
|
|
640
|
-
: undefined;
|
|
641
552
|
const evidenceRaw = row.evidence_ids ?? row.evidenceIds;
|
|
642
553
|
const evidenceIds = Array.isArray(evidenceRaw)
|
|
643
554
|
? evidenceRaw
|
|
@@ -670,10 +581,6 @@ function readKnowledgeStatePayload(params) {
|
|
|
670
581
|
statement,
|
|
671
582
|
trigger,
|
|
672
583
|
...(dependencyPath && dependencyPath.length > 0 ? { dependencyPath } : {}),
|
|
673
|
-
...(strengths && strengths.length > 0 ? { strengths } : {}),
|
|
674
|
-
...(weaknesses && weaknesses.length > 0 ? { weaknesses } : {}),
|
|
675
|
-
...(planSteps && planSteps.length > 0 ? { planSteps } : {}),
|
|
676
|
-
...(strictEvaluation ? { strictEvaluation } : {}),
|
|
677
584
|
...(evidenceIds && evidenceIds.length > 0 ? { evidenceIds } : {}),
|
|
678
585
|
...(validationStatus ? { validationStatus } : {}),
|
|
679
586
|
...(validationNotes ? { validationNotes } : {}),
|
|
@@ -689,25 +596,11 @@ function readKnowledgeStatePayload(params) {
|
|
|
689
596
|
? (() => {
|
|
690
597
|
const runLogRecord = runLogRaw;
|
|
691
598
|
const model = typeof runLogRecord.model === "string" ? runLogRecord.model.trim() : undefined;
|
|
692
|
-
const runProfileRaw = typeof (runLogRecord.run_profile ?? runLogRecord.runProfile) === "string"
|
|
693
|
-
? String(runLogRecord.run_profile ?? runLogRecord.runProfile).trim().toLowerCase()
|
|
694
|
-
: undefined;
|
|
695
|
-
const runProfile = runProfileRaw === "fast" || runProfileRaw === "strict"
|
|
696
|
-
? runProfileRaw
|
|
697
|
-
: undefined;
|
|
698
599
|
const durationMsRaw = runLogRecord.duration_ms ?? runLogRecord.durationMs;
|
|
699
600
|
const durationMs = typeof durationMsRaw === "number" && Number.isFinite(durationMsRaw) ? durationMsRaw : undefined;
|
|
700
601
|
const error = typeof runLogRecord.error === "string" ? runLogRecord.error.trim() : undefined;
|
|
701
602
|
const degraded = runLogRecord.degraded === true;
|
|
702
603
|
const notes = typeof runLogRecord.notes === "string" ? runLogRecord.notes.trim() : undefined;
|
|
703
|
-
const requiredCorePapersRaw = runLogRecord.required_core_papers ?? runLogRecord.requiredCorePapers;
|
|
704
|
-
const requiredCorePapers = typeof requiredCorePapersRaw === "number" && Number.isFinite(requiredCorePapersRaw)
|
|
705
|
-
? Math.max(0, Math.floor(requiredCorePapersRaw))
|
|
706
|
-
: undefined;
|
|
707
|
-
const requiredFullTextCoveragePctRaw = runLogRecord.required_full_text_coverage_pct ?? runLogRecord.requiredFullTextCoveragePct;
|
|
708
|
-
const requiredFullTextCoveragePct = typeof requiredFullTextCoveragePctRaw === "number" && Number.isFinite(requiredFullTextCoveragePctRaw)
|
|
709
|
-
? Math.max(0, Math.min(100, Number(requiredFullTextCoveragePctRaw.toFixed(2))))
|
|
710
|
-
: undefined;
|
|
711
604
|
const tempFullTextDir = typeof (runLogRecord.temp_full_text_dir ?? runLogRecord.tempFullTextDir) === "string"
|
|
712
605
|
? String(runLogRecord.temp_full_text_dir ?? runLogRecord.tempFullTextDir).trim()
|
|
713
606
|
: undefined;
|
|
@@ -732,85 +625,31 @@ function readKnowledgeStatePayload(params) {
|
|
|
732
625
|
const fullTextCompleted = typeof fullTextCompletedRaw === "number" && Number.isFinite(fullTextCompletedRaw)
|
|
733
626
|
? fullTextCompletedRaw
|
|
734
627
|
: undefined;
|
|
735
|
-
const recallTierStatsRaw = runLogRecord.recall_tier_stats ?? runLogRecord.recallTierStats;
|
|
736
|
-
const normalizeTierStat = (raw) => {
|
|
737
|
-
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
738
|
-
return undefined;
|
|
739
|
-
const record = raw;
|
|
740
|
-
const candidatesRaw = record.candidates;
|
|
741
|
-
const selectedRaw = record.selected;
|
|
742
|
-
const candidates = typeof candidatesRaw === "number" && Number.isFinite(candidatesRaw)
|
|
743
|
-
? Math.max(0, Math.floor(candidatesRaw))
|
|
744
|
-
: undefined;
|
|
745
|
-
const selected = typeof selectedRaw === "number" && Number.isFinite(selectedRaw)
|
|
746
|
-
? Math.max(0, Math.floor(selectedRaw))
|
|
747
|
-
: undefined;
|
|
748
|
-
if (candidates === undefined && selected === undefined)
|
|
749
|
-
return undefined;
|
|
750
|
-
return {
|
|
751
|
-
candidates: candidates ?? 0,
|
|
752
|
-
selected: selected ?? 0,
|
|
753
|
-
};
|
|
754
|
-
};
|
|
755
|
-
const recallTierStats = recallTierStatsRaw && typeof recallTierStatsRaw === "object" && !Array.isArray(recallTierStatsRaw)
|
|
756
|
-
? (() => {
|
|
757
|
-
const record = recallTierStatsRaw;
|
|
758
|
-
const tierA = normalizeTierStat(record.tier_a ?? record.tierA);
|
|
759
|
-
const tierB = normalizeTierStat(record.tier_b ?? record.tierB);
|
|
760
|
-
const tierC = normalizeTierStat(record.tier_c ?? record.tierC);
|
|
761
|
-
if (!tierA && !tierB && !tierC)
|
|
762
|
-
return undefined;
|
|
763
|
-
return {
|
|
764
|
-
...(tierA ? { tierA } : {}),
|
|
765
|
-
...(tierB ? { tierB } : {}),
|
|
766
|
-
...(tierC ? { tierC } : {}),
|
|
767
|
-
};
|
|
768
|
-
})()
|
|
769
|
-
: undefined;
|
|
770
|
-
const reflectionStepExecuted = typeof (runLogRecord.reflection_step_executed ?? runLogRecord.reflectionStepExecuted) === "boolean"
|
|
771
|
-
? Boolean(runLogRecord.reflection_step_executed ?? runLogRecord.reflectionStepExecuted)
|
|
772
|
-
: undefined;
|
|
773
|
-
const reflectionStepResultCountRaw = runLogRecord.reflection_step_result_count ?? runLogRecord.reflectionStepResultCount;
|
|
774
|
-
const reflectionStepResultCount = typeof reflectionStepResultCountRaw === "number" && Number.isFinite(reflectionStepResultCountRaw)
|
|
775
|
-
? Math.max(0, Math.floor(reflectionStepResultCountRaw))
|
|
776
|
-
: undefined;
|
|
777
628
|
if (!model &&
|
|
778
|
-
!runProfile &&
|
|
779
629
|
durationMs === undefined &&
|
|
780
630
|
!error &&
|
|
781
631
|
!degraded &&
|
|
782
632
|
!notes &&
|
|
783
|
-
requiredCorePapers === undefined &&
|
|
784
|
-
requiredFullTextCoveragePct === undefined &&
|
|
785
633
|
!tempFullTextDir &&
|
|
786
634
|
tempFilesDownloaded === undefined &&
|
|
787
635
|
!tempCleanupStatus &&
|
|
788
636
|
!tempCleanupNote &&
|
|
789
637
|
fullTextAttempted === undefined &&
|
|
790
|
-
fullTextCompleted === undefined
|
|
791
|
-
!recallTierStats &&
|
|
792
|
-
reflectionStepExecuted === undefined &&
|
|
793
|
-
reflectionStepResultCount === undefined) {
|
|
638
|
+
fullTextCompleted === undefined) {
|
|
794
639
|
return undefined;
|
|
795
640
|
}
|
|
796
641
|
return {
|
|
797
642
|
...(model ? { model } : {}),
|
|
798
|
-
...(runProfile ? { runProfile } : {}),
|
|
799
643
|
...(durationMs !== undefined ? { durationMs } : {}),
|
|
800
644
|
...(error ? { error } : {}),
|
|
801
645
|
...(degraded ? { degraded } : {}),
|
|
802
646
|
...(notes ? { notes } : {}),
|
|
803
|
-
...(requiredCorePapers !== undefined ? { requiredCorePapers } : {}),
|
|
804
|
-
...(requiredFullTextCoveragePct !== undefined ? { requiredFullTextCoveragePct } : {}),
|
|
805
647
|
...(tempFullTextDir ? { tempFullTextDir } : {}),
|
|
806
648
|
...(tempFilesDownloaded !== undefined ? { tempFilesDownloaded } : {}),
|
|
807
649
|
...(tempCleanupStatus ? { tempCleanupStatus } : {}),
|
|
808
650
|
...(tempCleanupNote ? { tempCleanupNote } : {}),
|
|
809
651
|
...(fullTextAttempted !== undefined ? { fullTextAttempted } : {}),
|
|
810
652
|
...(fullTextCompleted !== undefined ? { fullTextCompleted } : {}),
|
|
811
|
-
...(recallTierStats ? { recallTierStats } : {}),
|
|
812
|
-
...(reflectionStepExecuted !== undefined ? { reflectionStepExecuted } : {}),
|
|
813
|
-
...(reflectionStepResultCount !== undefined ? { reflectionStepResultCount } : {}),
|
|
814
653
|
};
|
|
815
654
|
})()
|
|
816
655
|
: undefined;
|
|
@@ -868,95 +707,6 @@ function serializeKnowledgePaper(paper) {
|
|
|
868
707
|
})),
|
|
869
708
|
};
|
|
870
709
|
}
|
|
871
|
-
function serializeKnowledgeSummaryPayload(summary) {
|
|
872
|
-
return {
|
|
873
|
-
project_id: summary.projectId,
|
|
874
|
-
stream_key: summary.streamKey,
|
|
875
|
-
run_profile: summary.runProfile,
|
|
876
|
-
total_runs: summary.totalRuns,
|
|
877
|
-
total_hypotheses: summary.totalHypotheses,
|
|
878
|
-
knowledge_topics_count: summary.knowledgeTopicsCount,
|
|
879
|
-
paper_notes_count: summary.paperNotesCount,
|
|
880
|
-
trigger_state: {
|
|
881
|
-
consecutive_new_revise_days: summary.triggerState.consecutiveNewReviseDays,
|
|
882
|
-
bridge_count_7d: summary.triggerState.bridgeCount7d,
|
|
883
|
-
unread_core_backlog: summary.triggerState.unreadCoreBacklog,
|
|
884
|
-
last_updated_at_ms: summary.triggerState.lastUpdatedAtMs,
|
|
885
|
-
},
|
|
886
|
-
recent_full_text_read_count: summary.recentFullTextReadCount,
|
|
887
|
-
recent_not_full_text_read_count: summary.recentNotFullTextReadCount,
|
|
888
|
-
quality_gate: {
|
|
889
|
-
mode: summary.qualityGate.mode,
|
|
890
|
-
severity: summary.qualityGate.severity,
|
|
891
|
-
warnings: summary.qualityGate.warnings,
|
|
892
|
-
fatal_reasons: summary.qualityGate.fatalReasons,
|
|
893
|
-
blocking: summary.qualityGate.blocking,
|
|
894
|
-
passed: summary.qualityGate.passed,
|
|
895
|
-
full_text_coverage_pct: summary.qualityGate.fullTextCoveragePct,
|
|
896
|
-
evidence_binding_rate_pct: summary.qualityGate.evidenceBindingRatePct,
|
|
897
|
-
citation_error_rate_pct: summary.qualityGate.citationErrorRatePct,
|
|
898
|
-
reasons: summary.qualityGate.reasons,
|
|
899
|
-
},
|
|
900
|
-
hypothesis_gate: {
|
|
901
|
-
accepted: summary.hypothesisGate.accepted,
|
|
902
|
-
rejected: summary.hypothesisGate.rejected,
|
|
903
|
-
rejection_reasons: summary.hypothesisGate.rejectionReasons,
|
|
904
|
-
},
|
|
905
|
-
unread_core_paper_ids: summary.unreadCorePaperIds,
|
|
906
|
-
last_run_at_ms: summary.lastRunAtMs ?? null,
|
|
907
|
-
last_status: summary.lastStatus ?? null,
|
|
908
|
-
last_reflection_tasks: summary.lastReflectionTasks.map((task) => ({
|
|
909
|
-
id: task.id,
|
|
910
|
-
trigger: task.trigger,
|
|
911
|
-
reason: task.reason,
|
|
912
|
-
query: task.query,
|
|
913
|
-
priority: task.priority,
|
|
914
|
-
status: task.status,
|
|
915
|
-
})),
|
|
916
|
-
recent_papers: summary.recentPapers.map(serializeKnowledgePaper),
|
|
917
|
-
};
|
|
918
|
-
}
|
|
919
|
-
function defaultKnowledgeSummaryPayload(args) {
|
|
920
|
-
return {
|
|
921
|
-
project_id: args.projectId ?? null,
|
|
922
|
-
stream_key: args.streamKey ?? null,
|
|
923
|
-
run_profile: "strict",
|
|
924
|
-
total_runs: 0,
|
|
925
|
-
total_hypotheses: 0,
|
|
926
|
-
knowledge_topics_count: 0,
|
|
927
|
-
paper_notes_count: 0,
|
|
928
|
-
trigger_state: {
|
|
929
|
-
consecutive_new_revise_days: 0,
|
|
930
|
-
bridge_count_7d: 0,
|
|
931
|
-
unread_core_backlog: 0,
|
|
932
|
-
last_updated_at_ms: null,
|
|
933
|
-
},
|
|
934
|
-
recent_full_text_read_count: 0,
|
|
935
|
-
recent_not_full_text_read_count: 0,
|
|
936
|
-
quality_gate: {
|
|
937
|
-
mode: "soft",
|
|
938
|
-
severity: "warn",
|
|
939
|
-
warnings: ["knowledge_state_summary_missing"],
|
|
940
|
-
fatal_reasons: [],
|
|
941
|
-
blocking: false,
|
|
942
|
-
passed: false,
|
|
943
|
-
full_text_coverage_pct: 0,
|
|
944
|
-
evidence_binding_rate_pct: 0,
|
|
945
|
-
citation_error_rate_pct: 0,
|
|
946
|
-
reasons: ["knowledge_state_summary_missing"],
|
|
947
|
-
},
|
|
948
|
-
hypothesis_gate: {
|
|
949
|
-
accepted: 0,
|
|
950
|
-
rejected: 0,
|
|
951
|
-
rejection_reasons: [],
|
|
952
|
-
},
|
|
953
|
-
unread_core_paper_ids: [],
|
|
954
|
-
last_run_at_ms: null,
|
|
955
|
-
last_status: null,
|
|
956
|
-
last_reflection_tasks: [],
|
|
957
|
-
recent_papers: [],
|
|
958
|
-
};
|
|
959
|
-
}
|
|
960
710
|
export function createScientifyLiteratureStateTool() {
|
|
961
711
|
return {
|
|
962
712
|
label: "Scientify Literature State",
|
|
@@ -1003,38 +753,8 @@ export function createScientifyLiteratureStateTool() {
|
|
|
1003
753
|
const papers = readPapers(params);
|
|
1004
754
|
const status = readStringParam(params, "status");
|
|
1005
755
|
const runId = readStringParam(params, "run_id");
|
|
1006
|
-
const runProfileRaw = readStringParam(params, "run_profile")?.toLowerCase();
|
|
1007
|
-
const requiredCorePapers = readNumberParam(params, "required_core_papers");
|
|
1008
|
-
const requiredFullTextCoveragePct = readNumberParam(params, "required_full_text_coverage_pct");
|
|
1009
|
-
const runProfile = runProfileRaw === "fast" || runProfileRaw === "strict"
|
|
1010
|
-
? runProfileRaw
|
|
1011
|
-
: undefined;
|
|
1012
756
|
const note = readStringParam(params, "note");
|
|
1013
757
|
const knowledgeState = readKnowledgeStatePayload(params);
|
|
1014
|
-
const mergedRunLog = runProfile !== undefined ||
|
|
1015
|
-
requiredCorePapers !== undefined ||
|
|
1016
|
-
requiredFullTextCoveragePct !== undefined ||
|
|
1017
|
-
knowledgeState?.runLog
|
|
1018
|
-
? {
|
|
1019
|
-
...(knowledgeState?.runLog ?? {}),
|
|
1020
|
-
...(!knowledgeState?.runLog?.runProfile && runProfile !== undefined
|
|
1021
|
-
? { runProfile }
|
|
1022
|
-
: {}),
|
|
1023
|
-
...(knowledgeState?.runLog?.requiredCorePapers === undefined && requiredCorePapers !== undefined
|
|
1024
|
-
? { requiredCorePapers }
|
|
1025
|
-
: {}),
|
|
1026
|
-
...(knowledgeState?.runLog?.requiredFullTextCoveragePct === undefined &&
|
|
1027
|
-
requiredFullTextCoveragePct !== undefined
|
|
1028
|
-
? { requiredFullTextCoveragePct }
|
|
1029
|
-
: {}),
|
|
1030
|
-
}
|
|
1031
|
-
: undefined;
|
|
1032
|
-
const mergedKnowledgeState = knowledgeState || mergedRunLog
|
|
1033
|
-
? {
|
|
1034
|
-
...(knowledgeState ?? {}),
|
|
1035
|
-
...(mergedRunLog ? { runLog: mergedRunLog } : {}),
|
|
1036
|
-
}
|
|
1037
|
-
: undefined;
|
|
1038
758
|
const recorded = await recordIncrementalPush({
|
|
1039
759
|
scope,
|
|
1040
760
|
topic,
|
|
@@ -1044,14 +764,13 @@ export function createScientifyLiteratureStateTool() {
|
|
|
1044
764
|
note,
|
|
1045
765
|
papers,
|
|
1046
766
|
...(projectId ? { projectId } : {}),
|
|
1047
|
-
...(
|
|
767
|
+
...(knowledgeState ? { knowledgeState } : {}),
|
|
1048
768
|
});
|
|
1049
769
|
return Result.ok({
|
|
1050
770
|
action,
|
|
1051
771
|
scope: recorded.scope,
|
|
1052
772
|
topic: recorded.topic,
|
|
1053
773
|
topic_key: recorded.topicKey,
|
|
1054
|
-
run_id: recorded.runId,
|
|
1055
774
|
preferences: {
|
|
1056
775
|
max_papers: recorded.preferences.maxPapers,
|
|
1057
776
|
recency_days: recorded.preferences.recencyDays,
|
|
@@ -1070,8 +789,28 @@ export function createScientifyLiteratureStateTool() {
|
|
|
1070
789
|
pushed_at_ms: recorded.pushedAtMs,
|
|
1071
790
|
project_id: recorded.projectId ?? null,
|
|
1072
791
|
knowledge_state_summary: recorded.knowledgeStateSummary
|
|
1073
|
-
?
|
|
1074
|
-
|
|
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,
|
|
1075
814
|
});
|
|
1076
815
|
}
|
|
1077
816
|
if (action === "feedback") {
|
|
@@ -1125,18 +864,11 @@ export function createScientifyLiteratureStateTool() {
|
|
|
1125
864
|
topic,
|
|
1126
865
|
...(projectId ? { projectId } : {}),
|
|
1127
866
|
});
|
|
1128
|
-
const detailedPaperById = new Map((status.knowledgeStateSummary?.recentPapers ?? [])
|
|
1129
|
-
.map((paper) => [paper.id, paper])
|
|
1130
|
-
.filter((entry) => {
|
|
1131
|
-
const [id] = entry;
|
|
1132
|
-
return typeof id === "string" && id.trim().length > 0;
|
|
1133
|
-
}));
|
|
1134
867
|
return Result.ok({
|
|
1135
868
|
action,
|
|
1136
869
|
scope: status.scope,
|
|
1137
870
|
topic: status.topic,
|
|
1138
871
|
topic_key: status.topicKey,
|
|
1139
|
-
latest_run_id: status.recentChangeStats[0]?.runId ?? null,
|
|
1140
872
|
preferences: {
|
|
1141
873
|
max_papers: status.preferences.maxPapers,
|
|
1142
874
|
recency_days: status.preferences.recencyDays,
|
|
@@ -1155,20 +887,35 @@ export function createScientifyLiteratureStateTool() {
|
|
|
1155
887
|
total_runs: status.totalRuns,
|
|
1156
888
|
last_status: status.lastStatus ?? null,
|
|
1157
889
|
last_pushed_at_ms: status.lastPushedAtMs ?? null,
|
|
1158
|
-
knowledge_state_missing_reason: status.knowledgeStateSummary
|
|
1159
|
-
? null
|
|
1160
|
-
: status.knowledgeStateMissingReason ?? "project_or_stream_not_found",
|
|
1161
890
|
knowledge_state_summary: status.knowledgeStateSummary
|
|
1162
|
-
?
|
|
1163
|
-
|
|
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,
|
|
1164
913
|
recent_hypotheses: status.recentHypotheses.map((item) => ({
|
|
1165
914
|
id: item.id,
|
|
1166
915
|
statement: item.statement,
|
|
1167
916
|
trigger: item.trigger,
|
|
1168
917
|
created_at_ms: item.createdAtMs,
|
|
1169
918
|
file: item.file,
|
|
1170
|
-
strict_overall_score: typeof item.strictOverallScore === "number" ? item.strictOverallScore : null,
|
|
1171
|
-
strict_decision: item.strictDecision ?? null,
|
|
1172
919
|
})),
|
|
1173
920
|
recent_change_stats: status.recentChangeStats.map((item) => ({
|
|
1174
921
|
day: item.day,
|
|
@@ -1196,19 +943,6 @@ export function createScientifyLiteratureStateTool() {
|
|
|
1196
943
|
first_pushed_at_ms: paper.firstPushedAtMs,
|
|
1197
944
|
last_pushed_at_ms: paper.lastPushedAtMs,
|
|
1198
945
|
push_count: paper.pushCount,
|
|
1199
|
-
...(detailedPaperById.has(paper.id)
|
|
1200
|
-
? {
|
|
1201
|
-
full_text_read: detailedPaperById.get(paper.id)?.fullTextRead ?? null,
|
|
1202
|
-
read_status: detailedPaperById.get(paper.id)?.readStatus ?? null,
|
|
1203
|
-
unread_reason: detailedPaperById.get(paper.id)?.unreadReason ?? null,
|
|
1204
|
-
evidence_anchors: (detailedPaperById.get(paper.id)?.evidenceAnchors ?? []).map((anchor) => ({
|
|
1205
|
-
section: anchor.section ?? null,
|
|
1206
|
-
locator: anchor.locator ?? null,
|
|
1207
|
-
claim: anchor.claim,
|
|
1208
|
-
quote: anchor.quote ?? null,
|
|
1209
|
-
})),
|
|
1210
|
-
}
|
|
1211
|
-
: {}),
|
|
1212
946
|
})),
|
|
1213
947
|
});
|
|
1214
948
|
}
|