@wirecat/wirecat 0.0.0-stage → 1.1.0

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.
Files changed (230) hide show
  1. package/LICENSE +204 -0
  2. package/README.md +399 -2
  3. package/THIRD_PARTY_NOTICES +2 -0
  4. package/contracts/wirecat.json +4612 -0
  5. package/dist/actions/actions.js +269 -0
  6. package/dist/actions/command.js +102 -0
  7. package/dist/agents/command.js +17 -0
  8. package/dist/agents/log.js +23 -0
  9. package/dist/answer.js +100 -0
  10. package/dist/answers/command.js +128 -0
  11. package/dist/app.js +15 -0
  12. package/dist/author.js +109 -0
  13. package/dist/bin/wcat-wirecat.js +40 -0
  14. package/dist/bots/command.js +175 -0
  15. package/dist/bundle/auto-O24ISPOI.js +43 -0
  16. package/dist/bundle/chunk-2A3YPENI.js +31 -0
  17. package/dist/bundle/chunk-6BDIFKF5.js +222 -0
  18. package/dist/bundle/chunk-7O7XM37N.js +2 -0
  19. package/dist/bundle/chunk-AYHZY24E.js +120 -0
  20. package/dist/bundle/chunk-CKBTMZUX.js +72 -0
  21. package/dist/bundle/chunk-FGXUH3XL.js +416 -0
  22. package/dist/bundle/chunk-I5JQBRRC.js +807 -0
  23. package/dist/bundle/chunk-RKVAWMZT.js +38 -0
  24. package/dist/bundle/chunk-SCDNOUUR.js +395 -0
  25. package/dist/bundle/chunk-T7TG4JKR.js +312 -0
  26. package/dist/bundle/chunk-XBUCXQKT.js +51 -0
  27. package/dist/bundle/entry-EW5A7FYV.js +64 -0
  28. package/dist/bundle/failure-HMELJ3K5.js +19 -0
  29. package/dist/bundle/from-memo-F7NTUXAR.js +314 -0
  30. package/dist/bundle/program-7XWGFN4H.js +14994 -0
  31. package/dist/bundle/server-T7RVBNRW.js +303 -0
  32. package/dist/bundle/update-JZDS7B6L.js +22 -0
  33. package/dist/bundle/wcat-wirecat.js +83 -0
  34. package/dist/config-command.js +39 -0
  35. package/dist/config-issues.js +15 -0
  36. package/dist/config.js +187 -0
  37. package/dist/context/command.js +162 -0
  38. package/dist/context/context.js +197 -0
  39. package/dist/contract-overrides/commands.js +81 -0
  40. package/dist/contract-overrides/mcp.js +241 -0
  41. package/dist/contract-overrides/meetings.js +344 -0
  42. package/dist/contract-overrides/search.js +508 -0
  43. package/dist/contract-overrides/skill.js +85 -0
  44. package/dist/contract-overrides.js +7 -0
  45. package/dist/digest/backfill.js +175 -0
  46. package/dist/digest/brief.js +189 -0
  47. package/dist/digest/catch-up-record.js +30 -0
  48. package/dist/digest/catch-up.js +86 -0
  49. package/dist/digest/command.js +110 -0
  50. package/dist/digest/digest-commands.js +327 -0
  51. package/dist/digest/digest.js +560 -0
  52. package/dist/digest/digests.js +213 -0
  53. package/dist/digest/history.js +202 -0
  54. package/dist/digest/input.js +30 -0
  55. package/dist/digest/known.js +28 -0
  56. package/dist/digest/sources.js +155 -0
  57. package/dist/digest/sync-health.js +158 -0
  58. package/dist/digest/task-proposals.js +67 -0
  59. package/dist/digest/tasks.js +145 -0
  60. package/dist/digest/text.js +49 -0
  61. package/dist/discovery/command.js +107 -0
  62. package/dist/doctor/command.js +167 -0
  63. package/dist/documents/command.js +107 -0
  64. package/dist/domain-lists/command.js +13 -0
  65. package/dist/events/command.js +35 -0
  66. package/dist/events/events.js +196 -0
  67. package/dist/examples.js +609 -0
  68. package/dist/facts/command.js +100 -0
  69. package/dist/facts/fact.js +54 -0
  70. package/dist/facts/facts.js +15 -0
  71. package/dist/failure.js +58 -0
  72. package/dist/finance/command.js +121 -0
  73. package/dist/finance/contracts-command.js +109 -0
  74. package/dist/finance/deal-text.js +34 -0
  75. package/dist/finance/deals-command.js +346 -0
  76. package/dist/finance/finance.js +129 -0
  77. package/dist/finance/lines-command.js +70 -0
  78. package/dist/finance/orders-command.js +94 -0
  79. package/dist/finance/products-command.js +98 -0
  80. package/dist/finance/subscriptions-command.js +152 -0
  81. package/dist/finance/transactions-command.js +136 -0
  82. package/dist/finance/wallets-command.js +105 -0
  83. package/dist/finance/written.js +36 -0
  84. package/dist/findings/command.js +102 -0
  85. package/dist/findings-input.js +23 -0
  86. package/dist/identity.js +20 -0
  87. package/dist/install/postinstall.js +47 -0
  88. package/dist/json-fields.js +48 -0
  89. package/dist/knowledge/business-text.js +19 -0
  90. package/dist/knowledge/command.js +435 -0
  91. package/dist/knowledge/document-context.js +33 -0
  92. package/dist/knowledge/key-documents.js +120 -0
  93. package/dist/knowledge/list-queries.js +20 -0
  94. package/dist/knowledge/meeting-projects-command.js +61 -0
  95. package/dist/knowledge/messenger-sync.js +253 -0
  96. package/dist/knowledge/money-text.js +16 -0
  97. package/dist/knowledge/notes-about.js +81 -0
  98. package/dist/knowledge/organization-delete-command.js +44 -0
  99. package/dist/knowledge/organization-text.js +27 -0
  100. package/dist/knowledge/project-actions-command.js +130 -0
  101. package/dist/knowledge/project-actions.js +104 -0
  102. package/dist/knowledge/project-activity-command.js +70 -0
  103. package/dist/knowledge/project-context.js +101 -0
  104. package/dist/knowledge/project-findings.js +41 -0
  105. package/dist/knowledge/project-gather-command.js +100 -0
  106. package/dist/knowledge/project-status-command.js +129 -0
  107. package/dist/knowledge/project-transfer-command.js +58 -0
  108. package/dist/knowledge/project-transfer.js +107 -0
  109. package/dist/knowledge/relationships-scan.js +116 -0
  110. package/dist/knowledge/relationships.js +115 -0
  111. package/dist/knowledge/roles-command.js +67 -0
  112. package/dist/mail/command.js +20 -0
  113. package/dist/mail/findings-command.js +143 -0
  114. package/dist/mail/findings-duplicates.js +159 -0
  115. package/dist/mail/messages-command.js +77 -0
  116. package/dist/mail/review-command.js +59 -0
  117. package/dist/mail/subscriptions-command.js +84 -0
  118. package/dist/mcp/catalogue.js +159 -0
  119. package/dist/mcp/command.js +125 -0
  120. package/dist/mcp/granted.js +18 -0
  121. package/dist/mcp/permissions.js +61 -0
  122. package/dist/mcp/server.js +128 -0
  123. package/dist/meetings/command.js +31 -0
  124. package/dist/meetings/list-command.js +59 -0
  125. package/dist/meetings/preparation-command.js +42 -0
  126. package/dist/meetings/preparation-text.js +44 -0
  127. package/dist/meetings/preparation.js +50 -0
  128. package/dist/meetings/read.js +32 -0
  129. package/dist/memories/command.js +105 -0
  130. package/dist/memories/memories.js +17 -0
  131. package/dist/memories/memory.js +89 -0
  132. package/dist/memories/sources.js +111 -0
  133. package/dist/mentions/command.js +91 -0
  134. package/dist/migrate/check.js +48 -0
  135. package/dist/migrate/from-memo.js +345 -0
  136. package/dist/migrate/skill.js +35 -0
  137. package/dist/models/command.js +19 -0
  138. package/dist/options.js +35 -0
  139. package/dist/output.js +17 -0
  140. package/dist/page.js +14 -0
  141. package/dist/people/command.js +144 -0
  142. package/dist/people/delete-command.js +53 -0
  143. package/dist/people/doubts-command.js +81 -0
  144. package/dist/people/identities-command.js +188 -0
  145. package/dist/people/identity.js +42 -0
  146. package/dist/people/owner.js +14 -0
  147. package/dist/people/proposal-rows.js +70 -0
  148. package/dist/people/proposals-command.js +248 -0
  149. package/dist/people/review-context.js +108 -0
  150. package/dist/people/subject.js +19 -0
  151. package/dist/program.js +875 -0
  152. package/dist/read-only.js +51 -0
  153. package/dist/reasons.js +368 -0
  154. package/dist/records/import.js +135 -0
  155. package/dist/records/input.js +210 -0
  156. package/dist/records/mapping.js +80 -0
  157. package/dist/records/record-commands.js +125 -0
  158. package/dist/records/sources.js +73 -0
  159. package/dist/refs.js +28 -0
  160. package/dist/review/command.js +171 -0
  161. package/dist/review/kinds.js +44 -0
  162. package/dist/review/review.js +299 -0
  163. package/dist/review/status.js +93 -0
  164. package/dist/rows.js +219 -0
  165. package/dist/run/auto.js +237 -0
  166. package/dist/run/entry.js +62 -0
  167. package/dist/run/files.js +51 -0
  168. package/dist/run/import.js +253 -0
  169. package/dist/run/lock.js +20 -0
  170. package/dist/save-help.js +3 -0
  171. package/dist/schedule/command.js +58 -0
  172. package/dist/schedule/mail-triage-input.js +152 -0
  173. package/dist/schedule/task-triage-input.js +152 -0
  174. package/dist/search/answers.js +176 -0
  175. package/dist/search/command.js +257 -0
  176. package/dist/search/denied.js +9 -0
  177. package/dist/search/embed.js +126 -0
  178. package/dist/search/hits.js +4 -0
  179. package/dist/search/lane-gates.js +76 -0
  180. package/dist/search/notes-text.js +18 -0
  181. package/dist/search/people.js +88 -0
  182. package/dist/search/search.js +306 -0
  183. package/dist/show/command.js +179 -0
  184. package/dist/store/crm-viewer.js +102 -0
  185. package/dist/store/group.js +112 -0
  186. package/dist/store/groups-command.js +136 -0
  187. package/dist/store/guard.js +94 -0
  188. package/dist/store/held.js +21 -0
  189. package/dist/store/info-command.js +37 -0
  190. package/dist/store/scope.js +53 -0
  191. package/dist/store/source-list.js +222 -0
  192. package/dist/store/source-target.js +28 -0
  193. package/dist/tags/command.js +176 -0
  194. package/dist/tasks/command.js +174 -0
  195. package/dist/tasks/context.js +74 -0
  196. package/dist/tasks/list.js +199 -0
  197. package/dist/tasks/proposal-duplicates.js +70 -0
  198. package/dist/tasks/relations-command.js +28 -0
  199. package/dist/tasks/shared.js +105 -0
  200. package/dist/tasks/tasks.js +197 -0
  201. package/dist/templates/command.js +18 -0
  202. package/dist/terminal.js +23 -0
  203. package/dist/update.js +35 -0
  204. package/dist/version.js +2 -0
  205. package/dist/vocabulary/command.js +103 -0
  206. package/dist/vocabulary/inspect.js +23 -0
  207. package/dist/vocabulary/inspection.js +18 -0
  208. package/dist/vocabulary/list.js +18 -0
  209. package/dist/vocabulary/project.js +19 -0
  210. package/dist/wcat.js +3 -0
  211. package/install/postinstall.mjs +9 -0
  212. package/package.json +89 -4
  213. package/scenarios/decision-trail.md +21 -0
  214. package/scenarios/person-brief.md +35 -0
  215. package/scenarios/prepare-meeting.md +17 -0
  216. package/scenarios/project-state.md +26 -0
  217. package/scenarios/set-up.md +18 -0
  218. package/scenarios/start-the-day.md +19 -0
  219. package/skills/mail-triage/SKILL.md +208 -0
  220. package/skills/morning-digest/SKILL.md +147 -0
  221. package/skills/task-triage/SKILL.md +79 -0
  222. package/skills/wcat/SKILL.md +65 -0
  223. package/skills/wcat/topics/mail.md +32 -0
  224. package/skills/wcat/topics/mcp.md +22 -0
  225. package/skills/wcat/topics/meetings.md +37 -0
  226. package/skills/wcat/topics/money.md +52 -0
  227. package/skills/wcat/topics/projects.md +54 -0
  228. package/skills/wcat/topics/proposals.md +113 -0
  229. package/skills/wcat/topics/search.md +85 -0
  230. package/skills/wcat/topics/vocabulary.md +8 -0
