agent-swarm-kit 1.0.68 → 1.0.70
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 +756 -19
- package/build/index.mjs +753 -18
- package/package.json +1 -1
- package/types.d.ts +423 -18
package/build/index.cjs
CHANGED
|
@@ -236,6 +236,7 @@ var connectionServices$1 = {
|
|
|
236
236
|
swarmConnectionService: Symbol('swarmConnectionService'),
|
|
237
237
|
sessionConnectionService: Symbol('sessionConnectionService'),
|
|
238
238
|
storageConnectionService: Symbol('storageConnectionService'),
|
|
239
|
+
stateConnectionService: Symbol('stateConnectionService'),
|
|
239
240
|
};
|
|
240
241
|
var schemaServices$1 = {
|
|
241
242
|
completionSchemaService: Symbol('completionSchemaService'),
|
|
@@ -244,6 +245,7 @@ var schemaServices$1 = {
|
|
|
244
245
|
toolSchemaService: Symbol('toolSchemaService'),
|
|
245
246
|
embeddingSchemaService: Symbol('embeddingSchemaService'),
|
|
246
247
|
storageSchemaService: Symbol('storageSchemaService'),
|
|
248
|
+
stateSchemaService: Symbol('stateSchemaService'),
|
|
247
249
|
};
|
|
248
250
|
var publicServices$1 = {
|
|
249
251
|
agentPublicService: Symbol('agentPublicService'),
|
|
@@ -251,6 +253,7 @@ var publicServices$1 = {
|
|
|
251
253
|
sessionPublicService: Symbol('sessionPublicService'),
|
|
252
254
|
swarmPublicService: Symbol('swarmPublicService'),
|
|
253
255
|
storagePublicService: Symbol('storagePublicService'),
|
|
256
|
+
statePublicService: Symbol('statePublicService'),
|
|
254
257
|
};
|
|
255
258
|
var validationServices$1 = {
|
|
256
259
|
agentValidationService: Symbol('agentValidationService'),
|
|
@@ -1425,7 +1428,7 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1425
1428
|
var _b = __read(_a, 2), clientId = _b[0], agentName = _b[1];
|
|
1426
1429
|
return "".concat(clientId, "-").concat(agentName);
|
|
1427
1430
|
}, function (clientId, agentName) {
|
|
1428
|
-
var _a = _this.agentSchemaService.get(agentName), prompt = _a.prompt, system = _a.system, tools = _a.tools, _b = _a.transform, transform = _b === void 0 ? GLOBAL_CONFIG.CC_AGENT_OUTPUT_TRANSFORM : _b, _c = _a.map, map = _c === void 0 ? GLOBAL_CONFIG.CC_AGENT_OUTPUT_MAP : _c, callbacks = _a.callbacks, storages = _a.storages, completionName = _a.completion, _d = _a.validate, validate = _d === void 0 ? validateDefault : _d;
|
|
1431
|
+
var _a = _this.agentSchemaService.get(agentName), prompt = _a.prompt, system = _a.system, tools = _a.tools, _b = _a.transform, transform = _b === void 0 ? GLOBAL_CONFIG.CC_AGENT_OUTPUT_TRANSFORM : _b, _c = _a.map, map = _c === void 0 ? GLOBAL_CONFIG.CC_AGENT_OUTPUT_MAP : _c, callbacks = _a.callbacks, storages = _a.storages, states = _a.states, completionName = _a.completion, _d = _a.validate, validate = _d === void 0 ? validateDefault : _d;
|
|
1429
1432
|
var completion = _this.completionSchemaService.get(completionName);
|
|
1430
1433
|
_this.sessionValidationService.addAgentUsage(clientId, agentName);
|
|
1431
1434
|
storages === null || storages === void 0 ? void 0 : storages.forEach(function (storageName) {
|
|
@@ -1433,6 +1436,11 @@ var AgentConnectionService = /** @class */ (function () {
|
|
|
1433
1436
|
.getStorage(clientId, storageName)
|
|
1434
1437
|
.waitForInit();
|
|
1435
1438
|
});
|
|
1439
|
+
states === null || states === void 0 ? void 0 : states.forEach(function (storageName) {
|
|
1440
|
+
return _this.storageConnectionService
|
|
1441
|
+
.getStorage(clientId, storageName)
|
|
1442
|
+
.waitForInit();
|
|
1443
|
+
});
|
|
1436
1444
|
return new ClientAgent(__assign({ clientId: clientId, agentName: agentName, validate: validate, logger: _this.loggerService, history: _this.historyConnectionService.getHistory(clientId, agentName), prompt: prompt, system: system, transform: transform, map: map, tools: tools === null || tools === void 0 ? void 0 : tools.map(_this.toolSchemaService.get), completion: completion }, callbacks));
|
|
1437
1445
|
});
|
|
1438
1446
|
/**
|
|
@@ -2783,6 +2791,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
2783
2791
|
agentName: agentName,
|
|
2784
2792
|
swarmName: "",
|
|
2785
2793
|
storageName: "",
|
|
2794
|
+
stateName: "",
|
|
2786
2795
|
})];
|
|
2787
2796
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2788
2797
|
}
|
|
@@ -2818,6 +2827,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
2818
2827
|
agentName: agentName,
|
|
2819
2828
|
swarmName: "",
|
|
2820
2829
|
storageName: "",
|
|
2830
|
+
stateName: "",
|
|
2821
2831
|
})];
|
|
2822
2832
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2823
2833
|
}
|
|
@@ -2850,6 +2860,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
2850
2860
|
agentName: agentName,
|
|
2851
2861
|
swarmName: "",
|
|
2852
2862
|
storageName: "",
|
|
2863
|
+
stateName: "",
|
|
2853
2864
|
})];
|
|
2854
2865
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2855
2866
|
}
|
|
@@ -2886,6 +2897,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
2886
2897
|
agentName: agentName,
|
|
2887
2898
|
swarmName: "",
|
|
2888
2899
|
storageName: "",
|
|
2900
|
+
stateName: "",
|
|
2889
2901
|
})];
|
|
2890
2902
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2891
2903
|
}
|
|
@@ -2920,6 +2932,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
2920
2932
|
agentName: agentName,
|
|
2921
2933
|
swarmName: "",
|
|
2922
2934
|
storageName: "",
|
|
2935
|
+
stateName: "",
|
|
2923
2936
|
})];
|
|
2924
2937
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2925
2938
|
}
|
|
@@ -2954,6 +2967,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
2954
2967
|
agentName: agentName,
|
|
2955
2968
|
swarmName: "",
|
|
2956
2969
|
storageName: "",
|
|
2970
|
+
stateName: "",
|
|
2957
2971
|
})];
|
|
2958
2972
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2959
2973
|
}
|
|
@@ -2986,6 +3000,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
2986
3000
|
agentName: agentName,
|
|
2987
3001
|
swarmName: "",
|
|
2988
3002
|
storageName: "",
|
|
3003
|
+
stateName: "",
|
|
2989
3004
|
})];
|
|
2990
3005
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2991
3006
|
}
|
|
@@ -3018,6 +3033,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3018
3033
|
agentName: agentName,
|
|
3019
3034
|
swarmName: "",
|
|
3020
3035
|
storageName: "",
|
|
3036
|
+
stateName: "",
|
|
3021
3037
|
})];
|
|
3022
3038
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3023
3039
|
}
|
|
@@ -3050,6 +3066,7 @@ var AgentPublicService = /** @class */ (function () {
|
|
|
3050
3066
|
agentName: agentName,
|
|
3051
3067
|
swarmName: "",
|
|
3052
3068
|
storageName: "",
|
|
3069
|
+
stateName: "",
|
|
3053
3070
|
})];
|
|
3054
3071
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3055
3072
|
}
|
|
@@ -3096,6 +3113,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3096
3113
|
agentName: agentName,
|
|
3097
3114
|
swarmName: "",
|
|
3098
3115
|
storageName: "",
|
|
3116
|
+
stateName: "",
|
|
3099
3117
|
})];
|
|
3100
3118
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3101
3119
|
}
|
|
@@ -3130,6 +3148,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3130
3148
|
agentName: agentName,
|
|
3131
3149
|
swarmName: "",
|
|
3132
3150
|
storageName: "",
|
|
3151
|
+
stateName: "",
|
|
3133
3152
|
})];
|
|
3134
3153
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3135
3154
|
}
|
|
@@ -3162,6 +3181,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3162
3181
|
agentName: agentName,
|
|
3163
3182
|
swarmName: "",
|
|
3164
3183
|
storageName: "",
|
|
3184
|
+
stateName: "",
|
|
3165
3185
|
})];
|
|
3166
3186
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3167
3187
|
}
|
|
@@ -3194,6 +3214,7 @@ var HistoryPublicService = /** @class */ (function () {
|
|
|
3194
3214
|
agentName: agentName,
|
|
3195
3215
|
swarmName: "",
|
|
3196
3216
|
storageName: "",
|
|
3217
|
+
stateName: "",
|
|
3197
3218
|
})];
|
|
3198
3219
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3199
3220
|
}
|
|
@@ -3240,6 +3261,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3240
3261
|
swarmName: swarmName,
|
|
3241
3262
|
agentName: "",
|
|
3242
3263
|
storageName: "",
|
|
3264
|
+
stateName: "",
|
|
3243
3265
|
})];
|
|
3244
3266
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3245
3267
|
}
|
|
@@ -3275,6 +3297,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3275
3297
|
swarmName: swarmName,
|
|
3276
3298
|
agentName: "",
|
|
3277
3299
|
storageName: "",
|
|
3300
|
+
stateName: "",
|
|
3278
3301
|
})];
|
|
3279
3302
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3280
3303
|
}
|
|
@@ -3309,6 +3332,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3309
3332
|
swarmName: swarmName,
|
|
3310
3333
|
agentName: "",
|
|
3311
3334
|
storageName: "",
|
|
3335
|
+
stateName: "",
|
|
3312
3336
|
})];
|
|
3313
3337
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3314
3338
|
}
|
|
@@ -3322,6 +3346,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3322
3346
|
swarmName: swarmName,
|
|
3323
3347
|
agentName: "",
|
|
3324
3348
|
storageName: "",
|
|
3349
|
+
stateName: "",
|
|
3325
3350
|
});
|
|
3326
3351
|
};
|
|
3327
3352
|
}, {
|
|
@@ -3329,6 +3354,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3329
3354
|
swarmName: swarmName,
|
|
3330
3355
|
agentName: "",
|
|
3331
3356
|
storageName: "",
|
|
3357
|
+
stateName: "",
|
|
3332
3358
|
});
|
|
3333
3359
|
};
|
|
3334
3360
|
/**
|
|
@@ -3362,6 +3388,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3362
3388
|
swarmName: swarmName,
|
|
3363
3389
|
agentName: "",
|
|
3364
3390
|
storageName: "",
|
|
3391
|
+
stateName: "",
|
|
3365
3392
|
})];
|
|
3366
3393
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3367
3394
|
}
|
|
@@ -3396,6 +3423,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3396
3423
|
swarmName: swarmName,
|
|
3397
3424
|
agentName: "",
|
|
3398
3425
|
storageName: "",
|
|
3426
|
+
stateName: "",
|
|
3399
3427
|
})];
|
|
3400
3428
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3401
3429
|
}
|
|
@@ -3430,6 +3458,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3430
3458
|
swarmName: swarmName,
|
|
3431
3459
|
agentName: "",
|
|
3432
3460
|
storageName: "",
|
|
3461
|
+
stateName: "",
|
|
3433
3462
|
})];
|
|
3434
3463
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3435
3464
|
}
|
|
@@ -3462,6 +3491,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3462
3491
|
swarmName: swarmName,
|
|
3463
3492
|
agentName: "",
|
|
3464
3493
|
storageName: "",
|
|
3494
|
+
stateName: "",
|
|
3465
3495
|
})];
|
|
3466
3496
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3467
3497
|
}
|
|
@@ -3494,6 +3524,7 @@ var SessionPublicService = /** @class */ (function () {
|
|
|
3494
3524
|
swarmName: swarmName,
|
|
3495
3525
|
agentName: "",
|
|
3496
3526
|
storageName: "",
|
|
3527
|
+
stateName: "",
|
|
3497
3528
|
})];
|
|
3498
3529
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3499
3530
|
}
|
|
@@ -3538,6 +3569,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3538
3569
|
swarmName: swarmName,
|
|
3539
3570
|
agentName: "",
|
|
3540
3571
|
storageName: "",
|
|
3572
|
+
stateName: "",
|
|
3541
3573
|
})];
|
|
3542
3574
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3543
3575
|
}
|
|
@@ -3570,6 +3602,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3570
3602
|
swarmName: swarmName,
|
|
3571
3603
|
agentName: "",
|
|
3572
3604
|
storageName: "",
|
|
3605
|
+
stateName: "",
|
|
3573
3606
|
})];
|
|
3574
3607
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3575
3608
|
}
|
|
@@ -3602,6 +3635,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3602
3635
|
swarmName: swarmName,
|
|
3603
3636
|
agentName: "",
|
|
3604
3637
|
storageName: "",
|
|
3638
|
+
stateName: "",
|
|
3605
3639
|
})];
|
|
3606
3640
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3607
3641
|
}
|
|
@@ -3638,6 +3672,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3638
3672
|
swarmName: swarmName,
|
|
3639
3673
|
agentName: "",
|
|
3640
3674
|
storageName: "",
|
|
3675
|
+
stateName: "",
|
|
3641
3676
|
})];
|
|
3642
3677
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3643
3678
|
}
|
|
@@ -3672,6 +3707,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3672
3707
|
swarmName: swarmName,
|
|
3673
3708
|
agentName: "",
|
|
3674
3709
|
storageName: "",
|
|
3710
|
+
stateName: "",
|
|
3675
3711
|
})];
|
|
3676
3712
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3677
3713
|
}
|
|
@@ -3704,6 +3740,7 @@ var SwarmPublicService = /** @class */ (function () {
|
|
|
3704
3740
|
swarmName: swarmName,
|
|
3705
3741
|
agentName: "",
|
|
3706
3742
|
storageName: "",
|
|
3743
|
+
stateName: "",
|
|
3707
3744
|
})];
|
|
3708
3745
|
case 1: return [2 /*return*/, _a.sent()];
|
|
3709
3746
|
}
|
|
@@ -3736,6 +3773,18 @@ var AgentValidationService = /** @class */ (function () {
|
|
|
3736
3773
|
}
|
|
3737
3774
|
return _this._agentMap.get(agentName).storages;
|
|
3738
3775
|
};
|
|
3776
|
+
/**
|
|
3777
|
+
* Retrieves the states used by the agent
|
|
3778
|
+
* @param {agentName} agentName - The name of the swarm.
|
|
3779
|
+
* @returns {string[]} The list of state names.
|
|
3780
|
+
* @throws Will throw an error if the swarm is not found.
|
|
3781
|
+
*/
|
|
3782
|
+
this.getStateList = function (agentName) {
|
|
3783
|
+
if (!_this._agentMap.has(agentName)) {
|
|
3784
|
+
throw new Error("agent-swarm agent ".concat(agentName, " not exist (getStateList)"));
|
|
3785
|
+
}
|
|
3786
|
+
return _this._agentMap.get(agentName).states;
|
|
3787
|
+
};
|
|
3739
3788
|
/**
|
|
3740
3789
|
* Adds a new agent to the validation service.
|
|
3741
3790
|
* @param {AgentName} agentName - The name of the agent.
|
|
@@ -3769,6 +3818,23 @@ var AgentValidationService = /** @class */ (function () {
|
|
|
3769
3818
|
var _a = _this._agentMap.get(agentName).storages, storages = _a === void 0 ? [] : _a;
|
|
3770
3819
|
return storages.includes(storageName);
|
|
3771
3820
|
});
|
|
3821
|
+
/**
|
|
3822
|
+
* Check if agent got registered state
|
|
3823
|
+
*/
|
|
3824
|
+
this.hasState = functoolsKit.memoize(function (_a) {
|
|
3825
|
+
var _b = __read(_a, 2), agentName = _b[0], stateName = _b[1];
|
|
3826
|
+
return "".concat(agentName, "-").concat(stateName);
|
|
3827
|
+
}, function (agentName, stateName) {
|
|
3828
|
+
_this.loggerService.log("agentValidationService hasState", {
|
|
3829
|
+
agentName: agentName,
|
|
3830
|
+
stateName: stateName,
|
|
3831
|
+
});
|
|
3832
|
+
if (!_this._agentMap.has(agentName)) {
|
|
3833
|
+
throw new Error("agent-swarm agent ".concat(agentName, " not exist (hasState)"));
|
|
3834
|
+
}
|
|
3835
|
+
var _a = _this._agentMap.get(agentName).states, states = _a === void 0 ? [] : _a;
|
|
3836
|
+
return states.includes(stateName);
|
|
3837
|
+
});
|
|
3772
3838
|
/**
|
|
3773
3839
|
* Validates an agent by its name and source.
|
|
3774
3840
|
* @param {AgentName} agentName - The name of the agent.
|
|
@@ -3862,6 +3928,7 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
3862
3928
|
this._storageSwarmMap = new Map();
|
|
3863
3929
|
this._historySwarmMap = new Map();
|
|
3864
3930
|
this._agentSwarmMap = new Map();
|
|
3931
|
+
this._stateSwarmMap = new Map();
|
|
3865
3932
|
this._sessionSwarmMap = new Map();
|
|
3866
3933
|
this._sessionModeMap = new Map();
|
|
3867
3934
|
/**
|
|
@@ -3941,6 +4008,26 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
3941
4008
|
_this._storageSwarmMap.set(sessionId, [storageName]);
|
|
3942
4009
|
}
|
|
3943
4010
|
};
|
|
4011
|
+
/**
|
|
4012
|
+
* Adds a state usage to a session.
|
|
4013
|
+
* @param {SessionId} sessionId - The ID of the session.
|
|
4014
|
+
* @param {StateName} stateName - The name of the state.
|
|
4015
|
+
*/
|
|
4016
|
+
this.addStateUsage = function (sessionId, stateName) {
|
|
4017
|
+
_this.loggerService.log("sessionValidationService addStateUsage", {
|
|
4018
|
+
sessionId: sessionId,
|
|
4019
|
+
stateName: stateName,
|
|
4020
|
+
});
|
|
4021
|
+
if (_this._stateSwarmMap.has(sessionId)) {
|
|
4022
|
+
var states = _this._stateSwarmMap.get(sessionId);
|
|
4023
|
+
if (!states.includes(stateName)) {
|
|
4024
|
+
states.push(stateName);
|
|
4025
|
+
}
|
|
4026
|
+
}
|
|
4027
|
+
else {
|
|
4028
|
+
_this._stateSwarmMap.set(sessionId, [stateName]);
|
|
4029
|
+
}
|
|
4030
|
+
};
|
|
3944
4031
|
/**
|
|
3945
4032
|
* Removes an agent usage from a session.
|
|
3946
4033
|
* @param {SessionId} sessionId - The ID of the session.
|
|
@@ -3992,11 +4079,11 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
3992
4079
|
}
|
|
3993
4080
|
};
|
|
3994
4081
|
/**
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4082
|
+
* Removes a storage usage from a session.
|
|
4083
|
+
* @param {SessionId} sessionId - The ID of the session.
|
|
4084
|
+
* @param {StorageName} storageName - The name of the storage.
|
|
4085
|
+
* @throws Will throw an error if no storages are found for the session.
|
|
4086
|
+
*/
|
|
4000
4087
|
this.removeStorageUsage = function (sessionId, storageName) {
|
|
4001
4088
|
_this.loggerService.log("sessionValidationService removeStorageUsage", {
|
|
4002
4089
|
sessionId: sessionId,
|
|
@@ -4016,6 +4103,31 @@ var SessionValidationService = /** @class */ (function () {
|
|
|
4016
4103
|
throw new Error("No agents found for sessionId=".concat(sessionId));
|
|
4017
4104
|
}
|
|
4018
4105
|
};
|
|
4106
|
+
/**
|
|
4107
|
+
* Removes a state usage from a session.
|
|
4108
|
+
* @param {SessionId} sessionId - The ID of the session.
|
|
4109
|
+
* @param {StateName} stateName - The name of the state.
|
|
4110
|
+
* @throws Will throw an error if no states are found for the session.
|
|
4111
|
+
*/
|
|
4112
|
+
this.removeStateUsage = function (sessionId, stateName) {
|
|
4113
|
+
_this.loggerService.log("sessionValidationService removeStateUsage", {
|
|
4114
|
+
sessionId: sessionId,
|
|
4115
|
+
stateName: stateName,
|
|
4116
|
+
});
|
|
4117
|
+
if (_this._stateSwarmMap.has(sessionId)) {
|
|
4118
|
+
var agents = _this._stateSwarmMap.get(sessionId);
|
|
4119
|
+
var agentIndex = agents.indexOf(stateName);
|
|
4120
|
+
if (agentIndex !== -1) {
|
|
4121
|
+
agents.splice(agentIndex, 1);
|
|
4122
|
+
}
|
|
4123
|
+
if (agents.length === 0) {
|
|
4124
|
+
_this._stateSwarmMap.delete(sessionId);
|
|
4125
|
+
}
|
|
4126
|
+
}
|
|
4127
|
+
else {
|
|
4128
|
+
throw new Error("No agents found for sessionId=".concat(sessionId));
|
|
4129
|
+
}
|
|
4130
|
+
};
|
|
4019
4131
|
/**
|
|
4020
4132
|
* Gets the mode of a session.
|
|
4021
4133
|
* @param {SessionId} clientId - The ID of the client.
|
|
@@ -4304,6 +4416,7 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4304
4416
|
*/
|
|
4305
4417
|
function ClientStorage(params) {
|
|
4306
4418
|
var _this = this;
|
|
4419
|
+
var _a;
|
|
4307
4420
|
this.params = params;
|
|
4308
4421
|
this._itemMap = new Map();
|
|
4309
4422
|
/**
|
|
@@ -4529,9 +4642,26 @@ var ClientStorage = /** @class */ (function () {
|
|
|
4529
4642
|
return [2 /*return*/, result];
|
|
4530
4643
|
});
|
|
4531
4644
|
}); };
|
|
4645
|
+
/**
|
|
4646
|
+
* Disposes of the state.
|
|
4647
|
+
* @returns {Promise<void>}
|
|
4648
|
+
*/
|
|
4649
|
+
this.dispose = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
4650
|
+
var _a;
|
|
4651
|
+
return __generator(this, function (_b) {
|
|
4652
|
+
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " dispose"));
|
|
4653
|
+
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onDispose) {
|
|
4654
|
+
this.params.callbacks.onDispose(this.params.clientId, this.params.storageName);
|
|
4655
|
+
}
|
|
4656
|
+
return [2 /*return*/];
|
|
4657
|
+
});
|
|
4658
|
+
}); };
|
|
4532
4659
|
this.params.logger.debug("ClientStorage storageName=".concat(this.params.storageName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " CTOR"), {
|
|
4533
4660
|
params: params,
|
|
4534
4661
|
});
|
|
4662
|
+
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onInit) {
|
|
4663
|
+
this.params.callbacks.onInit(this.params.clientId, this.params.storageName);
|
|
4664
|
+
}
|
|
4535
4665
|
}
|
|
4536
4666
|
return ClientStorage;
|
|
4537
4667
|
}());
|
|
@@ -4726,18 +4856,31 @@ var StorageConnectionService = /** @class */ (function () {
|
|
|
4726
4856
|
* @returns {Promise<void>}
|
|
4727
4857
|
*/
|
|
4728
4858
|
this.dispose = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
4729
|
-
var key;
|
|
4859
|
+
var key, storage;
|
|
4730
4860
|
return __generator(this, function (_a) {
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4861
|
+
switch (_a.label) {
|
|
4862
|
+
case 0:
|
|
4863
|
+
this.loggerService.log("storageConnectionService dispose", {
|
|
4864
|
+
context: this.contextService.context,
|
|
4865
|
+
});
|
|
4866
|
+
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.storageName);
|
|
4867
|
+
if (!this.getStorage.has(key)) {
|
|
4868
|
+
return [2 /*return*/];
|
|
4869
|
+
}
|
|
4870
|
+
if (!!this.getSharedStorage.has(this.contextService.context.storageName)) return [3 /*break*/, 3];
|
|
4871
|
+
storage = this.getSharedStorage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
4872
|
+
return [4 /*yield*/, storage.waitForInit()];
|
|
4873
|
+
case 1:
|
|
4874
|
+
_a.sent();
|
|
4875
|
+
return [4 /*yield*/, storage.dispose()];
|
|
4876
|
+
case 2:
|
|
4877
|
+
_a.sent();
|
|
4878
|
+
_a.label = 3;
|
|
4879
|
+
case 3:
|
|
4880
|
+
this.getStorage.clear(key);
|
|
4881
|
+
this.sessionValidationService.removeStorageUsage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
4882
|
+
return [2 /*return*/];
|
|
4737
4883
|
}
|
|
4738
|
-
this.getStorage.clear(key);
|
|
4739
|
-
this.sessionValidationService.removeStorageUsage(this.contextService.context.clientId, this.contextService.context.storageName);
|
|
4740
|
-
return [2 /*return*/];
|
|
4741
4884
|
});
|
|
4742
4885
|
}); };
|
|
4743
4886
|
}
|
|
@@ -4782,6 +4925,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
4782
4925
|
storageName: storageName,
|
|
4783
4926
|
agentName: "",
|
|
4784
4927
|
swarmName: "",
|
|
4928
|
+
stateName: "",
|
|
4785
4929
|
})];
|
|
4786
4930
|
case 1: return [2 /*return*/, _a.sent()];
|
|
4787
4931
|
}
|
|
@@ -4814,6 +4958,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
4814
4958
|
storageName: storageName,
|
|
4815
4959
|
agentName: "",
|
|
4816
4960
|
swarmName: "",
|
|
4961
|
+
stateName: "",
|
|
4817
4962
|
})];
|
|
4818
4963
|
case 1: return [2 /*return*/, _a.sent()];
|
|
4819
4964
|
}
|
|
@@ -4846,6 +4991,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
4846
4991
|
storageName: storageName,
|
|
4847
4992
|
agentName: "",
|
|
4848
4993
|
swarmName: "",
|
|
4994
|
+
stateName: "",
|
|
4849
4995
|
})];
|
|
4850
4996
|
case 1: return [2 /*return*/, _a.sent()];
|
|
4851
4997
|
}
|
|
@@ -4878,6 +5024,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
4878
5024
|
storageName: storageName,
|
|
4879
5025
|
agentName: "",
|
|
4880
5026
|
swarmName: "",
|
|
5027
|
+
stateName: "",
|
|
4881
5028
|
})];
|
|
4882
5029
|
case 1: return [2 /*return*/, _a.sent()];
|
|
4883
5030
|
}
|
|
@@ -4909,6 +5056,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
4909
5056
|
storageName: storageName,
|
|
4910
5057
|
agentName: "",
|
|
4911
5058
|
swarmName: "",
|
|
5059
|
+
stateName: "",
|
|
4912
5060
|
})];
|
|
4913
5061
|
case 1: return [2 /*return*/, _a.sent()];
|
|
4914
5062
|
}
|
|
@@ -4939,6 +5087,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
4939
5087
|
storageName: storageName,
|
|
4940
5088
|
agentName: "",
|
|
4941
5089
|
swarmName: "",
|
|
5090
|
+
stateName: "",
|
|
4942
5091
|
})];
|
|
4943
5092
|
case 1: return [2 /*return*/, _a.sent()];
|
|
4944
5093
|
}
|
|
@@ -4971,6 +5120,7 @@ var StoragePublicService = /** @class */ (function () {
|
|
|
4971
5120
|
storageName: storageName,
|
|
4972
5121
|
agentName: "",
|
|
4973
5122
|
swarmName: "",
|
|
5123
|
+
stateName: "",
|
|
4974
5124
|
})];
|
|
4975
5125
|
case 1: return [2 /*return*/, _a.sent()];
|
|
4976
5126
|
}
|
|
@@ -5077,6 +5227,470 @@ var EmbeddingValidationService = /** @class */ (function () {
|
|
|
5077
5227
|
return EmbeddingValidationService;
|
|
5078
5228
|
}());
|
|
5079
5229
|
|
|
5230
|
+
/**
|
|
5231
|
+
* Service for managing state schemas.
|
|
5232
|
+
*/
|
|
5233
|
+
var StateSchemaService = /** @class */ (function () {
|
|
5234
|
+
function StateSchemaService() {
|
|
5235
|
+
var _this = this;
|
|
5236
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
5237
|
+
this.registry = new functoolsKit.ToolRegistry("stateSchemaService");
|
|
5238
|
+
/**
|
|
5239
|
+
* Registers a new state schema.
|
|
5240
|
+
* @param {StateName} key - The key for the schema.
|
|
5241
|
+
* @param {IStateSchema} value - The schema to register.
|
|
5242
|
+
*/
|
|
5243
|
+
this.register = function (key, value) {
|
|
5244
|
+
_this.loggerService.log("stateSchemaService register", { key: key });
|
|
5245
|
+
_this.registry = _this.registry.register(key, value);
|
|
5246
|
+
};
|
|
5247
|
+
/**
|
|
5248
|
+
* Retrieves a state schema by key.
|
|
5249
|
+
* @param {StateName} key - The key of the schema to retrieve.
|
|
5250
|
+
* @returns {IStateSchema} The retrieved schema.
|
|
5251
|
+
*/
|
|
5252
|
+
this.get = function (key) {
|
|
5253
|
+
_this.loggerService.log("stateSchemaService get", { key: key });
|
|
5254
|
+
return _this.registry.get(key);
|
|
5255
|
+
};
|
|
5256
|
+
}
|
|
5257
|
+
return StateSchemaService;
|
|
5258
|
+
}());
|
|
5259
|
+
|
|
5260
|
+
/**
|
|
5261
|
+
* Class representing the client state.
|
|
5262
|
+
* @template State - The type of the state data.
|
|
5263
|
+
* @implements {IState<State>}
|
|
5264
|
+
*/
|
|
5265
|
+
var ClientState = /** @class */ (function () {
|
|
5266
|
+
/**
|
|
5267
|
+
* Creates an instance of ClientState.
|
|
5268
|
+
* @param {IStateParams<State>} params - The state parameters.
|
|
5269
|
+
*/
|
|
5270
|
+
function ClientState(params) {
|
|
5271
|
+
var _this = this;
|
|
5272
|
+
var _a;
|
|
5273
|
+
this.params = params;
|
|
5274
|
+
this._state = null;
|
|
5275
|
+
this.dispatch = functoolsKit.queued(function (action, payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
5276
|
+
var _a;
|
|
5277
|
+
return __generator(this, function (_b) {
|
|
5278
|
+
switch (_b.label) {
|
|
5279
|
+
case 0:
|
|
5280
|
+
if (action === "read") {
|
|
5281
|
+
return [2 /*return*/, this._state];
|
|
5282
|
+
}
|
|
5283
|
+
if (!(action === "write")) return [3 /*break*/, 2];
|
|
5284
|
+
console.assert(payload, "agent-swarm ClientState write action undefined payload");
|
|
5285
|
+
_a = this;
|
|
5286
|
+
return [4 /*yield*/, payload(this._state)];
|
|
5287
|
+
case 1: return [2 /*return*/, _a._state = _b.sent()];
|
|
5288
|
+
case 2: throw new Error("agent-swarm ClientState unknown action");
|
|
5289
|
+
}
|
|
5290
|
+
});
|
|
5291
|
+
}); });
|
|
5292
|
+
/**
|
|
5293
|
+
* Waits for the state to initialize.
|
|
5294
|
+
* @returns {Promise<void>}
|
|
5295
|
+
*/
|
|
5296
|
+
this.waitForInit = functoolsKit.singleshot(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5297
|
+
var _a;
|
|
5298
|
+
var _b;
|
|
5299
|
+
return __generator(this, function (_c) {
|
|
5300
|
+
switch (_c.label) {
|
|
5301
|
+
case 0:
|
|
5302
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " waitForInit"));
|
|
5303
|
+
_a = this;
|
|
5304
|
+
return [4 /*yield*/, this.params.getState(this.params.clientId, this.params.stateName)];
|
|
5305
|
+
case 1:
|
|
5306
|
+
_a._state = _c.sent();
|
|
5307
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " waitForInit output"), { initialState: this._state });
|
|
5308
|
+
if ((_b = this.params.callbacks) === null || _b === void 0 ? void 0 : _b.onLoad) {
|
|
5309
|
+
this.params.callbacks.onLoad(this._state, this.params.clientId, this.params.stateName);
|
|
5310
|
+
}
|
|
5311
|
+
return [2 /*return*/];
|
|
5312
|
+
}
|
|
5313
|
+
});
|
|
5314
|
+
}); });
|
|
5315
|
+
/**
|
|
5316
|
+
* Sets the state using the provided dispatch function.
|
|
5317
|
+
* @param {DispatchFn<State>} dispatchFn - The dispatch function.
|
|
5318
|
+
* @returns {Promise<State>}
|
|
5319
|
+
*/
|
|
5320
|
+
this.setState = function (dispatchFn) { return __awaiter(_this, void 0, void 0, function () {
|
|
5321
|
+
var _this = this;
|
|
5322
|
+
var _a;
|
|
5323
|
+
return __generator(this, function (_b) {
|
|
5324
|
+
switch (_b.label) {
|
|
5325
|
+
case 0:
|
|
5326
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " setState"));
|
|
5327
|
+
return [4 /*yield*/, this.dispatch("write", function (currentState) { return __awaiter(_this, void 0, void 0, function () {
|
|
5328
|
+
var _a, _b, middleware, e_1_1;
|
|
5329
|
+
var e_1, _c;
|
|
5330
|
+
return __generator(this, function (_d) {
|
|
5331
|
+
switch (_d.label) {
|
|
5332
|
+
case 0:
|
|
5333
|
+
_d.trys.push([0, 5, 6, 7]);
|
|
5334
|
+
_a = __values(this.params.middlewares), _b = _a.next();
|
|
5335
|
+
_d.label = 1;
|
|
5336
|
+
case 1:
|
|
5337
|
+
if (!!_b.done) return [3 /*break*/, 4];
|
|
5338
|
+
middleware = _b.value;
|
|
5339
|
+
return [4 /*yield*/, middleware(currentState, this.params.clientId, this.params.stateName)];
|
|
5340
|
+
case 2:
|
|
5341
|
+
currentState = _d.sent();
|
|
5342
|
+
_d.label = 3;
|
|
5343
|
+
case 3:
|
|
5344
|
+
_b = _a.next();
|
|
5345
|
+
return [3 /*break*/, 1];
|
|
5346
|
+
case 4: return [3 /*break*/, 7];
|
|
5347
|
+
case 5:
|
|
5348
|
+
e_1_1 = _d.sent();
|
|
5349
|
+
e_1 = { error: e_1_1 };
|
|
5350
|
+
return [3 /*break*/, 7];
|
|
5351
|
+
case 6:
|
|
5352
|
+
try {
|
|
5353
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
5354
|
+
}
|
|
5355
|
+
finally { if (e_1) throw e_1.error; }
|
|
5356
|
+
return [7 /*endfinally*/];
|
|
5357
|
+
case 7: return [4 /*yield*/, dispatchFn(currentState)];
|
|
5358
|
+
case 8: return [2 /*return*/, _d.sent()];
|
|
5359
|
+
}
|
|
5360
|
+
});
|
|
5361
|
+
}); })];
|
|
5362
|
+
case 1:
|
|
5363
|
+
_b.sent();
|
|
5364
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " setState output"), { pendingState: this._state });
|
|
5365
|
+
this.params.setState &&
|
|
5366
|
+
this.params.setState(this._state, this.params.clientId, this.params.stateName);
|
|
5367
|
+
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onWrite) {
|
|
5368
|
+
this.params.callbacks.onWrite(this._state, this.params.clientId, this.params.stateName);
|
|
5369
|
+
}
|
|
5370
|
+
return [2 /*return*/, this._state];
|
|
5371
|
+
}
|
|
5372
|
+
});
|
|
5373
|
+
}); };
|
|
5374
|
+
/**
|
|
5375
|
+
* Gets the current state.
|
|
5376
|
+
* @returns {Promise<State>}
|
|
5377
|
+
*/
|
|
5378
|
+
this.getState = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5379
|
+
var _a;
|
|
5380
|
+
return __generator(this, function (_b) {
|
|
5381
|
+
switch (_b.label) {
|
|
5382
|
+
case 0:
|
|
5383
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " getState"));
|
|
5384
|
+
return [4 /*yield*/, this.dispatch("read")];
|
|
5385
|
+
case 1:
|
|
5386
|
+
_b.sent();
|
|
5387
|
+
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onRead) {
|
|
5388
|
+
this.params.callbacks.onRead(this._state, this.params.clientId, this.params.stateName);
|
|
5389
|
+
}
|
|
5390
|
+
return [2 /*return*/, this._state];
|
|
5391
|
+
}
|
|
5392
|
+
});
|
|
5393
|
+
}); };
|
|
5394
|
+
/**
|
|
5395
|
+
* Disposes of the state.
|
|
5396
|
+
* @returns {Promise<void>}
|
|
5397
|
+
*/
|
|
5398
|
+
this.dispose = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5399
|
+
var _a;
|
|
5400
|
+
return __generator(this, function (_b) {
|
|
5401
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " dispose"));
|
|
5402
|
+
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onDispose) {
|
|
5403
|
+
this.params.callbacks.onDispose(this.params.clientId, this.params.stateName);
|
|
5404
|
+
}
|
|
5405
|
+
return [2 /*return*/];
|
|
5406
|
+
});
|
|
5407
|
+
}); };
|
|
5408
|
+
this.params.logger.debug("ClientState stateName=".concat(this.params.stateName, " clientId=").concat(this.params.clientId, " shared=").concat(this.params.shared, " CTOR"), {
|
|
5409
|
+
params: params,
|
|
5410
|
+
});
|
|
5411
|
+
if ((_a = this.params.callbacks) === null || _a === void 0 ? void 0 : _a.onInit) {
|
|
5412
|
+
this.params.callbacks.onInit(this.params.clientId, this.params.stateName);
|
|
5413
|
+
}
|
|
5414
|
+
}
|
|
5415
|
+
return ClientState;
|
|
5416
|
+
}());
|
|
5417
|
+
|
|
5418
|
+
/**
|
|
5419
|
+
* Service for managing state connections.
|
|
5420
|
+
* @template T - The type of state data.
|
|
5421
|
+
* @implements {IState<T>}
|
|
5422
|
+
*/
|
|
5423
|
+
var StateConnectionService = /** @class */ (function () {
|
|
5424
|
+
function StateConnectionService() {
|
|
5425
|
+
var _this = this;
|
|
5426
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
5427
|
+
this.contextService = inject(TYPES.contextService);
|
|
5428
|
+
this.stateSchemaService = inject(TYPES.stateSchemaService);
|
|
5429
|
+
this.sessionValidationService = inject(TYPES.sessionValidationService);
|
|
5430
|
+
/**
|
|
5431
|
+
* Memoized function to get a shared state reference.
|
|
5432
|
+
* @param {string} clientId - The client ID.
|
|
5433
|
+
* @param {StateName} stateName - The state name.
|
|
5434
|
+
* @returns {ClientState} The client state.
|
|
5435
|
+
*/
|
|
5436
|
+
this.getSharedStateRef = functoolsKit.memoize(function (_a) {
|
|
5437
|
+
var _b = __read(_a, 2), stateName = _b[1];
|
|
5438
|
+
return "".concat(stateName);
|
|
5439
|
+
}, function (clientId, stateName) {
|
|
5440
|
+
_this.sessionValidationService.addStateUsage(clientId, stateName);
|
|
5441
|
+
var _a = _this.stateSchemaService.get(stateName), getState = _a.getState, setState = _a.setState, _b = _a.middlewares, middlewares = _b === void 0 ? [] : _b, shared = _a.shared, callbacks = _a.callbacks;
|
|
5442
|
+
if (!shared) {
|
|
5443
|
+
throw new Error("agent-swarm state not shared stateName=".concat(stateName));
|
|
5444
|
+
}
|
|
5445
|
+
return new ClientState({
|
|
5446
|
+
clientId: clientId,
|
|
5447
|
+
stateName: stateName,
|
|
5448
|
+
logger: _this.loggerService,
|
|
5449
|
+
setState: setState
|
|
5450
|
+
? functoolsKit.queued(function () {
|
|
5451
|
+
var args = [];
|
|
5452
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
5453
|
+
args[_i] = arguments[_i];
|
|
5454
|
+
}
|
|
5455
|
+
return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
5456
|
+
switch (_a.label) {
|
|
5457
|
+
case 0: return [4 /*yield*/, setState.apply(void 0, __spreadArray([], __read(args), false))];
|
|
5458
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5459
|
+
}
|
|
5460
|
+
}); });
|
|
5461
|
+
})
|
|
5462
|
+
: setState,
|
|
5463
|
+
getState: getState,
|
|
5464
|
+
middlewares: middlewares,
|
|
5465
|
+
callbacks: callbacks,
|
|
5466
|
+
});
|
|
5467
|
+
});
|
|
5468
|
+
/**
|
|
5469
|
+
* Memoized function to get a state reference.
|
|
5470
|
+
* @param {string} clientId - The client ID.
|
|
5471
|
+
* @param {StateName} stateName - The state name.
|
|
5472
|
+
* @returns {ClientState} The client state.
|
|
5473
|
+
*/
|
|
5474
|
+
this.getStateRef = functoolsKit.memoize(function (_a) {
|
|
5475
|
+
var _b = __read(_a, 2), clientId = _b[0], stateName = _b[1];
|
|
5476
|
+
return "".concat(clientId, "-").concat(stateName);
|
|
5477
|
+
}, function (clientId, stateName) {
|
|
5478
|
+
_this.sessionValidationService.addStateUsage(clientId, stateName);
|
|
5479
|
+
var _a = _this.stateSchemaService.get(stateName), getState = _a.getState, setState = _a.setState, _b = _a.middlewares, middlewares = _b === void 0 ? [] : _b, callbacks = _a.callbacks, _c = _a.shared, shared = _c === void 0 ? false : _c;
|
|
5480
|
+
if (shared) {
|
|
5481
|
+
return _this.getSharedStateRef(clientId, stateName);
|
|
5482
|
+
}
|
|
5483
|
+
return new ClientState({
|
|
5484
|
+
clientId: clientId,
|
|
5485
|
+
stateName: stateName,
|
|
5486
|
+
logger: _this.loggerService,
|
|
5487
|
+
setState: setState
|
|
5488
|
+
? functoolsKit.queued(function () {
|
|
5489
|
+
var args = [];
|
|
5490
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
5491
|
+
args[_i] = arguments[_i];
|
|
5492
|
+
}
|
|
5493
|
+
return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
5494
|
+
switch (_a.label) {
|
|
5495
|
+
case 0: return [4 /*yield*/, setState.apply(void 0, __spreadArray([], __read(args), false))];
|
|
5496
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5497
|
+
}
|
|
5498
|
+
}); });
|
|
5499
|
+
})
|
|
5500
|
+
: setState,
|
|
5501
|
+
getState: getState,
|
|
5502
|
+
middlewares: middlewares,
|
|
5503
|
+
callbacks: callbacks,
|
|
5504
|
+
});
|
|
5505
|
+
});
|
|
5506
|
+
/**
|
|
5507
|
+
* Sets the state.
|
|
5508
|
+
* @param {function(T): Promise<T>} dispatchFn - The function to dispatch the new state.
|
|
5509
|
+
* @returns {Promise<T>} The new state.
|
|
5510
|
+
*/
|
|
5511
|
+
this.setState = function (dispatchFn) { return __awaiter(_this, void 0, void 0, function () {
|
|
5512
|
+
var state;
|
|
5513
|
+
return __generator(this, function (_a) {
|
|
5514
|
+
switch (_a.label) {
|
|
5515
|
+
case 0:
|
|
5516
|
+
this.loggerService.log("stateConnectionService setState", {
|
|
5517
|
+
context: this.contextService.context,
|
|
5518
|
+
});
|
|
5519
|
+
state = this.getStateRef(this.contextService.context.clientId, this.contextService.context.stateName);
|
|
5520
|
+
return [4 /*yield*/, state.waitForInit()];
|
|
5521
|
+
case 1:
|
|
5522
|
+
_a.sent();
|
|
5523
|
+
return [4 /*yield*/, state.setState(dispatchFn)];
|
|
5524
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
5525
|
+
}
|
|
5526
|
+
});
|
|
5527
|
+
}); };
|
|
5528
|
+
/**
|
|
5529
|
+
* Gets the state.
|
|
5530
|
+
* @returns {Promise<T>} The current state.
|
|
5531
|
+
*/
|
|
5532
|
+
this.getState = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5533
|
+
var state;
|
|
5534
|
+
return __generator(this, function (_a) {
|
|
5535
|
+
switch (_a.label) {
|
|
5536
|
+
case 0:
|
|
5537
|
+
this.loggerService.log("stateConnectionService getState", {
|
|
5538
|
+
context: this.contextService.context,
|
|
5539
|
+
});
|
|
5540
|
+
state = this.getStateRef(this.contextService.context.clientId, this.contextService.context.stateName);
|
|
5541
|
+
return [4 /*yield*/, state.waitForInit()];
|
|
5542
|
+
case 1:
|
|
5543
|
+
_a.sent();
|
|
5544
|
+
return [4 /*yield*/, state.getState()];
|
|
5545
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
5546
|
+
}
|
|
5547
|
+
});
|
|
5548
|
+
}); };
|
|
5549
|
+
/**
|
|
5550
|
+
* Disposes the state connection.
|
|
5551
|
+
* @returns {Promise<void>}
|
|
5552
|
+
*/
|
|
5553
|
+
this.dispose = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5554
|
+
var key, state;
|
|
5555
|
+
return __generator(this, function (_a) {
|
|
5556
|
+
switch (_a.label) {
|
|
5557
|
+
case 0:
|
|
5558
|
+
this.loggerService.log("stateConnectionService dispose", {
|
|
5559
|
+
context: this.contextService.context,
|
|
5560
|
+
});
|
|
5561
|
+
key = "".concat(this.contextService.context.clientId, "-").concat(this.contextService.context.stateName);
|
|
5562
|
+
if (!this.getStateRef.has(key)) {
|
|
5563
|
+
return [2 /*return*/];
|
|
5564
|
+
}
|
|
5565
|
+
if (!!this.getSharedStateRef.has(this.contextService.context.stateName)) return [3 /*break*/, 3];
|
|
5566
|
+
state = this.getStateRef(this.contextService.context.clientId, this.contextService.context.stateName);
|
|
5567
|
+
return [4 /*yield*/, state.waitForInit()];
|
|
5568
|
+
case 1:
|
|
5569
|
+
_a.sent();
|
|
5570
|
+
return [4 /*yield*/, state.dispose()];
|
|
5571
|
+
case 2:
|
|
5572
|
+
_a.sent();
|
|
5573
|
+
_a.label = 3;
|
|
5574
|
+
case 3:
|
|
5575
|
+
this.getStateRef.clear(key);
|
|
5576
|
+
this.sessionValidationService.removeStateUsage(this.contextService.context.clientId, this.contextService.context.stateName);
|
|
5577
|
+
return [2 /*return*/];
|
|
5578
|
+
}
|
|
5579
|
+
});
|
|
5580
|
+
}); };
|
|
5581
|
+
}
|
|
5582
|
+
return StateConnectionService;
|
|
5583
|
+
}());
|
|
5584
|
+
|
|
5585
|
+
var StatePublicService = /** @class */ (function () {
|
|
5586
|
+
function StatePublicService() {
|
|
5587
|
+
var _this = this;
|
|
5588
|
+
this.loggerService = inject(TYPES.loggerService);
|
|
5589
|
+
this.stateConnectionService = inject(TYPES.stateConnectionService);
|
|
5590
|
+
/**
|
|
5591
|
+
* Sets the state using the provided dispatch function.
|
|
5592
|
+
* @param {function(T): Promise<T>} dispatchFn - The function to dispatch the state change.
|
|
5593
|
+
* @param {string} clientId - The client ID.
|
|
5594
|
+
* @param {StateName} stateName - The name of the state.
|
|
5595
|
+
* @returns {Promise<T>} - The updated state.
|
|
5596
|
+
*/
|
|
5597
|
+
this.setState = function (dispatchFn, clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5598
|
+
var _this = this;
|
|
5599
|
+
return __generator(this, function (_a) {
|
|
5600
|
+
switch (_a.label) {
|
|
5601
|
+
case 0:
|
|
5602
|
+
this.loggerService.log("statePublicService setState", {
|
|
5603
|
+
clientId: clientId,
|
|
5604
|
+
stateName: stateName,
|
|
5605
|
+
});
|
|
5606
|
+
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5607
|
+
return __generator(this, function (_a) {
|
|
5608
|
+
switch (_a.label) {
|
|
5609
|
+
case 0: return [4 /*yield*/, this.stateConnectionService.setState(dispatchFn)];
|
|
5610
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5611
|
+
}
|
|
5612
|
+
});
|
|
5613
|
+
}); }, {
|
|
5614
|
+
clientId: clientId,
|
|
5615
|
+
stateName: stateName,
|
|
5616
|
+
agentName: "",
|
|
5617
|
+
swarmName: "",
|
|
5618
|
+
storageName: "",
|
|
5619
|
+
})];
|
|
5620
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5621
|
+
}
|
|
5622
|
+
});
|
|
5623
|
+
}); };
|
|
5624
|
+
/**
|
|
5625
|
+
* Gets the current state.
|
|
5626
|
+
* @param {string} clientId - The client ID.
|
|
5627
|
+
* @param {StateName} stateName - The name of the state.
|
|
5628
|
+
* @returns {Promise<T>} - The current state.
|
|
5629
|
+
*/
|
|
5630
|
+
this.getState = function (clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5631
|
+
var _this = this;
|
|
5632
|
+
return __generator(this, function (_a) {
|
|
5633
|
+
switch (_a.label) {
|
|
5634
|
+
case 0:
|
|
5635
|
+
this.loggerService.log("statePublicService getState", {
|
|
5636
|
+
clientId: clientId,
|
|
5637
|
+
stateName: stateName,
|
|
5638
|
+
});
|
|
5639
|
+
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5640
|
+
return __generator(this, function (_a) {
|
|
5641
|
+
switch (_a.label) {
|
|
5642
|
+
case 0: return [4 /*yield*/, this.stateConnectionService.getState()];
|
|
5643
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5644
|
+
}
|
|
5645
|
+
});
|
|
5646
|
+
}); }, {
|
|
5647
|
+
clientId: clientId,
|
|
5648
|
+
stateName: stateName,
|
|
5649
|
+
agentName: "",
|
|
5650
|
+
swarmName: "",
|
|
5651
|
+
storageName: "",
|
|
5652
|
+
})];
|
|
5653
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5654
|
+
}
|
|
5655
|
+
});
|
|
5656
|
+
}); };
|
|
5657
|
+
/**
|
|
5658
|
+
* Disposes the state.
|
|
5659
|
+
* @param {string} clientId - The client ID.
|
|
5660
|
+
* @param {StateName} stateName - The name of the state.
|
|
5661
|
+
* @returns {Promise<void>} - A promise that resolves when the state is disposed.
|
|
5662
|
+
*/
|
|
5663
|
+
this.dispose = function (clientId, stateName) { return __awaiter(_this, void 0, void 0, function () {
|
|
5664
|
+
var _this = this;
|
|
5665
|
+
return __generator(this, function (_a) {
|
|
5666
|
+
switch (_a.label) {
|
|
5667
|
+
case 0:
|
|
5668
|
+
this.loggerService.log("statePublicService dispose", {
|
|
5669
|
+
clientId: clientId,
|
|
5670
|
+
stateName: stateName,
|
|
5671
|
+
});
|
|
5672
|
+
return [4 /*yield*/, ContextService.runInContext(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
5673
|
+
return __generator(this, function (_a) {
|
|
5674
|
+
switch (_a.label) {
|
|
5675
|
+
case 0: return [4 /*yield*/, this.stateConnectionService.dispose()];
|
|
5676
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5677
|
+
}
|
|
5678
|
+
});
|
|
5679
|
+
}); }, {
|
|
5680
|
+
clientId: clientId,
|
|
5681
|
+
stateName: stateName,
|
|
5682
|
+
agentName: "",
|
|
5683
|
+
swarmName: "",
|
|
5684
|
+
storageName: "",
|
|
5685
|
+
})];
|
|
5686
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
5687
|
+
}
|
|
5688
|
+
});
|
|
5689
|
+
}); };
|
|
5690
|
+
}
|
|
5691
|
+
return StatePublicService;
|
|
5692
|
+
}());
|
|
5693
|
+
|
|
5080
5694
|
{
|
|
5081
5695
|
provide(TYPES.loggerService, function () { return new LoggerService(); });
|
|
5082
5696
|
provide(TYPES.contextService, function () { return new ContextService(); });
|
|
@@ -5087,6 +5701,7 @@ var EmbeddingValidationService = /** @class */ (function () {
|
|
|
5087
5701
|
provide(TYPES.swarmConnectionService, function () { return new SwarmConnectionService(); });
|
|
5088
5702
|
provide(TYPES.sessionConnectionService, function () { return new SessionConnectionService(); });
|
|
5089
5703
|
provide(TYPES.storageConnectionService, function () { return new StorageConnectionService(); });
|
|
5704
|
+
provide(TYPES.stateConnectionService, function () { return new StateConnectionService(); });
|
|
5090
5705
|
}
|
|
5091
5706
|
{
|
|
5092
5707
|
provide(TYPES.agentSchemaService, function () { return new AgentSchemaService(); });
|
|
@@ -5095,6 +5710,7 @@ var EmbeddingValidationService = /** @class */ (function () {
|
|
|
5095
5710
|
provide(TYPES.completionSchemaService, function () { return new CompletionSchemaService(); });
|
|
5096
5711
|
provide(TYPES.embeddingSchemaService, function () { return new EmbeddingSchemaService(); });
|
|
5097
5712
|
provide(TYPES.storageSchemaService, function () { return new StorageSchemaService(); });
|
|
5713
|
+
provide(TYPES.stateSchemaService, function () { return new StateSchemaService(); });
|
|
5098
5714
|
}
|
|
5099
5715
|
{
|
|
5100
5716
|
provide(TYPES.agentPublicService, function () { return new AgentPublicService(); });
|
|
@@ -5102,6 +5718,7 @@ var EmbeddingValidationService = /** @class */ (function () {
|
|
|
5102
5718
|
provide(TYPES.sessionPublicService, function () { return new SessionPublicService(); });
|
|
5103
5719
|
provide(TYPES.swarmPublicService, function () { return new SwarmPublicService(); });
|
|
5104
5720
|
provide(TYPES.storagePublicService, function () { return new StoragePublicService(); });
|
|
5721
|
+
provide(TYPES.statePublicService, function () { return new StatePublicService(); });
|
|
5105
5722
|
}
|
|
5106
5723
|
{
|
|
5107
5724
|
provide(TYPES.agentPublicService, function () { return new AgentPublicService(); });
|
|
@@ -5129,6 +5746,7 @@ var connectionServices = {
|
|
|
5129
5746
|
swarmConnectionService: inject(TYPES.swarmConnectionService),
|
|
5130
5747
|
sessionConnectionService: inject(TYPES.sessionConnectionService),
|
|
5131
5748
|
storageConnectionService: inject(TYPES.storageConnectionService),
|
|
5749
|
+
stateConnectionService: inject(TYPES.stateConnectionService),
|
|
5132
5750
|
};
|
|
5133
5751
|
var schemaServices = {
|
|
5134
5752
|
agentSchemaService: inject(TYPES.agentSchemaService),
|
|
@@ -5137,6 +5755,7 @@ var schemaServices = {
|
|
|
5137
5755
|
completionSchemaService: inject(TYPES.completionSchemaService),
|
|
5138
5756
|
embeddingSchemaService: inject(TYPES.embeddingSchemaService),
|
|
5139
5757
|
storageSchemaService: inject(TYPES.storageSchemaService),
|
|
5758
|
+
stateSchemaService: inject(TYPES.stateSchemaService),
|
|
5140
5759
|
};
|
|
5141
5760
|
var publicServices = {
|
|
5142
5761
|
agentPublicService: inject(TYPES.agentPublicService),
|
|
@@ -5144,6 +5763,7 @@ var publicServices = {
|
|
|
5144
5763
|
sessionPublicService: inject(TYPES.sessionPublicService),
|
|
5145
5764
|
swarmPublicService: inject(TYPES.swarmPublicService),
|
|
5146
5765
|
storagePublicService: inject(TYPES.storagePublicService),
|
|
5766
|
+
statePublicService: inject(TYPES.statePublicService),
|
|
5147
5767
|
};
|
|
5148
5768
|
var validationServices = {
|
|
5149
5769
|
agentValidationService: inject(TYPES.agentValidationService),
|
|
@@ -5219,6 +5839,25 @@ var addTool = function (toolSchema) {
|
|
|
5219
5839
|
return toolSchema.toolName;
|
|
5220
5840
|
};
|
|
5221
5841
|
|
|
5842
|
+
/**
|
|
5843
|
+
* Adds a new state to the state registry. The swarm takes only those states which was registered
|
|
5844
|
+
*
|
|
5845
|
+
* @param {IStateSchema} stateSchema - The schema of the state to be added.
|
|
5846
|
+
* @returns {string} The name of the added state.
|
|
5847
|
+
*/
|
|
5848
|
+
var addState = function (stateSchema) {
|
|
5849
|
+
swarm.loggerService.log("function addState", {
|
|
5850
|
+
stateSchema: stateSchema,
|
|
5851
|
+
});
|
|
5852
|
+
swarm.stateSchemaService.register(stateSchema.stateName, stateSchema);
|
|
5853
|
+
if (stateSchema.shared) {
|
|
5854
|
+
swarm.stateConnectionService
|
|
5855
|
+
.getSharedStateRef("shared", stateSchema.stateName)
|
|
5856
|
+
.waitForInit();
|
|
5857
|
+
}
|
|
5858
|
+
return stateSchema.stateName;
|
|
5859
|
+
};
|
|
5860
|
+
|
|
5222
5861
|
/**
|
|
5223
5862
|
* Adds a new embedding to the embedding registry. The swarm takes only those embeddings which was registered
|
|
5224
5863
|
*
|
|
@@ -5586,6 +6225,7 @@ var disposeConnection = function (clientId, swarmName) { return __awaiter(void 0
|
|
|
5586
6225
|
.flatMap(function (agentName) {
|
|
5587
6226
|
return swarm.agentValidationService.getStorageList(agentName);
|
|
5588
6227
|
})
|
|
6228
|
+
.filter(function (storageName) { return !!storageName; })
|
|
5589
6229
|
.map(function (storageName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
5590
6230
|
return __generator(this, function (_a) {
|
|
5591
6231
|
switch (_a.label) {
|
|
@@ -5599,8 +6239,28 @@ var disposeConnection = function (clientId, swarmName) { return __awaiter(void 0
|
|
|
5599
6239
|
])];
|
|
5600
6240
|
case 4:
|
|
5601
6241
|
_a.sent();
|
|
5602
|
-
return [4 /*yield*/,
|
|
6242
|
+
return [4 /*yield*/, Promise.all([
|
|
6243
|
+
swarm.swarmValidationService
|
|
6244
|
+
.getAgentList(swarmName)
|
|
6245
|
+
.flatMap(function (agentName) {
|
|
6246
|
+
return swarm.agentValidationService.getStateList(agentName);
|
|
6247
|
+
})
|
|
6248
|
+
.filter(function (stateName) { return !!stateName; })
|
|
6249
|
+
.map(function (stateName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
6250
|
+
return __generator(this, function (_a) {
|
|
6251
|
+
switch (_a.label) {
|
|
6252
|
+
case 0: return [4 /*yield*/, swarm.statePublicService.dispose(clientId, stateName)];
|
|
6253
|
+
case 1:
|
|
6254
|
+
_a.sent();
|
|
6255
|
+
return [2 /*return*/];
|
|
6256
|
+
}
|
|
6257
|
+
});
|
|
6258
|
+
}); }),
|
|
6259
|
+
])];
|
|
5603
6260
|
case 5:
|
|
6261
|
+
_a.sent();
|
|
6262
|
+
return [4 /*yield*/, HistoryAdapter.dispose(clientId, null)];
|
|
6263
|
+
case 6:
|
|
5604
6264
|
_a.sent();
|
|
5605
6265
|
return [2 /*return*/];
|
|
5606
6266
|
}
|
|
@@ -6614,14 +7274,91 @@ var StorageUtils = /** @class */ (function () {
|
|
|
6614
7274
|
}());
|
|
6615
7275
|
var Storage = new StorageUtils();
|
|
6616
7276
|
|
|
7277
|
+
/**
|
|
7278
|
+
* Utility class for managing state in the agent swarm.
|
|
7279
|
+
* @implements {TState}
|
|
7280
|
+
*/
|
|
7281
|
+
var StateUtils = /** @class */ (function () {
|
|
7282
|
+
function StateUtils() {
|
|
7283
|
+
var _this = this;
|
|
7284
|
+
/**
|
|
7285
|
+
* Retrieves the state for a given client and state name.
|
|
7286
|
+
* @template T
|
|
7287
|
+
* @param {Object} payload - The payload containing client and state information.
|
|
7288
|
+
* @param {string} payload.clientId - The client ID.
|
|
7289
|
+
* @param {AgentName} payload.agentName - The agent name.
|
|
7290
|
+
* @param {StateName} payload.stateName - The state name.
|
|
7291
|
+
* @returns {Promise<T>} The state data.
|
|
7292
|
+
* @throws Will throw an error if the state is not registered in the agent.
|
|
7293
|
+
*/
|
|
7294
|
+
this.getState = function (payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
7295
|
+
return __generator(this, function (_a) {
|
|
7296
|
+
switch (_a.label) {
|
|
7297
|
+
case 0:
|
|
7298
|
+
swarm.loggerService.log("StateUtils getState", {
|
|
7299
|
+
clientId: payload.clientId,
|
|
7300
|
+
stateName: payload.stateName,
|
|
7301
|
+
});
|
|
7302
|
+
if (!swarm.agentValidationService.hasState(payload.agentName, payload.stateName)) {
|
|
7303
|
+
throw new Error("agent-swarm StateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (getState)"));
|
|
7304
|
+
}
|
|
7305
|
+
return [4 /*yield*/, swarm.statePublicService.getState(payload.clientId, payload.stateName)];
|
|
7306
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
7307
|
+
}
|
|
7308
|
+
});
|
|
7309
|
+
}); };
|
|
7310
|
+
/**
|
|
7311
|
+
* Sets the state for a given client and state name.
|
|
7312
|
+
* @template T
|
|
7313
|
+
* @param {T | ((prevState: T) => Promise<T>)} dispatchFn - The new state or a function that returns the new state.
|
|
7314
|
+
* @param {Object} payload - The payload containing client and state information.
|
|
7315
|
+
* @param {string} payload.clientId - The client ID.
|
|
7316
|
+
* @param {AgentName} payload.agentName - The agent name.
|
|
7317
|
+
* @param {StateName} payload.stateName - The state name.
|
|
7318
|
+
* @returns {Promise<void>}
|
|
7319
|
+
* @throws Will throw an error if the state is not registered in the agent.
|
|
7320
|
+
*/
|
|
7321
|
+
this.setState = function (dispatchFn, payload) { return __awaiter(_this, void 0, void 0, function () {
|
|
7322
|
+
var _this = this;
|
|
7323
|
+
return __generator(this, function (_a) {
|
|
7324
|
+
switch (_a.label) {
|
|
7325
|
+
case 0:
|
|
7326
|
+
swarm.loggerService.log("StateUtils setState", {
|
|
7327
|
+
clientId: payload.clientId,
|
|
7328
|
+
stateName: payload.stateName,
|
|
7329
|
+
});
|
|
7330
|
+
if (!swarm.agentValidationService.hasState(payload.agentName, payload.stateName)) {
|
|
7331
|
+
throw new Error("agent-swarm StateUtils ".concat(payload.stateName, " not registered in ").concat(payload.agentName, " (setState)"));
|
|
7332
|
+
}
|
|
7333
|
+
if (!(typeof dispatchFn === "function")) return [3 /*break*/, 2];
|
|
7334
|
+
return [4 /*yield*/, swarm.statePublicService.setState(dispatchFn, payload.clientId, payload.stateName)];
|
|
7335
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
7336
|
+
case 2: return [4 /*yield*/, swarm.statePublicService.setState(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
7337
|
+
return [2 /*return*/, dispatchFn];
|
|
7338
|
+
}); }); }, payload.clientId, payload.stateName)];
|
|
7339
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
7340
|
+
}
|
|
7341
|
+
});
|
|
7342
|
+
}); };
|
|
7343
|
+
}
|
|
7344
|
+
return StateUtils;
|
|
7345
|
+
}());
|
|
7346
|
+
/**
|
|
7347
|
+
* Instance of StateUtils for managing state.
|
|
7348
|
+
* @type {StateUtils}
|
|
7349
|
+
*/
|
|
7350
|
+
var State = new StateUtils();
|
|
7351
|
+
|
|
6617
7352
|
exports.ContextService = ContextService;
|
|
6618
7353
|
exports.History = History;
|
|
7354
|
+
exports.HistoryAdapter = HistoryAdapter;
|
|
7355
|
+
exports.HistoryInstance = HistoryInstance;
|
|
7356
|
+
exports.State = State;
|
|
6619
7357
|
exports.Storage = Storage;
|
|
6620
|
-
exports._HistoryAdapter = HistoryAdapter;
|
|
6621
|
-
exports._HistoryInstance = HistoryInstance;
|
|
6622
7358
|
exports.addAgent = addAgent;
|
|
6623
7359
|
exports.addCompletion = addCompletion;
|
|
6624
7360
|
exports.addEmbedding = addEmbedding;
|
|
7361
|
+
exports.addState = addState;
|
|
6625
7362
|
exports.addStorage = addStorage;
|
|
6626
7363
|
exports.addSwarm = addSwarm;
|
|
6627
7364
|
exports.addTool = addTool;
|