Skip to content

Commit 983a884

Browse files
Merge pull request #57 from tripolskypetr/message-contract
Message contract
2 parents d61af7f + 91cdde5 commit 983a884

76 files changed

Lines changed: 1989 additions & 1513 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/classes/ClientAgent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Useful for external consumers (e.g., SwarmConnectionService) awaiting agent resp
169169
### getCompletion
170170

171171
```ts
172-
getCompletion(mode: ExecutionMode, tools: IAgentTool[]): Promise<IModelMessage>;
172+
getCompletion(mode: ExecutionMode, tools: IAgentTool[]): Promise<ISwarmMessage>;
173173
```
174174

175175
Retrieves a completion message from the model using the current history and tools.

docs/classes/ClientCompute.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ constructor(params: IComputeParams<Compute>);
2323
params: IComputeParams<Compute>
2424
```
2525

26-
### __@DISPOSE_SLOT_FN_SYMBOL@3154
26+
### __@DISPOSE_SLOT_FN_SYMBOL@3157
2727

2828
```ts
29-
__@DISPOSE_SLOT_FN_SYMBOL@3154: any
29+
__@DISPOSE_SLOT_FN_SYMBOL@3157: any
3030
```
3131

3232
Stores the composed dispose function.
3333

34-
### __@GET_COMPUTE_DATA_FN_SYMBOL@3155
34+
### __@GET_COMPUTE_DATA_FN_SYMBOL@3158
3535

3636
```ts
37-
__@GET_COMPUTE_DATA_FN_SYMBOL@3155: any
37+
__@GET_COMPUTE_DATA_FN_SYMBOL@3158: any
3838
```
3939

4040
Memoized function for retrieving compute data.

docs/classes/ClientHistory.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ params: IHistoryParams
3030
### _filterCondition
3131

3232
```ts
33-
_filterCondition: (message: IModelMessage<object>) => boolean
33+
_filterCondition: (message: ISwarmMessage<object>) => boolean
3434
```
3535

3636
Filter condition function for toArrayForAgent, used to filter messages based on agent-specific criteria.
@@ -41,7 +41,7 @@ Initialized from GLOBAL_CONFIG.CC_AGENT_HISTORY_FILTER, applied to common messag
4141
### push
4242

4343
```ts
44-
push<Payload extends object = object>(message: IModelMessage<Payload>): Promise<void>;
44+
push<Payload extends object = object>(message: ISwarmMessage<Payload>): Promise<void>;
4545
```
4646
4747
Pushes a message into the history and emits a corresponding event via BusService.
@@ -50,7 +50,7 @@ Adds the message to the underlying storage (params.items) and notifies the syste
5050
### pop
5151
5252
```ts
53-
pop(): Promise<IModelMessage | null>;
53+
pop(): Promise<ISwarmMessage | null>;
5454
```
5555
5656
Removes and returns the most recent message from the history, emitting an event via BusService.
@@ -60,7 +60,7 @@ Useful for ClientAgent to undo recent actions or inspect the latest entry.
6060
### toArrayForRaw
6161
6262
```ts
63-
toArrayForRaw(): Promise<IModelMessage[]>;
63+
toArrayForRaw(): Promise<ISwarmMessage[]>;
6464
```
6565
6666
Converts the history into an array of raw messages without filtering or transformation.
@@ -69,7 +69,7 @@ Iterates over params.items to collect all messages as-is, useful for debugging o
6969
### toArrayForAgent
7070
7171
```ts
72-
toArrayForAgent(prompt: string, system?: string[]): Promise<IModelMessage[]>;
72+
toArrayForAgent(prompt: string, system?: string[]): Promise<ISwarmMessage[]>;
7373
```
7474
7575
Converts the history into an array of messages tailored for the agent, used by ClientAgent for completions.

docs/classes/ClientState.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ group: docs
55

66
# ClientState
77

8-
Implements `IState<State>`, `IStateChangeContract`
8+
Implements `IState<State>`, `IStateChangeEvent`
99

1010
Class representing the client state in the swarm system, implementing the IState interface.
1111
Manages a single state object with queued read/write operations, middleware support, and event-driven updates via BusService.

docs/classes/CompletionSchemaService.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Supports ClientAgent execution by ensuring completion schema validity before reg
6161
### register
6262

6363
```ts
64-
register: (key: string, value: ICompletionSchema) => void
64+
register: (key: string, value: ICompletionSchema<IBaseMessage<any>>) => void
6565
```
6666

6767
Registers a new completion schema in the registry after validation.
@@ -72,7 +72,7 @@ Supports ClientAgent execution by providing validated completion schemas to Agen
7272
### override
7373

7474
```ts
75-
override: (key: string, value: Partial<ICompletionSchema>) => ICompletionSchema
75+
override: (key: string, value: Partial<ICompletionSchema<IBaseMessage<any>>>) => ICompletionSchema<IBaseMessage<any>>
7676
```
7777

7878
Overrides an existing completion schema in the registry with a new one.
@@ -83,7 +83,7 @@ Supports dynamic updates to completion schemas used by AgentSchemaService, Clien
8383
### get
8484

8585
```ts
86-
get: (key: string) => ICompletionSchema
86+
get: (key: string) => ICompletionSchema<IBaseMessage<any>>
8787
```
8888

8989
Retrieves a completion schema from the registry by its name.

docs/classes/HistoryConnectionService.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Supports ClientAgent (history in EXECUTE_FN), AgentConnectionService (history pr
8080
### push
8181

8282
```ts
83-
push: (message: IModelMessage<object>) => Promise<void>
83+
push: (message: ISwarmMessage<object>) => Promise<void>
8484
```
8585

8686
Pushes a message to the agent’s history.
@@ -90,7 +90,7 @@ Mirrors HistoryPublicService’s push, supporting ClientAgent’s history update
9090
### pop
9191

9292
```ts
93-
pop: () => Promise<IModelMessage<object>>
93+
pop: () => Promise<ISwarmMessage<object>>
9494
```
9595

9696
Pops the most recent message from the agent’s history.
@@ -100,17 +100,17 @@ Mirrors HistoryPublicService’s pop, supporting ClientAgent’s history manipul
100100
### toArrayForAgent
101101

102102
```ts
103-
toArrayForAgent: (prompt: string) => Promise<IModelMessage<object>[]>
103+
toArrayForAgent: (prompt: string) => Promise<ISwarmMessage<object>[]>
104104
```
105105

106-
Converts the agents history to an array formatted for agent use, incorporating a prompt.
106+
Converts the agent's history to an array formatted for agent use, incorporating a prompt.
107107
Delegates to ClientHistory.toArrayForAgent, using context from MethodContextService, logging via LoggerService if GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO is true.
108-
Mirrors HistoryPublicServices toArrayForAgent, supporting ClientAgents execution context (e.g., EXECUTE_FN with prompt).
108+
Mirrors HistoryPublicService's toArrayForAgent, supporting ClientAgent's execution context (e.g., EXECUTE_FN with prompt).
109109

110110
### toArrayForRaw
111111

112112
```ts
113-
toArrayForRaw: () => Promise<IModelMessage<object>[]>
113+
toArrayForRaw: () => Promise<ISwarmMessage<object>[]>
114114
```
115115

116116
Converts the agent’s history to a raw array of messages.

docs/classes/HistoryPublicService.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Provides core functionality (e.g., push, pop) called by public methods, aligning
4141
### push
4242

4343
```ts
44-
push: (message: IModelMessage<object>, methodName: string, clientId: string, agentName: string) => Promise<void>
44+
push: (message: ISwarmMessage<object>, methodName: string, clientId: string, agentName: string) => Promise<void>
4545
```
4646

4747
Pushes a message to the agent’s history for a specific client and method context.
@@ -51,7 +51,7 @@ Used in AgentPublicService (e.g., commitSystemMessage, commitUserMessage) and Cl
5151
### pop
5252

5353
```ts
54-
pop: (methodName: string, clientId: string, agentName: string) => Promise<IModelMessage<object>>
54+
pop: (methodName: string, clientId: string, agentName: string) => Promise<ISwarmMessage<object>>
5555
```
5656

5757
Pops the most recent message from the agent’s history.
@@ -61,17 +61,17 @@ Supports ClientAgent (e.g., retrieving last message in EXECUTE_FN) and AgentPubl
6161
### toArrayForAgent
6262

6363
```ts
64-
toArrayForAgent: (prompt: string, methodName: string, clientId: string, agentName: string) => Promise<IModelMessage<object>[]>
64+
toArrayForAgent: (prompt: string, methodName: string, clientId: string, agentName: string) => Promise<ISwarmMessage<object>[]>
6565
```
6666

67-
Converts the agents history to an array tailored for agent processing, incorporating a prompt.
67+
Converts the agent's history to an array tailored for agent processing, incorporating a prompt.
6868
Wraps HistoryConnectionService.toArrayForAgent with MethodContextService, logging via LoggerService if GLOBAL_CONFIG.CC_LOGGER_ENABLE_INFO is true.
6969
Used in ClientAgent (e.g., EXECUTE_FN context preparation) and DocService (e.g., history documentation with prompts).
7070

7171
### toArrayForRaw
7272

7373
```ts
74-
toArrayForRaw: (methodName: string, clientId: string, agentName: string) => Promise<IModelMessage<object>[]>
74+
toArrayForRaw: (methodName: string, clientId: string, agentName: string) => Promise<ISwarmMessage<object>[]>
7575
```
7676

7777
Converts the agent’s history to a raw array of items.

docs/classes/SchemaUtils.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ constructor();
1616

1717
## Properties
1818

19-
### __@PERSIST_WRITE_SYMBOL@4419
19+
### __@PERSIST_WRITE_SYMBOL@4438
2020

2121
```ts
22-
__@PERSIST_WRITE_SYMBOL@4419: any
22+
__@PERSIST_WRITE_SYMBOL@4438: any
2323
```
2424

2525
### writeSessionMemory

docs/functions/chat.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: docs/api-reference/function/chat
3+
group: docs
4+
---
5+
6+
# chat
7+
8+
```ts
9+
declare function chat(completionName: CompletionName, messages: IBaseMessage[]): Promise<string>;
10+
```
11+
12+
Processes a chat completion request by sending messages to a specified completion service.
13+
Delegates to an internal context-isolated function to ensure clean execution.
14+
15+
## Parameters
16+
17+
| Parameter | Description |
18+
|-----------|-------------|
19+
| `completionName` | The name of the completion service to use. |
20+
| `messages` | Array of messages representing the conversation history. |

docs/functions/getAgentHistory.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ group: docs
66
# getAgentHistory
77

88
```ts
9-
declare function getAgentHistory(clientId: string, agentName: AgentName): Promise<IModelMessage<object>[]>;
9+
declare function getAgentHistory(clientId: string, agentName: AgentName): Promise<ISwarmMessage<object>[]>;
1010
```
1111

1212
Retrieves the history prepared for a specific agent, incorporating rescue algorithm tweaks.

0 commit comments

Comments
 (0)