@adminforth/agent 2.0.1 → 2.0.3
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 +2 -2
- package/custom/conversation_area/ConversationArea.vue +12 -30
- package/dist/custom/conversation_area/ConversationArea.vue +12 -30
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -2
- package/index.ts +18 -2
- package/package.json +3 -3
package/build.log
CHANGED
|
@@ -63,5 +63,5 @@ custom/speech_recognition_frontend/voiceActivityDetection.ts
|
|
|
63
63
|
custom/speech_recognition_frontend/types/
|
|
64
64
|
custom/speech_recognition_frontend/types/voice-activity-detection.d.ts
|
|
65
65
|
|
|
66
|
-
sent 1,
|
|
67
|
-
total size is 1,
|
|
66
|
+
sent 1,682,247 bytes received 940 bytes 3,366,374.00 bytes/sec
|
|
67
|
+
total size is 1,677,986 speedup is 1.00
|
|
@@ -93,22 +93,14 @@ const agentTransitions = useAgentTransitions();
|
|
|
93
93
|
const showScrollContainer = ref(true);
|
|
94
94
|
const chatContainerRef = ref<HTMLElement | null>(null);
|
|
95
95
|
const messagesRefs = ref<Array<HTMLElement | null>>([]);
|
|
96
|
-
const useWaitingForHeight = ref(false);
|
|
97
|
-
|
|
98
96
|
/*
|
|
99
97
|
* Whenever user sends a message, it adds a bottom spacer, that takes the remaining height
|
|
100
98
|
* without last user and last agent message.
|
|
101
99
|
*
|
|
102
100
|
* On send message, happens the following logic:
|
|
103
101
|
* 1) showBottomSpacer is set to true
|
|
104
|
-
* 2)
|
|
105
|
-
*
|
|
106
|
-
* - When we want to read height of last user message, incremark shows text with some small delay
|
|
107
|
-
* - so when we read height of last user message, we actully getting height of the box without text ~18px
|
|
108
|
-
* - so for the initial period while useWaitingForHeight is true, we are waiting for real height to be bigger than 18px
|
|
109
|
-
* - and then we can read in normally, until new message is sent, then we need to wait again
|
|
110
|
-
* 3) updateSpacerHeight is called, which calculates the height for spacer based on scroll container height and messages height
|
|
111
|
-
* 4) Spacer moves text up
|
|
102
|
+
* 2) updateSpacerHeight is called, which calculates the height for spacer based on scroll container height and messages height
|
|
103
|
+
* 3) Spacer moves text up
|
|
112
104
|
*/
|
|
113
105
|
const showBottomSpacer = ref(false);
|
|
114
106
|
const spacerHeight = ref(0);
|
|
@@ -197,20 +189,6 @@ function getScrollClientHeight() {
|
|
|
197
189
|
return scrollContainer.value?.container.scrollEl.clientHeight ?? scrollContainer.value?.scrollParams.clientHeight ?? 0;
|
|
198
190
|
}
|
|
199
191
|
|
|
200
|
-
async function waitForRealHeight(role: 'user' | 'assistant'): Promise<number> {
|
|
201
|
-
const realHeightWeCanApprove = role === 'user' ? EMPTY_MESSAGE_HEIGHT : 0;
|
|
202
|
-
return new Promise((resolve) => {
|
|
203
|
-
const interval = setInterval(() => {
|
|
204
|
-
const height = role === 'user' ? getHeightOfLastUserMessage() : getHeightOfLastAgentMessage();
|
|
205
|
-
|
|
206
|
-
if (height > realHeightWeCanApprove) {
|
|
207
|
-
clearInterval(interval);
|
|
208
|
-
resolve(height);
|
|
209
|
-
}
|
|
210
|
-
}, 50);
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
192
|
async function updateSpacerHeight() {
|
|
215
193
|
if (!showBottomSpacer.value) {
|
|
216
194
|
return;
|
|
@@ -222,8 +200,8 @@ async function updateSpacerHeight() {
|
|
|
222
200
|
return;
|
|
223
201
|
}
|
|
224
202
|
|
|
225
|
-
const lastUserMessageHeight =
|
|
226
|
-
const lastAgentMessageHeight =
|
|
203
|
+
const lastUserMessageHeight = getHeightOfLastUserMessage();
|
|
204
|
+
const lastAgentMessageHeight = getHeightOfLastAgentMessage();
|
|
227
205
|
|
|
228
206
|
spacerHeight.value = Math.max(0, clientHeight - (lastUserMessageHeight + MASK_HEIGHT + lastAgentMessageHeight));
|
|
229
207
|
}
|
|
@@ -245,6 +223,14 @@ function scheduleSpacerHeightUpdate() {
|
|
|
245
223
|
spacerUpdateQueued = false;
|
|
246
224
|
pendingSpacerUpdate = updateSpacerHeight().finally(() => {
|
|
247
225
|
pendingSpacerUpdate = null;
|
|
226
|
+
|
|
227
|
+
// Auto-scroll to bottom if response generation is in progress
|
|
228
|
+
if (agentStore.isResponseInProgress) {
|
|
229
|
+
nextTick(() => {
|
|
230
|
+
scrollContainer.value?.scrollToBottom();
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
248
234
|
if (spacerUpdateQueued) {
|
|
249
235
|
scheduleSpacerHeightUpdate();
|
|
250
236
|
}
|
|
@@ -298,10 +284,6 @@ async function handleSendMessage() {
|
|
|
298
284
|
|
|
299
285
|
if (clientHeight) {
|
|
300
286
|
showBottomSpacer.value = true;
|
|
301
|
-
useWaitingForHeight.value = true;
|
|
302
|
-
setTimeout(() => {
|
|
303
|
-
useWaitingForHeight.value = false;
|
|
304
|
-
}, 1000);
|
|
305
287
|
await updateSpacerHeight();
|
|
306
288
|
await nextTick();
|
|
307
289
|
scrollContainer.value?.scrollToBottom();
|
|
@@ -93,22 +93,14 @@ const agentTransitions = useAgentTransitions();
|
|
|
93
93
|
const showScrollContainer = ref(true);
|
|
94
94
|
const chatContainerRef = ref<HTMLElement | null>(null);
|
|
95
95
|
const messagesRefs = ref<Array<HTMLElement | null>>([]);
|
|
96
|
-
const useWaitingForHeight = ref(false);
|
|
97
|
-
|
|
98
96
|
/*
|
|
99
97
|
* Whenever user sends a message, it adds a bottom spacer, that takes the remaining height
|
|
100
98
|
* without last user and last agent message.
|
|
101
99
|
*
|
|
102
100
|
* On send message, happens the following logic:
|
|
103
101
|
* 1) showBottomSpacer is set to true
|
|
104
|
-
* 2)
|
|
105
|
-
*
|
|
106
|
-
* - When we want to read height of last user message, incremark shows text with some small delay
|
|
107
|
-
* - so when we read height of last user message, we actully getting height of the box without text ~18px
|
|
108
|
-
* - so for the initial period while useWaitingForHeight is true, we are waiting for real height to be bigger than 18px
|
|
109
|
-
* - and then we can read in normally, until new message is sent, then we need to wait again
|
|
110
|
-
* 3) updateSpacerHeight is called, which calculates the height for spacer based on scroll container height and messages height
|
|
111
|
-
* 4) Spacer moves text up
|
|
102
|
+
* 2) updateSpacerHeight is called, which calculates the height for spacer based on scroll container height and messages height
|
|
103
|
+
* 3) Spacer moves text up
|
|
112
104
|
*/
|
|
113
105
|
const showBottomSpacer = ref(false);
|
|
114
106
|
const spacerHeight = ref(0);
|
|
@@ -197,20 +189,6 @@ function getScrollClientHeight() {
|
|
|
197
189
|
return scrollContainer.value?.container.scrollEl.clientHeight ?? scrollContainer.value?.scrollParams.clientHeight ?? 0;
|
|
198
190
|
}
|
|
199
191
|
|
|
200
|
-
async function waitForRealHeight(role: 'user' | 'assistant'): Promise<number> {
|
|
201
|
-
const realHeightWeCanApprove = role === 'user' ? EMPTY_MESSAGE_HEIGHT : 0;
|
|
202
|
-
return new Promise((resolve) => {
|
|
203
|
-
const interval = setInterval(() => {
|
|
204
|
-
const height = role === 'user' ? getHeightOfLastUserMessage() : getHeightOfLastAgentMessage();
|
|
205
|
-
|
|
206
|
-
if (height > realHeightWeCanApprove) {
|
|
207
|
-
clearInterval(interval);
|
|
208
|
-
resolve(height);
|
|
209
|
-
}
|
|
210
|
-
}, 50);
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
192
|
async function updateSpacerHeight() {
|
|
215
193
|
if (!showBottomSpacer.value) {
|
|
216
194
|
return;
|
|
@@ -222,8 +200,8 @@ async function updateSpacerHeight() {
|
|
|
222
200
|
return;
|
|
223
201
|
}
|
|
224
202
|
|
|
225
|
-
const lastUserMessageHeight =
|
|
226
|
-
const lastAgentMessageHeight =
|
|
203
|
+
const lastUserMessageHeight = getHeightOfLastUserMessage();
|
|
204
|
+
const lastAgentMessageHeight = getHeightOfLastAgentMessage();
|
|
227
205
|
|
|
228
206
|
spacerHeight.value = Math.max(0, clientHeight - (lastUserMessageHeight + MASK_HEIGHT + lastAgentMessageHeight));
|
|
229
207
|
}
|
|
@@ -245,6 +223,14 @@ function scheduleSpacerHeightUpdate() {
|
|
|
245
223
|
spacerUpdateQueued = false;
|
|
246
224
|
pendingSpacerUpdate = updateSpacerHeight().finally(() => {
|
|
247
225
|
pendingSpacerUpdate = null;
|
|
226
|
+
|
|
227
|
+
// Auto-scroll to bottom if response generation is in progress
|
|
228
|
+
if (agentStore.isResponseInProgress) {
|
|
229
|
+
nextTick(() => {
|
|
230
|
+
scrollContainer.value?.scrollToBottom();
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
248
234
|
if (spacerUpdateQueued) {
|
|
249
235
|
scheduleSpacerHeightUpdate();
|
|
250
236
|
}
|
|
@@ -298,10 +284,6 @@ async function handleSendMessage() {
|
|
|
298
284
|
|
|
299
285
|
if (clientHeight) {
|
|
300
286
|
showBottomSpacer.value = true;
|
|
301
|
-
useWaitingForHeight.value = true;
|
|
302
|
-
setTimeout(() => {
|
|
303
|
-
useWaitingForHeight.value = false;
|
|
304
|
-
}, 1000);
|
|
305
287
|
await updateSpacerHeight();
|
|
306
288
|
await nextTick();
|
|
307
289
|
scrollContainer.value?.scrollToBottom();
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
|
|
|
6
6
|
options: PluginOptions;
|
|
7
7
|
agentSystemPromptPromise: Promise<string>;
|
|
8
8
|
pluginsScope: "resource" | "global";
|
|
9
|
+
private agentSystemPrompt;
|
|
9
10
|
private checkpointer;
|
|
10
11
|
private sessionStore;
|
|
11
12
|
private agentTurnService;
|
package/dist/index.js
CHANGED
|
@@ -56,6 +56,7 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
|
|
|
56
56
|
var _a;
|
|
57
57
|
super(options, import.meta.url);
|
|
58
58
|
this.pluginsScope = "global";
|
|
59
|
+
this.agentSystemPrompt = null;
|
|
59
60
|
this.checkpointer = null;
|
|
60
61
|
this.options = options;
|
|
61
62
|
this.sessionStore = new AgentSessionStore(() => this.adminforth, this.options);
|
|
@@ -69,7 +70,15 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
|
|
|
69
70
|
const persistence = new TurnPersistenceService(() => this.adminforth, this.options);
|
|
70
71
|
this.agentTurnService = new AgentTurnService(new TurnLifecycleService(this.sessionStore, persistence, this.options), new TurnContextBuilder(() => this.adminforth), new AgentModeResolver(this.options), new AgentModelFactory((_a = this.options.maxTokens) !== null && _a !== void 0 ? _a : 1000), new TurnPromptBuilder({
|
|
71
72
|
getAdminforth: () => this.adminforth,
|
|
72
|
-
getAgentSystemPrompt: () => this
|
|
73
|
+
getAgentSystemPrompt: () => __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
if (!this.agentSystemPrompt) {
|
|
75
|
+
const systemPrompt = yield buildAgentSystemPrompt(this.adminforth, this.getInternalAgentResourceIds()).catch((err) => {
|
|
76
|
+
return DEFAULT_AGENT_SYSTEM_PROMPT;
|
|
77
|
+
});
|
|
78
|
+
this.agentSystemPrompt = appendCustomSystemPrompt(systemPrompt, this.options.systemPrompt);
|
|
79
|
+
}
|
|
80
|
+
return this.agentSystemPrompt;
|
|
81
|
+
}),
|
|
73
82
|
}), runtime, new TurnStreamConsumer());
|
|
74
83
|
this.speechTurnService = new SpeechTurnService(this.agentTurnService.runAndPersistAgentResponse.bind(this.agentTurnService));
|
|
75
84
|
this.chatSurfaceService = new ChatSurfaceService(() => this.adminforth, this.options, this.sessionStore, this.agentTurnService.handleTurn.bind(this.agentTurnService), this.agentTurnService.runAndPersistAgentResponse.bind(this.agentTurnService));
|
|
@@ -125,7 +134,11 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
|
|
|
125
134
|
chatSurfaceAdapter.validate();
|
|
126
135
|
}
|
|
127
136
|
this.agentSystemPromptPromise = buildAgentSystemPrompt(adminforth, this.getInternalAgentResourceIds())
|
|
128
|
-
.then((systemPrompt) =>
|
|
137
|
+
.then((systemPrompt) => {
|
|
138
|
+
const finalPrompt = appendCustomSystemPrompt(systemPrompt, this.options.systemPrompt);
|
|
139
|
+
this.agentSystemPrompt = finalPrompt;
|
|
140
|
+
return finalPrompt;
|
|
141
|
+
});
|
|
129
142
|
}
|
|
130
143
|
instanceUniqueRepresentation(pluginOptions) {
|
|
131
144
|
return `single`;
|
package/index.ts
CHANGED
|
@@ -35,6 +35,7 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
|
|
|
35
35
|
options: PluginOptions;
|
|
36
36
|
agentSystemPromptPromise: Promise<string>;
|
|
37
37
|
pluginsScope: "resource" | "global" = "global";
|
|
38
|
+
private agentSystemPrompt: string | null = null;
|
|
38
39
|
private checkpointer: BaseCheckpointSaver | null = null;
|
|
39
40
|
private sessionStore: AgentSessionStore;
|
|
40
41
|
private agentTurnService: AgentTurnService;
|
|
@@ -92,7 +93,18 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
|
|
|
92
93
|
new AgentModelFactory(this.options.maxTokens ?? 1000),
|
|
93
94
|
new TurnPromptBuilder({
|
|
94
95
|
getAdminforth: () => this.adminforth,
|
|
95
|
-
getAgentSystemPrompt: () =>
|
|
96
|
+
getAgentSystemPrompt: async () => {
|
|
97
|
+
if (!this.agentSystemPrompt) {
|
|
98
|
+
const systemPrompt = await buildAgentSystemPrompt(
|
|
99
|
+
this.adminforth,
|
|
100
|
+
this.getInternalAgentResourceIds(),
|
|
101
|
+
).catch((err) => {
|
|
102
|
+
return DEFAULT_AGENT_SYSTEM_PROMPT;
|
|
103
|
+
});
|
|
104
|
+
this.agentSystemPrompt = appendCustomSystemPrompt(systemPrompt, this.options.systemPrompt);
|
|
105
|
+
}
|
|
106
|
+
return this.agentSystemPrompt;
|
|
107
|
+
},
|
|
96
108
|
}),
|
|
97
109
|
runtime,
|
|
98
110
|
new TurnStreamConsumer(),
|
|
@@ -162,7 +174,11 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
|
|
|
162
174
|
adminforth,
|
|
163
175
|
this.getInternalAgentResourceIds(),
|
|
164
176
|
)
|
|
165
|
-
.then((systemPrompt) =>
|
|
177
|
+
.then((systemPrompt) => {
|
|
178
|
+
const finalPrompt = appendCustomSystemPrompt(systemPrompt, this.options.systemPrompt);
|
|
179
|
+
this.agentSystemPrompt = finalPrompt;
|
|
180
|
+
return finalPrompt;
|
|
181
|
+
});
|
|
166
182
|
}
|
|
167
183
|
|
|
168
184
|
instanceUniqueRepresentation(pluginOptions: any) : string {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminforth/agent",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"description": "AI agent plugin for AdminForth with tool-based workflows and persistent chat sessions",
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "latest",
|
|
28
|
-
"adminforth": "^3.
|
|
28
|
+
"adminforth": "^3.6.2",
|
|
29
29
|
"semantic-release": "^24.2.1",
|
|
30
30
|
"semantic-release-slack-bot": "^4.0.2",
|
|
31
31
|
"typescript": "^5.7.3"
|
|
@@ -67,6 +67,6 @@
|
|
|
67
67
|
}
|
|
68
68
|
],
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"adminforth": "^3.
|
|
70
|
+
"adminforth": "^3.6.2"
|
|
71
71
|
}
|
|
72
72
|
}
|