agent-swarm-kit 1.0.192 → 1.0.194
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/index.cjs +16 -15
- package/build/index.mjs +16 -15
- package/package.json +1 -1
package/build/index.cjs
CHANGED
|
@@ -16638,8 +16638,21 @@ const METHOD_NAME_CREATE = "RoundRobin.create";
|
|
|
16638
16638
|
class RoundRobin {
|
|
16639
16639
|
constructor(tokens, factory) {
|
|
16640
16640
|
this.currentIndex = 0;
|
|
16641
|
-
|
|
16642
|
-
|
|
16641
|
+
this.call = (...args) => {
|
|
16642
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16643
|
+
swarm$1.loggerService.log(METHOD_NAME_CALL, {
|
|
16644
|
+
currentIndex: this.currentIndex,
|
|
16645
|
+
tokenCount: this.tokens.length,
|
|
16646
|
+
});
|
|
16647
|
+
if (!this.tokens.length) {
|
|
16648
|
+
throw new Error("agent-swarm RoundRobin requires non-empty tokens array");
|
|
16649
|
+
}
|
|
16650
|
+
const token = this.tokens[this.currentIndex];
|
|
16651
|
+
const instance = this.instances.get(token);
|
|
16652
|
+
const value = instance(...args);
|
|
16653
|
+
this.currentIndex = (this.currentIndex + 1) % this.tokens.length;
|
|
16654
|
+
return value;
|
|
16655
|
+
};
|
|
16643
16656
|
this.tokens = tokens;
|
|
16644
16657
|
this.instances = new Map(tokens.map((token) => [token, factory(token)]));
|
|
16645
16658
|
}
|
|
@@ -16653,19 +16666,7 @@ class RoundRobin {
|
|
|
16653
16666
|
swarm$1.loggerService.log(METHOD_NAME_CREATE, {
|
|
16654
16667
|
tokenCount: tokens.length,
|
|
16655
16668
|
});
|
|
16656
|
-
return new RoundRobin(tokens, factory).call
|
|
16657
|
-
}
|
|
16658
|
-
call(...args) {
|
|
16659
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16660
|
-
swarm$1.loggerService.log(METHOD_NAME_CALL, {
|
|
16661
|
-
currentIndex: this.currentIndex,
|
|
16662
|
-
tokenCount: this.tokens.length,
|
|
16663
|
-
});
|
|
16664
|
-
const token = this.tokens[this.currentIndex];
|
|
16665
|
-
const instance = this.instances.get(token);
|
|
16666
|
-
const value = instance(...args);
|
|
16667
|
-
this.currentIndex = (this.currentIndex + 1) % this.tokens.length;
|
|
16668
|
-
return value;
|
|
16669
|
+
return new RoundRobin(tokens, factory).call;
|
|
16669
16670
|
}
|
|
16670
16671
|
}
|
|
16671
16672
|
|
package/build/index.mjs
CHANGED
|
@@ -16636,8 +16636,21 @@ const METHOD_NAME_CREATE = "RoundRobin.create";
|
|
|
16636
16636
|
class RoundRobin {
|
|
16637
16637
|
constructor(tokens, factory) {
|
|
16638
16638
|
this.currentIndex = 0;
|
|
16639
|
-
|
|
16640
|
-
|
|
16639
|
+
this.call = (...args) => {
|
|
16640
|
+
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16641
|
+
swarm$1.loggerService.log(METHOD_NAME_CALL, {
|
|
16642
|
+
currentIndex: this.currentIndex,
|
|
16643
|
+
tokenCount: this.tokens.length,
|
|
16644
|
+
});
|
|
16645
|
+
if (!this.tokens.length) {
|
|
16646
|
+
throw new Error("agent-swarm RoundRobin requires non-empty tokens array");
|
|
16647
|
+
}
|
|
16648
|
+
const token = this.tokens[this.currentIndex];
|
|
16649
|
+
const instance = this.instances.get(token);
|
|
16650
|
+
const value = instance(...args);
|
|
16651
|
+
this.currentIndex = (this.currentIndex + 1) % this.tokens.length;
|
|
16652
|
+
return value;
|
|
16653
|
+
};
|
|
16641
16654
|
this.tokens = tokens;
|
|
16642
16655
|
this.instances = new Map(tokens.map((token) => [token, factory(token)]));
|
|
16643
16656
|
}
|
|
@@ -16651,19 +16664,7 @@ class RoundRobin {
|
|
|
16651
16664
|
swarm$1.loggerService.log(METHOD_NAME_CREATE, {
|
|
16652
16665
|
tokenCount: tokens.length,
|
|
16653
16666
|
});
|
|
16654
|
-
return new RoundRobin(tokens, factory).call
|
|
16655
|
-
}
|
|
16656
|
-
call(...args) {
|
|
16657
|
-
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
16658
|
-
swarm$1.loggerService.log(METHOD_NAME_CALL, {
|
|
16659
|
-
currentIndex: this.currentIndex,
|
|
16660
|
-
tokenCount: this.tokens.length,
|
|
16661
|
-
});
|
|
16662
|
-
const token = this.tokens[this.currentIndex];
|
|
16663
|
-
const instance = this.instances.get(token);
|
|
16664
|
-
const value = instance(...args);
|
|
16665
|
-
this.currentIndex = (this.currentIndex + 1) % this.tokens.length;
|
|
16666
|
-
return value;
|
|
16667
|
+
return new RoundRobin(tokens, factory).call;
|
|
16667
16668
|
}
|
|
16668
16669
|
}
|
|
16669
16670
|
|