@wirecat/wirecat 0.0.0-stage → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +204 -0
- package/README.md +399 -2
- package/THIRD_PARTY_NOTICES +2 -0
- package/contracts/wirecat.json +4612 -0
- package/dist/actions/actions.js +269 -0
- package/dist/actions/command.js +102 -0
- package/dist/agents/command.js +17 -0
- package/dist/agents/log.js +23 -0
- package/dist/answer.js +100 -0
- package/dist/answers/command.js +128 -0
- package/dist/app.js +15 -0
- package/dist/author.js +109 -0
- package/dist/bin/wcat-wirecat.js +40 -0
- package/dist/bots/command.js +175 -0
- package/dist/bundle/auto-O24ISPOI.js +43 -0
- package/dist/bundle/chunk-2A3YPENI.js +31 -0
- package/dist/bundle/chunk-6BDIFKF5.js +222 -0
- package/dist/bundle/chunk-7O7XM37N.js +2 -0
- package/dist/bundle/chunk-AYHZY24E.js +120 -0
- package/dist/bundle/chunk-CKBTMZUX.js +72 -0
- package/dist/bundle/chunk-FGXUH3XL.js +416 -0
- package/dist/bundle/chunk-I5JQBRRC.js +807 -0
- package/dist/bundle/chunk-RKVAWMZT.js +38 -0
- package/dist/bundle/chunk-SCDNOUUR.js +395 -0
- package/dist/bundle/chunk-T7TG4JKR.js +312 -0
- package/dist/bundle/chunk-XBUCXQKT.js +51 -0
- package/dist/bundle/entry-EW5A7FYV.js +64 -0
- package/dist/bundle/failure-HMELJ3K5.js +19 -0
- package/dist/bundle/from-memo-F7NTUXAR.js +314 -0
- package/dist/bundle/program-7XWGFN4H.js +14994 -0
- package/dist/bundle/server-T7RVBNRW.js +303 -0
- package/dist/bundle/update-JZDS7B6L.js +22 -0
- package/dist/bundle/wcat-wirecat.js +83 -0
- package/dist/config-command.js +39 -0
- package/dist/config-issues.js +15 -0
- package/dist/config.js +187 -0
- package/dist/context/command.js +162 -0
- package/dist/context/context.js +197 -0
- package/dist/contract-overrides/commands.js +81 -0
- package/dist/contract-overrides/mcp.js +241 -0
- package/dist/contract-overrides/meetings.js +344 -0
- package/dist/contract-overrides/search.js +508 -0
- package/dist/contract-overrides/skill.js +85 -0
- package/dist/contract-overrides.js +7 -0
- package/dist/digest/backfill.js +175 -0
- package/dist/digest/brief.js +189 -0
- package/dist/digest/catch-up-record.js +30 -0
- package/dist/digest/catch-up.js +86 -0
- package/dist/digest/command.js +110 -0
- package/dist/digest/digest-commands.js +327 -0
- package/dist/digest/digest.js +560 -0
- package/dist/digest/digests.js +213 -0
- package/dist/digest/history.js +202 -0
- package/dist/digest/input.js +30 -0
- package/dist/digest/known.js +28 -0
- package/dist/digest/sources.js +155 -0
- package/dist/digest/sync-health.js +158 -0
- package/dist/digest/task-proposals.js +67 -0
- package/dist/digest/tasks.js +145 -0
- package/dist/digest/text.js +49 -0
- package/dist/discovery/command.js +107 -0
- package/dist/doctor/command.js +167 -0
- package/dist/documents/command.js +107 -0
- package/dist/domain-lists/command.js +13 -0
- package/dist/events/command.js +35 -0
- package/dist/events/events.js +196 -0
- package/dist/examples.js +609 -0
- package/dist/facts/command.js +100 -0
- package/dist/facts/fact.js +54 -0
- package/dist/facts/facts.js +15 -0
- package/dist/failure.js +58 -0
- package/dist/finance/command.js +121 -0
- package/dist/finance/contracts-command.js +109 -0
- package/dist/finance/deal-text.js +34 -0
- package/dist/finance/deals-command.js +346 -0
- package/dist/finance/finance.js +129 -0
- package/dist/finance/lines-command.js +70 -0
- package/dist/finance/orders-command.js +94 -0
- package/dist/finance/products-command.js +98 -0
- package/dist/finance/subscriptions-command.js +152 -0
- package/dist/finance/transactions-command.js +136 -0
- package/dist/finance/wallets-command.js +105 -0
- package/dist/finance/written.js +36 -0
- package/dist/findings/command.js +102 -0
- package/dist/findings-input.js +23 -0
- package/dist/identity.js +20 -0
- package/dist/install/postinstall.js +47 -0
- package/dist/json-fields.js +48 -0
- package/dist/knowledge/business-text.js +19 -0
- package/dist/knowledge/command.js +435 -0
- package/dist/knowledge/document-context.js +33 -0
- package/dist/knowledge/key-documents.js +120 -0
- package/dist/knowledge/list-queries.js +20 -0
- package/dist/knowledge/meeting-projects-command.js +61 -0
- package/dist/knowledge/messenger-sync.js +253 -0
- package/dist/knowledge/money-text.js +16 -0
- package/dist/knowledge/notes-about.js +81 -0
- package/dist/knowledge/organization-delete-command.js +44 -0
- package/dist/knowledge/organization-text.js +27 -0
- package/dist/knowledge/project-actions-command.js +130 -0
- package/dist/knowledge/project-actions.js +104 -0
- package/dist/knowledge/project-activity-command.js +70 -0
- package/dist/knowledge/project-context.js +101 -0
- package/dist/knowledge/project-findings.js +41 -0
- package/dist/knowledge/project-gather-command.js +100 -0
- package/dist/knowledge/project-status-command.js +129 -0
- package/dist/knowledge/project-transfer-command.js +58 -0
- package/dist/knowledge/project-transfer.js +107 -0
- package/dist/knowledge/relationships-scan.js +116 -0
- package/dist/knowledge/relationships.js +115 -0
- package/dist/knowledge/roles-command.js +67 -0
- package/dist/mail/command.js +20 -0
- package/dist/mail/findings-command.js +143 -0
- package/dist/mail/findings-duplicates.js +159 -0
- package/dist/mail/messages-command.js +77 -0
- package/dist/mail/review-command.js +59 -0
- package/dist/mail/subscriptions-command.js +84 -0
- package/dist/mcp/catalogue.js +159 -0
- package/dist/mcp/command.js +125 -0
- package/dist/mcp/granted.js +18 -0
- package/dist/mcp/permissions.js +61 -0
- package/dist/mcp/server.js +128 -0
- package/dist/meetings/command.js +31 -0
- package/dist/meetings/list-command.js +59 -0
- package/dist/meetings/preparation-command.js +42 -0
- package/dist/meetings/preparation-text.js +44 -0
- package/dist/meetings/preparation.js +50 -0
- package/dist/meetings/read.js +32 -0
- package/dist/memories/command.js +105 -0
- package/dist/memories/memories.js +17 -0
- package/dist/memories/memory.js +89 -0
- package/dist/memories/sources.js +111 -0
- package/dist/mentions/command.js +91 -0
- package/dist/migrate/check.js +48 -0
- package/dist/migrate/from-memo.js +345 -0
- package/dist/migrate/skill.js +35 -0
- package/dist/models/command.js +19 -0
- package/dist/options.js +35 -0
- package/dist/output.js +17 -0
- package/dist/page.js +14 -0
- package/dist/people/command.js +144 -0
- package/dist/people/delete-command.js +53 -0
- package/dist/people/doubts-command.js +81 -0
- package/dist/people/identities-command.js +188 -0
- package/dist/people/identity.js +42 -0
- package/dist/people/owner.js +14 -0
- package/dist/people/proposal-rows.js +70 -0
- package/dist/people/proposals-command.js +248 -0
- package/dist/people/review-context.js +108 -0
- package/dist/people/subject.js +19 -0
- package/dist/program.js +875 -0
- package/dist/read-only.js +51 -0
- package/dist/reasons.js +368 -0
- package/dist/records/import.js +135 -0
- package/dist/records/input.js +210 -0
- package/dist/records/mapping.js +80 -0
- package/dist/records/record-commands.js +125 -0
- package/dist/records/sources.js +73 -0
- package/dist/refs.js +28 -0
- package/dist/review/command.js +171 -0
- package/dist/review/kinds.js +44 -0
- package/dist/review/review.js +299 -0
- package/dist/review/status.js +93 -0
- package/dist/rows.js +219 -0
- package/dist/run/auto.js +237 -0
- package/dist/run/entry.js +62 -0
- package/dist/run/files.js +51 -0
- package/dist/run/import.js +253 -0
- package/dist/run/lock.js +20 -0
- package/dist/save-help.js +3 -0
- package/dist/schedule/command.js +58 -0
- package/dist/schedule/mail-triage-input.js +152 -0
- package/dist/schedule/task-triage-input.js +152 -0
- package/dist/search/answers.js +176 -0
- package/dist/search/command.js +257 -0
- package/dist/search/denied.js +9 -0
- package/dist/search/embed.js +126 -0
- package/dist/search/hits.js +4 -0
- package/dist/search/lane-gates.js +76 -0
- package/dist/search/notes-text.js +18 -0
- package/dist/search/people.js +88 -0
- package/dist/search/search.js +306 -0
- package/dist/show/command.js +179 -0
- package/dist/store/crm-viewer.js +102 -0
- package/dist/store/group.js +112 -0
- package/dist/store/groups-command.js +136 -0
- package/dist/store/guard.js +94 -0
- package/dist/store/held.js +21 -0
- package/dist/store/info-command.js +37 -0
- package/dist/store/scope.js +53 -0
- package/dist/store/source-list.js +222 -0
- package/dist/store/source-target.js +28 -0
- package/dist/tags/command.js +176 -0
- package/dist/tasks/command.js +174 -0
- package/dist/tasks/context.js +74 -0
- package/dist/tasks/list.js +199 -0
- package/dist/tasks/proposal-duplicates.js +70 -0
- package/dist/tasks/relations-command.js +28 -0
- package/dist/tasks/shared.js +105 -0
- package/dist/tasks/tasks.js +197 -0
- package/dist/templates/command.js +18 -0
- package/dist/terminal.js +23 -0
- package/dist/update.js +35 -0
- package/dist/version.js +2 -0
- package/dist/vocabulary/command.js +103 -0
- package/dist/vocabulary/inspect.js +23 -0
- package/dist/vocabulary/inspection.js +18 -0
- package/dist/vocabulary/list.js +18 -0
- package/dist/vocabulary/project.js +19 -0
- package/dist/wcat.js +3 -0
- package/install/postinstall.mjs +9 -0
- package/package.json +89 -4
- package/scenarios/decision-trail.md +21 -0
- package/scenarios/person-brief.md +35 -0
- package/scenarios/prepare-meeting.md +17 -0
- package/scenarios/project-state.md +26 -0
- package/scenarios/set-up.md +18 -0
- package/scenarios/start-the-day.md +19 -0
- package/skills/mail-triage/SKILL.md +208 -0
- package/skills/morning-digest/SKILL.md +147 -0
- package/skills/task-triage/SKILL.md +79 -0
- package/skills/wcat/SKILL.md +65 -0
- package/skills/wcat/topics/mail.md +32 -0
- package/skills/wcat/topics/mcp.md +22 -0
- package/skills/wcat/topics/meetings.md +37 -0
- package/skills/wcat/topics/money.md +52 -0
- package/skills/wcat/topics/projects.md +54 -0
- package/skills/wcat/topics/proposals.md +113 -0
- package/skills/wcat/topics/search.md +85 -0
- package/skills/wcat/topics/vocabulary.md +8 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { CliError } from "@wirecat/cli-base";
|
|
3
|
+
import { annotate } from "@wirecat/cli-base/commands";
|
|
4
|
+
import { agentSchedule, calendarOf, environmentOf, grantsAuthority, HARNESSES, harnessesOn, harnessInfo, harnessOfArgv, LOCAL_READ, LOCAL_WRITE, parseRoute, pauseSchedule, queryTerms, readSchedule, removeSchedule, reportsCost, routeText, runScheduleNow, scheduleName, setExitCode, slotsOfAt, termField, thisMachine, withQuery, writeSchedule, } from "@wirecat/cli-core";
|
|
5
|
+
import { Option } from "commander";
|
|
6
|
+
import { itemAnswer, wholeList, withStore } from "../answer.js";
|
|
7
|
+
import { APP } from "../app.js";
|
|
8
|
+
import { authorOf, fromAppOption, whoRuns } from "../author.js";
|
|
9
|
+
import { scheduleLimits } from "../config.js";
|
|
10
|
+
import { readOnly } from "../read-only.js";
|
|
11
|
+
import { agentInputOf, MAIL_CLI } from "../schedule/command.js";
|
|
12
|
+
import { checkedBrief, readBrief, refuseAgent } from "./brief.js";
|
|
13
|
+
import { sourcesOf } from "./command.js";
|
|
14
|
+
import { agentOf, briefAddress, DIGEST_PROMPT, DIGEST_SOURCES, digestNames, digestOf, digestScheduleFile, dropDefinition, legacyClaudeDigest, MORNING_DIGEST, readDefinition, runsDigestSkill, viewOf, writeDefinition, } from "./digests.js";
|
|
15
|
+
/** `--source all` and `--deliver-to none`: an edit's way to clear what an earlier one set. */
|
|
16
|
+
const ALL = "all";
|
|
17
|
+
const NONE = "none";
|
|
18
|
+
const usdOf = (flag, least) => (value) => {
|
|
19
|
+
const usd = Number(value);
|
|
20
|
+
if (!Number.isFinite(usd) || usd < 0 || (least === "above zero" && usd === 0))
|
|
21
|
+
throw new CliError("validation_error", `${flag} takes US dollars, ${least === "zero" ? "0 or more" : "more than 0"}; not "${value}"`, {
|
|
22
|
+
param: flag,
|
|
23
|
+
});
|
|
24
|
+
return usd;
|
|
25
|
+
};
|
|
26
|
+
const routeOf = (route, routes = []) => route === NONE ? [] : [...routes, routeText(parseRoute(route))];
|
|
27
|
+
const sourceOption = (value, before = []) => value.trim().toLowerCase() === ALL ? ALL : sourcesOf(value, before === ALL ? [] : before);
|
|
28
|
+
/** The options `add` and `edit` share; an edit replaces what each given option says and keeps the rest. */
|
|
29
|
+
const withDigestOptions = (command) => fromAppOption(command
|
|
30
|
+
.option("--title <title>", "the name the digest is shown under")
|
|
31
|
+
.option("--at <HH:MM>", "when it runs: HH:MM every day, or 'mon,fri 09:00' on those days; repeat it for more times, as 08:30 and 18:00", (at, all = []) => [...all, at])
|
|
32
|
+
.option("--source <accounts>", `what it reads, comma-separated or repeated: ${DIGEST_SOURCES.join(", ")}; ${ALL} (the default) reads everything`, sourceOption)
|
|
33
|
+
.option("--deliver-to <route>", `where each run is sent: telegram-bot:<profile>/<chat> or email:<profile>/<address>; repeat it for more, ${NONE} for nowhere`, routeOf)
|
|
34
|
+
.option("--text <text>", "your brief: what to collect, what to skip, how much; at most 4000 characters")
|
|
35
|
+
.addOption(new Option("--agent <agent>", "the agent that writes it; a new digest takes the one agent installed, and asks when there are more. A " +
|
|
36
|
+
"local model needs an agent set up to run one").choices(HARNESSES))
|
|
37
|
+
.option("--model <model>", 'the model the agent runs on: an alias such as sonnet or a model id; "" for the agent\'s own default')
|
|
38
|
+
.option("--allow-dangerous", "let an agent whose own limits cannot hold it to wcat's commands write it, where `wcat schedule agents list` " +
|
|
39
|
+
"says allowed_with_ack (codex): it may then run any program inside its sandbox. Only you give this")
|
|
40
|
+
.option("--max-cost <usd>", "stop a run that costs more than this, in US dollars; only for an agent that reports its cost", usdOf("--max-cost", "above zero"))
|
|
41
|
+
.option("--max-cost-per-day <usd>", "start no run for the rest of the day once its runs cost this much, in US dollars; 0 for no cap", usdOf("--max-cost-per-day", "zero"))
|
|
42
|
+
.option("--json", "print JSON"));
|
|
43
|
+
/** The commands an old claude digest was allowed: wcat's own and the mail CLI's. */
|
|
44
|
+
const LEGACY_TOOLS = [APP.command, MAIL_CLI.command].map((command) => `Bash(${command}:*)`);
|
|
45
|
+
/** What an existing digest's agent was asked, so an edit keeps it; an old file only in the shape wcat saved it. */
|
|
46
|
+
const kept = (schedule) => agentOf(schedule) ??
|
|
47
|
+
legacyClaudeDigest(schedule.argv, LEGACY_TOOLS) ?? { harness: harnessOfArgv(schedule.argv) ?? "claude", model: "" };
|
|
48
|
+
/** An agent no schedule may start, or one that needs `--allow-dangerous`, is refused before anything is asked. */
|
|
49
|
+
const refuseUnheld = (harness, accepted) => {
|
|
50
|
+
const info = harnessInfo(harness);
|
|
51
|
+
if (info.restricted || (info.allowedWithAck && accepted))
|
|
52
|
+
return;
|
|
53
|
+
throw new CliError("permission_error", info.allowedWithAck
|
|
54
|
+
? `${info.name} writes a digest only with --allow-dangerous, as ${info.restrictedReason}`
|
|
55
|
+
: `${info.name} cannot run on a schedule: ${info.restrictedReason}`, { reason: "agent.unrestricted", restricted_reason: info.restrictedReason });
|
|
56
|
+
};
|
|
57
|
+
/** A cost cap typed for an agent that reports no cost would never stop it, so it is refused rather than kept. */
|
|
58
|
+
const refuseUncostedCap = (harness, given) => {
|
|
59
|
+
if (!reportsCost(harness) && (given.maxCost !== undefined || given.maxCostPerDay))
|
|
60
|
+
throw new CliError("validation_error", `${harness} reports no cost, so --max-cost and --max-cost-per-day cannot stop it; leave them out`, { reason: "agent.cost-unknown", param: given.maxCost !== undefined ? "max-cost" : "max-cost-per-day" });
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* A new digest's agent when none is given: the one installed. With none or several, the owner names it, because a
|
|
64
|
+
* guessed agent may be one without credit.
|
|
65
|
+
*/
|
|
66
|
+
const installedAgent = (env) => {
|
|
67
|
+
const installed = harnessesOn(env, process.platform).filter((one) => one.installed);
|
|
68
|
+
if (installed.length === 1 && installed[0])
|
|
69
|
+
return installed[0].id;
|
|
70
|
+
const choices = (installed.length ? installed : harnessesOn(env, process.platform)).map(({ id }) => id);
|
|
71
|
+
throw new CliError("validation_error", installed.length
|
|
72
|
+
? `more than one agent is installed; name the one that writes it: --agent ${choices.join("|")}`
|
|
73
|
+
: `no agent is installed; install one and name it with --agent: ${choices.join(", ")}`, { param: "agent", reason: "digest.agent-unchosen", choices });
|
|
74
|
+
};
|
|
75
|
+
/** A digest's schedule rebuilt for `agent`, keeping its notice, pause and creation time. */
|
|
76
|
+
const digestSchedule = (site, name, schedule, agent) => ({
|
|
77
|
+
...agentSchedule(site, {
|
|
78
|
+
name,
|
|
79
|
+
harness: agent.harness,
|
|
80
|
+
prompt: DIGEST_PROMPT,
|
|
81
|
+
when: agent.when,
|
|
82
|
+
...(agent.model === undefined ? {} : { model: agent.model }),
|
|
83
|
+
...(agent.maxCost ? { maxCost: agent.maxCost } : {}),
|
|
84
|
+
...(agent.allowDangerous ? { allowDangerous: true } : {}),
|
|
85
|
+
...(agent.maxCostPerDay === undefined ? {} : { maxCostPerDay: agent.maxCostPerDay }),
|
|
86
|
+
...(schedule.notify ? { notify: schedule.notify } : {}),
|
|
87
|
+
...(agent.to.length ? { to: agent.to } : {}),
|
|
88
|
+
...(schedule.paused ? { paused: true } : {}),
|
|
89
|
+
}),
|
|
90
|
+
createdAt: schedule.createdAt,
|
|
91
|
+
});
|
|
92
|
+
export const digestCommands = (digest, print, env) => {
|
|
93
|
+
const siteOf = (command) => ({
|
|
94
|
+
app: APP,
|
|
95
|
+
system: environmentOf(command).system ?? thisMachine(),
|
|
96
|
+
env,
|
|
97
|
+
profile: "",
|
|
98
|
+
agentRuns: [MAIL_CLI],
|
|
99
|
+
limits: scheduleLimits(env),
|
|
100
|
+
});
|
|
101
|
+
/**
|
|
102
|
+
* After cli-core 0.643.0 a timer runs only a schedule that keeps its `agent` (SEC-11). Each old claude digest whose
|
|
103
|
+
* argv is the shape wcat saved is saved again once, at the owner's first command; the rest wait in `digest list`.
|
|
104
|
+
* Never in an agent's run or under the read-only lock, where a run could rewrite the owner's timers.
|
|
105
|
+
*/
|
|
106
|
+
const saveOldDigests = async (command) => {
|
|
107
|
+
if (readOnly(env) || env[`${APP.envPrefix}_SCHEDULED`] || authorOf(env) !== "owner")
|
|
108
|
+
return;
|
|
109
|
+
for (const name of digestNames(env)) {
|
|
110
|
+
const file = digestScheduleFile(env, name);
|
|
111
|
+
if (!existsSync(file))
|
|
112
|
+
continue;
|
|
113
|
+
try {
|
|
114
|
+
const schedule = readSchedule(file);
|
|
115
|
+
if (schedule.kind !== "agent" || schedule.agent !== undefined)
|
|
116
|
+
continue;
|
|
117
|
+
const legacy = legacyClaudeDigest(schedule.argv, LEGACY_TOOLS);
|
|
118
|
+
if (!legacy)
|
|
119
|
+
continue;
|
|
120
|
+
const site = siteOf(command);
|
|
121
|
+
await writeSchedule(site, digestSchedule(site, name, schedule, {
|
|
122
|
+
...legacy,
|
|
123
|
+
maxCostPerDay: schedule.maxCostPerDay,
|
|
124
|
+
when: schedule.when,
|
|
125
|
+
to: schedule.to ?? [],
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// A digest that cannot be saved again keeps its old file, and `digest list` says what it needs.
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
let root = digest;
|
|
134
|
+
while (root.parent)
|
|
135
|
+
root = root.parent;
|
|
136
|
+
root.hook("preAction", (_root, action) => saveOldDigests(action));
|
|
137
|
+
// Each of these spends the owner's money, sets his timers or sends to his chats: he does it, never an agent.
|
|
138
|
+
const owner = async (command, question) => {
|
|
139
|
+
refuseAgent(env);
|
|
140
|
+
if ((await whoRuns(command, env, { question })) !== "owner")
|
|
141
|
+
throw new CliError("permission_error", "a digest spends your money and writes to your chats; you change or run it at a terminal or in WireCat Desktop", { reason: "digest.owner-only" });
|
|
142
|
+
};
|
|
143
|
+
const shown = async (name) => viewOf(env, name, { brief: (await readBrief(env, name)) ?? null, limits: scheduleLimits(env) });
|
|
144
|
+
const say = async (json, name, line) => print(json, itemAnswer(await shown(name)), line);
|
|
145
|
+
const saveBrief = async (name, text) => {
|
|
146
|
+
if (text === undefined)
|
|
147
|
+
return;
|
|
148
|
+
const body = checkedBrief(text);
|
|
149
|
+
await withStore(env, async (store) => store.templates.save(briefAddress(name), body, "wcat"));
|
|
150
|
+
};
|
|
151
|
+
const listQuery = {
|
|
152
|
+
entity: "digest",
|
|
153
|
+
backend: "native",
|
|
154
|
+
fields: [termField("name", "kw", "name:weekly")],
|
|
155
|
+
};
|
|
156
|
+
withQuery(annotate(digest.command("list"), { effects: LOCAL_READ }).summary("your digests: when each runs, what it reads, where it goes, last and next run"), listQuery)
|
|
157
|
+
.option("--json", "print JSON")
|
|
158
|
+
.action(async (words, given) => {
|
|
159
|
+
const wanted = queryTerms(words, listQuery, "digest list").get("name");
|
|
160
|
+
const names = digestNames(env).filter((name) => wanted === undefined || name === wanted);
|
|
161
|
+
const items = await Promise.all(names.map(shown));
|
|
162
|
+
print(given.json, wholeList("digest list", items), items.length === 0
|
|
163
|
+
? "No digests. `wcat digest add <name> --title … --at 08:30` makes one."
|
|
164
|
+
: items
|
|
165
|
+
.map((one) => [
|
|
166
|
+
one.name,
|
|
167
|
+
one.title,
|
|
168
|
+
one.times.length
|
|
169
|
+
? `${one.weekdays.length ? one.weekdays.join(",") : "daily"} ${one.times.join(", ")}`
|
|
170
|
+
: "no set time",
|
|
171
|
+
one.scheduled ? "on" : "paused",
|
|
172
|
+
one.sources.length ? `reads ${one.sources.join(", ")}` : "reads everything",
|
|
173
|
+
one.routes.length ? `to ${one.routes.join(", ")}` : "sent nowhere",
|
|
174
|
+
one.last ? `last ${one.last.at.slice(0, 16).replace("T", " ")} ${one.last.ok ? "ok" : "failed"}` : "",
|
|
175
|
+
one.needs ? `needs you: ${one.needs}` : "",
|
|
176
|
+
]
|
|
177
|
+
.filter(Boolean)
|
|
178
|
+
.join(" "))
|
|
179
|
+
.join("\n"));
|
|
180
|
+
});
|
|
181
|
+
withDigestOptions(grantsAuthority(annotate(digest.command("add"), { effects: LOCAL_WRITE }))
|
|
182
|
+
.summary("make a digest: its times, sources, routes and brief, on its timer")
|
|
183
|
+
.description("make a digest: an agent that runs wcat's morning-digest skill at the given times, reading from its previous " +
|
|
184
|
+
"time (a weekly one reads the week) and only the sources given, and sends what it writes along the routes " +
|
|
185
|
+
"given. It runs read only. Each run is a paid model call; only you make one")
|
|
186
|
+
.argument("<name>", "lowercase letters, digits and dashes")
|
|
187
|
+
.option("--paused", "make it without putting it on its timer; `wcat digest resume` does")).action(async (name, given, command) => {
|
|
188
|
+
const digestName = scheduleName(name);
|
|
189
|
+
if (existsSync(digestScheduleFile(env, digestName)))
|
|
190
|
+
throw new CliError("validation_error", `${digestName} already exists; \`wcat digest edit ${digestName}\` changes it`, {
|
|
191
|
+
reason: "digest.exists",
|
|
192
|
+
});
|
|
193
|
+
if (!given.at?.length)
|
|
194
|
+
throw new CliError("validation_error", "say when: --at HH:MM, or --at 'mon 09:00'; repeat it for more times", {
|
|
195
|
+
param: "at",
|
|
196
|
+
});
|
|
197
|
+
const when = calendarOf(given.at.flatMap(slotsOfAt));
|
|
198
|
+
if (given.text !== undefined)
|
|
199
|
+
checkedBrief(given.text);
|
|
200
|
+
const harness = given.agent ?? installedAgent(env);
|
|
201
|
+
refuseUncostedCap(harness, given);
|
|
202
|
+
refuseUnheld(harness, given.allowDangerous === true);
|
|
203
|
+
await owner(command, `make the digest ${digestName}, a paid model call at each of its times?`);
|
|
204
|
+
const site = siteOf(command);
|
|
205
|
+
const schedule = agentSchedule(site, {
|
|
206
|
+
name: digestName,
|
|
207
|
+
harness,
|
|
208
|
+
prompt: DIGEST_PROMPT,
|
|
209
|
+
when,
|
|
210
|
+
...(given.model === undefined ? {} : { model: given.model }),
|
|
211
|
+
...(given.maxCost ? { maxCost: given.maxCost } : {}),
|
|
212
|
+
...(given.allowDangerous && harnessInfo(harness).allowedWithAck ? { allowDangerous: true } : {}),
|
|
213
|
+
...(given.maxCostPerDay === undefined ? {} : { maxCostPerDay: given.maxCostPerDay }),
|
|
214
|
+
...(given.deliverTo?.length ? { to: given.deliverTo } : {}),
|
|
215
|
+
...(given.paused ? { paused: true } : {}),
|
|
216
|
+
});
|
|
217
|
+
writeDefinition(env, {
|
|
218
|
+
name: digestName,
|
|
219
|
+
title: given.title?.trim() || digestName,
|
|
220
|
+
sources: given.source === ALL || given.source === undefined ? [] : given.source,
|
|
221
|
+
createdAt: new Date().toISOString(),
|
|
222
|
+
});
|
|
223
|
+
await writeSchedule(site, schedule);
|
|
224
|
+
await saveBrief(digestName, given.text);
|
|
225
|
+
await say(given.json, digestName, `Added ${digestName}${given.paused ? ", paused" : ""}.`);
|
|
226
|
+
});
|
|
227
|
+
withDigestOptions(grantsAuthority(annotate(digest.command("edit"), { effects: LOCAL_WRITE }))
|
|
228
|
+
.summary("change a digest; each option given replaces what it says, the rest stays")
|
|
229
|
+
.description(`change a digest: each option given replaces what it set before (--at all its times, --source all its sources, ` +
|
|
230
|
+
`--deliver-to all its routes), and the rest stays as it was. --source ${ALL} reads everything again, ` +
|
|
231
|
+
`--deliver-to ${NONE} sends nowhere. A paused digest stays paused. Only you change one`)
|
|
232
|
+
.argument("<name>", "the digest's name, as `wcat digest list` shows it")).action(async (name, given, command) => {
|
|
233
|
+
const { schedule } = digestOf(env, name);
|
|
234
|
+
if (!runsDigestSkill(schedule))
|
|
235
|
+
throw new CliError("validation_error", `${name} runs a prompt of its own, made with \`wcat schedule agent\`; an edit here would replace it — change it there`, { reason: "digest.own-prompt" });
|
|
236
|
+
const when = given.at?.length ? calendarOf(given.at.flatMap(slotsOfAt)) : schedule.when;
|
|
237
|
+
if (given.text !== undefined)
|
|
238
|
+
checkedBrief(given.text);
|
|
239
|
+
const previous = kept(schedule);
|
|
240
|
+
const harness = given.agent ?? previous.harness;
|
|
241
|
+
const same = harness === previous.harness;
|
|
242
|
+
const accepted = given.allowDangerous ?? (same && previous.allowDangerous === true);
|
|
243
|
+
refuseUncostedCap(harness, given);
|
|
244
|
+
refuseUnheld(harness, accepted);
|
|
245
|
+
await owner(command, `change the digest ${name}?`);
|
|
246
|
+
const costed = reportsCost(harness);
|
|
247
|
+
const rebuilt = digestSchedule(siteOf(command), name, schedule, {
|
|
248
|
+
harness,
|
|
249
|
+
// Another agent's model names mean nothing to this one; its default applies unless --model names one.
|
|
250
|
+
model: given.model ?? (same ? previous.model : undefined),
|
|
251
|
+
maxCost: costed ? (given.maxCost ?? previous.maxCost) : undefined,
|
|
252
|
+
maxCostPerDay: costed ? (given.maxCostPerDay ?? schedule.maxCostPerDay) : undefined,
|
|
253
|
+
allowDangerous: accepted && harnessInfo(harness).allowedWithAck,
|
|
254
|
+
when,
|
|
255
|
+
to: given.deliverTo ?? schedule.to ?? [],
|
|
256
|
+
});
|
|
257
|
+
const definition = readDefinition(env, name);
|
|
258
|
+
if (given.title !== undefined || given.source !== undefined || definition) {
|
|
259
|
+
writeDefinition(env, {
|
|
260
|
+
name,
|
|
261
|
+
title: given.title?.trim() || definition?.title || (name === MORNING_DIGEST ? "Morning digest" : name),
|
|
262
|
+
sources: given.source === ALL ? [] : (given.source ?? definition?.sources ?? []),
|
|
263
|
+
createdAt: definition?.createdAt || schedule.createdAt,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
await writeSchedule(siteOf(command), rebuilt);
|
|
267
|
+
await saveBrief(name, given.text);
|
|
268
|
+
await say(given.json, name, `Changed ${name}.`);
|
|
269
|
+
});
|
|
270
|
+
fromAppOption(annotate(digest.command("run"), { effects: LOCAL_WRITE }))
|
|
271
|
+
.summary("build a digest now and send it along its routes, or only some, or none")
|
|
272
|
+
.description("build a digest now, as its timer would, paused or not, and keep the run with its others; it is sent along " +
|
|
273
|
+
"its routes, only along those --deliver-to names (each one of its own), or with --no-notify nowhere. A paid " +
|
|
274
|
+
"model call: the day's cost cap holds, and only you run it")
|
|
275
|
+
.argument("<name>", "the digest's name, as `wcat digest list` shows it")
|
|
276
|
+
.option("--no-notify", "keep it here: send it nowhere")
|
|
277
|
+
.option("--deliver-to <route>", "send it only along this one of the digest's routes; repeat it for more", (route, routes = []) => [...routes, routeText(parseRoute(route))])
|
|
278
|
+
.option("--json", "print JSON")
|
|
279
|
+
.action(async (name, given, command) => {
|
|
280
|
+
const { file } = digestOf(env, name);
|
|
281
|
+
if (!given.notify && given.deliverTo)
|
|
282
|
+
throw new CliError("validation_error", "--no-notify sends nothing; leave out --deliver-to, or --no-notify", {
|
|
283
|
+
param: "deliver-to",
|
|
284
|
+
});
|
|
285
|
+
await owner(command, `run the digest ${name} now, a paid model call?`);
|
|
286
|
+
const routes = given.notify ? given.deliverTo : [];
|
|
287
|
+
const last = await runScheduleNow(command, siteOf(command), file, {
|
|
288
|
+
agentInput: agentInputOf(env),
|
|
289
|
+
...(routes ? { routes } : {}),
|
|
290
|
+
});
|
|
291
|
+
if (!("exitCode" in last)) {
|
|
292
|
+
print(given.json, itemAnswer({ name, skipped: true, ...last.skipped }), `${name}: skipped — ${last.skipped.why}`);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
if (last.exitCode !== 0)
|
|
296
|
+
setExitCode(command, 1);
|
|
297
|
+
print(given.json, itemAnswer({ name, ...last }), `${name}: ${last.exitCode === 0 ? "built" : `failed (exit ${last.exitCode})`} — ${last.output}`);
|
|
298
|
+
});
|
|
299
|
+
for (const [verb, paused] of [
|
|
300
|
+
["pause", true],
|
|
301
|
+
["resume", false],
|
|
302
|
+
])
|
|
303
|
+
fromAppOption(grantsAuthority(annotate(digest.command(verb), { effects: LOCAL_WRITE })))
|
|
304
|
+
.summary(paused
|
|
305
|
+
? "take a digest off its timer; it stays, and run still builds it"
|
|
306
|
+
: "put a paused digest back on its timer")
|
|
307
|
+
.argument("<name>", "the digest's name, as `wcat digest list` shows it")
|
|
308
|
+
.option("--json", "print JSON")
|
|
309
|
+
.action(async (name, given, command) => {
|
|
310
|
+
digestOf(env, name);
|
|
311
|
+
await owner(command, `${verb} the digest ${name}?`);
|
|
312
|
+
await pauseSchedule(siteOf(command), name, paused);
|
|
313
|
+
await say(given.json, name, paused ? `Paused ${name}.` : `Resumed ${name}.`);
|
|
314
|
+
});
|
|
315
|
+
fromAppOption(grantsAuthority(annotate(digest.command("remove"), { effects: LOCAL_WRITE })))
|
|
316
|
+
.summary("remove a digest and its timer; its past runs, brief and templates stay")
|
|
317
|
+
.argument("<name>", "the digest's name, as `wcat digest list` shows it")
|
|
318
|
+
.option("--json", "print JSON")
|
|
319
|
+
.action(async (name, given, command) => {
|
|
320
|
+
digestOf(env, name);
|
|
321
|
+
await owner(command, `remove the digest ${name}?`);
|
|
322
|
+
await removeSchedule(siteOf(command), name);
|
|
323
|
+
dropDefinition(env, name);
|
|
324
|
+
print(given.json, itemAnswer({ name, removed: true }), `Removed ${name}; its past runs stay.`);
|
|
325
|
+
});
|
|
326
|
+
};
|
|
327
|
+
//# sourceMappingURL=digest-commands.js.map
|