lua-cli 3.20.0 → 3.21.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/index.js CHANGED
@@ -8,8 +8,13 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
8
8
  if (typeof require !== "undefined") return require.apply(this, arguments);
9
9
  throw Error('Dynamic require of "' + x + '" is not supported');
10
10
  });
11
- var __esm = (fn, res) => function __init() {
12
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
+ var __esm = (fn, res, err) => function __init() {
12
+ if (err) throw err[0];
13
+ try {
14
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
15
+ } catch (e) {
16
+ throw err = [e], e;
17
+ }
13
18
  };
14
19
  var __export = (target, all) => {
15
20
  for (var name in all)
@@ -1449,7 +1454,8 @@ Feel free to add, remove, or rename sections. Your persona can be a single parag
1449
1454
  "mcp",
1450
1455
  "rag",
1451
1456
  "device",
1452
- "device-trigger"
1457
+ "device-trigger",
1458
+ "model-resolver"
1453
1459
  ];
1454
1460
  VoiceNameSchema = z.string().regex(/^[a-zA-Z0-9_-]+$/, "Voice name must contain only alphanumeric characters, underscores, or hyphens").min(1).max(64);
1455
1461
  PluginProviderSchema = z.enum([
@@ -21021,6 +21027,106 @@ function runBundleInContext(context, source, options) {
21021
21027
  }
21022
21028
  __name(runBundleInContext, "runBundleInContext");
21023
21029
  __name4(runBundleInContext, "runBundleInContext");
21030
+ var USER_CODE_ERROR_CODE = "USER_CODE_ERROR";
21031
+ var PLATFORM_VM_ERROR_CODE = "PLATFORM_VM_ERROR";
21032
+ var UserCodeError = class extends Error {
21033
+ static {
21034
+ __name(this, "UserCodeError");
21035
+ }
21036
+ static {
21037
+ __name4(this, "UserCodeError");
21038
+ }
21039
+ code = USER_CODE_ERROR_CODE;
21040
+ source;
21041
+ constructor(source, cause) {
21042
+ super(cause instanceof Error ? cause.message : String(cause), {
21043
+ cause
21044
+ });
21045
+ this.name = "UserCodeError";
21046
+ this.source = source;
21047
+ if (cause instanceof Error && cause.stack) {
21048
+ this.stack = cause.stack;
21049
+ }
21050
+ }
21051
+ };
21052
+ function isUserCodeError(error) {
21053
+ if (!error || typeof error !== "object") return false;
21054
+ return error.code === USER_CODE_ERROR_CODE;
21055
+ }
21056
+ __name(isUserCodeError, "isUserCodeError");
21057
+ __name4(isUserCodeError, "isUserCodeError");
21058
+ function isPlatformVmError(error) {
21059
+ if (!error || typeof error !== "object") return false;
21060
+ return error.code === PLATFORM_VM_ERROR_CODE;
21061
+ }
21062
+ __name(isPlatformVmError, "isPlatformVmError");
21063
+ __name4(isPlatformVmError, "isPlatformVmError");
21064
+ var DEFAULT_MAX_CAUSE_DEPTH = 10;
21065
+ function findUserCodeErrorInCauseChain(value, maxDepth = DEFAULT_MAX_CAUSE_DEPTH) {
21066
+ let current = value;
21067
+ for (let depth = 0; depth < maxDepth; depth++) {
21068
+ if (isUserCodeError(current)) return current;
21069
+ if (!current || typeof current !== "object") return null;
21070
+ const next = current.cause;
21071
+ if (next === current || next === value) return null;
21072
+ current = next;
21073
+ }
21074
+ return null;
21075
+ }
21076
+ __name(findUserCodeErrorInCauseChain, "findUserCodeErrorInCauseChain");
21077
+ __name4(findUserCodeErrorInCauseChain, "findUserCodeErrorInCauseChain");
21078
+ var MissingPrimitiveCodeError = class extends Error {
21079
+ static {
21080
+ __name(this, "MissingPrimitiveCodeError");
21081
+ }
21082
+ static {
21083
+ __name4(this, "MissingPrimitiveCodeError");
21084
+ }
21085
+ code = PLATFORM_VM_ERROR_CODE;
21086
+ source;
21087
+ // The message reaches the customer's vmExecutionLogs dashboard (via Mastra's
21088
+ // re-wrap → LuaMastraLogger.logToMongo), so it must be customer-safe: no
21089
+ // internal ticket refs, no jargon, and it must NOT imply the customer's code
21090
+ // is at fault (it isn't — the artifact exists; delivery failed). Internal
21091
+ // triage keys off the error NAME + PLATFORM_VM_ERROR code + ERROR level, not
21092
+ // this prose.
21093
+ constructor(source) {
21094
+ super(`This ${source}'s code could not be loaded due to a temporary platform issue and was not executed. Please try again shortly.`);
21095
+ this.name = "MissingPrimitiveCodeError";
21096
+ this.source = source;
21097
+ }
21098
+ };
21099
+ function assertPrimitiveCodePresent(code, source) {
21100
+ if (typeof code !== "string" || code.length === 0) {
21101
+ throw new MissingPrimitiveCodeError(source);
21102
+ }
21103
+ }
21104
+ __name(assertPrimitiveCodePresent, "assertPrimitiveCodePresent");
21105
+ __name4(assertPrimitiveCodePresent, "assertPrimitiveCodePresent");
21106
+ async function withUserCodeBoundary(source, fn) {
21107
+ try {
21108
+ return await fn();
21109
+ } catch (cause) {
21110
+ if (isUserCodeError(cause)) throw cause;
21111
+ if (isPlatformVmError(cause)) throw cause;
21112
+ throw new UserCodeError(source, cause);
21113
+ }
21114
+ }
21115
+ __name(withUserCodeBoundary, "withUserCodeBoundary");
21116
+ __name4(withUserCodeBoundary, "withUserCodeBoundary");
21117
+ function logUserCodeOrError(logger, message, error, context = {}) {
21118
+ if (isUserCodeError(error)) {
21119
+ logger.warn(`${message} (user code)`, {
21120
+ ...context,
21121
+ source: error.source,
21122
+ error: error.message
21123
+ });
21124
+ } else {
21125
+ logger.error(message, error, context);
21126
+ }
21127
+ }
21128
+ __name(logUserCodeOrError, "logUserCodeOrError");
21129
+ __name4(logUserCodeOrError, "logUserCodeOrError");
21024
21130
 
21025
21131
  // src/utils/env-loader.utils.ts
21026
21132
  import path15 from "path";
@@ -22142,66 +22248,89 @@ var ALIAS_MAP = {
22142
22248
  del: "delete"
22143
22249
  })
22144
22250
  },
22145
- "marketplace.role": {
22251
+ "marketplace.noun": {
22146
22252
  canonical: [
22147
- "create",
22148
- "install"
22253
+ "skill",
22254
+ "template"
22149
22255
  ],
22150
22256
  aliases: lowerKeys({
22151
- creator: "create",
22152
- new: "create",
22153
- publish: "create",
22154
- installer: "install",
22155
- consumer: "install",
22156
- use: "install"
22257
+ skills: "skill",
22258
+ templates: "template",
22259
+ "agent-template": "template",
22260
+ "agent-templates": "template"
22157
22261
  })
22158
22262
  },
22159
- "marketplace.action.create": {
22263
+ // Flat skill-marketplace action namespace. `list`/`publish`/`edit`/`unlist`/
22264
+ // `unpublish`/`mine` are the old creator actions; `search`/`view`/`install`/
22265
+ // `update`/`uninstall`/`installed` are the old installer actions.
22266
+ "marketplace.skill.action": {
22160
22267
  canonical: [
22161
22268
  "list",
22162
22269
  "publish",
22163
- "update",
22270
+ "edit",
22164
22271
  "unlist",
22165
22272
  "unpublish",
22166
- "view"
22273
+ "mine",
22274
+ "search",
22275
+ "view",
22276
+ "install",
22277
+ "update",
22278
+ "uninstall",
22279
+ "installed"
22167
22280
  ],
22168
22281
  aliases: lowerKeys({
22169
22282
  ls: "list",
22170
22283
  l: "list",
22171
22284
  new: "publish",
22172
22285
  submit: "publish",
22173
- edit: "update",
22174
- modify: "update",
22286
+ modify: "edit",
22175
22287
  hide: "unlist",
22176
- delete: "unpublish",
22177
- remove: "unpublish",
22178
- rm: "unpublish",
22288
+ delist: "unlist",
22289
+ retract: "unpublish",
22290
+ deprecate: "unpublish",
22291
+ my: "mine",
22292
+ "my-listings": "mine",
22293
+ listed: "mine",
22294
+ find: "search",
22179
22295
  show: "view",
22180
- info: "view"
22296
+ info: "view",
22297
+ details: "view",
22298
+ add: "install",
22299
+ upgrade: "update",
22300
+ remove: "uninstall",
22301
+ rm: "uninstall",
22302
+ delete: "uninstall"
22181
22303
  })
22182
22304
  },
22183
- "marketplace.action.install": {
22305
+ "template.action": {
22184
22306
  canonical: [
22185
- "search",
22307
+ "create",
22308
+ "publish",
22186
22309
  "view",
22310
+ "versions",
22187
22311
  "install",
22188
- "update",
22189
- "uninstall",
22190
- "installed"
22312
+ "apply",
22313
+ "status",
22314
+ "installed",
22315
+ "uninstall"
22191
22316
  ],
22192
22317
  aliases: lowerKeys({
22193
- find: "search",
22318
+ new: "create",
22319
+ publish_version: "publish",
22320
+ submit: "publish",
22194
22321
  show: "view",
22195
22322
  info: "view",
22323
+ details: "view",
22324
+ history: "versions",
22196
22325
  add: "install",
22197
- edit: "update",
22198
- upgrade: "update",
22326
+ deploy: "apply",
22327
+ "fleet-apply": "apply",
22328
+ rollout: "apply",
22329
+ ls: "installed",
22330
+ list: "installed",
22199
22331
  remove: "uninstall",
22200
22332
  rm: "uninstall",
22201
- delete: "uninstall",
22202
- list: "installed",
22203
- ls: "installed",
22204
- l: "installed"
22333
+ delete: "uninstall"
22205
22334
  })
22206
22335
  },
22207
22336
  "models.action": {
@@ -25806,16 +25935,14 @@ var ChatApi = class extends HttpClient {
25806
25935
  }
25807
25936
  }
25808
25937
  /**
25809
- * Clears conversation history for an agent
25938
+ * Clears the authenticated user's conversation history for an agent
25810
25939
  * @param agentId - The unique identifier of the agent
25811
- * @param targetIdentifier - Optional user identifier to clear history for specific user
25812
25940
  * @param threadId - Optional thread ID to clear a specific conversation thread
25813
25941
  * @returns Promise resolving to an ApiResponse with confirmation
25814
25942
  * @throws Error if the agent is not found or the clear operation fails
25815
25943
  */
25816
- async clearHistory(agentId, targetIdentifier, threadId) {
25944
+ async clearHistory(agentId, threadId) {
25817
25945
  const params = new URLSearchParams();
25818
- if (targetIdentifier) params.set("targetIdentifier", targetIdentifier);
25819
25946
  if (threadId) params.set("threadId", threadId);
25820
25947
  const query = params.toString() ? `?${params.toString()}` : "";
25821
25948
  const url = `/chat/history/${agentId}${query}`;
@@ -26984,7 +27111,7 @@ __name(startChatLoop, "startChatLoop");
26984
27111
  async function clearOnExit(chatEnv) {
26985
27112
  try {
26986
27113
  const chatApi = new ChatApi(BASE_URLS.CHAT, chatEnv.apiKey);
26987
- const response = await chatApi.clearHistory(chatEnv.agentId, void 0, chatEnv.threadId);
27114
+ const response = await chatApi.clearHistory(chatEnv.agentId, chatEnv.threadId);
26988
27115
  if (response.success) {
26989
27116
  const scope = chatEnv.threadId ? ` for thread "${chatEnv.threadId}"` : "";
26990
27117
  console.log(`
@@ -27248,22 +27375,22 @@ init_analytics();
27248
27375
  async function chatClearCommand(options, command) {
27249
27376
  return withErrorHandling(async () => {
27250
27377
  const resolvedOptions = options ?? {};
27378
+ if (resolvedOptions.user) {
27379
+ throw new Error("The --user option was removed: cross-user history clear is no longer supported. This command only clears your own chat history \u2014 re-run it without --user.");
27380
+ }
27251
27381
  const { agentId, apiKey } = await initializeCommand();
27252
- const targetIdentifier = resolvedOptions.user;
27253
27382
  const threadId = resolvedOptions.thread ?? command?.parent?.opts()?.thread;
27254
27383
  const force = !!resolvedOptions.force;
27255
- const userContext = targetIdentifier ? `for user ${targetIdentifier}` : "for your current user";
27256
27384
  const threadContext = threadId ? ` in thread "${threadId}"` : "";
27257
- const context = `${userContext}${threadContext}`;
27258
27385
  if (!force) {
27259
27386
  console.log(`
27260
- \u26A0\uFE0F WARNING: This will clear conversation history ${context}!`);
27387
+ \u26A0\uFE0F WARNING: This will clear your conversation history${threadContext}!`);
27261
27388
  console.log("\u26A0\uFE0F This action cannot be undone.\n");
27262
27389
  const confirmAnswer = await safePrompt([
27263
27390
  {
27264
27391
  type: "confirm",
27265
27392
  name: "confirm",
27266
- message: `Are you sure you want to clear the conversation history ${context}?`,
27393
+ message: `Are you sure you want to clear your conversation history${threadContext}?`,
27267
27394
  default: false
27268
27395
  }
27269
27396
  ]);
@@ -27273,16 +27400,15 @@ async function chatClearCommand(options, command) {
27273
27400
  }
27274
27401
  writeProgress("\u{1F504} Clearing conversation history...");
27275
27402
  const chatApi = new ChatApi(BASE_URLS.CHAT, apiKey);
27276
- const response = await chatApi.clearHistory(agentId, targetIdentifier, threadId);
27403
+ const response = await chatApi.clearHistory(agentId, threadId);
27277
27404
  if (!response.success) {
27278
27405
  throw new Error(response.error?.message || "Failed to clear conversation history");
27279
27406
  }
27280
- writeSuccess(`\u2705 Conversation history cleared successfully ${context}`);
27281
- console.log(`\u{1F4A1} The chat history has been completely removed ${context}.
27407
+ writeSuccess(`\u2705 Your conversation history has been cleared${threadContext}`);
27408
+ console.log(`\u{1F4A1} Your chat history has been completely removed${threadContext}.
27282
27409
  `);
27283
27410
  trackEvent("cli_chat_cleared", {
27284
27411
  force_mode: force,
27285
- has_user_target: !!targetIdentifier,
27286
27412
  has_thread_target: !!threadId
27287
27413
  });
27288
27414
  }, "chat clear");
@@ -37233,48 +37359,828 @@ init_developer_api_service();
37233
37359
  init_semver();
37234
37360
  init_analytics();
37235
37361
  import inquirer14 from "inquirer";
37236
- async function marketplaceCommand(role, action, options) {
37237
- return withErrorHandling(async () => {
37238
- const { config, apiKey } = await initializeCommand();
37239
- const marketplaceApi = new MarketplaceApiService(apiKey);
37240
- let selectedRole = null;
37241
- if (role) {
37242
- const normalizedRole = validateOrSuggest("marketplace.role", role);
37243
- selectedRole = normalizedRole === "create" ? "creator" : "installer";
37244
- }
37245
- if (selectedRole && action) {
37246
- if (selectedRole === "creator") {
37247
- const normalizedAction = validateOrSuggest("marketplace.action.create", action);
37248
- await executeCreatorActionNonInteractive(marketplaceApi, config, apiKey, normalizedAction, options || {});
37249
- } else {
37250
- const normalizedAction = validateOrSuggest("marketplace.action.install", action);
37251
- await executeInstallerActionNonInteractive(marketplaceApi, config, apiKey, normalizedAction, options || {});
37362
+
37363
+ // src/commands/template.ts
37364
+ init_cli();
37365
+ import { readFileSync as readFileSync13 } from "fs";
37366
+
37367
+ // src/api/template.api.service.ts
37368
+ init_constants();
37369
+ var TemplateApiService = class {
37370
+ static {
37371
+ __name(this, "TemplateApiService");
37372
+ }
37373
+ apiKey;
37374
+ baseUrl = BASE_URLS.API;
37375
+ constructor(apiKey) {
37376
+ this.apiKey = apiKey;
37377
+ }
37378
+ async _fetch(endpoint, options = {}) {
37379
+ const url = `${this.baseUrl}${endpoint}`;
37380
+ const headers = {
37381
+ Authorization: `Bearer ${this.apiKey}`,
37382
+ "Content-Type": "application/json",
37383
+ ...options.headers
37384
+ };
37385
+ const response = await fetch(url, {
37386
+ ...options,
37387
+ headers
37388
+ });
37389
+ if (!response.ok) {
37390
+ const errorText = await response.text();
37391
+ throw new Error(`API Error: ${response.status} ${response.statusText} - ${errorText}`);
37392
+ }
37393
+ if (response.status === 204) {
37394
+ return null;
37395
+ }
37396
+ return response.json();
37397
+ }
37398
+ async createTemplate(data) {
37399
+ return this._fetch("/marketplace/templates", {
37400
+ method: "POST",
37401
+ body: JSON.stringify(data)
37402
+ });
37403
+ }
37404
+ async createVersion(templateId, data) {
37405
+ return this._fetch(`/marketplace/templates/${templateId}/versions`, {
37406
+ method: "POST",
37407
+ body: JSON.stringify(data)
37408
+ });
37409
+ }
37410
+ async listTemplates() {
37411
+ return this._fetch("/marketplace/templates");
37412
+ }
37413
+ async getTemplate(templateId) {
37414
+ return this._fetch(`/marketplace/templates/${templateId}`);
37415
+ }
37416
+ async getVersions(templateId) {
37417
+ return this._fetch(`/marketplace/templates/${templateId}/versions`);
37418
+ }
37419
+ async getVersion(templateId, version) {
37420
+ return this._fetch(`/marketplace/templates/${templateId}/versions/${version}`);
37421
+ }
37422
+ async install(templateId, agentId, data) {
37423
+ return this._fetch(`/marketplace/templates/${templateId}/install/${agentId}`, {
37424
+ method: "POST",
37425
+ body: JSON.stringify(data)
37426
+ });
37427
+ }
37428
+ async apply(templateId, data) {
37429
+ return this._fetch(`/marketplace/templates/${templateId}/apply`, {
37430
+ method: "POST",
37431
+ body: JSON.stringify(data)
37432
+ });
37433
+ }
37434
+ async getApplyRun(templateId, runId) {
37435
+ return this._fetch(`/marketplace/templates/${templateId}/apply-runs/${runId}`);
37436
+ }
37437
+ async getInstalls(templateId, page, limit) {
37438
+ const params = new URLSearchParams();
37439
+ if (page !== void 0) params.set("page", String(page));
37440
+ if (limit !== void 0) params.set("limit", String(limit));
37441
+ const query = params.toString();
37442
+ return this._fetch(`/marketplace/templates/${templateId}/installs${query ? `?${query}` : ""}`);
37443
+ }
37444
+ async getAllInstalls(templateId) {
37445
+ const pageSize = 1e3;
37446
+ const all = [];
37447
+ for (let page = 1; ; page++) {
37448
+ const batch = await this.getInstalls(templateId, page, pageSize);
37449
+ all.push(...batch);
37450
+ if (batch.length < pageSize) return all;
37451
+ }
37452
+ }
37453
+ async getAgentTemplates(agentId) {
37454
+ return this._fetch(`/marketplace/templates/agent/${agentId}`);
37455
+ }
37456
+ async uninstall(templateId, agentId) {
37457
+ return this._fetch(`/marketplace/templates/${templateId}/installs/${agentId}`, {
37458
+ method: "DELETE"
37459
+ });
37460
+ }
37461
+ };
37462
+
37463
+ // src/commands/template.ts
37464
+ init_command_utils();
37465
+ init_analytics();
37466
+ function showTemplateUsage() {
37467
+ console.log("\nUsage:");
37468
+ console.log(" lua marketplace template Interactive mode");
37469
+ console.log(" lua marketplace template <action> [options] Non-interactive mode");
37470
+ console.log("\nActions:");
37471
+ console.log(" create --name <n> --display-name <n> [--description <text>] [--visibility public|private]");
37472
+ console.log(" publish --template-id <id> [--source-version <n>] [--changelog <text>] [--env-contract KEY=desc,...]");
37473
+ console.log(" view --template-id <id> [--version <n>] [--json]");
37474
+ console.log(" versions --template-id <id> [--json]");
37475
+ console.log(" install --template-id <id> [--version <n>] [--env-vars k=v,...] --force");
37476
+ console.log(" apply --template-id <id> [--version <n>] (--agents a,b | --file <path> | --all-installed) --force [--no-wait]");
37477
+ console.log(" status --template-id <id> [--json]");
37478
+ console.log(" installed [--json]");
37479
+ console.log(" uninstall --template-id <id> --force");
37480
+ }
37481
+ __name(showTemplateUsage, "showTemplateUsage");
37482
+ async function templateCommand(action, options = {}) {
37483
+ const { config, apiKey } = await initializeCommand();
37484
+ const templateApi = new TemplateApiService(apiKey);
37485
+ let selectedAction;
37486
+ if (action) {
37487
+ selectedAction = validateOrSuggest("template.action", action);
37488
+ } else {
37489
+ const answer = await safePrompt([
37490
+ {
37491
+ type: "list",
37492
+ name: "action",
37493
+ message: "What would you like to do?",
37494
+ choices: [
37495
+ {
37496
+ name: "Create a template from this agent",
37497
+ value: "create"
37498
+ },
37499
+ {
37500
+ name: "Publish a new template version",
37501
+ value: "publish"
37502
+ },
37503
+ {
37504
+ name: "View a template",
37505
+ value: "view"
37506
+ },
37507
+ {
37508
+ name: "List a template\u2019s versions",
37509
+ value: "versions"
37510
+ },
37511
+ {
37512
+ name: "Install a template onto this agent",
37513
+ value: "install"
37514
+ },
37515
+ {
37516
+ name: "Apply a template to a fleet of agents",
37517
+ value: "apply"
37518
+ },
37519
+ {
37520
+ name: "View a template\u2019s fleet install status",
37521
+ value: "status"
37522
+ },
37523
+ {
37524
+ name: "List templates installed on this agent",
37525
+ value: "installed"
37526
+ },
37527
+ {
37528
+ name: "Uninstall a template from this agent",
37529
+ value: "uninstall"
37530
+ },
37531
+ {
37532
+ name: "Exit",
37533
+ value: "exit"
37534
+ }
37535
+ ]
37252
37536
  }
37537
+ ]);
37538
+ if (!answer || answer.action === "exit") {
37539
+ console.log("\n\u{1F44B} Goodbye!\n");
37253
37540
  return;
37254
37541
  }
37255
- if (selectedRole) {
37256
- if (selectedRole === "creator") {
37257
- await handleCreatorActions(marketplaceApi, config, apiKey);
37258
- } else {
37259
- await handleInstallerActions(marketplaceApi, config, apiKey);
37542
+ selectedAction = answer.action;
37543
+ }
37544
+ switch (selectedAction) {
37545
+ case "create":
37546
+ await templateCreateAction(templateApi, config, options);
37547
+ break;
37548
+ case "publish":
37549
+ await templatePublishAction(templateApi, options);
37550
+ break;
37551
+ case "view":
37552
+ await templateViewAction(templateApi, options);
37553
+ break;
37554
+ case "versions":
37555
+ await templateVersionsAction(templateApi, options);
37556
+ break;
37557
+ case "install":
37558
+ await templateInstallAction(templateApi, config, options);
37559
+ break;
37560
+ case "apply":
37561
+ await templateApplyAction(templateApi, options);
37562
+ break;
37563
+ case "status":
37564
+ await templateStatusAction(templateApi, options);
37565
+ break;
37566
+ case "installed":
37567
+ await templateInstalledAction(templateApi, config, options);
37568
+ break;
37569
+ case "uninstall":
37570
+ await templateUninstallAction(templateApi, config, options);
37571
+ break;
37572
+ default:
37573
+ showTemplateUsage();
37574
+ }
37575
+ trackEvent("cli_template_action", {
37576
+ action: selectedAction,
37577
+ non_interactive: !!action
37578
+ });
37579
+ }
37580
+ __name(templateCommand, "templateCommand");
37581
+ function sleep2(ms) {
37582
+ return new Promise((resolve6) => setTimeout(resolve6, ms));
37583
+ }
37584
+ __name(sleep2, "sleep");
37585
+ async function resolveTemplateId(templateApi, options, message) {
37586
+ if (options.templateId) return options.templateId;
37587
+ writeProgress("\u{1F504} Loading your templates...");
37588
+ const { templates } = await templateApi.listTemplates();
37589
+ if (!templates.length) {
37590
+ throw new Error("You haven't created any templates yet. Run `lua marketplace template create` first.");
37591
+ }
37592
+ const answer = await safePrompt([
37593
+ {
37594
+ type: "list",
37595
+ name: "template",
37596
+ message,
37597
+ choices: templates.map((t) => ({
37598
+ name: `${t.displayName} (${t.name})`,
37599
+ value: t
37600
+ }))
37601
+ }
37602
+ ]);
37603
+ if (!answer) throw new Error("Cancelled.");
37604
+ return answer.template.id;
37605
+ }
37606
+ __name(resolveTemplateId, "resolveTemplateId");
37607
+ function parseKeyValuePairs(raw) {
37608
+ const result = {};
37609
+ for (const pair of raw.split(",")) {
37610
+ const [key, ...valueParts] = pair.split("=");
37611
+ if (key && valueParts.length > 0) {
37612
+ result[key.trim()] = valueParts.join("=").trim();
37613
+ }
37614
+ }
37615
+ return result;
37616
+ }
37617
+ __name(parseKeyValuePairs, "parseKeyValuePairs");
37618
+ function parseEnvContract(raw) {
37619
+ if (!raw || raw.length === 0) return void 0;
37620
+ const result = {};
37621
+ for (const entry of raw) {
37622
+ for (const pair of entry.split(",")) {
37623
+ const trimmed = pair.trim();
37624
+ if (!trimmed) continue;
37625
+ const eqIdx = trimmed.indexOf("=");
37626
+ if (eqIdx === -1) continue;
37627
+ let key = trimmed.slice(0, eqIdx).trim();
37628
+ const description = trimmed.slice(eqIdx + 1).trim();
37629
+ let required = true;
37630
+ if (key.endsWith("?")) {
37631
+ required = false;
37632
+ key = key.slice(0, -1).trim();
37633
+ }
37634
+ if (!key) continue;
37635
+ result[key] = {
37636
+ description,
37637
+ required
37638
+ };
37639
+ }
37640
+ }
37641
+ return Object.keys(result).length > 0 ? result : void 0;
37642
+ }
37643
+ __name(parseEnvContract, "parseEnvContract");
37644
+ function printManifestSummary(content) {
37645
+ console.log(` Skills: ${content.skills.length}`);
37646
+ console.log(` Webhooks: ${content.webhooks.length}`);
37647
+ console.log(` Jobs: ${content.jobs.length}`);
37648
+ console.log(` Preprocessors: ${content.preprocessors.length}`);
37649
+ console.log(` Postprocessors: ${content.postprocessors.length}`);
37650
+ console.log(` Triggers: ${content.triggers.length}`);
37651
+ console.log(` Model: ${content.model ?? "(unchanged)"}`);
37652
+ }
37653
+ __name(printManifestSummary, "printManifestSummary");
37654
+ function printManifestDetail(content, envContract) {
37655
+ const sections = [
37656
+ {
37657
+ name: "Skills",
37658
+ items: content.skills
37659
+ },
37660
+ {
37661
+ name: "Webhooks",
37662
+ items: content.webhooks
37663
+ },
37664
+ {
37665
+ name: "Jobs",
37666
+ items: content.jobs
37667
+ },
37668
+ {
37669
+ name: "Preprocessors",
37670
+ items: content.preprocessors
37671
+ },
37672
+ {
37673
+ name: "Postprocessors",
37674
+ items: content.postprocessors
37675
+ },
37676
+ {
37677
+ name: "Triggers",
37678
+ items: content.triggers
37679
+ }
37680
+ ];
37681
+ for (const { name, items } of sections) {
37682
+ console.log(`
37683
+ ${name}:`);
37684
+ if (items.length === 0) {
37685
+ console.log(" (none)");
37686
+ continue;
37687
+ }
37688
+ for (const item of items) {
37689
+ console.log(` ${item.name ?? item.key} \u2014 v${item.version} (${item.key})`);
37690
+ }
37691
+ }
37692
+ console.log(`
37693
+ Model: ${content.model ?? "(none)"}`);
37694
+ console.log(`
37695
+ Env contract:`);
37696
+ const entries = envContract ? Object.entries(envContract) : [];
37697
+ if (entries.length === 0) {
37698
+ console.log(" (none)");
37699
+ } else {
37700
+ for (const [key, meta] of entries) {
37701
+ const optionalTag = meta.required ? "" : " (optional)";
37702
+ const example = meta.example ? ` \u2014 e.g. ${meta.example}` : "";
37703
+ console.log(` ${key}${optionalTag}: ${meta.description}${example}`);
37704
+ }
37705
+ }
37706
+ }
37707
+ __name(printManifestDetail, "printManifestDetail");
37708
+ async function templateCreateAction(templateApi, config, options) {
37709
+ const agentId = config.agent?.agentId;
37710
+ if (!agentId) throw new Error("Agent ID not found in configuration.");
37711
+ let { name, displayName, description, visibility } = options;
37712
+ if (visibility && visibility !== "public" && visibility !== "private") {
37713
+ throw new Error('Invalid --visibility: must be "public" or "private"');
37714
+ }
37715
+ const questions = [];
37716
+ if (!name) {
37717
+ questions.push({
37718
+ type: "input",
37719
+ name: "name",
37720
+ message: "Template name (internal identifier):",
37721
+ validate: /* @__PURE__ */ __name((input) => input && input.trim().length > 0 ? true : "Name cannot be empty.", "validate")
37722
+ });
37723
+ }
37724
+ if (!displayName) {
37725
+ questions.push({
37726
+ type: "input",
37727
+ name: "displayName",
37728
+ message: "Display name:",
37729
+ validate: /* @__PURE__ */ __name((input) => input && input.trim().length > 0 ? true : "Display name cannot be empty.", "validate")
37730
+ });
37731
+ }
37732
+ if (description === void 0) {
37733
+ questions.push({
37734
+ type: "input",
37735
+ name: "description",
37736
+ message: "Description (optional):"
37737
+ });
37738
+ }
37739
+ if (!visibility) {
37740
+ questions.push({
37741
+ type: "list",
37742
+ name: "visibility",
37743
+ message: "Who can see and install this template?",
37744
+ choices: [
37745
+ {
37746
+ name: "Private \u2014 only your org can find and install it",
37747
+ value: "private"
37748
+ },
37749
+ {
37750
+ name: "Public \u2014 anyone can find and install it",
37751
+ value: "public"
37752
+ }
37753
+ ],
37754
+ default: "private"
37755
+ });
37756
+ }
37757
+ if (questions.length > 0) {
37758
+ const answers = await safePrompt(questions);
37759
+ if (!answers) throw new Error("Cancelled.");
37760
+ name = name ?? answers.name;
37761
+ displayName = displayName ?? answers.displayName;
37762
+ description = description ?? answers.description;
37763
+ visibility = visibility ?? answers.visibility;
37764
+ }
37765
+ if (!name || !displayName) {
37766
+ throw new Error("Missing required options: --name and --display-name");
37767
+ }
37768
+ writeProgress("\u{1F504} Creating template...");
37769
+ const template = await templateApi.createTemplate({
37770
+ sourceAgentId: agentId,
37771
+ name,
37772
+ displayName,
37773
+ description: description || void 0,
37774
+ visibility
37775
+ });
37776
+ if (options.json) {
37777
+ console.log(JSON.stringify(template, null, 2));
37778
+ return;
37779
+ }
37780
+ writeSuccess(`\u2705 Template "${template.displayName}" created!`);
37781
+ writeInfo(`Template ID: ${template.id}`);
37782
+ writeInfo(`Visibility: ${template.visibility === "private" ? "\u{1F512} Private" : "\u{1F310} Public"}`);
37783
+ writeHintBlock({
37784
+ headline: "Publish a version to make it installable:",
37785
+ lines: [
37786
+ {
37787
+ label: "Publish:",
37788
+ command: `lua marketplace template publish --template-id ${template.id}`
37260
37789
  }
37790
+ ],
37791
+ when: "success"
37792
+ });
37793
+ }
37794
+ __name(templateCreateAction, "templateCreateAction");
37795
+ async function templatePublishAction(templateApi, options) {
37796
+ const templateId = await resolveTemplateId(templateApi, options, "Which template would you like to publish a version for?");
37797
+ const sourceAgentVersion = options.sourceVersion ? Number.parseInt(options.sourceVersion, 10) : void 0;
37798
+ if (options.sourceVersion && (!Number.isFinite(sourceAgentVersion) || sourceAgentVersion <= 0)) {
37799
+ throw new Error(`Invalid --source-version "${options.sourceVersion}": must be a positive integer.`);
37800
+ }
37801
+ const envContract = parseEnvContract(options.envContract);
37802
+ writeProgress("\u{1F504} Publishing template version...");
37803
+ const version = await templateApi.createVersion(templateId, {
37804
+ sourceAgentVersion,
37805
+ changelog: options.changelog || void 0,
37806
+ envContract
37807
+ });
37808
+ if (options.json) {
37809
+ console.log(JSON.stringify(version, null, 2));
37810
+ return;
37811
+ }
37812
+ writeSuccess(`\u2705 Published v${version.version}`);
37813
+ writeInfo(`Frozen from agent version v${version.sourceAgentVersion}`);
37814
+ console.log("\nManifest:");
37815
+ printManifestSummary(version.content);
37816
+ const envCount = version.envContract ? Object.keys(version.envContract).length : 0;
37817
+ console.log(` Env contract: ${envCount} var(s)`);
37818
+ }
37819
+ __name(templatePublishAction, "templatePublishAction");
37820
+ async function templateViewAction(templateApi, options) {
37821
+ const templateId = await resolveTemplateId(templateApi, options, "Which template would you like to view?");
37822
+ if (options.version) {
37823
+ const versionNum = Number.parseInt(options.version, 10);
37824
+ if (!Number.isFinite(versionNum) || versionNum <= 0) {
37825
+ throw new Error(`Invalid --version "${options.version}": must be a positive integer.`);
37826
+ }
37827
+ const version = await templateApi.getVersion(templateId, versionNum).catch(() => null);
37828
+ if (!version) throw new Error(`Version v${versionNum} not found for this template.`);
37829
+ if (options.json) {
37830
+ console.log(JSON.stringify(version, null, 2));
37261
37831
  return;
37262
37832
  }
37263
- let exit = false;
37264
- while (!exit) {
37265
- const roleAnswer = await safePrompt([
37833
+ console.log(`
37834
+ ${"=".repeat(60)}`);
37835
+ console.log(`Template v${version.version} \u2014 ${templateId}`);
37836
+ console.log(`${"=".repeat(60)}`);
37837
+ if (version.changelog) console.log(`
37838
+ Changelog: ${version.changelog}`);
37839
+ printManifestDetail(version.content, version.envContract);
37840
+ return;
37841
+ }
37842
+ const template = await templateApi.getTemplate(templateId);
37843
+ if (options.json) {
37844
+ console.log(JSON.stringify(template, null, 2));
37845
+ return;
37846
+ }
37847
+ console.log(`
37848
+ ${"=".repeat(60)}`);
37849
+ console.log(`\u{1F4E6} ${template.displayName}`);
37850
+ console.log(`${"=".repeat(60)}
37851
+ `);
37852
+ console.log(`ID: ${template.id}`);
37853
+ console.log(`Name: ${template.name}`);
37854
+ if (template.description) console.log(`Description: ${template.description}`);
37855
+ console.log(`Visibility: ${template.visibility === "private" ? "\u{1F512} Private" : "\u{1F310} Public"}`);
37856
+ console.log(`Listed: ${template.listed ? "Yes" : "No"}`);
37857
+ console.log(`Installs: ${template.installCount}`);
37858
+ if (template.latestVersion != null) console.log(`Latest version: v${template.latestVersion}`);
37859
+ console.log(`Created: ${new Date(template.createdAt).toLocaleDateString()}`);
37860
+ console.log(`
37861
+ ${"=".repeat(60)}
37862
+ `);
37863
+ }
37864
+ __name(templateViewAction, "templateViewAction");
37865
+ async function templateVersionsAction(templateApi, options) {
37866
+ const templateId = await resolveTemplateId(templateApi, options, "Which template\u2019s versions would you like to see?");
37867
+ const versions = await templateApi.getVersions(templateId);
37868
+ if (options.json) {
37869
+ console.log(JSON.stringify(versions, null, 2));
37870
+ return;
37871
+ }
37872
+ if (versions.length === 0) {
37873
+ writeInfo("(no versions yet \u2014 run `lua marketplace template publish` to make one)");
37874
+ return;
37875
+ }
37876
+ const sorted = [
37877
+ ...versions
37878
+ ].sort((a, b) => b.version - a.version);
37879
+ for (const v of sorted) {
37880
+ console.log(`v${v.version} \u2014 from agent v${v.sourceAgentVersion} \u2014 ${new Date(v.createdAt).toLocaleString()}`);
37881
+ if (v.changelog) console.log(` ${v.changelog}`);
37882
+ }
37883
+ }
37884
+ __name(templateVersionsAction, "templateVersionsAction");
37885
+ async function templateInstallAction(templateApi, config, options) {
37886
+ const agentId = config.agent?.agentId;
37887
+ if (!agentId) throw new Error("Agent ID not found in configuration.");
37888
+ const templateId = await resolveTemplateId(templateApi, options, "Which template would you like to install?");
37889
+ const version = options.version ? Number.parseInt(options.version, 10) : void 0;
37890
+ const envValues = options.envVars ? parseKeyValuePairs(options.envVars) : void 0;
37891
+ if (!options.force) {
37892
+ writeInfo("\n\u{1F4CB} Install Summary:");
37893
+ writeInfo(` Template: ${templateId}`);
37894
+ writeInfo(` Version: ${version ?? "(latest)"}`);
37895
+ writeInfo(` Agent: ${agentId}`);
37896
+ if (envValues && Object.keys(envValues).length > 0) {
37897
+ writeInfo(` Env values: ${Object.keys(envValues).length} configured`);
37898
+ }
37899
+ console.error("\n\u274C Use --force to confirm installation");
37900
+ throw new Error("This action requires --force to confirm");
37901
+ }
37902
+ writeProgress("\u{1F504} Installing template...");
37903
+ const install = await templateApi.install(templateId, agentId, {
37904
+ version,
37905
+ envValues,
37906
+ allowCreatorUpdates: options.allowCreatorUpdates,
37907
+ skipEnvCheck: options.skipEnvCheck
37908
+ });
37909
+ if (options.json) {
37910
+ console.log(JSON.stringify(install, null, 2));
37911
+ return;
37912
+ }
37913
+ writeSuccess(`\u2705 Template installed! (v${install.installedVersion})`);
37914
+ if (install.appliedAgentVersion != null) {
37915
+ writeInfo(`Applied as agent version v${install.appliedAgentVersion}.`);
37916
+ }
37917
+ writeHintBlock({
37918
+ headline: "Roll back this agent to a prior state anytime:",
37919
+ lines: [
37920
+ {
37921
+ label: "Rollback:",
37922
+ command: "lua version promote <n>"
37923
+ }
37924
+ ],
37925
+ when: "success"
37926
+ });
37927
+ }
37928
+ __name(templateInstallAction, "templateInstallAction");
37929
+ function formatApplyResultTable(targets) {
37930
+ const header = {
37931
+ agentId: "AGENT ID",
37932
+ status: "STATUS",
37933
+ localAgentVersion: "LOCAL VERSION",
37934
+ error: "ERROR"
37935
+ };
37936
+ const rows = targets.map((t) => ({
37937
+ agentId: t.agentId,
37938
+ status: t.status,
37939
+ localAgentVersion: t.localAgentVersion != null ? `v${t.localAgentVersion}` : "\u2014",
37940
+ error: t.error ?? ""
37941
+ }));
37942
+ const cols = [
37943
+ "agentId",
37944
+ "status",
37945
+ "localAgentVersion",
37946
+ "error"
37947
+ ];
37948
+ const widths = {};
37949
+ for (const c of cols) {
37950
+ widths[c] = Math.max(header[c].length, ...rows.map((r) => r[c].length));
37951
+ }
37952
+ const fmt = /* @__PURE__ */ __name((r) => cols.map((c) => r[c].padEnd(widths[c])).join(" ").trimEnd(), "fmt");
37953
+ return [
37954
+ fmt(header),
37955
+ ...rows.map(fmt)
37956
+ ];
37957
+ }
37958
+ __name(formatApplyResultTable, "formatApplyResultTable");
37959
+ function resolveApplyTargets(options) {
37960
+ if (options.agents) {
37961
+ return options.agents.split(",").map((s) => s.trim()).filter(Boolean);
37962
+ }
37963
+ if (options.file) {
37964
+ const contents = readFileSync13(options.file, "utf-8");
37965
+ return contents.split("\n").map((s) => s.trim()).filter(Boolean);
37966
+ }
37967
+ return null;
37968
+ }
37969
+ __name(resolveApplyTargets, "resolveApplyTargets");
37970
+ async function templateApplyAction(templateApi, options) {
37971
+ const templateId = await resolveTemplateId(templateApi, options, "Which template would you like to apply?");
37972
+ let targets = resolveApplyTargets(options);
37973
+ if (!targets && options.allInstalled) {
37974
+ writeProgress("\u{1F504} Loading install ledger...");
37975
+ const installs = await templateApi.getAllInstalls(templateId);
37976
+ targets = installs.map((i) => i.agentId);
37977
+ }
37978
+ if (!targets) {
37979
+ throw new Error("Provide targets via --agents <a,b,c>, --file <path>, or --all-installed");
37980
+ }
37981
+ if (targets.length === 0) {
37982
+ writeInfo("No target agents resolved \u2014 nothing to apply.");
37983
+ return;
37984
+ }
37985
+ writeInfo(`Resolved ${targets.length} target agent(s): ${targets.join(", ")}`);
37986
+ const template = await templateApi.getTemplate(templateId);
37987
+ if (!template.latestVersion) {
37988
+ throw new Error("This template has no published versions. Run `lua marketplace template publish` first.");
37989
+ }
37990
+ const versionNum = options.version ? Number.parseInt(options.version, 10) : template.latestVersion;
37991
+ const versionObj = await templateApi.getVersion(templateId, versionNum).catch(() => null);
37992
+ if (!versionObj) throw new Error(`Version v${versionNum} not found for this template.`);
37993
+ if (!options.force) {
37994
+ console.log(`
37995
+ Apply plan:`);
37996
+ console.log(` Template: ${template.displayName} (${templateId})`);
37997
+ console.log(` Version: v${versionObj.version}`);
37998
+ console.log(` Targets: ${targets.length}`);
37999
+ console.log("\nManifest:");
38000
+ printManifestSummary(versionObj.content);
38001
+ const isTTY = Boolean(process.stdin.isTTY && process.stdout.isTTY);
38002
+ const isCi = isCiModeEnabled();
38003
+ if (isTTY && !isCi) {
38004
+ const confirmed = await confirmAction(`
38005
+ Apply v${versionObj.version} to ${targets.length} agent(s)?`);
38006
+ if (!confirmed) {
38007
+ writeInfo("Aborted.");
38008
+ return;
38009
+ }
38010
+ } else {
38011
+ throw new Error("This action requires --force to confirm (non-interactive mode)");
38012
+ }
38013
+ }
38014
+ writeProgress("\u{1F504} Starting apply run...");
38015
+ const { runId } = await templateApi.apply(templateId, {
38016
+ version: versionObj.version,
38017
+ targets,
38018
+ skipEnvCheck: options.skipEnvCheck
38019
+ });
38020
+ if (options.wait === false) {
38021
+ if (options.json) {
38022
+ console.log(JSON.stringify({
38023
+ runId
38024
+ }, null, 2));
38025
+ } else {
38026
+ writeSuccess(`\u2705 Apply run started: ${runId}`);
38027
+ }
38028
+ return;
38029
+ }
38030
+ writeProgress("\u{1F504} Waiting for apply run to complete...");
38031
+ const waitDeadline = Date.now() + 30 * 60 * 1e3;
38032
+ let run = await templateApi.getApplyRun(templateId, runId);
38033
+ while (run.status === "running") {
38034
+ if (Date.now() > waitDeadline) {
38035
+ throw new Error(`Apply run ${runId} still running after 30 minutes \u2014 a crashed worker can leave a run stuck. Check later with: lua marketplace template status --template-id ${templateId}`);
38036
+ }
38037
+ await sleep2(3e3);
38038
+ run = await templateApi.getApplyRun(templateId, runId);
38039
+ }
38040
+ if (options.json) {
38041
+ console.log(JSON.stringify(run, null, 2));
38042
+ } else {
38043
+ console.log(`
38044
+ Apply run ${run.status} (${run.id})`);
38045
+ for (const line of formatApplyResultTable(run.targets)) {
38046
+ console.log(line);
38047
+ }
38048
+ }
38049
+ const failedCount = run.targets.filter((t) => t.status === "failed").length;
38050
+ if (failedCount > 0) {
38051
+ throw new Error(`Apply run finished with ${failedCount} failed target(s).`);
38052
+ }
38053
+ }
38054
+ __name(templateApplyAction, "templateApplyAction");
38055
+ async function templateStatusAction(templateApi, options) {
38056
+ const templateId = await resolveTemplateId(templateApi, options, "Which template\u2019s fleet status would you like to see?");
38057
+ const installs = await templateApi.getAllInstalls(templateId);
38058
+ if (options.json) {
38059
+ console.log(JSON.stringify(installs, null, 2));
38060
+ return;
38061
+ }
38062
+ if (installs.length === 0) {
38063
+ writeInfo("No agents have installed this template yet.");
38064
+ return;
38065
+ }
38066
+ const header = {
38067
+ agentId: "AGENT ID",
38068
+ installedVersion: "TEMPLATE VERSION",
38069
+ appliedAgentVersion: "AGENT VERSION",
38070
+ status: "STATUS",
38071
+ appliedAt: "APPLIED AT"
38072
+ };
38073
+ const rows = installs.map((i) => ({
38074
+ agentId: i.agentId,
38075
+ installedVersion: `v${i.installedVersion}`,
38076
+ appliedAgentVersion: i.appliedAgentVersion != null ? `v${i.appliedAgentVersion}` : "\u2014",
38077
+ status: i.status,
38078
+ appliedAt: new Date(i.appliedAt).toISOString().slice(0, 16).replace("T", " ")
38079
+ }));
38080
+ const cols = [
38081
+ "agentId",
38082
+ "installedVersion",
38083
+ "appliedAgentVersion",
38084
+ "status",
38085
+ "appliedAt"
38086
+ ];
38087
+ const widths = {};
38088
+ for (const c of cols) {
38089
+ widths[c] = Math.max(header[c].length, ...rows.map((r) => r[c].length));
38090
+ }
38091
+ const fmt = /* @__PURE__ */ __name((r) => cols.map((c) => r[c].padEnd(widths[c])).join(" ").trimEnd(), "fmt");
38092
+ console.log(fmt(header));
38093
+ for (const r of rows) console.log(fmt(r));
38094
+ writeInfo("\n\u{1F4A1} Per-agent rollback: run `lua version promote <n>` directly on that agent.");
38095
+ }
38096
+ __name(templateStatusAction, "templateStatusAction");
38097
+ async function templateInstalledAction(templateApi, config, options) {
38098
+ const agentId = config.agent?.agentId;
38099
+ if (!agentId) throw new Error("Agent ID not found in configuration.");
38100
+ const summaries = await templateApi.getAgentTemplates(agentId);
38101
+ if (options.json) {
38102
+ console.log(JSON.stringify(summaries, null, 2));
38103
+ return;
38104
+ }
38105
+ if (summaries.length === 0) {
38106
+ writeInfo("\u{1F4E6} No templates installed on this agent.");
38107
+ return;
38108
+ }
38109
+ console.log(`
38110
+ \u{1F4CA} ${summaries.length} template(s) installed on this agent:
38111
+ `);
38112
+ for (const s of summaries) {
38113
+ console.log(`\u{1F4E6} ${s.displayName} (${s.templateId})`);
38114
+ console.log(` Installed version: v${s.installedVersion}`);
38115
+ console.log(` Status: ${s.status}`);
38116
+ console.log(` Applied: ${new Date(s.appliedAt).toLocaleString()}`);
38117
+ console.log("");
38118
+ }
38119
+ }
38120
+ __name(templateInstalledAction, "templateInstalledAction");
38121
+ async function templateUninstallAction(templateApi, config, options) {
38122
+ const agentId = config.agent?.agentId;
38123
+ if (!agentId) throw new Error("Agent ID not found in configuration.");
38124
+ const templateId = await resolveTemplateId(templateApi, options, "Which template would you like to uninstall?");
38125
+ if (!options.force) {
38126
+ console.error(`
38127
+ \u274C Use --force to confirm uninstalling template ${templateId} from this agent`);
38128
+ throw new Error("This action requires --force to confirm");
38129
+ }
38130
+ writeProgress("\u{1F504} Uninstalling template...");
38131
+ await templateApi.uninstall(templateId, agentId);
38132
+ writeSuccess("\u2705 Template uninstalled from this agent.");
38133
+ }
38134
+ __name(templateUninstallAction, "templateUninstallAction");
38135
+
38136
+ // src/commands/marketplace.ts
38137
+ var SKILL_ACTIONS = [
38138
+ "list",
38139
+ "publish",
38140
+ "edit",
38141
+ "unlist",
38142
+ "unpublish",
38143
+ "mine",
38144
+ "search",
38145
+ "view",
38146
+ "install",
38147
+ "update",
38148
+ "uninstall",
38149
+ "installed"
38150
+ ];
38151
+ var INTERACTIVE_SKILL_ACTIONS = SKILL_ACTIONS.filter((a) => a !== "view");
38152
+ var SKILL_ACTION_LABELS = {
38153
+ search: "Browse & search for skills",
38154
+ install: "Install a skill",
38155
+ update: "Update an installed skill",
38156
+ uninstall: "Uninstall a skill",
38157
+ installed: "List installed skills",
38158
+ list: "List a new skill on the Marketplace",
38159
+ publish: "Publish a new version of a skill",
38160
+ edit: "Edit metadata for a listed skill",
38161
+ unlist: "Unlist a skill from the Marketplace",
38162
+ unpublish: "Unpublish a skill version",
38163
+ mine: "View my listed skills"
38164
+ };
38165
+ async function marketplaceCommand(noun, action, options = {}) {
38166
+ return withErrorHandling(async () => {
38167
+ let domain;
38168
+ if (noun) {
38169
+ domain = validateOrSuggest("marketplace.noun", noun);
38170
+ } else {
38171
+ const domainAnswer = await safePrompt([
37266
38172
  {
37267
38173
  type: "list",
37268
- name: "role",
37269
- message: "What would you like to do?",
38174
+ name: "domain",
38175
+ message: "What would you like to browse?",
37270
38176
  choices: [
37271
38177
  {
37272
- name: "As a Creator (Publish & Manage your skills)",
37273
- value: "creator"
38178
+ name: "Skills",
38179
+ value: "skill"
37274
38180
  },
37275
38181
  {
37276
- name: "As an Installer (Find & Install skills)",
37277
- value: "installer"
38182
+ name: "Agent templates",
38183
+ value: "template"
37278
38184
  },
37279
38185
  {
37280
38186
  name: "Exit",
@@ -37283,26 +38189,67 @@ async function marketplaceCommand(role, action, options) {
37283
38189
  ]
37284
38190
  }
37285
38191
  ]);
37286
- if (!roleAnswer || roleAnswer.role === "exit") {
37287
- exit = true;
38192
+ if (!domainAnswer || domainAnswer.domain === "exit") {
37288
38193
  console.log("\n\u{1F44B} Goodbye!\n");
37289
- continue;
38194
+ return;
37290
38195
  }
37291
- if (roleAnswer.role === "creator") {
37292
- await handleCreatorActions(marketplaceApi, config, apiKey);
37293
- } else if (roleAnswer.role === "installer") {
37294
- await handleInstallerActions(marketplaceApi, config, apiKey);
38196
+ domain = domainAnswer.domain;
38197
+ }
38198
+ if (domain === "template") {
38199
+ return templateCommand(action, options);
38200
+ }
38201
+ return skillMarketplaceCommand(action, options);
38202
+ }, "marketplace");
38203
+ }
38204
+ __name(marketplaceCommand, "marketplaceCommand");
38205
+ async function skillMarketplaceCommand(action, options = {}) {
38206
+ const { config, apiKey } = await initializeCommand();
38207
+ const marketplaceApi = new MarketplaceApiService(apiKey);
38208
+ if (action) {
38209
+ const selectedAction = validateOrSuggest("marketplace.skill.action", action);
38210
+ await executeSkillActionNonInteractive(marketplaceApi, config, apiKey, selectedAction, options);
38211
+ trackEvent("cli_marketplace_action", {
38212
+ domain: "skill",
38213
+ action: selectedAction,
38214
+ non_interactive: true
38215
+ });
38216
+ return;
38217
+ }
38218
+ let exit = false;
38219
+ while (!exit) {
38220
+ const answer = await safePrompt([
38221
+ {
38222
+ type: "list",
38223
+ name: "action",
38224
+ message: "What would you like to do?",
38225
+ choices: [
38226
+ ...INTERACTIVE_SKILL_ACTIONS.map((a) => ({
38227
+ name: SKILL_ACTION_LABELS[a],
38228
+ value: a
38229
+ })),
38230
+ {
38231
+ name: "Exit",
38232
+ value: "exit"
38233
+ }
38234
+ ]
37295
38235
  }
38236
+ ]);
38237
+ if (!answer || answer.action === "exit") {
38238
+ exit = true;
38239
+ console.log("\n\u{1F44B} Goodbye!\n");
38240
+ continue;
37296
38241
  }
38242
+ const selectedAction = answer.action;
38243
+ await executeSkillActionInteractive(marketplaceApi, config, apiKey, selectedAction);
37297
38244
  trackEvent("cli_marketplace_action", {
37298
- role: role || "interactive",
37299
- action: action || null,
37300
- non_interactive: !!(selectedRole && action)
38245
+ domain: "skill",
38246
+ action: selectedAction,
38247
+ non_interactive: false
37301
38248
  });
37302
- }, "marketplace");
38249
+ }
37303
38250
  }
37304
- __name(marketplaceCommand, "marketplaceCommand");
37305
- async function executeCreatorActionNonInteractive(marketplaceApi, config, apiKey, action, options) {
38251
+ __name(skillMarketplaceCommand, "skillMarketplaceCommand");
38252
+ async function executeSkillActionNonInteractive(marketplaceApi, config, apiKey, action, options) {
37306
38253
  switch (action) {
37307
38254
  case "list":
37308
38255
  await listSkillNonInteractive(marketplaceApi, config, apiKey, options);
@@ -37310,7 +38257,7 @@ async function executeCreatorActionNonInteractive(marketplaceApi, config, apiKey
37310
38257
  case "publish":
37311
38258
  await publishVersionNonInteractive(marketplaceApi, config, apiKey, options);
37312
38259
  break;
37313
- case "update":
38260
+ case "edit":
37314
38261
  await updateMetadataNonInteractive(marketplaceApi, options);
37315
38262
  break;
37316
38263
  case "unlist":
@@ -37319,14 +38266,9 @@ async function executeCreatorActionNonInteractive(marketplaceApi, config, apiKey
37319
38266
  case "unpublish":
37320
38267
  await unpublishVersionNonInteractive(marketplaceApi, options);
37321
38268
  break;
37322
- case "view":
38269
+ case "mine":
37323
38270
  await viewMyListedSkillsNonInteractive(marketplaceApi, options);
37324
38271
  break;
37325
- }
37326
- }
37327
- __name(executeCreatorActionNonInteractive, "executeCreatorActionNonInteractive");
37328
- async function executeInstallerActionNonInteractive(marketplaceApi, config, apiKey, action, options) {
37329
- switch (action) {
37330
38272
  case "search":
37331
38273
  await searchSkillsNonInteractive(marketplaceApi, options);
37332
38274
  break;
@@ -37347,14 +38289,58 @@ async function executeInstallerActionNonInteractive(marketplaceApi, config, apiK
37347
38289
  break;
37348
38290
  }
37349
38291
  }
37350
- __name(executeInstallerActionNonInteractive, "executeInstallerActionNonInteractive");
38292
+ __name(executeSkillActionNonInteractive, "executeSkillActionNonInteractive");
38293
+ async function executeSkillActionInteractive(marketplaceApi, config, apiKey, action) {
38294
+ switch (action) {
38295
+ case "list":
38296
+ await listSkillOnMarketplace(marketplaceApi, config, apiKey);
38297
+ break;
38298
+ case "publish":
38299
+ await publishSkillVersion(marketplaceApi, config, apiKey);
38300
+ break;
38301
+ case "edit":
38302
+ await updateSkillMetadata(marketplaceApi, config);
38303
+ break;
38304
+ case "unlist":
38305
+ await unlistSkillFromMarketplace(marketplaceApi);
38306
+ break;
38307
+ case "unpublish":
38308
+ await unpublishSkillVersion(marketplaceApi);
38309
+ break;
38310
+ case "mine":
38311
+ await viewMyListedSkills(marketplaceApi);
38312
+ break;
38313
+ case "search":
38314
+ await searchMarketplaceSkills(marketplaceApi);
38315
+ break;
38316
+ case "install":
38317
+ await installMarketplaceSkill(marketplaceApi, config, apiKey);
38318
+ break;
38319
+ case "update":
38320
+ await updateInstalledSkill(marketplaceApi, config, apiKey);
38321
+ break;
38322
+ case "uninstall":
38323
+ await uninstallMarketplaceSkill(marketplaceApi, config);
38324
+ break;
38325
+ case "installed":
38326
+ await listInstalledSkills(marketplaceApi, config);
38327
+ break;
38328
+ case "view":
38329
+ break;
38330
+ }
38331
+ }
38332
+ __name(executeSkillActionInteractive, "executeSkillActionInteractive");
37351
38333
  async function listSkillNonInteractive(marketplaceApi, config, apiKey, options) {
37352
- const { skillName, displayName } = options;
38334
+ const { skillName, displayName, visibility } = options;
37353
38335
  if (!skillName || !displayName) {
37354
38336
  console.error("\u274C Missing required options");
37355
- console.log("\nUsage: lua marketplace create list --skill-name <name> --display-name <name>");
38337
+ console.log("\nUsage: lua marketplace skill list --skill-name <name> --display-name <name>");
37356
38338
  throw new Error("Missing required options");
37357
38339
  }
38340
+ if (visibility && visibility !== "public" && visibility !== "private") {
38341
+ console.error('\u274C Invalid --visibility: must be "public" or "private"');
38342
+ throw new Error('Invalid --visibility: must be "public" or "private"');
38343
+ }
37358
38344
  const agentId = config.agent?.agentId;
37359
38345
  if (!agentId) {
37360
38346
  console.error("\u274C Agent ID not found in configuration.");
@@ -37385,10 +38371,12 @@ async function listSkillNonInteractive(marketplaceApi, config, apiKey, options)
37385
38371
  writeProgress("\u{1F504} Listing skill on marketplace...");
37386
38372
  const marketplaceSkill = await marketplaceApi.listSkill({
37387
38373
  skillId: skill.id,
37388
- displayName
38374
+ displayName,
38375
+ visibility
37389
38376
  });
37390
38377
  writeSuccess(`\u2705 Skill "${marketplaceSkill.displayName}" listed successfully!`);
37391
38378
  writeInfo(`Marketplace Skill ID: ${marketplaceSkill.id}`);
38379
+ writeInfo(`Visibility: ${marketplaceSkill.visibility === "private" ? "\u{1F512} Private" : "\u{1F310} Public"}`);
37392
38380
  writeInfo("\u{1F4A1} You can now publish a version to make it installable.");
37393
38381
  }
37394
38382
  __name(listSkillNonInteractive, "listSkillNonInteractive");
@@ -37396,7 +38384,7 @@ async function publishVersionNonInteractive(marketplaceApi, config, apiKey, opti
37396
38384
  const { marketplaceId, versionId, changelog, envVarsJson } = options;
37397
38385
  if (!marketplaceId || !versionId) {
37398
38386
  console.error("\u274C Missing required options");
37399
- console.log("\nUsage: lua marketplace create publish --marketplace-id <id> --version-id <id> [--changelog <text>]");
38387
+ console.log("\nUsage: lua marketplace skill publish --marketplace-id <id> --version-id <id> [--changelog <text>]");
37400
38388
  throw new Error("Missing required options");
37401
38389
  }
37402
38390
  let envVars;
@@ -37423,7 +38411,7 @@ async function updateMetadataNonInteractive(marketplaceApi, options) {
37423
38411
  const { marketplaceId, displayName } = options;
37424
38412
  if (!marketplaceId) {
37425
38413
  console.error("\u274C Missing required option: --marketplace-id");
37426
- console.log("\nUsage: lua marketplace create update --marketplace-id <id> --display-name <name>");
38414
+ console.log("\nUsage: lua marketplace skill edit --marketplace-id <id> --display-name <name>");
37427
38415
  throw new Error("Missing required option: --marketplace-id");
37428
38416
  }
37429
38417
  if (!displayName) {
@@ -37441,12 +38429,12 @@ async function unlistSkillNonInteractive(marketplaceApi, options) {
37441
38429
  const { marketplaceId, force } = options;
37442
38430
  if (!marketplaceId) {
37443
38431
  console.error("\u274C Missing required option: --marketplace-id");
37444
- console.log("\nUsage: lua marketplace create unlist --marketplace-id <id> [--force]");
38432
+ console.log("\nUsage: lua marketplace skill unlist --marketplace-id <id> [--force]");
37445
38433
  throw new Error("Missing required option: --marketplace-id");
37446
38434
  }
37447
38435
  if (!force) {
37448
38436
  console.error("\u274C This action requires --force to confirm");
37449
- console.log("\nUsage: lua marketplace create unlist --marketplace-id <id> --force");
38437
+ console.log("\nUsage: lua marketplace skill unlist --marketplace-id <id> --force");
37450
38438
  throw new Error("This action requires --force to confirm");
37451
38439
  }
37452
38440
  writeProgress("\u{1F504} Unlisting skill...");
@@ -37459,7 +38447,7 @@ async function unpublishVersionNonInteractive(marketplaceApi, options) {
37459
38447
  const { marketplaceId, versionId, force } = options;
37460
38448
  if (!marketplaceId || !versionId) {
37461
38449
  console.error("\u274C Missing required options");
37462
- console.log("\nUsage: lua marketplace create unpublish --marketplace-id <id> --version-id <id> [--force]");
38450
+ console.log("\nUsage: lua marketplace skill unpublish --marketplace-id <id> --version-id <id> [--force]");
37463
38451
  throw new Error("Missing required options");
37464
38452
  }
37465
38453
  if (!force) {
@@ -37492,6 +38480,7 @@ async function viewMyListedSkillsNonInteractive(marketplaceApi, options) {
37492
38480
  console.log(`${statusIcon} ${skill.displayName} (${skill.name})`);
37493
38481
  console.log(` ID: ${skill.id}`);
37494
38482
  console.log(` Status: ${statusText}`);
38483
+ console.log(` Visibility: ${skill.visibility === "private" ? "\u{1F512} Private" : "\u{1F310} Public"}`);
37495
38484
  if (skill.versions && skill.versions.length > 0) {
37496
38485
  const publishedVersions = skill.versions.filter((v) => v.published);
37497
38486
  console.log(` Versions: ${publishedVersions.length} published / ${skill.versions.length} total`);
@@ -37540,7 +38529,7 @@ async function viewSkillNonInteractive(marketplaceApi, options) {
37540
38529
  const { marketplaceId } = options;
37541
38530
  if (!marketplaceId) {
37542
38531
  console.error("\u274C Missing required option: --marketplace-id");
37543
- console.log("\nUsage: lua marketplace install view --marketplace-id <id>");
38532
+ console.log("\nUsage: lua marketplace skill view --marketplace-id <id>");
37544
38533
  throw new Error("Missing required option: --marketplace-id");
37545
38534
  }
37546
38535
  writeProgress("\u{1F504} Loading skill details...");
@@ -37584,7 +38573,7 @@ async function installSkillNonInteractive(marketplaceApi, config, options) {
37584
38573
  const { marketplaceId, versionId, envVars, force } = options;
37585
38574
  if (!marketplaceId || !versionId) {
37586
38575
  console.error("\u274C Missing required options");
37587
- console.log("\nUsage: lua marketplace install install --marketplace-id <id> --version-id <id> [--env-vars <k=v,...>]");
38576
+ console.log("\nUsage: lua marketplace skill install --marketplace-id <id> --version-id <id> [--env-vars <k=v,...>]");
37588
38577
  throw new Error("Missing required options");
37589
38578
  }
37590
38579
  const agentId = config.agent?.agentId;
@@ -37641,7 +38630,7 @@ async function updateInstalledSkillNonInteractive(marketplaceApi, config, apiKey
37641
38630
  const { skillName, versionId, envVars } = options;
37642
38631
  if (!skillName) {
37643
38632
  console.error("\u274C Missing required option: --skill-name");
37644
- console.log("\nUsage: lua marketplace install update --skill-name <name> [--version-id <id>] [--env-vars <k=v,...>]");
38633
+ console.log("\nUsage: lua marketplace skill update --skill-name <name> [--version-id <id>] [--env-vars <k=v,...>]");
37645
38634
  throw new Error("Missing required option: --skill-name");
37646
38635
  }
37647
38636
  const agentId = config.agent?.agentId;
@@ -37693,7 +38682,7 @@ async function uninstallSkillNonInteractive(marketplaceApi, config, options) {
37693
38682
  const { skillName, force } = options;
37694
38683
  if (!skillName) {
37695
38684
  console.error("\u274C Missing required option: --skill-name");
37696
- console.log("\nUsage: lua marketplace install uninstall --skill-name <name> [--force]");
38685
+ console.log("\nUsage: lua marketplace skill uninstall --skill-name <name> [--force]");
37697
38686
  throw new Error("Missing required option: --skill-name");
37698
38687
  }
37699
38688
  const agentId = config.agent?.agentId;
@@ -37756,86 +38745,6 @@ async function listInstalledSkillsNonInteractive(marketplaceApi, config, options
37756
38745
  }
37757
38746
  }
37758
38747
  __name(listInstalledSkillsNonInteractive, "listInstalledSkillsNonInteractive");
37759
- async function handleCreatorActions(marketplaceApi, config, apiKey) {
37760
- let back = false;
37761
- while (!back) {
37762
- const creatorAnswer = await safePrompt([
37763
- {
37764
- type: "list",
37765
- name: "action",
37766
- message: "Creator Menu:",
37767
- choices: [
37768
- {
37769
- name: "List a new skill on the Marketplace",
37770
- value: "list"
37771
- },
37772
- {
37773
- name: "Publish a new version of a skill",
37774
- value: "publish"
37775
- },
37776
- {
37777
- name: "Update metadata for a listed skill",
37778
- value: "update"
37779
- },
37780
- {
37781
- name: "Unlist a skill from the Marketplace",
37782
- value: "unlist"
37783
- },
37784
- {
37785
- name: "Unpublish a skill version",
37786
- value: "unpublish"
37787
- },
37788
- {
37789
- name: "View my listed skills",
37790
- value: "view"
37791
- },
37792
- {
37793
- name: "Back",
37794
- value: "back"
37795
- }
37796
- ]
37797
- }
37798
- ]);
37799
- if (!creatorAnswer || creatorAnswer.action === "back") {
37800
- back = true;
37801
- continue;
37802
- }
37803
- switch (creatorAnswer.action) {
37804
- case "list":
37805
- await listSkillOnMarketplace(marketplaceApi, config, apiKey);
37806
- continue;
37807
- case "publish":
37808
- await publishSkillVersion(marketplaceApi, config, apiKey);
37809
- continue;
37810
- case "update":
37811
- await updateSkillMetadata(marketplaceApi, config);
37812
- continue;
37813
- case "unlist":
37814
- await unlistSkillFromMarketplace(marketplaceApi);
37815
- continue;
37816
- case "unpublish":
37817
- await unpublishSkillVersion(marketplaceApi);
37818
- continue;
37819
- case "view":
37820
- await viewMyListedSkills(marketplaceApi);
37821
- continue;
37822
- // Other cases will be added here
37823
- default:
37824
- console.log(`
37825
- Action '${creatorAnswer.action}' is not implemented yet.
37826
- `);
37827
- await safePrompt([
37828
- {
37829
- type: "input",
37830
- name: "continue",
37831
- message: "Press Enter to continue..."
37832
- }
37833
- ]);
37834
- continue;
37835
- }
37836
- }
37837
- }
37838
- __name(handleCreatorActions, "handleCreatorActions");
37839
38748
  async function listSkillOnMarketplace(marketplaceApi, config, apiKey) {
37840
38749
  const agentId = config.agent?.agentId;
37841
38750
  if (!agentId) {
@@ -37898,9 +38807,29 @@ async function listSkillOnMarketplace(marketplaceApi, config, apiKey) {
37898
38807
  }
37899
38808
  ]);
37900
38809
  if (!metadata) return;
38810
+ const visibilityAnswer = await safePrompt([
38811
+ {
38812
+ type: "list",
38813
+ name: "visibility",
38814
+ message: "Who can see and install this skill?",
38815
+ choices: [
38816
+ {
38817
+ name: "Public \u2014 anyone can find and install it",
38818
+ value: "public"
38819
+ },
38820
+ {
38821
+ name: "Private \u2014 only you (and your org) can find and install it",
38822
+ value: "private"
38823
+ }
38824
+ ],
38825
+ default: "public"
38826
+ }
38827
+ ]);
38828
+ if (!visibilityAnswer) return;
37901
38829
  const payload = {
37902
38830
  skillId: skillToList.id,
37903
- displayName: metadata.displayName
38831
+ displayName: metadata.displayName,
38832
+ visibility: visibilityAnswer.visibility
37904
38833
  };
37905
38834
  try {
37906
38835
  writeProgress("\nListing skill on the marketplace...");
@@ -37908,6 +38837,7 @@ async function listSkillOnMarketplace(marketplaceApi, config, apiKey) {
37908
38837
  writeSuccess(`
37909
38838
  \u2705 Skill "${marketplaceSkill.displayName}" listed successfully!`);
37910
38839
  writeInfo(`Marketplace Skill ID: ${marketplaceSkill.id}`);
38840
+ writeInfo(`Visibility: ${marketplaceSkill.visibility === "private" ? "\u{1F512} Private" : "\u{1F310} Public"}`);
37911
38841
  writeInfo("\u{1F4A1} You can now publish a version to make it installable.\n");
37912
38842
  } catch (error) {
37913
38843
  console.error(`
@@ -38278,6 +39208,7 @@ async function viewMyListedSkills(marketplaceApi) {
38278
39208
  const statusText = skill.listed ? "Listed" : "Unlisted";
38279
39209
  console.log(`${statusIcon} ${skill.displayName} (${skill.name})`);
38280
39210
  console.log(` Status: ${statusText}`);
39211
+ console.log(` Visibility: ${skill.visibility === "private" ? "\u{1F512} Private" : "\u{1F310} Public"}`);
38281
39212
  if (skill.description) {
38282
39213
  console.log(` Description: ${skill.description}`);
38283
39214
  }
@@ -38509,79 +39440,6 @@ async function configureEnvVar(varName, envVars) {
38509
39440
  `);
38510
39441
  }
38511
39442
  __name(configureEnvVar, "configureEnvVar");
38512
- async function handleInstallerActions(marketplaceApi, config, apiKey) {
38513
- let back = false;
38514
- while (!back) {
38515
- const installerAnswer = await safePrompt([
38516
- {
38517
- type: "list",
38518
- name: "action",
38519
- message: "Installer Menu:",
38520
- choices: [
38521
- {
38522
- name: "Browse & Search for skills",
38523
- value: "search"
38524
- },
38525
- {
38526
- name: "Install a skill from the Marketplace",
38527
- value: "install"
38528
- },
38529
- {
38530
- name: "Update an installed skill",
38531
- value: "update"
38532
- },
38533
- {
38534
- name: "Uninstall a skill",
38535
- value: "uninstall"
38536
- },
38537
- {
38538
- name: "List my currently installed skills",
38539
- value: "installed"
38540
- },
38541
- {
38542
- name: "Back",
38543
- value: "back"
38544
- }
38545
- ]
38546
- }
38547
- ]);
38548
- if (!installerAnswer || installerAnswer.action === "back") {
38549
- back = true;
38550
- continue;
38551
- }
38552
- switch (installerAnswer.action) {
38553
- case "search":
38554
- await searchMarketplaceSkills(marketplaceApi);
38555
- continue;
38556
- case "install":
38557
- await installMarketplaceSkill(marketplaceApi, config, apiKey);
38558
- continue;
38559
- case "update":
38560
- await updateInstalledSkill(marketplaceApi, config, apiKey);
38561
- continue;
38562
- case "uninstall":
38563
- await uninstallMarketplaceSkill(marketplaceApi, config);
38564
- continue;
38565
- case "installed":
38566
- await listInstalledSkills(marketplaceApi, config);
38567
- continue;
38568
- // Other cases will be added here
38569
- default:
38570
- console.log(`
38571
- Action '${installerAnswer.action}' is not implemented yet.
38572
- `);
38573
- await safePrompt([
38574
- {
38575
- type: "input",
38576
- name: "continue",
38577
- message: "Press Enter to continue..."
38578
- }
38579
- ]);
38580
- continue;
38581
- }
38582
- }
38583
- }
38584
- __name(handleInstallerActions, "handleInstallerActions");
38585
39443
  var MARKETPLACE_PAGE_SIZE = 10;
38586
39444
  async function browseAndSelectSkill(marketplaceApi, purpose, publishedVersionsOnly) {
38587
39445
  try {
@@ -44946,20 +45804,21 @@ Examples:
44946
45804
  }
44947
45805
  __name(setupAuthCommands, "setupAuthCommands");
44948
45806
  function setupMarketplaceCommands(program2) {
44949
- program2.command("marketplace [role] [action]").description("\u{1F6CD}\uFE0F Browse, install, and manage marketplace skills").option("--skill-name <name>", "Skill name (for creator list, installer update/uninstall)").option("--display-name <name>", "Display name (for creator list/update)").option("--marketplace-id <id>", "Marketplace skill ID").option("--version-id <id>", "Version ID (for publish/install)").option("--changelog <text>", "Changelog for version (for publish)").option("--env-vars-json <json>", "JSON string with env var metadata (for creator publish)").option("--env-vars <pairs>", "Comma-separated key=value pairs (for installer)").option("--query <text>", "Search query (for search)").option("--page <n>", "Page number (for search)").option("--limit <n>", "Results per page (for search)").option("--json", "Output as JSON").option("--force", "Skip confirmation prompts").addHelpText("after", `
45807
+ program2.command("marketplace [noun] [action]").description("\u{1F6CD}\uFE0F Browse, install, and manage marketplace skills and agent templates").option("--skill-name <name>", "Skill name (for skill list/update/uninstall)").option("--marketplace-id <id>", "Marketplace skill ID").option("--version-id <id>", "Version ID (for skill publish/install)").option("--env-vars-json <json>", "JSON string with env var metadata (for skill publish)").option("--query <text>", "Search query (for skill search)").option("--page <n>", "Page number (for skill search)").option("--limit <n>", "Results per page (for skill search)").option("--name <name>", "Template name, an internal identifier (for template create)").option("--description <text>", "Description (for template create)").option("--template-id <id>", "Template ID").option("--source-version <n>", "Agent version to freeze into this template version (default: active) (for template publish)").option("--env-contract <pair>", "KEY=description env contract entry, repeatable; use KEY?=description for optional (for template publish)", (val, previous) => [
45808
+ ...previous,
45809
+ val
45810
+ ], []).option("--version <n>", "Template version (for template view/install/apply)").option("--allow-creator-updates", "Allow the template creator to push future updates onto this install").option("--skip-env-check", "Skip env-contract validation (for template install/apply)").option("--agents <ids>", "Comma-separated target agent IDs (for template apply)").option("--file <path>", "Path to a file with one target agent ID per line (for template apply)").option("--all-installed", "Target every agent that already has this template installed (for template apply)").option("--no-wait", "Print the apply runId immediately instead of polling for completion (for template apply)").option("--display-name <name>", "Display name (for skill list/edit, template create)").option("--visibility <visibility>", "Who can see and install it: public or private (for skill list, template create)").option("--changelog <text>", "Changelog for this version (for skill/template publish)").option("--env-vars <pairs>", "Comma-separated key=value pairs (for skill/template install/update)").option("--json", "Output as JSON").option("--force", "Skip confirmation prompts").addHelpText("after", `
44950
45811
  Arguments:
44951
- role Optional: 'create' or 'install' (prompts if not provided)
45812
+ noun Optional: 'skill' or 'template' (prompts if not provided)
44952
45813
  action Optional: specific action for non-interactive mode
44953
45814
 
44954
- Creator Actions:
44955
- list --skill-name <name> --display-name <name>
45815
+ Skill Actions:
45816
+ list --skill-name <name> --display-name <name> [--visibility public|private]
44956
45817
  publish --marketplace-id <id> --version-id <id> [--changelog <text>] [--env-vars-json <json>]
44957
- update --marketplace-id <id> --display-name <name>
45818
+ edit --marketplace-id <id> --display-name <name>
44958
45819
  unlist --marketplace-id <id> --force
44959
45820
  unpublish --marketplace-id <id> --version-id <id> --force
44960
- view [--json]
44961
-
44962
- Installer Actions:
45821
+ mine [--json]
44963
45822
  search [--query <text>] [--page <n>] [--limit <n>] [--json]
44964
45823
  view --marketplace-id <id> [--json]
44965
45824
  install --marketplace-id <id> --version-id <id> [--env-vars <k=v,...>] --force
@@ -44967,18 +45826,32 @@ Installer Actions:
44967
45826
  uninstall --skill-name <name> --force
44968
45827
  installed [--json]
44969
45828
 
45829
+ Template Actions:
45830
+ create --name <n> --display-name <n> [--description <text>] [--visibility public|private]
45831
+ publish --template-id <id> [--source-version <n>] [--changelog <text>] [--env-contract KEY=desc,...]
45832
+ view --template-id <id> [--version <n>] [--json]
45833
+ versions --template-id <id> [--json]
45834
+ install --template-id <id> [--version <n>] [--env-vars <k=v,...>] --force
45835
+ apply --template-id <id> [--version <n>] (--agents <a,b,c> | --file <path> | --all-installed) --force [--no-wait]
45836
+ status --template-id <id> [--json]
45837
+ installed [--json]
45838
+ uninstall --template-id <id> --force
45839
+
44970
45840
  Examples:
44971
- $ lua marketplace Interactive selection
44972
- $ lua marketplace create Creator menu
44973
- $ lua marketplace install Installer menu
44974
- $ lua marketplace create view View my listed skills
44975
- $ lua marketplace create list --skill-name mySkill --display-name "My Skill"
44976
- $ lua marketplace create publish --marketplace-id xyz --version-id v1
44977
- $ lua marketplace create unlist --marketplace-id xyz --force
44978
- $ lua marketplace install search --query "CRM"
44979
- $ lua marketplace install view --marketplace-id xyz --json
44980
- $ lua marketplace install install --marketplace-id xyz --version-id v1 --force
44981
- $ lua marketplace install installed --json
45841
+ $ lua marketplace Interactive domain selection
45842
+ $ lua marketplace skill Skill action menu
45843
+ $ lua marketplace skill mine View my listed skills
45844
+ $ lua marketplace skill list --skill-name mySkill --display-name "My Skill"
45845
+ $ lua marketplace skill publish --marketplace-id xyz --version-id v1
45846
+ $ lua marketplace skill unlist --marketplace-id xyz --force
45847
+ $ lua marketplace skill search --query "CRM"
45848
+ $ lua marketplace skill view --marketplace-id xyz --json
45849
+ $ lua marketplace skill install --marketplace-id xyz --version-id v1 --force
45850
+ $ lua marketplace skill installed --json
45851
+ $ lua marketplace template Template action menu
45852
+ $ lua marketplace template create --name support-bot --display-name "Support Bot"
45853
+ $ lua marketplace template publish --template-id xyz --changelog "Add refund skill"
45854
+ $ lua marketplace template apply --template-id xyz --all-installed --force
44982
45855
  `).action(marketplaceCommand);
44983
45856
  }
44984
45857
  __name(setupMarketplaceCommands, "setupMarketplaceCommands");
@@ -45121,20 +45994,16 @@ Examples:
45121
45994
  $ lua chat -b "Hello" "What is the weather?" "Tell me a joke" -d 2000 -e sandbox Batch test
45122
45995
  $ lua chat --agent-version 3 -m "test" Preview agent version 3 in an isolated thread
45123
45996
  `).action(chatCommand);
45124
- 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", `
45997
+ chatCmd.command("clear").description("Clear your conversation history").option("--user <identifier>", "[removed] cross-user history clear is no longer supported").option("-t, --thread <id>", "Clear a specific thread's history instead of all history").option("--force", "Skip confirmation prompt").addHelpText("after", `
45125
45998
  Examples:
45126
- $ lua chat clear Clear history
45127
- $ lua chat clear --force Clear history without confirmation
45128
- $ lua chat clear --user <userId> Clear user's history by user ID
45129
- $ lua chat clear --user <email> Clear user's history by email
45130
- $ lua chat clear --user <mobile> Clear user's history by mobile number
45131
- $ lua chat clear --user <userId> --force Clear user's history without confirmation
45999
+ $ lua chat clear Clear your history
46000
+ $ lua chat clear --force Clear your history without confirmation
45132
46001
  $ lua chat clear --thread <threadId> Clear a specific thread's history
45133
46002
  $ lua chat clear --thread <threadId> --force Clear a specific thread's history without confirmation
45134
46003
 
45135
46004
  Notes:
45136
- - User identifier can be UUID, email address, or mobile number
45137
- - Mobile numbers should be in international format without + (e.g., 919876543210)
46005
+ - This command only clears YOUR OWN conversation history
46006
+ - The --user option was removed: cross-user history clear is no longer supported
45138
46007
  `).action(chatClearCommand);
45139
46008
  program2.command("env [environment]").description("\u2699\uFE0F Manage environment variables").option("-k, --key <name>", "Environment variable key").option("-v, --value <value>", "Environment variable value").option("-d, --delete", "Delete the specified key").option("--list", "List all environment variables").addHelpText("after", `
45140
46009
  Arguments:
@@ -45689,7 +46558,7 @@ if (isBareInvocation || isHelpInvocation) {
45689
46558
  });
45690
46559
  }
45691
46560
  var program = new Command();
45692
- program.showSuggestionAfterError().name("lua").description("Lua AI - Build and deploy AI agents with superpowers").version(CLI_VERSION).option("--ci", "CI/CD mode: fail loudly on missing required flags instead of prompting").addHelpText("after", `
46561
+ program.showSuggestionAfterError().name("lua").description("Lua AI - Build and deploy AI agents with superpowers").version(CLI_VERSION, "-V, --cli-version").option("--ci", "CI/CD mode: fail loudly on missing required flags instead of prompting").addHelpText("after", `
45693
46562
  Categories:
45694
46563
  \u{1F510} Authentication Manage API keys and authentication
45695
46564
  \u{1F680} Project Setup Initialize and configure projects
@@ -45731,7 +46600,8 @@ Examples:
45731
46600
  $ lua evals \u{1F4CA} Open evaluations dashboard
45732
46601
  $ lua docs \u{1F4D6} Open documentation
45733
46602
  $ lua completion \u{1F3AF} Enable shell autocomplete
45734
- $ lua marketplace \u{1F6CD}\uFE0F Interact with the Lua Marketplace
46603
+ $ lua marketplace \u{1F6CD}\uFE0F Interact with the Lua Marketplace (skills & agent templates)
46604
+ $ lua marketplace template \u{1F9E9} Create, publish, and apply marketplace agent templates
45735
46605
 
45736
46606
  \u{1F319} Documentation: https://docs.heylua.ai
45737
46607
  \u{1F319} Support: https://heylua.ai/support
@@ -45745,5 +46615,10 @@ program.hook("preAction", (thisCommand) => {
45745
46615
  setupAuthCommands(program);
45746
46616
  setupSkillCommands(program);
45747
46617
  setupMarketplaceCommands(program);
46618
+ var rawArgs = process.argv.slice(2);
46619
+ if (rawArgs.length === 1 && rawArgs[0] === "--version") {
46620
+ console.log(CLI_VERSION);
46621
+ process.exit(0);
46622
+ }
45748
46623
  program.parse(process.argv);
45749
46624
  //# sourceMappingURL=index.js.map