Skip to content

Commit 977bae5

Browse files
committed
types
1 parent 4680288 commit 977bae5

4 files changed

Lines changed: 35 additions & 29 deletions

File tree

src/functions/test/overrideCompute.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @description Provides a function to override an existing compute schema with partial updates.
44
*/
55

6-
import { IComputeSchema } from "../../interfaces/Compute.interface";
6+
import { IComputeData, IComputeSchema } from "../../interfaces/Compute.interface";
77
import swarm from "../../lib";
88
import { GLOBAL_CONFIG } from "../../config/params";
99
import beginContext from "../../utils/beginContext";
@@ -20,9 +20,9 @@ const METHOD_NAME = "function.test.overrideCompute";
2020
* @type TComputeSchema
2121
* @description Type for partial compute schema updates, requiring computeName and allowing other IComputeSchema properties.
2222
*/
23-
type TComputeSchema = {
24-
computeName: IComputeSchema["computeName"];
25-
} & Partial<IComputeSchema>;
23+
type TComputeSchema<T extends IComputeData = any> = {
24+
computeName: IComputeSchema<T>["computeName"];
25+
} & Partial<IComputeSchema<T>>;
2626

2727
/**
2828
* Function implementation
@@ -43,6 +43,6 @@ const overrideComputeInternal = beginContext((publicComputeSchema: TComputeSchem
4343
* @param {TComputeSchema} computeSchema - The partial compute schema with updates.
4444
* @returns {IComputeSchema} The updated compute schema.
4545
*/
46-
export function overrideCompute(computeSchema: TComputeSchema) {
46+
export function overrideCompute<T extends IComputeData = any>(computeSchema: TComputeSchema<T>) {
4747
return overrideComputeInternal(computeSchema)
4848
}

src/functions/test/overrideOutline.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IOutlineSchema } from "../../interfaces/Outline.interface";
1+
import { IOutlineData, IOutlineParam, IOutlineSchema } from "../../interfaces/Outline.interface";
22
import swarm from "../../lib";
33
import { GLOBAL_CONFIG } from "../../config/params";
44
import beginContext from "../../utils/beginContext";
@@ -19,9 +19,12 @@ const METHOD_NAME = "function.test.overrideOutline";
1919
* @property {IOutlineSchema["outlineName"]} outlineName - The unique name of the outline to override.
2020
* @property {Partial<IOutlineSchema>} [partial] - Optional partial properties of the `IOutlineSchema` to override.
2121
*/
22-
type TOutlineSchema = {
23-
outlineName: IOutlineSchema["outlineName"];
24-
} & Partial<IOutlineSchema>;
22+
type TOutlineSchema<
23+
Data extends IOutlineData = IOutlineData,
24+
Param extends IOutlineParam = IOutlineParam
25+
> = {
26+
outlineName: IOutlineSchema<Data, Param>["outlineName"];
27+
} & Partial<IOutlineSchema<Data, Param>>;
2528

