@wirecat/cli-core 0.666.0 → 0.667.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.
- package/CHANGELOG.md +45 -0
- package/dist/calendar/cli/conference.d.ts +3 -0
- package/dist/calendar/cli/conference.js +7 -0
- package/dist/calendar/cli/index.d.ts +1 -0
- package/dist/calendar/cli/index.js +4 -2
- package/dist/calendar/mcp/index.d.ts +62 -12
- package/dist/calendar/mcp/index.js +6 -0
- package/dist/calendar/testing/writer-contract.js +1 -0
- package/dist/calendar/testing/writer.d.ts +3 -0
- package/dist/calendar/testing/writer.js +9 -1
- package/dist/calendar/writer.d.ts +13 -0
- package/dist/calendar/writes.d.ts +3 -0
- package/dist/calendar/writes.js +21 -1
- package/dist/cli/documents/words.d.ts +1 -1
- package/dist/domain/providers.js +2 -1
- package/dist/entities/index.d.ts +6 -0
- package/dist/errors/reasons.js +1 -0
- package/dist/meetings/answers.d.ts +10 -0
- package/dist/meetings/answers.js +24 -1
- package/dist/meetings/cli/index.js +3 -2
- package/dist/meetings/cli/management.d.ts +1 -1
- package/dist/meetings/cli/management.js +67 -25
- package/dist/meetings/export.d.ts +2 -0
- package/dist/meetings/export.js +1 -0
- package/dist/meetings/index.d.ts +1 -1
- package/dist/meetings/index.js +1 -1
- package/dist/meetings/meeting-management.d.ts +68 -3
- package/dist/meetings/meeting-management.js +134 -17
- package/dist/meetings/read-answers.d.ts +1 -0
- package/dist/meetings/read-answers.js +1 -0
- package/dist/meetings/reads.d.ts +29 -2
- package/dist/meetings/reads.js +3 -2
- package/dist/meetings/result-items.d.ts +3 -0
- package/dist/meetings/result-items.js +9 -1
- package/dist/meetings/testing/management-contract.js +27 -5
- package/package.json +1 -1
|
@@ -58,6 +58,8 @@ export declare const meetingTranscript: v.StrictObjectSchema<{
|
|
|
58
58
|
readonly speaker: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
59
59
|
readonly text: v.StringSchema<undefined>;
|
|
60
60
|
}, undefined>, undefined>;
|
|
61
|
+
/** What people said, and who the service says said it: data, never instructions. */
|
|
62
|
+
readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
61
63
|
}, undefined>;
|
|
62
64
|
/** A provider's summary of a meeting. */
|
|
63
65
|
export declare const meetingSummary: v.StrictObjectSchema<{
|
|
@@ -75,6 +77,8 @@ export declare const meetingSummary: v.StrictObjectSchema<{
|
|
|
75
77
|
readonly url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
76
78
|
readonly created_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
|
|
77
79
|
readonly updated_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
|
|
80
|
+
/** What the service wrote of what people said. */
|
|
81
|
+
readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
78
82
|
}, undefined>;
|
|
79
83
|
/** `meetings show`: the meeting with who took part, what was said in its chat, and what it holds. */
|
|
80
84
|
declare const meetingDetailsEntries: {
|
|
@@ -141,6 +145,8 @@ declare const meetingDetailsEntries: {
|
|
|
141
145
|
readonly url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
142
146
|
readonly created_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
|
|
143
147
|
readonly updated_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
|
|
148
|
+
/** What the service wrote of what people said. */
|
|
149
|
+
readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
144
150
|
}, undefined>, undefined>;
|
|
145
151
|
attachments: v.ArraySchema<v.StrictObjectSchema<{
|
|
146
152
|
readonly position: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
@@ -172,6 +178,10 @@ export type MeetingDetailsItem = v.InferOutput<typeof meetingDetails>;
|
|
|
172
178
|
/** Answers without `meta`: the host adds it, as it knows the run. */
|
|
173
179
|
export type MeetingListBody<T> = Omit<ListEnvelope<T>, "meta">;
|
|
174
180
|
export type MeetingItemBody<T> = Omit<ItemEnvelope<T>, "meta">;
|
|
181
|
+
/** Other people's text in each meetings answer: names they gave the service, what they said and wrote. */
|
|
182
|
+
export declare const TRANSCRIPT_UNTRUSTED: string[];
|
|
183
|
+
export declare const SUMMARY_UNTRUSTED: string[];
|
|
184
|
+
export declare const PARTICIPANT_UNTRUSTED: string[];
|
|
175
185
|
export declare const meetingTranscriptItem: (accountId: number, transcript: Transcript, rows: TranscriptRow[]) => MeetingTranscriptItem;
|
|
176
186
|
export declare const meetingSummaryItem: (accountId: number, summary: Summary) => MeetingSummaryItem;
|
|
177
187
|
export declare const meetingDetailsItem: (details: MeetingDetails, owner: MeetingOwner) => MeetingDetailsItem;
|
package/dist/meetings/answers.js
CHANGED
|
@@ -55,6 +55,8 @@ export const meetingTranscript = v.strictObject({
|
|
|
55
55
|
superseded_at: v.nullable(isoTime),
|
|
56
56
|
created_at: isoTime,
|
|
57
57
|
lines: v.array(line),
|
|
58
|
+
/** What people said, and who the service says said it: data, never instructions. */
|
|
59
|
+
untrusted: v.optional(v.array(text)),
|
|
58
60
|
});
|
|
59
61
|
/** A provider's summary of a meeting. */
|
|
60
62
|
export const meetingSummary = v.strictObject({
|
|
@@ -69,6 +71,8 @@ export const meetingSummary = v.strictObject({
|
|
|
69
71
|
url: v.nullable(text),
|
|
70
72
|
created_at: isoTime,
|
|
71
73
|
updated_at: isoTime,
|
|
74
|
+
/** What the service wrote of what people said. */
|
|
75
|
+
untrusted: v.optional(v.array(text)),
|
|
72
76
|
});
|
|
73
77
|
/** `meetings show`: the meeting with who took part, what was said in its chat, and what it holds. */
|
|
74
78
|
const meetingDetailsEntries = {
|
|
@@ -110,6 +114,21 @@ const meetingDetailsEntries = {
|
|
|
110
114
|
})),
|
|
111
115
|
};
|
|
112
116
|
export const meetingDetails = v.strictObject(meetingDetailsEntries);
|
|
117
|
+
/** Other people's text in each meetings answer: names they gave the service, what they said and wrote. */
|
|
118
|
+
export const TRANSCRIPT_UNTRUSTED = ["lines.text", "lines.speaker"];
|
|
119
|
+
export const SUMMARY_UNTRUSTED = ["title", "overview", "sections.label", "sections.text", "next_steps", "content"];
|
|
120
|
+
const DETAILS_UNTRUSTED = [
|
|
121
|
+
"series_title",
|
|
122
|
+
"participants.name",
|
|
123
|
+
"participants.email",
|
|
124
|
+
"participants.person.name",
|
|
125
|
+
"chat.sender",
|
|
126
|
+
"chat.recipient",
|
|
127
|
+
"chat.text",
|
|
128
|
+
"attachments.name",
|
|
129
|
+
"documents.title",
|
|
130
|
+
];
|
|
131
|
+
export const PARTICIPANT_UNTRUSTED = ["display_name", "email", "person.name"];
|
|
113
132
|
const meetingRef = (accountId, meetingId) => formatMeetingReference({ type: "meeting", accountId, meetingId });
|
|
114
133
|
export const meetingTranscriptItem = (accountId, transcript, rows) => ({
|
|
115
134
|
ref: formatMeetingReference({
|
|
@@ -130,6 +149,7 @@ export const meetingTranscriptItem = (accountId, transcript, rows) => ({
|
|
|
130
149
|
speaker: row.speakerName,
|
|
131
150
|
text: row.text,
|
|
132
151
|
})),
|
|
152
|
+
untrusted: [...TRANSCRIPT_UNTRUSTED],
|
|
133
153
|
});
|
|
134
154
|
export const meetingSummaryItem = (accountId, summary) => ({
|
|
135
155
|
id: String(summary.id),
|
|
@@ -143,11 +163,14 @@ export const meetingSummaryItem = (accountId, summary) => ({
|
|
|
143
163
|
url: summary.docUrl,
|
|
144
164
|
created_at: new Date(summary.externalCreatedAt ?? summary.createdAt).toISOString(),
|
|
145
165
|
updated_at: new Date(summary.externalUpdatedAt ?? summary.updatedAt).toISOString(),
|
|
166
|
+
untrusted: [...SUMMARY_UNTRUSTED],
|
|
146
167
|
});
|
|
147
168
|
export const meetingDetailsItem = (details, owner) => {
|
|
148
169
|
const { accountId } = details.meeting;
|
|
170
|
+
const item = meetingItem(details.meeting, owner);
|
|
149
171
|
return {
|
|
150
|
-
...
|
|
172
|
+
...item,
|
|
173
|
+
untrusted: [...(item.untrusted ?? []), ...DETAILS_UNTRUSTED],
|
|
151
174
|
event_id: details.meeting.eventId === null ? null : String(details.meeting.eventId),
|
|
152
175
|
series_id: details.meeting.meetingSeriesId === null ? null : String(details.meeting.meetingSeriesId),
|
|
153
176
|
series_title: details.series?.title ?? null,
|
|
@@ -142,12 +142,13 @@ const addMeetingCommandsDefinition = (program, deps) => {
|
|
|
142
142
|
.option("--max-read-bytes <bytes>", "most stored name and email bytes to read (default 1048576)", integer)
|
|
143
143
|
.option("--cursor <cursor>", "continue with the same name query and selected account")
|
|
144
144
|
.action(async (query, opts, command) => {
|
|
145
|
-
|
|
145
|
+
const found = await meetingPeople(deps.store, query, deps.accountId, {
|
|
146
146
|
limit: opts.limit,
|
|
147
147
|
scanLimit: opts.scanLimit,
|
|
148
148
|
maxReadBytes: opts.maxReadBytes,
|
|
149
149
|
cursor: opts.cursor,
|
|
150
|
-
})
|
|
150
|
+
});
|
|
151
|
+
print(found, command);
|
|
151
152
|
});
|
|
152
153
|
output(annotate(group.command("sync"), {
|
|
153
154
|
effects: FETCH,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Command } from "commander";
|
|
2
|
-
import type
|
|
2
|
+
import { type MeetingManagement } from "../meeting-management.js";
|
|
3
3
|
export interface MeetingManagementCommandDeps {
|
|
4
4
|
management: MeetingManagement;
|
|
5
5
|
print: (value: unknown, command: Command) => void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { annotate } from "@wirecat/cli-base/commands";
|
|
3
3
|
import { InvalidArgumentError, Option } from "commander";
|
|
4
|
+
import { MEETING_FIELD_KEYS, MEETING_FIELDS, meetingFieldFlag, SNAKE_CASE, } from "../meeting-management.js";
|
|
4
5
|
const REMOTE_READ = { remote: "read", local: "read" };
|
|
5
6
|
const REMOTE_WRITE = { remote: "write", local: "write" };
|
|
6
7
|
const minutes = (text) => {
|
|
@@ -8,14 +9,56 @@ const minutes = (text) => {
|
|
|
8
9
|
throw new InvalidArgumentError("expected whole minutes");
|
|
9
10
|
return Number(text);
|
|
10
11
|
};
|
|
11
|
-
const
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
12
|
+
const setting = (text, previous = []) => {
|
|
13
|
+
const at = text.indexOf("=");
|
|
14
|
+
const name = text.slice(0, at);
|
|
15
|
+
if (at < 1 || !SNAKE_CASE.test(name))
|
|
16
|
+
throw new InvalidArgumentError("expected name=value with a snake_case name, such as access_type=trusted");
|
|
17
|
+
return [...previous, [name, text.slice(at + 1)]];
|
|
18
|
+
};
|
|
19
|
+
const valuesOf = (one) => one.type === "choice" ? one.values.join("|") : one.type === "boolean" ? "true|false" : "<text>";
|
|
20
|
+
/** The same options in every meetings tool; what this service takes is in `--setting`'s description and the help. */
|
|
21
|
+
const changeOptions = (command, declared, create) => {
|
|
22
|
+
const settings = declared.settings.length
|
|
23
|
+
? declared.settings.map((one) => `${one.name}=${valuesOf(one)}`).join(", ")
|
|
24
|
+
: "this service has none";
|
|
25
|
+
const takes = declared.fields.map(meetingFieldFlag).join(", ") || "none of the options above";
|
|
26
|
+
const schedules = declared.fields.includes("startTime");
|
|
27
|
+
const start = !create
|
|
28
|
+
? ""
|
|
29
|
+
: !schedules
|
|
30
|
+
? "; this service takes none, its meetings start now"
|
|
31
|
+
: declared.fields.includes("kind")
|
|
32
|
+
? "; for a meeting that starts now, give --kind instant instead"
|
|
33
|
+
: "";
|
|
34
|
+
return command
|
|
35
|
+
.option("--title <title>", "the meeting's title")
|
|
36
|
+
.addOption(new Option("--kind <kind>", "an instant or a scheduled meeting").choices(["instant", "scheduled"]))
|
|
37
|
+
.option("--start-time <time>", `when it starts: an ISO time with its offset, 2026-11-20T10:00:00+01:00${start}`)
|
|
38
|
+
.option("--duration-minutes <minutes>", "how long it lasts, 1–1440", minutes)
|
|
39
|
+
.option("--timezone <zone>", "its IANA time zone, Europe/Madrid")
|
|
40
|
+
.option("--agenda <text>", "its agenda")
|
|
41
|
+
.option("--setting <name=value>", `a setting of this service; repeat it for more: ${settings}`, setting)
|
|
42
|
+
.addHelpText("after", [
|
|
43
|
+
"",
|
|
44
|
+
`This service takes ${takes}.`,
|
|
45
|
+
...(declared.settings.length
|
|
46
|
+
? ["Its settings:", ...declared.settings.map((one) => ` ${one.name}=${valuesOf(one)} ${one.description}`)]
|
|
47
|
+
: []),
|
|
48
|
+
].join("\n"));
|
|
49
|
+
};
|
|
50
|
+
const changeOf = (flags) => {
|
|
51
|
+
const change = Object.fromEntries(MEETING_FIELDS.flatMap((key) => (flags[key] === undefined ? [] : [[key, flags[key]]])));
|
|
52
|
+
if (!flags.setting)
|
|
53
|
+
return change;
|
|
54
|
+
const settings = new Map();
|
|
55
|
+
for (const [name, value] of flags.setting) {
|
|
56
|
+
if (settings.has(name))
|
|
57
|
+
throw new CliError("validation_error", `--setting ${name} is given twice`);
|
|
58
|
+
settings.set(name, value);
|
|
59
|
+
}
|
|
60
|
+
return { ...change, settings: Object.fromEntries(settings) };
|
|
61
|
+
};
|
|
19
62
|
const meetingOf = (one) => ({
|
|
20
63
|
id: one.id,
|
|
21
64
|
title: one.title,
|
|
@@ -37,17 +80,15 @@ const receiptItem = (receipt) => {
|
|
|
37
80
|
...(change
|
|
38
81
|
? {
|
|
39
82
|
change: {
|
|
40
|
-
...(
|
|
41
|
-
...(change.
|
|
42
|
-
...(change.startTime === undefined ? {} : { start_time: change.startTime }),
|
|
43
|
-
...(change.durationMinutes === undefined ? {} : { duration_minutes: change.durationMinutes }),
|
|
44
|
-
...(change.timezone === undefined ? {} : { timezone: change.timezone }),
|
|
45
|
-
...(change.agenda === undefined ? {} : { agenda: change.agenda }),
|
|
83
|
+
...Object.fromEntries(MEETING_FIELDS.flatMap((key) => change[key] === undefined ? [] : [[MEETING_FIELD_KEYS[key], change[key]]])),
|
|
84
|
+
...(change.settings === undefined ? {} : { settings: { ...change.settings } }),
|
|
46
85
|
},
|
|
47
86
|
}
|
|
48
87
|
: {}),
|
|
49
88
|
applied: receipt.applied,
|
|
50
|
-
...(receipt.meeting
|
|
89
|
+
...(receipt.meeting
|
|
90
|
+
? { meeting: meetingOf(receipt.meeting), untrusted: ["meeting.title", "meeting.agenda", "meeting.join_url"] }
|
|
91
|
+
: {}),
|
|
51
92
|
};
|
|
52
93
|
};
|
|
53
94
|
/**
|
|
@@ -58,26 +99,27 @@ const receiptItem = (receipt) => {
|
|
|
58
99
|
export const addMeetingManagementCommands = (group, deps) => {
|
|
59
100
|
const { management, print, output, inRun, askFirst } = deps;
|
|
60
101
|
const has = (name) => management.capabilities.includes(name);
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
102
|
+
// The question comes after validation, so a change the service cannot take is refused without asking. A write the
|
|
103
|
+
// owner could not be asked about never goes: a host that forgets the question gets a refusal.
|
|
104
|
+
const mutation = (command) => ({
|
|
105
|
+
apply: true,
|
|
106
|
+
dryRun: command.optsWithGlobals().dryRun === true,
|
|
107
|
+
confirm: async () => {
|
|
65
108
|
if (!askFirst)
|
|
66
109
|
throw new CliError("configuration_error", "this tool cannot ask before it changes a meeting on the service");
|
|
67
110
|
await askFirst(command);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
};
|
|
111
|
+
},
|
|
112
|
+
});
|
|
71
113
|
const write = (name) => annotate(group.command(name), { effects: REMOTE_WRITE, offline: false, output: { entity: "meeting_change" } });
|
|
72
114
|
const target = (command) => command.argument("<meeting>", "the service's id of the meeting");
|
|
73
115
|
if (has("create"))
|
|
74
|
-
output(changeOptions(write("create").description("create a meeting on the service"))).action(async (flags, command) => inRun(command, async () => print({ item: receiptItem(await management.create(changeOf(flags),
|
|
116
|
+
output(changeOptions(write("create").description("create a meeting on the service"), management.fields.create, true)).action(async (flags, command) => inRun(command, async () => print({ item: receiptItem(await management.create(changeOf(flags), mutation(command))) }, command)));
|
|
75
117
|
if (has("update"))
|
|
76
|
-
output(changeOptions(target(write("update").description("change a meeting on the service")))).action(async (id, flags, command) => inRun(command, async () => print({ item: receiptItem(await management.update(id, changeOf(flags),
|
|
118
|
+
output(changeOptions(target(write("update").description("change a meeting on the service")), management.fields.update, false)).action(async (id, flags, command) => inRun(command, async () => print({ item: receiptItem(await management.update(id, changeOf(flags), mutation(command))) }, command)));
|
|
77
119
|
if (has("cancel"))
|
|
78
120
|
output(target(write("cancel").description("cancel a meeting on the service")).option("--occurrence-id <id>", "cancel only this occurrence of a repeating meeting")).action(async (id, flags, command) => inRun(command, async () => print({
|
|
79
121
|
item: receiptItem(await management.cancel(id, {
|
|
80
|
-
...
|
|
122
|
+
...mutation(command),
|
|
81
123
|
...(flags.occurrenceId === undefined ? {} : { occurrenceId: flags.occurrenceId }),
|
|
82
124
|
})),
|
|
83
125
|
}, command)));
|
|
@@ -11,6 +11,8 @@ export interface MeetingExport {
|
|
|
11
11
|
format: MeetingExportFormat;
|
|
12
12
|
filename: string;
|
|
13
13
|
content: string;
|
|
14
|
+
/** The content is what people said and wrote. */
|
|
15
|
+
untrusted: string[];
|
|
14
16
|
}
|
|
15
17
|
export declare const serializeVtt: (lines: readonly TranscriptLine[]) => string;
|
|
16
18
|
export declare const exportMeeting: (store: MeetingStore, id: number, options: MeetingExportOptions) => Promise<MeetingExport>;
|
package/dist/meetings/export.js
CHANGED
|
@@ -93,5 +93,6 @@ export const exportMeeting = async (store, id, options) => {
|
|
|
93
93
|
format: options.format,
|
|
94
94
|
filename: `meeting-${details.meeting.id}${options.transcriptId === undefined ? "" : `-transcript-${options.transcriptId}`}.${options.format === "markdown" ? "md" : "vtt"}`,
|
|
95
95
|
content,
|
|
96
|
+
untrusted: ["content"],
|
|
96
97
|
};
|
|
97
98
|
};
|
package/dist/meetings/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export { joinKeyOf, joinUrlWithoutQuery } from "./join-key.js";
|
|
|
21
21
|
export { transcriptLanguage } from "./language.js";
|
|
22
22
|
export { CHAT_MESSAGES_READ, type MeetingChatLine, type MeetingChatLinesInput, type MeetingChatLinesStore, type MeetingLink, } from "./links.js";
|
|
23
23
|
export { createMeetingContext, type MeetingContextAction, type MeetingContextChange, type MeetingContextOperation, type MeetingContextPorts, type MeetingContextReceipt, validateMeetingContextChange, } from "./meeting-context.js";
|
|
24
|
-
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";
|
|
24
|
+
export { createMeetingManagement, type DeclaredMeetingFields, declareMeetingFields, dispatchMeetingMutation, type ManagedMeeting, type ManagedMeetingChange, MEETING_FIELD_KEYS, MEETING_FIELDS, type MeetingChangeRules, type MeetingField, type MeetingFields, type MeetingManagement, type MeetingManagementPorts, type MeetingMutationOptions, type MeetingMutationProposal, type MeetingMutationReceipt, type MeetingOperationOptions, type MeetingProviderContext, type MeetingSetting, meetingFieldFlag, validateMeetingChange, } from "./meeting-management.js";
|
|
25
25
|
export type { Attachment, ChatLine, Event, EventSeries, JsonValue, Meeting, MeetingSeries, Metadata, Occurrence, Participant, RecordTimes, SourceChatLine, SourceMeeting, Summary, SummaryContent, Transcript, TranscriptLine, TranscriptRow, } from "./model.js";
|
|
26
26
|
export { type MeetingParticipantCandidate, type MeetingParticipantPage, type MeetingParticipantReader, type MeetingParticipantSearchOptions, type MeetingParticipantSearchStore, normalizeMeetingParticipantQuery, validateMeetingParticipantSearch, } from "./participant-search.js";
|
|
27
27
|
export { type MeetingContextCue, type MeetingHitContextOptions, type MeetingHitContextPacket, type MeetingPassageOutputFormat, type MeetingPassageReader, type MeetingPassageRequest, type MeetingPassageResult, meetingHitContextLimits, validateMeetingPassage, } from "./passage.js";
|
package/dist/meetings/index.js
CHANGED
|
@@ -18,7 +18,7 @@ export { joinKeyOf, joinUrlWithoutQuery } from "./join-key.js";
|
|
|
18
18
|
export { transcriptLanguage } from "./language.js";
|
|
19
19
|
export { CHAT_MESSAGES_READ, } from "./links.js";
|
|
20
20
|
export { createMeetingContext, validateMeetingContextChange, } from "./meeting-context.js";
|
|
21
|
-
export { createMeetingManagement, dispatchMeetingMutation, validateMeetingChange, } from "./meeting-management.js";
|
|
21
|
+
export { createMeetingManagement, declareMeetingFields, dispatchMeetingMutation, MEETING_FIELD_KEYS, MEETING_FIELDS, meetingFieldFlag, validateMeetingChange, } from "./meeting-management.js";
|
|
22
22
|
export { normalizeMeetingParticipantQuery, validateMeetingParticipantSearch, } from "./participant-search.js";
|
|
23
23
|
export { meetingHitContextLimits, validateMeetingPassage, } from "./passage.js";
|
|
24
24
|
export { FACT_TYPES, PAYMENT_DIRECTIONS, PAYMENT_STATES, paymentTitle, validatePayment, } from "./payment.js";
|
|
@@ -16,6 +16,42 @@ export interface ManagedMeetingChange {
|
|
|
16
16
|
durationMinutes?: number;
|
|
17
17
|
timezone?: string;
|
|
18
18
|
agenda?: string;
|
|
19
|
+
/** The service's own settings by their declared names (`MeetingSetting`). */
|
|
20
|
+
settings?: Readonly<Record<string, string | boolean>>;
|
|
21
|
+
}
|
|
22
|
+
/** A field every meetings service may take; each port declares the ones its service reads. */
|
|
23
|
+
export type MeetingField = "title" | "kind" | "startTime" | "durationMinutes" | "timezone" | "agenda";
|
|
24
|
+
/** Each field's key in an answer; its option is the key with dashes, `--start-time`. */
|
|
25
|
+
export declare const MEETING_FIELD_KEYS: Readonly<Record<MeetingField, string>>;
|
|
26
|
+
export declare const MEETING_FIELDS: readonly MeetingField[];
|
|
27
|
+
export declare const meetingFieldFlag: (field: MeetingField) => string;
|
|
28
|
+
/** A setting only this service has, given as `--setting <name>=<value>`; the name is snake_case. */
|
|
29
|
+
export type MeetingSetting = {
|
|
30
|
+
name: string;
|
|
31
|
+
description: string;
|
|
32
|
+
type: "choice";
|
|
33
|
+
values: readonly string[];
|
|
34
|
+
} | {
|
|
35
|
+
name: string;
|
|
36
|
+
description: string;
|
|
37
|
+
type: "boolean";
|
|
38
|
+
}
|
|
39
|
+
/** Blank text is refused unless `clearable`: then `""` clears the setting on the service. */
|
|
40
|
+
| {
|
|
41
|
+
name: string;
|
|
42
|
+
description: string;
|
|
43
|
+
type: "text";
|
|
44
|
+
clearable?: boolean;
|
|
45
|
+
};
|
|
46
|
+
/** What one write port reads. A port that declares nothing reads every `MEETING_FIELDS` entry and no setting. */
|
|
47
|
+
export interface MeetingFields {
|
|
48
|
+
fields?: readonly MeetingField[];
|
|
49
|
+
settings?: readonly MeetingSetting[];
|
|
50
|
+
}
|
|
51
|
+
/** A declaration with its defaults filled in, as `createMeetingManagement` exposes it. */
|
|
52
|
+
export interface DeclaredMeetingFields {
|
|
53
|
+
readonly fields: readonly MeetingField[];
|
|
54
|
+
readonly settings: readonly MeetingSetting[];
|
|
19
55
|
}
|
|
20
56
|
export interface MeetingOperationOptions {
|
|
21
57
|
signal?: AbortSignal;
|
|
@@ -24,6 +60,8 @@ export interface MeetingMutationOptions extends MeetingOperationOptions {
|
|
|
24
60
|
apply?: boolean;
|
|
25
61
|
dryRun?: boolean;
|
|
26
62
|
occurrenceId?: string;
|
|
63
|
+
/** Runs after the change is validated and before it is dispatched, only when it will be: the owner's question. */
|
|
64
|
+
confirm?: () => Promise<void>;
|
|
27
65
|
}
|
|
28
66
|
export interface MeetingProviderContext extends MeetingOperationOptions {
|
|
29
67
|
readonly scope: Readonly<MeetingProviderScope>;
|
|
@@ -40,6 +78,11 @@ export interface MeetingManagementPorts {
|
|
|
40
78
|
cancel?(id: string, context: MeetingProviderContext & {
|
|
41
79
|
occurrenceId?: string;
|
|
42
80
|
}): Promise<void>;
|
|
81
|
+
/** What `create` and `update` read; see `MeetingFields`. */
|
|
82
|
+
fields?: {
|
|
83
|
+
create?: MeetingFields;
|
|
84
|
+
update?: MeetingFields;
|
|
85
|
+
};
|
|
43
86
|
}
|
|
44
87
|
export interface MeetingMutationProposal {
|
|
45
88
|
action: "create" | "update" | "cancel";
|
|
@@ -52,15 +95,37 @@ export interface MeetingMutationReceipt extends MeetingMutationProposal {
|
|
|
52
95
|
applied: boolean;
|
|
53
96
|
meeting?: ManagedMeeting;
|
|
54
97
|
}
|
|
55
|
-
|
|
56
|
-
|
|
98
|
+
export declare const SNAKE_CASE: RegExp;
|
|
99
|
+
/**
|
|
100
|
+
* Checks a port's declaration once, when the management is made: a bad one is the host's mistake, not the owner's.
|
|
101
|
+
* A create that declares `kind` without `startTime` could never schedule, so it is refused.
|
|
102
|
+
*/
|
|
103
|
+
export declare const declareMeetingFields: (declared?: MeetingFields, action?: "create" | "update") => DeclaredMeetingFields;
|
|
104
|
+
export interface MeetingChangeRules {
|
|
105
|
+
/** What the port reads; `declareMeetingFields()` (every portable field, no setting) when absent. */
|
|
106
|
+
declared?: DeclaredMeetingFields;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Returns a detached, canonical change with only what the port declared; a create always carries `kind`. A service
|
|
110
|
+
* that cannot schedule (no `startTime` declared) only makes meetings that start now. One that can needs a start or
|
|
111
|
+
* an explicit `kind: "instant"`: over MCP an agent is not asked first, so a forgotten start must be an error, not a
|
|
112
|
+
* live meeting. An instant create gets its `startTime` when it is dispatched (`createMeetingManagement`).
|
|
113
|
+
*/
|
|
114
|
+
export declare const validateMeetingChange: (change: ManagedMeetingChange, create: boolean, rules?: MeetingChangeRules) => Readonly<ManagedMeetingChange>;
|
|
57
115
|
/** Dispatches at most once. An adapter owns acknowledgement and uncertain-outcome errors. */
|
|
58
116
|
export declare const dispatchMeetingMutation: <T>(options: MeetingMutationOptions, dispatch: (signal?: AbortSignal) => Promise<T>) => Promise<{
|
|
59
117
|
applied: boolean;
|
|
60
118
|
value?: T;
|
|
61
119
|
}>;
|
|
62
|
-
export declare const createMeetingManagement: (scope: MeetingProviderScope, ports: MeetingManagementPorts
|
|
120
|
+
export declare const createMeetingManagement: (scope: MeetingProviderScope, ports: MeetingManagementPorts, options?: {
|
|
121
|
+
now?: () => number;
|
|
122
|
+
}) => {
|
|
63
123
|
scope: Readonly<MeetingProviderScope>;
|
|
124
|
+
/** What `create` and `update` take, with the defaults filled in. */
|
|
125
|
+
fields: Readonly<{
|
|
126
|
+
create: DeclaredMeetingFields;
|
|
127
|
+
update: DeclaredMeetingFields;
|
|
128
|
+
}>;
|
|
64
129
|
capabilities: readonly string[];
|
|
65
130
|
list(options?: MeetingOperationOptions): Promise<ManagedMeeting[]>;
|
|
66
131
|
get(id: string, options?: MeetingOperationOptions): Promise<ManagedMeeting>;
|
|
@@ -1,23 +1,115 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { snapshotMeetingScope } from "./provider.js";
|
|
3
3
|
import { meetingTimestamp } from "./timestamp.js";
|
|
4
|
+
/** Each field's key in an answer; its option is the key with dashes, `--start-time`. */
|
|
5
|
+
export const MEETING_FIELD_KEYS = Object.freeze({
|
|
6
|
+
title: "title",
|
|
7
|
+
kind: "kind",
|
|
8
|
+
startTime: "start_time",
|
|
9
|
+
durationMinutes: "duration_minutes",
|
|
10
|
+
timezone: "timezone",
|
|
11
|
+
agenda: "agenda",
|
|
12
|
+
});
|
|
13
|
+
export const MEETING_FIELDS = Object.freeze(Object.keys(MEETING_FIELD_KEYS));
|
|
14
|
+
export const meetingFieldFlag = (field) => `--${MEETING_FIELD_KEYS[field].replaceAll("_", "-")}`;
|
|
4
15
|
const nonempty = (value, name) => {
|
|
5
16
|
if (typeof value !== "string" || !value.trim())
|
|
6
17
|
throw new CliError("validation_error", `${name} must be nonempty`);
|
|
7
18
|
return value;
|
|
8
19
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
export const SNAKE_CASE = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;
|
|
21
|
+
const isField = (key) => Object.hasOwn(MEETING_FIELD_KEYS, key);
|
|
22
|
+
/**
|
|
23
|
+
* Checks a port's declaration once, when the management is made: a bad one is the host's mistake, not the owner's.
|
|
24
|
+
* A create that declares `kind` without `startTime` could never schedule, so it is refused.
|
|
25
|
+
*/
|
|
26
|
+
export const declareMeetingFields = (declared = {}, action = "create") => {
|
|
27
|
+
const wrong = (why) => new CliError("configuration_error", `meeting fields: ${why}`);
|
|
28
|
+
const fields = declared.fields ?? MEETING_FIELDS;
|
|
29
|
+
for (const field of fields)
|
|
30
|
+
if (!isField(String(field)))
|
|
31
|
+
throw wrong(`unknown field ${String(field)}`);
|
|
32
|
+
if (action === "create" && fields.includes("kind") && !fields.includes("startTime"))
|
|
33
|
+
throw wrong("create declares kind without startTime, so a scheduled meeting could never get its start");
|
|
34
|
+
const names = new Set();
|
|
35
|
+
const settings = (declared.settings ?? []).map((setting) => {
|
|
36
|
+
const name = setting?.name;
|
|
37
|
+
if (typeof name !== "string" || !SNAKE_CASE.test(name))
|
|
38
|
+
throw wrong(`setting name ${String(name)} is not snake_case`);
|
|
39
|
+
if (names.has(name))
|
|
40
|
+
throw wrong(`setting ${name} is declared twice`);
|
|
41
|
+
names.add(name);
|
|
42
|
+
if (typeof setting.description !== "string" || !setting.description.trim())
|
|
43
|
+
throw wrong(`setting ${name} has no description`);
|
|
44
|
+
if (setting.type === "choice") {
|
|
45
|
+
const values = setting.values;
|
|
46
|
+
if (!Array.isArray(values) || !values.length || values.some((value) => typeof value !== "string" || !value))
|
|
47
|
+
throw wrong(`setting ${name} lists no values`);
|
|
48
|
+
return Object.freeze({ ...setting, values: Object.freeze([...new Set(values)]) });
|
|
49
|
+
}
|
|
50
|
+
if (setting.type !== "boolean" && setting.type !== "text")
|
|
51
|
+
throw wrong(`setting ${name} has an unknown type`);
|
|
52
|
+
return Object.freeze({ ...setting });
|
|
53
|
+
});
|
|
54
|
+
return Object.freeze({ fields: Object.freeze([...new Set(fields)]), settings: Object.freeze(settings) });
|
|
55
|
+
};
|
|
56
|
+
const settingNamed = (declared, name) => declared.settings.find((setting) => setting.name === name);
|
|
57
|
+
const supportedList = (declared) => {
|
|
58
|
+
const all = [
|
|
59
|
+
...declared.fields.map(meetingFieldFlag),
|
|
60
|
+
...declared.settings.map((setting) => `--setting ${setting.name}`),
|
|
61
|
+
];
|
|
62
|
+
return all.length ? all.join(", ") : "nothing";
|
|
63
|
+
};
|
|
64
|
+
const settingValue = (setting, value) => {
|
|
65
|
+
const refuse = (expected) => new CliError("validation_error", `meeting setting ${setting.name} must be ${expected}`);
|
|
66
|
+
if (setting.type === "boolean") {
|
|
67
|
+
if (typeof value === "boolean")
|
|
68
|
+
return value;
|
|
69
|
+
if (value === "true" || value === "false")
|
|
70
|
+
return value === "true";
|
|
71
|
+
throw refuse("true or false");
|
|
72
|
+
}
|
|
73
|
+
if (typeof value !== "string")
|
|
74
|
+
throw refuse(setting.type === "choice" ? setting.values.join(", ") : "text");
|
|
75
|
+
if (setting.type === "choice" && !setting.values.includes(value))
|
|
76
|
+
throw refuse(`one of ${setting.values.join(", ")}`);
|
|
77
|
+
if (setting.type === "text" && !value.trim()) {
|
|
78
|
+
if (!setting.clearable)
|
|
79
|
+
throw refuse("nonempty text: this service cannot clear it");
|
|
80
|
+
return "";
|
|
81
|
+
}
|
|
82
|
+
return value;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Returns a detached, canonical change with only what the port declared; a create always carries `kind`. A service
|
|
86
|
+
* that cannot schedule (no `startTime` declared) only makes meetings that start now. One that can needs a start or
|
|
87
|
+
* an explicit `kind: "instant"`: over MCP an agent is not asked first, so a forgotten start must be an error, not a
|
|
88
|
+
* live meeting. An instant create gets its `startTime` when it is dispatched (`createMeetingManagement`).
|
|
89
|
+
*/
|
|
90
|
+
export const validateMeetingChange = (change, create, rules = {}) => {
|
|
91
|
+
const declared = rules.declared ?? declareMeetingFields();
|
|
92
|
+
const action = create ? "create" : "update";
|
|
93
|
+
if (!change || typeof change !== "object" || Array.isArray(change))
|
|
94
|
+
throw new CliError("validation_error", "a meeting change must be an object");
|
|
95
|
+
const undeclared = Object.keys(change).flatMap((key) => change[key] === undefined || key === "settings"
|
|
96
|
+
? []
|
|
97
|
+
: isField(key)
|
|
98
|
+
? declared.fields.includes(key)
|
|
99
|
+
? []
|
|
100
|
+
: [meetingFieldFlag(key)]
|
|
101
|
+
: [key]);
|
|
102
|
+
const given = change.settings ?? {};
|
|
103
|
+
if (typeof given !== "object" || Array.isArray(given) || given === null)
|
|
104
|
+
throw new CliError("validation_error", "meeting settings must be an object of name and value");
|
|
105
|
+
for (const name of Object.keys(given))
|
|
106
|
+
if (!settingNamed(declared, name))
|
|
107
|
+
undeclared.push(`--setting ${name}`);
|
|
108
|
+
if (undeclared.length)
|
|
109
|
+
throw new CliError("validation_error", `this service does not take ${undeclared.join(", ")} on ${action}; it takes ${supportedList(declared)}`);
|
|
16
110
|
const result = {};
|
|
17
111
|
if (change.title !== undefined)
|
|
18
112
|
result.title = nonempty(change.title, "meeting title");
|
|
19
|
-
if (create && result.title === undefined)
|
|
20
|
-
throw new CliError("validation_error", "meeting title is required");
|
|
21
113
|
if (change.kind !== undefined) {
|
|
22
114
|
if (change.kind !== "instant" && change.kind !== "scheduled")
|
|
23
115
|
throw new CliError("validation_error", "only instant or scheduled meeting kinds are supported");
|
|
@@ -47,10 +139,18 @@ export const validateMeetingChange = (change, create) => {
|
|
|
47
139
|
throw new CliError("validation_error", "meeting agenda must be text");
|
|
48
140
|
result.agenda = change.agenda;
|
|
49
141
|
}
|
|
142
|
+
const settings = Object.entries(given).map(([name, value]) => [name, settingValue(settingNamed(declared, name), value)]);
|
|
143
|
+
if (settings.length)
|
|
144
|
+
result.settings = Object.freeze(Object.fromEntries(settings));
|
|
50
145
|
if (create) {
|
|
51
|
-
|
|
146
|
+
const schedules = declared.fields.includes("startTime");
|
|
147
|
+
result.kind ??= result.startTime !== undefined ? "scheduled" : schedules ? undefined : "instant";
|
|
148
|
+
if (result.kind === undefined)
|
|
149
|
+
throw new CliError("validation_error", declared.fields.includes("kind")
|
|
150
|
+
? "give --start-time, or --kind instant for a meeting that starts now"
|
|
151
|
+
: "give --start-time: this service has no meeting that starts now");
|
|
52
152
|
if (result.kind === "scheduled" && result.startTime === undefined)
|
|
53
|
-
throw new CliError("validation_error", "scheduled meeting start
|
|
153
|
+
throw new CliError("validation_error", "a scheduled meeting needs --start-time");
|
|
54
154
|
}
|
|
55
155
|
else if (!Object.keys(result).length)
|
|
56
156
|
throw new CliError("validation_error", "at least one meeting change is required");
|
|
@@ -66,14 +166,23 @@ const checkCancelled = (signal) => {
|
|
|
66
166
|
};
|
|
67
167
|
/** Dispatches at most once. An adapter owns acknowledgement and uncertain-outcome errors. */
|
|
68
168
|
export const dispatchMeetingMutation = async (options, dispatch) => {
|
|
69
|
-
const { apply, dryRun, signal } = options;
|
|
169
|
+
const { apply, dryRun, signal, confirm } = options;
|
|
70
170
|
checkCancelled(signal);
|
|
71
171
|
if (apply !== true || dryRun)
|
|
72
172
|
return { applied: false };
|
|
173
|
+
if (confirm) {
|
|
174
|
+
await confirm();
|
|
175
|
+
checkCancelled(signal);
|
|
176
|
+
}
|
|
73
177
|
return { applied: true, value: await dispatch(signal) };
|
|
74
178
|
};
|
|
75
|
-
export const createMeetingManagement = (scope, ports) => {
|
|
179
|
+
export const createMeetingManagement = (scope, ports, options = {}) => {
|
|
76
180
|
const fixed = snapshotMeetingScope(scope);
|
|
181
|
+
const fields = Object.freeze({
|
|
182
|
+
create: declareMeetingFields(ports.fields?.create, "create"),
|
|
183
|
+
update: declareMeetingFields(ports.fields?.update, "update"),
|
|
184
|
+
});
|
|
185
|
+
const now = options.now ?? Date.now;
|
|
77
186
|
const capabilities = {};
|
|
78
187
|
for (const name of ["list", "get", "invitation", "create", "update", "cancel"]) {
|
|
79
188
|
const port = ports[name];
|
|
@@ -94,6 +203,8 @@ export const createMeetingManagement = (scope, ports) => {
|
|
|
94
203
|
};
|
|
95
204
|
return {
|
|
96
205
|
scope: fixed,
|
|
206
|
+
/** What `create` and `update` take, with the defaults filled in. */
|
|
207
|
+
fields,
|
|
97
208
|
capabilities: Object.freeze(Object.keys(capabilities).filter((name) => typeof capabilities[name] === "function")),
|
|
98
209
|
list(options = {}) {
|
|
99
210
|
return capability("list")(context(options));
|
|
@@ -106,13 +217,19 @@ export const createMeetingManagement = (scope, ports) => {
|
|
|
106
217
|
},
|
|
107
218
|
async create(change, options = {}) {
|
|
108
219
|
const port = capability("create");
|
|
109
|
-
const validated = validateMeetingChange(change, true);
|
|
220
|
+
const validated = validateMeetingChange(change, true, { declared: fields.create });
|
|
110
221
|
const ctx = context(options);
|
|
111
|
-
|
|
222
|
+
let sent = validated;
|
|
223
|
+
// "Now" is when it goes, after the owner's question, not when the command started.
|
|
224
|
+
const outcome = await dispatchMeetingMutation(options, () => {
|
|
225
|
+
if (sent.startTime === undefined)
|
|
226
|
+
sent = Object.freeze({ ...validated, startTime: new Date(now()).toISOString() });
|
|
227
|
+
return port(sent, ctx);
|
|
228
|
+
});
|
|
112
229
|
return {
|
|
113
230
|
action: "create",
|
|
114
231
|
scope: fixed,
|
|
115
|
-
change:
|
|
232
|
+
change: sent,
|
|
116
233
|
applied: outcome.applied,
|
|
117
234
|
...(outcome.value ? { meeting: outcome.value } : {}),
|
|
118
235
|
};
|
|
@@ -120,7 +237,7 @@ export const createMeetingManagement = (scope, ports) => {
|
|
|
120
237
|
async update(id, change, options = {}) {
|
|
121
238
|
const port = capability("update");
|
|
122
239
|
const validatedId = nonempty(id, "meeting id");
|
|
123
|
-
const validated = validateMeetingChange(change, false);
|
|
240
|
+
const validated = validateMeetingChange(change, false, { declared: fields.update });
|
|
124
241
|
const ctx = context(options);
|
|
125
242
|
const outcome = await dispatchMeetingMutation(options, () => port(validatedId, validated, ctx));
|
|
126
243
|
return { action: "update", scope: fixed, id: validatedId, change: validated, applied: outcome.applied };
|
|
@@ -128,6 +128,7 @@ export declare const meetingParticipants: v.StrictObjectSchema<{
|
|
|
128
128
|
readonly ref: v.StringSchema<undefined>;
|
|
129
129
|
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
130
130
|
}, undefined>, undefined>;
|
|
131
|
+
readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
131
132
|
}, undefined>, undefined>;
|
|
132
133
|
/** Several identities on one page are observations, never speaker attribution or person links. */
|
|
133
134
|
readonly ambiguity: v.StrictObjectSchema<{
|
|
@@ -165,6 +165,7 @@ export const meetingParticipants = v.strictObject({
|
|
|
165
165
|
display_name: v.nullable(text),
|
|
166
166
|
email: v.nullable(text),
|
|
167
167
|
person: v.nullable(v.strictObject({ ref: text, name: v.nullable(text) })),
|
|
168
|
+
untrusted: v.optional(v.array(text)),
|
|
168
169
|
})),
|
|
169
170
|
/** Several identities on one page are observations, never speaker attribution or person links. */
|
|
170
171
|
ambiguity: v.strictObject({ scope: v.literal("page"), multiple_identities: v.boolean(), identity_ids: v.array(id) }),
|