@wirecat/cli-core 0.560.0 → 0.562.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 +48 -1
- package/dist/calendar/busy.d.ts +11 -0
- package/dist/calendar/busy.js +14 -1
- package/dist/calendar/cli/index.d.ts +9 -3
- package/dist/calendar/cli/index.js +14 -7
- package/dist/calendar/cli/local-times.d.ts +5 -0
- package/dist/calendar/cli/local-times.js +39 -0
- package/dist/calendar/mcp/index.js +1 -1
- package/dist/calendar/reads.d.ts +11 -2
- package/dist/calendar/reads.js +34 -18
- package/dist/calendar/writes.js +3 -44
- package/dist/cli/app-doctor-command.js +3 -1
- package/dist/cli/index.d.ts +2 -1
- package/dist/cli/index.js +2 -1
- package/dist/cli/setting-defaults.d.ts +27 -0
- package/dist/cli/setting-defaults.js +36 -0
- package/dist/errors/reasons.js +1 -0
- package/dist/meetings/mcp/index.d.ts +15 -15
- package/dist/sends/index.d.ts +1 -0
- package/dist/sends/index.js +1 -0
- package/dist/sends/keyed-guard.d.ts +12 -0
- package/dist/sends/keyed-guard.js +49 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,54 @@ Notable changes to `@wirecat/cli-core` (`@wirecat/cli-messaging` up to 0.261.0,
|
|
|
5
5
|
minor version may break callers, and says how under "Changed — may break callers". `pnpm docs:check` checks the
|
|
6
6
|
shape of this file.
|
|
7
7
|
|
|
8
|
-
##
|
|
8
|
+
## 0.562.0 — 03.11.2026
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **A CLI can write each of its settings into its config file with the default, so the owner sees every setting
|
|
13
|
+
there.** A CLI declares its scalar settings as `DeclaredSetting` (`key`, `default`, `description`).
|
|
14
|
+
`withSettingDefaults(raw, declared)` returns the file with each missing setting added at its default. It keeps the
|
|
15
|
+
owner's values, their order and unknown keys. It does not create a section that is not there.
|
|
16
|
+
`settingRows(raw, declared)` gives `config show` each setting with its value, default, description and `from`
|
|
17
|
+
(`config file` or `default`). memo is the first user (cli-base WC-CMD-30).
|
|
18
|
+
- **`KEEP_SUCCESSFUL_RUNS_FOR_DAYS` and `RUNS_SIZE_LIMIT_MB` are exported** beside `KEEP_RUNS_FOR_DAYS`. A host can
|
|
19
|
+
then name the run-record defaults it writes into its config file.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- **The shared `doctor` (`appDoctorCommand`) answers with the clock:** `meta.now`, `meta.now_local` and
|
|
24
|
+
`meta.timezone`, as a setup check should (WC-TIME-7). A CLI that kept its own doctor for this can use the shared one.
|
|
25
|
+
|
|
26
|
+
## 0.561.0 — 03.11.2026
|
|
27
|
+
|
|
28
|
+
### Changed — may break callers
|
|
29
|
+
|
|
30
|
+
- **`links review` under a profile lock lists only the profile's own link choices.** With `deps.locked`, or without
|
|
31
|
+
`deps.messages`, only choices about the account's own copies are listed, and a candidate event the account holds no
|
|
32
|
+
copy of shows its ref alone, so no other account's titles. Unlocked it still lists every account's and names them
|
|
33
|
+
in `meta.accounts` (WC-ACCT-9); the top-level `accounts: "all"` is gone. Over MCP, `event_links_review` lists only
|
|
34
|
+
the served accounts' choices. `reviewsAnswer(store, accountIds?)` takes the scope; `calendarAccountNames` names the
|
|
35
|
+
store's calendar accounts.
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
|
|
39
|
+
- **`keyedGuard` in `@wirecat/cli-core/sends`:** the guard over a write's main key and its extra keys that the
|
|
40
|
+
calendar writes use — a key that refuses refuses before anything is asked, one question names every key at `ask`,
|
|
41
|
+
and `refuse(request)` checks without asking. A CLI's own API writes can now share it instead of a copy.
|
|
42
|
+
- **Calendar times at a terminal are in the zone in use, and the zone is named (WC-TIME-4).** Every shared calendar
|
|
43
|
+
command hands its host a `view` that prints each time on the zone's wall clock (an all-day event by its dates) and
|
|
44
|
+
ends with `times in <zone>`. JSON, JSONL and `--compact` are unchanged. `CalendarCommandDeps.write`'s `view` now
|
|
45
|
+
takes the host's body, which `renderAnswer` passes.
|
|
46
|
+
|
|
47
|
+
### Fixed
|
|
48
|
+
|
|
49
|
+
- **`calendars busy` says when the provider did not answer for a calendar or person.** `meta.complete` is false
|
|
50
|
+
with a `busy.unanswered` issue each (`calendar:<id>` or `person:<email>`), with or without `--duration-minutes`,
|
|
51
|
+
so free stretches are no longer shown as whole. The command is `partial`, so it still exits 0. `meta` also has
|
|
52
|
+
`now`, `now_local` and `timezone` (WC-TIME-7).
|
|
53
|
+
- **`events list`'s first help example runs.** It named `starts_at` twice, which the query refuses; it is now
|
|
54
|
+
`'starts_at:[2026-11-02 TO 2026-11-07}'`, quoted, as are `events export`'s, so zsh does not read the brackets. A
|
|
55
|
+
test runs every calendar help example with a query.
|
|
9
56
|
|
|
10
57
|
## 0.560.0 — 02.11.2026
|
|
11
58
|
|
package/dist/calendar/busy.d.ts
CHANGED
|
@@ -72,4 +72,15 @@ export declare const busyAnswer: (source: CalendarSource, query: BusyQuery, opti
|
|
|
72
72
|
end: string;
|
|
73
73
|
}[] | undefined;
|
|
74
74
|
unknown?: string[] | undefined;
|
|
75
|
+
meta: {
|
|
76
|
+
now: string;
|
|
77
|
+
now_local: string;
|
|
78
|
+
timezone: string;
|
|
79
|
+
complete: boolean;
|
|
80
|
+
issues?: {
|
|
81
|
+
code: "authentication_error" | "cancelled" | "configuration_error" | "confirmation_required" | "invalid_response" | "network_error" | "not_found" | "outcome_unknown" | "permission_error" | "provider_error" | "provider_unavailable" | "rate_limited" | "timeout" | "validation_error";
|
|
82
|
+
reason?: string | undefined;
|
|
83
|
+
source: string;
|
|
84
|
+
}[] | undefined;
|
|
85
|
+
};
|
|
75
86
|
}>;
|
package/dist/calendar/busy.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { dayBoundary, queryError, queryFieldsOf, zonedMoment, } from "@wirecat/cli-base/query";
|
|
3
|
+
import { clockMeta } from "@wirecat/cli-base/standards";
|
|
3
4
|
import { LIST_QUERY_GUIDE, listQuery, nativeTermLists, typedQuery } from "../cli/list-query.js";
|
|
4
5
|
import { calendarBusy } from "./cli/answers.js";
|
|
5
6
|
import { isFeedCalendar } from "./feeds.js";
|
|
@@ -153,7 +154,13 @@ export const busyAnswer = async (source, query, options) => {
|
|
|
153
154
|
...query.calendars.map((calendar) => ({ calendar: String(calendar.id), ...missing(calendar.externalId) })),
|
|
154
155
|
...query.people.map((person) => ({ person, ...missing(person) })),
|
|
155
156
|
];
|
|
156
|
-
const
|
|
157
|
+
const failed = rows.filter(({ error }) => error !== undefined);
|
|
158
|
+
const unknown = failed.map(({ id }) => id);
|
|
159
|
+
const issues = failed.map((row) => ({
|
|
160
|
+
code: "provider_error",
|
|
161
|
+
reason: "busy.unanswered",
|
|
162
|
+
source: "person" in row ? `person:${row.person}` : `calendar:${row.calendar}`,
|
|
163
|
+
}));
|
|
157
164
|
return {
|
|
158
165
|
...times(query.window),
|
|
159
166
|
timezone: options.zone,
|
|
@@ -169,5 +176,11 @@ export const busyAnswer = async (source, query, options) => {
|
|
|
169
176
|
...(unknown.length ? { unknown } : {}),
|
|
170
177
|
}
|
|
171
178
|
: {}),
|
|
179
|
+
// Busy times missing for one calendar or person make every free stretch a guess, slots or not.
|
|
180
|
+
meta: {
|
|
181
|
+
complete: issues.length === 0,
|
|
182
|
+
...(issues.length ? { issues } : {}),
|
|
183
|
+
...clockMeta(options.now, options.zone),
|
|
184
|
+
},
|
|
172
185
|
};
|
|
173
186
|
};
|
|
@@ -40,8 +40,11 @@ export interface CalendarCommandDeps {
|
|
|
40
40
|
embedded: number;
|
|
41
41
|
left: boolean;
|
|
42
42
|
}>;
|
|
43
|
-
/**
|
|
44
|
-
|
|
43
|
+
/**
|
|
44
|
+
* `view` is the text a person reads in place of the default rendering: the times on the zone's wall clock, and the
|
|
45
|
+
* zone named. It takes the host's own body (`renderAnswer` passes it) or, without one, renders `value`.
|
|
46
|
+
*/
|
|
47
|
+
write: (value: unknown, format: "json" | "jsonl" | "text", view?: (body?: unknown) => string) => void;
|
|
45
48
|
/** A line for the person beside the answer, never in it: which accounts `search all` read and which it skipped. */
|
|
46
49
|
note?: (text: string) => void;
|
|
47
50
|
/**
|
|
@@ -58,7 +61,10 @@ export interface CalendarCommandDeps {
|
|
|
58
61
|
writeFile?: (path: string, content: string) => Promise<void>;
|
|
59
62
|
/** Reads `events import`'s file; without it, and the writer's `import`, there is no `events import`. */
|
|
60
63
|
readFile?: (path: string) => Promise<string>;
|
|
61
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* A profile lock pins the process (WC-ACCT-5): `events list --source` may then read only the profile's account, and
|
|
66
|
+
* `links review` lists only its choices.
|
|
67
|
+
*/
|
|
62
68
|
locked?: boolean;
|
|
63
69
|
}
|
|
64
70
|
export declare const addCalendarCommands: (program: Command, deps: CalendarCommandDeps) => void;
|
|
@@ -16,12 +16,13 @@ import { linkPeople } from "../../services/people.js";
|
|
|
16
16
|
import { BUSY_QUERY, BUSY_QUERY_NOTE, busyAnswer, busyQuery, workingHoursOf } from "../busy.js";
|
|
17
17
|
import { isFeedCalendar, isPlainHttp, syncWithFeeds } from "../feeds.js";
|
|
18
18
|
import { eventPreparation, nextMeeting, PREPARE_MESSAGES } from "../prepare.js";
|
|
19
|
-
import { accountsMeta, CALENDAR_UNTRUSTED_FIELDS, calendarIn, calendarItem, EVENTS_QUERY, EVENTS_QUERY_NOTE, EXPORT_MAX, eventAnswer, eventIdOf, eventOf, eventsAnswer, eventsFilter, eventsIcs, peopleAnswer, resolveAnswer, reviewsAnswer, sourceAccounts, weekFilter, } from "../reads.js";
|
|
19
|
+
import { accountsMeta, CALENDAR_UNTRUSTED_FIELDS, calendarAccountNames, calendarIn, calendarItem, EVENTS_QUERY, EVENTS_QUERY_NOTE, EXPORT_MAX, eventAnswer, eventIdOf, eventOf, eventsAnswer, eventsFilter, eventsIcs, peopleAnswer, resolveAnswer, reviewsAnswer, sourceAccounts, weekFilter, } from "../reads.js";
|
|
20
20
|
import { REPEAT_HELP } from "../recurrence.js";
|
|
21
21
|
import { bothSearchAnswer, serverSearchAnswer } from "../server-search.js";
|
|
22
22
|
import { calendarStatus } from "../sync.js";
|
|
23
23
|
import { createEvent, createEventFromText, deleteEvent, EVENT_RESPONSES, IMPORT_MAX, importEvents, moveEvent, respondToEvent, updateEvent, } from "../writes.js";
|
|
24
24
|
import { CALENDARS_QUERY, declareCalendarAnswers, PEOPLE_QUERY } from "./answers.js";
|
|
25
|
+
import { localTimesView } from "./local-times.js";
|
|
25
26
|
import { addRemind } from "./remind.js";
|
|
26
27
|
import { addSearchAll } from "./search-all.js";
|
|
27
28
|
const LOCAL_READ = { remote: "none", local: "read" };
|
|
@@ -69,7 +70,7 @@ const addCalendarCommandsDefinition = (program, deps) => {
|
|
|
69
70
|
const zone = () => timezoneOf(deps.timezone);
|
|
70
71
|
const print = (value, command) => {
|
|
71
72
|
const opts = command.optsWithGlobals();
|
|
72
|
-
deps.write(value, opts.json ? "json" : opts.jsonl ? "jsonl" : "text");
|
|
73
|
+
deps.write(value, opts.json ? "json" : opts.jsonl ? "jsonl" : "text", (body) => localTimesView(body ?? value, zone(), outputFor(command).color));
|
|
73
74
|
};
|
|
74
75
|
const messages = (what) => {
|
|
75
76
|
if (!deps.messages)
|
|
@@ -154,7 +155,7 @@ const addCalendarCommandsDefinition = (program, deps) => {
|
|
|
154
155
|
});
|
|
155
156
|
}
|
|
156
157
|
if (deps.freeBusy)
|
|
157
|
-
example(withQuery(annotate(calendars.command("busy"), { effects: REMOTE_READ, offline: false }).description("when calendars and people are taken, asked of the provider and not stored; with --duration-minutes, " +
|
|
158
|
+
example(withQuery(annotate(calendars.command("busy"), { effects: REMOTE_READ, offline: false, partial: true }).description("when calendars and people are taken, asked of the provider and not stored; with --duration-minutes, " +
|
|
158
159
|
"the free stretches they share"), BUSY_QUERY).addHelpText("after", BUSY_QUERY_NOTE), "calendars busy person:ana@example.com --json", "calendars busy start>=2026-11-02 end<=2026-11-06 person:ana@example.com --duration-minutes 30 " +
|
|
159
160
|
"--hours 10:00-16:00")
|
|
160
161
|
.option("--duration-minutes <minutes>", "find free stretches at least this long, 5–1440", minutes)
|
|
@@ -256,7 +257,7 @@ const addCalendarCommandsDefinition = (program, deps) => {
|
|
|
256
257
|
}), command);
|
|
257
258
|
});
|
|
258
259
|
const events = annotate(program.command("events").description("the account's stored events"), { effects: GROUP });
|
|
259
|
-
example(withQuery(annotate(events.command("list"), { effects: LOCAL_READ, partial: true }).description("list stored events, earliest first; --source reads several accounts as one list"), EVENTS_QUERY).addHelpText("after", EVENTS_QUERY_NOTE), "events list starts_at
|
|
260
|
+
example(withQuery(annotate(events.command("list"), { effects: LOCAL_READ, partial: true }).description("list stored events, earliest first; --source reads several accounts as one list"), EVENTS_QUERY).addHelpText("after", EVENTS_QUERY_NOTE), "events list 'starts_at:[2026-11-02 TO 2026-11-07}' --json", "events list ends_at>=today person:ana@example.com", "events list overlapping:true --source all")
|
|
260
261
|
.option("--limit <n>", "events per page, 1–1000", integer, 100)
|
|
261
262
|
.option("--page <n>", "which page, starting at 1", integer, 1)
|
|
262
263
|
.option("--source <accounts>", "calendar accounts held in the store to read as one list: all, a provider, or a list such as " +
|
|
@@ -285,9 +286,9 @@ const addCalendarCommandsDefinition = (program, deps) => {
|
|
|
285
286
|
"finds; each occurrence of a repeating event as an event of its own"), EVENTS_QUERY).addHelpText("after", EVENTS_QUERY_NOTE), ...(deps.writeFile
|
|
286
287
|
? [
|
|
287
288
|
"events export id:42 --output planning.ics",
|
|
288
|
-
"events export starts_at:[2026-11-02 TO 2026-11-09} NOT event_type:birthday --output week.ics",
|
|
289
|
+
"events export 'starts_at:[2026-11-02 TO 2026-11-09}' NOT event_type:birthday --output week.ics",
|
|
289
290
|
]
|
|
290
|
-
: ["events export id:42", "events export starts_at:[2026-11-02 TO 2026-11-09} NOT event_type:birthday"]));
|
|
291
|
+
: ["events export id:42", "events export 'starts_at:[2026-11-02 TO 2026-11-09}' NOT event_type:birthday"]));
|
|
291
292
|
// Not over MCP: an agent would choose where on the owner's disk to write. It gets the text in the answer.
|
|
292
293
|
if (deps.writeFile)
|
|
293
294
|
writesFileOnlyWith(exporter.addOption(ownerOnlyOption("--output <file>", "the file to write; printed in the answer when absent")), "output");
|
|
@@ -440,7 +441,13 @@ const addCalendarCommandsDefinition = (program, deps) => {
|
|
|
440
441
|
effects: GROUP,
|
|
441
442
|
});
|
|
442
443
|
example(annotate(links.command("review"), { effects: LOCAL_READ }).description("copies that fit two or more events equally well, waiting for the owner's choice"), "links review --json").action(async (_opts, command) => {
|
|
443
|
-
|
|
444
|
+
// Locked to a profile (WC-ACCT-5), or with no shared store to name the others by, only the profile's own account.
|
|
445
|
+
const own = deps.locked || !deps.messages;
|
|
446
|
+
const answer = await reviewsAnswer(deps.store, own ? [deps.accountId] : undefined);
|
|
447
|
+
const accounts = own
|
|
448
|
+
? [`${deps.account.provider}:${deps.account.account}`]
|
|
449
|
+
: await calendarAccountNames(deps.store, messages("links review"), deps.account);
|
|
450
|
+
print({ ...eachMarked(answer, REVIEW_UNTRUSTED), meta: { accounts, complete: true } }, command);
|
|
444
451
|
});
|
|
445
452
|
example(annotate(links.command("resolve"), { effects: LOCAL_WRITE })
|
|
446
453
|
.description("join a copy to the event you choose, or keep it apart")
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A calendar answer as a person reads it at a terminal (WC-TIME-4): each UTC time on the wall clock of `zone`, an
|
|
3
|
+
* all-day event's times as its local dates, and a last line naming the zone. JSON keeps the UTC times.
|
|
4
|
+
*/
|
|
5
|
+
export declare const localTimesView: (value: unknown, zone: string, color: boolean) => string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { renderPretty } from "@wirecat/cli-base";
|
|
2
|
+
const UTC_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/u;
|
|
3
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4
|
+
/**
|
|
5
|
+
* A calendar answer as a person reads it at a terminal (WC-TIME-4): each UTC time on the wall clock of `zone`, an
|
|
6
|
+
* all-day event's times as its local dates, and a last line naming the zone. JSON keeps the UTC times.
|
|
7
|
+
*/
|
|
8
|
+
export const localTimesView = (value, zone, color) => {
|
|
9
|
+
const clock = new Intl.DateTimeFormat("en-CA", {
|
|
10
|
+
timeZone: zone,
|
|
11
|
+
year: "numeric",
|
|
12
|
+
month: "2-digit",
|
|
13
|
+
day: "2-digit",
|
|
14
|
+
hour: "2-digit",
|
|
15
|
+
minute: "2-digit",
|
|
16
|
+
hourCycle: "h23",
|
|
17
|
+
});
|
|
18
|
+
let shown = false;
|
|
19
|
+
const local = (text, dateOnly) => {
|
|
20
|
+
const part = Object.fromEntries(clock.formatToParts(Date.parse(text)).map(({ type, value }) => [type, value]));
|
|
21
|
+
shown = true;
|
|
22
|
+
const date = `${part.year}-${part.month}-${part.day}`;
|
|
23
|
+
return dateOnly ? date : `${date} ${part.hour}:${part.minute}`;
|
|
24
|
+
};
|
|
25
|
+
const walk = (one, allDay = false) => {
|
|
26
|
+
if (typeof one === "string")
|
|
27
|
+
return UTC_TIME.test(one) ? local(one, allDay) : one;
|
|
28
|
+
if (Array.isArray(one))
|
|
29
|
+
return one.map((item) => walk(item));
|
|
30
|
+
if (!isRecord(one))
|
|
31
|
+
return one;
|
|
32
|
+
const dates = one.all_day === true || one.allDay === true;
|
|
33
|
+
return Object.fromEntries(Object.entries(one).map(([key, item]) => [key, walk(item, dates && /^(starts|ends)_?at$/iu.test(key))]));
|
|
34
|
+
};
|
|
35
|
+
const { meta: _meta, ...rest } = isRecord(value) ? value : { value };
|
|
36
|
+
const body = isRecord(value) ? (Array.isArray(rest.items) ? rest.items : "item" in rest ? rest.item : rest) : value;
|
|
37
|
+
const text = renderPretty(walk(body), { color });
|
|
38
|
+
return shown ? `${text}\n\ntimes in ${zone}` : text;
|
|
39
|
+
};
|
|
@@ -256,7 +256,7 @@ export const callCalendarTool = async (store, name, input, { accountIds, failure
|
|
|
256
256
|
break;
|
|
257
257
|
}
|
|
258
258
|
default:
|
|
259
|
-
answer = await reviewsAnswer(store);
|
|
259
|
+
answer = await reviewsAnswer(store, accounts);
|
|
260
260
|
}
|
|
261
261
|
const result = { accounts, ...answer, untrusted: CALENDAR_UNTRUSTED_FIELDS };
|
|
262
262
|
return agentResult({
|
package/dist/calendar/reads.d.ts
CHANGED
|
@@ -168,7 +168,12 @@ export declare const peopleAnswer: (store: EventStore, accountId: number, option
|
|
|
168
168
|
};
|
|
169
169
|
}>;
|
|
170
170
|
/** Open link choices, with each candidate event's title and time so the owner can pick. */
|
|
171
|
-
|
|
171
|
+
/**
|
|
172
|
+
* Open link choices on calendar copies. Link choices are kept per store, so without `accountIds` every account's are
|
|
173
|
+
* listed; with them, only choices about those accounts' copies, and a candidate event none of them holds a copy of is
|
|
174
|
+
* shown by its ref alone.
|
|
175
|
+
*/
|
|
176
|
+
export declare const reviewsAnswer: (store: EventStore, accountIds?: readonly number[]) => Promise<{
|
|
172
177
|
limit: number;
|
|
173
178
|
hasMore: boolean;
|
|
174
179
|
items: {
|
|
@@ -182,8 +187,12 @@ export declare const reviewsAnswer: (store: EventStore) => Promise<{
|
|
|
182
187
|
}[];
|
|
183
188
|
}[];
|
|
184
189
|
page: number;
|
|
185
|
-
accounts: string;
|
|
186
190
|
}>;
|
|
191
|
+
/**
|
|
192
|
+
* The calendar accounts the store holds, by `provider:account`: the stored accounts with a calendar, and the running
|
|
193
|
+
* one. What `links review` names when it reads every account (WC-ACCT-9).
|
|
194
|
+
*/
|
|
195
|
+
export declare const calendarAccountNames: (store: EventStore, messages: MessageStore, running: AccountKey) => Promise<string[]>;
|
|
187
196
|
export declare const resolveAnswer: (store: EventStore, accountId: number, review: string, choice: string, now: number) => Promise<{
|
|
188
197
|
id: string;
|
|
189
198
|
status: "apart" | "linked" | "open";
|
package/dist/calendar/reads.js
CHANGED
|
@@ -348,25 +348,41 @@ export const peopleAnswer = async (store, accountId, options) => {
|
|
|
348
348
|
return hasMore ? { ...answer, meta: { complete: true, truncated: true } } : answer;
|
|
349
349
|
};
|
|
350
350
|
/** Open link choices, with each candidate event's title and time so the owner can pick. */
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
})),
|
|
366
|
-
})))),
|
|
367
|
-
// Link choices are kept per store, not per account, so every calendar account's are listed.
|
|
368
|
-
accounts: "all",
|
|
351
|
+
/**
|
|
352
|
+
* Open link choices on calendar copies. Link choices are kept per store, so without `accountIds` every account's are
|
|
353
|
+
* listed; with them, only choices about those accounts' copies, and a candidate event none of them holds a copy of is
|
|
354
|
+
* shown by its ref alone.
|
|
355
|
+
*/
|
|
356
|
+
export const reviewsAnswer = async (store, accountIds) => {
|
|
357
|
+
const scope = accountIds &&
|
|
358
|
+
new Set((await Promise.all(accountIds.map((id) => calendarIds(store, id)))).flatMap((ids) => [...ids]));
|
|
359
|
+
const open = (await store.reviews({ status: "open" })).filter(({ linkableType, calendarId }) => linkableType === "calendar_entry" && (!scope || (calendarId !== null && scope.has(calendarId))));
|
|
360
|
+
const shown = async (review, id) => {
|
|
361
|
+
const details = review.entityType === "event" ? await store.event(id) : undefined;
|
|
362
|
+
if (!details || (scope && !details.entries.some(({ calendarId }) => scope.has(calendarId))))
|
|
363
|
+
return undefined;
|
|
364
|
+
return details.event;
|
|
369
365
|
};
|
|
366
|
+
return listed(await Promise.all(open.map(async (review) => ({
|
|
367
|
+
id: String(review.id),
|
|
368
|
+
entry_id: String(review.linkableId),
|
|
369
|
+
reason: review.reason,
|
|
370
|
+
candidates: await Promise.all(review.candidates.map(async (id) => {
|
|
371
|
+
const event = await shown(review, id);
|
|
372
|
+
return { ref: `event:${id}`, title: event?.title ?? null, starts_at: iso(event?.startsAt ?? null) };
|
|
373
|
+
})),
|
|
374
|
+
}))));
|
|
375
|
+
};
|
|
376
|
+
/**
|
|
377
|
+
* The calendar accounts the store holds, by `provider:account`: the stored accounts with a calendar, and the running
|
|
378
|
+
* one. What `links review` names when it reads every account (WC-ACCT-9).
|
|
379
|
+
*/
|
|
380
|
+
export const calendarAccountNames = async (store, messages, running) => {
|
|
381
|
+
const names = new Set([nameOf(running)]);
|
|
382
|
+
for (const one of await messages.accounts.storedAccounts())
|
|
383
|
+
if ((await store.calendars(one.id)).length)
|
|
384
|
+
names.add(nameOf(one));
|
|
385
|
+
return [...names];
|
|
370
386
|
};
|
|
371
387
|
export const resolveAnswer = async (store, accountId, review, choice, now) => {
|
|
372
388
|
if (!/^[1-9]\d*$/u.test(review))
|
package/dist/calendar/writes.js
CHANGED
|
@@ -3,6 +3,7 @@ import { CliError, isCliError } from "@wirecat/cli-base";
|
|
|
3
3
|
import { zonedMoment } from "@wirecat/cli-base/query";
|
|
4
4
|
import { guardFor } from "../sends/guard.js";
|
|
5
5
|
import { guardedWrite } from "../sends/guarded.js";
|
|
6
|
+
import { keyedGuard } from "../sends/keyed-guard.js";
|
|
6
7
|
import { DEFAULT_PERMISSIONS, levelFor } from "../sends/permissions.js";
|
|
7
8
|
import { newOperationId } from "../sends/send-id.js";
|
|
8
9
|
import { isFeedCalendar } from "./feeds.js";
|
|
@@ -85,53 +86,11 @@ export const draftOf = (fields, zone, { whole, allDay = false }) => {
|
|
|
85
86
|
throw new CliError("validation_error", "nothing to change");
|
|
86
87
|
return patch;
|
|
87
88
|
};
|
|
88
|
-
/**
|
|
89
|
-
* Over the profile's guard, the write's other keys are checked too. A key that refuses is refused before anything is
|
|
90
|
-
* asked, so nobody answers yes to a write that a stricter key then stops, and one answer covers every key of a write.
|
|
91
|
-
*/
|
|
89
|
+
/** The profile's guard over the write's main key and its other keys (`keyedGuard`). */
|
|
92
90
|
const writeGuard = (context, extra) => {
|
|
93
91
|
const settings = context.writes.settings();
|
|
94
92
|
const defaults = { ...DEFAULT_PERMISSIONS, ...CALENDAR_WRITE_DEFAULTS, ...settings.permissionDefaults };
|
|
95
|
-
|
|
96
|
-
let answered = false;
|
|
97
|
-
const guard = guardFor(context.writes.app, { ...settings, permissionDefaults: defaults }, context.writes.warn ?? (() => { }), context.writes.env, async (key, request) => {
|
|
98
|
-
if (answered)
|
|
99
|
-
return;
|
|
100
|
-
await context.ask(question ?? key, request);
|
|
101
|
-
answered = true;
|
|
102
|
-
});
|
|
103
|
-
const probes = new WeakMap();
|
|
104
|
-
// A probe is checked and never journaled or counted: the write itself holds the one journal line.
|
|
105
|
-
const all = (request) => {
|
|
106
|
-
let found = probes.get(request);
|
|
107
|
-
if (!found) {
|
|
108
|
-
found = extra.map((key) => ({ chatId: null, kind: "read", key }));
|
|
109
|
-
probes.set(request, found);
|
|
110
|
-
}
|
|
111
|
-
return [request, ...found];
|
|
112
|
-
};
|
|
113
|
-
return {
|
|
114
|
-
ask: async (request) => {
|
|
115
|
-
const levelOf = ({ key }) => levelFor(settings.permissions, key, defaults).level;
|
|
116
|
-
const refused = all(request).find((one) => ["deny", "readonly"].includes(levelOf(one)));
|
|
117
|
-
if (refused)
|
|
118
|
-
guard.check(refused, { reserve: false });
|
|
119
|
-
// The one question names every key that asks, so a yes to the write is never a silent yes to mailing people.
|
|
120
|
-
question = all(request)
|
|
121
|
-
.filter((one) => levelOf(one) === "ask")
|
|
122
|
-
.map(({ key }) => key)
|
|
123
|
-
.join(" and ");
|
|
124
|
-
for (const one of all(request))
|
|
125
|
-
await guard.ask?.(one);
|
|
126
|
-
},
|
|
127
|
-
check: (request, options) => {
|
|
128
|
-
for (const one of all(request).slice(1))
|
|
129
|
-
guard.check(one, { reserve: false });
|
|
130
|
-
guard.check(request, options);
|
|
131
|
-
},
|
|
132
|
-
...(guard.reserve ? { reserve: guard.reserve } : {}),
|
|
133
|
-
record: (entry) => guard.record(entry),
|
|
134
|
-
};
|
|
93
|
+
return keyedGuard((ask) => guardFor(context.writes.app, { ...settings, permissionDefaults: defaults }, context.writes.warn ?? (() => { }), context.writes.env, ask), context.ask, (key) => levelFor(settings.permissions, key, defaults).level, extra);
|
|
135
94
|
};
|
|
136
95
|
const notifyOf = (context, choice, others) => {
|
|
137
96
|
if (choice !== undefined)
|
|
@@ -2,6 +2,8 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import { dirname, resolve } from "node:path";
|
|
3
3
|
import { CliError, configFilePath, resolvePaths } from "@wirecat/cli-base";
|
|
4
4
|
import { annotate } from "@wirecat/cli-base/commands";
|
|
5
|
+
import { timezoneOf } from "@wirecat/cli-base/query";
|
|
6
|
+
import { clockMeta } from "@wirecat/cli-base/standards";
|
|
5
7
|
import { isNewer, latestVersion } from "@wirecat/cli-base/update";
|
|
6
8
|
import { Command } from "commander";
|
|
7
9
|
import { envName, readOnlyLockOf } from "../ports/app.js";
|
|
@@ -149,7 +151,7 @@ export const appDoctorCommand = (app, configuration, options = {}) => profileFre
|
|
|
149
151
|
? await onlineCheck(app, env, environment.fetch ?? fetch, options)
|
|
150
152
|
: undefined;
|
|
151
153
|
const output = outputFor(this);
|
|
152
|
-
renderAnswer(this, output, itemOf({ ...report, ...local.fields, ...(online ? { online } : {}) }));
|
|
154
|
+
renderAnswer(this, output, itemOf({ ...report, ...local.fields, ...(online ? { online } : {}) }, { meta: clockMeta(Date.now(), timezoneOf()) }));
|
|
153
155
|
for (const fix of fixes)
|
|
154
156
|
output.renderer.note(`to make it private: ${fix}`);
|
|
155
157
|
for (const note of local.notes)
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export { type CacheEvent, type DiagnosticEvent, type EventSink, providerErrorKey
|
|
|
26
26
|
export { CORE_LOG_EVENTS } from "../runs/log-events.js";
|
|
27
27
|
export { openProviderLog, PROVIDER_LOG_BYTES, type ProviderWarnings, providerLogPathFor, providerWarnings, writeProviderWarning, } from "../runs/provider-log.js";
|
|
28
28
|
export { crashOf, type Recording, type RecordingOptions, recorded, startRecording, wasSettled, } from "../runs/recording.js";
|
|
29
|
-
export { findRun, KEEP_RUNS_FOR_DAYS, listRuns, pruneRuns, type RunContext, type RunMetadata, readEvents, runsDirFor, runtime, startRun, } from "../runs/run.js";
|
|
29
|
+
export { findRun, KEEP_RUNS_FOR_DAYS, KEEP_SUCCESSFUL_RUNS_FOR_DAYS, listRuns, pruneRuns, RUNS_SIZE_LIMIT_MB, type RunContext, type RunMetadata, readEvents, runsDirFor, runtime, startRun, } from "../runs/run.js";
|
|
30
30
|
export { runContextOf, secretInput } from "../runs/run-context.js";
|
|
31
31
|
export { type Attempt, currentAttempt, currentRun, inRun, type RunScope, runEvent, useAsProcessRun, withAttempt, } from "../runs/scope.js";
|
|
32
32
|
export { LANGUAGES } from "../search/languages.js";
|
|
@@ -119,6 +119,7 @@ export { type ProjectStatusHints, type ProjectStatusItem, projectStatusAnswer, p
|
|
|
119
119
|
export { STATUS_ROWS, STATUS_SIGNAL_ROWS } from "./project-status-rows.js";
|
|
120
120
|
export { fieldsOf, projectFields } from "./result-fields.js";
|
|
121
121
|
export type { ScheduleHost } from "./schedule/schedule-command.js";
|
|
122
|
+
export { type DeclaredSetting, type SettingRow, settingRows, withSettingDefaults } from "./setting-defaults.js";
|
|
122
123
|
export { type Config, type Configuration, count, first, flag, fromFile, type GlobalFlags, NONE_NAMED, namedProfile, type ProfileKind, plain, type ResolveOptions, type Settings, type SettingsExtension, type SettingsExtensionContext, type Source, settingsFor, } from "./settings.js";
|
|
123
124
|
export { type PermissionAnswer, readSetupAnswers, type SetupAnswers, setupPermissionCeiling } from "./setup-answers.js";
|
|
124
125
|
export { AGENTS, type Agent, agentFor, screenFor } from "./setup-screen.js";
|
package/dist/cli/index.js
CHANGED
|
@@ -22,7 +22,7 @@ export { providerErrorKey, renderEvent, } from "../runs/events.js";
|
|
|
22
22
|
export { CORE_LOG_EVENTS } from "../runs/log-events.js";
|
|
23
23
|
export { openProviderLog, PROVIDER_LOG_BYTES, providerLogPathFor, providerWarnings, writeProviderWarning, } from "../runs/provider-log.js";
|
|
24
24
|
export { crashOf, recorded, startRecording, wasSettled, } from "../runs/recording.js";
|
|
25
|
-
export { findRun, KEEP_RUNS_FOR_DAYS, listRuns, pruneRuns, readEvents, runsDirFor, runtime, startRun, } from "../runs/run.js";
|
|
25
|
+
export { findRun, KEEP_RUNS_FOR_DAYS, KEEP_SUCCESSFUL_RUNS_FOR_DAYS, listRuns, pruneRuns, RUNS_SIZE_LIMIT_MB, readEvents, runsDirFor, runtime, startRun, } from "../runs/run.js";
|
|
26
26
|
export { runContextOf, secretInput } from "../runs/run-context.js";
|
|
27
27
|
export { currentAttempt, currentRun, inRun, runEvent, useAsProcessRun, withAttempt, } from "../runs/scope.js";
|
|
28
28
|
export { LANGUAGES } from "../search/languages.js";
|
|
@@ -108,6 +108,7 @@ export { projectAnswerParts, projectCutoffTime, projectEvidenceText, projectWind
|
|
|
108
108
|
export { projectStatusAnswer, projectStatusRow, projectStatusSchema, projectStatusText, } from "./project-status.js";
|
|
109
109
|
export { STATUS_ROWS, STATUS_SIGNAL_ROWS } from "./project-status-rows.js";
|
|
110
110
|
export { fieldsOf, projectFields } from "./result-fields.js";
|
|
111
|
+
export { settingRows, withSettingDefaults } from "./setting-defaults.js";
|
|
111
112
|
export { count, first, flag, fromFile, NONE_NAMED, namedProfile, plain, settingsFor, } from "./settings.js";
|
|
112
113
|
export { readSetupAnswers, setupPermissionCeiling } from "./setup-answers.js";
|
|
113
114
|
export { AGENTS, agentFor, screenFor } from "./setup-screen.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A scalar setting a CLI writes into its config file with its default, so the owner finds and edits it there without
|
|
3
|
+
* reading the docs (WC-CMD-30). Never declare a secret: `config show` prints every declared value.
|
|
4
|
+
*/
|
|
5
|
+
export interface DeclaredSetting {
|
|
6
|
+
/** The dotted path in the file. A nested setting is written only where its section already exists. */
|
|
7
|
+
key: string;
|
|
8
|
+
default: string | number | boolean;
|
|
9
|
+
description: string;
|
|
10
|
+
}
|
|
11
|
+
export interface SettingRow {
|
|
12
|
+
setting: string;
|
|
13
|
+
value: unknown;
|
|
14
|
+
default: string | number | boolean;
|
|
15
|
+
from: "config file" | "default";
|
|
16
|
+
description: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The file with every declared setting it lacks, at its default. What the owner wrote stays as written, in its order,
|
|
20
|
+
* unknown keys included; a section that is not there is not created, since it may need fields no default can give.
|
|
21
|
+
*/
|
|
22
|
+
export declare const withSettingDefaults: (raw: unknown, declared: readonly DeclaredSetting[]) => {
|
|
23
|
+
config: unknown;
|
|
24
|
+
added: string[];
|
|
25
|
+
};
|
|
26
|
+
/** Every declared setting with what holds and whether the file says it, for `config show`. */
|
|
27
|
+
export declare const settingRows: (raw: unknown, declared: readonly DeclaredSetting[]) => SettingRow[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const isNode = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2
|
+
const parentOf = (config, key) => {
|
|
3
|
+
const path = key.split(".");
|
|
4
|
+
const leaf = path.pop();
|
|
5
|
+
return { node: path.reduce((node, part) => (isNode(node) ? node[part] : undefined), config), leaf };
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The file with every declared setting it lacks, at its default. What the owner wrote stays as written, in its order,
|
|
9
|
+
* unknown keys included; a section that is not there is not created, since it may need fields no default can give.
|
|
10
|
+
*/
|
|
11
|
+
export const withSettingDefaults = (raw, declared) => {
|
|
12
|
+
if (raw !== undefined && !isNode(raw))
|
|
13
|
+
return { config: raw, added: [] };
|
|
14
|
+
const config = raw === undefined ? {} : structuredClone(raw);
|
|
15
|
+
const added = [];
|
|
16
|
+
for (const setting of declared) {
|
|
17
|
+
const { node, leaf } = parentOf(config, setting.key);
|
|
18
|
+
if (!isNode(node) || Object.hasOwn(node, leaf))
|
|
19
|
+
continue;
|
|
20
|
+
node[leaf] = setting.default;
|
|
21
|
+
added.push(setting.key);
|
|
22
|
+
}
|
|
23
|
+
return { config, added };
|
|
24
|
+
};
|
|
25
|
+
/** Every declared setting with what holds and whether the file says it, for `config show`. */
|
|
26
|
+
export const settingRows = (raw, declared) => declared.map((setting) => {
|
|
27
|
+
const { node, leaf } = isNode(raw) ? parentOf(raw, setting.key) : { node: undefined, leaf: "" };
|
|
28
|
+
const written = isNode(node) && Object.hasOwn(node, leaf);
|
|
29
|
+
return {
|
|
30
|
+
setting: setting.key,
|
|
31
|
+
value: written ? node[leaf] : setting.default,
|
|
32
|
+
default: setting.default,
|
|
33
|
+
from: written ? "config file" : "default",
|
|
34
|
+
description: setting.description,
|
|
35
|
+
};
|
|
36
|
+
});
|
package/dist/errors/reasons.js
CHANGED
|
@@ -107,6 +107,7 @@ const OTHERS = [
|
|
|
107
107
|
["meetings.index-pending", "not_found", "some stored meetings are not indexed by person yet"],
|
|
108
108
|
["profile.locked", "permission_error", "a profile lock pins this process to its own account"],
|
|
109
109
|
["busy.offline", "permission_error", "calendars busy asks the provider; --offline was given"],
|
|
110
|
+
["busy.unanswered", "provider_error", "the provider gave no busy times for a calendar or person that was asked"],
|
|
110
111
|
validation("busy.no-calendars", "no calendar syncs and no person was named, so there is nobody to ask"),
|
|
111
112
|
["search.offline", "permission_error", "search --backend server asks the provider; --offline was given"],
|
|
112
113
|
validation("search.no-calendars", "no calendar of this profile syncs yet, so the provider has nothing to search"),
|
|
@@ -38,6 +38,7 @@ export declare const meetingTools: ({
|
|
|
38
38
|
max_read_bytes?: undefined;
|
|
39
39
|
cursor?: undefined;
|
|
40
40
|
} | {
|
|
41
|
+
limit?: undefined;
|
|
41
42
|
event_id?: undefined;
|
|
42
43
|
series_id?: undefined;
|
|
43
44
|
page?: undefined;
|
|
@@ -53,11 +54,11 @@ export declare const meetingTools: ({
|
|
|
53
54
|
format?: undefined;
|
|
54
55
|
transcript_id?: undefined;
|
|
55
56
|
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;
|
|
61
62
|
event_id?: undefined;
|
|
62
63
|
series_id?: undefined;
|
|
63
64
|
page?: undefined;
|
|
@@ -75,11 +76,11 @@ export declare const meetingTools: ({
|
|
|
75
76
|
format?: undefined;
|
|
76
77
|
transcript_id?: undefined;
|
|
77
78
|
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;
|
|
83
84
|
event_id?: undefined;
|
|
84
85
|
series_id?: undefined;
|
|
85
86
|
page?: undefined;
|
|
@@ -101,7 +102,6 @@ export declare const meetingTools: ({
|
|
|
101
102
|
minimum: number;
|
|
102
103
|
};
|
|
103
104
|
query?: undefined;
|
|
104
|
-
limit?: undefined;
|
|
105
105
|
scan_limit?: undefined;
|
|
106
106
|
max_read_bytes?: undefined;
|
|
107
107
|
cursor?: undefined;
|
|
@@ -188,6 +188,7 @@ export declare const meetingTools: ({
|
|
|
188
188
|
max_read_bytes?: undefined;
|
|
189
189
|
cursor?: undefined;
|
|
190
190
|
} | {
|
|
191
|
+
limit?: undefined;
|
|
191
192
|
event_id?: undefined;
|
|
192
193
|
series_id?: undefined;
|
|
193
194
|
page?: undefined;
|
|
@@ -203,11 +204,11 @@ export declare const meetingTools: ({
|
|
|
203
204
|
format?: undefined;
|
|
204
205
|
transcript_id?: undefined;
|
|
205
206
|
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;
|
|
211
212
|
event_id?: undefined;
|
|
212
213
|
series_id?: undefined;
|
|
213
214
|
page?: undefined;
|
|
@@ -225,11 +226,11 @@ export declare const meetingTools: ({
|
|
|
225
226
|
format?: undefined;
|
|
226
227
|
transcript_id?: undefined;
|
|
227
228
|
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;
|
|
233
234
|
event_id?: undefined;
|
|
234
235
|
series_id?: undefined;
|
|
235
236
|
page?: undefined;
|
|
@@ -251,7 +252,6 @@ export declare const meetingTools: ({
|
|
|
251
252
|
minimum: number;
|
|
252
253
|
};
|
|
253
254
|
query?: undefined;
|
|
254
|
-
limit?: undefined;
|
|
255
255
|
scan_limit?: undefined;
|
|
256
256
|
max_read_bytes?: undefined;
|
|
257
257
|
cursor?: undefined;
|
|
@@ -338,6 +338,7 @@ export declare const meetingTools: ({
|
|
|
338
338
|
max_read_bytes?: undefined;
|
|
339
339
|
cursor?: undefined;
|
|
340
340
|
} | {
|
|
341
|
+
limit?: undefined;
|
|
341
342
|
event_id?: undefined;
|
|
342
343
|
series_id?: undefined;
|
|
343
344
|
page?: undefined;
|
|
@@ -353,11 +354,11 @@ export declare const meetingTools: ({
|
|
|
353
354
|
format?: undefined;
|
|
354
355
|
transcript_id?: undefined;
|
|
355
356
|
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;
|
|
361
362
|
event_id?: undefined;
|
|
362
363
|
series_id?: undefined;
|
|
363
364
|
page?: undefined;
|
|
@@ -375,11 +376,11 @@ export declare const meetingTools: ({
|
|
|
375
376
|
format?: undefined;
|
|
376
377
|
transcript_id?: undefined;
|
|
377
378
|
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;
|
|
383
384
|
event_id?: undefined;
|
|
384
385
|
series_id?: undefined;
|
|
385
386
|
page?: undefined;
|
|
@@ -401,7 +402,6 @@ export declare const meetingTools: ({
|
|
|
401
402
|
minimum: number;
|
|
402
403
|
};
|
|
403
404
|
query?: undefined;
|
|
404
|
-
limit?: undefined;
|
|
405
405
|
scan_limit?: undefined;
|
|
406
406
|
max_read_bytes?: undefined;
|
|
407
407
|
cursor?: undefined;
|
|
@@ -488,6 +488,7 @@ export declare const meetingTools: ({
|
|
|
488
488
|
max_read_bytes?: undefined;
|
|
489
489
|
cursor?: undefined;
|
|
490
490
|
} | {
|
|
491
|
+
limit?: undefined;
|
|
491
492
|
event_id?: undefined;
|
|
492
493
|
series_id?: undefined;
|
|
493
494
|
page?: undefined;
|
|
@@ -503,11 +504,11 @@ export declare const meetingTools: ({
|
|
|
503
504
|
format?: undefined;
|
|
504
505
|
transcript_id?: undefined;
|
|
505
506
|
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;
|
|
511
512
|
event_id?: undefined;
|
|
512
513
|
series_id?: undefined;
|
|
513
514
|
page?: undefined;
|
|
@@ -525,11 +526,11 @@ export declare const meetingTools: ({
|
|
|
525
526
|
format?: undefined;
|
|
526
527
|
transcript_id?: undefined;
|
|
527
528
|
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;
|
|
533
534
|
event_id?: undefined;
|
|
534
535
|
series_id?: undefined;
|
|
535
536
|
page?: undefined;
|
|
@@ -551,7 +552,6 @@ export declare const meetingTools: ({
|
|
|
551
552
|
minimum: number;
|
|
552
553
|
};
|
|
553
554
|
query?: undefined;
|
|
554
|
-
limit?: undefined;
|
|
555
555
|
scan_limit?: undefined;
|
|
556
556
|
max_read_bytes?: undefined;
|
|
557
557
|
cursor?: undefined;
|
|
@@ -638,6 +638,7 @@ export declare const meetingTools: ({
|
|
|
638
638
|
max_read_bytes?: undefined;
|
|
639
639
|
cursor?: undefined;
|
|
640
640
|
} | {
|
|
641
|
+
limit?: undefined;
|
|
641
642
|
event_id?: undefined;
|
|
642
643
|
series_id?: undefined;
|
|
643
644
|
page?: undefined;
|
|
@@ -653,11 +654,11 @@ export declare const meetingTools: ({
|
|
|
653
654
|
format?: undefined;
|
|
654
655
|
transcript_id?: undefined;
|
|
655
656
|
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;
|
|
661
662
|
event_id?: undefined;
|
|
662
663
|
series_id?: undefined;
|
|
663
664
|
page?: undefined;
|
|
@@ -675,11 +676,11 @@ export declare const meetingTools: ({
|
|
|
675
676
|
format?: undefined;
|
|
676
677
|
transcript_id?: undefined;
|
|
677
678
|
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;
|
|
683
684
|
event_id?: undefined;
|
|
684
685
|
series_id?: undefined;
|
|
685
686
|
page?: undefined;
|
|
@@ -701,7 +702,6 @@ export declare const meetingTools: ({
|
|
|
701
702
|
minimum: number;
|
|
702
703
|
};
|
|
703
704
|
query?: undefined;
|
|
704
|
-
limit?: undefined;
|
|
705
705
|
scan_limit?: undefined;
|
|
706
706
|
max_read_bytes?: undefined;
|
|
707
707
|
cursor?: undefined;
|
package/dist/sends/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { type FloodDeadline, FloodMemory, type FloodState, FROZEN_HOLD_MS, flood
|
|
|
3
3
|
export { type Asker, type GuardRequest, guardFor, type SendGuard, type SendGuardOptions, sendGuard, sharedJournal, } from "./guard.js";
|
|
4
4
|
export { currentOperation, guardedWrite, type Operated } from "./guarded.js";
|
|
5
5
|
export { type AccountAction, type ChatAction, type SendEntry, SendJournal, type SendKind, type SendOutcome, sendsPathFor, } from "./journal.js";
|
|
6
|
+
export { type KeyedGuard, keyedGuard } from "./keyed-guard.js";
|
|
6
7
|
export { DEFAULT_PACE, type PaceRate, Pacer, pacePathFor } from "./pace.js";
|
|
7
8
|
export { assertOverridesTighten, CEILING_KEY, COMMAND_PATH_KEY, DEFAULT_PERMISSIONS, keyForCommand, keyForWrite, LEVELS, type Level, layerPermissions, levelFor, type PermissionKey, permissionOverrides, readKeysForCommand, skipFlagFor, WRITE_KEYS, } from "./permissions.js";
|
|
8
9
|
export { type Recipient, RecipientList, recipientsPathFor } from "./recipients.js";
|
package/dist/sends/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { FloodMemory, FROZEN_HOLD_MS, floodPathFor, LIMITED_HOLD_MS, } from "./f
|
|
|
2
2
|
export { guardFor, sendGuard, sharedJournal, } from "./guard.js";
|
|
3
3
|
export { currentOperation, guardedWrite } from "./guarded.js";
|
|
4
4
|
export { SendJournal, sendsPathFor, } from "./journal.js";
|
|
5
|
+
export { keyedGuard } from "./keyed-guard.js";
|
|
5
6
|
export { DEFAULT_PACE, Pacer, pacePathFor } from "./pace.js";
|
|
6
7
|
export { assertOverridesTighten, CEILING_KEY, COMMAND_PATH_KEY, DEFAULT_PERMISSIONS, keyForCommand, keyForWrite, LEVELS, layerPermissions, levelFor, permissionOverrides, readKeysForCommand, skipFlagFor, WRITE_KEYS, } from "./permissions.js";
|
|
7
8
|
export { RecipientList, recipientsPathFor } from "./recipients.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Asker, GuardRequest, SendGuard } from "./guard.js";
|
|
2
|
+
import type { Level, PermissionKey } from "./permissions.js";
|
|
3
|
+
export type KeyedGuard = SendGuard & {
|
|
4
|
+
/** Refuses the write when one of its keys denies it or is read-only; asks nothing. */
|
|
5
|
+
refuse(request: GuardRequest): void;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A guard over a write's main key and its extra keys. A key that refuses refuses before anything is asked, so nobody
|
|
9
|
+
* answers yes to a write that a stricter key then stops, and one question names every key at `ask`. The extra keys are
|
|
10
|
+
* probed as reads, never journaled or counted: the write itself holds the one journal line.
|
|
11
|
+
*/
|
|
12
|
+
export declare const keyedGuard: (build: (ask: Asker) => SendGuard, ask: Asker, levelOf: (key: PermissionKey) => Level, extra: readonly PermissionKey[]) => KeyedGuard;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A guard over a write's main key and its extra keys. A key that refuses refuses before anything is asked, so nobody
|
|
3
|
+
* answers yes to a write that a stricter key then stops, and one question names every key at `ask`. The extra keys are
|
|
4
|
+
* probed as reads, never journaled or counted: the write itself holds the one journal line.
|
|
5
|
+
*/
|
|
6
|
+
export const keyedGuard = (build, ask, levelOf, extra) => {
|
|
7
|
+
let question;
|
|
8
|
+
let answered = false;
|
|
9
|
+
const guard = build(async (key, request) => {
|
|
10
|
+
if (answered)
|
|
11
|
+
return;
|
|
12
|
+
await ask(question || key, request);
|
|
13
|
+
answered = true;
|
|
14
|
+
});
|
|
15
|
+
const probes = new WeakMap();
|
|
16
|
+
const all = (request) => {
|
|
17
|
+
let found = probes.get(request);
|
|
18
|
+
if (!found) {
|
|
19
|
+
found = extra.map((key) => ({ chatId: null, kind: "read", key }));
|
|
20
|
+
probes.set(request, found);
|
|
21
|
+
}
|
|
22
|
+
return [request, ...found];
|
|
23
|
+
};
|
|
24
|
+
const levelOfRequest = ({ key }) => levelOf(key ?? "");
|
|
25
|
+
const refuse = (request) => {
|
|
26
|
+
const refused = all(request).find((one) => ["deny", "readonly"].includes(levelOfRequest(one)));
|
|
27
|
+
if (refused)
|
|
28
|
+
guard.check(refused, { reserve: false });
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
refuse,
|
|
32
|
+
ask: async (request) => {
|
|
33
|
+
refuse(request);
|
|
34
|
+
question = all(request)
|
|
35
|
+
.filter((one) => levelOfRequest(one) === "ask")
|
|
36
|
+
.map(({ key }) => key)
|
|
37
|
+
.join(" and ");
|
|
38
|
+
for (const one of all(request))
|
|
39
|
+
await guard.ask?.(one);
|
|
40
|
+
},
|
|
41
|
+
check: (request, options) => {
|
|
42
|
+
for (const one of all(request).slice(1))
|
|
43
|
+
guard.check(one, { reserve: false });
|
|
44
|
+
guard.check(request, options);
|
|
45
|
+
},
|
|
46
|
+
...(guard.reserve ? { reserve: guard.reserve } : {}),
|
|
47
|
+
record: (entry) => guard.record(entry),
|
|
48
|
+
};
|
|
49
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.562.0",
|
|
4
4
|
"description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Viacheslav Ptsarev",
|