@mozaik-ai/core 4.2.0-beta.6 → 4.2.0-beta.7

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/dist/index.d.mts CHANGED
@@ -97,7 +97,7 @@ declare function defineRuntime<TSharedState extends SharedState>(): {
97
97
  resolveRuntime: () => RuntimeService<TSharedState>;
98
98
  createParticipant: (name: string, capabilities: readonly string[], handlers: SituationHandler[]) => Promise<Participant>;
99
99
  createSpace: (name: string) => Promise<Space>;
100
- join: (spaceId: string, participantId: string) => Promise<void>;
100
+ join: (spaceId: string, participant: Participant) => Promise<void>;
101
101
  leave: (spaceId: string, participantId: string) => Promise<void>;
102
102
  sendMessage: (spaceId: string, participantId: string, message: string) => Promise<void>;
103
103
  sendMessageTool: FunctionTool;
package/dist/index.d.ts CHANGED
@@ -97,7 +97,7 @@ declare function defineRuntime<TSharedState extends SharedState>(): {
97
97
  resolveRuntime: () => RuntimeService<TSharedState>;
98
98
  createParticipant: (name: string, capabilities: readonly string[], handlers: SituationHandler[]) => Promise<Participant>;
99
99
  createSpace: (name: string) => Promise<Space>;
100
- join: (spaceId: string, participantId: string) => Promise<void>;
100
+ join: (spaceId: string, participant: Participant) => Promise<void>;
101
101
  leave: (spaceId: string, participantId: string) => Promise<void>;
102
102
  sendMessage: (spaceId: string, participantId: string, message: string) => Promise<void>;
103
103
  sendMessageTool: FunctionTool;
package/dist/index.js CHANGED
@@ -118,20 +118,20 @@ var CreateParticipantUseCase = class {
118
118
  }
119
119
  };
120
120
 
121
- // src/application/use-cases/participant-joined.ts
122
- var ParticipantJoinedUseCase = class {
121
+ // src/application/use-cases/participant-join.ts
122
+ var ParticipantJoinUseCase = class {
123
123
  constructor(spaceRepository, eventPublisher) {
124
124
  this.spaceRepository = spaceRepository;
125
125
  this.eventPublisher = eventPublisher;
126
126
  }
127
- async execute(spaceId, participantId) {
127
+ async execute(spaceId, participant) {
128
128
  const space = await this.spaceRepository.findById(spaceId);
129
129
  if (!space) {
130
130
  throw new Error("Space not found");
131
131
  }
132
- const participant = space.getParticipant(participantId);
133
- if (!participant) {
134
- throw new Error("Participant not found");
132
+ const existingParticipant = space.getParticipant(participant.getId());
133
+ if (existingParticipant) {
134
+ throw new Error("Participant already joined");
135
135
  }
136
136
  const event = space.addParticipant(participant);
137
137
  if (event) {
@@ -170,8 +170,8 @@ var EventPublisher = class {
170
170
  }
171
171
  };
172
172
 
173
- // src/application/use-cases/participant-left.ts
174
- var ParticipantLefUseCase = class {
173
+ // src/application/use-cases/participant-leave.ts
174
+ var ParticipantLeaveUseCase = class {
175
175
  constructor(spaceRepository, eventPublisher) {
176
176
  this.spaceRepository = spaceRepository;
177
177
  this.eventPublisher = eventPublisher;
@@ -322,11 +322,11 @@ function defineRuntime() {
322
322
  const createSpace = async (name) => {
323
323
  return await createSpaceUseCase.execute(name);
324
324
  };
325
- const participantJoinedUseCase = new ParticipantJoinedUseCase(spaceRepository, eventPublisher);
326
- const join = async (spaceId, participantId) => {
327
- return await participantJoinedUseCase.execute(spaceId, participantId);
325
+ const participantJoinedUseCase = new ParticipantJoinUseCase(spaceRepository, eventPublisher);
326
+ const join = async (spaceId, participant) => {
327
+ return await participantJoinedUseCase.execute(spaceId, participant);
328
328
  };
329
- const participantLeftUseCase = new ParticipantLefUseCase(spaceRepository, eventPublisher);
329
+ const participantLeftUseCase = new ParticipantLeaveUseCase(spaceRepository, eventPublisher);
330
330
  const leave = async (spaceId, participantId) => {
331
331
  return await participantLeftUseCase.execute(spaceId, participantId);
332
332
  };