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