lua-cli 3.23.1 → 3.23.2

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
@@ -26261,15 +26261,18 @@ var ChatApi = class extends HttpClient {
26261
26261
  }
26262
26262
  }
26263
26263
  /**
26264
- * Clears the authenticated user's conversation history for an agent
26264
+ * Clears conversation history for an agent. Without targetIdentifier this is
26265
+ * self-scoped; cross-user clears require org:manage for the agent on the server.
26265
26266
  * @param agentId - The unique identifier of the agent
26266
26267
  * @param threadId - Optional thread ID to clear a specific conversation thread
26268
+ * @param targetIdentifier - Optional target user ID, email, or mobile number
26267
26269
  * @returns Promise resolving to an ApiResponse with confirmation
26268
26270
  * @throws Error if the agent is not found or the clear operation fails
26269
26271
  */
26270
- async clearHistory(agentId, threadId) {
26272
+ async clearHistory(agentId, threadId, targetIdentifier) {
26271
26273
  const params = new URLSearchParams();
26272
26274
  if (threadId) params.set("threadId", threadId);
26275
+ if (targetIdentifier !== void 0) params.set("targetIdentifier", targetIdentifier);
26273
26276
  const query = params.toString() ? `?${params.toString()}` : "";
26274
26277
  const url = `/chat/history/${agentId}${query}`;
26275
26278
  return this.httpDelete(url, {
@@ -27701,22 +27704,24 @@ init_analytics();
27701
27704
  async function chatClearCommand(options, command) {
27702
27705
  return withErrorHandling(async () => {
27703
27706
  const resolvedOptions = options ?? {};
27704
- if (resolvedOptions.user) {
27705
- 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.");
27707
+ const targetIdentifier = resolvedOptions.user?.trim();
27708
+ if (resolvedOptions.user !== void 0 && !targetIdentifier) {
27709
+ throw new Error("--user requires a non-empty user ID, email address, or mobile number.");
27706
27710
  }
27707
27711
  const { agentId, apiKey } = await initializeCommand();
27708
27712
  const threadId = resolvedOptions.thread ?? command?.parent?.opts()?.thread;
27709
27713
  const force = !!resolvedOptions.force;
27710
27714
  const threadContext = threadId ? ` in thread "${threadId}"` : "";
27715
+ const targetContext = targetIdentifier ? ` for user "${targetIdentifier}"` : "";
27711
27716
  if (!force) {
27712
27717
  console.log(`
27713
- \u26A0\uFE0F WARNING: This will clear your conversation history${threadContext}!`);
27718
+ \u26A0\uFE0F WARNING: This will clear conversation history${targetContext}${threadContext}!`);
27714
27719
  console.log("\u26A0\uFE0F This action cannot be undone.\n");
27715
27720
  const confirmAnswer = await safePrompt([
27716
27721
  {
27717
27722
  type: "confirm",
27718
27723
  name: "confirm",
27719
- message: `Are you sure you want to clear your conversation history${threadContext}?`,
27724
+ message: `Are you sure you want to clear conversation history${targetContext}${threadContext}?`,
27720
27725
  default: false
27721
27726
  }
27722
27727
  ]);
@@ -27726,16 +27731,17 @@ async function chatClearCommand(options, command) {
27726
27731
  }
27727
27732
  writeProgress("\u{1F504} Clearing conversation history...");
27728
27733
  const chatApi = new ChatApi(BASE_URLS.CHAT, apiKey);
27729
- const response = await chatApi.clearHistory(agentId, threadId);
27734
+ const response = await chatApi.clearHistory(agentId, threadId, targetIdentifier);
27730
27735
  if (!response.success) {
27731
27736
  throw new Error(response.error?.message || "Failed to clear conversation history");
27732
27737
  }
27733
- writeSuccess(`\u2705 Your conversation history has been cleared${threadContext}`);
27734
- console.log(`\u{1F4A1} Your chat history has been completely removed${threadContext}.
27738
+ writeSuccess(`\u2705 Conversation history has been cleared${targetContext}${threadContext}`);
27739
+ console.log(`\u{1F4A1} Chat history has been completely removed${targetContext}${threadContext}.
27735
27740
  `);
27736
27741
  trackEvent("cli_chat_cleared", {
27737
27742
  force_mode: force,
27738
- has_thread_target: !!threadId
27743
+ has_thread_target: !!threadId,
27744
+ has_user_target: !!targetIdentifier
27739
27745
  });
27740
27746
  }, "chat clear");
27741
27747
  }
@@ -46380,16 +46386,19 @@ Examples:
46380
46386
  $ lua chat -b "Hello" "What is the weather?" "Tell me a joke" -d 2000 -e sandbox Batch test
46381
46387
  $ lua chat --agent-version 3 -m "test" Preview agent version 3 in an isolated thread
46382
46388
  `).action(chatCommand);
46383
- 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", `
46389
+ chatCmd.command("clear").description("Clear your own or an administered user's conversation history").option("--user <identifier>", "Clear another user by ID, email, or mobile (requires org:manage)").option("-t, --thread <id>", "Clear a specific thread's history instead of all history").option("--force", "Skip confirmation prompt").addHelpText("after", `
46384
46390
  Examples:
46385
46391
  $ lua chat clear Clear your history
46386
46392
  $ lua chat clear --force Clear your history without confirmation
46393
+ $ lua chat clear --user user@example.com Clear another user's history (requires org:manage)
46394
+ $ lua chat clear --user +1234567890 --force Clear another user's history without confirmation
46387
46395
  $ lua chat clear --thread <threadId> Clear a specific thread's history
46388
46396
  $ lua chat clear --thread <threadId> --force Clear a specific thread's history without confirmation
46389
46397
 
46390
46398
  Notes:
46391
- - This command only clears YOUR OWN conversation history
46392
- - The --user option was removed: cross-user history clear is no longer supported
46399
+ - Without --user, this command clears only YOUR OWN conversation history
46400
+ - --user requires org:manage for the agent
46401
+ - Org-admin grants do not cascade to private agents; org owners and explicit agent grants follow shared authorization rules
46393
46402
  `).action(chatClearCommand);
46394
46403
  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", `
46395
46404
  Arguments: