@ftai/dsh-plugin-acn 0.0.0-stage → 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 (272) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/LICENSE-APACHE +201 -0
  3. package/LICENSE-MIT +19 -0
  4. package/README.md +55 -2
  5. package/README_EN.md +56 -0
  6. package/cordis.patch.yml +29 -0
  7. package/docs/acn-compat.md +33 -0
  8. package/docs/architecture.md +129 -0
  9. package/docs/assets/activity-view.png +0 -0
  10. package/docs/assets/install-package.png +0 -0
  11. package/docs/assets/knowledge-model.png +0 -0
  12. package/docs/assets/knowledge-view.png +0 -0
  13. package/docs/assets/personal-configuration.png +0 -0
  14. package/docs/assets/session-upstream.png +0 -0
  15. package/docs/assets/upstream-settings.png +0 -0
  16. package/docs/assets/upstream-team.png +0 -0
  17. package/docs/command-reference.md +201 -0
  18. package/docs/config.md +243 -0
  19. package/docs/development.md +197 -0
  20. package/docs/dsh-compat.md +59 -0
  21. package/docs/index.md +16 -0
  22. package/docs/outstanding-issues.md +61 -0
  23. package/docs/user_guide.md +183 -0
  24. package/icon.svg +8 -0
  25. package/lib/activities-LRoCwpzw.js +327 -0
  26. package/lib/alignment-CwH0nBf-.js +80 -0
  27. package/lib/auth-DFI9yowX.js +71 -0
  28. package/lib/checkpoint-Bmt8q2vB.js +188 -0
  29. package/lib/checkpoint-RgcdqifN.js +318 -0
  30. package/lib/claim-DOAGe8ZK.js +168 -0
  31. package/lib/client.js +18420 -0
  32. package/lib/deliver-BuYQaPRW.js +168 -0
  33. package/lib/delivery-status-D5m3178s.js +87 -0
  34. package/lib/dispute-CtrInHzf.js +20 -0
  35. package/lib/disputes-ByEmi43j.js +51 -0
  36. package/lib/dream-agent-DBszTHXY.js +249 -0
  37. package/lib/dream.js +4 -0
  38. package/lib/effects-DJ4Xa7Tx.js +268 -0
  39. package/lib/errors-Bp_2WXBr.js +19 -0
  40. package/lib/errors-pPumDOGD.js +18 -0
  41. package/lib/evidence-store-DLFvSuNa.js +1030 -0
  42. package/lib/formation-D4LO31WW.js +187 -0
  43. package/lib/formation-replay-CEOy5FkI.js +87 -0
  44. package/lib/formation.js +9 -0
  45. package/lib/inbox-2CugZZQm.js +188 -0
  46. package/lib/inbox-DFtE2fOp.js +71 -0
  47. package/lib/inbox.js +3 -0
  48. package/lib/index.js +1377 -0
  49. package/lib/lock-DbmlKOoX.js +332 -0
  50. package/lib/pages-BEWC3kmZ.js +51 -0
  51. package/lib/paths-CDYV5UH9.js +154 -0
  52. package/lib/plugins/commands.js +590 -0
  53. package/lib/plugins/dream.js +66 -0
  54. package/lib/plugins/formation.js +66 -0
  55. package/lib/plugins/inbox.js +53 -0
  56. package/lib/plugins/knowledge.js +1111 -0
  57. package/lib/plugins/prompt.js +102 -0
  58. package/lib/plugins/tools.js +280 -0
  59. package/lib/policy-DnyHh7Bl.js +16 -0
  60. package/lib/prepare-DwHZudbA.js +134 -0
  61. package/lib/presentation-BlLjgDjP.js +47 -0
  62. package/lib/protocol.js +8 -0
  63. package/lib/queue-M917xHPS.js +153 -0
  64. package/lib/regular-file-BFpqMoub.js +136 -0
  65. package/lib/render-CJaVcKKC.js +48 -0
  66. package/lib/reported-sets-DdEKdeVb.js +122 -0
  67. package/lib/revision-DeoL_IUN.js +11 -0
  68. package/lib/scheduler-MaUEbXr3.js +64 -0
  69. package/lib/service-B7AI5jds.js +344 -0
  70. package/lib/service-BcHV5mc7.js +305 -0
  71. package/lib/service-CNjqHCBR.js +505 -0
  72. package/lib/service-C_i3BzdP.js +1106 -0
  73. package/lib/session-binding-BQrOGhZI.js +151 -0
  74. package/lib/session-state-CYqUhC95.js +38 -0
  75. package/lib/sessions-C2xuPFQv.js +218 -0
  76. package/lib/store.js +16 -0
  77. package/lib/structured-lyQCK-Zk.js +452 -0
  78. package/lib/subagent-yJsFxHmH.js +9 -0
  79. package/lib/team-credentials-C9xHrPIi.js +579 -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 +71 -0
  85. package/lib/types/advanced-configuration.d.ts +11 -0
  86. package/lib/types/client/ActivityDetails.d.ts +18 -0
  87. package/lib/types/client/AdvancedPreferences.d.ts +8 -0
  88. package/lib/types/client/BlankCommandFeedback.d.ts +10 -0
  89. package/lib/types/client/ComposerMenu.d.ts +24 -0
  90. package/lib/types/client/ConfigurationPage.d.ts +11 -0
  91. package/lib/types/client/ConnectionCheckDialog.d.ts +12 -0
  92. package/lib/types/client/KnowledgeDetail.d.ts +6 -0
  93. package/lib/types/client/KnowledgeDirectoryField.d.ts +11 -0
  94. package/lib/types/client/KnowledgePanel.d.ts +12 -0
  95. package/lib/types/client/KnowledgeReference.d.ts +13 -0
  96. package/lib/types/client/SessionToolbar.d.ts +16 -0
  97. package/lib/types/client/SettingsToast.d.ts +3 -0
  98. package/lib/types/client/SourceSessionLink.d.ts +15 -0
  99. package/lib/types/client/TeamCredentialField.d.ts +16 -0
  100. package/lib/types/client/TeamSettingsPage.d.ts +30 -0
  101. package/lib/types/client/configuration-errors.d.ts +2 -0
  102. package/lib/types/client/interaction-styles.d.ts +1 -0
  103. package/lib/types/client/interaction-ui.d.ts +30 -0
  104. package/lib/types/client/knowledge-labels.d.ts +5 -0
  105. package/lib/types/client/locales.d.ts +51 -0
  106. package/lib/types/commands/claim.d.ts +4 -0
  107. package/lib/types/commands/import.d.ts +10 -0
  108. package/lib/types/commands/status.d.ts +5 -0
  109. package/lib/types/config.d.ts +122 -0
  110. package/lib/types/configuration.d.ts +259 -0
  111. package/lib/types/credentials.d.ts +65 -0
  112. package/lib/types/dream/audit.d.ts +4 -0
  113. package/lib/types/dream/autonomous.d.ts +185 -0
  114. package/lib/types/dream/candidates.d.ts +34 -0
  115. package/lib/types/dream/checkpoint.d.ts +35 -0
  116. package/lib/types/dream/evidence-files.d.ts +10 -0
  117. package/lib/types/dream/evidence-store.d.ts +103 -0
  118. package/lib/types/dream/evidence.d.ts +30 -0
  119. package/lib/types/dream/index.d.ts +10 -0
  120. package/lib/types/dream/plan.d.ts +18 -0
  121. package/lib/types/dream/preservation.d.ts +6 -0
  122. package/lib/types/dream/review.d.ts +10 -0
  123. package/lib/types/dream/schema.d.ts +1475 -0
  124. package/lib/types/dream/service.d.ts +56 -0
  125. package/lib/types/dream/sync.d.ts +147 -0
  126. package/lib/types/dsh-adapter/configuration-remote.d.ts +1 -0
  127. package/lib/types/dsh-adapter/configuration-service.d.ts +28 -0
  128. package/lib/types/dsh-adapter/dream-agent.d.ts +4 -0
  129. package/lib/types/dsh-adapter/dream-evidence.d.ts +3 -0
  130. package/lib/types/dsh-adapter/formation-archive.d.ts +3 -0
  131. package/lib/types/dsh-adapter/formation-replay.d.ts +5 -0
  132. package/lib/types/dsh-adapter/formation.d.ts +4 -0
  133. package/lib/types/dsh-adapter/interaction-service.d.ts +13 -0
  134. package/lib/types/dsh-adapter/knowledge-paths.d.ts +3 -0
  135. package/lib/types/dsh-adapter/llm.d.ts +10 -0
  136. package/lib/types/dsh-adapter/project-upstream.d.ts +4 -0
  137. package/lib/types/dsh-adapter/runtime-pool.d.ts +110 -0
  138. package/lib/types/dsh-adapter/session-binding.d.ts +43 -0
  139. package/lib/types/dsh-adapter/source-sessions.d.ts +3 -0
  140. package/lib/types/dsh-adapter/team-credentials.d.ts +5 -0
  141. package/lib/types/dsh-adapter/tool-schema.d.ts +4 -0
  142. package/lib/types/dsh-adapter/tools.d.ts +5 -0
  143. package/lib/types/formation/capture.d.ts +19 -0
  144. package/lib/types/formation/checkpoint.d.ts +136 -0
  145. package/lib/types/formation/index.d.ts +10 -0
  146. package/lib/types/formation/prepare.d.ts +16 -0
  147. package/lib/types/formation/schema.d.ts +45 -0
  148. package/lib/types/formation/service.d.ts +58 -0
  149. package/lib/types/formation/transcript.d.ts +75 -0
  150. package/lib/types/formation/triggers.d.ts +3 -0
  151. package/lib/types/inbox/cascade.d.ts +3 -0
  152. package/lib/types/inbox/effects.d.ts +275 -0
  153. package/lib/types/inbox/index.d.ts +5 -0
  154. package/lib/types/inbox/prepare.d.ts +380 -0
  155. package/lib/types/inbox/service.d.ts +26 -0
  156. package/lib/types/inbox/sync.d.ts +9 -0
  157. package/lib/types/index.d.ts +1 -0
  158. package/lib/types/interaction-messages.d.ts +69 -0
  159. package/lib/types/interaction.d.ts +550 -0
  160. package/lib/types/knowledge/alignment.d.ts +49 -0
  161. package/lib/types/knowledge/catalog.d.ts +5 -0
  162. package/lib/types/knowledge/changes.d.ts +32 -0
  163. package/lib/types/knowledge/disputes.d.ts +3 -0
  164. package/lib/types/knowledge/errors.d.ts +9 -0
  165. package/lib/types/knowledge/ordering.d.ts +7 -0
  166. package/lib/types/knowledge/pages.d.ts +7 -0
  167. package/lib/types/knowledge/safety.d.ts +2 -0
  168. package/lib/types/knowledge/service.d.ts +52 -0
  169. package/lib/types/knowledge/sessions.d.ts +59 -0
  170. package/lib/types/knowledge/sources.d.ts +2 -0
  171. package/lib/types/knowledge/timestamps.d.ts +1 -0
  172. package/lib/types/knowledge/types.d.ts +84 -0
  173. package/lib/types/llm/response.d.ts +1 -0
  174. package/lib/types/llm/structured.d.ts +27 -0
  175. package/lib/types/local-name.d.ts +1 -0
  176. package/lib/types/plugins/client.d.ts +9 -0
  177. package/lib/types/plugins/commands.d.ts +11 -0
  178. package/lib/types/plugins/configuration.d.ts +8 -0
  179. package/lib/types/plugins/dream.d.ts +16 -0
  180. package/lib/types/plugins/formation.d.ts +16 -0
  181. package/lib/types/plugins/inbox.d.ts +16 -0
  182. package/lib/types/plugins/knowledge.d.ts +19 -0
  183. package/lib/types/plugins/prompt.d.ts +17 -0
  184. package/lib/types/plugins/tools.d.ts +10 -0
  185. package/lib/types/prompt/render.d.ts +2 -0
  186. package/lib/types/protocol/arbitration.d.ts +154 -0
  187. package/lib/types/protocol/auth.d.ts +31 -0
  188. package/lib/types/protocol/claim.d.ts +36 -0
  189. package/lib/types/protocol/dispute.d.ts +17 -0
  190. package/lib/types/protocol/ids.d.ts +20 -0
  191. package/lib/types/protocol/inbox.d.ts +141 -0
  192. package/lib/types/protocol/index.d.ts +11 -0
  193. package/lib/types/protocol/policy.d.ts +21 -0
  194. package/lib/types/protocol/revision.d.ts +2 -0
  195. package/lib/types/protocol/router.d.ts +114 -0
  196. package/lib/types/protocol/schema.d.ts +4 -0
  197. package/lib/types/protocol/time.d.ts +5 -0
  198. package/lib/types/protocol/trace.d.ts +11 -0
  199. package/lib/types/store/atomic.d.ts +8 -0
  200. package/lib/types/store/claim-edits.d.ts +33 -0
  201. package/lib/types/store/claims.d.ts +7 -0
  202. package/lib/types/store/context.d.ts +13 -0
  203. package/lib/types/store/delivery-status.d.ts +47 -0
  204. package/lib/types/store/disputes.d.ts +6 -0
  205. package/lib/types/store/entities.d.ts +16 -0
  206. package/lib/types/store/errors.d.ts +8 -0
  207. package/lib/types/store/inbox.d.ts +27 -0
  208. package/lib/types/store/index.d.ts +16 -0
  209. package/lib/types/store/jobs.d.ts +5 -0
  210. package/lib/types/store/lock.d.ts +11 -0
  211. package/lib/types/store/path-names.d.ts +2 -0
  212. package/lib/types/store/paths.d.ts +45 -0
  213. package/lib/types/store/presentation.d.ts +13 -0
  214. package/lib/types/store/regular-file.d.ts +2 -0
  215. package/lib/types/store/rejected-disputes.d.ts +18 -0
  216. package/lib/types/store/rename.d.ts +1 -0
  217. package/lib/types/store/reported-sets.d.ts +24 -0
  218. package/lib/types/store/session-state.d.ts +17 -0
  219. package/lib/types/store/traces.d.ts +6 -0
  220. package/lib/types/store/uploads.d.ts +312 -0
  221. package/lib/types/store/yaml.d.ts +8 -0
  222. package/lib/types/team/errors.d.ts +10 -0
  223. package/lib/types/team/http.d.ts +20 -0
  224. package/lib/types/team/index.d.ts +5 -0
  225. package/lib/types/team/maintainer-client.d.ts +18 -0
  226. package/lib/types/team/router-client.d.ts +14 -0
  227. package/lib/types/team/service.d.ts +28 -0
  228. package/lib/types/team/system-proxy.d.ts +9 -0
  229. package/lib/types/tools/claim.d.ts +63 -0
  230. package/lib/types/tools/consult-router.d.ts +11 -0
  231. package/lib/types/tools/subagent.d.ts +8 -0
  232. package/lib/types/tools/validation.d.ts +2 -0
  233. package/lib/types/upload/consolidation.d.ts +63 -0
  234. package/lib/types/upload/deliver.d.ts +15 -0
  235. package/lib/types/upload/index.d.ts +2 -0
  236. package/lib/types/upload/scheduler.d.ts +19 -0
  237. package/lib/types/upstreams.d.ts +5 -0
  238. package/lib/types/worker/queue.d.ts +17 -0
  239. package/lib/types/worker/types.d.ts +51 -0
  240. package/lib/types/worker/worker.d.ts +39 -0
  241. package/lib/types-C2ST2Zdg.js +17 -0
  242. package/lib/upload.js +3 -0
  243. package/lib/uploads-BCA2p92b.js +210 -0
  244. package/lib/worker-BBTYP2RE.js +185 -0
  245. package/locale/commands/en.json +1 -0
  246. package/locale/commands/zh.json +1 -0
  247. package/locale/dream/en.json +1 -0
  248. package/locale/dream/zh.json +1 -0
  249. package/locale/en.json +7 -0
  250. package/locale/formation/en.json +1 -0
  251. package/locale/formation/zh.json +1 -0
  252. package/locale/inbox/en.json +1 -0
  253. package/locale/inbox/zh.json +1 -0
  254. package/locale/knowledge/en.json +1 -0
  255. package/locale/knowledge/zh.json +1 -0
  256. package/locale/prompt/en.json +1 -0
  257. package/locale/prompt/zh.json +1 -0
  258. package/locale/tools/en.json +1 -0
  259. package/locale/tools/zh.json +1 -0
  260. package/locale/zh.json +7 -0
  261. package/package.json +262 -3
  262. package/prompts/claim_dream.j2 +77 -0
  263. package/prompts/claim_dream_legacy.j2 +63 -0
  264. package/prompts/dream_compaction.j2 +11 -0
  265. package/prompts/dream_evidence.j2 +5 -0
  266. package/prompts/inbox_claim_attribute_update_internalize.j2 +112 -0
  267. package/prompts/inbox_policy_update_internalize.j2 +87 -0
  268. package/prompts/knowledge.j2 +38 -0
  269. package/prompts/session_recap.j2 +113 -0
  270. package/prompts/what_is_claim.j2 +51 -0
  271. package/prompts/what_is_dispute.j2 +21 -0
  272. package/prompts/what_is_policy.j2 +22 -0
