@adminforth/agent 1.18.1 → 1.18.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/build.log CHANGED
@@ -32,5 +32,5 @@ custom/skills/fetch_data/SKILL.md
32
32
  custom/skills/mutate_data/
33
33
  custom/skills/mutate_data/SKILL.md
34
34
 
35
- sent 186,137 bytes received 455 bytes 373,184.00 bytes/sec
36
- total size is 184,285 speedup is 0.99
35
+ sent 187,002 bytes received 451 bytes 374,906.00 bytes/sec
36
+ total size is 185,150 speedup is 0.99
@@ -37,9 +37,8 @@
37
37
  class="flex flex-col w-full"
38
38
  :class="message.role === 'user' ? 'self-end' : 'self-start'"
39
39
  >
40
- <ToolsGroup :toolGroup="groupToolCallParts(message)" />
41
40
  <template
42
- v-for="part in getParts(message)"
41
+ v-for="(part, index) in getParts(message)"
43
42
  :key="part.type"
44
43
  >
45
44
  <Message
@@ -52,6 +51,7 @@
52
51
  @toggle-thoughts="() => clicks++"
53
52
  >
54
53
  </Message>
54
+ <ToolsGroup v-else :toolGroup="groupToolCallParts(message, index, part)" />
55
55
  </template>
56
56
  </div>
57
57
  <!-- Show a placeholder message if the last message is not of type 'text' or 'reasoning' -->
@@ -154,27 +154,39 @@ const formatToolCallTextPart = ((part: IPart, currentMessage: IMessage) => {
154
154
  return null;
155
155
  });
156
156
 