2629
/**
2730
* Internal implementation of the outline override logic, wrapped in a clean context.
@@ -35,7 +38,7 @@ const overrideOutlineInternal = beginContext(
3538
swarm.loggerService.log(METHOD_NAME, {
3639
outlineSchema: publicOutlineSchema,
3740
});
38-
41+
3942
const outlineSchema = removeUndefined(publicOutlineSchema);
4043

4144
return swarm.outlineSchemaService.override(
@@ -51,6 +54,9 @@ const overrideOutlineInternal = beginContext(
5154
* Logs the operation if logging is enabled in the global configuration.
5255
* @param {TOutlineSchema} outlineSchema - The partial outline schema containing the outline name and optional schema properties to override.
5356
*/
54-
export function overrideOutline(outlineSchema: TOutlineSchema) {
57+
export function overrideOutline<
58+
Data extends IOutlineData = IOutlineData,
59+
Param extends IOutlineParam = IOutlineParam
60+
>(outlineSchema: TOutlineSchema<Data, Param>) {
5561
return overrideOutlineInternal(outlineSchema);
5662
}

src/functions/test/overrideTool.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { IAgentTool } from "../../interfaces/Agent.interface";
1+
import { IAgentTool, ToolValue } from "../../interfaces/Agent.interface";
22
import swarm from "../../lib";
33
import { GLOBAL_CONFIG } from "../../config/params";
44
import beginContext from "../../utils/beginContext";
55
import removeUndefined from "../../helpers/removeUndefined";
66

77
const METHOD_NAME = "function.test.overrideTool";
88

9-
type TAgentTool = {
10-
toolName: IAgentTool["toolName"];
11-
} & Partial<IAgentTool>;
9+
type TAgentTool<T extends any = Record<string, ToolValue>> = {
10+
toolName: IAgentTool<T>["toolName"];
11+
} & Partial<IAgentTool<T>>;
1212

1313
/**
1414
* Function implementation
1515
*/
16-
const overrideToolInternal = beginContext((publicToolSchema: TAgentTool) => {
16+
const overrideToolInternal = beginContext((publicToolSchema: TAgentTool<unknown>) => {
1717
GLOBAL_CONFIG.CC_LOGGER_ENABLE_LOG &&
1818
swarm.loggerService.log(METHOD_NAME, {
1919
toolSchema: publicToolSchema,
@@ -45,6 +45,6 @@ const overrideToolInternal = beginContext((publicToolSchema: TAgentTool) => {
4545
* });
4646
* // Logs the operation (if enabled) and updates the tool schema in the swarm.
4747
*/
48-
export function overrideTool(toolSchema: TAgentTool) {
48+
export function overrideTool<T extends any = Record<string, ToolValue>>(toolSchema: TAgentTool<T>) {
4949
return overrideToolInternal(toolSchema);
5050
}

types.d.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12464,9 +12464,9 @@ type TSwarmSchema = {
1246412464
*/
1246512465
declare function overrideSwarm(swarmSchema: TSwarmSchema): ISwarmSchema;
1246612466

12467-
type TAgentTool = {
12468-
toolName: IAgentTool["toolName"];
12469-
} & Partial<IAgentTool>;
12467+
type TAgentTool<T extends any = Record<string, ToolValue>> = {
12468+
toolName: IAgentTool<T>["toolName"];
12469+
} & Partial<IAgentTool<T>>;
1247012470
/**
1247112471
* Overrides an existing tool schema in the swarm system with a new or partial schema.
1247212472
* This function updates the configuration of a tool identified by its `toolName`, applying the provided schema properties.
@@ -12488,7 +12488,7 @@ type TAgentTool = {
1248812488
* });
1248912489
* // Logs the operation (if enabled) and updates the tool schema in the swarm.
1249012490
*/
12491-
declare function overrideTool(toolSchema: TAgentTool): IAgentTool<Record<string, ToolValue>>;
12491+
declare function overrideTool<T extends any = Record<string, ToolValue>>(toolSchema: TAgentTool<T>): IAgentTool<Record<string, ToolValue>>;
1249212492

1249312493
/**
1249412494
* Type definition for a partial MCP schema, requiring at least an mcpName.
@@ -12538,15 +12538,15 @@ declare function overrideWiki(wikiSchema: TWikiSchema): IWikiSchema;
1253812538
* @type TComputeSchema
1253912539
* @description Type for partial compute schema updates, requiring computeName and allowing other IComputeSchema properties.
1254012540
*/
12541-
type TComputeSchema = {
12542-
computeName: IComputeSchema["computeName"];
12543-
} & Partial<IComputeSchema>;
12541+
type TComputeSchema<T extends IComputeData = any> = {
12542+
computeName: IComputeSchema<T>["computeName"];
12543+
} & Partial<IComputeSchema<T>>;
1254412544
/**
1254512545
* Overrides an existing compute schema with provided partial updates.
1254612546
* @param {TComputeSchema} computeSchema - The partial compute schema with updates.
1254712547
* @returns {IComputeSchema} The updated compute schema.
1254812548
*/
12549-
declare function overrideCompute(computeSchema: TComputeSchema): IComputeSchema<any>;
12549+
declare function overrideCompute<T extends IComputeData = any>(computeSchema: TComputeSchema<T>): IComputeSchema<any>;
1255012550

1255112551
/**
1255212552
* @module overridePipeline
@@ -12568,16 +12568,16 @@ declare function overridePipeline<Payload extends object = any>(pipelineSchema:
1256812568
* @property {IOutlineSchema["outlineName"]} outlineName - The unique name of the outline to override.
1256912569
* @property {Partial<IOutlineSchema>} [partial] - Optional partial properties of the `IOutlineSchema` to override.
1257012570
*/
12571-
type TOutlineSchema = {
12572-
outlineName: IOutlineSchema["outlineName"];
12573-
} & Partial<IOutlineSchema>;
12571+
type TOutlineSchema<Data extends IOutlineData = IOutlineData, Param extends IOutlineParam = IOutlineParam> = {
12572+
outlineName: IOutlineSchema<Data, Param>["outlineName"];
12573+
} & Partial<IOutlineSchema<Data, Param>>;
1257412574
/**
1257512575
* Overrides an existing outline schema in the swarm system by updating it with the provided partial schema.
1257612576
* Ensures the operation runs in a clean context using `beginContext` to avoid interference from existing method or execution contexts.
1257712577
* Logs the operation if logging is enabled in the global configuration.
1257812578
* @param {TOutlineSchema} outlineSchema - The partial outline schema containing the outline name and optional schema properties to override.
1257912579
*/
12580-
declare function overrideOutline(outlineSchema: TOutlineSchema): IOutlineSchema<any, any>;
12580+
declare function overrideOutline<Data extends IOutlineData = IOutlineData, Param extends IOutlineParam = IOutlineParam>(outlineSchema: TOutlineSchema<Data, Param>): IOutlineSchema<any, any>;
1258112581

1258212582
/**
1258312583
* Marks a client as online in the specified swarm.

0 commit comments

Comments
 (0)