dsh-research-report 0.1.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/CHANGELOG.md +18 -0
- package/LICENSE +201 -0
- package/README.es.md +155 -0
- package/README.hi.md +155 -0
- package/README.md +155 -0
- package/README.pt.md +155 -0
- package/README.zh.md +155 -0
- package/THIRD_PARTY_NOTICES.md +21 -0
- package/cordis.patch.yml +24 -0
- package/lib/index.js +2143 -0
- package/lib/types/assemble.d.ts +123 -0
- package/lib/types/assemble.d.ts.map +1 -0
- package/lib/types/assemble.js +239 -0
- package/lib/types/assemble.js.map +1 -0
- package/lib/types/config.d.ts +48 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/config.js +60 -0
- package/lib/types/config.js.map +1 -0
- package/lib/types/gather.d.ts +119 -0
- package/lib/types/gather.d.ts.map +1 -0
- package/lib/types/gather.js +165 -0
- package/lib/types/gather.js.map +1 -0
- package/lib/types/index.d.ts +51 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +71 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/ledger.d.ts +159 -0
- package/lib/types/ledger.d.ts.map +1 -0
- package/lib/types/ledger.js +276 -0
- package/lib/types/ledger.js.map +1 -0
- package/lib/types/provider-local.d.ts +137 -0
- package/lib/types/provider-local.d.ts.map +1 -0
- package/lib/types/provider-local.js +418 -0
- package/lib/types/provider-local.js.map +1 -0
- package/lib/types/service.d.ts +302 -0
- package/lib/types/service.d.ts.map +1 -0
- package/lib/types/service.js +31 -0
- package/lib/types/service.js.map +1 -0
- package/lib/types/tools/evidence-add.d.ts +36 -0
- package/lib/types/tools/evidence-add.d.ts.map +1 -0
- package/lib/types/tools/evidence-add.js +107 -0
- package/lib/types/tools/evidence-add.js.map +1 -0
- package/lib/types/tools/ledger-query.d.ts +42 -0
- package/lib/types/tools/ledger-query.d.ts.map +1 -0
- package/lib/types/tools/ledger-query.js +154 -0
- package/lib/types/tools/ledger-query.js.map +1 -0
- package/lib/types/tools/research-report.d.ts +67 -0
- package/lib/types/tools/research-report.d.ts.map +1 -0
- package/lib/types/tools/research-report.js +345 -0
- package/lib/types/tools/research-report.js.map +1 -0
- package/lib/types/verify.d.ts +128 -0
- package/lib/types/verify.d.ts.map +1 -0
- package/lib/types/verify.js +208 -0
- package/lib/types/verify.js.map +1 -0
- package/lib/types/version.d.ts +7 -0
- package/lib/types/version.d.ts.map +1 -0
- package/lib/types/version.js +7 -0
- package/lib/types/version.js.map +1 -0
- package/package.json +147 -0
- package/src/assemble.ts +302 -0
- package/src/config.ts +97 -0
- package/src/gather.ts +239 -0
- package/src/index.ts +139 -0
- package/src/ledger.ts +344 -0
- package/src/provider-local.ts +489 -0
- package/src/service.ts +322 -0
- package/src/tools/evidence-add.ts +132 -0
- package/src/tools/ledger-query.ts +191 -0
- package/src/tools/research-report.ts +424 -0
- package/src/verify.ts +285 -0
- package/src/version.ts +7 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `ledger_query` model tool (Consumer): read-only queries over the
|
|
3
|
+
* evidence ledger — bindings, verdicts, and the live integrity re-check.
|
|
4
|
+
* @module dsh-research-report/tools/ledger-query
|
|
5
|
+
*/
|
|
6
|
+
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
7
|
+
/** The evidence view schema fragment. */
|
|
8
|
+
const evidenceViewSchema = {
|
|
9
|
+
type: 'object',
|
|
10
|
+
additionalProperties: false,
|
|
11
|
+
properties: {
|
|
12
|
+
id: { type: 'string', required: true },
|
|
13
|
+
hash: { type: 'string', required: true },
|
|
14
|
+
title: { type: 'string', required: true },
|
|
15
|
+
origin: { type: 'string', required: true },
|
|
16
|
+
capturedAt: { type: 'string', required: true },
|
|
17
|
+
bytes: { type: 'integer', required: true },
|
|
18
|
+
integrity: { type: 'string', required: true, enum: ['ok', 'tampered', 'missing'] },
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
/** The claim view schema fragment. */
|
|
22
|
+
const claimViewSchema = {
|
|
23
|
+
type: 'object',
|
|
24
|
+
additionalProperties: false,
|
|
25
|
+
properties: {
|
|
26
|
+
id: { type: 'string', required: true },
|
|
27
|
+
text: { type: 'string', required: true },
|
|
28
|
+
evidenceIds: { type: 'array', required: true, items: { type: 'string' } },
|
|
29
|
+
dataset: { type: 'string' },
|
|
30
|
+
verdict: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
additionalProperties: false,
|
|
33
|
+
properties: {
|
|
34
|
+
claimId: { type: 'string', required: true },
|
|
35
|
+
status: { type: 'string', required: true, enum: ['verified', 'unverified', 'contradicted'] },
|
|
36
|
+
note: { type: 'string' },
|
|
37
|
+
at: { type: 'string', required: true },
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
/** The tool's output schema (all four branches). */
|
|
43
|
+
const OUTPUT_SCHEMA = {
|
|
44
|
+
type: 'object',
|
|
45
|
+
additionalProperties: false,
|
|
46
|
+
properties: {
|
|
47
|
+
kind: { type: 'string', required: true, enum: ['evidence', 'claim', 'summary', 'not-found'] },
|
|
48
|
+
evidence: evidenceViewSchema,
|
|
49
|
+
claim: claimViewSchema,
|
|
50
|
+
evidenceCount: { type: 'integer' },
|
|
51
|
+
claimCount: { type: 'integer' },
|
|
52
|
+
verdictCount: { type: 'integer' },
|
|
53
|
+
tamperedCount: { type: 'integer' },
|
|
54
|
+
evidenceIds: { type: 'array', items: { type: 'string' } },
|
|
55
|
+
claimIds: { type: 'array', items: { type: 'string' } },
|
|
56
|
+
message: { type: 'string' },
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
/** Render the canonical value as model-facing text. */
|
|
60
|
+
function renderValue(value) {
|
|
61
|
+
switch (value.kind) {
|
|
62
|
+
case 'evidence': {
|
|
63
|
+
const item = value.evidence;
|
|
64
|
+
const lines = [
|
|
65
|
+
`evidence ${item.id}${item.integrity === 'ok' ? '' : ` — INTEGRITY ${item.integrity.toUpperCase()}`}`,
|
|
66
|
+
` title: ${item.title}`,
|
|
67
|
+
` origin: ${item.origin}`,
|
|
68
|
+
` sha256: ${item.hash}`,
|
|
69
|
+
` captured: ${item.capturedAt} (${item.bytes} bytes)`,
|
|
70
|
+
];
|
|
71
|
+
if (item.integrity !== 'ok') {
|
|
72
|
+
lines.push(` WARNING: the stored bytes no longer match the indexed hash — any claim bound to this evidence verifies as contradicted`);
|
|
73
|
+
}
|
|
74
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
75
|
+
}
|
|
76
|
+
case 'claim': {
|
|
77
|
+
const claim = value.claim;
|
|
78
|
+
const lines = [
|
|
79
|
+
`claim ${claim.id}`,
|
|
80
|
+
` text: ${claim.text}`,
|
|
81
|
+
` evidence: ${claim.evidenceIds.join(', ') || '(none)'}`,
|
|
82
|
+
];
|
|
83
|
+
if (claim.dataset !== undefined)
|
|
84
|
+
lines.push(` dataset: ${claim.dataset}`);
|
|
85
|
+
if (claim.verdict === undefined) {
|
|
86
|
+
lines.push(' verdict: (never verified)');
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
lines.push(` verdict: ${claim.verdict.status} at ${claim.verdict.at}${claim.verdict.note === undefined ? '' : ` — ${claim.verdict.note}`}`);
|
|
90
|
+
}
|
|
91
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
92
|
+
}
|
|
93
|
+
case 'summary':
|
|
94
|
+
return [{
|
|
95
|
+
type: 'text',
|
|
96
|
+
text: [
|
|
97
|
+
`ledger summary: ${value.evidenceCount} evidence, ${value.claimCount} claims, ${value.verdictCount} verdicts, ${value.tamperedCount} integrity failures`,
|
|
98
|
+
`evidence ids: ${value.evidenceIds.join(', ') || '(none)'}`,
|
|
99
|
+
`claim ids: ${value.claimIds.join(', ') || '(none)'}`,
|
|
100
|
+
].join('\n'),
|
|
101
|
+
}];
|
|
102
|
+
case 'not-found':
|
|
103
|
+
return [{ type: 'text', text: value.message }];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Build the `ledger_query` tool bound to the local provider.
|
|
108
|
+
* @param service - the local research-report provider.
|
|
109
|
+
* @returns the tool definition.
|
|
110
|
+
*/
|
|
111
|
+
export function makeLedgerQueryTool(service) {
|
|
112
|
+
return defineTool({
|
|
113
|
+
name: 'ledger_query',
|
|
114
|
+
description: [
|
|
115
|
+
'Read-only query over the verifiable research ledger (dsh-research-report): claim ↔ evidence bindings and verification verdicts.',
|
|
116
|
+
'Pass claimId or evidenceId for one entry (evidence is re-hashed on read — integrity tampered/missing is reported explicitly), or neither for a ledger summary.',
|
|
117
|
+
].join('\n'),
|
|
118
|
+
parameters: {
|
|
119
|
+
claimId: { type: 'string', description: 'Query one claim: its bindings and latest verdict.' },
|
|
120
|
+
evidenceId: { type: 'string', description: 'Query one evidence item: provenance, hash, live integrity.' },
|
|
121
|
+
},
|
|
122
|
+
output: {
|
|
123
|
+
schema: OUTPUT_SCHEMA,
|
|
124
|
+
render: (_args, value) => renderValue(value),
|
|
125
|
+
},
|
|
126
|
+
async execute(args, exec) {
|
|
127
|
+
exec.signal.throwIfAborted();
|
|
128
|
+
if (args.claimId !== undefined) {
|
|
129
|
+
const claim = await service.getClaim(args.claimId);
|
|
130
|
+
return claim === undefined
|
|
131
|
+
? { kind: 'not-found', message: `no claim "${args.claimId}" in the ledger` }
|
|
132
|
+
: { kind: 'claim', claim };
|
|
133
|
+
}
|
|
134
|
+
if (args.evidenceId !== undefined) {
|
|
135
|
+
const evidence = await service.getEvidence(args.evidenceId);
|
|
136
|
+
return evidence === undefined
|
|
137
|
+
? { kind: 'not-found', message: `no evidence "${args.evidenceId}" in the ledger` }
|
|
138
|
+
: { kind: 'evidence', evidence };
|
|
139
|
+
}
|
|
140
|
+
const [summary, evidence, claims] = await Promise.all([
|
|
141
|
+
service.summarize(),
|
|
142
|
+
service.listEvidence(),
|
|
143
|
+
service.listClaims(),
|
|
144
|
+
]);
|
|
145
|
+
return {
|
|
146
|
+
kind: 'summary',
|
|
147
|
+
...summary,
|
|
148
|
+
evidenceIds: evidence.map(item => item.id),
|
|
149
|
+
claimIds: claims.map(claim => claim.id),
|
|
150
|
+
};
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=ledger-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger-query.js","sourceRoot":"","sources":["../../../src/tools/ledger-query.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAoCnD,yCAAyC;AACzC,MAAM,kBAAkB,GAAG;IACzB,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QACtC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QACxC,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QACzC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC1C,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC9C,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC1C,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE;KACnF;CACO,CAAA;AAEV,sCAAsC;AACtC,MAAM,eAAe,GAAG;IACtB,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,Q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gBAAgB,IAAI,CAAC,UAAU,iBAAiB,EAAE;oBAClF,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAA;YACpC,CAAC;YACD,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBACpD,OAAO,CAAC,SAAS,EAAE;gBACnB,OAAO,CAAC,YAAY,EAAE;gBACtB,OAAO,CAAC,UAAU,EAAE;aACrB,CAAC,CAAA;YACF,OAAO;gBACL,IAAI,EAAE,SAAS;gBACf,GAAG,OAAO;gBACV,WAAW,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC1C,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;aACxC,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `research_report` model tool (Consumer): assemble and seal one
|
|
3
|
+
* verifiable report from ledger evidence, or — with `gather: true` — run one
|
|
4
|
+
* search round over `ctx.web` and hand the candidate/gap list back to the
|
|
5
|
+
* model for confirmation (never auto-assembles). Long runs may go to a
|
|
6
|
+
* `research-report` background job over `ctx.jobs`.
|
|
7
|
+
* @module dsh-research-report/tools/research-report
|
|
8
|
+
*/
|
|
9
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
10
|
+
import type { LocalResearchReportService } from '../provider-local.js';
|
|
11
|
+
import type { ClaimVerdict } from '../service.js';
|
|
12
|
+
/** The sealed branch of the canonical value. */
|
|
13
|
+
interface SealedValue {
|
|
14
|
+
kind: 'sealed';
|
|
15
|
+
reportDir: string;
|
|
16
|
+
reportFile: string;
|
|
17
|
+
manifestFile: string;
|
|
18
|
+
sealHash: string;
|
|
19
|
+
verdicts: ClaimVerdict[];
|
|
20
|
+
counts: {
|
|
21
|
+
verified: number;
|
|
22
|
+
unverified: number;
|
|
23
|
+
contradicted: number;
|
|
24
|
+
};
|
|
25
|
+
evidenceCount: number;
|
|
26
|
+
}
|
|
27
|
+
/** The background branch: the typed job handle. */
|
|
28
|
+
interface BackgroundValue {
|
|
29
|
+
kind: 'background';
|
|
30
|
+
jobId: string;
|
|
31
|
+
}
|
|
32
|
+
/** The gathered branch: candidates plus the explicit gap list. */
|
|
33
|
+
interface GatheredValue {
|
|
34
|
+
kind: 'gathered';
|
|
35
|
+
topic: string;
|
|
36
|
+
candidates: Array<{
|
|
37
|
+
url: string;
|
|
38
|
+
title?: string;
|
|
39
|
+
snippet?: string;
|
|
40
|
+
status: 'captured' | 'uncaptured';
|
|
41
|
+
evidenceId?: string;
|
|
42
|
+
reason?: string;
|
|
43
|
+
}>;
|
|
44
|
+
gaps: string[];
|
|
45
|
+
}
|
|
46
|
+
/** The `research_report` canonical value. */
|
|
47
|
+
export type ResearchReportValue = SealedValue | BackgroundValue | GatheredValue;
|
|
48
|
+
/** Everything the tool needs beyond the provider (the optional jobs seam). */
|
|
49
|
+
export interface ResearchReportToolDeps {
|
|
50
|
+
/** The plugin context (for the optional `ctx.jobs` lookup). */
|
|
51
|
+
ctx: Context;
|
|
52
|
+
/** The local research-report provider. */
|
|
53
|
+
service: LocalResearchReportService;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Build the `research_report` tool bound to the local provider.
|
|
57
|
+
* @param deps - the plugin context plus the provider.
|
|
58
|
+
* @returns the tool definition.
|
|
59
|
+
*/
|
|
60
|
+
export declare function makeResearchReportTool(deps: ResearchReportToolDeps): import("@deepseek-ai/dsh-tools").ToolDefinition;
|
|
61
|
+
/** The durable presentation projection (report file paths for the UI card). */
|
|
62
|
+
declare function sealedMeta(value: SealedValue): {
|
|
63
|
+
reportFile: string;
|
|
64
|
+
manifestFile: string;
|
|
65
|
+
};
|
|
66
|
+
export { sealedMeta };
|
|
67
|
+
//# sourceMappingURL=research-report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"research-report.d.ts","sourceRoot":"","sources":["../../../src/tools/research-report.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,KAAK,EAGV,YAAY,EAEb,MAAM,eAAe,CAAA;AAEtB,gDAAgD;AAChD,UAAU,WAAW;IACnB,IAAI,EAAE,QAAQ,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,YAAY,EAAE,CAAA;IACxB,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAA;IACtE,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,mDAAmD;AACnD,UAAU,eAAe;IACvB,IAAI,EAAE,YAAY,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,kEAAkE;AAClE,UAAU,aAAa;IACrB,IAAI,EAAE,UAAU,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,KAAK,CAAC;QAChB,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,MAAM,EAAE,UAAU,GAAG,YAAY,CAAA;QACjC,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAC,CAAA;IACF,IAAI,EAAE,MAAM,EAAE,CAAA;CACf;AAED,6CAA6C;AAC7C,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,eAAe,GAAG,aAAa,CAAA;AAuJ/E,8EAA8E;AAC9E,MAAM,WAAW,sBAAsB;IACrC,+DAA+D;IAC/D,GAAG,EAAE,OAAO,CAAA;IACZ,0CAA0C;IAC1C,OAAO,EAAE,0BAA0B,CAAA;CACpC;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,sBAAsB,mDAsFlE;AAED,+EAA+E;AAC/E,iBAAS,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAEpF;AA+GD,OAAO,EAAE,UAAU,EAAE,CAAA"}
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `research_report` model tool (Consumer): assemble and seal one
|
|
3
|
+
* verifiable report from ledger evidence, or — with `gather: true` — run one
|
|
4
|
+
* search round over `ctx.web` and hand the candidate/gap list back to the
|
|
5
|
+
* model for confirmation (never auto-assembles). Long runs may go to a
|
|
6
|
+
* `research-report` background job over `ctx.jobs`.
|
|
7
|
+
* @module dsh-research-report/tools/research-report
|
|
8
|
+
*/
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
11
|
+
import { CaptureError } from "../gather.js";
|
|
12
|
+
/** The verdict item schema fragment. */
|
|
13
|
+
const verdictSchema = {
|
|
14
|
+
type: 'object',
|
|
15
|
+
additionalProperties: false,
|
|
16
|
+
properties: {
|
|
17
|
+
claimId: { type: 'string', required: true },
|
|
18
|
+
status: { type: 'string', required: true, enum: ['verified', 'unverified', 'contradicted'] },
|
|
19
|
+
note: { type: 'string' },
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
/** The tool's output schema (all three branches). */
|
|
23
|
+
const OUTPUT_SCHEMA = {
|
|
24
|
+
type: 'object',
|
|
25
|
+
additionalProperties: false,
|
|
26
|
+
properties: {
|
|
27
|
+
kind: { type: 'string', required: true, enum: ['sealed', 'background', 'gathered'] },
|
|
28
|
+
reportDir: { type: 'string' },
|
|
29
|
+
reportFile: { type: 'string' },
|
|
30
|
+
manifestFile: { type: 'string' },
|
|
31
|
+
sealHash: { type: 'string' },
|
|
32
|
+
verdicts: { type: 'array', items: verdictSchema },
|
|
33
|
+
counts: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
additionalProperties: false,
|
|
36
|
+
properties: {
|
|
37
|
+
verified: { type: 'integer', required: true },
|
|
38
|
+
unverified: { type: 'integer', required: true },
|
|
39
|
+
contradicted: { type: 'integer', required: true },
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
evidenceCount: { type: 'integer' },
|
|
43
|
+
jobId: { type: 'string' },
|
|
44
|
+
topic: { type: 'string' },
|
|
45
|
+
candidates: {
|
|
46
|
+
type: 'array',
|
|
47
|
+
items: {
|
|
48
|
+
type: 'object',
|
|
49
|
+
additionalProperties: false,
|
|
50
|
+
properties: {
|
|
51
|
+
url: { type: 'string', required: true },
|
|
52
|
+
title: { type: 'string' },
|
|
53
|
+
snippet: { type: 'string' },
|
|
54
|
+
status: { type: 'string', required: true, enum: ['captured', 'uncaptured'] },
|
|
55
|
+
evidenceId: { type: 'string' },
|
|
56
|
+
reason: { type: 'string' },
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
gaps: { type: 'array', items: { type: 'string' } },
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
/** The sections parameter schema fragment. */
|
|
64
|
+
const sectionsSchema = {
|
|
65
|
+
type: 'array',
|
|
66
|
+
items: {
|
|
67
|
+
type: 'object',
|
|
68
|
+
additionalProperties: false,
|
|
69
|
+
properties: {
|
|
70
|
+
heading: { type: 'string', required: true },
|
|
71
|
+
paragraphs: {
|
|
72
|
+
type: 'array',
|
|
73
|
+
required: true,
|
|
74
|
+
items: {
|
|
75
|
+
type: 'object',
|
|
76
|
+
additionalProperties: false,
|
|
77
|
+
properties: {
|
|
78
|
+
text: { type: 'string', required: true },
|
|
79
|
+
claimIds: { type: 'array', items: { type: 'string' } },
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
/** The claims parameter schema fragment (frozen shape + the optional numeric bridge). */
|
|
87
|
+
const claimsSchema = {
|
|
88
|
+
type: 'array',
|
|
89
|
+
items: {
|
|
90
|
+
type: 'object',
|
|
91
|
+
additionalProperties: false,
|
|
92
|
+
properties: {
|
|
93
|
+
id: { type: 'string', required: true },
|
|
94
|
+
text: { type: 'string', required: true },
|
|
95
|
+
evidenceIds: { type: 'array', required: true, items: { type: 'string' } },
|
|
96
|
+
dataset: { type: 'string' },
|
|
97
|
+
citations: {
|
|
98
|
+
type: 'array',
|
|
99
|
+
items: {
|
|
100
|
+
type: 'object',
|
|
101
|
+
additionalProperties: false,
|
|
102
|
+
properties: {
|
|
103
|
+
id: { type: 'string', required: true },
|
|
104
|
+
path: { type: 'string', required: true },
|
|
105
|
+
value: { oneOf: [{ type: 'number' }, { type: 'string' }], required: true },
|
|
106
|
+
tolerance: { type: 'number' },
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
/** Render the sealed branch as model-facing text (gaps/contradictions explicit). */
|
|
114
|
+
function renderSealed(value) {
|
|
115
|
+
const lines = [
|
|
116
|
+
`report sealed: ${value.reportDir}`,
|
|
117
|
+
`seal (sha256 of manifest.json): ${value.sealHash}`,
|
|
118
|
+
`claims: ${value.counts.verified} verified / ${value.counts.unverified} unverified / ${value.counts.contradicted} contradicted (of ${value.verdicts.length}); evidence bound: ${value.evidenceCount}`,
|
|
119
|
+
];
|
|
120
|
+
const problems = value.verdicts.filter(verdict => verdict.status !== 'verified');
|
|
121
|
+
if (problems.length > 0) {
|
|
122
|
+
lines.push('', 'claims needing attention (visible markers kept in the report body):');
|
|
123
|
+
for (const verdict of problems) {
|
|
124
|
+
lines.push(`- [${verdict.status}] ${verdict.claimId}${verdict.note === undefined ? '' : ` — ${verdict.note}`}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return lines.join('\n');
|
|
128
|
+
}
|
|
129
|
+
/** Render the canonical value as model-facing text. */
|
|
130
|
+
function renderValue(value) {
|
|
131
|
+
switch (value.kind) {
|
|
132
|
+
case 'background':
|
|
133
|
+
return [{
|
|
134
|
+
type: 'text',
|
|
135
|
+
text: `started background report job ${value.jobId}; read progress with job_output and stop it with job_kill — the final output names the sealed directory and seal hash`,
|
|
136
|
+
}];
|
|
137
|
+
case 'gathered': {
|
|
138
|
+
const lines = [`gathered ${value.candidates.length} candidate source(s) for "${value.topic}" (nothing assembled yet — confirm the evidence set first):`];
|
|
139
|
+
for (const candidate of value.candidates) {
|
|
140
|
+
lines.push(candidate.status === 'captured'
|
|
141
|
+
? `- captured ${candidate.evidenceId}: ${candidate.title ?? candidate.url}`
|
|
142
|
+
: `- uncaptured ${candidate.url}: ${candidate.reason ?? 'unknown reason'}`);
|
|
143
|
+
}
|
|
144
|
+
if (value.gaps.length > 0) {
|
|
145
|
+
lines.push('', 'gaps to close:');
|
|
146
|
+
for (const gap of value.gaps)
|
|
147
|
+
lines.push(`- ${gap}`);
|
|
148
|
+
}
|
|
149
|
+
lines.push('', 'next: call research_report again with evidenceRefs chosen from the captured ids (or add more with evidence_add).');
|
|
150
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
151
|
+
}
|
|
152
|
+
case 'sealed':
|
|
153
|
+
return [{ type: 'text', text: renderSealed(value) }];
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Build the `research_report` tool bound to the local provider.
|
|
158
|
+
* @param deps - the plugin context plus the provider.
|
|
159
|
+
* @returns the tool definition.
|
|
160
|
+
*/
|
|
161
|
+
export function makeResearchReportTool(deps) {
|
|
162
|
+
const { service } = deps;
|
|
163
|
+
return defineTool({
|
|
164
|
+
name: 'research_report',
|
|
165
|
+
description: [
|
|
166
|
+
'Assemble and seal a verifiable research report (dsh-research-report).',
|
|
167
|
+
'',
|
|
168
|
+
'Every claim must bind evidence already in the ledger (evidence_add) and is verified against the stored bytes: numbers and quoted spans must be locatable verbatim. The report directory is versioned and sealed (manifest.json + SHA-256 seal hash); unverified or contradicted claims keep a visible [未核实] / [与证据矛盾] marker in the body and are listed in Appendix A — they are never silently passed.',
|
|
169
|
+
'',
|
|
170
|
+
'Optional convenience: set gather: true to run ONE search round over the topic via the harness web capability. Captured snapshots are registered as evidence; the candidate list plus an explicit gap list come back for your confirmation — nothing is assembled automatically.',
|
|
171
|
+
'',
|
|
172
|
+
'Set background: true for a background job (returns a job id; read with job_output, stop with job_kill).',
|
|
173
|
+
].join('\n'),
|
|
174
|
+
parameters: {
|
|
175
|
+
topic: { type: 'string', required: true, description: 'The research topic (names the versioned report directory).' },
|
|
176
|
+
title: { type: 'string', description: 'Report title (defaults to "Research report: <topic>").' },
|
|
177
|
+
sections: { ...sectionsSchema, description: 'Report body: heading + paragraphs; each paragraph may cite claim ids.' },
|
|
178
|
+
claims: { ...claimsSchema, description: 'Claim registrations: id, text, bound evidence ids, and the optional dataset citation bridge.' },
|
|
179
|
+
evidenceRefs: {
|
|
180
|
+
type: 'array',
|
|
181
|
+
items: { type: 'string' },
|
|
182
|
+
description: 'Ledger evidence ids (from evidence_add / gather) to bind into this report.',
|
|
183
|
+
},
|
|
184
|
+
gather: { type: 'boolean', description: 'Run one search round and return candidates + gaps instead of assembling.' },
|
|
185
|
+
depth: { type: 'string', enum: ['quick', 'standard', 'deep'], description: 'Gather depth: quick=3, standard=5, deep=8 sources.' },
|
|
186
|
+
background: { type: 'boolean', description: 'Assemble as a background job (ctx.jobs) and return the job id immediately.' },
|
|
187
|
+
},
|
|
188
|
+
output: {
|
|
189
|
+
schema: OUTPUT_SCHEMA,
|
|
190
|
+
render: (_args, value) => renderValue(value),
|
|
191
|
+
presentationMeta: (_args, value) => {
|
|
192
|
+
const result = value;
|
|
193
|
+
return result.kind === 'sealed' ? sealedMeta(result) : {};
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
async execute(args, exec) {
|
|
197
|
+
exec.signal.throwIfAborted();
|
|
198
|
+
const session = exec.agent?.session;
|
|
199
|
+
if (args.gather === true) {
|
|
200
|
+
const outcome = await service.gather(args.topic, args.depth ?? 'standard', exec.signal, session);
|
|
201
|
+
return {
|
|
202
|
+
kind: 'gathered',
|
|
203
|
+
topic: outcome.topic,
|
|
204
|
+
candidates: outcome.candidates,
|
|
205
|
+
gaps: outcome.gaps,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
const request = await buildRequest(service, args);
|
|
209
|
+
if (args.background === true) {
|
|
210
|
+
const jobs = deps.ctx.get('jobs');
|
|
211
|
+
if (jobs === undefined) {
|
|
212
|
+
throw new Error('background jobs unavailable: this composition mounts no ctx.jobs (load @deepseek-ai/dsh-jobs-local and @deepseek-ai/dsh-tool-jobs), or call without background');
|
|
213
|
+
}
|
|
214
|
+
if (exec.signal.aborted)
|
|
215
|
+
throw new Error('tool call aborted');
|
|
216
|
+
const jobId = jobs.start({
|
|
217
|
+
kind: 'research-report',
|
|
218
|
+
label: `assemble report: ${args.topic}`,
|
|
219
|
+
...exec.agent === undefined ? {} : { owner: exec.agent },
|
|
220
|
+
run: () => startAssembleJob(service, request, session === undefined ? {} : { session }),
|
|
221
|
+
});
|
|
222
|
+
return { kind: 'background', jobId };
|
|
223
|
+
}
|
|
224
|
+
const result = await service.assemble(request, session === undefined ? {} : { session });
|
|
225
|
+
return sealedValue(result.reportDir, result.sealHash, result.verdicts, request.evidence.length);
|
|
226
|
+
},
|
|
227
|
+
presentCall: (args) => {
|
|
228
|
+
const topic = args.topic;
|
|
229
|
+
return { card: 'generic', title: `Research report: ${typeof topic === 'string' ? topic : ''}` };
|
|
230
|
+
},
|
|
231
|
+
presentResult: (_args, result) => {
|
|
232
|
+
// The sealed report files are the deliverables: declare the edit intent
|
|
233
|
+
// and the produced paths so the UI lists them (replay-safe: the paths
|
|
234
|
+
// ride the persisted presentation meta, not any live state).
|
|
235
|
+
const meta = result.meta;
|
|
236
|
+
if (meta?.reportFile === undefined || meta.manifestFile === undefined)
|
|
237
|
+
return undefined;
|
|
238
|
+
return {
|
|
239
|
+
card: 'generic',
|
|
240
|
+
title: 'Sealed research report',
|
|
241
|
+
kind: 'edit',
|
|
242
|
+
locations: [{ path: meta.reportFile }, { path: meta.manifestFile }],
|
|
243
|
+
};
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/** The durable presentation projection (report file paths for the UI card). */
|
|
248
|
+
function sealedMeta(value) {
|
|
249
|
+
return { reportFile: value.reportFile, manifestFile: value.manifestFile };
|
|
250
|
+
}
|
|
251
|
+
/** Shape the sealed canonical value. */
|
|
252
|
+
function sealedValue(reportDir, sealHash, verdicts, evidenceCount) {
|
|
253
|
+
const counts = { verified: 0, unverified: 0, contradicted: 0 };
|
|
254
|
+
for (const verdict of verdicts)
|
|
255
|
+
counts[verdict.status] += 1;
|
|
256
|
+
return {
|
|
257
|
+
kind: 'sealed',
|
|
258
|
+
reportDir,
|
|
259
|
+
reportFile: path.join(reportDir, 'report.md'),
|
|
260
|
+
manifestFile: path.join(reportDir, 'manifest.json'),
|
|
261
|
+
sealHash,
|
|
262
|
+
verdicts,
|
|
263
|
+
counts,
|
|
264
|
+
evidenceCount,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Build the frozen assemble request from the tool args: resolve evidenceRefs
|
|
269
|
+
* through the ledger (unknown ids fail loud) and default the title.
|
|
270
|
+
* @param service - the local provider.
|
|
271
|
+
* @param args - the validated tool args.
|
|
272
|
+
* @returns the assemble request.
|
|
273
|
+
*/
|
|
274
|
+
async function buildRequest(service, args) {
|
|
275
|
+
const refs = args.evidenceRefs ?? [];
|
|
276
|
+
const evidence = [];
|
|
277
|
+
for (const ref of refs) {
|
|
278
|
+
const record = await service.getEvidence(ref);
|
|
279
|
+
const read = await service.readEvidenceContent(ref);
|
|
280
|
+
if (record === undefined || read === undefined) {
|
|
281
|
+
throw new Error(`unknown evidence id "${ref}" in evidenceRefs — register it with evidence_add first`);
|
|
282
|
+
}
|
|
283
|
+
evidence.push({
|
|
284
|
+
id: record.id,
|
|
285
|
+
title: record.title,
|
|
286
|
+
origin: record.origin,
|
|
287
|
+
content: read.content,
|
|
288
|
+
capturedAt: record.capturedAt,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
return {
|
|
292
|
+
title: args.title ?? `Research report: ${args.topic}`,
|
|
293
|
+
topic: args.topic,
|
|
294
|
+
evidence,
|
|
295
|
+
sections: args.sections ?? [],
|
|
296
|
+
claims: args.claims ?? [],
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Start the background assemble job body. The job owns its cancellation
|
|
301
|
+
* signal; settlement flushes the sealed summary into the job output.
|
|
302
|
+
* @param service - the local provider.
|
|
303
|
+
* @param request - the frozen assemble request.
|
|
304
|
+
* @param context - the assemble context (owning session, when known).
|
|
305
|
+
* @returns the job hooks.
|
|
306
|
+
*/
|
|
307
|
+
function startAssembleJob(service, request, context) {
|
|
308
|
+
const abort = new AbortController();
|
|
309
|
+
const progress = [`assembling report: ${request.topic}`];
|
|
310
|
+
const done = Promise.withResolvers();
|
|
311
|
+
let settled = false;
|
|
312
|
+
const settle = (outcome) => {
|
|
313
|
+
if (settled)
|
|
314
|
+
return;
|
|
315
|
+
settled = true;
|
|
316
|
+
done.resolve(outcome);
|
|
317
|
+
};
|
|
318
|
+
void service.assemble(request, context)
|
|
319
|
+
.then((result) => {
|
|
320
|
+
const value = sealedValue(result.reportDir, result.sealHash, result.verdicts, request.evidence.length);
|
|
321
|
+
progress.push(renderSealed(value));
|
|
322
|
+
settle({ status: 'completed', detail: `sealed ${result.sealHash.slice(0, 12)}`, output: renderSealed(value) });
|
|
323
|
+
})
|
|
324
|
+
.catch((error) => {
|
|
325
|
+
const message = error instanceof CaptureError || error instanceof Error ? error.message : String(error);
|
|
326
|
+
progress.push(`assemble failed: ${message}`);
|
|
327
|
+
settle({ status: 'failed', detail: message.length > 200 ? `${message.slice(0, 197)}…` : message });
|
|
328
|
+
});
|
|
329
|
+
return {
|
|
330
|
+
cancel(reason) {
|
|
331
|
+
abort.abort(reason ?? 'cancelled');
|
|
332
|
+
settle({ status: 'killed', detail: `cancelled: ${reason ?? 'no reason given'}` });
|
|
333
|
+
},
|
|
334
|
+
done: done.promise,
|
|
335
|
+
readOutput: () => {
|
|
336
|
+
if (progress.length === 0)
|
|
337
|
+
return '';
|
|
338
|
+
return `${progress.splice(0, progress.length).join('\n')}\n`;
|
|
339
|
+
},
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
// `sealedMeta` feeds `output.presentationMeta`: the durable, replay-safe
|
|
343
|
+
// projection the UI card reads back from `tool/result.meta`.
|
|
344
|
+
export { sealedMeta };
|
|
345
|
+
//# sourceMappingURL=research-report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"research-report.js","sourceRoot":"","sources":["../../../src/tools/research-report.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAA;AAG5B,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AA6C3C,wCAAwC;AACxC,MAAM,aAAa,GAAG;IACpB,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC3C,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,cA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