157
- const groupToolCallParts = (message: IMessage) => {
158
- const groupedParts = [];
159
- let currentToolName = null;
157
+ const groupToolCallParts = (message: IMessage, currentPartIndex: number, currentPart: IPart) => {
158
+ const groupedParts: { title: string; groupedTools: IPart[] }[] = [];
159
+ let currentToolName: string | null = null;
160
160
  const parts = getParts(message);
161
161
  if (!parts) return [];
162
162
  const formatedToolParts = parts.map(part => {
163
163
  return formatToolCallTextPart(part as IPart, message)
164
164
  });
165
+ const currentPartIndexInFormatedParts = formatedToolParts.findIndex(part => part?.toolInfo?.toolCallId === currentPart.data?.toolCallId);
166
+ if (currentPartIndexInFormatedParts === -1) {
167
+ return [];
168
+ }
165
169
  for( const[index, part] of formatedToolParts.entries()){
166
- if(!part?.toolInfo) {
170
+ if ( index < currentPartIndexInFormatedParts - 1 ) {
167
171
  continue;
168
172
  }
169
- if (part.toolInfo.toolName === currentToolName) {
170
- groupedParts[groupedParts.length - 1].groupedTools.push(part);
173
+ if(!part || !part.toolInfo) {
171
174
  continue;
172
175
  }
173
176
  currentToolName = part.toolInfo.toolName;
174
- groupedParts.push({
175
- title: currentToolName,
176
- groupedTools: [part]
177
- });
177
+ if (!groupedParts.find(group => group.title === currentToolName)) {
178
+ groupedParts.push({
179
+ title: currentToolName,
180
+ groupedTools: []
181
+ })
182
+ }
183
+ if( formatedToolParts[currentPartIndexInFormatedParts - 1]?.toolInfo.toolName === part.toolInfo.toolName) {
184
+ continue;
185
+ } else if ( formatedToolParts[currentPartIndexInFormatedParts + 1]?.toolInfo.toolName === part.toolInfo.toolName) {
186
+ groupedParts[groupedParts.length - 1].groupedTools.push(formatedToolParts[currentPartIndexInFormatedParts + 1] as IPart);
187
+ } else {
188
+ groupedParts[groupedParts.length - 1].groupedTools.push(part);
189
+ }
178
190
  }
179
191
  return groupedParts;
180
192
  }
@@ -15,7 +15,7 @@
15
15
  </div>
16
16
  </transition>
17
17
  </div>
18
- <ToolRenderer v-else :data="group.groupedTools[0]" />
18
+ <ToolRenderer v-else-if="group.groupedTools.length > 0" :data="group.groupedTools[0]" />
19
19
  </template>
20
20
 
21
21
  </template>
@@ -37,9 +37,8 @@
37
37
  class="flex flex-col w-full"
38
38
  :class="message.role === 'user' ? 'self-end' : 'self-start'"
39
39
  >
40
- <ToolsGroup :toolGroup="groupToolCallParts(message)" />
41
40
  <template
42
- v-for="part in getParts(message)"
41
+ v-for="(part, index) in getParts(message)"
43
42
  :key="part.type"
44
43
  >
45
44
  <Message
@@ -52,6 +51,7 @@
52
51
  @toggle-thoughts="() => clicks++"
53
52
  >
54
53
  </Message>
54
+ <ToolsGroup v-else :toolGroup="groupToolCallParts(message, index, part)" />
55
55
  </template>
56
56
  </div>
57
57
  <!-- Show a placeholder message if the last message is not of type 'text' or 'reasoning' -->
@@ -154,27 +154,39 @@ const formatToolCallTextPart = ((part: IPart, currentMessage: IMessage) => {
154
154
  return null;
155
155
  });
156
156
 
157
- const groupToolCallParts = (message: IMessage) => {
158
- const groupedParts = [];
159
- let currentToolName = null;
157
+ const groupToolCallParts = (message: IMessage, currentPartIndex: number, currentPart: IPart) => {
158
+ const groupedParts: { title: string; groupedTools: IPart[] }[] = [];
159
+ let currentToolName: string | null = null;
160
160
  const parts = getParts(message);
161
161
  if (!parts) return [];
162
162
  const formatedToolParts = parts.map(part => {
163
163
  return formatToolCallTextPart(part as IPart, message)
164
164
  });
165
+ const currentPartIndexInFormatedParts = formatedToolParts.findIndex(part => part?.toolInfo?.toolCallId === currentPart.data?.toolCallId);
166
+ if (currentPartIndexInFormatedParts === -1) {
167
+ return [];
168
+ }
165
169
  for( const[index, part] of formatedToolParts.entries()){
166
- if(!part?.toolInfo) {
170
+ if ( index < currentPartIndexInFormatedParts - 1 ) {
167
171
  continue;
168
172
  }
169
- if (part.toolInfo.toolName === currentToolName) {
170
- groupedParts[groupedParts.length - 1].groupedTools.push(part);
173
+ if(!part || !part.toolInfo) {
171
174
  continue;
172
175
  }
173
176
  currentToolName = part.toolInfo.toolName;
174
- groupedParts.push({
175
- title: currentToolName,
176
- groupedTools: [part]
177
- });
177
+ if (!groupedParts.find(group => group.title === currentToolName)) {
178
+ groupedParts.push({
179
+ title: currentToolName,
180
+ groupedTools: []
181
+ })
182
+ }
183
+ if( formatedToolParts[currentPartIndexInFormatedParts - 1]?.toolInfo.toolName === part.toolInfo.toolName) {
184
+ continue;
185
+ } else if ( formatedToolParts[currentPartIndexInFormatedParts + 1]?.toolInfo.toolName === part.toolInfo.toolName) {
186
+ groupedParts[groupedParts.length - 1].groupedTools.push(formatedToolParts[currentPartIndexInFormatedParts + 1] as IPart);
187
+ } else {
188
+ groupedParts[groupedParts.length - 1].groupedTools.push(part);
189
+ }
178
190
  }
179
191
  return groupedParts;
180
192
  }
@@ -15,7 +15,7 @@
15
15
  </div>
16
16
  </transition>
17
17
  </div>
18
- <ToolRenderer v-else :data="group.groupedTools[0]" />
18
+ <ToolRenderer v-else-if="group.groupedTools.length > 0" :data="group.groupedTools[0]" />
19
19
  </template>
20
20
 
21
21
  </template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/agent",
3
- "version": "1.18.1",
3
+ "version": "1.18.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",