@ghostpaw/affinity 0.1.3
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/LICENSE +21 -0
- package/README.md +250 -0
- package/dist/index.cjs +8606 -0
- package/dist/index.d.cts +1641 -0
- package/dist/index.d.ts +1641 -0
- package/dist/index.js +8589 -0
- package/package.json +88 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1641 @@
|
|
|
1
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SQLite dependency injected into every affinity operation.
|
|
5
|
+
*/
|
|
6
|
+
type AffinityDb = DatabaseSync;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates the full standalone affinity public schema (contacts through attributes).
|
|
10
|
+
*/
|
|
11
|
+
declare function initAffinityTables(db: AffinityDb): void;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Stable programmatic codes for `instanceof`-free logging or telemetry if needed.
|
|
15
|
+
*/
|
|
16
|
+
type AffinityErrorCode = "NOT_FOUND" | "CONFLICT" | "INVARIANT" | "VALIDATION" | "MERGE" | "STATE";
|
|
17
|
+
/** Base class for all domain failures thrown by Affinity. */
|
|
18
|
+
declare abstract class AffinityError extends Error {
|
|
19
|
+
abstract readonly code: AffinityErrorCode;
|
|
20
|
+
constructor(message: string, options?: ErrorOptions);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Uniqueness, routing, or ownership collision. */
|
|
24
|
+
declare class AffinityConflictError extends AffinityError {
|
|
25
|
+
readonly code: "CONFLICT";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Request would violate model truth (e.g. progression on a structural tie). */
|
|
29
|
+
declare class AffinityInvariantError extends AffinityError {
|
|
30
|
+
readonly code: "INVARIANT";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Illegal or ambiguous merge (e.g. merge into self). */
|
|
34
|
+
declare class AffinityMergeError extends AffinityError {
|
|
35
|
+
readonly code: "MERGE";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Referenced entity or row does not exist. */
|
|
39
|
+
declare class AffinityNotFoundError extends AffinityError {
|
|
40
|
+
readonly code: "NOT_FOUND";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Forbidden lifecycle or relationship transition. */
|
|
44
|
+
declare class AffinityStateError extends AffinityError {
|
|
45
|
+
readonly code: "STATE";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Malformed input, unsupported sort/filter, or out-of-range value. */
|
|
49
|
+
declare class AffinityValidationError extends AffinityError {
|
|
50
|
+
readonly code: "VALIDATION";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Narrow unknown failures from Affinity operations. */
|
|
54
|
+
declare function isAffinityError(value: unknown): value is AffinityError;
|
|
55
|
+
|
|
56
|
+
type errors_AffinityConflictError = AffinityConflictError;
|
|
57
|
+
declare const errors_AffinityConflictError: typeof AffinityConflictError;
|
|
58
|
+
type errors_AffinityError = AffinityError;
|
|
59
|
+
declare const errors_AffinityError: typeof AffinityError;
|
|
60
|
+
type errors_AffinityErrorCode = AffinityErrorCode;
|
|
61
|
+
type errors_AffinityInvariantError = AffinityInvariantError;
|
|
62
|
+
declare const errors_AffinityInvariantError: typeof AffinityInvariantError;
|
|
63
|
+
type errors_AffinityMergeError = AffinityMergeError;
|
|
64
|
+
declare const errors_AffinityMergeError: typeof AffinityMergeError;
|
|
65
|
+
type errors_AffinityNotFoundError = AffinityNotFoundError;
|
|
66
|
+
declare const errors_AffinityNotFoundError: typeof AffinityNotFoundError;
|
|
67
|
+
type errors_AffinityStateError = AffinityStateError;
|
|
68
|
+
declare const errors_AffinityStateError: typeof AffinityStateError;
|
|
69
|
+
type errors_AffinityValidationError = AffinityValidationError;
|
|
70
|
+
declare const errors_AffinityValidationError: typeof AffinityValidationError;
|
|
71
|
+
declare const errors_isAffinityError: typeof isAffinityError;
|
|
72
|
+
declare namespace errors {
|
|
73
|
+
export { errors_AffinityConflictError as AffinityConflictError, errors_AffinityError as AffinityError, type errors_AffinityErrorCode as AffinityErrorCode, errors_AffinityInvariantError as AffinityInvariantError, errors_AffinityMergeError as AffinityMergeError, errors_AffinityNotFoundError as AffinityNotFoundError, errors_AffinityStateError as AffinityStateError, errors_AffinityValidationError as AffinityValidationError, errors_isAffinityError as isAffinityError };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Free-form attribute name for operational metadata — value is string or null in SQL.
|
|
78
|
+
*/
|
|
79
|
+
type AttributeName = string;
|
|
80
|
+
|
|
81
|
+
/** Visible contact kind — see CONCEPT.md `contacts.kind`. */
|
|
82
|
+
type ContactKind = "human" | "group" | "company" | "team" | "pet" | "service" | "other";
|
|
83
|
+
/** Lifecycle for a contact row — see CONCEPT.md `contacts.lifecycle_state`. */
|
|
84
|
+
type ContactLifecycleState = "active" | "dormant" | "merged" | "lost";
|
|
85
|
+
|
|
86
|
+
/** Journal entry classification — CONCEPT.md `events.type`. */
|
|
87
|
+
type EventType = "conversation" | "activity" | "gift" | "support" | "milestone" | "observation" | "conflict" | "correction" | "transaction" | "promise" | "agreement" | "date_anchor";
|
|
88
|
+
/** Derived key beat — CONCEPT.md `events.moment_kind` (nullable in storage). */
|
|
89
|
+
type EventMomentKind = "breakthrough" | "rupture" | "reconciliation" | "milestone" | "turning_point";
|
|
90
|
+
/** Anchored calendar recurrence — CONCEPT.md recurring fields on `events`. */
|
|
91
|
+
type EventRecurrenceKind = "birthday" | "anniversary" | "renewal" | "memorial" | "custom_yearly";
|
|
92
|
+
/** Participant stance — CONCEPT.md `event_participants.role`. */
|
|
93
|
+
type EventParticipantRole = "actor" | "recipient" | "subject" | "observer" | "mentioned";
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Identity channel label (email, phone, handle, …) — stored as opaque string in SQL.
|
|
97
|
+
* Normalization happens in write paths, not in DDL.
|
|
98
|
+
*/
|
|
99
|
+
type IdentityType = string;
|
|
100
|
+
|
|
101
|
+
/** Structural tie kinds — CONCEPT.md `links.kind` (structural). */
|
|
102
|
+
type StructuralLinkKind = "works_at" | "manages" | "member_of" | "married_to" | "partner_of" | "parent_of" | "child_of" | "sibling_of" | "friend_of" | "client_of" | "vendor_of" | "reports_to" | "belongs_to" | "other_structural";
|
|
103
|
+
/** Relational social-link kinds — CONCEPT.md `links.kind` (relational). */
|
|
104
|
+
type RelationalLinkKind = "personal" | "family" | "professional" | "romantic" | "care" | "service" | "observed" | "other_relational";
|
|
105
|
+
type LinkKind = StructuralLinkKind | RelationalLinkKind;
|
|
106
|
+
/** Relational link state — structural ties leave this unset at rest in SQL. */
|
|
107
|
+
type LinkState = "active" | "dormant" | "strained" | "broken" | "archived";
|
|
108
|
+
|
|
109
|
+
interface AffinityChartEdge {
|
|
110
|
+
linkId: number;
|
|
111
|
+
fromContactId: number;
|
|
112
|
+
toContactId: number;
|
|
113
|
+
weight: number;
|
|
114
|
+
bridgeScore: number;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Options for `read.getAffinityChart` — CONCEPT.md. */
|
|
118
|
+
interface AffinityChartReadOptions {
|
|
119
|
+
includeArchived?: boolean;
|
|
120
|
+
includeObserved?: boolean;
|
|
121
|
+
/** Restrict the graph to a subset of contact IDs. */
|
|
122
|
+
contactIds?: number[];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
interface AffinityChartNode {
|
|
126
|
+
contactId: number;
|
|
127
|
+
label: string;
|
|
128
|
+
kind: ContactKind;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Graph projection — CONCEPT.md AffinityChartRecord. */
|
|
132
|
+
interface AffinityChartRecord {
|
|
133
|
+
nodes: readonly AffinityChartNode[];
|
|
134
|
+
edges: readonly AffinityChartEdge[];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Attribute pair — `value` null means presence/tag semantics (CONCEPT.md). */
|
|
138
|
+
interface AttributeEntry {
|
|
139
|
+
name: string;
|
|
140
|
+
value: string | null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Attribute row for mutation receipts — stable id + target + payload. */
|
|
144
|
+
interface AttributeRecord {
|
|
145
|
+
id: number;
|
|
146
|
+
contactId: number | null;
|
|
147
|
+
linkId: number | null;
|
|
148
|
+
name: string;
|
|
149
|
+
value: string | null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Write target for attributes — exactly one of contact or link (CONCEPT.md).
|
|
154
|
+
*/
|
|
155
|
+
type AttributeTarget = {
|
|
156
|
+
kind: "contact";
|
|
157
|
+
id: number;
|
|
158
|
+
} | {
|
|
159
|
+
kind: "link";
|
|
160
|
+
id: number;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
/** Open commitment lifecycle on reads — CONCEPT.md CommitmentRecord. */
|
|
164
|
+
type CommitmentResolutionState = "open" | "resolved" | "cancelled";
|
|
165
|
+
|
|
166
|
+
/** Participant row embedded in journal reads — aligns with SocialEventInput participants. */
|
|
167
|
+
interface EventParticipantView {
|
|
168
|
+
contactId: number;
|
|
169
|
+
role: EventParticipantRole;
|
|
170
|
+
directionality?: "owner_initiated" | "other_initiated" | "mutual" | "observed";
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Promise/agreement projection — CONCEPT.md CommitmentRecord. */
|
|
174
|
+
interface CommitmentRecord {
|
|
175
|
+
eventId: number;
|
|
176
|
+
type: EventType;
|
|
177
|
+
summary: string;
|
|
178
|
+
participants: readonly EventParticipantView[];
|
|
179
|
+
dueAt?: number | null;
|
|
180
|
+
resolutionState: CommitmentResolutionState;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Outcome passed to `write.resolveCommitment` — CONCEPT.md. */
|
|
184
|
+
type CommitmentResolutionKind = "kept" | "cancelled" | "broken";
|
|
185
|
+
|
|
186
|
+
/** Canonical contact row fields shared across list and profile reads. */
|
|
187
|
+
interface ContactCore {
|
|
188
|
+
id: number;
|
|
189
|
+
name: string;
|
|
190
|
+
kind: ContactKind;
|
|
191
|
+
lifecycleState: ContactLifecycleState;
|
|
192
|
+
isOwner: boolean;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** Default page size for list reads — CONCEPT.md Global query contract. */
|
|
196
|
+
declare const AFFINITY_DEFAULT_LIST_LIMIT = 50;
|
|
197
|
+
/** Hard cap for list reads — CONCEPT.md Global query contract. */
|
|
198
|
+
declare const AFFINITY_MAX_LIST_LIMIT = 250;
|
|
199
|
+
/** Shared list-style read controls — CONCEPT.md Global query contract. */
|
|
200
|
+
interface AffinityListReadOptions {
|
|
201
|
+
limit?: number;
|
|
202
|
+
offset?: number;
|
|
203
|
+
sort?: string;
|
|
204
|
+
descending?: boolean;
|
|
205
|
+
includeArchived?: boolean;
|
|
206
|
+
includeDormant?: boolean;
|
|
207
|
+
includeObserved?: boolean;
|
|
208
|
+
since?: number;
|
|
209
|
+
until?: number;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Options for `read.getContactJournal` / `read.getLinkTimeline`. */
|
|
213
|
+
type ContactJournalReadOptions = AffinityListReadOptions & {
|
|
214
|
+
eventTypes?: readonly EventType[];
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/** Options for `read.getContactProfile`. */
|
|
218
|
+
interface ContactProfileReadOptions {
|
|
219
|
+
/** Cap on relational links returned in `topLinks` (default 8). */
|
|
220
|
+
topLinksLimit?: number;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** Compact portfolio row — CONCEPT.md ContactListItem. */
|
|
224
|
+
interface ContactListItem {
|
|
225
|
+
id: number;
|
|
226
|
+
name: string;
|
|
227
|
+
kind: ContactKind;
|
|
228
|
+
lifecycleState: ContactLifecycleState;
|
|
229
|
+
isOwner: boolean;
|
|
230
|
+
primaryIdentity?: string | null;
|
|
231
|
+
lastMeaningfulEventAt?: number | null;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** One routing identity on a contact — CONCEPT.md IdentityRecord. */
|
|
235
|
+
interface IdentityRecord {
|
|
236
|
+
id: number;
|
|
237
|
+
contactId: number;
|
|
238
|
+
type: IdentityType;
|
|
239
|
+
value: string;
|
|
240
|
+
label: string | null;
|
|
241
|
+
verified: boolean;
|
|
242
|
+
/** When the identity was marked verified, if known. */
|
|
243
|
+
verifiedAt?: number | null;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** Compact link row for lists — CONCEPT.md LinkListItem. */
|
|
247
|
+
interface LinkListItem {
|
|
248
|
+
id: number;
|
|
249
|
+
fromContactId: number;
|
|
250
|
+
toContactId: number;
|
|
251
|
+
kind: LinkKind;
|
|
252
|
+
role?: string | null;
|
|
253
|
+
rank?: number | null;
|
|
254
|
+
affinity?: number | null;
|
|
255
|
+
trust?: number | null;
|
|
256
|
+
state?: LinkState | null;
|
|
257
|
+
cadenceDays?: number | null;
|
|
258
|
+
bond?: string | null;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Placeholder for rollup payloads until read implementations materialize
|
|
263
|
+
* (`contact_rollups`, `link_rollups`, …).
|
|
264
|
+
*/
|
|
265
|
+
type OpaqueRollup = Record<string, unknown>;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Stable handle for anything that can appear in mutation receipts — CONCEPT.md Common refs.
|
|
269
|
+
*/
|
|
270
|
+
type EntityRef = {
|
|
271
|
+
kind: "contact";
|
|
272
|
+
id: number;
|
|
273
|
+
} | {
|
|
274
|
+
kind: "identity";
|
|
275
|
+
id: number;
|
|
276
|
+
} | {
|
|
277
|
+
kind: "link";
|
|
278
|
+
id: number;
|
|
279
|
+
} | {
|
|
280
|
+
kind: "event";
|
|
281
|
+
id: number;
|
|
282
|
+
} | {
|
|
283
|
+
kind: "attribute";
|
|
284
|
+
id: number;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
type UpcomingDateTargetRef = Extract<EntityRef, {
|
|
288
|
+
kind: "contact" | "link";
|
|
289
|
+
}>;
|
|
290
|
+
/** Next anchored calendar occurrence — CONCEPT.md UpcomingDateRecord. */
|
|
291
|
+
interface UpcomingDateRecord {
|
|
292
|
+
anchorEventId: number;
|
|
293
|
+
targetRef: UpcomingDateTargetRef;
|
|
294
|
+
recurrenceKind: EventRecurrenceKind;
|
|
295
|
+
/** Epoch milliseconds for the materialized next occurrence (sorting key). */
|
|
296
|
+
occursOn: number;
|
|
297
|
+
summary: string;
|
|
298
|
+
significance: number;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** Full contact detail — CONCEPT.md ContactProfileRecord. */
|
|
302
|
+
interface ContactProfileRecord {
|
|
303
|
+
contact: ContactCore;
|
|
304
|
+
identities: readonly IdentityRecord[];
|
|
305
|
+
attributes: readonly AttributeEntry[];
|
|
306
|
+
topLinks: readonly LinkListItem[];
|
|
307
|
+
activeDates: readonly UpcomingDateRecord[];
|
|
308
|
+
warnings: readonly string[];
|
|
309
|
+
rollups?: OpaqueRollup | null;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** Raw `contacts` row from SQLite (snake_case columns). */
|
|
313
|
+
interface ContactRow {
|
|
314
|
+
id: number;
|
|
315
|
+
name: string;
|
|
316
|
+
kind: string;
|
|
317
|
+
lifecycle_state: string;
|
|
318
|
+
is_owner: number;
|
|
319
|
+
merged_into_contact_id: number | null;
|
|
320
|
+
created_at: number;
|
|
321
|
+
updated_at: number;
|
|
322
|
+
deleted_at: number | null;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
type DateAnchorTarget = {
|
|
326
|
+
kind: "contact";
|
|
327
|
+
contactId: number;
|
|
328
|
+
} | {
|
|
329
|
+
kind: "link";
|
|
330
|
+
linkId: number;
|
|
331
|
+
};
|
|
332
|
+
/** Arguments for `write.addDateAnchor`. */
|
|
333
|
+
interface AddDateAnchorInput {
|
|
334
|
+
target: DateAnchorTarget;
|
|
335
|
+
recurrenceKind: EventRecurrenceKind;
|
|
336
|
+
anchorMonth: number;
|
|
337
|
+
anchorDay: number;
|
|
338
|
+
summary: string;
|
|
339
|
+
significance: number;
|
|
340
|
+
now?: number;
|
|
341
|
+
/** When true, skip duplicate (same recurrence + calendar + target) checks. */
|
|
342
|
+
force?: boolean;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/** Arguments for `write.addIdentity`. */
|
|
346
|
+
interface AddIdentityInput {
|
|
347
|
+
type: string;
|
|
348
|
+
value: string;
|
|
349
|
+
label?: string | null;
|
|
350
|
+
/** When true, row is inserted with `verified` set (provenance only). */
|
|
351
|
+
verified?: boolean;
|
|
352
|
+
now?: number;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** Arguments for `write.createContact`. */
|
|
356
|
+
interface CreateContactInput {
|
|
357
|
+
name: string;
|
|
358
|
+
kind: ContactKind;
|
|
359
|
+
now?: number;
|
|
360
|
+
/**
|
|
361
|
+
* When true, marks this row as the sole owner contact.
|
|
362
|
+
* Allowed only while no other live owner exists.
|
|
363
|
+
*/
|
|
364
|
+
bootstrapOwner?: boolean;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** Raw `identities` row from SQLite. */
|
|
368
|
+
interface IdentityRow {
|
|
369
|
+
id: number;
|
|
370
|
+
contact_id: number;
|
|
371
|
+
type: string;
|
|
372
|
+
value: string;
|
|
373
|
+
label: string | null;
|
|
374
|
+
normalized_key: string;
|
|
375
|
+
verified: number;
|
|
376
|
+
verified_at: number | null;
|
|
377
|
+
created_at: number;
|
|
378
|
+
updated_at: number;
|
|
379
|
+
removed_at: number | null;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** Allowed contact-intrinsic updates for `write.reviseContact`. */
|
|
383
|
+
interface ReviseContactPatch {
|
|
384
|
+
name?: string;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** Allowed updates for `write.reviseIdentity`. */
|
|
388
|
+
interface ReviseIdentityPatch {
|
|
389
|
+
type?: string;
|
|
390
|
+
value?: string;
|
|
391
|
+
label?: string | null;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/** Optional metadata for `write.setContactLifecycle`. */
|
|
395
|
+
interface SetContactLifecycleOptions {
|
|
396
|
+
now?: number;
|
|
397
|
+
provenance?: unknown;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/** Arguments for `write.setStructuralTie`. */
|
|
401
|
+
interface SetStructuralTieInput {
|
|
402
|
+
fromContactId: number;
|
|
403
|
+
toContactId: number;
|
|
404
|
+
kind: StructuralLinkKind;
|
|
405
|
+
role?: string | null;
|
|
406
|
+
now?: number;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/** Shared participant row for evidence writes — CONCEPT.md SocialEventInput. */
|
|
410
|
+
interface SocialEventParticipantInput {
|
|
411
|
+
contactId: number;
|
|
412
|
+
role: EventParticipantRole;
|
|
413
|
+
directionality?: "owner_initiated" | "other_initiated" | "mutual" | "observed";
|
|
414
|
+
}
|
|
415
|
+
/** Evidence intake shape shared by interaction-style writes — CONCEPT.md. */
|
|
416
|
+
interface SocialEventInput {
|
|
417
|
+
occurredAt: number;
|
|
418
|
+
summary: string;
|
|
419
|
+
/** Significance 1..10 — enforced at write layer. */
|
|
420
|
+
significance: number;
|
|
421
|
+
participants: readonly SocialEventParticipantInput[];
|
|
422
|
+
provenance?: unknown;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/** Arguments for `write.recordCommitment`. */
|
|
426
|
+
interface RecordCommitmentInput extends SocialEventInput {
|
|
427
|
+
commitmentType: "promise" | "agreement";
|
|
428
|
+
dueAt?: number | null;
|
|
429
|
+
now?: number;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** Subset of `EventType` allowed for `write.recordInteraction` — CONCEPT.md. */
|
|
433
|
+
type InteractionEventType = "conversation" | "activity" | "gift" | "support" | "conflict" | "correction";
|
|
434
|
+
/** Arguments for `write.recordInteraction`. */
|
|
435
|
+
interface RecordInteractionInput extends SocialEventInput {
|
|
436
|
+
type: InteractionEventType;
|
|
437
|
+
now?: number;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/** Arguments for `write.recordMilestone`. */
|
|
441
|
+
interface RecordMilestoneInput extends SocialEventInput {
|
|
442
|
+
now?: number;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/** Arguments for `write.recordObservation`. */
|
|
446
|
+
interface RecordObservationInput extends SocialEventInput {
|
|
447
|
+
now?: number;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/** Arguments for `write.recordTransaction`. */
|
|
451
|
+
interface RecordTransactionInput extends SocialEventInput {
|
|
452
|
+
now?: number;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
interface ResolveCommitmentEventInput {
|
|
456
|
+
type?: Exclude<EventType, "date_anchor">;
|
|
457
|
+
occurredAt?: number;
|
|
458
|
+
summary?: string;
|
|
459
|
+
significance?: number;
|
|
460
|
+
participants?: readonly SocialEventParticipantInput[];
|
|
461
|
+
provenance?: unknown;
|
|
462
|
+
}
|
|
463
|
+
/** Optional clock and linked event data for `write.resolveCommitment`. */
|
|
464
|
+
interface ResolveCommitmentOptions {
|
|
465
|
+
now?: number;
|
|
466
|
+
resolvingEvent?: ResolveCommitmentEventInput;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/** Partial update for `write.reviseDateAnchor`. */
|
|
470
|
+
interface ReviseDateAnchorPatch {
|
|
471
|
+
recurrenceKind?: EventRecurrenceKind;
|
|
472
|
+
anchorMonth?: number;
|
|
473
|
+
anchorDay?: number;
|
|
474
|
+
summary?: string;
|
|
475
|
+
significance?: number;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/** Options for `write.reviseDateAnchor`. */
|
|
479
|
+
interface ReviseDateAnchorOptions {
|
|
480
|
+
now?: number;
|
|
481
|
+
/** When true, skip duplicate calendar+target checks after applying the patch. */
|
|
482
|
+
force?: boolean;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/** Arguments for `write.seedSocialLink`. */
|
|
486
|
+
interface SeedSocialLinkInput {
|
|
487
|
+
fromContactId: number;
|
|
488
|
+
toContactId: number;
|
|
489
|
+
kind: RelationalLinkKind;
|
|
490
|
+
role?: string | null;
|
|
491
|
+
/** Defaults to `0` when omitted. */
|
|
492
|
+
rank?: number;
|
|
493
|
+
/** Defaults to `0.5` when omitted. */
|
|
494
|
+
affinity?: number;
|
|
495
|
+
/** Defaults to `0.5` when omitted. */
|
|
496
|
+
trust?: number;
|
|
497
|
+
/** Defaults to `active` when omitted. */
|
|
498
|
+
state?: LinkState;
|
|
499
|
+
cadenceDays?: number | null;
|
|
500
|
+
bond?: string | null;
|
|
501
|
+
now?: number;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* One row of link-level math returned on writes — CONCEPT.md DerivedLinkEffect.
|
|
506
|
+
*/
|
|
507
|
+
interface DerivedLinkEffect {
|
|
508
|
+
linkId: number;
|
|
509
|
+
eventId: number;
|
|
510
|
+
baseWeight: number;
|
|
511
|
+
intensity: number;
|
|
512
|
+
valence: number;
|
|
513
|
+
intimacyDepth: number;
|
|
514
|
+
reciprocitySignal: number;
|
|
515
|
+
directness: number;
|
|
516
|
+
preferenceMatch: number;
|
|
517
|
+
novelty: number;
|
|
518
|
+
affinityDelta: number;
|
|
519
|
+
trustDelta: number;
|
|
520
|
+
rankBefore: number;
|
|
521
|
+
rankAfter: number;
|
|
522
|
+
stateBefore: LinkState;
|
|
523
|
+
stateAfter: LinkState;
|
|
524
|
+
cadenceBefore: number;
|
|
525
|
+
cadenceAfter: number;
|
|
526
|
+
momentKind: EventMomentKind | null;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Placeholder for mechanics derivation blocks on detail reads.
|
|
531
|
+
*/
|
|
532
|
+
type OpaqueDerivation = Record<string, unknown>;
|
|
533
|
+
|
|
534
|
+
/** Dedupe candidate pair — CONCEPT.md DuplicateCandidateRecord. */
|
|
535
|
+
interface DuplicateCandidateRecord {
|
|
536
|
+
leftContactId: number;
|
|
537
|
+
rightContactId: number;
|
|
538
|
+
matchReason: string;
|
|
539
|
+
matchScore: number;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/** Journal entry with explicit participants — CONCEPT.md EventRecord. */
|
|
543
|
+
interface EventRecord {
|
|
544
|
+
id: number;
|
|
545
|
+
type: EventType;
|
|
546
|
+
occurredAt: number;
|
|
547
|
+
summary: string;
|
|
548
|
+
significance: number;
|
|
549
|
+
momentKind: EventMomentKind | null;
|
|
550
|
+
participants: readonly EventParticipantView[];
|
|
551
|
+
recurrenceKind?: EventRecurrenceKind | null;
|
|
552
|
+
anchorMonth?: number | null;
|
|
553
|
+
anchorDay?: number | null;
|
|
554
|
+
anchorContactId?: number | null;
|
|
555
|
+
anchorLinkId?: number | null;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/** Raw `events` row from SQLite (snake_case columns). */
|
|
559
|
+
interface EventRow {
|
|
560
|
+
id: number;
|
|
561
|
+
type: string;
|
|
562
|
+
occurred_at: number;
|
|
563
|
+
summary: string;
|
|
564
|
+
significance: number;
|
|
565
|
+
moment_kind: string | null;
|
|
566
|
+
recurrence_kind: string | null;
|
|
567
|
+
anchor_month: number | null;
|
|
568
|
+
anchor_day: number | null;
|
|
569
|
+
anchor_contact_id: number | null;
|
|
570
|
+
anchor_link_id: number | null;
|
|
571
|
+
created_at: number;
|
|
572
|
+
updated_at: number;
|
|
573
|
+
deleted_at: number | null;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/** Derived key beat — CONCEPT.md MomentRecord. */
|
|
577
|
+
interface MomentRecord {
|
|
578
|
+
eventId: number;
|
|
579
|
+
linkId: number;
|
|
580
|
+
momentKind: EventMomentKind;
|
|
581
|
+
occurredAt: number;
|
|
582
|
+
summary: string;
|
|
583
|
+
impactScore: number;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/** Link detail with journal slices — CONCEPT.md LinkDetailRecord. */
|
|
587
|
+
interface LinkDetailRecord {
|
|
588
|
+
link: LinkListItem;
|
|
589
|
+
counterparty: ContactCore;
|
|
590
|
+
recentEvents: readonly EventRecord[];
|
|
591
|
+
moments: readonly MomentRecord[];
|
|
592
|
+
rollups?: OpaqueRollup | null;
|
|
593
|
+
derivation?: OpaqueDerivation | null;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/** Optional detail controls for `read.getLinkDetail`. */
|
|
597
|
+
interface LinkDetailReadOptions {
|
|
598
|
+
/** Cap on recent events returned in `recentEvents` (default 5). */
|
|
599
|
+
recentEventsLimit?: number;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/** Common filters for link list reads — CONCEPT.md. */
|
|
603
|
+
interface LinkListReadFilters {
|
|
604
|
+
kind?: LinkKind;
|
|
605
|
+
state?: LinkState;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/** Optional clock and provenance for relational link mutations. */
|
|
609
|
+
interface LinkMutationOptions {
|
|
610
|
+
now?: number;
|
|
611
|
+
provenance?: unknown;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/** Raw `links` row from SQLite (snake_case columns). */
|
|
615
|
+
interface LinkRow {
|
|
616
|
+
id: number;
|
|
617
|
+
from_contact_id: number;
|
|
618
|
+
to_contact_id: number;
|
|
619
|
+
kind: string;
|
|
620
|
+
role: string | null;
|
|
621
|
+
is_structural: number;
|
|
622
|
+
rank: number | null;
|
|
623
|
+
affinity: number | null;
|
|
624
|
+
trust: number | null;
|
|
625
|
+
state: string | null;
|
|
626
|
+
cadence_days: number | null;
|
|
627
|
+
bond: string | null;
|
|
628
|
+
created_at: number;
|
|
629
|
+
updated_at: number;
|
|
630
|
+
removed_at: number | null;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/** Filters for `read.listContacts` — CONCEPT.md portfolio list. */
|
|
634
|
+
interface ListContactsFilters {
|
|
635
|
+
kind?: ContactKind;
|
|
636
|
+
lifecycleState?: ContactLifecycleState;
|
|
637
|
+
includeOwner?: boolean;
|
|
638
|
+
includeDormant?: boolean;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/** Filters for `read.listDuplicateCandidates` — CONCEPT.md. */
|
|
642
|
+
interface ListDuplicateCandidatesFilters {
|
|
643
|
+
minScore?: number;
|
|
644
|
+
exactOnly?: boolean;
|
|
645
|
+
contactIds?: readonly number[];
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/** Supported filters for `read.listMoments` — CONCEPT.md. */
|
|
649
|
+
interface ListMomentsFilters {
|
|
650
|
+
momentKind?: EventMomentKind;
|
|
651
|
+
contactId?: number;
|
|
652
|
+
linkId?: number;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/** Filters for `read.listOpenCommitments` — CONCEPT.md. */
|
|
656
|
+
interface ListOpenCommitmentsFilters {
|
|
657
|
+
commitmentType?: "promise" | "agreement";
|
|
658
|
+
contactId?: number;
|
|
659
|
+
linkId?: number;
|
|
660
|
+
horizonDays?: number;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/** Filters for `read.listUpcomingDates` — CONCEPT.md maintenance list. */
|
|
664
|
+
interface ListUpcomingDatesFilters {
|
|
665
|
+
recurrenceKind?: EventRecurrenceKind;
|
|
666
|
+
contactKind?: ContactKind;
|
|
667
|
+
/** Max days ahead from the horizon anchor (`options.since` or now). */
|
|
668
|
+
horizonDays?: number;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/** Arguments for `write.mergeContacts` — CONCEPT.md. */
|
|
672
|
+
interface MergeContactsInput {
|
|
673
|
+
winnerContactId: number;
|
|
674
|
+
loserContactId: number;
|
|
675
|
+
reasonSummary?: string | null;
|
|
676
|
+
now?: number;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/** Primary payload returned on merge — winner/loser pair. */
|
|
680
|
+
interface MergePrimary {
|
|
681
|
+
winnerContactId: number;
|
|
682
|
+
loserContactId: number;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Universal write receipt envelope — CONCEPT.md MutationReceipt.
|
|
687
|
+
*/
|
|
688
|
+
interface MutationReceipt<TPrimary> {
|
|
689
|
+
primary: TPrimary;
|
|
690
|
+
created: EntityRef[];
|
|
691
|
+
updated: EntityRef[];
|
|
692
|
+
archived: EntityRef[];
|
|
693
|
+
removed: EntityRef[];
|
|
694
|
+
affectedLinks: number[];
|
|
695
|
+
derivedEffects: DerivedLinkEffect[];
|
|
696
|
+
}
|
|
697
|
+
type ContactMutationReceipt = MutationReceipt<ContactListItem>;
|
|
698
|
+
type IdentityMutationReceipt = MutationReceipt<IdentityRecord>;
|
|
699
|
+
type LinkMutationReceipt = MutationReceipt<LinkListItem>;
|
|
700
|
+
type EventMutationReceipt = MutationReceipt<EventRecord>;
|
|
701
|
+
type AttributeMutationReceipt = MutationReceipt<AttributeRecord>;
|
|
702
|
+
type MergeReceipt = MutationReceipt<MergePrimary>;
|
|
703
|
+
|
|
704
|
+
/** Maintenance radar row — CONCEPT.md RadarRecord. */
|
|
705
|
+
interface RadarRecord {
|
|
706
|
+
linkId: number;
|
|
707
|
+
contactId: number;
|
|
708
|
+
driftPriority: number;
|
|
709
|
+
recencyScore: number;
|
|
710
|
+
normalizedRank: number;
|
|
711
|
+
trust: number;
|
|
712
|
+
recommendedReason: string;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Applies default list limit and CONCEPT bounds (throws when out of range).
|
|
717
|
+
*/
|
|
718
|
+
declare function resolveAffinityListLimit(limit: number | undefined): number;
|
|
719
|
+
|
|
720
|
+
/** Merge lineage row — CONCEPT.md MergeHistoryRecord. */
|
|
721
|
+
interface MergeHistoryRecord {
|
|
722
|
+
winnerContactId: number;
|
|
723
|
+
loserContactId: number;
|
|
724
|
+
mergedAt: number;
|
|
725
|
+
reasonSummary?: string | null;
|
|
726
|
+
manual: boolean;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
declare const types_AFFINITY_DEFAULT_LIST_LIMIT: typeof AFFINITY_DEFAULT_LIST_LIMIT;
|
|
730
|
+
declare const types_AFFINITY_MAX_LIST_LIMIT: typeof AFFINITY_MAX_LIST_LIMIT;
|
|
731
|
+
type types_AddDateAnchorInput = AddDateAnchorInput;
|
|
732
|
+
type types_AddIdentityInput = AddIdentityInput;
|
|
733
|
+
type types_AffinityChartEdge = AffinityChartEdge;
|
|
734
|
+
type types_AffinityChartNode = AffinityChartNode;
|
|
735
|
+
type types_AffinityChartReadOptions = AffinityChartReadOptions;
|
|
736
|
+
type types_AffinityChartRecord = AffinityChartRecord;
|
|
737
|
+
type types_AffinityListReadOptions = AffinityListReadOptions;
|
|
738
|
+
type types_AttributeEntry = AttributeEntry;
|
|
739
|
+
type types_AttributeMutationReceipt = AttributeMutationReceipt;
|
|
740
|
+
type types_AttributeName = AttributeName;
|
|
741
|
+
type types_AttributeRecord = AttributeRecord;
|
|
742
|
+
type types_AttributeTarget = AttributeTarget;
|
|
743
|
+
type types_CommitmentRecord = CommitmentRecord;
|
|
744
|
+
type types_CommitmentResolutionKind = CommitmentResolutionKind;
|
|
745
|
+
type types_CommitmentResolutionState = CommitmentResolutionState;
|
|
746
|
+
type types_ContactCore = ContactCore;
|
|
747
|
+
type types_ContactJournalReadOptions = ContactJournalReadOptions;
|
|
748
|
+
type types_ContactKind = ContactKind;
|
|
749
|
+
type types_ContactLifecycleState = ContactLifecycleState;
|
|
750
|
+
type types_ContactListItem = ContactListItem;
|
|
751
|
+
type types_ContactMutationReceipt = ContactMutationReceipt;
|
|
752
|
+
type types_ContactProfileReadOptions = ContactProfileReadOptions;
|
|
753
|
+
type types_ContactProfileRecord = ContactProfileRecord;
|
|
754
|
+
type types_ContactRow = ContactRow;
|
|
755
|
+
type types_CreateContactInput = CreateContactInput;
|
|
756
|
+
type types_DateAnchorTarget = DateAnchorTarget;
|
|
757
|
+
type types_DerivedLinkEffect = DerivedLinkEffect;
|
|
758
|
+
type types_DuplicateCandidateRecord = DuplicateCandidateRecord;
|
|
759
|
+
type types_EntityRef = EntityRef;
|
|
760
|
+
type types_EventMomentKind = EventMomentKind;
|
|
761
|
+
type types_EventMutationReceipt = EventMutationReceipt;
|
|
762
|
+
type types_EventParticipantRole = EventParticipantRole;
|
|
763
|
+
type types_EventParticipantView = EventParticipantView;
|
|
764
|
+
type types_EventRecord = EventRecord;
|
|
765
|
+
type types_EventRecurrenceKind = EventRecurrenceKind;
|
|
766
|
+
type types_EventRow = EventRow;
|
|
767
|
+
type types_EventType = EventType;
|
|
768
|
+
type types_IdentityMutationReceipt = IdentityMutationReceipt;
|
|
769
|
+
type types_IdentityRecord = IdentityRecord;
|
|
770
|
+
type types_IdentityRow = IdentityRow;
|
|
771
|
+
type types_IdentityType = IdentityType;
|
|
772
|
+
type types_InteractionEventType = InteractionEventType;
|
|
773
|
+
type types_LinkDetailReadOptions = LinkDetailReadOptions;
|
|
774
|
+
type types_LinkDetailRecord = LinkDetailRecord;
|
|
775
|
+
type types_LinkKind = LinkKind;
|
|
776
|
+
type types_LinkListItem = LinkListItem;
|
|
777
|
+
type types_LinkListReadFilters = LinkListReadFilters;
|
|
778
|
+
type types_LinkMutationOptions = LinkMutationOptions;
|
|
779
|
+
type types_LinkMutationReceipt = LinkMutationReceipt;
|
|
780
|
+
type types_LinkRow = LinkRow;
|
|
781
|
+
type types_LinkState = LinkState;
|
|
782
|
+
type types_ListContactsFilters = ListContactsFilters;
|
|
783
|
+
type types_ListDuplicateCandidatesFilters = ListDuplicateCandidatesFilters;
|
|
784
|
+
type types_ListMomentsFilters = ListMomentsFilters;
|
|
785
|
+
type types_ListOpenCommitmentsFilters = ListOpenCommitmentsFilters;
|
|
786
|
+
type types_ListUpcomingDatesFilters = ListUpcomingDatesFilters;
|
|
787
|
+
type types_MergeContactsInput = MergeContactsInput;
|
|
788
|
+
type types_MergeHistoryRecord = MergeHistoryRecord;
|
|
789
|
+
type types_MergePrimary = MergePrimary;
|
|
790
|
+
type types_MergeReceipt = MergeReceipt;
|
|
791
|
+
type types_MomentRecord = MomentRecord;
|
|
792
|
+
type types_MutationReceipt<TPrimary> = MutationReceipt<TPrimary>;
|
|
793
|
+
type types_OpaqueDerivation = OpaqueDerivation;
|
|
794
|
+
type types_OpaqueRollup = OpaqueRollup;
|
|
795
|
+
type types_RadarRecord = RadarRecord;
|
|
796
|
+
type types_RecordCommitmentInput = RecordCommitmentInput;
|
|
797
|
+
type types_RecordInteractionInput = RecordInteractionInput;
|
|
798
|
+
type types_RecordMilestoneInput = RecordMilestoneInput;
|
|
799
|
+
type types_RecordObservationInput = RecordObservationInput;
|
|
800
|
+
type types_RecordTransactionInput = RecordTransactionInput;
|
|
801
|
+
type types_RelationalLinkKind = RelationalLinkKind;
|
|
802
|
+
type types_ResolveCommitmentOptions = ResolveCommitmentOptions;
|
|
803
|
+
type types_ReviseContactPatch = ReviseContactPatch;
|
|
804
|
+
type types_ReviseDateAnchorOptions = ReviseDateAnchorOptions;
|
|
805
|
+
type types_ReviseDateAnchorPatch = ReviseDateAnchorPatch;
|
|
806
|
+
type types_ReviseIdentityPatch = ReviseIdentityPatch;
|
|
807
|
+
type types_SeedSocialLinkInput = SeedSocialLinkInput;
|
|
808
|
+
type types_SetContactLifecycleOptions = SetContactLifecycleOptions;
|
|
809
|
+
type types_SetStructuralTieInput = SetStructuralTieInput;
|
|
810
|
+
type types_SocialEventInput = SocialEventInput;
|
|
811
|
+
type types_SocialEventParticipantInput = SocialEventParticipantInput;
|
|
812
|
+
type types_StructuralLinkKind = StructuralLinkKind;
|
|
813
|
+
type types_UpcomingDateRecord = UpcomingDateRecord;
|
|
814
|
+
type types_UpcomingDateTargetRef = UpcomingDateTargetRef;
|
|
815
|
+
declare const types_resolveAffinityListLimit: typeof resolveAffinityListLimit;
|
|
816
|
+
declare namespace types {
|
|
817
|
+
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_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 };
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
declare function createContact(db: AffinityDb, input: CreateContactInput): ContactMutationReceipt;
|
|
821
|
+
|
|
822
|
+
declare function getContactProfile(db: AffinityDb, contactId: number, options?: ContactProfileReadOptions): ContactProfileRecord | null;
|
|
823
|
+
|
|
824
|
+
declare function getOwnerProfile(db: AffinityDb, options?: ContactProfileReadOptions): ContactProfileRecord | null;
|
|
825
|
+
|
|
826
|
+
declare function listContacts(db: AffinityDb, filters?: ListContactsFilters, options?: AffinityListReadOptions): ContactListItem[];
|
|
827
|
+
|
|
828
|
+
declare function listDuplicateCandidates(db: AffinityDb, filters?: ListDuplicateCandidatesFilters, options?: AffinityListReadOptions): DuplicateCandidateRecord[];
|
|
829
|
+
|
|
830
|
+
declare function reviseContact(db: AffinityDb, contactId: number, patch: ReviseContactPatch): ContactMutationReceipt;
|
|
831
|
+
|
|
832
|
+
declare function searchContacts(db: AffinityDb, query: string, filters?: ListContactsFilters, options?: AffinityListReadOptions): ContactListItem[];
|
|
833
|
+
|
|
834
|
+
declare function setContactLifecycle(db: AffinityDb, contactId: number, lifecycleState: ContactLifecycleState, options?: SetContactLifecycleOptions): ContactMutationReceipt;
|
|
835
|
+
|
|
836
|
+
declare function addDateAnchor(db: AffinityDb, input: AddDateAnchorInput): EventMutationReceipt;
|
|
837
|
+
|
|
838
|
+
declare function listUpcomingDates(db: AffinityDb, filters?: ListUpcomingDatesFilters, options?: AffinityListReadOptions): UpcomingDateRecord[];
|
|
839
|
+
|
|
840
|
+
declare function removeDateAnchor(db: AffinityDb, anchorEventId: number, removedAt?: number): EventMutationReceipt;
|
|
841
|
+
|
|
842
|
+
declare function reviseDateAnchor(db: AffinityDb, anchorEventId: number, patch: ReviseDateAnchorPatch, options?: ReviseDateAnchorOptions): EventMutationReceipt;
|
|
843
|
+
|
|
844
|
+
declare function getAffinityChart(db: AffinityDb, options?: AffinityChartReadOptions): AffinityChartRecord;
|
|
845
|
+
|
|
846
|
+
declare function getLinkDetail(db: AffinityDb, linkId: number, options?: LinkDetailReadOptions): LinkDetailRecord | null;
|
|
847
|
+
|
|
848
|
+
declare function getLinkTimeline(db: AffinityDb, linkId: number, options?: ContactJournalReadOptions): EventRecord[];
|
|
849
|
+
|
|
850
|
+
declare function listObservedLinks(db: AffinityDb, filters?: LinkListReadFilters, options?: AffinityListReadOptions): LinkListItem[];
|
|
851
|
+
|
|
852
|
+
declare function listOwnerSocialLinks(db: AffinityDb, filters?: LinkListReadFilters, options?: AffinityListReadOptions): LinkListItem[];
|
|
853
|
+
|
|
854
|
+
declare function listProgressionReadiness(db: AffinityDb, filters?: {
|
|
855
|
+
kind?: LinkKind;
|
|
856
|
+
}, options?: AffinityListReadOptions): LinkListItem[];
|
|
857
|
+
|
|
858
|
+
declare function listRadar(db: AffinityDb, filters?: LinkListReadFilters, options?: AffinityListReadOptions): RadarRecord[];
|
|
859
|
+
|
|
860
|
+
declare function overrideLinkState(db: AffinityDb, linkId: number, state: LinkState, options?: LinkMutationOptions): LinkMutationReceipt;
|
|
861
|
+
|
|
862
|
+
declare function removeStructuralTie(db: AffinityDb, tieId: number, removedAt?: number): LinkMutationReceipt;
|
|
863
|
+
|
|
864
|
+
declare function reviseBond(db: AffinityDb, linkId: number, bond: string | null, options?: LinkMutationOptions): LinkMutationReceipt;
|
|
865
|
+
|
|
866
|
+
declare function seedSocialLink(db: AffinityDb, input: SeedSocialLinkInput): LinkMutationReceipt;
|
|
867
|
+
|
|
868
|
+
declare function setStructuralTie(db: AffinityDb, input: SetStructuralTieInput): LinkMutationReceipt;
|
|
869
|
+
|
|
870
|
+
declare function getMergeHistory(db: AffinityDb, contactId: number, options?: AffinityListReadOptions): MergeHistoryRecord[];
|
|
871
|
+
|
|
872
|
+
declare function mergeContacts(db: AffinityDb, input: MergeContactsInput): MergeReceipt;
|
|
873
|
+
|
|
874
|
+
declare function getContactJournal(db: AffinityDb, contactId: number, options?: ContactJournalReadOptions): EventRecord[];
|
|
875
|
+
|
|
876
|
+
declare function listMoments(db: AffinityDb, filters?: ListMomentsFilters, options?: AffinityListReadOptions): MomentRecord[];
|
|
877
|
+
|
|
878
|
+
declare function listOpenCommitments(db: AffinityDb, filters?: ListOpenCommitmentsFilters, options?: AffinityListReadOptions): CommitmentRecord[];
|
|
879
|
+
|
|
880
|
+
declare function recordCommitment(db: AffinityDb, input: RecordCommitmentInput): EventMutationReceipt;
|
|
881
|
+
|
|
882
|
+
declare function recordInteraction(db: AffinityDb, input: RecordInteractionInput): EventMutationReceipt;
|
|
883
|
+
|
|
884
|
+
declare function recordMilestone(db: AffinityDb, input: RecordMilestoneInput): EventMutationReceipt;
|
|
885
|
+
|
|
886
|
+
declare function recordObservation(db: AffinityDb, input: RecordObservationInput): EventMutationReceipt;
|
|
887
|
+
|
|
888
|
+
declare function recordTransaction(db: AffinityDb, input: RecordTransactionInput): EventMutationReceipt;
|
|
889
|
+
|
|
890
|
+
declare function resolveCommitment(db: AffinityDb, commitmentEventId: number, resolution: CommitmentResolutionKind, options?: ResolveCommitmentOptions): EventMutationReceipt;
|
|
891
|
+
|
|
892
|
+
declare const read_getAffinityChart: typeof getAffinityChart;
|
|
893
|
+
declare const read_getContactJournal: typeof getContactJournal;
|
|
894
|
+
declare const read_getContactProfile: typeof getContactProfile;
|
|
895
|
+
declare const read_getLinkDetail: typeof getLinkDetail;
|
|
896
|
+
declare const read_getLinkTimeline: typeof getLinkTimeline;
|
|
897
|
+
declare const read_getMergeHistory: typeof getMergeHistory;
|
|
898
|
+
declare const read_getOwnerProfile: typeof getOwnerProfile;
|
|
899
|
+
declare const read_listContacts: typeof listContacts;
|
|
900
|
+
declare const read_listDuplicateCandidates: typeof listDuplicateCandidates;
|
|
901
|
+
declare const read_listMoments: typeof listMoments;
|
|
902
|
+
declare const read_listObservedLinks: typeof listObservedLinks;
|
|
903
|
+
declare const read_listOpenCommitments: typeof listOpenCommitments;
|
|
904
|
+
declare const read_listOwnerSocialLinks: typeof listOwnerSocialLinks;
|
|
905
|
+
declare const read_listProgressionReadiness: typeof listProgressionReadiness;
|
|
906
|
+
declare const read_listRadar: typeof listRadar;
|
|
907
|
+
declare const read_listUpcomingDates: typeof listUpcomingDates;
|
|
908
|
+
declare const read_searchContacts: typeof searchContacts;
|
|
909
|
+
declare namespace read {
|
|
910
|
+
export { read_getAffinityChart as getAffinityChart, read_getContactJournal as getContactJournal, read_getContactProfile as getContactProfile, read_getLinkDetail as getLinkDetail, read_getLinkTimeline as getLinkTimeline, read_getMergeHistory as getMergeHistory, read_getOwnerProfile as getOwnerProfile, read_listContacts as listContacts, 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 };
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
interface AffinitySoulTrait {
|
|
914
|
+
principle: string;
|
|
915
|
+
provenance: string;
|
|
916
|
+
}
|
|
917
|
+
interface AffinitySoul {
|
|
918
|
+
slug: string;
|
|
919
|
+
name: string;
|
|
920
|
+
description: string;
|
|
921
|
+
essence: string;
|
|
922
|
+
traits: readonly AffinitySoulTrait[];
|
|
923
|
+
}
|
|
924
|
+
declare const affinitySoulEssence = "You think like a disciplined gardener of relationship truth whose main instrument is Affinity. Your job is not to sound warm, strategic, or emotionally intelligent in the abstract. Your job is to keep the system's representation of people, ties, social links, journal evidence, obligations, and recurring salience true enough that decisions made from it stay good over time. You are always asking: what actually happened, what kind of truth is this, what is still ambiguous, and what is the smallest honest move that will leave the graph cleaner and more useful tomorrow than it is today.\n\nYour first boundary is evidence. Affinity is not a place for wishful narration or flattering reconstruction. A relationship does not become deeper because someone hopes it is deep. A contact does not become certain because a name sounds familiar. A past does not become cleaner because fake journal entries are backfilled to justify a desired Rank, Affinity, or Trust. You prefer one honest seed over synthetic history, one exact identity over a fuzzy guess, and one explicit clarification over a confident mistake.\n\nYour second boundary is type of truth. Structural ties, owner-facing social links, observed third-party links, commitments, recurring dates, attributes, and bond interpretation all exist for different reasons. Work history is not family structure. Observation is not direct intimacy. A promise is not a conversation summary. A birthday is not just another attribute. A Bond is a narrative reading of a link, not the same thing as the link itself. Affinity becomes powerful only when those truths stay separate and the right tool is used for the right layer.\n\nYour third boundary is between declared fact and derived mechanics. The system owns what it derives: Rank, hidden Affinity, Trust movement, Moments, drift, readiness, bridge significance, and Radar signals. You read those surfaces seriously, but you do not worship them or try to narratively override them. A score is a cue to inspect context, not permission to act blindly. Review surfaces help the operator notice, prioritize, and remember; they do not replace judgment.\n\nYou also think in rhythms. Affinity is not only for dramatic relationship beats. Its value comes from maintenance: keeping identities clean, resolving duplicates carefully, recording direct evidence honestly, honoring commitments, tending important dates, and checking Radar before drift becomes neglect. Whether the operator is tending friendships, clients, collaborators, recruits, patients, referral networks, or AI-assisted memory, the mission is the same: cultivate a relationship graph that stays trustworthy, legible, and alive over time.";
|
|
925
|
+
declare const affinitySoulTraits: {
|
|
926
|
+
principle: string;
|
|
927
|
+
provenance: string;
|
|
928
|
+
}[];
|
|
929
|
+
declare const affinitySoul: AffinitySoul;
|
|
930
|
+
declare function renderAffinitySoulPromptFoundation(soul?: AffinitySoul): string;
|
|
931
|
+
|
|
932
|
+
type soul_AffinitySoul = AffinitySoul;
|
|
933
|
+
type soul_AffinitySoulTrait = AffinitySoulTrait;
|
|
934
|
+
declare const soul_affinitySoul: typeof affinitySoul;
|
|
935
|
+
declare const soul_affinitySoulEssence: typeof affinitySoulEssence;
|
|
936
|
+
declare const soul_affinitySoulTraits: typeof affinitySoulTraits;
|
|
937
|
+
declare const soul_renderAffinitySoulPromptFoundation: typeof renderAffinitySoulPromptFoundation;
|
|
938
|
+
declare namespace soul {
|
|
939
|
+
export { type soul_AffinitySoul as AffinitySoul, type soul_AffinitySoulTrait as AffinitySoulTrait, soul_affinitySoul as affinitySoul, soul_affinitySoulEssence as affinitySoulEssence, soul_affinitySoulTraits as affinitySoulTraits, soul_renderAffinitySoulPromptFoundation as renderAffinitySoulPromptFoundation };
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
declare const bootstrapAndColdStartSkill: {
|
|
943
|
+
name: string;
|
|
944
|
+
description: string;
|
|
945
|
+
content: string;
|
|
946
|
+
};
|
|
947
|
+
|
|
948
|
+
declare const captureTransactionsAndCommercialEventsSkill: {
|
|
949
|
+
name: string;
|
|
950
|
+
description: string;
|
|
951
|
+
content: string;
|
|
952
|
+
};
|
|
953
|
+
|
|
954
|
+
declare const identifyAndLocateContactsSkill: {
|
|
955
|
+
name: string;
|
|
956
|
+
description: string;
|
|
957
|
+
content: string;
|
|
958
|
+
};
|
|
959
|
+
|
|
960
|
+
declare const importHistoryWithoutFakingEvidenceSkill: {
|
|
961
|
+
name: string;
|
|
962
|
+
description: string;
|
|
963
|
+
content: string;
|
|
964
|
+
};
|
|
965
|
+
|
|
966
|
+
declare const managePromisesAndAgreementsSkill: {
|
|
967
|
+
name: string;
|
|
968
|
+
description: string;
|
|
969
|
+
content: string;
|
|
970
|
+
};
|
|
971
|
+
|
|
972
|
+
declare const manageRecurringDatesAndRemindersSkill: {
|
|
973
|
+
name: string;
|
|
974
|
+
description: string;
|
|
975
|
+
content: string;
|
|
976
|
+
};
|
|
977
|
+
|
|
978
|
+
declare const modelStructureOrgsAndHouseholdsSkill: {
|
|
979
|
+
name: string;
|
|
980
|
+
description: string;
|
|
981
|
+
content: string;
|
|
982
|
+
};
|
|
983
|
+
|
|
984
|
+
declare const recordDirectEvidenceWellSkill: {
|
|
985
|
+
name: string;
|
|
986
|
+
description: string;
|
|
987
|
+
content: string;
|
|
988
|
+
};
|
|
989
|
+
|
|
990
|
+
declare const recordObservationsAndReferralsSkill: {
|
|
991
|
+
name: string;
|
|
992
|
+
description: string;
|
|
993
|
+
content: string;
|
|
994
|
+
};
|
|
995
|
+
|
|
996
|
+
declare const reconcileDuplicatesAndMergeSafelySkill: {
|
|
997
|
+
name: string;
|
|
998
|
+
description: string;
|
|
999
|
+
content: string;
|
|
1000
|
+
};
|
|
1001
|
+
|
|
1002
|
+
declare const reviewRadarProgressionAndGraphSkill: {
|
|
1003
|
+
name: string;
|
|
1004
|
+
description: string;
|
|
1005
|
+
content: string;
|
|
1006
|
+
};
|
|
1007
|
+
|
|
1008
|
+
interface AffinitySkill {
|
|
1009
|
+
name: string;
|
|
1010
|
+
description: string;
|
|
1011
|
+
content: string;
|
|
1012
|
+
}
|
|
1013
|
+
type AffinitySkillRegistry = readonly AffinitySkill[];
|
|
1014
|
+
declare function defineAffinitySkill<TSkill extends AffinitySkill>(skill: TSkill): TSkill;
|
|
1015
|
+
|
|
1016
|
+
declare const affinitySkills: {
|
|
1017
|
+
name: string;
|
|
1018
|
+
description: string;
|
|
1019
|
+
content: string;
|
|
1020
|
+
}[];
|
|
1021
|
+
declare function listAffinitySkills(): AffinitySkillRegistry;
|
|
1022
|
+
declare function getAffinitySkillByName(name: string): {
|
|
1023
|
+
name: string;
|
|
1024
|
+
description: string;
|
|
1025
|
+
content: string;
|
|
1026
|
+
} | null;
|
|
1027
|
+
|
|
1028
|
+
type index$1_AffinitySkill = AffinitySkill;
|
|
1029
|
+
type index$1_AffinitySkillRegistry = AffinitySkillRegistry;
|
|
1030
|
+
declare const index$1_affinitySkills: typeof affinitySkills;
|
|
1031
|
+
declare const index$1_bootstrapAndColdStartSkill: typeof bootstrapAndColdStartSkill;
|
|
1032
|
+
declare const index$1_captureTransactionsAndCommercialEventsSkill: typeof captureTransactionsAndCommercialEventsSkill;
|
|
1033
|
+
declare const index$1_defineAffinitySkill: typeof defineAffinitySkill;
|
|
1034
|
+
declare const index$1_getAffinitySkillByName: typeof getAffinitySkillByName;
|
|
1035
|
+
declare const index$1_identifyAndLocateContactsSkill: typeof identifyAndLocateContactsSkill;
|
|
1036
|
+
declare const index$1_importHistoryWithoutFakingEvidenceSkill: typeof importHistoryWithoutFakingEvidenceSkill;
|
|
1037
|
+
declare const index$1_listAffinitySkills: typeof listAffinitySkills;
|
|
1038
|
+
declare const index$1_managePromisesAndAgreementsSkill: typeof managePromisesAndAgreementsSkill;
|
|
1039
|
+
declare const index$1_manageRecurringDatesAndRemindersSkill: typeof manageRecurringDatesAndRemindersSkill;
|
|
1040
|
+
declare const index$1_modelStructureOrgsAndHouseholdsSkill: typeof modelStructureOrgsAndHouseholdsSkill;
|
|
1041
|
+
declare const index$1_reconcileDuplicatesAndMergeSafelySkill: typeof reconcileDuplicatesAndMergeSafelySkill;
|
|
1042
|
+
declare const index$1_recordDirectEvidenceWellSkill: typeof recordDirectEvidenceWellSkill;
|
|
1043
|
+
declare const index$1_recordObservationsAndReferralsSkill: typeof recordObservationsAndReferralsSkill;
|
|
1044
|
+
declare const index$1_reviewRadarProgressionAndGraphSkill: typeof reviewRadarProgressionAndGraphSkill;
|
|
1045
|
+
declare namespace index$1 {
|
|
1046
|
+
export { type index$1_AffinitySkill as AffinitySkill, type index$1_AffinitySkillRegistry as AffinitySkillRegistry, index$1_affinitySkills as affinitySkills, index$1_bootstrapAndColdStartSkill as bootstrapAndColdStartSkill, index$1_captureTransactionsAndCommercialEventsSkill as captureTransactionsAndCommercialEventsSkill, index$1_defineAffinitySkill as defineAffinitySkill, index$1_getAffinitySkillByName as getAffinitySkillByName, index$1_identifyAndLocateContactsSkill as identifyAndLocateContactsSkill, index$1_importHistoryWithoutFakingEvidenceSkill as importHistoryWithoutFakingEvidenceSkill, index$1_listAffinitySkills as listAffinitySkills, index$1_managePromisesAndAgreementsSkill as managePromisesAndAgreementsSkill, index$1_manageRecurringDatesAndRemindersSkill as manageRecurringDatesAndRemindersSkill, index$1_modelStructureOrgsAndHouseholdsSkill as modelStructureOrgsAndHouseholdsSkill, index$1_reconcileDuplicatesAndMergeSafelySkill as reconcileDuplicatesAndMergeSafelySkill, index$1_recordDirectEvidenceWellSkill as recordDirectEvidenceWellSkill, index$1_recordObservationsAndReferralsSkill as recordObservationsAndReferralsSkill, index$1_reviewRadarProgressionAndGraphSkill as reviewRadarProgressionAndGraphSkill };
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
type ToolEntityKind = "contact" | "identity" | "link" | "event" | "attribute";
|
|
1050
|
+
type ToolOutcomeKind = "success" | "no_op" | "needs_clarification" | "error";
|
|
1051
|
+
type ToolErrorCode = "clarification_needed" | "conflict" | "constraint_violation" | "invalid_input" | "invalid_state" | "not_found" | "system_error" | "unsupported_target";
|
|
1052
|
+
type ToolErrorKind = "domain" | "protocol" | "system";
|
|
1053
|
+
type ToolWarningCode = "already_in_state" | "derived_value_used" | "empty_result" | "partial_match" | "unchanged";
|
|
1054
|
+
type ToolClarificationCode = "ambiguous_target" | "missing_required_choice" | "multiple_plausible_matches";
|
|
1055
|
+
type ToolNextStepHintKind = "ask_user" | "inspect_item" | "review_view" | "retry_with" | "use_tool";
|
|
1056
|
+
interface ToolEntityRef {
|
|
1057
|
+
kind: ToolEntityKind;
|
|
1058
|
+
id: number;
|
|
1059
|
+
title?: string | undefined;
|
|
1060
|
+
subtitle?: string | undefined;
|
|
1061
|
+
state?: ContactLifecycleState | EventType | LinkKind | LinkState | ContactKind | string | null | undefined;
|
|
1062
|
+
}
|
|
1063
|
+
interface ToolListItem extends ToolEntityRef {
|
|
1064
|
+
snippet?: string | undefined;
|
|
1065
|
+
}
|
|
1066
|
+
interface ToolWarning {
|
|
1067
|
+
code: ToolWarningCode;
|
|
1068
|
+
message: string;
|
|
1069
|
+
}
|
|
1070
|
+
interface ToolNextStepHint {
|
|
1071
|
+
kind: ToolNextStepHintKind;
|
|
1072
|
+
message: string;
|
|
1073
|
+
tool?: string | undefined;
|
|
1074
|
+
suggestedInput?: Record<string, unknown> | undefined;
|
|
1075
|
+
}
|
|
1076
|
+
interface ToolBaseResult {
|
|
1077
|
+
ok: boolean;
|
|
1078
|
+
outcome: ToolOutcomeKind;
|
|
1079
|
+
summary: string;
|
|
1080
|
+
entities: ToolEntityRef[];
|
|
1081
|
+
warnings?: ToolWarning[] | undefined;
|
|
1082
|
+
next?: ToolNextStepHint[] | undefined;
|
|
1083
|
+
}
|
|
1084
|
+
interface ToolSuccess<TData> extends ToolBaseResult {
|
|
1085
|
+
ok: true;
|
|
1086
|
+
outcome: "success" | "no_op";
|
|
1087
|
+
data: TData;
|
|
1088
|
+
}
|
|
1089
|
+
interface ToolNeedsClarification extends ToolBaseResult {
|
|
1090
|
+
ok: false;
|
|
1091
|
+
outcome: "needs_clarification";
|
|
1092
|
+
clarification: {
|
|
1093
|
+
code: ToolClarificationCode;
|
|
1094
|
+
question: string;
|
|
1095
|
+
missing: string[];
|
|
1096
|
+
options?: Array<{
|
|
1097
|
+
label: string;
|
|
1098
|
+
value: number | string;
|
|
1099
|
+
}> | undefined;
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
interface ToolFailure extends ToolBaseResult {
|
|
1103
|
+
ok: false;
|
|
1104
|
+
outcome: "error";
|
|
1105
|
+
error: {
|
|
1106
|
+
kind: ToolErrorKind;
|
|
1107
|
+
code: ToolErrorCode;
|
|
1108
|
+
message: string;
|
|
1109
|
+
recovery?: string | undefined;
|
|
1110
|
+
details?: Record<string, unknown> | undefined;
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
type ToolResult<TData> = ToolFailure | ToolNeedsClarification | ToolSuccess<TData>;
|
|
1114
|
+
interface ToolResultOptions {
|
|
1115
|
+
entities?: ToolEntityRef[] | undefined;
|
|
1116
|
+
next?: ToolNextStepHint[] | undefined;
|
|
1117
|
+
warnings?: ToolWarning[] | undefined;
|
|
1118
|
+
}
|
|
1119
|
+
declare function toolWarning(code: ToolWarningCode, message: string): ToolWarning;
|
|
1120
|
+
declare function toolSuccess<TData>(summary: string, data: TData, options?: ToolResultOptions): ToolSuccess<TData>;
|
|
1121
|
+
declare function toolNoOp<TData>(summary: string, data: TData, options?: ToolResultOptions): ToolSuccess<TData>;
|
|
1122
|
+
interface ToolClarificationOptions extends ToolResultOptions {
|
|
1123
|
+
options?: Array<{
|
|
1124
|
+
label: string;
|
|
1125
|
+
value: number | string;
|
|
1126
|
+
}> | undefined;
|
|
1127
|
+
}
|
|
1128
|
+
declare function toolNeedsClarification(code: ToolClarificationCode, question: string, missing: string[], options?: ToolClarificationOptions): ToolNeedsClarification;
|
|
1129
|
+
interface ToolFailureOptions extends ToolResultOptions {
|
|
1130
|
+
details?: Record<string, unknown> | undefined;
|
|
1131
|
+
recovery?: string | undefined;
|
|
1132
|
+
}
|
|
1133
|
+
declare function toolFailure(kind: ToolErrorKind, code: ToolErrorCode, summary: string, message: string, options?: ToolFailureOptions): ToolFailure;
|
|
1134
|
+
|
|
1135
|
+
type ToolInputDescriptions = Readonly<Record<string, string>>;
|
|
1136
|
+
type ToolOutputDescription = string;
|
|
1137
|
+
type JsonSchemaType = "array" | "boolean" | "integer" | "null" | "number" | "object" | "string";
|
|
1138
|
+
interface JsonSchema {
|
|
1139
|
+
type?: JsonSchemaType | undefined;
|
|
1140
|
+
description?: string | undefined;
|
|
1141
|
+
enum?: ReadonlyArray<boolean | number | string | null> | undefined;
|
|
1142
|
+
const?: boolean | number | string | null;
|
|
1143
|
+
items?: JsonSchema | undefined;
|
|
1144
|
+
properties?: Readonly<Record<string, JsonSchema>> | undefined;
|
|
1145
|
+
required?: ReadonlyArray<string> | undefined;
|
|
1146
|
+
additionalProperties?: boolean | undefined;
|
|
1147
|
+
oneOf?: ReadonlyArray<JsonSchema> | undefined;
|
|
1148
|
+
anyOf?: ReadonlyArray<JsonSchema> | undefined;
|
|
1149
|
+
}
|
|
1150
|
+
type ToolSideEffects = "none" | "writes_state";
|
|
1151
|
+
interface AffinityToolDefinition<TInput, TResult extends ToolResult<unknown>> {
|
|
1152
|
+
name: string;
|
|
1153
|
+
description: string;
|
|
1154
|
+
whenToUse: string;
|
|
1155
|
+
whenNotToUse?: string | undefined;
|
|
1156
|
+
sideEffects: ToolSideEffects;
|
|
1157
|
+
readOnly: boolean;
|
|
1158
|
+
supportsClarification: boolean;
|
|
1159
|
+
targetKinds: readonly string[];
|
|
1160
|
+
inputDescriptions: ToolInputDescriptions;
|
|
1161
|
+
outputDescription: ToolOutputDescription;
|
|
1162
|
+
inputSchema: JsonSchema;
|
|
1163
|
+
handler: (db: AffinityDb, input: TInput) => TResult;
|
|
1164
|
+
}
|
|
1165
|
+
type ToolDefinitionRegistry = readonly AffinityToolDefinition<never, ToolResult<unknown>>[];
|
|
1166
|
+
declare function defineAffinityTool<TInput, TResult extends ToolResult<unknown>>(definition: AffinityToolDefinition<TInput, TResult>): AffinityToolDefinition<TInput, TResult>;
|
|
1167
|
+
declare function stringSchema(description: string, options?: Partial<JsonSchema>): JsonSchema;
|
|
1168
|
+
declare function numberSchema(description: string, options?: Partial<JsonSchema>): JsonSchema;
|
|
1169
|
+
declare function integerSchema(description: string, options?: Partial<JsonSchema>): JsonSchema;
|
|
1170
|
+
declare function booleanSchema(description: string, options?: Partial<JsonSchema>): JsonSchema;
|
|
1171
|
+
declare function enumSchema(description: string, values: ReadonlyArray<boolean | number | string | null>): JsonSchema;
|
|
1172
|
+
declare function literalSchema(value: boolean | number | string | null, description?: string): JsonSchema;
|
|
1173
|
+
declare function arraySchema(items: JsonSchema, description: string): JsonSchema;
|
|
1174
|
+
declare function objectSchema(properties: Record<string, JsonSchema>, required: ReadonlyArray<string>, description?: string): JsonSchema;
|
|
1175
|
+
declare function nullableStringSchema(description: string): JsonSchema;
|
|
1176
|
+
declare function oneOfSchema(schemas: ReadonlyArray<JsonSchema>, description?: string): JsonSchema;
|
|
1177
|
+
|
|
1178
|
+
type ContactLocator = {
|
|
1179
|
+
contactId: number;
|
|
1180
|
+
} | {
|
|
1181
|
+
identity: {
|
|
1182
|
+
type: string;
|
|
1183
|
+
value: string;
|
|
1184
|
+
};
|
|
1185
|
+
};
|
|
1186
|
+
type LinkLocator = {
|
|
1187
|
+
linkId: number;
|
|
1188
|
+
} | {
|
|
1189
|
+
endpoints: {
|
|
1190
|
+
fromContactId: number;
|
|
1191
|
+
toContactId: number;
|
|
1192
|
+
kind?: string | undefined;
|
|
1193
|
+
role?: string | null | undefined;
|
|
1194
|
+
isStructural?: boolean | undefined;
|
|
1195
|
+
};
|
|
1196
|
+
};
|
|
1197
|
+
type ResolvedTarget<T> = {
|
|
1198
|
+
ok: true;
|
|
1199
|
+
value: T;
|
|
1200
|
+
} | {
|
|
1201
|
+
ok: false;
|
|
1202
|
+
result: ToolFailure | ToolNeedsClarification;
|
|
1203
|
+
};
|
|
1204
|
+
declare function resolveContactLocator(db: AffinityDb, locator: ContactLocator, field?: string): ResolvedTarget<ContactRow>;
|
|
1205
|
+
declare function resolveLinkLocator(db: AffinityDb, locator: LinkLocator, field?: string): ResolvedTarget<LinkRow>;
|
|
1206
|
+
declare function mapErrorToToolFailure(error: unknown, summary?: string): ToolFailure;
|
|
1207
|
+
declare function withToolHandling<TData>(operation: () => ToolResult<TData>, summary?: string): ToolResult<TData>;
|
|
1208
|
+
|
|
1209
|
+
type InspectAffinityItemToolInput = {
|
|
1210
|
+
kind: "owner_profile";
|
|
1211
|
+
topLinksLimit?: number;
|
|
1212
|
+
} | {
|
|
1213
|
+
kind: "contact_profile";
|
|
1214
|
+
contact: ContactLocator;
|
|
1215
|
+
topLinksLimit?: number;
|
|
1216
|
+
} | {
|
|
1217
|
+
kind: "link";
|
|
1218
|
+
link: LinkLocator;
|
|
1219
|
+
recentEventsLimit?: number;
|
|
1220
|
+
};
|
|
1221
|
+
type InspectAffinityItemToolData = {
|
|
1222
|
+
kind: "owner_profile";
|
|
1223
|
+
detail: ContactProfileRecord;
|
|
1224
|
+
} | {
|
|
1225
|
+
kind: "contact_profile";
|
|
1226
|
+
detail: ContactProfileRecord;
|
|
1227
|
+
} | {
|
|
1228
|
+
kind: "link";
|
|
1229
|
+
detail: LinkDetailRecord;
|
|
1230
|
+
};
|
|
1231
|
+
type InspectAffinityItemToolResult = ToolResult<InspectAffinityItemToolData>;
|
|
1232
|
+
declare function inspectAffinityItemToolHandler(db: AffinityDb, input: InspectAffinityItemToolInput): InspectAffinityItemToolResult;
|
|
1233
|
+
declare const inspectAffinityItemTool: AffinityToolDefinition<InspectAffinityItemToolInput, InspectAffinityItemToolResult>;
|
|
1234
|
+
|
|
1235
|
+
interface MutationToolData<TPrimary> {
|
|
1236
|
+
action: string;
|
|
1237
|
+
primary: TPrimary;
|
|
1238
|
+
created: MutationReceipt<TPrimary>["created"];
|
|
1239
|
+
updated: MutationReceipt<TPrimary>["updated"];
|
|
1240
|
+
archived: MutationReceipt<TPrimary>["archived"];
|
|
1241
|
+
removed: MutationReceipt<TPrimary>["removed"];
|
|
1242
|
+
affectedLinks: number[];
|
|
1243
|
+
derivedEffects: MutationReceipt<TPrimary>["derivedEffects"];
|
|
1244
|
+
}
|
|
1245
|
+
declare function mutationToolResult<TPrimary>(action: string, receipt: MutationReceipt<TPrimary>, entitySummary: string): ToolResult<MutationToolData<TPrimary>>;
|
|
1246
|
+
|
|
1247
|
+
type AttributeTargetInput = {
|
|
1248
|
+
kind: "contact";
|
|
1249
|
+
contact: ContactLocator;
|
|
1250
|
+
} | {
|
|
1251
|
+
kind: "link";
|
|
1252
|
+
link: LinkLocator;
|
|
1253
|
+
};
|
|
1254
|
+
type ManageAttributeToolInput = {
|
|
1255
|
+
action: "set";
|
|
1256
|
+
target: AttributeTargetInput;
|
|
1257
|
+
name: string;
|
|
1258
|
+
value: string | null;
|
|
1259
|
+
} | {
|
|
1260
|
+
action: "unset";
|
|
1261
|
+
target: AttributeTargetInput;
|
|
1262
|
+
name: string;
|
|
1263
|
+
removedAt?: number;
|
|
1264
|
+
} | {
|
|
1265
|
+
action: "replace";
|
|
1266
|
+
target: AttributeTargetInput;
|
|
1267
|
+
entries: AttributeEntry[];
|
|
1268
|
+
};
|
|
1269
|
+
type ManageAttributeToolResult = ToolResult<MutationToolData<AttributeRecord>>;
|
|
1270
|
+
declare function manageAttributeToolHandler(db: AffinityDb, input: ManageAttributeToolInput): ManageAttributeToolResult;
|
|
1271
|
+
declare const manageAttributeTool: AffinityToolDefinition<ManageAttributeToolInput, ManageAttributeToolResult>;
|
|
1272
|
+
|
|
1273
|
+
type ManageCommitmentToolInput = {
|
|
1274
|
+
action: "record";
|
|
1275
|
+
input: RecordCommitmentInput;
|
|
1276
|
+
} | {
|
|
1277
|
+
action: "resolve";
|
|
1278
|
+
commitmentEventId: number;
|
|
1279
|
+
resolution: CommitmentResolutionKind;
|
|
1280
|
+
options?: ResolveCommitmentOptions;
|
|
1281
|
+
};
|
|
1282
|
+
type ManageCommitmentToolResult = ToolResult<MutationToolData<EventRecord>>;
|
|
1283
|
+
declare function manageCommitmentToolHandler(db: AffinityDb, input: ManageCommitmentToolInput): ManageCommitmentToolResult;
|
|
1284
|
+
declare const manageCommitmentTool: AffinityToolDefinition<ManageCommitmentToolInput, ManageCommitmentToolResult>;
|
|
1285
|
+
|
|
1286
|
+
type ManageContactToolInput = {
|
|
1287
|
+
action: "create";
|
|
1288
|
+
input: CreateContactInput;
|
|
1289
|
+
} | {
|
|
1290
|
+
action: "revise";
|
|
1291
|
+
contact: ContactLocator;
|
|
1292
|
+
patch: ReviseContactPatch;
|
|
1293
|
+
} | {
|
|
1294
|
+
action: "set_lifecycle";
|
|
1295
|
+
contact: ContactLocator;
|
|
1296
|
+
lifecycleState: ContactLifecycleState;
|
|
1297
|
+
options?: SetContactLifecycleOptions;
|
|
1298
|
+
};
|
|
1299
|
+
type ManageContactToolResult = ToolResult<MutationToolData<ContactListItem>>;
|
|
1300
|
+
declare function manageContactToolHandler(db: AffinityDb, input: ManageContactToolInput): ManageContactToolResult;
|
|
1301
|
+
declare const manageContactTool: AffinityToolDefinition<ManageContactToolInput, ManageContactToolResult>;
|
|
1302
|
+
|
|
1303
|
+
type DateAnchorTargetInput = {
|
|
1304
|
+
kind: "contact";
|
|
1305
|
+
contact: ContactLocator;
|
|
1306
|
+
} | {
|
|
1307
|
+
kind: "link";
|
|
1308
|
+
link: LinkLocator;
|
|
1309
|
+
};
|
|
1310
|
+
type ManageDateAnchorToolInput = {
|
|
1311
|
+
action: "add";
|
|
1312
|
+
input: Omit<AddDateAnchorInput, "target"> & {
|
|
1313
|
+
target: DateAnchorTargetInput;
|
|
1314
|
+
};
|
|
1315
|
+
} | {
|
|
1316
|
+
action: "revise";
|
|
1317
|
+
anchorEventId: number;
|
|
1318
|
+
patch: ReviseDateAnchorPatch;
|
|
1319
|
+
options?: ReviseDateAnchorOptions;
|
|
1320
|
+
} | {
|
|
1321
|
+
action: "remove";
|
|
1322
|
+
anchorEventId: number;
|
|
1323
|
+
removedAt?: number;
|
|
1324
|
+
};
|
|
1325
|
+
type ManageDateAnchorToolResult = ToolResult<MutationToolData<EventRecord>>;
|
|
1326
|
+
declare function manageDateAnchorToolHandler(db: AffinityDb, input: ManageDateAnchorToolInput): ManageDateAnchorToolResult;
|
|
1327
|
+
declare const manageDateAnchorTool: AffinityToolDefinition<ManageDateAnchorToolInput, ManageDateAnchorToolResult>;
|
|
1328
|
+
|
|
1329
|
+
type ManageIdentityToolInput = {
|
|
1330
|
+
action: "add";
|
|
1331
|
+
contact: ContactLocator;
|
|
1332
|
+
input: AddIdentityInput;
|
|
1333
|
+
} | {
|
|
1334
|
+
action: "revise";
|
|
1335
|
+
identityId: number;
|
|
1336
|
+
patch: ReviseIdentityPatch;
|
|
1337
|
+
} | {
|
|
1338
|
+
action: "verify";
|
|
1339
|
+
identityId: number;
|
|
1340
|
+
verifiedAt?: number;
|
|
1341
|
+
} | {
|
|
1342
|
+
action: "remove";
|
|
1343
|
+
identityId: number;
|
|
1344
|
+
removedAt?: number;
|
|
1345
|
+
};
|
|
1346
|
+
type ManageIdentityToolResult = ToolResult<MutationToolData<IdentityRecord>>;
|
|
1347
|
+
declare function manageIdentityToolHandler(db: AffinityDb, input: ManageIdentityToolInput): ManageIdentityToolResult;
|
|
1348
|
+
declare const manageIdentityTool: AffinityToolDefinition<ManageIdentityToolInput, ManageIdentityToolResult>;
|
|
1349
|
+
|
|
1350
|
+
type ManageRelationshipToolInput = {
|
|
1351
|
+
action: "seed_social_link";
|
|
1352
|
+
from: ContactLocator;
|
|
1353
|
+
to: ContactLocator;
|
|
1354
|
+
input: Omit<SeedSocialLinkInput, "fromContactId" | "toContactId">;
|
|
1355
|
+
} | {
|
|
1356
|
+
action: "revise_bond";
|
|
1357
|
+
link: LinkLocator;
|
|
1358
|
+
bond: string | null;
|
|
1359
|
+
options?: LinkMutationOptions;
|
|
1360
|
+
} | {
|
|
1361
|
+
action: "override_state";
|
|
1362
|
+
link: LinkLocator;
|
|
1363
|
+
state: LinkState;
|
|
1364
|
+
options?: LinkMutationOptions;
|
|
1365
|
+
} | {
|
|
1366
|
+
action: "set_structural_tie";
|
|
1367
|
+
from: ContactLocator;
|
|
1368
|
+
to: ContactLocator;
|
|
1369
|
+
input: Omit<SetStructuralTieInput, "fromContactId" | "toContactId">;
|
|
1370
|
+
} | {
|
|
1371
|
+
action: "remove_structural_tie";
|
|
1372
|
+
link: LinkLocator;
|
|
1373
|
+
removedAt?: number;
|
|
1374
|
+
};
|
|
1375
|
+
type ManageRelationshipToolResult = ToolResult<MutationToolData<LinkListItem>>;
|
|
1376
|
+
declare function manageRelationshipToolHandler(db: AffinityDb, input: ManageRelationshipToolInput): ManageRelationshipToolResult;
|
|
1377
|
+
declare const manageRelationshipTool: AffinityToolDefinition<ManageRelationshipToolInput, ManageRelationshipToolResult>;
|
|
1378
|
+
|
|
1379
|
+
interface MergeContactsToolInput {
|
|
1380
|
+
winner: ContactLocator;
|
|
1381
|
+
loser: ContactLocator;
|
|
1382
|
+
reasonSummary?: string | null;
|
|
1383
|
+
now?: number;
|
|
1384
|
+
}
|
|
1385
|
+
type MergeContactsToolResult = ToolResult<MutationToolData<MergePrimary>>;
|
|
1386
|
+
declare function mergeContactsToolHandler(db: AffinityDb, input: MergeContactsToolInput): MergeContactsToolResult;
|
|
1387
|
+
declare const mergeContactsTool: AffinityToolDefinition<MergeContactsToolInput, MergeContactsToolResult>;
|
|
1388
|
+
|
|
1389
|
+
type RecordEventToolInput = {
|
|
1390
|
+
kind: "interaction";
|
|
1391
|
+
input: RecordInteractionInput;
|
|
1392
|
+
} | {
|
|
1393
|
+
kind: "observation";
|
|
1394
|
+
input: RecordObservationInput;
|
|
1395
|
+
} | {
|
|
1396
|
+
kind: "milestone";
|
|
1397
|
+
input: RecordMilestoneInput;
|
|
1398
|
+
} | {
|
|
1399
|
+
kind: "transaction";
|
|
1400
|
+
input: RecordTransactionInput;
|
|
1401
|
+
};
|
|
1402
|
+
type RecordEventToolResult = ToolResult<MutationToolData<EventRecord>>;
|
|
1403
|
+
declare function recordEventToolHandler(db: AffinityDb, input: RecordEventToolInput): RecordEventToolResult;
|
|
1404
|
+
declare const recordEventTool: AffinityToolDefinition<RecordEventToolInput, RecordEventToolResult>;
|
|
1405
|
+
|
|
1406
|
+
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";
|
|
1407
|
+
interface ReviewAffinityToolInput {
|
|
1408
|
+
view: ReviewAffinityToolView;
|
|
1409
|
+
contact?: ContactLocator;
|
|
1410
|
+
link?: LinkLocator;
|
|
1411
|
+
contactIds?: number[];
|
|
1412
|
+
kind?: ContactKind | LinkKind;
|
|
1413
|
+
lifecycleState?: ContactLifecycleState;
|
|
1414
|
+
linkState?: LinkState;
|
|
1415
|
+
includeOwner?: boolean;
|
|
1416
|
+
includeDormant?: boolean;
|
|
1417
|
+
includeArchived?: boolean;
|
|
1418
|
+
includeObserved?: boolean;
|
|
1419
|
+
eventTypes?: EventType[];
|
|
1420
|
+
momentKind?: EventMomentKind;
|
|
1421
|
+
commitmentType?: "promise" | "agreement";
|
|
1422
|
+
recurrenceKind?: EventRecurrenceKind;
|
|
1423
|
+
horizonDays?: number;
|
|
1424
|
+
exactOnly?: boolean;
|
|
1425
|
+
minScore?: number;
|
|
1426
|
+
since?: number;
|
|
1427
|
+
until?: number;
|
|
1428
|
+
limit?: number;
|
|
1429
|
+
offset?: number;
|
|
1430
|
+
}
|
|
1431
|
+
interface ReviewAffinityToolData {
|
|
1432
|
+
view: ReviewAffinityToolView;
|
|
1433
|
+
items: ToolListItem[];
|
|
1434
|
+
count: number;
|
|
1435
|
+
appliedFilters: Record<string, unknown>;
|
|
1436
|
+
chart?: AffinityChartRecord | undefined;
|
|
1437
|
+
}
|
|
1438
|
+
type ReviewAffinityToolResult = ToolResult<ReviewAffinityToolData>;
|
|
1439
|
+
declare function reviewAffinityToolHandler(db: AffinityDb, input: ReviewAffinityToolInput): ReviewAffinityToolResult;
|
|
1440
|
+
declare const reviewAffinityTool: AffinityToolDefinition<ReviewAffinityToolInput, ReviewAffinityToolResult>;
|
|
1441
|
+
|
|
1442
|
+
declare function toContactEntityRef(value: ContactCore | ContactListItem | ContactRow): ToolEntityRef;
|
|
1443
|
+
declare function toContactListToolItem(value: ContactCore | ContactListItem | ContactRow): ToolListItem;
|
|
1444
|
+
declare function toIdentityEntityRef(value: IdentityRecord): ToolEntityRef;
|
|
1445
|
+
declare function toIdentityListToolItem(value: IdentityRecord): ToolListItem;
|
|
1446
|
+
declare function toLinkEntityRef(value: LinkListItem | LinkRow): ToolEntityRef;
|
|
1447
|
+
declare function toLinkListToolItem(value: LinkListItem | LinkRow): ToolListItem;
|
|
1448
|
+
declare function toEventEntityRef(value: EventRecord): ToolEntityRef;
|
|
1449
|
+
declare function toEventListToolItem(value: EventRecord): ToolListItem;
|
|
1450
|
+
declare function toAttributeEntityRef(value: AttributeRecord): ToolEntityRef;
|
|
1451
|
+
declare function toAttributeListToolItem(value: AttributeRecord): ToolListItem;
|
|
1452
|
+
declare function toMutationRefEntity(ref: EntityRef): ToolEntityRef;
|
|
1453
|
+
declare function toReceiptEntityRefs<TPrimary>(receipt: MutationReceipt<TPrimary>): ToolEntityRef[];
|
|
1454
|
+
|
|
1455
|
+
interface SearchAffinityToolInput {
|
|
1456
|
+
query: string;
|
|
1457
|
+
kind?: ContactKind;
|
|
1458
|
+
lifecycleState?: ContactLifecycleState;
|
|
1459
|
+
includeOwner?: boolean;
|
|
1460
|
+
includeDormant?: boolean;
|
|
1461
|
+
limit?: number;
|
|
1462
|
+
offset?: number;
|
|
1463
|
+
}
|
|
1464
|
+
interface SearchAffinityToolData {
|
|
1465
|
+
query: string;
|
|
1466
|
+
items: ReturnType<typeof toContactListToolItem>[];
|
|
1467
|
+
count: number;
|
|
1468
|
+
}
|
|
1469
|
+
type SearchAffinityToolResult = ToolResult<SearchAffinityToolData>;
|
|
1470
|
+
declare function searchAffinityToolHandler(db: AffinityDb, input: SearchAffinityToolInput): SearchAffinityToolResult;
|
|
1471
|
+
declare const searchAffinityTool: AffinityToolDefinition<SearchAffinityToolInput, SearchAffinityToolResult>;
|
|
1472
|
+
|
|
1473
|
+
declare const affinityTools: (AffinityToolDefinition<InspectAffinityItemToolInput, InspectAffinityItemToolResult> | AffinityToolDefinition<ManageAttributeToolInput, ManageAttributeToolResult> | AffinityToolDefinition<ManageCommitmentToolInput, ManageCommitmentToolResult> | AffinityToolDefinition<ManageContactToolInput, ManageContactToolResult> | AffinityToolDefinition<ManageDateAnchorToolInput, ManageDateAnchorToolResult> | AffinityToolDefinition<ManageIdentityToolInput, ManageIdentityToolResult> | AffinityToolDefinition<ManageRelationshipToolInput, ManageRelationshipToolResult> | AffinityToolDefinition<MergeContactsToolInput, MergeContactsToolResult> | AffinityToolDefinition<RecordEventToolInput, RecordEventToolResult> | AffinityToolDefinition<ReviewAffinityToolInput, ReviewAffinityToolResult> | AffinityToolDefinition<SearchAffinityToolInput, SearchAffinityToolResult>)[];
|
|
1474
|
+
declare function listAffinityToolDefinitions(): (AffinityToolDefinition<InspectAffinityItemToolInput, InspectAffinityItemToolResult> | AffinityToolDefinition<ManageAttributeToolInput, ManageAttributeToolResult> | AffinityToolDefinition<ManageCommitmentToolInput, ManageCommitmentToolResult> | AffinityToolDefinition<ManageContactToolInput, ManageContactToolResult> | AffinityToolDefinition<ManageDateAnchorToolInput, ManageDateAnchorToolResult> | AffinityToolDefinition<ManageIdentityToolInput, ManageIdentityToolResult> | AffinityToolDefinition<ManageRelationshipToolInput, ManageRelationshipToolResult> | AffinityToolDefinition<MergeContactsToolInput, MergeContactsToolResult> | AffinityToolDefinition<RecordEventToolInput, RecordEventToolResult> | AffinityToolDefinition<ReviewAffinityToolInput, ReviewAffinityToolResult> | AffinityToolDefinition<SearchAffinityToolInput, SearchAffinityToolResult>)[];
|
|
1475
|
+
declare function getAffinityToolByName(name: string): AffinityToolDefinition<InspectAffinityItemToolInput, InspectAffinityItemToolResult> | AffinityToolDefinition<ManageAttributeToolInput, ManageAttributeToolResult> | AffinityToolDefinition<ManageCommitmentToolInput, ManageCommitmentToolResult> | AffinityToolDefinition<ManageContactToolInput, ManageContactToolResult> | AffinityToolDefinition<ManageDateAnchorToolInput, ManageDateAnchorToolResult> | AffinityToolDefinition<ManageIdentityToolInput, ManageIdentityToolResult> | AffinityToolDefinition<ManageRelationshipToolInput, ManageRelationshipToolResult> | AffinityToolDefinition<MergeContactsToolInput, MergeContactsToolResult> | AffinityToolDefinition<RecordEventToolInput, RecordEventToolResult> | AffinityToolDefinition<ReviewAffinityToolInput, ReviewAffinityToolResult> | AffinityToolDefinition<SearchAffinityToolInput, SearchAffinityToolResult> | null;
|
|
1476
|
+
|
|
1477
|
+
interface AffinityToolMapping {
|
|
1478
|
+
source: string;
|
|
1479
|
+
tool: string;
|
|
1480
|
+
action?: string;
|
|
1481
|
+
view?: string;
|
|
1482
|
+
notes?: string;
|
|
1483
|
+
}
|
|
1484
|
+
declare const affinityToolMappings: AffinityToolMapping[];
|
|
1485
|
+
|
|
1486
|
+
declare const searchAffinityToolName = "search_affinity";
|
|
1487
|
+
declare const reviewAffinityToolName = "review_affinity";
|
|
1488
|
+
declare const inspectAffinityItemToolName = "inspect_affinity_item";
|
|
1489
|
+
declare const manageContactToolName = "manage_contact";
|
|
1490
|
+
declare const mergeContactsToolName = "merge_contacts";
|
|
1491
|
+
declare const manageIdentityToolName = "manage_identity";
|
|
1492
|
+
declare const manageRelationshipToolName = "manage_relationship";
|
|
1493
|
+
declare const recordEventToolName = "record_event";
|
|
1494
|
+
declare const manageCommitmentToolName = "manage_commitment";
|
|
1495
|
+
declare const manageDateAnchorToolName = "manage_date_anchor";
|
|
1496
|
+
declare const manageAttributeToolName = "manage_attribute";
|
|
1497
|
+
|
|
1498
|
+
declare function summarizeCount(count: number, singular: string): string;
|
|
1499
|
+
|
|
1500
|
+
type index_AffinityToolDefinition<TInput, TResult extends ToolResult<unknown>> = AffinityToolDefinition<TInput, TResult>;
|
|
1501
|
+
type index_AffinityToolMapping = AffinityToolMapping;
|
|
1502
|
+
type index_ContactLocator = ContactLocator;
|
|
1503
|
+
type index_JsonSchema = JsonSchema;
|
|
1504
|
+
type index_JsonSchemaType = JsonSchemaType;
|
|
1505
|
+
type index_LinkLocator = LinkLocator;
|
|
1506
|
+
type index_MutationToolData<TPrimary> = MutationToolData<TPrimary>;
|
|
1507
|
+
type index_ResolvedTarget<T> = ResolvedTarget<T>;
|
|
1508
|
+
type index_ToolBaseResult = ToolBaseResult;
|
|
1509
|
+
type index_ToolDefinitionRegistry = ToolDefinitionRegistry;
|
|
1510
|
+
type index_ToolEntityKind = ToolEntityKind;
|
|
1511
|
+
type index_ToolEntityRef = ToolEntityRef;
|
|
1512
|
+
type index_ToolFailure = ToolFailure;
|
|
1513
|
+
type index_ToolInputDescriptions = ToolInputDescriptions;
|
|
1514
|
+
type index_ToolListItem = ToolListItem;
|
|
1515
|
+
type index_ToolNeedsClarification = ToolNeedsClarification;
|
|
1516
|
+
type index_ToolNextStepHint = ToolNextStepHint;
|
|
1517
|
+
type index_ToolOutcomeKind = ToolOutcomeKind;
|
|
1518
|
+
type index_ToolOutputDescription = ToolOutputDescription;
|
|
1519
|
+
type index_ToolResult<TData> = ToolResult<TData>;
|
|
1520
|
+
type index_ToolSideEffects = ToolSideEffects;
|
|
1521
|
+
type index_ToolSuccess<TData> = ToolSuccess<TData>;
|
|
1522
|
+
type index_ToolWarning = ToolWarning;
|
|
1523
|
+
declare const index_affinityToolMappings: typeof affinityToolMappings;
|
|
1524
|
+
declare const index_affinityTools: typeof affinityTools;
|
|
1525
|
+
declare const index_arraySchema: typeof arraySchema;
|
|
1526
|
+
declare const index_booleanSchema: typeof booleanSchema;
|
|
1527
|
+
declare const index_defineAffinityTool: typeof defineAffinityTool;
|
|
1528
|
+
declare const index_enumSchema: typeof enumSchema;
|
|
1529
|
+
declare const index_getAffinityToolByName: typeof getAffinityToolByName;
|
|
1530
|
+
declare const index_inspectAffinityItemTool: typeof inspectAffinityItemTool;
|
|
1531
|
+
declare const index_inspectAffinityItemToolHandler: typeof inspectAffinityItemToolHandler;
|
|
1532
|
+
declare const index_inspectAffinityItemToolName: typeof inspectAffinityItemToolName;
|
|
1533
|
+
declare const index_integerSchema: typeof integerSchema;
|
|
1534
|
+
declare const index_listAffinityToolDefinitions: typeof listAffinityToolDefinitions;
|
|
1535
|
+
declare const index_literalSchema: typeof literalSchema;
|
|
1536
|
+
declare const index_manageAttributeTool: typeof manageAttributeTool;
|
|
1537
|
+
declare const index_manageAttributeToolHandler: typeof manageAttributeToolHandler;
|
|
1538
|
+
declare const index_manageAttributeToolName: typeof manageAttributeToolName;
|
|
1539
|
+
declare const index_manageCommitmentTool: typeof manageCommitmentTool;
|
|
1540
|
+
declare const index_manageCommitmentToolHandler: typeof manageCommitmentToolHandler;
|
|
1541
|
+
declare const index_manageCommitmentToolName: typeof manageCommitmentToolName;
|
|
1542
|
+
declare const index_manageContactTool: typeof manageContactTool;
|
|
1543
|
+
declare const index_manageContactToolHandler: typeof manageContactToolHandler;
|
|
1544
|
+
declare const index_manageContactToolName: typeof manageContactToolName;
|
|
1545
|
+
declare const index_manageDateAnchorTool: typeof manageDateAnchorTool;
|
|
1546
|
+
declare const index_manageDateAnchorToolHandler: typeof manageDateAnchorToolHandler;
|
|
1547
|
+
declare const index_manageDateAnchorToolName: typeof manageDateAnchorToolName;
|
|
1548
|
+
declare const index_manageIdentityTool: typeof manageIdentityTool;
|
|
1549
|
+
declare const index_manageIdentityToolHandler: typeof manageIdentityToolHandler;
|
|
1550
|
+
declare const index_manageIdentityToolName: typeof manageIdentityToolName;
|
|
1551
|
+
declare const index_manageRelationshipTool: typeof manageRelationshipTool;
|
|
1552
|
+
declare const index_manageRelationshipToolHandler: typeof manageRelationshipToolHandler;
|
|
1553
|
+
declare const index_manageRelationshipToolName: typeof manageRelationshipToolName;
|
|
1554
|
+
declare const index_mapErrorToToolFailure: typeof mapErrorToToolFailure;
|
|
1555
|
+
declare const index_mergeContactsTool: typeof mergeContactsTool;
|
|
1556
|
+
declare const index_mergeContactsToolHandler: typeof mergeContactsToolHandler;
|
|
1557
|
+
declare const index_mergeContactsToolName: typeof mergeContactsToolName;
|
|
1558
|
+
declare const index_mutationToolResult: typeof mutationToolResult;
|
|
1559
|
+
declare const index_nullableStringSchema: typeof nullableStringSchema;
|
|
1560
|
+
declare const index_numberSchema: typeof numberSchema;
|
|
1561
|
+
declare const index_objectSchema: typeof objectSchema;
|
|
1562
|
+
declare const index_oneOfSchema: typeof oneOfSchema;
|
|
1563
|
+
declare const index_recordEventTool: typeof recordEventTool;
|
|
1564
|
+
declare const index_recordEventToolHandler: typeof recordEventToolHandler;
|
|
1565
|
+
declare const index_recordEventToolName: typeof recordEventToolName;
|
|
1566
|
+
declare const index_resolveContactLocator: typeof resolveContactLocator;
|
|
1567
|
+
declare const index_resolveLinkLocator: typeof resolveLinkLocator;
|
|
1568
|
+
declare const index_reviewAffinityTool: typeof reviewAffinityTool;
|
|
1569
|
+
declare const index_reviewAffinityToolHandler: typeof reviewAffinityToolHandler;
|
|
1570
|
+
declare const index_reviewAffinityToolName: typeof reviewAffinityToolName;
|
|
1571
|
+
declare const index_searchAffinityTool: typeof searchAffinityTool;
|
|
1572
|
+
declare const index_searchAffinityToolHandler: typeof searchAffinityToolHandler;
|
|
1573
|
+
declare const index_searchAffinityToolName: typeof searchAffinityToolName;
|
|
1574
|
+
declare const index_stringSchema: typeof stringSchema;
|
|
1575
|
+
declare const index_summarizeCount: typeof summarizeCount;
|
|
1576
|
+
declare const index_toAttributeEntityRef: typeof toAttributeEntityRef;
|
|
1577
|
+
declare const index_toAttributeListToolItem: typeof toAttributeListToolItem;
|
|
1578
|
+
declare const index_toContactEntityRef: typeof toContactEntityRef;
|
|
1579
|
+
declare const index_toContactListToolItem: typeof toContactListToolItem;
|
|
1580
|
+
declare const index_toEventEntityRef: typeof toEventEntityRef;
|
|
1581
|
+
declare const index_toEventListToolItem: typeof toEventListToolItem;
|
|
1582
|
+
declare const index_toIdentityEntityRef: typeof toIdentityEntityRef;
|
|
1583
|
+
declare const index_toIdentityListToolItem: typeof toIdentityListToolItem;
|
|
1584
|
+
declare const index_toLinkEntityRef: typeof toLinkEntityRef;
|
|
1585
|
+
declare const index_toLinkListToolItem: typeof toLinkListToolItem;
|
|
1586
|
+
declare const index_toMutationRefEntity: typeof toMutationRefEntity;
|
|
1587
|
+
declare const index_toReceiptEntityRefs: typeof toReceiptEntityRefs;
|
|
1588
|
+
declare const index_toolFailure: typeof toolFailure;
|
|
1589
|
+
declare const index_toolNeedsClarification: typeof toolNeedsClarification;
|
|
1590
|
+
declare const index_toolNoOp: typeof toolNoOp;
|
|
1591
|
+
declare const index_toolSuccess: typeof toolSuccess;
|
|
1592
|
+
declare const index_toolWarning: typeof toolWarning;
|
|
1593
|
+
declare const index_withToolHandling: typeof withToolHandling;
|
|
1594
|
+
declare namespace index {
|
|
1595
|
+
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_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_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 };
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
declare function addIdentity(db: AffinityDb, contactId: number, input: AddIdentityInput): IdentityMutationReceipt;
|
|
1599
|
+
|
|
1600
|
+
declare function removeIdentity(db: AffinityDb, identityId: number, removedAt?: number): IdentityMutationReceipt;
|
|
1601
|
+
|
|
1602
|
+
declare function reviseIdentity(db: AffinityDb, identityId: number, patch: ReviseIdentityPatch): IdentityMutationReceipt;
|
|
1603
|
+
|
|
1604
|
+
declare function verifyIdentity(db: AffinityDb, identityId: number, verifiedAt?: number): IdentityMutationReceipt;
|
|
1605
|
+
|
|
1606
|
+
declare function replaceAttributes(db: AffinityDb, target: AttributeTarget, entries: readonly AttributeEntry[]): AttributeMutationReceipt;
|
|
1607
|
+
|
|
1608
|
+
declare function setAttribute(db: AffinityDb, target: AttributeTarget, name: string, value: string | null): AttributeMutationReceipt;
|
|
1609
|
+
|
|
1610
|
+
declare function unsetAttribute(db: AffinityDb, target: AttributeTarget, name: string, removedAt?: number): AttributeMutationReceipt;
|
|
1611
|
+
|
|
1612
|
+
declare const write_addDateAnchor: typeof addDateAnchor;
|
|
1613
|
+
declare const write_addIdentity: typeof addIdentity;
|
|
1614
|
+
declare const write_createContact: typeof createContact;
|
|
1615
|
+
declare const write_mergeContacts: typeof mergeContacts;
|
|
1616
|
+
declare const write_overrideLinkState: typeof overrideLinkState;
|
|
1617
|
+
declare const write_recordCommitment: typeof recordCommitment;
|
|
1618
|
+
declare const write_recordInteraction: typeof recordInteraction;
|
|
1619
|
+
declare const write_recordMilestone: typeof recordMilestone;
|
|
1620
|
+
declare const write_recordObservation: typeof recordObservation;
|
|
1621
|
+
declare const write_recordTransaction: typeof recordTransaction;
|
|
1622
|
+
declare const write_removeDateAnchor: typeof removeDateAnchor;
|
|
1623
|
+
declare const write_removeIdentity: typeof removeIdentity;
|
|
1624
|
+
declare const write_removeStructuralTie: typeof removeStructuralTie;
|
|
1625
|
+
declare const write_replaceAttributes: typeof replaceAttributes;
|
|
1626
|
+
declare const write_resolveCommitment: typeof resolveCommitment;
|
|
1627
|
+
declare const write_reviseBond: typeof reviseBond;
|
|
1628
|
+
declare const write_reviseContact: typeof reviseContact;
|
|
1629
|
+
declare const write_reviseDateAnchor: typeof reviseDateAnchor;
|
|
1630
|
+
declare const write_reviseIdentity: typeof reviseIdentity;
|
|
1631
|
+
declare const write_seedSocialLink: typeof seedSocialLink;
|
|
1632
|
+
declare const write_setAttribute: typeof setAttribute;
|
|
1633
|
+
declare const write_setContactLifecycle: typeof setContactLifecycle;
|
|
1634
|
+
declare const write_setStructuralTie: typeof setStructuralTie;
|
|
1635
|
+
declare const write_unsetAttribute: typeof unsetAttribute;
|
|
1636
|
+
declare const write_verifyIdentity: typeof verifyIdentity;
|
|
1637
|
+
declare namespace write {
|
|
1638
|
+
export { write_addDateAnchor as addDateAnchor, write_addIdentity as addIdentity, write_createContact as createContact, 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_unsetAttribute as unsetAttribute, write_verifyIdentity as verifyIdentity };
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
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 };
|