@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/client.js CHANGED
@@ -17384,7 +17384,7 @@ var getStoredAgentContext = (storage, sessionId, storageKey = STORAGE_KEY) => {
17384
17384
  if (!isRecord(context)) throw new Error(`Session ${sessionId} is invalid`);
17385
17385
  const content = context.content;
17386
17386
  const prompt = context.prompt;
17387
- if (typeof content !== "string" || typeof prompt !== "string") {
17387
+ if (!Array.isArray(content) || typeof prompt !== "string") {
17388
17388
  throw new Error(`Session ${sessionId} is invalid`);
17389
17389
  }
17390
17390
  const options = context.options;
@@ -17486,11 +17486,11 @@ var sanitizeMessages = (messages) => {
17486
17486
  }
17487
17487
  return sanitized;
17488
17488
  };
17489
- var runAgent = async (context, token, projectId, onStatus, existingMessages, existingChatId) => {
17489
+ var runAgentForElement = async (prompt, elementContent, token, projectId, onStatus, existingMessages, existingChatId) => {
17490
17490
  const isFollowUp = Boolean(existingMessages && existingMessages.length > 0);
17491
- const userMessageContent = isFollowUp ? context.prompt : `${context.prompt}
17491
+ const userMessageContent = isFollowUp ? prompt : `${prompt}
17492
17492
 
17493
- ${context.content}`;
17493
+ ${elementContent}`;
17494
17494
  const messages = existingMessages ? [...existingMessages] : [];
17495
17495
  messages.push(
17496
17496
  _({
@@ -17540,6 +17540,35 @@ ${context.content}`;
17540
17540
  return { status: COMPLETED_STATUS, messages, chatId };
17541
17541
  }
17542
17542
  };
17543
+ var runAgent = async (context, token, projectId, onStatus, existingMessages, existingChatId) => {
17544
+ const contentItems = Array.isArray(context.content) ? context.content : [context.content];
17545
+ let currentMessages = existingMessages;
17546
+ let currentChatId = existingChatId;
17547
+ for (let elementIndex = 0; elementIndex < contentItems.length; elementIndex++) {
17548
+ const elementContent = contentItems[elementIndex];
17549
+ if (contentItems.length > 1) {
17550
+ onStatus(
17551
+ `Processing element ${elementIndex + 1} of ${contentItems.length}...`
17552
+ );
17553
+ }
17554
+ const result = await runAgentForElement(
17555
+ context.prompt,
17556
+ elementContent,
17557
+ token,
17558
+ projectId,
17559
+ onStatus,
17560
+ currentMessages,
17561
+ currentChatId
17562
+ );
17563
+ currentMessages = result.messages;
17564
+ currentChatId = result.chatId;
17565
+ }
17566
+ return {
17567
+ status: COMPLETED_STATUS,
17568
+ messages: currentMessages ?? [],
17569
+ chatId: currentChatId ?? ""
17570
+ };
17571
+ };
17543
17572
  var isReactGrabApi = (value) => typeof value === "object" && value !== null && "setAgent" in value;
17544
17573
  var createAmiAgentProvider = (projectId) => {
17545
17574
  let lastAgentMessages = null;
package/dist/server.cjs CHANGED
@@ -7,7 +7,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
7
  var pc__default = /*#__PURE__*/_interopDefault(pc);
8
8
 
9
9
  // src/server.ts
10
- var VERSION = "0.0.91";
10
+ var VERSION = "0.0.92";
11
11
  try {
12
12
  fetch(
13
13
  `https://www.react-grab.com/api/version?source=ami&t=${Date.now()}`
package/dist/server.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import pc from 'picocolors';
2
2
 
3
3
  // src/server.ts
4
- var VERSION = "0.0.91";
4
+ var VERSION = "0.0.92";
5
5
  try {
6
6
  fetch(
7
7
  `https://www.react-grab.com/api/version?source=ami&t=${Date.now()}`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-grab/ami",
3
- "version": "0.0.91",
3
+ "version": "0.0.92",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "react-grab-ami": "./dist/cli.cjs"
@@ -23,12 +23,12 @@
23
23
  "devDependencies": {
24
24
  "@types/node": "^22.10.7",
25
25
  "tsup": "^8.4.0",
26
- "@react-grab/utils": "0.0.91"
26
+ "@react-grab/utils": "0.0.92"
27
27
  },
28
28
  "dependencies": {
29
29
  "ami-sdk": "^0.0.6",
30
30
  "picocolors": "^1.1.1",
31
- "react-grab": "0.0.91"
31
+ "react-grab": "0.0.92"
32
32
  },
33
33
  "scripts": {
34
34
  "dev": "tsup --watch",