agent-swarm-kit 1.1.142 → 1.1.144
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 +131 -11
- package/build/index.mjs +131 -12
- package/package.json +1 -1
- package/types.d.ts +46 -1
package/build/index.cjs
CHANGED
|
@@ -5044,6 +5044,9 @@ async function commitToolOutput(toolId, content, clientId, agentName) {
|
|
|
5044
5044
|
return await commitToolOutputInternal(toolId, content, clientId, agentName);
|
|
5045
5045
|
}
|
|
5046
5046
|
|
|
5047
|
+
const disposeSubject = new functoolsKit.Subject();
|
|
5048
|
+
const errorSubject = new functoolsKit.Subject();
|
|
5049
|
+
|
|
5047
5050
|
const METHOD_NAME$1G = "function.target.execute";
|
|
5048
5051
|
/**
|
|
5049
5052
|
* Function implementation
|
|
@@ -5083,18 +5086,29 @@ const executeInternal = beginContext(async (content, clientId, agentName) => {
|
|
|
5083
5086
|
agentName,
|
|
5084
5087
|
swarmName,
|
|
5085
5088
|
});
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5089
|
+
let result = "";
|
|
5090
|
+
let errorValue = null;
|
|
5091
|
+
const unError = errorSubject.once(([errorClientId, error]) => {
|
|
5092
|
+
if (clientId === errorClientId) {
|
|
5093
|
+
errorValue = error;
|
|
5094
|
+
}
|
|
5091
5095
|
});
|
|
5096
|
+
result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$1G, clientId, swarmName);
|
|
5097
|
+
unError();
|
|
5098
|
+
if (errorValue) {
|
|
5099
|
+
throw errorValue;
|
|
5100
|
+
}
|
|
5101
|
+
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
5092
5102
|
return result;
|
|
5093
5103
|
}
|
|
5094
5104
|
finally {
|
|
5095
5105
|
if (!isFinished) {
|
|
5096
5106
|
swarm$1.perfService.endExecution(executionId, clientId, 0);
|
|
5097
5107
|
}
|
|
5108
|
+
swarm$1.busService.commitExecutionEnd(clientId, {
|
|
5109
|
+
agentName,
|
|
5110
|
+
swarmName,
|
|
5111
|
+
});
|
|
5098
5112
|
swarm$1.executionValidationService.decrementCount(executionId, clientId, swarmName);
|
|
5099
5113
|
}
|
|
5100
5114
|
}, {
|
|
@@ -19323,8 +19337,6 @@ async function getLastUserMessage(clientId) {
|
|
|
19323
19337
|
return await getLastUserMessageInternal(clientId);
|
|
19324
19338
|
}
|
|
19325
19339
|
|
|
19326
|
-
const disposeSubject = new functoolsKit.Subject();
|
|
19327
|
-
|
|
19328
19340
|
const METHOD_NAME$1q = "function.navigate.changeToDefaultAgent";
|
|
19329
19341
|
/**
|
|
19330
19342
|
* Creates a change agent function with time-to-live (TTL) and queuing capabilities for switching to the default agent.
|
|
@@ -20109,16 +20121,56 @@ function addAgent(agentSchema) {
|
|
|
20109
20121
|
return addAgentInternal(agentSchema);
|
|
20110
20122
|
}
|
|
20111
20123
|
|
|
20124
|
+
/**
|
|
20125
|
+
* Maps a completion schema by wrapping its `getCompletion` method with error handling.
|
|
20126
|
+
* If an error occurs during the execution of `getCompletion`, it emits the error using `errorSubject`.
|
|
20127
|
+
* Also removes any undefined properties from the resulting schema object.
|
|
20128
|
+
*
|
|
20129
|
+
* @param {ICompletionSchema} param0 - The completion schema object containing a `getCompletion` function and other properties.
|
|
20130
|
+
* @returns {ICompletionSchema} - The new completion schema with error-handled `getCompletion` and no undefined properties.
|
|
20131
|
+
*/
|
|
20132
|
+
const mapCompletionSchema = ({ getCompletion, ...schema }) => removeUndefined({
|
|
20133
|
+
...schema,
|
|
20134
|
+
getCompletion: getCompletion
|
|
20135
|
+
? async ({ mode, messages, agentName, clientId, format, outlineName, tools, }) => {
|
|
20136
|
+
const params = {
|
|
20137
|
+
mode,
|
|
20138
|
+
messages,
|
|
20139
|
+
agentName,
|
|
20140
|
+
clientId,
|
|
20141
|
+
format,
|
|
20142
|
+
outlineName,
|
|
20143
|
+
tools,
|
|
20144
|
+
};
|
|
20145
|
+
try {
|
|
20146
|
+
return await getCompletion(params);
|
|
20147
|
+
}
|
|
20148
|
+
catch (error) {
|
|
20149
|
+
if (clientId) {
|
|
20150
|
+
errorSubject.next([clientId, error]);
|
|
20151
|
+
}
|
|
20152
|
+
return {
|
|
20153
|
+
agentName,
|
|
20154
|
+
content: "",
|
|
20155
|
+
mode,
|
|
20156
|
+
role: "assistant",
|
|
20157
|
+
};
|
|
20158
|
+
}
|
|
20159
|
+
}
|
|
20160
|
+
: undefined,
|
|
20161
|
+
});
|
|
20162
|
+
|
|
20112
20163
|
const METHOD_NAME$1e = "function.setup.addCompletion";
|
|
20113
20164
|
/**
|
|
20114
20165
|
* Function implementation
|
|
20115
20166
|
*/
|
|
20116
|
-
const addCompletionInternal = beginContext((
|
|
20167
|
+
const addCompletionInternal = beginContext((completionPublicSchema) => {
|
|
20117
20168
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
20118
20169
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
20119
20170
|
swarm$1.loggerService.log(METHOD_NAME$1e, {
|
|
20120
|
-
completionSchema,
|
|
20171
|
+
completionSchema: completionPublicSchema,
|
|
20121
20172
|
});
|
|
20173
|
+
const completionSchema = mapCompletionSchema(completionPublicSchema);
|
|
20122
20174
|
// Register the completion in the validation and schema services
|
|
20123
20175
|
swarm$1.completionValidationService.addCompletion(completionSchema.completionName);
|
|
20124
20176
|
swarm$1.completionSchemaService.register(completionSchema.completionName, completionSchema);
|
|
@@ -20500,7 +20552,7 @@ const overrideCompletionInternal = beginContext((publicCompletionSchema) => {
|
|
|
20500
20552
|
swarm$1.loggerService.log(METHOD_NAME$14, {
|
|
20501
20553
|
completionSchema: publicCompletionSchema,
|
|
20502
20554
|
});
|
|
20503
|
-
const completionSchema =
|
|
20555
|
+
const completionSchema = mapCompletionSchema(publicCompletionSchema);
|
|
20504
20556
|
return swarm$1.completionSchemaService.override(completionSchema.completionName, completionSchema);
|
|
20505
20557
|
});
|
|
20506
20558
|
/**
|
|
@@ -21665,6 +21717,7 @@ const jsonInternal = beginContext(async (outlineName, param) => {
|
|
|
21665
21717
|
swarm$1.loggerService.log(METHOD_NAME$E, {});
|
|
21666
21718
|
swarm$1.outlineValidationService.validate(outlineName, METHOD_NAME$E);
|
|
21667
21719
|
const resultId = functoolsKit.randomString();
|
|
21720
|
+
const clientId = `${resultId}_outline`;
|
|
21668
21721
|
const { getOutlineHistory, completion, validations = [], maxAttempts = MAX_ATTEMPTS, format, prompt, system, callbacks: outlineCallbacks, } = swarm$1.outlineSchemaService.get(outlineName);
|
|
21669
21722
|
swarm$1.completionValidationService.validate(completion, METHOD_NAME$E);
|
|
21670
21723
|
const { getCompletion, flags = [], callbacks: completionCallbacks, } = swarm$1.completionSchemaService.get(completion);
|
|
@@ -21708,12 +21761,24 @@ const jsonInternal = beginContext(async (outlineName, param) => {
|
|
|
21708
21761
|
await getOutlineHistory(inputArgs);
|
|
21709
21762
|
const messages = await history.list();
|
|
21710
21763
|
try {
|
|
21711
|
-
|
|
21764
|
+
let output;
|
|
21765
|
+
let errorValue = null;
|
|
21766
|
+
const unError = errorSubject.once(([errorClientId, error]) => {
|
|
21767
|
+
if (clientId === errorClientId) {
|
|
21768
|
+
errorValue = error;
|
|
21769
|
+
}
|
|
21770
|
+
});
|
|
21771
|
+
output = await getCompletion({
|
|
21772
|
+
clientId,
|
|
21712
21773
|
messages: await history.list(),
|
|
21713
21774
|
mode: "tool",
|
|
21714
21775
|
outlineName,
|
|
21715
21776
|
format,
|
|
21716
21777
|
});
|
|
21778
|
+
unError();
|
|
21779
|
+
if (errorValue) {
|
|
21780
|
+
throw errorValue;
|
|
21781
|
+
}
|
|
21717
21782
|
if (completionCallbacks?.onComplete) {
|
|
21718
21783
|
completionCallbacks.onComplete({
|
|
21719
21784
|
messages,
|
|
@@ -26195,6 +26260,60 @@ const toJsonSchema = (name, schema) => ({
|
|
|
26195
26260
|
},
|
|
26196
26261
|
});
|
|
26197
26262
|
|
|
26263
|
+
/**
|
|
26264
|
+
* Validates tool function arguments against a JSON schema
|
|
26265
|
+
*
|
|
26266
|
+
* @param parsedArguments - Already parsed arguments object
|
|
26267
|
+
* @param schema - JSON schema to validate against
|
|
26268
|
+
* @returns Validation result with validated data or error message
|
|
26269
|
+
*
|
|
26270
|
+
* @example
|
|
26271
|
+
* ```typescript
|
|
26272
|
+
* const result = validateToolArguments({ name: "test" }, {
|
|
26273
|
+
* type: "object",
|
|
26274
|
+
* required: ["name"],
|
|
26275
|
+
* properties: { name: { type: "string" } }
|
|
26276
|
+
* });
|
|
26277
|
+
*
|
|
26278
|
+
* if (result.success) {
|
|
26279
|
+
* console.log(result.data); // { name: "test" }
|
|
26280
|
+
* } else {
|
|
26281
|
+
* console.error(result.error);
|
|
26282
|
+
* }
|
|
26283
|
+
* ```
|
|
26284
|
+
*/
|
|
26285
|
+
const validateToolArguments = (parsedArguments, schema) => {
|
|
26286
|
+
// Check if arguments are null or undefined only when required fields exist
|
|
26287
|
+
if (parsedArguments == null) {
|
|
26288
|
+
if (schema?.required?.length) {
|
|
26289
|
+
return {
|
|
26290
|
+
success: false,
|
|
26291
|
+
error: "Tool call has empty arguments",
|
|
26292
|
+
};
|
|
26293
|
+
}
|
|
26294
|
+
// If no required fields, empty arguments is valid
|
|
26295
|
+
return {
|
|
26296
|
+
success: true,
|
|
26297
|
+
data: {},
|
|
26298
|
+
};
|
|
26299
|
+
}
|
|
26300
|
+
// Validate required fields if schema has them
|
|
26301
|
+
if (schema?.required?.length) {
|
|
26302
|
+
const argumentsObj = parsedArguments;
|
|
26303
|
+
const missingFields = schema.required.filter((field) => !(field in argumentsObj));
|
|
26304
|
+
if (missingFields.length > 0) {
|
|
26305
|
+
return {
|
|
26306
|
+
success: false,
|
|
26307
|
+
error: `Missing required fields: ${missingFields.join(", ")}`,
|
|
26308
|
+
};
|
|
26309
|
+
}
|
|
26310
|
+
}
|
|
26311
|
+
return {
|
|
26312
|
+
success: true,
|
|
26313
|
+
data: parsedArguments,
|
|
26314
|
+
};
|
|
26315
|
+
};
|
|
26316
|
+
|
|
26198
26317
|
const Utils = {
|
|
26199
26318
|
PersistStateUtils,
|
|
26200
26319
|
PersistSwarmUtils,
|
|
@@ -26368,3 +26487,4 @@ exports.startPipeline = startPipeline;
|
|
|
26368
26487
|
exports.swarm = swarm;
|
|
26369
26488
|
exports.toJsonSchema = toJsonSchema;
|
|
26370
26489
|
exports.validate = validate;
|
|
26490
|
+
exports.validateToolArguments = validateToolArguments;
|
package/build/index.mjs
CHANGED
|
@@ -5042,6 +5042,9 @@ async function commitToolOutput(toolId, content, clientId, agentName) {
|
|
|
5042
5042
|
return await commitToolOutputInternal(toolId, content, clientId, agentName);
|
|
5043
5043
|
}
|
|
5044
5044
|
|
|
5045
|
+
const disposeSubject = new Subject();
|
|
5046
|
+
const errorSubject = new Subject();
|
|
5047
|
+
|
|
5045
5048
|
const METHOD_NAME$1G = "function.target.execute";
|
|
5046
5049
|
/**
|
|
5047
5050
|
* Function implementation
|
|
@@ -5081,18 +5084,29 @@ const executeInternal = beginContext(async (content, clientId, agentName) => {
|
|
|
5081
5084
|
agentName,
|
|
5082
5085
|
swarmName,
|
|
5083
5086
|
});
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5087
|
+
let result = "";
|
|
5088
|
+
let errorValue = null;
|
|
5089
|
+
const unError = errorSubject.once(([errorClientId, error]) => {
|
|
5090
|
+
if (clientId === errorClientId) {
|
|
5091
|
+
errorValue = error;
|
|
5092
|
+
}
|
|
5089
5093
|
});
|
|
5094
|
+
result = await swarm$1.sessionPublicService.execute(content, "tool", METHOD_NAME$1G, clientId, swarmName);
|
|
5095
|
+
unError();
|
|
5096
|
+
if (errorValue) {
|
|
5097
|
+
throw errorValue;
|
|
5098
|
+
}
|
|
5099
|
+
isFinished = swarm$1.perfService.endExecution(executionId, clientId, result.length);
|
|
5090
5100
|
return result;
|
|
5091
5101
|
}
|
|
5092
5102
|
finally {
|
|
5093
5103
|
if (!isFinished) {
|
|
5094
5104
|
swarm$1.perfService.endExecution(executionId, clientId, 0);
|
|
5095
5105
|
}
|
|
5106
|
+
swarm$1.busService.commitExecutionEnd(clientId, {
|
|
5107
|
+
agentName,
|
|
5108
|
+
swarmName,
|
|
5109
|
+
});
|
|
5096
5110
|
swarm$1.executionValidationService.decrementCount(executionId, clientId, swarmName);
|
|
5097
5111
|
}
|
|
5098
5112
|
}, {
|
|
@@ -19321,8 +19335,6 @@ async function getLastUserMessage(clientId) {
|
|
|
19321
19335
|
return await getLastUserMessageInternal(clientId);
|
|
19322
19336
|
}
|
|
19323
19337
|
|
|
19324
|
-
const disposeSubject = new Subject();
|
|
19325
|
-
|
|
19326
19338
|
const METHOD_NAME$1q = "function.navigate.changeToDefaultAgent";
|
|
19327
19339
|
/**
|
|
19328
19340
|
* Creates a change agent function with time-to-live (TTL) and queuing capabilities for switching to the default agent.
|
|
@@ -20107,16 +20119,56 @@ function addAgent(agentSchema) {
|
|
|
20107
20119
|
return addAgentInternal(agentSchema);
|
|
20108
20120
|
}
|
|
20109
20121
|
|
|
20122
|
+
/**
|
|
20123
|
+
* Maps a completion schema by wrapping its `getCompletion` method with error handling.
|
|
20124
|
+
* If an error occurs during the execution of `getCompletion`, it emits the error using `errorSubject`.
|
|
20125
|
+
* Also removes any undefined properties from the resulting schema object.
|
|
20126
|
+
*
|
|
20127
|
+
* @param {ICompletionSchema} param0 - The completion schema object containing a `getCompletion` function and other properties.
|
|
20128
|
+
* @returns {ICompletionSchema} - The new completion schema with error-handled `getCompletion` and no undefined properties.
|
|
20129
|
+
*/
|
|
20130
|
+
const mapCompletionSchema = ({ getCompletion, ...schema }) => removeUndefined({
|
|
20131
|
+
...schema,
|
|
20132
|
+
getCompletion: getCompletion
|
|
20133
|
+
? async ({ mode, messages, agentName, clientId, format, outlineName, tools, }) => {
|
|
20134
|
+
const params = {
|
|
20135
|
+
mode,
|
|
20136
|
+
messages,
|
|
20137
|
+
agentName,
|
|
20138
|
+
clientId,
|
|
20139
|
+
format,
|
|
20140
|
+
outlineName,
|
|
20141
|
+
tools,
|
|
20142
|
+
};
|
|
20143
|
+
try {
|
|
20144
|
+
return await getCompletion(params);
|
|
20145
|
+
}
|
|
20146
|
+
catch (error) {
|
|
20147
|
+
if (clientId) {
|
|
20148
|
+
errorSubject.next([clientId, error]);
|
|
20149
|
+
}
|
|
20150
|
+
return {
|
|
20151
|
+
agentName,
|
|
20152
|
+
content: "",
|
|
20153
|
+
mode,
|
|
20154
|
+
role: "assistant",
|
|
20155
|
+
};
|
|
20156
|
+
}
|
|
20157
|
+
}
|
|
20158
|
+
: undefined,
|
|
20159
|
+
});
|
|
20160
|
+
|
|
20110
20161
|
const METHOD_NAME$1e = "function.setup.addCompletion";
|
|
20111
20162
|
/**
|
|
20112
20163
|
* Function implementation
|
|
20113
20164
|
*/
|
|
20114
|
-
const addCompletionInternal = beginContext((
|
|
20165
|
+
const addCompletionInternal = beginContext((completionPublicSchema) => {
|
|
20115
20166
|
// Log the operation details if logging is enabled in GLOBAL_CONFIG
|
|
20116
20167
|
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
|
|
20117
20168
|
swarm$1.loggerService.log(METHOD_NAME$1e, {
|
|
20118
|
-
completionSchema,
|
|
20169
|
+
completionSchema: completionPublicSchema,
|
|
20119
20170
|
});
|
|
20171
|
+
const completionSchema = mapCompletionSchema(completionPublicSchema);
|
|
20120
20172
|
// Register the completion in the validation and schema services
|
|
20121
20173
|
swarm$1.completionValidationService.addCompletion(completionSchema.completionName);
|
|
20122
20174
|
swarm$1.completionSchemaService.register(completionSchema.completionName, completionSchema);
|
|
@@ -20498,7 +20550,7 @@ const overrideCompletionInternal = beginContext((publicCompletionSchema) => {
|
|
|
20498
20550
|
swarm$1.loggerService.log(METHOD_NAME$14, {
|
|
20499
20551
|
completionSchema: publicCompletionSchema,
|
|
20500
20552
|
});
|
|
20501
|
-
const completionSchema =
|
|
20553
|
+
const completionSchema = mapCompletionSchema(publicCompletionSchema);
|
|
20502
20554
|
return swarm$1.completionSchemaService.override(completionSchema.completionName, completionSchema);
|
|
20503
20555
|
});
|
|
20504
20556
|
/**
|
|
@@ -21663,6 +21715,7 @@ const jsonInternal = beginContext(async (outlineName, param) => {
|
|
|
21663
21715
|
swarm$1.loggerService.log(METHOD_NAME$E, {});
|
|
21664
21716
|
swarm$1.outlineValidationService.validate(outlineName, METHOD_NAME$E);
|
|
21665
21717
|
const resultId = randomString();
|
|
21718
|
+
const clientId = `${resultId}_outline`;
|
|
21666
21719
|
const { getOutlineHistory, completion, validations = [], maxAttempts = MAX_ATTEMPTS, format, prompt, system, callbacks: outlineCallbacks, } = swarm$1.outlineSchemaService.get(outlineName);
|
|
21667
21720
|
swarm$1.completionValidationService.validate(completion, METHOD_NAME$E);
|
|
21668
21721
|
const { getCompletion, flags = [], callbacks: completionCallbacks, } = swarm$1.completionSchemaService.get(completion);
|
|
@@ -21706,12 +21759,24 @@ const jsonInternal = beginContext(async (outlineName, param) => {
|
|
|
21706
21759
|
await getOutlineHistory(inputArgs);
|
|
21707
21760
|
const messages = await history.list();
|
|
21708
21761
|
try {
|
|
21709
|
-
|
|
21762
|
+
let output;
|
|
21763
|
+
let errorValue = null;
|
|
21764
|
+
const unError = errorSubject.once(([errorClientId, error]) => {
|
|
21765
|
+
if (clientId === errorClientId) {
|
|
21766
|
+
errorValue = error;
|
|
21767
|
+
}
|
|
21768
|
+
});
|
|
21769
|
+
output = await getCompletion({
|
|
21770
|
+
clientId,
|
|
21710
21771
|
messages: await history.list(),
|
|
21711
21772
|
mode: "tool",
|
|
21712
21773
|
outlineName,
|
|
21713
21774
|
format,
|
|
21714
21775
|
});
|
|
21776
|
+
unError();
|
|
21777
|
+
if (errorValue) {
|
|
21778
|
+
throw errorValue;
|
|
21779
|
+
}
|
|
21715
21780
|
if (completionCallbacks?.onComplete) {
|
|
21716
21781
|
completionCallbacks.onComplete({
|
|
21717
21782
|
messages,
|
|
@@ -26193,6 +26258,60 @@ const toJsonSchema = (name, schema) => ({
|
|
|
26193
26258
|
},
|
|
26194
26259
|
});
|
|
26195
26260
|
|
|
26261
|
+
/**
|
|
26262
|
+
* Validates tool function arguments against a JSON schema
|
|
26263
|
+
*
|
|
26264
|
+
* @param parsedArguments - Already parsed arguments object
|
|
26265
|
+
* @param schema - JSON schema to validate against
|
|
26266
|
+
* @returns Validation result with validated data or error message
|
|
26267
|
+
*
|
|
26268
|
+
* @example
|
|
26269
|
+
* ```typescript
|
|
26270
|
+
* const result = validateToolArguments({ name: "test" }, {
|
|
26271
|
+
* type: "object",
|
|
26272
|
+
* required: ["name"],
|
|
26273
|
+
* properties: { name: { type: "string" } }
|
|
26274
|
+
* });
|
|
26275
|
+
*
|
|
26276
|
+
* if (result.success) {
|
|
26277
|
+
* console.log(result.data); // { name: "test" }
|
|
26278
|
+
* } else {
|
|
26279
|
+
* console.error(result.error);
|
|
26280
|
+
* }
|
|
26281
|
+
* ```
|
|
26282
|
+
*/
|
|
26283
|
+
const validateToolArguments = (parsedArguments, schema) => {
|
|
26284
|
+
// Check if arguments are null or undefined only when required fields exist
|
|
26285
|
+
if (parsedArguments == null) {
|
|
26286
|
+
if (schema?.required?.length) {
|
|
26287
|
+
return {
|
|
26288
|
+
success: false,
|
|
26289
|
+
error: "Tool call has empty arguments",
|
|
26290
|
+
};
|
|
26291
|
+
}
|
|
26292
|
+
// If no required fields, empty arguments is valid
|
|
26293
|
+
return {
|
|
26294
|
+
success: true,
|
|
26295
|
+
data: {},
|
|
26296
|
+
};
|
|
26297
|
+
}
|
|
26298
|
+
// Validate required fields if schema has them
|
|
26299
|
+
if (schema?.required?.length) {
|
|
26300
|
+
const argumentsObj = parsedArguments;
|
|
26301
|
+
const missingFields = schema.required.filter((field) => !(field in argumentsObj));
|
|
26302
|
+
if (missingFields.length > 0) {
|
|
26303
|
+
return {
|
|
26304
|
+
success: false,
|
|
26305
|
+
error: `Missing required fields: ${missingFields.join(", ")}`,
|
|
26306
|
+
};
|
|
26307
|
+
}
|
|
26308
|
+
}
|
|
26309
|
+
return {
|
|
26310
|
+
success: true,
|
|
26311
|
+
data: parsedArguments,
|
|
26312
|
+
};
|
|
26313
|
+
};
|
|
26314
|
+
|
|
26196
26315
|
const Utils = {
|
|
26197
26316
|
PersistStateUtils,
|
|
26198
26317
|
PersistSwarmUtils,
|
|
@@ -26203,4 +26322,4 @@ const Utils = {
|
|
|
26203
26322
|
PersistEmbeddingUtils,
|
|
26204
26323
|
};
|
|
26205
26324
|
|
|
26206
|
-
export { Adapter, Chat, ChatInstance, Compute, ExecutionContextService, History, HistoryMemoryInstance, HistoryPersistInstance, Logger, LoggerInstance, MCP, MethodContextService, Operator, OperatorInstance, PayloadContextService, PersistAlive, PersistBase, PersistEmbedding, PersistList, PersistMemory, PersistPolicy, PersistState, PersistStorage, PersistSwarm, Policy, RoundRobin, Schema, SchemaContextService, SharedCompute, SharedState, SharedStorage, State, Storage, Utils, addAgent, addAgentNavigation, addCompletion, addCompute, addEmbedding, addMCP, addOutline, addPipeline, addPolicy, addState, addStorage, addSwarm, addTool, addTriageNavigation, addWiki, beginContext, cancelOutput, cancelOutputForce, changeToAgent, changeToDefaultAgent, changeToPrevAgent, commitAssistantMessage, commitAssistantMessageForce, commitDeveloperMessage, commitDeveloperMessageForce, commitFlush, commitFlushForce, commitStopTools, commitStopToolsForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitToolRequest, commitToolRequestForce, commitUserMessage, commitUserMessageForce, complete, createNavigateToAgent, createNavigateToTriageAgent, disposeConnection, dumpAgent, dumpClientPerformance, dumpDocs, dumpPerfomance, dumpSwarm, emit, emitForce, event, execute, executeForce, fork, getAgent, getAgentHistory, getAgentName, getAssistantHistory, getCheckBusy, getCompletion, getCompute, getEmbeding, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getMCP, getNavigationRoute, getPayload, getPipeline, getPolicy, getRawHistory, getSessionContext, getSessionMode, getState, getStorage, getSwarm, getTool, getToolNameForModel, getUserHistory, getWiki, hasNavigation, hasSession, json, listenAgentEvent, listenAgentEventOnce, listenEvent, listenEventOnce, listenExecutionEvent, listenExecutionEventOnce, listenHistoryEvent, listenHistoryEventOnce, listenPolicyEvent, listenPolicyEventOnce, listenSessionEvent, listenSessionEventOnce, listenStateEvent, listenStateEventOnce, listenStorageEvent, listenStorageEventOnce, listenSwarmEvent, listenSwarmEventOnce, makeAutoDispose, makeConnection, markOffline, markOnline, notify, notifyForce, overrideAgent, overrideCompletion, overrideCompute, overrideEmbeding, overrideMCP, overrideOutline, overridePipeline, overridePolicy, overrideState, overrideStorage, overrideSwarm, overrideTool, overrideWiki, question, questionForce, runStateless, runStatelessForce, scope, session, setConfig, startPipeline, swarm, toJsonSchema, validate };
|
|
26325
|
+
export { Adapter, Chat, ChatInstance, Compute, ExecutionContextService, History, HistoryMemoryInstance, HistoryPersistInstance, Logger, LoggerInstance, MCP, MethodContextService, Operator, OperatorInstance, PayloadContextService, PersistAlive, PersistBase, PersistEmbedding, PersistList, PersistMemory, PersistPolicy, PersistState, PersistStorage, PersistSwarm, Policy, RoundRobin, Schema, SchemaContextService, SharedCompute, SharedState, SharedStorage, State, Storage, Utils, addAgent, addAgentNavigation, addCompletion, addCompute, addEmbedding, addMCP, addOutline, addPipeline, addPolicy, addState, addStorage, addSwarm, addTool, addTriageNavigation, addWiki, beginContext, cancelOutput, cancelOutputForce, changeToAgent, changeToDefaultAgent, changeToPrevAgent, commitAssistantMessage, commitAssistantMessageForce, commitDeveloperMessage, commitDeveloperMessageForce, commitFlush, commitFlushForce, commitStopTools, commitStopToolsForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitToolRequest, commitToolRequestForce, commitUserMessage, commitUserMessageForce, complete, createNavigateToAgent, createNavigateToTriageAgent, disposeConnection, dumpAgent, dumpClientPerformance, dumpDocs, dumpPerfomance, dumpSwarm, emit, emitForce, event, execute, executeForce, fork, getAgent, getAgentHistory, getAgentName, getAssistantHistory, getCheckBusy, getCompletion, getCompute, getEmbeding, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getMCP, getNavigationRoute, getPayload, getPipeline, getPolicy, getRawHistory, getSessionContext, getSessionMode, getState, getStorage, getSwarm, getTool, getToolNameForModel, getUserHistory, getWiki, hasNavigation, hasSession, json, listenAgentEvent, listenAgentEventOnce, listenEvent, listenEventOnce, listenExecutionEvent, listenExecutionEventOnce, listenHistoryEvent, listenHistoryEventOnce, listenPolicyEvent, listenPolicyEventOnce, listenSessionEvent, listenSessionEventOnce, listenStateEvent, listenStateEventOnce, listenStorageEvent, listenStorageEventOnce, listenSwarmEvent, listenSwarmEventOnce, makeAutoDispose, makeConnection, markOffline, markOnline, notify, notifyForce, overrideAgent, overrideCompletion, overrideCompute, overrideEmbeding, overrideMCP, overrideOutline, overridePipeline, overridePolicy, overrideState, overrideStorage, overrideSwarm, overrideTool, overrideWiki, question, questionForce, runStateless, runStatelessForce, scope, session, setConfig, startPipeline, swarm, toJsonSchema, validate, validateToolArguments };
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -15920,6 +15920,51 @@ declare function validate(): void;
|
|
|
15920
15920
|
*/
|
|
15921
15921
|
declare const toJsonSchema: (name: string, schema: IOutlineObjectFormat) => IOutlineSchemaFormat;
|
|
15922
15922
|
|
|
15923
|
+
/**
|
|
15924
|
+
* JSON Schema type definition
|
|
15925
|
+
*/
|
|
15926
|
+
interface JsonSchema {
|
|
15927
|
+
type?: string;
|
|
15928
|
+
properties?: Record<string, any>;
|
|
15929
|
+
required?: string[];
|
|
15930
|
+
additionalProperties?: boolean;
|
|
15931
|
+
[key: string]: any;
|
|
15932
|
+
}
|
|
15933
|
+
/**
|
|
15934
|
+
* Result of tool arguments validation
|
|
15935
|
+
*/
|
|
15936
|
+
interface ValidationResult<T = any> {
|
|
15937
|
+
/** Whether validation was successful */
|
|
15938
|
+
success: boolean;
|
|
15939
|
+
/** Parsed and validated data (only present when success is true) */
|
|
15940
|
+
data?: T;
|
|
15941
|
+
/** Error message (only present when success is false) */
|
|
15942
|
+
error?: string;
|
|
15943
|
+
}
|
|
15944
|
+
/**
|
|
15945
|
+
* Validates tool function arguments against a JSON schema
|
|
15946
|
+
*
|
|
15947
|
+
* @param parsedArguments - Already parsed arguments object
|
|
15948
|
+
* @param schema - JSON schema to validate against
|
|
15949
|
+
* @returns Validation result with validated data or error message
|
|
15950
|
+
*
|
|
15951
|
+
* @example
|
|
15952
|
+
* ```typescript
|
|
15953
|
+
* const result = validateToolArguments({ name: "test" }, {
|
|
15954
|
+
* type: "object",
|
|
15955
|
+
* required: ["name"],
|
|
15956
|
+
* properties: { name: { type: "string" } }
|
|
15957
|
+
* });
|
|
15958
|
+
*
|
|
15959
|
+
* if (result.success) {
|
|
15960
|
+
* console.log(result.data); // { name: "test" }
|
|
15961
|
+
* } else {
|
|
15962
|
+
* console.error(result.error);
|
|
15963
|
+
* }
|
|
15964
|
+
* ```
|
|
15965
|
+
*/
|
|
15966
|
+
declare const validateToolArguments: <T = any>(parsedArguments: unknown, schema: JsonSchema) => ValidationResult<T>;
|
|
15967
|
+
|
|
15923
15968
|
declare const Utils: {
|
|
15924
15969
|
PersistStateUtils: typeof PersistStateUtils;
|
|
15925
15970
|
PersistSwarmUtils: typeof PersistSwarmUtils;
|
|
@@ -15930,4 +15975,4 @@ declare const Utils: {
|
|
|
15930
15975
|
PersistEmbeddingUtils: typeof PersistEmbeddingUtils;
|
|
15931
15976
|
};
|
|
15932
15977
|
|
|
15933
|
-
export { Adapter, Chat, ChatInstance, Compute, type EventSource, ExecutionContextService, History, HistoryMemoryInstance, HistoryPersistInstance, type IAgentSchemaInternal, type IAgentTool, type IBaseEvent, type IBusEvent, type IBusEventContext, type IChatArgs, type IChatInstance, type IChatInstanceCallbacks, type ICompletionArgs, type ICompletionSchema, type IComputeSchema, type ICustomEvent, type IEmbeddingSchema, type IGlobalConfig, type IHistoryAdapter, type IHistoryControl, type IHistoryInstance, type IHistoryInstanceCallbacks, type IIncomingMessage, type ILoggerAdapter, type ILoggerInstance, type ILoggerInstanceCallbacks, type IMCPSchema, type IMCPTool, type IMCPToolCallDto, type IMakeConnectionConfig, type IMakeDisposeParams, type IModelMessage, type INavigateToAgentParams, type INavigateToTriageParams, type IOutgoingMessage, type IOutlineFormat, type IOutlineHistory, type IOutlineMessage, type IOutlineObjectFormat, type IOutlineResult, type IOutlineSchema, type IOutlineSchemaFormat, type IOutlineValidationFn, type IPersistActiveAgentData, type IPersistAliveData, type IPersistBase, type IPersistEmbeddingData, type IPersistMemoryData, type IPersistNavigationStackData, type IPersistPolicyData, type IPersistStateData, type IPersistStorageData, type IPipelineSchema, type IPolicySchema, type ISessionConfig, type IStateSchema, type IStorageData, type IStorageSchema, type ISwarmSchema, type ITool, type IToolCall, type IWikiSchema, Logger, LoggerInstance, MCP, type MCPToolProperties, MethodContextService, Operator, OperatorInstance, PayloadContextService, PersistAlive, PersistBase, PersistEmbedding, PersistList, PersistMemory, PersistPolicy, PersistState, PersistStorage, PersistSwarm, Policy, type ReceiveMessageFn, RoundRobin, Schema, SchemaContextService, type SendMessageFn, SharedCompute, SharedState, SharedStorage, State, Storage, type THistoryInstanceCtor, type THistoryMemoryInstance, type THistoryPersistInstance, type TLoggerInstance, type TOperatorInstance, type TPersistBase, type TPersistBaseCtor, type TPersistList, type ToolValue, Utils, addAgent, addAgentNavigation, addCompletion, addCompute, addEmbedding, addMCP, addOutline, addPipeline, addPolicy, addState, addStorage, addSwarm, addTool, addTriageNavigation, addWiki, beginContext, cancelOutput, cancelOutputForce, changeToAgent, changeToDefaultAgent, changeToPrevAgent, commitAssistantMessage, commitAssistantMessageForce, commitDeveloperMessage, commitDeveloperMessageForce, commitFlush, commitFlushForce, commitStopTools, commitStopToolsForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitToolRequest, commitToolRequestForce, commitUserMessage, commitUserMessageForce, complete, createNavigateToAgent, createNavigateToTriageAgent, disposeConnection, dumpAgent, dumpClientPerformance, dumpDocs, dumpPerfomance, dumpSwarm, emit, emitForce, event, execute, executeForce, fork, getAgent, getAgentHistory, getAgentName, getAssistantHistory, getCheckBusy, getCompletion, getCompute, getEmbeding, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getMCP, getNavigationRoute, getPayload, getPipeline, getPolicy, getRawHistory, getSessionContext, getSessionMode, getState, getStorage, getSwarm, getTool, getToolNameForModel, getUserHistory, getWiki, hasNavigation, hasSession, json, listenAgentEvent, listenAgentEventOnce, listenEvent, listenEventOnce, listenExecutionEvent, listenExecutionEventOnce, listenHistoryEvent, listenHistoryEventOnce, listenPolicyEvent, listenPolicyEventOnce, listenSessionEvent, listenSessionEventOnce, listenStateEvent, listenStateEventOnce, listenStorageEvent, listenStorageEventOnce, listenSwarmEvent, listenSwarmEventOnce, makeAutoDispose, makeConnection, markOffline, markOnline, notify, notifyForce, overrideAgent, overrideCompletion, overrideCompute, overrideEmbeding, overrideMCP, overrideOutline, overridePipeline, overridePolicy, overrideState, overrideStorage, overrideSwarm, overrideTool, overrideWiki, question, questionForce, runStateless, runStatelessForce, scope, session, setConfig, startPipeline, swarm, toJsonSchema, validate };
|
|
15978
|
+
export { Adapter, Chat, ChatInstance, Compute, type EventSource, ExecutionContextService, History, HistoryMemoryInstance, HistoryPersistInstance, type IAgentSchemaInternal, type IAgentTool, type IBaseEvent, type IBusEvent, type IBusEventContext, type IChatArgs, type IChatInstance, type IChatInstanceCallbacks, type ICompletionArgs, type ICompletionSchema, type IComputeSchema, type ICustomEvent, type IEmbeddingSchema, type IGlobalConfig, type IHistoryAdapter, type IHistoryControl, type IHistoryInstance, type IHistoryInstanceCallbacks, type IIncomingMessage, type ILoggerAdapter, type ILoggerInstance, type ILoggerInstanceCallbacks, type IMCPSchema, type IMCPTool, type IMCPToolCallDto, type IMakeConnectionConfig, type IMakeDisposeParams, type IModelMessage, type INavigateToAgentParams, type INavigateToTriageParams, type IOutgoingMessage, type IOutlineFormat, type IOutlineHistory, type IOutlineMessage, type IOutlineObjectFormat, type IOutlineResult, type IOutlineSchema, type IOutlineSchemaFormat, type IOutlineValidationFn, type IPersistActiveAgentData, type IPersistAliveData, type IPersistBase, type IPersistEmbeddingData, type IPersistMemoryData, type IPersistNavigationStackData, type IPersistPolicyData, type IPersistStateData, type IPersistStorageData, type IPipelineSchema, type IPolicySchema, type ISessionConfig, type IStateSchema, type IStorageData, type IStorageSchema, type ISwarmSchema, type ITool, type IToolCall, type IWikiSchema, Logger, LoggerInstance, MCP, type MCPToolProperties, MethodContextService, Operator, OperatorInstance, PayloadContextService, PersistAlive, PersistBase, PersistEmbedding, PersistList, PersistMemory, PersistPolicy, PersistState, PersistStorage, PersistSwarm, Policy, type ReceiveMessageFn, RoundRobin, Schema, SchemaContextService, type SendMessageFn, SharedCompute, SharedState, SharedStorage, State, Storage, type THistoryInstanceCtor, type THistoryMemoryInstance, type THistoryPersistInstance, type TLoggerInstance, type TOperatorInstance, type TPersistBase, type TPersistBaseCtor, type TPersistList, type ToolValue, Utils, addAgent, addAgentNavigation, addCompletion, addCompute, addEmbedding, addMCP, addOutline, addPipeline, addPolicy, addState, addStorage, addSwarm, addTool, addTriageNavigation, addWiki, beginContext, cancelOutput, cancelOutputForce, changeToAgent, changeToDefaultAgent, changeToPrevAgent, commitAssistantMessage, commitAssistantMessageForce, commitDeveloperMessage, commitDeveloperMessageForce, commitFlush, commitFlushForce, commitStopTools, commitStopToolsForce, commitSystemMessage, commitSystemMessageForce, commitToolOutput, commitToolOutputForce, commitToolRequest, commitToolRequestForce, commitUserMessage, commitUserMessageForce, complete, createNavigateToAgent, createNavigateToTriageAgent, disposeConnection, dumpAgent, dumpClientPerformance, dumpDocs, dumpPerfomance, dumpSwarm, emit, emitForce, event, execute, executeForce, fork, getAgent, getAgentHistory, getAgentName, getAssistantHistory, getCheckBusy, getCompletion, getCompute, getEmbeding, getLastAssistantMessage, getLastSystemMessage, getLastUserMessage, getMCP, getNavigationRoute, getPayload, getPipeline, getPolicy, getRawHistory, getSessionContext, getSessionMode, getState, getStorage, getSwarm, getTool, getToolNameForModel, getUserHistory, getWiki, hasNavigation, hasSession, json, listenAgentEvent, listenAgentEventOnce, listenEvent, listenEventOnce, listenExecutionEvent, listenExecutionEventOnce, listenHistoryEvent, listenHistoryEventOnce, listenPolicyEvent, listenPolicyEventOnce, listenSessionEvent, listenSessionEventOnce, listenStateEvent, listenStateEventOnce, listenStorageEvent, listenStorageEventOnce, listenSwarmEvent, listenSwarmEventOnce, makeAutoDispose, makeConnection, markOffline, markOnline, notify, notifyForce, overrideAgent, overrideCompletion, overrideCompute, overrideEmbeding, overrideMCP, overrideOutline, overridePipeline, overridePolicy, overrideState, overrideStorage, overrideSwarm, overrideTool, overrideWiki, question, questionForce, runStateless, runStatelessForce, scope, session, setConfig, startPipeline, swarm, toJsonSchema, validate, validateToolArguments };
|