@erdoai/cli 0.207.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.
Files changed (2) hide show
  1. package/dist/index.js +37 -5
  2. 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";
@@ -10814,9 +10832,14 @@ declarationsCmd.command("upsert").description("Write one declaration. The same n
10814
10832
  }
10815
10833
  });
10816
10834
  var knowledgeCmd = program.command("knowledge").description("Knowledge objects");
10817
- 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("--type <type>", "snippet or skill", "snippet").option("--category <category>", "category").option("--tags <tags>", "comma-separated tags").option("--agent <name>", "name of the agent making the write").action(async (opts) => {
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) => {
10818
10840
  try {
10819
10841
  const body = readMaybeFile(opts.body) ?? "";
10842
+ const freshness = knowledgeFreshnessFromOptions(opts);
10820
10843
  print(await new ErdoClient().createKnowledge({
10821
10844
  title: opts.title,
10822
10845
  content: body,
@@ -10824,7 +10847,8 @@ knowledgeCmd.command("create").description("Create a Knowledge object").required
10824
10847
  type: opts.type,
10825
10848
  category: opts.category,
10826
10849
  tags: opts.tags?.split(",").map((tag) => tag.trim()).filter(Boolean),
10827
- agent: opts.agent
10850
+ agent: opts.agent,
10851
+ ...Object.keys(freshness).length > 0 ? { freshness } : {}
10828
10852
  }));
10829
10853
  } catch (e) {
10830
10854
  fail(e);
@@ -10837,10 +10861,15 @@ knowledgeCmd.command("get <id>").description("Get one full typed Knowledge objec
10837
10861
  fail(e);
10838
10862
  }
10839
10863
  });
10840
- 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) => {
10841
10865
  try {
10842
- if (opts.title === void 0 && opts.body === void 0 && opts.config === void 0) {
10843
- throw new Error("provide at least one of --title, --body, or --config");
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");
10844
10873
  }
10845
10874
  if (opts.title !== void 0 && !opts.title.trim()) {
10846
10875
  throw new Error("title must not be empty");
@@ -10854,6 +10883,9 @@ knowledgeCmd.command("update <id>").description("Update a Knowledge object while
10854
10883
  title: opts.title ?? object.title,
10855
10884
  body_markdown: replacementBody ?? object.body_markdown,
10856
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 } : {},
10857
10889
  expected_updated_at: object.updated_at,
10858
10890
  agent: opts.agent
10859
10891
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.207.0",
3
+ "version": "0.208.0",
4
4
  "description": "Erdo CLI \u2014 drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {