@ftai/dsh-plugin-acn 0.0.0-stage → 0.1.1

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 (276) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/LICENSE-APACHE +201 -0
  3. package/LICENSE-MIT +19 -0
  4. package/README.md +82 -2
  5. package/README_EN.md +83 -0
  6. package/cordis.patch.yml +29 -0
  7. package/docs/acn-compat.md +33 -0
  8. package/docs/architecture.md +130 -0
  9. package/docs/assets/acn-claim-reuse.png +0 -0
  10. package/docs/assets/activity-view.png +0 -0
  11. package/docs/assets/install-package.png +0 -0
  12. package/docs/assets/knowledge-model.png +0 -0
  13. package/docs/assets/knowledge-view.png +0 -0
  14. package/docs/assets/personal-configuration.png +0 -0
  15. package/docs/assets/session-upstream.png +0 -0
  16. package/docs/assets/upstream-settings.png +0 -0
  17. package/docs/assets/upstream-team.png +0 -0
  18. package/docs/command-reference.md +201 -0
  19. package/docs/config.md +253 -0
  20. package/docs/development.md +197 -0
  21. package/docs/dsh-compat.md +59 -0
  22. package/docs/index.md +16 -0
  23. package/docs/outstanding-issues.md +61 -0
  24. package/docs/user_guide.md +185 -0
  25. package/icon.svg +8 -0
  26. package/lib/activities-B8U-iW4-.js +407 -0
  27. package/lib/alignment-CwH0nBf-.js +80 -0
  28. package/lib/auth-DFI9yowX.js +71 -0
  29. package/lib/checkpoint-CPFPOxBM.js +188 -0
  30. package/lib/checkpoint-c7aI4D-X.js +318 -0
  31. package/lib/claim-DOAGe8ZK.js +168 -0
  32. package/lib/client.js +18417 -0
  33. package/lib/deliver-C-dmhkfm.js +168 -0
  34. package/lib/delivery-status-M7-Rwoyj.js +89 -0
  35. package/lib/dispute-CtrInHzf.js +20 -0
  36. package/lib/disputes-ByEmi43j.js +51 -0
  37. package/lib/dream-agent-BVqxbKFc.js +249 -0
  38. package/lib/dream.js +4 -0
  39. package/lib/effects-DX1iy6FM.js +268 -0
  40. package/lib/errors-Bp_2WXBr.js +19 -0
  41. package/lib/errors-pPumDOGD.js +18 -0
  42. package/lib/evidence-store-DW7kj20i.js +1030 -0
  43. package/lib/formation-D4LO31WW.js +187 -0
  44. package/lib/formation-replay-Bf4TSBiz.js +87 -0
  45. package/lib/formation.js +9 -0
  46. package/lib/history-DPMHX3ZE.js +214 -0
  47. package/lib/inbox-2CugZZQm.js +188 -0
  48. package/lib/inbox-DFtE2fOp.js +71 -0
  49. package/lib/inbox.js +3 -0
  50. package/lib/index.js +1373 -0
  51. package/lib/lock-DbmlKOoX.js +332 -0
  52. package/lib/pages-BEWC3kmZ.js +51 -0
  53. package/lib/paths-B7NI9Ano.js +157 -0
  54. package/lib/plugins/commands.js +590 -0
  55. package/lib/plugins/dream.js +66 -0
  56. package/lib/plugins/formation.js +66 -0
  57. package/lib/plugins/inbox.js +53 -0
  58. package/lib/plugins/knowledge.js +1109 -0
  59. package/lib/plugins/prompt.js +102 -0
  60. package/lib/plugins/tools.js +280 -0
  61. package/lib/policy-DnyHh7Bl.js +16 -0
  62. package/lib/prepare-CGXwBEcu.js +134 -0
  63. package/lib/protocol.js +8 -0
  64. package/lib/queue-M917xHPS.js +153 -0
  65. package/lib/regular-file-BFpqMoub.js +136 -0
  66. package/lib/render-CJaVcKKC.js +48 -0
  67. package/lib/reported-sets-DdEKdeVb.js +122 -0
  68. package/lib/revision-DeoL_IUN.js +11 -0
  69. package/lib/scheduler-BfJSY1eq.js +64 -0
  70. package/lib/service-BPwaZzFF.js +1106 -0
  71. package/lib/service-BQaszW_v.js +344 -0
  72. package/lib/service-BhniAHLo.js +305 -0
  73. package/lib/service-C2lXoygJ.js +505 -0
  74. package/lib/session-binding-zCSuizHs.js +342 -0
  75. package/lib/session-state-CYqUhC95.js +38 -0
  76. package/lib/sessions-C2xuPFQv.js +218 -0
  77. package/lib/store.js +16 -0
  78. package/lib/structured-C9byFuzm.js +453 -0
  79. package/lib/subagent-yJsFxHmH.js +9 -0
  80. package/lib/team.js +3 -0
  81. package/lib/tool-schema-3b4gH1zf.js +28 -0
  82. package/lib/trace-Da0RnL5R.js +14 -0
  83. package/lib/traces-CHBo8y1z.js +11 -0
  84. package/lib/types/activities.d.ts +73 -0
  85. package/lib/types/advanced-configuration.d.ts +11 -0
  86. package/lib/types/client/ActivityCard.d.ts +14 -0
  87. package/lib/types/client/ActivityDetails.d.ts +18 -0
  88. package/lib/types/client/AdvancedPreferences.d.ts +8 -0
  89. package/lib/types/client/BlankCommandFeedback.d.ts +10 -0
  90. package/lib/types/client/ComposerMenu.d.ts +24 -0
  91. package/lib/types/client/ConfigurationPage.d.ts +11 -0
  92. package/lib/types/client/ConnectionCheckDialog.d.ts +12 -0
  93. package/lib/types/client/KnowledgeDetail.d.ts +6 -0
  94. package/lib/types/client/KnowledgeDirectoryField.d.ts +11 -0
  95. package/lib/types/client/KnowledgePanel.d.ts +12 -0
  96. package/lib/types/client/KnowledgeReference.d.ts +13 -0
  97. package/lib/types/client/SessionToolbar.d.ts +16 -0
  98. package/lib/types/client/SettingsToast.d.ts +3 -0
  99. package/lib/types/client/SourceSessionLink.d.ts +16 -0
  100. package/lib/types/client/TeamCredentialField.d.ts +16 -0
  101. package/lib/types/client/TeamSettingsPage.d.ts +28 -0
  102. package/lib/types/client/configuration-errors.d.ts +2 -0
  103. package/lib/types/client/interaction-styles.d.ts +1 -0
  104. package/lib/types/client/interaction-ui.d.ts +30 -0
  105. package/lib/types/client/knowledge-labels.d.ts +5 -0
  106. package/lib/types/client/locales.d.ts +51 -0
  107. package/lib/types/commands/claim.d.ts +4 -0
  108. package/lib/types/commands/import.d.ts +10 -0
  109. package/lib/types/commands/status.d.ts +5 -0
  110. package/lib/types/config.d.ts +111 -0
  111. package/lib/types/configuration.d.ts +235 -0
  112. package/lib/types/credentials.d.ts +59 -0
  113. package/lib/types/dream/audit.d.ts +4 -0
  114. package/lib/types/dream/autonomous.d.ts +185 -0
  115. package/lib/types/dream/candidates.d.ts +34 -0
  116. package/lib/types/dream/checkpoint.d.ts +35 -0
  117. package/lib/types/dream/evidence-files.d.ts +10 -0
  118. package/lib/types/dream/evidence-store.d.ts +103 -0
  119. package/lib/types/dream/evidence.d.ts +30 -0
  120. package/lib/types/dream/index.d.ts +10 -0
  121. package/lib/types/dream/plan.d.ts +18 -0
  122. package/lib/types/dream/preservation.d.ts +6 -0
  123. package/lib/types/dream/review.d.ts +10 -0
  124. package/lib/types/dream/schema.d.ts +1475 -0
  125. package/lib/types/dream/service.d.ts +56 -0
  126. package/lib/types/dream/sync.d.ts +147 -0
  127. package/lib/types/dsh-adapter/configuration-remote.d.ts +1 -0
  128. package/lib/types/dsh-adapter/configuration-service.d.ts +28 -0
  129. package/lib/types/dsh-adapter/dream-agent.d.ts +4 -0
  130. package/lib/types/dsh-adapter/dream-evidence.d.ts +3 -0
  131. package/lib/types/dsh-adapter/formation-archive.d.ts +3 -0
  132. package/lib/types/dsh-adapter/formation-replay.d.ts +5 -0
  133. package/lib/types/dsh-adapter/formation.d.ts +4 -0
  134. package/lib/types/dsh-adapter/interaction-service.d.ts +13 -0
  135. package/lib/types/dsh-adapter/knowledge-paths.d.ts +3 -0
  136. package/lib/types/dsh-adapter/llm.d.ts +10 -0
  137. package/lib/types/dsh-adapter/project-upstream.d.ts +4 -0
  138. package/lib/types/dsh-adapter/runtime-pool.d.ts +110 -0
  139. package/lib/types/dsh-adapter/session-binding.d.ts +43 -0
  140. package/lib/types/dsh-adapter/source-sessions.d.ts +3 -0
  141. package/lib/types/dsh-adapter/team-credentials.d.ts +5 -0
  142. package/lib/types/dsh-adapter/tool-schema.d.ts +4 -0
  143. package/lib/types/dsh-adapter/tools.d.ts +5 -0
  144. package/lib/types/formation/capture.d.ts +19 -0
  145. package/lib/types/formation/checkpoint.d.ts +136 -0
  146. package/lib/types/formation/index.d.ts +10 -0
  147. package/lib/types/formation/prepare.d.ts +16 -0
  148. package/lib/types/formation/schema.d.ts +45 -0
  149. package/lib/types/formation/service.d.ts +58 -0
  150. package/lib/types/formation/transcript.d.ts +75 -0
  151. package/lib/types/formation/triggers.d.ts +3 -0
  152. package/lib/types/inbox/cascade.d.ts +3 -0
  153. package/lib/types/inbox/effects.d.ts +275 -0
  154. package/lib/types/inbox/index.d.ts +5 -0
  155. package/lib/types/inbox/prepare.d.ts +380 -0
  156. package/lib/types/inbox/service.d.ts +26 -0
  157. package/lib/types/inbox/sync.d.ts +9 -0
  158. package/lib/types/index.d.ts +1 -0
  159. package/lib/types/interaction-messages.d.ts +69 -0
  160. package/lib/types/interaction.d.ts +541 -0
  161. package/lib/types/knowledge/alignment.d.ts +49 -0
  162. package/lib/types/knowledge/catalog.d.ts +5 -0
  163. package/lib/types/knowledge/changes.d.ts +32 -0
  164. package/lib/types/knowledge/disputes.d.ts +3 -0
  165. package/lib/types/knowledge/errors.d.ts +9 -0
  166. package/lib/types/knowledge/ordering.d.ts +7 -0
  167. package/lib/types/knowledge/pages.d.ts +7 -0
  168. package/lib/types/knowledge/safety.d.ts +2 -0
  169. package/lib/types/knowledge/service.d.ts +52 -0
  170. package/lib/types/knowledge/sessions.d.ts +59 -0
  171. package/lib/types/knowledge/sources.d.ts +2 -0
  172. package/lib/types/knowledge/timestamps.d.ts +1 -0
  173. package/lib/types/knowledge/types.d.ts +84 -0
  174. package/lib/types/llm/response.d.ts +1 -0
  175. package/lib/types/llm/structured.d.ts +27 -0
  176. package/lib/types/local-name.d.ts +1 -0
  177. package/lib/types/plugins/client.d.ts +9 -0
  178. package/lib/types/plugins/commands.d.ts +11 -0
  179. package/lib/types/plugins/configuration.d.ts +8 -0
  180. package/lib/types/plugins/dream.d.ts +16 -0
  181. package/lib/types/plugins/formation.d.ts +16 -0
  182. package/lib/types/plugins/inbox.d.ts +16 -0
  183. package/lib/types/plugins/knowledge.d.ts +19 -0
  184. package/lib/types/plugins/prompt.d.ts +17 -0
  185. package/lib/types/plugins/tools.d.ts +10 -0
  186. package/lib/types/prompt/render.d.ts +2 -0
  187. package/lib/types/protocol/arbitration.d.ts +154 -0
  188. package/lib/types/protocol/auth.d.ts +31 -0
  189. package/lib/types/protocol/claim.d.ts +36 -0
  190. package/lib/types/protocol/dispute.d.ts +17 -0
  191. package/lib/types/protocol/ids.d.ts +20 -0
  192. package/lib/types/protocol/inbox.d.ts +141 -0
  193. package/lib/types/protocol/index.d.ts +11 -0
  194. package/lib/types/protocol/policy.d.ts +21 -0
  195. package/lib/types/protocol/revision.d.ts +2 -0
  196. package/lib/types/protocol/router.d.ts +114 -0
  197. package/lib/types/protocol/schema.d.ts +4 -0
  198. package/lib/types/protocol/time.d.ts +5 -0
  199. package/lib/types/protocol/trace.d.ts +11 -0
  200. package/lib/types/store/atomic.d.ts +8 -0
  201. package/lib/types/store/claim-edits.d.ts +33 -0
  202. package/lib/types/store/claims.d.ts +7 -0
  203. package/lib/types/store/context.d.ts +13 -0
  204. package/lib/types/store/delivery-status.d.ts +48 -0
  205. package/lib/types/store/disputes.d.ts +6 -0
  206. package/lib/types/store/entities.d.ts +16 -0
  207. package/lib/types/store/errors.d.ts +8 -0
  208. package/lib/types/store/history.d.ts +65 -0
  209. package/lib/types/store/inbox.d.ts +27 -0
  210. package/lib/types/store/index.d.ts +16 -0
  211. package/lib/types/store/jobs.d.ts +5 -0
  212. package/lib/types/store/library-directory.d.ts +4 -0
  213. package/lib/types/store/lock.d.ts +11 -0
  214. package/lib/types/store/path-names.d.ts +2 -0
  215. package/lib/types/store/paths.d.ts +45 -0
  216. package/lib/types/store/presentation.d.ts +13 -0
  217. package/lib/types/store/regular-file.d.ts +2 -0
  218. package/lib/types/store/rejected-disputes.d.ts +18 -0
  219. package/lib/types/store/rename.d.ts +1 -0
  220. package/lib/types/store/reported-sets.d.ts +24 -0
  221. package/lib/types/store/session-state.d.ts +17 -0
  222. package/lib/types/store/traces.d.ts +6 -0
  223. package/lib/types/store/uploads.d.ts +312 -0
  224. package/lib/types/store/yaml.d.ts +8 -0
  225. package/lib/types/team/errors.d.ts +10 -0
  226. package/lib/types/team/http.d.ts +20 -0
  227. package/lib/types/team/index.d.ts +5 -0
  228. package/lib/types/team/maintainer-client.d.ts +18 -0
  229. package/lib/types/team/router-client.d.ts +14 -0
  230. package/lib/types/team/service.d.ts +28 -0
  231. package/lib/types/team/system-proxy.d.ts +9 -0
  232. package/lib/types/tools/claim.d.ts +63 -0
  233. package/lib/types/tools/consult-router.d.ts +11 -0
  234. package/lib/types/tools/subagent.d.ts +8 -0
  235. package/lib/types/tools/validation.d.ts +2 -0
  236. package/lib/types/upload/consolidation.d.ts +63 -0
  237. package/lib/types/upload/deliver.d.ts +15 -0
  238. package/lib/types/upload/index.d.ts +2 -0
  239. package/lib/types/upload/scheduler.d.ts +19 -0
  240. package/lib/types/upstreams.d.ts +5 -0
  241. package/lib/types/worker/queue.d.ts +17 -0
  242. package/lib/types/worker/types.d.ts +51 -0
  243. package/lib/types/worker/worker.d.ts +39 -0
  244. package/lib/types-C2ST2Zdg.js +17 -0
  245. package/lib/upload.js +3 -0
  246. package/lib/uploads-BCA2p92b.js +210 -0
  247. package/lib/upstreams-DEi-56tD.js +495 -0
  248. package/lib/worker-HMGzJFWd.js +185 -0
  249. package/locale/commands/en.json +1 -0
  250. package/locale/commands/zh.json +1 -0
  251. package/locale/dream/en.json +1 -0
  252. package/locale/dream/zh.json +1 -0
  253. package/locale/en.json +7 -0
  254. package/locale/formation/en.json +1 -0
  255. package/locale/formation/zh.json +1 -0
  256. package/locale/inbox/en.json +1 -0
  257. package/locale/inbox/zh.json +1 -0
  258. package/locale/knowledge/en.json +1 -0
  259. package/locale/knowledge/zh.json +1 -0
  260. package/locale/prompt/en.json +1 -0
  261. package/locale/prompt/zh.json +1 -0
  262. package/locale/tools/en.json +1 -0
  263. package/locale/tools/zh.json +1 -0
  264. package/locale/zh.json +7 -0
  265. package/package.json +262 -3
  266. package/prompts/claim_dream.j2 +77 -0
  267. package/prompts/claim_dream_legacy.j2 +63 -0
  268. package/prompts/dream_compaction.j2 +11 -0
  269. package/prompts/dream_evidence.j2 +5 -0
  270. package/prompts/inbox_claim_attribute_update_internalize.j2 +112 -0
  271. package/prompts/inbox_policy_update_internalize.j2 +87 -0
  272. package/prompts/knowledge.j2 +38 -0
  273. package/prompts/session_recap.j2 +113 -0
  274. package/prompts/what_is_claim.j2 +51 -0
  275. package/prompts/what_is_dispute.j2 +21 -0
  276. package/prompts/what_is_policy.j2 +22 -0
