@wirecat/cli-core 0.398.0 → 0.400.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 (248) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/dist/analysis/consents.d.ts +11 -6
  3. package/dist/analysis/consents.js +5 -2
  4. package/dist/cli/analysis-choice.d.ts +1 -0
  5. package/dist/cli/analysis-choice.js +3 -0
  6. package/dist/cli/bot/admins.js +14 -4
  7. package/dist/cli/bot/command.js +38 -16
  8. package/dist/cli/bot/examples.d.ts +3 -0
  9. package/dist/cli/bot/examples.js +2 -0
  10. package/dist/cli/bot/mcp.js +6 -2
  11. package/dist/cli/bot/messages.js +17 -6
  12. package/dist/cli/bot/moderation.js +16 -4
  13. package/dist/cli/bot/people.js +16 -4
  14. package/dist/cli/bot/setup.js +27 -8
  15. package/dist/cli/bot/watch.js +7 -1
  16. package/dist/cli/config-command.js +20 -1
  17. package/dist/cli/context.d.ts +2 -0
  18. package/dist/cli/context.js +1 -1
  19. package/dist/cli/effects.d.ts +4 -1
  20. package/dist/cli/effects.js +10 -2
  21. package/dist/cli/embedding-choice.d.ts +2 -1
  22. package/dist/cli/embedding-choice.js +4 -1
  23. package/dist/cli/index.d.ts +1 -1
  24. package/dist/cli/index.js +1 -1
  25. package/dist/cli/json-fields.js +12 -1
  26. package/dist/cli/messenger/account-command.js +15 -6
  27. package/dist/cli/messenger/account-profile-query.d.ts +2 -0
  28. package/dist/cli/messenger/account-profile-query.js +13 -0
  29. package/dist/cli/messenger/account-sessions-command.js +1 -0
  30. package/dist/cli/messenger/admin-commands.js +30 -21
  31. package/dist/cli/messenger/admin-contacts-command.js +6 -3
  32. package/dist/cli/messenger/admin-folders-command.js +5 -5
  33. package/dist/cli/messenger/admin-moderation-command.js +4 -4
  34. package/dist/cli/messenger/admin-statistics-command.js +6 -14
  35. package/dist/cli/messenger/analysis-consents-query.d.ts +5 -0
  36. package/dist/cli/messenger/analysis-consents-query.js +20 -0
  37. package/dist/cli/messenger/archive-commands.js +3 -3
  38. package/dist/cli/messenger/attachments-command.js +3 -0
  39. package/dist/cli/messenger/backfill-command.js +5 -4
  40. package/dist/cli/messenger/catch-up-answers.d.ts +2 -1
  41. package/dist/cli/messenger/catch-up-answers.js +6 -2
  42. package/dist/cli/messenger/chat-queries.d.ts +1 -0
  43. package/dist/cli/messenger/chat-queries.js +12 -2
  44. package/dist/cli/messenger/chats-command.js +2 -2
  45. package/dist/cli/messenger/chats-documents-command.js +7 -5
  46. package/dist/cli/messenger/chats-members-command.js +7 -3
  47. package/dist/cli/messenger/chats-read-command.js +1 -1
  48. package/dist/cli/messenger/chats-stats-command.js +1 -1
  49. package/dist/cli/messenger/chats-tracking-command.js +14 -6
  50. package/dist/cli/messenger/contacts-command.js +11 -7
  51. package/dist/cli/messenger/context.d.ts +2 -0
  52. package/dist/cli/messenger/conversations-command.js +47 -29
  53. package/dist/cli/messenger/doctor-command.js +5 -1
  54. package/dist/cli/messenger/document-links-query.d.ts +2 -0
  55. package/dist/cli/messenger/document-links-query.js +9 -0
  56. package/dist/cli/messenger/download-command.js +1 -0
  57. package/dist/cli/messenger/flood-command.d.ts +2 -2
  58. package/dist/cli/messenger/flood-command.js +3 -3
  59. package/dist/cli/messenger/gaps-command.js +2 -2
  60. package/dist/cli/messenger/guard-commands.js +35 -13
  61. package/dist/cli/messenger/hearing-command.d.ts +1 -1
  62. package/dist/cli/messenger/hearing-command.js +1 -1
  63. package/dist/cli/messenger/images-command.js +1 -0
  64. package/dist/cli/messenger/inbox.js +6 -4
  65. package/dist/cli/messenger/media-archive-command.js +2 -0
  66. package/dist/cli/messenger/media-archive-move-command.js +1 -0
  67. package/dist/cli/messenger/media-archive-timer-command.js +1 -1
  68. package/dist/cli/messenger/mentions-command.js +15 -2
  69. package/dist/cli/messenger/messages-command.js +2 -0
  70. package/dist/cli/messenger/messages-delete-command.js +1 -0
  71. package/dist/cli/messenger/messages-edit-command.js +1 -0
  72. package/dist/cli/messenger/messages-evidence-command.js +3 -1
  73. package/dist/cli/messenger/messages-forward-command.js +1 -0
  74. package/dist/cli/messenger/messages-pin-command.js +3 -0
  75. package/dist/cli/messenger/messages-send-command.js +1 -0
  76. package/dist/cli/messenger/messages-stats-command.js +1 -1
  77. package/dist/cli/messenger/metadata-command.js +7 -2
  78. package/dist/cli/messenger/models-command.js +10 -2
  79. package/dist/cli/messenger/polls-command.js +4 -0
  80. package/dist/cli/messenger/private-people-command.js +8 -6
  81. package/dist/cli/messenger/rankings-command.js +6 -11
  82. package/dist/cli/messenger/reactions-command.js +2 -0
  83. package/dist/cli/messenger/recipients-query.d.ts +5 -0
  84. package/dist/cli/messenger/recipients-query.js +18 -0
  85. package/dist/cli/messenger/records-command.js +13 -6
  86. package/dist/cli/messenger/replies-edit-command.d.ts +1 -1
  87. package/dist/cli/messenger/replies-edit-command.js +13 -5
  88. package/dist/cli/messenger/retention-command.js +1 -1
  89. package/dist/cli/messenger/review.js +6 -4
  90. package/dist/cli/messenger/search-command.js +3 -1
  91. package/dist/cli/messenger/searches-command.js +6 -2
  92. package/dist/cli/messenger/sends-query.d.ts +5 -0
  93. package/dist/cli/messenger/sends-query.js +33 -0
  94. package/dist/cli/messenger/serve-command.js +1 -0
  95. package/dist/cli/messenger/serve-relay.d.ts +1 -0
  96. package/dist/cli/messenger/statistics-query.d.ts +14 -0
  97. package/dist/cli/messenger/statistics-query.js +143 -0
  98. package/dist/cli/messenger/stats-command.js +6 -6
  99. package/dist/cli/messenger/store-maintenance-command.d.ts +1 -1
  100. package/dist/cli/messenger/store-maintenance-command.js +10 -10
  101. package/dist/cli/messenger/tags-command.js +18 -6
  102. package/dist/cli/messenger/tasks-command.js +47 -8
  103. package/dist/cli/messenger/transcribe-command.js +2 -1
  104. package/dist/cli/messenger/watch-answers.d.ts +6 -0
  105. package/dist/cli/messenger/watch-answers.js +69 -0
  106. package/dist/cli/messenger/watch-command.d.ts +1 -1
  107. package/dist/cli/messenger/watch-command.js +56 -7
  108. package/dist/cli/program.js +5 -1
  109. package/dist/cli/runs/command.js +25 -38
  110. package/dist/cli/runs/query.d.ts +5 -0
  111. package/dist/cli/runs/query.js +32 -0
  112. package/dist/cli/runs/search-command.d.ts +4 -0
  113. package/dist/cli/runs/search-command.js +27 -0
  114. package/dist/cli/runs/search-query.d.ts +4 -0
  115. package/dist/cli/runs/search-query.js +50 -0
  116. package/dist/cli/runs/search.d.ts +2 -1
  117. package/dist/cli/runs/search.js +6 -6
  118. package/dist/domain/attachments.js +9 -1
  119. package/dist/domain/rankings-options.js +3 -3
  120. package/dist/entities/account-change.d.ts +89 -0
  121. package/dist/entities/account-change.js +20 -0
  122. package/dist/entities/account-profile.d.ts +7 -0
  123. package/dist/entities/account-profile.js +8 -0
  124. package/dist/entities/analysis-consent.d.ts +9 -0
  125. package/dist/entities/analysis-consent.js +4 -0
  126. package/dist/entities/attachment-results.d.ts +96 -0
  127. package/dist/entities/attachment-results.js +31 -0
  128. package/dist/entities/batch-result.d.ts +27 -0
  129. package/dist/entities/batch-result.js +18 -0
  130. package/dist/entities/chat-admin.d.ts +234 -0
  131. package/dist/entities/chat-admin.js +84 -0
  132. package/dist/entities/chat-change.d.ts +25 -0
  133. package/dist/entities/chat-change.js +11 -0
  134. package/dist/entities/chat-metadata.d.ts +34 -0
  135. package/dist/entities/chat-metadata.js +15 -0
  136. package/dist/entities/chat-moderation.d.ts +44 -0
  137. package/dist/entities/chat-moderation.js +37 -0
  138. package/dist/entities/chat-tracking.d.ts +26 -0
  139. package/dist/entities/chat-tracking.js +23 -0
  140. package/dist/entities/contact-activity.d.ts +52 -0
  141. package/dist/entities/contact-activity.js +42 -0
  142. package/dist/entities/contact-context.d.ts +1568 -0
  143. package/dist/entities/contact-context.js +191 -0
  144. package/dist/entities/contact-write.d.ts +22 -0
  145. package/dist/entities/contact-write.js +6 -0
  146. package/dist/entities/conversation-preparation.d.ts +63 -0
  147. package/dist/entities/conversation-preparation.js +23 -0
  148. package/dist/entities/conversation-results.d.ts +567 -0
  149. package/dist/entities/conversation-results.js +94 -0
  150. package/dist/entities/document-link.d.ts +13 -0
  151. package/dist/entities/document-link.js +11 -0
  152. package/dist/entities/extraction-report.d.ts +95 -0
  153. package/dist/entities/extraction-report.js +34 -0
  154. package/dist/entities/image-embedding.d.ts +9 -0
  155. package/dist/entities/image-embedding.js +10 -0
  156. package/dist/entities/index.d.ts +8006 -1928
  157. package/dist/entities/index.js +174 -3
  158. package/dist/entities/listener.d.ts +2150 -0
  159. package/dist/entities/listener.js +46 -0
  160. package/dist/entities/media-archive.d.ts +43 -0
  161. package/dist/entities/media-archive.js +32 -0
  162. package/dist/entities/meeting-task-proposal.d.ts +14 -0
  163. package/dist/entities/meeting-task-proposal.js +19 -0
  164. package/dist/entities/meeting.d.ts +1 -1
  165. package/dist/entities/meeting.js +1 -1
  166. package/dist/entities/mention.d.ts +63 -0
  167. package/dist/entities/mention.js +44 -0
  168. package/dist/entities/message-change.d.ts +19 -0
  169. package/dist/entities/message-change.js +6 -0
  170. package/dist/entities/message-context.d.ts +617 -0
  171. package/dist/entities/message-context.js +20 -0
  172. package/dist/entities/message-read.d.ts +73 -0
  173. package/dist/entities/message-read.js +58 -0
  174. package/dist/entities/message-transfer.d.ts +379 -0
  175. package/dist/entities/message-transfer.js +83 -0
  176. package/dist/entities/message-write.d.ts +191 -0
  177. package/dist/entities/message-write.js +8 -0
  178. package/dist/entities/model-key.d.ts +14 -0
  179. package/dist/entities/model-key.js +10 -0
  180. package/dist/entities/poll.d.ts +40 -0
  181. package/dist/entities/poll.js +16 -0
  182. package/dist/entities/private-contact.d.ts +10 -0
  183. package/dist/entities/private-contact.js +4 -0
  184. package/dist/entities/reaction-change.d.ts +7 -0
  185. package/dist/entities/reaction-change.js +8 -0
  186. package/dist/entities/recipient.d.ts +29 -0
  187. package/dist/entities/recipient.js +11 -0
  188. package/dist/entities/recorded-run.d.ts +103 -0
  189. package/dist/entities/recorded-run.js +44 -0
  190. package/dist/entities/saved-search.d.ts +4 -0
  191. package/dist/entities/saved-search.js +2 -0
  192. package/dist/entities/send-attempt.d.ts +31 -0
  193. package/dist/entities/send-attempt.js +29 -0
  194. package/dist/entities/store-maintenance.d.ts +319 -0
  195. package/dist/entities/store-maintenance.js +145 -0
  196. package/dist/entities/store-records.d.ts +442 -0
  197. package/dist/entities/store-records.js +99 -0
  198. package/dist/entities/tag-change.d.ts +74 -0
  199. package/dist/entities/tag-change.js +31 -0
  200. package/dist/entities/task-pair.d.ts +31 -0
  201. package/dist/entities/task-pair.js +23 -0
  202. package/dist/entities/task-results.d.ts +524 -0
  203. package/dist/entities/task-results.js +142 -0
  204. package/dist/errors/reasons.js +1 -0
  205. package/dist/mcp/agent.d.ts +3 -1
  206. package/dist/mcp/agent.js +9 -6
  207. package/dist/mcp/bot/server.d.ts +2 -0
  208. package/dist/mcp/bot/server.js +1 -0
  209. package/dist/mcp/prompts.js +8 -2
  210. package/dist/mcp/server.js +3 -1
  211. package/dist/mcp/tools/attachments.js +1 -0
  212. package/dist/meetings/cli/index.js +1 -1
  213. package/dist/meetings/cli/passage.js +1 -0
  214. package/dist/meetings/index.d.ts +2 -1
  215. package/dist/meetings/index.js +1 -0
  216. package/dist/meetings/links.d.ts +16 -0
  217. package/dist/meetings/mcp/index.d.ts +15 -15
  218. package/dist/meetings/read-answers.d.ts +167 -0
  219. package/dist/meetings/read-answers.js +183 -0
  220. package/dist/runs/run.d.ts +10 -2
  221. package/dist/runs/run.js +11 -3
  222. package/dist/sends/journal.d.ts +8 -1
  223. package/dist/sends/journal.js +9 -2
  224. package/dist/sends/permissions.d.ts +5 -1
  225. package/dist/sends/permissions.js +11 -1
  226. package/dist/sends/recipients.d.ts +8 -0
  227. package/dist/sends/recipients.js +9 -0
  228. package/dist/services/admin-statistics.js +3 -3
  229. package/dist/services/chat-documents.d.ts +1 -0
  230. package/dist/services/chat-documents.js +9 -3
  231. package/dist/services/chats.d.ts +1 -1
  232. package/dist/services/chats.js +5 -2
  233. package/dist/services/meeting-links.d.ts +2 -17
  234. package/dist/store/exports.d.ts +1 -1
  235. package/dist/store/exports.js +1 -1
  236. package/dist/store/messages.d.ts +3 -1
  237. package/dist/store/messages.js +2 -2
  238. package/dist/store/roster.d.ts +4 -1
  239. package/dist/store/roster.js +2 -2
  240. package/dist/store/sqlite/chats.d.ts +12 -0
  241. package/dist/store/sqlite/chats.js +1 -0
  242. package/dist/store/sqlite/document-links.d.ts +1 -1
  243. package/dist/store/sqlite/document-links.js +5 -5
  244. package/dist/store/sqlite/involvements.js +2 -1
  245. package/dist/store/sqlite/roster.d.ts +2 -1
  246. package/dist/store/sqlite/roster.js +3 -2
  247. package/package.json +3 -3
  248. package/parity.json +76 -108
