@ghostpaw/affinity 0.5.0 → 0.6.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.
package/dist/index.d.cts CHANGED
@@ -17,6 +17,7 @@ declare abstract class AffinityError extends Error {
17
17
 
18
18
  /** Uniqueness, routing, or ownership collision. */
19
19
  declare class AffinityConflictError extends AffinityError {
20
+ existingContactId?: number;
20
21
  readonly code: "CONFLICT";
21
22
  }
22
23
 
@@ -137,6 +138,7 @@ interface AttributeEntry {
137
138
 
138
139
  /** Attribute row for mutation receipts — stable id + target + payload. */
139
140
  interface AttributeRecord {
141
+ eventId?: number;
140
142
  id: number;
141
143
  contactId: number | null;
142
144
  linkId: number | null;
@@ -145,7 +147,7 @@ interface AttributeRecord {
145
147
  }
146
148
 
147
149
  /**
148
- * Write target for attributes — exactly one of contact or link (CONCEPT.md).
150
+ * Write target for attributes — exactly one of contact, link or event (CONCEPT.md).
149
151
  */
150
152
  type AttributeTarget = {
151
153
  kind: "contact";
@@ -153,6 +155,9 @@ type AttributeTarget = {
153
155
  } | {
154
156
  kind: "link";
155
157
  id: number;
158
+ } | {
159
+ kind: "event";
160
+ eventId: number;
156
161
  };
157
162
 
158
163
  /** Open commitment lifecycle on reads — CONCEPT.md CommitmentRecord. */
@@ -174,6 +179,7 @@ interface CommitmentRecord {
174
179
  summary: string;
175
180
  participants: readonly EventParticipantView[];
176
181
  dueAt?: number | null;
182
+ dueOn?: string | null;
177
183
  resolutionState: CommitmentResolutionState;
178
184
  }
179
185
 
@@ -209,6 +215,8 @@ interface AffinityListReadOptions {
209
215
 
210
216
  /** Options for `read.getContactJournal` / `read.getLinkTimeline`. */
211
217
  type ContactJournalReadOptions = AffinityListReadOptions & {
218
+ includeContent?: boolean;
219
+ channel?: string;
212
220
  eventTypes?: readonly EventType[];
213
221
  };
214
222
 
@@ -232,11 +240,53 @@ interface ContactListItem {
232
240
  lastMeaningfulEventAt?: number | null;
233
241
  }
234
242
 
243
+ /** Shared participant row for evidence writes — CONCEPT.md SocialEventInput. */
244
+ interface SocialEventParticipantInput {
245
+ contactId: number;
246
+ role: EventParticipantRole;
247
+ directionality?: undefined | "owner_initiated" | "other_initiated" | "mutual" | "observed";
248
+ }
249
+ /** Evidence intake shape shared by interaction-style writes — CONCEPT.md. */
250
+ interface SocialEventInput {
251
+ occurredAt: number;
252
+ occurredOn?: string;
253
+ summary?: string;
254
+ content?: string;
255
+ affectsBond?: boolean;
256
+ externalRef?: ExternalRef;
257
+ channel?: string;
258
+ parentRef?: ExternalRef;
259
+ parentEventId?: number;
260
+ threadRef?: ExternalRef;
261
+ momentKind?: EventMomentKind;
262
+ /** Significance 1..10 — enforced at write layer. */
263
+ significance: number;
264
+ participants: readonly SocialEventParticipantInput[];
265
+ provenance?: unknown;
266
+ }
267
+ /** Stable external event identity. */
268
+ interface ExternalRef {
269
+ source: string;
270
+ id: string;
271
+ }
272
+
235
273
  /** Journal entry with explicit participants — CONCEPT.md EventRecord. */
236
274
  interface EventRecord {
275
+ content?: string;
276
+ provenance?: unknown;
277
+ externalRef?: ExternalRef;
278
+ channel?: string;
279
+ parentRef?: ExternalRef;
280
+ parentEventId?: number;
281
+ threadRef?: ExternalRef;
282
+ attributes?: AttributeRecord[];
237
283
  id: number;
284
+ affectsBond?: boolean;
238
285
  type: EventType;
239
286
  occurredAt: number;
287
+ occurredOn?: string;
288
+ dueAt?: number | null;
289
+ dueOn?: string | null;
240
290
  summary: string;
241
291
  significance: number;
242
292
  momentKind: EventMomentKind | null;
@@ -263,6 +313,7 @@ interface IdentityRecord {
263
313
  /** Compact link row for lists — CONCEPT.md LinkListItem. */
264
314
  interface LinkListItem {
265
315
  id: number;
316
+ counterpartyName?: string;
266
317
  fromContactId: number;
267
318
  toContactId: number;
268
319
  kind: LinkKind;
@@ -311,6 +362,8 @@ interface UpcomingDateRecord {
311
362
  recurrenceKind: EventRecurrenceKind;
312
363
  /** Epoch milliseconds for the materialized next occurrence (sorting key). */
313
364
  occursOn: number;
365
+ /** Calendar date; occursOn retains its existing numeric sorting key. */
366
+ occursOnDate?: string;
314
367
  summary: string;
315
368
  significance: number;
316
369
  }
@@ -376,6 +429,7 @@ interface AddDateAnchorInput {
376
429
 
377
430
  /** Arguments for `write.addIdentity`. */
378
431
  interface AddIdentityInput {
432
+ ifExists?: "error" | "return";
379
433
  type: string;
380
434
  value: string;
381
435
  label?: string | null;
@@ -389,6 +443,8 @@ interface CreateContactInput {
389
443
  name: string;
390
444
  kind: ContactKind;
391
445
  now?: number;
446
+ identities?: AddIdentityInput[];
447
+ ifExists?: "error" | "return";
392
448
  /**
393
449
  * When true, marks this row as the sole owner contact.
394
450
  * Allowed only while no other live owner exists.
@@ -438,26 +494,11 @@ interface SetStructuralTieInput {
438
494
  now?: number;
439
495
  }
440
496
 
441
- /** Shared participant row for evidence writes — CONCEPT.md SocialEventInput. */
442
- interface SocialEventParticipantInput {
443
- contactId: number;
444
- role: EventParticipantRole;
445
- directionality?: "owner_initiated" | "other_initiated" | "mutual" | "observed";
446
- }
447
- /** Evidence intake shape shared by interaction-style writes — CONCEPT.md. */
448
- interface SocialEventInput {
449
- occurredAt: number;
450
- summary: string;
451
- /** Significance 1..10 — enforced at write layer. */
452
- significance: number;
453
- participants: readonly SocialEventParticipantInput[];
454
- provenance?: unknown;
455
- }
456
-
457
497
  /** Arguments for `write.recordCommitment`. */
458
498
  interface RecordCommitmentInput extends SocialEventInput {
459
499
  commitmentType: "promise" | "agreement";
460
500
  dueAt?: number | null;
501
+ dueOn?: string | null;
461
502
  now?: number;
462
503
  }
463
504
 
@@ -487,6 +528,7 @@ interface RecordTransactionInput extends SocialEventInput {
487
528
  interface ResolveCommitmentEventInput {
488
529
  type?: Exclude<EventType, "date_anchor">;
489
530
  occurredAt?: number;
531
+ occurredOn?: string;
490
532
  summary?: string;
491
533
  significance?: number;
492
534
  participants?: readonly SocialEventParticipantInput[];
@@ -516,6 +558,7 @@ interface ReviseDateAnchorOptions {
516
558
 
517
559
  /** Arguments for `write.seedSocialLink`. */
518
560
  interface SeedSocialLinkInput {
561
+ ifExists?: "error" | "return";
519
562
  fromContactId: number;
520
563
  toContactId: number;
521
564
  kind: RelationalLinkKind;
@@ -589,9 +632,22 @@ interface DismissedDuplicateRecord {
589
632
 
590
633
  /** Raw `events` row from SQLite (snake_case columns). */
591
634
  interface EventRow {
635
+ content?: string | null;
636
+ external_source?: string | null;
637
+ external_id?: string | null;
638
+ channel?: string | null;
639
+ parent_source?: string | null;
640
+ parent_ref_id?: string | null;
641
+ parent_event_id?: number | null;
642
+ thread_source?: string | null;
643
+ thread_id?: string | null;
644
+ provenance_json?: string | null;
592
645
  id: number;
593
646
  type: string;
594
647
  occurred_at: number;
648
+ occurred_on?: string | null;
649
+ due_at?: number | null;
650
+ due_on?: string | null;
595
651
  summary: string;
596
652
  significance: number;
597
653
  moment_kind: string | null;
@@ -611,6 +667,7 @@ interface MomentRecord {
611
667
  linkId: number;
612
668
  momentKind: EventMomentKind;
613
669
  occurredAt: number;
670
+ occurredOn?: string;
614
671
  summary: string;
615
672
  impactScore: number;
616
673
  }
@@ -633,6 +690,7 @@ interface LinkDetailReadOptions {
633
690
 
634
691
  /** Common filters for link list reads — CONCEPT.md. */
635
692
  interface LinkListReadFilters {
693
+ includeLost?: boolean;
636
694
  kind?: LinkKind;
637
695
  state?: LinkState;
638
696
  }
@@ -724,6 +782,10 @@ interface MergePrimary {
724
782
  */
725
783
  interface MutationReceipt<TPrimary> {
726
784
  primary: TPrimary;
785
+ warnings?: {
786
+ code: "future_event";
787
+ message: string;
788
+ }[];
727
789
  created: EntityRef[];
728
790
  updated: EntityRef[];
729
791
  archived: EntityRef[];
@@ -731,10 +793,15 @@ interface MutationReceipt<TPrimary> {
731
793
  affectedLinks: number[];
732
794
  derivedEffects: DerivedLinkEffect[];
733
795
  }
734
- type ContactMutationReceipt = MutationReceipt<ContactListItem>;
796
+ type ContactMutationReceipt = MutationReceipt<ContactListItem> & {
797
+ outcome?: "success" | "no_op";
798
+ matchedIdentities?: AddIdentityInput[];
799
+ };
735
800
  type IdentityMutationReceipt = MutationReceipt<IdentityRecord>;
736
801
  type LinkMutationReceipt = MutationReceipt<LinkListItem>;
737
- type EventMutationReceipt = MutationReceipt<EventRecord>;
802
+ type EventMutationReceipt = MutationReceipt<EventRecord> & {
803
+ outcome?: "success" | "no_op";
804
+ };
738
805
  type AttributeMutationReceipt = MutationReceipt<AttributeRecord>;
739
806
  type MergeReceipt = MutationReceipt<MergePrimary>;
740
807
  type DismissalMutationReceipt = MutationReceipt<DismissedPairRef>;
@@ -765,6 +832,68 @@ interface MergeHistoryRecord {
765
832
  manual: boolean;
766
833
  }
767
834
 
835
+ interface EventSearchItem {
836
+ [key: string]: unknown;
837
+ kind: "event";
838
+ id: number;
839
+ occurredOn: string;
840
+ type: string;
841
+ title: string;
842
+ matchedOn: string[];
843
+ externalRef?: ExternalRef;
844
+ }
845
+ declare function searchEvents(db: AffinityDb, query: string, options?: {
846
+ limit?: number;
847
+ offset?: number;
848
+ }): EventSearchItem[];
849
+ declare function getEventThread(db: AffinityDb, source: string, id: string, options?: {
850
+ eventTypes?: readonly EventType[];
851
+ includeContent?: boolean;
852
+ channel?: string;
853
+ limit?: number;
854
+ offset?: number;
855
+ }): EventRecord[];
856
+
857
+ declare function getContactJournal(db: AffinityDb, contactId: number, options?: ContactJournalReadOptions): EventRecord[];
858
+
859
+ declare function listMoments(db: AffinityDb, filters?: ListMomentsFilters, options?: AffinityListReadOptions & {
860
+ channel?: string;
861
+ }): MomentRecord[];
862
+
863
+ declare function listOpenCommitments(db: AffinityDb, filters?: ListOpenCommitmentsFilters, options?: AffinityListReadOptions & {
864
+ channel?: string;
865
+ }): CommitmentRecord[];
866
+
867
+ declare function recordCommitment(db: AffinityDb, input: RecordCommitmentInput): EventMutationReceipt;
868
+
869
+ declare function recordInteraction(db: AffinityDb, input: RecordInteractionInput): EventMutationReceipt;
870
+
871
+ declare function recordMilestone(db: AffinityDb, input: RecordMilestoneInput): EventMutationReceipt;
872
+
873
+ declare function recordObservation(db: AffinityDb, input: RecordObservationInput): EventMutationReceipt;
874
+
875
+ declare function recordTransaction(db: AffinityDb, input: RecordTransactionInput): EventMutationReceipt;
876
+
877
+ declare function resolveCommitment(db: AffinityDb, commitmentEventId: number, resolution: CommitmentResolutionKind, options?: ResolveCommitmentOptions): EventMutationReceipt;
878
+
879
+ type EventTarget = number | {
880
+ eventId?: number;
881
+ ref?: ExternalRef;
882
+ };
883
+ interface ReviseEventPatch {
884
+ summary?: string;
885
+ content?: string;
886
+ occurredAt?: number;
887
+ significance?: number;
888
+ channel?: string;
889
+ type?: EventType;
890
+ externalRef?: ExternalRef;
891
+ }
892
+ declare function reviseEvent(db: AffinityDb, target: EventTarget, patch: ReviseEventPatch): EventMutationReceipt;
893
+ declare function deleteEvent(db: AffinityDb, target: EventTarget, options: {
894
+ confirm: boolean;
895
+ }): EventMutationReceipt;
896
+
768
897
  declare const types_AFFINITY_DEFAULT_LIST_LIMIT: typeof AFFINITY_DEFAULT_LIST_LIMIT;
769
898
  declare const types_AFFINITY_MAX_LIST_LIMIT: typeof AFFINITY_MAX_LIST_LIMIT;
770
899
  type types_AddDateAnchorInput = AddDateAnchorInput;
@@ -806,7 +935,10 @@ type types_EventParticipantView = EventParticipantView;
806
935
  type types_EventRecord = EventRecord;
807
936
  type types_EventRecurrenceKind = EventRecurrenceKind;
808
937
  type types_EventRow = EventRow;
938
+ type types_EventSearchItem = EventSearchItem;
939
+ type types_EventTarget = EventTarget;
809
940
  type types_EventType = EventType;
941
+ type types_ExternalRef = ExternalRef;
810
942
  type types_IdentityMutationReceipt = IdentityMutationReceipt;
811
943
  type types_IdentityRecord = IdentityRecord;
812
944
  type types_IdentityRow = IdentityRow;
@@ -845,6 +977,7 @@ type types_ResolveCommitmentOptions = ResolveCommitmentOptions;
845
977
  type types_ReviseContactPatch = ReviseContactPatch;
846
978
  type types_ReviseDateAnchorOptions = ReviseDateAnchorOptions;
847
979
  type types_ReviseDateAnchorPatch = ReviseDateAnchorPatch;
980
+ type types_ReviseEventPatch = ReviseEventPatch;
848
981
  type types_ReviseIdentityPatch = ReviseIdentityPatch;
849
982
  type types_SeedSocialLinkInput = SeedSocialLinkInput;
850
983
  type types_SetContactLifecycleOptions = SetContactLifecycleOptions;
@@ -856,7 +989,7 @@ type types_UpcomingDateRecord = UpcomingDateRecord;
856
989
  type types_UpcomingDateTargetRef = UpcomingDateTargetRef;
857
990
  declare const types_resolveAffinityListLimit: typeof resolveAffinityListLimit;
858
991
  declare namespace types {
859
- export { types_AFFINITY_DEFAULT_LIST_LIMIT as AFFINITY_DEFAULT_LIST_LIMIT, types_AFFINITY_MAX_LIST_LIMIT as AFFINITY_MAX_LIST_LIMIT, type types_AddDateAnchorInput as AddDateAnchorInput, type types_AddIdentityInput as AddIdentityInput, type types_AffinityChartEdge as AffinityChartEdge, type types_AffinityChartNode as AffinityChartNode, type types_AffinityChartReadOptions as AffinityChartReadOptions, type types_AffinityChartRecord as AffinityChartRecord, type types_AffinityListReadOptions as AffinityListReadOptions, type types_AttributeEntry as AttributeEntry, type types_AttributeMutationReceipt as AttributeMutationReceipt, type types_AttributeName as AttributeName, type types_AttributeRecord as AttributeRecord, type types_AttributeTarget as AttributeTarget, type types_CommitmentRecord as CommitmentRecord, type types_CommitmentResolutionKind as CommitmentResolutionKind, type types_CommitmentResolutionState as CommitmentResolutionState, type types_ContactCore as ContactCore, type types_ContactJournalReadOptions as ContactJournalReadOptions, type types_ContactKind as ContactKind, type types_ContactLifecycleState as ContactLifecycleState, type types_ContactListItem as ContactListItem, type types_ContactMutationReceipt as ContactMutationReceipt, type types_ContactProfileReadOptions as ContactProfileReadOptions, type types_ContactProfileRecord as ContactProfileRecord, type types_ContactRow as ContactRow, type types_CreateContactInput as CreateContactInput, type types_DateAnchorTarget as DateAnchorTarget, type types_DerivedLinkEffect as DerivedLinkEffect, type types_DismissalMutationReceipt as DismissalMutationReceipt, type types_DismissedDuplicateRecord as DismissedDuplicateRecord, type types_DismissedPairRef as DismissedPairRef, type types_DuplicateCandidateRecord as DuplicateCandidateRecord, type types_EntityRef as EntityRef, type types_EventMomentKind as EventMomentKind, type types_EventMutationReceipt as EventMutationReceipt, type types_EventParticipantRole as EventParticipantRole, type types_EventParticipantView as EventParticipantView, type types_EventRecord as EventRecord, type types_EventRecurrenceKind as EventRecurrenceKind, type types_EventRow as EventRow, type types_EventType as EventType, type types_IdentityMutationReceipt as IdentityMutationReceipt, type types_IdentityRecord as IdentityRecord, type types_IdentityRow as IdentityRow, type types_IdentityType as IdentityType, type types_InteractionEventType as InteractionEventType, type types_LinkDetailReadOptions as LinkDetailReadOptions, type types_LinkDetailRecord as LinkDetailRecord, type types_LinkKind as LinkKind, type types_LinkListItem as LinkListItem, type types_LinkListReadFilters as LinkListReadFilters, type types_LinkMutationOptions as LinkMutationOptions, type types_LinkMutationReceipt as LinkMutationReceipt, type types_LinkRow as LinkRow, type types_LinkState as LinkState, type types_ListContactsFilters as ListContactsFilters, type types_ListDuplicateCandidatesFilters as ListDuplicateCandidatesFilters, type types_ListMomentsFilters as ListMomentsFilters, type types_ListOpenCommitmentsFilters as ListOpenCommitmentsFilters, type types_ListUpcomingDatesFilters as ListUpcomingDatesFilters, type types_MergeContactsInput as MergeContactsInput, type types_MergeHistoryRecord as MergeHistoryRecord, type types_MergePrimary as MergePrimary, type types_MergeReceipt as MergeReceipt, type types_MomentRecord as MomentRecord, type types_MutationReceipt as MutationReceipt, type types_OpaqueDerivation as OpaqueDerivation, type types_OpaqueRollup as OpaqueRollup, type types_RadarRecord as RadarRecord, type types_RecordCommitmentInput as RecordCommitmentInput, type types_RecordInteractionInput as RecordInteractionInput, type types_RecordMilestoneInput as RecordMilestoneInput, type types_RecordObservationInput as RecordObservationInput, type types_RecordTransactionInput as RecordTransactionInput, type types_RelationalLinkKind as RelationalLinkKind, type types_ResolveCommitmentOptions as ResolveCommitmentOptions, type types_ReviseContactPatch as ReviseContactPatch, type types_ReviseDateAnchorOptions as ReviseDateAnchorOptions, type types_ReviseDateAnchorPatch as ReviseDateAnchorPatch, type types_ReviseIdentityPatch as ReviseIdentityPatch, type types_SeedSocialLinkInput as SeedSocialLinkInput, type types_SetContactLifecycleOptions as SetContactLifecycleOptions, type types_SetStructuralTieInput as SetStructuralTieInput, type types_SocialEventInput as SocialEventInput, type types_SocialEventParticipantInput as SocialEventParticipantInput, type types_StructuralLinkKind as StructuralLinkKind, type types_UpcomingDateRecord as UpcomingDateRecord, type types_UpcomingDateTargetRef as UpcomingDateTargetRef, types_resolveAffinityListLimit as resolveAffinityListLimit };
992
+ export { types_AFFINITY_DEFAULT_LIST_LIMIT as AFFINITY_DEFAULT_LIST_LIMIT, types_AFFINITY_MAX_LIST_LIMIT as AFFINITY_MAX_LIST_LIMIT, type types_AddDateAnchorInput as AddDateAnchorInput, type types_AddIdentityInput as AddIdentityInput, type types_AffinityChartEdge as AffinityChartEdge, type types_AffinityChartNode as AffinityChartNode, type types_AffinityChartReadOptions as AffinityChartReadOptions, type types_AffinityChartRecord as AffinityChartRecord, type types_AffinityListReadOptions as AffinityListReadOptions, type types_AttributeEntry as AttributeEntry, type types_AttributeMutationReceipt as AttributeMutationReceipt, type types_AttributeName as AttributeName, type types_AttributeRecord as AttributeRecord, type types_AttributeTarget as AttributeTarget, type types_CommitmentRecord as CommitmentRecord, type types_CommitmentResolutionKind as CommitmentResolutionKind, type types_CommitmentResolutionState as CommitmentResolutionState, type types_ContactCore as ContactCore, type types_ContactJournalReadOptions as ContactJournalReadOptions, type types_ContactKind as ContactKind, type types_ContactLifecycleState as ContactLifecycleState, type types_ContactListItem as ContactListItem, type types_ContactMutationReceipt as ContactMutationReceipt, type types_ContactProfileReadOptions as ContactProfileReadOptions, type types_ContactProfileRecord as ContactProfileRecord, type types_ContactRow as ContactRow, type types_CreateContactInput as CreateContactInput, type types_DateAnchorTarget as DateAnchorTarget, type types_DerivedLinkEffect as DerivedLinkEffect, type types_DismissalMutationReceipt as DismissalMutationReceipt, type types_DismissedDuplicateRecord as DismissedDuplicateRecord, type types_DismissedPairRef as DismissedPairRef, type types_DuplicateCandidateRecord as DuplicateCandidateRecord, type types_EntityRef as EntityRef, type types_EventMomentKind as EventMomentKind, type types_EventMutationReceipt as EventMutationReceipt, type types_EventParticipantRole as EventParticipantRole, type types_EventParticipantView as EventParticipantView, type types_EventRecord as EventRecord, type types_EventRecurrenceKind as EventRecurrenceKind, type types_EventRow as EventRow, type types_EventSearchItem as EventSearchItem, type types_EventTarget as EventTarget, type types_EventType as EventType, type types_ExternalRef as ExternalRef, type types_IdentityMutationReceipt as IdentityMutationReceipt, type types_IdentityRecord as IdentityRecord, type types_IdentityRow as IdentityRow, type types_IdentityType as IdentityType, type types_InteractionEventType as InteractionEventType, type types_LinkDetailReadOptions as LinkDetailReadOptions, type types_LinkDetailRecord as LinkDetailRecord, type types_LinkKind as LinkKind, type types_LinkListItem as LinkListItem, type types_LinkListReadFilters as LinkListReadFilters, type types_LinkMutationOptions as LinkMutationOptions, type types_LinkMutationReceipt as LinkMutationReceipt, type types_LinkRow as LinkRow, type types_LinkState as LinkState, type types_ListContactsFilters as ListContactsFilters, type types_ListDuplicateCandidatesFilters as ListDuplicateCandidatesFilters, type types_ListMomentsFilters as ListMomentsFilters, type types_ListOpenCommitmentsFilters as ListOpenCommitmentsFilters, type types_ListUpcomingDatesFilters as ListUpcomingDatesFilters, type types_MergeContactsInput as MergeContactsInput, type types_MergeHistoryRecord as MergeHistoryRecord, type types_MergePrimary as MergePrimary, type types_MergeReceipt as MergeReceipt, type types_MomentRecord as MomentRecord, type types_MutationReceipt as MutationReceipt, type types_OpaqueDerivation as OpaqueDerivation, type types_OpaqueRollup as OpaqueRollup, type types_RadarRecord as RadarRecord, type types_RecordCommitmentInput as RecordCommitmentInput, type types_RecordInteractionInput as RecordInteractionInput, type types_RecordMilestoneInput as RecordMilestoneInput, type types_RecordObservationInput as RecordObservationInput, type types_RecordTransactionInput as RecordTransactionInput, type types_RelationalLinkKind as RelationalLinkKind, type types_ResolveCommitmentOptions as ResolveCommitmentOptions, type types_ReviseContactPatch as ReviseContactPatch, type types_ReviseDateAnchorOptions as ReviseDateAnchorOptions, type types_ReviseDateAnchorPatch as ReviseDateAnchorPatch, type types_ReviseEventPatch as ReviseEventPatch, type types_ReviseIdentityPatch as ReviseIdentityPatch, type types_SeedSocialLinkInput as SeedSocialLinkInput, type types_SetContactLifecycleOptions as SetContactLifecycleOptions, type types_SetStructuralTieInput as SetStructuralTieInput, type types_SocialEventInput as SocialEventInput, type types_SocialEventParticipantInput as SocialEventParticipantInput, type types_StructuralLinkKind as StructuralLinkKind, type types_UpcomingDateRecord as UpcomingDateRecord, type types_UpcomingDateTargetRef as UpcomingDateTargetRef, types_resolveAffinityListLimit as resolveAffinityListLimit };
860
993
  }
861
994
 
862
995
  declare function createContact(db: AffinityDb, input: CreateContactInput): ContactMutationReceipt;
@@ -925,24 +1058,6 @@ declare function undismissDuplicate(db: AffinityDb, leftContactId: number, right
925
1058
 
926
1059
  declare function listDismissedDuplicates(db: AffinityDb, options?: AffinityListReadOptions): DismissedDuplicateRecord[];
927
1060
 
928
- declare function getContactJournal(db: AffinityDb, contactId: number, options?: ContactJournalReadOptions): EventRecord[];
929
-
930
- declare function listMoments(db: AffinityDb, filters?: ListMomentsFilters, options?: AffinityListReadOptions): MomentRecord[];
931
-
932
- declare function listOpenCommitments(db: AffinityDb, filters?: ListOpenCommitmentsFilters, options?: AffinityListReadOptions): CommitmentRecord[];
933
-
934
- declare function recordCommitment(db: AffinityDb, input: RecordCommitmentInput): EventMutationReceipt;
935
-
936
- declare function recordInteraction(db: AffinityDb, input: RecordInteractionInput): EventMutationReceipt;
937
-
938
- declare function recordMilestone(db: AffinityDb, input: RecordMilestoneInput): EventMutationReceipt;
939
-
940
- declare function recordObservation(db: AffinityDb, input: RecordObservationInput): EventMutationReceipt;
941
-
942
- declare function recordTransaction(db: AffinityDb, input: RecordTransactionInput): EventMutationReceipt;
943
-
944
- declare function resolveCommitment(db: AffinityDb, commitmentEventId: number, resolution: CommitmentResolutionKind, options?: ResolveCommitmentOptions): EventMutationReceipt;
945
-
946
1061
  /** Export all stored records belonging to a contact, including archived history. */
947
1062
  declare function exportContact(db: AffinityDb, id: number): {
948
1063
  contact: Record<string, unknown>;
@@ -962,25 +1077,32 @@ declare function exportAffinity(db: AffinityDb): {
962
1077
  version: number;
963
1078
  exportedAt: number;
964
1079
  exportedAtIso: string;
1080
+ events: (Record<string, unknown> & {
1081
+ participants: Record<string, unknown>[];
1082
+ })[];
965
1083
  contacts: {
1084
+ eventIds: unknown[];
1085
+ dateIds: unknown[];
966
1086
  contact: Record<string, unknown>;
967
1087
  identities: Record<string, unknown>[];
968
1088
  attributes: Record<string, unknown>[];
969
1089
  links: Record<string, unknown>[];
970
- events: (Record<string, unknown> & {
971
- participants: Record<string, unknown>[];
972
- })[];
973
1090
  commitments: Record<string, unknown>[];
974
- dates: Record<string, unknown>[];
975
1091
  mergeHistory: Record<string, unknown>[];
976
1092
  }[];
977
1093
  };
978
1094
 
1095
+ declare function getEventById(db: AffinityDb, eventId: number): EventRecord | null;
1096
+ declare function getEventByExternalRef(db: AffinityDb, source: string, id: string): EventRecord | null;
1097
+
979
1098
  declare const read_exportAffinity: typeof exportAffinity;
980
1099
  declare const read_exportContact: typeof exportContact;
981
1100
  declare const read_getAffinityChart: typeof getAffinityChart;
982
1101
  declare const read_getContactJournal: typeof getContactJournal;
983
1102
  declare const read_getContactProfile: typeof getContactProfile;
1103
+ declare const read_getEventByExternalRef: typeof getEventByExternalRef;
1104
+ declare const read_getEventById: typeof getEventById;
1105
+ declare const read_getEventThread: typeof getEventThread;
984
1106
  declare const read_getLinkDetail: typeof getLinkDetail;
985
1107
  declare const read_getLinkTimeline: typeof getLinkTimeline;
986
1108
  declare const read_getLinksBetween: typeof getLinksBetween;
@@ -997,8 +1119,9 @@ declare const read_listProgressionReadiness: typeof listProgressionReadiness;
997
1119
  declare const read_listRadar: typeof listRadar;
998
1120
  declare const read_listUpcomingDates: typeof listUpcomingDates;
999
1121
  declare const read_searchContacts: typeof searchContacts;
1122
+ declare const read_searchEvents: typeof searchEvents;
1000
1123
  declare namespace read {
1001
- export { read_exportAffinity as exportAffinity, read_exportContact as exportContact, read_getAffinityChart as getAffinityChart, read_getContactJournal as getContactJournal, read_getContactProfile as getContactProfile, read_getLinkDetail as getLinkDetail, read_getLinkTimeline as getLinkTimeline, read_getLinksBetween as getLinksBetween, read_getMergeHistory as getMergeHistory, read_getOwnerProfile as getOwnerProfile, read_listContacts as listContacts, read_listDismissedDuplicates as listDismissedDuplicates, read_listDuplicateCandidates as listDuplicateCandidates, read_listMoments as listMoments, read_listObservedLinks as listObservedLinks, read_listOpenCommitments as listOpenCommitments, read_listOwnerSocialLinks as listOwnerSocialLinks, read_listProgressionReadiness as listProgressionReadiness, read_listRadar as listRadar, read_listUpcomingDates as listUpcomingDates, read_searchContacts as searchContacts };
1124
+ export { read_exportAffinity as exportAffinity, read_exportContact as exportContact, read_getAffinityChart as getAffinityChart, read_getContactJournal as getContactJournal, read_getContactProfile as getContactProfile, read_getEventByExternalRef as getEventByExternalRef, read_getEventById as getEventById, read_getEventThread as getEventThread, read_getLinkDetail as getLinkDetail, read_getLinkTimeline as getLinkTimeline, read_getLinksBetween as getLinksBetween, read_getMergeHistory as getMergeHistory, read_getOwnerProfile as getOwnerProfile, read_listContacts as listContacts, read_listDismissedDuplicates as listDismissedDuplicates, read_listDuplicateCandidates as listDuplicateCandidates, read_listMoments as listMoments, read_listObservedLinks as listObservedLinks, read_listOpenCommitments as listOpenCommitments, read_listOwnerSocialLinks as listOwnerSocialLinks, read_listProgressionReadiness as listProgressionReadiness, read_listRadar as listRadar, read_listUpcomingDates as listUpcomingDates, read_searchContacts as searchContacts, read_searchEvents as searchEvents };
1002
1125
  }
1003
1126
 
1004
1127
  interface AffinitySoulTrait {
@@ -1141,7 +1264,7 @@ type ToolEntityKind = "contact" | "identity" | "link" | "event" | "attribute";
1141
1264
  type ToolOutcomeKind = "success" | "no_op" | "needs_clarification" | "error";
1142
1265
  type ToolErrorCode = "clarification_needed" | "conflict" | "constraint_violation" | "invalid_input" | "invalid_state" | "not_found" | "system_error" | "unsupported_target";
1143
1266
  type ToolErrorKind = "domain" | "protocol" | "system";
1144
- type ToolWarningCode = "already_in_state" | "derived_value_used" | "empty_result" | "possible_duplicate" | "partial_match" | "unchanged";
1267
+ type ToolWarningCode = "already_in_state" | "derived_value_used" | "empty_result" | "future_event" | "possible_duplicate" | "partial_match" | "unchanged";
1145
1268
  type ToolClarificationCode = "ambiguous_target" | "missing_required_choice" | "multiple_plausible_matches";
1146
1269
  type ToolNextStepHintKind = "ask_user" | "inspect_item" | "review_view" | "retry_with" | "use_tool";
1147
1270
  interface ToolEntityRef {
@@ -1194,6 +1317,9 @@ interface ToolNeedsClarification extends ToolBaseResult {
1194
1317
  };
1195
1318
  }
1196
1319
  interface ToolFailure extends ToolBaseResult {
1320
+ data?: {
1321
+ existingContactId: number;
1322
+ };
1197
1323
  ok: false;
1198
1324
  outcome: "error";
1199
1325
  error: {
@@ -1272,7 +1398,6 @@ declare function oneOfSchema(schemas: ReadonlyArray<JsonSchema>, description?: s
1272
1398
  type TimeInputs<T> = T extends readonly (infer U)[] ? readonly TimeInputs<U>[] : T extends object ? {
1273
1399
  [K in keyof T]: K extends `${string}At` | "now" | "asOf" | "since" | "until" ? T[K] | string : TimeInputs<T[K]>;
1274
1400
  } : T;
1275
- /** Parse human time inputs using UTC days. Library mutations still accept numbers. */
1276
1401
  declare function parseTimeInput(value: number | string, field?: string, now?: number): number;
1277
1402
 
1278
1403
  type ContactLocator = {
@@ -1307,6 +1432,10 @@ declare function mapErrorToToolFailure(error: unknown, summary?: string): ToolFa
1307
1432
  declare function withToolHandling<TData>(operation: () => ToolResult<TData>, summary?: string): ToolResult<TData>;
1308
1433
 
1309
1434
  type InspectAffinityItemToolInput = {
1435
+ kind: "event";
1436
+ eventId?: number;
1437
+ ref?: ExternalRef;
1438
+ } | {
1310
1439
  kind: "owner_profile";
1311
1440
  topLinksLimit?: number;
1312
1441
  } | {
@@ -1320,6 +1449,9 @@ type InspectAffinityItemToolInput = {
1320
1449
  recentEventsLimit?: number;
1321
1450
  };
1322
1451
  type InspectAffinityItemToolData = {
1452
+ kind: "event";
1453
+ detail: EventRecord;
1454
+ } | {
1323
1455
  kind: "owner_profile";
1324
1456
  detail: ContactProfileRecord;
1325
1457
  } | {
@@ -1342,6 +1474,7 @@ interface MutationToolData<TPrimary> {
1342
1474
  }[];
1343
1475
  action: string;
1344
1476
  primary: TPrimary;
1477
+ matchedIdentities?: AddIdentityInput[];
1345
1478
  created: MutationReceipt<TPrimary>["created"];
1346
1479
  updated: MutationReceipt<TPrimary>["updated"];
1347
1480
  archived: MutationReceipt<TPrimary>["archived"];
@@ -1357,6 +1490,14 @@ type AttributeTargetInput = {
1357
1490
  } | {
1358
1491
  kind: "link";
1359
1492
  link: LinkLocator;
1493
+ } | {
1494
+ kind: "event";
1495
+ eventId: number;
1496
+ ref?: never;
1497
+ } | {
1498
+ kind: "event";
1499
+ ref: ExternalRef;
1500
+ eventId?: never;
1360
1501
  };
1361
1502
  type ManageAttributeToolInput = {
1362
1503
  action: "set";
@@ -1589,25 +1730,37 @@ declare const mergeContactsTool: AffinityToolDefinition<{
1589
1730
  now?: string | number;
1590
1731
  }, MergeContactsToolResult>;
1591
1732
 
1733
+ type ToolEvidence<T extends {
1734
+ participants: readonly SocialEventParticipantInput[];
1735
+ }> = Omit<T, "participants"> & {
1736
+ participants: readonly (SocialEventParticipantInput | {
1737
+ contact: ContactLocator;
1738
+ role: SocialEventParticipantInput["role"];
1739
+ directionality?: SocialEventParticipantInput["directionality"];
1740
+ })[];
1741
+ };
1592
1742
  type RecordEventToolInput = {
1593
1743
  kind: "interaction";
1594
- input: RecordInteractionInput;
1744
+ input: ToolEvidence<RecordInteractionInput>;
1595
1745
  } | {
1596
1746
  kind: "observation";
1597
- input: RecordObservationInput;
1747
+ input: ToolEvidence<RecordObservationInput>;
1598
1748
  } | {
1599
1749
  kind: "milestone";
1600
- input: RecordMilestoneInput;
1750
+ input: ToolEvidence<RecordMilestoneInput>;
1601
1751
  } | {
1602
1752
  kind: "transaction";
1603
- input: RecordTransactionInput;
1753
+ input: ToolEvidence<RecordTransactionInput>;
1604
1754
  };
1605
1755
  type RecordEventToolResult = ToolResult<MutationToolData<EventRecord>>;
1606
1756
  declare function recordEventToolHandler(db: AffinityDb, rawInput: TimeInputs<RecordEventToolInput>): RecordEventToolResult;
1607
1757
  declare const recordEventTool: AffinityToolDefinition<TimeInputs<RecordEventToolInput>, RecordEventToolResult>;
1608
1758
 
1609
- type ReviewAffinityToolView = "contacts.list" | "contacts.duplicates" | "events.contact_journal" | "events.link_timeline" | "events.moments" | "commitments.open" | "links.owner" | "links.observed" | "links.progression_readiness" | "links.radar" | "dates.upcoming" | "graph.chart" | "merges.history" | "merges.dismissed";
1759
+ type ReviewAffinityToolView = "contacts.list" | "contacts.duplicates" | "events.thread" | "events.contact_journal" | "events.link_timeline" | "events.moments" | "commitments.open" | "links.owner" | "links.observed" | "links.progression_readiness" | "links.radar" | "dates.upcoming" | "graph.chart" | "merges.history" | "merges.dismissed";
1610
1760
  interface ReviewAffinityToolInput {
1761
+ ref?: ExternalRef;
1762
+ includeContent?: boolean;
1763
+ channel?: string;
1611
1764
  view: ReviewAffinityToolView;
1612
1765
  now?: number;
1613
1766
  contact?: ContactLocator;
@@ -1640,12 +1793,20 @@ interface ReviewAffinityToolData {
1640
1793
  view: ReviewAffinityToolView;
1641
1794
  items: ToolListItem[];
1642
1795
  count: number;
1796
+ total?: number;
1797
+ hasMore?: boolean;
1643
1798
  appliedFilters: Record<string, unknown>;
1644
1799
  chart?: AffinityChartRecord | undefined;
1645
1800
  }
1646
1801
  type ReviewAffinityToolResult = ToolResult<ReviewAffinityToolData>;
1647
1802
  declare function reviewAffinityToolHandler(db: AffinityDb, rawInput: TimeInputs<ReviewAffinityToolInput>): ReviewAffinityToolResult;
1648
1803
  declare const reviewAffinityTool: AffinityToolDefinition<{
1804
+ ref?: {
1805
+ source: string;
1806
+ id: string;
1807
+ };
1808
+ includeContent?: boolean;
1809
+ channel?: string;
1649
1810
  view: ReviewAffinityToolView;
1650
1811
  now?: string | number;
1651
1812
  contact?: {
@@ -1706,6 +1867,7 @@ declare function toMutationRefEntity(ref: EntityRef): ToolEntityRef;
1706
1867
  declare function toReceiptEntityRefs<TPrimary>(receipt: MutationReceipt<TPrimary>): ToolEntityRef[];
1707
1868
 
1708
1869
  interface SearchAffinityToolInput {
1870
+ scope?: "contacts" | "events" | "all";
1709
1871
  query: string;
1710
1872
  kind?: ContactKind;
1711
1873
  lifecycleState?: ContactLifecycleState;
@@ -1721,10 +1883,13 @@ interface SearchAffinityToolData {
1721
1883
  query: string;
1722
1884
  items: ReturnType<typeof toContactListToolItem>[];
1723
1885
  count: number;
1886
+ total?: number;
1887
+ hasMore?: boolean;
1724
1888
  }
1725
1889
  type SearchAffinityToolResult = ToolResult<SearchAffinityToolData>;
1726
1890
  declare function searchAffinityToolHandler(db: AffinityDb, rawInput: TimeInputs<SearchAffinityToolInput>): SearchAffinityToolResult;
1727
1891
  declare const searchAffinityTool: AffinityToolDefinition<{
1892
+ scope?: "contacts" | "events" | "all";
1728
1893
  query: string;
1729
1894
  kind?: ContactKind;
1730
1895
  lifecycleState?: ContactLifecycleState;
@@ -1737,6 +1902,37 @@ declare const searchAffinityTool: AffinityToolDefinition<{
1737
1902
  offset?: number;
1738
1903
  }, SearchAffinityToolResult>;
1739
1904
 
1905
+ interface ManageEventToolInput {
1906
+ action: "revise" | "delete";
1907
+ eventId?: number;
1908
+ ref?: ExternalRef;
1909
+ patch?: ReviseEventPatch;
1910
+ confirm?: boolean;
1911
+ }
1912
+ type ManageEventToolResult = ToolResult<MutationToolData<EventRecord>>;
1913
+ declare function manageEventToolHandler(db: AffinityDb, raw: TimeInputs<ManageEventToolInput>): ManageEventToolResult;
1914
+ declare const manageEventTool: AffinityToolDefinition<{
1915
+ action: "revise" | "delete";
1916
+ eventId?: number;
1917
+ ref?: {
1918
+ source: string;
1919
+ id: string;
1920
+ };
1921
+ patch?: {
1922
+ summary?: string;
1923
+ content?: string;
1924
+ occurredAt?: string | number;
1925
+ significance?: number;
1926
+ channel?: string;
1927
+ type?: EventType;
1928
+ externalRef?: {
1929
+ source: string;
1930
+ id: string;
1931
+ };
1932
+ };
1933
+ confirm?: boolean;
1934
+ }, ManageEventToolResult>;
1935
+
1740
1936
  declare const affinityTools: (AffinityToolDefinition<TimeInputs<InspectAffinityItemToolInput>, InspectAffinityItemToolResult> | AffinityToolDefinition<TimeInputs<ManageAttributeToolInput>, ManageAttributeToolResult> | AffinityToolDefinition<TimeInputs<ManageCommitmentToolInput>, ManageCommitmentToolResult> | AffinityToolDefinition<TimeInputs<ManageContactToolInput>, ManageContactToolResult> | AffinityToolDefinition<{
1741
1937
  action: "dismiss" | "undismiss";
1742
1938
  left: {
@@ -1776,6 +1972,12 @@ declare const affinityTools: (AffinityToolDefinition<TimeInputs<InspectAffinityI
1776
1972
  reasonSummary?: string | null;
1777
1973
  now?: string | number;
1778
1974
  }, MergeContactsToolResult> | AffinityToolDefinition<TimeInputs<RecordEventToolInput>, RecordEventToolResult> | AffinityToolDefinition<{
1975
+ ref?: {
1976
+ source: string;
1977
+ id: string;
1978
+ };
1979
+ includeContent?: boolean;
1980
+ channel?: string;
1779
1981
  view: ReviewAffinityToolView;
1780
1982
  now?: string | number;
1781
1983
  contact?: {
@@ -1821,6 +2023,7 @@ declare const affinityTools: (AffinityToolDefinition<TimeInputs<InspectAffinityI
1821
2023
  limit?: number;
1822
2024
  offset?: number;
1823
2025
  }, ReviewAffinityToolResult> | AffinityToolDefinition<{
2026
+ scope?: "contacts" | "events" | "all";
1824
2027
  query: string;
1825
2028
  kind?: ContactKind;
1826
2029
  lifecycleState?: ContactLifecycleState;
@@ -1831,7 +2034,27 @@ declare const affinityTools: (AffinityToolDefinition<TimeInputs<InspectAffinityI
1831
2034
  includeDormant?: boolean;
1832
2035
  limit?: number;
1833
2036
  offset?: number;
1834
- }, SearchAffinityToolResult>)[];
2037
+ }, SearchAffinityToolResult> | AffinityToolDefinition<{
2038
+ action: "revise" | "delete";
2039
+ eventId?: number;
2040
+ ref?: {
2041
+ source: string;
2042
+ id: string;
2043
+ };
2044
+ patch?: {
2045
+ summary?: string;
2046
+ content?: string;
2047
+ occurredAt?: string | number;
2048
+ significance?: number;
2049
+ channel?: string;
2050
+ type?: EventType;
2051
+ externalRef?: {
2052
+ source: string;
2053
+ id: string;
2054
+ };
2055
+ };
2056
+ confirm?: boolean;
2057
+ }, ManageEventToolResult>)[];
1835
2058
  declare function listAffinityToolDefinitions(): (AffinityToolDefinition<TimeInputs<InspectAffinityItemToolInput>, InspectAffinityItemToolResult> | AffinityToolDefinition<TimeInputs<ManageAttributeToolInput>, ManageAttributeToolResult> | AffinityToolDefinition<TimeInputs<ManageCommitmentToolInput>, ManageCommitmentToolResult> | AffinityToolDefinition<TimeInputs<ManageContactToolInput>, ManageContactToolResult> | AffinityToolDefinition<{
1836
2059
  action: "dismiss" | "undismiss";
1837
2060
  left: {
@@ -1871,6 +2094,12 @@ declare function listAffinityToolDefinitions(): (AffinityToolDefinition<TimeInpu
1871
2094
  reasonSummary?: string | null;
1872
2095
  now?: string | number;
1873
2096
  }, MergeContactsToolResult> | AffinityToolDefinition<TimeInputs<RecordEventToolInput>, RecordEventToolResult> | AffinityToolDefinition<{
2097
+ ref?: {
2098
+ source: string;
2099
+ id: string;
2100
+ };
2101
+ includeContent?: boolean;
2102
+ channel?: string;
1874
2103
  view: ReviewAffinityToolView;
1875
2104
  now?: string | number;
1876
2105
  contact?: {
@@ -1916,6 +2145,7 @@ declare function listAffinityToolDefinitions(): (AffinityToolDefinition<TimeInpu
1916
2145
  limit?: number;
1917
2146
  offset?: number;
1918
2147
  }, ReviewAffinityToolResult> | AffinityToolDefinition<{
2148
+ scope?: "contacts" | "events" | "all";
1919
2149
  query: string;
1920
2150
  kind?: ContactKind;
1921
2151
  lifecycleState?: ContactLifecycleState;
@@ -1926,7 +2156,27 @@ declare function listAffinityToolDefinitions(): (AffinityToolDefinition<TimeInpu
1926
2156
  includeDormant?: boolean;
1927
2157
  limit?: number;
1928
2158
  offset?: number;
1929
- }, SearchAffinityToolResult>)[];
2159
+ }, SearchAffinityToolResult> | AffinityToolDefinition<{
2160
+ action: "revise" | "delete";
2161
+ eventId?: number;
2162
+ ref?: {
2163
+ source: string;
2164
+ id: string;
2165
+ };
2166
+ patch?: {
2167
+ summary?: string;
2168
+ content?: string;
2169
+ occurredAt?: string | number;
2170
+ significance?: number;
2171
+ channel?: string;
2172
+ type?: EventType;
2173
+ externalRef?: {
2174
+ source: string;
2175
+ id: string;
2176
+ };
2177
+ };
2178
+ confirm?: boolean;
2179
+ }, ManageEventToolResult>)[];
1930
2180
  declare function getAffinityToolByName(name: string): AffinityToolDefinition<TimeInputs<InspectAffinityItemToolInput>, InspectAffinityItemToolResult> | AffinityToolDefinition<TimeInputs<ManageAttributeToolInput>, ManageAttributeToolResult> | AffinityToolDefinition<TimeInputs<ManageCommitmentToolInput>, ManageCommitmentToolResult> | AffinityToolDefinition<TimeInputs<ManageContactToolInput>, ManageContactToolResult> | AffinityToolDefinition<{
1931
2181
  action: "dismiss" | "undismiss";
1932
2182
  left: {
@@ -1966,6 +2216,12 @@ declare function getAffinityToolByName(name: string): AffinityToolDefinition<Tim
1966
2216
  reasonSummary?: string | null;
1967
2217
  now?: string | number;
1968
2218
  }, MergeContactsToolResult> | AffinityToolDefinition<TimeInputs<RecordEventToolInput>, RecordEventToolResult> | AffinityToolDefinition<{
2219
+ ref?: {
2220
+ source: string;
2221
+ id: string;
2222
+ };
2223
+ includeContent?: boolean;
2224
+ channel?: string;
1969
2225
  view: ReviewAffinityToolView;
1970
2226
  now?: string | number;
1971
2227
  contact?: {
@@ -2011,6 +2267,7 @@ declare function getAffinityToolByName(name: string): AffinityToolDefinition<Tim
2011
2267
  limit?: number;
2012
2268
  offset?: number;
2013
2269
  }, ReviewAffinityToolResult> | AffinityToolDefinition<{
2270
+ scope?: "contacts" | "events" | "all";
2014
2271
  query: string;
2015
2272
  kind?: ContactKind;
2016
2273
  lifecycleState?: ContactLifecycleState;
@@ -2021,7 +2278,27 @@ declare function getAffinityToolByName(name: string): AffinityToolDefinition<Tim
2021
2278
  includeDormant?: boolean;
2022
2279
  limit?: number;
2023
2280
  offset?: number;
2024
- }, SearchAffinityToolResult> | null;
2281
+ }, SearchAffinityToolResult> | AffinityToolDefinition<{
2282
+ action: "revise" | "delete";
2283
+ eventId?: number;
2284
+ ref?: {
2285
+ source: string;
2286
+ id: string;
2287
+ };
2288
+ patch?: {
2289
+ summary?: string;
2290
+ content?: string;
2291
+ occurredAt?: string | number;
2292
+ significance?: number;
2293
+ channel?: string;
2294
+ type?: EventType;
2295
+ externalRef?: {
2296
+ source: string;
2297
+ id: string;
2298
+ };
2299
+ };
2300
+ confirm?: boolean;
2301
+ }, ManageEventToolResult> | null;
2025
2302
 
2026
2303
  interface AffinityToolMapping {
2027
2304
  source: string;
@@ -2044,6 +2321,7 @@ declare const recordEventToolName = "record_event";
2044
2321
  declare const manageCommitmentToolName = "manage_commitment";
2045
2322
  declare const manageDateAnchorToolName = "manage_date_anchor";
2046
2323
  declare const manageAttributeToolName = "manage_attribute";
2324
+ declare const manageEventToolName = "manage_event";
2047
2325
 
2048
2326
  declare function summarizeCount(count: number, singular: string): string;
2049
2327
 
@@ -2053,6 +2331,8 @@ type index_ContactLocator = ContactLocator;
2053
2331
  type index_JsonSchema = JsonSchema;
2054
2332
  type index_JsonSchemaType = JsonSchemaType;
2055
2333
  type index_LinkLocator = LinkLocator;
2334
+ type index_ManageEventToolInput = ManageEventToolInput;
2335
+ type index_ManageEventToolResult = ManageEventToolResult;
2056
2336
  type index_MutationToolData<TPrimary> = MutationToolData<TPrimary>;
2057
2337
  type index_ResolvedTarget<T> = ResolvedTarget<T>;
2058
2338
  type index_ToolBaseResult = ToolBaseResult;
@@ -2098,6 +2378,9 @@ declare const index_manageDateAnchorToolName: typeof manageDateAnchorToolName;
2098
2378
  declare const index_manageDuplicateDismissalTool: typeof manageDuplicateDismissalTool;
2099
2379
  declare const index_manageDuplicateDismissalToolHandler: typeof manageDuplicateDismissalToolHandler;
2100
2380
  declare const index_manageDuplicateDismissalToolName: typeof manageDuplicateDismissalToolName;
2381
+ declare const index_manageEventTool: typeof manageEventTool;
2382
+ declare const index_manageEventToolHandler: typeof manageEventToolHandler;
2383
+ declare const index_manageEventToolName: typeof manageEventToolName;
2101
2384
  declare const index_manageIdentityTool: typeof manageIdentityTool;
2102
2385
  declare const index_manageIdentityToolHandler: typeof manageIdentityToolHandler;
2103
2386
  declare const index_manageIdentityToolName: typeof manageIdentityToolName;
@@ -2146,7 +2429,7 @@ declare const index_toolSuccess: typeof toolSuccess;
2146
2429
  declare const index_toolWarning: typeof toolWarning;
2147
2430
  declare const index_withToolHandling: typeof withToolHandling;
2148
2431
  declare namespace index {
2149
- export { type index_AffinityToolDefinition as AffinityToolDefinition, type index_AffinityToolMapping as AffinityToolMapping, type index_ContactLocator as ContactLocator, type index_JsonSchema as JsonSchema, type index_JsonSchemaType as JsonSchemaType, type index_LinkLocator as LinkLocator, type index_MutationToolData as MutationToolData, type index_ResolvedTarget as ResolvedTarget, type index_ToolBaseResult as ToolBaseResult, type index_ToolDefinitionRegistry as ToolDefinitionRegistry, type index_ToolEntityKind as ToolEntityKind, type index_ToolEntityRef as ToolEntityRef, type index_ToolFailure as ToolFailure, type index_ToolInputDescriptions as ToolInputDescriptions, type index_ToolListItem as ToolListItem, type index_ToolNeedsClarification as ToolNeedsClarification, type index_ToolNextStepHint as ToolNextStepHint, type index_ToolOutcomeKind as ToolOutcomeKind, type index_ToolOutputDescription as ToolOutputDescription, type index_ToolResult as ToolResult, type index_ToolSideEffects as ToolSideEffects, type index_ToolSuccess as ToolSuccess, type index_ToolWarning as ToolWarning, index_affinityToolMappings as affinityToolMappings, index_affinityTools as affinityTools, index_arraySchema as arraySchema, index_booleanSchema as booleanSchema, index_defineAffinityTool as defineAffinityTool, index_enumSchema as enumSchema, index_getAffinityToolByName as getAffinityToolByName, index_inspectAffinityItemTool as inspectAffinityItemTool, index_inspectAffinityItemToolHandler as inspectAffinityItemToolHandler, index_inspectAffinityItemToolName as inspectAffinityItemToolName, index_integerSchema as integerSchema, index_listAffinityToolDefinitions as listAffinityToolDefinitions, index_literalSchema as literalSchema, index_manageAttributeTool as manageAttributeTool, index_manageAttributeToolHandler as manageAttributeToolHandler, index_manageAttributeToolName as manageAttributeToolName, index_manageCommitmentTool as manageCommitmentTool, index_manageCommitmentToolHandler as manageCommitmentToolHandler, index_manageCommitmentToolName as manageCommitmentToolName, index_manageContactTool as manageContactTool, index_manageContactToolHandler as manageContactToolHandler, index_manageContactToolName as manageContactToolName, index_manageDateAnchorTool as manageDateAnchorTool, index_manageDateAnchorToolHandler as manageDateAnchorToolHandler, index_manageDateAnchorToolName as manageDateAnchorToolName, index_manageDuplicateDismissalTool as manageDuplicateDismissalTool, index_manageDuplicateDismissalToolHandler as manageDuplicateDismissalToolHandler, index_manageDuplicateDismissalToolName as manageDuplicateDismissalToolName, index_manageIdentityTool as manageIdentityTool, index_manageIdentityToolHandler as manageIdentityToolHandler, index_manageIdentityToolName as manageIdentityToolName, index_manageRelationshipTool as manageRelationshipTool, index_manageRelationshipToolHandler as manageRelationshipToolHandler, index_manageRelationshipToolName as manageRelationshipToolName, index_mapErrorToToolFailure as mapErrorToToolFailure, index_mergeContactsTool as mergeContactsTool, index_mergeContactsToolHandler as mergeContactsToolHandler, index_mergeContactsToolName as mergeContactsToolName, index_mutationToolResult as mutationToolResult, index_nullableStringSchema as nullableStringSchema, index_numberSchema as numberSchema, index_objectSchema as objectSchema, index_oneOfSchema as oneOfSchema, index_parseTimeInput as parseTimeInput, index_recordEventTool as recordEventTool, index_recordEventToolHandler as recordEventToolHandler, index_recordEventToolName as recordEventToolName, index_resolveContactLocator as resolveContactLocator, index_resolveLinkLocator as resolveLinkLocator, index_reviewAffinityTool as reviewAffinityTool, index_reviewAffinityToolHandler as reviewAffinityToolHandler, index_reviewAffinityToolName as reviewAffinityToolName, index_searchAffinityTool as searchAffinityTool, index_searchAffinityToolHandler as searchAffinityToolHandler, index_searchAffinityToolName as searchAffinityToolName, index_stringSchema as stringSchema, index_summarizeCount as summarizeCount, index_toAttributeEntityRef as toAttributeEntityRef, index_toAttributeListToolItem as toAttributeListToolItem, index_toContactEntityRef as toContactEntityRef, index_toContactListToolItem as toContactListToolItem, index_toEventEntityRef as toEventEntityRef, index_toEventListToolItem as toEventListToolItem, index_toIdentityEntityRef as toIdentityEntityRef, index_toIdentityListToolItem as toIdentityListToolItem, index_toLinkEntityRef as toLinkEntityRef, index_toLinkListToolItem as toLinkListToolItem, index_toMutationRefEntity as toMutationRefEntity, index_toReceiptEntityRefs as toReceiptEntityRefs, index_toolFailure as toolFailure, index_toolNeedsClarification as toolNeedsClarification, index_toolNoOp as toolNoOp, index_toolSuccess as toolSuccess, index_toolWarning as toolWarning, index_withToolHandling as withToolHandling };
2432
+ export { type index_AffinityToolDefinition as AffinityToolDefinition, type index_AffinityToolMapping as AffinityToolMapping, type index_ContactLocator as ContactLocator, type index_JsonSchema as JsonSchema, type index_JsonSchemaType as JsonSchemaType, type index_LinkLocator as LinkLocator, type index_ManageEventToolInput as ManageEventToolInput, type index_ManageEventToolResult as ManageEventToolResult, type index_MutationToolData as MutationToolData, type index_ResolvedTarget as ResolvedTarget, type index_ToolBaseResult as ToolBaseResult, type index_ToolDefinitionRegistry as ToolDefinitionRegistry, type index_ToolEntityKind as ToolEntityKind, type index_ToolEntityRef as ToolEntityRef, type index_ToolFailure as ToolFailure, type index_ToolInputDescriptions as ToolInputDescriptions, type index_ToolListItem as ToolListItem, type index_ToolNeedsClarification as ToolNeedsClarification, type index_ToolNextStepHint as ToolNextStepHint, type index_ToolOutcomeKind as ToolOutcomeKind, type index_ToolOutputDescription as ToolOutputDescription, type index_ToolResult as ToolResult, type index_ToolSideEffects as ToolSideEffects, type index_ToolSuccess as ToolSuccess, type index_ToolWarning as ToolWarning, index_affinityToolMappings as affinityToolMappings, index_affinityTools as affinityTools, index_arraySchema as arraySchema, index_booleanSchema as booleanSchema, index_defineAffinityTool as defineAffinityTool, index_enumSchema as enumSchema, index_getAffinityToolByName as getAffinityToolByName, index_inspectAffinityItemTool as inspectAffinityItemTool, index_inspectAffinityItemToolHandler as inspectAffinityItemToolHandler, index_inspectAffinityItemToolName as inspectAffinityItemToolName, index_integerSchema as integerSchema, index_listAffinityToolDefinitions as listAffinityToolDefinitions, index_literalSchema as literalSchema, index_manageAttributeTool as manageAttributeTool, index_manageAttributeToolHandler as manageAttributeToolHandler, index_manageAttributeToolName as manageAttributeToolName, index_manageCommitmentTool as manageCommitmentTool, index_manageCommitmentToolHandler as manageCommitmentToolHandler, index_manageCommitmentToolName as manageCommitmentToolName, index_manageContactTool as manageContactTool, index_manageContactToolHandler as manageContactToolHandler, index_manageContactToolName as manageContactToolName, index_manageDateAnchorTool as manageDateAnchorTool, index_manageDateAnchorToolHandler as manageDateAnchorToolHandler, index_manageDateAnchorToolName as manageDateAnchorToolName, index_manageDuplicateDismissalTool as manageDuplicateDismissalTool, index_manageDuplicateDismissalToolHandler as manageDuplicateDismissalToolHandler, index_manageDuplicateDismissalToolName as manageDuplicateDismissalToolName, index_manageEventTool as manageEventTool, index_manageEventToolHandler as manageEventToolHandler, index_manageEventToolName as manageEventToolName, index_manageIdentityTool as manageIdentityTool, index_manageIdentityToolHandler as manageIdentityToolHandler, index_manageIdentityToolName as manageIdentityToolName, index_manageRelationshipTool as manageRelationshipTool, index_manageRelationshipToolHandler as manageRelationshipToolHandler, index_manageRelationshipToolName as manageRelationshipToolName, index_mapErrorToToolFailure as mapErrorToToolFailure, index_mergeContactsTool as mergeContactsTool, index_mergeContactsToolHandler as mergeContactsToolHandler, index_mergeContactsToolName as mergeContactsToolName, index_mutationToolResult as mutationToolResult, index_nullableStringSchema as nullableStringSchema, index_numberSchema as numberSchema, index_objectSchema as objectSchema, index_oneOfSchema as oneOfSchema, index_parseTimeInput as parseTimeInput, index_recordEventTool as recordEventTool, index_recordEventToolHandler as recordEventToolHandler, index_recordEventToolName as recordEventToolName, index_resolveContactLocator as resolveContactLocator, index_resolveLinkLocator as resolveLinkLocator, index_reviewAffinityTool as reviewAffinityTool, index_reviewAffinityToolHandler as reviewAffinityToolHandler, index_reviewAffinityToolName as reviewAffinityToolName, index_searchAffinityTool as searchAffinityTool, index_searchAffinityToolHandler as searchAffinityToolHandler, index_searchAffinityToolName as searchAffinityToolName, index_stringSchema as stringSchema, index_summarizeCount as summarizeCount, index_toAttributeEntityRef as toAttributeEntityRef, index_toAttributeListToolItem as toAttributeListToolItem, index_toContactEntityRef as toContactEntityRef, index_toContactListToolItem as toContactListToolItem, index_toEventEntityRef as toEventEntityRef, index_toEventListToolItem as toEventListToolItem, index_toIdentityEntityRef as toIdentityEntityRef, index_toIdentityListToolItem as toIdentityListToolItem, index_toLinkEntityRef as toLinkEntityRef, index_toLinkListToolItem as toLinkListToolItem, index_toMutationRefEntity as toMutationRefEntity, index_toReceiptEntityRefs as toReceiptEntityRefs, index_toolFailure as toolFailure, index_toolNeedsClarification as toolNeedsClarification, index_toolNoOp as toolNoOp, index_toolSuccess as toolSuccess, index_toolWarning as toolWarning, index_withToolHandling as withToolHandling };
2150
2433
  }
2151
2434
 
2152
2435
  declare function addIdentity(db: AffinityDb, contactId: number, input: AddIdentityInput): IdentityMutationReceipt;
@@ -2167,6 +2450,7 @@ declare const write_addDateAnchor: typeof addDateAnchor;
2167
2450
  declare const write_addIdentity: typeof addIdentity;
2168
2451
  declare const write_createContact: typeof createContact;
2169
2452
  declare const write_deleteContact: typeof deleteContact;
2453
+ declare const write_deleteEvent: typeof deleteEvent;
2170
2454
  declare const write_dismissDuplicate: typeof dismissDuplicate;
2171
2455
  declare const write_mergeContacts: typeof mergeContacts;
2172
2456
  declare const write_overrideLinkState: typeof overrideLinkState;
@@ -2183,6 +2467,7 @@ declare const write_resolveCommitment: typeof resolveCommitment;
2183
2467
  declare const write_reviseBond: typeof reviseBond;
2184
2468
  declare const write_reviseContact: typeof reviseContact;
2185
2469
  declare const write_reviseDateAnchor: typeof reviseDateAnchor;
2470
+ declare const write_reviseEvent: typeof reviseEvent;
2186
2471
  declare const write_reviseIdentity: typeof reviseIdentity;
2187
2472
  declare const write_seedSocialLink: typeof seedSocialLink;
2188
2473
  declare const write_setAttribute: typeof setAttribute;
@@ -2192,7 +2477,7 @@ declare const write_undismissDuplicate: typeof undismissDuplicate;
2192
2477
  declare const write_unsetAttribute: typeof unsetAttribute;
2193
2478
  declare const write_verifyIdentity: typeof verifyIdentity;
2194
2479
  declare namespace write {
2195
- export { write_addDateAnchor as addDateAnchor, write_addIdentity as addIdentity, write_createContact as createContact, write_deleteContact as deleteContact, write_dismissDuplicate as dismissDuplicate, write_mergeContacts as mergeContacts, write_overrideLinkState as overrideLinkState, write_recordCommitment as recordCommitment, write_recordInteraction as recordInteraction, write_recordMilestone as recordMilestone, write_recordObservation as recordObservation, write_recordTransaction as recordTransaction, write_removeDateAnchor as removeDateAnchor, write_removeIdentity as removeIdentity, write_removeStructuralTie as removeStructuralTie, write_replaceAttributes as replaceAttributes, write_resolveCommitment as resolveCommitment, write_reviseBond as reviseBond, write_reviseContact as reviseContact, write_reviseDateAnchor as reviseDateAnchor, write_reviseIdentity as reviseIdentity, write_seedSocialLink as seedSocialLink, write_setAttribute as setAttribute, write_setContactLifecycle as setContactLifecycle, write_setStructuralTie as setStructuralTie, write_undismissDuplicate as undismissDuplicate, write_unsetAttribute as unsetAttribute, write_verifyIdentity as verifyIdentity };
2480
+ export { write_addDateAnchor as addDateAnchor, write_addIdentity as addIdentity, write_createContact as createContact, write_deleteContact as deleteContact, write_deleteEvent as deleteEvent, write_dismissDuplicate as dismissDuplicate, write_mergeContacts as mergeContacts, write_overrideLinkState as overrideLinkState, write_recordCommitment as recordCommitment, write_recordInteraction as recordInteraction, write_recordMilestone as recordMilestone, write_recordObservation as recordObservation, write_recordTransaction as recordTransaction, write_removeDateAnchor as removeDateAnchor, write_removeIdentity as removeIdentity, write_removeStructuralTie as removeStructuralTie, write_replaceAttributes as replaceAttributes, write_resolveCommitment as resolveCommitment, write_reviseBond as reviseBond, write_reviseContact as reviseContact, write_reviseDateAnchor as reviseDateAnchor, write_reviseEvent as reviseEvent, write_reviseIdentity as reviseIdentity, write_seedSocialLink as seedSocialLink, write_setAttribute as setAttribute, write_setContactLifecycle as setContactLifecycle, write_setStructuralTie as setStructuralTie, write_undismissDuplicate as undismissDuplicate, write_unsetAttribute as unsetAttribute, write_verifyIdentity as verifyIdentity };
2196
2481
  }
2197
2482
 
2198
2483
  export { AffinityConflictError, AffinityError, type AffinityErrorCode, AffinityInvariantError, AffinityMergeError, AffinityNotFoundError, type AffinitySkill, type AffinitySkillRegistry, type AffinitySoul, type AffinitySoulTrait, AffinityStateError, AffinityValidationError, affinitySkills, affinitySoul, affinitySoulEssence, affinitySoulTraits, bootstrapAndColdStartSkill, captureTransactionsAndCommercialEventsSkill, defineAffinitySkill, errors, getAffinitySkillByName, identifyAndLocateContactsSkill, importHistoryWithoutFakingEvidenceSkill, initAffinityTables, isAffinityError, listAffinitySkills, managePromisesAndAgreementsSkill, manageRecurringDatesAndRemindersSkill, modelStructureOrgsAndHouseholdsSkill, read, reconcileDuplicatesAndMergeSafelySkill, recordDirectEvidenceWellSkill, recordObservationsAndReferralsSkill, renderAffinitySoulPromptFoundation, reviewRadarProgressionAndGraphSkill, index$1 as skills, soul, index as tools, types, write };