agent-swarm-kit 1.0.25 → 1.0.27
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 +20 -10
- package/build/index.mjs +20 -10
- package/package.json +1 -1
- package/types.d.ts +7 -4
package/build/index.cjs
CHANGED
|
@@ -543,7 +543,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
543
543
|
switch (_b.label) {
|
|
544
544
|
case 0:
|
|
545
545
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " getCompletion"));
|
|
546
|
-
return [4 /*yield*/, this.params.history.toArrayForAgent(this.params.prompt)];
|
|
546
|
+
return [4 /*yield*/, this.params.history.toArrayForAgent(this.params.prompt, this.params.system)];
|
|
547
547
|
case 1:
|
|
548
548
|
messages = _b.sent();
|
|
549
549
|
return [4 /*yield*/, this.params.completion.getCompletion({
|
|
@@ -787,7 +787,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
787
787
|
var _b = __read(_a, 2), clientId = _b[0], agentName = _b[1];
|
|
788
788
|
return "".concat(clientId, "-").concat(agentName);
|
|
789
789
|
}, function (clientId, agentName) {
|
|
790
|
-
var _a = _this.agentSchemaService.get(agentName), prompt = _a.prompt, tools = _a.tools, completionName = _a.completion, _b = _a.validate, validate = _b === void 0 ? validateDefault : _b;
|
|
790
|
+
var _a = _this.agentSchemaService.get(agentName), prompt = _a.prompt, system = _a.system, tools = _a.tools, completionName = _a.completion, _b = _a.validate, validate = _b === void 0 ? validateDefault : _b;
|
|
791
791
|
var completion = _this.completionSchemaService.get(completionName);
|
|
792
792
|
_this.sessionValidationService.addAgentUsage(clientId, agentName);
|
|
793
793
|
return new ClientAgent({
|
|
@@ -797,6 +797,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
797
797
|
logger: _this.loggerService,
|
|
798
798
|
history: _this.historyConnectionService.getHistory(clientId, agentName),
|
|
799
799
|
prompt: prompt,
|
|
800
|
+
system: system,
|
|
800
801
|
tools: tools === null || tools === void 0 ? void 0 : tools.map(_this.toolSchemaService.get),
|
|
801
802
|
completion: completion,
|
|
802
803
|
});
|
|
@@ -988,10 +989,11 @@ var ClientHistory = /** @class */ (function () {
|
|
|
988
989
|
/**
|
|
989
990
|
* Converts the history to an array of messages for the agent.
|
|
990
991
|
* @param {string} prompt - The prompt message.
|
|
992
|
+
* @param {string} system - The tool calling protocol
|
|
991
993
|
* @returns {Promise<IModelMessage[]>} - The array of messages for the agent.
|
|
992
994
|
*/
|
|
993
|
-
this.toArrayForAgent = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
994
|
-
var commonMessagesRaw, systemMessagesRaw, _a, _b, _c, content, message, e_2_1, systemMessages, commonMessages,
|
|
995
|
+
this.toArrayForAgent = function (prompt, system) { return __awaiter(_this, void 0, void 0, function () {
|
|
996
|
+
var commonMessagesRaw, systemMessagesRaw, _a, _b, _c, content, message, e_2_1, systemMessages, commonMessages, promptMessages;
|
|
995
997
|
var _this = this;
|
|
996
998
|
var _d, e_2, _e, _f;
|
|
997
999
|
return __generator(this, function (_g) {
|
|
@@ -1062,12 +1064,20 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1062
1064
|
return isOk;
|
|
1063
1065
|
})
|
|
1064
1066
|
.slice(-GLOBAL_CONFIG.CC_KEEP_MESSAGES);
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1067
|
+
promptMessages = [];
|
|
1068
|
+
{
|
|
1069
|
+
promptMessages.push({
|
|
1070
|
+
agentName: this.params.agentName,
|
|
1071
|
+
content: prompt,
|
|
1072
|
+
role: "system",
|
|
1073
|
+
});
|
|
1074
|
+
system && promptMessages.push({
|
|
1075
|
+
agentName: this.params.agentName,
|
|
1076
|
+
content: system,
|
|
1077
|
+
role: "system",
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
return [2 /*return*/, __spreadArray(__spreadArray(__spreadArray([], __read(promptMessages), false), __read(systemMessages), false), __read(commonMessages), false)];
|
|
1071
1081
|
}
|
|
1072
1082
|
});
|
|
1073
1083
|
}); };
|
package/build/index.mjs
CHANGED
|
@@ -541,7 +541,7 @@ var ClientAgent = /** @class */ (function () {
|
|
|
541
541
|
switch (_b.label) {
|
|
542
542
|
case 0:
|
|
543
543
|
this.params.logger.debug("ClientAgent agentName=".concat(this.params.agentName, " clientId=").concat(this.params.clientId, " getCompletion"));
|
|
544
|
-
return [4 /*yield*/, this.params.history.toArrayForAgent(this.params.prompt)];
|
|
544
|
+
return [4 /*yield*/, this.params.history.toArrayForAgent(this.params.prompt, this.params.system)];
|
|
545
545
|
case 1:
|
|
546
546
|
messages = _b.sent();
|
|
547
547
|
return [4 /*yield*/, this.params.completion.getCompletion({
|
|
@@ -785,7 +785,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
785
785
|
var _b = __read(_a, 2), clientId = _b[0], agentName = _b[1];
|
|
786
786
|
return "".concat(clientId, "-").concat(agentName);
|
|
787
787
|
}, function (clientId, agentName) {
|
|
788
|
-
var _a = _this.agentSchemaService.get(agentName), prompt = _a.prompt, tools = _a.tools, completionName = _a.completion, _b = _a.validate, validate = _b === void 0 ? validateDefault : _b;
|
|
788
|
+
var _a = _this.agentSchemaService.get(agentName), prompt = _a.prompt, system = _a.system, tools = _a.tools, completionName = _a.completion, _b = _a.validate, validate = _b === void 0 ? validateDefault : _b;
|
|
789
789
|
var completion = _this.completionSchemaService.get(completionName);
|
|
790
790
|
_this.sessionValidationService.addAgentUsage(clientId, agentName);
|
|
791
791
|
return new ClientAgent({
|
|
@@ -795,6 +795,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
795
795
|
logger: _this.loggerService,
|
|
796
796
|
history: _this.historyConnectionService.getHistory(clientId, agentName),
|
|
797
797
|
prompt: prompt,
|
|
798
|
+
system: system,
|
|
798
799
|
tools: tools === null || tools === void 0 ? void 0 : tools.map(_this.toolSchemaService.get),
|
|
799
800
|
completion: completion,
|
|
800
801
|
});
|
|
@@ -986,10 +987,11 @@ var ClientHistory = /** @class */ (function () {
|
|
|
986
987
|
/**
|
|
987
988
|
* Converts the history to an array of messages for the agent.
|
|
988
989
|
* @param {string} prompt - The prompt message.
|
|
990
|
+
* @param {string} system - The tool calling protocol
|
|
989
991
|
* @returns {Promise<IModelMessage[]>} - The array of messages for the agent.
|
|
990
992
|
*/
|
|
991
|
-
this.toArrayForAgent = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
992
|
-
var commonMessagesRaw, systemMessagesRaw, _a, _b, _c, content, message, e_2_1, systemMessages, commonMessages,
|
|
993
|
+
this.toArrayForAgent = function (prompt, system) { return __awaiter(_this, void 0, void 0, function () {
|
|
994
|
+
var commonMessagesRaw, systemMessagesRaw, _a, _b, _c, content, message, e_2_1, systemMessages, commonMessages, promptMessages;
|
|
993
995
|
var _this = this;
|
|
994
996
|
var _d, e_2, _e, _f;
|
|
995
997
|
return __generator(this, function (_g) {
|
|
@@ -1060,12 +1062,20 @@ var ClientHistory = /** @class */ (function () {
|
|
|
1060
1062
|
return isOk;
|
|
1061
1063
|
})
|
|
1062
1064
|
.slice(-GLOBAL_CONFIG.CC_KEEP_MESSAGES);
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1065
|
+
promptMessages = [];
|
|
1066
|
+
{
|
|
1067
|
+
promptMessages.push({
|
|
1068
|
+
agentName: this.params.agentName,
|
|
1069
|
+
content: prompt,
|
|
1070
|
+
role: "system",
|
|
1071
|
+
});
|
|
1072
|
+
system && promptMessages.push({
|
|
1073
|
+
agentName: this.params.agentName,
|
|
1074
|
+
content: system,
|
|
1075
|
+
role: "system",
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
return [2 /*return*/, __spreadArray(__spreadArray(__spreadArray([], __read(promptMessages), false), __read(systemMessages), false), __read(commonMessages), false)];
|
|
1069
1079
|
}
|
|
1070
1080
|
});
|
|
1071
1081
|
}); };
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ interface IHistory {
|
|
|
66
66
|
* @param {string} prompt - The prompt to filter messages for the agent.
|
|
67
67
|
* @returns {Promise<IModelMessage[]>}
|
|
68
68
|
*/
|
|
69
|
-
toArrayForAgent(prompt: string): Promise<IModelMessage[]>;
|
|
69
|
+
toArrayForAgent(prompt: string, system?: string): Promise<IModelMessage[]>;
|
|
70
70
|
/**
|
|
71
71
|
* Converts the history to an array of raw messages.
|
|
72
72
|
* @returns {Promise<IModelMessage[]>}
|
|
@@ -278,6 +278,8 @@ interface IAgentSchema {
|
|
|
278
278
|
completion: CompletionName;
|
|
279
279
|
/** The prompt for the agent. */
|
|
280
280
|
prompt: string;
|
|
281
|
+
/** The system prompt. Usually used for tool calling protocol. */
|
|
282
|
+
system?: string;
|
|
281
283
|
/** The names of the tools used by the agent. */
|
|
282
284
|
tools?: ToolName[];
|
|
283
285
|
/**
|
|
@@ -577,9 +579,10 @@ declare class ClientHistory implements IHistory {
|
|
|
577
579
|
/**
|
|
578
580
|
* Converts the history to an array of messages for the agent.
|
|
579
581
|
* @param {string} prompt - The prompt message.
|
|
582
|
+
* @param {string} system - The tool calling protocol
|
|
580
583
|
* @returns {Promise<IModelMessage[]>} - The array of messages for the agent.
|
|
581
584
|
*/
|
|
582
|
-
toArrayForAgent: (prompt: string) => Promise<IModelMessage[]>;
|
|
585
|
+
toArrayForAgent: (prompt: string, system?: string) => Promise<IModelMessage[]>;
|
|
583
586
|
}
|
|
584
587
|
|
|
585
588
|
/**
|
|
@@ -1810,6 +1813,6 @@ declare const GLOBAL_CONFIG: {
|
|
|
1810
1813
|
CC_AGENT_DISALLOWED_TAGS: string[];
|
|
1811
1814
|
CC_AGENT_DISALLOWED_SYMBOLS: string[];
|
|
1812
1815
|
};
|
|
1813
|
-
declare const setConfig: (config: typeof GLOBAL_CONFIG) => void;
|
|
1816
|
+
declare const setConfig: (config: Partial<typeof GLOBAL_CONFIG>) => void;
|
|
1814
1817
|
|
|
1815
|
-
export { ContextService, type IAgentSchema, type IAgentTool, type ICompletionSchema, type IIncomingMessage, type IMakeConnectionConfig, type IMakeDisposeParams, type IModelMessage, type IOutgoingMessage, type ISessionConfig, type ISwarmSchema, type ITool, type IToolCall, type ReceiveMessageFn, type SendMessageFn$1 as SendMessageFn, addAgent, addCompletion, addSwarm, addTool, changeAgent, commitSystemMessage, commitToolOutput, commitUserMessage, complete, disposeConnection, emit, execute, getAgentHistory, getAgentName, getAssistantHistory, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getRawHistory, getUserHistory, makeAutoDispose, makeConnection, session, setConfig, swarm };
|
|
1818
|
+
export { ContextService, type IAgentSchema, type IAgentTool, type ICompletionArgs, type ICompletionSchema, type IIncomingMessage, type IMakeConnectionConfig, type IMakeDisposeParams, type IModelMessage, type IOutgoingMessage, type ISessionConfig, type ISwarmSchema, type ITool, type IToolCall, type ReceiveMessageFn, type SendMessageFn$1 as SendMessageFn, addAgent, addCompletion, addSwarm, addTool, changeAgent, commitSystemMessage, commitToolOutput, commitUserMessage, complete, disposeConnection, emit, execute, getAgentHistory, getAgentName, getAssistantHistory, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getRawHistory, getUserHistory, makeAutoDispose, makeConnection, session, setConfig, swarm };
|