@cloudbase/agent-agents 0.0.2 → 0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,71 @@
1
1
  # @cloudbase/agent-agents
2
2
 
3
+ ## 0.0.11-alpha.3
4
+
5
+ ### Patch Changes
6
+
7
+ - alpha release 0.0.10-alpha.2
8
+ - Update all public packages to version 0.0.10-alpha.2
9
+ - Trigger automated alpha release workflow
10
+ - Includes latest features and improvements
11
+
12
+ - Updated dependencies
13
+ - @cloudbase/agent-tools@0.0.11-alpha.3
14
+
15
+ ## 0.0.11-alpha.2
16
+
17
+ ### Patch Changes
18
+
19
+ - alpha release 0.0.10-alpha.2
20
+ - Update all public packages to version 0.0.10-alpha.2
21
+ - Trigger automated alpha release workflow
22
+ - Includes latest features and improvements
23
+
24
+ - Updated dependencies
25
+ - @cloudbase/agent-tools@0.0.11-alpha.2
26
+
27
+ ## 0.0.11-alpha.1
28
+
29
+ ### Patch Changes
30
+
31
+ - alpha release 0.0.10-alpha.2
32
+ - Update all public packages to version 0.0.10-alpha.2
33
+ - Trigger automated alpha release workflow
34
+ - Includes latest features and improvements
35
+
36
+ - Updated dependencies
37
+ - @cloudbase/agent-tools@0.0.11-alpha.1
38
+
39
+ ## 0.0.11-alpha.0
40
+
41
+ ### Patch Changes
42
+
43
+ - 97b2740: alpha release 0.0.10-alpha.2
44
+ - Update all public packages to version 0.0.10-alpha.2
45
+ - Trigger automated alpha release workflow
46
+ - Includes latest features and improvements
47
+
48
+ - fd4c62a: alpha release 0.0.10-alpha.2
49
+ - Update all public packages to version 0.0.10-alpha.2
50
+ - Trigger automated alpha release workflow
51
+ - Includes latest features and improvements
52
+
53
+ - da3388c: alpha release 0.0.10-alpha.2
54
+ - Update all public packages to version 0.0.10-alpha.2
55
+ - Trigger automated alpha release workflow
56
+ - Includes latest features and improvements
57
+
58
+ - alpha release 0.0.10-alpha.2
59
+ - Update all public packages to version 0.0.10-alpha.2
60
+ - Trigger automated alpha release workflow
61
+ - Includes latest features and improvements
62
+
63
+ - Updated dependencies [97b2740]
64
+ - Updated dependencies [fd4c62a]
65
+ - Updated dependencies [da3388c]
66
+ - Updated dependencies
67
+ - @cloudbase/agent-tools@0.0.11-alpha.0
68
+
3
69
  ## 0.0.10
4
70
 
5
71
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1938,13 +1938,14 @@ var import_node_crypto3 = require("crypto");
1938
1938
  init_events();
1939
1939
  var import_v42 = require("zod/v4");
1940
1940
  var AgentExecutor = class {
1941
- constructor(config, modelProvider, toolExecutionHandler, messageBuilder, getBusinessState, addMessages) {
1941
+ constructor(config, modelProvider, toolExecutionHandler, messageBuilder, getBusinessState, addMessages, syncState) {
1942
1942
  this.config = config;
1943
1943
  this.modelProvider = modelProvider;
1944
1944
  this.toolExecutionHandler = toolExecutionHandler;
1945
1945
  this.messageBuilder = messageBuilder;
1946
1946
  this.getBusinessState = getBusinessState;
1947
1947
  this.addMessages = addMessages;
1948
+ this.syncState = syncState;
1948
1949
  }
1949
1950
  /**
1950
1951
  * Execute the agent core loop
@@ -2271,6 +2272,10 @@ var AgentExecutor = class {
2271
2272
  [result.messageToSave],
2272
2273
  this.getBusinessState()
2273
2274
  );
2275
+ if (this.syncState && result.messageToSave.metadata?.state) {
2276
+ const updatedState = result.messageToSave.metadata.state;
2277
+ this.syncState(updatedState);
2278
+ }
2274
2279
  }
2275
2280
  if (!result.success) {
2276
2281
  allToolsHandled = false;
@@ -2284,10 +2289,17 @@ var AgentExecutor = class {
2284
2289
  async checkControlFlow(customHandler, context, eventEmitter, startTime, allMessages, totalTokenUsage) {
2285
2290
  if (!customHandler) return null;
2286
2291
  try {
2292
+ const latestUserMessage = allMessages.filter((m) => m.role === "user").pop()?.content || "";
2293
+ const state = this.getBusinessState();
2294
+ const userMessage = state?.userResponse || latestUserMessage;
2287
2295
  const controlDecision = await customHandler.handleNextStep(
2288
2296
  context,
2289
- this.getBusinessState()
2297
+ state,
2298
+ userMessage
2290
2299
  );
2300
+ if (this.syncState) {
2301
+ this.syncState(state);
2302
+ }
2291
2303
  switch (controlDecision.action) {
2292
2304
  case "continue":
2293
2305
  return null;
@@ -4163,7 +4175,15 @@ var Agent = class {
4163
4175
  this.toolExecutionHandler,
4164
4176
  this.messageBuilder,
4165
4177
  () => this.state.businessState,
4166
- (conversationId, messages, state) => this.addMessages(conversationId, messages, state)
4178
+ (conversationId, messages, state) => this.addMessages(conversationId, messages, state),
4179
+ // State sync callback: merge updated state into businessState
4180
+ (updatedState) => {
4181
+ if (this.state.businessState && typeof this.state.businessState === "object" && typeof updatedState === "object") {
4182
+ Object.assign(this.state.businessState, updatedState);
4183
+ } else {
4184
+ this.state.businessState = updatedState;
4185
+ }
4186
+ }
4167
4187
  );
4168
4188
  }
4169
4189
  /**