@ghostpaw/affinity 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1452,8 +1452,8 @@ function searchContacts(db, query, filters, options) {
1452
1452
  GROUP BY c.id
1453
1453
  `;
1454
1454
  const rows = db.prepare(sql).all(
1455
- ...params,
1456
1455
  normalizedPattern,
1456
+ ...params,
1457
1457
  pattern,
1458
1458
  pattern,
1459
1459
  normalizedPattern
@@ -4598,7 +4598,9 @@ Your second boundary is type of truth. Structural ties, owner-facing social link
4598
4598
 
4599
4599
  Your 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.
4600
4600
 
4601
- You 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.`;
4601
+ You 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.
4602
+
4603
+ In practice, this means: search before you create, attach identities before you seed links, seed links before you record events, and anchor dates when they are mentioned \u2014 not later.`;
4602
4604
  var affinitySoulTraits = [
4603
4605
  {
4604
4606
  principle: "Honor evidence before narrative.",
@@ -4619,6 +4621,10 @@ var affinitySoulTraits = [
4619
4621
  {
4620
4622
  principle: "Protect relationship integrity over time.",
4621
4623
  provenance: "A good relationship memory is maintained, not merely captured. Clean identities, honest commitment resolution, careful merges, and recurring review keep the graph trustworthy across personal and business use cases."
4624
+ },
4625
+ {
4626
+ principle: "Follow the operational protocol.",
4627
+ provenance: "Search before you create \u2014 every time a person, company, or entity is mentioned, call search_affinity first; duplicates corrupt the entire graph. Attach identities (emails, phones, handles, URLs) with manage_identity, not manage_attribute \u2014 if it could locate a person, it is an identity. Seed links for every stated relationship on first mention with manage_relationship \u2014 do not wait for repeated evidence. Anchor recurring dates (birthdays, anniversaries, yearly events) immediately with manage_date_anchor \u2014 do not store them as attributes."
4622
4628
  }
4623
4629
  ];
4624
4630
  var affinitySoul = {
@@ -5849,48 +5855,38 @@ function affinityErrorCodeToToolCode(error) {
5849
5855
 
5850
5856
  // src/tools/inspect_affinity_item_tool.ts
5851
5857
  function contactLocatorSchema(description) {
5852
- return oneOfSchema(
5853
- [
5854
- objectSchema({ contactId: integerSchema("Exact contact id.") }, [
5855
- "contactId"
5856
- ]),
5857
- objectSchema(
5858
+ return {
5859
+ type: "object",
5860
+ properties: {
5861
+ contactId: integerSchema("Exact contact id."),
5862
+ identity: objectSchema(
5858
5863
  {
5859
- identity: objectSchema(
5860
- {
5861
- type: stringSchema("Identity type."),
5862
- value: stringSchema("Identity value.")
5863
- },
5864
- ["type", "value"],
5865
- "Contact identity locator."
5866
- )
5864
+ type: stringSchema("Identity type."),
5865
+ value: stringSchema("Identity value.")
5867
5866
  },
5868
- ["identity"]
5867
+ ["type", "value"],
5868
+ "Contact identity locator."
5869
5869
  )
5870
- ],
5870
+ },
5871
5871
  description
5872
- );
5872
+ };
5873
5873
  }
5874
5874
  function linkLocatorSchema(description) {
5875
- return oneOfSchema(
5876
- [
5877
- objectSchema({ linkId: integerSchema("Exact link id.") }, ["linkId"]),
5878
- objectSchema(
5875
+ return {
5876
+ type: "object",
5877
+ properties: {
5878
+ linkId: integerSchema("Exact link id."),
5879
+ endpoints: objectSchema(
5879
5880
  {
5880
- endpoints: objectSchema(
5881
- {
5882
- fromContactId: integerSchema("From contact id."),
5883
- toContactId: integerSchema("To contact id.")
5884
- },
5885
- ["fromContactId", "toContactId"],
5886
- "Endpoint-based link locator."
5887
- )
5881
+ fromContactId: integerSchema("From contact id."),
5882
+ toContactId: integerSchema("To contact id.")
5888
5883
  },
5889
- ["endpoints"]
5884
+ ["fromContactId", "toContactId"],
5885
+ "Endpoint-based link locator."
5890
5886
  )
5891
- ],
5887
+ },
5892
5888
  description
5893
- );
5889
+ };
5894
5890
  }
5895
5891
  function inspectAffinityItemToolHandler(db, input) {
5896
5892
  return withToolHandling(() => {
@@ -5983,32 +5979,23 @@ var inspectAffinityItemTool = defineAffinityTool({
5983
5979
  recentEventsLimit: "Optional recent-events cap for link detail."
5984
5980
  },
5985
5981
  outputDescription: "Returns one shaped detail object and dense entity references for the inspected item.",
5986
- inputSchema: oneOfSchema(
5987
- [
5988
- objectSchema(
5989
- {
5990
- kind: literalSchema("owner_profile"),
5991
- topLinksLimit: integerSchema("Optional top-links cap.")
5992
- },
5993
- ["kind"]
5982
+ inputSchema: objectSchema(
5983
+ {
5984
+ kind: enumSchema("What to inspect.", [
5985
+ "owner_profile",
5986
+ "contact_profile",
5987
+ "link"
5988
+ ]),
5989
+ contact: contactLocatorSchema(
5990
+ "Target contact. Required when kind=contact_profile. Provide contactId or identity."
5994
5991
  ),
5995
- objectSchema(
5996
- {
5997
- kind: literalSchema("contact_profile"),
5998
- contact: contactLocatorSchema("Target contact."),
5999
- topLinksLimit: integerSchema("Optional top-links cap.")
6000
- },
6001
- ["kind", "contact"]
5992
+ link: linkLocatorSchema(
5993
+ "Target link. Required when kind=link. Provide linkId or endpoints."
6002
5994
  ),
6003
- objectSchema(
6004
- {
6005
- kind: literalSchema("link"),
6006
- link: linkLocatorSchema("Target link."),
6007
- recentEventsLimit: integerSchema("Optional recent-events cap.")
6008
- },
6009
- ["kind", "link"]
6010
- )
6011
- ],
5995
+ topLinksLimit: integerSchema("Optional top-links cap."),
5996
+ recentEventsLimit: integerSchema("Optional recent-events cap.")
5997
+ },
5998
+ ["kind"],
6012
5999
  "Inspect one exact affinity item."
6013
6000
  ),
6014
6001
  handler: inspectAffinityItemToolHandler
@@ -6320,49 +6307,38 @@ function mutationToolResult(action, receipt, entitySummary) {
6320
6307
 
6321
6308
  // src/tools/manage_attribute_tool.ts
6322
6309
  function contactLocatorSchema2(description) {
6323
- return oneOfSchema(
6324
- [
6325
- objectSchema({ contactId: integerSchema("Exact contact id.") }, [
6326
- "contactId"
6327
- ]),
6328
- objectSchema(
6310
+ return {
6311
+ type: "object",
6312
+ properties: {
6313
+ contactId: integerSchema("Exact contact id."),
6314
+ identity: objectSchema(
6329
6315
  {
6330
- identity: objectSchema(
6331
- {
6332
- type: stringSchema("Identity type."),
6333
- value: stringSchema("Identity value.")
6334
- },
6335
- ["type", "value"]
6336
- )
6316
+ type: stringSchema("Identity type."),
6317
+ value: stringSchema("Identity value.")
6337
6318
  },
6338
- ["identity"]
6319
+ ["type", "value"],
6320
+ "Contact identity locator."
6339
6321
  )
6340
- ],
6322
+ },
6341
6323
  description
6342
- );
6324
+ };
6343
6325
  }
6344
6326
  function linkLocatorSchema2(description) {
6345
- return oneOfSchema(
6346
- [
6347
- objectSchema({ linkId: integerSchema("Exact link id.") }, ["linkId"]),
6348
- objectSchema(
6327
+ return {
6328
+ type: "object",
6329
+ properties: {
6330
+ linkId: integerSchema("Exact link id."),
6331
+ endpoints: objectSchema(
6349
6332
  {
6350
- endpoints: objectSchema(
6351
- {
6352
- fromContactId: integerSchema("From contact id."),
6353
- toContactId: integerSchema("To contact id."),
6354
- kind: stringSchema("Optional link kind."),
6355
- role: stringSchema("Optional link role."),
6356
- isStructural: booleanSchema("Optional structural discriminator.")
6357
- },
6358
- ["fromContactId", "toContactId"]
6359
- )
6333
+ fromContactId: integerSchema("From contact id."),
6334
+ toContactId: integerSchema("To contact id.")
6360
6335
  },
6361
- ["endpoints"]
6336
+ ["fromContactId", "toContactId"],
6337
+ "Endpoint-based link locator."
6362
6338
  )
6363
- ],
6339
+ },
6364
6340
  description
6365
- );
6341
+ };
6366
6342
  }
6367
6343
  function resolveAttributeTarget(db, target) {
6368
6344
  if (target.kind === "contact") {
@@ -6408,7 +6384,7 @@ function manageAttributeToolHandler(db, input) {
6408
6384
  }
6409
6385
  var manageAttributeTool = defineAffinityTool({
6410
6386
  name: manageAttributeToolName,
6411
- description: "Set, unset, or replace attributes on contacts and links.",
6387
+ description: "Set, unset, or replace custom metadata attributes on contacts and links. For emails, phones, handles, and URLs use manage_identity instead \u2014 those are routing keys, not attributes.",
6412
6388
  whenToUse: "Use this for metadata such as tags, notes, or small labeled facts attached to a contact or link.",
6413
6389
  whenNotToUse: "Do not use this for core contact fields, identities, or direct relationship mechanics.",
6414
6390
  sideEffects: "writes_state",
@@ -6424,135 +6400,47 @@ var manageAttributeTool = defineAffinityTool({
6424
6400
  entries: "Replacement attribute set for the target."
6425
6401
  },
6426
6402
  outputDescription: "Returns the primary attribute plus the mutation receipt fields needed to understand what changed.",
6427
- inputSchema: oneOfSchema(
6428
- [
6429
- objectSchema(
6403
+ inputSchema: objectSchema(
6404
+ {
6405
+ action: enumSchema("Operation to perform.", ["set", "unset", "replace"]),
6406
+ target: objectSchema(
6430
6407
  {
6431
- action: literalSchema("set"),
6432
- target: oneOfSchema(
6433
- [
6434
- objectSchema(
6435
- {
6436
- kind: literalSchema("contact"),
6437
- contact: contactLocatorSchema2("Target contact.")
6438
- },
6439
- ["kind", "contact"]
6440
- ),
6441
- objectSchema(
6442
- {
6443
- kind: literalSchema("link"),
6444
- link: linkLocatorSchema2("Target link.")
6445
- },
6446
- ["kind", "link"]
6447
- )
6448
- ],
6449
- "Attribute target."
6408
+ kind: enumSchema("Target kind.", ["contact", "link"]),
6409
+ contact: contactLocatorSchema2(
6410
+ "Contact locator. Required when kind=contact. Provide contactId or identity."
6450
6411
  ),
6451
- name: stringSchema("Attribute name."),
6452
- value: nullableStringSchema(
6453
- "Attribute value, or null for presence/tag semantics."
6412
+ link: linkLocatorSchema2(
6413
+ "Link locator. Required when kind=link. Provide linkId or endpoints."
6454
6414
  )
6455
6415
  },
6456
- ["action", "target", "name"]
6416
+ ["kind"],
6417
+ "Attribute target. Always required."
6457
6418
  ),
6458
- objectSchema(
6459
- {
6460
- action: literalSchema("unset"),
6461
- target: oneOfSchema(
6462
- [
6463
- objectSchema(
6464
- {
6465
- kind: literalSchema("contact"),
6466
- contact: contactLocatorSchema2("Target contact.")
6467
- },
6468
- ["kind", "contact"]
6469
- ),
6470
- objectSchema(
6471
- {
6472
- kind: literalSchema("link"),
6473
- link: linkLocatorSchema2("Target link.")
6474
- },
6475
- ["kind", "link"]
6476
- )
6477
- ],
6478
- "Attribute target."
6479
- ),
6480
- name: stringSchema("Attribute name."),
6481
- removedAt: integerSchema("Optional removal timestamp.")
6482
- },
6483
- ["action", "target", "name"]
6419
+ name: stringSchema("Attribute name. Required when action=set or unset."),
6420
+ value: nullableStringSchema(
6421
+ "Attribute value. Required when action=set. Null for presence/tag semantics."
6484
6422
  ),
6485
- objectSchema(
6486
- {
6487
- action: literalSchema("replace"),
6488
- target: oneOfSchema(
6489
- [
6490
- objectSchema(
6491
- {
6492
- kind: literalSchema("contact"),
6493
- contact: contactLocatorSchema2("Target contact.")
6494
- },
6495
- ["kind", "contact"]
6496
- ),
6497
- objectSchema(
6498
- {
6499
- kind: literalSchema("link"),
6500
- link: linkLocatorSchema2("Target link.")
6501
- },
6502
- ["kind", "link"]
6503
- )
6504
- ],
6505
- "Attribute target."
6506
- ),
6507
- entries: arraySchema(
6508
- objectSchema(
6509
- {
6510
- name: stringSchema("Attribute name."),
6511
- value: nullableStringSchema(
6512
- "Attribute value, or null for presence/tag semantics."
6513
- )
6514
- },
6515
- ["name"]
6516
- ),
6517
- "Replacement attribute entries."
6518
- )
6519
- },
6520
- ["action", "target", "entries"]
6521
- )
6522
- ],
6523
- "Manage attributes."
6524
- ),
6525
- handler: manageAttributeToolHandler
6526
- });
6527
-
6528
- // src/tools/manage_commitment_tool.ts
6529
- function commitmentInputSchema() {
6530
- return objectSchema(
6531
- {
6532
- commitmentType: enumSchema("Promise or agreement.", [
6533
- "promise",
6534
- "agreement"
6535
- ]),
6536
- occurredAt: integerSchema("When the commitment was made."),
6537
- summary: stringSchema("Commitment summary."),
6538
- significance: integerSchema("Commitment significance."),
6539
- dueAt: integerSchema("Optional due timestamp."),
6540
- participants: arraySchema(
6423
+ entries: arraySchema(
6541
6424
  objectSchema(
6542
6425
  {
6543
- contactId: integerSchema("Participant contact id."),
6544
- role: stringSchema("Participant role."),
6545
- directionality: stringSchema("Optional directionality.")
6426
+ name: stringSchema("Attribute name."),
6427
+ value: nullableStringSchema(
6428
+ "Attribute value, or null for presence/tag semantics."
6429
+ )
6546
6430
  },
6547
- ["contactId", "role"]
6431
+ ["name"]
6548
6432
  ),
6549
- "Participant list."
6433
+ "Key-value map to replace all attributes. Required when action=replace."
6550
6434
  ),
6551
- now: integerSchema("Optional timestamp.")
6435
+ removedAt: integerSchema("Removal timestamp. Optional for action=unset.")
6552
6436
  },
6553
- ["commitmentType", "occurredAt", "summary", "significance", "participants"]
6554
- );
6555
- }
6437
+ ["action"],
6438
+ "Set, unset, or replace attributes on contacts and links."
6439
+ ),
6440
+ handler: manageAttributeToolHandler
6441
+ });
6442
+
6443
+ // src/tools/manage_commitment_tool.ts
6556
6444
  function manageCommitmentToolHandler(db, input) {
6557
6445
  return withToolHandling(() => {
6558
6446
  if (input.action === "record") {
@@ -6591,75 +6479,62 @@ var manageCommitmentTool = defineAffinityTool({
6591
6479
  options: "Optional resolution metadata and resolving event data."
6592
6480
  },
6593
6481
  outputDescription: "Returns the commitment mutation receipt, including linked event creation and derived link effects.",
6594
- inputSchema: oneOfSchema(
6595
- [
6596
- objectSchema(
6597
- {
6598
- action: literalSchema("record"),
6599
- input: commitmentInputSchema()
6600
- },
6601
- ["action", "input"]
6482
+ inputSchema: objectSchema(
6483
+ {
6484
+ action: enumSchema("Operation to perform.", ["record", "resolve"]),
6485
+ input: {
6486
+ type: "object",
6487
+ description: "Commitment payload. Required when action=record."
6488
+ },
6489
+ commitmentEventId: integerSchema(
6490
+ "Commitment event id. Required when action=resolve."
6491
+ ),
6492
+ resolution: enumSchema(
6493
+ "How the commitment was resolved. Required when action=resolve.",
6494
+ ["kept", "cancelled", "broken"]
6602
6495
  ),
6603
- objectSchema(
6496
+ options: objectSchema(
6604
6497
  {
6605
- action: literalSchema("resolve"),
6606
- commitmentEventId: integerSchema("Commitment event id."),
6607
- resolution: enumSchema("Commitment resolution.", [
6608
- "kept",
6609
- "cancelled",
6610
- "broken"
6611
- ]),
6612
- options: objectSchema(
6498
+ now: integerSchema("Optional timestamp."),
6499
+ resolvingEvent: objectSchema(
6613
6500
  {
6614
- now: integerSchema("Optional timestamp."),
6615
- resolvingEvent: objectSchema(
6616
- {
6617
- type: stringSchema("Optional resolving event type."),
6618
- occurredAt: integerSchema(
6619
- "Optional resolving event timestamp."
6620
- ),
6621
- summary: stringSchema("Optional resolving event summary."),
6622
- significance: integerSchema(
6623
- "Optional resolving event significance."
6624
- )
6625
- },
6626
- []
6501
+ type: stringSchema("Optional resolving event type."),
6502
+ occurredAt: integerSchema("Optional resolving event timestamp."),
6503
+ summary: stringSchema("Optional resolving event summary."),
6504
+ significance: integerSchema(
6505
+ "Optional resolving event significance."
6627
6506
  )
6628
6507
  },
6629
6508
  []
6630
6509
  )
6631
6510
  },
6632
- ["action", "commitmentEventId", "resolution"]
6511
+ [],
6512
+ "Optional metadata."
6633
6513
  )
6634
- ],
6635
- "Manage commitments."
6514
+ },
6515
+ ["action"],
6516
+ "Record or resolve one commitment."
6636
6517
  ),
6637
6518
  handler: manageCommitmentToolHandler
6638
6519
  });
6639
6520
 
6640
6521
  // src/tools/manage_contact_tool.ts
6641
6522
  function contactLocatorSchema3(description) {
6642
- return oneOfSchema(
6643
- [
6644
- objectSchema({ contactId: integerSchema("Exact contact id.") }, [
6645
- "contactId"
6646
- ]),
6647
- objectSchema(
6523
+ return {
6524
+ type: "object",
6525
+ properties: {
6526
+ contactId: integerSchema("Exact contact id."),
6527
+ identity: objectSchema(
6648
6528
  {
6649
- identity: objectSchema(
6650
- {
6651
- type: stringSchema("Identity type."),
6652
- value: stringSchema("Identity value.")
6653
- },
6654
- ["type", "value"],
6655
- "Contact identity locator."
6656
- )
6529
+ type: stringSchema("Identity type."),
6530
+ value: stringSchema("Identity value.")
6657
6531
  },
6658
- ["identity"]
6532
+ ["type", "value"],
6533
+ "Contact identity locator."
6659
6534
  )
6660
- ],
6535
+ },
6661
6536
  description
6662
- );
6537
+ };
6663
6538
  }
6664
6539
  function manageContactToolHandler(db, input) {
6665
6540
  return withToolHandling(() => {
@@ -6695,7 +6570,7 @@ function manageContactToolHandler(db, input) {
6695
6570
  }
6696
6571
  var manageContactTool = defineAffinityTool({
6697
6572
  name: manageContactToolName,
6698
- description: "Create a contact, revise one contact's core fields, or change lifecycle state.",
6573
+ description: "Create a contact, revise one contact's core fields, or change lifecycle state. ALWAYS search_affinity first before creating \u2014 duplicates corrupt the graph.",
6699
6574
  whenToUse: "Use this for contact creation and lifecycle-safe contact maintenance.",
6700
6575
  whenNotToUse: "Do not use this for identities, links, attributes, or merges.",
6701
6576
  sideEffects: "writes_state",
@@ -6711,120 +6586,62 @@ var manageContactTool = defineAffinityTool({
6711
6586
  options: "Optional lifecycle metadata such as now and provenance."
6712
6587
  },
6713
6588
  outputDescription: "Returns the primary contact plus the mutation receipt fields needed to understand what changed.",
6714
- inputSchema: oneOfSchema(
6715
- [
6716
- objectSchema(
6589
+ inputSchema: objectSchema(
6590
+ {
6591
+ action: enumSchema("Operation to perform.", [
6592
+ "create",
6593
+ "revise",
6594
+ "set_lifecycle"
6595
+ ]),
6596
+ input: objectSchema(
6717
6597
  {
6718
- action: literalSchema("create"),
6719
- input: objectSchema(
6720
- {
6721
- name: stringSchema("Contact name."),
6722
- kind: enumSchema("Contact kind.", [
6723
- "human",
6724
- "group",
6725
- "company",
6726
- "team",
6727
- "pet",
6728
- "service",
6729
- "other"
6730
- ]),
6731
- now: integerSchema("Optional timestamp."),
6732
- bootstrapOwner: booleanSchema(
6733
- "Whether this contact should be the owner."
6734
- )
6735
- },
6736
- ["name", "kind"],
6737
- "New contact payload."
6598
+ name: stringSchema("Contact name."),
6599
+ kind: enumSchema("Contact kind.", [
6600
+ "human",
6601
+ "group",
6602
+ "company",
6603
+ "team",
6604
+ "pet",
6605
+ "service",
6606
+ "other"
6607
+ ]),
6608
+ now: integerSchema("Optional timestamp."),
6609
+ bootstrapOwner: booleanSchema(
6610
+ "Whether this contact should be the owner."
6738
6611
  )
6739
6612
  },
6740
- ["action", "input"]
6613
+ ["name", "kind"],
6614
+ "New contact payload. Required when action=create."
6741
6615
  ),
6742
- objectSchema(
6616
+ contact: contactLocatorSchema3(
6617
+ "Target contact. Required when action=revise or set_lifecycle. Provide contactId or identity."
6618
+ ),
6619
+ patch: objectSchema(
6743
6620
  {
6744
- action: literalSchema("revise"),
6745
- contact: contactLocatorSchema3("Target contact."),
6746
- patch: objectSchema(
6747
- {
6748
- name: stringSchema("Optional replacement name.")
6749
- },
6750
- [],
6751
- "Allowed contact patch."
6752
- )
6621
+ name: stringSchema("Optional replacement name.")
6753
6622
  },
6754
- ["action", "contact", "patch"]
6623
+ [],
6624
+ "Allowed contact patch. Required when action=revise."
6625
+ ),
6626
+ lifecycleState: enumSchema(
6627
+ "Target lifecycle state. Required when action=set_lifecycle.",
6628
+ ["active", "dormant", "merged", "lost"]
6755
6629
  ),
6756
- objectSchema(
6630
+ options: objectSchema(
6757
6631
  {
6758
- action: literalSchema("set_lifecycle"),
6759
- contact: contactLocatorSchema3("Target contact."),
6760
- lifecycleState: enumSchema("Target lifecycle state.", [
6761
- "active",
6762
- "dormant",
6763
- "merged",
6764
- "lost"
6765
- ]),
6766
- options: objectSchema(
6767
- {
6768
- now: integerSchema("Optional timestamp.")
6769
- },
6770
- [],
6771
- "Optional lifecycle metadata."
6772
- )
6632
+ now: integerSchema("Optional timestamp.")
6773
6633
  },
6774
- ["action", "contact", "lifecycleState"]
6634
+ [],
6635
+ "Optional lifecycle metadata."
6775
6636
  )
6776
- ],
6637
+ },
6638
+ ["action"],
6777
6639
  "Manage contacts."
6778
6640
  ),
6779
6641
  handler: manageContactToolHandler
6780
6642
  });
6781
6643
 
6782
6644
  // src/tools/manage_date_anchor_tool.ts
6783
- function contactLocatorSchema4(description) {
6784
- return oneOfSchema(
6785
- [
6786
- objectSchema({ contactId: integerSchema("Exact contact id.") }, [
6787
- "contactId"
6788
- ]),
6789
- objectSchema(
6790
- {
6791
- identity: objectSchema(
6792
- {
6793
- type: stringSchema("Identity type."),
6794
- value: stringSchema("Identity value.")
6795
- },
6796
- ["type", "value"]
6797
- )
6798
- },
6799
- ["identity"]
6800
- )
6801
- ],
6802
- description
6803
- );
6804
- }
6805
- function linkLocatorSchema3(description) {
6806
- return oneOfSchema(
6807
- [
6808
- objectSchema({ linkId: integerSchema("Exact link id.") }, ["linkId"]),
6809
- objectSchema(
6810
- {
6811
- endpoints: objectSchema(
6812
- {
6813
- fromContactId: integerSchema("From contact id."),
6814
- toContactId: integerSchema("To contact id."),
6815
- kind: stringSchema("Optional link kind."),
6816
- role: stringSchema("Optional link role."),
6817
- isStructural: booleanSchema("Optional structural discriminator.")
6818
- },
6819
- ["fromContactId", "toContactId"]
6820
- )
6821
- },
6822
- ["endpoints"]
6823
- )
6824
- ],
6825
- description
6826
- );
6827
- }
6828
6645
  function resolveDateAnchorTarget(db, target) {
6829
6646
  if (target.kind === "contact") {
6830
6647
  const contact = resolveContactLocator(db, target.contact, "target.contact");
@@ -6871,7 +6688,7 @@ function manageDateAnchorToolHandler(db, input) {
6871
6688
  }
6872
6689
  var manageDateAnchorTool = defineAffinityTool({
6873
6690
  name: manageDateAnchorToolName,
6874
- description: "Add, revise, or remove recurring date anchors on contacts or links.",
6691
+ description: "Add, revise, or remove recurring date anchors on contacts or links. Use this for birthdays, anniversaries, and yearly events \u2014 not manage_attribute.",
6875
6692
  whenToUse: "Use this for birthdays, anniversaries, renewals, memorials, and other recurring anchors.",
6876
6693
  whenNotToUse: "Do not use this for one-off events or relationship state changes.",
6877
6694
  sideEffects: "writes_state",
@@ -6887,102 +6704,34 @@ var manageDateAnchorTool = defineAffinityTool({
6887
6704
  removedAt: "Optional removal timestamp."
6888
6705
  },
6889
6706
  outputDescription: "Returns the date-anchor mutation receipt, including any recomputed upcoming occurrences.",
6890
- inputSchema: oneOfSchema(
6891
- [
6892
- objectSchema(
6893
- {
6894
- action: literalSchema("add"),
6895
- input: objectSchema(
6896
- {
6897
- target: oneOfSchema(
6898
- [
6899
- objectSchema(
6900
- {
6901
- kind: literalSchema("contact"),
6902
- contact: contactLocatorSchema4("Target contact.")
6903
- },
6904
- ["kind", "contact"]
6905
- ),
6906
- objectSchema(
6907
- {
6908
- kind: literalSchema("link"),
6909
- link: linkLocatorSchema3("Target link.")
6910
- },
6911
- ["kind", "link"]
6912
- )
6913
- ],
6914
- "Date-anchor target."
6915
- ),
6916
- recurrenceKind: enumSchema("Recurrence kind.", [
6917
- "birthday",
6918
- "anniversary",
6919
- "renewal",
6920
- "memorial",
6921
- "custom_yearly"
6922
- ]),
6923
- anchorMonth: integerSchema("Anchor month."),
6924
- anchorDay: integerSchema("Anchor day."),
6925
- summary: stringSchema("Summary."),
6926
- significance: integerSchema("Significance."),
6927
- now: integerSchema("Optional timestamp."),
6928
- force: booleanSchema(
6929
- "Whether duplicate checks should be bypassed."
6930
- )
6931
- },
6932
- [
6933
- "target",
6934
- "recurrenceKind",
6935
- "anchorMonth",
6936
- "anchorDay",
6937
- "summary",
6938
- "significance"
6939
- ]
6940
- )
6941
- },
6942
- ["action", "input"]
6707
+ inputSchema: objectSchema(
6708
+ {
6709
+ action: enumSchema("Operation to perform.", ["add", "revise", "remove"]),
6710
+ input: {
6711
+ type: "object",
6712
+ description: "Date anchor payload. Required when action=add."
6713
+ },
6714
+ anchorEventId: integerSchema(
6715
+ "Anchor event id. Required when action=revise or remove."
6943
6716
  ),
6944
- objectSchema(
6717
+ patch: {
6718
+ type: "object",
6719
+ description: "Anchor patch. Required when action=revise."
6720
+ },
6721
+ options: objectSchema(
6945
6722
  {
6946
- action: literalSchema("revise"),
6947
- anchorEventId: integerSchema("Anchor event id."),
6948
- patch: objectSchema(
6949
- {
6950
- recurrenceKind: enumSchema("Optional recurrence kind.", [
6951
- "birthday",
6952
- "anniversary",
6953
- "renewal",
6954
- "memorial",
6955
- "custom_yearly"
6956
- ]),
6957
- anchorMonth: integerSchema("Optional month."),
6958
- anchorDay: integerSchema("Optional day."),
6959
- summary: stringSchema("Optional summary."),
6960
- significance: integerSchema("Optional significance.")
6961
- },
6962
- []
6963
- ),
6964
- options: objectSchema(
6965
- {
6966
- now: integerSchema("Optional timestamp."),
6967
- force: booleanSchema(
6968
- "Whether duplicate checks should be bypassed."
6969
- )
6970
- },
6971
- []
6972
- )
6723
+ now: integerSchema("Optional timestamp."),
6724
+ force: booleanSchema("Whether duplicate checks should be bypassed.")
6973
6725
  },
6974
- ["action", "anchorEventId", "patch"]
6726
+ [],
6727
+ "Optional metadata."
6975
6728
  ),
6976
- objectSchema(
6977
- {
6978
- action: literalSchema("remove"),
6979
- anchorEventId: integerSchema("Anchor event id."),
6980
- removedAt: integerSchema("Optional removal timestamp.")
6981
- },
6982
- ["action", "anchorEventId"]
6729
+ removedAt: integerSchema(
6730
+ "Removal timestamp. Optional for action=remove."
6983
6731
  )
6984
- ],
6985
- "Manage date anchors."
6732
+ },
6733
+ ["action"],
6734
+ "Add, revise, or remove recurring date anchors."
6986
6735
  ),
6987
6736
  handler: manageDateAnchorToolHandler
6988
6737
  });
@@ -7170,27 +6919,22 @@ function verifyIdentity(db, identityId, verifiedAt) {
7170
6919
  }
7171
6920
 
7172
6921
  // src/tools/manage_identity_tool.ts
7173
- function contactLocatorSchema5(description) {
7174
- return oneOfSchema(
7175
- [
7176
- objectSchema({ contactId: integerSchema("Exact contact id.") }, [
7177
- "contactId"
7178
- ]),
7179
- objectSchema(
6922
+ function contactLocatorSchema4(description) {
6923
+ return {
6924
+ type: "object",
6925
+ properties: {
6926
+ contactId: integerSchema("Exact contact id."),
6927
+ identity: objectSchema(
7180
6928
  {
7181
- identity: objectSchema(
7182
- {
7183
- type: stringSchema("Identity type."),
7184
- value: stringSchema("Identity value.")
7185
- },
7186
- ["type", "value"]
7187
- )
6929
+ type: stringSchema("Identity type."),
6930
+ value: stringSchema("Identity value.")
7188
6931
  },
7189
- ["identity"]
6932
+ ["type", "value"],
6933
+ "Contact identity locator."
7190
6934
  )
7191
- ],
6935
+ },
7192
6936
  description
7193
- );
6937
+ };
7194
6938
  }
7195
6939
  function manageIdentityToolHandler(db, input) {
7196
6940
  return withToolHandling(() => {
@@ -7229,7 +6973,7 @@ function manageIdentityToolHandler(db, input) {
7229
6973
  }
7230
6974
  var manageIdentityTool = defineAffinityTool({
7231
6975
  name: manageIdentityToolName,
7232
- description: "Add, revise, verify, or remove one routing identity on a contact.",
6976
+ description: "Add, revise, verify, or remove one routing identity on a contact. Use this for emails, phone numbers, social handles, and URLs \u2014 anything that could locate a person. Do not use manage_attribute for these.",
7233
6977
  whenToUse: "Use this for contact identity management such as email, handle, or phone routing keys.",
7234
6978
  whenNotToUse: "Do not use this for contact core fields, links, or attributes.",
7235
6979
  sideEffects: "writes_state",
@@ -7246,107 +6990,90 @@ var manageIdentityTool = defineAffinityTool({
7246
6990
  removedAt: "Optional removal timestamp."
7247
6991
  },
7248
6992
  outputDescription: "Returns the primary identity plus the mutation receipt fields needed to understand what changed.",
7249
- inputSchema: oneOfSchema(
7250
- [
7251
- objectSchema(
7252
- {
7253
- action: literalSchema("add"),
7254
- contact: contactLocatorSchema5("Target contact."),
7255
- input: objectSchema(
7256
- {
7257
- type: stringSchema("Identity type."),
7258
- value: stringSchema("Identity value."),
7259
- label: stringSchema("Optional label."),
7260
- verified: booleanSchema("Whether the identity starts verified."),
7261
- now: integerSchema("Optional timestamp.")
7262
- },
7263
- ["type", "value"]
7264
- )
7265
- },
7266
- ["action", "contact", "input"]
6993
+ inputSchema: objectSchema(
6994
+ {
6995
+ action: enumSchema("Operation to perform.", [
6996
+ "add",
6997
+ "revise",
6998
+ "verify",
6999
+ "remove"
7000
+ ]),
7001
+ contact: contactLocatorSchema4(
7002
+ "Target contact. Required when action=add. Provide contactId or identity."
7267
7003
  ),
7268
- objectSchema(
7004
+ input: objectSchema(
7269
7005
  {
7270
- action: literalSchema("revise"),
7271
- identityId: integerSchema("Identity id."),
7272
- patch: objectSchema(
7273
- {
7274
- type: stringSchema("Optional identity type."),
7275
- value: stringSchema("Optional identity value."),
7276
- label: stringSchema("Optional label.")
7277
- },
7278
- []
7279
- )
7006
+ type: stringSchema("Identity type."),
7007
+ value: stringSchema("Identity value."),
7008
+ label: stringSchema("Optional label."),
7009
+ verified: booleanSchema("Whether the identity starts verified."),
7010
+ now: integerSchema("Optional timestamp.")
7280
7011
  },
7281
- ["action", "identityId", "patch"]
7012
+ ["type", "value"],
7013
+ "New identity payload. Required when action=add."
7282
7014
  ),
7283
- objectSchema(
7284
- {
7285
- action: literalSchema("verify"),
7286
- identityId: integerSchema("Identity id."),
7287
- verifiedAt: integerSchema("Optional verification timestamp.")
7288
- },
7289
- ["action", "identityId"]
7015
+ identityId: integerSchema(
7016
+ "Identity id. Required when action=revise, verify, or remove."
7290
7017
  ),
7291
- objectSchema(
7018
+ patch: objectSchema(
7292
7019
  {
7293
- action: literalSchema("remove"),
7294
- identityId: integerSchema("Identity id."),
7295
- removedAt: integerSchema("Optional removal timestamp.")
7020
+ type: stringSchema("Optional identity type."),
7021
+ value: stringSchema("Optional identity value."),
7022
+ label: stringSchema("Optional label.")
7296
7023
  },
7297
- ["action", "identityId"]
7024
+ [],
7025
+ "Identity patch. Required when action=revise."
7026
+ ),
7027
+ verifiedAt: integerSchema(
7028
+ "Verification timestamp. Optional for action=verify."
7029
+ ),
7030
+ removedAt: integerSchema(
7031
+ "Removal timestamp. Optional for action=remove."
7298
7032
  )
7299
- ],
7300
- "Manage identities."
7033
+ },
7034
+ ["action"],
7035
+ "Add, revise, verify, or remove one routing identity on a contact."
7301
7036
  ),
7302
7037
  handler: manageIdentityToolHandler
7303
7038
  });
7304
7039
 
7305
7040
  // src/tools/manage_relationship_tool.ts
7306
- function contactLocatorSchema6(description) {
7307
- return oneOfSchema(
7308
- [
7309
- objectSchema({ contactId: integerSchema("Exact contact id.") }, [
7310
- "contactId"
7311
- ]),
7312
- objectSchema(
7041
+ function contactLocatorSchema5(description) {
7042
+ return {
7043
+ type: "object",
7044
+ properties: {
7045
+ contactId: integerSchema("Exact contact id."),
7046
+ identity: objectSchema(
7313
7047
  {
7314
- identity: objectSchema(
7315
- {
7316
- type: stringSchema("Identity type."),
7317
- value: stringSchema("Identity value.")
7318
- },
7319
- ["type", "value"]
7320
- )
7048
+ type: stringSchema("Identity type."),
7049
+ value: stringSchema("Identity value.")
7321
7050
  },
7322
- ["identity"]
7051
+ ["type", "value"],
7052
+ "Contact identity locator."
7323
7053
  )
7324
- ],
7054
+ },
7325
7055
  description
7326
- );
7056
+ };
7327
7057
  }
7328
- function linkLocatorSchema4(description) {
7329
- return oneOfSchema(
7330
- [
7331
- objectSchema({ linkId: integerSchema("Exact link id.") }, ["linkId"]),
7332
- objectSchema(
7058
+ function linkLocatorSchema3(description) {
7059
+ return {
7060
+ type: "object",
7061
+ properties: {
7062
+ linkId: integerSchema("Exact link id."),
7063
+ endpoints: objectSchema(
7333
7064
  {
7334
- endpoints: objectSchema(
7335
- {
7336
- fromContactId: integerSchema("From contact id."),
7337
- toContactId: integerSchema("To contact id."),
7338
- kind: stringSchema("Optional link kind."),
7339
- role: stringSchema("Optional link role."),
7340
- isStructural: booleanSchema("Optional structural discriminator.")
7341
- },
7342
- ["fromContactId", "toContactId"]
7343
- )
7065
+ fromContactId: integerSchema("From contact id."),
7066
+ toContactId: integerSchema("To contact id."),
7067
+ kind: stringSchema("Optional link kind."),
7068
+ role: stringSchema("Optional link role."),
7069
+ isStructural: booleanSchema("Optional structural discriminator.")
7344
7070
  },
7345
- ["endpoints"]
7071
+ ["fromContactId", "toContactId"],
7072
+ "Endpoint-based link locator."
7346
7073
  )
7347
- ],
7074
+ },
7348
7075
  description
7349
- );
7076
+ };
7350
7077
  }
7351
7078
  function manageRelationshipToolHandler(db, input) {
7352
7079
  return withToolHandling(() => {
@@ -7360,10 +7087,15 @@ function manageRelationshipToolHandler(db, input) {
7360
7087
  if (!to.ok) {
7361
7088
  return to.result;
7362
7089
  }
7090
+ const merged = {
7091
+ ...input.input,
7092
+ ...input.kind !== void 0 && input.input?.kind === void 0 ? { kind: input.kind } : {},
7093
+ ...input.role !== void 0 && input.input?.role === void 0 ? { role: input.role } : {}
7094
+ };
7363
7095
  return mutationToolResult(
7364
7096
  "seed_social_link",
7365
7097
  seedSocialLink(db, {
7366
- ...input.input,
7098
+ ...merged,
7367
7099
  fromContactId: from.value.id,
7368
7100
  toContactId: to.value.id
7369
7101
  }),
@@ -7401,10 +7133,15 @@ function manageRelationshipToolHandler(db, input) {
7401
7133
  if (!to.ok) {
7402
7134
  return to.result;
7403
7135
  }
7136
+ const merged = {
7137
+ ...input.input,
7138
+ ...input.kind !== void 0 && input.input?.kind === void 0 ? { kind: input.kind } : {},
7139
+ ...input.role !== void 0 && input.input?.role === void 0 ? { role: input.role } : {}
7140
+ };
7404
7141
  return mutationToolResult(
7405
7142
  "set_structural_tie",
7406
7143
  setStructuralTie(db, {
7407
- ...input.input,
7144
+ ...merged,
7408
7145
  fromContactId: from.value.id,
7409
7146
  toContactId: to.value.id
7410
7147
  }),
@@ -7427,7 +7164,7 @@ function manageRelationshipToolHandler(db, input) {
7427
7164
  }
7428
7165
  var manageRelationshipTool = defineAffinityTool({
7429
7166
  name: manageRelationshipToolName,
7430
- description: "Seed social links, revise bond and state, and manage structural ties.",
7167
+ description: "Seed social links, revise bond and state, and manage structural ties. Seed a link as soon as a relationship is mentioned \u2014 do not wait for repeated evidence.",
7431
7168
  whenToUse: "Use this for direct relationship modeling and link-state changes.",
7432
7169
  whenNotToUse: "Do not use this for recording social evidence or resolving commitments.",
7433
7170
  sideEffects: "writes_state",
@@ -7438,7 +7175,9 @@ var manageRelationshipTool = defineAffinityTool({
7438
7175
  action: "Which relationship action to perform.",
7439
7176
  from: "Source contact locator for actions that create or set links.",
7440
7177
  to: "Destination contact locator for actions that create or set links.",
7441
- input: "Action-specific creation payload.",
7178
+ input: "Action-specific creation payload (alternative to top-level kind/role).",
7179
+ kind: "Link kind for seed_social_link or set_structural_tie. Can be passed here or inside input.",
7180
+ role: "Optional role for seed_social_link or set_structural_tie. Can be passed here or inside input.",
7442
7181
  link: "Target link locator for existing-link actions.",
7443
7182
  bond: "Replacement bond text or null.",
7444
7183
  state: "Replacement link state.",
@@ -7446,144 +7185,76 @@ var manageRelationshipTool = defineAffinityTool({
7446
7185
  removedAt: "Optional structural-tie removal timestamp."
7447
7186
  },
7448
7187
  outputDescription: "Returns the primary link plus the mutation receipt fields needed to understand what changed.",
7449
- inputSchema: oneOfSchema(
7450
- [
7451
- objectSchema(
7452
- {
7453
- action: literalSchema("seed_social_link"),
7454
- from: contactLocatorSchema6("From contact."),
7455
- to: contactLocatorSchema6("To contact."),
7456
- input: objectSchema(
7457
- {
7458
- kind: enumSchema("Relational link kind.", [
7459
- "personal",
7460
- "family",
7461
- "professional",
7462
- "romantic",
7463
- "care",
7464
- "service",
7465
- "observed",
7466
- "other_relational"
7467
- ]),
7468
- role: stringSchema("Optional role."),
7469
- rank: integerSchema("Optional rank."),
7470
- affinity: numberSchema("Optional affinity score 0\u20131."),
7471
- trust: numberSchema("Optional trust score 0\u20131."),
7472
- state: enumSchema("Optional initial state.", [
7473
- "active",
7474
- "dormant",
7475
- "strained",
7476
- "broken",
7477
- "archived"
7478
- ]),
7479
- cadenceDays: integerSchema("Optional cadence days."),
7480
- bond: stringSchema("Optional bond."),
7481
- now: integerSchema("Optional timestamp.")
7482
- },
7483
- ["kind"]
7484
- )
7485
- },
7486
- ["action", "from", "to", "input"]
7188
+ inputSchema: objectSchema(
7189
+ {
7190
+ action: enumSchema("Operation to perform.", [
7191
+ "seed_social_link",
7192
+ "revise_bond",
7193
+ "override_state",
7194
+ "set_structural_tie",
7195
+ "remove_structural_tie"
7196
+ ]),
7197
+ from: contactLocatorSchema5(
7198
+ "Source contact. Required when action=seed_social_link or set_structural_tie. Provide contactId or identity."
7487
7199
  ),
7488
- objectSchema(
7489
- {
7490
- action: literalSchema("revise_bond"),
7491
- link: linkLocatorSchema4("Target link."),
7492
- bond: nullableStringSchema(
7493
- "Replacement bond text, or null to clear."
7494
- ),
7495
- options: objectSchema(
7496
- { now: integerSchema("Optional timestamp.") },
7497
- []
7498
- )
7499
- },
7500
- ["action", "link", "bond"]
7200
+ to: contactLocatorSchema5(
7201
+ "Target contact. Required when action=seed_social_link or set_structural_tie. Provide contactId or identity."
7501
7202
  ),
7502
- objectSchema(
7503
- {
7504
- action: literalSchema("override_state"),
7505
- link: linkLocatorSchema4("Target link."),
7506
- state: enumSchema("Replacement link state.", [
7507
- "active",
7508
- "dormant",
7509
- "strained",
7510
- "broken",
7511
- "archived"
7512
- ]),
7513
- options: objectSchema(
7514
- { now: integerSchema("Optional timestamp.") },
7515
- []
7516
- )
7517
- },
7518
- ["action", "link", "state"]
7203
+ kind: stringSchema(
7204
+ "Link kind. Required for seed_social_link and set_structural_tie. Can be passed here or inside input."
7519
7205
  ),
7520
- objectSchema(
7521
- {
7522
- action: literalSchema("set_structural_tie"),
7523
- from: contactLocatorSchema6("From contact."),
7524
- to: contactLocatorSchema6("To contact."),
7525
- input: objectSchema(
7526
- {
7527
- kind: enumSchema("Structural link kind.", [
7528
- "works_at",
7529
- "manages",
7530
- "member_of",
7531
- "married_to",
7532
- "partner_of",
7533
- "parent_of",
7534
- "child_of",
7535
- "sibling_of",
7536
- "friend_of",
7537
- "client_of",
7538
- "vendor_of",
7539
- "reports_to",
7540
- "belongs_to",
7541
- "other_structural"
7542
- ]),
7543
- role: stringSchema("Optional role."),
7544
- now: integerSchema("Optional timestamp.")
7545
- },
7546
- ["kind"]
7547
- )
7548
- },
7549
- ["action", "from", "to", "input"]
7206
+ role: stringSchema(
7207
+ "Optional role for seed_social_link or set_structural_tie. Can be passed here or inside input."
7550
7208
  ),
7551
- objectSchema(
7552
- {
7553
- action: literalSchema("remove_structural_tie"),
7554
- link: linkLocatorSchema4("Target structural tie."),
7555
- removedAt: integerSchema("Optional removal timestamp.")
7556
- },
7557
- ["action", "link"]
7209
+ input: {
7210
+ type: "object",
7211
+ description: "Full payload for seed_social_link or set_structural_tie. Alternative to top-level kind/role."
7212
+ },
7213
+ link: linkLocatorSchema3(
7214
+ "Target link. Required when action=revise_bond, override_state, or remove_structural_tie. Provide linkId or endpoints."
7215
+ ),
7216
+ bond: nullableStringSchema(
7217
+ "Bond text. Required when action=revise_bond. Null to clear."
7218
+ ),
7219
+ state: enumSchema("Link state. Required when action=override_state.", [
7220
+ "active",
7221
+ "dormant",
7222
+ "strained",
7223
+ "broken",
7224
+ "archived"
7225
+ ]),
7226
+ options: objectSchema(
7227
+ { now: integerSchema("Optional timestamp.") },
7228
+ [],
7229
+ "Optional metadata."
7230
+ ),
7231
+ removedAt: integerSchema(
7232
+ "Removal timestamp. Optional for action=remove_structural_tie."
7558
7233
  )
7559
- ],
7560
- "Manage relationships."
7234
+ },
7235
+ ["action"],
7236
+ "Seed social links, revise bond and state, and manage structural ties."
7561
7237
  ),
7562
7238
  handler: manageRelationshipToolHandler
7563
7239
  });
7564
7240
 
7565
7241
  // src/tools/merge_contacts_tool.ts
7566
- function contactLocatorSchema7(description) {
7567
- return oneOfSchema(
7568
- [
7569
- objectSchema({ contactId: integerSchema("Exact contact id.") }, [
7570
- "contactId"
7571
- ]),
7572
- objectSchema(
7242
+ function contactLocatorSchema6(description) {
7243
+ return {
7244
+ type: "object",
7245
+ properties: {
7246
+ contactId: integerSchema("Exact contact id."),
7247
+ identity: objectSchema(
7573
7248
  {
7574
- identity: objectSchema(
7575
- {
7576
- type: stringSchema("Identity type."),
7577
- value: stringSchema("Identity value.")
7578
- },
7579
- ["type", "value"]
7580
- )
7249
+ type: stringSchema("Identity type."),
7250
+ value: stringSchema("Identity value.")
7581
7251
  },
7582
- ["identity"]
7252
+ ["type", "value"],
7253
+ "Contact identity locator."
7583
7254
  )
7584
- ],
7255
+ },
7585
7256
  description
7586
- );
7257
+ };
7587
7258
  }
7588
7259
  function mergeContactsToolHandler(db, input) {
7589
7260
  return withToolHandling(() => {
@@ -7625,8 +7296,12 @@ var mergeContactsTool = defineAffinityTool({
7625
7296
  outputDescription: "Returns the merge receipt with rewired entities and affected-link information.",
7626
7297
  inputSchema: objectSchema(
7627
7298
  {
7628
- winner: contactLocatorSchema7("Winner contact."),
7629
- loser: contactLocatorSchema7("Loser contact."),
7299
+ winner: contactLocatorSchema6(
7300
+ "Winner contact. Provide contactId or identity."
7301
+ ),
7302
+ loser: contactLocatorSchema6(
7303
+ "Loser contact. Provide contactId or identity."
7304
+ ),
7630
7305
  reasonSummary: stringSchema("Optional merge reason."),
7631
7306
  now: integerSchema("Optional merge timestamp.")
7632
7307
  },
@@ -7637,57 +7312,6 @@ var mergeContactsTool = defineAffinityTool({
7637
7312
  });
7638
7313
 
7639
7314
  // src/tools/record_event_tool.ts
7640
- var participantSchema = objectSchema(
7641
- {
7642
- contactId: integerSchema("Participant contact id."),
7643
- role: enumSchema("Participant role.", [
7644
- "actor",
7645
- "recipient",
7646
- "subject",
7647
- "observer",
7648
- "mentioned"
7649
- ]),
7650
- directionality: enumSchema("Optional participant directionality.", [
7651
- "owner_initiated",
7652
- "other_initiated",
7653
- "mutual",
7654
- "observed"
7655
- ])
7656
- },
7657
- ["contactId", "role"]
7658
- );
7659
- function interactionInputSchema() {
7660
- return objectSchema(
7661
- {
7662
- type: enumSchema("Interaction subtype.", [
7663
- "conversation",
7664
- "activity",
7665
- "gift",
7666
- "support",
7667
- "conflict",
7668
- "correction"
7669
- ]),
7670
- occurredAt: integerSchema("When the event occurred."),
7671
- summary: stringSchema("Event summary."),
7672
- significance: integerSchema("Event significance from 1 to 10."),
7673
- participants: arraySchema(participantSchema, "Participant list."),
7674
- now: integerSchema("Optional timestamp.")
7675
- },
7676
- ["type", "occurredAt", "summary", "significance", "participants"]
7677
- );
7678
- }
7679
- function socialEventInputSchema() {
7680
- return objectSchema(
7681
- {
7682
- occurredAt: integerSchema("When the event occurred."),
7683
- summary: stringSchema("Event summary."),
7684
- significance: integerSchema("Event significance from 1 to 10."),
7685
- participants: arraySchema(participantSchema, "Participant list."),
7686
- now: integerSchema("Optional timestamp.")
7687
- },
7688
- ["occurredAt", "summary", "significance", "participants"]
7689
- );
7690
- }
7691
7315
  function recordEventToolHandler(db, input) {
7692
7316
  return withToolHandling(() => {
7693
7317
  switch (input.kind) {
@@ -7732,38 +7356,21 @@ var recordEventTool = defineAffinityTool({
7732
7356
  input: "The event payload for that family. Interaction events require a `type` subtype; the others do not."
7733
7357
  },
7734
7358
  outputDescription: "Returns the primary event plus the mutation receipt fields and any affected links or derived effects.",
7735
- inputSchema: oneOfSchema(
7736
- [
7737
- objectSchema(
7738
- {
7739
- kind: literalSchema("interaction"),
7740
- input: interactionInputSchema()
7741
- },
7742
- ["kind", "input"]
7743
- ),
7744
- objectSchema(
7745
- {
7746
- kind: literalSchema("observation"),
7747
- input: socialEventInputSchema()
7748
- },
7749
- ["kind", "input"]
7750
- ),
7751
- objectSchema(
7752
- {
7753
- kind: literalSchema("milestone"),
7754
- input: socialEventInputSchema()
7755
- },
7756
- ["kind", "input"]
7757
- ),
7758
- objectSchema(
7759
- {
7760
- kind: literalSchema("transaction"),
7761
- input: socialEventInputSchema()
7762
- },
7763
- ["kind", "input"]
7764
- )
7765
- ],
7766
- "Record one event."
7359
+ inputSchema: objectSchema(
7360
+ {
7361
+ kind: enumSchema("Event kind.", [
7362
+ "interaction",
7363
+ "observation",
7364
+ "milestone",
7365
+ "transaction"
7366
+ ]),
7367
+ input: {
7368
+ type: "object",
7369
+ description: "Event payload. Shape depends on kind. Interaction events require a `type` subtype; others do not. Always required."
7370
+ }
7371
+ },
7372
+ ["kind", "input"],
7373
+ "Record one social event."
7767
7374
  ),
7768
7375
  handler: recordEventToolHandler
7769
7376
  });
@@ -7787,50 +7394,42 @@ function buildChartOptions(input) {
7787
7394
  ...input.contactIds === void 0 ? {} : { contactIds: input.contactIds }
7788
7395
  };
7789
7396
  }
7790
- function contactLocatorSchema8(description) {
7791
- return oneOfSchema(
7792
- [
7793
- objectSchema({ contactId: integerSchema("Exact contact id.") }, [
7794
- "contactId"
7795
- ]),
7796
- objectSchema(
7397
+ function contactLocatorSchema7(description) {
7398
+ return {
7399
+ type: "object",
7400
+ properties: {
7401
+ contactId: integerSchema("Exact contact id."),
7402
+ identity: objectSchema(
7797
7403
  {
7798
- identity: objectSchema(
7799
- {
7800
- type: stringSchema("Identity type."),
7801
- value: stringSchema("Identity value.")
7802
- },
7803
- ["type", "value"]
7804
- )
7404
+ type: stringSchema("Identity type."),
7405
+ value: stringSchema("Identity value.")
7805
7406
  },
7806
- ["identity"]
7407
+ ["type", "value"],
7408
+ "Contact identity locator."
7807
7409
  )
7808
- ],
7410
+ },
7809
7411
  description
7810
- );
7412
+ };
7811
7413
  }
7812
- function linkLocatorSchema5(description) {
7813
- return oneOfSchema(
7814
- [
7815
- objectSchema({ linkId: integerSchema("Exact link id.") }, ["linkId"]),
7816
- objectSchema(
7414
+ function linkLocatorSchema4(description) {
7415
+ return {
7416
+ type: "object",
7417
+ properties: {
7418
+ linkId: integerSchema("Exact link id."),
7419
+ endpoints: objectSchema(
7817
7420
  {
7818
- endpoints: objectSchema(
7819
- {
7820
- fromContactId: integerSchema("From contact id."),
7821
- toContactId: integerSchema("To contact id."),
7822
- kind: stringSchema("Optional link kind."),
7823
- role: stringSchema("Optional link role."),
7824
- isStructural: booleanSchema("Optional structural discriminator.")
7825
- },
7826
- ["fromContactId", "toContactId"]
7827
- )
7421
+ fromContactId: integerSchema("From contact id."),
7422
+ toContactId: integerSchema("To contact id."),
7423
+ kind: stringSchema("Optional link kind."),
7424
+ role: stringSchema("Optional link role."),
7425
+ isStructural: booleanSchema("Optional structural discriminator.")
7828
7426
  },
7829
- ["endpoints"]
7427
+ ["fromContactId", "toContactId"],
7428
+ "Endpoint-based link locator."
7830
7429
  )
7831
- ],
7430
+ },
7832
7431
  description
7833
- );
7432
+ };
7834
7433
  }
7835
7434
  function validateReviewInput(input) {
7836
7435
  if (input.view === "events.contact_journal" || input.view === "events.moments" || input.view === "commitments.open" || input.view === "merges.history") {
@@ -8231,8 +7830,8 @@ var reviewAffinityTool = defineAffinityTool({
8231
7830
  "graph.chart",
8232
7831
  "merges.history"
8233
7832
  ]),
8234
- contact: contactLocatorSchema8("Optional target contact locator."),
8235
- link: linkLocatorSchema5("Optional target link locator."),
7833
+ contact: contactLocatorSchema7("Optional target contact locator."),
7834
+ link: linkLocatorSchema4("Optional target link locator."),
8236
7835
  contactIds: arraySchema(
8237
7836
  integerSchema("Contact id."),
8238
7837
  "Optional contact-id subset."