@elevasis/sdk 1.8.3 → 1.10.0

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/cli.cjs CHANGED
@@ -102,8 +102,8 @@ var require_package = __commonJS({
102
102
  // ../../node_modules/.pnpm/dotenv@16.6.1/node_modules/dotenv/lib/main.js
103
103
  var require_main = __commonJS({
104
104
  "../../node_modules/.pnpm/dotenv@16.6.1/node_modules/dotenv/lib/main.js"(exports2, module2) {
105
- var fs = require("fs");
106
- var path2 = require("path");
105
+ var fs2 = require("fs");
106
+ var path3 = require("path");
107
107
  var os2 = require("os");
108
108
  var crypto = require("crypto");
109
109
  var packageJson = require_package();
@@ -211,7 +211,7 @@ var require_main = __commonJS({
211
211
  if (options && options.path && options.path.length > 0) {
212
212
  if (Array.isArray(options.path)) {
213
213
  for (const filepath of options.path) {
214
- if (fs.existsSync(filepath)) {
214
+ if (fs2.existsSync(filepath)) {
215
215
  possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
216
216
  }
217
217
  }
@@ -219,15 +219,15 @@ var require_main = __commonJS({
219
219
  possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
220
220
  }
221
221
  } else {
222
- possibleVaultPath = path2.resolve(process.cwd(), ".env.vault");
222
+ possibleVaultPath = path3.resolve(process.cwd(), ".env.vault");
223
223
  }
224
- if (fs.existsSync(possibleVaultPath)) {
224
+ if (fs2.existsSync(possibleVaultPath)) {
225
225
  return possibleVaultPath;
226
226
  }
227
227
  return null;
228
228
  }
229
229
  function _resolveHome(envPath2) {
230
- return envPath2[0] === "~" ? path2.join(os2.homedir(), envPath2.slice(1)) : envPath2;
230
+ return envPath2[0] === "~" ? path3.join(os2.homedir(), envPath2.slice(1)) : envPath2;
231
231
  }
232
232
  function _configVault(options) {
233
233
  const debug = Boolean(options && options.debug);
@@ -244,7 +244,7 @@ var require_main = __commonJS({
244
244
  return { parsed };
245
245
  }
246
246
  function configDotenv(options) {
247
- const dotenvPath = path2.resolve(process.cwd(), ".env");
247
+ const dotenvPath = path3.resolve(process.cwd(), ".env");
248
248
  let encoding = "utf8";
249
249
  const debug = Boolean(options && options.debug);
250
250
  const quiet = options && "quiet" in options ? options.quiet : true;
@@ -268,13 +268,13 @@ var require_main = __commonJS({
268
268
  }
269
269
  let lastError;
270
270
  const parsedAll = {};
271
- for (const path3 of optionPaths) {
271
+ for (const path4 of optionPaths) {
272
272
  try {
273
- const parsed = DotenvModule.parse(fs.readFileSync(path3, { encoding }));
273
+ const parsed = DotenvModule.parse(fs2.readFileSync(path4, { encoding }));
274
274
  DotenvModule.populate(parsedAll, parsed, options);
275
275
  } catch (e) {
276
276
  if (debug) {
277
- _debug(`Failed to load ${path3} ${e.message}`);
277
+ _debug(`Failed to load ${path4} ${e.message}`);
278
278
  }
279
279
  lastError = e;
280
280
  }
@@ -289,7 +289,7 @@ var require_main = __commonJS({
289
289
  const shortPaths = [];
290
290
  for (const filePath of optionPaths) {
291
291
  try {
292
- const relative = path2.relative(process.cwd(), filePath);
292
+ const relative = path3.relative(process.cwd(), filePath);
293
293
  shortPaths.push(relative);
294
294
  } catch (e) {
295
295
  if (debug) {
@@ -1284,8 +1284,8 @@ var require_command = __commonJS({
1284
1284
  "../../node_modules/.pnpm/commander@11.1.0/node_modules/commander/lib/command.js"(exports2) {
1285
1285
  var EventEmitter = require("events").EventEmitter;
1286
1286
  var childProcess = require("child_process");
1287
- var path2 = require("path");
1288
- var fs = require("fs");
1287
+ var path3 = require("path");
1288
+ var fs2 = require("fs");
1289
1289
  var process8 = require("process");
1290
1290
  var { Argument: Argument2, humanReadableArgName } = require_argument();
1291
1291
  var { CommanderError: CommanderError2 } = require_error();
@@ -2108,10 +2108,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
2108
2108
  let launchWithNode = false;
2109
2109
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
2110
2110
  function findFile(baseDir, baseName) {
2111
- const localBin = path2.resolve(baseDir, baseName);
2112
- if (fs.existsSync(localBin)) return localBin;
2113
- if (sourceExt.includes(path2.extname(baseName))) return void 0;
2114
- const foundExt = sourceExt.find((ext) => fs.existsSync(`${localBin}${ext}`));
2111
+ const localBin = path3.resolve(baseDir, baseName);
2112
+ if (fs2.existsSync(localBin)) return localBin;
2113
+ if (sourceExt.includes(path3.extname(baseName))) return void 0;
2114
+ const foundExt = sourceExt.find((ext) => fs2.existsSync(`${localBin}${ext}`));
2115
2115
  if (foundExt) return `${localBin}${foundExt}`;
2116
2116
  return void 0;
2117
2117
  }
@@ -2122,23 +2122,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
2122
2122
  if (this._scriptPath) {
2123
2123
  let resolvedScriptPath;
2124
2124
  try {
2125
- resolvedScriptPath = fs.realpathSync(this._scriptPath);
2125
+ resolvedScriptPath = fs2.realpathSync(this._scriptPath);
2126
2126
  } catch (err) {
2127
2127
  resolvedScriptPath = this._scriptPath;
2128
2128
  }
2129
- executableDir = path2.resolve(path2.dirname(resolvedScriptPath), executableDir);
2129
+ executableDir = path3.resolve(path3.dirname(resolvedScriptPath), executableDir);
2130
2130
  }
2131
2131
  if (executableDir) {
2132
2132
  let localFile = findFile(executableDir, executableFile);
2133
2133
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
2134
- const legacyName = path2.basename(this._scriptPath, path2.extname(this._scriptPath));
2134
+ const legacyName = path3.basename(this._scriptPath, path3.extname(this._scriptPath));
2135
2135
  if (legacyName !== this._name) {
2136
2136
  localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
2137
2137
  }
2138
2138
  }
2139
2139
  executableFile = localFile || executableFile;
2140
2140
  }
2141
- launchWithNode = sourceExt.includes(path2.extname(executableFile));
2141
+ launchWithNode = sourceExt.includes(path3.extname(executableFile));
2142
2142
  let proc;
2143
2143
  if (process8.platform !== "win32") {
2144
2144
  if (launchWithNode) {
@@ -2921,7 +2921,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2921
2921
  * @return {Command}
2922
2922
  */
2923
2923
  nameFromFilename(filename) {
2924
- this._name = path2.basename(filename, path2.extname(filename));
2924
+ this._name = path3.basename(filename, path3.extname(filename));
2925
2925
  return this;
2926
2926
  }
2927
2927
  /**
@@ -2935,9 +2935,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2935
2935
  * @param {string} [path]
2936
2936
  * @return {string|null|Command}
2937
2937
  */
2938
- executableDir(path3) {
2939
- if (path3 === void 0) return this._executableDir;
2940
- this._executableDir = path3;
2938
+ executableDir(path4) {
2939
+ if (path4 === void 0) return this._executableDir;
2940
+ this._executableDir = path4;
2941
2941
  return this;
2942
2942
  }
2943
2943
  /**
@@ -6623,14 +6623,14 @@ var require_async_iterator = __commonJS({
6623
6623
  };
6624
6624
  }
6625
6625
  function readAndResolve(iter) {
6626
- var resolve5 = iter[kLastResolve];
6627
- if (resolve5 !== null) {
6626
+ var resolve3 = iter[kLastResolve];
6627
+ if (resolve3 !== null) {
6628
6628
  var data = iter[kStream].read();
6629
6629
  if (data !== null) {
6630
6630
  iter[kLastPromise] = null;
6631
6631
  iter[kLastResolve] = null;
6632
6632
  iter[kLastReject] = null;
6633
- resolve5(createIterResult(data, false));
6633
+ resolve3(createIterResult(data, false));
6634
6634
  }
6635
6635
  }
6636
6636
  }
@@ -6638,13 +6638,13 @@ var require_async_iterator = __commonJS({
6638
6638
  process.nextTick(readAndResolve, iter);
6639
6639
  }
6640
6640
  function wrapForNext(lastPromise, iter) {
6641
- return function(resolve5, reject) {
6641
+ return function(resolve3, reject) {
6642
6642
  lastPromise.then(function() {
6643
6643
  if (iter[kEnded]) {
6644
- resolve5(createIterResult(void 0, true));
6644
+ resolve3(createIterResult(void 0, true));
6645
6645
  return;
6646
6646
  }
6647
- iter[kHandlePromise](resolve5, reject);
6647
+ iter[kHandlePromise](resolve3, reject);
6648
6648
  }, reject);
6649
6649
  };
6650
6650
  }
@@ -6664,12 +6664,12 @@ var require_async_iterator = __commonJS({
6664
6664
  return Promise.resolve(createIterResult(void 0, true));
6665
6665
  }
6666
6666
  if (this[kStream].destroyed) {
6667
- return new Promise(function(resolve5, reject) {
6667
+ return new Promise(function(resolve3, reject) {
6668
6668
  process.nextTick(function() {
6669
6669
  if (_this[kError]) {
6670
6670
  reject(_this[kError]);
6671
6671
  } else {
6672
- resolve5(createIterResult(void 0, true));
6672
+ resolve3(createIterResult(void 0, true));
6673
6673
  }
6674
6674
  });
6675
6675
  });
@@ -6692,13 +6692,13 @@ var require_async_iterator = __commonJS({
6692
6692
  return this;
6693
6693
  }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
6694
6694
  var _this2 = this;
6695
- return new Promise(function(resolve5, reject) {
6695
+ return new Promise(function(resolve3, reject) {
6696
6696
  _this2[kStream].destroy(null, function(err) {
6697
6697
  if (err) {
6698
6698
  reject(err);
6699
6699
  return;
6700
6700
  }
6701
- resolve5(createIterResult(void 0, true));
6701
+ resolve3(createIterResult(void 0, true));
6702
6702
  });
6703
6703
  });
6704
6704
  }), _Object$setPrototypeO), AsyncIteratorPrototype);
@@ -6720,15 +6720,15 @@ var require_async_iterator = __commonJS({
6720
6720
  value: stream._readableState.endEmitted,
6721
6721
  writable: true
6722
6722
  }), _defineProperty(_Object$create, kHandlePromise, {
6723
- value: function value(resolve5, reject) {
6723
+ value: function value(resolve3, reject) {
6724
6724
  var data = iterator[kStream].read();
6725
6725
  if (data) {
6726
6726
  iterator[kLastPromise] = null;
6727
6727
  iterator[kLastResolve] = null;
6728
6728
  iterator[kLastReject] = null;
6729
- resolve5(createIterResult(data, false));
6729
+ resolve3(createIterResult(data, false));
6730
6730
  } else {
6731
- iterator[kLastResolve] = resolve5;
6731
+ iterator[kLastResolve] = resolve3;
6732
6732
  iterator[kLastReject] = reject;
6733
6733
  }
6734
6734
  },
@@ -6747,12 +6747,12 @@ var require_async_iterator = __commonJS({
6747
6747
  iterator[kError] = err;
6748
6748
  return;
6749
6749
  }
6750
- var resolve5 = iterator[kLastResolve];
6751
- if (resolve5 !== null) {
6750
+ var resolve3 = iterator[kLastResolve];
6751
+ if (resolve3 !== null) {
6752
6752
  iterator[kLastPromise] = null;
6753
6753
  iterator[kLastResolve] = null;
6754
6754
  iterator[kLastReject] = null;
6755
- resolve5(createIterResult(void 0, true));
6755
+ resolve3(createIterResult(void 0, true));
6756
6756
  }
6757
6757
  iterator[kEnded] = true;
6758
6758
  });
@@ -6767,7 +6767,7 @@ var require_async_iterator = __commonJS({
6767
6767
  var require_from = __commonJS({
6768
6768
  "../../node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/from.js"(exports2, module2) {
6769
6769
  "use strict";
6770
- function asyncGeneratorStep(gen, resolve5, reject, _next, _throw, key, arg) {
6770
+ function asyncGeneratorStep(gen, resolve3, reject, _next, _throw, key, arg) {
6771
6771
  try {
6772
6772
  var info = gen[key](arg);
6773
6773
  var value = info.value;
@@ -6776,7 +6776,7 @@ var require_from = __commonJS({
6776
6776
  return;
6777
6777
  }
6778
6778
  if (info.done) {
6779
- resolve5(value);
6779
+ resolve3(value);
6780
6780
  } else {
6781
6781
  Promise.resolve(value).then(_next, _throw);
6782
6782
  }
@@ -6784,13 +6784,13 @@ var require_from = __commonJS({
6784
6784
  function _asyncToGenerator(fn) {
6785
6785
  return function() {
6786
6786
  var self2 = this, args = arguments;
6787
- return new Promise(function(resolve5, reject) {
6787
+ return new Promise(function(resolve3, reject) {
6788
6788
  var gen = fn.apply(self2, args);
6789
6789
  function _next(value) {
6790
- asyncGeneratorStep(gen, resolve5, reject, _next, _throw, "next", value);
6790
+ asyncGeneratorStep(gen, resolve3, reject, _next, _throw, "next", value);
6791
6791
  }
6792
6792
  function _throw(err) {
6793
- asyncGeneratorStep(gen, resolve5, reject, _next, _throw, "throw", err);
6793
+ asyncGeneratorStep(gen, resolve3, reject, _next, _throw, "throw", err);
6794
6794
  }
6795
6795
  _next(void 0);
6796
6796
  });
@@ -8456,10 +8456,10 @@ var require_util = __commonJS({
8456
8456
  function cloneDef2(schema) {
8457
8457
  return mergeDefs2(schema._zod.def);
8458
8458
  }
8459
- function getElementAtPath2(obj, path2) {
8460
- if (!path2)
8459
+ function getElementAtPath2(obj, path3) {
8460
+ if (!path3)
8461
8461
  return obj;
8462
- return path2.reduce((acc, key) => acc?.[key], obj);
8462
+ return path3.reduce((acc, key) => acc?.[key], obj);
8463
8463
  }
8464
8464
  function promiseAllObject2(promisesObj) {
8465
8465
  const keys = Object.keys(promisesObj);
@@ -8821,11 +8821,11 @@ var require_util = __commonJS({
8821
8821
  }
8822
8822
  return false;
8823
8823
  }
8824
- function prefixIssues2(path2, issues) {
8824
+ function prefixIssues2(path3, issues) {
8825
8825
  return issues.map((iss) => {
8826
8826
  var _a;
8827
8827
  (_a = iss).path ?? (_a.path = []);
8828
- iss.path.unshift(path2);
8828
+ iss.path.unshift(path3);
8829
8829
  return iss;
8830
8830
  });
8831
8831
  }
@@ -9029,7 +9029,7 @@ var require_errors2 = __commonJS({
9029
9029
  }
9030
9030
  function treeifyError2(error46, mapper = (issue2) => issue2.message) {
9031
9031
  const result = { errors: [] };
9032
- const processError = (error47, path2 = []) => {
9032
+ const processError = (error47, path3 = []) => {
9033
9033
  var _a, _b;
9034
9034
  for (const issue2 of error47.issues) {
9035
9035
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -9039,7 +9039,7 @@ var require_errors2 = __commonJS({
9039
9039
  } else if (issue2.code === "invalid_element") {
9040
9040
  processError({ issues: issue2.issues }, issue2.path);
9041
9041
  } else {
9042
- const fullpath = [...path2, ...issue2.path];
9042
+ const fullpath = [...path3, ...issue2.path];
9043
9043
  if (fullpath.length === 0) {
9044
9044
  result.errors.push(mapper(issue2));
9045
9045
  continue;
@@ -9071,8 +9071,8 @@ var require_errors2 = __commonJS({
9071
9071
  }
9072
9072
  function toDotPath2(_path) {
9073
9073
  const segs = [];
9074
- const path2 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
9075
- for (const seg of path2) {
9074
+ const path3 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
9075
+ for (const seg of path3) {
9076
9076
  if (typeof seg === "number")
9077
9077
  segs.push(`[${seg}]`);
9078
9078
  else if (typeof seg === "symbol")
@@ -23012,6 +23012,8 @@ __export(index_exports, {
23012
23012
  });
23013
23013
  module.exports = __toCommonJS(index_exports);
23014
23014
  var import_dotenv = __toESM(require_main(), 1);
23015
+ var import_fs2 = require("fs");
23016
+ var import_path3 = require("path");
23015
23017
 
23016
23018
  // ../../node_modules/.pnpm/commander@11.1.0/node_modules/commander/esm.mjs
23017
23019
  var import_index = __toESM(require_commander(), 1);
@@ -23525,9 +23527,6 @@ var chalk = createChalk();
23525
23527
  var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
23526
23528
  var source_default = chalk;
23527
23529
 
23528
- // src/cli/commands/check.ts
23529
- var import_path3 = require("path");
23530
-
23531
23530
  // ../../node_modules/.pnpm/ora@7.0.1/node_modules/ora/index.js
23532
23531
  var import_node_process6 = __toESM(require("node:process"), 1);
23533
23532
 
@@ -24772,10 +24771,10 @@ function mergeDefs(...defs) {
24772
24771
  function cloneDef(schema) {
24773
24772
  return mergeDefs(schema._zod.def);
24774
24773
  }
24775
- function getElementAtPath(obj, path2) {
24776
- if (!path2)
24774
+ function getElementAtPath(obj, path3) {
24775
+ if (!path3)
24777
24776
  return obj;
24778
- return path2.reduce((acc, key) => acc?.[key], obj);
24777
+ return path3.reduce((acc, key) => acc?.[key], obj);
24779
24778
  }
24780
24779
  function promiseAllObject(promisesObj) {
24781
24780
  const keys = Object.keys(promisesObj);
@@ -25136,11 +25135,11 @@ function aborted(x, startIndex = 0) {
25136
25135
  }
25137
25136
  return false;
25138
25137
  }
25139
- function prefixIssues(path2, issues) {
25138
+ function prefixIssues(path3, issues) {
25140
25139
  return issues.map((iss) => {
25141
25140
  var _a;
25142
25141
  (_a = iss).path ?? (_a.path = []);
25143
- iss.path.unshift(path2);
25142
+ iss.path.unshift(path3);
25144
25143
  return iss;
25145
25144
  });
25146
25145
  }
@@ -25302,7 +25301,7 @@ function formatError(error46, mapper = (issue2) => issue2.message) {
25302
25301
  }
25303
25302
  function treeifyError(error46, mapper = (issue2) => issue2.message) {
25304
25303
  const result = { errors: [] };
25305
- const processError = (error47, path2 = []) => {
25304
+ const processError = (error47, path3 = []) => {
25306
25305
  var _a, _b;
25307
25306
  for (const issue2 of error47.issues) {
25308
25307
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -25312,7 +25311,7 @@ function treeifyError(error46, mapper = (issue2) => issue2.message) {
25312
25311
  } else if (issue2.code === "invalid_element") {
25313
25312
  processError({ issues: issue2.issues }, issue2.path);
25314
25313
  } else {
25315
- const fullpath = [...path2, ...issue2.path];
25314
+ const fullpath = [...path3, ...issue2.path];
25316
25315
  if (fullpath.length === 0) {
25317
25316
  result.errors.push(mapper(issue2));
25318
25317
  continue;
@@ -25344,8 +25343,8 @@ function treeifyError(error46, mapper = (issue2) => issue2.message) {
25344
25343
  }
25345
25344
  function toDotPath(_path) {
25346
25345
  const segs = [];
25347
- const path2 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
25348
- for (const seg of path2) {
25346
+ const path3 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
25347
+ for (const seg of path3) {
25349
25348
  if (typeof seg === "number")
25350
25349
  segs.push(`[${seg}]`);
25351
25350
  else if (typeof seg === "symbol")
@@ -36586,6 +36585,31 @@ config(en_default());
36586
36585
  // src/cli/commands/deploy.ts
36587
36586
  var import_module = require("module");
36588
36587
 
36588
+ // ../core/src/platform/utils/validation.ts
36589
+ var UuidSchema = external_exports.string().uuid();
36590
+ var NonEmptyStringSchema = external_exports.string().trim().min(1).max(1e3);
36591
+ var ResourceTypeSchema = external_exports.enum(["agent", "workflow"]);
36592
+ var OriginResourceTypeSchema = external_exports.enum(["agent", "workflow", "scheduler", "api"]);
36593
+ var CredentialNameSchema = external_exports.string().trim().toLowerCase().min(1, "Credential name required").max(100, "Credential name too long (max 100 chars)").regex(
36594
+ /^[a-z0-9]+(-[a-z0-9]+)+$/,
36595
+ "Credential name must be lowercase letters, numbers, and hyphens in format: service-environment (e.g., gmail-prod, attio-dev)"
36596
+ );
36597
+ var OAuthProviderSchema = external_exports.enum(["google-sheets", "dropbox"]);
36598
+ var OAuthCodeSchema = external_exports.string().min(10, "Authorization code too short").max(1e3, "Authorization code too long");
36599
+ var OAuthStateParamSchema = external_exports.string().min(10, "State parameter too short").max(2048, "State parameter too long");
36600
+ var SanitizedStringSchema = external_exports.string().trim().transform((str) => str.replace(/[<>'"]/g, ""));
36601
+ var EmailSchema = external_exports.string().email();
36602
+ var UrlSchema = external_exports.string().url();
36603
+ var PaginationSchema = external_exports.object({
36604
+ limit: external_exports.coerce.number().int().min(1).max(100).default(20),
36605
+ offset: external_exports.coerce.number().int().min(0).default(0)
36606
+ });
36607
+ var TimestampSchema = external_exports.string().datetime();
36608
+ var DateRangeSchema = external_exports.object({
36609
+ startDate: external_exports.string().datetime(),
36610
+ endDate: external_exports.string().datetime()
36611
+ });
36612
+
36589
36613
  // ../core/src/platform/registry/domains.ts
36590
36614
  var DOMAINS = {
36591
36615
  // Business domains
@@ -40384,7 +40408,7 @@ function resolveApiKey(prod) {
40384
40408
  }
40385
40409
  return process.env.ELEVASIS_PLATFORM_KEY ?? "";
40386
40410
  }
40387
- function findProjectRoot(startDir) {
40411
+ function tryFindProjectRoot(startDir) {
40388
40412
  const raw = (0, import_path.resolve)(startDir);
40389
40413
  let dir;
40390
40414
  try {
@@ -40398,6 +40422,11 @@ function findProjectRoot(startDir) {
40398
40422
  if (parent === dir) break;
40399
40423
  dir = parent;
40400
40424
  }
40425
+ return null;
40426
+ }
40427
+ function findProjectRoot(startDir) {
40428
+ const root = tryFindProjectRoot(startDir);
40429
+ if (root !== null) return root;
40401
40430
  process.stderr.write(
40402
40431
  "Not inside an Elevasis project. Run this command from a project directory (an Elevasis project has a .elevasis file at its root).\n"
40403
40432
  );
@@ -40418,9 +40447,42 @@ function resolveProjectRelative(relOrAbsPath) {
40418
40447
  return (0, import_path.resolve)(getProjectRoot(), relOrAbsPath);
40419
40448
  }
40420
40449
  function findEnvFile(_startDir) {
40421
- const candidate = (0, import_path.join)(getProjectRoot(), ".env");
40450
+ const projectRoot = tryFindProjectRoot(process.cwd());
40451
+ if (projectRoot === null) return void 0;
40452
+ const candidate = (0, import_path.join)(projectRoot, ".env");
40422
40453
  return (0, import_fs.existsSync)(candidate) ? candidate : void 0;
40423
40454
  }
40455
+ function findPackageRoot(startDir) {
40456
+ const raw = (0, import_path.resolve)(startDir);
40457
+ let dir;
40458
+ try {
40459
+ dir = (0, import_fs.realpathSync)(raw);
40460
+ } catch {
40461
+ dir = raw;
40462
+ }
40463
+ const projectRoot = tryFindProjectRoot(dir);
40464
+ while (true) {
40465
+ if ((0, import_fs.existsSync)((0, import_path.join)(dir, "package.json"))) return dir;
40466
+ const parent = (0, import_path.dirname)(dir);
40467
+ if (parent === dir) break;
40468
+ if (projectRoot !== null && dir === projectRoot) break;
40469
+ dir = parent;
40470
+ }
40471
+ process.stderr.write(
40472
+ "No package.json found between the current directory and the project root.\nRemediation: run this command from inside a package directory (one that contains package.json).\n"
40473
+ );
40474
+ process.exit(1);
40475
+ }
40476
+ var _packageRoot;
40477
+ function getPackageRoot() {
40478
+ if (_packageRoot !== void 0) return _packageRoot;
40479
+ _packageRoot = isHelpOrVersionOnly() ? process.cwd() : findPackageRoot(process.cwd());
40480
+ return _packageRoot;
40481
+ }
40482
+ function resolvePackageRelative(relOrAbsPath) {
40483
+ if ((0, import_path.isAbsolute)(relOrAbsPath)) return relOrAbsPath;
40484
+ return (0, import_path.resolve)(getPackageRoot(), relOrAbsPath);
40485
+ }
40424
40486
 
40425
40487
  // src/cli/api-client.ts
40426
40488
  function getApiKey(apiUrl) {
@@ -40520,7 +40582,7 @@ function wrapAction(commandName, fn) {
40520
40582
  // package.json
40521
40583
  var package_default = {
40522
40584
  name: "@elevasis/sdk",
40523
- version: "1.8.3",
40585
+ version: "1.10.0",
40524
40586
  description: "SDK for building Elevasis organization resources",
40525
40587
  type: "module",
40526
40588
  bin: {
@@ -40534,6 +40596,10 @@ var package_default = {
40534
40596
  "./worker": {
40535
40597
  types: "./dist/types/worker/index.d.ts",
40536
40598
  import: "./dist/worker/index.js"
40599
+ },
40600
+ "./test-utils": {
40601
+ types: "./dist/test-utils/index.d.ts",
40602
+ import: "./dist/test-utils/index.js"
40537
40603
  }
40538
40604
  },
40539
40605
  files: [
@@ -40543,6 +40609,8 @@ var package_default = {
40543
40609
  "dist/types/worker/index.d.ts",
40544
40610
  "dist/types/worker/platform.d.ts",
40545
40611
  "dist/types/worker/adapters/",
40612
+ "dist/test-utils/index.js",
40613
+ "dist/test-utils/index.d.ts",
40546
40614
  "dist/cli.cjs",
40547
40615
  "reference/"
40548
40616
  ],
@@ -40581,13 +40649,13 @@ var SDK_VERSION = package_default.version;
40581
40649
 
40582
40650
  // src/cli/commands/deploy.ts
40583
40651
  function getEsbuild() {
40584
- const consumerRequire = (0, import_module.createRequire)((0, import_path2.resolve)(process.cwd(), "package.json"));
40652
+ const consumerRequire = (0, import_module.createRequire)(resolvePackageRelative("package.json"));
40585
40653
  return consumerRequire("esbuild");
40586
40654
  }
40587
40655
  async function loadTsModule(filePath) {
40588
40656
  const esbuild = getEsbuild();
40589
- const absPath = (0, import_path2.resolve)(filePath);
40590
- const tmpOut = (0, import_path2.resolve)(`.elevasis-tmp-${Date.now()}.mjs`);
40657
+ const absPath = resolvePackageRelative(filePath);
40658
+ const tmpOut = (0, import_path2.resolve)(getPackageRoot(), `.elevasis-tmp-${Date.now()}.mjs`);
40591
40659
  try {
40592
40660
  await esbuild.build({
40593
40661
  entryPoints: [absPath],
@@ -40685,7 +40753,7 @@ function registerDeployCommand(program3) {
40685
40753
  org = entryModule.default;
40686
40754
  if (!org) {
40687
40755
  validateSpinner.fail("Invalid entry: no default export found");
40688
- console.error(source_default.gray(` Entry file: ${(0, import_path2.resolve)(entryPath)}`));
40756
+ console.error(source_default.gray(` Entry file: ${resolvePackageRelative(entryPath)}`));
40689
40757
  throw new Error("Invalid entry: no default export found");
40690
40758
  }
40691
40759
  new ResourceRegistry({ [orgName]: org });
@@ -40703,7 +40771,7 @@ function registerDeployCommand(program3) {
40703
40771
  const currentVersion = org.version;
40704
40772
  if (bumpType !== null) {
40705
40773
  const newVersion = bumpVersion(currentVersion, bumpType);
40706
- const absEntryPath = (0, import_path2.resolve)(entryPath);
40774
+ const absEntryPath = resolvePackageRelative(entryPath);
40707
40775
  const entryContent = await (0, import_promises.readFile)(absEntryPath, "utf-8");
40708
40776
  const updatedContent = entryContent.replace(
40709
40777
  /version:\s*['"][\d]+\.[\d]+\.[\d]+['"]/,
@@ -40764,16 +40832,16 @@ function registerDeployCommand(program3) {
40764
40832
  console.log("");
40765
40833
  }
40766
40834
  const bundleSpinner = ora("Bundling...").start();
40767
- const wrapperPath = (0, import_path2.resolve)("__elevasis_worker.ts");
40768
- const bundleOutfile = (0, import_path2.resolve)("dist/bundle.js");
40835
+ const wrapperPath = resolvePackageRelative("__elevasis_worker.ts");
40836
+ const bundleOutfile = resolvePackageRelative("dist/bundle.js");
40769
40837
  try {
40770
- const entryImport = entryPath.replace(/\.ts$/, ".js");
40771
- const wrapperContent = `import org from ${JSON.stringify(entryImport)}
40838
+ const absEntryForImport = resolvePackageRelative(entryPath).replace(/\.ts$/, ".js");
40839
+ const wrapperContent = `import org from ${JSON.stringify(absEntryForImport)}
40772
40840
  import { startWorker } from '@elevasis/sdk/worker'
40773
40841
  startWorker(org)
40774
40842
  `;
40775
40843
  await (0, import_promises.writeFile)(wrapperPath, wrapperContent, "utf-8");
40776
- await (0, import_promises.mkdir)((0, import_path2.resolve)("dist"), { recursive: true });
40844
+ await (0, import_promises.mkdir)(resolvePackageRelative("dist"), { recursive: true });
40777
40845
  const esbuild = getEsbuild();
40778
40846
  await esbuild.build({
40779
40847
  entryPoints: [wrapperPath],
@@ -40882,7 +40950,7 @@ function registerCheckCommand(program3) {
40882
40950
  const org = entryModule.default;
40883
40951
  if (!org) {
40884
40952
  spinner.fail("Invalid entry: no default export found");
40885
- console.error(source_default.gray(` Entry file: ${(0, import_path3.resolve)(entryPath)}`));
40953
+ console.error(source_default.gray(` Entry file: ${resolvePackageRelative(entryPath)}`));
40886
40954
  console.error(source_default.gray(" Expected: export default { workflows: [...], agents: [...] }"));
40887
40955
  throw new Error("Invalid entry");
40888
40956
  }
@@ -40965,7 +41033,7 @@ async function pollForCompletion(resourceId, executionId, apiUrl) {
40965
41033
  if (interrupted) {
40966
41034
  return;
40967
41035
  }
40968
- await new Promise((resolve5) => setTimeout(resolve5, POLL_INTERVAL_MS));
41036
+ await new Promise((resolve3) => setTimeout(resolve3, POLL_INTERVAL_MS));
40969
41037
  if (interrupted) {
40970
41038
  return;
40971
41039
  }
@@ -41580,10 +41648,10 @@ Credential renamed successfully!`));
41580
41648
  var import_readline = require("readline");
41581
41649
  function confirm(message) {
41582
41650
  const rl = (0, import_readline.createInterface)({ input: process.stdin, output: process.stdout });
41583
- return new Promise((resolve5) => {
41651
+ return new Promise((resolve3) => {
41584
41652
  rl.question(message, (answer) => {
41585
41653
  rl.close();
41586
- resolve5(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
41654
+ resolve3(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
41587
41655
  });
41588
41656
  });
41589
41657
  }
@@ -42198,13 +42266,14 @@ Milestone created: ${m.name}`));
42198
42266
  );
42199
42267
  }
42200
42268
  function registerMilestoneUpdate(program3) {
42201
- program3.command("project:milestone:update <id>").description("Update a milestone\n Example: elevasis-sdk project:milestone:update <uuid> --status completed").option("--name <name>", "New milestone name").option("--status <status>", "New status: upcoming | in_progress | completed | overdue | blocked").option("--due-date <date>", "New due date (ISO 8601)").option("--checklist <json>", `Replace checklist (full array): '[{"id":"1","label":"Step","completed":false}]'`).option("--api-url <url>", "API base URL").option("--pretty", "Render human-readable output instead of raw JSON").action(
42269
+ program3.command("project:milestone:update <id>").description("Update a milestone\n Example: elevasis-sdk project:milestone:update <uuid> --status completed").option("--name <name>", "New milestone name").option("--status <status>", "New status: upcoming | in_progress | completed | overdue | blocked").option("--description <description>", "New description").option("--due-date <date>", "New due date (ISO 8601)").option("--checklist <json>", `Replace checklist (full array): '[{"id":"1","label":"Step","completed":false}]'`).option("--api-url <url>", "API base URL").option("--pretty", "Render human-readable output instead of raw JSON").action(
42202
42270
  wrapAction(
42203
42271
  "project:milestone:update",
42204
42272
  async (id, options) => {
42205
42273
  const body = {};
42206
42274
  if (options.name !== void 0) body.name = options.name;
42207
42275
  if (options.status !== void 0) body.status = options.status;
42276
+ if (options.description !== void 0) body.description = options.description;
42208
42277
  if (options.dueDate !== void 0) body.due_date = options.dueDate;
42209
42278
  if (options.checklist !== void 0) {
42210
42279
  try {
@@ -42219,7 +42288,7 @@ function registerMilestoneUpdate(program3) {
42219
42288
  if (Object.keys(body).length === 0) {
42220
42289
  process.stderr.write(
42221
42290
  JSON.stringify({
42222
- error: "At least one field must be provided (--name, --status, --due-date, --checklist)",
42291
+ error: "At least one field must be provided (--name, --status, --description, --due-date, --checklist)",
42223
42292
  code: "MISSING_FIELDS"
42224
42293
  }) + "\n"
42225
42294
  );
@@ -42535,7 +42604,148 @@ Resume context saved for task ${id}`));
42535
42604
  );
42536
42605
  }
42537
42606
 
42607
+ // ../core/src/projects/api-schemas.ts
42608
+ var ProjectKindSchema = external_exports.enum(["client_engagement", "internal", "research", "other"]);
42609
+ var ProjectStatusSchema = external_exports.enum(["active", "on_track", "at_risk", "blocked", "completed", "paused"]);
42610
+ var MilestoneStatusSchema = external_exports.enum(["upcoming", "in_progress", "completed", "overdue", "blocked"]);
42611
+ var TaskStatusSchema = external_exports.enum([
42612
+ "planned",
42613
+ "in_progress",
42614
+ "blocked",
42615
+ "completed",
42616
+ "cancelled",
42617
+ "submitted",
42618
+ "approved",
42619
+ "rejected",
42620
+ "revision_requested"
42621
+ ]);
42622
+ var TaskTypeSchema = external_exports.enum([
42623
+ "documentation",
42624
+ "code",
42625
+ "report",
42626
+ "design",
42627
+ "refactor",
42628
+ "feature",
42629
+ "bug",
42630
+ "research",
42631
+ "other"
42632
+ ]);
42633
+ var NoteTypeSchema = external_exports.enum(["call_note", "status_update", "issue", "blocker", "agent_learning"]);
42634
+ var ChecklistItemSchema = external_exports.object({
42635
+ id: external_exports.string(),
42636
+ label: external_exports.string(),
42637
+ completed: external_exports.boolean()
42638
+ });
42639
+ var ChecklistSchema = external_exports.array(ChecklistItemSchema);
42640
+ var ResumeContextSchema = external_exports.record(external_exports.string(), external_exports.unknown());
42641
+ var CreateProjectRequestSchema = external_exports.object({
42642
+ name: external_exports.string().trim().min(1).max(255),
42643
+ kind: ProjectKindSchema,
42644
+ status: ProjectStatusSchema.optional(),
42645
+ description: external_exports.string().nullable().optional(),
42646
+ deal_id: UuidSchema.nullable().optional(),
42647
+ client_company_id: UuidSchema.nullable().optional(),
42648
+ start_date: external_exports.string().nullable().optional(),
42649
+ target_end_date: external_exports.string().nullable().optional(),
42650
+ contract_value: external_exports.number().nullable().optional(),
42651
+ metadata: external_exports.record(external_exports.string(), external_exports.unknown()).nullable().optional()
42652
+ }).strict();
42653
+ var UpdateProjectRequestSchema = external_exports.object({
42654
+ name: external_exports.string().trim().min(1).max(255).optional(),
42655
+ kind: ProjectKindSchema.optional(),
42656
+ status: ProjectStatusSchema.optional(),
42657
+ description: external_exports.string().nullable().optional(),
42658
+ deal_id: UuidSchema.nullable().optional(),
42659
+ client_company_id: UuidSchema.nullable().optional(),
42660
+ start_date: external_exports.string().nullable().optional(),
42661
+ target_end_date: external_exports.string().nullable().optional(),
42662
+ actual_end_date: external_exports.string().nullable().optional(),
42663
+ contract_value: external_exports.number().nullable().optional(),
42664
+ metadata: external_exports.record(external_exports.string(), external_exports.unknown()).nullable().optional()
42665
+ }).strict().refine((data) => Object.keys(data).length > 0, { message: "At least one field must be provided" });
42666
+ var GetProjectsQuerySchema = external_exports.object({
42667
+ kind: ProjectKindSchema.optional(),
42668
+ status: ProjectStatusSchema.optional(),
42669
+ search: external_exports.string().trim().min(1).max(255).optional()
42670
+ }).strict();
42671
+ var ProjectIdParamsSchema = external_exports.object({ id: UuidSchema });
42672
+ var CreateMilestoneRequestSchema = external_exports.object({
42673
+ name: external_exports.string().trim().min(1).max(255),
42674
+ status: MilestoneStatusSchema.optional(),
42675
+ description: external_exports.string().nullable().optional(),
42676
+ due_date: external_exports.string().nullable().optional(),
42677
+ sequence: external_exports.number().int().min(0).optional(),
42678
+ metadata: external_exports.record(external_exports.string(), external_exports.unknown()).nullable().optional()
42679
+ }).strict();
42680
+ var UpdateMilestoneRequestSchema = external_exports.object({
42681
+ name: external_exports.string().trim().min(1).max(255).optional(),
42682
+ status: MilestoneStatusSchema.optional(),
42683
+ description: external_exports.string().nullable().optional(),
42684
+ due_date: external_exports.string().nullable().optional(),
42685
+ completed_at: external_exports.string().nullable().optional(),
42686
+ sequence: external_exports.number().int().min(0).optional(),
42687
+ checklist: ChecklistSchema.optional(),
42688
+ metadata: external_exports.record(external_exports.string(), external_exports.unknown()).nullable().optional()
42689
+ }).strict().refine((data) => Object.keys(data).length > 0, { message: "At least one field must be provided" });
42690
+ var ProjectIdPathParamsSchema = external_exports.object({ projectId: UuidSchema });
42691
+ var MilestoneIdParamsSchema = external_exports.object({ id: UuidSchema });
42692
+ var CreateTaskRequestSchema = external_exports.object({
42693
+ project_id: UuidSchema,
42694
+ name: external_exports.string().trim().min(1).max(255),
42695
+ type: TaskTypeSchema.optional(),
42696
+ status: TaskStatusSchema.optional(),
42697
+ description: external_exports.string().nullable().optional(),
42698
+ milestone_id: UuidSchema.nullable().optional(),
42699
+ parent_task_id: UuidSchema.nullable().optional(),
42700
+ due_date: external_exports.string().nullable().optional(),
42701
+ checklist: ChecklistSchema.optional(),
42702
+ resume_context: ResumeContextSchema.nullable().optional(),
42703
+ metadata: external_exports.record(external_exports.string(), external_exports.unknown()).nullable().optional()
42704
+ }).strict();
42705
+ var UpdateTaskRequestSchema = external_exports.object({
42706
+ name: external_exports.string().trim().min(1).max(255).optional(),
42707
+ type: TaskTypeSchema.optional(),
42708
+ status: TaskStatusSchema.optional(),
42709
+ description: external_exports.string().nullable().optional(),
42710
+ milestone_id: UuidSchema.nullable().optional(),
42711
+ parent_task_id: UuidSchema.nullable().optional(),
42712
+ due_date: external_exports.string().nullable().optional(),
42713
+ completed_at: external_exports.string().nullable().optional(),
42714
+ checklist: ChecklistSchema.optional(),
42715
+ resume_context: ResumeContextSchema.nullable().optional(),
42716
+ file_url: external_exports.string().nullable().optional(),
42717
+ metadata: external_exports.record(external_exports.string(), external_exports.unknown()).nullable().optional()
42718
+ }).strict().refine((data) => Object.keys(data).length > 0, { message: "At least one field must be provided" });
42719
+ var MergeResumeContextRequestSchema = external_exports.record(external_exports.string(), external_exports.unknown()).refine((data) => Object.keys(data).length > 0, { message: "At least one field must be provided" });
42720
+ var GetTasksQuerySchema = external_exports.object({
42721
+ status: TaskStatusSchema.optional(),
42722
+ milestone_id: UuidSchema.optional(),
42723
+ parent_task_id: UuidSchema.optional()
42724
+ }).strict();
42725
+ var TaskIdParamsSchema = external_exports.object({ id: UuidSchema });
42726
+ var CreateNoteRequestSchema = external_exports.object({
42727
+ project_id: UuidSchema,
42728
+ content: external_exports.string().trim().min(1),
42729
+ type: NoteTypeSchema.optional(),
42730
+ summary: external_exports.string().nullable().optional(),
42731
+ task_id: UuidSchema.nullable().optional(),
42732
+ milestone_id: UuidSchema.nullable().optional(),
42733
+ occurred_at: external_exports.string().optional(),
42734
+ metadata: external_exports.record(external_exports.string(), external_exports.unknown()).nullable().optional()
42735
+ }).strict();
42736
+ var UpdateNoteRequestSchema = external_exports.object({
42737
+ content: external_exports.string().trim().min(1).optional(),
42738
+ type: NoteTypeSchema.optional(),
42739
+ summary: external_exports.string().nullable().optional(),
42740
+ task_id: UuidSchema.nullable().optional(),
42741
+ milestone_id: UuidSchema.nullable().optional(),
42742
+ occurred_at: external_exports.string().optional(),
42743
+ metadata: external_exports.record(external_exports.string(), external_exports.unknown()).nullable().optional()
42744
+ }).strict().refine((data) => Object.keys(data).length > 0, { message: "At least one field must be provided" });
42745
+ var NoteIdParamsSchema = external_exports.object({ id: UuidSchema });
42746
+
42538
42747
  // src/cli/commands/project/notes.ts
42748
+ var NOTE_TYPE_HELP = NoteTypeSchema.options.join(" | ");
42539
42749
  function registerNoteList(program3) {
42540
42750
  program3.command("project:note:list").description("List notes for a project\n Example: elevasis-sdk project:note:list --project <uuid>").requiredOption("--project <project-id>", "Project ID (UUID)").option("--api-url <url>", "API base URL").option("--pretty", "Render human-readable output instead of raw JSON").action(
42541
42751
  wrapAction("project:note:list", async (options) => {
@@ -42565,7 +42775,7 @@ Notes (${notes.length}):
42565
42775
  function registerNoteCreate(program3) {
42566
42776
  program3.command("project:note:create").description(
42567
42777
  'Create a note\n Example: elevasis-sdk project:note:create --project <uuid> --content "Status update"'
42568
- ).requiredOption("--project <project-id>", "Project ID (UUID)").requiredOption("--content <content>", "Note content").option("--task <task-id>", "Attach to a task (UUID)").option("--milestone <milestone-id>", "Attach to a milestone (UUID)").option("--type <type>", "Note type: call_note | status_update | issue | blocker | agent_learning").option("--api-url <url>", "API base URL").option("--pretty", "Render human-readable output instead of raw JSON").action(
42778
+ ).requiredOption("--project <project-id>", "Project ID (UUID)").requiredOption("--content <content>", "Note content").option("--task <task-id>", "Attach to a task (UUID)").option("--milestone <milestone-id>", "Attach to a milestone (UUID)").option("--type <type>", `Note type: ${NOTE_TYPE_HELP}`).option("--api-url <url>", "API base URL").option("--pretty", "Render human-readable output instead of raw JSON").action(
42569
42779
  wrapAction(
42570
42780
  "project:note:create",
42571
42781
  async (options) => {
@@ -42694,9 +42904,16 @@ var ListRequestsQuerySchema = external_exports.object({
42694
42904
  });
42695
42905
 
42696
42906
  // src/cli/commands/request/request.ts
42907
+ var REQUEST_TYPE_HELP = RequestTypeEnum.options.join(" | ");
42908
+ var REQUEST_CATEGORY_HELP = RequestCategoryEnum.options.join(" | ");
42909
+ var REQUEST_SEVERITY_HELP = RequestSeverityEnum.options.join(" | ");
42697
42910
  function registerRequestCommands(program3) {
42698
42911
  program3.command("request:submit").description(
42699
- "Submit a structured request report via POST /api/external/requests\n Example: elevasis-sdk request:submit -f ./request-report.json"
42912
+ `Submit a structured request report via POST /api/external/requests
42913
+ Example: elevasis-sdk request:submit -f ./request-report.json
42914
+ type: ${REQUEST_TYPE_HELP}
42915
+ category: ${REQUEST_CATEGORY_HELP}
42916
+ severity: ${REQUEST_SEVERITY_HELP}`
42700
42917
  ).option("-i, --input <json>", "Request body as JSON string").option(
42701
42918
  "-f, --input-file <path>",
42702
42919
  "Read request body from a JSON file (e.g. request-report.json, avoids shell escaping). Relative paths resolve against the project root."
@@ -42747,9 +42964,151 @@ ${issues}`);
42747
42964
  );
42748
42965
  }
42749
42966
 
42750
- // src/cli/commands/doctor.ts
42751
- var import_node_fs3 = require("node:fs");
42967
+ // src/cli/commands/ui/ui-switcher.ts
42968
+ var import_node_child_process = require("node:child_process");
42969
+ var import_node_fs3 = __toESM(require("node:fs"), 1);
42752
42970
  var import_node_path3 = __toESM(require("node:path"), 1);
42971
+ function run(command, args, cwd) {
42972
+ (0, import_node_child_process.execFileSync)(command, args, {
42973
+ cwd,
42974
+ stdio: "inherit",
42975
+ shell: process.platform === "win32"
42976
+ });
42977
+ }
42978
+ function readJson(filePath) {
42979
+ return JSON.parse(import_node_fs3.default.readFileSync(filePath, "utf8"));
42980
+ }
42981
+ function writeJson(filePath, value) {
42982
+ import_node_fs3.default.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}
42983
+ `);
42984
+ }
42985
+ function requireDependencies(packageJson, filePath) {
42986
+ if (!packageJson.dependencies) {
42987
+ throw new Error(`${filePath} does not define dependencies`);
42988
+ }
42989
+ return packageJson.dependencies;
42990
+ }
42991
+ function resolveExistingDir(label, dir) {
42992
+ const resolved = import_node_path3.default.resolve(dir);
42993
+ if (!import_node_fs3.default.existsSync(resolved) || !import_node_fs3.default.statSync(resolved).isDirectory()) {
42994
+ throw new Error(`${label} not found: ${resolved}`);
42995
+ }
42996
+ return resolved;
42997
+ }
42998
+ function findRepoRootFromProject(projectRoot) {
42999
+ let dir = projectRoot;
43000
+ while (true) {
43001
+ if (import_node_fs3.default.existsSync(import_node_path3.default.join(dir, "packages", "ui", "package.json"))) return dir;
43002
+ const parent = import_node_path3.default.dirname(dir);
43003
+ if (parent === dir) return null;
43004
+ dir = parent;
43005
+ }
43006
+ }
43007
+ function resolveUiPackageRoot(projectRoot, explicitRoot) {
43008
+ if (explicitRoot) return resolveExistingDir("UI package root", explicitRoot);
43009
+ const repoRoot = findRepoRootFromProject(projectRoot);
43010
+ if (repoRoot === null) {
43011
+ throw new Error(
43012
+ "Could not find packages/ui from this Elevasis project. Pass --ui-package-root <path> from a monorepo checkout."
43013
+ );
43014
+ }
43015
+ return import_node_path3.default.join(repoRoot, "packages", "ui");
43016
+ }
43017
+ function removeLocalUiTarballs(templateTmpDir) {
43018
+ if (!import_node_fs3.default.existsSync(templateTmpDir)) return;
43019
+ for (const entry of import_node_fs3.default.readdirSync(templateTmpDir)) {
43020
+ if (entry.startsWith("elevasis-ui-") && entry.endsWith(".tgz")) {
43021
+ import_node_fs3.default.rmSync(import_node_path3.default.join(templateTmpDir, entry), { force: true });
43022
+ }
43023
+ }
43024
+ }
43025
+ function prepareUiPackageForPack(uiPackageJson) {
43026
+ const publishConfig = uiPackageJson.publishConfig ?? {};
43027
+ const packedPackageJson = {
43028
+ ...uiPackageJson,
43029
+ name: publishConfig.name ?? uiPackageJson.name
43030
+ };
43031
+ if (publishConfig.exports) packedPackageJson.exports = publishConfig.exports;
43032
+ if (publishConfig.peerDependencies) packedPackageJson.peerDependencies = publishConfig.peerDependencies;
43033
+ if (publishConfig.peerDependenciesMeta) packedPackageJson.peerDependenciesMeta = publishConfig.peerDependenciesMeta;
43034
+ delete packedPackageJson.publishConfig;
43035
+ return packedPackageJson;
43036
+ }
43037
+ function useLocalUi(options = {}) {
43038
+ const projectRoot = getProjectRoot();
43039
+ const repoRoot = findRepoRootFromProject(projectRoot);
43040
+ const uiPackageRoot = resolveUiPackageRoot(projectRoot, options.uiPackageRoot);
43041
+ const commandRoot = repoRoot ?? import_node_path3.default.dirname(import_node_path3.default.dirname(uiPackageRoot));
43042
+ const templateUiPackageJsonPath = import_node_path3.default.join(projectRoot, "ui", "package.json");
43043
+ const templateTmpDir = import_node_path3.default.join(projectRoot, "tmp");
43044
+ const uiPackageJsonPath = import_node_path3.default.join(uiPackageRoot, "package.json");
43045
+ const uiPackageBackupPath = import_node_path3.default.join(uiPackageRoot, "package.json.local-pack.bak");
43046
+ if (!import_node_fs3.default.existsSync(templateUiPackageJsonPath)) {
43047
+ throw new Error(`Template UI package.json not found: ${templateUiPackageJsonPath}`);
43048
+ }
43049
+ import_node_fs3.default.mkdirSync(templateTmpDir, { recursive: true });
43050
+ removeLocalUiTarballs(templateTmpDir);
43051
+ run("pnpm", ["--filter", "@repo/ui", "build:publish"], commandRoot);
43052
+ try {
43053
+ const raw = import_node_fs3.default.readFileSync(uiPackageJsonPath, "utf8");
43054
+ import_node_fs3.default.writeFileSync(uiPackageBackupPath, raw);
43055
+ writeJson(uiPackageJsonPath, prepareUiPackageForPack(JSON.parse(raw)));
43056
+ run("pnpm", ["-C", uiPackageRoot, "pack", "--pack-destination", templateTmpDir], commandRoot);
43057
+ } finally {
43058
+ if (import_node_fs3.default.existsSync(uiPackageBackupPath)) {
43059
+ import_node_fs3.default.copyFileSync(uiPackageBackupPath, uiPackageJsonPath);
43060
+ import_node_fs3.default.rmSync(uiPackageBackupPath, { force: true });
43061
+ }
43062
+ }
43063
+ const tarballName = import_node_fs3.default.readdirSync(templateTmpDir).find((entry) => entry.startsWith("elevasis-ui-") && entry.endsWith(".tgz"));
43064
+ if (!tarballName) {
43065
+ throw new Error(`Failed to create local @elevasis/ui tarball in ${templateTmpDir}`);
43066
+ }
43067
+ const templateUiPackageJson = readJson(templateUiPackageJsonPath);
43068
+ requireDependencies(templateUiPackageJson, templateUiPackageJsonPath)["@elevasis/ui"] = `file:../tmp/${tarballName}`;
43069
+ writeJson(templateUiPackageJsonPath, templateUiPackageJson);
43070
+ run("pnpm", ["-C", projectRoot, "install"], commandRoot);
43071
+ console.log(`${import_node_path3.default.basename(projectRoot)}/ui now uses local @elevasis/ui tarball: ${tarballName}`);
43072
+ }
43073
+ function usePublishedUi(options = {}) {
43074
+ const projectRoot = getProjectRoot();
43075
+ const repoRoot = findRepoRootFromProject(projectRoot);
43076
+ const commandRoot = repoRoot ?? projectRoot;
43077
+ const templateUiPackageJsonPath = import_node_path3.default.join(projectRoot, "ui", "package.json");
43078
+ const templateTmpDir = import_node_path3.default.join(projectRoot, "tmp");
43079
+ const uiPackageRoot = options.version ? void 0 : resolveUiPackageRoot(projectRoot, options.uiPackageRoot);
43080
+ const uiVersion = options.version ?? readJson(import_node_path3.default.join(uiPackageRoot, "package.json")).version;
43081
+ if (!uiVersion) {
43082
+ throw new Error("Could not determine @elevasis/ui version. Pass --version <version>.");
43083
+ }
43084
+ if (!import_node_fs3.default.existsSync(templateUiPackageJsonPath)) {
43085
+ throw new Error(`Template UI package.json not found: ${templateUiPackageJsonPath}`);
43086
+ }
43087
+ const templateUiPackageJson = readJson(templateUiPackageJsonPath);
43088
+ requireDependencies(templateUiPackageJson, templateUiPackageJsonPath)["@elevasis/ui"] = `^${uiVersion}`;
43089
+ writeJson(templateUiPackageJsonPath, templateUiPackageJson);
43090
+ removeLocalUiTarballs(templateTmpDir);
43091
+ run("pnpm", ["-C", projectRoot, "install"], commandRoot);
43092
+ console.log(`${import_node_path3.default.basename(projectRoot)}/ui restored to published @elevasis/ui ^${uiVersion}`);
43093
+ }
43094
+
43095
+ // src/cli/commands/ui/ui.ts
43096
+ function registerUiCommands(program3) {
43097
+ program3.command("ui:use-local").description("Switch this Elevasis project to a local @elevasis/ui tarball").option("--ui-package-root <path>", "Path to the local packages/ui checkout").action(
43098
+ wrapAction("ui:use-local", async (options) => {
43099
+ useLocalUi(options);
43100
+ })
43101
+ );
43102
+ program3.command("ui:use-published").description("Restore this Elevasis project to a published @elevasis/ui dependency").option("--ui-package-root <path>", "Path to the local packages/ui checkout used to infer the version").option("--version <version>", "Explicit @elevasis/ui version to restore").action(
43103
+ wrapAction("ui:use-published", async (options) => {
43104
+ usePublishedUi(options);
43105
+ })
43106
+ );
43107
+ }
43108
+
43109
+ // src/cli/commands/doctor.ts
43110
+ var import_node_fs4 = require("node:fs");
43111
+ var import_node_path4 = __toESM(require("node:path"), 1);
42753
43112
  function ok(label, detail) {
42754
43113
  console.log(`${source_default.green("[OK]")} ${source_default.bold(label)}: ${detail}`);
42755
43114
  }
@@ -42785,8 +43144,8 @@ function registerDoctorCommand(program3) {
42785
43144
  printSummary(failCount);
42786
43145
  process.exit(1);
42787
43146
  }
42788
- const envPath2 = import_node_path3.default.join(projectRoot, ".env");
42789
- const envExists = (0, import_node_fs3.existsSync)(envPath2);
43147
+ const envPath2 = import_node_path4.default.join(projectRoot, ".env");
43148
+ const envExists = (0, import_node_fs4.existsSync)(envPath2);
42790
43149
  if (!envExists) {
42791
43150
  fail(".env", `Not found at ${envPath2}. Create it from .env.example and fill in ELEVASIS_PLATFORM_KEY.`);
42792
43151
  if (isVerbose) verbose(`Checked: ${envPath2}`);
@@ -42873,74 +43232,53 @@ function printSummary(failCount) {
42873
43232
  }
42874
43233
  }
42875
43234
 
42876
- // src/cli/commands/init-claude.ts
42877
- var import_path4 = require("path");
42878
- var import_fs2 = require("fs");
42879
- var import_url = require("url");
42880
- var import_meta = {};
42881
- var _filename = import_meta.url ? (0, import_url.fileURLToPath)(import_meta.url) : process.argv[1];
42882
- var _dirname = (0, import_path4.dirname)(_filename);
42883
- function copyDirectoryRecursive(sourceDir, targetDir) {
42884
- if (!(0, import_fs2.existsSync)(sourceDir)) return 0;
42885
- let count = 0;
42886
- for (const entry of (0, import_fs2.readdirSync)(sourceDir, { withFileTypes: true })) {
42887
- const srcPath = (0, import_path4.join)(sourceDir, entry.name);
42888
- const destPath = (0, import_path4.join)(targetDir, entry.name);
42889
- if (entry.isDirectory()) {
42890
- count += copyDirectoryRecursive(srcPath, destPath);
42891
- } else {
42892
- (0, import_fs2.mkdirSync)((0, import_path4.dirname)(destPath), { recursive: true });
42893
- (0, import_fs2.writeFileSync)(destPath, (0, import_fs2.readFileSync)(srcPath, "utf-8"), "utf-8");
42894
- count++;
42895
- }
43235
+ // src/cli/index.ts
43236
+ var PREFLIGHT_SKIP_FLAGS = /* @__PURE__ */ new Set(["--help", "-h", "--version", "-V"]);
43237
+ var LOCAL_PROJECT_COMMANDS = /* @__PURE__ */ new Set(["ui:use-local", "ui:use-published"]);
43238
+ function shouldSkipPreflight() {
43239
+ const args = process.argv.slice(2);
43240
+ if (args.length === 0) return true;
43241
+ return args.every((a) => PREFLIGHT_SKIP_FLAGS.has(a));
43242
+ }
43243
+ function isLocalProjectCommand() {
43244
+ return LOCAL_PROJECT_COMMANDS.has(process.argv[2] ?? "");
43245
+ }
43246
+ function runPreflight() {
43247
+ if (shouldSkipPreflight()) return;
43248
+ const projectRoot = tryFindProjectRoot(process.cwd());
43249
+ if (projectRoot === null) {
43250
+ process.stderr.write(
43251
+ source_default.red("Not inside an Elevasis project. Run from a directory under one containing `.elevasis`.\n")
43252
+ );
43253
+ process.stderr.write(
43254
+ source_default.gray("Remediation: cd into your Elevasis project (e.g. external/my-project/) and retry.\n")
43255
+ );
43256
+ process.exit(1);
42896
43257
  }
42897
- return count;
42898
- }
42899
- function listFilesRecursive(dir, prefix = "") {
42900
- for (const entry of (0, import_fs2.readdirSync)(dir, { withFileTypes: true })) {
42901
- const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
42902
- if (entry.isDirectory()) {
42903
- listFilesRecursive((0, import_path4.join)(dir, entry.name), rel);
42904
- } else {
42905
- console.log(source_default.gray(` .claude/${rel}`));
42906
- }
43258
+ if (isLocalProjectCommand()) return;
43259
+ const envPath2 = (0, import_path3.join)(projectRoot, ".env");
43260
+ if (!(0, import_fs2.existsSync)(envPath2)) {
43261
+ process.stderr.write(source_default.red(`No \`.env\` found at \`${envPath2}\`. Set \`ELEVASIS_PLATFORM_KEY\`.
43262
+ `));
43263
+ process.stderr.write(
43264
+ source_default.gray(`Remediation: copy \`.env.example\` to \`${envPath2}\` and fill in ELEVASIS_PLATFORM_KEY.
43265
+ `)
43266
+ );
43267
+ process.exit(1);
43268
+ }
43269
+ if (!process.env.ELEVASIS_PLATFORM_KEY) {
43270
+ process.stderr.write(source_default.red(`\`ELEVASIS_PLATFORM_KEY\` missing from \`${envPath2}\`.
43271
+ `));
43272
+ process.stderr.write(source_default.gray("Remediation: add ELEVASIS_PLATFORM_KEY=sk_... to your .env file.\n"));
43273
+ process.exit(1);
42907
43274
  }
42908
43275
  }
42909
- function registerInitClaudeCommand(program3) {
42910
- program3.command("init-claude").description("Initialize or update .claude/ configuration from SDK defaults").option("--dry-run", "Show what would be copied without writing files").action(
42911
- wrapAction("init-claude", async (options) => {
42912
- const spinner = ora("Initializing .claude/ configuration...").start();
42913
- const claudeConfigSource = (0, import_path4.resolve)(_dirname, "..", "reference", "claude-config");
42914
- if (!(0, import_fs2.existsSync)(claudeConfigSource)) {
42915
- spinner.fail("Claude config source not found in SDK package");
42916
- console.error(source_default.gray(` Expected: ${claudeConfigSource}`));
42917
- console.error(source_default.gray(" This may indicate an incomplete SDK build."));
42918
- throw new Error("Claude config source not found");
42919
- }
42920
- const targetDir = (0, import_path4.resolve)(process.cwd(), ".claude");
42921
- if (options.dryRun) {
42922
- spinner.info("Dry run -- listing files that would be copied:");
42923
- listFilesRecursive(claudeConfigSource);
42924
- return;
42925
- }
42926
- const count = copyDirectoryRecursive(claudeConfigSource, targetDir);
42927
- spinner.succeed(
42928
- source_default.green(".claude/ configuration initialized") + source_default.gray(` (${count} file${count !== 1 ? "s" : ""} written)`)
42929
- );
42930
- })
42931
- );
42932
- }
42933
-
42934
- // src/cli/index.ts
42935
43276
  var envPath = findEnvFile();
42936
43277
  if (envPath) {
42937
43278
  const result = (0, import_dotenv.config)({ path: envPath, override: true });
42938
43279
  if (result.error) {
42939
43280
  console.error(source_default.yellow(`\u26A0 Found .env at ${envPath} but failed to load it: ${result.error.message}`));
42940
43281
  }
42941
- } else if (!process.env.ELEVASIS_PLATFORM_KEY) {
42942
- console.error(source_default.yellow(`\u26A0 No .env file found at ${getProjectRoot()}/.env`));
42943
- console.error(source_default.gray(" Set ELEVASIS_PLATFORM_KEY in a .env at your project root."));
42944
43282
  }
42945
43283
  var program2 = new Command();
42946
43284
  program2.name("elevasis-sdk").description(
@@ -42959,12 +43297,16 @@ Commands:
42959
43297
  elevasis-sdk project:resolve <query> Resolve a project ID from a name or UUID
42960
43298
  elevasis-sdk project:work <query> Open a lifecycle-aware project work brief
42961
43299
  elevasis-sdk request:submit -f <path> Submit a structured request report
43300
+ elevasis-sdk ui:use-local Use a local @elevasis/ui tarball
43301
+ elevasis-sdk ui:use-published Restore published @elevasis/ui
42962
43302
  elevasis-sdk rename <id> --to <newId> [--prod] Rename resource across platform tables
42963
- elevasis-sdk init-claude Initialize .claude/ config from SDK
42964
43303
  elevasis-sdk doctor [--verbose] Check project environment and API connectivity
42965
43304
 
42966
43305
  Use "elevasis-sdk <command> --help" for more information about a command.`
42967
43306
  ).version(SDK_VERSION);
43307
+ program2.hook("preAction", () => {
43308
+ runPreflight();
43309
+ });
42968
43310
  registerCheckCommand(program2);
42969
43311
  registerDeployCommand(program2);
42970
43312
  registerExecCommand(program2);
@@ -42978,8 +43320,8 @@ registerErrorCommand(program2);
42978
43320
  registerRenameCommand(program2);
42979
43321
  registerProjectCommands(program2);
42980
43322
  registerRequestCommands(program2);
43323
+ registerUiCommands(program2);
42981
43324
  registerDoctorCommand(program2);
42982
- registerInitClaudeCommand(program2);
42983
43325
  program2.parse();
42984
43326
  // Annotate the CommonJS export names for ESM import in node:
42985
43327
  0 && (module.exports = {