@autohq/cli 0.1.279 → 0.1.281

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.
@@ -23353,7 +23353,7 @@ Object.assign(lookup, {
23353
23353
  // package.json
23354
23354
  var package_default = {
23355
23355
  name: "@autohq/cli",
23356
- version: "0.1.279",
23356
+ version: "0.1.281",
23357
23357
  license: "SEE LICENSE IN README.md",
23358
23358
  publishConfig: {
23359
23359
  access: "public"
@@ -28237,6 +28237,25 @@ var UsageEventRecordSchema = UsageEventSchema.extend({
28237
28237
  id: external_exports.string().trim().min(1),
28238
28238
  createdAt: external_exports.string().datetime()
28239
28239
  });
28240
+ var UsageTotalsSchema = external_exports.object({
28241
+ eventCount: NonNegativeTokenCountSchema,
28242
+ inputTokens: NonNegativeTokenCountSchema,
28243
+ outputTokens: NonNegativeTokenCountSchema,
28244
+ cacheCreationTokens: NonNegativeTokenCountSchema,
28245
+ cacheReadTokens: NonNegativeTokenCountSchema,
28246
+ totalTokens: NonNegativeTokenCountSchema,
28247
+ derivedCostUsd: NonNegativeUsdSchema
28248
+ });
28249
+ var SessionUsageModelSummarySchema = UsageTotalsSchema.extend({
28250
+ model: external_exports.string().trim().min(1)
28251
+ });
28252
+ var SessionUsageResponseSchema = external_exports.object({
28253
+ sessionId: SessionIdSchema2,
28254
+ totals: UsageTotalsSchema,
28255
+ models: external_exports.array(SessionUsageModelSummarySchema),
28256
+ firstUsageAt: external_exports.string().datetime().nullable(),
28257
+ lastUsageAt: external_exports.string().datetime().nullable()
28258
+ });
28240
28259
 
28241
28260
  // src/commands/agent-bridge/harness/output-buffer.ts
28242
28261
  var AGENT_BRIDGE_OUTPUT_DELTA_FLUSH_MS = 50;
package/dist/index.js CHANGED
@@ -20143,7 +20143,7 @@ var init_temporal = __esm({
20143
20143
  });
20144
20144
 
20145
20145
  // ../../packages/schemas/src/usage.ts
20146
- var UsageHarnessSchema, ModelCredentialFundingSourceSchema, NonNegativeTokenCountSchema, NonNegativeUsdSchema, UsageEventSchema, UsageEventRecordSchema;
20146
+ var UsageHarnessSchema, ModelCredentialFundingSourceSchema, NonNegativeTokenCountSchema, NonNegativeUsdSchema, UsageEventSchema, UsageEventRecordSchema, UsageTotalsSchema, SessionUsageModelSummarySchema, SessionUsageResponseSchema;
20147
20147
  var init_usage = __esm({
20148
20148
  "../../packages/schemas/src/usage.ts"() {
20149
20149
  "use strict";
@@ -20191,6 +20191,25 @@ var init_usage = __esm({
20191
20191
  id: external_exports.string().trim().min(1),
20192
20192
  createdAt: external_exports.string().datetime()
20193
20193
  });
20194
+ UsageTotalsSchema = external_exports.object({
20195
+ eventCount: NonNegativeTokenCountSchema,
20196
+ inputTokens: NonNegativeTokenCountSchema,
20197
+ outputTokens: NonNegativeTokenCountSchema,
20198
+ cacheCreationTokens: NonNegativeTokenCountSchema,
20199
+ cacheReadTokens: NonNegativeTokenCountSchema,
20200
+ totalTokens: NonNegativeTokenCountSchema,
20201
+ derivedCostUsd: NonNegativeUsdSchema
20202
+ });
20203
+ SessionUsageModelSummarySchema = UsageTotalsSchema.extend({
20204
+ model: external_exports.string().trim().min(1)
20205
+ });
20206
+ SessionUsageResponseSchema = external_exports.object({
20207
+ sessionId: SessionIdSchema,
20208
+ totals: UsageTotalsSchema,
20209
+ models: external_exports.array(SessionUsageModelSummarySchema),
20210
+ firstUsageAt: external_exports.string().datetime().nullable(),
20211
+ lastUsageAt: external_exports.string().datetime().nullable()
20212
+ });
20194
20213
  }
20195
20214
  });
20196
20215
 
@@ -22980,7 +22999,7 @@ var init_package = __esm({
22980
22999
  "package.json"() {
22981
23000
  package_default = {
22982
23001
  name: "@autohq/cli",
22983
- version: "0.1.279",
23002
+ version: "0.1.281",
22984
23003
  license: "SEE LICENSE IN README.md",
22985
23004
  publishConfig: {
22986
23005
  access: "public"
@@ -24164,7 +24183,12 @@ var init_helpers = __esm({
24164
24183
  "../../packages/schemas/src/project-apply-files/agent-fields/helpers.ts"() {
24165
24184
  "use strict";
24166
24185
  init_source();
24167
- CONTROL_FIELDS = /* @__PURE__ */ new Set(["import", "imports", "remove"]);
24186
+ CONTROL_FIELDS = /* @__PURE__ */ new Set([
24187
+ "import",
24188
+ "imports",
24189
+ "remove",
24190
+ "variables"
24191
+ ]);
24168
24192
  AGENT_METADATA_FIELD_KEYS = ["name", "labels", "annotations"];
24169
24193
  }
24170
24194
  });
@@ -24601,6 +24625,87 @@ var init_agent_fields = __esm({
24601
24625
  }
24602
24626
  });
24603
24627
 
24628
+ // ../../packages/schemas/src/project-apply-files/template-variables.ts
24629
+ function readVariableScope(document, path2) {
24630
+ const declared = document[VARIABLE_DECLARATIONS_FIELD];
24631
+ if (declared === void 0) {
24632
+ return /* @__PURE__ */ new Map();
24633
+ }
24634
+ if (!isRecord2(declared)) {
24635
+ throw new Error(
24636
+ `Invalid variables in ${path2}: variables must be a map of name to value`
24637
+ );
24638
+ }
24639
+ const scope = /* @__PURE__ */ new Map();
24640
+ for (const [name, value] of Object.entries(declared)) {
24641
+ if (!VARIABLE_NAME_PATTERN.test(name)) {
24642
+ throw new Error(
24643
+ `Invalid variable name "${name}" in ${path2}: names must match [A-Za-z_][A-Za-z0-9_]*`
24644
+ );
24645
+ }
24646
+ scope.set(name, coerceVariableValue(name, value, path2));
24647
+ }
24648
+ return scope;
24649
+ }
24650
+ function substituteVariables(document, scope, site) {
24651
+ if (scope.size === 0) {
24652
+ return document;
24653
+ }
24654
+ return substituteValue(document, scope, site);
24655
+ }
24656
+ function substituteValue(value, scope, site) {
24657
+ if (typeof value === "string") {
24658
+ return substituteString(value, scope, site);
24659
+ }
24660
+ if (Array.isArray(value)) {
24661
+ return value.map((item) => substituteValue(item, scope, site));
24662
+ }
24663
+ if (isRecord2(value)) {
24664
+ return Object.fromEntries(
24665
+ Object.entries(value).map(([key, nested]) => [
24666
+ key,
24667
+ substituteValue(nested, scope, site)
24668
+ ])
24669
+ );
24670
+ }
24671
+ return value;
24672
+ }
24673
+ function substituteString(value, scope, site) {
24674
+ return value.replace(VARIABLE_REFERENCE_PATTERN, (_match, name) => {
24675
+ const resolved = scope.get(name);
24676
+ if (resolved === void 0) {
24677
+ throw new Error(
24678
+ `Unresolved variable "{{ $${name} }}" in imported ${site.importPath}: declare it in the importing agent's variables (available: ${availableNames(scope)}).`
24679
+ );
24680
+ }
24681
+ return resolved;
24682
+ });
24683
+ }
24684
+ function coerceVariableValue(name, value, path2) {
24685
+ if (typeof value === "string") {
24686
+ return value;
24687
+ }
24688
+ if (typeof value === "number" || typeof value === "boolean") {
24689
+ return String(value);
24690
+ }
24691
+ throw new Error(
24692
+ `Invalid value for variable "${name}" in ${path2}: variable values must be a string, number, or boolean`
24693
+ );
24694
+ }
24695
+ function availableNames(scope) {
24696
+ return [...scope.keys()].sort().map((name) => `{{ $${name} }}`).join(", ");
24697
+ }
24698
+ var VARIABLE_DECLARATIONS_FIELD, VARIABLE_NAME_PATTERN, VARIABLE_REFERENCE_PATTERN;
24699
+ var init_template_variables = __esm({
24700
+ "../../packages/schemas/src/project-apply-files/template-variables.ts"() {
24701
+ "use strict";
24702
+ init_source();
24703
+ VARIABLE_DECLARATIONS_FIELD = "variables";
24704
+ VARIABLE_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
24705
+ VARIABLE_REFERENCE_PATTERN = /\{\{\s*\$([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g;
24706
+ }
24707
+ });
24708
+
24604
24709
  // ../../packages/schemas/src/project-apply-files/agent-authoring.ts
24605
24710
  function readApplyDocument(path2, document, fileIndex) {
24606
24711
  assertAgentAuthoringDocument(document, path2);
@@ -24628,7 +24733,8 @@ function validateAgentFragmentDocument(document, path2, context) {
24628
24733
  imported,
24629
24734
  {
24630
24735
  fileIndex: context.fileIndex,
24631
- stack: [...context.stack, normalizedPath]
24736
+ stack: [...context.stack, normalizedPath],
24737
+ variables: context.variables
24632
24738
  }
24633
24739
  );
24634
24740
  }
@@ -24665,7 +24771,8 @@ function compileAgentDocumentValue(document, path2, fileIndex) {
24665
24771
  return compileAgentDraftResources(
24666
24772
  compileAgentDocument2(document, path2, {
24667
24773
  fileIndex,
24668
- stack: []
24774
+ stack: [],
24775
+ variables: /* @__PURE__ */ new Map()
24669
24776
  }),
24670
24777
  path2
24671
24778
  );
@@ -24680,20 +24787,26 @@ function compileAgentDocument2(document, path2, context) {
24680
24787
  if (!isRecord2(document)) {
24681
24788
  throw new Error(`Invalid agent authoring file ${path2}: expected object`);
24682
24789
  }
24790
+ const variables = context.stack.length === 0 ? readVariableScope(document, normalizedPath) : context.variables;
24683
24791
  let merged = emptyAgentDraft();
24684
- for (const imported of importPaths2(document).map(
24685
- (importPath) => resolveImportPath2(importPath, normalizedPath, context.fileIndex)
24686
- )) {
24792
+ for (const importPath of importPaths2(document)) {
24793
+ const imported = resolveImportPath2(
24794
+ importPath,
24795
+ normalizedPath,
24796
+ context.fileIndex
24797
+ );
24798
+ const importedDocument = substituteVariables(
24799
+ readSingleDocument2(imported, context.fileIndex),
24800
+ variables,
24801
+ { importPath }
24802
+ );
24687
24803
  merged = mergeAgentDrafts(
24688
24804
  merged,
24689
- compileAgentDocument2(
24690
- readSingleDocument2(imported, context.fileIndex),
24691
- imported,
24692
- {
24693
- fileIndex: context.fileIndex,
24694
- stack: [...context.stack, normalizedPath]
24695
- }
24696
- )
24805
+ compileAgentDocument2(importedDocument, imported, {
24806
+ fileIndex: context.fileIndex,
24807
+ stack: [...context.stack, normalizedPath],
24808
+ variables
24809
+ })
24697
24810
  );
24698
24811
  }
24699
24812
  for (const removal of removalDirectives2(document, normalizedPath)) {
@@ -24710,6 +24823,7 @@ var init_agent_authoring = __esm({
24710
24823
  init_agent_document_merge();
24711
24824
  init_agent_fields();
24712
24825
  init_source();
24826
+ init_template_variables();
24713
24827
  }
24714
24828
  });
24715
24829
 
@@ -25097,7 +25211,8 @@ function assertValidFragmentSourceFiles(files, resourceRoot, fileIndex) {
25097
25211
  }
25098
25212
  validateAgentFragmentDocument(documents[0], file2.path, {
25099
25213
  fileIndex,
25100
- stack: []
25214
+ stack: [],
25215
+ variables: /* @__PURE__ */ new Map()
25101
25216
  });
25102
25217
  } catch (error51) {
25103
25218
  throw new Error(
@@ -25123,6 +25238,7 @@ var init_project_apply_files = __esm({
25123
25238
  init_template_injection();
25124
25239
  init_template_bump_diagnostics();
25125
25240
  init_template_staleness();
25241
+ init_template_variables();
25126
25242
  }
25127
25243
  });
25128
25244
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.279",
3
+ "version": "0.1.281",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"