@autohq/cli 0.1.136 → 0.1.138

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.
@@ -21253,7 +21253,6 @@ var EventRoutingTriggerResultSchema = external_exports.object({
21253
21253
 
21254
21254
  // ../../packages/schemas/src/sessions.ts
21255
21255
  var RESOURCE_KIND_AGENT = "agent";
21256
- var LEGACY_RESOURCE_KIND_SESSION = "session";
21257
21256
  var RESOURCE_KIND_SESSION = RESOURCE_KIND_AGENT;
21258
21257
  var SESSION_HARNESSES = ["claude-code"];
21259
21258
  var TriggerFilterScalarSchema = external_exports.union([
@@ -21909,14 +21908,11 @@ var SessionApplyDocumentSchema = resourceApplyDocumentSchema(
21909
21908
  RESOURCE_KIND_SESSION,
21910
21909
  SessionApplyRequestSchema.shape.spec
21911
21910
  );
21912
- var ProjectApplyResourceSchema = external_exports.preprocess(
21913
- normalizeLegacySessionKind,
21914
- external_exports.discriminatedUnion("kind", [
21915
- EnvironmentApplyDocumentSchema,
21916
- IdentityApplyDocumentSchema,
21917
- SessionApplyDocumentSchema
21918
- ])
21919
- );
21911
+ var ProjectApplyResourceSchema = external_exports.discriminatedUnion("kind", [
21912
+ EnvironmentApplyDocumentSchema,
21913
+ IdentityApplyDocumentSchema,
21914
+ SessionApplyDocumentSchema
21915
+ ]);
21920
21916
  var PROJECT_RESOURCE_APPLY_ORDER = [
21921
21917
  RESOURCE_KIND_CONNECTION,
21922
21918
  RESOURCE_KIND_IDENTITY,
@@ -21932,12 +21928,9 @@ var PROJECT_APPLY_RESOURCE_KINDS = [
21932
21928
  var ProjectDeleteResourceBaseSchema = external_exports.object({
21933
21929
  name: external_exports.string().trim().min(1)
21934
21930
  });
21935
- var ProjectDeleteResourceSchema = external_exports.preprocess(
21936
- normalizeLegacySessionKind,
21937
- ProjectDeleteResourceBaseSchema.extend({
21938
- kind: external_exports.enum(PROJECT_APPLY_RESOURCE_KINDS)
21939
- })
21940
- );
21931
+ var ProjectDeleteResourceSchema = ProjectDeleteResourceBaseSchema.extend({
21932
+ kind: external_exports.enum(PROJECT_APPLY_RESOURCE_KINDS)
21933
+ });
21941
21934
  var AVATAR_ASSET_CONTENT_TYPES = ["image/png", "image/jpeg"];
21942
21935
  var MAX_AVATAR_ASSET_BASE64_LENGTH = Math.ceil(MAX_AVATAR_ASSET_BYTES / 3) * 4 + 4;
21943
21936
  var ProjectApplyAssetSchema = external_exports.object({
@@ -21993,12 +21986,6 @@ var ProjectApplyDiagnosticSchema = external_exports.object({
21993
21986
  ]),
21994
21987
  name: external_exports.string().min(1)
21995
21988
  });
21996
- var ProjectApplyResponseResourceKindSchema = external_exports.union([
21997
- external_exports.enum(PROJECT_RESOURCE_KINDS),
21998
- external_exports.literal(LEGACY_RESOURCE_KIND_SESSION)
21999
- ]).transform(
22000
- (kind) => kind === LEGACY_RESOURCE_KIND_SESSION ? RESOURCE_KIND_SESSION : kind
22001
- );
22002
21989
  var ProjectApplyResponseSchema = external_exports.object({
22003
21990
  dryRun: external_exports.boolean().default(false),
22004
21991
  resources: external_exports.array(ProjectAppliedResourceSchema),
@@ -22007,28 +21994,19 @@ var ProjectApplyResponseSchema = external_exports.object({
22007
21994
  plan: external_exports.array(
22008
21995
  external_exports.object({
22009
21996
  action: external_exports.enum(["create", "update", "unchanged", "archive"]),
22010
- kind: ProjectApplyResponseResourceKindSchema,
21997
+ kind: external_exports.enum(PROJECT_RESOURCE_KINDS),
22011
21998
  name: external_exports.string().min(1),
22012
21999
  uid: external_exports.string().min(1).optional()
22013
22000
  })
22014
22001
  ).default([]),
22015
22002
  pruned: external_exports.array(
22016
22003
  external_exports.object({
22017
- kind: ProjectApplyResponseResourceKindSchema,
22004
+ kind: external_exports.enum(PROJECT_RESOURCE_KINDS),
22018
22005
  name: external_exports.string().min(1),
22019
22006
  uid: external_exports.string().min(1)
22020
22007
  })
22021
22008
  ).default([])
22022
22009
  });
22023
- function normalizeLegacySessionKind(value2) {
22024
- if (isRecord(value2) && value2.kind === LEGACY_RESOURCE_KIND_SESSION) {
22025
- return { ...value2, kind: RESOURCE_KIND_SESSION };
22026
- }
22027
- return value2;
22028
- }
22029
- function isRecord(value2) {
22030
- return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
22031
- }
22032
22010
 
22033
22011
  // ../../packages/schemas/src/run-diagnostics.ts
22034
22012
  var RUN_DIAGNOSTIC_REALTIME_EVENT = "run.diagnostic";
@@ -26290,7 +26268,7 @@ Object.assign(lookup, {
26290
26268
  // package.json
26291
26269
  var package_default = {
26292
26270
  name: "@autohq/cli",
26293
- version: "0.1.136",
26271
+ version: "0.1.138",
26294
26272
  license: "SEE LICENSE IN README.md",
26295
26273
  publishConfig: {
26296
26274
  access: "public"
package/dist/index.js CHANGED
@@ -18062,7 +18062,7 @@ function isChatMessageEvent(trigger) {
18062
18062
  function hasFilterValue(trigger, path2, expected) {
18063
18063
  return trigger.where?.[path2] === expected;
18064
18064
  }
18065
- var RESOURCE_KIND_AGENT, LEGACY_RESOURCE_KIND_SESSION, RESOURCE_KIND_SESSION, SESSION_HARNESSES, TriggerFilterScalarSchema, TriggerFilterPathSchema, TriggerFilterClauseSchema, TriggerFilterSchema, SessionTriggerCheckTimeoutSchema, TriggerEventSchema, TriggerEventsSchema, SessionTriggerSharedFields, SessionTriggerEventSourceFields, SessionTriggerBaseSchema, SessionTriggerDefinitionBaseSchema, SessionTriggerSchema, SessionApplyTriggerSchema, SessionHeartbeatTriggerBaseSchema, SessionHeartbeatTriggerSchema, SessionApplyHeartbeatTriggerSchema, SessionTriggerDefinitionSchema, SessionApplyTriggerDefinitionSchema, SessionTriggersSchema, SessionApplyTriggersSchema, AVATAR_ASSET_EXTENSIONS, MAX_AVATAR_ASSET_BYTES, MIN_AVATAR_ASSET_DIMENSION_PX, MAX_AVATAR_ASSET_DIMENSION_PX, PNG_SIGNATURE, SESSION_IDENTITY_DESCRIPTION_MAX_LENGTH, SHA256_HEX_PATTERN, SessionIdentitySchema, SessionSpecFieldsSchema, SessionSpecSchema, SessionApplySpecSchema, SessionStatusSchema, SessionResourceSchema, SessionApplyRequestSchema, SessionApplyTriggerReceiptSchema, SessionApplyResponseSchema, SESSION_TELEGRAM_IDENTITY_STATUSES, SessionTelegramIdentityStatusSchema, SessionPresenceIdentitySchema, SessionPresenceResponseSchema, SessionPresenceConnectRequestSchema, SessionPresenceConnectPendingSchema, SessionPresenceConnectResponseSchema, SessionPresenceIconRequestSchema, SessionPresenceIconResponseSchema, SessionPresenceCompleteResponseSchema;
18065
+ var RESOURCE_KIND_AGENT, RESOURCE_KIND_SESSION, SESSION_HARNESSES, TriggerFilterScalarSchema, TriggerFilterPathSchema, TriggerFilterClauseSchema, TriggerFilterSchema, SessionTriggerCheckTimeoutSchema, TriggerEventSchema, TriggerEventsSchema, SessionTriggerSharedFields, SessionTriggerEventSourceFields, SessionTriggerBaseSchema, SessionTriggerDefinitionBaseSchema, SessionTriggerSchema, SessionApplyTriggerSchema, SessionHeartbeatTriggerBaseSchema, SessionHeartbeatTriggerSchema, SessionApplyHeartbeatTriggerSchema, SessionTriggerDefinitionSchema, SessionApplyTriggerDefinitionSchema, SessionTriggersSchema, SessionApplyTriggersSchema, AVATAR_ASSET_EXTENSIONS, MAX_AVATAR_ASSET_BYTES, MIN_AVATAR_ASSET_DIMENSION_PX, MAX_AVATAR_ASSET_DIMENSION_PX, PNG_SIGNATURE, SESSION_IDENTITY_DESCRIPTION_MAX_LENGTH, SHA256_HEX_PATTERN, SessionIdentitySchema, SessionSpecFieldsSchema, SessionSpecSchema, SessionApplySpecSchema, SessionStatusSchema, SessionResourceSchema, SessionApplyRequestSchema, SessionApplyTriggerReceiptSchema, SessionApplyResponseSchema, SESSION_TELEGRAM_IDENTITY_STATUSES, SessionTelegramIdentityStatusSchema, SessionPresenceIdentitySchema, SessionPresenceResponseSchema, SessionPresenceConnectRequestSchema, SessionPresenceConnectPendingSchema, SessionPresenceConnectResponseSchema, SessionPresenceIconRequestSchema, SessionPresenceIconResponseSchema, SessionPresenceCompleteResponseSchema;
18066
18066
  var init_sessions = __esm({
18067
18067
  "../../packages/schemas/src/sessions.ts"() {
18068
18068
  "use strict";
@@ -18075,7 +18075,6 @@ var init_sessions = __esm({
18075
18075
  init_tools();
18076
18076
  init_trigger_router();
18077
18077
  RESOURCE_KIND_AGENT = "agent";
18078
- LEGACY_RESOURCE_KIND_SESSION = "session";
18079
18078
  RESOURCE_KIND_SESSION = RESOURCE_KIND_AGENT;
18080
18079
  SESSION_HARNESSES = ["claude-code"];
18081
18080
  TriggerFilterScalarSchema = external_exports.union([
@@ -18595,16 +18594,7 @@ var init_project_service_accounts = __esm({
18595
18594
  });
18596
18595
 
18597
18596
  // ../../packages/schemas/src/project-resources.ts
18598
- function normalizeLegacySessionKind(value) {
18599
- if (isRecord(value) && value.kind === LEGACY_RESOURCE_KIND_SESSION) {
18600
- return { ...value, kind: RESOURCE_KIND_SESSION };
18601
- }
18602
- return value;
18603
- }
18604
- function isRecord(value) {
18605
- return typeof value === "object" && value !== null && !Array.isArray(value);
18606
- }
18607
- var EnvironmentApplyDocumentSchema, IdentityApplyDocumentSchema, SessionApplyDocumentSchema, ProjectApplyResourceSchema, PROJECT_RESOURCE_APPLY_ORDER, PROJECT_RESOURCE_KINDS, PROJECT_APPLY_RESOURCE_KINDS, ProjectDeleteResourceBaseSchema, ProjectDeleteResourceSchema, AVATAR_ASSET_CONTENT_TYPES, MAX_AVATAR_ASSET_BASE64_LENGTH, ProjectApplyAssetSchema, ProjectApplyAssetsSchema, AvatarAssetUploadRequestSchema, AvatarAssetUploadResponseSchema, ProjectApplyRequestSchema, ProjectApplySystemConfigSchema, ProjectAppliedResourceSchema, ProjectApplyDiagnosticSchema, ProjectApplyResponseResourceKindSchema, ProjectApplyResponseSchema;
18597
+ var EnvironmentApplyDocumentSchema, IdentityApplyDocumentSchema, SessionApplyDocumentSchema, ProjectApplyResourceSchema, PROJECT_RESOURCE_APPLY_ORDER, PROJECT_RESOURCE_KINDS, PROJECT_APPLY_RESOURCE_KINDS, ProjectDeleteResourceBaseSchema, ProjectDeleteResourceSchema, AVATAR_ASSET_CONTENT_TYPES, MAX_AVATAR_ASSET_BASE64_LENGTH, ProjectApplyAssetSchema, ProjectApplyAssetsSchema, AvatarAssetUploadRequestSchema, AvatarAssetUploadResponseSchema, ProjectApplyRequestSchema, ProjectApplySystemConfigSchema, ProjectAppliedResourceSchema, ProjectApplyDiagnosticSchema, ProjectApplyResponseSchema;
18608
18598
  var init_project_resources = __esm({
18609
18599
  "../../packages/schemas/src/project-resources.ts"() {
18610
18600
  "use strict";
@@ -18626,14 +18616,11 @@ var init_project_resources = __esm({
18626
18616
  RESOURCE_KIND_SESSION,
18627
18617
  SessionApplyRequestSchema.shape.spec
18628
18618
  );
18629
- ProjectApplyResourceSchema = external_exports.preprocess(
18630
- normalizeLegacySessionKind,
18631
- external_exports.discriminatedUnion("kind", [
18632
- EnvironmentApplyDocumentSchema,
18633
- IdentityApplyDocumentSchema,
18634
- SessionApplyDocumentSchema
18635
- ])
18636
- );
18619
+ ProjectApplyResourceSchema = external_exports.discriminatedUnion("kind", [
18620
+ EnvironmentApplyDocumentSchema,
18621
+ IdentityApplyDocumentSchema,
18622
+ SessionApplyDocumentSchema
18623
+ ]);
18637
18624
  PROJECT_RESOURCE_APPLY_ORDER = [
18638
18625
  RESOURCE_KIND_CONNECTION,
18639
18626
  RESOURCE_KIND_IDENTITY,
@@ -18649,12 +18636,9 @@ var init_project_resources = __esm({
18649
18636
  ProjectDeleteResourceBaseSchema = external_exports.object({
18650
18637
  name: external_exports.string().trim().min(1)
18651
18638
  });
18652
- ProjectDeleteResourceSchema = external_exports.preprocess(
18653
- normalizeLegacySessionKind,
18654
- ProjectDeleteResourceBaseSchema.extend({
18655
- kind: external_exports.enum(PROJECT_APPLY_RESOURCE_KINDS)
18656
- })
18657
- );
18639
+ ProjectDeleteResourceSchema = ProjectDeleteResourceBaseSchema.extend({
18640
+ kind: external_exports.enum(PROJECT_APPLY_RESOURCE_KINDS)
18641
+ });
18658
18642
  AVATAR_ASSET_CONTENT_TYPES = ["image/png", "image/jpeg"];
18659
18643
  MAX_AVATAR_ASSET_BASE64_LENGTH = Math.ceil(MAX_AVATAR_ASSET_BYTES / 3) * 4 + 4;
18660
18644
  ProjectApplyAssetSchema = external_exports.object({
@@ -18710,12 +18694,6 @@ var init_project_resources = __esm({
18710
18694
  ]),
18711
18695
  name: external_exports.string().min(1)
18712
18696
  });
18713
- ProjectApplyResponseResourceKindSchema = external_exports.union([
18714
- external_exports.enum(PROJECT_RESOURCE_KINDS),
18715
- external_exports.literal(LEGACY_RESOURCE_KIND_SESSION)
18716
- ]).transform(
18717
- (kind) => kind === LEGACY_RESOURCE_KIND_SESSION ? RESOURCE_KIND_SESSION : kind
18718
- );
18719
18697
  ProjectApplyResponseSchema = external_exports.object({
18720
18698
  dryRun: external_exports.boolean().default(false),
18721
18699
  resources: external_exports.array(ProjectAppliedResourceSchema),
@@ -18724,14 +18702,14 @@ var init_project_resources = __esm({
18724
18702
  plan: external_exports.array(
18725
18703
  external_exports.object({
18726
18704
  action: external_exports.enum(["create", "update", "unchanged", "archive"]),
18727
- kind: ProjectApplyResponseResourceKindSchema,
18705
+ kind: external_exports.enum(PROJECT_RESOURCE_KINDS),
18728
18706
  name: external_exports.string().min(1),
18729
18707
  uid: external_exports.string().min(1).optional()
18730
18708
  })
18731
18709
  ).default([]),
18732
18710
  pruned: external_exports.array(
18733
18711
  external_exports.object({
18734
- kind: ProjectApplyResponseResourceKindSchema,
18712
+ kind: external_exports.enum(PROJECT_RESOURCE_KINDS),
18735
18713
  name: external_exports.string().min(1),
18736
18714
  uid: external_exports.string().min(1)
18737
18715
  })
@@ -21226,7 +21204,7 @@ var init_package = __esm({
21226
21204
  "package.json"() {
21227
21205
  package_default = {
21228
21206
  name: "@autohq/cli",
21229
- version: "0.1.136",
21207
+ version: "0.1.138",
21230
21208
  license: "SEE LICENSE IN README.md",
21231
21209
  publishConfig: {
21232
21210
  access: "public"
@@ -21407,7 +21385,7 @@ import { parseAllDocuments as parseYamlDocuments, stringify } from "yaml";
21407
21385
  function compileAgentFile(path2) {
21408
21386
  const context = { graph: /* @__PURE__ */ new Map(), removals: [] };
21409
21387
  const document = readSingleDocument(path2);
21410
- const compiled = normalizeAgentDocument(
21388
+ const compiled = finalizeAgentApplyShape(
21411
21389
  compileAgentDocument(document, path2, [], context)
21412
21390
  );
21413
21391
  const parsed = ProjectApplyResourceSchema.safeParse(compiled);
@@ -21427,7 +21405,7 @@ function compileAgentFile(path2) {
21427
21405
  }
21428
21406
  function compileAgentDocumentValue(document, path2) {
21429
21407
  const context = { graph: /* @__PURE__ */ new Map(), removals: [] };
21430
- const compiled = normalizeAgentDocument(
21408
+ const compiled = finalizeAgentApplyShape(
21431
21409
  compileAgentDocument(document, path2, [], context)
21432
21410
  );
21433
21411
  const parsed = ProjectApplyResourceSchema.safeParse(compiled);
@@ -21548,7 +21526,7 @@ function discoverImports(document, path2, stack, imported) {
21548
21526
  `Agent import cycle detected: ${[...stack, resolvedPath].join(" -> ")}`
21549
21527
  );
21550
21528
  }
21551
- if (!isRecord2(document)) {
21529
+ if (!isRecord(document)) {
21552
21530
  return;
21553
21531
  }
21554
21532
  for (const importPath of importPaths(document)) {
@@ -21569,7 +21547,7 @@ function compileAgentDocument(document, path2, stack, context) {
21569
21547
  `Agent import cycle detected: ${[...stack, resolvedPath].join(" -> ")}`
21570
21548
  );
21571
21549
  }
21572
- if (!isRecord2(document)) {
21550
+ if (!isRecord(document)) {
21573
21551
  throw new Error(`Invalid agent authoring file ${path2}: expected object`);
21574
21552
  }
21575
21553
  const imports = importPaths(document).map(
@@ -21595,7 +21573,11 @@ function compileAgentDocument(document, path2, stack, context) {
21595
21573
  merged = applyRemoval(merged, removal);
21596
21574
  context.removals.push(removal);
21597
21575
  }
21598
- return mergeValues2(merged, sanitizedAgentDocument(document), []);
21576
+ return mergeValues2(
21577
+ merged,
21578
+ authoringDocumentApplyShape(document, resolvedPath),
21579
+ []
21580
+ );
21599
21581
  }
21600
21582
  function readSingleDocument(path2) {
21601
21583
  const documents = readDocuments(path2);
@@ -21640,26 +21622,110 @@ function sanitizedAgentDocument(document) {
21640
21622
  delete next.import;
21641
21623
  delete next.imports;
21642
21624
  delete next.remove;
21643
- if (isRecord2(next.spec) && "remove" in next.spec) {
21644
- const spec = { ...next.spec };
21645
- delete spec.remove;
21646
- next.spec = spec;
21647
- }
21648
21625
  return next;
21649
21626
  }
21650
- function normalizeAgentDocument(document) {
21651
- if (!isRecord2(document) || "kind" in document) {
21627
+ function authoringDocumentApplyShape(document, path2) {
21628
+ const sanitized = sanitizedAgentDocument(document);
21629
+ const legacyEnvelopeFields = ["kind", "metadata", "spec"].filter(
21630
+ (field) => field in sanitized
21631
+ );
21632
+ if (legacyEnvelopeFields.length > 0) {
21633
+ throw new Error(
21634
+ `Invalid agent authoring file ${path2}: legacy resource envelope fields are no longer supported (${legacyEnvelopeFields.join(", ")}). Use root-level Agent facade fields instead.`
21635
+ );
21636
+ }
21637
+ const metadata = {};
21638
+ const spec = {};
21639
+ for (const [key, value] of Object.entries(sanitized)) {
21640
+ if (key === "kind" || key === "metadata" || key === "spec" || value === void 0) {
21641
+ continue;
21642
+ }
21643
+ if (AGENT_METADATA_FIELDS.has(key)) {
21644
+ const metadataKey = key === "name" ? "name" : key;
21645
+ assertNoDuplicateFacadeField({
21646
+ path: path2,
21647
+ field: key,
21648
+ target: `metadata.${metadataKey}`,
21649
+ targetValue: metadata[metadataKey]
21650
+ });
21651
+ metadata[metadataKey] = value;
21652
+ continue;
21653
+ }
21654
+ if (AGENT_SPEC_FIELDS.has(key)) {
21655
+ assertNoDuplicateFacadeField({
21656
+ path: path2,
21657
+ field: key,
21658
+ target: `spec.${key}`,
21659
+ targetValue: spec[key]
21660
+ });
21661
+ spec[key] = value;
21662
+ }
21663
+ }
21664
+ return {
21665
+ kind: RESOURCE_KIND_SESSION,
21666
+ metadata,
21667
+ spec: resolveFileBackedFields(spec, path2)
21668
+ };
21669
+ }
21670
+ function finalizeAgentApplyShape(document) {
21671
+ if (!isRecord(document) || !isRecord(document.spec)) {
21652
21672
  return document;
21653
21673
  }
21654
- return { ...document, kind: RESOURCE_KIND_SESSION };
21674
+ const next = structuredClone(document);
21675
+ const spec = next.spec;
21676
+ if (Array.isArray(spec.triggers)) {
21677
+ spec.triggers = spec.triggers.map((trigger) => {
21678
+ if (!isRecord(trigger) || !("name" in trigger)) {
21679
+ return trigger;
21680
+ }
21681
+ const compiledTrigger = { ...trigger };
21682
+ delete compiledTrigger.name;
21683
+ return compiledTrigger;
21684
+ });
21685
+ }
21686
+ return next;
21687
+ }
21688
+ function assertNoDuplicateFacadeField(input) {
21689
+ if (input.targetValue !== void 0) {
21690
+ throw new Error(
21691
+ `Invalid agent authoring file ${input.path}: ${input.field} duplicates ${input.target}`
21692
+ );
21693
+ }
21694
+ }
21695
+ function resolveFileBackedFields(spec, path2) {
21696
+ return {
21697
+ ...spec,
21698
+ systemPrompt: resolveFileBackedString(spec.systemPrompt, {
21699
+ path: path2,
21700
+ field: "systemPrompt"
21701
+ }),
21702
+ initialPrompt: resolveFileBackedString(spec.initialPrompt, {
21703
+ path: path2,
21704
+ field: "initialPrompt"
21705
+ })
21706
+ };
21707
+ }
21708
+ function resolveFileBackedString(value, input) {
21709
+ if (!isRecord(value) || !("file" in value)) {
21710
+ return value;
21711
+ }
21712
+ const file2 = value.file;
21713
+ if (typeof file2 !== "string" || file2.trim().length === 0) {
21714
+ throw new Error(
21715
+ `Invalid agent authoring file ${input.path}: ${input.field}.file must be a non-empty string`
21716
+ );
21717
+ }
21718
+ const filePath = file2.trim();
21719
+ if (isAbsolute(filePath) || /^[A-Za-z]+:\/\//.test(filePath)) {
21720
+ throw new Error(
21721
+ `Invalid agent authoring file ${input.path}: ${input.field}.file must be a relative path`
21722
+ );
21723
+ }
21724
+ return readFileSync3(resolve(dirname4(input.path), filePath), "utf8");
21655
21725
  }
21656
21726
  function removalDirectives(document, path2) {
21657
- const raw = mergeValues2(
21658
- isRecord2(document.remove) ? document.remove : {},
21659
- isRecord2(document.spec) && isRecord2(document.spec.remove) ? document.spec.remove : {},
21660
- []
21661
- );
21662
- if (!isRecord2(raw)) {
21727
+ const raw = isRecord(document.remove) ? document.remove : {};
21728
+ if (!isRecord(raw)) {
21663
21729
  return [];
21664
21730
  }
21665
21731
  const directives = [];
@@ -21681,19 +21747,18 @@ function stringList(value, label) {
21681
21747
  });
21682
21748
  }
21683
21749
  function applyRemoval(value, removal) {
21684
- if (!isRecord2(value)) {
21750
+ if (!isRecord(value)) {
21685
21751
  return value;
21686
21752
  }
21687
21753
  const next = structuredClone(value);
21688
- if (!isRecord2(next.spec)) {
21754
+ if (!isRecord(next.spec)) {
21689
21755
  return next;
21690
21756
  }
21691
21757
  const spec = { ...next.spec };
21692
21758
  next.spec = spec;
21693
21759
  switch (removal.target) {
21694
- case "tools":
21695
- case "env": {
21696
- if (!isRecord2(spec[removal.target])) {
21760
+ case "tools": {
21761
+ if (!isRecord(spec[removal.target])) {
21697
21762
  return next;
21698
21763
  }
21699
21764
  const collection = {
@@ -21705,7 +21770,6 @@ function applyRemoval(value, removal) {
21705
21770
  spec[removal.target] = collection;
21706
21771
  return next;
21707
21772
  }
21708
- case "mounts":
21709
21773
  case "triggers": {
21710
21774
  const value2 = spec[removal.target];
21711
21775
  if (!Array.isArray(value2)) {
@@ -21721,7 +21785,7 @@ function applyRemoval(value, removal) {
21721
21785
  }
21722
21786
  default:
21723
21787
  throw new Error(
21724
- `Unsupported agent remove target "${removal.target}"; supported targets are tools, env, mounts, triggers`
21788
+ `Unsupported agent remove target "${removal.target}"; supported targets are tools, triggers`
21725
21789
  );
21726
21790
  }
21727
21791
  }
@@ -21732,7 +21796,7 @@ function mergeValues2(base, override, path2) {
21732
21796
  if (Array.isArray(base) && Array.isArray(override)) {
21733
21797
  return mergeArrays(base, override, path2);
21734
21798
  }
21735
- if (isRecord2(base) && isRecord2(override)) {
21799
+ if (isRecord(base) && isRecord(override)) {
21736
21800
  const merged = { ...base };
21737
21801
  for (const [key, value] of Object.entries(override)) {
21738
21802
  merged[key] = mergeValues2(merged[key], value, [...path2, key]);
@@ -21743,8 +21807,8 @@ function mergeValues2(base, override, path2) {
21743
21807
  }
21744
21808
  function mergeArrays(base, override, path2) {
21745
21809
  const pathKey = path2.join(".");
21746
- if (pathKey !== "spec.mounts" && pathKey !== "spec.triggers") {
21747
- return [...base, ...override];
21810
+ if (!isNamedArrayMergePath(pathKey)) {
21811
+ return override;
21748
21812
  }
21749
21813
  const merged = [...base];
21750
21814
  const indexByKey = /* @__PURE__ */ new Map();
@@ -21771,8 +21835,11 @@ function mergeArrays(base, override, path2) {
21771
21835
  }
21772
21836
  return merged;
21773
21837
  }
21838
+ function isNamedArrayMergePath(path2) {
21839
+ return path2 === "spec.mounts" || path2 === "spec.triggers";
21840
+ }
21774
21841
  function collectionItemKey(collection, item) {
21775
- if (!isRecord2(item)) {
21842
+ if (!isRecord(item)) {
21776
21843
  return void 0;
21777
21844
  }
21778
21845
  if (typeof item.name === "string") {
@@ -21804,15 +21871,28 @@ function isAgentFile(path2) {
21804
21871
  return false;
21805
21872
  }
21806
21873
  }
21807
- function isRecord2(value) {
21874
+ function isRecord(value) {
21808
21875
  return typeof value === "object" && value !== null && !Array.isArray(value);
21809
21876
  }
21810
- var AGENT_FILE_EXTENSIONS;
21877
+ var AGENT_FILE_EXTENSIONS, AGENT_SPEC_FIELDS, AGENT_METADATA_FIELDS;
21811
21878
  var init_authoring = __esm({
21812
21879
  "src/commands/agents/authoring.ts"() {
21813
21880
  "use strict";
21814
21881
  init_src();
21815
21882
  AGENT_FILE_EXTENSIONS = [".yaml", ".yml", ".json"];
21883
+ AGENT_SPEC_FIELDS = /* @__PURE__ */ new Set([
21884
+ "harness",
21885
+ "systemPrompt",
21886
+ "environment",
21887
+ "identity",
21888
+ "initialPrompt",
21889
+ "env",
21890
+ "mounts",
21891
+ "triggers",
21892
+ "workingDirectory",
21893
+ "tools"
21894
+ ]);
21895
+ AGENT_METADATA_FIELDS = /* @__PURE__ */ new Set(["name", "labels", "annotations"]);
21816
21896
  }
21817
21897
  });
21818
21898
 
@@ -21846,6 +21926,7 @@ function readProjectApplyRequest(options) {
21846
21926
  return { ...request, assets: assets2 };
21847
21927
  }
21848
21928
  const directory = options.directory ?? join4(process.cwd(), ".auto");
21929
+ assertNoLegacySessionFiles(directory);
21849
21930
  const files = applyFiles(directory);
21850
21931
  if (files.length === 0) {
21851
21932
  throw new Error(`No resource files found in ${directory}`);
@@ -21898,21 +21979,19 @@ function applyFiles(root) {
21898
21979
  const files = [];
21899
21980
  for (const kind of PROJECT_APPLY_RESOURCE_KINDS) {
21900
21981
  const kindFiles = [];
21901
- for (const directory of applyDirectories(kind)) {
21902
- const path2 = join4(root, directory);
21903
- let entries;
21904
- try {
21905
- entries = readdirSync3(path2, { withFileTypes: true });
21906
- } catch {
21907
- continue;
21908
- }
21909
- kindFiles.push(...resourceApplyFiles(path2, entries));
21982
+ const path2 = join4(root, primaryApplyDirectory(kind));
21983
+ let entries;
21984
+ try {
21985
+ entries = readdirSync3(path2, { withFileTypes: true });
21986
+ } catch {
21987
+ continue;
21910
21988
  }
21989
+ kindFiles.push(...resourceApplyFiles(path2, entries));
21911
21990
  const importedFiles = kind === RESOURCE_KIND_SESSION ? importedAgentAuthoringPaths(kindFiles) : /* @__PURE__ */ new Set();
21912
21991
  const appliedFiles = kind === RESOURCE_KIND_SESSION ? kindFiles.filter(
21913
- (path2) => !importedFiles.has(resolve2(path2)) && !isSharedAgentAuthoringFile(root, path2)
21992
+ (path3) => !importedFiles.has(resolve2(path3)) && !isSharedAgentAuthoringFile(root, path3)
21914
21993
  ) : kindFiles;
21915
- files.push(...appliedFiles.map((path2) => ({ kind, path: path2 })));
21994
+ files.push(...appliedFiles.map((path3) => ({ kind, path: path3 })));
21916
21995
  }
21917
21996
  return files;
21918
21997
  }
@@ -21921,6 +22000,22 @@ function isSharedAgentAuthoringFile(root, path2) {
21921
22000
  const resolvedPath = resolve2(path2);
21922
22001
  return resolvedPath.startsWith(`${agentsSharedRoot}/`);
21923
22002
  }
22003
+ function assertNoLegacySessionFiles(root) {
22004
+ const path2 = join4(root, "sessions");
22005
+ let entries;
22006
+ try {
22007
+ entries = readdirSync3(path2, { withFileTypes: true });
22008
+ } catch {
22009
+ return;
22010
+ }
22011
+ const files = resourceApplyFiles(path2, entries);
22012
+ if (files.length === 0) {
22013
+ return;
22014
+ }
22015
+ throw new Error(
22016
+ `Legacy .auto/sessions files are no longer supported. Move ${files.length === 1 ? "this file" : "these files"} to .auto/agents and use the root-level Agent facade format: ${files.join(", ")}`
22017
+ );
22018
+ }
21924
22019
  function mcpOAuthSessionToolConnectionsFromSessionTools(input) {
21925
22020
  return Object.entries(input.tools).flatMap(([alias, tool]) => {
21926
22021
  if (tool.kind !== "mcp_remote" || tool.disabled || tool.auth.kind !== "mcp_oauth") {
@@ -22093,23 +22188,19 @@ function isInside(path2, parent) {
22093
22188
  return path2.startsWith(`${parent}/`);
22094
22189
  }
22095
22190
  function applyCandidate(document) {
22096
- if (!isRecord3(document) || !("kind" in document)) {
22191
+ if (!isRecord2(document) || !("kind" in document)) {
22097
22192
  return { kind: RESOURCE_KIND_SESSION, value: document };
22098
22193
  }
22099
- if (document.kind === LEGACY_RESOURCE_KIND_SESSION) {
22100
- return {
22101
- kind: RESOURCE_KIND_SESSION,
22102
- value: {
22103
- metadata: document.metadata,
22104
- spec: document.spec
22105
- }
22106
- };
22194
+ if (document.kind === "session") {
22195
+ throw new Error(
22196
+ 'Legacy resource kind "session" is no longer supported. Use .auto/agents with the root-level Agent facade format.'
22197
+ );
22107
22198
  }
22108
22199
  if (!PROJECT_APPLY_RESOURCE_KINDS.includes(
22109
22200
  document.kind
22110
22201
  )) {
22111
22202
  throw new Error(
22112
- `Unsupported apply resource kind "${String(document.kind)}"; supported kinds are ${PROJECT_APPLY_RESOURCE_KINDS.map((kind2) => `"${kind2}"`).join(", ")} (legacy alias "session" is also accepted)`
22203
+ `Unsupported apply resource kind "${String(document.kind)}"; supported kinds are ${PROJECT_APPLY_RESOURCE_KINDS.map((kind2) => `"${kind2}"`).join(", ")}`
22113
22204
  );
22114
22205
  }
22115
22206
  const kind = document.kind;
@@ -22121,13 +22212,10 @@ function applyCandidate(document) {
22121
22212
  }
22122
22213
  };
22123
22214
  }
22124
- function applyDirectories(kind) {
22125
- return [...LEGACY_APPLY_DIRECTORIES[kind] ?? [], APPLY_DIRECTORIES[kind]];
22126
- }
22127
22215
  function primaryApplyDirectory(kind) {
22128
22216
  return APPLY_DIRECTORIES[kind];
22129
22217
  }
22130
- function isRecord3(value) {
22218
+ function isRecord2(value) {
22131
22219
  return typeof value === "object" && value !== null && !Array.isArray(value);
22132
22220
  }
22133
22221
  function resourceApplyFiles(directory, entries) {
@@ -22146,7 +22234,7 @@ function resourceApplyFiles(directory, entries) {
22146
22234
  }
22147
22235
  return files.sort((left, right) => left.localeCompare(right));
22148
22236
  }
22149
- var APPLY_DIRECTORIES, LEGACY_APPLY_DIRECTORIES, APPLY_SCHEMAS, ALLOWED_AVATAR_EXTENSIONS;
22237
+ var APPLY_DIRECTORIES, APPLY_SCHEMAS, ALLOWED_AVATAR_EXTENSIONS;
22150
22238
  var init_files = __esm({
22151
22239
  "src/commands/apply/files.ts"() {
22152
22240
  "use strict";
@@ -22157,9 +22245,6 @@ var init_files = __esm({
22157
22245
  identity: "identities",
22158
22246
  agent: "agents"
22159
22247
  };
22160
- LEGACY_APPLY_DIRECTORIES = {
22161
- [RESOURCE_KIND_SESSION]: ["sessions"]
22162
- };
22163
22248
  APPLY_SCHEMAS = {
22164
22249
  environment: EnvironmentApplyRequestSchema,
22165
22250
  identity: IdentityApplyRequestSchema,
@@ -22459,11 +22544,8 @@ function parseProjectResourceReference(resource) {
22459
22544
  if (!PROJECT_APPLY_RESOURCE_KINDS.includes(
22460
22545
  kind
22461
22546
  )) {
22462
- if (kind === LEGACY_RESOURCE_KIND_SESSION) {
22463
- return { kind: RESOURCE_KIND_SESSION, name };
22464
- }
22465
22547
  throw new Error(
22466
- `Unsupported resource kind "${kind}"; supported kinds are ${PROJECT_APPLY_RESOURCE_KINDS.map((value) => `"${value}"`).join(", ")} (legacy alias "session" is also accepted)`
22548
+ `Unsupported resource kind "${kind}"; supported kinds are ${PROJECT_APPLY_RESOURCE_KINDS.map((value) => `"${value}"`).join(", ")}`
22467
22549
  );
22468
22550
  }
22469
22551
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.136",
3
+ "version": "0.1.138",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"