@autohq/cli 0.1.247 → 0.1.249

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.249",
23344
23344
  license: "SEE LICENSE IN README.md",
23345
23345
  publishConfig: {
23346
23346
  access: "public"
@@ -27346,6 +27346,21 @@ var SessionTurnRecordSchema = external_exports.object({
27346
27346
  updatedAt: external_exports.string().datetime()
27347
27347
  });
27348
27348
 
27349
+ // ../../packages/schemas/src/singleton-refresh.ts
27350
+ var SINGLETON_RESPAWN_REASONS = ["refresh"];
27351
+ var SingletonRespawnReasonSchema = external_exports.enum(SINGLETON_RESPAWN_REASONS);
27352
+ var SingletonRespawnSchema = external_exports.object({
27353
+ reason: SingletonRespawnReasonSchema.default("refresh")
27354
+ }).strict();
27355
+ var SingletonRefreshEventPayloadSchema = external_exports.object({
27356
+ trigger: external_exports.literal("agent.refresh"),
27357
+ refresh: external_exports.object({
27358
+ reason: SingletonRespawnReasonSchema,
27359
+ agentResourceId: external_exports.string().trim().min(1),
27360
+ previousSessionId: external_exports.string().trim().min(1)
27361
+ })
27362
+ });
27363
+
27349
27364
  // ../../packages/schemas/src/session-commands.ts
27350
27365
  var SESSION_COMMAND_KINDS = [
27351
27366
  "message",
@@ -27454,10 +27469,15 @@ var RunAnswerCommandPayloadSchema = external_exports.object({
27454
27469
  var RunLifecycleCommandPayloadSchema = external_exports.object({
27455
27470
  reason: external_exports.string().trim().min(1).optional()
27456
27471
  }).strict();
27472
+ var RunStopCommandPayloadSchema = external_exports.object({
27473
+ reason: external_exports.string().trim().min(1).optional(),
27474
+ respawn: SingletonRespawnSchema.optional()
27475
+ }).strict();
27457
27476
  var SessionCommandPayloadSchema = external_exports.union([
27458
27477
  RunMessageCommandPayloadSchema,
27459
27478
  RunAnswerCommandPayloadSchema,
27460
- RunLifecycleCommandPayloadSchema
27479
+ RunLifecycleCommandPayloadSchema,
27480
+ RunStopCommandPayloadSchema
27461
27481
  ]);
27462
27482
  var CreateRunMessageCommandRequestSchema = external_exports.object({
27463
27483
  message: external_exports.string().trim().min(1),
@@ -27467,6 +27487,10 @@ var CreateRunAnswerCommandRequestSchema = RunAnswerCommandPayloadSchema;
27467
27487
  var CreateRunLifecycleCommandRequestSchema = external_exports.object({
27468
27488
  reason: external_exports.string().trim().min(1).optional()
27469
27489
  });
27490
+ var CreateRunStopCommandRequestSchema = external_exports.object({
27491
+ reason: external_exports.string().trim().min(1).optional(),
27492
+ respawn: SingletonRespawnSchema.optional()
27493
+ });
27470
27494
  var CreateSessionCommandRequestSchema = external_exports.discriminatedUnion("kind", [
27471
27495
  external_exports.object({
27472
27496
  kind: external_exports.literal("message"),
@@ -27494,7 +27518,7 @@ var CreateSessionCommandRequestSchema = external_exports.discriminatedUnion("kin
27494
27518
  }).strict(),
27495
27519
  external_exports.object({
27496
27520
  kind: external_exports.literal("stop"),
27497
- payload: CreateRunLifecycleCommandRequestSchema
27521
+ payload: CreateRunStopCommandRequestSchema
27498
27522
  }).strict()
27499
27523
  ]);
27500
27524
  var RunResolutionPolicySchema = external_exports.enum([
@@ -27535,6 +27559,7 @@ var SessionPersistedCommandPayloadSchema = external_exports.union([
27535
27559
  RunMessageCommandPayloadSchema,
27536
27560
  RunAnswerCommandPayloadSchema,
27537
27561
  RunLifecycleCommandPayloadSchema,
27562
+ RunStopCommandPayloadSchema,
27538
27563
  RunStartCommandPayloadSchema,
27539
27564
  RunStartWithMessageCommandPayloadSchema
27540
27565
  ]);
@@ -27565,7 +27590,7 @@ var SessionCommandRecordSchema = external_exports.discriminatedUnion("kind", [
27565
27590
  }),
27566
27591
  SessionCommandRecordBaseSchema.extend({
27567
27592
  kind: external_exports.literal("stop"),
27568
- payload: RunLifecycleCommandPayloadSchema
27593
+ payload: RunStopCommandPayloadSchema
27569
27594
  }),
27570
27595
  SessionCommandRecordBaseSchema.extend({
27571
27596
  kind: external_exports.literal("start"),
@@ -27747,6 +27772,125 @@ var SessionCommandDispatchSignalPayloadSchema = external_exports.object({
27747
27772
  }).strict();
27748
27773
  var RealtimeRunCursorSchema = external_exports.string().regex(/^rt:(0|[1-9]\d*)$/);
27749
27774
 
27775
+ // ../../packages/schemas/src/templates/registry.ts
27776
+ function deriveLatestVersion(template) {
27777
+ const [first, ...rest] = template.versions;
27778
+ if (!first) {
27779
+ throw new Error(`Managed template ${template.name} has no versions`);
27780
+ }
27781
+ return rest.reduce(
27782
+ (latest, candidate) => compareSemver(candidate.version, latest.version) > 0 ? candidate : latest,
27783
+ first
27784
+ );
27785
+ }
27786
+ function compareSemver(left, right) {
27787
+ const leftParts = left.split(".").map((part) => Number.parseInt(part, 10));
27788
+ const rightParts = right.split(".").map((part) => Number.parseInt(part, 10));
27789
+ const length = Math.max(leftParts.length, rightParts.length);
27790
+ for (let index = 0; index < length; index += 1) {
27791
+ const diff = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);
27792
+ if (diff !== 0) {
27793
+ return diff < 0 ? -1 : 1;
27794
+ }
27795
+ }
27796
+ return 0;
27797
+ }
27798
+
27799
+ // ../../packages/schemas/src/templates/hardcoded.ts
27800
+ var ONBOARDING_FRAGMENT_V1 = [
27801
+ "# Managed onboarding fragment (@auto/onboarding). Tenant onboarding agents",
27802
+ "# import this to inherit Auto's house onboarding guidance. Tenant fields win",
27803
+ "# on merge, so house tweaks can be layered on top of this base.",
27804
+ "systemPrompt: |",
27805
+ " You are an Auto onboarding guide. Greet the user warmly, explain that Auto",
27806
+ " lets them compose agents and triggers into automated workflows from simple",
27807
+ " `.auto/` YAML, and guide them to their first deployed workflow. Keep replies",
27808
+ " short and conversational, ask one question at a time, and verify each step",
27809
+ " actually worked before telling the user it did."
27810
+ ].join("\n");
27811
+ var MANAGED_TEMPLATES = [
27812
+ {
27813
+ name: "@auto/onboarding",
27814
+ description: "Auto's house onboarding guidance, importable as a managed template.",
27815
+ versions: [
27816
+ {
27817
+ version: "1.0.0",
27818
+ files: [
27819
+ {
27820
+ path: "fragments/onboarding.yaml",
27821
+ content: ONBOARDING_FRAGMENT_V1
27822
+ }
27823
+ ]
27824
+ }
27825
+ ]
27826
+ }
27827
+ ];
27828
+ var HardcodedTemplateRegistry = class {
27829
+ templates;
27830
+ constructor(templates = MANAGED_TEMPLATES) {
27831
+ this.templates = new Map(
27832
+ templates.map((template) => [template.name, template])
27833
+ );
27834
+ }
27835
+ listTemplates() {
27836
+ return [...this.templates.values()].map(toManagedTemplate);
27837
+ }
27838
+ getTemplate(name) {
27839
+ const template = this.templates.get(name);
27840
+ return template ? toManagedTemplate(template) : void 0;
27841
+ }
27842
+ resolveVersion(name, track) {
27843
+ const template = this.requireTemplate(name);
27844
+ if (track.kind === "pinned") {
27845
+ return toTemplateVersion(this.requireVersion(template, track.version));
27846
+ }
27847
+ return deriveLatestVersion(toManagedTemplate(template));
27848
+ }
27849
+ getFiles(name, version2) {
27850
+ return this.requireVersion(this.requireTemplate(name), version2).files.map(
27851
+ toBundleFile
27852
+ );
27853
+ }
27854
+ // ---------------------------------------------------------------------------
27855
+ // Helpers
27856
+ // ---------------------------------------------------------------------------
27857
+ requireTemplate(name) {
27858
+ const template = this.templates.get(name);
27859
+ if (!template) {
27860
+ throw new Error(`Unknown managed template ${name}`);
27861
+ }
27862
+ return template;
27863
+ }
27864
+ requireVersion(template, version2) {
27865
+ const found = template.versions.find(
27866
+ (candidate) => candidate.version === version2
27867
+ );
27868
+ if (!found) {
27869
+ throw new Error(
27870
+ `Managed template ${template.name} has no version ${version2}`
27871
+ );
27872
+ }
27873
+ return found;
27874
+ }
27875
+ };
27876
+ var defaultTemplateRegistry = new HardcodedTemplateRegistry();
27877
+ function toBundleFile(file2) {
27878
+ return {
27879
+ path: file2.path,
27880
+ contentBase64: Buffer.from(file2.content, "utf8").toString("base64")
27881
+ };
27882
+ }
27883
+ function toTemplateVersion(version2) {
27884
+ return { version: version2.version, files: version2.files.map(toBundleFile) };
27885
+ }
27886
+ function toManagedTemplate(template) {
27887
+ return {
27888
+ name: template.name,
27889
+ description: template.description,
27890
+ versions: template.versions.map(toTemplateVersion)
27891
+ };
27892
+ }
27893
+
27750
27894
  // ../../packages/schemas/src/temporal.ts
27751
27895
  var ResourceReconciliationScopeSchema = external_exports.object({
27752
27896
  organizationId: external_exports.string().trim().min(1),
package/dist/index.js CHANGED
@@ -19141,8 +19141,30 @@ var init_session_turns = __esm({
19141
19141
  }
19142
19142
  });
19143
19143
 
19144
+ // ../../packages/schemas/src/singleton-refresh.ts
19145
+ var SINGLETON_RESPAWN_REASONS, SingletonRespawnReasonSchema, SingletonRespawnSchema, SingletonRefreshEventPayloadSchema;
19146
+ var init_singleton_refresh = __esm({
19147
+ "../../packages/schemas/src/singleton-refresh.ts"() {
19148
+ "use strict";
19149
+ init_zod();
19150
+ SINGLETON_RESPAWN_REASONS = ["refresh"];
19151
+ SingletonRespawnReasonSchema = external_exports.enum(SINGLETON_RESPAWN_REASONS);
19152
+ SingletonRespawnSchema = external_exports.object({
19153
+ reason: SingletonRespawnReasonSchema.default("refresh")
19154
+ }).strict();
19155
+ SingletonRefreshEventPayloadSchema = external_exports.object({
19156
+ trigger: external_exports.literal("agent.refresh"),
19157
+ refresh: external_exports.object({
19158
+ reason: SingletonRespawnReasonSchema,
19159
+ agentResourceId: external_exports.string().trim().min(1),
19160
+ previousSessionId: external_exports.string().trim().min(1)
19161
+ })
19162
+ });
19163
+ }
19164
+ });
19165
+
19144
19166
  // ../../packages/schemas/src/session-commands.ts
19145
- var SESSION_COMMAND_KINDS, SESSION_DISPATCH_COMMAND_KINDS, SESSION_PERSISTED_COMMAND_KINDS, SESSION_LIFECYCLE_COMMAND_KINDS, SESSION_COMMAND_STATUSES, SESSION_DISPATCH_COMMAND_STATUSES, SessionCommandKindSchema, SessionPersistedCommandKindSchema, SessionDispatchCommandKindSchema, RunLifecycleCommandKindSchema, SessionCommandStatusSchema, SessionDispatchCommandStatusSchema, SessionCommandSenderSchema, MESSAGE_DELIVERY_MODES, MessageDeliveryModeSchema, TRIGGER_INJECTION_MODALITIES, TriggerInjectionModalitySchema, RunMessageCommandPayloadSchema, RunAnswerCommandPayloadSchema, RunLifecycleCommandPayloadSchema, SessionCommandPayloadSchema, CreateRunMessageCommandRequestSchema, CreateRunAnswerCommandRequestSchema, CreateRunLifecycleCommandRequestSchema, CreateSessionCommandRequestSchema, RunResolutionPolicySchema, AgentAddressedCommandTargetSchema, SessionCommandRecordBaseSchema, RunStartCommandPayloadSchema, RunStartWithMessageCommandPayloadSchema, SessionPersistedCommandPayloadSchema, SessionCommandRecordSchema, SessionDispatchMessageCommandPayloadSchema, SessionDispatchAnswerCommandPayloadSchema, SessionDispatchStopCommandPayloadSchema, SessionDispatchCommandPayloadSchema, SessionDispatchCommandRecordBaseSchema, SessionDispatchCommandRecordSchema;
19167
+ var SESSION_COMMAND_KINDS, SESSION_DISPATCH_COMMAND_KINDS, SESSION_PERSISTED_COMMAND_KINDS, SESSION_LIFECYCLE_COMMAND_KINDS, SESSION_COMMAND_STATUSES, SESSION_DISPATCH_COMMAND_STATUSES, SessionCommandKindSchema, SessionPersistedCommandKindSchema, SessionDispatchCommandKindSchema, RunLifecycleCommandKindSchema, SessionCommandStatusSchema, SessionDispatchCommandStatusSchema, SessionCommandSenderSchema, MESSAGE_DELIVERY_MODES, MessageDeliveryModeSchema, TRIGGER_INJECTION_MODALITIES, TriggerInjectionModalitySchema, RunMessageCommandPayloadSchema, RunAnswerCommandPayloadSchema, RunLifecycleCommandPayloadSchema, RunStopCommandPayloadSchema, SessionCommandPayloadSchema, CreateRunMessageCommandRequestSchema, CreateRunAnswerCommandRequestSchema, CreateRunLifecycleCommandRequestSchema, CreateRunStopCommandRequestSchema, CreateSessionCommandRequestSchema, RunResolutionPolicySchema, AgentAddressedCommandTargetSchema, SessionCommandRecordBaseSchema, RunStartCommandPayloadSchema, RunStartWithMessageCommandPayloadSchema, SessionPersistedCommandPayloadSchema, SessionCommandRecordSchema, SessionDispatchMessageCommandPayloadSchema, SessionDispatchAnswerCommandPayloadSchema, SessionDispatchStopCommandPayloadSchema, SessionDispatchCommandPayloadSchema, SessionDispatchCommandRecordBaseSchema, SessionDispatchCommandRecordSchema;
19146
19168
  var init_session_commands = __esm({
19147
19169
  "../../packages/schemas/src/session-commands.ts"() {
19148
19170
  "use strict";
@@ -19150,6 +19172,7 @@ var init_session_commands = __esm({
19150
19172
  init_auth();
19151
19173
  init_ids();
19152
19174
  init_primitives();
19175
+ init_singleton_refresh();
19153
19176
  SESSION_COMMAND_KINDS = [
19154
19177
  "message",
19155
19178
  "answer",
@@ -19257,10 +19280,15 @@ var init_session_commands = __esm({
19257
19280
  RunLifecycleCommandPayloadSchema = external_exports.object({
19258
19281
  reason: external_exports.string().trim().min(1).optional()
19259
19282
  }).strict();
19283
+ RunStopCommandPayloadSchema = external_exports.object({
19284
+ reason: external_exports.string().trim().min(1).optional(),
19285
+ respawn: SingletonRespawnSchema.optional()
19286
+ }).strict();
19260
19287
  SessionCommandPayloadSchema = external_exports.union([
19261
19288
  RunMessageCommandPayloadSchema,
19262
19289
  RunAnswerCommandPayloadSchema,
19263
- RunLifecycleCommandPayloadSchema
19290
+ RunLifecycleCommandPayloadSchema,
19291
+ RunStopCommandPayloadSchema
19264
19292
  ]);
19265
19293
  CreateRunMessageCommandRequestSchema = external_exports.object({
19266
19294
  message: external_exports.string().trim().min(1),
@@ -19270,6 +19298,10 @@ var init_session_commands = __esm({
19270
19298
  CreateRunLifecycleCommandRequestSchema = external_exports.object({
19271
19299
  reason: external_exports.string().trim().min(1).optional()
19272
19300
  });
19301
+ CreateRunStopCommandRequestSchema = external_exports.object({
19302
+ reason: external_exports.string().trim().min(1).optional(),
19303
+ respawn: SingletonRespawnSchema.optional()
19304
+ });
19273
19305
  CreateSessionCommandRequestSchema = external_exports.discriminatedUnion("kind", [
19274
19306
  external_exports.object({
19275
19307
  kind: external_exports.literal("message"),
@@ -19297,7 +19329,7 @@ var init_session_commands = __esm({
19297
19329
  }).strict(),
19298
19330
  external_exports.object({
19299
19331
  kind: external_exports.literal("stop"),
19300
- payload: CreateRunLifecycleCommandRequestSchema
19332
+ payload: CreateRunStopCommandRequestSchema
19301
19333
  }).strict()
19302
19334
  ]);
19303
19335
  RunResolutionPolicySchema = external_exports.enum([
@@ -19338,6 +19370,7 @@ var init_session_commands = __esm({
19338
19370
  RunMessageCommandPayloadSchema,
19339
19371
  RunAnswerCommandPayloadSchema,
19340
19372
  RunLifecycleCommandPayloadSchema,
19373
+ RunStopCommandPayloadSchema,
19341
19374
  RunStartCommandPayloadSchema,
19342
19375
  RunStartWithMessageCommandPayloadSchema
19343
19376
  ]);
@@ -19368,7 +19401,7 @@ var init_session_commands = __esm({
19368
19401
  }),
19369
19402
  SessionCommandRecordBaseSchema.extend({
19370
19403
  kind: external_exports.literal("stop"),
19371
- payload: RunLifecycleCommandPayloadSchema
19404
+ payload: RunStopCommandPayloadSchema
19372
19405
  }),
19373
19406
  SessionCommandRecordBaseSchema.extend({
19374
19407
  kind: external_exports.literal("start"),
@@ -19583,6 +19616,185 @@ var init_runtimes = __esm({
19583
19616
  }
19584
19617
  });
19585
19618
 
19619
+ // ../../packages/schemas/src/templates/types.ts
19620
+ var init_types = __esm({
19621
+ "../../packages/schemas/src/templates/types.ts"() {
19622
+ "use strict";
19623
+ }
19624
+ });
19625
+
19626
+ // ../../packages/schemas/src/templates/specifier.ts
19627
+ function isTemplateImportSpecifier(importPath) {
19628
+ return importPath.startsWith("@");
19629
+ }
19630
+ function parseTemplateImportSpecifier(importPath) {
19631
+ const match = SPECIFIER_PATTERN.exec(importPath);
19632
+ if (!match) {
19633
+ throw new Error(
19634
+ `Invalid managed template import specifier: ${importPath}. Expected @scope/name[@version][/subpath].`
19635
+ );
19636
+ }
19637
+ const [, scope, name, version2, subpath] = match;
19638
+ return {
19639
+ name: `@${scope}/${name}`,
19640
+ track: version2 === void 0 || version2 === "latest" ? { kind: "latest" } : { kind: "pinned", version: version2 },
19641
+ subpath: subpath ?? ""
19642
+ };
19643
+ }
19644
+ function templateInjectionKey(name, subpath) {
19645
+ return subpath ? `${TEMPLATE_INJECTION_PREFIX}/${name}/${subpath}` : `${TEMPLATE_INJECTION_PREFIX}/${name}`;
19646
+ }
19647
+ var TEMPLATE_INJECTION_PREFIX, SPECIFIER_PATTERN;
19648
+ var init_specifier = __esm({
19649
+ "../../packages/schemas/src/templates/specifier.ts"() {
19650
+ "use strict";
19651
+ TEMPLATE_INJECTION_PREFIX = "packages";
19652
+ SPECIFIER_PATTERN = /^@([^/@\s]+)\/([^/@\s]+)(?:@([^/\s]+))?(?:\/(.+))?$/;
19653
+ }
19654
+ });
19655
+
19656
+ // ../../packages/schemas/src/templates/registry.ts
19657
+ function deriveLatestVersion(template) {
19658
+ const [first, ...rest] = template.versions;
19659
+ if (!first) {
19660
+ throw new Error(`Managed template ${template.name} has no versions`);
19661
+ }
19662
+ return rest.reduce(
19663
+ (latest, candidate) => compareSemver(candidate.version, latest.version) > 0 ? candidate : latest,
19664
+ first
19665
+ );
19666
+ }
19667
+ function compareSemver(left, right) {
19668
+ const leftParts = left.split(".").map((part) => Number.parseInt(part, 10));
19669
+ const rightParts = right.split(".").map((part) => Number.parseInt(part, 10));
19670
+ const length = Math.max(leftParts.length, rightParts.length);
19671
+ for (let index = 0; index < length; index += 1) {
19672
+ const diff = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);
19673
+ if (diff !== 0) {
19674
+ return diff < 0 ? -1 : 1;
19675
+ }
19676
+ }
19677
+ return 0;
19678
+ }
19679
+ var init_registry = __esm({
19680
+ "../../packages/schemas/src/templates/registry.ts"() {
19681
+ "use strict";
19682
+ }
19683
+ });
19684
+
19685
+ // ../../packages/schemas/src/templates/hardcoded.ts
19686
+ function toBundleFile(file2) {
19687
+ return {
19688
+ path: file2.path,
19689
+ contentBase64: Buffer.from(file2.content, "utf8").toString("base64")
19690
+ };
19691
+ }
19692
+ function toTemplateVersion(version2) {
19693
+ return { version: version2.version, files: version2.files.map(toBundleFile) };
19694
+ }
19695
+ function toManagedTemplate(template) {
19696
+ return {
19697
+ name: template.name,
19698
+ description: template.description,
19699
+ versions: template.versions.map(toTemplateVersion)
19700
+ };
19701
+ }
19702
+ var ONBOARDING_FRAGMENT_V1, MANAGED_TEMPLATES, HardcodedTemplateRegistry, defaultTemplateRegistry;
19703
+ var init_hardcoded = __esm({
19704
+ "../../packages/schemas/src/templates/hardcoded.ts"() {
19705
+ "use strict";
19706
+ init_registry();
19707
+ ONBOARDING_FRAGMENT_V1 = [
19708
+ "# Managed onboarding fragment (@auto/onboarding). Tenant onboarding agents",
19709
+ "# import this to inherit Auto's house onboarding guidance. Tenant fields win",
19710
+ "# on merge, so house tweaks can be layered on top of this base.",
19711
+ "systemPrompt: |",
19712
+ " You are an Auto onboarding guide. Greet the user warmly, explain that Auto",
19713
+ " lets them compose agents and triggers into automated workflows from simple",
19714
+ " `.auto/` YAML, and guide them to their first deployed workflow. Keep replies",
19715
+ " short and conversational, ask one question at a time, and verify each step",
19716
+ " actually worked before telling the user it did."
19717
+ ].join("\n");
19718
+ MANAGED_TEMPLATES = [
19719
+ {
19720
+ name: "@auto/onboarding",
19721
+ description: "Auto's house onboarding guidance, importable as a managed template.",
19722
+ versions: [
19723
+ {
19724
+ version: "1.0.0",
19725
+ files: [
19726
+ {
19727
+ path: "fragments/onboarding.yaml",
19728
+ content: ONBOARDING_FRAGMENT_V1
19729
+ }
19730
+ ]
19731
+ }
19732
+ ]
19733
+ }
19734
+ ];
19735
+ HardcodedTemplateRegistry = class {
19736
+ templates;
19737
+ constructor(templates = MANAGED_TEMPLATES) {
19738
+ this.templates = new Map(
19739
+ templates.map((template) => [template.name, template])
19740
+ );
19741
+ }
19742
+ listTemplates() {
19743
+ return [...this.templates.values()].map(toManagedTemplate);
19744
+ }
19745
+ getTemplate(name) {
19746
+ const template = this.templates.get(name);
19747
+ return template ? toManagedTemplate(template) : void 0;
19748
+ }
19749
+ resolveVersion(name, track) {
19750
+ const template = this.requireTemplate(name);
19751
+ if (track.kind === "pinned") {
19752
+ return toTemplateVersion(this.requireVersion(template, track.version));
19753
+ }
19754
+ return deriveLatestVersion(toManagedTemplate(template));
19755
+ }
19756
+ getFiles(name, version2) {
19757
+ return this.requireVersion(this.requireTemplate(name), version2).files.map(
19758
+ toBundleFile
19759
+ );
19760
+ }
19761
+ // ---------------------------------------------------------------------------
19762
+ // Helpers
19763
+ // ---------------------------------------------------------------------------
19764
+ requireTemplate(name) {
19765
+ const template = this.templates.get(name);
19766
+ if (!template) {
19767
+ throw new Error(`Unknown managed template ${name}`);
19768
+ }
19769
+ return template;
19770
+ }
19771
+ requireVersion(template, version2) {
19772
+ const found = template.versions.find(
19773
+ (candidate) => candidate.version === version2
19774
+ );
19775
+ if (!found) {
19776
+ throw new Error(
19777
+ `Managed template ${template.name} has no version ${version2}`
19778
+ );
19779
+ }
19780
+ return found;
19781
+ }
19782
+ };
19783
+ defaultTemplateRegistry = new HardcodedTemplateRegistry();
19784
+ }
19785
+ });
19786
+
19787
+ // ../../packages/schemas/src/templates/index.ts
19788
+ var init_templates = __esm({
19789
+ "../../packages/schemas/src/templates/index.ts"() {
19790
+ "use strict";
19791
+ init_types();
19792
+ init_specifier();
19793
+ init_registry();
19794
+ init_hardcoded();
19795
+ }
19796
+ });
19797
+
19586
19798
  // ../../packages/schemas/src/temporal.ts
19587
19799
  var ResourceReconciliationScopeSchema;
19588
19800
  var init_temporal = __esm({
@@ -19681,11 +19893,13 @@ var init_src = __esm({
19681
19893
  init_secrets();
19682
19894
  init_session_commands();
19683
19895
  init_setup();
19896
+ init_singleton_refresh();
19684
19897
  init_runtime_log();
19685
19898
  init_runtime_log_tailer();
19686
19899
  init_runtimes();
19687
19900
  init_sessions();
19688
19901
  init_agents();
19902
+ init_templates();
19689
19903
  init_temporal();
19690
19904
  init_tools();
19691
19905
  init_trigger_router();
@@ -22418,7 +22632,7 @@ var init_package = __esm({
22418
22632
  "package.json"() {
22419
22633
  package_default = {
22420
22634
  name: "@autohq/cli",
22421
- version: "0.1.247",
22635
+ version: "0.1.249",
22422
22636
  license: "SEE LICENSE IN README.md",
22423
22637
  publishConfig: {
22424
22638
  access: "public"
@@ -23449,6 +23663,9 @@ function importPaths2(document) {
23449
23663
  });
23450
23664
  }
23451
23665
  function resolveImportPath2(importPath, importerPath, fileIndex) {
23666
+ if (isTemplateImportSpecifier(importPath)) {
23667
+ return resolveTemplateImportPath(importPath, fileIndex);
23668
+ }
23452
23669
  if (isAbsoluteSourcePath(importPath) || /^[A-Za-z]+:\/\//.test(importPath)) {
23453
23670
  throw new Error(`Agent import must be a relative path: ${importPath}`);
23454
23671
  }
@@ -23462,6 +23679,21 @@ function resolveImportPath2(importPath, importerPath, fileIndex) {
23462
23679
  }
23463
23680
  return resolved;
23464
23681
  }
23682
+ function resolveTemplateImportPath(importPath, fileIndex) {
23683
+ const specifier = parseTemplateImportSpecifier(importPath);
23684
+ if (specifier.subpath === "") {
23685
+ throw new Error(
23686
+ `Managed template import must include a file subpath: ${importPath} (e.g. ${specifier.name}/fragments/runtime.yaml)`
23687
+ );
23688
+ }
23689
+ const key = normalizeSourcePath(
23690
+ templateInjectionKey(specifier.name, specifier.subpath)
23691
+ );
23692
+ if (!fileIndex.has(key)) {
23693
+ throw new Error(`Agent import not found: ${importPath}`);
23694
+ }
23695
+ return key;
23696
+ }
23465
23697
  function removalDirectives2(document, path2) {
23466
23698
  const raw = isRecord2(document.remove) ? document.remove : {};
23467
23699
  const directives = [];
@@ -23485,6 +23717,7 @@ function stringList2(value, label) {
23485
23717
  var init_agent_document_merge = __esm({
23486
23718
  "../../packages/schemas/src/project-apply-files/agent-document-merge.ts"() {
23487
23719
  "use strict";
23720
+ init_templates();
23488
23721
  init_source();
23489
23722
  }
23490
23723
  });
@@ -24281,6 +24514,77 @@ var init_assets = __esm({
24281
24514
  }
24282
24515
  });
24283
24516
 
24517
+ // ../../packages/schemas/src/project-apply-files/template-injection.ts
24518
+ function injectManagedTemplateFiles(input) {
24519
+ const references = collectTemplateReferences(input.files);
24520
+ if (references.size === 0) {
24521
+ return input.files;
24522
+ }
24523
+ const present = new Set(
24524
+ input.files.map((file2) => normalizeSourcePath(file2.path))
24525
+ );
24526
+ const injected = [];
24527
+ for (const reference of references.values()) {
24528
+ for (const file2 of resolveTemplateFiles(input.registry, reference)) {
24529
+ const key = normalizeSourcePath(
24530
+ templateInjectionKey(reference.name, normalizeSourcePath(file2.path))
24531
+ );
24532
+ if (present.has(key)) {
24533
+ continue;
24534
+ }
24535
+ present.add(key);
24536
+ injected.push({ path: key, contentBase64: file2.contentBase64 });
24537
+ }
24538
+ }
24539
+ return injected.length === 0 ? input.files : [...input.files, ...injected];
24540
+ }
24541
+ function resolveTemplateFiles(registry2, reference) {
24542
+ try {
24543
+ const version2 = registry2.resolveVersion(reference.name, reference.track);
24544
+ return registry2.getFiles(reference.name, version2.version);
24545
+ } catch {
24546
+ return [];
24547
+ }
24548
+ }
24549
+ function collectTemplateReferences(files) {
24550
+ const references = /* @__PURE__ */ new Map();
24551
+ for (const file2 of files) {
24552
+ for (const importPath of templateImportsInFile(file2)) {
24553
+ const specifier = parseTemplateImportSpecifier(importPath);
24554
+ if (!references.has(specifier.name)) {
24555
+ references.set(specifier.name, specifier);
24556
+ }
24557
+ }
24558
+ }
24559
+ return references;
24560
+ }
24561
+ function templateImportsInFile(file2) {
24562
+ try {
24563
+ const specifiers = [];
24564
+ for (const document of readDocumentsFromSource(file2)) {
24565
+ if (!isRecord2(document)) {
24566
+ continue;
24567
+ }
24568
+ for (const importPath of importPaths2(document)) {
24569
+ if (isTemplateImportSpecifier(importPath)) {
24570
+ specifiers.push(importPath);
24571
+ }
24572
+ }
24573
+ }
24574
+ return specifiers;
24575
+ } catch {
24576
+ return [];
24577
+ }
24578
+ }
24579
+ var init_template_injection = __esm({
24580
+ "../../packages/schemas/src/project-apply-files/template-injection.ts"() {
24581
+ "use strict";
24582
+ init_templates();
24583
+ init_agent_document_merge();
24584
+ init_source();
24585
+ }
24586
+ });
24587
+
24284
24588
  // ../../packages/schemas/src/project-apply-files/index.ts
24285
24589
  function readProjectApplyDirectorySource(input) {
24286
24590
  const resourceRoot = normalizeSourcePath(input.resourceRoot ?? "");
@@ -24431,6 +24735,7 @@ var init_project_apply_files = __esm({
24431
24735
  init_apply_result();
24432
24736
  init_assets();
24433
24737
  init_source();
24738
+ init_template_injection();
24434
24739
  }
24435
24740
  });
24436
24741
 
@@ -24467,7 +24772,9 @@ function readProjectApplyBundleInput(options) {
24467
24772
  const file2 = resolve2(options.file);
24468
24773
  const projectRoot2 = applyFileProjectRoot(file2);
24469
24774
  const sourceRoot = applyFileSourceRoot(file2, projectRoot2);
24470
- const files2 = sourceFiles(sourceRoot, projectRoot2);
24775
+ const files2 = withManagedTemplateFiles(
24776
+ sourceFiles(sourceRoot, projectRoot2)
24777
+ );
24471
24778
  const request = readProjectApplyFileSource({
24472
24779
  file: sourceFile(file2, projectRoot2),
24473
24780
  files: files2,
@@ -24486,7 +24793,7 @@ function readProjectApplyBundleInput(options) {
24486
24793
  }
24487
24794
  const directory = resolve2(options.directory ?? join7(process.cwd(), ".auto"));
24488
24795
  const projectRoot = applyProjectRoot(directory);
24489
- const files = sourceFiles(directory, projectRoot);
24796
+ const files = withManagedTemplateFiles(sourceFiles(directory, projectRoot));
24490
24797
  const resourceRoot = sourcePathRelative(projectRoot, directory);
24491
24798
  return {
24492
24799
  request: readProjectApplyDirectorySource({
@@ -24507,6 +24814,12 @@ function readProjectApplyBundleInput(options) {
24507
24814
  function serializeProjectApplyBundle(bundle) {
24508
24815
  return JSON.stringify(ProjectApplyBundleSchema.parse(bundle));
24509
24816
  }
24817
+ function withManagedTemplateFiles(files) {
24818
+ return injectManagedTemplateFiles({
24819
+ files,
24820
+ registry: defaultTemplateRegistry
24821
+ });
24822
+ }
24510
24823
  function sourceFiles(root, projectRoot) {
24511
24824
  let entries;
24512
24825
  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.249",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"