@@ -0,0 +1,16 @@
1
+ import type { Claim } from '../protocol/claim.js';
2
+ import type { Dispute } from '../protocol/dispute.js';
3
+ import type { AgentId, ClaimId } from '../protocol/ids.js';
4
+ export interface PreparedFormation {
5
+ claims: Claim[];
6
+ disputes: Dispute[];
7
+ usedClaimIds: ClaimId[];
8
+ warnings: string[];
9
+ syncClaims?: Claim[];
10
+ }
11
+ export interface PreparationVisibility {
12
+ directClaims?: readonly Claim[];
13
+ editableDeprecatedIds?: ReadonlySet<ClaimId>;
14
+ }
15
+ export declare function recapClaimIds(texts: readonly string[]): ClaimId[];
16
+ export declare function prepareFormation(raw: unknown, agentId: AgentId, local: readonly Claim[], seenSourceIds: readonly string[], now?: string, visibility?: PreparationVisibility): PreparedFormation;
@@ -0,0 +1,45 @@
1
+ import { z } from 'zod';
2
+ export declare const RecapOutputSchema: z.ZodObject<{
3
+ new_claims: z.ZodArray<z.ZodObject<{
4
+ id: z.ZodString;
5
+ name: z.ZodString;
6
+ statement: z.ZodString;
7
+ scope: z.ZodString;
8
+ confidence: z.ZodEnum<{
9
+ high: "high";
10
+ medium: "medium";
11
+ low: "low";
12
+ }>;
13
+ evidence_summary: z.ZodString;
14
+ source_claim_ids: z.ZodArray<z.ZodString>;
15
+ }, z.core.$strict>>;
16
+ updated_claims: z.ZodArray<z.ZodObject<{
17
+ status: z.ZodEnum<{
18
+ active: "active";
19
+ stale: "stale";
20
+ deprecated: "deprecated";
21
+ }>;
22
+ id: z.ZodString;
23
+ name: z.ZodString;
24
+ statement: z.ZodString;
25
+ scope: z.ZodString;
26
+ confidence: z.ZodEnum<{
27
+ high: "high";
28
+ medium: "medium";
29
+ low: "low";
30
+ }>;
31
+ evidence_summary: z.ZodString;
32
+ source_claim_ids: z.ZodArray<z.ZodString>;
33
+ }, z.core.$strict>>;
34
+ used_claim_ids: z.ZodArray<z.ZodString>;
35
+ new_disputes: z.ZodArray<z.ZodObject<{
36
+ id: z.ZodString;
37
+ name: z.ZodString;
38
+ claims: z.ZodArray<z.ZodString>;
39
+ summary: z.ZodString;
40
+ }, z.core.$strict>>;
41
+ }, z.core.$strict>;
42
+ export type RecapOutput = z.infer<typeof RecapOutputSchema>;
43
+ export declare class FormationValidationError extends Error {
44
+ readonly kind = "formation_validation";
45
+ }
@@ -0,0 +1,58 @@
1
+ import type { AcnKnowledge } from '../knowledge/service.js';
2
+ import type { StructuredBackend } from '../llm/structured.js';
3
+ import { DurableWorker } from '../worker/worker.js';
4
+ import type { Job } from '../worker/types.js';
5
+ import { TranscriptStore } from './transcript.js';
6
+ import type { Projection, Route } from './transcript.js';
7
+ import type { ProjectionReplay } from './capture.js';
8
+ export declare class AcnFormation {
9
+ readonly knowledge: AcnKnowledge;
10
+ private readonly backend;
11
+ private readonly render;
12
+ private readonly routeReady?;
13
+ readonly worker: DurableWorker;
14
+ readonly transcript: TranscriptStore;
15
+ private pending;
16
+ private readonly captures;
17
+ private readonly compactions;
18
+ private readonly archiveChecks;
19
+ private archiveView;
20
+ private readonly timers;
21
+ private readonly attached;
22
+ private readonly activeSessions;
23
+ private scanner;
24
+ private started;
25
+ private closing;
26
+ private closeTask;
27
+ private readonly unregister;
28
+ private readonly ownsWorker;
29
+ constructor(knowledge: AcnKnowledge, backend: StructuredBackend, render: (name: string, context: object) => string, workerOptions?: ConstructorParameters<typeof DurableWorker>[1], worker?: DurableWorker, routeReady?: ((route: Route) => Promise<boolean>) | undefined, replay?: ProjectionReplay);
30
+ start(): Promise<void>;
31
+ attach(id: string): void;
32
+ capture(id: string, projection: Projection, compactedUntil?: number): void;
33
+ private report;
34
+ private schedule;
35
+ private flushCompaction;
36
+ flush(id?: string): Promise<void>;
37
+ private rememberRoute;
38
+ running(id: string): void;
39
+ idle(id: string): void;
40
+ disposed(id: string): void;
41
+ finalize(id: string): Promise<Job>;
42
+ recap(id: string): Promise<Job | null>;
43
+ scan(now?: number): Promise<void>;
44
+ private scanPending;
45
+ private checkIdle;
46
+ beginArchive(id: string, upper?: number): Promise<number | null>;
47
+ cancelArchive(id: string): Promise<void>;
48
+ archived(id: string, upper: number): Promise<void>;
49
+ private recordArchive;
50
+ reconcileArchives(archived: ReadonlySet<string>): Promise<void>;
51
+ private reconcilePendingArchives;
52
+ private finishArchive;
53
+ private enqueueNew;
54
+ private enqueue;
55
+ private run;
56
+ close(): Promise<void>;
57
+ private finishClose;
58
+ }
@@ -0,0 +1,75 @@
1
+ import { z } from 'zod';
2
+ import type { StoreContext } from '../store/context.js';
3
+ import { SessionStateStore } from '../store/session-state.js';
4
+ export declare const RouteSchema: z.ZodObject<{
5
+ provider: z.ZodString;
6
+ model: z.ZodString;
7
+ }, z.core.$strict>;
8
+ export type Route = z.infer<typeof RouteSchema>;
9
+ export declare const FormationStateSchema: z.ZodObject<{
10
+ lastSeenSeq: z.ZodDefault<z.ZodNumber>;
11
+ recappedThroughSeq: z.ZodDefault<z.ZodNumber>;
12
+ finalizedThroughSeq: z.ZodDefault<z.ZodNumber>;
13
+ lastRoute: z.ZodOptional<z.ZodObject<{
14
+ provider: z.ZodString;
15
+ model: z.ZodString;
16
+ }, z.core.$strict>>;
17
+ seenSourceIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
18
+ privateToolCalls: z.ZodDefault<z.ZodArray<z.ZodString>>;
19
+ activityAt: z.ZodDefault<z.ZodNumber>;
20
+ activitySeq: z.ZodDefault<z.ZodNumber>;
21
+ humanTurn: z.ZodDefault<z.ZodBoolean>;
22
+ completedTurns: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
23
+ autoPaused: z.ZodDefault<z.ZodBoolean>;
24
+ archivedThroughSeq: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
25
+ archiveIntent: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
26
+ archivePending: z.ZodDefault<z.ZodBoolean>;
27
+ }, z.core.$strip>;
28
+ export type FormationState = z.infer<typeof FormationStateSchema>;
29
+ export declare const TranscriptEntrySchema: z.ZodObject<{
30
+ seq: z.ZodNumber;
31
+ type: z.ZodEnum<{
32
+ user: "user";
33
+ assistant: "assistant";
34
+ tool_call: "tool_call";
35
+ tool_result: "tool_result";
36
+ }>;
37
+ text: z.ZodString;
38
+ projection: z.ZodOptional<z.ZodObject<{
39
+ truncated: z.ZodBoolean;
40
+ original_chars: z.ZodNumber;
41
+ retained_chars: z.ZodNumber;
42
+ }, z.core.$strict>>;
43
+ }, z.core.$strict>;
44
+ export type TranscriptEntry = z.infer<typeof TranscriptEntrySchema>;
45
+ export interface Projection {
46
+ entry?: TranscriptEntry;
47
+ route?: Route;
48
+ seenSourceIds?: string[];
49
+ privateCallId?: string;
50
+ resultCallId?: string;
51
+ sourceSeq?: number;
52
+ sourceArchived?: boolean;
53
+ activity?: {
54
+ seq: number;
55
+ at: number;
56
+ human?: boolean;
57
+ turn?: 'start' | 'completed' | 'ended';
58
+ };
59
+ }
60
+ export declare const processedThrough: (state: FormationState) => number;
61
+ export declare class TranscriptStore {
62
+ readonly context: StoreContext;
63
+ private readonly maxBytes;
64
+ readonly states: SessionStateStore;
65
+ constructor(context: StoreContext, maxBytes?: number);
66
+ state(id: string): Promise<FormationState>;
67
+ read(id: string, repair?: boolean): Promise<TranscriptEntry[]>;
68
+ private pendingFiles;
69
+ private materialize;
70
+ record(id: string, projection: Projection): Promise<void>;
71
+ replay(id: string, projections: readonly Projection[]): Promise<void>;
72
+ advance(id: string, kind: 'recap' | 'finalize', untilSeq: number): Promise<void>;
73
+ lifecycle(id: string, change: (state: FormationState) => void): Promise<FormationState>;
74
+ sessions(formationOnly?: boolean): Promise<string[]>;
75
+ }
@@ -0,0 +1,3 @@
1
+ import type { ResolvedConfig } from '../config.js';
2
+ import type { FormationState, TranscriptEntry } from './transcript.js';
3
+ export declare function idleTrigger(config: ResolvedConfig['formation'], state: FormationState, entries: readonly TranscriptEntry[], now: number): 'batch-idle' | 'tail-idle' | undefined;
@@ -0,0 +1,3 @@
1
+ import type { Claim } from '../protocol/claim.js';
2
+ import type { PolicyId } from '../protocol/ids.js';
3
+ export declare function deprecatePolicyClaims(policyId: PolicyId, local: readonly Claim[], now?: string): Claim[];
@@ -0,0 +1,275 @@
1
+ import { z } from 'zod';
2
+ import type { StoreContext } from '../store/context.js';
3
+ import { type Claim } from '../protocol/claim.js';
4
+ import { type InboxMessage } from '../protocol/inbox.js';
5
+ import type { PreparedFormation } from '../formation/prepare.js';
6
+ import type { JobControl } from '../worker/worker.js';
7
+ export declare const InboxEffectSchema: z.ZodObject<{
8
+ schemaVersion: z.ZodLiteral<1>;
9
+ type: z.ZodLiteral<"effect">;
10
+ canonicalId: z.core.$ZodBranded<z.ZodString, "InboxId", "out">;
11
+ batchHash: z.ZodString;
12
+ members: z.ZodArray<z.ZodObject<{
13
+ id: z.core.$ZodBranded<z.ZodString, "InboxId", "out">;
14
+ hash: z.ZodString;
15
+ message: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
16
+ id: z.core.$ZodBranded<z.ZodString, "InboxId", "out">;
17
+ message_type: z.ZodLiteral<"policy_update">;
18
+ policy: z.ZodObject<{
19
+ id: z.core.$ZodBranded<z.ZodString, "PolicyId", "out">;
20
+ message_type: z.ZodDefault<z.ZodEnum<{
21
+ policy_update: "policy_update";
22
+ claim_attribute_update: "claim_attribute_update";
23
+ }>>;
24
+ name: z.ZodString;
25
+ statement: z.ZodString;
26
+ scope: z.ZodString;
27
+ status: z.ZodEnum<{
28
+ active: "active";
29
+ deprecated: "deprecated";
30
+ }>;
31
+ created_at: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
32
+ updated_at: z.ZodPreprocess<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
33
+ target_agents: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.core.$ZodBranded<z.ZodString, "AgentId", "out">>>>;
34
+ }, z.core.$strip>;
35
+ handled_at: z.ZodPreprocess<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
36
+ }, z.core.$strip>, z.ZodObject<{
37
+ id: z.core.$ZodBranded<z.ZodString, "InboxId", "out">;
38
+ message_type: z.ZodLiteral<"claim_attribute_update">;
39
+ policy: z.ZodObject<{
40
+ id: z.core.$ZodBranded<z.ZodString, "PolicyId", "out">;
41
+ message_type: z.ZodDefault<z.ZodEnum<{
42
+ policy_update: "policy_update";
43
+ claim_attribute_update: "claim_attribute_update";
44
+ }>>;
45
+ name: z.ZodString;
46
+ statement: z.ZodString;
47
+ scope: z.ZodString;
48
+ status: z.ZodEnum<{
49
+ active: "active";
50
+ deprecated: "deprecated";
51
+ }>;
52
+ created_at: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
53
+ updated_at: z.ZodPreprocess<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
54
+ target_agents: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.core.$ZodBranded<z.ZodString, "AgentId", "out">>>>;
55
+ }, z.core.$strip>;
56
+ arbitration_resolution: z.ZodPreprocess<z.ZodOptional<z.ZodPreprocess<z.ZodObject<{
57
+ context_snapshot_hash: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
58
+ dispute_snapshot: z.ZodObject<{
59
+ id: z.core.$ZodBranded<z.ZodString, "DisputeId", "out">;
60
+ name: z.ZodString;
61
+ reporter_agent_id: z.ZodDefault<z.core.$ZodBranded<z.ZodString, "AgentId", "out">>;
62
+ claims: z.ZodArray<z.core.$ZodBranded<z.ZodString, "ClaimId", "out">>;
63
+ summary: z.ZodString;
64
+ status: z.ZodEnum<{
65
+ open: "open";
66
+ resolved: "resolved";
67
+ }>;
68
+ created_at: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
69
+ resolved_at: z.ZodPreprocess<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
70
+ }, z.core.$strip>;
71
+ direct_claim_snapshots: z.ZodArray<z.ZodObject<{
72
+ id: z.core.$ZodBranded<z.ZodString, "ClaimId", "out">;
73
+ name: z.ZodString;
74
+ statement: z.ZodString;
75
+ scope: z.ZodString;
76
+ holder: z.core.$ZodBranded<z.ZodString, "AgentId", "out">;
77
+ confidence: z.ZodEnum<{
78
+ high: "high";
79
+ medium: "medium";
80
+ low: "low";
81
+ }>;
82
+ status: z.ZodEnum<{
83
+ active: "active";
84
+ stale: "stale";
85
+ deprecated: "deprecated";
86
+ }>;
87
+ created_at: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
88
+ updated_at: z.ZodPreprocess<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
89
+ source_claim_ids: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.core.$ZodBranded<z.ZodString, "ClaimId", "out">, z.core.$ZodBranded<z.ZodString, "PolicyId", "out">]>>>;
90
+ evidence_summary: z.ZodString;
91
+ }, z.core.$strip>>;
92
+ snapshot_source_resolution_id: z.ZodPreprocess<z.ZodOptional<z.core.$ZodBranded<z.ZodString, "ResolutionId", "out">>>;
93
+ resolution_id: z.core.$ZodBranded<z.ZodString, "ResolutionId", "out">;
94
+ resolved_by: z.ZodEnum<{
95
+ human: "human";
96
+ automatic: "automatic";
97
+ }>;
98
+ resolved_at: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
99
+ resolution_type: z.ZodPreprocess<z.ZodOptional<z.ZodEnum<{
100
+ coexist: "coexist";
101
+ lifecycle_update: "lifecycle_update";
102
+ conflict_resolved: "conflict_resolved";
103
+ unresolved: "unresolved";
104
+ }>>>;
105
+ resolution_basis: z.ZodPreprocess<z.ZodOptional<z.ZodEnum<{
106
+ evidence: "evidence";
107
+ insufficient_evidence: "insufficient_evidence";
108
+ direct_analysis: "direct_analysis";
109
+ prior_resolution: "prior_resolution";
110
+ policy: "policy";
111
+ }>>>;
112
+ conclusion: z.ZodString;
113
+ claim_assessments: z.ZodPipe<z.ZodDefault<z.ZodArray<z.ZodObject<{
114
+ claim_id: z.core.$ZodBranded<z.ZodString, "ClaimId", "out">;
115
+ recommended_status: z.ZodEnum<{
116
+ active: "active";
117
+ stale: "stale";
118
+ deprecated: "deprecated";
119
+ }>;
120
+ assessment: z.ZodString;
121
+ recommended_scope: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
122
+ recommended_statement: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
123
+ reason: z.ZodString;
124
+ }, z.core.$strip>>>, z.ZodTransform<{
125
+ claim_id: string & z.core.$brand<"ClaimId">;
126
+ recommended_status: "active" | "stale" | "deprecated";
127
+ assessment: string;
128
+ reason: string;
129
+ recommended_scope?: string | undefined;
130
+ recommended_statement?: string | undefined;
131
+ }[] | undefined, {
132
+ claim_id: string & z.core.$brand<"ClaimId">;
133
+ recommended_status: "active" | "stale" | "deprecated";
134
+ assessment: string;
135
+ reason: string;
136
+ recommended_scope?: string | undefined;
137
+ recommended_statement?: string | undefined;
138
+ }[]>>;
139
+ rejection_reason: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
140
+ dispute_id: z.core.$ZodBranded<z.ZodString, "DisputeId", "out">;
141
+ }, z.core.$loose>>>>;
142
+ handled_at: z.ZodPreprocess<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
143
+ }, z.core.$strip>], "message_type">>;
144
+ }, z.core.$strict>>;
145
+ status: z.ZodEnum<{
146
+ prepared: "prepared";
147
+ applied: "applied";
148
+ }>;
149
+ analysisClaims: z.ZodNullable<z.ZodArray<z.ZodObject<{
150
+ id: z.core.$ZodBranded<z.ZodString, "ClaimId", "out">;
151
+ name: z.ZodString;
152
+ statement: z.ZodString;
153
+ scope: z.ZodString;
154
+ holder: z.core.$ZodBranded<z.ZodString, "AgentId", "out">;
155
+ confidence: z.ZodEnum<{
156
+ high: "high";
157
+ medium: "medium";
158
+ low: "low";
159
+ }>;
160
+ status: z.ZodEnum<{
161
+ active: "active";
162
+ stale: "stale";
163
+ deprecated: "deprecated";
164
+ }>;
165
+ created_at: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
166
+ updated_at: z.ZodPreprocess<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
167
+ source_claim_ids: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.core.$ZodBranded<z.ZodString, "ClaimId", "out">, z.core.$ZodBranded<z.ZodString, "PolicyId", "out">]>>>;
168
+ evidence_summary: z.ZodString;
169
+ }, z.core.$strip>>>;
170
+ preparedClaims: z.ZodArray<z.ZodObject<{
171
+ id: z.core.$ZodBranded<z.ZodString, "ClaimId", "out">;
172
+ name: z.ZodString;
173
+ statement: z.ZodString;
174
+ scope: z.ZodString;
175
+ holder: z.core.$ZodBranded<z.ZodString, "AgentId", "out">;
176
+ confidence: z.ZodEnum<{
177
+ high: "high";
178
+ medium: "medium";
179
+ low: "low";
180
+ }>;
181
+ status: z.ZodEnum<{
182
+ active: "active";
183
+ stale: "stale";
184
+ deprecated: "deprecated";
185
+ }>;
186
+ created_at: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
187
+ updated_at: z.ZodPreprocess<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
188
+ source_claim_ids: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.core.$ZodBranded<z.ZodString, "ClaimId", "out">, z.core.$ZodBranded<z.ZodString, "PolicyId", "out">]>>>;
189
+ evidence_summary: z.ZodString;
190
+ }, z.core.$strip>>;
191
+ appliedClaims: z.ZodArray<z.ZodObject<{
192
+ id: z.core.$ZodBranded<z.ZodString, "ClaimId", "out">;
193
+ name: z.ZodString;
194
+ statement: z.ZodString;
195
+ scope: z.ZodString;
196
+ holder: z.core.$ZodBranded<z.ZodString, "AgentId", "out">;
197
+ confidence: z.ZodEnum<{
198
+ high: "high";
199
+ medium: "medium";
200
+ low: "low";
201
+ }>;
202
+ status: z.ZodEnum<{
203
+ active: "active";
204
+ stale: "stale";
205
+ deprecated: "deprecated";
206
+ }>;
207
+ created_at: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
208
+ updated_at: z.ZodPreprocess<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
209
+ source_claim_ids: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.core.$ZodBranded<z.ZodString, "ClaimId", "out">, z.core.$ZodBranded<z.ZodString, "PolicyId", "out">]>>>;
210
+ evidence_summary: z.ZodString;
211
+ }, z.core.$strip>>;
212
+ teamAuthorized: z.ZodOptional<z.ZodBoolean>;
213
+ syncClaims: z.ZodOptional<z.ZodArray<z.ZodObject<{
214
+ id: z.core.$ZodBranded<z.ZodString, "ClaimId", "out">;
215
+ name: z.ZodString;
216
+ statement: z.ZodString;
217
+ scope: z.ZodString;
218
+ holder: z.core.$ZodBranded<z.ZodString, "AgentId", "out">;
219
+ confidence: z.ZodEnum<{
220
+ high: "high";
221
+ medium: "medium";
222
+ low: "low";
223
+ }>;
224
+ status: z.ZodEnum<{
225
+ active: "active";
226
+ stale: "stale";
227
+ deprecated: "deprecated";
228
+ }>;
229
+ created_at: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
230
+ updated_at: z.ZodPreprocess<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
231
+ source_claim_ids: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.core.$ZodBranded<z.ZodString, "ClaimId", "out">, z.core.$ZodBranded<z.ZodString, "PolicyId", "out">]>>>;
232
+ evidence_summary: z.ZodString;
233
+ }, z.core.$strip>>>;
234
+ disputes: z.ZodArray<z.ZodObject<{
235
+ id: z.core.$ZodBranded<z.ZodString, "DisputeId", "out">;
236
+ name: z.ZodString;
237
+ reporter_agent_id: z.ZodDefault<z.core.$ZodBranded<z.ZodString, "AgentId", "out">>;
238
+ claims: z.ZodArray<z.core.$ZodBranded<z.ZodString, "ClaimId", "out">>;
239
+ summary: z.ZodString;
240
+ status: z.ZodEnum<{
241
+ open: "open";
242
+ resolved: "resolved";
243
+ }>;
244
+ created_at: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
245
+ resolved_at: z.ZodPreprocess<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
246
+ }, z.core.$strip>>;
247
+ trace: z.ZodNullable<z.ZodObject<{
248
+ id: z.core.$ZodBranded<z.ZodString, "TraceId", "out">;
249
+ name: z.ZodString;
250
+ task: z.ZodString;
251
+ agent: z.core.$ZodBranded<z.ZodString, "AgentId", "out">;
252
+ input_claims: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.core.$ZodBranded<z.ZodString, "ClaimId", "out">, z.core.$ZodBranded<z.ZodString, "PolicyId", "out">]>>>;
253
+ output_claims: z.ZodDefault<z.ZodArray<z.core.$ZodBranded<z.ZodString, "ClaimId", "out">>>;
254
+ created_at: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
255
+ }, z.core.$strip>>;
256
+ warnings: z.ZodArray<z.ZodString>;
257
+ retiredPolicies: z.ZodArray<z.core.$ZodBranded<z.ZodString, "PolicyId", "out">>;
258
+ }, z.core.$strict>;
259
+ export type InboxEffect = z.infer<typeof InboxEffectSchema>;
260
+ export declare const inboxMessageHash: (message: InboxMessage) => string;
261
+ export declare class InboxEffectStore {
262
+ readonly context: StoreContext;
263
+ constructor(context: StoreContext);
264
+ private journals;
265
+ private write;
266
+ private references;
267
+ recover(): Promise<void>;
268
+ recoverLocked(): Promise<void>;
269
+ commit(messages: readonly InboxMessage[], analysisClaims: Claim[], prepared: PreparedFormation, control: JobControl): Promise<{
270
+ applied: number;
271
+ warnings: string[];
272
+ entityIds?: string[];
273
+ }>;
274
+ private applyLocked;
275
+ }
@@ -0,0 +1,5 @@
1
+ export * from './prepare.js';
2
+ export * from './cascade.js';
3
+ export * from './effects.js';
4
+ export * from './sync.js';
5
+ export * from './service.js';