@react-grab/ami 0.0.91 → 0.0.92

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
@@ -101,7 +101,7 @@ var require_picocolors = __commonJS({
101
101
 
102
102
  // src/cli.ts
103
103
  var import_picocolors = __toESM(require_picocolors());
104
- var VERSION = "0.0.91";
104
+ var VERSION = "0.0.92";
105
105
  console.log(
106
106
  `${import_picocolors.default.magenta("\u273F")} ${import_picocolors.default.bold("React Grab")} ${import_picocolors.default.gray(VERSION)} ${import_picocolors.default.dim("(Ami)")}`
107
107
  );
package/dist/cli.js CHANGED
@@ -99,7 +99,7 @@ var require_picocolors = __commonJS({
99
99
 
100
100
  // src/cli.ts
101
101
  var import_picocolors = __toESM(require_picocolors());
102
- var VERSION = "0.0.91";
102
+ var VERSION = "0.0.92";
103
103
  console.log(
104
104
  `${import_picocolors.default.magenta("\u273F")} ${import_picocolors.default.bold("React Grab")} ${import_picocolors.default.gray(VERSION)} ${import_picocolors.default.dim("(Ami)")}`
105
105
  );
package/dist/client.cjs CHANGED
@@ -17386,7 +17386,7 @@ var getStoredAgentContext = (storage, sessionId, storageKey = STORAGE_KEY) => {
17386
17386
  if (!isRecord(context)) throw new Error(`Session ${sessionId} is invalid`);
17387
17387
  const content = context.content;
17388
17388
  const prompt = context.prompt;
17389
- if (typeof content !== "string" || typeof prompt !== "string") {
17389
+ if (!Array.isArray(content) || typeof prompt !== "string") {
17390
17390
  throw new Error(`Session ${sessionId} is invalid`);
17391
17391
  }
17392
17392
  const options = context.options;
@@ -17488,11 +17488,11 @@ var sanitizeMessages = (messages) => {
17488
17488
  }
17489
17489
  return sanitized;
17490
17490
  };
17491
- var runAgent = async (context, token, projectId, onStatus, existingMessages, existingChatId) => {
17491
+ var runAgentForElement = async (prompt, elementContent, token, projectId, onStatus, existingMessages, existingChatId) => {
17492
17492
  const isFollowUp = Boolean(existingMessages && existingMessages.length > 0);
17493
- const userMessageContent = isFollowUp ? context.prompt : `${context.prompt}
17493
+ const userMessageContent = isFollowUp ? prompt : `${prompt}
17494
17494
 
17495
- ${context.content}`;
17495
+ ${elementContent}`;
17496
17496
  const messages = existingMessages ? [...existingMessages] : [];
17497
17497
  messages.push(
17498
17498
  _({
@@ -17542,6 +17542,35 @@ ${context.content}`;
17542
17542
  return { status: COMPLETED_STATUS, messages, chatId };
17543
17543
  }
17544
17544
  };
17545
+ var runAgent = async (context, token, projectId, onStatus, existingMessages, existingChatId) => {
17546
+ const contentItems = Array.isArray(context.content) ? context.content : [context.content];
17547
+ let currentMessages = existingMessages;
17548
+ let currentChatId = existingChatId;
17549
+ for (let elementIndex = 0; elementIndex < contentItems.length; elementIndex++) {
17550
+ const elementContent = contentItems[elementIndex];
17551
+ if (contentItems.length > 1) {
17552
+ onStatus(
17553
+ `Processing element ${elementIndex + 1} of ${contentItems.length}...`
17554
+ );
17555
+ }
17556
+ const result = await runAgentForElement(
17557
+ context.prompt,
17558
+ elementContent,
17559
+ token,
17560
+ projectId,
17561
+ onStatus,
17562
+ currentMessages,
17563
+ currentChatId
17564
+ );
17565
+ currentMessages = result.messages;
17566
+ currentChatId = result.chatId;
17567
+ }
17568
+ return {
17569
+ status: COMPLETED_STATUS,
17570
+ messages: currentMessages ?? [],
17571
+ chatId: currentChatId ?? ""
17572
+ };
17573
+ };
17545
17574
  var isReactGrabApi = (value) => typeof value === "object" && value !== null && "setAgent" in value;
17546
17575
  var createAmiAgentProvider = (projectId) => {
17547
17576
  let lastAgentMessages = null;