lua-cli 3.17.3 → 3.17.6

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.
package/dist/index.js CHANGED
@@ -2991,10 +2991,14 @@ var init_analytics = __esm({
2991
2991
  function writeInfo(message) {
2992
2992
  process.stdout.write("\r\x1B[K" + message + "\n");
2993
2993
  }
2994
+ function writeProgress(message) {
2995
+ process.stderr.write("\r\x1B[K" + message);
2996
+ }
2994
2997
  var init_write_info = __esm({
2995
2998
  "src/utils/write-info.ts"() {
2996
2999
  "use strict";
2997
3000
  __name(writeInfo, "writeInfo");
3001
+ __name(writeProgress, "writeProgress");
2998
3002
  }
2999
3003
  });
3000
3004
 
@@ -3134,9 +3138,6 @@ function clearPromptLines(count = 1) {
3134
3138
  process.stdout.write("\x1B[1A\x1B[2K");
3135
3139
  }
3136
3140
  }
3137
- function writeProgress(message) {
3138
- process.stdout.write("\r\x1B[K" + message);
3139
- }
3140
3141
  function writeSuccess(message) {
3141
3142
  process.stdout.write("\r\x1B[K" + message + "\n");
3142
3143
  }
@@ -3159,7 +3160,6 @@ var init_cli = __esm({
3159
3160
  __name(showUpdateWarningIfNeeded, "showUpdateWarningIfNeeded");
3160
3161
  __name(withErrorHandling, "withErrorHandling");
3161
3162
  __name(clearPromptLines, "clearPromptLines");
3162
- __name(writeProgress, "writeProgress");
3163
3163
  __name(writeSuccess, "writeSuccess");
3164
3164
  __name(writeError, "writeError");
3165
3165
  }
@@ -5075,11 +5075,11 @@ var init_mcp_server_plugin = __esm({
5075
5075
  // ../shared-source-sync/dist/index.mjs
5076
5076
  import { createHash } from "crypto";
5077
5077
  import { extname } from "path";
5078
- import { readdirSync as readdirSync2, readFileSync as readFileSync7, statSync as statSync2 } from "fs";
5078
+ import { readdirSync as readdirSync2, readFileSync as readFileSync6, statSync as statSync2 } from "fs";
5079
5079
  import { join as join4, sep } from "path";
5080
5080
  import { gunzipSync, gzipSync } from "zlib";
5081
- import { existsSync as existsSync5, mkdirSync as mkdirSync6, readFileSync as readFileSync22, statSync as statSync22, writeFileSync as writeFileSync6 } from "fs";
5082
- import { dirname as dirname4, join as join22, resolve, sep as sep2 } from "path";
5081
+ import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync22, statSync as statSync22, writeFileSync as writeFileSync5 } from "fs";
5082
+ import { dirname as dirname3, join as join22, resolve, sep as sep2 } from "path";
5083
5083
  import { mkdirSync as mkdirSync22, readdirSync as readdirSync22, readFileSync as readFileSync32, statSync as statSync3, writeFileSync as writeFileSync22 } from "fs";
5084
5084
  import { dirname as dirname22, join as join32, sep as sep3 } from "path";
5085
5085
  import { gunzipSync as gunzipSync2, gzipSync as gzipSync2 } from "zlib";
@@ -5139,7 +5139,7 @@ function walkWorkspace(rootDir, opts = {}) {
5139
5139
  if (stats.size > maxBytes) continue;
5140
5140
  let content;
5141
5141
  try {
5142
- content = readFileSync7(abs);
5142
+ content = readFileSync6(abs);
5143
5143
  } catch {
5144
5144
  continue;
5145
5145
  }
@@ -5256,10 +5256,10 @@ function restoreFromBlobs(manifest, blobs, targetDir, opts = {}) {
5256
5256
  continue;
5257
5257
  }
5258
5258
  }
5259
- mkdirSync6(dirname4(targetPath), {
5259
+ mkdirSync5(dirname3(targetPath), {
5260
5260
  recursive: true
5261
5261
  });
5262
- writeFileSync6(targetPath, content);
5262
+ writeFileSync5(targetPath, content);
5263
5263
  filesWritten++;
5264
5264
  }
5265
5265
  return {
@@ -5454,12 +5454,12 @@ var init_dist2 = __esm({
5454
5454
  this.options = options;
5455
5455
  this.fetchFn = options.fetch ?? fetch;
5456
5456
  }
5457
- url(path19) {
5457
+ url(path18) {
5458
5458
  const base = this.options.baseUrl.replace(/\/$/, "");
5459
- return `${base}/developer/agents/${encodeURIComponent(this.options.agentId)}${path19}`;
5459
+ return `${base}/developer/agents/${encodeURIComponent(this.options.agentId)}${path18}`;
5460
5460
  }
5461
- async json(method, path19, body) {
5462
- const endpoint = this.url(path19);
5461
+ async json(method, path18, body) {
5462
+ const endpoint = this.url(path18);
5463
5463
  const res = await this.fetchFn(endpoint, {
5464
5464
  method,
5465
5465
  headers: {
@@ -5478,7 +5478,7 @@ var init_dist2 = __esm({
5478
5478
  } catch {
5479
5479
  text2 = void 0;
5480
5480
  }
5481
- throw new BackupHttpError(`Backup request failed: ${method} ${path19} \u2192 ${res.status} ${res.statusText}`, res.status, endpoint, text2);
5481
+ throw new BackupHttpError(`Backup request failed: ${method} ${path18} \u2192 ${res.status} ${res.statusText}`, res.status, endpoint, text2);
5482
5482
  }
5483
5483
  const text = await res.text();
5484
5484
  if (!text) return void 0;
@@ -5545,16 +5545,16 @@ var init_dist2 = __esm({
5545
5545
  });
5546
5546
 
5547
5547
  // src/compiler/utils/common.ts
5548
- import path4 from "path";
5548
+ import path3 from "path";
5549
5549
  function hashContent(content) {
5550
5550
  return hashContentTruncated(content);
5551
5551
  }
5552
5552
  function isInside(child, parent) {
5553
- const resolvedChild = path4.resolve(child);
5554
- const resolvedParent = path4.resolve(parent);
5553
+ const resolvedChild = path3.resolve(child);
5554
+ const resolvedParent = path3.resolve(parent);
5555
5555
  if (resolvedChild === resolvedParent) return true;
5556
- const rel = path4.relative(resolvedParent, resolvedChild);
5557
- return !!rel && !rel.startsWith("..") && !path4.isAbsolute(rel);
5556
+ const rel = path3.relative(resolvedParent, resolvedChild);
5557
+ return !!rel && !rel.startsWith("..") && !path3.isAbsolute(rel);
5558
5558
  }
5559
5559
  function classifyProjectFile(name) {
5560
5560
  if (name.endsWith(".ts") || name.endsWith(".tsx") || name.endsWith(".js")) {
@@ -5583,20 +5583,20 @@ var init_common = __esm({
5583
5583
  });
5584
5584
 
5585
5585
  // src/compiler/utils/path-resolver.ts
5586
- import * as fs4 from "fs";
5587
- import * as path5 from "path";
5586
+ import * as fs3 from "fs";
5587
+ import * as path4 from "path";
5588
5588
  function getTsConfigPathMappings(rootDir) {
5589
- const resolvedRoot = path5.resolve(rootDir);
5589
+ const resolvedRoot = path4.resolve(rootDir);
5590
5590
  if (mappingsCache.has(resolvedRoot)) {
5591
5591
  return mappingsCache.get(resolvedRoot) ?? null;
5592
5592
  }
5593
- const tsconfigPath = path5.join(resolvedRoot, "tsconfig.json");
5594
- if (!fs4.existsSync(tsconfigPath)) {
5593
+ const tsconfigPath = path4.join(resolvedRoot, "tsconfig.json");
5594
+ if (!fs3.existsSync(tsconfigPath)) {
5595
5595
  mappingsCache.set(resolvedRoot, null);
5596
5596
  return null;
5597
5597
  }
5598
5598
  try {
5599
- const tsconfigContent = fs4.readFileSync(tsconfigPath, "utf-8");
5599
+ const tsconfigContent = fs3.readFileSync(tsconfigPath, "utf-8");
5600
5600
  const tsconfig = JSON.parse(tsconfigContent);
5601
5601
  const compilerOptions = tsconfig.compilerOptions || {};
5602
5602
  if (compilerOptions.paths) {
@@ -5623,7 +5623,7 @@ function resolvePathAlias(specifier, rootDir) {
5623
5623
  if (match) {
5624
5624
  const captured = match[1] || "";
5625
5625
  const targetPath = targets[0].replace("*", captured);
5626
- return path5.join(mappings.rootDir, mappings.baseUrl, targetPath);
5626
+ return path4.join(mappings.rootDir, mappings.baseUrl, targetPath);
5627
5627
  }
5628
5628
  }
5629
5629
  return null;
@@ -5635,20 +5635,20 @@ function resolveModuleSpecifier(specifier, fromFile, rootDir) {
5635
5635
  return tryExtensions(aliasResolved);
5636
5636
  }
5637
5637
  if (normalized.startsWith("./") || normalized.startsWith("../")) {
5638
- const basePath = path5.resolve(path5.dirname(fromFile), normalized);
5638
+ const basePath = path4.resolve(path4.dirname(fromFile), normalized);
5639
5639
  return tryExtensions(basePath);
5640
5640
  }
5641
5641
  return void 0;
5642
5642
  }
5643
5643
  function tryExtensions(basePath) {
5644
5644
  for (const ext of MODULE_EXTENSIONS) {
5645
- const full = ext.startsWith("/") ? path5.join(basePath, ext) : basePath + ext;
5646
- if (fs4.existsSync(full)) return full;
5645
+ const full = ext.startsWith("/") ? path4.join(basePath, ext) : basePath + ext;
5646
+ if (fs3.existsSync(full)) return full;
5647
5647
  }
5648
5648
  return void 0;
5649
5649
  }
5650
5650
  function registerProjectRootDir(project, rootDir) {
5651
- projectRootDirs.set(project, path5.resolve(rootDir));
5651
+ projectRootDirs.set(project, path4.resolve(rootDir));
5652
5652
  }
5653
5653
  function getProjectRootDir(project) {
5654
5654
  return projectRootDirs.get(project);
@@ -6248,7 +6248,7 @@ var init_reference_resolver = __esm({
6248
6248
  });
6249
6249
 
6250
6250
  // src/compiler/plugins/skill.plugin.ts
6251
- import fs5 from "fs/promises";
6251
+ import fs4 from "fs/promises";
6252
6252
  import { Node as Node11 } from "ts-morph";
6253
6253
  function findEnclosingVariableDeclaration(config) {
6254
6254
  let current = config.getParent();
@@ -6581,7 +6581,7 @@ var init_skill_plugin = __esm({
6581
6581
  description: metadata.description,
6582
6582
  metadata: this.sanitizeForPersistence(metadata.metadata)
6583
6583
  }, null, 2);
6584
- const originalSource = await fs5.readFile(metadata.sourcePath, "utf-8");
6584
+ const originalSource = await fs4.readFile(metadata.sourcePath, "utf-8");
6585
6585
  return {
6586
6586
  code,
6587
6587
  sourceMap: "",
@@ -7380,10 +7380,10 @@ var init_device_trigger_plugin = __esm({
7380
7380
  });
7381
7381
 
7382
7382
  // src/compiler/utils/primitive-rewrite.ts
7383
- import { readFileSync as readFileSync9 } from "fs";
7383
+ import { readFileSync as readFileSync8 } from "fs";
7384
7384
  import { Node as Node14, Project, ts as ts3 } from "ts-morph";
7385
7385
  function rewritePrimitiveSource(metadata, opts) {
7386
- const sourceCode = readFileSync9(metadata.sourcePath, "utf-8");
7386
+ const sourceCode = readFileSync8(metadata.sourcePath, "utf-8");
7387
7387
  const localProject = new Project({
7388
7388
  useInMemoryFileSystem: true,
7389
7389
  compilerOptions: {
@@ -7722,7 +7722,7 @@ var init_cross_file_specs = __esm({
7722
7722
  });
7723
7723
 
7724
7724
  // src/compiler/plugins/voice.plugin.ts
7725
- import fs6 from "fs/promises";
7725
+ import fs5 from "fs/promises";
7726
7726
  import { Node as Node15 } from "ts-morph";
7727
7727
  function astObjectToPlain(obj) {
7728
7728
  const result = {};
@@ -8266,8 +8266,8 @@ var init_voice_plugin = __esm({
8266
8266
  }, "isMissingTopLevelRequired");
8267
8267
  for (const issue of parsed.error.issues) {
8268
8268
  if (isMissingTopLevelRequired(issue)) continue;
8269
- const path19 = issue.path.length > 0 ? issue.path.join(".") : "<root>";
8270
- errors.push(validationError(`Voice config invalid at \`${path19}\`: ${issue.message}`, {
8269
+ const path18 = issue.path.length > 0 ? issue.path.join(".") : "<root>";
8270
+ errors.push(validationError(`Voice config invalid at \`${path18}\`: ${issue.message}`, {
8271
8271
  line
8272
8272
  }));
8273
8273
  }
@@ -8348,7 +8348,7 @@ var init_voice_plugin = __esm({
8348
8348
  description: metadata.description,
8349
8349
  metadata: sanitized
8350
8350
  }, null, 2);
8351
- const originalSource = await fs6.readFile(metadata.sourcePath, "utf-8");
8351
+ const originalSource = await fs5.readFile(metadata.sourcePath, "utf-8");
8352
8352
  return {
8353
8353
  code,
8354
8354
  sourceMap: "",
@@ -8502,8 +8502,8 @@ var init_registry = __esm({
8502
8502
  });
8503
8503
 
8504
8504
  // src/compiler/bundler.ts
8505
- import fs7 from "fs/promises";
8506
- import path6 from "path";
8505
+ import fs6 from "fs/promises";
8506
+ import path5 from "path";
8507
8507
  import crypto4 from "crypto";
8508
8508
  import { build } from "esbuild";
8509
8509
  var Bundler;
@@ -8572,9 +8572,9 @@ var init_bundler = __esm({
8572
8572
  * Bundle a primitive's entry point using esbuild.
8573
8573
  */
8574
8574
  async bundle(metadata, entryPointCode) {
8575
- const tempDir = path6.join(this.options.outDir, ".temp");
8576
- const outfile = path6.join(tempDir, `${metadata.kind}-${metadata.name}.bundle.js`);
8577
- const sourceDir = path6.dirname(metadata.sourcePath);
8575
+ const tempDir = path5.join(this.options.outDir, ".temp");
8576
+ const outfile = path5.join(tempDir, `${metadata.kind}-${metadata.name}.bundle.js`);
8577
+ const sourceDir = path5.dirname(metadata.sourcePath);
8578
8578
  if (this.options.debug) {
8579
8579
  this.verbose(` Source: ${metadata.sourcePath}`);
8580
8580
  this.verbose(` Output: ${outfile}`);
@@ -8604,15 +8604,15 @@ var init_bundler = __esm({
8604
8604
  ],
8605
8605
  logLevel: this.options.debug ? "debug" : "silent"
8606
8606
  });
8607
- const code = await fs7.readFile(outfile, "utf-8");
8607
+ const code = await fs6.readFile(outfile, "utf-8");
8608
8608
  let sourceMap = "";
8609
8609
  try {
8610
- sourceMap = await fs7.readFile(outfile + ".map", "utf-8");
8610
+ sourceMap = await fs6.readFile(outfile + ".map", "utf-8");
8611
8611
  } catch {
8612
8612
  }
8613
- const originalSource = await fs7.readFile(metadata.sourcePath, "utf-8");
8613
+ const originalSource = await fs6.readFile(metadata.sourcePath, "utf-8");
8614
8614
  const hash = crypto4.createHash("sha256").update(code).digest("hex").slice(0, 16);
8615
- const stats = await fs7.stat(outfile);
8615
+ const stats = await fs6.stat(outfile);
8616
8616
  return {
8617
8617
  code,
8618
8618
  sourceMap,
@@ -8629,14 +8629,14 @@ var init_bundler = __esm({
8629
8629
  const bundler = this;
8630
8630
  const sourcePath = metadata.sourcePath;
8631
8631
  const exportName = metadata.exportName;
8632
- const sourceDir = path6.dirname(sourcePath);
8632
+ const sourceDir = path5.dirname(sourcePath);
8633
8633
  return {
8634
8634
  name: "lua-virtual-source",
8635
8635
  setup(build2) {
8636
8636
  build2.onResolve({
8637
8637
  filter: /.*/
8638
8638
  }, (args2) => {
8639
- const resolved = args2.path.startsWith(".") ? path6.resolve(args2.resolveDir, args2.path) : args2.path;
8639
+ const resolved = args2.path.startsWith(".") ? path5.resolve(args2.resolveDir, args2.path) : args2.path;
8640
8640
  const normalizedResolved = resolved.replace(/\.(ts|tsx|js|jsx)$/, "");
8641
8641
  const normalizedSource = sourcePath.replace(/\.(ts|tsx|js|jsx)$/, "");
8642
8642
  if (normalizedResolved === normalizedSource) {
@@ -8652,8 +8652,8 @@ var init_bundler = __esm({
8652
8652
  namespace: "lua-virtual-source"
8653
8653
  }, async () => {
8654
8654
  const sourceFile = bundler.project.getSourceFile(sourcePath);
8655
- let content = sourceFile?.getText() ?? await fs7.readFile(sourcePath, "utf-8");
8656
- content = bundler.stripLuaCliImportsAST(content, path6.basename(sourcePath));
8655
+ let content = sourceFile?.getText() ?? await fs6.readFile(sourcePath, "utf-8");
8656
+ content = bundler.stripLuaCliImportsAST(content, path5.basename(sourcePath));
8657
8657
  const virtualContent = metadata.isDefaultExport ? content : `${content}
8658
8658
  export { ${exportName} as __lua_target__ };
8659
8659
  `;
@@ -8681,17 +8681,17 @@ export { ${exportName} as __lua_target__ };
8681
8681
  namespace: "file"
8682
8682
  }, async (args2) => {
8683
8683
  if (args2.path.includes("node_modules")) return null;
8684
- const contents = await fs7.readFile(args2.path, "utf-8");
8684
+ const contents = await fs6.readFile(args2.path, "utf-8");
8685
8685
  if (!contents.includes("lua-cli") && !contents.includes("api-exports")) {
8686
8686
  return null;
8687
8687
  }
8688
8688
  try {
8689
- const modifiedContents = stripImports(contents, path6.basename(args2.path));
8689
+ const modifiedContents = stripImports(contents, path5.basename(args2.path));
8690
8690
  if (modifiedContents !== contents) {
8691
8691
  return {
8692
8692
  contents: modifiedContents,
8693
8693
  loader: args2.path.endsWith(".ts") || args2.path.endsWith(".tsx") ? "ts" : "js",
8694
- resolveDir: path6.dirname(args2.path)
8694
+ resolveDir: path5.dirname(args2.path)
8695
8695
  };
8696
8696
  }
8697
8697
  return null;
@@ -8728,8 +8728,8 @@ export { ${exportName} as __lua_target__ };
8728
8728
 
8729
8729
  // src/compiler/agent-traverser.ts
8730
8730
  import { Project as Project2, Node as Node16 } from "ts-morph";
8731
- import path7 from "path";
8732
- import fs8 from "fs";
8731
+ import path6 from "path";
8732
+ import fs7 from "fs";
8733
8733
  var PRIMITIVE_TYPES, AgentTraverser;
8734
8734
  var init_agent_traverser = __esm({
8735
8735
  "src/compiler/agent-traverser.ts"() {
@@ -8802,7 +8802,7 @@ var init_agent_traverser = __esm({
8802
8802
  this.rootDir = rootDir;
8803
8803
  this.debug = debug;
8804
8804
  this.project = new Project2({
8805
- tsConfigFilePath: path7.join(rootDir, "tsconfig.json"),
8805
+ tsConfigFilePath: path6.join(rootDir, "tsconfig.json"),
8806
8806
  skipAddingFilesFromTsConfig: true
8807
8807
  });
8808
8808
  registerProjectRootDir(this.project, this.rootDir);
@@ -8886,15 +8886,15 @@ var init_agent_traverser = __esm({
8886
8886
  */
8887
8887
  detectAgent() {
8888
8888
  const priorityFiles = [
8889
- path7.join(this.rootDir, "index.ts"),
8890
- path7.join(this.rootDir, "src", "index.ts"),
8891
- path7.join(this.rootDir, "agent.ts"),
8892
- path7.join(this.rootDir, "src", "agent.ts"),
8893
- path7.join(this.rootDir, "main.ts"),
8894
- path7.join(this.rootDir, "src", "main.ts")
8889
+ path6.join(this.rootDir, "index.ts"),
8890
+ path6.join(this.rootDir, "src", "index.ts"),
8891
+ path6.join(this.rootDir, "agent.ts"),
8892
+ path6.join(this.rootDir, "src", "agent.ts"),
8893
+ path6.join(this.rootDir, "main.ts"),
8894
+ path6.join(this.rootDir, "src", "main.ts")
8895
8895
  ];
8896
8896
  for (const filePath of priorityFiles) {
8897
- if (fs8.existsSync(filePath)) {
8897
+ if (fs7.existsSync(filePath)) {
8898
8898
  try {
8899
8899
  const sourceFile = this.project.addSourceFileAtPath(filePath);
8900
8900
  const agent = this.detectAgentInFile(sourceFile);
@@ -9046,7 +9046,7 @@ var init_agent_traverser = __esm({
9046
9046
  console.warn(formatSarifWarning({
9047
9047
  ruleId: "lua/missing-primitive-declaration",
9048
9048
  filePath: sourcePath,
9049
- message: `agent references ${kind} "${refName}" but ${path7.basename(sourcePath)} does not define a matching primitive`,
9049
+ message: `agent references ${kind} "${refName}" but ${path6.basename(sourcePath)} does not define a matching primitive`,
9050
9050
  hint: `export a named ${plugin.displayName.toLowerCase()} declaration as "${refName}", or adjust the import so it points to the file that does`
9051
9051
  }));
9052
9052
  return null;
@@ -9066,20 +9066,20 @@ var init_agent_traverser = __esm({
9066
9066
  });
9067
9067
 
9068
9068
  // src/compiler/utils/workspace.ts
9069
- import fs9 from "fs";
9070
- import path8 from "path";
9069
+ import fs8 from "fs";
9070
+ import path7 from "path";
9071
9071
  function findWorkspaceRoot(rootDir) {
9072
- const resolvedInput = path8.resolve(rootDir);
9072
+ const resolvedInput = path7.resolve(rootDir);
9073
9073
  const cached = workspaceRootCache.get(resolvedInput);
9074
9074
  if (cached !== void 0) return cached;
9075
9075
  let current = resolvedInput;
9076
- const { root } = path8.parse(current);
9076
+ const { root } = path7.parse(current);
9077
9077
  while (true) {
9078
9078
  if (isWorkspaceRoot(current)) {
9079
9079
  workspaceRootCache.set(resolvedInput, current);
9080
9080
  return current;
9081
9081
  }
9082
- const parent = path8.dirname(current);
9082
+ const parent = path7.dirname(current);
9083
9083
  if (parent === current || current === root) break;
9084
9084
  current = parent;
9085
9085
  }
@@ -9087,22 +9087,22 @@ function findWorkspaceRoot(rootDir) {
9087
9087
  return resolvedInput;
9088
9088
  }
9089
9089
  function isWorkspaceRoot(dir) {
9090
- if (fileExists(path8.join(dir, "pnpm-workspace.yaml"))) return true;
9091
- if (fileExists(path8.join(dir, "lerna.json"))) return true;
9092
- if (packageJsonHasWorkspaces(path8.join(dir, "package.json"))) return true;
9093
- if (dirExists(path8.join(dir, ".git"))) return true;
9090
+ if (fileExists(path7.join(dir, "pnpm-workspace.yaml"))) return true;
9091
+ if (fileExists(path7.join(dir, "lerna.json"))) return true;
9092
+ if (packageJsonHasWorkspaces(path7.join(dir, "package.json"))) return true;
9093
+ if (dirExists(path7.join(dir, ".git"))) return true;
9094
9094
  return false;
9095
9095
  }
9096
9096
  function fileExists(p) {
9097
9097
  try {
9098
- return fs9.statSync(p).isFile();
9098
+ return fs8.statSync(p).isFile();
9099
9099
  } catch {
9100
9100
  return false;
9101
9101
  }
9102
9102
  }
9103
9103
  function dirExists(p) {
9104
9104
  try {
9105
- return fs9.statSync(p).isDirectory();
9105
+ return fs8.statSync(p).isDirectory();
9106
9106
  } catch {
9107
9107
  return false;
9108
9108
  }
@@ -9110,7 +9110,7 @@ function dirExists(p) {
9110
9110
  function packageJsonHasWorkspaces(pkgPath) {
9111
9111
  if (!fileExists(pkgPath)) return false;
9112
9112
  try {
9113
- const raw = fs9.readFileSync(pkgPath, "utf-8");
9113
+ const raw = fs8.readFileSync(pkgPath, "utf-8");
9114
9114
  const json = JSON.parse(raw);
9115
9115
  if (!json.workspaces) return false;
9116
9116
  return Array.isArray(json.workspaces) || typeof json.workspaces === "object";
@@ -9132,8 +9132,8 @@ var init_workspace = __esm({
9132
9132
  });
9133
9133
 
9134
9134
  // src/compiler/compiler.ts
9135
- import fs10 from "fs/promises";
9136
- import path9 from "path";
9135
+ import fs9 from "fs/promises";
9136
+ import path8 from "path";
9137
9137
  import { Project as Project3 } from "ts-morph";
9138
9138
  async function compile(options) {
9139
9139
  const compiler = new Compiler(options);
@@ -9186,7 +9186,7 @@ var init_compiler = __esm({
9186
9186
  ...options
9187
9187
  };
9188
9188
  this.project = new Project3({
9189
- tsConfigFilePath: path9.join(options.rootDir, "tsconfig.json")
9189
+ tsConfigFilePath: path8.join(options.rootDir, "tsconfig.json")
9190
9190
  });
9191
9191
  registerProjectRootDir(this.project, this.options.rootDir);
9192
9192
  this.bundler = new Bundler({
@@ -9263,10 +9263,10 @@ var init_compiler = __esm({
9263
9263
  return await this.createResult(false, [], errors, warnings, startTime);
9264
9264
  }
9265
9265
  this.verbose("\u{1F4E6} Bundling primitives...");
9266
- await fs10.mkdir(this.options.outDir, {
9266
+ await fs9.mkdir(this.options.outDir, {
9267
9267
  recursive: true
9268
9268
  });
9269
- await fs10.mkdir(path9.join(this.options.outDir, ".temp"), {
9269
+ await fs9.mkdir(path8.join(this.options.outDir, ".temp"), {
9270
9270
  recursive: true
9271
9271
  });
9272
9272
  const CONCURRENCY = 4;
@@ -9286,7 +9286,7 @@ var init_compiler = __esm({
9286
9286
  this.verbose("\u{1F4BE} Writing artifacts...");
9287
9287
  await this.writeArtifacts(compiledPrimitives);
9288
9288
  if (!this.options.debug) {
9289
- await fs10.rm(path9.join(this.options.outDir, ".temp"), {
9289
+ await fs9.rm(path8.join(this.options.outDir, ".temp"), {
9290
9290
  recursive: true,
9291
9291
  force: true
9292
9292
  });
@@ -9329,7 +9329,7 @@ var init_compiler = __esm({
9329
9329
  */
9330
9330
  getWorkspaceRoot() {
9331
9331
  if (this._workspaceRoot === void 0) {
9332
- this._workspaceRoot = findWorkspaceRoot(path9.resolve(this.options.rootDir));
9332
+ this._workspaceRoot = findWorkspaceRoot(path8.resolve(this.options.rootDir));
9333
9333
  }
9334
9334
  return this._workspaceRoot;
9335
9335
  }
@@ -9343,18 +9343,18 @@ var init_compiler = __esm({
9343
9343
  * - Files outside the detected workspace root (not our code)
9344
9344
  */
9345
9345
  collectExternalWorkspaceFiles(traverser) {
9346
- const rootDir = path9.resolve(this.options.rootDir);
9346
+ const rootDir = path8.resolve(this.options.rootDir);
9347
9347
  const workspaceRoot = this.getWorkspaceRoot();
9348
9348
  if (workspaceRoot === rootDir) return [];
9349
9349
  const loaded = traverser.getAllLoadedSourceFilePaths();
9350
9350
  const result = [];
9351
9351
  const seen = /* @__PURE__ */ new Set();
9352
9352
  for (const raw of loaded) {
9353
- const abs = path9.resolve(raw);
9353
+ const abs = path8.resolve(raw);
9354
9354
  if (seen.has(abs)) continue;
9355
9355
  seen.add(abs);
9356
9356
  if (isInside(abs, rootDir)) continue;
9357
- if (abs.includes(`${path9.sep}node_modules${path9.sep}`)) continue;
9357
+ if (abs.includes(`${path8.sep}node_modules${path8.sep}`)) continue;
9358
9358
  if (!isInside(abs, workspaceRoot)) continue;
9359
9359
  result.push(abs);
9360
9360
  }
@@ -9487,9 +9487,9 @@ var init_compiler = __esm({
9487
9487
  * @param primitives - All compiled primitives to write
9488
9488
  */
9489
9489
  async writeArtifacts(primitives) {
9490
- const artifactsDir = path9.join(this.options.outDir, "artifacts");
9491
- const sourcesDir = path9.join(this.options.outDir, "sources");
9492
- await fs10.mkdir(sourcesDir, {
9490
+ const artifactsDir = path8.join(this.options.outDir, "artifacts");
9491
+ const sourcesDir = path8.join(this.options.outDir, "sources");
9492
+ await fs9.mkdir(sourcesDir, {
9493
9493
  recursive: true
9494
9494
  });
9495
9495
  const writtenSources = /* @__PURE__ */ new Map();
@@ -9497,7 +9497,7 @@ var init_compiler = __esm({
9497
9497
  this.verbose(" \u{1F4C2} Collecting project files...");
9498
9498
  const projectFiles = await this.storeProjectFiles(sourcesDir, writtenSources);
9499
9499
  const manifest = await this.createManifest(primitives, projectFiles);
9500
- await fs10.writeFile(path9.join(this.options.outDir, "manifest.json"), JSON.stringify(manifest, null, 2));
9500
+ await fs9.writeFile(path8.join(this.options.outDir, "manifest.json"), JSON.stringify(manifest, null, 2));
9501
9501
  this.verbose(` \u{1F4E6} Total files stored: ${writtenSources.size} (deduplicated)`);
9502
9502
  this.verbose(` \u{1F4C1} Project files: ${projectFiles.length}`);
9503
9503
  if (this.options.verbose || this.options.debug) {
@@ -9509,25 +9509,25 @@ var init_compiler = __esm({
9509
9509
  */
9510
9510
  async writePrimitiveArtifacts(primitives, artifactsDir, sourcesDir, writtenSources) {
9511
9511
  for (const primitive of primitives) {
9512
- const primitiveDir = path9.join(artifactsDir, primitive.kind);
9513
- await fs10.mkdir(primitiveDir, {
9512
+ const primitiveDir = path8.join(artifactsDir, primitive.kind);
9513
+ await fs9.mkdir(primitiveDir, {
9514
9514
  recursive: true
9515
9515
  });
9516
9516
  const baseName = primitive.name;
9517
- await fs10.writeFile(path9.join(primitiveDir, `${baseName}.js`), primitive.artifact.code);
9517
+ await fs9.writeFile(path8.join(primitiveDir, `${baseName}.js`), primitive.artifact.code);
9518
9518
  if (primitive.artifact.sourceMap) {
9519
- await fs10.writeFile(path9.join(primitiveDir, `${baseName}.js.map`), primitive.artifact.sourceMap);
9519
+ await fs9.writeFile(path8.join(primitiveDir, `${baseName}.js.map`), primitive.artifact.sourceMap);
9520
9520
  }
9521
9521
  const sourceHash = hashContent(primitive.artifact.originalSource);
9522
9522
  if (!writtenSources.has(sourceHash)) {
9523
9523
  const ext = primitive.sourcePath.endsWith(".tsx") ? ".tsx" : ".ts";
9524
- await fs10.writeFile(path9.join(sourcesDir, `${sourceHash}${ext}`), primitive.artifact.originalSource);
9525
- const relativePath = path9.relative(this.options.rootDir, primitive.sourcePath);
9524
+ await fs9.writeFile(path8.join(sourcesDir, `${sourceHash}${ext}`), primitive.artifact.originalSource);
9525
+ const relativePath = path8.relative(this.options.rootDir, primitive.sourcePath);
9526
9526
  writtenSources.set(sourceHash, relativePath);
9527
9527
  }
9528
9528
  const sidecarPlugin = pluginRegistry.get(primitive.kind);
9529
9529
  const sidecarMetadata = sidecarPlugin?.sanitizeForPersistence ? sidecarPlugin.sanitizeForPersistence(primitive.metadata) : primitive.metadata;
9530
- await fs10.writeFile(path9.join(primitiveDir, `${baseName}.json`), JSON.stringify({
9530
+ await fs9.writeFile(path8.join(primitiveDir, `${baseName}.json`), JSON.stringify({
9531
9531
  kind: primitive.kind,
9532
9532
  name: primitive.name,
9533
9533
  description: primitive.description,
@@ -9549,12 +9549,12 @@ var init_compiler = __esm({
9549
9549
  const allFiles = await this.collectProjectFiles();
9550
9550
  const workspaceRoot = this.getWorkspaceRoot();
9551
9551
  for (const file of allFiles) {
9552
- const absPath = file.external ? path9.join(workspaceRoot, file.relativePath) : path9.join(this.options.rootDir, file.relativePath);
9553
- const content = await fs10.readFile(absPath, "utf-8");
9552
+ const absPath = file.external ? path8.join(workspaceRoot, file.relativePath) : path8.join(this.options.rootDir, file.relativePath);
9553
+ const content = await fs9.readFile(absPath, "utf-8");
9554
9554
  const hash = hashContent(content);
9555
9555
  if (!writtenSources.has(hash)) {
9556
- const ext = path9.extname(file.relativePath) || ".txt";
9557
- await fs10.writeFile(path9.join(sourcesDir, `${hash}${ext}`), content);
9556
+ const ext = path8.extname(file.relativePath) || ".txt";
9557
+ await fs9.writeFile(path8.join(sourcesDir, `${hash}${ext}`), content);
9558
9558
  writtenSources.set(hash, file.relativePath);
9559
9559
  }
9560
9560
  projectFiles.push({
@@ -9630,12 +9630,12 @@ var init_compiler = __esm({
9630
9630
  async collectProjectFiles() {
9631
9631
  const files = [];
9632
9632
  const scanDir = /* @__PURE__ */ __name(async (dir, relativeBase = "") => {
9633
- const entries = await fs10.readdir(dir, {
9633
+ const entries = await fs9.readdir(dir, {
9634
9634
  withFileTypes: true
9635
9635
  });
9636
9636
  for (const entry of entries) {
9637
9637
  const relativePath = relativeBase ? `${relativeBase}/${entry.name}` : entry.name;
9638
- const fullPath = path9.join(dir, entry.name);
9638
+ const fullPath = path8.join(dir, entry.name);
9639
9639
  if (entry.isDirectory()) {
9640
9640
  if (shouldSkipDirectory(entry.name)) continue;
9641
9641
  await scanDir(fullPath, relativePath);
@@ -9652,10 +9652,10 @@ var init_compiler = __esm({
9652
9652
  const workspaceRoot = this.getWorkspaceRoot();
9653
9653
  const externalSeen = /* @__PURE__ */ new Set();
9654
9654
  for (const abs of this.externalWorkspaceFiles) {
9655
- const rel = path9.relative(workspaceRoot, abs).split(path9.sep).join("/");
9655
+ const rel = path8.relative(workspaceRoot, abs).split(path8.sep).join("/");
9656
9656
  if (!rel || rel.startsWith("..")) continue;
9657
9657
  if (externalSeen.has(rel)) continue;
9658
- const name = path9.basename(abs);
9658
+ const name = path8.basename(abs);
9659
9659
  if (shouldSkipFile(rel) || shouldSkipFile(name)) continue;
9660
9660
  externalSeen.add(rel);
9661
9661
  files.push({
@@ -9756,13 +9756,13 @@ var init_compiler = __esm({
9756
9756
  });
9757
9757
 
9758
9758
  // src/compiler/utils/file-discovery.ts
9759
- import path10 from "path";
9760
- import fs11 from "fs";
9759
+ import path9 from "path";
9760
+ import fs10 from "fs";
9761
9761
  function findEntryPoint(projectDir) {
9762
9762
  const baseDir = projectDir || process.cwd();
9763
9763
  for (const relativePath of ENTRY_POINT_PRIORITY) {
9764
- const fullPath = path10.join(baseDir, relativePath);
9765
- if (fs11.existsSync(fullPath)) {
9764
+ const fullPath = path9.join(baseDir, relativePath);
9765
+ if (fs10.existsSync(fullPath)) {
9766
9766
  return fullPath;
9767
9767
  }
9768
9768
  }
@@ -9799,8 +9799,8 @@ var init_file_discovery = __esm({
9799
9799
 
9800
9800
  // src/compiler/source-writer.ts
9801
9801
  import { Project as Project4, Node as Node17 } from "ts-morph";
9802
- import fs12 from "fs";
9803
- import path11 from "path";
9802
+ import fs11 from "fs";
9803
+ import path10 from "path";
9804
9804
  function resolveEntryPath(options) {
9805
9805
  let indexPath;
9806
9806
  try {
@@ -9812,14 +9812,14 @@ function resolveEntryPath(options) {
9812
9812
  indexPath = entryPoint;
9813
9813
  } else {
9814
9814
  const baseDir = options?.projectDir || process.cwd();
9815
- indexPath = path11.join(baseDir, "src", "index.ts");
9815
+ indexPath = path10.join(baseDir, "src", "index.ts");
9816
9816
  }
9817
9817
  }
9818
9818
  } catch {
9819
9819
  const baseDir = options?.projectDir || process.cwd();
9820
- indexPath = path11.join(baseDir, "src", "index.ts");
9820
+ indexPath = path10.join(baseDir, "src", "index.ts");
9821
9821
  }
9822
- if (!fs12.existsSync(indexPath)) {
9822
+ if (!fs11.existsSync(indexPath)) {
9823
9823
  console.warn(`Warning: Entry file not found at ${indexPath}`);
9824
9824
  return null;
9825
9825
  }
@@ -13628,6 +13628,16 @@ var init_mcp_server_handler = __esm({
13628
13628
  // src/index.ts
13629
13629
  import { Command } from "commander";
13630
13630
 
13631
+ // src/cli/parse-agent-version.ts
13632
+ import { InvalidArgumentError } from "commander";
13633
+ function parseAgentVersionFlag(value) {
13634
+ if (!/^\d+$/.test(value) || Number(value) < 1) {
13635
+ throw new InvalidArgumentError("--agent-version must be a positive integer (the version number to preview).");
13636
+ }
13637
+ return Number(value);
13638
+ }
13639
+ __name(parseAgentVersionFlag, "parseAgentVersionFlag");
13640
+
13631
13641
  // src/commands/configure.ts
13632
13642
  init_cli();
13633
13643
 
@@ -13809,164 +13819,6 @@ __name(promptAuthMethod, "promptAuthMethod");
13809
13819
 
13810
13820
  // src/commands/configure.ts
13811
13821
  init_analytics();
13812
-
13813
- // src/utils/versioning-mode-cache.ts
13814
- import * as fs3 from "fs";
13815
- import * as path3 from "path";
13816
-
13817
- // src/api/agent-version.api.service.ts
13818
- init_http_client();
13819
- var AgentVersionApi = class extends HttpClient {
13820
- static {
13821
- __name(this, "AgentVersionApi");
13822
- }
13823
- apiKey;
13824
- agentId;
13825
- constructor(baseUrl, apiKey, agentId) {
13826
- super(baseUrl);
13827
- this.apiKey = apiKey;
13828
- this.agentId = agentId;
13829
- }
13830
- get basePath() {
13831
- return `/developer/agents/${encodeURIComponent(this.agentId)}`;
13832
- }
13833
- get authHeader() {
13834
- return {
13835
- Authorization: `Bearer ${this.apiKey}`
13836
- };
13837
- }
13838
- // ---------------------------------------------------------------------------
13839
- // Versioning mode
13840
- // ---------------------------------------------------------------------------
13841
- async getVersioningMode() {
13842
- return this.httpGet(`${this.basePath}/versioning/mode`, this.authHeader);
13843
- }
13844
- // ---------------------------------------------------------------------------
13845
- // Version CRUD
13846
- // ---------------------------------------------------------------------------
13847
- async createVersion(body) {
13848
- return this.httpPost(`${this.basePath}/versions`, body, this.authHeader);
13849
- }
13850
- async listVersions(query) {
13851
- const params = new URLSearchParams();
13852
- if (query?.all !== void 0) params.append("all", String(query.all));
13853
- if (query?.limit !== void 0) params.append("limit", String(query.limit));
13854
- if (query?.status !== void 0) params.append("status", query.status);
13855
- const qs = params.toString();
13856
- const url = qs ? `${this.basePath}/versions?${qs}` : `${this.basePath}/versions`;
13857
- return this.httpGet(url, this.authHeader);
13858
- }
13859
- async getVersion(version) {
13860
- return this.httpGet(`${this.basePath}/versions/${version}`, this.authHeader);
13861
- }
13862
- async deleteVersion(version) {
13863
- return this.httpDelete(`${this.basePath}/versions/${version}`, this.authHeader);
13864
- }
13865
- // ---------------------------------------------------------------------------
13866
- // Diff
13867
- // ---------------------------------------------------------------------------
13868
- async diffVersions(from, to) {
13869
- const url = `${this.basePath}/versions/diff?from=${from}&to=${to}`;
13870
- return this.httpGet(url, this.authHeader);
13871
- }
13872
- // ---------------------------------------------------------------------------
13873
- // Promote
13874
- // ---------------------------------------------------------------------------
13875
- async promoteVersion(version) {
13876
- return this.httpPost(`${this.basePath}/versions/${version}/promote`, {}, this.authHeader);
13877
- }
13878
- // ---------------------------------------------------------------------------
13879
- // Patch commit hash — called by `lua version create` after a successful git
13880
- // commit + tag to propagate the SHA to the backend AgentVersion record.
13881
- // Failure is non-fatal; the version snapshot is valid whether or not this
13882
- // PATCH lands.
13883
- // ---------------------------------------------------------------------------
13884
- async patchCommitHash(version, commitHash) {
13885
- return this.httpPatch(`${this.basePath}/versions/${version}/commit-hash`, {
13886
- commitHash
13887
- }, this.authHeader);
13888
- }
13889
- };
13890
-
13891
- // src/utils/versioning-mode-cache.ts
13892
- init_constants();
13893
- init_auth_error();
13894
- init_constants();
13895
- var CACHE_TTL_MS = 60 * 60 * 1e3;
13896
- function readCacheFile() {
13897
- try {
13898
- const raw = fs3.readFileSync(CLI_CACHE_FILE, "utf-8");
13899
- return JSON.parse(raw);
13900
- } catch {
13901
- return {};
13902
- }
13903
- }
13904
- __name(readCacheFile, "readCacheFile");
13905
- function writeCacheFile(data) {
13906
- try {
13907
- fs3.mkdirSync(path3.dirname(CLI_CACHE_FILE), {
13908
- recursive: true
13909
- });
13910
- fs3.writeFileSync(CLI_CACHE_FILE, JSON.stringify(data, null, 2));
13911
- } catch {
13912
- }
13913
- }
13914
- __name(writeCacheFile, "writeCacheFile");
13915
- function isFresh(entry) {
13916
- const age = Date.now() - new Date(entry.cachedAt).getTime();
13917
- return age >= 0 && age < CACHE_TTL_MS;
13918
- }
13919
- __name(isFresh, "isFresh");
13920
- async function getVersioningModeCached(apiKey, agentId) {
13921
- const file = readCacheFile();
13922
- const existing = file.versioningMode?.[agentId];
13923
- if (existing && isFresh(existing)) {
13924
- return {
13925
- enabled: existing.enabled
13926
- };
13927
- }
13928
- try {
13929
- const api = new AgentVersionApi(BASE_URLS.API, apiKey, agentId);
13930
- const response = await api.getVersioningMode();
13931
- if (!response.success || !response.data) {
13932
- if (existing) return {
13933
- enabled: existing.enabled
13934
- };
13935
- return {
13936
- enabled: false
13937
- };
13938
- }
13939
- const enabled = response.data.enabled === true;
13940
- file.versioningMode = file.versioningMode ?? {};
13941
- file.versioningMode[agentId] = {
13942
- enabled,
13943
- cachedAt: (/* @__PURE__ */ new Date()).toISOString()
13944
- };
13945
- writeCacheFile(file);
13946
- return {
13947
- enabled
13948
- };
13949
- } catch (err) {
13950
- if (err instanceof AuthenticationError) throw err;
13951
- if (err instanceof Error && /access denied|forbidden|403|401/i.test(err.message)) throw err;
13952
- if (existing) return {
13953
- enabled: existing.enabled
13954
- };
13955
- return {
13956
- enabled: false
13957
- };
13958
- }
13959
- }
13960
- __name(getVersioningModeCached, "getVersioningModeCached");
13961
- function invalidateVersioningModeCache() {
13962
- const file = readCacheFile();
13963
- if (!file.versioningMode) return;
13964
- delete file.versioningMode;
13965
- writeCacheFile(file);
13966
- }
13967
- __name(invalidateVersioningModeCache, "invalidateVersioningModeCache");
13968
-
13969
- // src/commands/configure.ts
13970
13822
  async function configureCommand(options = {}) {
13971
13823
  return withErrorHandling(async () => {
13972
13824
  const { apiKey, email, otp } = options;
@@ -13976,13 +13828,11 @@ async function configureCommand(options = {}) {
13976
13828
  authMethod = "api-key";
13977
13829
  nonInteractive = true;
13978
13830
  await handleApiKeyAuthNonInteractive(apiKey);
13979
- invalidateVersioningModeCache();
13980
13831
  } else if (email) {
13981
13832
  authMethod = "email";
13982
13833
  nonInteractive = true;
13983
13834
  if (otp) {
13984
13835
  await handleEmailOtpVerify(email, otp);
13985
- invalidateVersioningModeCache();
13986
13836
  } else {
13987
13837
  await handleEmailOtpRequest(email);
13988
13838
  }
@@ -13991,10 +13841,8 @@ async function configureCommand(options = {}) {
13991
13841
  clearPromptLines(2);
13992
13842
  if (authMethod === "api-key") {
13993
13843
  await handleApiKeyAuth();
13994
- invalidateVersioningModeCache();
13995
13844
  } else if (authMethod === "email") {
13996
13845
  await handleEmailAuth();
13997
- invalidateVersioningModeCache();
13998
13846
  }
13999
13847
  }
14000
13848
  trackEvent("cli_auth_completed", {
@@ -14666,8 +14514,8 @@ init_compile_constants();
14666
14514
  init_artifact_loader();
14667
14515
  init_backup_api_service();
14668
14516
  init_constants();
14669
- import fs13 from "fs";
14670
- import path12 from "path";
14517
+ import fs12 from "fs";
14518
+ import path11 from "path";
14671
14519
  var BACKUP_CACHE_FILENAME = "backup-manifest.json";
14672
14520
  function calculateProjectHash(projectFiles) {
14673
14521
  return combineFileHashes(projectFiles);
@@ -14680,11 +14528,11 @@ function getCurrentProjectHash(projectPath = process.cwd()) {
14680
14528
  }
14681
14529
  __name(getCurrentProjectHash, "getCurrentProjectHash");
14682
14530
  function loadSourceByHash(hash, relativePath, projectPath = process.cwd()) {
14683
- const sourcesDir = path12.join(projectPath, COMPILE_DIRS.DIST_V2, "sources");
14684
- const ext = path12.extname(relativePath) || ".txt";
14685
- const sourcePath = path12.join(sourcesDir, `${hash}${ext}`);
14686
- if (fs13.existsSync(sourcePath)) {
14687
- return fs13.readFileSync(sourcePath, "utf-8");
14531
+ const sourcesDir = path11.join(projectPath, COMPILE_DIRS.DIST_V2, "sources");
14532
+ const ext = path11.extname(relativePath) || ".txt";
14533
+ const sourcePath = path11.join(sourcesDir, `${hash}${ext}`);
14534
+ if (fs12.existsSync(sourcePath)) {
14535
+ return fs12.readFileSync(sourcePath, "utf-8");
14688
14536
  }
14689
14537
  return null;
14690
14538
  }
@@ -14703,30 +14551,30 @@ function prepareFileRefs(projectPath = process.cwd()) {
14703
14551
  }
14704
14552
  __name(prepareFileRefs, "prepareFileRefs");
14705
14553
  function reconcileManifestWithDisk(projectPath = process.cwd()) {
14706
- const manifestPath = path12.join(projectPath, COMPILE_DIRS.DIST_V2, "manifest.json");
14707
- if (!fs13.existsSync(manifestPath)) return;
14554
+ const manifestPath = path11.join(projectPath, COMPILE_DIRS.DIST_V2, "manifest.json");
14555
+ if (!fs12.existsSync(manifestPath)) return;
14708
14556
  const manifest = loadManifest(projectPath);
14709
- const sourcesDir = path12.join(projectPath, COMPILE_DIRS.DIST_V2, "sources");
14710
- fs13.mkdirSync(sourcesDir, {
14557
+ const sourcesDir = path11.join(projectPath, COMPILE_DIRS.DIST_V2, "sources");
14558
+ fs12.mkdirSync(sourcesDir, {
14711
14559
  recursive: true
14712
14560
  });
14713
14561
  let changed = false;
14714
14562
  for (const file of manifest.projectFiles) {
14715
14563
  if (file.external) continue;
14716
- const absPath = path12.join(projectPath, file.relativePath);
14717
- if (!fs13.existsSync(absPath)) continue;
14564
+ const absPath = path11.join(projectPath, file.relativePath);
14565
+ if (!fs12.existsSync(absPath)) continue;
14718
14566
  let content;
14719
14567
  try {
14720
- content = fs13.readFileSync(absPath, "utf-8");
14568
+ content = fs12.readFileSync(absPath, "utf-8");
14721
14569
  } catch {
14722
14570
  continue;
14723
14571
  }
14724
14572
  const freshHash = hashContent(content);
14725
14573
  if (freshHash === file.hash) continue;
14726
- const ext = path12.extname(file.relativePath) || ".txt";
14727
- const sourceTargetPath = path12.join(sourcesDir, `${freshHash}${ext}`);
14574
+ const ext = path11.extname(file.relativePath) || ".txt";
14575
+ const sourceTargetPath = path11.join(sourcesDir, `${freshHash}${ext}`);
14728
14576
  try {
14729
- fs13.writeFileSync(sourceTargetPath, content, "utf-8");
14577
+ fs12.writeFileSync(sourceTargetPath, content, "utf-8");
14730
14578
  } catch {
14731
14579
  continue;
14732
14580
  }
@@ -14735,7 +14583,7 @@ function reconcileManifestWithDisk(projectPath = process.cwd()) {
14735
14583
  changed = true;
14736
14584
  }
14737
14585
  if (changed) {
14738
- fs13.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2), "utf-8");
14586
+ fs12.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2), "utf-8");
14739
14587
  }
14740
14588
  }
14741
14589
  __name(reconcileManifestWithDisk, "reconcileManifestWithDisk");
@@ -14808,7 +14656,7 @@ function checkRestoreConflicts(manifest, targetDir) {
14808
14656
  const existingFiles = [];
14809
14657
  for (const file of manifest.files) {
14810
14658
  const filePath = resolveBackupFileTarget2(file, targetDir);
14811
- if (fs13.existsSync(filePath)) {
14659
+ if (fs12.existsSync(filePath)) {
14812
14660
  existingFiles.push(file.relativePath);
14813
14661
  } else {
14814
14662
  newFiles.push(file.relativePath);
@@ -14834,16 +14682,16 @@ function createBackupTracking(projectHash) {
14834
14682
  }
14835
14683
  __name(createBackupTracking, "createBackupTracking");
14836
14684
  function getBackupCachePath(projectPath = process.cwd()) {
14837
- return path12.join(projectPath, ".lua", BACKUP_CACHE_FILENAME);
14685
+ return path11.join(projectPath, ".lua", BACKUP_CACHE_FILENAME);
14838
14686
  }
14839
14687
  __name(getBackupCachePath, "getBackupCachePath");
14840
14688
  function writeBackupManifestCache(cache, projectPath = process.cwd()) {
14841
14689
  const cachePath = getBackupCachePath(projectPath);
14842
14690
  try {
14843
- fs13.mkdirSync(path12.dirname(cachePath), {
14691
+ fs12.mkdirSync(path11.dirname(cachePath), {
14844
14692
  recursive: true
14845
14693
  });
14846
- fs13.writeFileSync(cachePath, JSON.stringify(cache, null, 2), "utf-8");
14694
+ fs12.writeFileSync(cachePath, JSON.stringify(cache, null, 2), "utf-8");
14847
14695
  } catch (error) {
14848
14696
  const message = error instanceof Error ? error.message : String(error);
14849
14697
  console.warn(`Could not write backup manifest cache: ${message}`);
@@ -14852,9 +14700,9 @@ function writeBackupManifestCache(cache, projectPath = process.cwd()) {
14852
14700
  __name(writeBackupManifestCache, "writeBackupManifestCache");
14853
14701
  function readBackupManifestCache(projectPath = process.cwd()) {
14854
14702
  const cachePath = getBackupCachePath(projectPath);
14855
- if (!fs13.existsSync(cachePath)) return null;
14703
+ if (!fs12.existsSync(cachePath)) return null;
14856
14704
  try {
14857
- const raw = fs13.readFileSync(cachePath, "utf-8");
14705
+ const raw = fs12.readFileSync(cachePath, "utf-8");
14858
14706
  const parsed = JSON.parse(raw);
14859
14707
  if (typeof parsed.lastHash !== "string" || typeof parsed.lastPushedAt !== "string" || !Array.isArray(parsed.files) || !parsed.files.every((f) => f && typeof f.relativePath === "string" && typeof f.hash === "string")) {
14860
14708
  return null;
@@ -14881,18 +14729,18 @@ function detectLocalConflictsForPull(incomingFiles, projectPath = process.cwd())
14881
14729
  f.hash
14882
14730
  ]));
14883
14731
  const conflicts = /* @__PURE__ */ new Set();
14884
- const projectRoot = path12.resolve(projectPath);
14732
+ const projectRoot = path11.resolve(projectPath);
14885
14733
  for (const incoming of incomingFiles) {
14886
14734
  if (COMPILE_MANAGED_FILES.has(incoming.relativePath)) continue;
14887
14735
  if (incoming.external) continue;
14888
- const absPath = path12.resolve(projectRoot, incoming.relativePath);
14889
- if (absPath !== projectRoot && !absPath.startsWith(projectRoot + path12.sep)) {
14736
+ const absPath = path11.resolve(projectRoot, incoming.relativePath);
14737
+ if (absPath !== projectRoot && !absPath.startsWith(projectRoot + path11.sep)) {
14890
14738
  continue;
14891
14739
  }
14892
- if (!fs13.existsSync(absPath)) continue;
14740
+ if (!fs12.existsSync(absPath)) continue;
14893
14741
  let diskHash;
14894
14742
  try {
14895
- const bytes = fs13.readFileSync(absPath, "utf-8");
14743
+ const bytes = fs12.readFileSync(absPath, "utf-8");
14896
14744
  diskHash = hashContent(bytes);
14897
14745
  } catch {
14898
14746
  conflicts.add(incoming.relativePath);
@@ -15071,17 +14919,17 @@ function writeBackupFilesWithByteCompare(manifest, blobs, targetDir) {
15071
14919
  }
15072
14920
  restoredContents.set(makeRestoredContentsKey(file), content);
15073
14921
  const filePath = resolveBackupFileTarget2(file, targetDir);
15074
- if (fs13.existsSync(filePath)) {
15075
- const existing = fs13.readFileSync(filePath);
14922
+ if (fs12.existsSync(filePath)) {
14923
+ const existing = fs12.readFileSync(filePath);
15076
14924
  if (existing.equals(content)) {
15077
14925
  filesUnchanged++;
15078
14926
  continue;
15079
14927
  }
15080
14928
  }
15081
- fs13.mkdirSync(path12.dirname(filePath), {
14929
+ fs12.mkdirSync(path11.dirname(filePath), {
15082
14930
  recursive: true
15083
14931
  });
15084
- fs13.writeFileSync(filePath, content);
14932
+ fs12.writeFileSync(filePath, content);
15085
14933
  filesWritten++;
15086
14934
  }
15087
14935
  return {
@@ -16895,7 +16743,6 @@ async function destroyCommand(options) {
16895
16743
  if (options?.force) {
16896
16744
  const deleted2 = deleteApiKey();
16897
16745
  if (deleted2) {
16898
- invalidateVersioningModeCache();
16899
16746
  writeSuccess("\u2705 API key deleted successfully.");
16900
16747
  } else {
16901
16748
  writeProgress("\u274C Failed to delete API key.");
@@ -16921,7 +16768,6 @@ async function destroyCommand(options) {
16921
16768
  if (confirm) {
16922
16769
  deleted = deleteApiKey();
16923
16770
  if (deleted) {
16924
- invalidateVersioningModeCache();
16925
16771
  writeSuccess("\u2705 API key deleted successfully.");
16926
16772
  } else {
16927
16773
  writeProgress("\u274C Failed to delete API key.");
@@ -16992,13 +16838,13 @@ __name(apiKeyCommand, "apiKeyCommand");
16992
16838
  init_cli();
16993
16839
  init_files();
16994
16840
  init_auth();
16995
- import path14 from "path";
16841
+ import path13 from "path";
16996
16842
 
16997
16843
  // src/commands/sync.ts
16998
16844
  init_dist();
16999
16845
  init_cli();
17000
- import fs14 from "fs";
17001
- import path13 from "path";
16846
+ import fs13 from "fs";
16847
+ import path12 from "path";
17002
16848
 
17003
16849
  // src/utils/prompt-handler.ts
17004
16850
  init_cli();
@@ -17221,8 +17067,8 @@ init_mcp_server_handler();
17221
17067
  async function syncCommand(options) {
17222
17068
  return withErrorHandling(async () => {
17223
17069
  const preCompileYaml = readYamlConfig();
17224
- const yamlPath = path13.resolve(process.cwd(), "lua.skill.yaml");
17225
- const preCompileYamlBytes = fs14.existsSync(yamlPath) ? fs14.readFileSync(yamlPath, "utf-8") : null;
17070
+ const yamlPath = path12.resolve(process.cwd(), "lua.skill.yaml");
17071
+ const preCompileYamlBytes = fs13.existsSync(yamlPath) ? fs13.readFileSync(yamlPath, "utf-8") : null;
17226
17072
  let syncCompletedSuccessfully = false;
17227
17073
  try {
17228
17074
  writeProgress("\u{1F504} Compiling to get latest local state...");
@@ -17283,7 +17129,7 @@ async function syncCommand(options) {
17283
17129
  } finally {
17284
17130
  if (!syncCompletedSuccessfully && preCompileYamlBytes !== null) {
17285
17131
  try {
17286
- fs14.writeFileSync(yamlPath, preCompileYamlBytes, "utf-8");
17132
+ fs13.writeFileSync(yamlPath, preCompileYamlBytes, "utf-8");
17287
17133
  } catch {
17288
17134
  }
17289
17135
  }
@@ -18841,7 +18687,7 @@ async function compileCommand(options) {
18841
18687
  }
18842
18688
  writeProgress("\u{1F528} Compiling...");
18843
18689
  const rootDir = process.cwd();
18844
- const outDir = path14.join(rootDir, "dist-v2");
18690
+ const outDir = path13.join(rootDir, "dist-v2");
18845
18691
  const result = await compile({
18846
18692
  rootDir,
18847
18693
  outDir,
@@ -19005,12 +18851,12 @@ init_command_utils();
19005
18851
 
19006
18852
  // src/utils/sandbox.ts
19007
18853
  import vm3 from "vm";
19008
- import path17 from "path";
18854
+ import path16 from "path";
19009
18855
 
19010
18856
  // ../shared-sandbox/dist/index.mjs
19011
18857
  import vm from "vm";
19012
18858
  import { createRequire } from "module";
19013
- import path15 from "path";
18859
+ import path14 from "path";
19014
18860
  import dns from "dns";
19015
18861
  import net from "net";
19016
18862
  import { promisify } from "util";
@@ -19180,7 +19026,7 @@ var REQUIRE_BLOCKLIST = /* @__PURE__ */ new Set([
19180
19026
  var SANDBOX_FAKE_DIRNAME = "/";
19181
19027
  var SANDBOX_FAKE_FILENAME = "/index.ts";
19182
19028
  function buildSandboxRequire(opts) {
19183
- const realRequire = createRequire(path15.join(opts.cwd, "package.json"));
19029
+ const realRequire = createRequire(path14.join(opts.cwd, "package.json"));
19184
19030
  const wrapped = /* @__PURE__ */ __name4((id) => {
19185
19031
  if (REQUIRE_BLOCKLIST.has(id)) {
19186
19032
  const evt = {
@@ -19850,14 +19696,14 @@ __name(runBundleInContext, "runBundleInContext");
19850
19696
  __name4(runBundleInContext, "runBundleInContext");
19851
19697
 
19852
19698
  // src/utils/env-loader.utils.ts
19853
- import path16 from "path";
19854
- import fs15 from "fs";
19699
+ import path15 from "path";
19700
+ import fs14 from "fs";
19855
19701
  function parseEnvFile(filePath) {
19856
- if (!fs15.existsSync(filePath)) {
19702
+ if (!fs14.existsSync(filePath)) {
19857
19703
  return {};
19858
19704
  }
19859
19705
  try {
19860
- const content = fs15.readFileSync(filePath, "utf8");
19706
+ const content = fs14.readFileSync(filePath, "utf8");
19861
19707
  if (!content.trim()) return {};
19862
19708
  const envVars = {};
19863
19709
  content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).forEach((line) => {
@@ -19883,7 +19729,7 @@ async function loadEnvironmentVariables(context) {
19883
19729
  }
19884
19730
  __name(loadEnvironmentVariables, "loadEnvironmentVariables");
19885
19731
  function loadSandboxEnvVariables() {
19886
- const envFilePath = path16.join(process.cwd(), ".env");
19732
+ const envFilePath = path15.join(process.cwd(), ".env");
19887
19733
  const envMap = parseEnvFile(envFilePath);
19888
19734
  return Object.entries(envMap).map(([key, value]) => ({
19889
19735
  key,
@@ -19978,7 +19824,7 @@ function loadEnvironmentVariables2() {
19978
19824
  envVars[key] = value;
19979
19825
  }
19980
19826
  }
19981
- const envFilePath = path17.join(process.cwd(), ".env");
19827
+ const envFilePath = path16.join(process.cwd(), ".env");
19982
19828
  const fileEnvVars = parseEnvFile(envFilePath);
19983
19829
  Object.assign(envVars, fileEnvVars);
19984
19830
  return envVars;
@@ -21864,7 +21710,6 @@ init_dist();
21864
21710
  init_files();
21865
21711
  init_cli();
21866
21712
  init_command_utils();
21867
- init_auth();
21868
21713
  init_semver();
21869
21714
  init_auth_error();
21870
21715
  init_constants();
@@ -21992,8 +21837,8 @@ async function runBackupPush(opts) {
21992
21837
  }
21993
21838
  __name(runBackupPush, "runBackupPush");
21994
21839
  async function uploadBlobsFromDisk(uploadUrls, files, projectPath, concurrency = 10) {
21995
- const fs17 = await import("fs");
21996
- const path19 = await import("path");
21840
+ const fs16 = await import("fs");
21841
+ const path18 = await import("path");
21997
21842
  const zlib2 = await import("zlib");
21998
21843
  const hashToPath = /* @__PURE__ */ new Map();
21999
21844
  for (const f of files) {
@@ -22007,8 +21852,8 @@ async function uploadBlobsFromDisk(uploadUrls, files, projectPath, concurrency =
22007
21852
  if (!rel) {
22008
21853
  throw new Error(`No file found for hash: ${hash}`);
22009
21854
  }
22010
- const abs = path19.join(projectPath, rel);
22011
- const content = fs17.readFileSync(abs);
21855
+ const abs = path18.join(projectPath, rel);
21856
+ const content = fs16.readFileSync(abs);
22012
21857
  const compressed = zlib2.gzipSync(content);
22013
21858
  const response = await fetch(uploadUrls[hash], {
22014
21859
  method: "PUT",
@@ -22266,11 +22111,11 @@ init_cli();
22266
22111
 
22267
22112
  // src/utils/git-auth-store.ts
22268
22113
  init_constants();
22269
- import { mkdirSync as mkdirSync7, readFileSync as readFileSync10, writeFileSync as writeFileSync7 } from "fs";
22270
- import { dirname as dirname6 } from "path";
22114
+ import { mkdirSync as mkdirSync6, readFileSync as readFileSync9, writeFileSync as writeFileSync6 } from "fs";
22115
+ import { dirname as dirname5 } from "path";
22271
22116
  function readStore() {
22272
22117
  try {
22273
- const raw = readFileSync10(AUTH_STORAGE_FILE, "utf8");
22118
+ const raw = readFileSync9(AUTH_STORAGE_FILE, "utf8");
22274
22119
  const parsed = JSON.parse(raw);
22275
22120
  return {
22276
22121
  providers: parsed.providers ?? {}
@@ -22283,10 +22128,10 @@ function readStore() {
22283
22128
  }
22284
22129
  __name(readStore, "readStore");
22285
22130
  function writeStore(store) {
22286
- mkdirSync7(dirname6(AUTH_STORAGE_FILE), {
22131
+ mkdirSync6(dirname5(AUTH_STORAGE_FILE), {
22287
22132
  recursive: true
22288
22133
  });
22289
- writeFileSync7(AUTH_STORAGE_FILE, JSON.stringify(store, null, 2), {
22134
+ writeFileSync6(AUTH_STORAGE_FILE, JSON.stringify(store, null, 2), {
22290
22135
  mode: 384
22291
22136
  });
22292
22137
  }
@@ -23050,15 +22895,9 @@ async function pushCommand(type, cmdObj) {
23050
22895
  allowAll: true
23051
22896
  });
23052
22897
  }
23053
- const earlyApiKey = loadApiKey();
23054
- const earlyConfig = readYamlConfig();
23055
- const earlyAgentId = earlyConfig?.agent?.agentId;
23056
- const versioning = earlyApiKey && earlyAgentId ? await getVersioningModeCached(earlyApiKey, earlyAgentId) : {
23057
- enabled: false
23058
- };
23059
- const isStageAll = !type && versioning.enabled;
23060
- const isGranular = Boolean(type && type !== "all" && versioning.enabled);
23061
- const isAutoDeployNoOp = versioning.enabled && (type === "all" || !type) && Boolean(options.autoDeploy);
22898
+ const isStageAll = !type;
22899
+ const isGranular = Boolean(type && type !== "all");
22900
+ const isAutoDeployNoOp = (type === "all" || !type) && Boolean(options.autoDeploy);
23062
22901
  if (isAutoDeployNoOp) {
23063
22902
  writeInfo("\u26A0\uFE0F --auto-deploy is ignored when agent versioning is on. Use `lua version promote <version>` after `lua version create`.");
23064
22903
  options.autoDeploy = false;
@@ -23090,64 +22929,7 @@ async function pushCommand(type, cmdObj) {
23090
22929
  autoDeployNoopWarned: isAutoDeployNoOp
23091
22930
  });
23092
22931
  }
23093
- if (type) {
23094
- selectedType = type;
23095
- } else {
23096
- const typeAnswer = await safePrompt([
23097
- {
23098
- type: "list",
23099
- name: "type",
23100
- message: "What would you like to push?",
23101
- choices: [
23102
- {
23103
- name: "\u{1F6E0}\uFE0F Skill",
23104
- value: "skill"
23105
- },
23106
- {
23107
- name: "\u{1FA9D} Webhook",
23108
- value: "webhook"
23109
- },
23110
- {
23111
- name: "\u23F0 Job",
23112
- value: "job"
23113
- },
23114
- {
23115
- name: "\u{1F4E5} PreProcessor",
23116
- value: "preprocessor"
23117
- },
23118
- {
23119
- name: "\u{1F4E4} PostProcessor",
23120
- value: "postprocessor"
23121
- },
23122
- {
23123
- name: "\u{1F50C} MCP Server",
23124
- value: "mcp"
23125
- },
23126
- {
23127
- name: "\u{1F4E1} Device",
23128
- value: "device"
23129
- },
23130
- {
23131
- name: "\u{1F4E1} Device Trigger",
23132
- value: "device-trigger"
23133
- },
23134
- {
23135
- name: "\u{1F916} Agent (persona, model)",
23136
- value: "agent"
23137
- },
23138
- {
23139
- name: "\u{1F4BE} Backup (source files)",
23140
- value: "backup"
23141
- }
23142
- ]
23143
- }
23144
- ]);
23145
- if (!typeAnswer) {
23146
- console.log("Push cancelled.");
23147
- return;
23148
- }
23149
- selectedType = typeAnswer.type;
23150
- }
22932
+ selectedType = type;
23151
22933
  if (selectedType === "skill") {
23152
22934
  versionedPushDeployResult = await pushVersionedPrimitive(skillHandler, options);
23153
22935
  } else if (selectedType === "webhook") {
@@ -23237,7 +23019,7 @@ Until the backup catches up, \`lua init\` for this agent will restore an older s
23237
23019
  include_source_attached: trackedIncludeSource?.attached ?? 0,
23238
23020
  include_source_failed: trackedIncludeSource?.failed ?? 0,
23239
23021
  // Agent-versioning telemetry. Driven by isStageAll / isGranular.
23240
- versioning_mode: versioning.enabled ? isGranular ? "granular" : "all" : "flag-off",
23022
+ versioning_mode: isGranular ? "granular" : "all",
23241
23023
  granular_deprecation_warned: isGranular,
23242
23024
  auto_deploy_noop_warned: isAutoDeployNoOp
23243
23025
  });
@@ -23532,7 +23314,6 @@ async function pushAllCommand(options) {
23532
23314
  }
23533
23315
  const apiKey = await requireAuthOrExit(false);
23534
23316
  const agentId = config.agent.agentId;
23535
- const pushAllVersioning = await getVersioningModeCached(apiKey, agentId);
23536
23317
  let manifest;
23537
23318
  try {
23538
23319
  manifest = loadManifest();
@@ -23838,7 +23619,7 @@ Until the backup catches up, \`lua init\` for this agent will restore an older s
23838
23619
  include_source_attached: includeSourceStats?.attached ?? 0,
23839
23620
  include_source_failed: includeSourceStats?.failed ?? 0,
23840
23621
  // Agent-versioning telemetry.
23841
- versioning_mode: pushAllVersioning.enabled ? "stage-all" : "flag-off",
23622
+ versioning_mode: "stage-all",
23842
23623
  granular_deprecation_warned: false,
23843
23624
  auto_deploy_noop_warned: options.autoDeployNoopWarned || false
23844
23625
  });
@@ -23856,42 +23637,8 @@ Until the backup catches up, \`lua init\` for this agent will restore an older s
23856
23637
  });
23857
23638
  if (variant === "success") {
23858
23639
  console.log("");
23859
- if (pushAllVersioning.enabled) {
23860
- if (!options.suppressVersionCreateHint) {
23861
- writeInfo(`Run \`lua version create [-m "<message>"]\` to snapshot the staged state into a named version, then \`lua version promote <version>\` to deploy.`);
23862
- }
23863
- } else if (options.autoDeploy) {
23864
- writeHintBlock({
23865
- headline: "All deployed. Generate test traffic first, then inspect:",
23866
- lines: [
23867
- {
23868
- label: "Test:",
23869
- command: 'lua chat -e production -m "your test message"'
23870
- },
23871
- {
23872
- label: "Inspect:",
23873
- command: buildLogsCommand({
23874
- limit: 10
23875
- })
23876
- }
23877
- ],
23878
- when: "success"
23879
- });
23880
- } else {
23881
- writeHintBlock({
23882
- headline: "Code staged but NOT live. Make it active:",
23883
- lines: [
23884
- {
23885
- label: "Deploy all:",
23886
- command: "lua deploy all --force"
23887
- },
23888
- {
23889
- label: "Or re-push:",
23890
- command: "lua push all --force --auto-deploy"
23891
- }
23892
- ],
23893
- when: "success"
23894
- });
23640
+ if (!options.suppressVersionCreateHint) {
23641
+ writeInfo(`Run \`lua version create [-m "<message>"]\` to snapshot the staged state into a named version, then \`lua version promote <version>\` to deploy.`);
23895
23642
  }
23896
23643
  } else if (variant === "partial") {
23897
23644
  console.log("");
@@ -24128,10 +23875,7 @@ async function deployCommand(type, cmdObj) {
24128
23875
  selectedType = answer.type;
24129
23876
  }
24130
23877
  const apiKey = await requireAuthOrExit();
24131
- const versioning = await getVersioningModeCached(apiKey, agentId);
24132
- if (versioning.enabled) {
24133
- writeInfo("\u26A0\uFE0F `lua deploy` is deprecated when agent versioning is on. Use `lua version promote <version>` for instant, atomic promotion.");
24134
- }
23878
+ writeInfo("\u26A0\uFE0F `lua deploy` is deprecated when agent versioning is on. Use `lua version promote <version>` for instant, atomic promotion.");
24135
23879
  let personaDeployed = false;
24136
23880
  let versionedOutcome = null;
24137
23881
  if (selectedType === "persona") {
@@ -24145,7 +23889,7 @@ async function deployCommand(type, cmdObj) {
24145
23889
  force_mode: options.force || false,
24146
23890
  entity_selected_by_name: !!options.name,
24147
23891
  version_selected_by_flag: !!options.version,
24148
- granular_deprecation_warned: versioning.enabled
23892
+ granular_deprecation_warned: true
24149
23893
  });
24150
23894
  const deployed = selectedType === "persona" ? personaDeployed : versionedOutcome?.deployed ?? false;
24151
23895
  const hintPrintedAlready = selectedType !== "persona" && !!versionedOutcome?.hintPrinted;
@@ -24639,11 +24383,11 @@ init_cli();
24639
24383
 
24640
24384
  // src/utils/sandbox-storage.ts
24641
24385
  init_constants();
24642
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync8, mkdirSync as mkdirSync8 } from "fs";
24643
- import { dirname as dirname7 } from "path";
24386
+ import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, mkdirSync as mkdirSync7 } from "fs";
24387
+ import { dirname as dirname6 } from "path";
24644
24388
  function readStore2() {
24645
24389
  try {
24646
- const raw = readFileSync11(SANDBOX_STORAGE_FILE, "utf8");
24390
+ const raw = readFileSync10(SANDBOX_STORAGE_FILE, "utf8");
24647
24391
  const parsed = JSON.parse(raw);
24648
24392
  return {
24649
24393
  skills: parsed.skills ?? {},
@@ -24663,10 +24407,10 @@ function readStore2() {
24663
24407
  __name(readStore2, "readStore");
24664
24408
  function writeStore2(store) {
24665
24409
  try {
24666
- mkdirSync8(dirname7(SANDBOX_STORAGE_FILE), {
24410
+ mkdirSync7(dirname6(SANDBOX_STORAGE_FILE), {
24667
24411
  recursive: true
24668
24412
  });
24669
- writeFileSync8(SANDBOX_STORAGE_FILE, JSON.stringify(store, null, 2), "utf8");
24413
+ writeFileSync7(SANDBOX_STORAGE_FILE, JSON.stringify(store, null, 2), "utf8");
24670
24414
  } catch {
24671
24415
  }
24672
24416
  }
@@ -25129,6 +24873,74 @@ async function pushProcessorsToSandbox(apiKey, agentId, manifest, yamlConfig, is
25129
24873
  }
25130
24874
  __name(pushProcessorsToSandbox, "pushProcessorsToSandbox");
25131
24875
 
24876
+ // src/api/agent-version.api.service.ts
24877
+ init_http_client();
24878
+ var AgentVersionApi = class extends HttpClient {
24879
+ static {
24880
+ __name(this, "AgentVersionApi");
24881
+ }
24882
+ apiKey;
24883
+ agentId;
24884
+ constructor(baseUrl, apiKey, agentId) {
24885
+ super(baseUrl);
24886
+ this.apiKey = apiKey;
24887
+ this.agentId = agentId;
24888
+ }
24889
+ get basePath() {
24890
+ return `/developer/agents/${encodeURIComponent(this.agentId)}`;
24891
+ }
24892
+ get authHeader() {
24893
+ return {
24894
+ Authorization: `Bearer ${this.apiKey}`
24895
+ };
24896
+ }
24897
+ // ---------------------------------------------------------------------------
24898
+ // Version CRUD
24899
+ // ---------------------------------------------------------------------------
24900
+ async createVersion(body) {
24901
+ return this.httpPost(`${this.basePath}/versions`, body, this.authHeader);
24902
+ }
24903
+ async listVersions(query) {
24904
+ const params = new URLSearchParams();
24905
+ if (query?.all !== void 0) params.append("all", String(query.all));
24906
+ if (query?.limit !== void 0) params.append("limit", String(query.limit));
24907
+ if (query?.status !== void 0) params.append("status", query.status);
24908
+ const qs = params.toString();
24909
+ const url = qs ? `${this.basePath}/versions?${qs}` : `${this.basePath}/versions`;
24910
+ return this.httpGet(url, this.authHeader);
24911
+ }
24912
+ async getVersion(version) {
24913
+ return this.httpGet(`${this.basePath}/versions/${version}`, this.authHeader);
24914
+ }
24915
+ async deleteVersion(version) {
24916
+ return this.httpDelete(`${this.basePath}/versions/${version}`, this.authHeader);
24917
+ }
24918
+ // ---------------------------------------------------------------------------
24919
+ // Diff
24920
+ // ---------------------------------------------------------------------------
24921
+ async diffVersions(from, to) {
24922
+ const url = `${this.basePath}/versions/diff?from=${from}&to=${to}`;
24923
+ return this.httpGet(url, this.authHeader);
24924
+ }
24925
+ // ---------------------------------------------------------------------------
24926
+ // Promote
24927
+ // ---------------------------------------------------------------------------
24928
+ async promoteVersion(version) {
24929
+ return this.httpPost(`${this.basePath}/versions/${version}/promote`, {}, this.authHeader);
24930
+ }
24931
+ // ---------------------------------------------------------------------------
24932
+ // Patch commit hash — called by `lua version create` after a successful git
24933
+ // commit + tag to propagate the SHA to the backend AgentVersion record.
24934
+ // Failure is non-fatal; the version snapshot is valid whether or not this
24935
+ // PATCH lands.
24936
+ // ---------------------------------------------------------------------------
24937
+ async patchCommitHash(version, commitHash) {
24938
+ return this.httpPatch(`${this.basePath}/versions/${version}/commit-hash`, {
24939
+ commitHash
24940
+ }, this.authHeader);
24941
+ }
24942
+ };
24943
+
25132
24944
  // src/commands/chat.ts
25133
24945
  init_constants();
25134
24946
 
@@ -25428,6 +25240,14 @@ async function chatCommand(cmdObj) {
25428
25240
  const delay = parseInt(cmdObj?.delay || "100", 10);
25429
25241
  const env = cmdObj?.env || null;
25430
25242
  const autoClear = !!cmdObj?.clear || !!cmdObj?.clearThread;
25243
+ const rawVersion = cmdObj?.agentVersion;
25244
+ let previewVersion;
25245
+ if (rawVersion != null) {
25246
+ if (!Number.isInteger(rawVersion) || rawVersion < 1) {
25247
+ throw new Error("--agent-version must be a positive integer (the version number to preview).");
25248
+ }
25249
+ previewVersion = rawVersion;
25250
+ }
25431
25251
  const rawThread = cmdObj?.thread;
25432
25252
  let threadId;
25433
25253
  if (rawThread === true) {
@@ -25436,48 +25256,68 @@ async function chatCommand(cmdObj) {
25436
25256
  threadId = rawThread;
25437
25257
  }
25438
25258
  const { config, agentId, apiKey } = await initializeCommand();
25259
+ if (previewVersion != null) {
25260
+ const versionApi = new AgentVersionApi(BASE_URLS.API, apiKey, agentId);
25261
+ const versionResponse = await versionApi.getVersion(previewVersion);
25262
+ if (!versionResponse.success) {
25263
+ throw new Error(`Agent version v${previewVersion} not found.`);
25264
+ }
25265
+ writeInfo(`\u{1F50E} Previewing agent version v${previewVersion} in an isolated thread (not promoted) \u2026`);
25266
+ }
25439
25267
  let selectedEnvironment;
25440
- const envResolution = resolveChatEnvironment(env, !!(message || batch));
25441
- switch (envResolution.type) {
25442
- case "resolved":
25443
- selectedEnvironment = envResolution.environment;
25444
- break;
25445
- case "default_sandbox":
25446
- console.log(`
25268
+ let envResolutionType;
25269
+ if (previewVersion != null) {
25270
+ if (env != null && env !== "production") {
25271
+ throw new Error(`--agent-version previews a server-stored version and only runs against production (got --env ${env}). Remove --env or pass --env production.`);
25272
+ }
25273
+ selectedEnvironment = "production";
25274
+ envResolutionType = "preview_forced_production";
25275
+ } else {
25276
+ const envResolution = resolveChatEnvironment(env, !!(message || batch));
25277
+ envResolutionType = envResolution.type;
25278
+ switch (envResolution.type) {
25279
+ case "resolved":
25280
+ selectedEnvironment = envResolution.environment;
25281
+ break;
25282
+ case "default_sandbox":
25283
+ console.log(`
25447
25284
  \u2139\uFE0F No --env provided, defaulting to sandbox. Use --env production for production.
25448
25285
  `);
25449
- selectedEnvironment = envResolution.environment;
25450
- break;
25451
- case "prompt":
25452
- const { environment } = await inquirer9.prompt([
25453
- {
25454
- type: "list",
25455
- name: "environment",
25456
- message: "Select environment:",
25457
- choices: [
25458
- {
25459
- name: "\u{1F527} Sandbox (Agent will execute skills etc from your local machine)",
25460
- value: "sandbox"
25461
- },
25462
- {
25463
- name: "\u{1F680} Production (Agent will execute latest version of skills etc)",
25464
- value: "production"
25465
- }
25466
- ]
25467
- }
25468
- ]);
25469
- selectedEnvironment = environment;
25470
- break;
25471
- case "error":
25472
- console.log(`\u274C ${envResolution.message}`);
25473
- throw new Error(`${envResolution.message}`);
25286
+ selectedEnvironment = envResolution.environment;
25287
+ break;
25288
+ case "prompt": {
25289
+ const { environment } = await inquirer9.prompt([
25290
+ {
25291
+ type: "list",
25292
+ name: "environment",
25293
+ message: "Select environment:",
25294
+ choices: [
25295
+ {
25296
+ name: "\u{1F527} Sandbox (Agent will execute skills etc from your local machine)",
25297
+ value: "sandbox"
25298
+ },
25299
+ {
25300
+ name: "\u{1F680} Production (Agent will execute latest version of skills etc)",
25301
+ value: "production"
25302
+ }
25303
+ ]
25304
+ }
25305
+ ]);
25306
+ selectedEnvironment = environment;
25307
+ break;
25308
+ }
25309
+ case "error":
25310
+ console.log(`\u274C ${envResolution.message}`);
25311
+ throw new Error(`${envResolution.message}`);
25312
+ }
25474
25313
  }
25475
25314
  let chatEnv = {
25476
25315
  type: selectedEnvironment,
25477
25316
  agentId,
25478
25317
  apiKey,
25479
25318
  threadId,
25480
- autoClear
25319
+ autoClear,
25320
+ previewVersion
25481
25321
  };
25482
25322
  if (selectedEnvironment === "sandbox") {
25483
25323
  writeInfo("\u{1F4A1} Sandbox mode: uses your locally compiled code \u2014 no lua push needed.");
@@ -25490,11 +25330,12 @@ async function chatCommand(cmdObj) {
25490
25330
  trackEvent("cli_chat_started", {
25491
25331
  environment: selectedEnvironment,
25492
25332
  non_interactive_message: !!message,
25493
- env_resolution_type: envResolution.type,
25333
+ env_resolution_type: envResolutionType,
25494
25334
  has_preprocessor_overrides: (chatEnv.preprocessorOverrides?.length || 0) > 0,
25495
25335
  has_postprocessor_overrides: (chatEnv.postprocessorOverrides?.length || 0) > 0,
25496
25336
  has_thread_id: !!chatEnv.threadId,
25497
- auto_clear: chatEnv.autoClear || false
25337
+ auto_clear: chatEnv.autoClear || false,
25338
+ preview_version: chatEnv.previewVersion ?? null
25498
25339
  });
25499
25340
  const probeWindow = {
25500
25341
  value: (/* @__PURE__ */ new Date()).toISOString()
@@ -25743,6 +25584,9 @@ async function sendSandboxMessageStream(chatEnv, messages, callbacks) {
25743
25584
  if (chatEnv.threadId) {
25744
25585
  chatRequest.threadId = chatEnv.threadId;
25745
25586
  }
25587
+ if (chatEnv.previewVersion != null) {
25588
+ chatRequest.version = chatEnv.previewVersion;
25589
+ }
25746
25590
  const chatApi = new ChatApi(BASE_URLS.CHAT, chatEnv.apiKey);
25747
25591
  await chatApi.sendMessageStream(chatEnv.agentId, chatRequest, callbacks.onChunk, callbacks.onPostprocessComplete, callbacks.onPreprocessorBlocked, callbacks.onBatchAbort, callbacks.onBatchHandled);
25748
25592
  }
@@ -25758,6 +25602,9 @@ async function sendProductionMessageStream(chatEnv, messages, callbacks) {
25758
25602
  if (chatEnv.threadId) {
25759
25603
  chatRequest.threadId = chatEnv.threadId;
25760
25604
  }
25605
+ if (chatEnv.previewVersion != null) {
25606
+ chatRequest.version = chatEnv.previewVersion;
25607
+ }
25761
25608
  const chatApi = new ChatApi(BASE_URLS.CHAT, chatEnv.apiKey);
25762
25609
  await chatApi.sendMessageStream(chatEnv.agentId, chatRequest, callbacks.onChunk, callbacks.onPostprocessComplete, callbacks.onPreprocessorBlocked, callbacks.onBatchAbort, callbacks.onBatchHandled);
25763
25610
  }
@@ -25988,8 +25835,8 @@ init_cli();
25988
25835
  init_constants();
25989
25836
  init_command_utils();
25990
25837
  init_developer_api_service();
25991
- import fs16 from "fs";
25992
- import path18 from "path";
25838
+ import fs15 from "fs";
25839
+ import path17 from "path";
25993
25840
  import inquirer10 from "inquirer";
25994
25841
  init_analytics();
25995
25842
  function resolveEnvironment(env, hasNonInteractiveFlags) {
@@ -26348,10 +26195,10 @@ function variablesToEnvContent(variables) {
26348
26195
  }
26349
26196
  __name(variablesToEnvContent, "variablesToEnvContent");
26350
26197
  function saveSandboxEnvVariables(variables) {
26351
- const envFilePath = path18.join(process.cwd(), ".env");
26198
+ const envFilePath = path17.join(process.cwd(), ".env");
26352
26199
  try {
26353
26200
  const content = variablesToEnvContent(variables);
26354
- fs16.writeFileSync(envFilePath, content, "utf8");
26201
+ fs15.writeFileSync(envFilePath, content, "utf8");
26355
26202
  return true;
26356
26203
  } catch (error) {
26357
26204
  console.error("\u274C Error saving .env file:", error);
@@ -30166,13 +30013,8 @@ init_command_utils();
30166
30013
 
30167
30014
  // src/utils/primitive-version-display.ts
30168
30015
  var PRIMITIVE_VERSION_HISTORY_NOTE = "\u2139\uFE0F Primitive versions are managed by agent versioning. Run `lua version list` to view agent versions.";
30169
- async function shouldHidePrimitiveVersions(apiKey, agentId) {
30170
- try {
30171
- const { enabled } = await getVersioningModeCached(apiKey, agentId);
30172
- return enabled;
30173
- } catch {
30174
- return false;
30175
- }
30016
+ async function shouldHidePrimitiveVersions(_apiKey, _agentId) {
30017
+ return true;
30176
30018
  }
30177
30019
  __name(shouldHidePrimitiveVersions, "shouldHidePrimitiveVersions");
30178
30020
  var DIVIDER = "=".repeat(60);
@@ -30889,7 +30731,7 @@ init_auth();
30889
30731
  init_auth_api_service();
30890
30732
  init_files();
30891
30733
  init_artifact_loader();
30892
- import { existsSync as existsSync7, readFileSync as readFileSync12 } from "fs";
30734
+ import { existsSync as existsSync7, readFileSync as readFileSync11 } from "fs";
30893
30735
  import { join as join6 } from "path";
30894
30736
  import { performance } from "perf_hooks";
30895
30737
  import * as os from "os";
@@ -31240,7 +31082,7 @@ function gatherTelemetry() {
31240
31082
  } else {
31241
31083
  try {
31242
31084
  if (existsSync7(TELEMETRY_FILE)) {
31243
- const raw = readFileSync12(TELEMETRY_FILE, "utf8");
31085
+ const raw = readFileSync11(TELEMETRY_FILE, "utf8");
31244
31086
  const cfg = JSON.parse(raw);
31245
31087
  if (typeof cfg.enabled === "boolean") enabled = cfg.enabled;
31246
31088
  }
@@ -40451,7 +40293,7 @@ __name(telemetryCommand, "telemetryCommand");
40451
40293
  init_cli();
40452
40294
  init_command_utils();
40453
40295
  init_analytics();
40454
- import { writeFileSync as writeFileSync9, existsSync as existsSync8, unlinkSync as unlinkSync2 } from "fs";
40296
+ import { writeFileSync as writeFileSync8, existsSync as existsSync8, unlinkSync as unlinkSync2 } from "fs";
40455
40297
  import { resolve as resolve4, join as join7 } from "path";
40456
40298
  init_artifact_loader();
40457
40299
  init_types();
@@ -40612,7 +40454,7 @@ async function governanceCommand(action) {
40612
40454
  }
40613
40455
  }
40614
40456
  const content = generateFile(setup);
40615
- writeFileSync9(filePath, content, "utf-8");
40457
+ writeFileSync8(filePath, content, "utf-8");
40616
40458
  const relativePath = filePath.replace(process.cwd() + "/", "");
40617
40459
  writeSuccess(`Created ${relativePath}`);
40618
40460
  console.log("");
@@ -41901,10 +41743,7 @@ async function sourceRollbackCommand(opts) {
41901
41743
  const agentId = config?.agent?.agentId;
41902
41744
  if (!agentId) throw new Error("No agentId in lua.skill.yaml. Run `lua init` first.");
41903
41745
  if (!opts.silent) {
41904
- const versioning = await getVersioningModeCached(apiKey, agentId);
41905
- if (versioning.enabled) {
41906
- writeInfo("\u26A0\uFE0F `lua source rollback` is deprecated when agent versioning is on. Use `lua version promote <version>` \u2014 instant, no re-upload required.");
41907
- }
41746
+ writeInfo("\u26A0\uFE0F `lua source rollback` is deprecated when agent versioning is on. Use `lua version promote <version>` \u2014 instant, no re-upload required.");
41908
41747
  }
41909
41748
  const fetchM = opts.fetchManifest ?? defaultFetchManifest;
41910
41749
  const fetchU = opts.fetchUrls ?? defaultFetchUrls;
@@ -41996,17 +41835,9 @@ function parseVersion2(arg) {
41996
41835
  __name(parseVersion2, "parseVersion");
41997
41836
 
41998
41837
  // src/commands/version.ts
41999
- async function assertVersioningEnabled(apiKey, agentId) {
42000
- const { enabled } = await getVersioningModeCached(apiKey, agentId);
42001
- if (!enabled) {
42002
- throw new Error("Agent versioning is not enabled for your organization. Contact your admin to enable it, or use `lua push <primitive>` for the legacy flow.");
42003
- }
42004
- }
42005
- __name(assertVersioningEnabled, "assertVersioningEnabled");
42006
41838
  async function versionCreateCommand(options = {}) {
42007
41839
  return withErrorHandling(async () => {
42008
41840
  const { apiKey, agentId } = await initializeCommand();
42009
- await assertVersioningEnabled(apiKey, agentId);
42010
41841
  let config = readYamlConfig();
42011
41842
  let backupVersion = config?.backup?.activeVersion;
42012
41843
  if (options.autoPush) {
@@ -42067,10 +41898,38 @@ async function versionCreateCommand(options = {}) {
42067
41898
  }, "version create");
42068
41899
  }
42069
41900
  __name(versionCreateCommand, "versionCreateCommand");
41901
+ function formatVersionTable(rows) {
41902
+ const header = {
41903
+ version: "VERSION",
41904
+ status: "STATUS",
41905
+ created: "CREATED",
41906
+ by: "BY",
41907
+ message: "MESSAGE"
41908
+ };
41909
+ const cols = [
41910
+ "version",
41911
+ "status",
41912
+ "created",
41913
+ "by",
41914
+ "message"
41915
+ ];
41916
+ const widths = {};
41917
+ for (const c of cols) {
41918
+ widths[c] = Math.max(header[c].length, ...rows.map((r) => r[c].length));
41919
+ }
41920
+ const fmt = /* @__PURE__ */ __name((r) => cols.map((c) => r[c].padEnd(widths[c])).join(" ").trimEnd(), "fmt");
41921
+ return [
41922
+ fmt(header),
41923
+ ...rows.map(fmt)
41924
+ ];
41925
+ }
41926
+ __name(formatVersionTable, "formatVersionTable");
42070
41927
  async function versionListCommand(options = {}) {
42071
41928
  return withErrorHandling(async () => {
41929
+ if (options.limit != null && (!Number.isInteger(options.limit) || options.limit < 1)) {
41930
+ throw new Error(`--limit must be a positive integer (got ${options.limit}).`);
41931
+ }
42072
41932
  const { apiKey, agentId } = await initializeCommand();
42073
- await assertVersioningEnabled(apiKey, agentId);
42074
41933
  const query = {};
42075
41934
  if (options.all) query.all = true;
42076
41935
  if (options.limit != null) query.limit = options.limit;
@@ -42082,18 +41941,29 @@ async function versionListCommand(options = {}) {
42082
41941
  }
42083
41942
  const versions = response.data;
42084
41943
  if (options.json) {
42085
- console.log(JSON.stringify(versions, null, 2));
41944
+ const summary = versions.map((v) => ({
41945
+ version: v.version,
41946
+ status: v.status,
41947
+ message: v.message,
41948
+ createdBy: v.createdBy,
41949
+ createdByEmail: v.createdByEmail,
41950
+ createdAt: v.createdAt,
41951
+ commitHash: v.commitHash,
41952
+ sourceManifestVersion: v.sourceManifestVersion
41953
+ }));
41954
+ console.log(JSON.stringify(summary, null, 2));
42086
41955
  } else if (versions.length === 0) {
42087
41956
  writeInfo("(no versions yet \u2014 run `lua version create` to make one)");
42088
41957
  } else {
42089
- console.log("VERSION STATUS CREATED BY MESSAGE");
42090
- for (const v of versions) {
42091
- const star = v.status === "active" ? "*" : " ";
42092
- const date = new Date(v.createdAt).toISOString().slice(0, 16).replace("T", " ");
42093
- const status = v.status.padEnd(11);
42094
- const by = (v.createdBy || "").slice(0, 10).padEnd(10);
42095
- const msg = (v.message || "").slice(0, 60);
42096
- console.log(`v${v.version}${star} ${status} ${date} ${by}${msg}`);
41958
+ const rows = versions.map((v) => ({
41959
+ version: `v${v.version}${v.status === "active" ? "*" : ""}`,
41960
+ status: v.status,
41961
+ created: new Date(v.createdAt).toISOString().slice(0, 16).replace("T", " "),
41962
+ by: v.createdByEmail || (v.createdBy ? `${v.createdBy.slice(0, 8)}\u2026` : ""),
41963
+ message: (v.message || "").slice(0, 60)
41964
+ }));
41965
+ for (const line of formatVersionTable(rows)) {
41966
+ console.log(line);
42097
41967
  }
42098
41968
  }
42099
41969
  trackEvent("cli_version_list_completed", {
@@ -42106,7 +41976,6 @@ __name(versionListCommand, "versionListCommand");
42106
41976
  async function versionShowCommand(versionArg, options = {}) {
42107
41977
  return withErrorHandling(async () => {
42108
41978
  const { apiKey, agentId } = await initializeCommand();
42109
- await assertVersioningEnabled(apiKey, agentId);
42110
41979
  const version = parseVersion2(versionArg);
42111
41980
  const api = new AgentVersionApi(BASE_URLS.API, apiKey, agentId);
42112
41981
  const response = await api.getVersion(version);
@@ -42129,7 +41998,8 @@ async function versionShowCommand(versionArg, options = {}) {
42129
41998
  console.log(` Preprocessors: ${v.snapshot.preprocessors.length}`);
42130
41999
  console.log(` Postprocessors: ${v.snapshot.postprocessors.length}`);
42131
42000
  console.log(` MCP servers: ${v.snapshot.mcpServers.length}`);
42132
- console.log(` Persona: ${v.snapshot.persona.versionId || "(none)"}`);
42001
+ const personaLabel = v.snapshot.persona.version != null ? `v${v.snapshot.persona.version}` : v.snapshot.persona.versionId || "(none)";
42002
+ console.log(` Persona: ${personaLabel}`);
42133
42003
  }
42134
42004
  trackEvent("cli_version_show_completed", {
42135
42005
  version,
@@ -42141,7 +42011,6 @@ __name(versionShowCommand, "versionShowCommand");
42141
42011
  async function versionDiffCommand(fromArg, toArg, options = {}) {
42142
42012
  return withErrorHandling(async () => {
42143
42013
  const { apiKey, agentId } = await initializeCommand();
42144
- await assertVersioningEnabled(apiKey, agentId);
42145
42014
  const from = parseVersion2(fromArg);
42146
42015
  const to = parseVersion2(toArg);
42147
42016
  const api = new AgentVersionApi(BASE_URLS.API, apiKey, agentId);
@@ -42154,6 +42023,7 @@ async function versionDiffCommand(fromArg, toArg, options = {}) {
42154
42023
  console.log(JSON.stringify(diff, null, 2));
42155
42024
  } else {
42156
42025
  console.log(`Diff v${from} \u2192 v${to}`);
42026
+ const label = /* @__PURE__ */ __name((item, fallback) => item.name ?? fallback, "label");
42157
42027
  const sections = [
42158
42028
  {
42159
42029
  name: "Skills",
@@ -42189,25 +42059,31 @@ async function versionDiffCommand(fromArg, toArg, options = {}) {
42189
42059
  }
42190
42060
  console.log(`${name}:`);
42191
42061
  for (const a of entry.added) {
42192
- console.log(` + ${a[key]}@${a.version} (added)`);
42062
+ console.log(` + ${label(a, a[key])}@${a.version} (added)`);
42193
42063
  }
42194
42064
  for (const r of entry.removed) {
42195
- console.log(` - ${r[key]}@${r.version} (removed)`);
42065
+ console.log(` - ${label(r, r[key])}@${r.version} (removed)`);
42196
42066
  }
42197
42067
  for (const c of entry.changed) {
42198
- console.log(` ~ ${c[key]} ${c.from.version} \u2192 ${c.to.version}`);
42068
+ console.log(` ~ ${label(c, c[key])} ${c.from.version} \u2192 ${c.to.version}`);
42199
42069
  }
42200
42070
  }
42201
42071
  const mcp = diff.mcpServers;
42202
42072
  if (mcp.added.length || mcp.removed.length || mcp.changed.length) {
42203
42073
  console.log("MCP servers:");
42204
- mcp.added.forEach((m) => console.log(` + ${m.id} (added)`));
42205
- mcp.removed.forEach((m) => console.log(` - ${m.id} (removed)`));
42206
- mcp.changed.forEach((m) => console.log(` ~ ${m.id} (config changed)`));
42074
+ mcp.added.forEach((m) => console.log(` + ${label(m, m.id)} (added)`));
42075
+ mcp.removed.forEach((m) => console.log(` - ${label(m, m.id)} (removed)`));
42076
+ mcp.changed.forEach((m) => console.log(` ~ ${label(m, m.id)} (config changed${m.changedFields?.length ? `: ${m.changedFields.join(", ")}` : ""})`));
42207
42077
  } else {
42208
42078
  console.log("MCP servers: (no changes)");
42209
42079
  }
42210
- console.log(`Persona: ${diff.persona ? `${diff.persona.from} \u2192 ${diff.persona.to}` : "(unchanged)"}`);
42080
+ if (!diff.persona) {
42081
+ console.log("Persona: (unchanged)");
42082
+ } else if (diff.persona.fromVersion != null && diff.persona.toVersion != null) {
42083
+ console.log(`Persona: v${diff.persona.fromVersion} \u2192 v${diff.persona.toVersion}`);
42084
+ } else {
42085
+ console.log(`Persona: ${diff.persona.from} \u2192 ${diff.persona.to}`);
42086
+ }
42211
42087
  console.log(`Model: ${diff.model ? `${diff.model.from} \u2192 ${diff.model.to}` : "(unchanged)"}`);
42212
42088
  }
42213
42089
  trackEvent("cli_version_diff_completed", {
@@ -42219,7 +42095,6 @@ __name(versionDiffCommand, "versionDiffCommand");
42219
42095
  async function versionPromoteCommand(versionArg) {
42220
42096
  return withErrorHandling(async () => {
42221
42097
  const { apiKey, agentId } = await initializeCommand();
42222
- await assertVersioningEnabled(apiKey, agentId);
42223
42098
  const version = parseVersion2(versionArg);
42224
42099
  const api = new AgentVersionApi(BASE_URLS.API, apiKey, agentId);
42225
42100
  const response = await api.promoteVersion(version);
@@ -42260,7 +42135,6 @@ __name(versionPromoteCommand, "versionPromoteCommand");
42260
42135
  async function versionDeleteCommand(versionArg, options = {}) {
42261
42136
  return withErrorHandling(async () => {
42262
42137
  const { apiKey, agentId } = await initializeCommand();
42263
- await assertVersioningEnabled(apiKey, agentId);
42264
42138
  if (versionArg === "current" || versionArg === "active") {
42265
42139
  throw new Error(`Cannot delete the active version directly. Use \`lua version promote <other>\` to roll back first, then delete.`);
42266
42140
  }
@@ -42566,7 +42440,6 @@ async function pullCommand(options = {}) {
42566
42440
  const { apiKey, agentId } = await initializeCommand();
42567
42441
  const force = Boolean(options.force);
42568
42442
  if (options.version) {
42569
- await assertVersioningEnabled(apiKey, agentId);
42570
42443
  const version = parseVersion2(options.version);
42571
42444
  const api = new AgentVersionApi(BASE_URLS.API, apiKey, agentId);
42572
42445
  const response = await api.getVersion(version);
@@ -42812,7 +42685,7 @@ Examples:
42812
42685
  $ lua deploy skill --name mySkill --set-version 1.0.5 --force Deploy specific version
42813
42686
  $ lua deploy webhook --name myWebhook --set-version latest --force Deploy latest webhook version
42814
42687
  `).action(deployCommand);
42815
- const chatCmd = program2.command("chat").description("\u{1F4AC} Interactive chat with your agent").option("-e, --env <environment>", "Environment: sandbox or production").option("-m, --message <text>", "Message to send (non-interactive mode)").option("-b, --batch <messages...>", "Send multiple messages concurrently to test batching").option("-d, --delay <ms>", "Delay between batch messages in ms (default: 100)").option("-t, --thread [id]", "Thread ID for conversation scoping. If no ID is provided, a UUID is auto-generated. Displayed at session start so you can reuse it later.").option("--clear", "Automatically clear chat history when session ends (clears thread if -t is used, otherwise clears all history)").option("--clear-thread", "Alias for --clear").addHelpText("after", `
42688
+ const chatCmd = program2.command("chat").description("\u{1F4AC} Interactive chat with your agent").option("-e, --env <environment>", "Environment: sandbox or production").option("-m, --message <text>", "Message to send (non-interactive mode)").option("-b, --batch <messages...>", "Send multiple messages concurrently to test batching").option("-d, --delay <ms>", "Delay between batch messages in ms (default: 100)").option("-t, --thread [id]", "Thread ID for conversation scoping. If no ID is provided, a UUID is auto-generated. Displayed at session start so you can reuse it later.").option("--clear", "Automatically clear chat history when session ends (clears thread if -t is used, otherwise clears all history)").option("--clear-thread", "Alias for --clear").option("--agent-version <n>", "Preview a specific (unpromoted) agent version in an isolated thread", parseAgentVersionFlag).addHelpText("after", `
42816
42689
  Examples:
42817
42690
  $ lua chat Start interactive chat session
42818
42691
  $ lua chat clear Clear all conversation history
@@ -42825,6 +42698,7 @@ Examples:
42825
42698
  $ lua chat -t my-test --clear Chat in "my-test" thread, clear on exit
42826
42699
  $ lua chat -m "test" -t my-test --clear Non-interactive: isolated thread, clear after
42827
42700
  $ lua chat -b "Hello" "What is the weather?" "Tell me a joke" -d 2000 -e sandbox Batch test
42701
+ $ lua chat --agent-version 3 -m "test" Preview agent version 3 in an isolated thread
42828
42702
  `).action(chatCommand);
42829
42703
  chatCmd.command("clear").description("Clear conversation history").option("--user <identifier>", "User ID, email, or mobile number of the user whose history to clear").option("-t, --thread <id>", "Clear a specific thread's history instead of all history").option("--force", "Skip confirmation prompt").addHelpText("after", `
42830
42704
  Examples:
@@ -43249,19 +43123,14 @@ Examples:
43249
43123
  $ lua voice test --runner vitest Force vitest
43250
43124
  `).action(voiceTestCommand);
43251
43125
  voice.command("list").description("List LuaVoice primitives in the compiled manifest").option("--json", "Output as JSON").action(voiceListCommand);
43252
- const versionGroup = program2.command("version").description("\u{1F3F7}\uFE0F Manage agent versions \u2014 atomic snapshots (requires agentVersioningEnabled for your org)").addHelpText("after", `
43253
- Note:
43254
- All \`lua version\` subcommands require the \`agentVersioningEnabled\`
43255
- feature flag for your org. If a subcommand errors with "Agent versioning
43256
- is not enabled," contact your admin to enable it.
43257
- `);
43126
+ const versionGroup = program2.command("version").description("\u{1F3F7}\uFE0F Manage agent versions \u2014 atomic snapshots of agent state");
43258
43127
  versionGroup.command("create").description("Snapshot current staged state into a new version").option("-m, --message <message>", "Optional description for this version").option("--auto-push", "Push first if local changes are not yet staged").option("--commit-hash <hash>", "Optional git commit hash to associate with this version").addHelpText("after", `
43259
43128
  Examples:
43260
43129
  $ lua version create Snapshot current state
43261
43130
  $ lua version create -m "Add FAQ skill" Include a description
43262
43131
  $ lua version create --auto-push Push then snapshot in one step
43263
43132
  `).action((opts) => versionCreateCommand(opts));
43264
- versionGroup.command("list").description("List versions of the current agent").option("--all", "Show all versions (no server-side cap)").option("--limit <n>", "Cap output to this many entries", (v) => parseInt(v, 10)).option("--status <status>", "Filter by status: active | staged | all", "all").option("--json", "Output as JSON").addHelpText("after", `
43133
+ versionGroup.command("list").description("List versions of the current agent").option("--all", "Show all versions (no server-side cap)").option("--limit <n>", "Cap output to this many entries", (v) => parseInt(v, 10)).option("--status <status>", "Filter by status: active | staged | superseded | deleted | all", "all").option("--json", "Output as JSON").addHelpText("after", `
43265
43134
  Examples:
43266
43135
  $ lua version list List all versions (default)
43267
43136
  $ lua version list --status active Show only active versions