@erdoai/cli 0.206.0 → 0.208.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/dist/index.js +67 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -192,6 +192,24 @@ function parseCSV(text) {
|
|
|
192
192
|
return rows;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
// src/knowledge-freshness.ts
|
|
196
|
+
function knowledgeFreshnessFromOptions(opts) {
|
|
197
|
+
const out = {};
|
|
198
|
+
const set = (key, value) => {
|
|
199
|
+
if (value !== void 0 && value.trim() !== "") out[key] = value.trim();
|
|
200
|
+
};
|
|
201
|
+
set("provider", opts.provider);
|
|
202
|
+
set("api_family", opts.apiFamily);
|
|
203
|
+
set("version", opts.providerVersion);
|
|
204
|
+
set("source_url", opts.sourceUrl);
|
|
205
|
+
set("verified_at", opts.verifiedAt);
|
|
206
|
+
set("stale_after", opts.staleAfter);
|
|
207
|
+
set("stale_when", opts.staleWhen);
|
|
208
|
+
set("superseded_by", opts.supersededBy);
|
|
209
|
+
if (opts.deprecated) out.deprecated = true;
|
|
210
|
+
return out;
|
|
211
|
+
}
|
|
212
|
+
|
|
195
213
|
// src/eval-compare.ts
|
|
196
214
|
function evalResultScored(r) {
|
|
197
215
|
return !r.agent_error && r.failure_classification !== "judge_error" && r.scoring_status !== "awaiting_truth";
|
|
@@ -691,11 +709,14 @@ var ErdoClient = class {
|
|
|
691
709
|
}
|
|
692
710
|
// Daily paid-media and lead performance for one organization, or for every
|
|
693
711
|
// client org this account manages when organization_slug is omitted.
|
|
712
|
+
// page_event_series entries are "metric=event"; omitted, the server counts
|
|
713
|
+
// visits=pageview, form_starts=form_start, leads_on_page=generate_lead.
|
|
694
714
|
managerPerformance(params) {
|
|
695
715
|
const qs = new URLSearchParams();
|
|
696
716
|
if (params.organization_slug) qs.set("organization_slug", params.organization_slug);
|
|
697
717
|
if (params.from) qs.set("from", params.from);
|
|
698
718
|
if (params.to) qs.set("to", params.to);
|
|
719
|
+
for (const entry of params.page_event_series ?? []) qs.append("page_event_series", entry);
|
|
699
720
|
const q = qs.toString();
|
|
700
721
|
return this.request(
|
|
701
722
|
"GET",
|
|
@@ -4006,13 +4027,19 @@ This key operates every org you manage; target one with X-Organization-ID (or \`
|
|
|
4006
4027
|
});
|
|
4007
4028
|
managed.command("performance").description(
|
|
4008
4029
|
"Daily spend, traffic and captured leads for the client orgs you manage \u2014 one organization with --organization, otherwise every client. Each advertising source prints its as-of time and the provider day it runs through. A metric whose source dataset is missing or unreadable prints as '-' and is explained under coverage; it is never reported as zero."
|
|
4009
|
-
).option("--organization <slug>", "read one organization instead of every client org").option("--from <YYYY-MM-DD>", "first day to include (inclusive); defaults to 89 days before --to").option("--to <YYYY-MM-DD>", "last day to include (inclusive); defaults to today (UTC)").option(
|
|
4030
|
+
).option("--organization <slug>", "read one organization instead of every client org").option("--from <YYYY-MM-DD>", "first day to include (inclusive); defaults to 89 days before --to").option("--to <YYYY-MM-DD>", "last day to include (inclusive); defaults to today (UTC)").option(
|
|
4031
|
+
"--page-event <metric=event>",
|
|
4032
|
+
"count page events named <event> as <metric> (repeatable); replaces the default visits=pageview, form_starts=form_start, leads_on_page=generate_lead columns",
|
|
4033
|
+
collect,
|
|
4034
|
+
[]
|
|
4035
|
+
).option("--daily", "one row per organization per day instead of window totals").option("--json", "print the raw JSON result instead of a table").action(
|
|
4010
4036
|
async (opts) => {
|
|
4011
4037
|
try {
|
|
4012
4038
|
const res = await new ErdoClient().managerPerformance({
|
|
4013
4039
|
organization_slug: opts.organization,
|
|
4014
4040
|
from: opts.from,
|
|
4015
|
-
to: opts.to
|
|
4041
|
+
to: opts.to,
|
|
4042
|
+
page_event_series: opts.pageEvent.length > 0 ? opts.pageEvent : void 0
|
|
4016
4043
|
});
|
|
4017
4044
|
if (opts.json) {
|
|
4018
4045
|
print(res);
|
|
@@ -4032,6 +4059,14 @@ managed.command("performance").description(
|
|
|
4032
4059
|
}
|
|
4033
4060
|
return sum;
|
|
4034
4061
|
};
|
|
4062
|
+
const pageColumns = opts.pageEvent.length > 0 ? opts.pageEvent.map((entry) => {
|
|
4063
|
+
const metric = entry.split("=")[0].trim();
|
|
4064
|
+
return { header: metric, pick: (d) => d.page_events?.[metric] ?? null };
|
|
4065
|
+
}) : [
|
|
4066
|
+
{ header: "visits", pick: (d) => d.visits },
|
|
4067
|
+
{ header: "form starts", pick: (d) => d.form_starts },
|
|
4068
|
+
{ header: "page leads", pick: (d) => d.leads_on_page }
|
|
4069
|
+
];
|
|
4035
4070
|
if (opts.daily) {
|
|
4036
4071
|
const rows = [];
|
|
4037
4072
|
for (const org2 of res.organizations) {
|
|
@@ -4041,20 +4076,25 @@ managed.command("performance").description(
|
|
|
4041
4076
|
day2.date,
|
|
4042
4077
|
cell(day2.spend, 2),
|
|
4043
4078
|
cell(day2.clicks),
|
|
4044
|
-
cell(day2
|
|
4045
|
-
cell(day2.form_starts),
|
|
4046
|
-
cell(day2.leads_on_page),
|
|
4079
|
+
...pageColumns.map((column) => cell(column.pick(day2))),
|
|
4047
4080
|
cell(day2.leads_captured)
|
|
4048
4081
|
]);
|
|
4049
4082
|
}
|
|
4050
4083
|
}
|
|
4051
4084
|
printAlignedTable(
|
|
4052
|
-
["organization", "date", "spend", "clicks",
|
|
4085
|
+
["organization", "date", "spend", "clicks", ...pageColumns.map((column) => column.header), "leads"],
|
|
4053
4086
|
rows
|
|
4054
4087
|
);
|
|
4055
4088
|
} else {
|
|
4056
4089
|
printAlignedTable(
|
|
4057
|
-
[
|
|
4090
|
+
[
|
|
4091
|
+
"organization",
|
|
4092
|
+
"spend",
|
|
4093
|
+
"clicks",
|
|
4094
|
+
...pageColumns.map((column) => column.header),
|
|
4095
|
+
"leads",
|
|
4096
|
+
"cost/lead"
|
|
4097
|
+
],
|
|
4058
4098
|
res.organizations.map((org2) => {
|
|
4059
4099
|
const spend = total(org2.days, (d) => d.spend);
|
|
4060
4100
|
const leads = total(org2.days, (d) => d.leads_captured);
|
|
@@ -4063,9 +4103,7 @@ managed.command("performance").description(
|
|
|
4063
4103
|
org2.organization_slug,
|
|
4064
4104
|
cell(spend, 2),
|
|
4065
4105
|
cell(total(org2.days, (d) => d.clicks)),
|
|
4066
|
-
cell(total(org2.days,
|
|
4067
|
-
cell(total(org2.days, (d) => d.form_starts)),
|
|
4068
|
-
cell(total(org2.days, (d) => d.leads_on_page)),
|
|
4106
|
+
...pageColumns.map((column) => cell(total(org2.days, column.pick))),
|
|
4069
4107
|
cell(leads, 0),
|
|
4070
4108
|
cell(costPerLead, 2)
|
|
4071
4109
|
];
|
|
@@ -10794,9 +10832,14 @@ declarationsCmd.command("upsert").description("Write one declaration. The same n
|
|
|
10794
10832
|
}
|
|
10795
10833
|
});
|
|
10796
10834
|
var knowledgeCmd = program.command("knowledge").description("Knowledge objects");
|
|
10797
|
-
knowledgeCmd.command("create").description("Create a Knowledge object").requiredOption("--title <title>", "title").requiredOption("--body <body>", "body text, or @file").option("--description <description>", "short description").option(
|
|
10835
|
+
knowledgeCmd.command("create").description("Create a Knowledge object").requiredOption("--title <title>", "title").requiredOption("--body <body>", "body text, or @file").option("--description <description>", "short description").option(
|
|
10836
|
+
"--type <type>",
|
|
10837
|
+
"snippet (durable context), skill (reusable instructions), dataset_note, or integration_model (a dated provider/API fact: needs --provider, --source-url, --verified-at and --stale-after)",
|
|
10838
|
+
"snippet"
|
|
10839
|
+
).option("--category <category>", "category").option("--tags <tags>", "comma-separated tags").option("--agent <name>", "name of the agent making the write").option("--provider <name>", "provider a volatile fact is about, e.g. sec_edgar").option("--api-family <name>", "API family or surface the fact covers").option("--provider-version <version>", "provider API or schema version the fact applies to").option("--source-url <url>", "official source that verified the fact").option("--verified-at <date>", "when the fact was verified (YYYY-MM-DD or RFC 3339)").option("--stale-after <date>", "when the fact must be re-verified (YYYY-MM-DD or RFC 3339)").option("--stale-when <text>", "condition that makes the fact stale sooner").action(async (opts) => {
|
|
10798
10840
|
try {
|
|
10799
10841
|
const body = readMaybeFile(opts.body) ?? "";
|
|
10842
|
+
const freshness = knowledgeFreshnessFromOptions(opts);
|
|
10800
10843
|
print(await new ErdoClient().createKnowledge({
|
|
10801
10844
|
title: opts.title,
|
|
10802
10845
|
content: body,
|
|
@@ -10804,7 +10847,8 @@ knowledgeCmd.command("create").description("Create a Knowledge object").required
|
|
|
10804
10847
|
type: opts.type,
|
|
10805
10848
|
category: opts.category,
|
|
10806
10849
|
tags: opts.tags?.split(",").map((tag) => tag.trim()).filter(Boolean),
|
|
10807
|
-
agent: opts.agent
|
|
10850
|
+
agent: opts.agent,
|
|
10851
|
+
...Object.keys(freshness).length > 0 ? { freshness } : {}
|
|
10808
10852
|
}));
|
|
10809
10853
|
} catch (e) {
|
|
10810
10854
|
fail(e);
|
|
@@ -10817,10 +10861,15 @@ knowledgeCmd.command("get <id>").description("Get one full typed Knowledge objec
|
|
|
10817
10861
|
fail(e);
|
|
10818
10862
|
}
|
|
10819
10863
|
});
|
|
10820
|
-
knowledgeCmd.command("update <id>").description("Update a Knowledge object while preserving fields omitted from the command").option("--body <value>", "new body text, or @file; pass an empty value to clear the body").option("--config <file>", "JSON object file containing the complete replacement config, or @file").option("--title <title>", "new title").option("--agent <name>", "name of the agent making the write").action(async (id, opts) => {
|
|
10864
|
+
knowledgeCmd.command("update <id>").description("Update a Knowledge object while preserving fields omitted from the command").option("--body <value>", "new body text, or @file; pass an empty value to clear the body").option("--config <file>", "JSON object file containing the complete replacement config, or @file").option("--title <title>", "new title").option("--agent <name>", "name of the agent making the write").option("--verified-at <date>", "re-verification date for a dated fact (YYYY-MM-DD or RFC 3339)").option("--stale-after <date>", "new re-check date for a dated fact (YYYY-MM-DD or RFC 3339)").option("--source-url <url>", "replacement verifying source").option("--deprecated", "mark a dated fact deprecated").option("--superseded-by <ref>", "id, slug or title of the Knowledge object that replaces this fact").action(async (id, opts) => {
|
|
10821
10865
|
try {
|
|
10822
|
-
|
|
10823
|
-
|
|
10866
|
+
const freshness = knowledgeFreshnessFromOptions(opts);
|
|
10867
|
+
const hasFreshness = Object.keys(freshness).length > 0;
|
|
10868
|
+
if (opts.title === void 0 && opts.body === void 0 && opts.config === void 0 && !hasFreshness) {
|
|
10869
|
+
throw new Error("provide at least one of --title, --body, --config, or a freshness option");
|
|
10870
|
+
}
|
|
10871
|
+
if (hasFreshness && opts.config !== void 0) {
|
|
10872
|
+
throw new Error("--config replaces the whole config; put freshness fields in that file instead of passing freshness options");
|
|
10824
10873
|
}
|
|
10825
10874
|
if (opts.title !== void 0 && !opts.title.trim()) {
|
|
10826
10875
|
throw new Error("title must not be empty");
|
|
@@ -10834,6 +10883,9 @@ knowledgeCmd.command("update <id>").description("Update a Knowledge object while
|
|
|
10834
10883
|
title: opts.title ?? object.title,
|
|
10835
10884
|
body_markdown: replacementBody ?? object.body_markdown,
|
|
10836
10885
|
config_json: replacementConfig ?? object.config_json,
|
|
10886
|
+
// Sent as its own field so the Knowledge service merges it and checks
|
|
10887
|
+
// the merged dates, rather than this command editing config blindly.
|
|
10888
|
+
...hasFreshness ? { freshness } : {},
|
|
10837
10889
|
expected_updated_at: object.updated_at,
|
|
10838
10890
|
agent: opts.agent
|
|
10839
10891
|
}));
|