@autohq/cli 0.1.136 → 0.1.137

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.
@@ -26290,7 +26290,7 @@ Object.assign(lookup, {
26290
26290
  // package.json
26291
26291
  var package_default = {
26292
26292
  name: "@autohq/cli",
26293
- version: "0.1.136",
26293
+ version: "0.1.137",
26294
26294
  license: "SEE LICENSE IN README.md",
26295
26295
  publishConfig: {
26296
26296
  access: "public"
package/dist/index.js CHANGED
@@ -21226,7 +21226,7 @@ var init_package = __esm({
21226
21226
  "package.json"() {
21227
21227
  package_default = {
21228
21228
  name: "@autohq/cli",
21229
- version: "0.1.136",
21229
+ version: "0.1.137",
21230
21230
  license: "SEE LICENSE IN README.md",
21231
21231
  publishConfig: {
21232
21232
  access: "public"
@@ -21407,7 +21407,7 @@ import { parseAllDocuments as parseYamlDocuments, stringify } from "yaml";
21407
21407
  function compileAgentFile(path2) {
21408
21408
  const context = { graph: /* @__PURE__ */ new Map(), removals: [] };
21409
21409
  const document = readSingleDocument(path2);
21410
- const compiled = normalizeAgentDocument(
21410
+ const compiled = finalizeAgentApplyShape(
21411
21411
  compileAgentDocument(document, path2, [], context)
21412
21412
  );
21413
21413
  const parsed = ProjectApplyResourceSchema.safeParse(compiled);
@@ -21427,7 +21427,7 @@ function compileAgentFile(path2) {
21427
21427
  }
21428
21428
  function compileAgentDocumentValue(document, path2) {
21429
21429
  const context = { graph: /* @__PURE__ */ new Map(), removals: [] };
21430
- const compiled = normalizeAgentDocument(
21430
+ const compiled = finalizeAgentApplyShape(
21431
21431
  compileAgentDocument(document, path2, [], context)
21432
21432
  );
21433
21433
  const parsed = ProjectApplyResourceSchema.safeParse(compiled);
@@ -21595,7 +21595,11 @@ function compileAgentDocument(document, path2, stack, context) {
21595
21595
  merged = applyRemoval(merged, removal);
21596
21596
  context.removals.push(removal);
21597
21597
  }
21598
- return mergeValues2(merged, sanitizedAgentDocument(document), []);
21598
+ return mergeValues2(
21599
+ merged,
21600
+ authoringDocumentApplyShape(document, resolvedPath),
21601
+ []
21602
+ );
21599
21603
  }
21600
21604
  function readSingleDocument(path2) {
21601
21605
  const documents = readDocuments(path2);
@@ -21647,11 +21651,97 @@ function sanitizedAgentDocument(document) {
21647
21651
  }
21648
21652
  return next;
21649
21653
  }
21650
- function normalizeAgentDocument(document) {
21651
- if (!isRecord2(document) || "kind" in document) {
21654
+ function authoringDocumentApplyShape(document, path2) {
21655
+ const sanitized = sanitizedAgentDocument(document);
21656
+ const kind = typeof sanitized.kind === "string" ? sanitized.kind : RESOURCE_KIND_SESSION;
21657
+ const metadata = isRecord2(sanitized.metadata) ? { ...sanitized.metadata } : {};
21658
+ const spec = isRecord2(sanitized.spec) ? { ...sanitized.spec } : {};
21659
+ for (const [key, value] of Object.entries(sanitized)) {
21660
+ if (key === "kind" || key === "metadata" || key === "spec" || value === void 0) {
21661
+ continue;
21662
+ }
21663
+ if (AGENT_METADATA_FIELDS.has(key)) {
21664
+ const metadataKey = key === "name" ? "name" : key;
21665
+ assertNoDuplicateFacadeField({
21666
+ path: path2,
21667
+ field: key,
21668
+ target: `metadata.${metadataKey}`,
21669
+ targetValue: metadata[metadataKey]
21670
+ });
21671
+ metadata[metadataKey] = value;
21672
+ continue;
21673
+ }
21674
+ if (AGENT_SPEC_FIELDS.has(key)) {
21675
+ assertNoDuplicateFacadeField({
21676
+ path: path2,
21677
+ field: key,
21678
+ target: `spec.${key}`,
21679
+ targetValue: spec[key]
21680
+ });
21681
+ spec[key] = value;
21682
+ }
21683
+ }
21684
+ return {
21685
+ kind,
21686
+ metadata,
21687
+ spec: resolveFileBackedFields(spec, path2)
21688
+ };
21689
+ }
21690
+ function finalizeAgentApplyShape(document) {
21691
+ if (!isRecord2(document) || !isRecord2(document.spec)) {
21652
21692
  return document;
21653
21693
  }
21654
- return { ...document, kind: RESOURCE_KIND_SESSION };
21694
+ const next = structuredClone(document);
21695
+ const spec = next.spec;
21696
+ if (Array.isArray(spec.triggers)) {
21697
+ spec.triggers = spec.triggers.map((trigger) => {
21698
+ if (!isRecord2(trigger) || !("name" in trigger)) {
21699
+ return trigger;
21700
+ }
21701
+ const compiledTrigger = { ...trigger };
21702
+ delete compiledTrigger.name;
21703
+ return compiledTrigger;
21704
+ });
21705
+ }
21706
+ return next;
21707
+ }
21708
+ function assertNoDuplicateFacadeField(input) {
21709
+ if (input.targetValue !== void 0) {
21710
+ throw new Error(
21711
+ `Invalid agent authoring file ${input.path}: ${input.field} duplicates ${input.target}`
21712
+ );
21713
+ }
21714
+ }
21715
+ function resolveFileBackedFields(spec, path2) {
21716
+ return {
21717
+ ...spec,
21718
+ systemPrompt: resolveFileBackedString(spec.systemPrompt, {
21719
+ path: path2,
21720
+ field: "systemPrompt"
21721
+ }),
21722
+ initialPrompt: resolveFileBackedString(spec.initialPrompt, {
21723
+ path: path2,
21724
+ field: "initialPrompt"
21725
+ })
21726
+ };
21727
+ }
21728
+ function resolveFileBackedString(value, input) {
21729
+ if (!isRecord2(value) || !("file" in value)) {
21730
+ return value;
21731
+ }
21732
+ const file2 = value.file;
21733
+ if (typeof file2 !== "string" || file2.trim().length === 0) {
21734
+ throw new Error(
21735
+ `Invalid agent authoring file ${input.path}: ${input.field}.file must be a non-empty string`
21736
+ );
21737
+ }
21738
+ const filePath = file2.trim();
21739
+ if (isAbsolute(filePath) || /^[A-Za-z]+:\/\//.test(filePath)) {
21740
+ throw new Error(
21741
+ `Invalid agent authoring file ${input.path}: ${input.field}.file must be a relative path`
21742
+ );
21743
+ }
21744
+ return readFileSync3(resolve(dirname4(input.path), filePath), "utf8");
21655
21745
  }
21656
21746
  function removalDirectives(document, path2) {
21657
21747
  const raw = mergeValues2(
@@ -21691,8 +21781,7 @@ function applyRemoval(value, removal) {
21691
21781
  const spec = { ...next.spec };
21692
21782
  next.spec = spec;
21693
21783
  switch (removal.target) {
21694
- case "tools":
21695
- case "env": {
21784
+ case "tools": {
21696
21785
  if (!isRecord2(spec[removal.target])) {
21697
21786
  return next;
21698
21787
  }
@@ -21705,7 +21794,6 @@ function applyRemoval(value, removal) {
21705
21794
  spec[removal.target] = collection;
21706
21795
  return next;
21707
21796
  }
21708
- case "mounts":
21709
21797
  case "triggers": {
21710
21798
  const value2 = spec[removal.target];
21711
21799
  if (!Array.isArray(value2)) {
@@ -21721,7 +21809,7 @@ function applyRemoval(value, removal) {
21721
21809
  }
21722
21810
  default:
21723
21811
  throw new Error(
21724
- `Unsupported agent remove target "${removal.target}"; supported targets are tools, env, mounts, triggers`
21812
+ `Unsupported agent remove target "${removal.target}"; supported targets are tools, triggers`
21725
21813
  );
21726
21814
  }
21727
21815
  }
@@ -21743,8 +21831,8 @@ function mergeValues2(base, override, path2) {
21743
21831
  }
21744
21832
  function mergeArrays(base, override, path2) {
21745
21833
  const pathKey = path2.join(".");
21746
- if (pathKey !== "spec.mounts" && pathKey !== "spec.triggers") {
21747
- return [...base, ...override];
21834
+ if (!isNamedArrayMergePath(pathKey)) {
21835
+ return override;
21748
21836
  }
21749
21837
  const merged = [...base];
21750
21838
  const indexByKey = /* @__PURE__ */ new Map();
@@ -21771,6 +21859,9 @@ function mergeArrays(base, override, path2) {
21771
21859
  }
21772
21860
  return merged;
21773
21861
  }
21862
+ function isNamedArrayMergePath(path2) {
21863
+ return path2 === "spec.mounts" || path2 === "spec.triggers";
21864
+ }
21774
21865
  function collectionItemKey(collection, item) {
21775
21866
  if (!isRecord2(item)) {
21776
21867
  return void 0;
@@ -21807,12 +21898,25 @@ function isAgentFile(path2) {
21807
21898
  function isRecord2(value) {
21808
21899
  return typeof value === "object" && value !== null && !Array.isArray(value);
21809
21900
  }
21810
- var AGENT_FILE_EXTENSIONS;
21901
+ var AGENT_FILE_EXTENSIONS, AGENT_SPEC_FIELDS, AGENT_METADATA_FIELDS;
21811
21902
  var init_authoring = __esm({
21812
21903
  "src/commands/agents/authoring.ts"() {
21813
21904
  "use strict";
21814
21905
  init_src();
21815
21906
  AGENT_FILE_EXTENSIONS = [".yaml", ".yml", ".json"];
21907
+ AGENT_SPEC_FIELDS = /* @__PURE__ */ new Set([
21908
+ "harness",
21909
+ "systemPrompt",
21910
+ "environment",
21911
+ "identity",
21912
+ "initialPrompt",
21913
+ "env",
21914
+ "mounts",
21915
+ "triggers",
21916
+ "workingDirectory",
21917
+ "tools"
21918
+ ]);
21919
+ AGENT_METADATA_FIELDS = /* @__PURE__ */ new Set(["name", "labels", "annotations"]);
21816
21920
  }
21817
21921
  });
21818
21922
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.136",
3
+ "version": "0.1.137",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"