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.
Files changed (71) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE +201 -0
  3. package/README.es.md +155 -0
  4. package/README.hi.md +155 -0
  5. package/README.md +155 -0
  6. package/README.pt.md +155 -0
  7. package/README.zh.md +155 -0
  8. package/THIRD_PARTY_NOTICES.md +21 -0
  9. package/cordis.patch.yml +24 -0
  10. package/lib/index.js +2143 -0
  11. package/lib/types/assemble.d.ts +123 -0
  12. package/lib/types/assemble.d.ts.map +1 -0
  13. package/lib/types/assemble.js +239 -0
  14. package/lib/types/assemble.js.map +1 -0
  15. package/lib/types/config.d.ts +48 -0
  16. package/lib/types/config.d.ts.map +1 -0
  17. package/lib/types/config.js +60 -0
  18. package/lib/types/config.js.map +1 -0
  19. package/lib/types/gather.d.ts +119 -0
  20. package/lib/types/gather.d.ts.map +1 -0
  21. package/lib/types/gather.js +165 -0
  22. package/lib/types/gather.js.map +1 -0
  23. package/lib/types/index.d.ts +51 -0
  24. package/lib/types/index.d.ts.map +1 -0
  25. package/lib/types/index.js +71 -0
  26. package/lib/types/index.js.map +1 -0
  27. package/lib/types/ledger.d.ts +159 -0
  28. package/lib/types/ledger.d.ts.map +1 -0
  29. package/lib/types/ledger.js +276 -0
  30. package/lib/types/ledger.js.map +1 -0
  31. package/lib/types/provider-local.d.ts +137 -0
  32. package/lib/types/provider-local.d.ts.map +1 -0
  33. package/lib/types/provider-local.js +418 -0
  34. package/lib/types/provider-local.js.map +1 -0
  35. package/lib/types/service.d.ts +302 -0
  36. package/lib/types/service.d.ts.map +1 -0
  37. package/lib/types/service.js +31 -0
  38. package/lib/types/service.js.map +1 -0
  39. package/lib/types/tools/evidence-add.d.ts +36 -0
  40. package/lib/types/tools/evidence-add.d.ts.map +1 -0
  41. package/lib/types/tools/evidence-add.js +107 -0
  42. package/lib/types/tools/evidence-add.js.map +1 -0
  43. package/lib/types/tools/ledger-query.d.ts +42 -0
  44. package/lib/types/tools/ledger-query.d.ts.map +1 -0
  45. package/lib/types/tools/ledger-query.js +154 -0
  46. package/lib/types/tools/ledger-query.js.map +1 -0
  47. package/lib/types/tools/research-report.d.ts +67 -0
  48. package/lib/types/tools/research-report.d.ts.map +1 -0
  49. package/lib/types/tools/research-report.js +345 -0
  50. package/lib/types/tools/research-report.js.map +1 -0
  51. package/lib/types/verify.d.ts +128 -0
  52. package/lib/types/verify.d.ts.map +1 -0
  53. package/lib/types/verify.js +208 -0
  54. package/lib/types/verify.js.map +1 -0
  55. package/lib/types/version.d.ts +7 -0
  56. package/lib/types/version.d.ts.map +1 -0
  57. package/lib/types/version.js +7 -0
  58. package/lib/types/version.js.map +1 -0
  59. package/package.json +147 -0
  60. package/src/assemble.ts +302 -0
  61. package/src/config.ts +97 -0
  62. package/src/gather.ts +239 -0
  63. package/src/index.ts +139 -0
  64. package/src/ledger.ts +344 -0
  65. package/src/provider-local.ts +489 -0
  66. package/src/service.ts +322 -0
  67. package/src/tools/evidence-add.ts +132 -0
  68. package/src/tools/ledger-query.ts +191 -0
  69. package/src/tools/research-report.ts +424 -0
  70. package/src/verify.ts +285 -0
  71. package/src/version.ts +7 -0
@@ -0,0 +1,302 @@
1
+ /**
2
+ * Service Definition of the verifiable research-report seam (`ctx.researchReport`).
3
+ *
4
+ * Three roles in one package (they evolve together): this file owns the
5
+ * Definition — the frozen `assemble` contract, the evidence/claim vocabulary,
6
+ * and the typed session events; `provider-local.ts` owns the local Provider
7
+ * (filesystem ledger + byte-level verification); `tools/` owns the model-facing
8
+ * Consumers.
9
+ *
10
+ * The `ReportSectionInput` / `EvidenceInput` / `AssembleReportRequest` /
11
+ * `AssembleReportResult` block below is BYTE-FROZEN: sibling plugins
12
+ * (dsh-industry-research) consume `ctx.researchReport.assemble` against this
13
+ * exact text. `scripts/verify-frozen-contract.mjs` gates drift.
14
+ *
15
+ * @module dsh-research-report/service
16
+ */
17
+ import { Context, Service } from '@deepseek-ai/cordis';
18
+ export interface ReportSectionInput {
19
+ heading: string;
20
+ /** Paragraphs; each claim string may carry citations. */
21
+ paragraphs: Array<{
22
+ text: string;
23
+ claimIds?: string[];
24
+ }>;
25
+ }
26
+ export interface EvidenceInput {
27
+ id: string;
28
+ title: string;
29
+ /** Where the evidence came from (URL or workspace path). */
30
+ origin: string;
31
+ /** Verbatim content snapshot used for byte-level checks. */
32
+ content: string;
33
+ /** ISO-8601 time the snapshot was captured. */
34
+ capturedAt: string;
35
+ }
36
+ export interface AssembleReportRequest {
37
+ title: string;
38
+ topic: string;
39
+ evidence: EvidenceInput[];
40
+ sections: ReportSectionInput[];
41
+ /** Every claim id referenced in sections must be registered here. */
42
+ claims: Array<{
43
+ id: string;
44
+ text: string;
45
+ evidenceIds: string[];
46
+ }>;
47
+ }
48
+ export interface AssembleReportResult {
49
+ /** Workspace path of the sealed report directory (report.md + manifest.json). */
50
+ reportDir: string;
51
+ /** SHA-256 content hash of manifest.json. */
52
+ sealHash: string;
53
+ /** Per-claim verification verdicts. */
54
+ verdicts: Array<{
55
+ claimId: string;
56
+ status: 'verified' | 'unverified' | 'contradicted';
57
+ note?: string;
58
+ }>;
59
+ }
60
+ /** The three-state verification verdict of one claim. */
61
+ export type VerdictStatus = 'verified' | 'unverified' | 'contradicted';
62
+ /** One claim's verification outcome (same fields as the frozen result item). */
63
+ export interface ClaimVerdict {
64
+ /** The claim this verdict belongs to. */
65
+ claimId: string;
66
+ /** Byte-level (and optional numeric-bridge) outcome. */
67
+ status: VerdictStatus;
68
+ /** Human-readable evidence note (missing citations, contradiction detail, …). */
69
+ note?: string;
70
+ }
71
+ /**
72
+ * Claim registration accepted by the tools layer: the frozen claim shape plus
73
+ * the OPTIONAL numeric-bridge extension consumed when the claim's numbers cite
74
+ * a structured workspace dataset and `ctx.dataQuality` is mounted.
75
+ */
76
+ export interface ClaimRegistration {
77
+ /** Stable claim id chosen by the caller. */
78
+ id: string;
79
+ /** The claim text; numbers and quoted spans are byte-checked against evidence. */
80
+ text: string;
81
+ /** Ledger evidence ids this claim binds to. */
82
+ evidenceIds: string[];
83
+ /** Workspace-relative dataset path (CSV/JSON) for the optional numeric bridge. */
84
+ dataset?: string;
85
+ /** Dataset citations for `ctx.dataQuality.verifyCitations` (requires `dataset`). */
86
+ citations?: Array<{
87
+ /** Stable id chosen by the caller, echoed back in results. */
88
+ id: string;
89
+ /** JSON-path-ish locator, e.g. "rows[3].nav". */
90
+ path: string;
91
+ /** The value as cited in the claim. */
92
+ value: number | string;
93
+ /** Optional relative tolerance for numeric comparison, e.g. 0.01 = 1%. */
94
+ tolerance?: number;
95
+ }>;
96
+ }
97
+ /** Input for registering one evidence snapshot in the ledger. */
98
+ export interface AddEvidenceInput {
99
+ /** Caller-chosen evidence id; omitted derives a content-addressed `ev-<hash12>` id. */
100
+ id?: string;
101
+ /** Display title. */
102
+ title: string;
103
+ /** Where the evidence came from (URL or workspace path). */
104
+ origin: string;
105
+ /** Verbatim content snapshot used for byte-level checks. */
106
+ content: string;
107
+ /** ISO-8601 capture time; defaults to the registration clock. */
108
+ capturedAt?: string;
109
+ }
110
+ /** Durable ledger facts of one evidence snapshot. */
111
+ export interface EvidenceRecord {
112
+ /** Ledger id (caller-chosen or `ev-<hash12>`). */
113
+ id: string;
114
+ /** SHA-256 hex of the snapshot content (the object address). */
115
+ hash: string;
116
+ /** Display title. */
117
+ title: string;
118
+ /** Where the evidence came from (URL or workspace path). */
119
+ origin: string;
120
+ /** ISO-8601 capture time. */
121
+ capturedAt: string;
122
+ /** UTF-8 byte length of the snapshot. */
123
+ bytes: number;
124
+ }
125
+ /** Integrity state of a stored snapshot, recomputed on every read. */
126
+ export type EvidenceIntegrity = 'ok' | 'tampered' | 'missing';
127
+ /** Read view of one ledger evidence item; content stays in the object store. */
128
+ export interface EvidenceView extends EvidenceRecord {
129
+ /** `ok` when the object bytes still hash to the indexed value. */
130
+ integrity: EvidenceIntegrity;
131
+ }
132
+ /** Stored verdict record (latest write wins on read). */
133
+ export interface StoredVerdict extends ClaimVerdict {
134
+ /** ISO-8601 time the verdict was written. */
135
+ at: string;
136
+ }
137
+ /** Read view of one registered claim and its latest verdict, when any. */
138
+ export interface ClaimView {
139
+ /** The claim id. */
140
+ id: string;
141
+ /** The claim text. */
142
+ text: string;
143
+ /** Bound evidence ids. */
144
+ evidenceIds: string[];
145
+ /** Optional numeric-bridge dataset citation carried from registration. */
146
+ dataset?: string;
147
+ /** Latest stored verdict; absent when the claim was never verified. */
148
+ verdict?: StoredVerdict;
149
+ }
150
+ /** Aggregate ledger counts for summary queries. */
151
+ export interface LedgerSummary {
152
+ /** Registered evidence count. */
153
+ evidenceCount: number;
154
+ /** Registered claim count. */
155
+ claimCount: number;
156
+ /** Claims carrying a stored verdict. */
157
+ verdictCount: number;
158
+ /** Evidence items whose object failed the read-time re-hash. */
159
+ tamperedCount: number;
160
+ }
161
+ /** Optional assemble-time context: the owning session for event logging. */
162
+ export interface AssembleContext {
163
+ /** The session whose log receives the research-report/* events, when known. */
164
+ session?: import('@deepseek-ai/dsh-session').Session;
165
+ }
166
+ declare module '@deepseek-ai/dsh-session/types' {
167
+ interface SessionEventMap {
168
+ /**
169
+ * One evidence snapshot entered the ledger (id ↔ content hash binding).
170
+ * Log-only audit record; the ledger itself is the durable source of truth.
171
+ * @mode emit
172
+ * @param id - ledger evidence id.
173
+ * @param hash - SHA-256 of the snapshot bytes.
174
+ * @param origin - where the evidence came from (URL or workspace path).
175
+ * @param title - display title.
176
+ * @param capturedAt - ISO-8601 capture time.
177
+ * @param bytes - UTF-8 byte length.
178
+ * @param deduplicated - true when the content was already stored.
179
+ */
180
+ 'research-report/evidence': {
181
+ id: string;
182
+ hash: string;
183
+ origin: string;
184
+ title: string;
185
+ capturedAt: string;
186
+ bytes: number;
187
+ deduplicated: boolean;
188
+ };
189
+ /**
190
+ * One claim's verification verdict was written back to the ledger.
191
+ * Log-only audit record; `verdicts.jsonl` is the durable source of truth.
192
+ * @mode emit
193
+ * @param claimId - the verified claim.
194
+ * @param status - verified | unverified | contradicted.
195
+ * @param note - human-readable evidence note.
196
+ * @param evidenceIds - the bindings the verdict was computed over.
197
+ */
198
+ 'research-report/verify': {
199
+ claimId: string;
200
+ status: VerdictStatus;
201
+ note?: string;
202
+ evidenceIds: string[];
203
+ };
204
+ /**
205
+ * A report directory was sealed (manifest written, hash computed).
206
+ * Log-only audit record; `manifest.json` is the durable source of truth.
207
+ * @mode emit
208
+ * @param reportDir - workspace path of the sealed report directory.
209
+ * @param sealHash - SHA-256 of manifest.json.
210
+ * @param topic - the report topic.
211
+ * @param title - the report title.
212
+ * @param verdicts - the per-claim outcomes the seal covers.
213
+ */
214
+ 'research-report/seal': {
215
+ reportDir: string;
216
+ sealHash: string;
217
+ topic: string;
218
+ title: string;
219
+ verdicts: ClaimVerdict[];
220
+ };
221
+ }
222
+ }
223
+ declare module '@deepseek-ai/dsh-jobs' {
224
+ interface JobKindMap {
225
+ /** Report assembly jobs started by the research_report tool. */
226
+ 'research-report': 'research-report';
227
+ }
228
+ }
229
+ declare module '@deepseek-ai/cordis' {
230
+ interface Context {
231
+ researchReport: ResearchReportService;
232
+ }
233
+ }
234
+ /**
235
+ * The verifiable research-report service (`ctx.researchReport`).
236
+ *
237
+ * `assemble` is the frozen cross-plugin surface: validate the request, verify
238
+ * every claim against the ledger's immutable snapshots, render `report.md`
239
+ * (unverified/contradicted claims stay visibly marked in the body), write
240
+ * `manifest.json`, and seal the directory with the manifest's SHA-256.
241
+ */
242
+ export declare abstract class ResearchReportService extends Service {
243
+ constructor(ctx: Context);
244
+ /**
245
+ * Assemble and seal one report.
246
+ * @param request - the frozen assemble request (see the module-level block).
247
+ * @returns the sealed directory, its seal hash, and the per-claim verdicts.
248
+ */
249
+ abstract assemble(request: AssembleReportRequest): Promise<AssembleReportResult>;
250
+ /**
251
+ * Register one evidence snapshot (content-addressed; same content dedupes).
252
+ * @param input - the snapshot and its provenance.
253
+ * @returns the durable record and whether this call created it.
254
+ */
255
+ abstract addEvidence(input: AddEvidenceInput): Promise<{
256
+ record: EvidenceRecord;
257
+ deduplicated: boolean;
258
+ }>;
259
+ /**
260
+ * Re-run verification for one registered claim and write back the verdict.
261
+ * @param claimId - the claim to verify.
262
+ * @returns the fresh verdict.
263
+ */
264
+ abstract verifyClaim(claimId: string): Promise<ClaimVerdict>;
265
+ /**
266
+ * Read one evidence item; the snapshot is re-hashed on every read.
267
+ * @param evidenceId - the ledger id.
268
+ * @returns the view (with integrity), or undefined when unknown.
269
+ */
270
+ abstract getEvidence(evidenceId: string): Promise<EvidenceView | undefined>;
271
+ /**
272
+ * Read the raw snapshot bytes of one evidence item (verification path).
273
+ * @param evidenceId - the ledger id.
274
+ * @returns the content plus integrity state, or undefined when unknown.
275
+ */
276
+ abstract readEvidenceContent(evidenceId: string): Promise<{
277
+ content: string;
278
+ integrity: EvidenceIntegrity;
279
+ } | undefined>;
280
+ /**
281
+ * Read one registered claim with its latest verdict.
282
+ * @param claimId - the claim id.
283
+ * @returns the view, or undefined when unknown.
284
+ */
285
+ abstract getClaim(claimId: string): Promise<ClaimView | undefined>;
286
+ /**
287
+ * List every registered evidence item (re-hashed on read).
288
+ * @returns all evidence views in registration order.
289
+ */
290
+ abstract listEvidence(): Promise<EvidenceView[]>;
291
+ /**
292
+ * List every registered claim.
293
+ * @returns all claim views in registration order.
294
+ */
295
+ abstract listClaims(): Promise<ClaimView[]>;
296
+ /**
297
+ * Aggregate ledger counts.
298
+ * @returns the summary (evidence/claim/verdict/tamper counts).
299
+ */
300
+ abstract summarize(): Promise<LedgerSummary>;
301
+ }
302
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAItD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EA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H,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAElE;;;OAGG;IACH,QAAQ,CAAC,YAAY,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAEhD;;;OAGG;IACH,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAE3C;;;OAGG;IACH,QAAQ,CAAC,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC;CAC7C"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Service Definition of the verifiable research-report seam (`ctx.researchReport`).
3
+ *
4
+ * Three roles in one package (they evolve together): this file owns the
5
+ * Definition — the frozen `assemble` contract, the evidence/claim vocabulary,
6
+ * and the typed session events; `provider-local.ts` owns the local Provider
7
+ * (filesystem ledger + byte-level verification); `tools/` owns the model-facing
8
+ * Consumers.
9
+ *
10
+ * The `ReportSectionInput` / `EvidenceInput` / `AssembleReportRequest` /
11
+ * `AssembleReportResult` block below is BYTE-FROZEN: sibling plugins
12
+ * (dsh-industry-research) consume `ctx.researchReport.assemble` against this
13
+ * exact text. `scripts/verify-frozen-contract.mjs` gates drift.
14
+ *
15
+ * @module dsh-research-report/service
16
+ */
17
+ import { Service } from '@deepseek-ai/cordis';
18
+ /**
19
+ * The verifiable research-report service (`ctx.researchReport`).
20
+ *
21
+ * `assemble` is the frozen cross-plugin surface: validate the request, verify
22
+ * every claim against the ledger's immutable snapshots, render `report.md`
23
+ * (unverified/contradicted claims stay visibly marked in the body), write
24
+ * `manifest.json`, and seal the directory with the manifest's SHA-256.
25
+ */
26
+ export class ResearchReportService extends Service {
27
+ constructor(ctx) {
28
+ super(ctx, 'researchReport');
29
+ }
30
+ }
31
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAW,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAwOtD;;;;;;;GAOG;AACH,MAAM,OAAgB,qBAAsB,SAAQ,OAAO;IACzD,YAAY,GAAY;QACtB,KAAK,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAA;IAC9B,CAAC;CA6DF"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The `evidence_add` model tool (Consumer): register one evidence snapshot in
3
+ * the ledger. `content` given inline is used verbatim; absent, the origin is
4
+ * captured — a URL through the `ctx.web` seam, a workspace path from disk.
5
+ * @module dsh-research-report/tools/evidence-add
6
+ */
7
+ import type { LocalResearchReportService } from '../provider-local.js';
8
+ /** The canonical success value. */
9
+ interface EvidenceAddSuccess {
10
+ ok: true;
11
+ evidenceId: string;
12
+ hash: string;
13
+ bytes: number;
14
+ title: string;
15
+ origin: string;
16
+ capturedAt: string;
17
+ deduplicated: boolean;
18
+ }
19
+ /** The canonical domain-failure value (capability absence still throws). */
20
+ interface EvidenceAddFailure {
21
+ ok: false;
22
+ error: {
23
+ code: string;
24
+ message: string;
25
+ };
26
+ }
27
+ /** The `evidence_add` canonical value. */
28
+ export type EvidenceAddValue = EvidenceAddSuccess | EvidenceAddFailure;
29
+ /**
30
+ * Build the `evidence_add` tool bound to the local provider.
31
+ * @param service - the local research-report provider.
32
+ * @returns the tool definition.
33
+ */
34
+ export declare function makeEvidenceAddTool(service: LocalResearchReportService): import("@deepseek-ai/dsh-tools").ToolDefinition;
35
+ export {};
36
+ //# sourceMappingURL=evidence-add.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence-add.d.ts","sourceRoot":"","sources":["../../../src/tools/evidence-add.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AAEtE,mCAAmC;AACnC,UAAU,kBAAkB;IAC1B,EAAE,EAAE,IAAI,CAAA;IACR,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,OAAO,CAAA;CACtB;AAED,4EAA4E;AAC5E,UAAU,kBAAkB;IAC1B,EAAE,EAAE,KAAK,CAAA;IACT,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CACzC;AAED,0CAA0C;AAC1C,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,GAAG,kBAAkB,CAAA;AA0BtE;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,mDAqEtE"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * The `evidence_add` model tool (Consumer): register one evidence snapshot in
3
+ * the ledger. `content` given inline is used verbatim; absent, the origin is
4
+ * captured — a URL through the `ctx.web` seam, a workspace path from disk.
5
+ * @module dsh-research-report/tools/evidence-add
6
+ */
7
+ import { defineTool } from '@deepseek-ai/dsh-tools';
8
+ import { CaptureError } from "../gather.js";
9
+ import { ResearchReportError } from "../provider-local.js";
10
+ /** The tool's output schema (both branches). */
11
+ const OUTPUT_SCHEMA = {
12
+ type: 'object',
13
+ additionalProperties: false,
14
+ properties: {
15
+ ok: { type: 'boolean', required: true },
16
+ evidenceId: { type: 'string' },
17
+ hash: { type: 'string' },
18
+ bytes: { type: 'integer' },
19
+ title: { type: 'string' },
20
+ origin: { type: 'string' },
21
+ capturedAt: { type: 'string' },
22
+ deduplicated: { type: 'boolean' },
23
+ error: {
24
+ type: 'object',
25
+ additionalProperties: false,
26
+ properties: {
27
+ code: { type: 'string', required: true },
28
+ message: { type: 'string', required: true },
29
+ },
30
+ },
31
+ },
32
+ };
33
+ /**
34
+ * Build the `evidence_add` tool bound to the local provider.
35
+ * @param service - the local research-report provider.
36
+ * @returns the tool definition.
37
+ */
38
+ export function makeEvidenceAddTool(service) {
39
+ return defineTool({
40
+ name: 'evidence_add',
41
+ description: [
42
+ 'Register one evidence snapshot in the verifiable research ledger (dsh-research-report).',
43
+ '',
44
+ 'Pass `content` inline when you already hold the text; otherwise the origin is captured for you — a URL is fetched through the harness web capability (ctx.web), a workspace-relative path is read from disk. Snapshots are content-addressed and immutable: the same content is stored once, and any later byte change is detected as tampering during verification.',
45
+ '',
46
+ 'Returns the evidence id and its SHA-256 hash. Bind the id to claims in research_report.',
47
+ ].join('\n'),
48
+ parameters: {
49
+ origin: {
50
+ type: 'string',
51
+ required: true,
52
+ description: 'Where the evidence comes from: an http(s) URL or a workspace-relative path.',
53
+ },
54
+ content: {
55
+ type: 'string',
56
+ description: 'The verbatim snapshot text. When omitted, the origin is captured (URL fetched / file read).',
57
+ },
58
+ title: {
59
+ type: 'string',
60
+ description: 'Display title (defaults to the origin).',
61
+ },
62
+ },
63
+ output: {
64
+ schema: OUTPUT_SCHEMA,
65
+ render: (_args, value) => {
66
+ const result = value;
67
+ if (!result.ok) {
68
+ return [{ type: 'text', text: `evidence_add failed (${result.error.code}): ${result.error.message}` }];
69
+ }
70
+ return [{
71
+ type: 'text',
72
+ text: `evidence registered: ${result.evidenceId}${result.deduplicated ? ' (already stored — deduplicated)' : ''}\nsha256: ${result.hash}\norigin: ${result.origin}\nbytes: ${result.bytes}`,
73
+ }];
74
+ },
75
+ },
76
+ async execute(args, exec) {
77
+ exec.signal.throwIfAborted();
78
+ const session = exec.agent?.session;
79
+ try {
80
+ const added = args.content !== undefined
81
+ ? await service.addEvidence({ title: args.title ?? args.origin, origin: args.origin, content: args.content }, session)
82
+ : await service.captureAndRegister(args.origin, args.title, exec.signal, session);
83
+ return {
84
+ ok: true,
85
+ evidenceId: added.record.id,
86
+ hash: added.record.hash,
87
+ bytes: added.record.bytes,
88
+ title: added.record.title,
89
+ origin: added.record.origin,
90
+ capturedAt: added.record.capturedAt,
91
+ deduplicated: added.deduplicated,
92
+ };
93
+ }
94
+ catch (error) {
95
+ // The web capability being absent for a URL origin is a deployment
96
+ // fact: fail loudly (isError) so the model stops retrying URLs.
97
+ if (error instanceof CaptureError && error.code === 'WEB_UNAVAILABLE')
98
+ throw error;
99
+ if (error instanceof CaptureError || error instanceof ResearchReportError) {
100
+ return { ok: false, error: { code: error.code, message: error.message } };
101
+ }
102
+ throw error;
103
+ }
104
+ },
105
+ });
106
+ }
107
+ //# sourceMappingURL=evidence-add.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence-add.js","sourceRoot":"","sources":["../../../src/tools/evidence-add.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAwB1D,gDAAgD;AAChD,MAAM,aAAa,GAAG;IACpB,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACV,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE;QACvC,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC9B,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACxB,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;QAC1B,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC1B,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC9B,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;QACjC,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,oBAAoB,EAAE,KAAK;YAC3B,UAAU,EAAE;gBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAA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Ac,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,CAAA;gBACpF,CAAC;gBACD,MAAM,KAAK,CAAA;YACb,CAAC;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,42 @@
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 type { LocalResearchReportService } from '../provider-local.js';
7
+ import type { ClaimView, EvidenceView } from '../service.js';
8
+ /** The evidence branch of the canonical value. */
9
+ interface EvidenceBranch {
10
+ kind: 'evidence';
11
+ evidence: EvidenceView;
12
+ }
13
+ /** The claim branch of the canonical value. */
14
+ interface ClaimBranch {
15
+ kind: 'claim';
16
+ claim: ClaimView;
17
+ }
18
+ /** The summary branch (no id given). */
19
+ interface SummaryBranch {
20
+ kind: 'summary';
21
+ evidenceCount: number;
22
+ claimCount: number;
23
+ verdictCount: number;
24
+ tamperedCount: number;
25
+ evidenceIds: string[];
26
+ claimIds: string[];
27
+ }
28
+ /** The not-found branch (unknown id — query semantics, not an error). */
29
+ interface NotFoundBranch {
30
+ kind: 'not-found';
31
+ message: string;
32
+ }
33
+ /** The `ledger_query` canonical value. */
34
+ export type LedgerQueryValue = EvidenceBranch | ClaimBranch | SummaryBranch | NotFoundBranch;
35
+ /**
36
+ * Build the `ledger_query` tool bound to the local provider.
37
+ * @param service - the local research-report provider.
38
+ * @returns the tool definition.
39
+ */
40
+ export declare function makeLedgerQueryTool(service: LocalResearchReportService): import("@deepseek-ai/dsh-tools").ToolDefinition;
41
+ export {};
42
+ //# sourceMappingURL=ledger-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ledger-query.d.ts","sourceRoot":"","sources":["../../../src/tools/ledger-query.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5D,kDAAkD;AAClD,UAAU,cAAc;IACtB,IAAI,EAAE,UAAU,CAAA;IAChB,QAAQ,EAAE,YAAY,CAAA;CACvB;AAED,+CAA+C;AAC/C,UAAU,WAAW;IACnB,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,SAAS,CAAA;CACjB;AAED,wCAAwC;AACxC,UAAU,aAAa;IACrB,IAAI,EAAE,SAAS,CAAA;IACf,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB;AAED,yEAAyE;AACzE,UAAU,cAAc;IACtB,IAAI,EAAE,WAAW,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,0CAA0C;AAC1C,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,WAAW,GAAG,aAAa,GAAG,cAAc,CAAA;AAuG5F;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,mDA0CtE"}