@letterstory/cli 0.176.12 → 0.176.13
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/lib/cli.mjs +7 -2
- package/lib/commands/automations.mjs +21 -1
- package/lib/commands/seers.mjs +31 -4
- package/package.json +1 -1
package/lib/cli.mjs
CHANGED
|
@@ -80,7 +80,7 @@ import {
|
|
|
80
80
|
import { fetchParkedSections, withoutParked } from "./parked.mjs";
|
|
81
81
|
|
|
82
82
|
// Matches cli/package.json; publish-cli.yml rewrites both to the published version.
|
|
83
|
-
export const VERSION = "0.176.
|
|
83
|
+
export const VERSION = "0.176.13";
|
|
84
84
|
|
|
85
85
|
/** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
|
|
86
86
|
export const EXIT_PAYMENT_REQUIRED = 3;
|
|
@@ -89,6 +89,8 @@ export const EXIT_PAYMENT_REQUIRED = 3;
|
|
|
89
89
|
// can't accidentally swallow the id as --json's value. Every `type: "bool"` flag (and its
|
|
90
90
|
// `negate` spelling) in a command's ARGS map must be listed; boolean-flags.test.ts enforces it.
|
|
91
91
|
export const BOOLEAN_FLAGS = new Set([
|
|
92
|
+
// automations set: stop reading a data feed.
|
|
93
|
+
"no-reads",
|
|
92
94
|
// vary start: pause the test running on the page first.
|
|
93
95
|
"pause-running",
|
|
94
96
|
// bench run: the spec was just changed.
|
|
@@ -577,10 +579,13 @@ Reviewers:
|
|
|
577
579
|
automations dismiss <topic-id> --collection <id> Set one subject aside
|
|
578
580
|
automations add topic|series|signal|best --collection <id> [--topic <id>] [--goal <target-id>]
|
|
579
581
|
[--seer <id>] [--pace <n> | --on "fri 09:00 America/New_York"] [--brief <text>]
|
|
580
|
-
[--new-topic <name>] [--new-series <name>]
|
|
582
|
+
[--reads <seer-id> [--window <days>]] [--new-topic <name>] [--new-series <name>]
|
|
581
583
|
Add one (refused if it says the same as another).
|
|
582
584
|
--on pins it: one post a week, on that day and time
|
|
585
|
+
--reads: a data feed (a data_feed seer) whose records in
|
|
586
|
+
the window before each post are the post's own data
|
|
583
587
|
automations set <automation-id> --collection <id> [--pace <n> | --on "<day> <HH:MM> <tz>" | --unpin]
|
|
588
|
+
[--reads <seer-id> [--window <days>] | --no-reads]
|
|
584
589
|
[--pause | --resume] [--goal <id>] [--brief <text>] [--remap]
|
|
585
590
|
automations remove <automation-id> --collection <id>
|
|
586
591
|
automate options What an automation can be made of here: the triggers,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Same flag/positional/io conventions as posts.mjs — no commander, no color.
|
|
4
4
|
|
|
5
5
|
import { CliError } from "../client.mjs";
|
|
6
|
-
import { printResult, ok, argsFromFlags, refuseUnknownFlags } from "./shared.mjs";
|
|
6
|
+
import { flagStr, printResult, ok, argsFromFlags, refuseUnknownFlags } from "./shared.mjs";
|
|
7
7
|
|
|
8
8
|
const WEEKDAYS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
|
|
9
9
|
|
|
@@ -23,6 +23,24 @@ export function parsePublishAt(text) {
|
|
|
23
23
|
return { weekday, time, timezone };
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* `--reads <seer-id> [--window <days>]` → { seer_id, window_days } (the tool's `reads`): a data
|
|
28
|
+
* feed the automation reads, the window ending at each post's publish instant (7 days unless set).
|
|
29
|
+
* `--no-reads` sends null (stop reading one).
|
|
30
|
+
*/
|
|
31
|
+
export function parseReads(flags) {
|
|
32
|
+
if (flags["no-reads"] === true) return null;
|
|
33
|
+
const seer = flagStr(flags.reads);
|
|
34
|
+
if (seer === undefined) {
|
|
35
|
+
if (flags.window !== undefined) throw new CliError("--window goes with --reads <seer-id>");
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
const days = flags.window === undefined ? 7 : Number(flags.window);
|
|
39
|
+
if (!Number.isInteger(days) || days < 1)
|
|
40
|
+
throw new CliError("--window takes a whole number of days, e.g. --window 7");
|
|
41
|
+
return { seer_id: seer, window_days: days };
|
|
42
|
+
}
|
|
43
|
+
|
|
26
44
|
/** See `argsFromFlags` in shared.mjs; `scripts/parity-check.ts` diffs these keys against the tool. */
|
|
27
45
|
export const ARGS = {
|
|
28
46
|
list_automations: {
|
|
@@ -56,6 +74,7 @@ export const ARGS = {
|
|
|
56
74
|
seer_id: { flag: "seer" },
|
|
57
75
|
pace_per_week: { flag: "pace", type: "num" },
|
|
58
76
|
publish_at: { value: (flags) => parsePublishAt(flags.on) },
|
|
77
|
+
reads: { value: (flags) => parseReads(flags) ?? undefined },
|
|
59
78
|
brief: { flag: "brief" },
|
|
60
79
|
new_topic: {
|
|
61
80
|
value: (flags) => (typeof flags["new-topic"] === "string" ? { name: flags["new-topic"] } : undefined),
|
|
@@ -69,6 +88,7 @@ export const ARGS = {
|
|
|
69
88
|
automation_id: { positional: 0, label: "automation-id", required: true },
|
|
70
89
|
pace_per_week: { flag: "pace", type: "num" },
|
|
71
90
|
publish_at: { value: (flags) => (flags.unpin === true ? null : parsePublishAt(flags.on)) },
|
|
91
|
+
reads: { value: (flags) => parseReads(flags) },
|
|
72
92
|
paused: {
|
|
73
93
|
value: (flags) => (flags.pause === true ? true : flags.resume === true ? false : undefined),
|
|
74
94
|
},
|
package/lib/commands/seers.mjs
CHANGED
|
@@ -60,7 +60,7 @@ export const ARGS = {
|
|
|
60
60
|
// forever but never produce (auto mode is rejected without one).
|
|
61
61
|
collection_id: { flag: "collection" },
|
|
62
62
|
provider: { flag: "provider", required: true },
|
|
63
|
-
mode: { flag: "mode", enum: ["suggest", "auto"] },
|
|
63
|
+
mode: { flag: "mode", enum: ["suggest", "auto", "record"] },
|
|
64
64
|
poll_interval_minutes: { flag: "interval", type: "num" },
|
|
65
65
|
// The whole config document — provider source params plus the behavior keys
|
|
66
66
|
// (auto_draft_scope, template_key, mention_degree, kernel_family, relevance{…}).
|
|
@@ -72,7 +72,7 @@ export const ARGS = {
|
|
|
72
72
|
// --collection <uuid> sets it, --clear-collection sends null (the seer becomes
|
|
73
73
|
// detect-only — rejected if it's mode "auto"), neither leaves it unchanged.
|
|
74
74
|
collection_id: clearableValue("collection", "clear-collection"),
|
|
75
|
-
mode: { flag: "mode", enum: ["suggest", "auto"] },
|
|
75
|
+
mode: { flag: "mode", enum: ["suggest", "auto", "record"] },
|
|
76
76
|
enabled: { value: (flags) => readEnabledFlag(flags) },
|
|
77
77
|
poll_interval_minutes: { flag: "interval", type: "num" },
|
|
78
78
|
config: { value: (flags) => readJsonObjectFlag(flags, "config") },
|
|
@@ -84,6 +84,14 @@ export const ARGS = {
|
|
|
84
84
|
seer_id: { positional: 0, label: "seer-id", required: true },
|
|
85
85
|
limit: { flag: "limit", type: "num" },
|
|
86
86
|
offset: { flag: "offset", type: "num" },
|
|
87
|
+
// A window by each event's own date: `seers events <id> --since 2026-10-30T13:00:00Z`.
|
|
88
|
+
since: { flag: "since" },
|
|
89
|
+
until: { flag: "until" },
|
|
90
|
+
},
|
|
91
|
+
// `seers credential <id> --token "Bearer …"` (a private data feed's header value; --clear removes it).
|
|
92
|
+
set_seer_credential: {
|
|
93
|
+
seer_id: { positional: 0, label: "seer-id", required: true },
|
|
94
|
+
token: { value: (flags) => (flags.clear ? null : flagStr(flags.token)) },
|
|
87
95
|
},
|
|
88
96
|
dismiss_seer_event: {
|
|
89
97
|
seer_id: { positional: 0, label: "seer-id", required: true },
|
|
@@ -146,6 +154,8 @@ export async function cmdSeers(ctx) {
|
|
|
146
154
|
return seersRuns(rest);
|
|
147
155
|
case "balance":
|
|
148
156
|
return seersBalance(rest);
|
|
157
|
+
case "credential":
|
|
158
|
+
return seersCredential(rest);
|
|
149
159
|
case "events":
|
|
150
160
|
return seersEvents(rest);
|
|
151
161
|
case "dismiss":
|
|
@@ -170,7 +180,7 @@ export async function cmdSeers(ctx) {
|
|
|
170
180
|
return seersApply(rest);
|
|
171
181
|
default:
|
|
172
182
|
throw new CliError(
|
|
173
|
-
`Unknown seers subcommand: ${sub ?? "(none)"}. Try: list, get, create, update, delete, run, run-status, runs, balance, events, dismiss, headlines, held, release, discard, providers, connections, connect, export, apply`
|
|
183
|
+
`Unknown seers subcommand: ${sub ?? "(none)"}. Try: list, get, create, update, delete, run, run-status, runs, balance, events, credential, dismiss, headlines, held, release, discard, providers, connections, connect, export, apply`
|
|
174
184
|
);
|
|
175
185
|
}
|
|
176
186
|
}
|
|
@@ -340,6 +350,16 @@ async function seersBalance(ctx) {
|
|
|
340
350
|
|
|
341
351
|
// --- Events / headlines / holding pen ----------------------------------------------
|
|
342
352
|
|
|
353
|
+
async function seersCredential(ctx) {
|
|
354
|
+
const { client, positionals, flags, io } = ctx;
|
|
355
|
+
const args = argsFromFlags(ARGS.set_seer_credential, flags, positionals);
|
|
356
|
+
if (args.token === undefined) throw new CliError("Pass --token <header value> or --clear");
|
|
357
|
+
const result = await client.callTool("set_seer_credential", args);
|
|
358
|
+
ok(ctx, args.token === null ? "Credential removed." : "Credential stored.");
|
|
359
|
+
printResult(io, flags, result);
|
|
360
|
+
return 0;
|
|
361
|
+
}
|
|
362
|
+
|
|
343
363
|
async function seersEvents(ctx) {
|
|
344
364
|
const { client, positionals, flags, io } = ctx;
|
|
345
365
|
const args = argsFromFlags(ARGS.list_seer_events, flags, positionals);
|
|
@@ -348,7 +368,14 @@ async function seersEvents(ctx) {
|
|
|
348
368
|
const lines = (r.events ?? []).map((e) => {
|
|
349
369
|
const blocked = e.auto_production_blocked_reason ? ` [blocked: ${e.auto_production_blocked_reason}]` : "";
|
|
350
370
|
const aliases = e.aliases?.length ? ` (+${e.aliases.length} aliases)` : "";
|
|
351
|
-
|
|
371
|
+
const fields =
|
|
372
|
+
e.payload?.fields && typeof e.payload.fields === "object"
|
|
373
|
+
? " " +
|
|
374
|
+
Object.entries(e.payload.fields)
|
|
375
|
+
.map(([k, v]) => `${k}=${v}`)
|
|
376
|
+
.join(" ")
|
|
377
|
+
: "";
|
|
378
|
+
return `${e.id} [${e.status}] ${e.payload?.occurred_at ?? e.detected_at} ${e.title}${aliases}${blocked}${fields}`;
|
|
352
379
|
});
|
|
353
380
|
if (!lines.length) lines.push("No events detected yet.");
|
|
354
381
|
if (r.has_more) lines.push(`… more available (--offset ${r.next_offset})`);
|