@autohq/cli 0.1.247 → 0.1.248

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.
@@ -23340,7 +23340,7 @@ Object.assign(lookup, {
23340
23340
  // package.json
23341
23341
  var package_default = {
23342
23342
  name: "@autohq/cli",
23343
- version: "0.1.247",
23343
+ version: "0.1.248",
23344
23344
  license: "SEE LICENSE IN README.md",
23345
23345
  publishConfig: {
23346
23346
  access: "public"
@@ -27747,6 +27747,125 @@ var SessionCommandDispatchSignalPayloadSchema = external_exports.object({
27747
27747
  }).strict();
27748
27748
  var RealtimeRunCursorSchema = external_exports.string().regex(/^rt:(0|[1-9]\d*)$/);
27749
27749
 
27750
+ // ../../packages/schemas/src/templates/registry.ts
27751
+ function deriveLatestVersion(template) {
27752
+ const [first, ...rest] = template.versions;
27753
+ if (!first) {
27754
+ throw new Error(`Managed template ${template.name} has no versions`);
27755
+ }
27756
+ return rest.reduce(
27757
+ (latest, candidate) => compareSemver(candidate.version, latest.version) > 0 ? candidate : latest,
27758
+ first
27759
+ );
27760
+ }
27761
+ function compareSemver(left, right) {
27762
+ const leftParts = left.split(".").map((part) => Number.parseInt(part, 10));
27763
+ const rightParts = right.split(".").map((part) => Number.parseInt(part, 10));
27764
+ const length = Math.max(leftParts.length, rightParts.length);
27765
+ for (let index = 0; index < length; index += 1) {
27766
+ const diff = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);
27767
+ if (diff !== 0) {
27768
+ return diff < 0 ? -1 : 1;
27769
+ }
27770
+ }
27771
+ return 0;
27772
+ }
27773
+
27774
+ // ../../packages/schemas/src/templates/hardcoded.ts
27775
+ var ONBOARDING_FRAGMENT_V1 = [
27776
+ "# Managed onboarding fragment (@auto/onboarding). Tenant onboarding agents",
27777
+ "# import this to inherit Auto's house onboarding guidance. Tenant fields win",
27778
+ "# on merge, so house tweaks can be layered on top of this base.",
27779
+ "systemPrompt: |",
27780
+ " You are an Auto onboarding guide. Greet the user warmly, explain that Auto",
27781
+ " lets them compose agents and triggers into automated workflows from simple",
27782
+ " `.auto/` YAML, and guide them to their first deployed workflow. Keep replies",
27783
+ " short and conversational, ask one question at a time, and verify each step",
27784
+ " actually worked before telling the user it did."
27785
+ ].join("\n");
27786
+ var MANAGED_TEMPLATES = [
27787
+ {
27788
+ name: "@auto/onboarding",
27789
+ description: "Auto's house onboarding guidance, importable as a managed template.",
27790
+ versions: [
27791
+ {
27792
+ version: "1.0.0",
27793
+ files: [
27794
+ {
27795
+ path: "fragments/onboarding.yaml",
27796
+ content: ONBOARDING_FRAGMENT_V1
27797
+ }
27798
+ ]
27799
+ }
27800
+ ]
27801
+ }
27802
+ ];
27803
+ var HardcodedTemplateRegistry = class {
27804
+ templates;
27805
+ constructor(templates = MANAGED_TEMPLATES) {
27806
+ this.templates = new Map(
27807
+ templates.map((template) => [template.name, template])
27808
+ );
27809
+ }
27810
+ listTemplates() {
27811
+ return [...this.templates.values()].map(toManagedTemplate);
27812
+ }
27813
+ getTemplate(name) {
27814
+ const template = this.templates.get(name);
27815
+ return template ? toManagedTemplate(template) : void 0;
27816
+ }
27817
+ resolveVersion(name, track) {
27818
+ const template = this.requireTemplate(name);
27819
+ if (track.kind === "pinned") {
27820
+ return toTemplateVersion(this.requireVersion(template, track.version));
27821
+ }
27822
+ return deriveLatestVersion(toManagedTemplate(template));
27823
+ }
27824
+ getFiles(name, version2) {
27825
+ return this.requireVersion(this.requireTemplate(name), version2).files.map(
27826
+ toBundleFile
27827
+ );
27828
+ }
27829
+ // ---------------------------------------------------------------------------
27830
+ // Helpers
27831
+ // ---------------------------------------------------------------------------
27832
+ requireTemplate(name) {
27833
+ const template = this.templates.get(name);
27834
+ if (!template) {
27835
+ throw new Error(`Unknown managed template ${name}`);
27836
+ }
27837
+ return template;
27838
+ }
27839
+ requireVersion(template, version2) {
27840
+ const found = template.versions.find(
27841
+ (candidate) => candidate.version === version2
27842
+ );
27843
+ if (!found) {
27844
+ throw new Error(
27845
+ `Managed template ${template.name} has no version ${version2}`
27846
+ );
27847
+ }
27848
+ return found;
27849
+ }
27850
+ };
27851
+ var defaultTemplateRegistry = new HardcodedTemplateRegistry();
27852
+ function toBundleFile(file2) {
27853
+ return {
27854
+ path: file2.path,
27855
+ contentBase64: Buffer.from(file2.content, "utf8").toString("base64")
27856
+ };
27857
+ }
27858
+ function toTemplateVersion(version2) {
27859
+ return { version: version2.version, files: version2.files.map(toBundleFile) };
27860
+ }
27861
+ function toManagedTemplate(template) {
27862
+ return {
27863
+ name: template.name,
27864
+ description: template.description,
27865
+ versions: template.versions.map(toTemplateVersion)
27866
+ };
27867
+ }
27868
+
27750
27869
  // ../../packages/schemas/src/temporal.ts
27751
27870
  var ResourceReconciliationScopeSchema = external_exports.object({
27752
27871
  organizationId: external_exports.string().trim().min(1),
package/dist/index.js CHANGED
@@ -19583,6 +19583,185 @@ var init_runtimes = __esm({
19583
19583
  }
19584
19584
  });
19585
19585
 
19586
+ // ../../packages/schemas/src/templates/types.ts
19587
+ var init_types = __esm({
19588
+ "../../packages/schemas/src/templates/types.ts"() {
19589
+ "use strict";
19590
+ }
19591
+ });
19592
+
19593
+ // ../../packages/schemas/src/templates/specifier.ts
19594
+ function isTemplateImportSpecifier(importPath) {
19595
+ return importPath.startsWith("@");
19596
+ }
19597
+ function parseTemplateImportSpecifier(importPath) {
19598
+ const match = SPECIFIER_PATTERN.exec(importPath);
19599
+ if (!match) {
19600
+ throw new Error(
19601
+ `Invalid managed template import specifier: ${importPath}. Expected @scope/name[@version][/subpath].`
19602
+ );
19603
+ }
19604
+ const [, scope, name, version2, subpath] = match;
19605
+ return {
19606
+ name: `@${scope}/${name}`,
19607
+ track: version2 === void 0 || version2 === "latest" ? { kind: "latest" } : { kind: "pinned", version: version2 },
19608
+ subpath: subpath ?? ""
19609
+ };
19610
+ }
19611
+ function templateInjectionKey(name, subpath) {
19612
+ return subpath ? `${TEMPLATE_INJECTION_PREFIX}/${name}/${subpath}` : `${TEMPLATE_INJECTION_PREFIX}/${name}`;
19613
+ }
19614
+ var TEMPLATE_INJECTION_PREFIX, SPECIFIER_PATTERN;
19615
+ var init_specifier = __esm({
19616
+ "../../packages/schemas/src/templates/specifier.ts"() {
19617
+ "use strict";
19618
+ TEMPLATE_INJECTION_PREFIX = "packages";
19619
+ SPECIFIER_PATTERN = /^@([^/@\s]+)\/([^/@\s]+)(?:@([^/\s]+))?(?:\/(.+))?$/;
19620
+ }
19621
+ });
19622
+
19623
+ // ../../packages/schemas/src/templates/registry.ts
19624
+ function deriveLatestVersion(template) {
19625
+ const [first, ...rest] = template.versions;
19626
+ if (!first) {
19627
+ throw new Error(`Managed template ${template.name} has no versions`);
19628
+ }
19629
+ return rest.reduce(
19630
+ (latest, candidate) => compareSemver(candidate.version, latest.version) > 0 ? candidate : latest,
19631
+ first
19632
+ );
19633
+ }
19634
+ function compareSemver(left, right) {
19635
+ const leftParts = left.split(".").map((part) => Number.parseInt(part, 10));
19636
+ const rightParts = right.split(".").map((part) => Number.parseInt(part, 10));
19637
+ const length = Math.max(leftParts.length, rightParts.length);
19638
+ for (let index = 0; index < length; index += 1) {
19639
+ const diff = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);
19640
+ if (diff !== 0) {
19641
+ return diff < 0 ? -1 : 1;
19642
+ }
19643
+ }
19644
+ return 0;
19645
+ }
19646
+ var init_registry = __esm({
19647
+ "../../packages/schemas/src/templates/registry.ts"() {
19648
+ "use strict";
19649
+ }
19650
+ });
19651
+
19652
+ // ../../packages/schemas/src/templates/hardcoded.ts
19653
+ function toBundleFile(file2) {
19654
+ return {
19655
+ path: file2.path,
19656
+ contentBase64: Buffer.from(file2.content, "utf8").toString("base64")
19657
+ };
19658
+ }
19659
+ function toTemplateVersion(version2) {
19660
+ return { version: version2.version, files: version2.files.map(toBundleFile) };
19661
+ }
19662
+ function toManagedTemplate(template) {
19663
+ return {
19664
+ name: template.name,
19665
+ description: template.description,
19666
+ versions: template.versions.map(toTemplateVersion)
19667
+ };
19668
+ }
19669
+ var ONBOARDING_FRAGMENT_V1, MANAGED_TEMPLATES, HardcodedTemplateRegistry, defaultTemplateRegistry;
19670
+ var init_hardcoded = __esm({
19671
+ "../../packages/schemas/src/templates/hardcoded.ts"() {
19672
+ "use strict";
19673
+ init_registry();
19674
+ ONBOARDING_FRAGMENT_V1 = [
19675
+ "# Managed onboarding fragment (@auto/onboarding). Tenant onboarding agents",
19676
+ "# import this to inherit Auto's house onboarding guidance. Tenant fields win",
19677
+ "# on merge, so house tweaks can be layered on top of this base.",
19678
+ "systemPrompt: |",
19679
+ " You are an Auto onboarding guide. Greet the user warmly, explain that Auto",
19680
+ " lets them compose agents and triggers into automated workflows from simple",
19681
+ " `.auto/` YAML, and guide them to their first deployed workflow. Keep replies",
19682
+ " short and conversational, ask one question at a time, and verify each step",
19683
+ " actually worked before telling the user it did."
19684
+ ].join("\n");
19685
+ MANAGED_TEMPLATES = [
19686
+ {
19687
+ name: "@auto/onboarding",
19688
+ description: "Auto's house onboarding guidance, importable as a managed template.",
19689
+ versions: [
19690
+ {
19691
+ version: "1.0.0",
19692
+ files: [
19693
+ {
19694
+ path: "fragments/onboarding.yaml",
19695
+ content: ONBOARDING_FRAGMENT_V1
19696
+ }
19697
+ ]
19698
+ }
19699
+ ]
19700
+ }
19701
+ ];
19702
+ HardcodedTemplateRegistry = class {
19703
+ templates;
19704
+ constructor(templates = MANAGED_TEMPLATES) {
19705
+ this.templates = new Map(
19706
+ templates.map((template) => [template.name, template])
19707
+ );
19708
+ }
19709
+ listTemplates() {
19710
+ return [...this.templates.values()].map(toManagedTemplate);
19711
+ }
19712
+ getTemplate(name) {
19713
+ const template = this.templates.get(name);
19714
+ return template ? toManagedTemplate(template) : void 0;
19715
+ }
19716
+ resolveVersion(name, track) {
19717
+ const template = this.requireTemplate(name);
19718
+ if (track.kind === "pinned") {
19719
+ return toTemplateVersion(this.requireVersion(template, track.version));
19720
+ }
19721
+ return deriveLatestVersion(toManagedTemplate(template));
19722
+ }
19723
+ getFiles(name, version2) {
19724
+ return this.requireVersion(this.requireTemplate(name), version2).files.map(
19725
+ toBundleFile
19726
+ );
19727
+ }
19728
+ // ---------------------------------------------------------------------------
19729
+ // Helpers
19730
+ // ---------------------------------------------------------------------------
19731
+ requireTemplate(name) {
19732
+ const template = this.templates.get(name);
19733
+ if (!template) {
19734
+ throw new Error(`Unknown managed template ${name}`);
19735
+ }
19736
+ return template;
19737
+ }
19738
+ requireVersion(template, version2) {
19739
+ const found = template.versions.find(
19740
+ (candidate) => candidate.version === version2
19741
+ );
19742
+ if (!found) {
19743
+ throw new Error(
19744
+ `Managed template ${template.name} has no version ${version2}`
19745
+ );
19746
+ }
19747
+ return found;
19748
+ }
19749
+ };
19750
+ defaultTemplateRegistry = new HardcodedTemplateRegistry();
19751
+ }
19752
+ });
19753
+
19754
+ // ../../packages/schemas/src/templates/index.ts
19755
+ var init_templates = __esm({
19756
+ "../../packages/schemas/src/templates/index.ts"() {
19757
+ "use strict";
19758
+ init_types();
19759
+ init_specifier();
19760
+ init_registry();
19761
+ init_hardcoded();
19762
+ }
19763
+ });
19764
+
19586
19765
  // ../../packages/schemas/src/temporal.ts
19587
19766
  var ResourceReconciliationScopeSchema;
19588
19767
  var init_temporal = __esm({
@@ -19686,6 +19865,7 @@ var init_src = __esm({
19686
19865
  init_runtimes();
19687
19866
  init_sessions();
19688
19867
  init_agents();
19868
+ init_templates();
19689
19869
  init_temporal();
19690
19870
  init_tools();
19691
19871
  init_trigger_router();
@@ -22418,7 +22598,7 @@ var init_package = __esm({
22418
22598
  "package.json"() {
22419
22599
  package_default = {
22420
22600
  name: "@autohq/cli",
22421
- version: "0.1.247",
22601
+ version: "0.1.248",
22422
22602
  license: "SEE LICENSE IN README.md",
22423
22603
  publishConfig: {
22424
22604
  access: "public"
@@ -23449,6 +23629,9 @@ function importPaths2(document) {
23449
23629
  });
23450
23630
  }
23451
23631
  function resolveImportPath2(importPath, importerPath, fileIndex) {
23632
+ if (isTemplateImportSpecifier(importPath)) {
23633
+ return resolveTemplateImportPath(importPath, fileIndex);
23634
+ }
23452
23635
  if (isAbsoluteSourcePath(importPath) || /^[A-Za-z]+:\/\//.test(importPath)) {
23453
23636
  throw new Error(`Agent import must be a relative path: ${importPath}`);
23454
23637
  }
@@ -23462,6 +23645,21 @@ function resolveImportPath2(importPath, importerPath, fileIndex) {
23462
23645
  }
23463
23646
  return resolved;
23464
23647
  }
23648
+ function resolveTemplateImportPath(importPath, fileIndex) {
23649
+ const specifier = parseTemplateImportSpecifier(importPath);
23650
+ if (specifier.subpath === "") {
23651
+ throw new Error(
23652
+ `Managed template import must include a file subpath: ${importPath} (e.g. ${specifier.name}/fragments/runtime.yaml)`
23653
+ );
23654
+ }
23655
+ const key = normalizeSourcePath(
23656
+ templateInjectionKey(specifier.name, specifier.subpath)
23657
+ );
23658
+ if (!fileIndex.has(key)) {
23659
+ throw new Error(`Agent import not found: ${importPath}`);
23660
+ }
23661
+ return key;
23662
+ }
23465
23663
  function removalDirectives2(document, path2) {
23466
23664
  const raw = isRecord2(document.remove) ? document.remove : {};
23467
23665
  const directives = [];
@@ -23485,6 +23683,7 @@ function stringList2(value, label) {
23485
23683
  var init_agent_document_merge = __esm({
23486
23684
  "../../packages/schemas/src/project-apply-files/agent-document-merge.ts"() {
23487
23685
  "use strict";
23686
+ init_templates();
23488
23687
  init_source();
23489
23688
  }
23490
23689
  });
@@ -24281,6 +24480,77 @@ var init_assets = __esm({
24281
24480
  }
24282
24481
  });
24283
24482
 
24483
+ // ../../packages/schemas/src/project-apply-files/template-injection.ts
24484
+ function injectManagedTemplateFiles(input) {
24485
+ const references = collectTemplateReferences(input.files);
24486
+ if (references.size === 0) {
24487
+ return input.files;
24488
+ }
24489
+ const present = new Set(
24490
+ input.files.map((file2) => normalizeSourcePath(file2.path))
24491
+ );
24492
+ const injected = [];
24493
+ for (const reference of references.values()) {
24494
+ for (const file2 of resolveTemplateFiles(input.registry, reference)) {
24495
+ const key = normalizeSourcePath(
24496
+ templateInjectionKey(reference.name, normalizeSourcePath(file2.path))
24497
+ );
24498
+ if (present.has(key)) {
24499
+ continue;
24500
+ }
24501
+ present.add(key);
24502
+ injected.push({ path: key, contentBase64: file2.contentBase64 });
24503
+ }
24504
+ }
24505
+ return injected.length === 0 ? input.files : [...input.files, ...injected];
24506
+ }
24507
+ function resolveTemplateFiles(registry2, reference) {
24508
+ try {
24509
+ const version2 = registry2.resolveVersion(reference.name, reference.track);
24510
+ return registry2.getFiles(reference.name, version2.version);
24511
+ } catch {
24512
+ return [];
24513
+ }
24514
+ }
24515
+ function collectTemplateReferences(files) {
24516
+ const references = /* @__PURE__ */ new Map();
24517
+ for (const file2 of files) {
24518
+ for (const importPath of templateImportsInFile(file2)) {
24519
+ const specifier = parseTemplateImportSpecifier(importPath);
24520
+ if (!references.has(specifier.name)) {
24521
+ references.set(specifier.name, specifier);
24522
+ }
24523
+ }
24524
+ }
24525
+ return references;
24526
+ }
24527
+ function templateImportsInFile(file2) {
24528
+ try {
24529
+ const specifiers = [];
24530
+ for (const document of readDocumentsFromSource(file2)) {
24531
+ if (!isRecord2(document)) {
24532
+ continue;
24533
+ }
24534
+ for (const importPath of importPaths2(document)) {
24535
+ if (isTemplateImportSpecifier(importPath)) {
24536
+ specifiers.push(importPath);
24537
+ }
24538
+ }
24539
+ }
24540
+ return specifiers;
24541
+ } catch {
24542
+ return [];
24543
+ }
24544
+ }
24545
+ var init_template_injection = __esm({
24546
+ "../../packages/schemas/src/project-apply-files/template-injection.ts"() {
24547
+ "use strict";
24548
+ init_templates();
24549
+ init_agent_document_merge();
24550
+ init_source();
24551
+ }
24552
+ });
24553
+
24284
24554
  // ../../packages/schemas/src/project-apply-files/index.ts
24285
24555
  function readProjectApplyDirectorySource(input) {
24286
24556
  const resourceRoot = normalizeSourcePath(input.resourceRoot ?? "");
@@ -24431,6 +24701,7 @@ var init_project_apply_files = __esm({
24431
24701
  init_apply_result();
24432
24702
  init_assets();
24433
24703
  init_source();
24704
+ init_template_injection();
24434
24705
  }
24435
24706
  });
24436
24707
 
@@ -24467,7 +24738,9 @@ function readProjectApplyBundleInput(options) {
24467
24738
  const file2 = resolve2(options.file);
24468
24739
  const projectRoot2 = applyFileProjectRoot(file2);
24469
24740
  const sourceRoot = applyFileSourceRoot(file2, projectRoot2);
24470
- const files2 = sourceFiles(sourceRoot, projectRoot2);
24741
+ const files2 = withManagedTemplateFiles(
24742
+ sourceFiles(sourceRoot, projectRoot2)
24743
+ );
24471
24744
  const request = readProjectApplyFileSource({
24472
24745
  file: sourceFile(file2, projectRoot2),
24473
24746
  files: files2,
@@ -24486,7 +24759,7 @@ function readProjectApplyBundleInput(options) {
24486
24759
  }
24487
24760
  const directory = resolve2(options.directory ?? join7(process.cwd(), ".auto"));
24488
24761
  const projectRoot = applyProjectRoot(directory);
24489
- const files = sourceFiles(directory, projectRoot);
24762
+ const files = withManagedTemplateFiles(sourceFiles(directory, projectRoot));
24490
24763
  const resourceRoot = sourcePathRelative(projectRoot, directory);
24491
24764
  return {
24492
24765
  request: readProjectApplyDirectorySource({
@@ -24507,6 +24780,12 @@ function readProjectApplyBundleInput(options) {
24507
24780
  function serializeProjectApplyBundle(bundle) {
24508
24781
  return JSON.stringify(ProjectApplyBundleSchema.parse(bundle));
24509
24782
  }
24783
+ function withManagedTemplateFiles(files) {
24784
+ return injectManagedTemplateFiles({
24785
+ files,
24786
+ registry: defaultTemplateRegistry
24787
+ });
24788
+ }
24510
24789
  function sourceFiles(root, projectRoot) {
24511
24790
  let entries;
24512
24791
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.247",
3
+ "version": "0.1.248",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"