@dench.com/cli 3.3.0-staging.314 → 3.5.0-staging.327

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/signals.ts DELETED
@@ -1,109 +0,0 @@
1
- import { readFile } from "node:fs/promises";
2
- import type { ConvexHttpClient } from "convex/browser";
3
- import { makeFunctionReference } from "convex/server";
4
- import { assertNoUnknownFlags, getFlag, hasFlag, shift } from "./lib/cli-args";
5
- import {
6
- defaultSignalAgentConfig,
7
- signalAgentConfigSchema,
8
- } from "./lib/signal-agents";
9
-
10
- const HELP = `dench signals — recurring, multi-source lead discovery
11
-
12
- list | catalog | get <id> | runs <id> [--json]
13
- template [--json] Print a starting config
14
- create --name <name> --file config.json [--active] [--accept-warnings]
15
- update <id> --name <name> --file config.json [--active] [--accept-warnings]
16
- pause <id> | resume <id> | run <id>
17
-
18
- --config '<JSON>' can replace --file. Updates replace the full configuration.
19
- Create/update default to paused unless --active is passed. Review warnings before
20
- --accept-warnings. Agents keep their own prospect list; enrichment stays explicit.
21
- Read/write API keys need crons:read / crons:write. LinkedIn is the required primary
22
- source. Choose linkedinAccountId from catalog; web and data support discovery.`;
23
-
24
- export async function runSignalsCommand(opts: {
25
- convex: ConvexHttpClient;
26
- args: string[];
27
- sessionToken?: string;
28
- jsonOutput?: boolean;
29
- }) {
30
- const args = [...opts.args];
31
- const json = hasFlag(args, "--json") || opts.jsonOutput;
32
- const command = args.shift() ?? "help";
33
- if (["help", "--help", "-h"].includes(command)) {
34
- console.log(HELP);
35
- return;
36
- }
37
- if (command === "template") {
38
- assertNoUnknownFlags(args, "signals template");
39
- console.log(JSON.stringify(defaultSignalAgentConfig(), null, 2));
40
- return;
41
- }
42
- let result: unknown;
43
- const token = opts.sessionToken ? { sessionToken: opts.sessionToken } : {};
44
- if (["list", "catalog", "get", "runs"].includes(command)) {
45
- const agentId =
46
- command === "get" || command === "runs"
47
- ? shift(args, "agent ID")
48
- : undefined;
49
- if ((command === "get" || command === "runs") && !agentId)
50
- throw new Error("Provide an agent ID");
51
- assertNoUnknownFlags(args, `signals ${command}`);
52
- if (args.length) throw new Error(`Unexpected argument: ${args[0]}`);
53
- result = await opts.convex.query(
54
- makeFunctionReference<"query">(`functions/signalAgents:${command}`),
55
- { ...token, ...(agentId ? { agentId } : {}) },
56
- );
57
- } else if (command === "create" || command === "update") {
58
- const agentId = command === "update" ? shift(args, "agent ID") : undefined;
59
- const name = getFlag(args, "--name");
60
- const file = getFlag(args, "--file");
61
- const inline = getFlag(args, "--config");
62
- const active = hasFlag(args, "--active");
63
- const acknowledgeWarnings = hasFlag(args, "--accept-warnings");
64
- assertNoUnknownFlags(args, `signals ${command}`);
65
- if (args.length) throw new Error(`Unexpected argument: ${args[0]}`);
66
- if (
67
- !name ||
68
- (!file && !inline) ||
69
- (file && inline) ||
70
- (command === "update" && !agentId)
71
- )
72
- throw new Error(
73
- "Provide --name and exactly one of --file / --config (plus an ID for update)",
74
- );
75
- const config = signalAgentConfigSchema.parse(
76
- JSON.parse(file ? await readFile(file, "utf8") : (inline ?? "")),
77
- );
78
- result = await opts.convex.mutation(
79
- makeFunctionReference<"mutation">("functions/signalAgents:save"),
80
- {
81
- ...token,
82
- ...(agentId ? { agentId } : {}),
83
- name,
84
- config,
85
- status: active ? "active" : "paused",
86
- acknowledgeWarnings,
87
- },
88
- );
89
- } else if (["pause", "resume", "run"].includes(command)) {
90
- const agentId = shift(args, "agent ID");
91
- assertNoUnknownFlags(args, `signals ${command}`);
92
- if (!agentId || args.length)
93
- throw new Error("Provide exactly one agent ID");
94
- result = await opts.convex.mutation(
95
- makeFunctionReference<"mutation">(
96
- `functions/signalAgents:${command === "run" ? "run" : "setStatus"}`,
97
- ),
98
- {
99
- ...token,
100
- agentId,
101
- ...(command === "run"
102
- ? {}
103
- : { status: command === "pause" ? "paused" : "active" }),
104
- },
105
- );
106
- } else throw new Error(`Unknown signals command: ${command}\n${HELP}`);
107
- // Structured output is also readable for humans; never prefix --json output.
108
- console.log(JSON.stringify(result, null, json ? 2 : 2));
109
- }