@@ -0,0 +1,142 @@
1
+ import * as v from "valibot";
2
+ import { TASK_TYPES } from "../domain/knowledge.js";
3
+ import { TASK_KINDS, TASK_ORIGINS, TASK_STATES, TASK_VERDICTS } from "../tasks/index.js";
4
+ import { count, id, reference, text, time } from "./fields.js";
5
+ import { closeSuggestion } from "./task.js";
6
+ import { taskPair } from "./task-pair.js";
7
+ const nullableTime = v.nullable(time);
8
+ const link = v.strictObject({
9
+ id,
10
+ from: reference,
11
+ to: v.nullable(reference),
12
+ kind: v.picklist([
13
+ "links-to",
14
+ "blocked-by",
15
+ "follow-up-of",
16
+ "about",
17
+ "member-of",
18
+ "labelled",
19
+ "answered-by",
20
+ "evidence",
21
+ "created-from",
22
+ "duplicate-of",
23
+ "related-to",
24
+ "assigned-to",
25
+ ]),
26
+ anchor: v.nullable(text),
27
+ origin: v.picklist(["file", "owner", "suggested", "message"]),
28
+ target_text: v.nullable(text),
29
+ role: v.nullable(text),
30
+ evidence: v.nullable(text),
31
+ provenance: v.nullable(text),
32
+ confirmed: v.boolean(),
33
+ created_at: time,
34
+ });
35
+ export const taskCard = v.strictObject({
36
+ id,
37
+ ref: reference,
38
+ key: text,
39
+ project: reference,
40
+ title: text,
41
+ description: v.nullable(text),
42
+ type: v.picklist(TASK_TYPES),
43
+ status: v.picklist(TASK_STATES),
44
+ priority: v.nullable(v.number()),
45
+ parent: v.nullable(reference),
46
+ source: v.nullable(text),
47
+ due_at: nullableTime,
48
+ next_check_at: nullableTime,
49
+ closed_at: nullableTime,
50
+ reason: v.nullable(text),
51
+ verdict: v.nullable(v.picklist(TASK_VERDICTS)),
52
+ category: v.nullable(text),
53
+ claimed_by: v.nullable(text),
54
+ claimed_until: nullableTime,
55
+ close_certainty: v.nullable(v.number()),
56
+ close_suggestion: v.nullable(closeSuggestion),
57
+ assignments: v.array(v.strictObject({ to: reference, role: v.picklist(["assignee", "reviewer", "watcher"]) })),
58
+ created_at: time,
59
+ updated_at: time,
60
+ links: v.array(link),
61
+ linked_from: v.array(link),
62
+ });
63
+ /** Service task receipts preserve source pointers and their on-demand previews. */
64
+ const taskView = v.strictObject({
65
+ id,
66
+ source: text,
67
+ source_kind: text,
68
+ account: text,
69
+ group: text,
70
+ kind: v.picklist(TASK_KINDS),
71
+ state: v.picklist(TASK_STATES),
72
+ reason: v.optional(text),
73
+ origin: v.picklist(TASK_ORIGINS),
74
+ created_at: time,
75
+ due_at: v.optional(time),
76
+ closed_at: v.optional(time),
77
+ closed_by: v.optional(v.picklist(TASK_ORIGINS)),
78
+ key: v.optional(text),
79
+ category: v.optional(text),
80
+ claimed_by: v.optional(text),
81
+ claimed_until: v.optional(time),
82
+ message: v.nullable(v.strictObject({ sender_name: v.nullable(text), text, timestamp: time })),
83
+ note: v.optional(v.nullable(v.strictObject({ id, title: v.nullable(text), text, updated_at: time }))),
84
+ });
85
+ export const taskCreated = v.strictObject({
86
+ ...taskView.entries,
87
+ created: v.boolean(),
88
+ attached: v.optional(v.literal(true)),
89
+ review: v.optional(count),
90
+ follow_up_of: v.optional(taskPair.entries.other),
91
+ card: v.optional(taskCard),
92
+ });
93
+ export const taskClosed = v.strictObject({
94
+ ...taskView.entries,
95
+ close_certainty: v.nullable(v.number()),
96
+ close_suggestion: v.nullable(closeSuggestion),
97
+ });
98
+ export const taskLinks = v.union([
99
+ v.strictObject({ ...taskCard.entries, review: v.optional(count) }),
100
+ v.strictObject({
101
+ relations: v.array(v.strictObject({
102
+ id,
103
+ from: reference,
104
+ to: reference,
105
+ kind: v.picklist(["blocked-by", "follow-up-of", "related-to", "duplicate-of", "discovered-from"]),
106
+ })),
107
+ }),
108
+ ]);
109
+ export const taskSimilar = v.strictObject({
110
+ ref: reference,
111
+ key: text,
112
+ title: text,
113
+ status: text,
114
+ created_at: time,
115
+ found_by: v.array(v.picklist(["text", "person", "category", "reply"])),
116
+ score: v.number(),
117
+ band: taskPair.entries.band,
118
+ levels: taskPair.entries.levels,
119
+ reasons: v.array(text),
120
+ text: v.strictObject({ shared_stems: count, all_stems: count, stems: v.number(), trigrams: v.number() }),
121
+ });
122
+ export const taskMerge = v.strictObject({ pair: taskPair, linked: count, review: count, task: taskCard });
123
+ export const taskUnmerge = v.strictObject({ pair: taskPair, task: taskCard });
124
+ export const taskCategories = v.strictObject({
125
+ categories: v.array(v.strictObject({
126
+ name: text,
127
+ meaning: text,
128
+ triggers: v.strictObject({ en: v.array(text), ru: v.array(text), es: v.array(text) }),
129
+ })),
130
+ unlisted: v.array(v.strictObject({ name: text, open: count, total: count })),
131
+ file: v.nullable(text),
132
+ });
133
+ export const taskScan = v.strictObject({
134
+ chat: text,
135
+ messages: count,
136
+ added: count,
137
+ closed: count,
138
+ review: count,
139
+ held: v.optional(count),
140
+ held_chats: v.optional(count),
141
+ tasks: v.array(v.strictObject({ source: text, kind: v.picklist(TASK_KINDS), category: v.nullable(text) })),
142
+ });
@@ -8,6 +8,7 @@ const QUERY = [
8
8
  ["query.invalid-context", "the context size is out of range"],
9
9
  ["query.invalid-limit", "the limit is out of range"],
10
10
  ["query.invalid-scope", "the query selects no account"],
11
+ ["query.invalid-duration", "a duration in the query cannot be read"],
11
12
  ["query.invalid-size", "a size in the query cannot be read"],
12
13
  ["query.invalid-reference", "a reference in the query is not valid"],
13
14
  ["query.invalid-tag", "a tag in the query is not valid"],
@@ -53,6 +53,8 @@ export interface CatalogueOptions {
53
53
  /** Under `<PREFIX>_READ_ONLY`: a change on the messenger is not offered either. */
54
54
  readOnly?: boolean;
55
55
  keyOf?: (path: readonly string[]) => PermissionKey | null | undefined;
56
+ /** Whether a command changes what a later run may do (`grantsAuthority`): offered only under `mcp.authority`. */
57
+ authority?: (path: readonly string[]) => boolean;
56
58
  /** Arguments left out of every tool, by name. */
57
59
  omit?: readonly string[];
58
60
  /** Offer `offline` on commands that read the messenger: answer from the copy on this machine. */
@@ -64,7 +66,7 @@ export interface CatalogueOptions {
64
66
  * One tool per command an agent may run under `root` (NEED-1411): every leaf command and every group that runs on
65
67
  * its own, except one marked
66
68
  * `mcp: false` (on itself or a group above it), one with a `lifetime` — an agent call must return — and one the
67
- * profile's levels refuse. Its input is the command's arguments and options in snake_case, typed as far as the
69
+ * profile's levels refuse, which include `mcp.authority` for what `authority` names. Its input is the command's arguments and options in snake_case, typed as far as the
68
70
  * command tree and the shared flag vocabulary say; an option marked `mcp: false` is left out.
69
71
  */
70
72
  export declare const toolsFromCommands: (commands: readonly CommandInfo[], options?: CatalogueOptions) => AgentTool[];
package/dist/mcp/agent.js CHANGED
@@ -6,7 +6,7 @@ import { VOCABULARY } from "@wirecat/cli-base/standards/tables";
6
6
  import * as v from "valibot";
7
7
  import { changesMessenger } from "../cli/effects.js";
8
8
  import { lentConnection } from "../cli/messenger/serve-relay.js";
9
- import { keyForCommand, levelFor, readKeysForCommand } from "../sends/permissions.js";
9
+ import { AUTHORITY_KEY, authorityAllowed, keyForCommand, levelFor, readKeysForCommand, } from "../sends/permissions.js";
10
10
  const TYPES = new Map(VOCABULARY.flags.map((flag) => [flag.name, flag.type]));
11
11
  // `<name|id>` is one argument: its field is `name_or_id`.
12
12
  const snake = (name) => name.replaceAll("|", "_or_").replace(/[^a-z0-9]+/gi, "_");
@@ -115,7 +115,9 @@ const fieldsOf = (info, { omit = [], offline = false, stdin }) => {
115
115
  const schemaOf = (fields) => v.object(Object.fromEntries(fields.map((field) => [field.name, field.required ? field.schema : v.optional(field.schema)])));
116
116
  const startsWith = (path, prefix) => prefix.every((word, at) => path[at] === word);
117
117
  /** Why the profile refuses this command now, or nothing. */
118
- const refusal = (info, levels, keyOf) => {
118
+ const refusal = (info, levels, keyOf, authority) => {
119
+ if (authority?.(info.path) && !authorityAllowed(levels))
120
+ return `the profile keeps ${AUTHORITY_KEY} off`;
119
121
  const key = keyOf?.(info.path) ?? keyForCommand(info.path);
120
122
  const level = key ? levelFor(levels, key).level : "allow";
121
123
  if (level === "deny")
@@ -129,11 +131,11 @@ const refusal = (info, levels, keyOf) => {
129
131
  * One tool per command an agent may run under `root` (NEED-1411): every leaf command and every group that runs on
130
132
  * its own, except one marked
131
133
  * `mcp: false` (on itself or a group above it), one with a `lifetime` — an agent call must return — and one the
132
- * profile's levels refuse. Its input is the command's arguments and options in snake_case, typed as far as the
134
+ * profile's levels refuse, which include `mcp.authority` for what `authority` names. Its input is the command's arguments and options in snake_case, typed as far as the
133
135
  * command tree and the shared flag vocabulary say; an option marked `mcp: false` is left out.
134
136
  */
135
137
  export const toolsFromCommands = (commands, options = {}) => {
136
- const { root = [], exclude = [], levels, keyOf, readOnly = false } = options;
138
+ const { root = [], exclude = [], levels, keyOf, authority, readOnly = false } = options;
137
139
  return flatten(commands)
138
140
  .filter((info) =>
139
141
  // A group that also runs on its own declares effects: `tasks duplicates` lists, its subcommands decide.
@@ -143,8 +145,8 @@ export const toolsFromCommands = (commands, options = {}) => {
143
145
  !exclude.some((skipped) => startsWith(info.path.slice(root.length), skipped)) &&
144
146
  info.mcp !== false &&
145
147
  info.lifetime === undefined &&
146
- !(readOnly && changesMessenger(info)) &&
147
- (levels === undefined || refusal(info, levels, keyOf) === undefined))
148
+ !(readOnly && (changesMessenger(info) || authority?.(info.path))) &&
149
+ (levels === undefined || refusal(info, levels, keyOf, authority) === undefined))
148
150
  .map((info) => ({
149
151
  command: info.path.slice(root.length).join(" "),
150
152
  path: info.path,
@@ -223,6 +225,7 @@ export const runCommandForAgent = async (program, path, input, ctx) => {
223
225
  failure = object;
224
226
  },
225
227
  ...(ctx.overrides?.length ? { overrides: ctx.overrides } : {}),
228
+ authority: levels !== undefined && authorityAllowed(levels),
226
229
  },
227
230
  // Opened only when the command asks: a read the store answers never connects.
228
231
  ...(lend
@@ -14,6 +14,8 @@ export interface BotServerOptions {
14
14
  levels?: () => Readonly<Record<PermissionKey, Level>>;
15
15
  /** The key a CLI's own bot command is guarded by, from its full path, when `keyForCommand` does not know it. */
16
16
  keyOf?: (path: readonly string[]) => PermissionKey | null | undefined;
17
+ /** Whether a command changes what a later run may do; such a command is offered only under `mcp.authority`. */
18
+ authority?: (path: readonly string[]) => boolean;
17
19
  env: NodeJS.ProcessEnv;
18
20
  skill?: URL;
19
21
  }
@@ -28,6 +28,7 @@ export const createBotServer = (options) => {
28
28
  levels: settings.permissions,
29
29
  readOnly: readOnlyLockOf(bot.app, env) !== undefined,
30
30
  ...(options.keyOf ? { keyOf: options.keyOf } : {}),
31
+ ...(options.authority ? { authority: options.authority } : {}),
31
32
  offline: true,
32
33
  // Another bot's copy is this bot's to read only where `read_other_bots` says so.
33
34
  ...(settings.readOtherBots ? {} : { omit: ["all_bots", "bots"] }),
@@ -42,9 +42,15 @@ export const registerPrompts = (server, { command, name }) => {
42
42
  ?.split(",")
43
43
  .map((one) => one.trim())
44
44
  .filter((one) => one.length > 0);
45
+ const query = [
46
+ kinds?.length ? `kind:${JSON.stringify(kinds.join(","))}` : "",
47
+ mode === undefined || mode === "unread" || mode === "new" ? "" : after(mode),
48
+ ]
49
+ .filter(Boolean)
50
+ .join(" ");
45
51
  const args = {
46
- ...(kinds?.length ? { kind: kinds.join(",") } : {}),
47
- ...(mode === undefined || mode === "unread" ? {} : mode === "new" ? { new: true } : { query: after(mode) }),
52
+ ...(query ? { query } : {}),
53
+ ...(mode === "new" ? { new: true } : {}),
48
54
  };
49
55
  return asked([
50
56
  `Catch me up on ${name}. Call ${call(`${command}_read`, "inbox", args)} once.`,
@@ -8,7 +8,7 @@ import * as v from "valibot";
8
8
  import { findCommand } from "../cli/command-contract.js";
9
9
  import { environmentOf } from "../cli/context.js";
10
10
  import { refuseWriteBeforeConnecting } from "../cli/early-refusal.js";
11
- import { judgedTargets } from "../cli/effects.js";
11
+ import { changesAuthorityAt, judgedTargets } from "../cli/effects.js";
12
12
  import { itemOf } from "../cli/envelope.js";
13
13
  import { DEFAULT_OUTPUT_BYTES } from "../cli/execution.js";
14
14
  import { recalledAccount } from "../cli/messenger/accounts.js";
@@ -98,6 +98,7 @@ export const createServer = (command, context, messenger, sessionOptions) => {
98
98
  return undefined;
99
99
  }
100
100
  };
101
+ const authority = changesAuthorityAt(root);
101
102
  const stdin = (path) => {
102
103
  try {
103
104
  return stdinFieldOf(findCommand(root, path));
@@ -115,6 +116,7 @@ export const createServer = (command, context, messenger, sessionOptions) => {
115
116
  levels: settings.permissions,
116
117
  readOnly: readOnlyLockOf(app, context.env) !== undefined,
117
118
  keyOf,
119
+ authority,
118
120
  offline: true,
119
121
  stdin,
120
122
  }).map((one) => "sync_first" in one.input.entries && !syncAllowed(one.path)
@@ -9,6 +9,7 @@ export const attachmentsTools = (messenger) => {
9
9
  const _command = messenger.app.command;
10
10
  return {
11
11
  attachments_show: tool({
12
+ output: { entity: "attachment_bytes", list: false },
12
13
  title: "Read bytes of one retained attachment",
13
14
  outputLimit: (args, defaults) => args.page === undefined
14
15
  ? DEFAULT_OUTPUT_BYTES
@@ -94,7 +94,7 @@ export const addMeetingCommands = (program, deps) => {
94
94
  else
95
95
  print(result, command);
96
96
  });
97
- output(annotate(group.command("people"), { effects: LOCAL_READ })
97
+ output(annotate(group.command("people"), { effects: LOCAL_READ, output: { entity: "meeting_participants" } })
98
98
  .description("find meeting participants by name or email")
99
99
  .argument("<query>", "a name or an email address"))
100
100
  .option("--limit <n>", "most matching observations per page, 1–1000 (default 50)", integer)
@@ -39,6 +39,7 @@ export const createMeetingPassageCommand = (program) => {
39
39
  .default("text")), {
40
40
  origin: "handwritten",
41
41
  effects: { remote: "none", local: "read" },
42
+ output: { entity: "meeting_passage" },
42
43
  examples: [`${program.name()} meetings passage meeting:1/1/1/0 --json`],
43
44
  });
44
45
  };
@@ -9,7 +9,7 @@ export { type Finding, type FindingsInput, type FindingsReceipt, type FindingsRu
9
9
  export { liftMeetingFields, MEETING_HIT_QUERY, meetingWordsQuery, parseMeetingQuery } from "./hit-query.js";
10
10
  export { type ImportFile, importFiles } from "./import.js";
11
11
  export { MEETING_ISSUES, MEETING_QUERY, type MeetingIssue, type MeetingItem, type MeetingOwner, meeting, meetingIssuesOf, meetingItem, } from "./item.js";
12
- export { CHAT_MESSAGES_READ, type MeetingChatLine, type MeetingChatLinesInput, type MeetingChatLinesStore, } from "./links.js";
12
+ export { CHAT_MESSAGES_READ, type MeetingChatLine, type MeetingChatLinesInput, type MeetingChatLinesStore, type MeetingLink, } from "./links.js";
13
13
  export { createMeetingContext, MEETING_FACT_TYPES, type MeetingContextAction, type MeetingContextChange, type MeetingContextOperation, type MeetingContextPorts, type MeetingContextReceipt, validateMeetingContextChange, } from "./meeting-context.js";
14
14
  export { createMeetingManagement, dispatchMeetingMutation, type ManagedMeeting, type ManagedMeetingChange, type MeetingManagement, type MeetingManagementPorts, type MeetingMutationOptions, type MeetingMutationProposal, type MeetingMutationReceipt, type MeetingOperationOptions, type MeetingProviderContext, validateMeetingChange, } from "./meeting-management.js";
15
15
  export type { Attachment, ChatLine, Event, EventSeries, JsonValue, Meeting, MeetingSeries, Metadata, Occurrence, Participant, RecordTimes, SourceChatLine, SourceMeeting, Summary, SummaryContent, Transcript, TranscriptLine, TranscriptRow, } from "./model.js";
@@ -25,6 +25,7 @@ export { type MeetingProjectEvidenceAnswer, type MeetingProjectEvidenceItem, mee
25
25
  export { MEETING_PROJECT_EVIDENCE_QUERY, type MeetingProjectEvidenceRequest, prepareMeetingProjectEvidence, } from "./project-evidence-query.js";
26
26
  export { type MeetingProviderScope, snapshotMeetingScope } from "./provider.js";
27
27
  export { type PullOptions, pull, type RunReport } from "./pull.js";
28
+ export { meetingLink, meetingLinkItem, meetingParticipants, meetingPassage, meetingReview, meetingReviewItem, meetingSpeaker, meetingSpeakerItem, meetingStats, meetingStatsItem, } from "./read-answers.js";
28
29
  export type { MeetingContextReadCapabilities, MeetingReadBudget, MeetingReadCapabilities, MeetingReadScope, TranscriptContextInput, TranscriptContextPage, TranscriptPage, TranscriptReadScope, TranscriptRowPage, } from "./read-store.js";
29
30
  export { listed, MeetingError, meetingDetailsAnswer, meetingPeople, meetingSummaryAnswer, meetingTranscriptAnswer, type TranscriptReadOptions, } from "./reads.js";
30
31
  export { installRecordingArchiveSchedule, parseRecordingArchiveSchedule, planRecordingArchiveSchedule, type RecordingArchiveSchedule, type RecordingArchiveScheduleInput, type RecordingArchiveScheduler, recordingArchiveScheduleWindow, } from "./recording-schedule.js";
@@ -18,6 +18,7 @@ export { meetingProjectEvidence, meetingProjectEvidenceAnswer, } from "./project
18
18
  export { MEETING_PROJECT_EVIDENCE_QUERY, prepareMeetingProjectEvidence, } from "./project-evidence-query.js";
19
19
  export { snapshotMeetingScope } from "./provider.js";
20
20
  export { pull } from "./pull.js";
21
+ export { meetingLink, meetingLinkItem, meetingParticipants, meetingPassage, meetingReview, meetingReviewItem, meetingSpeaker, meetingSpeakerItem, meetingStats, meetingStatsItem, } from "./read-answers.js";
21
22
  export { listed, MeetingError, meetingDetailsAnswer, meetingPeople, meetingSummaryAnswer, meetingTranscriptAnswer, } from "./reads.js";
22
23
  export { installRecordingArchiveSchedule, parseRecordingArchiveSchedule, planRecordingArchiveSchedule, recordingArchiveScheduleWindow, } from "./recording-schedule.js";
23
24
  export { parseRecordingSyncCheckpoint, RecordingSyncError, recordingAssetFingerprint, recordingWindows, syncRecordingArchive, } from "./recording-sync.js";
@@ -15,4 +15,20 @@ export interface MeetingChatLine {
15
15
  export interface MeetingChatLinesStore {
16
16
  meetingChatLines(input: MeetingChatLinesInput): Promise<MeetingChatLine[]>;
17
17
  }
18
+ /** One link as the meetings' chat holds it: where and how often it was shared. */
19
+ export interface MeetingLink {
20
+ url: string;
21
+ domain: string | null;
22
+ /** The Google Docs, Sheets, Slides, Forms or Drive file it names. */
23
+ documentId: string | null;
24
+ count: number;
25
+ firstAt: number;
26
+ lastAt: number;
27
+ senders: string[];
28
+ meetings: {
29
+ meetingId: number;
30
+ accountId: number;
31
+ title: string | null;
32
+ }[];
33
+ }
18
34
  export declare const CHAT_MESSAGES_READ = 100000;
@@ -38,7 +38,6 @@ export declare const meetingTools: ({
38
38
  max_read_bytes?: undefined;
39
39
  cursor?: undefined;
40
40
  } | {
41
- limit?: undefined;
42
41
  event_id?: undefined;
43
42
  series_id?: undefined;
44
43
  page?: undefined;
@@ -54,11 +53,11 @@ export declare const meetingTools: ({
54
53
  format?: undefined;
55
54
  transcript_id?: undefined;
56
55
  query?: undefined;
56
+ limit?: undefined;
57
57
  scan_limit?: undefined;
58
58
  max_read_bytes?: undefined;
59
59
  cursor?: undefined;
60
60
  } | {
61
- limit?: undefined;
62
61
  event_id?: undefined;
63
62
  series_id?: undefined;
64
63
  page?: undefined;
@@ -76,11 +75,11 @@ export declare const meetingTools: ({
76
75
  format?: undefined;
77
76
  transcript_id?: undefined;
78
77
  query?: undefined;
78
+ limit?: undefined;
79
79
  scan_limit?: undefined;
80
80
  max_read_bytes?: undefined;
81
81
  cursor?: undefined;
82
82
  } | {
83
- limit?: undefined;
84
83
  event_id?: undefined;
85
84
  series_id?: undefined;
86
85
  page?: undefined;
@@ -102,6 +101,7 @@ export declare const meetingTools: ({
102
101
  minimum: number;
103
102
  };
104
103
  query?: undefined;
104
+ limit?: undefined;
105
105
  scan_limit?: undefined;
106
106
  max_read_bytes?: undefined;
107
107
  cursor?: undefined;
@@ -188,7 +188,6 @@ export declare const meetingTools: ({
188
188
  max_read_bytes?: undefined;
189
189
  cursor?: undefined;
190
190
  } | {
191
- limit?: undefined;
192
191
  event_id?: undefined;
193
192
  series_id?: undefined;
194
193
  page?: undefined;
@@ -204,11 +203,11 @@ export declare const meetingTools: ({
204
203
  format?: undefined;
205
204
  transcript_id?: undefined;
206
205
  query?: undefined;
206
+ limit?: undefined;
207
207
  scan_limit?: undefined;
208
208
  max_read_bytes?: undefined;
209
209
  cursor?: undefined;
210
210
  } | {
211
- limit?: undefined;
212
211
  event_id?: undefined;
213
212
  series_id?: undefined;
214
213
  page?: undefined;
@@ -226,11 +225,11 @@ export declare const meetingTools: ({
226
225
  format?: undefined;
227
226
  transcript_id?: undefined;
228
227
  query?: undefined;
228
+ limit?: undefined;
229
229
  scan_limit?: undefined;
230
230
  max_read_bytes?: undefined;
231
231
  cursor?: undefined;
232
232
  } | {
233
- limit?: undefined;
234
233
  event_id?: undefined;
235
234
  series_id?: undefined;
236
235
  page?: undefined;
@@ -252,6 +251,7 @@ export declare const meetingTools: ({
252
251
  minimum: number;
253
252
  };
254
253
  query?: undefined;
254
+ limit?: undefined;
255
255
  scan_limit?: undefined;
256
256
  max_read_bytes?: undefined;
257
257
  cursor?: undefined;
@@ -338,7 +338,6 @@ export declare const meetingTools: ({
338
338
  max_read_bytes?: undefined;
339
339
  cursor?: undefined;
340
340
  } | {
341
- limit?: undefined;
342
341
  event_id?: undefined;
343
342
  series_id?: undefined;
344
343
  page?: undefined;
@@ -354,11 +353,11 @@ export declare const meetingTools: ({
354
353
  format?: undefined;
355
354
  transcript_id?: undefined;
356
355
  query?: undefined;
356
+ limit?: undefined;
357
357
  scan_limit?: undefined;
358
358
  max_read_bytes?: undefined;
359
359
  cursor?: undefined;
360
360
  } | {
361
- limit?: undefined;
362
361
  event_id?: undefined;
363
362
  series_id?: undefined;
364
363
  page?: undefined;
@@ -376,11 +375,11 @@ export declare const meetingTools: ({
376
375
  format?: undefined;
377
376
  transcript_id?: undefined;
378
377
  query?: undefined;
378
+ limit?: undefined;
379
379
  scan_limit?: undefined;
380
380
  max_read_bytes?: undefined;
381
381
  cursor?: undefined;
382
382
  } | {
383
- limit?: undefined;
384
383
  event_id?: undefined;
385
384
  series_id?: undefined;
386
385
  page?: undefined;
@@ -402,6 +401,7 @@ export declare const meetingTools: ({
402
401
  minimum: number;
403
402
  };
404
403
  query?: undefined;
404
+ limit?: undefined;
405
405
  scan_limit?: undefined;
406
406
  max_read_bytes?: undefined;
407
407
  cursor?: undefined;
@@ -488,7 +488,6 @@ export declare const meetingTools: ({
488
488
  max_read_bytes?: undefined;
489
489
  cursor?: undefined;
490
490
  } | {
491
- limit?: undefined;
492
491
  event_id?: undefined;
493
492
  series_id?: undefined;
494
493
  page?: undefined;
@@ -504,11 +503,11 @@ export declare const meetingTools: ({
504
503
  format?: undefined;
505
504
  transcript_id?: undefined;
506
505
  query?: undefined;
506
+ limit?: undefined;
507
507
  scan_limit?: undefined;
508
508
  max_read_bytes?: undefined;
509
509
  cursor?: undefined;
510
510
  } | {
511
- limit?: undefined;
512
511
  event_id?: undefined;
513
512
  series_id?: undefined;
514
513
  page?: undefined;
@@ -526,11 +525,11 @@ export declare const meetingTools: ({
526
525
  format?: undefined;
527
526
  transcript_id?: undefined;
528
527
  query?: undefined;
528
+ limit?: undefined;
529
529
  scan_limit?: undefined;
530
530
  max_read_bytes?: undefined;
531
531
  cursor?: undefined;
532
532
  } | {
533
- limit?: undefined;
534
533
  event_id?: undefined;
535
534
  series_id?: undefined;
536
535
  page?: undefined;
@@ -552,6 +551,7 @@ export declare const meetingTools: ({
552
551
  minimum: number;
553
552
  };
554
553
  query?: undefined;
554
+ limit?: undefined;
555
555
  scan_limit?: undefined;
556
556
  max_read_bytes?: undefined;
557
557
  cursor?: undefined;
@@ -638,7 +638,6 @@ export declare const meetingTools: ({
638
638
  max_read_bytes?: undefined;
639
639
  cursor?: undefined;
640
640
  } | {
641
- limit?: undefined;
642
641
  event_id?: undefined;
643
642
  series_id?: undefined;
644
643
  page?: undefined;
@@ -654,11 +653,11 @@ export declare const meetingTools: ({
654
653
  format?: undefined;
655
654
  transcript_id?: undefined;
656
655
  query?: undefined;
656
+ limit?: undefined;
657
657
  scan_limit?: undefined;
658
658
  max_read_bytes?: undefined;
659
659
  cursor?: undefined;
660
660
  } | {
661
- limit?: undefined;
662
661
  event_id?: undefined;
663
662
  series_id?: undefined;
664
663
  page?: undefined;
@@ -676,11 +675,11 @@ export declare const meetingTools: ({
676
675
  format?: undefined;
677
676
  transcript_id?: undefined;
678
677
  query?: undefined;
678
+ limit?: undefined;
679
679
  scan_limit?: undefined;
680
680
  max_read_bytes?: undefined;
681
681
  cursor?: undefined;
682
682
  } | {
683
- limit?: undefined;
684
683
  event_id?: undefined;
685
684
  series_id?: undefined;
686
685
  page?: undefined;
@@ -702,6 +701,7 @@ export declare const meetingTools: ({
702
701
  minimum: number;
703
702
  };
704
703
  query?: undefined;
704
+ limit?: undefined;
705
705
  scan_limit?: undefined;
706
706
  max_read_bytes?: undefined;
707
707
  cursor?: undefined;