agent-swarm-kit 1.1.141 → 1.1.143
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 +141 -0
- package/build/index.mjs +141 -1
- package/package.json +1 -1
- package/types.d.ts +53 -1
package/build/index.cjs
CHANGED
|
@@ -25653,6 +25653,92 @@ const RETRY_DELAY = 5000;
|
|
|
25653
25653
|
*/
|
|
25654
25654
|
class AdapterUtils {
|
|
25655
25655
|
constructor() {
|
|
25656
|
+
/**
|
|
25657
|
+
* Creates a function to interact with Hugging Face Inference API chat completions.
|
|
25658
|
+
* @param {any} inferenceClient - The Hugging Face inference client instance.
|
|
25659
|
+
* @param {string} [model="openai/gpt-oss-120b"] - The model to use for completions (defaults to "openai/gpt-oss-120b").
|
|
25660
|
+
* @returns {TCompleteFn} A function that processes completion arguments and returns a response from Hugging Face.
|
|
25661
|
+
*/
|
|
25662
|
+
this.fromHf = (inferenceClient, model = "openai/gpt-oss-120b") =>
|
|
25663
|
+
/**
|
|
25664
|
+
* Handles a completion request to Hugging Face, transforming messages and tools into the required format.
|
|
25665
|
+
* Executes requests in a pool to limit concurrency with retry logic for reliability.
|
|
25666
|
+
* @param {ICompletionArgs} args - The arguments for the completion request.
|
|
25667
|
+
* @param {string} args.agentName - The name of the agent making the request.
|
|
25668
|
+
* @param {IModelMessage[]} args.messages - The array of messages to send to Hugging Face.
|
|
25669
|
+
* @param {string} args.mode - The mode of the completion (e.g., "user" or "tool").
|
|
25670
|
+
* @param {any[]} args.tools - The tools available for the completion, if any.
|
|
25671
|
+
* @param {string} args.clientId - The ID of the client making the request.
|
|
25672
|
+
* @returns {Promise<IModelMessage>} The response from Hugging Face in `agent-swarm-kit` format.
|
|
25673
|
+
*/
|
|
25674
|
+
functoolsKit.execpool(functoolsKit.retry(async ({ agentName, messages: rawMessages, mode, tools: rawTools, clientId, }) => {
|
|
25675
|
+
LoggerAdapter.logClient(clientId, "AdapterUtils fromHf completion", JSON.stringify(rawMessages));
|
|
25676
|
+
const messages = rawMessages.map(({ role, content, tool_calls, tool_call_id }) => {
|
|
25677
|
+
if (role === "tool") {
|
|
25678
|
+
return {
|
|
25679
|
+
role: "tool",
|
|
25680
|
+
content,
|
|
25681
|
+
tool_call_id: tool_call_id,
|
|
25682
|
+
};
|
|
25683
|
+
}
|
|
25684
|
+
if (role === "assistant" && tool_calls) {
|
|
25685
|
+
return {
|
|
25686
|
+
role: "assistant",
|
|
25687
|
+
content,
|
|
25688
|
+
tool_calls: tool_calls.map((tc) => ({
|
|
25689
|
+
id: tc.id,
|
|
25690
|
+
type: tc.type,
|
|
25691
|
+
function: {
|
|
25692
|
+
name: tc.function.name,
|
|
25693
|
+
arguments: typeof tc.function.arguments === "string"
|
|
25694
|
+
? tc.function.arguments
|
|
25695
|
+
: JSON.stringify(tc.function.arguments),
|
|
25696
|
+
},
|
|
25697
|
+
})),
|
|
25698
|
+
};
|
|
25699
|
+
}
|
|
25700
|
+
return {
|
|
25701
|
+
role: role,
|
|
25702
|
+
content,
|
|
25703
|
+
};
|
|
25704
|
+
});
|
|
25705
|
+
const tools = rawTools?.map(({ function: f }) => ({
|
|
25706
|
+
type: "function",
|
|
25707
|
+
function: {
|
|
25708
|
+
name: f.name,
|
|
25709
|
+
description: f.description,
|
|
25710
|
+
parameters: f.parameters,
|
|
25711
|
+
},
|
|
25712
|
+
}));
|
|
25713
|
+
const completion = await inferenceClient.chatCompletion({
|
|
25714
|
+
model,
|
|
25715
|
+
messages,
|
|
25716
|
+
...(tools && { tools }),
|
|
25717
|
+
});
|
|
25718
|
+
const choice = completion.choices[0];
|
|
25719
|
+
const text = choice.message.content || "";
|
|
25720
|
+
const tool_calls = choice.message.tool_calls || [];
|
|
25721
|
+
const result = {
|
|
25722
|
+
content: text,
|
|
25723
|
+
mode,
|
|
25724
|
+
agentName: agentName,
|
|
25725
|
+
role: "assistant",
|
|
25726
|
+
tool_calls: tool_calls.map(({ id, type, function: f }) => ({
|
|
25727
|
+
id: id,
|
|
25728
|
+
type: type,
|
|
25729
|
+
function: {
|
|
25730
|
+
name: f.name,
|
|
25731
|
+
arguments: typeof f.arguments === "string"
|
|
25732
|
+
? JSON.parse(f.arguments)
|
|
25733
|
+
: f.arguments,
|
|
25734
|
+
},
|
|
25735
|
+
})),
|
|
25736
|
+
};
|
|
25737
|
+
return result;
|
|
25738
|
+
}, RETRY_COUNT, RETRY_DELAY), {
|
|
25739
|
+
maxExec: EXECPOOL_SIZE,
|
|
25740
|
+
delay: EXECPOOL_WAIT,
|
|
25741
|
+
});
|
|
25656
25742
|
/**
|
|
25657
25743
|
* Creates a function to interact with Cortex's chat completions API.
|
|
25658
25744
|
* @param {string} [model="tripolskypetr:gemma-3-12b-it:gemma-3-12b-it-Q4_K_S.gguf"] - The model to use for completions.
|
|
@@ -26109,6 +26195,60 @@ const toJsonSchema = (name, schema) => ({
|
|
|
26109
26195
|
},
|
|
26110
26196
|
});
|
|
26111
26197
|
|
|
26198
|
+
/**
|
|
26199
|
+
* Validates tool function arguments against a JSON schema
|
|
26200
|
+
*
|
|
26201
|
+
* @param parsedArguments - Already parsed arguments object
|
|
26202
|
+
* @param schema - JSON schema to validate against
|
|
26203
|
+
* @returns Validation result with validated data or error message
|
|
26204
|
+
*
|
|
26205
|
+
* @example
|
|
26206
|
+
* ```typescript
|
|
26207
|
+
* const result = validateToolArguments({ name: "test" }, {
|
|
26208
|
+
* type: "object",
|
|
26209
|
+
* required: ["name"],
|
|
26210
|
+
* properties: { name: { type: "string" } }
|
|
26211
|
+
* });
|
|
26212
|
+
*
|
|
26213
|
+
* if (result.success) {
|
|
26214
|
+
* console.log(result.data); // { name: "test" }
|
|
26215
|
+
* } else {
|
|
26216
|
+
* console.error(result.error);
|
|
26217
|
+
* }
|
|
26218
|
+
* ```
|
|
26219
|
+
*/
|
|
26220
|
+
const validateToolArguments = (parsedArguments, schema) => {
|
|
26221
|
+
// Check if arguments are null or undefined only when required fields exist
|
|
26222
|
+
if (parsedArguments == null) {
|
|
26223
|
+
if (schema?.required?.length) {
|
|
26224
|
+
return {
|
|
26225
|
+
success: false,
|
|
26226
|
+
error: "Tool call has empty arguments",
|
|
26227
|
+
};
|
|
26228
|
+
}
|
|
26229
|
+
// If no required fields, empty arguments is valid
|
|
26230
|
+
return {
|
|
26231
|
+
success: true,
|
|
26232
|
+
data: {},
|
|
26233
|
+
};
|
|
26234
|
+
}
|
|
26235
|
+
// Validate required fields if schema has them
|
|
26236
|
+
if (schema?.required?.length) {
|
|
26237
|
+
const argumentsObj = parsedArguments;
|
|
26238
|
+
const missingFields = schema.required.filter((field) => !(field in argumentsObj));
|
|
26239
|
+
if (missingFields.length > 0) {
|
|
26240
|
+
return {
|
|
26241
|
+
success: false,
|
|
26242
|
+
error: `Missing required fields: ${missingFields.join(", ")}`,
|
|
26243
|
+
};
|
|
26244
|
+
}
|
|
26245
|
+
}
|
|
26246
|
+
return {
|
|
26247
|
+
success: true,
|
|
26248
|
+
data: parsedArguments,
|
|
26249
|
+
};
|
|
26250
|
+
};
|
|
26251
|
+
|
|
26112
26252
|
const Utils = {
|
|
26113
26253
|
PersistStateUtils,
|
|
26114
26254
|
PersistSwarmUtils,
|
|
@@ -26282,3 +26422,4 @@ exports.startPipeline = startPipeline;
|
|
|
26282
26422
|
exports.swarm = swarm;
|
|
26283
26423
|
exports.toJsonSchema = toJsonSchema;
|
|
26284
26424
|
exports.validate = validate;
|
|
26425
|
+
exports.validateToolArguments = validateToolArguments;
|
package/build/index.mjs
CHANGED
|
@@ -25651,6 +25651,92 @@ const RETRY_DELAY = 5000;
|
|
|
25651
25651
|
*/
|
|
25652
25652
|
class AdapterUtils {
|
|
25653
25653
|
constructor() {
|
|
25654
|
+
/**
|
|
25655
|
+
* Creates a function to interact with Hugging Face Inference API chat completions.
|
|
25656
|
+
* @param {any} inferenceClient - The Hugging Face inference client instance.
|
|
25657
|
+
* @param {string} [model="openai/gpt-oss-120b"] - The model to use for completions (defaults to "openai/gpt-oss-120b").
|
|
25658
|
+
* @returns {TCompleteFn} A function that processes completion arguments and returns a response from Hugging Face.
|
|
25659
|
+
*/
|
|
25660
|
+
this.fromHf = (inferenceClient, model = "openai/gpt-oss-120b") =>
|
|
25661
|
+
/**
|
|
25662
|
+
* Handles a completion request to Hugging Face, transforming messages and tools into the required format.
|
|
25663
|
+
* Executes requests in a pool to limit concurrency with retry logic for reliability.
|
|
25664
|
+
* @param {ICompletionArgs} args - The arguments for the completion request.
|
|
25665
|
+
* @param {string} args.agentName - The name of the agent making the request.
|
|
25666
|
+
* @param {IModelMessage[]} args.messages - The array of messages to send to Hugging Face.
|
|
25667
|
+
* @param {string} args.mode - The mode of the completion (e.g., "user" or "tool").
|
|
25668
|
+
* @param {any[]} args.tools - The tools available for the completion, if any.
|
|
25669
|
+
* @param {string} args.clientId - The ID of the client making the request.
|
|
25670
|
+
* @returns {Promise<IModelMessage>} The response from Hugging Face in `agent-swarm-kit` format.
|
|
25671
|
+
*/
|
|
25672
|
+
execpool(retry(async ({ agentName, messages: rawMessages, mode, tools: rawTools, clientId, }) => {
|
|
25673
|
+
LoggerAdapter.logClient(clientId, "AdapterUtils fromHf completion", JSON.stringify(rawMessages));
|
|
25674
|
+
const messages = rawMessages.map(({ role, content, tool_calls, tool_call_id }) => {
|
|
25675
|
+
if (role === "tool") {
|
|
25676
|
+
return {
|
|
25677
|
+
role: "tool",
|
|
25678
|
+
content,
|
|
25679
|
+
tool_call_id: tool_call_id,
|
|
25680
|
+
};
|
|
25681
|
+
}
|
|
25682
|
+
if (role === "assistant" && tool_calls) {
|
|
25683
|
+
return {
|
|
25684
|
+
role: "assistant",
|
|
25685
|
+
content,
|
|
25686
|
+
tool_calls: tool_calls.map((tc) => ({
|
|
25687
|
+
id: tc.id,
|
|
25688
|
+
type: tc.type,
|
|
25689
|
+
function: {
|
|
25690
|
+
name: tc.function.name,
|
|
25691
|
+
arguments: typeof tc.function.arguments === "string"
|
|
25692
|
+
? tc.function.arguments
|
|
25693
|
+
: JSON.stringify(tc.function.arguments),
|
|
25694
|
+
},
|
|
25695
|
+
})),
|
|
25696
|
+
};
|
|
25697
|
+
}
|
|
25698
|
+
return {
|
|
25699
|
+
role: role,
|
|
25700
|
+
content,
|
|
25701
|
+
};
|
|
25702
|
+
});
|
|
25703
|
+
const tools = rawTools?.map(({ function: f }) => ({
|
|
25704
|
+
type: "function",
|
|
25705
|
+
function: {
|
|
25706
|
+
name: f.name,
|
|
25707
|
+
description: f.description,
|
|
25708
|
+
parameters: f.parameters,
|
|
25709
|
+
},
|
|
25710
|
+
}));
|
|
25711
|
+
const completion = await inferenceClient.chatCompletion({
|
|
25712
|
+
model,
|
|
25713
|
+
messages,
|
|
25714
|
+
...(tools && { tools }),
|
|
25715
|
+
});
|
|
25716
|
+
const choice = completion.choices[0];
|
|
25717
|
+
const text = choice.message.content || "";
|
|
25718
|
+
const tool_calls = choice.message.tool_calls || [];
|
|
25719
|
+
const result = {
|
|
25720
|
+
content: text,
|
|
25721
|
+
mode,
|
|
25722
|
+
agentName: agentName,
|
|
25723
|
+
role: "assistant",
|
|
25724
|
+
tool_calls: tool_calls.map(({ id, type, function: f }) => ({
|
|
25725
|
+
id: id,
|
|
25726
|
+
type: type,
|
|
25727
|
+
function: {
|
|
25728
|
+
name: f.name,
|
|
25729
|
+
arguments: typeof f.arguments === "string"
|
|
25730
|
+
? JSON.parse(f.arguments)
|
|
25731
|
+
: f.arguments,
|
|
25732
|
+
},
|
|
25733
|
+
})),
|
|
25734
|
+
};
|
|
25735
|
+
return result;
|
|
25736
|
+
}, RETRY_COUNT, RETRY_DELAY), {
|
|
25737
|
+
maxExec: EXECPOOL_SIZE,
|
|
25738
|
+
delay: EXECPOOL_WAIT,
|
|
25739
|
+
});
|
|
25654
25740
|
/**
|
|
25655
25741
|
* Creates a function to interact with Cortex's chat completions API.
|
|
25656
25742
|
* @param {string} [model="tripolskypetr:gemma-3-12b-it:gemma-3-12b-it-Q4_K_S.gguf"] - The model to use for completions.
|
|
@@ -26107,6 +26193,60 @@ const toJsonSchema = (name, schema) => ({
|
|
|
26107
26193
|
},
|
|
26108
26194
|
});
|
|
26109
26195
|
|
|
26196
|
+
/**
|
|
26197
|
+
* Validates tool function arguments against a JSON schema
|
|
26198
|
+
*
|
|
26199
|
+
* @param parsedArguments - Already parsed arguments object
|
|
26200
|
+
* @param schema - JSON schema to validate against
|
|
26201
|
+
* @returns Validation result with validated data or error message
|
|
26202
|
+
*
|
|
26203
|
+
* @example
|
|
26204
|
+
* ```typescript
|
|
26205
|
+
* const result = validateToolArguments({ name: "test" }, {
|
|
26206
|
+
* type: "object",
|
|
26207
|
+
* required: ["name"],
|
|
26208
|
+
* properties: { name: { type: "string" } }
|
|
26209
|
+
* });
|
|
26210
|
+
*
|
|
26211
|
+
* if (result.success) {
|
|
26212
|
+
* console.log(result.data); // { name: "test" }
|
|
26213
|
+
* } else {
|
|
26214
|
+
* console.error(result.error);
|
|
26215
|
+
* }
|
|
26216
|
+
* ```
|
|
26217
|
+
*/
|
|
26218
|
+
const validateToolArguments = (parsedArguments, schema) => {
|
|
26219
|
+
// Check if arguments are null or undefined only when required fields exist
|
|
26220
|
+
if (parsedArguments == null) {
|
|
26221
|
+
if (schema?.required?.length) {
|
|
26222
|
+
return {
|
|
26223
|
+
success: false,
|
|
26224
|
+
error: "Tool call has empty arguments",
|
|
26225
|
+
};
|
|
26226
|
+
}
|
|
26227
|
+
// If no required fields, empty arguments is valid
|
|
26228
|
+
return {
|
|
26229
|
+
success: true,
|
|
26230
|
+
data: {},
|
|
26231
|
+
};
|
|
26232
|
+
}
|
|
26233
|
+
// Validate required fields if schema has them
|
|
26234
|
+
if (schema?.required?.length) {
|
|
26235
|
+
const argumentsObj = parsedArguments;
|
|
26236
|
+
const missingFields = schema.required.filter((field) => !(field in argumentsObj));
|
|
26237
|
+
if (missingFields.length > 0) {
|
|
26238
|
+
return {
|
|
26239
|
+
success: false,
|
|
26240
|
+
error: `Missing required fields: ${missingFields.join(", ")}`,
|
|
26241
|
+
};
|
|
26242
|
+
}
|
|
26243
|
+
}
|
|
26244
|
+
return {
|
|
26245
|
+
success: true,
|
|
26246
|
+
data: parsedArguments,
|
|
26247
|
+
};
|
|
26248
|
+
};
|
|
26249
|
+
|
|
26110
26250
|
const Utils = {
|
|
26111
26251
|
PersistStateUtils,
|
|
26112
26252
|
PersistSwarmUtils,
|
|
@@ -26117,4 +26257,4 @@ const Utils = {
|
|
|
26117
26257
|
PersistEmbeddingUtils,
|
|
26118
26258
|
};
|
|
26119
26259
|
|
|
26120
|
-
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 };
|
|
26260
|
+
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
|
@@ -15799,6 +15799,13 @@ type TCompleteFn = (args: ICompletionArgs) => Promise<IModelMessage>;
|
|
|
15799
15799
|
* Utility class providing adapter functions for interacting with various AI completion providers.
|
|
15800
15800
|
*/
|
|
15801
15801
|
declare class AdapterUtils {
|
|
15802
|
+
/**
|
|
15803
|
+
* Creates a function to interact with Hugging Face Inference API chat completions.
|
|
15804
|
+
* @param {any} inferenceClient - The Hugging Face inference client instance.
|
|
15805
|
+
* @param {string} [model="openai/gpt-oss-120b"] - The model to use for completions (defaults to "openai/gpt-oss-120b").
|
|
15806
|
+
* @returns {TCompleteFn} A function that processes completion arguments and returns a response from Hugging Face.
|
|
15807
|
+
*/
|
|
15808
|
+
fromHf: (inferenceClient: any, model?: string) => TCompleteFn;
|
|
15802
15809
|
/**
|
|
15803
15810
|
* Creates a function to interact with Cortex's chat completions API.
|
|
15804
15811
|
* @param {string} [model="tripolskypetr:gemma-3-12b-it:gemma-3-12b-it-Q4_K_S.gguf"] - The model to use for completions.
|
|
@@ -15913,6 +15920,51 @@ declare function validate(): void;
|
|
|
15913
15920
|
*/
|
|
15914
15921
|
declare const toJsonSchema: (name: string, schema: IOutlineObjectFormat) => IOutlineSchemaFormat;
|
|
15915
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
|
+
|
|
15916
15968
|
declare const Utils: {
|
|
15917
15969
|
PersistStateUtils: typeof PersistStateUtils;
|
|
15918
15970
|
PersistSwarmUtils: typeof PersistSwarmUtils;
|
|
@@ -15923,4 +15975,4 @@ declare const Utils: {
|
|
|
15923
15975
|
PersistEmbeddingUtils: typeof PersistEmbeddingUtils;
|
|
15924
15976
|
};
|
|
15925
15977
|
|
|
15926
|
-
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 };
|