@@ -0,0 +1,81 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { annotate } from "@wirecat/cli-base/commands";
3
+ import { LOCAL_READ, LOCAL_WRITE } from "@wirecat/cli-core";
4
+ import { answers, itemAnswer, listAnswer, withStore } from "../answer.js";
5
+ import { byOption } from "../author.js";
6
+ import { oneOf, positive } from "../options.js";
7
+ import { groupOf, keepInGroup } from "../store/group.js";
8
+ import { personOf } from "./identity.js";
9
+ import { asOwner } from "./proposal-rows.js";
10
+ const RESOLVE_ANSWERS = ["keep", "test"];
11
+ const textOf = (doubt) => [
12
+ `${doubt.person}${doubt.name ? ` ${doubt.name}` : ""}${doubt.owner ? " (you)" : ""} · ${doubt.reason}`,
13
+ ` ${doubt.why}`,
14
+ ...doubt.identities.map(({ identity, name, method, by, at }) => ` ${identity}${name ? ` ${name}` : ""} (${method} by ${by}, ${at.slice(0, 10)})`),
15
+ ...doubt.fix.map((command) => ` fix: wcat ${command}`),
16
+ ].join("\n");
17
+ /** People that may be wrong across the whole store, so the owner or an agent can set them right. */
18
+ export const doubtsCommand = (people, program, streams, env) => {
19
+ const { print } = answers(program, streams, env);
20
+ const links = people.commands.find((command) => command.name() === "links") ??
21
+ people.command("links").description("who is who: the links that make identities one person");
22
+ annotate(links.command("check"), { effects: LOCAL_READ })
23
+ .summary("people that may be wrong, with why and the command that fixes each")
24
+ .description("people that may be wrong, you first: your person holding an identity under another name, what may be test " +
25
+ "data (sure test data is hidden without asking: people list kind:test), an " +
26
+ "identity joined by an address a person of another name has, one person with different names and nothing " +
27
+ "in common. Each says why and gives the unlink or unmerge that fixes it; an agent adds --reason and it waits " +
28
+ "for you in people review. What you linked by hand, what the person held when you did, what you kept with " +
29
+ "people links resolve <who> keep, or kept together by turning a split down, is left out")
30
+ .option("--limit <n>", "most people on a page, up to 200", positive, 20)
31
+ .option("--page <n>", "which page, from 1", positive, 1)
32
+ .option("--json", "print JSON; --json=id,title keeps only those fields")
33
+ .action(async (options) => {
34
+ const limit = Math.min(options.limit, 200);
35
+ const counted = groupOf(env) === undefined;
36
+ const found = await withStore(env, async (store) => {
37
+ const page = await store.people.doubts({ limit, offset: (options.page - 1) * limit });
38
+ // In a group the total covers people outside it (WC-ACCT-13), so the answer claims none.
39
+ return { ...page, items: await keepInGroup(store, env, page.items, ({ person }) => person) };
40
+ });
41
+ print(options.json, listAnswer("people links check", {
42
+ items: found.items,
43
+ limit,
44
+ page: options.page,
45
+ has_more: found.hasMore,
46
+ ...(counted ? { total: { value: found.total, relation: "eq" } } : {}),
47
+ }), [
48
+ found.items.map(textOf).join("\n\n") || (found.hasMore ? "none on this page" : "no person looks wrong"),
49
+ ...(found.hasMore ? [`more: --page ${options.page + 1}`] : []),
50
+ ].join("\n\n"));
51
+ });
52
+ const resolve = byOption(annotate(links.command("resolve"), { effects: LOCAL_WRITE })
53
+ .summary("say a person people links check doubts is right as they are, or test data; only you")
54
+ .description("answers a doubt with keep: the person's links are right, so links check stops listing the identities in " +
55
+ "doubt until one of them moves to another person; an identity that joins later is checked again, and an " +
56
+ "agent's split of the kept ones is refused. Keep also says what looked like test data is a real contact, " +
57
+ "and brings back a person wcat hid as test data (people list kind:test lists them). test: the person is " +
58
+ "test data, hidden from every list until you keep them")
59
+ .argument("<who>", "person:<uid> as people links check lists it, person:me, or an identity of the person")
60
+ .argument("<answer>", "keep: the person is right as they are; test: the person is test data", oneOf(RESOLVE_ANSWERS))).option("--json", "print JSON; --json=id,title keeps only those fields");
61
+ resolve.action(async (who, answer, options) => {
62
+ const person = await withStore(env, async (store) => {
63
+ const ref = `person:${(await personOf(store, who)).uid}`;
64
+ if ((await keepInGroup(store, env, [ref], (one) => one)).length === 0)
65
+ throw new CliError("not_found", `${ref} is outside the account group this run reads`, {
66
+ reason: "person.not-found",
67
+ });
68
+ return ref;
69
+ });
70
+ if (answer === "test") {
71
+ const by = await asOwner(resolve, env, `hide ${person} as test data?`);
72
+ const hidden = await withStore(env, (store) => store.people.markTestData(person, by));
73
+ print(options.json, itemAnswer(hidden), `${hidden.person}: test data, hidden (${hidden.identities.join(", ")})`);
74
+ return;
75
+ }
76
+ const by = await asOwner(resolve, env, `say ${person}'s links are right?`);
77
+ const kept = await withStore(env, (store) => store.people.keep(person, by));
78
+ print(options.json, itemAnswer(kept), `${kept.person}: kept ${kept.kept.join(", ")}`);
79
+ });
80
+ };
81
+ //# sourceMappingURL=doubts-command.js.map
@@ -0,0 +1,188 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { annotate } from "@wirecat/cli-base/commands";
3
+ import { commandRunId, currentRun, LOCAL_READ, LOCAL_WRITE, parseMergeId, } from "@wirecat/cli-core";
4
+ import { answers, itemAnswer, withStore } from "../answer.js";
5
+ import { byOption, reasonOption, UNATTENDED, whoRuns } from "../author.js";
6
+ import { agentMergesApply } from "../config.js";
7
+ import { deleteCommand } from "./delete-command.js";
8
+ import { doubtsCommand } from "./doubts-command.js";
9
+ import { exactIdentityOf, identityOf, personOf } from "./identity.js";
10
+ import { withOwner } from "./owner.js";
11
+ import { matchAnswer, summaryOf } from "./proposal-rows.js";
12
+ import { peopleProposalCommands } from "./proposals-command.js";
13
+ import { strongText, weakText } from "./review-context.js";
14
+ const PERSON = /^person:([1-9]\d*)$/;
15
+ const FROM = /^person:([1-9]\d*|me)$/;
16
+ const personAnswer = (person) => ({
17
+ ref: `person:${person.uid}`,
18
+ name: person.name,
19
+ display_name: person.displayName ?? null,
20
+ ...(person.mergedInto === undefined ? {} : { mergedInto: `person:${person.mergedInto}` }),
21
+ identities: person.identities.map((identity) => ({
22
+ identity: `${identity.provider}:${identity.id}`,
23
+ name: identity.name,
24
+ username: identity.username,
25
+ phone: identity.phone ?? null,
26
+ email: identity.email ?? null,
27
+ phones: identity.phones ?? [],
28
+ emails: identity.emails ?? [],
29
+ seenIn: identity.seenIn,
30
+ method: identity.method,
31
+ linkedBy: identity.linkedBy,
32
+ linkedAt: identity.linkedAt,
33
+ })),
34
+ });
35
+ const identitiesOf = async (store, refs) => {
36
+ const found = [];
37
+ for (const ref of refs)
38
+ found.push(await identityOf(store, ref));
39
+ return found;
40
+ };
41
+ /** Who is who across sources: one person's identities and merges, the matches waiting, and the owner's moves. */
42
+ export const identitiesCommands = (people, program, streams, env) => {
43
+ const { print } = answers(program, streams, env);
44
+ annotate(people.command("show"), { effects: LOCAL_READ })
45
+ .summary("one person: identities by source, merges and open matches")
46
+ .description("one person: their identities by source with the accounts that saw each, merges and open matches")
47
+ .argument("<who>", "person:<uid>, or <messenger>:<name or id> of an identity of the person")
48
+ .option("--json", "print JSON; --json=id,title keeps only those fields")
49
+ .action(async (who, options) => {
50
+ const shown = await withStore(env, async (store) => {
51
+ const person = await personOf(store, who);
52
+ const matches = await store.people.linkProposals({ person: person.uid, limit: 500, offset: 0 });
53
+ return {
54
+ ...personAnswer(person),
55
+ merges: await store.people.merges(person.uid),
56
+ matches: matches.items.map(matchAnswer),
57
+ };
58
+ });
59
+ print(options.json, itemAnswer(shown), [
60
+ `${shown.ref} ${shown.display_name ?? ""}`.trim(),
61
+ ...shown.identities.map(({ identity, name }) => ` ${identity}${name ? ` ${name}` : ""}`),
62
+ ...shown.merges.map(({ id, from, method, by, at }) => ` merged: ${id} (person:${from}) by ${by} via ${method}, ${at.slice(0, 10)}`),
63
+ ...shown.matches.map((match) => ` match ${match.id}: ${summaryOf(match)}`),
64
+ ].join("\n"));
65
+ });
66
+ peopleProposalCommands(people, program, streams, env);
67
+ doubtsCommand(people, program, streams, env);
68
+ deleteCommand(people, program, streams, env);
69
+ annotate(people.command("scan"), { effects: LOCAL_WRITE })
70
+ .summary("match people across sources now; wcat sync does it too")
71
+ .description("match people across sources now: the same address or a phone two people share joins them, the rest waits " +
72
+ "in people review; wcat sync runs it too")
73
+ .option("--json", "print JSON; --json=id,title keeps only those fields")
74
+ .action(async (options) => {
75
+ const scan = await withStore(env, (store) => store.people.scanMatches());
76
+ print(options.json, itemAnswer(scan), `${scan.merged.length} joined, ${scan.proposed.filter(({ opened }) => opened).length} new matches, ` +
77
+ `${scan.skipped.length} left apart`);
78
+ });
79
+ reasonOption(byOption(annotate(people.command("link"), { effects: LOCAL_WRITE })
80
+ .summary("say two identities are one person; an agent's merges only on strong evidence")
81
+ .description("say two identities are one person: yours links them; an agent's merges them at once when the store finds " +
82
+ "strong evidence (one mobile number or personal address no one else has, or each source has once, from " +
83
+ "two sources, one of them a messenger or a call for a phone), and otherwise waits for you as a match that says why; " +
84
+ "agent_merges: propose makes every agent's link wait; wcat people unmerge undoes a merge")
85
+ .argument("<identity>", "<messenger>:<name or id>")
86
+ .argument("<other>", "<messenger>:<name or id> of the person it joins")))
87
+ .option("--json", "print JSON; --json=id,title keeps only those fields")
88
+ .action(async (one, other, options, command) => {
89
+ const who = await whoRuns(command, env, {
90
+ asOwner: options.asOwner,
91
+ question: `link ${one} and ${other} as you?`,
92
+ });
93
+ if (who !== "owner" && !options.reason?.trim())
94
+ throw new CliError("validation_error", "an agent's link says why with --reason", {
95
+ reason: "proposal.reason-required",
96
+ param: "reason",
97
+ });
98
+ const done = await withStore(env, async (store) => {
99
+ const [identity, joined] = (await identitiesOf(store, [one, other]));
100
+ if (who === "owner") {
101
+ const person = await store.people.linkIdentities(joined, identity, { method: "manual", by: "owner" });
102
+ return { outcome: "linked", person: `person:${person.uid}` };
103
+ }
104
+ // A run nobody named could be anyone, so it never merges.
105
+ const apply = who.bot !== UNATTENDED && agentMergesApply(env);
106
+ const linked = await store.people.agentLink({
107
+ identity,
108
+ with: joined,
109
+ bot: who.bot,
110
+ run: commandRunId() ?? currentRun().runId,
111
+ reason: options.reason?.trim(),
112
+ apply,
113
+ });
114
+ return linked.outcome === "merged"
115
+ ? { ...linked, outcome: "merged" }
116
+ : { outcome: "proposed", proposal: linked.proposal, evidence: linked.evidence };
117
+ });
118
+ print(options.json, itemAnswer(done), done.outcome === "linked"
119
+ ? `linked: ${done.person}`
120
+ : done.outcome === "merged"
121
+ ? `merged into ${done.person} on ${strongText(done.evidence)}; wcat people unmerge ${done.merge} undoes it`
122
+ : `waits for the owner as match ${done.proposal}: ${weakText(done.evidence)}`);
123
+ });
124
+ /**
125
+ * The owner's separations apply at once; anyone else's waits for the owner as a split proposal, with why. A run with
126
+ * no reason that is not the owner's is refused before anything is read.
127
+ */
128
+ const separation = async (command, question, reason) => {
129
+ const who = await whoRuns(command, env, { asOwner: command.opts().asOwner, question });
130
+ if (who !== "owner" && !reason?.trim())
131
+ throw new CliError("validation_error", "an agent's split waits for the owner; say why with --reason", {
132
+ reason: "proposal.reason-required",
133
+ param: "reason",
134
+ });
135
+ return who;
136
+ };
137
+ const proposed = (json, proposal) => print(json, itemAnswer({ outcome: "proposed", proposal }), `waits for the owner as split ${proposal}: wcat people review`);
138
+ reasonOption(byOption(annotate(people.command("unlink"), { effects: LOCAL_WRITE })
139
+ .summary("take identities off a person, to one new person; an agent's waits for you")
140
+ .description("take identities off their person: one gets a person of its own again, several move together to one new " +
141
+ "person, and no automatic match joins them back; yours applies at once, an agent's waits for you in " +
142
+ "people review")
143
+ .argument("<identities...>", "the identities that leave, each <messenger>:<id> exactly, all of one person")))
144
+ .option("--from <person>", "the person they leave, person:<uid> or person:me; refused when they sit on another")
145
+ .option("--json", "print JSON; --json=id,title keeps only those fields")
146
+ .action(async (refs, options, command) => {
147
+ if (!FROM.test(options.from?.trim() ?? ""))
148
+ throw new CliError("validation_error", "say whom they leave: --from person:<uid> or --from person:me; wcat people show <identity> names who holds one", { reason: "person.from-required", param: "from" });
149
+ const who = await separation(command, `unlink ${refs.join(" ")} from ${options.from}?`, options.reason);
150
+ const done = await withStore(env, async (store) => {
151
+ const from = PERSON.exec(await withOwner(store, options.from.trim()))?.[1];
152
+ const chosen = [];
153
+ for (const ref of refs)
154
+ chosen.push(await exactIdentityOf(store, ref));
155
+ if (who !== "owner") {
156
+ const reason = options.reason?.trim();
157
+ return { proposal: (await store.people.proposeSplit({ identities: chosen, from, by: who, reason })).id };
158
+ }
159
+ const [first] = chosen;
160
+ if (chosen.length === 1)
161
+ return store.people.unlinkIdentity(first, { method: "unlink", by: "owner", from });
162
+ return store.people.split(from, chosen, "owner");
163
+ });
164
+ if ("proposal" in done)
165
+ proposed(options.json, done.proposal);
166
+ else
167
+ print(options.json, itemAnswer(personAnswer(done)), `person:${done.uid}`);
168
+ });
169
+ reasonOption(byOption(annotate(people.command("unmerge"), { effects: LOCAL_WRITE })
170
+ .summary("undo a merge: its identities go back to their person; an agent's waits for you")
171
+ .description("give the identities a merge brought back to the person they came from; yours applies at once, an " +
172
+ "agent's waits for you in people review")
173
+ .argument("<merge>", "merge:<to>-<from>, as people show lists it")))
174
+ .option("--json", "print JSON; --json=id,title keeps only those fields")
175
+ .action(async (merge, options, command) => {
176
+ const { to, from } = parseMergeId(merge);
177
+ const who = await separation(command, `undo ${merge}?`, options.reason);
178
+ if (who !== "owner") {
179
+ const reason = options.reason?.trim();
180
+ const proposal = await withStore(env, (store) => store.people.proposeSplit({ merge, by: who, reason }));
181
+ proposed(options.json, proposal.id);
182
+ return;
183
+ }
184
+ const person = await withStore(env, (store) => store.people.undoMerge(to, from, "owner"));
185
+ print(options.json, itemAnswer(personAnswer(person)), `person:${person.uid}`);
186
+ });
187
+ };
188
+ //# sourceMappingURL=identities-command.js.map
@@ -0,0 +1,42 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { pickPerson } from "@wirecat/cli-core";
3
+ import { withOwner } from "./owner.js";
4
+ const parsed = (reference) => {
5
+ const match = /^([a-z][a-z0-9-]*):(.+)$/.exec(reference.trim());
6
+ if (match === null)
7
+ throw new CliError("validation_error", `"${reference}" names no messenger — write it as <messenger>:<name or id>`, {
8
+ reason: "identity.no-messenger",
9
+ });
10
+ const [, provider = "", who = ""] = match;
11
+ return { provider, who };
12
+ };
13
+ /** `telegram:Ana`, `max:12345`, `email:ana@example.com` — the messenger is always named. */
14
+ export const identityOf = async (store, reference) => {
15
+ const { provider, who } = parsed(reference);
16
+ const people = await store.people.people(provider);
17
+ const exact = people.get(provider === "email" ? who.toLowerCase() : who);
18
+ return { provider, id: exact?.id ?? pickPerson(who, people).id };
19
+ };
20
+ /**
21
+ * `<messenger>:<id>` exactly as the store keeps it. The owner's separations take only this: a name that resolves to
22
+ * the nearest person would take apart someone the owner did not name.
23
+ */
24
+ export const exactIdentityOf = async (store, reference) => {
25
+ const { provider, who } = parsed(reference);
26
+ const ref = { provider, id: provider === "email" ? who.toLowerCase() : who };
27
+ if ((await store.people.personOf(ref)) === undefined)
28
+ throw new CliError("not_found", `the store has no identity ${provider}:${who}; people show lists the exact ids`, {
29
+ reason: "identity.not-found",
30
+ });
31
+ return ref;
32
+ };
33
+ const PERSON = /^person:([1-9]\d*)$/;
34
+ /** `person:<uid>`, `person:me`, or an identity of the person as `<messenger>:<name or id>`. */
35
+ export const personOf = async (store, who) => {
36
+ const uid = PERSON.exec((await withOwner(store, who)).trim())?.[1];
37
+ const found = uid === undefined ? await store.people.personOf(await identityOf(store, who)) : await store.people.personByUid(uid);
38
+ if (found === undefined)
39
+ throw new CliError("not_found", `the store has no person for "${who}"`, { reason: "person.not-found" });
40
+ return found;
41
+ };
42
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1,14 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ /**
3
+ * `person:me` as the owner's `person:<uid>`; any other reference as written. The store always holds an owner row; it is
4
+ * marked once an identity is linked to it.
5
+ */
6
+ export const withOwner = async (store, reference) => {
7
+ if (reference.trim() !== "person:me")
8
+ return reference;
9
+ const owner = await store.people.owner();
10
+ if (owner === undefined || owner.identities.length === 0)
11
+ throw new CliError("not_found", "person:me: no person is marked as you in the store; mark yours with `tg <profile> contacts link <your id> me`", { reason: "person.no-owner" });
12
+ return `person:${owner.uid}`;
13
+ };
14
+ //# sourceMappingURL=owner.js.map
@@ -0,0 +1,70 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { whoRuns } from "../author.js";
3
+ /** The owner's moves: refused for anyone else before anything is read, whatever the store would say. */
4
+ export const asOwner = async (command, env, question) => {
5
+ const options = command.opts();
6
+ const who = await whoRuns(command, env, { asOwner: options.asOwner, question });
7
+ if (who !== "owner")
8
+ throw new CliError("permission_error", `only the owner can ${question.replace(/\?$/, "")}`, {
9
+ reason: "identity.owner-only",
10
+ });
11
+ return who;
12
+ };
13
+ export const matchAnswer = (row) => ({
14
+ id: row.id,
15
+ kind: "identity_link",
16
+ persons: row.persons,
17
+ joins: row.joins,
18
+ identity: row.identity,
19
+ with: row.with,
20
+ signal: row.signal,
21
+ score: row.score,
22
+ shared: row.shared,
23
+ mailbox: row.mailbox,
24
+ candidates: row.candidates,
25
+ reason: row.reason,
26
+ evidence: row.evidence,
27
+ proposedBy: row.proposedBy,
28
+ createdAt: row.createdAt,
29
+ });
30
+ /**
31
+ * A split names one `person`, never a `persons` pair: an app that reads every row with two persons as a match would
32
+ * offer to confirm a split under a merge's words.
33
+ */
34
+ export const splitAnswer = (row) => ({
35
+ id: row.id,
36
+ kind: "identity_split",
37
+ split: row.split,
38
+ person: row.person,
39
+ identities: row.identities,
40
+ merge: row.merge,
41
+ reason: row.reason,
42
+ evidence: row.evidence,
43
+ proposedBy: row.proposedBy,
44
+ createdAt: row.createdAt,
45
+ });
46
+ export const summaryOf = (row) => {
47
+ if (row.kind === "identity_link") {
48
+ const why = [row.signal, ...(row.mailbox ? [`shared mailbox ${row.mailbox}`] : [])];
49
+ const score = row.score === null ? "" : `, score ${row.score}`;
50
+ return `${row.identity} may be the same person as ${row.with ?? row.persons[1]} (${why.join(", ")}${score})`;
51
+ }
52
+ return row.split === "unmerge"
53
+ ? `undo ${row.merge}: ${row.identities.join(" ")} go back to their own person`
54
+ : `take ${row.identities.join(" ")} off ${row.person}`;
55
+ };
56
+ export const PROPOSAL_KINDS = ["all", "link", "split"];
57
+ const scoreOf = (row) => (row.kind === "identity_link" ? (row.score ?? -1) : -1);
58
+ /**
59
+ * The matches and splits waiting for the owner, highest score first, those without one newest first after them
60
+ * (NEED-2527), at most `limit`, and whether more wait.
61
+ */
62
+ export const waiting = async (store, { kind, limit }) => {
63
+ const none = { items: [], hasMore: false };
64
+ const page = { status: "proposed", limit, offset: 0 };
65
+ const links = kind === "split" ? none : await store.people.linkProposals({ ...page, order: "score" });
66
+ const splits = kind === "link" ? none : await store.people.splitProposals(page);
67
+ const rows = [...links.items.map(matchAnswer), ...splits.items.map(splitAnswer)].sort((a, b) => scoreOf(b) - scoreOf(a) || b.createdAt.localeCompare(a.createdAt) || Number(b.id) - Number(a.id));
68
+ return { items: rows.slice(0, limit), hasMore: links.hasMore || splits.hasMore || rows.length > limit };
69
+ };
70
+ //# sourceMappingURL=proposal-rows.js.map
@@ -0,0 +1,248 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { annotate } from "@wirecat/cli-base/commands";
3
+ import { IDENTITY_LINK_KIND, IDENTITY_SPLIT_KIND, LOCAL_READ, LOCAL_WRITE, parseProposalIds, } from "@wirecat/cli-core";
4
+ import { answers, itemAnswer, listAnswer, shortenedBy, withStore } from "../answer.js";
5
+ import { byOption } from "../author.js";
6
+ import { oneOf, positive } from "../options.js";
7
+ import { decidedText, decisionOf } from "../review/review.js";
8
+ import { deniedCrmKinds } from "../search/denied.js";
9
+ import { crmNotes } from "../store/crm-viewer.js";
10
+ import { reviewOf } from "../store/guard.js";
11
+ import { asOwner, PROPOSAL_KINDS, summaryOf, waiting } from "./proposal-rows.js";
12
+ import { agentMergeAnswer, sideLines, sideOf, weakText } from "./review-context.js";
13
+ /** `merged` is what agents merged on strong evidence: the review lists it, and confirm and reject never take it. */
14
+ const REVIEW_KINDS = [...PROPOSAL_KINDS, "merged"];
15
+ const PEOPLE_KINDS = [IDENTITY_LINK_KIND, IDENTITY_SPLIT_KIND];
16
+ const limitOf = (limit) => {
17
+ if (limit > 500)
18
+ throw new CliError("validation_error", "--limit takes 1–500", { param: "limit" });
19
+ return limit;
20
+ };
21
+ /** Only the people review's own proposals; any other id is refused on its own, so the rest are still decided. */
22
+ const peopleIds = async (store, ids) => {
23
+ const kept = [];
24
+ const refused = [];
25
+ for (const id of ids) {
26
+ const kind = await store.proposedActions.get(id).then((action) => action.kind, () => undefined);
27
+ if (kind === undefined)
28
+ refused.push({ id, code: "not_found", reason: "proposal.not-found", message: `no proposal ${id}` });
29
+ else if (!PEOPLE_KINDS.includes(kind))
30
+ refused.push({
31
+ id,
32
+ code: "validation_error",
33
+ reason: "proposal.not-people",
34
+ message: `${id} is a ${kind} proposal; wcat review decides it`,
35
+ });
36
+ else
37
+ kept.push(id);
38
+ }
39
+ return { ids: kept, refused };
40
+ };
41
+ /**
42
+ * The owner's answers besides confirm and reject: one address is a company's (NEED-2528), or both people are the
43
+ * company's mailboxes (NEED-2573).
44
+ */
45
+ const RESOLVE_ANSWERS = ["company", "organization"];
46
+ const organizationOf = (word) => {
47
+ if (word === undefined)
48
+ return undefined;
49
+ const id = /^(?:organization:)?(\d+)$/.exec(word)?.[1];
50
+ if (id === undefined)
51
+ throw new CliError("validation_error", `${word} is not an organization; it looks like organization:12`, {
52
+ param: "organization",
53
+ });
54
+ return Number(id);
55
+ };
56
+ /** The matches and splits waiting for the owner, and the owner's answer to one, several or all of them. */
57
+ export const peopleProposalCommands = (people, program, streams, env) => {
58
+ const { print } = answers(program, streams, env);
59
+ const review = annotate(people.command("review"), { effects: LOCAL_READ })
60
+ .summary("people that may be one, an agent's splits, and what agents merged")
61
+ .description("what waits for the owner about who is who: matches (people that may be one) and splits (identities an agent " +
62
+ "says are not this person), highest score first, then newest; each match says what the two share and why " +
63
+ "it is not strong enough for an agent to merge, and each side: identities by source, the last messages or " +
64
+ "calls with dates, companies and deals (--full: more of each, with phones, addresses and accounts; --brief: " +
65
+ "no sides). --kind merged lists what agents merged on strong " +
66
+ "evidence, each with the people unmerge that undoes it. people confirm or people reject answers a match " +
67
+ "or a split, and people resolve company answers a match on a shared mailbox")
68
+ .option("--kind <kind>", `${REVIEW_KINDS.join(", ")} (default all)`, oneOf(REVIEW_KINDS), "all")
69
+ .option("--brief", "each match without its two sides")
70
+ .option("--full", "each side with phones, addresses, accounts, and more messages and calls in full")
71
+ .option("--limit <n>", "most proposals, up to 500", positive, 50)
72
+ .option("--json", "print JSON; --json=id,title keeps only those fields");
73
+ review.action(async (options) => {
74
+ if (options.brief && options.full)
75
+ throw new CliError("validation_error", "--brief and --full ask for opposite things; give one", {
76
+ param: "full",
77
+ });
78
+ const detail = options.brief ? "none" : options.full ? "full" : "brief";
79
+ const limit = limitOf(options.limit);
80
+ if (options.kind === "merged") {
81
+ const merged = await withStore(env, (store) => store.people.agentMerges({ limit, offset: 0 }));
82
+ const items = merged.items.map(agentMergeAnswer);
83
+ print(options.json, listAnswer("people review", { items, limit, has_more: merged.hasMore }), items
84
+ .map((item) => `${item.id} ${item.from} into ${item.person} by ${item.by}, ${item.at.slice(0, 10)}`)
85
+ .concat(items.length ? [`undo one: wcat people unmerge <merge>`] : [])
86
+ .join("\n") || "no merge an agent made is in place");
87
+ return;
88
+ }
89
+ const kind = options.kind;
90
+ const deniedKinds = deniedCrmKinds(review, env);
91
+ const found = await withStore(env, async (store) => {
92
+ const listed = await waiting(store, { kind, limit });
93
+ const links = listed.items.filter((row) => row.kind === "identity_link");
94
+ const evidence = await store.people.linkEvidence(links.map(({ persons }) => persons));
95
+ const sides = new Map();
96
+ const sideFor = async (person) => {
97
+ if (detail === "none")
98
+ return undefined;
99
+ const known = sides.get(person) ?? (await sideOf(store, env, person, detail, deniedKinds));
100
+ sides.set(person, known);
101
+ return known;
102
+ };
103
+ const items = [];
104
+ for (const row of listed.items) {
105
+ if (row.kind !== "identity_link") {
106
+ items.push(row);
107
+ continue;
108
+ }
109
+ const strength = evidence[links.indexOf(row)];
110
+ const both = detail === "none" ? {} : { sides: [await sideFor(row.persons[0]), await sideFor(row.persons[1])] };
111
+ items.push({ ...row, strength, ...both });
112
+ }
113
+ return { items, hasMore: listed.hasMore, notes: crmNotes(store) };
114
+ });
115
+ print(options.json, shortenedBy(found.notes, listAnswer("people review", { items: found.items, limit, has_more: found.hasMore })), [
116
+ ...found.items.flatMap((row) => [
117
+ `${row.id} ${summaryOf(row)}${row.reason ? ` — ${row.reason}` : ""}`,
118
+ ...("strength" in row ? [` not merged: ${weakText(row.strength)}`] : []),
119
+ ...("sides" in row ? row.sides.flatMap(sideLines) : []),
120
+ ]),
121
+ ...(found.hasMore ? [`more wait: --limit ${Math.min(500, limit * 2)}`] : []),
122
+ ].join("\n") || "nothing about people waits for you");
123
+ });
124
+ for (const name of ["confirm", "reject"]) {
125
+ const confirm = name === "confirm";
126
+ const command = byOption(annotate(people.command(name), { effects: LOCAL_WRITE })
127
+ .summary(confirm
128
+ ? "confirm matches and splits by id, or all that people review lists; only you"
129
+ : "turn down matches and splits by id, or all that people review lists; only you")
130
+ .description(confirm
131
+ ? "confirm matches (the people become one) and splits (the identities leave their person) by id or range " +
132
+ "as people review lists them, or `all` of what it lists with the same --kind and --limit; each is " +
133
+ "decided on its own, so a refusal leaves the others decided. `all` shows what it would do until --yes"
134
+ : "turn down matches and splits by id or range, or `all` of what people review lists; a turned-down match " +
135
+ "comes back only on new evidence, a turned-down split not while its identities stay on that person. " +
136
+ "`all` shows what it would do until --yes")
137
+ .argument("<ids...>", "ids or ranges as people review lists them (17080 17082-17085), or all"))
138
+ .option("--kind <kind>", `with all: ${PROPOSAL_KINDS.join(", ")} (default all)`, oneOf(PROPOSAL_KINDS), "all")
139
+ .option("--limit <n>", "with all: as many as people review lists, up to 500", positive, 50)
140
+ .option("--yes", "with all: do it, not only show what would be done");
141
+ if (confirm)
142
+ command.option("--reason <text>", "why, in a few words");
143
+ else
144
+ command.requiredOption("--reason <text>", "why they are turned down, in a few words");
145
+ command.option("--json", "print JSON; --json=id,title keeps only those fields");
146
+ command.action(async (words, options) => {
147
+ const everything = words.length === 1 && words[0]?.toLowerCase() === "all";
148
+ const limit = limitOf(options.limit);
149
+ await asOwner(command, env, `${name} ${everything ? "all waiting" : words.join(" ")} people proposals?`);
150
+ const result = await withStore(env, async (store) => {
151
+ const listed = everything ? await waiting(store, { kind: options.kind, limit }) : undefined;
152
+ const chosen = listed
153
+ ? { ids: listed.items.map(({ id }) => id), refused: [] }
154
+ : await peopleIds(store, parseProposalIds(words));
155
+ const more = listed?.hasMore ?? false;
156
+ if (everything && !options.yes)
157
+ return { kind: "preview", preview: chosen.ids, more };
158
+ const done = await (await reviewOf(store, env)).decide(chosen.ids, decisionOf(confirm, "owner", options.reason));
159
+ return { kind: "decided", ...done, refused: [...chosen.refused, ...done.refused], more };
160
+ });
161
+ const moreText = result.more ? `\nmore wait than --limit ${limit}; run it again for the rest` : "";
162
+ if (result.kind === "preview") {
163
+ const count = result.preview.length;
164
+ print(options.json, itemAnswer({ outcome: "preview", would: name, ids: result.preview, has_more: result.more }), count === 0
165
+ ? "nothing about people waits for you"
166
+ : `would ${name} ${count}: ${result.preview.join(" ")}\nnothing changed; add --yes to ${name} them${moreText}`);
167
+ return;
168
+ }
169
+ const { more, kind: _, ...decided } = result;
170
+ const issues = decided.refused.map((one) => ({ code: one.code, source: one.id, reason: one.reason }));
171
+ print(options.json, itemAnswer({ ...decided, has_more: more }, issues.length ? { meta: { complete: false, issues } } : undefined), decidedText(decided) + moreText);
172
+ });
173
+ }
174
+ const company = byOption(annotate(people.command("resolve"), { effects: LOCAL_WRITE })
175
+ .summary("say a match's mailbox, or both its people, are a company's; only you")
176
+ .description("answers a match with company: the address goes to the " +
177
+ "organization you name, else to the one that has the address or its company domain, else to one named " +
178
+ "--name, else to a new company named after the domain. The two people are not joined and are not proposed " +
179
+ "again on that address. A match on a shared mailbox (people review shows shared and mailbox) names its " +
180
+ "address; on any other match, by name say, --mailbox names which of the two people's addresses it is. " +
181
+ "organization answers a match whose two people are the company's mailboxes: every address on it goes to " +
182
+ "one organization, chosen the same way, else named after the people's shared name; people who are only " +
183
+ "those addresses become the company's, people with other identities keep them and stay people")
184
+ .argument("<id>", "the match's id as people review lists it")
185
+ .argument("<answer>", "company: the mailbox is a company's, not either person's; organization: both are the company's mailboxes", oneOf(RESOLVE_ANSWERS))
186
+ .argument("[organization]", "organization:<id> to give the addresses to"))
187
+ .option("--name <name>", "the company's name, when no organization is named")
188
+ .option("--mailbox <address>", "with company, on a match not about a shared mailbox: the company's address")
189
+ .option("--all", "every match waiting on the same addresses, in this one answer; without it, only this match")
190
+ .option("--reason <text>", "why, in a few words")
191
+ .option("--json", "print JSON; --json=id,title keeps only those fields");
192
+ company.action(async (id, answer, organization, options) => {
193
+ const owned = organizationOf(organization);
194
+ if (answer === "organization") {
195
+ if (options.mailbox !== undefined)
196
+ throw new CliError("validation_error", "organization gives every address on the match; drop --mailbox", {
197
+ param: "mailbox",
198
+ });
199
+ await asOwner(company, env, `say the people of people proposal ${id} are a company's mailboxes?`);
200
+ const decided = await withStore(env, async (store) => {
201
+ await (await reviewOf(store, env)).get(id);
202
+ return store.people.decideLink(id, {
203
+ confirm: false,
204
+ by: "owner",
205
+ organization: {
206
+ ...(owned === undefined ? {} : { organization: owned }),
207
+ ...(options.name ? { name: options.name } : {}),
208
+ ...(options.all ? { all: true } : {}),
209
+ },
210
+ ...(options.reason ? { reason: options.reason } : {}),
211
+ });
212
+ });
213
+ const result = decided.result;
214
+ const people = result.people.length > 0 ? `; ${result.people.join(" ")} are the company's now` : "";
215
+ print(options.json, itemAnswer({
216
+ id,
217
+ kind: IDENTITY_LINK_KIND,
218
+ status: "rejected",
219
+ organization: result.organization,
220
+ mailboxes: result.mailboxes,
221
+ people: result.people,
222
+ closed: result.closed,
223
+ }), `${result.closed.join(" ")}: ${result.mailboxes.join(", ")} belong to ${result.organization}${people}`);
224
+ return;
225
+ }
226
+ await asOwner(company, env, `say the mailbox of people proposal ${id} is a company's?`);
227
+ const decided = await withStore(env, async (store) => {
228
+ await (await reviewOf(store, env)).get(id);
229
+ return store.people.decideLink(id, {
230
+ confirm: false,
231
+ by: "owner",
232
+ company: {
233
+ ...(owned === undefined ? {} : { organization: owned }),
234
+ ...(options.name ? { name: options.name } : {}),
235
+ ...(options.mailbox ? { mailbox: options.mailbox } : {}),
236
+ ...(options.all ? { all: true } : {}),
237
+ },
238
+ ...(options.reason ? { reason: options.reason } : {}),
239
+ });
240
+ });
241
+ const result = decided.result;
242
+ const given = result?.organization ?? null;
243
+ const closed = result?.closed ?? [id];
244
+ const mailbox = result?.mailbox ?? decided.payload.mailbox ?? null;
245
+ print(options.json, itemAnswer({ id, kind: IDENTITY_LINK_KIND, status: "rejected", mailbox, organization: given, closed }), `${closed.join(" ")}: ${mailbox} is ${given}'s mailbox now; the people on it stay apart`);
246
+ });
247
+ };
248
+ //# sourceMappingURL=proposals-command.js.map