agent-swarm-kit 1.0.21 → 1.0.22
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 +55 -0
- package/build/index.mjs +56 -2
- package/package.json +1 -1
- package/types.d.ts +29 -1
package/build/index.cjs
CHANGED
|
@@ -4189,6 +4189,60 @@ var getLastSystemMessage = function (clientId) { return __awaiter(void 0, void 0
|
|
|
4189
4189
|
});
|
|
4190
4190
|
}); };
|
|
4191
4191
|
|
|
4192
|
+
var DEFAULT_TIMEOUT = 15 * 60;
|
|
4193
|
+
/**
|
|
4194
|
+
* Creates an auto-dispose mechanism for a client in a swarm.
|
|
4195
|
+
*
|
|
4196
|
+
* @param {string} clientId - The ID of the client.
|
|
4197
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
4198
|
+
* @param {Partial<IMakeDisposeParams>} [params={}] - Optional parameters for auto-dispose.
|
|
4199
|
+
* @returns {Object} An object with tick and stop methods to control the auto-dispose.
|
|
4200
|
+
*/
|
|
4201
|
+
var makeAutoDispose = function (clientId, swarmName, _a) {
|
|
4202
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.timeoutSeconds, timeoutSeconds = _c === void 0 ? DEFAULT_TIMEOUT : _c;
|
|
4203
|
+
var stateEmitter = new functoolsKit.Subject();
|
|
4204
|
+
var unSource = functoolsKit.Source.join([
|
|
4205
|
+
stateEmitter.toObserver(),
|
|
4206
|
+
functoolsKit.Source.fromInterval(1000),
|
|
4207
|
+
])
|
|
4208
|
+
.reduce(function (acm, _a) {
|
|
4209
|
+
var _b = __read(_a, 1), isOk = _b[0];
|
|
4210
|
+
if (isOk) {
|
|
4211
|
+
return acm + 1;
|
|
4212
|
+
}
|
|
4213
|
+
return 0;
|
|
4214
|
+
}, 0)
|
|
4215
|
+
.filter(function (ticker) { return ticker >= timeoutSeconds; })
|
|
4216
|
+
.once(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
4217
|
+
return __generator(this, function (_a) {
|
|
4218
|
+
switch (_a.label) {
|
|
4219
|
+
case 0:
|
|
4220
|
+
unSource();
|
|
4221
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) return [3 /*break*/, 2];
|
|
4222
|
+
return [4 /*yield*/, disposeConnection(clientId, swarmName)];
|
|
4223
|
+
case 1:
|
|
4224
|
+
_a.sent();
|
|
4225
|
+
_a.label = 2;
|
|
4226
|
+
case 2: return [2 /*return*/];
|
|
4227
|
+
}
|
|
4228
|
+
});
|
|
4229
|
+
}); });
|
|
4230
|
+
return {
|
|
4231
|
+
/**
|
|
4232
|
+
* Signals that the client is active, resetting the auto-dispose timer.
|
|
4233
|
+
*/
|
|
4234
|
+
tick: function () {
|
|
4235
|
+
stateEmitter.next(true);
|
|
4236
|
+
},
|
|
4237
|
+
/**
|
|
4238
|
+
* Stops the auto-dispose mechanism.
|
|
4239
|
+
*/
|
|
4240
|
+
stop: function () {
|
|
4241
|
+
unSource();
|
|
4242
|
+
},
|
|
4243
|
+
};
|
|
4244
|
+
};
|
|
4245
|
+
|
|
4192
4246
|
exports.ContextService = ContextService;
|
|
4193
4247
|
exports.addAgent = addAgent;
|
|
4194
4248
|
exports.addCompletion = addCompletion;
|
|
@@ -4210,6 +4264,7 @@ exports.getLastSystemMessage = getLastSystemMessage;
|
|
|
4210
4264
|
exports.getLastUserMessage = getLastUserMessage;
|
|
4211
4265
|
exports.getRawHistory = getRawHistory;
|
|
4212
4266
|
exports.getUserHistory = getUserHistory;
|
|
4267
|
+
exports.makeAutoDispose = makeAutoDispose;
|
|
4213
4268
|
exports.makeConnection = makeConnection;
|
|
4214
4269
|
exports.session = session;
|
|
4215
4270
|
exports.setConfig = setConfig;
|
package/build/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { scoped } from 'di-scoped';
|
|
2
|
-
import { ToolRegistry, sleep, PubsubArrayAdapter, Subject, queued, not, trycatch, memoize, schedule, ttl, singleshot } from 'functools-kit';
|
|
2
|
+
import { ToolRegistry, sleep, PubsubArrayAdapter, Subject, queued, not, trycatch, memoize, schedule, ttl, singleshot, Source } from 'functools-kit';
|
|
3
3
|
import { createActivator } from 'di-kit';
|
|
4
4
|
import { omit } from 'lodash-es';
|
|
5
5
|
import xml2js from 'xml2js';
|
|
@@ -4187,4 +4187,58 @@ var getLastSystemMessage = function (clientId) { return __awaiter(void 0, void 0
|
|
|
4187
4187
|
});
|
|
4188
4188
|
}); };
|
|
4189
4189
|
|
|
4190
|
-
|
|
4190
|
+
var DEFAULT_TIMEOUT = 15 * 60;
|
|
4191
|
+
/**
|
|
4192
|
+
* Creates an auto-dispose mechanism for a client in a swarm.
|
|
4193
|
+
*
|
|
4194
|
+
* @param {string} clientId - The ID of the client.
|
|
4195
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
4196
|
+
* @param {Partial<IMakeDisposeParams>} [params={}] - Optional parameters for auto-dispose.
|
|
4197
|
+
* @returns {Object} An object with tick and stop methods to control the auto-dispose.
|
|
4198
|
+
*/
|
|
4199
|
+
var makeAutoDispose = function (clientId, swarmName, _a) {
|
|
4200
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.timeoutSeconds, timeoutSeconds = _c === void 0 ? DEFAULT_TIMEOUT : _c;
|
|
4201
|
+
var stateEmitter = new Subject();
|
|
4202
|
+
var unSource = Source.join([
|
|
4203
|
+
stateEmitter.toObserver(),
|
|
4204
|
+
Source.fromInterval(1000),
|
|
4205
|
+
])
|
|
4206
|
+
.reduce(function (acm, _a) {
|
|
4207
|
+
var _b = __read(_a, 1), isOk = _b[0];
|
|
4208
|
+
if (isOk) {
|
|
4209
|
+
return acm + 1;
|
|
4210
|
+
}
|
|
4211
|
+
return 0;
|
|
4212
|
+
}, 0)
|
|
4213
|
+
.filter(function (ticker) { return ticker >= timeoutSeconds; })
|
|
4214
|
+
.once(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
4215
|
+
return __generator(this, function (_a) {
|
|
4216
|
+
switch (_a.label) {
|
|
4217
|
+
case 0:
|
|
4218
|
+
unSource();
|
|
4219
|
+
if (!swarm.sessionValidationService.hasSession(clientId)) return [3 /*break*/, 2];
|
|
4220
|
+
return [4 /*yield*/, disposeConnection(clientId, swarmName)];
|
|
4221
|
+
case 1:
|
|
4222
|
+
_a.sent();
|
|
4223
|
+
_a.label = 2;
|
|
4224
|
+
case 2: return [2 /*return*/];
|
|
4225
|
+
}
|
|
4226
|
+
});
|
|
4227
|
+
}); });
|
|
4228
|
+
return {
|
|
4229
|
+
/**
|
|
4230
|
+
* Signals that the client is active, resetting the auto-dispose timer.
|
|
4231
|
+
*/
|
|
4232
|
+
tick: function () {
|
|
4233
|
+
stateEmitter.next(true);
|
|
4234
|
+
},
|
|
4235
|
+
/**
|
|
4236
|
+
* Stops the auto-dispose mechanism.
|
|
4237
|
+
*/
|
|
4238
|
+
stop: function () {
|
|
4239
|
+
unSource();
|
|
4240
|
+
},
|
|
4241
|
+
};
|
|
4242
|
+
};
|
|
4243
|
+
|
|
4244
|
+
export { ContextService, 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 };
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1766,6 +1766,34 @@ declare const getLastAssistantMessage: (clientId: string) => Promise<string>;
|
|
|
1766
1766
|
*/
|
|
1767
1767
|
declare const getLastSystemMessage: (clientId: string) => Promise<string>;
|
|
1768
1768
|
|
|
1769
|
+
/**
|
|
1770
|
+
* Interface for the parameters of the makeAutoDispose function.
|
|
1771
|
+
*/
|
|
1772
|
+
interface IMakeDisposeParams {
|
|
1773
|
+
/**
|
|
1774
|
+
* Timeout in seconds before auto-dispose is triggered.
|
|
1775
|
+
*/
|
|
1776
|
+
timeoutSeconds: number;
|
|
1777
|
+
}
|
|
1778
|
+
/**
|
|
1779
|
+
* Creates an auto-dispose mechanism for a client in a swarm.
|
|
1780
|
+
*
|
|
1781
|
+
* @param {string} clientId - The ID of the client.
|
|
1782
|
+
* @param {SwarmName} swarmName - The name of the swarm.
|
|
1783
|
+
* @param {Partial<IMakeDisposeParams>} [params={}] - Optional parameters for auto-dispose.
|
|
1784
|
+
* @returns {Object} An object with tick and stop methods to control the auto-dispose.
|
|
1785
|
+
*/
|
|
1786
|
+
declare const makeAutoDispose: (clientId: string, swarmName: SwarmName, { timeoutSeconds }?: Partial<IMakeDisposeParams>) => {
|
|
1787
|
+
/**
|
|
1788
|
+
* Signals that the client is active, resetting the auto-dispose timer.
|
|
1789
|
+
*/
|
|
1790
|
+
tick(): void;
|
|
1791
|
+
/**
|
|
1792
|
+
* Stops the auto-dispose mechanism.
|
|
1793
|
+
*/
|
|
1794
|
+
stop(): void;
|
|
1795
|
+
};
|
|
1796
|
+
|
|
1769
1797
|
declare const GLOBAL_CONFIG: {
|
|
1770
1798
|
CC_TOOL_CALL_EXCEPTION_PROMPT: string;
|
|
1771
1799
|
CC_EMPTY_OUTPUT_PLACEHOLDERS: string[];
|
|
@@ -1777,4 +1805,4 @@ declare const GLOBAL_CONFIG: {
|
|
|
1777
1805
|
};
|
|
1778
1806
|
declare const setConfig: (config: typeof GLOBAL_CONFIG) => void;
|
|
1779
1807
|
|
|
1780
|
-
export { ContextService, type IAgentSchema, type IAgentTool, type ICompletionSchema, type IIncomingMessage, type IMakeConnectionConfig, 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, makeConnection, session, setConfig, swarm };
|
|
1808
|
+
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 };
|