@@ -0,0 +1,1030 @@
1
+ import { S as timestampNanos, b as normalizeTimestamp, h as TraceIdSchema, i as effectiveUpdatedAt, l as ClaimIdSchema, m as SourceIdSchema, n as ClaimStatusSchema, r as ConfidenceSchema, t as ClaimSchema, x as nowSeconds, y as TimestampSchema } from "./claim-DOAGe8ZK.js";
2
+ import { u as FormationValidationError } from "./structured-C9byFuzm.js";
3
+ import { n as claimRevision } from "./revision-DeoL_IUN.js";
4
+ import { n as validateClaimText, t as openSingleFile } from "./regular-file-BFpqMoub.js";
5
+ import { c as readYamlOr, l as writeYamlAtomic, n as withFileLock, w as hasCode } from "./lock-DbmlKOoX.js";
6
+ import { l as sameClaim } from "./alignment-CwH0nBf-.js";
7
+ import { z } from "zod";
8
+ import { createHash, randomUUID } from "node:crypto";
9
+ import fs from "node:fs/promises";
10
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
11
+ //#region src/dream/schema.ts
12
+ var DreamValidationError = class extends FormationValidationError {};
13
+ const text = z.string().min(1).refine((value) => value.trim() !== "", "Text cannot be blank.");
14
+ const KeySchema = z.string().regex(/^[a-zA-Z0-9_-]+$/);
15
+ const HashSchema = z.string().regex(/^[0-9a-f]{64}$/);
16
+ const KindSchema = z.enum([
17
+ "quality",
18
+ "evidence",
19
+ "consolidation"
20
+ ]);
21
+ const ReviewSummarySchema = z.strictObject({
22
+ quality: text,
23
+ evidence: text,
24
+ consolidation: text
25
+ });
26
+ const BasisSchema = z.strictObject({
27
+ claim_id: ClaimIdSchema,
28
+ removed_or_changed: text,
29
+ added: z.string(),
30
+ justification: text,
31
+ evidence_ids: z.array(z.string())
32
+ });
33
+ const CoverageSchema = z.strictObject({
34
+ input_id: ClaimIdSchema,
35
+ output_ids: z.array(ClaimIdSchema),
36
+ note: text
37
+ });
38
+ const UpdateSchema = ClaimSchema.pick({
39
+ id: true,
40
+ name: true,
41
+ statement: true,
42
+ scope: true,
43
+ confidence: true,
44
+ status: true,
45
+ source_claim_ids: true,
46
+ evidence_summary: true
47
+ }).strict();
48
+ const GroupSchema = z.strictObject({
49
+ kind: KindSchema,
50
+ reason: text,
51
+ evidence_ids: z.array(z.string()),
52
+ coverage: z.array(CoverageSchema),
53
+ change_basis: z.array(BasisSchema).default([]),
54
+ updates: z.array(UpdateSchema)
55
+ });
56
+ const PlanSchema = z.object({
57
+ review: ReviewSummarySchema,
58
+ groups: z.array(GroupSchema)
59
+ });
60
+ const changes = z.strictObject({
61
+ name: z.string().optional(),
62
+ statement: z.string().optional(),
63
+ scope: z.string().optional(),
64
+ confidence: ConfidenceSchema.optional(),
65
+ status: ClaimStatusSchema.optional(),
66
+ source_claim_ids: z.array(SourceIdSchema).describe("继承已有来源。来源指向被整合或将废弃的输入时仍保留;仅来源等于存续 ID 自身时移除该自引用。").optional(),
67
+ evidence_summary: z.string().optional()
68
+ });
69
+ const OperationSchema = z.strictObject({
70
+ id: ClaimIdSchema,
71
+ action: z.enum([
72
+ "keep",
73
+ "update",
74
+ "deprecate"
75
+ ]),
76
+ changes: changes.default({}),
77
+ reason: z.string().describe("仅供 quality/deprecate 且 changes 为空、无对应 change_basis 时简写依据。update、keep 及 evidence/consolidation 的所有 operation 必须省略此字段,修改依据放 group.change_basis.justification。").optional()
78
+ });
79
+ const DraftGroupSchema = z.strictObject({
80
+ kind: KindSchema,
81
+ reason: text,
82
+ evidence_ids: z.array(z.string()).default([]),
83
+ coverage: z.array(CoverageSchema).default([]),
84
+ change_basis: z.array(BasisSchema).default([]),
85
+ operations: z.array(OperationSchema).min(1)
86
+ });
87
+ const CandidateSchema = z.strictObject({
88
+ group_id: KeySchema,
89
+ claim_ids: z.array(ClaimIdSchema).min(1),
90
+ kind: KindSchema,
91
+ reason: text
92
+ });
93
+ const KeepReasonSchema = z.enum([
94
+ "insufficient_evidence",
95
+ "useful_knowledge",
96
+ "uncertain_preservation",
97
+ "no_consolidation_benefit",
98
+ "external_change"
99
+ ]);
100
+ const DraftResponseSchema = z.discriminatedUnion("action", [z.strictObject({
101
+ action: z.literal("stage"),
102
+ group: DraftGroupSchema
103
+ }), z.strictObject({
104
+ action: z.literal("keep"),
105
+ reason_kind: KeepReasonSchema,
106
+ reason: text
107
+ })]);
108
+ const DiscoverySchema = z.strictObject({
109
+ review: ReviewSummarySchema,
110
+ candidates: z.array(CandidateSchema),
111
+ sync_candidates: z.array(z.strictObject({
112
+ source_id: ClaimIdSchema,
113
+ carrier_ids: z.array(ClaimIdSchema).min(1),
114
+ reason: text
115
+ }))
116
+ });
117
+ const QuoteSchema = z.strictObject({
118
+ claim_id: ClaimIdSchema,
119
+ field: z.enum([
120
+ "name",
121
+ "statement",
122
+ "scope",
123
+ "evidence_summary"
124
+ ]),
125
+ quote: text
126
+ });
127
+ const evidenceQuote = z.strictObject({
128
+ evidence_id: z.string(),
129
+ quote: text
130
+ });
131
+ const SelfReviewSchema = z.strictObject({
132
+ group_id: KeySchema,
133
+ validation_id: HashSchema,
134
+ preservation: z.array(z.strictObject({
135
+ before: QuoteSchema,
136
+ after: z.array(QuoteSchema),
137
+ disposition: z.enum([
138
+ "preserved",
139
+ "episodic",
140
+ "corrected"
141
+ ]),
142
+ reason: text,
143
+ evidence: z.array(evidenceQuote)
144
+ })),
145
+ support: z.array(z.strictObject({
146
+ after: QuoteSchema,
147
+ before: z.array(QuoteSchema),
148
+ evidence: z.array(evidenceQuote),
149
+ reason: text
150
+ })),
151
+ scope_and_certainty: text
152
+ });
153
+ const SemanticReviewSchema = z.strictObject({
154
+ claims: z.array(z.strictObject({
155
+ claim_id: ClaimIdSchema,
156
+ final_name: z.string().default(""),
157
+ name_reason: z.string().default(""),
158
+ information_preserved: text,
159
+ removal_or_correction: text,
160
+ factual_correction: z.boolean(),
161
+ output_ids: z.array(ClaimIdSchema),
162
+ evidence_ids: z.array(z.string())
163
+ })),
164
+ scope_and_certainty: text
165
+ });
166
+ const ReviewInputSchema = z.strictObject({
167
+ group_id: KeySchema,
168
+ kind: KindSchema,
169
+ reason: text,
170
+ before: z.array(ClaimSchema),
171
+ after: z.array(UpdateSchema),
172
+ changes: z.array(OperationSchema),
173
+ coverage: z.array(CoverageSchema),
174
+ change_basis: z.array(BasisSchema),
175
+ unversioned_evidence_omitted: z.array(z.string()).default([]),
176
+ evidence: z.record(z.string(), z.json())
177
+ });
178
+ const ValidationSchema = z.strictObject({
179
+ validation_id: HashSchema,
180
+ input: ReviewInputSchema
181
+ });
182
+ const ReviewRecordSchema = z.strictObject({
183
+ validation: ValidationSchema,
184
+ review: SelfReviewSchema
185
+ });
186
+ const ReviewResponseSchema = z.strictObject({
187
+ decision: z.enum([
188
+ "apply",
189
+ "repair",
190
+ "keep"
191
+ ]),
192
+ reason: text,
193
+ reason_kind: KeepReasonSchema,
194
+ semantic: SemanticReviewSchema.nullable(),
195
+ self_review: SelfReviewSchema.nullable()
196
+ });
197
+ const PreparedGroupSchema = z.object({
198
+ before: z.array(ClaimSchema),
199
+ after: z.array(ClaimSchema),
200
+ completed: z.boolean().default(false),
201
+ skipped: z.boolean().default(false)
202
+ });
203
+ const CheckpointSchema = z.object({
204
+ team_authorized: z.boolean().optional(),
205
+ snapshot_at: TimestampSchema,
206
+ input_versions: z.record(ClaimIdSchema, z.string()),
207
+ coverage: z.json(),
208
+ plan: PlanSchema,
209
+ receipts: z.record(z.string(), z.json()),
210
+ exploration_receipts: z.number().int().nonnegative().optional(),
211
+ groups: z.array(PreparedGroupSchema),
212
+ safety_reviews: z.array(z.json()).default([]),
213
+ self_reviews: z.array(ReviewRecordSchema).default([]),
214
+ trace_id: TraceIdSchema,
215
+ applied: z.boolean().default(false),
216
+ success_at: TimestampSchema.nullable().optional(),
217
+ self_versions: z.record(ClaimIdSchema, z.string()).default({}),
218
+ operation: z.object({
219
+ job_id: KeySchema,
220
+ group_id: KeySchema,
221
+ validation_id: HashSchema,
222
+ review: SemanticReviewSchema,
223
+ hard_validation_passed: z.boolean()
224
+ }).nullable().optional()
225
+ });
226
+ const DreamStateSchema = z.object({
227
+ last_success_at: TimestampSchema.nullable().default(null),
228
+ last_input_snapshot_at: TimestampSchema.nullable().default(null),
229
+ known_versions: z.record(ClaimIdSchema, z.string()).default({})
230
+ });
231
+ const OriginSchema = z.strictObject({
232
+ snapshot_at: TimestampSchema,
233
+ claims: z.array(ClaimSchema),
234
+ coverage: z.json(),
235
+ workspace_root: z.string().optional()
236
+ });
237
+ const ProgressSchema = z.strictObject({
238
+ schemaVersion: z.literal(1),
239
+ discovery: DiscoverySchema,
240
+ entries: z.array(z.strictObject({
241
+ candidate: CandidateSchema,
242
+ status: z.enum([
243
+ "pending",
244
+ "executed",
245
+ "kept",
246
+ "skipped"
247
+ ]),
248
+ reason: z.string(),
249
+ draft: GroupSchema.nullable(),
250
+ validation: ValidationSchema.nullable(),
251
+ review: ReviewResponseSchema.nullable()
252
+ })),
253
+ syncCompleted: z.array(ClaimIdSchema),
254
+ finished: z.boolean(),
255
+ finish_reminder_sent: z.boolean().default(false),
256
+ proposal_attempted: z.boolean().default(false),
257
+ exploration_receipts: z.number().int().nonnegative().default(0),
258
+ summary: z.strictObject({
259
+ checked: z.string(),
260
+ findings: z.string(),
261
+ uncertainties: z.string(),
262
+ next_steps: z.string()
263
+ }).nullable(),
264
+ compactedThrough: z.number().int().nonnegative().default(0),
265
+ autonomy: z.strictObject({
266
+ steps: z.number().int().nonnegative(),
267
+ epoch: z.number().int().nonnegative(),
268
+ limit: z.number().int().positive(),
269
+ read_ids: z.array(ClaimIdSchema),
270
+ wrap_up: z.strictObject({
271
+ steps: z.number().int().nonnegative(),
272
+ limit: z.number().int().positive()
273
+ }).optional()
274
+ }).optional()
275
+ });
276
+ function requireDream(condition, message) {
277
+ if (!condition) throw new DreamValidationError(message);
278
+ }
279
+ //#endregion
280
+ //#region src/knowledge/timestamps.ts
281
+ function nextClaimUpdateAt(now, previous) {
282
+ const clock = timestampNanos(`${normalizeTimestamp(now).slice(0, 19)}Z`);
283
+ const successor = timestampNanos(previous) + 1000000000n;
284
+ const nanos = clock > successor ? clock : successor;
285
+ const seconds = nanos >= 0n ? nanos / 1000000000n : (nanos - 999999999n) / 1000000000n;
286
+ const fraction = nanos - seconds * 1000000000n;
287
+ return normalizeTimestamp(`${(/* @__PURE__ */ new Date(Number(seconds) * 1e3)).toISOString().slice(0, 19)}.${fraction.toString().padStart(9, "0")}Z`);
288
+ }
289
+ //#endregion
290
+ //#region src/dream/evidence.ts
291
+ const ReceiptSchema = z.object({
292
+ tool: z.literal("file_read"),
293
+ input: z.object({
294
+ path: z.string(),
295
+ claim_ids: z.array(ClaimIdSchema).optional(),
296
+ show_linenos: z.boolean().optional()
297
+ }).passthrough(),
298
+ output: z.object({
299
+ content: z.string(),
300
+ page: z.object({
301
+ returned_start: z.number().int().positive(),
302
+ returned_end: z.number().int().nonnegative()
303
+ }).passthrough().optional(),
304
+ file_version: z.object({
305
+ path: z.string(),
306
+ revision: z.strictObject({
307
+ sha256: z.string().regex(/^[0-9a-f]{64}$/),
308
+ byte_len: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)
309
+ })
310
+ })
311
+ }).passthrough()
312
+ }).passthrough();
313
+ function independentReceipt(receipts, id) {
314
+ const parsed = ReceiptSchema.safeParse(receipts[id]);
315
+ return parsed.success ? parsed.data : null;
316
+ }
317
+ function directEvidence(receipts, ids, claimId) {
318
+ return ids.filter((id) => {
319
+ const receipt = independentReceipt(receipts, id);
320
+ return receipt !== null && (receipt.input.claim_ids === void 0 || receipt.input.claim_ids.includes(claimId));
321
+ });
322
+ }
323
+ function evidenceBody(receipt) {
324
+ const { content, page } = receipt.output;
325
+ if (receipt.input.show_linenos === false || page === void 0) return content;
326
+ const lines = content.match(/[^\n]*\n|[^\n]+$/g) ?? [];
327
+ let next = page.returned_start;
328
+ const body = [];
329
+ for (const line of lines) {
330
+ const prefix = `${next}|`;
331
+ if (!line.startsWith(prefix)) return content;
332
+ body.push(line.slice(prefix.length));
333
+ next += 1;
334
+ }
335
+ return next - 1 === page.returned_end ? body.join("") : content;
336
+ }
337
+ function requireEvidenceIds(ids, available, message) {
338
+ requireDream(new Set(ids).size === ids.length && ids.every((id) => available.includes(id)), message);
339
+ }
340
+ //#endregion
341
+ //#region src/dream/preservation.ts
342
+ function validateEvidenceSummaryPreservation(input, outputs) {
343
+ if (input.evidence_summary.trim() === "") return;
344
+ requireDream(outputs.some((output) => output.evidence_summary.includes(input.evidence_summary)), `必须在指定去向的 evidence_summary 中逐字保留 ${input.id} 的完整原证据摘要;置信度等级、相似引用或废弃历史不能代替。请保留原文,再追加本轮新证据、版本和适用限制;无法安全承接时 keep。`);
345
+ }
346
+ function validateEvidencePreservation(input) {
347
+ for (const original of input.before) {
348
+ validateEvidenceSummaryPreservation(original, input.after.filter((claim) => claim.id === original.id));
349
+ if (input.kind === "consolidation") {
350
+ const destinations = input.coverage.find((item) => item.input_id === original.id)?.output_ids ?? [];
351
+ validateEvidenceSummaryPreservation(original, input.after.filter((claim) => claim.status !== "deprecated" && destinations.includes(claim.id)));
352
+ }
353
+ }
354
+ }
355
+ //#endregion
356
+ //#region src/dream/plan.ts
357
+ const contentHash = (claim) => claimRevision(claim).slice(10);
358
+ function valueHash(value) {
359
+ return createHash("sha256").update(JSON.stringify(value, (_key, item) => item !== null && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) : item)).digest("hex");
360
+ }
361
+ function sameIds(a, b) {
362
+ return new Set(a).size === a.length && new Set(b).size === b.length && a.length === b.length && a.every((id) => b.includes(id));
363
+ }
364
+ const rank = {
365
+ low: 0,
366
+ medium: 1,
367
+ high: 2
368
+ };
369
+ function validateCandidates(candidates, readable, owner, evidenceEnabled = false) {
370
+ const groups = /* @__PURE__ */ new Set();
371
+ const ids = /* @__PURE__ */ new Set();
372
+ for (const candidate of candidates) {
373
+ requireDream(!groups.has(candidate.group_id), "候选 group_id 重复。");
374
+ groups.add(candidate.group_id);
375
+ requireDream(candidate.kind !== "evidence" || evidenceEnabled, "证据校准未启用或受限查证能力不可用。");
376
+ requireDream(new Set(candidate.claim_ids).size === candidate.claim_ids.length, "候选 Claim ID 必须唯一。");
377
+ for (const id of candidate.claim_ids) {
378
+ const claim = readable.find((claim) => claim.id === id);
379
+ requireDream(claim !== void 0 && claim.holder === owner && claim.status !== "deprecated", "候选只能包含完整展示过的自身非 deprecated Claim。");
380
+ requireDream(candidate.kind !== "evidence" || claim.confidence !== "high", "high Claim 不进入证据校准;不能先降级再纠正。");
381
+ requireDream(!ids.has(id), "同一 Claim 不得被多个未处理候选占用。");
382
+ ids.add(id);
383
+ }
384
+ }
385
+ }
386
+ function expandDraft(draft, readable) {
387
+ const basis = [...draft.change_basis];
388
+ const updates = draft.operations.map((operation) => {
389
+ const original = readable.find((claim) => claim.id === operation.id);
390
+ requireDream(original !== void 0, "操作只能针对本轮完整读过的 Claim。");
391
+ const fields = Object.keys(operation.changes);
392
+ if (operation.reason !== void 0) {
393
+ requireDream(draft.kind === "quality" && operation.action === "deprecate" && fields.length === 0 && operation.reason.trim() !== "" && !basis.some((item) => item.claim_id === operation.id), `${operation.id} 的 operation.reason 不是通用备注;当前为 ${draft.kind}/${operation.action},请省略 reason,将修改依据放入 group.change_basis.justification。仅无 changes 且无对应 change_basis 的 quality/deprecate 可使用 reason 简写。`);
394
+ basis.push({
395
+ claim_id: operation.id,
396
+ removed_or_changed: "从当前知识中移除一次性记录,历史正文保持。",
397
+ added: "",
398
+ justification: operation.reason,
399
+ evidence_ids: []
400
+ });
401
+ }
402
+ requireDream(operation.action !== "keep" || fields.length === 0, "keep 不得携带 changes。");
403
+ requireDream(operation.action !== "update" || fields.length > 0, "update 必须携带 changes。");
404
+ requireDream(operation.action !== "deprecate" || fields.every((key) => key === "evidence_summary"), "deprecate 仅允许补充 evidence_summary;其余历史正文保持。");
405
+ const update = UpdateSchema.strip().parse({
406
+ ...original,
407
+ ...operation.changes,
408
+ ...operation.action === "deprecate" ? { status: "deprecated" } : {}
409
+ });
410
+ requireDream(operation.action === "deprecate" || update.status !== "deprecated", "废弃必须使用 deprecate 动作。");
411
+ return update;
412
+ });
413
+ return GroupSchema.parse({
414
+ kind: draft.kind,
415
+ reason: draft.reason,
416
+ evidence_ids: draft.evidence_ids,
417
+ coverage: draft.coverage,
418
+ change_basis: basis,
419
+ updates
420
+ });
421
+ }
422
+ function reaches(id, target, graph, visited = /* @__PURE__ */ new Set()) {
423
+ if (id === target) return true;
424
+ if (visited.has(id)) return false;
425
+ visited.add(id);
426
+ return graph.find((claim) => claim.id === id)?.source_claim_ids.some((source) => source.startsWith("claim_") && graph.some((claim) => claim.id === source && reaches(claim.id, target, graph, visited))) ?? false;
427
+ }
428
+ function validateConsolidationSources(input, after, destinations) {
429
+ const missing = input.source_claim_ids.filter((source) => !after.some((claim) => destinations.includes(claim.id) && claim.status !== "deprecated" && (claim.source_claim_ids.includes(source) || source === claim.id)));
430
+ requireDream(missing.length === 0, `整合必须在存续去向中保留 ${input.id} 的既有来源:${missing.join(", ")};来源对应输入将被 deprecated 也不能删除,仅合回来源 ID 自身时免去自引用。`);
431
+ }
432
+ function prepareGroup(group, readable, owner, now = nowSeconds(), evidence = {
433
+ enabled: false,
434
+ receipts: {}
435
+ }) {
436
+ requireDream(group.kind !== "evidence" || evidence.enabled, "证据校准未启用。");
437
+ requireDream(group.evidence_ids.length === 0 || evidence.enabled, "证据校准关闭时不能引入新证据。");
438
+ requireEvidenceIds(group.evidence_ids, Object.keys(evidence.receipts), "组引用了不存在或重复的查证回执。");
439
+ for (const basis of group.change_basis) {
440
+ requireEvidenceIds(basis.evidence_ids, group.evidence_ids, "change_basis 只能引用本组已读证据。");
441
+ requireDream(directEvidence(evidence.receipts, basis.evidence_ids, basis.claim_id).length === basis.evidence_ids.length, "直接证据必须绑定对应 Claim,不能借用其他 Claim 的查证。");
442
+ }
443
+ requireDream(group.updates.length > 0 && new Set(group.updates.map((item) => item.id)).size === group.updates.length, "组必须包含唯一的更新 ID。");
444
+ const before = [];
445
+ const after = [];
446
+ const inputs = group.updates.map((item) => readable.find((claim) => claim.id === item.id));
447
+ requireDream(inputs.every((claim) => claim !== void 0 && claim.holder === owner && claim.status !== "deprecated"), "整理只能修改完整读过、自身持有、非废弃的 Claim。");
448
+ const inherited = new Set(inputs.flatMap((claim) => claim?.source_claim_ids ?? []));
449
+ for (const update of group.updates) {
450
+ const original = readable.find((claim) => claim.id === update.id);
451
+ requireDream(original !== void 0, "缺少原 Claim。");
452
+ validateClaimText({
453
+ name: update.name,
454
+ statement: update.statement,
455
+ scope: update.scope,
456
+ evidence_summary: update.evidence_summary
457
+ });
458
+ const ids = group.change_basis.find((basis) => basis.claim_id === original.id)?.evidence_ids ?? [];
459
+ const supported = directEvidence(evidence.receipts, ids, original.id).length > 0 && update.evidence_summary !== original.evidence_summary;
460
+ requireDream(rank[update.confidence] <= rank[original.confidence] || supported, "没有对应 Claim 的新独立证据和新的 evidence_summary,不得提高置信度。");
461
+ requireDream(new Set(update.source_claim_ids).size === update.source_claim_ids.length && update.source_claim_ids.every((source) => source !== update.id && inherited.has(source)), "source_claim_ids 只能继承本组已有来源,不得自引用或新增输入 ID。");
462
+ const target = {
463
+ ...original,
464
+ ...update
465
+ };
466
+ if (!evidence.semanticReview) validateEvidenceSummaryPreservation(original, [target]);
467
+ if (group.kind === "evidence" && !sameClaim(original, target)) requireDream(original.confidence !== "high" && supported, "B 类事实校准必须针对原始 medium/low Claim,引用对应新证据并更新 evidence_summary。");
468
+ if (!sameClaim(original, target)) target.updated_at = nextClaimUpdateAt(now, effectiveUpdatedAt(original));
469
+ before.push(original);
470
+ after.push(target);
471
+ }
472
+ const changed = before.filter((claim, index) => after[index] !== void 0 && !sameClaim(claim, after[index])).map((claim) => claim.id);
473
+ requireDream(sameIds(group.change_basis.map((item) => item.claim_id), changed), "change_basis 必须恰好解释全部变更,不能遗漏、重复或解释 keep。");
474
+ if (group.kind === "consolidation") {
475
+ const outputs = after.filter((claim) => claim.status !== "deprecated");
476
+ requireDream(before.length >= 2 && outputs.length > 0, "整合至少两个输入且必须有存续输出。");
477
+ requireDream(sameIds(group.coverage.map((item) => item.input_id), before.map((claim) => claim.id)), "coverage 必须恰好覆盖每条输入。");
478
+ for (const coverage of group.coverage) {
479
+ requireDream(coverage.output_ids.length > 0 && new Set(coverage.output_ids).size === coverage.output_ids.length && coverage.output_ids.every((id) => outputs.some((claim) => claim.id === id)), "coverage 的去向必须是本组存续 Claim。");
480
+ const original = before.find((claim) => claim.id === coverage.input_id);
481
+ requireDream(original !== void 0, "coverage 输入不存在。");
482
+ validateConsolidationSources(original, outputs, coverage.output_ids);
483
+ if (!evidence.semanticReview) validateEvidenceSummaryPreservation(original, outputs.filter((claim) => coverage.output_ids.includes(claim.id)));
484
+ requireDream(outputs.filter((claim) => coverage.output_ids.includes(claim.id)).every((claim) => rank[claim.confidence] <= rank[original.confidence] || directEvidence(evidence.receipts, group.change_basis.find((basis) => basis.claim_id === claim.id)?.evidence_ids ?? [], claim.id).length > 0 && claim.evidence_summary !== before.find((input) => input.id === claim.id)?.evidence_summary), "整合不得把较弱来源无证据提升为更高置信度。");
485
+ }
486
+ requireDream(outputs.some((claim) => before.find((input) => input.id === claim.id)?.statement !== claim.statement), "整合必须改写存续正文:至少一个存续 ID 应使用 update,并在 operations[].changes.statement 中提交不同于原文、完整承接有效信息的正文。仅 keep 一条并 deprecate 其余,或只修改名称/依据,均不满足要求。若没有安全且有收益的重组,返回 action=keep、reason_kind=no_consolidation_benefit,不能为通过校验无依据改写。");
487
+ }
488
+ const graph = [...readable.filter((claim) => !after.some((target) => target.id === claim.id)), ...after];
489
+ for (const target of after) for (const source of target.source_claim_ids) if (!before.find((claim) => claim.id === target.id)?.source_claim_ids.includes(source)) {
490
+ const claim = graph.find((claim) => claim.id === source);
491
+ requireDream(claim === void 0 || !reaches(claim.id, target.id, graph), "整理不得引入来源环。");
492
+ }
493
+ return {
494
+ before,
495
+ after,
496
+ completed: false,
497
+ skipped: false
498
+ };
499
+ }
500
+ function reviewInput(groupId, group, readable, receipts = {}) {
501
+ const input = {
502
+ group_id: groupId,
503
+ kind: group.kind,
504
+ reason: group.reason,
505
+ before: group.updates.flatMap((update) => readable.filter((claim) => claim.id === update.id)),
506
+ after: group.updates,
507
+ changes: group.updates.map((update) => {
508
+ const original = readable.find((claim) => claim.id === update.id);
509
+ const changes = Object.fromEntries(Object.entries(update).filter(([key, value]) => key !== "id" && JSON.stringify(original?.[key]) !== JSON.stringify(value)));
510
+ return {
511
+ id: update.id,
512
+ action: update.status === "deprecated" ? "deprecate" : Object.keys(changes).length === 0 ? "keep" : "update",
513
+ changes: update.status === "deprecated" ? Object.fromEntries(Object.entries(changes).filter(([key]) => key === "evidence_summary")) : changes
514
+ };
515
+ }),
516
+ coverage: group.coverage,
517
+ change_basis: group.change_basis,
518
+ unversioned_evidence_omitted: group.evidence_ids.filter((id) => independentReceipt(receipts, id) === null),
519
+ evidence: Object.fromEntries(group.evidence_ids.flatMap((id) => {
520
+ const receipt = receipts[id];
521
+ return receipt !== void 0 && independentReceipt(receipts, id) !== null ? [[id, receipt]] : [];
522
+ }))
523
+ };
524
+ return {
525
+ validation_id: valueHash(input),
526
+ input
527
+ };
528
+ }
529
+ //#endregion
530
+ //#region src/dream/review.ts
531
+ const fields = [
532
+ "name",
533
+ "statement",
534
+ "scope",
535
+ "evidence_summary"
536
+ ];
537
+ function quoted(validation, side, quote) {
538
+ const claim = validation.input[side].find((claim) => claim.id === quote.claim_id);
539
+ requireDream(claim !== void 0, `复核引用 ${side}.${quote.claim_id}.${quote.field} 对应的 Claim 不存在。`);
540
+ requireDream(side !== "after" || claim.status !== "deprecated", `after 引用 ${quote.claim_id}.${quote.field} 指向 deprecated Claim,不能承接保留信息。其历史记录仍会保留,但 preservation.after 和 support.after 只能引用存续输出;按 coverage.output_ids 找到实际承接字段,不能把历史原名或 scope 当成存续去向。`);
541
+ const value = claim[quote.field];
542
+ requireDream(quote.quote.trim() !== "" && value.includes(quote.quote), `复核引用 ${side}.${quote.claim_id}.${quote.field} 必须是对应字段的逐字非空子串。请直接复制该字段原文,不翻译、改写或合并不连续片段;字段值中的引号与换行使用 JSON 转义。`);
543
+ return value;
544
+ }
545
+ function coverageGaps(validation, review) {
546
+ const gaps = [];
547
+ for (const side of ["before", "after"]) {
548
+ const quotes = side === "before" ? review.preservation.map((item) => item.before) : review.support.map((item) => item.after);
549
+ for (const claim of validation.input[side]) {
550
+ if (side === "after" && claim.status === "deprecated") continue;
551
+ for (const field of fields) {
552
+ const text = claim[field];
553
+ const covered = /* @__PURE__ */ new Set();
554
+ for (const quote of quotes.filter((quote) => quote.claim_id === claim.id && quote.field === field && quote.quote !== "")) {
555
+ let start = text.indexOf(quote.quote);
556
+ while (start !== -1) {
557
+ for (let index = start; index < start + quote.quote.length; index += 1) covered.add(index);
558
+ start = text.indexOf(quote.quote, start + 1);
559
+ }
560
+ }
561
+ const missing = [];
562
+ let fragment = "";
563
+ let offset = 0;
564
+ for (const char of text) {
565
+ if (!covered.has(offset) && !/[\s,。;:、,;:]/u.test(char)) fragment += char;
566
+ else if (fragment !== "") {
567
+ missing.push(fragment);
568
+ fragment = "";
569
+ }
570
+ offset += char.length;
571
+ }
572
+ if (fragment !== "") missing.push(fragment);
573
+ if (missing.length > 0) gaps.push({
574
+ side,
575
+ claim_id: claim.id,
576
+ field,
577
+ missing_fragments: missing
578
+ });
579
+ }
580
+ }
581
+ }
582
+ return gaps;
583
+ }
584
+ function validateSelfReview(validation, review) {
585
+ requireDream(review.validation_id === validation.validation_id && review.group_id === validation.input.group_id, "复核对应的草稿版本已变化,必须重新 validate。");
586
+ validateEvidencePreservation(validation.input);
587
+ const bad = [];
588
+ for (const [section, items] of [["preservation", review.preservation], ["support", review.support]]) for (const [index, item] of items.entries()) for (const [offset, quote] of item.evidence.entries()) {
589
+ const receipt = independentReceipt(validation.input.evidence, quote.evidence_id);
590
+ const text = quote.quote.trim();
591
+ if (receipt === null || text === "" || !receipt.output.content.includes(text) && !evidenceBody(receipt).includes(text)) bad.push({
592
+ location: `${section}.${index}.evidence.${offset}`,
593
+ evidence_id: quote.evidence_id,
594
+ source_preview: receipt === null ? "" : evidenceBody(receipt).slice(0, 240)
595
+ });
596
+ }
597
+ requireDream(bad.length === 0, `新证据引用必须逐字出现在对应版本回执中;错误 ${bad.length} 处:${JSON.stringify(bad.slice(0, 8))}`);
598
+ for (const item of review.preservation) {
599
+ quoted(validation, "before", item.before);
600
+ for (const quote of item.after) quoted(validation, "after", quote);
601
+ if (item.disposition === "preserved") requireDream(item.after.length > 0, "有效信息必须有存续输出引用。");
602
+ else if (item.disposition === "episodic") requireDream(validation.input.kind !== "evidence" && item.after.length === 0 && item.evidence.length === 0, "仅纯情景片段可在 A/C 中无证据移除。");
603
+ else validateCorrection(validation, item.before.claim_id, item.evidence.map((quote) => quote.evidence_id));
604
+ }
605
+ for (const item of review.support) {
606
+ quoted(validation, "after", item.after);
607
+ for (const quote of item.before) quoted(validation, "before", quote);
608
+ requireDream(item.before.length > 0 || item.evidence.length > 0, "每个输出断言必须有具体原文或新独立证据。");
609
+ if (item.evidence.length > 0) validateCorrection(validation, item.after.claim_id, [...new Set(item.evidence.map((quote) => quote.evidence_id))]);
610
+ }
611
+ const gaps = coverageGaps(validation, review);
612
+ requireDream(gaps.length === 0, `复核未覆盖完整 name/statement/scope/evidence_summary,含条件、否定、备选行动和证据限制:${JSON.stringify(gaps.slice(0, 8))}`);
613
+ }
614
+ function validateCorrection(validation, id, ids) {
615
+ const before = validation.input.before.find((claim) => claim.id === id);
616
+ const after = validation.input.after.find((claim) => claim.id === id);
617
+ requireDream(before !== void 0 && after !== void 0 && before.confidence !== "high", "high Claim 不能事实纠正,包括混入 A/C 或先降低置信度。");
618
+ const basis = validation.input.change_basis.find((basis) => basis.claim_id === id)?.evidence_ids ?? [];
619
+ const direct = directEvidence(validation.input.evidence, basis, id);
620
+ requireDream(ids.length > 0 && ids.every((id) => direct.includes(id)), "事实修订必须引用对应 Claim 的 change_basis 中的新直接证据。");
621
+ requireDream(after.evidence_summary !== before.evidence_summary, "事实修订必须更新 evidence_summary,说明新证据与限制。");
622
+ }
623
+ function validateSemanticReview(validation, review) {
624
+ requireDream(sameIds(review.claims.map((item) => item.claim_id), validation.input.before.map((claim) => claim.id)), "语义复核必须恰好覆盖全部输入 Claim。");
625
+ for (const item of review.claims) {
626
+ const after = validation.input.after.find((claim) => claim.id === item.claim_id);
627
+ requireDream(after !== void 0, "复核缺少输出 Claim。");
628
+ requireDream(item.final_name === after.name && item.name_reason.trim() !== "", "final_name 必须绑定最终名称,并说明名称与正文一致;废弃保留历史名称。");
629
+ requireEvidenceIds(item.evidence_ids, Object.keys(validation.input.evidence).filter((id) => independentReceipt(validation.input.evidence, id) !== null), "语义复核引用了无版本、未知或重复的独立证据。");
630
+ if (item.factual_correction || validation.input.kind === "evidence" && validation.input.changes.some((change) => change.id === item.claim_id && change.action !== "keep")) validateCorrection(validation, item.claim_id, item.evidence_ids);
631
+ requireDream(new Set(item.output_ids).size === item.output_ids.length && item.output_ids.every((id) => validation.input.after.some((claim) => claim.id === id && claim.status !== "deprecated")), "复核去向必须唯一且属于本组存续 Claim。");
632
+ if (validation.input.kind === "consolidation") requireDream(sameIds(item.output_ids, validation.input.coverage.find((coverage) => coverage.input_id === item.claim_id)?.output_ids ?? []), "语义复核必须与 coverage 的信息去向一致。");
633
+ else if (after.status !== "deprecated") requireDream(item.output_ids.includes(item.claim_id), "存续 Claim 必须包含自身信息去向。");
634
+ }
635
+ }
636
+ //#endregion
637
+ //#region src/dream/candidates.ts
638
+ const INPUT_TOKENS = 64e3;
639
+ function conservativeTokens(text) {
640
+ return Array.from(text).reduce((sum, char) => sum + (char.codePointAt(0) !== void 0 && char.charCodeAt(0) < 128 ? 1 : 3), 0);
641
+ }
642
+ function claimInput(claims, budget = INPUT_TOKENS) {
643
+ const sorted = [...claims].sort((a, b) => {
644
+ const changed = timestampNanos(effectiveUpdatedAt(b)) - timestampNanos(effectiveUpdatedAt(a));
645
+ const created = timestampNanos(b.created_at) - timestampNanos(a.created_at);
646
+ return changed !== 0n ? changed > 0n ? 1 : -1 : created !== 0n ? created > 0n ? 1 : -1 : a.id.localeCompare(b.id);
647
+ });
648
+ const loaded = [];
649
+ let used = 0;
650
+ for (const claim of sorted) {
651
+ const cost = conservativeTokens(JSON.stringify(claim));
652
+ if (cost > budget) continue;
653
+ if (used + cost > budget) break;
654
+ used += cost;
655
+ loaded.push(claim);
656
+ }
657
+ return {
658
+ loaded,
659
+ coverage: {
660
+ total: claims.length,
661
+ included: loaded.length,
662
+ omitted: claims.length - loaded.length,
663
+ order: "effective_updated_at descending; oldest omitted first",
664
+ estimated_tokens: used,
665
+ budget_tokens: budget
666
+ }
667
+ };
668
+ }
669
+ function versions(claims) {
670
+ return Object.fromEntries([...claims].sort((a, b) => a.id.localeCompare(b.id)).map((claim) => [claim.id, contentHash(claim)]));
671
+ }
672
+ function dreamEligible(config, state, claims, owner, manual, now = Date.now()) {
673
+ const owned = claims.filter((claim) => claim.holder === owner);
674
+ if (!config.enabled || !owned.some((claim) => claim.status !== "deprecated")) return false;
675
+ if (manual) return true;
676
+ if (state.last_success_at !== void 0 && state.last_success_at !== null && now - Date.parse(state.last_success_at) < config.minIntervalHours * 36e5) return false;
677
+ return owned.filter((claim) => state.known_versions[claim.id] !== contentHash(claim)).length >= config.minChangedClaims;
678
+ }
679
+ //#endregion
680
+ //#region src/dream/evidence-files.ts
681
+ const within = (root, path) => {
682
+ const rel = relative(root, path);
683
+ return rel === "" || rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel);
684
+ };
685
+ const blocked = (part) => part.startsWith(".") || /^(?:memory\.md|user\.md|export_env\.sh|node_modules|memories)$/i.test(part) || /(?:^|[._-])(?:secrets?|credentials?|private[-_]?keys?|tokens?)(?:[._-]|$)/i.test(part) || /\.(?:pem|key|p12|pfx)$/i.test(part);
686
+ async function authorizeFile(workspace, privateHome, input) {
687
+ requireDream(isAbsolute(workspace) && relative(await fs.realpath(workspace), workspace) === "", "查证工作区已变化。");
688
+ const path = resolve(workspace, input);
689
+ requireDream(within(workspace, path) && !within(await fs.realpath(privateHome), path), "查证路径必须位于工作区且不能进入私有数据目录。");
690
+ const parts = relative(workspace, path).split(sep);
691
+ requireDream(parts.every((part) => part !== "" && !blocked(part)) && !blocked(basename(workspace)), "查证不能读取私有、隐藏或凭据路径。");
692
+ let current = workspace;
693
+ for (const part of parts) {
694
+ current = resolve(current, part);
695
+ requireDream(!(await fs.lstat(current)).isSymbolicLink(), "查证不跟随符号链接。");
696
+ }
697
+ requireDream(relative(await fs.realpath(path), path) === "", "查证文件路径已变化。");
698
+ return path;
699
+ }
700
+ async function readEvidenceFile(workspace, privateHome, input, maxBytes) {
701
+ const path = await authorizeFile(workspace, privateHome, input);
702
+ const file = await openSingleFile(path, () => new DreamValidationError("查证仅接受单链接普通文件,不跟随符号链接。"));
703
+ try {
704
+ const before = await file.stat();
705
+ requireDream(before.isFile() && before.nlink === 1 && before.size <= maxBytes, "查证仅接受预算内的单链接普通文件。");
706
+ const buffer = Buffer.alloc(before.size + 1);
707
+ let length = 0;
708
+ while (length < buffer.length) {
709
+ const read = await file.read(buffer, length, buffer.length - length, length);
710
+ if (read.bytesRead === 0) break;
711
+ length += read.bytesRead;
712
+ }
713
+ const after = await file.stat();
714
+ const current = await fs.lstat(path);
715
+ requireDream(length === before.size && before.size === after.size && before.mtimeMs === after.mtimeMs && before.ctimeMs === after.ctimeMs && before.ino === current.ino && before.dev === current.dev && after.nlink === 1 && !current.isSymbolicLink(), "查证读取期间文件发生变化。");
716
+ await authorizeFile(workspace, privateHome, input);
717
+ const bytes = buffer.subarray(0, length);
718
+ let content;
719
+ try {
720
+ content = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
721
+ } catch {
722
+ throw new DreamValidationError("查证仅接受 UTF-8 文本。");
723
+ }
724
+ requireDream(!content.includes("\0"), "查证不读取二进制内容。");
725
+ return {
726
+ path,
727
+ content,
728
+ revision: {
729
+ sha256: createHash("sha256").update(bytes).digest("hex"),
730
+ byte_len: length
731
+ }
732
+ };
733
+ } finally {
734
+ await file.close();
735
+ }
736
+ }
737
+ async function receiptCurrent(receipt, workspace, privateHome) {
738
+ try {
739
+ const { path, revision } = receipt.output.file_version;
740
+ if (path !== receipt.input.path) return false;
741
+ const file = await readEvidenceFile(workspace, privateHome, path, revision.byte_len);
742
+ return file.revision.sha256 === revision.sha256 && file.revision.byte_len === revision.byte_len;
743
+ } catch (error) {
744
+ if (hasCode(error, "ENOENT") || hasCode(error, "ENOTDIR") || hasCode(error, "ELOOP") || error instanceof DreamValidationError) return false;
745
+ throw error;
746
+ }
747
+ }
748
+ function discoverable(name) {
749
+ return !blocked(name);
750
+ }
751
+ //#endregion
752
+ //#region src/dream/evidence-store.ts
753
+ const ReadArgs = z.strictObject({
754
+ path: z.string().min(1),
755
+ claim_ids: z.array(ClaimIdSchema).min(1),
756
+ start: z.number().int().positive().default(1),
757
+ count: z.number().int().positive().max(2e3).default(200)
758
+ });
759
+ const GlobArgs = z.strictObject({ query: z.string().max(200).default("") });
760
+ const GrepArgs = z.strictObject({ query: z.string().min(1).max(200) });
761
+ const ClaimArgs = z.discriminatedUnion("action", [z.strictObject({ action: z.literal("list") }), z.strictObject({
762
+ action: z.literal("read"),
763
+ id: ClaimIdSchema
764
+ })]);
765
+ const EvidenceTools = {
766
+ read: ReadArgs,
767
+ glob: GlobArgs,
768
+ grep: GrepArgs,
769
+ claim: ClaimArgs
770
+ };
771
+ const LimitsSchema = z.strictObject({
772
+ calls: z.number().int().positive(),
773
+ steps: z.number().int().positive(),
774
+ bytes: z.number().int().positive(),
775
+ chars: z.number().int().positive(),
776
+ files: z.number().int().positive()
777
+ });
778
+ const EvidenceManifestSchema = z.strictObject({
779
+ schemaVersion: z.literal(1),
780
+ job_id: KeySchema,
781
+ group_id: KeySchema,
782
+ workspace_root: z.string(),
783
+ claim_versions: z.record(ClaimIdSchema, z.string()),
784
+ receipts: z.record(z.string(), ReceiptSchema),
785
+ calls: z.number().int().nonnegative(),
786
+ model_steps: z.number().int().nonnegative(),
787
+ bytes_read: z.number().int().nonnegative(),
788
+ files_examined: z.number().int().nonnegative(),
789
+ limits: LimitsSchema,
790
+ completed: z.boolean()
791
+ });
792
+ const privateDataHome = (context) => dirname(dirname(context.paths.root));
793
+ var EvidenceStore = class {
794
+ context;
795
+ jobId;
796
+ groupId;
797
+ path;
798
+ constructor(context, jobId, groupId) {
799
+ this.context = context;
800
+ this.jobId = jobId;
801
+ this.groupId = groupId;
802
+ this.path = join(context.paths.dreamJob(jobId), "evidence", `${KeySchema.parse(groupId)}.yaml`);
803
+ }
804
+ async read() {
805
+ const manifest = await readYamlOr(this.path, EvidenceManifestSchema, () => null);
806
+ requireDream(manifest === null || manifest.job_id === this.jobId && manifest.group_id === this.groupId, "查证清单身份与任务不一致。");
807
+ return manifest;
808
+ }
809
+ save(manifest) {
810
+ return writeYamlAtomic(this.path, manifest, EvidenceManifestSchema, this.context.logger);
811
+ }
812
+ async initialize(workspace, claims, config, signal) {
813
+ return withFileLock(`${this.path}.lock`, async () => {
814
+ signal?.throwIfAborted();
815
+ requireDream(config.evidenceCalibration, "证据校准未启用。");
816
+ const prior = await this.read();
817
+ const versions = Object.fromEntries(claims.map((claim) => [claim.id, claimRevision(claim)]));
818
+ requireDream(claims.length > 0 && claims.every((claim) => claim.holder === this.context.agentId && claim.confidence !== "high" && claim.status !== "deprecated"), "受限查证仅接受自身 medium/low 候选。");
819
+ if (prior !== null) {
820
+ requireDream(prior.workspace_root === workspace && Object.entries(prior.claim_versions).every(([id, revision]) => versions[id] === revision), "查证权限不能换工作区、删除原目标或更换 Claim 版本。");
821
+ if (valueHash(prior.claim_versions) !== valueHash(versions)) {
822
+ prior.claim_versions = versions;
823
+ await this.save(prior);
824
+ }
825
+ return prior;
826
+ }
827
+ const manifest = {
828
+ schemaVersion: 1,
829
+ job_id: this.jobId,
830
+ group_id: this.groupId,
831
+ workspace_root: workspace,
832
+ claim_versions: versions,
833
+ receipts: {},
834
+ calls: 0,
835
+ model_steps: 0,
836
+ bytes_read: 0,
837
+ files_examined: 0,
838
+ limits: {
839
+ calls: config.evidenceMaxCalls,
840
+ steps: config.evidenceMaxSteps,
841
+ bytes: config.evidenceMaxBytes,
842
+ chars: config.evidenceMaxChars,
843
+ files: config.evidenceMaxFiles
844
+ },
845
+ completed: false
846
+ };
847
+ await this.save(manifest);
848
+ return manifest;
849
+ }, { signal });
850
+ }
851
+ async admitStep(signal) {
852
+ await withFileLock(`${this.path}.lock`, async () => {
853
+ signal.throwIfAborted();
854
+ const manifest = await this.read();
855
+ requireDream(manifest !== null && !manifest.completed && manifest.model_steps < manifest.limits.steps, "查证模型步数预算已用尽。");
856
+ manifest.model_steps += 1;
857
+ await this.save(manifest);
858
+ }, { signal });
859
+ }
860
+ async reopen(signal) {
861
+ await withFileLock(`${this.path}.lock`, async () => {
862
+ signal.throwIfAborted();
863
+ const manifest = await this.read();
864
+ requireDream(manifest !== null, "缺少查证清单。");
865
+ manifest.completed = false;
866
+ await this.save(manifest);
867
+ }, { signal });
868
+ }
869
+ async complete(signal) {
870
+ await withFileLock(`${this.path}.lock`, async () => {
871
+ signal.throwIfAborted();
872
+ const manifest = await this.read();
873
+ requireDream(manifest !== null, "缺少查证清单。");
874
+ manifest.completed = true;
875
+ await this.save(manifest);
876
+ }, { signal });
877
+ }
878
+ async current(manifest) {
879
+ for (const receipt of Object.values(manifest.receipts)) if (!await receiptCurrent(receipt, manifest.workspace_root, privateDataHome(this.context))) return false;
880
+ return true;
881
+ }
882
+ async authorize(receipts, workspace, before) {
883
+ if (Object.keys(receipts).length === 0) return true;
884
+ const manifest = await this.read();
885
+ requireDream(manifest !== null && manifest.completed && manifest.workspace_root === workspace, "证据缺少已完成的插件查证清单或工作区授权。");
886
+ for (const [id, raw] of Object.entries(receipts)) {
887
+ const receipt = independentReceipt(receipts, id);
888
+ const original = manifest.receipts[id];
889
+ requireDream(receipt !== null && original !== void 0 && valueHash(raw) === valueHash(original), "证据回执并非由本组受限读取产生。");
890
+ requireDream(receipt.input.claim_ids !== void 0 && receipt.input.claim_ids.length > 0 && receipt.input.claim_ids.every((id) => before.some((claim) => claim.id === id && manifest.claim_versions[id] === claimRevision(claim) && claim.confidence !== "high")), "证据授权的 Claim 或原始版本不一致。");
891
+ if (!await receiptCurrent(receipt, manifest.workspace_root, privateDataHome(this.context))) return false;
892
+ }
893
+ return true;
894
+ }
895
+ async execute(name, args, claims, signal) {
896
+ return withFileLock(`${this.path}.lock`, async () => {
897
+ signal.throwIfAborted();
898
+ const manifest = await this.read();
899
+ requireDream(manifest !== null && !manifest.completed, "查证已结束或尚未授权。");
900
+ requireDream(manifest.calls < manifest.limits.calls, "查证工具调用预算已用尽。");
901
+ manifest.calls += 1;
902
+ await this.save(manifest);
903
+ const eligible = claims.filter((claim) => manifest.claim_versions[claim.id] === claimRevision(claim));
904
+ if (name === "claim") {
905
+ const input = ClaimArgs.parse(args);
906
+ if (input.action === "list") return z.json().parse(eligible);
907
+ const claim = eligible.find((claim) => claim.id === input.id);
908
+ requireDream(claim !== void 0, "只读 claim 不能访问候选以外的知识。");
909
+ return z.json().parse(claim);
910
+ }
911
+ const load = async (path) => {
912
+ signal.throwIfAborted();
913
+ const allowed = await authorizeFile(manifest.workspace_root, privateDataHome(this.context), path);
914
+ const stat = await fs.lstat(allowed);
915
+ requireDream(stat.isFile() && stat.nlink === 1 && stat.size + 1 <= manifest.limits.bytes - manifest.bytes_read, "查证文件或总字节预算不允许本次读取。");
916
+ manifest.bytes_read += stat.size + 1;
917
+ await this.save(manifest);
918
+ return readEvidenceFile(manifest.workspace_root, privateDataHome(this.context), path, stat.size);
919
+ };
920
+ if (name === "read") {
921
+ const input = ReadArgs.parse(args);
922
+ requireDream(new Set(input.claim_ids).size === input.claim_ids.length && input.claim_ids.every((id) => eligible.some((claim) => claim.id === id)), `读取证据必须明确绑定本组可校准 Claim,允许的 claim_ids:${eligible.map((claim) => claim.id).join(", ")}。`);
923
+ const file = await load(input.path);
924
+ const lines = file.content.split("\n");
925
+ requireDream(input.start <= lines.length, "读取起始行超过文件。");
926
+ const selected = [];
927
+ let chars = 0;
928
+ for (const line of lines.slice(input.start - 1, input.start - 1 + input.count)) {
929
+ if (chars + line.length + 1 > manifest.limits.chars) break;
930
+ selected.push(line);
931
+ chars += line.length + 1;
932
+ }
933
+ requireDream(selected.length > 0, "单行超过查证字符预算,请缩小文件内容。");
934
+ const receipt = ReceiptSchema.parse({
935
+ tool: "file_read",
936
+ input: {
937
+ path: file.path,
938
+ claim_ids: input.claim_ids,
939
+ show_linenos: false,
940
+ start: input.start,
941
+ count: input.count
942
+ },
943
+ output: {
944
+ content: selected.join("\n"),
945
+ page: {
946
+ returned_start: input.start,
947
+ returned_end: input.start + selected.length - 1,
948
+ total_lines: lines.length,
949
+ truncated: input.start + selected.length - 1 < lines.length
950
+ },
951
+ file_version: {
952
+ path: file.path,
953
+ revision: file.revision
954
+ }
955
+ }
956
+ });
957
+ const evidence_id = `file_${randomUUID().replaceAll("-", "")}`;
958
+ manifest.receipts[evidence_id] = receipt;
959
+ await this.save(manifest);
960
+ signal.throwIfAborted();
961
+ return z.json().parse({
962
+ evidence_id,
963
+ ...receipt
964
+ });
965
+ }
966
+ const input = name === "glob" ? GlobArgs.parse(args) : GrepArgs.parse(args);
967
+ const matches = [];
968
+ let chars = 0;
969
+ let truncated = false;
970
+ const walk = async (directory) => {
971
+ const dir = await fs.opendir(directory);
972
+ for await (const entry of dir) {
973
+ signal.throwIfAborted();
974
+ if (manifest.files_examined >= manifest.limits.files) {
975
+ truncated = true;
976
+ break;
977
+ }
978
+ manifest.files_examined += 1;
979
+ await this.save(manifest);
980
+ if (!discoverable(entry.name) || entry.isSymbolicLink()) continue;
981
+ const path = join(directory, entry.name);
982
+ try {
983
+ await authorizeFile(manifest.workspace_root, privateDataHome(this.context), path);
984
+ if (entry.isDirectory()) {
985
+ await walk(path);
986
+ if (truncated) break;
987
+ } else if (entry.isFile()) {
988
+ const label = relative(manifest.workspace_root, path);
989
+ if (name === "glob") {
990
+ if (!label.includes(input.query)) continue;
991
+ if (chars + label.length > manifest.limits.chars) {
992
+ truncated = true;
993
+ break;
994
+ }
995
+ matches.push({ path: label });
996
+ chars += label.length;
997
+ } else {
998
+ const file = await load(path);
999
+ for (const [index, line] of file.content.split("\n").entries()) if (line.includes(input.query)) {
1000
+ if (chars + line.length + label.length > manifest.limits.chars) {
1001
+ truncated = true;
1002
+ break;
1003
+ }
1004
+ matches.push({
1005
+ path: label,
1006
+ line: index + 1,
1007
+ text: line
1008
+ });
1009
+ chars += line.length + label.length;
1010
+ }
1011
+ if (truncated) break;
1012
+ }
1013
+ }
1014
+ } catch (error) {
1015
+ if (!(error instanceof DreamValidationError)) throw error;
1016
+ }
1017
+ }
1018
+ };
1019
+ await walk(manifest.workspace_root);
1020
+ await this.save(manifest);
1021
+ return z.json().parse({
1022
+ matches,
1023
+ truncated,
1024
+ independent_evidence: false
1025
+ });
1026
+ }, { signal });
1027
+ }
1028
+ };
1029
+ //#endregion
1030
+ export { OperationSchema as $, valueHash as A, CandidateSchema as B, expandDraft as C, sameIds as D, reviewInput as E, evidenceBody as F, DraftResponseSchema as G, CoverageSchema as H, independentReceipt as I, GroupSchema as J, DreamStateSchema as K, requireEvidenceIds as L, validateEvidenceSummaryPreservation as M, ReceiptSchema as N, validateCandidates as O, directEvidence as P, KindSchema as Q, nextClaimUpdateAt as R, contentHash as S, reaches as T, DiscoverySchema as U, CheckpointSchema as V, DraftGroupSchema as W, KeepReasonSchema as X, HashSchema as Y, KeySchema as Z, dreamEligible as _, GlobArgs as a, ReviewInputSchema as at, validateSelfReview as b, privateDataHome as c, ReviewSummarySchema as ct, readEvidenceFile as d, UpdateSchema as dt, OriginSchema as et, receiptCurrent as f, ValidationSchema as ft, conservativeTokens as g, claimInput as h, EvidenceTools as i, QuoteSchema as it, validateEvidencePreservation as j, validateConsolidationSources as k, authorizeFile as l, SelfReviewSchema as lt, INPUT_TOKENS as m, text as mt, EvidenceManifestSchema as n, PreparedGroupSchema as nt, GrepArgs as o, ReviewRecordSchema as ot, within as p, requireDream as pt, DreamValidationError as q, EvidenceStore as r, ProgressSchema as rt, ReadArgs as s, ReviewResponseSchema as st, ClaimArgs as t, PlanSchema as tt, discoverable as u, SemanticReviewSchema as ut, versions as v, prepareGroup as w, validateSemanticReview as x, coverageGaps as y, BasisSchema as z };