@productbrain/mcp 0.0.1-beta.11709 → 0.0.1-beta.11823

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.
@@ -596,7 +596,8 @@ var ROUTE_TYPE_ENTRIES = {
596
596
  "chain.search": "query",
597
597
  "organisation.hierarchy.release": "mutation",
598
598
  "organisation.hierarchy.accept": "mutation",
599
- "organisation.hierarchy.refuse": "mutation"
599
+ "organisation.hierarchy.refuse": "mutation",
600
+ "chain.replaceEntry": "mutation"
600
601
  };
601
602
  var ROUTE_TYPE_BY_NAME = Object.assign(
602
603
  /* @__PURE__ */ Object.create(null),
@@ -886,6 +887,60 @@ var SPINE_RUNG_SEQUENCE = [
886
887
  { relationType: "part_of", targetKey: "purpose", gapIfMissing: "purpose_missing" }
887
888
  ];
888
889
 
890
+ // src/lib/seatSentence.ts
891
+ var PERSON_STATUS_WORDS = {
892
+ active: "Active",
893
+ invited: "Invited",
894
+ placeholder: "Not invited",
895
+ archived: "Archived"
896
+ };
897
+ function personStatusTag(status) {
898
+ if (!status || status === "active" || !Object.prototype.hasOwnProperty.call(PERSON_STATUS_WORDS, status)) return null;
899
+ return PERSON_STATUS_WORDS[status];
900
+ }
901
+ var roleRetireDetailOf = (details) => (details ?? []).map((detail) => detail?.roleRetire).find((found) => typeof found?.roleId === "string");
902
+ function formatSeatSentence(action, reply, clean) {
903
+ if (reply.outcome === "refused") {
904
+ return `Refused: ${reply.refusal?.reason ?? reply.refusal?.code ?? "not allowed"}${reply.refusal?.requiredAction ? ` ${reply.refusal.requiredAction}` : ""}`;
905
+ }
906
+ const tag = personStatusTag(reply.personStatus);
907
+ const who = `${clean(reply.person ?? "")}${tag ? ` (${tag})` : ""}`;
908
+ const roleLabel = `${clean(reply.roleName ?? "")} (${reply.role ?? ""})`;
909
+ const teamLabel = clean(reply.teamName ?? "");
910
+ if (action === "seat" && reply.onYourAuthority) {
911
+ return `${who} holds ${clean(reply.roleName ?? "")} of ${teamLabel} on your authority. Unseat them to revoke it.`;
912
+ }
913
+ if (action === "seat") {
914
+ const id = reply.personId ? ` [${reply.personId}]` : "";
915
+ return `${reply.created ? "Seated" : "Confirmed"} ${who}${id} as ${roleLabel} in ${teamLabel}.`;
916
+ }
917
+ return reply.removed ? `Unseated ${who} from ${roleLabel} in ${teamLabel}.` : `${who} did not hold ${roleLabel} in ${teamLabel}; nothing changed.`;
918
+ }
919
+ function formatInviteSentence(reply, clean) {
920
+ const who = `${clean(reply.person)} [${reply.personId}]`;
921
+ return reply.inPlace ? `Invited ${who} at ${clean(reply.email)}; they keep every role they already hold.` : `Invited ${who} at ${clean(reply.email)} as a new person.`;
922
+ }
923
+ var ORGANISATION_VALIDATION_REFUSALS = /* @__PURE__ */ new Set([
924
+ "duplicate_membership",
925
+ "last_team_lead",
926
+ "child_team_invalid",
927
+ "parent_team_invalid",
928
+ "existing_parent_invalid",
929
+ "hierarchy_ambiguous",
930
+ "self_parent",
931
+ "hierarchy_cycle",
932
+ "hierarchy_too_deep",
933
+ "hierarchy_too_large",
934
+ "hierarchy_repair_required",
935
+ "archived_parent_authority_invalid",
936
+ "role_still_held",
937
+ "move_not_needed",
938
+ "no_pending_move",
939
+ "why_required",
940
+ "role_unplaced",
941
+ "role_work_target_invalid"
942
+ ]);
943
+
889
944
  // src/errors.ts
890
945
  var MCP_CALL_ERROR_RE = /^MCP call "([^"]+)" failed \(\d+\): (.+)$/s;
891
946
  function asKernelCallError(err) {
@@ -919,8 +974,16 @@ function spineNextLine(details) {
919
974
  const to = next.to ?? spineKindPlaceholder(next.toKind);
920
975
  return `Next: \`relations action=create from="${next.from}" type="${next.type}" to="${to}"\`.`;
921
976
  }
977
+ function roleRetireNextLine(details) {
978
+ const retire = roleRetireDetailOf(details);
979
+ if (!retire) return null;
980
+ if (retire.holderPersonIds?.length) {
981
+ return retire.holderPersonIds.map((personId) => `Next: \`role action=unseat roleId="${retire.roleId}" person="${personId}"\`.`).join("\n");
982
+ }
983
+ return retire.openItems ? `Next: \`role action=move_work fromRoleId="${retire.roleId}" toRoleId="<role>"\`.` : null;
984
+ }
922
985
  function acceptCall(entryId, replaces) {
923
- return `\`entries action=accept entryId="${entryId}"${replaces ? ` replaces="${replaces}"` : ""}\``;
986
+ return `\`entries action=accept entryId="${entryId}"${replaces ? ` replaces="${replaces}" reason="<why>"` : ""}\``;
924
987
  }
925
988
  var GateError = class extends Error {
926
989
  constructor(message) {
@@ -996,7 +1059,7 @@ function classifyError(err) {
996
1059
  const { code: convexCode, fn, cleanMessage, missingRequiredFields, fieldErrors } = mcpErr;
997
1060
  if (convexCode === "VALIDATION_FAILED") {
998
1061
  const hasDiagnostics = missingRequiredFields?.length || fieldErrors?.length;
999
- const next2 = spineNextLine(mcpErr.details);
1062
+ const next2 = spineNextLine(mcpErr.details) ?? roleRetireNextLine(mcpErr.details);
1000
1063
  return {
1001
1064
  code: "VALIDATION_ERROR",
1002
1065
  fn,
@@ -1672,6 +1735,10 @@ export {
1672
1735
  PASTE_NOW,
1673
1736
  formatBriefingLines,
1674
1737
  SPINE_RUNG_SEQUENCE,
1738
+ PERSON_STATUS_WORDS,
1739
+ formatSeatSentence,
1740
+ formatInviteSentence,
1741
+ ORGANISATION_VALIDATION_REFUSALS,
1675
1742
  authorityRecovery,
1676
1743
  acceptCall,
1677
1744
  PASS_SESSION_ID,
@@ -1713,4 +1780,4 @@ export {
1713
1780
  appUrl,
1714
1781
  apiKeysUrl
1715
1782
  };
1716
- //# sourceMappingURL=chunk-H2SLL2NX.js.map
1783
+ //# sourceMappingURL=chunk-LWGNWR3F.js.map