@mozaik-ai/core 3.13.0 → 3.14.0

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.js CHANGED
@@ -32,33 +32,18 @@ var index_exports = {};
32
32
  __export(index_exports, {
33
33
  AgenticEnvironment: () => AgenticEnvironment,
34
34
  AgenticError: () => AgenticError,
35
- AnthropicMessages: () => AnthropicMessages,
36
35
  BaseParticipant: () => BaseParticipant,
37
- ClaudeHaiku45: () => ClaudeHaiku45,
38
- ClaudeOpus47: () => ClaudeOpus47,
39
- ClaudeOpus48: () => ClaudeOpus48,
40
- ClaudeSonnet46: () => ClaudeSonnet46,
41
36
  ContextItem: () => ContextItem,
42
- DeepSeekV4Flash: () => DeepSeekV4Flash,
43
- DeepSeekV4Pro: () => DeepSeekV4Pro,
44
37
  DeveloperMessageItem: () => DeveloperMessageItem,
45
38
  FunctionCallItem: () => FunctionCallItem,
46
39
  FunctionCallOutputItem: () => FunctionCallOutputItem,
47
- Gemini31Pro: () => Gemini31Pro,
48
- Gemini35Flash: () => Gemini35Flash,
49
- GeminiGenerateContent: () => GeminiGenerateContent,
50
- Gpt54: () => Gpt54,
51
- Gpt54Mini: () => Gpt54Mini,
52
- Gpt54Nano: () => Gpt54Nano,
53
- Gpt55: () => Gpt55,
54
40
  InMemoryModelContextRepository: () => InMemoryModelContextRepository,
55
- InferenceRequest: () => InferenceRequest,
56
41
  InferenceResponse: () => InferenceResponse,
57
42
  InputTokenDetails: () => InputTokenDetails,
43
+ McpClient: () => McpClient,
44
+ McpToolRegistry: () => McpToolRegistry,
58
45
  ModelContext: () => ModelContext,
59
46
  ModelMessageItem: () => ModelMessageItem,
60
- OpenAIChatCompletions: () => OpenAIChatCompletions,
61
- OpenAIResponses: () => OpenAIResponses,
62
47
  OutputTokenDetails: () => OutputTokenDetails,
63
48
  Participant: () => Participant,
64
49
  ReasoningItem: () => ReasoningItem,
@@ -109,9 +94,6 @@ var ModelContext = class _ModelContext {
109
94
  static rehydrate(data) {
110
95
  return new _ModelContext(data.id, data.projectId, data.items);
111
96
  }
112
- toJSON() {
113
- return this.items.map((item) => item.toJSON());
114
- }
115
97
  };
116
98
 
117
99
  // src/domain/model-context/context-item/context-item.ts
@@ -138,14 +120,6 @@ var InputText = class _InputText extends ItemContent {
138
120
  static rehydrate(data) {
139
121
  return new _InputText(data.text);
140
122
  }
141
- toJSON() {
142
- return [
143
- {
144
- type: this.type,
145
- text: this.text
146
- }
147
- ];
148
- }
149
123
  };
150
124
 
151
125
  // src/domain/model-context/context-item/client-item/user-message.ts
@@ -164,13 +138,6 @@ var UserMessageItem = class _UserMessageItem extends ContextItem {
164
138
  const content = InputText.rehydrate(data);
165
139
  return new _UserMessageItem(content);
166
140
  }
167
- toJSON() {
168
- return {
169
- type: this.type,
170
- role: this.role,
171
- content: this.content.toJSON()
172
- };
173
- }
174
141
  };
175
142
 
176
143
  // src/domain/model-context/context-item/client-item/developer-message.ts
@@ -181,13 +148,6 @@ var DeveloperMessageItem = class _DeveloperMessageItem extends ContextItem {
181
148
  this.role = "developer";
182
149
  this.content = content;
183
150
  }
184
- toJSON() {
185
- return {
186
- type: this.type,
187
- role: this.role,
188
- content: this.content.toJSON()
189
- };
190
- }
191
151
  static create(text) {
192
152
  const content = InputText.create(text);
193
153
  return new _DeveloperMessageItem(content);
@@ -208,14 +168,6 @@ var OutputText = class _OutputText extends ItemContent {
208
168
  static rehydrate(data) {
209
169
  return new _OutputText(data.text);
210
170
  }
211
- toJSON() {
212
- return [
213
- {
214
- type: this.type,
215
- text: this.text
216
- }
217
- ];
218
- }
219
171
  };
220
172
 
221
173
  // src/domain/model-context/context-item/model-item/model-message.ts
@@ -230,13 +182,6 @@ var ModelMessageItem = class _ModelMessageItem extends ContextItem {
230
182
  const content = OutputText.rehydrate(data);
231
183
  return new _ModelMessageItem(content);
232
184
  }
233
- toJSON() {
234
- return {
235
- type: this.type,
236
- role: this.role,
237
- content: this.content.toJSON()
238
- };
239
- }
240
185
  };
241
186
 
242
187
  // src/domain/model-context/context-item/model-item/function-call.ts
@@ -251,14 +196,6 @@ var FunctionCallItem = class _FunctionCallItem extends ContextItem {
251
196
  static rehydrate(data) {
252
197
  return new _FunctionCallItem(data.callId, data.name, data.args);
253
198
  }
254
- toJSON() {
255
- return {
256
- type: this.type,
257
- call_id: this.callId,
258
- name: this.name,
259
- arguments: this.args
260
- };
261
- }
262
199
  };
263
200
 
264
201
  // src/domain/model-context/context-item/model-item/reasoning.ts
@@ -273,14 +210,18 @@ var ReasoningItem = class _ReasoningItem extends ContextItem {
273
210
  static rehydrate(data) {
274
211
  return new _ReasoningItem(data.content, data.encryptedContent, data.summary);
275
212
  }
276
- toJSON() {
277
- var _a;
278
- return {
279
- type: this.type,
280
- content: (_a = this.content) == null ? void 0 : _a.toJSON(),
281
- encryptedContent: this.encryptedContent,
282
- summary: this.summary.map((s) => s.toJSON())
283
- };
213
+ };
214
+
215
+ // src/domain/generative-model/request-validation/structured-output.ts
216
+ var StructuredOutputValidation = class {
217
+ constructor() {
218
+ this.name = "structured-output";
219
+ }
220
+ isValid(inferenceParams, model) {
221
+ if (inferenceParams.structuredOutput === void 0) {
222
+ return true;
223
+ }
224
+ return model.supportsStructuredOutput;
284
225
  }
285
226
  };
286
227
 
@@ -299,179 +240,6 @@ var FunctionCallOutputItem = class _FunctionCallOutputItem extends ContextItem {
299
240
  static rehydrate(data) {
300
241
  return new _FunctionCallOutputItem(data.callId, data.output);
301
242
  }
302
- toJSON() {
303
- return {
304
- type: this.type,
305
- call_id: this.callId,
306
- output: this.output.toJSON()
307
- };
308
- }
309
- };
310
-
311
- // src/infrastructure/providers/openai/reasoning-effort.ts
312
- var OpenAIReasoningEffort = class {
313
- constructor(reasoningEffort) {
314
- this.reasoningEffort = reasoningEffort;
315
- }
316
- setReasoningEffort(effort) {
317
- this.reasoningEffort = effort;
318
- }
319
- getReasoningEffort() {
320
- if (!this.reasoningEffort) {
321
- throw new Error("Reasoning effort not supported");
322
- }
323
- return this.reasoningEffort;
324
- }
325
- };
326
-
327
- // src/infrastructure/providers/openai/models/gpt-5-4-nano.ts
328
- var Gpt54Nano = class {
329
- constructor() {
330
- this.specification = {
331
- name: "gpt-5.4-nano",
332
- provider: "openai",
333
- supportReasoningEffort: true,
334
- defaultReasoningEffort: "none",
335
- supportStreaming: true,
336
- contextWindowSize: 4e5,
337
- maxOutputTokens: 128e3,
338
- supportFunctionCalling: true,
339
- supportStructuredOutput: true
340
- };
341
- this.tools = [];
342
- this.streaming = false;
343
- this.structuredOutput = void 0;
344
- this.effort = new OpenAIReasoningEffort(
345
- this.specification.defaultReasoningEffort
346
- );
347
- }
348
- setStreaming(streaming) {
349
- this.streaming = streaming;
350
- }
351
- getStreaming() {
352
- return this.streaming;
353
- }
354
- setTools(tools) {
355
- this.tools = tools;
356
- }
357
- getTools() {
358
- return this.tools;
359
- }
360
- setReasoningEffort(effort) {
361
- this.effort.setReasoningEffort(effort);
362
- }
363
- getReasoningEffort() {
364
- return this.effort.getReasoningEffort();
365
- }
366
- setStructuredOutput(format) {
367
- this.structuredOutput = format;
368
- }
369
- getStructuredOutput() {
370
- return this.structuredOutput;
371
- }
372
- hasStructuredOutput() {
373
- return this.structuredOutput !== void 0;
374
- }
375
- };
376
-
377
- // src/infrastructure/providers/openai/models/gpt-5-4.ts
378
- var Gpt54 = class {
379
- constructor() {
380
- this.specification = {
381
- name: "gpt-5.4",
382
- provider: "openai",
383
- supportReasoningEffort: true,
384
- defaultReasoningEffort: "none",
385
- supportStreaming: true,
386
- contextWindowSize: 105e4,
387
- maxOutputTokens: 128e3,
388
- supportFunctionCalling: true,
389
- supportStructuredOutput: true
390
- };
391
- this.tools = [];
392
- this.streaming = false;
393
- this.structuredOutput = void 0;
394
- this.effort = new OpenAIReasoningEffort(
395
- this.specification.defaultReasoningEffort
396
- );
397
- }
398
- setStreaming(streaming) {
399
- this.streaming = streaming;
400
- }
401
- getStreaming() {
402
- return this.streaming;
403
- }
404
- setTools(tools) {
405
- this.tools = tools;
406
- }
407
- getTools() {
408
- return this.tools;
409
- }
410
- setReasoningEffort(effort) {
411
- this.effort.setReasoningEffort(effort);
412
- }
413
- getReasoningEffort() {
414
- return this.effort.getReasoningEffort();
415
- }
416
- setStructuredOutput(format) {
417
- this.structuredOutput = format;
418
- }
419
- getStructuredOutput() {
420
- return this.structuredOutput;
421
- }
422
- hasStructuredOutput() {
423
- return this.structuredOutput !== void 0;
424
- }
425
- };
426
-
427
- // src/infrastructure/providers/openai/models/gpt-5-4-mini.ts
428
- var Gpt54Mini = class {
429
- constructor() {
430
- this.specification = {
431
- name: "gpt-5.4-mini",
432
- provider: "openai",
433
- supportReasoningEffort: true,
434
- defaultReasoningEffort: "none",
435
- supportStreaming: true,
436
- contextWindowSize: 4e5,
437
- maxOutputTokens: 128e3,
438
- supportFunctionCalling: true,
439
- supportStructuredOutput: true
440
- };
441
- this.tools = [];
442
- this.streaming = false;
443
- this.structuredOutput = void 0;
444
- this.effort = new OpenAIReasoningEffort(
445
- this.specification.defaultReasoningEffort
446
- );
447
- }
448
- setStreaming(streaming) {
449
- this.streaming = streaming;
450
- }
451
- getStreaming() {
452
- return this.streaming;
453
- }
454
- setReasoningEffort(effort) {
455
- this.effort.setReasoningEffort(effort);
456
- }
457
- getReasoningEffort() {
458
- return this.effort.getReasoningEffort();
459
- }
460
- setTools(tools) {
461
- this.tools = tools;
462
- }
463
- getTools() {
464
- return this.tools;
465
- }
466
- setStructuredOutput(format) {
467
- this.structuredOutput = format;
468
- }
469
- getStructuredOutput() {
470
- return this.structuredOutput;
471
- }
472
- hasStructuredOutput() {
473
- return this.structuredOutput !== void 0;
474
- }
475
243
  };
476
244
 
477
245
  // src/domain/generative-model/token-usage.ts
@@ -495,6 +263,98 @@ var TokenUsage = class {
495
263
  }
496
264
  };
497
265
 
266
+ // src/infrastructure/mcp/mcp-client.ts
267
+ var import_client = require("@modelcontextprotocol/sdk/client/index.js");
268
+ var import_streamableHttp = require("@modelcontextprotocol/sdk/client/streamableHttp.js");
269
+ var McpClient = class {
270
+ constructor(config) {
271
+ this.config = config;
272
+ this.connected = false;
273
+ var _a, _b;
274
+ const headers = { ...(_a = config.headers) != null ? _a : {} };
275
+ if (config.authToken) headers.Authorization = `Bearer ${config.authToken}`;
276
+ this.transport = new import_streamableHttp.StreamableHTTPClientTransport(
277
+ new URL(config.url),
278
+ Object.keys(headers).length > 0 ? { requestInit: { headers } } : void 0
279
+ );
280
+ this.client = new import_client.Client({ name: (_b = config.name) != null ? _b : "mozaik", version: "1.0.0" }, { capabilities: {} });
281
+ }
282
+ async connect() {
283
+ if (this.connected) return;
284
+ await this.client.connect(this.transport);
285
+ this.connected = true;
286
+ }
287
+ /** The tools this server exposes. */
288
+ async listTools() {
289
+ var _a;
290
+ await this.connect();
291
+ const res = await this.client.listTools();
292
+ return ((_a = res.tools) != null ? _a : []).map((t) => {
293
+ var _a2, _b;
294
+ return {
295
+ name: t.name,
296
+ description: (_a2 = t.description) != null ? _a2 : "",
297
+ inputSchema: (_b = t.inputSchema) != null ? _b : { type: "object", properties: {} }
298
+ };
299
+ });
300
+ }
301
+ /** Call a tool by name; returns its text output. Throws if the server flags an error. */
302
+ async callTool(name, args) {
303
+ await this.connect();
304
+ const res = await this.client.callTool({ name, arguments: args != null ? args : {} });
305
+ const text = extractText(res);
306
+ if (res.isError) {
307
+ throw new Error(`MCP tool "${name}" failed: ${text || "unknown error"}`);
308
+ }
309
+ return text;
310
+ }
311
+ async close() {
312
+ if (!this.connected) return;
313
+ try {
314
+ await this.client.close();
315
+ } catch (e) {
316
+ }
317
+ this.connected = false;
318
+ }
319
+ };
320
+ function extractText(res) {
321
+ const content = res.content;
322
+ if (!Array.isArray(content)) return "";
323
+ return content.filter((c) => (c == null ? void 0 : c.type) === "text" && typeof c.text === "string").map((c) => c.text).join("\n");
324
+ }
325
+
326
+ // src/infrastructure/mcp/mcp-tool-registry.ts
327
+ var McpToolRegistry = class {
328
+ constructor(servers, createClient = (config) => new McpClient(config)) {
329
+ this.servers = servers;
330
+ this.createClient = createClient;
331
+ this.clients = [];
332
+ }
333
+ /** Discover every tool across the configured servers, as FunctionTools ready to pass to a model. */
334
+ async discoverTools() {
335
+ const tools = [];
336
+ for (const server of this.servers) {
337
+ const client = this.createClient(server);
338
+ this.clients.push(client);
339
+ for (const spec of await client.listTools()) {
340
+ tools.push({
341
+ type: "function",
342
+ name: spec.name,
343
+ description: spec.description,
344
+ parameters: spec.inputSchema,
345
+ strict: false,
346
+ invoke: (args) => client.callTool(spec.name, args != null ? args : {})
347
+ });
348
+ }
349
+ }
350
+ return tools;
351
+ }
352
+ /** Close all underlying MCP connections. */
353
+ async close() {
354
+ await Promise.all(this.clients.map((c) => c.close()));
355
+ }
356
+ };
357
+
498
358
  // src/infrastructure/repository/in-memory-model-context-repository.ts
499
359
  var InMemoryModelContextRepository = class {
500
360
  constructor() {
@@ -545,13 +405,6 @@ var SystemMessageItem = class _SystemMessageItem extends ContextItem {
545
405
  this.role = "system";
546
406
  this.content = content;
547
407
  }
548
- toJSON() {
549
- return {
550
- type: this.type,
551
- role: this.role,
552
- content: this.content.toJSON()
553
- };
554
- }
555
408
  static create(text) {
556
409
  const content = InputText.create(text);
557
410
  return new _SystemMessageItem(content);
@@ -698,8 +551,10 @@ var AgenticEnvironment = class {
698
551
  src.onError(error);
699
552
  } catch (error2) {
700
553
  if (this.showLogs) {
701
- console.warn(`[AgenticEnvironment] Participant.onError() failed. Reason: ${error2}
702
- ${JSON.stringify({ error: error2 }, null, 2)}`);
554
+ console.warn(
555
+ `[AgenticEnvironment] Participant.onError() failed. Reason: ${error2}
556
+ ${JSON.stringify({ error: error2 }, null, 2)}`
557
+ );
703
558
  }
704
559
  } finally {
705
560
  src.markInactive(this);
@@ -710,8 +565,10 @@ var AgenticEnvironment = class {
710
565
  sub.onParticipantError(source, error);
711
566
  } catch (error2) {
712
567
  if (this.showLogs) {
713
- console.warn(`[AgenticEnvironment] Participant.onError() failed. Reason: ${error2}
714
- ${JSON.stringify({ error: error2 }, null, 2)}`);
568
+ console.warn(
569
+ `[AgenticEnvironment] Participant.onError() failed. Reason: ${error2}
570
+ ${JSON.stringify({ error: error2 }, null, 2)}`
571
+ );
715
572
  }
716
573
  }
717
574
  }
@@ -754,56 +611,6 @@ var AgenticEnvironment = class {
754
611
  }
755
612
  };
756
613
 
757
- // src/infrastructure/providers/openai/models/gpt-5-5.ts
758
- var Gpt55 = class {
759
- constructor() {
760
- this.specification = {
761
- name: "gpt-5.5",
762
- provider: "openai",
763
- supportReasoningEffort: true,
764
- defaultReasoningEffort: "none",
765
- supportStreaming: true,
766
- contextWindowSize: 105e4,
767
- maxOutputTokens: 128e3,
768
- supportFunctionCalling: true,
769
- supportStructuredOutput: true
770
- };
771
- this.tools = [];
772
- this.streaming = false;
773
- this.structuredOutput = void 0;
774
- this.effort = new OpenAIReasoningEffort(
775
- this.specification.defaultReasoningEffort
776
- );
777
- }
778
- setStreaming(streaming) {
779
- this.streaming = streaming;
780
- }
781
- getStreaming() {
782
- return this.streaming;
783
- }
784
- setTools(tools) {
785
- this.tools = tools;
786
- }
787
- getTools() {
788
- return this.tools;
789
- }
790
- setReasoningEffort(effort) {
791
- this.effort.setReasoningEffort(effort);
792
- }
793
- getReasoningEffort() {
794
- return this.effort.getReasoningEffort();
795
- }
796
- setStructuredOutput(format) {
797
- this.structuredOutput = format;
798
- }
799
- getStructuredOutput() {
800
- return this.structuredOutput;
801
- }
802
- hasStructuredOutput() {
803
- return this.structuredOutput !== void 0;
804
- }
805
- };
806
-
807
614
  // src/domain/model-context/semantic-event/semantic-event.ts
808
615
  var SemanticEvent = class {
809
616
  constructor(type, data) {
@@ -815,14 +622,6 @@ var SemanticEvent = class {
815
622
  }
816
623
  };
817
624
 
818
- // src/domain/agentic-environment/inference/request.ts
819
- var InferenceRequest = class {
820
- constructor(model, context) {
821
- this.model = model;
822
- this.context = context;
823
- }
824
- };
825
-
826
625
  // src/domain/agentic-environment/inference/response.ts
827
626
  var InferenceResponse = class {
828
627
  constructor(contextItems, tokenUsage) {
@@ -831,191 +630,196 @@ var InferenceResponse = class {
831
630
  }
832
631
  };
833
632
 
834
- // src/infrastructure/providers/openai/runtime/openai-responses.ts
835
- var import_openai = __toESM(require("openai"));
836
- var OpenAIResponses = class {
837
- constructor() {
838
- this.client = new import_openai.default();
839
- }
840
- async infer(inferenceRequest) {
841
- const request = this.buildRequest(inferenceRequest);
842
- const response = await this.client.responses.create(request);
843
- const contextItems = this.extractContextItems(response);
844
- const tokenUsage = this.extractTokenUsage(response);
845
- return new InferenceResponse(contextItems, tokenUsage);
633
+ // src/application/services/inference-runner.ts
634
+ var StreamingInference = class {
635
+ async *run(request, endpoint) {
636
+ var _a;
637
+ if ((_a = request.signal) == null ? void 0 : _a.aborted) {
638
+ return;
639
+ }
640
+ yield* endpoint.stream(request, request.signal);
846
641
  }
847
- async *stream(inferenceRequest, signal) {
848
- const specification = inferenceRequest.model.specification;
849
- if (!specification.supportStreaming) {
850
- throw new Error("Streaming is not supported for this model");
642
+ };
643
+ var NonStreamingInference = class {
644
+ async *run(request, endpoint) {
645
+ var _a, _b;
646
+ if ((_a = request.signal) == null ? void 0 : _a.aborted) {
647
+ return;
851
648
  }
852
- const request = { ...this.buildRequest(inferenceRequest), stream: true };
853
- const response = await this.client.responses.create(request);
854
- for await (const event of response) {
855
- if (signal == null ? void 0 : signal.aborted) {
649
+ const response = await endpoint.infer(request);
650
+ for (const item of response.contextItems) {
651
+ if ((_b = request.signal) == null ? void 0 : _b.aborted) {
856
652
  break;
857
653
  }
858
- yield new SemanticEvent(event.type, event);
654
+ yield item;
859
655
  }
860
656
  }
861
- buildRequest(inferenceRequest) {
862
- var _a, _b;
863
- const specification = inferenceRequest.model.specification;
864
- const input = this.mapContextToRequest(inferenceRequest.context);
865
- const request = {
866
- model: specification.name,
867
- input
657
+ };
658
+
659
+ // src/application/use-cases/run-inference.ts
660
+ var RunInference = class {
661
+ constructor(generativeModelRepository2, requestValidator) {
662
+ this.generativeModelRepository = generativeModelRepository2;
663
+ this.requestValidator = requestValidator;
664
+ }
665
+ async execute(inferenceParams) {
666
+ var _a;
667
+ const { caller, environment, signal } = inferenceParams;
668
+ const generativeModel = await this.generativeModelRepository.getByModelName(inferenceParams.model);
669
+ this.requestValidator.validate(inferenceParams, generativeModel.specification);
670
+ const resolvedParams = {
671
+ ...inferenceParams,
672
+ maxOutputTokens: (_a = inferenceParams.maxOutputTokens) != null ? _a : generativeModel.specification.maxOutputTokens
868
673
  };
869
- if (specification.supportFunctionCalling && inferenceRequest.model.getTools().length > 0) {
870
- request.tools = inferenceRequest.model.getTools().map((tool) => {
871
- return {
872
- type: tool.type,
873
- name: tool.name,
874
- description: tool.description,
875
- parameters: tool.parameters
876
- };
877
- });
878
- }
879
- if (specification.supportReasoningEffort) {
880
- request.reasoning = {
881
- effort: inferenceRequest.model.getReasoningEffort()
882
- };
883
- }
884
- if (inferenceRequest.model.hasStructuredOutput()) {
885
- if (!specification.supportStructuredOutput) {
886
- throw new Error(`Structured output is not supported for model: ${specification.name}`);
674
+ const inferenceRunner = inferenceParams.streaming ? new StreamingInference() : new NonStreamingInference();
675
+ const result = inferenceRunner.run(resolvedParams, generativeModel.endpoint);
676
+ for await (const item of result) {
677
+ if (signal == null ? void 0 : signal.aborted) {
678
+ break;
679
+ }
680
+ if (item instanceof ReasoningItem) {
681
+ environment.deliverReasoning(caller, item);
682
+ } else if (item instanceof FunctionCallItem) {
683
+ environment.deliverFunctionCall(caller, item);
684
+ } else if (item instanceof ModelMessageItem) {
685
+ environment.deliverModelMessage(caller, item);
686
+ } else if (item instanceof SemanticEvent) {
687
+ environment.deliverSemanticEvent(caller, item);
887
688
  }
888
- const format = inferenceRequest.model.getStructuredOutput();
889
- request.text = {
890
- format: {
891
- type: "json_schema",
892
- name: (_a = format.name) != null ? _a : "response",
893
- schema: format.schema,
894
- strict: (_b = format.strict) != null ? _b : true
895
- }
896
- };
897
689
  }
898
- return request;
899
690
  }
900
- extractTokenUsage(response) {
901
- if (!response.usage) {
902
- return void 0;
903
- }
904
- return new TokenUsage(
905
- response.usage.input_tokens,
906
- response.usage.output_tokens,
907
- response.usage.total_tokens,
908
- new InputTokenDetails(response.usage.input_tokens_details.cached_tokens),
909
- new OutputTokenDetails(response.usage.output_tokens_details.reasoning_tokens)
910
- );
691
+ };
692
+
693
+ // src/application/use-cases/execute-function-call.ts
694
+ var ExecuteFunctionCall = class {
695
+ constructor(functionCallRunner) {
696
+ this.functionCallRunner = functionCallRunner;
911
697
  }
912
- mapContextToRequest(context) {
913
- return context.getItems().map((item) => item.toJSON());
698
+ async execute(environment, functionCallItem, tool, caller, signal) {
699
+ const stream = this.functionCallRunner.run(functionCallItem, tool, signal);
700
+ for await (const item of stream) {
701
+ environment.deliverFunctionCallOutput(caller, item);
702
+ }
914
703
  }
915
- extractContextItems(response) {
916
- return response.output.map((item) => {
917
- if (item.type === "message" && item.role === "assistant") {
918
- return ModelMessageItem.rehydrate(item.content[0]);
919
- }
920
- if (item.type === "function_call") {
921
- return FunctionCallItem.rehydrate({
922
- callId: item.call_id,
923
- name: item.name,
924
- args: item.arguments
925
- });
926
- }
927
- if (item.type === "reasoning") {
928
- return ReasoningItem.rehydrate(item);
929
- }
930
- });
704
+ };
705
+
706
+ // src/application/services/function-call-runner.ts
707
+ var FunctionCallRunner = class {
708
+ async *run(call, tool, signal) {
709
+ if (signal == null ? void 0 : signal.aborted) {
710
+ return;
711
+ }
712
+ if (!tool) throw new Error(`Unknown tool: ${call.name}`);
713
+ const result = await tool.invoke(JSON.parse(call.args));
714
+ yield FunctionCallOutputItem.create(call.callId, JSON.stringify(result));
931
715
  }
932
716
  };
933
717
 
934
- // src/infrastructure/providers/anthropic/runtime/anthropic-messages.ts
935
- var import_sdk = __toESM(require("@anthropic-ai/sdk"));
936
- var AnthropicMessages = class {
937
- constructor() {
938
- this.client = new import_sdk.default();
718
+ // src/application/participants/participant.ts
719
+ var BaseParticipant = class extends Participant {
720
+ onFunctionCall(_item) {
939
721
  }
940
- async infer(inferenceRequest) {
941
- const response = await this.client.messages.create(this.buildRequest(inferenceRequest));
942
- const contextItems = this.extractContextItems(response);
943
- const tokenUsage = this.extractTokenUsage(response);
944
- return new InferenceResponse(contextItems, tokenUsage);
722
+ onExternalFunctionCall(_source, _item) {
945
723
  }
946
- async *stream(inferenceRequest, signal) {
947
- const stream = await this.client.messages.create({
948
- ...this.buildRequest(inferenceRequest),
949
- stream: true
950
- });
951
- for await (const event of stream) {
952
- if (signal == null ? void 0 : signal.aborted) {
953
- break;
954
- }
955
- yield new SemanticEvent(event.type, event);
956
- }
724
+ onFunctionCallOutput(_item) {
957
725
  }
958
- buildRequest(inferenceRequest) {
959
- const { messages, system } = this.mapContextToRequest(inferenceRequest.context);
960
- const specification = inferenceRequest.model.specification;
961
- const request = {
962
- model: specification.name,
963
- max_tokens: specification.maxOutputTokens,
964
- messages
965
- };
966
- if (system) {
967
- request.system = system;
968
- }
969
- if (specification.supportFunctionCalling && inferenceRequest.model.getTools().length > 0) {
970
- request.tools = inferenceRequest.model.getTools().map((tool) => {
971
- return {
972
- name: tool.name,
973
- description: tool.description,
974
- input_schema: tool.parameters
975
- };
976
- });
977
- }
978
- if (specification.supportReasoningEffort) {
979
- const effort = inferenceRequest.model.getReasoningEffort();
980
- const budgets = { low: 1024, medium: 4096, high: 8192 };
981
- const budget = budgets[effort];
982
- if (budget !== void 0) {
983
- request.thinking = {
984
- type: "enabled",
985
- budget_tokens: Math.min(budget, specification.maxOutputTokens - 1)
986
- };
987
- }
726
+ onExternalFunctionCallOutput(_source, _item) {
727
+ }
728
+ onReasoning(_item) {
729
+ }
730
+ onExternalReasoning(_source, _item) {
731
+ }
732
+ onModelMessage(_item) {
733
+ }
734
+ onExternalModelMessage(_source, _item) {
735
+ }
736
+ onMessage(_message) {
737
+ }
738
+ onJoined() {
739
+ }
740
+ onLeft() {
741
+ }
742
+ onParticipantJoined(_participant) {
743
+ }
744
+ onParticipantLeft(_participant) {
745
+ }
746
+ onInternalEvent(_item) {
747
+ }
748
+ onExternalEvent(_source, _item) {
749
+ }
750
+ onError(_error) {
751
+ }
752
+ onParticipantError(_source, _error) {
753
+ }
754
+ };
755
+
756
+ // src/application/use-cases/send-message.ts
757
+ var SendMessage = class {
758
+ async execute(environment, message, caller) {
759
+ if (!caller.isJoinedTo(environment)) {
760
+ throw new Error("Not joined to environment");
988
761
  }
989
- if (inferenceRequest.model.hasStructuredOutput()) {
990
- if (!specification.supportStructuredOutput) {
991
- throw new Error(`Structured output is not supported for model: ${specification.name}`);
992
- }
993
- const format = inferenceRequest.model.getStructuredOutput();
994
- request.output_config = {
995
- format: {
996
- type: "json_schema",
997
- json_schema: format.schema
998
- }
762
+ environment.deliverMessage(caller, message);
763
+ }
764
+ };
765
+
766
+ // src/infrastructure/providers/anthropic/endpoints/anthropic-messages-mapper.ts
767
+ var AnthropicMessagesMapper = class {
768
+ toRequest(inferenceParams) {
769
+ const { messages, system } = this.mapContextItems(inferenceParams);
770
+ const outputConfig = {};
771
+ const request = {
772
+ model: inferenceParams.model,
773
+ messages
774
+ };
775
+ request.max_tokens = inferenceParams.maxOutputTokens;
776
+ if (system) {
777
+ request.system = system;
778
+ }
779
+ if (inferenceParams.tools && inferenceParams.tools.length > 0) {
780
+ request.tools = inferenceParams.tools.map((tool) => ({
781
+ name: tool.name,
782
+ description: tool.description,
783
+ input_schema: tool.parameters
784
+ }));
785
+ }
786
+ if (inferenceParams.structuredOutput) {
787
+ outputConfig.format = {
788
+ type: "json_schema",
789
+ json_schema: inferenceParams.structuredOutput.schema
999
790
  };
1000
791
  }
792
+ if (inferenceParams.reasoningEffort) {
793
+ request.thinking = { type: "adaptive" };
794
+ outputConfig.effort = inferenceParams.reasoningEffort;
795
+ }
796
+ if (Object.keys(outputConfig).length > 0) {
797
+ request.output_config = outputConfig;
798
+ }
799
+ if (inferenceParams.streaming) {
800
+ request.stream = inferenceParams.streaming;
801
+ }
1001
802
  return request;
1002
803
  }
1003
- extractTokenUsage(response) {
1004
- var _a, _b;
1005
- if (!response.usage) {
1006
- return void 0;
804
+ toResponse(response) {
805
+ const contextItems = this.extractContextItems(response);
806
+ const tokenUsage = this.extractTokenUsage(response);
807
+ return new InferenceResponse(contextItems, tokenUsage);
808
+ }
809
+ addContentBlock(messages, role, block) {
810
+ const lastMessage = messages[messages.length - 1];
811
+ if ((lastMessage == null ? void 0 : lastMessage.role) === role) {
812
+ lastMessage.content.push(block);
813
+ return;
1007
814
  }
1008
- return new TokenUsage(
1009
- response.usage.input_tokens,
1010
- response.usage.output_tokens,
1011
- response.usage.input_tokens + response.usage.output_tokens,
1012
- new InputTokenDetails(
1013
- ((_a = response.usage.cache_creation_input_tokens) != null ? _a : 0) + ((_b = response.usage.cache_read_input_tokens) != null ? _b : 0)
1014
- ),
1015
- new OutputTokenDetails(0)
1016
- );
815
+ messages.push({
816
+ role,
817
+ content: [block]
818
+ });
1017
819
  }
1018
- mapContextToRequest(context) {
820
+ mapContextItems(inferenceParams) {
821
+ var _a, _b, _c;
822
+ const context = inferenceParams.context;
1019
823
  const messages = [];
1020
824
  const system = [];
1021
825
  for (const item of context.getItems()) {
@@ -1031,6 +835,14 @@ var AnthropicMessages = class {
1031
835
  this.addContentBlock(messages, "assistant", { type: "text", text: item.content.text });
1032
836
  continue;
1033
837
  }
838
+ if (item instanceof ReasoningItem) {
839
+ this.addContentBlock(messages, "assistant", {
840
+ type: "thinking",
841
+ thinking: (_b = (_a = item.content) == null ? void 0 : _a.text) != null ? _b : "",
842
+ signature: (_c = item.encryptedContent) != null ? _c : ""
843
+ });
844
+ continue;
845
+ }
1034
846
  if (item instanceof FunctionCallItem) {
1035
847
  let input;
1036
848
  try {
@@ -1059,6 +871,21 @@ var AnthropicMessages = class {
1059
871
  system: system.length > 0 ? system.join("\n\n") : void 0
1060
872
  };
1061
873
  }
874
+ extractTokenUsage(response) {
875
+ var _a, _b;
876
+ if (!response.usage) {
877
+ return void 0;
878
+ }
879
+ return new TokenUsage(
880
+ response.usage.input_tokens,
881
+ response.usage.output_tokens,
882
+ response.usage.input_tokens + response.usage.output_tokens,
883
+ new InputTokenDetails(
884
+ ((_a = response.usage.cache_creation_input_tokens) != null ? _a : 0) + ((_b = response.usage.cache_read_input_tokens) != null ? _b : 0)
885
+ ),
886
+ new OutputTokenDetails(0)
887
+ );
888
+ }
1062
889
  extractContextItems(response) {
1063
890
  var _a;
1064
891
  const items = [];
@@ -1081,7 +908,7 @@ var AnthropicMessages = class {
1081
908
  items.push(
1082
909
  ReasoningItem.rehydrate({
1083
910
  content: block.thinking ? InputText.rehydrate({ text: block.thinking }) : void 0,
1084
- encryptedContent: void 0,
911
+ encryptedContent: block.signature,
1085
912
  summary: []
1086
913
  })
1087
914
  );
@@ -1089,423 +916,261 @@ var AnthropicMessages = class {
1089
916
  }
1090
917
  return items;
1091
918
  }
1092
- addContentBlock(messages, role, block) {
1093
- const lastMessage = messages[messages.length - 1];
1094
- if ((lastMessage == null ? void 0 : lastMessage.role) === role) {
1095
- lastMessage.content.push(block);
1096
- return;
1097
- }
1098
- messages.push({
1099
- role,
1100
- content: [block]
1101
- });
1102
- }
1103
919
  };
1104
920
 
1105
- // src/infrastructure/providers/anthropic/reasoning-effort.ts
1106
- var AnthropicReasoningEffort = class {
1107
- constructor(reasoningEffort) {
1108
- this.reasoningEffort = reasoningEffort;
921
+ // src/infrastructure/providers/anthropic/endpoints/anthropic-messages.ts
922
+ var import_sdk = __toESM(require("@anthropic-ai/sdk"));
923
+ var AnthropicMessages = class {
924
+ constructor(endpointMapper = new AnthropicMessagesMapper()) {
925
+ this.endpointMapper = endpointMapper;
926
+ this.client = new import_sdk.default();
1109
927
  }
1110
- setReasoningEffort(effort) {
1111
- this.reasoningEffort = effort;
928
+ async infer(inferenceParams) {
929
+ const inferenceRequest = this.endpointMapper.toRequest(inferenceParams);
930
+ const response = await this.client.messages.create(inferenceRequest);
931
+ return this.endpointMapper.toResponse(response);
1112
932
  }
1113
- getReasoningEffort() {
1114
- if (!this.reasoningEffort) {
1115
- throw new Error("Reasoning effort not supported");
933
+ async *stream(inferenceParams, signal) {
934
+ const inferenceRequest = this.endpointMapper.toRequest(inferenceParams);
935
+ const stream = await this.client.messages.create(inferenceRequest);
936
+ for await (const event of stream) {
937
+ if (signal == null ? void 0 : signal.aborted) {
938
+ break;
939
+ }
940
+ yield new SemanticEvent(event.type, event);
1116
941
  }
1117
- return this.reasoningEffort;
1118
- }
1119
- };
1120
-
1121
- // src/infrastructure/providers/anthropic/models/claude-4-8-opus.ts
1122
- var ClaudeOpus48 = class {
1123
- constructor() {
1124
- this.specification = {
1125
- name: "claude-opus-4-8",
1126
- provider: "anthropic",
1127
- supportReasoningEffort: true,
1128
- defaultReasoningEffort: "none",
1129
- supportStreaming: true,
1130
- contextWindowSize: 2e5,
1131
- maxOutputTokens: 32e3,
1132
- supportFunctionCalling: true,
1133
- supportStructuredOutput: true
1134
- };
1135
- this.tools = [];
1136
- this.streaming = false;
1137
- this.structuredOutput = void 0;
1138
- this.effort = new AnthropicReasoningEffort(
1139
- this.specification.defaultReasoningEffort
1140
- );
1141
- }
1142
- setStreaming(streaming) {
1143
- this.streaming = streaming;
1144
- }
1145
- getStreaming() {
1146
- return this.streaming;
1147
- }
1148
- setTools(tools) {
1149
- this.tools = tools;
1150
- }
1151
- getTools() {
1152
- return this.tools;
1153
- }
1154
- setReasoningEffort(effort) {
1155
- this.effort.setReasoningEffort(effort);
1156
- }
1157
- getReasoningEffort() {
1158
- return this.effort.getReasoningEffort();
1159
- }
1160
- setStructuredOutput(format) {
1161
- this.structuredOutput = format;
1162
- }
1163
- getStructuredOutput() {
1164
- return this.structuredOutput;
1165
- }
1166
- hasStructuredOutput() {
1167
- return this.structuredOutput !== void 0;
1168
942
  }
1169
943
  };
1170
944
 
1171
- // src/infrastructure/providers/anthropic/models/claude-4-7-opus.ts
1172
- var ClaudeOpus47 = class {
1173
- constructor() {
1174
- this.specification = {
1175
- name: "claude-opus-4-7",
1176
- provider: "anthropic",
1177
- supportReasoningEffort: true,
1178
- defaultReasoningEffort: "none",
1179
- supportStreaming: true,
1180
- contextWindowSize: 2e5,
1181
- maxOutputTokens: 32e3,
1182
- supportFunctionCalling: true,
1183
- supportStructuredOutput: true
1184
- };
1185
- this.tools = [];
1186
- this.streaming = false;
1187
- this.structuredOutput = void 0;
1188
- this.effort = new AnthropicReasoningEffort(
1189
- this.specification.defaultReasoningEffort
1190
- );
1191
- }
1192
- setStreaming(streaming) {
1193
- this.streaming = streaming;
1194
- }
1195
- getStreaming() {
1196
- return this.streaming;
1197
- }
1198
- setTools(tools) {
1199
- this.tools = tools;
1200
- }
1201
- getTools() {
1202
- return this.tools;
1203
- }
1204
- setReasoningEffort(effort) {
1205
- this.effort.setReasoningEffort(effort);
1206
- }
1207
- getReasoningEffort() {
1208
- return this.effort.getReasoningEffort();
1209
- }
1210
- setStructuredOutput(format) {
1211
- this.structuredOutput = format;
1212
- }
1213
- getStructuredOutput() {
1214
- return this.structuredOutput;
1215
- }
1216
- hasStructuredOutput() {
1217
- return this.structuredOutput !== void 0;
1218
- }
1219
- };
945
+ // src/infrastructure/providers/openai/endpoints/openai-responses.ts
946
+ var import_openai = __toESM(require("openai"));
1220
947
 
1221
- // src/infrastructure/providers/anthropic/models/claude-4-6-sonnet.ts
1222
- var ClaudeSonnet46 = class {
1223
- constructor() {
1224
- this.specification = {
1225
- name: "claude-sonnet-4-6",
1226
- provider: "anthropic",
1227
- supportReasoningEffort: true,
1228
- defaultReasoningEffort: "none",
1229
- supportStreaming: true,
1230
- contextWindowSize: 2e5,
1231
- maxOutputTokens: 64e3,
1232
- supportFunctionCalling: true,
1233
- supportStructuredOutput: true
1234
- };
1235
- this.tools = [];
1236
- this.streaming = false;
1237
- this.structuredOutput = void 0;
1238
- this.effort = new AnthropicReasoningEffort(
1239
- this.specification.defaultReasoningEffort
1240
- );
1241
- }
1242
- setStreaming(streaming) {
1243
- this.streaming = streaming;
1244
- }
1245
- getStreaming() {
1246
- return this.streaming;
1247
- }
1248
- setTools(tools) {
1249
- this.tools = tools;
1250
- }
1251
- getTools() {
1252
- return this.tools;
1253
- }
1254
- setReasoningEffort(effort) {
1255
- this.effort.setReasoningEffort(effort);
1256
- }
1257
- getReasoningEffort() {
1258
- return this.effort.getReasoningEffort();
1259
- }
1260
- setStructuredOutput(format) {
1261
- this.structuredOutput = format;
1262
- }
1263
- getStructuredOutput() {
1264
- return this.structuredOutput;
948
+ // src/domain/model-context/context-item/item-content/summary-text.ts
949
+ var SummaryText = class _SummaryText extends ItemContent {
950
+ constructor(text) {
951
+ super();
952
+ this.text = text;
953
+ this.type = "summary_text";
1265
954
  }
1266
- hasStructuredOutput() {
1267
- return this.structuredOutput !== void 0;
955
+ static rehydrate(data) {
956
+ return new _SummaryText(data.text);
1268
957
  }
1269
958
  };
1270
959
 
1271
- // src/infrastructure/providers/anthropic/models/claude-4-5-haiku.ts
1272
- var ClaudeHaiku45 = class {
1273
- constructor() {
1274
- this.specification = {
1275
- name: "claude-haiku-4-5",
1276
- provider: "anthropic",
1277
- supportReasoningEffort: true,
1278
- defaultReasoningEffort: "none",
1279
- supportStreaming: true,
1280
- contextWindowSize: 2e5,
1281
- maxOutputTokens: 64e3,
1282
- supportFunctionCalling: true,
1283
- supportStructuredOutput: true
960
+ // src/infrastructure/providers/openai/endpoints/openai-responses-mapper.ts
961
+ var OpenAIResponsesMapper = class {
962
+ toRequest(inferenceParams) {
963
+ var _a, _b;
964
+ const request = {
965
+ model: inferenceParams.model,
966
+ input: this.mapContextItems(inferenceParams)
1284
967
  };
1285
- this.tools = [];
1286
- this.streaming = false;
1287
- this.structuredOutput = void 0;
1288
- this.effort = new AnthropicReasoningEffort(
1289
- this.specification.defaultReasoningEffort
1290
- );
1291
- }
1292
- setStreaming(streaming) {
1293
- this.streaming = streaming;
1294
- }
1295
- getStreaming() {
1296
- return this.streaming;
1297
- }
1298
- setTools(tools) {
1299
- this.tools = tools;
1300
- }
1301
- getTools() {
1302
- return this.tools;
1303
- }
1304
- setReasoningEffort(effort) {
1305
- this.effort.setReasoningEffort(effort);
1306
- }
1307
- getReasoningEffort() {
1308
- return this.effort.getReasoningEffort();
1309
- }
1310
- setStructuredOutput(format) {
1311
- this.structuredOutput = format;
1312
- }
1313
- getStructuredOutput() {
1314
- return this.structuredOutput;
1315
- }
1316
- hasStructuredOutput() {
1317
- return this.structuredOutput !== void 0;
1318
- }
1319
- };
1320
-
1321
- // src/infrastructure/providers/deepseek/reasoning-effort.ts
1322
- var DeepSeekReasoningEffort = class {
1323
- constructor(reasoningEffort) {
1324
- this.reasoningEffort = reasoningEffort;
1325
- }
1326
- setReasoningEffort(effort) {
1327
- this.reasoningEffort = effort;
1328
- }
1329
- getReasoningEffort() {
1330
- if (!this.reasoningEffort) {
1331
- throw new Error("Reasoning effort not supported");
968
+ if (inferenceParams.tools && inferenceParams.tools.length > 0) {
969
+ request.tools = inferenceParams.tools.map((tool) => ({
970
+ type: tool.type,
971
+ name: tool.name,
972
+ description: tool.description,
973
+ parameters: tool.parameters
974
+ }));
1332
975
  }
1333
- return this.reasoningEffort;
1334
- }
1335
- };
1336
-
1337
- // src/infrastructure/providers/deepseek/models/deepseek-v4-flash.ts
1338
- var DeepSeekV4Flash = class {
1339
- constructor() {
1340
- this.specification = {
1341
- name: "deepseek-v4-flash",
1342
- provider: "deepseek",
1343
- supportReasoningEffort: true,
1344
- defaultReasoningEffort: "high",
1345
- supportStreaming: true,
1346
- contextWindowSize: 1e6,
1347
- maxOutputTokens: 384e3,
1348
- supportFunctionCalling: true,
1349
- supportStructuredOutput: false
1350
- };
1351
- this.tools = [];
1352
- this.streaming = false;
1353
- this.structuredOutput = void 0;
1354
- this.effort = new DeepSeekReasoningEffort(
1355
- this.specification.defaultReasoningEffort
1356
- );
1357
- }
1358
- setStreaming(streaming) {
1359
- this.streaming = streaming;
1360
- }
1361
- getStreaming() {
1362
- return this.streaming;
1363
- }
1364
- setTools(tools) {
1365
- this.tools = tools;
1366
- }
1367
- getTools() {
1368
- return this.tools;
1369
- }
1370
- setReasoningEffort(effort) {
1371
- this.effort.setReasoningEffort(effort);
1372
- }
1373
- getReasoningEffort() {
1374
- return this.effort.getReasoningEffort();
1375
- }
1376
- setStructuredOutput(format) {
1377
- this.structuredOutput = format;
976
+ if (inferenceParams.reasoningEffort) {
977
+ request.reasoning = {
978
+ effort: inferenceParams.reasoningEffort
979
+ };
980
+ }
981
+ if (inferenceParams.structuredOutput) {
982
+ const format = inferenceParams.structuredOutput;
983
+ request.text = {
984
+ format: {
985
+ type: "json_schema",
986
+ name: (_a = format.name) != null ? _a : "response",
987
+ schema: format.schema,
988
+ strict: (_b = format.strict) != null ? _b : true
989
+ }
990
+ };
991
+ }
992
+ if (inferenceParams.streaming) {
993
+ request.stream = inferenceParams.streaming;
994
+ }
995
+ return request;
1378
996
  }
1379
- getStructuredOutput() {
1380
- return this.structuredOutput;
997
+ toResponse(response) {
998
+ const contextItems = this.extractContextItems(response);
999
+ const tokenUsage = this.extractTokenUsage(response);
1000
+ return new InferenceResponse(contextItems, tokenUsage);
1381
1001
  }
1382
- hasStructuredOutput() {
1383
- return this.structuredOutput !== void 0;
1002
+ mapContextItems(inferenceParams) {
1003
+ const input = [];
1004
+ for (const item of inferenceParams.context.getItems()) {
1005
+ if (item instanceof DeveloperMessageItem || item instanceof SystemMessageItem || item instanceof UserMessageItem) {
1006
+ input.push({
1007
+ type: item.type,
1008
+ role: item.role,
1009
+ content: [{ type: "input_text", text: item.content.text }]
1010
+ });
1011
+ continue;
1012
+ }
1013
+ if (item instanceof ModelMessageItem) {
1014
+ input.push({
1015
+ type: item.type,
1016
+ role: item.role,
1017
+ content: [{ type: "output_text", text: item.content.text }]
1018
+ });
1019
+ continue;
1020
+ }
1021
+ if (item instanceof FunctionCallItem) {
1022
+ input.push({
1023
+ type: item.type,
1024
+ call_id: item.callId,
1025
+ name: item.name,
1026
+ arguments: item.args
1027
+ });
1028
+ continue;
1029
+ }
1030
+ if (item instanceof FunctionCallOutputItem) {
1031
+ input.push({
1032
+ type: item.type,
1033
+ call_id: item.callId,
1034
+ output: [{ type: "input_text", text: item.output.text }]
1035
+ });
1036
+ continue;
1037
+ }
1038
+ if (item instanceof ReasoningItem) {
1039
+ const reasoningInput = {
1040
+ type: item.type,
1041
+ summary: item.summary.map((summary) => ({ type: "summary_text", text: summary.text }))
1042
+ };
1043
+ if (item.encryptedContent !== void 0) {
1044
+ reasoningInput.encrypted_content = item.encryptedContent;
1045
+ }
1046
+ input.push(reasoningInput);
1047
+ }
1048
+ }
1049
+ return input;
1384
1050
  }
1385
- };
1386
-
1387
- // src/infrastructure/providers/deepseek/models/deepseek-v4-pro.ts
1388
- var DeepSeekV4Pro = class {
1389
- constructor() {
1390
- this.specification = {
1391
- name: "deepseek-v4-pro",
1392
- provider: "deepseek",
1393
- supportReasoningEffort: true,
1394
- defaultReasoningEffort: "high",
1395
- supportStreaming: true,
1396
- contextWindowSize: 1e6,
1397
- maxOutputTokens: 384e3,
1398
- supportFunctionCalling: true,
1399
- supportStructuredOutput: false
1400
- };
1401
- this.tools = [];
1402
- this.streaming = false;
1403
- this.structuredOutput = void 0;
1404
- this.effort = new DeepSeekReasoningEffort(
1405
- this.specification.defaultReasoningEffort
1051
+ extractTokenUsage(response) {
1052
+ var _a, _b, _c, _d;
1053
+ if (!response.usage) {
1054
+ return void 0;
1055
+ }
1056
+ return new TokenUsage(
1057
+ response.usage.input_tokens,
1058
+ response.usage.output_tokens,
1059
+ response.usage.total_tokens,
1060
+ new InputTokenDetails((_b = (_a = response.usage.input_tokens_details) == null ? void 0 : _a.cached_tokens) != null ? _b : 0),
1061
+ new OutputTokenDetails((_d = (_c = response.usage.output_tokens_details) == null ? void 0 : _c.reasoning_tokens) != null ? _d : 0)
1406
1062
  );
1407
1063
  }
1408
- setStreaming(streaming) {
1409
- this.streaming = streaming;
1410
- }
1411
- getStreaming() {
1412
- return this.streaming;
1413
- }
1414
- setTools(tools) {
1415
- this.tools = tools;
1416
- }
1417
- getTools() {
1418
- return this.tools;
1419
- }
1420
- setReasoningEffort(effort) {
1421
- this.effort.setReasoningEffort(effort);
1422
- }
1423
- getReasoningEffort() {
1424
- return this.effort.getReasoningEffort();
1425
- }
1426
- setStructuredOutput(format) {
1427
- this.structuredOutput = format;
1428
- }
1429
- getStructuredOutput() {
1430
- return this.structuredOutput;
1431
- }
1432
- hasStructuredOutput() {
1433
- return this.structuredOutput !== void 0;
1064
+ extractContextItems(response) {
1065
+ var _a, _b, _c;
1066
+ const items = [];
1067
+ for (const item of (_a = response.output) != null ? _a : []) {
1068
+ if (item.type === "message" && item.role === "assistant") {
1069
+ const firstContent = (_b = item.content) == null ? void 0 : _b[0];
1070
+ if (firstContent) {
1071
+ items.push(ModelMessageItem.rehydrate(firstContent));
1072
+ }
1073
+ continue;
1074
+ }
1075
+ if (item.type === "function_call") {
1076
+ items.push(
1077
+ FunctionCallItem.rehydrate({
1078
+ callId: item.call_id,
1079
+ name: item.name,
1080
+ args: item.arguments
1081
+ })
1082
+ );
1083
+ continue;
1084
+ }
1085
+ if (item.type === "reasoning") {
1086
+ items.push(
1087
+ ReasoningItem.rehydrate({
1088
+ content: void 0,
1089
+ encryptedContent: item.encrypted_content,
1090
+ summary: ((_c = item.summary) != null ? _c : []).map(
1091
+ (summary) => SummaryText.rehydrate({ text: summary.text })
1092
+ )
1093
+ })
1094
+ );
1095
+ }
1096
+ }
1097
+ return items;
1434
1098
  }
1435
1099
  };
1436
1100
 
1437
- // src/infrastructure/providers/gemini/runtime/gemini-generate-content.ts
1438
- var import_genai = require("@google/genai");
1439
- var GeminiGenerateContent = class {
1440
- constructor() {
1441
- this.client = new import_genai.GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
1101
+ // src/infrastructure/providers/openai/endpoints/openai-responses.ts
1102
+ var OpenAIResponses = class {
1103
+ constructor(endpointMapper = new OpenAIResponsesMapper()) {
1104
+ this.endpointMapper = endpointMapper;
1105
+ this.client = new import_openai.default();
1442
1106
  }
1443
- async infer(inferenceRequest) {
1444
- const response = await this.client.models.generateContent(this.buildRequest(inferenceRequest));
1445
- const contextItems = this.extractContextItems(response);
1446
- const tokenUsage = this.extractTokenUsage(response);
1447
- return new InferenceResponse(contextItems, tokenUsage);
1107
+ async infer(inferenceParams) {
1108
+ const request = this.endpointMapper.toRequest(inferenceParams);
1109
+ const response = await this.client.responses.create(request);
1110
+ return this.endpointMapper.toResponse(response);
1448
1111
  }
1449
- async *stream(inferenceRequest, signal) {
1450
- const stream = await this.client.models.generateContentStream(this.buildRequest(inferenceRequest));
1451
- for await (const chunk of stream) {
1112
+ async *stream(inferenceParams, signal) {
1113
+ const request = this.endpointMapper.toRequest(inferenceParams);
1114
+ const response = await this.client.responses.create(request);
1115
+ for await (const event of response) {
1452
1116
  if (signal == null ? void 0 : signal.aborted) {
1453
1117
  break;
1454
1118
  }
1455
- yield new SemanticEvent("generate_content_chunk", chunk);
1119
+ yield new SemanticEvent(event.type, event);
1456
1120
  }
1457
1121
  }
1458
- buildRequest(inferenceRequest) {
1459
- const specification = inferenceRequest.model.specification;
1460
- const { contents, systemInstruction } = this.mapContextToRequest(inferenceRequest.context);
1122
+ };
1123
+
1124
+ // src/infrastructure/providers/gemini/endpoints/gemini-generate-content.ts
1125
+ var import_genai = require("@google/genai");
1126
+
1127
+ // src/infrastructure/providers/gemini/endpoints/gemini-generate-content-mapper.ts
1128
+ var GeminiGenerateContentMapper = class {
1129
+ toRequest(inferenceParams) {
1130
+ const { contents, systemInstruction } = this.mapContextItems(inferenceParams);
1461
1131
  const config = {};
1462
1132
  if (systemInstruction) {
1463
1133
  config.systemInstruction = systemInstruction;
1464
1134
  }
1465
- if (specification.supportFunctionCalling && inferenceRequest.model.getTools().length > 0) {
1135
+ if (inferenceParams.tools && inferenceParams.tools.length > 0) {
1466
1136
  config.tools = [
1467
1137
  {
1468
- functionDeclarations: inferenceRequest.model.getTools().map((tool) => {
1469
- return {
1470
- name: tool.name,
1471
- description: tool.description,
1472
- parametersJsonSchema: tool.parameters
1473
- };
1474
- })
1138
+ functionDeclarations: inferenceParams.tools.map((tool) => ({
1139
+ name: tool.name,
1140
+ description: tool.description,
1141
+ parametersJsonSchema: tool.parameters
1142
+ }))
1475
1143
  }
1476
1144
  ];
1477
1145
  }
1478
- if (specification.supportReasoningEffort) {
1479
- const effort = inferenceRequest.model.getReasoningEffort();
1480
- const thinkingLevel = effort === "none" ? "minimal" : effort;
1481
- config.thinkingConfig = { thinkingLevel, includeThoughts: true };
1482
- }
1483
- if (inferenceRequest.model.hasStructuredOutput()) {
1484
- if (!specification.supportStructuredOutput) {
1485
- throw new Error(`Structured output is not supported for model: ${specification.name}`);
1486
- }
1487
- const format = inferenceRequest.model.getStructuredOutput();
1146
+ if (inferenceParams.structuredOutput) {
1488
1147
  config.responseMimeType = "application/json";
1489
- config.responseSchema = format.schema;
1148
+ config.responseSchema = inferenceParams.structuredOutput.schema;
1490
1149
  }
1491
- return { model: specification.name, contents, config };
1492
- }
1493
- extractTokenUsage(response) {
1494
- var _a, _b, _c, _d, _e;
1495
- const usage = response.usageMetadata;
1496
- if (!usage) {
1497
- return void 0;
1150
+ if (inferenceParams.reasoningEffort) {
1151
+ config.thinkingConfig = {
1152
+ thinkingLevel: inferenceParams.reasoningEffort,
1153
+ includeThoughts: true
1154
+ };
1498
1155
  }
1499
- return new TokenUsage(
1500
- (_a = usage.promptTokenCount) != null ? _a : 0,
1501
- (_b = usage.candidatesTokenCount) != null ? _b : 0,
1502
- (_c = usage.totalTokenCount) != null ? _c : 0,
1503
- new InputTokenDetails((_d = usage.cachedContentTokenCount) != null ? _d : 0),
1504
- new OutputTokenDetails((_e = usage.thoughtsTokenCount) != null ? _e : 0)
1505
- );
1156
+ const request = {
1157
+ model: inferenceParams.model,
1158
+ contents,
1159
+ config
1160
+ };
1161
+ if (inferenceParams.streaming) {
1162
+ request.stream = inferenceParams.streaming;
1163
+ }
1164
+ return request;
1165
+ }
1166
+ toResponse(response) {
1167
+ const contextItems = this.extractContextItems(response);
1168
+ const tokenUsage = this.extractTokenUsage(response);
1169
+ return new InferenceResponse(contextItems, tokenUsage);
1506
1170
  }
1507
- mapContextToRequest(context) {
1171
+ mapContextItems(inferenceParams) {
1508
1172
  var _a;
1173
+ const context = inferenceParams.context;
1509
1174
  const contents = [];
1510
1175
  const system = [];
1511
1176
  const callNames = /* @__PURE__ */ new Map();
@@ -1548,45 +1213,6 @@ var GeminiGenerateContent = class {
1548
1213
  systemInstruction: system.length > 0 ? system.join("\n\n") : void 0
1549
1214
  };
1550
1215
  }
1551
- extractContextItems(response) {
1552
- var _a, _b, _c, _d, _e, _f;
1553
- const items = [];
1554
- const parts = (_d = (_c = (_b = (_a = response.candidates) == null ? void 0 : _a[0]) == null ? void 0 : _b.content) == null ? void 0 : _c.parts) != null ? _d : [];
1555
- for (const part of parts) {
1556
- if (part.thought && part.text) {
1557
- items.push(
1558
- ReasoningItem.rehydrate({
1559
- content: InputText.rehydrate({ text: part.text }),
1560
- encryptedContent: void 0,
1561
- summary: []
1562
- })
1563
- );
1564
- continue;
1565
- }
1566
- if (part.text) {
1567
- items.push(ModelMessageItem.rehydrate({ text: part.text }));
1568
- continue;
1569
- }
1570
- if (part.functionCall) {
1571
- items.push(
1572
- FunctionCallItem.rehydrate({
1573
- callId: (_e = part.functionCall.id) != null ? _e : "",
1574
- name: part.functionCall.name,
1575
- args: JSON.stringify((_f = part.functionCall.args) != null ? _f : {})
1576
- })
1577
- );
1578
- }
1579
- }
1580
- return items;
1581
- }
1582
- parseResponse(output) {
1583
- try {
1584
- const parsed = JSON.parse(output);
1585
- return parsed && typeof parsed === "object" ? parsed : { output };
1586
- } catch (e) {
1587
- return { output };
1588
- }
1589
- }
1590
1216
  addPart(contents, role, part) {
1591
1217
  const last = contents[contents.length - 1];
1592
1218
  if ((last == null ? void 0 : last.role) === role) {
@@ -1595,195 +1221,118 @@ var GeminiGenerateContent = class {
1595
1221
  }
1596
1222
  contents.push({ role, parts: [part] });
1597
1223
  }
1598
- };
1599
-
1600
- // src/infrastructure/providers/gemini/reasoning-effort.ts
1601
- var GeminiReasoningEffort = class {
1602
- constructor(reasoningEffort) {
1603
- this.reasoningEffort = reasoningEffort;
1604
- }
1605
- setReasoningEffort(effort) {
1606
- this.reasoningEffort = effort;
1607
- }
1608
- getReasoningEffort() {
1609
- if (!this.reasoningEffort) {
1610
- throw new Error("Reasoning effort not supported");
1611
- }
1612
- return this.reasoningEffort;
1613
- }
1614
- };
1615
-
1616
- // src/infrastructure/providers/gemini/models/gemini-3-5-flash.ts
1617
- var Gemini35Flash = class {
1618
- constructor() {
1619
- this.specification = {
1620
- name: "gemini-3.5-flash",
1621
- provider: "google",
1622
- supportReasoningEffort: true,
1623
- defaultReasoningEffort: "medium",
1624
- supportStreaming: true,
1625
- contextWindowSize: 1048576,
1626
- maxOutputTokens: 64e3,
1627
- supportFunctionCalling: true,
1628
- supportStructuredOutput: true
1629
- };
1630
- this.tools = [];
1631
- this.streaming = false;
1632
- this.structuredOutput = void 0;
1633
- this.effort = new GeminiReasoningEffort(
1634
- this.specification.defaultReasoningEffort
1635
- );
1636
- }
1637
- setStreaming(streaming) {
1638
- this.streaming = streaming;
1639
- }
1640
- getStreaming() {
1641
- return this.streaming;
1642
- }
1643
- setTools(tools) {
1644
- this.tools = tools;
1645
- }
1646
- getTools() {
1647
- return this.tools;
1648
- }
1649
- setReasoningEffort(effort) {
1650
- this.effort.setReasoningEffort(effort);
1651
- }
1652
- getReasoningEffort() {
1653
- return this.effort.getReasoningEffort();
1654
- }
1655
- setStructuredOutput(format) {
1656
- this.structuredOutput = format;
1657
- }
1658
- getStructuredOutput() {
1659
- return this.structuredOutput;
1660
- }
1661
- hasStructuredOutput() {
1662
- return this.structuredOutput !== void 0;
1663
- }
1664
- };
1665
-
1666
- // src/infrastructure/providers/gemini/models/gemini-3-1-pro.ts
1667
- var Gemini31Pro = class {
1668
- constructor() {
1669
- this.specification = {
1670
- name: "gemini-3.1-pro-preview",
1671
- provider: "google",
1672
- supportReasoningEffort: true,
1673
- defaultReasoningEffort: "high",
1674
- supportStreaming: true,
1675
- contextWindowSize: 1048576,
1676
- maxOutputTokens: 64e3,
1677
- supportFunctionCalling: true,
1678
- supportStructuredOutput: true
1679
- };
1680
- this.tools = [];
1681
- this.streaming = false;
1682
- this.structuredOutput = void 0;
1683
- this.effort = new GeminiReasoningEffort(
1684
- this.specification.defaultReasoningEffort
1685
- );
1686
- }
1687
- setStreaming(streaming) {
1688
- this.streaming = streaming;
1689
- }
1690
- getStreaming() {
1691
- return this.streaming;
1692
- }
1693
- setTools(tools) {
1694
- this.tools = tools;
1695
- }
1696
- getTools() {
1697
- return this.tools;
1698
- }
1699
- setReasoningEffort(effort) {
1700
- this.effort.setReasoningEffort(effort);
1701
- }
1702
- getReasoningEffort() {
1703
- return this.effort.getReasoningEffort();
1704
- }
1705
- setStructuredOutput(format) {
1706
- this.structuredOutput = format;
1224
+ parseResponse(output) {
1225
+ try {
1226
+ const parsed = JSON.parse(output);
1227
+ return parsed && typeof parsed === "object" ? parsed : { output };
1228
+ } catch (e) {
1229
+ return { output };
1230
+ }
1707
1231
  }
1708
- getStructuredOutput() {
1709
- return this.structuredOutput;
1232
+ extractTokenUsage(response) {
1233
+ var _a, _b, _c, _d, _e;
1234
+ const usage = response.usageMetadata;
1235
+ if (!usage) {
1236
+ return void 0;
1237
+ }
1238
+ return new TokenUsage(
1239
+ (_a = usage.promptTokenCount) != null ? _a : 0,
1240
+ (_b = usage.candidatesTokenCount) != null ? _b : 0,
1241
+ (_c = usage.totalTokenCount) != null ? _c : 0,
1242
+ new InputTokenDetails((_d = usage.cachedContentTokenCount) != null ? _d : 0),
1243
+ new OutputTokenDetails((_e = usage.thoughtsTokenCount) != null ? _e : 0)
1244
+ );
1710
1245
  }
1711
- hasStructuredOutput() {
1712
- return this.structuredOutput !== void 0;
1246
+ extractContextItems(response) {
1247
+ var _a, _b, _c, _d, _e, _f;
1248
+ const items = [];
1249
+ const parts = (_d = (_c = (_b = (_a = response.candidates) == null ? void 0 : _a[0]) == null ? void 0 : _b.content) == null ? void 0 : _c.parts) != null ? _d : [];
1250
+ for (const part of parts) {
1251
+ if (part.thought && part.text) {
1252
+ items.push(
1253
+ ReasoningItem.rehydrate({
1254
+ content: InputText.rehydrate({ text: part.text }),
1255
+ encryptedContent: void 0,
1256
+ summary: []
1257
+ })
1258
+ );
1259
+ continue;
1260
+ }
1261
+ if (part.text) {
1262
+ items.push(ModelMessageItem.rehydrate({ text: part.text }));
1263
+ continue;
1264
+ }
1265
+ if (part.functionCall) {
1266
+ items.push(
1267
+ FunctionCallItem.rehydrate({
1268
+ callId: (_e = part.functionCall.id) != null ? _e : "",
1269
+ name: part.functionCall.name,
1270
+ args: JSON.stringify((_f = part.functionCall.args) != null ? _f : {})
1271
+ })
1272
+ );
1273
+ }
1274
+ }
1275
+ return items;
1713
1276
  }
1714
1277
  };
1715
1278
 
1716
- // src/infrastructure/providers/openai/runtime/openai-chat-completions.ts
1717
- var import_openai2 = __toESM(require("openai"));
1718
- var OpenAIChatCompletions = class {
1719
- constructor(config = {}) {
1720
- var _a;
1721
- this.client = new import_openai2.default({
1722
- baseURL: config.baseURL,
1723
- apiKey: config.apiKey
1724
- });
1725
- this.extraBody = (_a = config.extraBody) != null ? _a : {};
1279
+ // src/infrastructure/providers/gemini/endpoints/gemini-generate-content.ts
1280
+ var GeminiGenerateContent = class {
1281
+ constructor(endpointMapper = new GeminiGenerateContentMapper()) {
1282
+ this.endpointMapper = endpointMapper;
1283
+ this.client = new import_genai.GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
1726
1284
  }
1727
- async infer(inferenceRequest) {
1728
- const response = await this.client.chat.completions.create(this.buildRequest(inferenceRequest));
1729
- const contextItems = this.extractContextItems(response);
1730
- const tokenUsage = this.extractTokenUsage(response);
1731
- return new InferenceResponse(contextItems, tokenUsage);
1285
+ async infer(inferenceParams) {
1286
+ const inferenceRequest = this.endpointMapper.toRequest(inferenceParams);
1287
+ const response = await this.client.models.generateContent(inferenceRequest);
1288
+ return this.endpointMapper.toResponse(response);
1732
1289
  }
1733
- async *stream(inferenceRequest, signal) {
1734
- var _a;
1735
- const stream = await this.client.chat.completions.create({
1736
- ...this.buildRequest(inferenceRequest),
1737
- stream: true
1738
- });
1739
- for await (const event of stream) {
1290
+ async *stream(inferenceParams, signal) {
1291
+ const inferenceRequest = this.endpointMapper.toRequest(inferenceParams);
1292
+ const stream = await this.client.models.generateContentStream(inferenceRequest);
1293
+ for await (const chunk of stream) {
1740
1294
  if (signal == null ? void 0 : signal.aborted) {
1741
1295
  break;
1742
1296
  }
1743
- yield new SemanticEvent((_a = event.object) != null ? _a : "chat.completion.chunk", event);
1297
+ yield new SemanticEvent("generate_content_chunk", chunk);
1744
1298
  }
1745
1299
  }
1746
- buildRequest(inferenceRequest) {
1747
- const specification = inferenceRequest.model.specification;
1300
+ };
1301
+
1302
+ // src/infrastructure/providers/openai/endpoints/openai-chat-completions-mapper.ts
1303
+ var OpenAIChatCompletionsMapper = class {
1304
+ toRequest(inferenceParams) {
1748
1305
  const request = {
1749
- ...this.extraBody,
1750
- model: specification.name,
1751
- messages: this.mapContextToRequest(inferenceRequest.context)
1306
+ model: inferenceParams.model,
1307
+ messages: this.mapContextItems(inferenceParams)
1752
1308
  };
1753
- if (specification.supportFunctionCalling && inferenceRequest.model.getTools().length > 0) {
1754
- request.tools = inferenceRequest.model.getTools().map((tool) => {
1755
- return {
1756
- type: "function",
1757
- function: {
1758
- name: tool.name,
1759
- description: tool.description,
1760
- parameters: tool.parameters
1761
- }
1762
- };
1763
- });
1309
+ if (inferenceParams.tools && inferenceParams.tools.length > 0) {
1310
+ request.tools = inferenceParams.tools.map((tool) => ({
1311
+ type: "function",
1312
+ function: {
1313
+ name: tool.name,
1314
+ description: tool.description,
1315
+ parameters: tool.parameters
1316
+ }
1317
+ }));
1318
+ }
1319
+ if (inferenceParams.reasoningEffort) {
1320
+ request.reasoning_effort = inferenceParams.reasoningEffort;
1764
1321
  }
1765
- if (specification.supportReasoningEffort) {
1766
- request.reasoning_effort = inferenceRequest.model.getReasoningEffort();
1322
+ if (inferenceParams.streaming) {
1323
+ request.stream = inferenceParams.streaming;
1767
1324
  }
1768
1325
  return request;
1769
1326
  }
1770
- extractTokenUsage(response) {
1771
- var _a, _b, _c, _d;
1772
- if (!response.usage) {
1773
- return void 0;
1774
- }
1775
- return new TokenUsage(
1776
- response.usage.prompt_tokens,
1777
- response.usage.completion_tokens,
1778
- response.usage.total_tokens,
1779
- new InputTokenDetails((_b = (_a = response.usage.prompt_tokens_details) == null ? void 0 : _a.cached_tokens) != null ? _b : 0),
1780
- new OutputTokenDetails((_d = (_c = response.usage.completion_tokens_details) == null ? void 0 : _c.reasoning_tokens) != null ? _d : 0)
1781
- );
1327
+ toResponse(response) {
1328
+ const contextItems = this.extractContextItems(response);
1329
+ const tokenUsage = this.extractTokenUsage(response);
1330
+ return new InferenceResponse(contextItems, tokenUsage);
1782
1331
  }
1783
- mapContextToRequest(context) {
1332
+ mapContextItems(inferenceParams) {
1784
1333
  var _a;
1785
1334
  const messages = [];
1786
- for (const item of context.getItems()) {
1335
+ for (const item of inferenceParams.context.getItems()) {
1787
1336
  if (item instanceof DeveloperMessageItem || item instanceof SystemMessageItem) {
1788
1337
  messages.push({ role: "system", content: item.content.text });
1789
1338
  continue;
@@ -1817,6 +1366,19 @@ var OpenAIChatCompletions = class {
1817
1366
  }
1818
1367
  return messages;
1819
1368
  }
1369
+ extractTokenUsage(response) {
1370
+ var _a, _b, _c, _d;
1371
+ if (!response.usage) {
1372
+ return void 0;
1373
+ }
1374
+ return new TokenUsage(
1375
+ response.usage.prompt_tokens,
1376
+ response.usage.completion_tokens,
1377
+ response.usage.total_tokens,
1378
+ new InputTokenDetails((_b = (_a = response.usage.prompt_tokens_details) == null ? void 0 : _a.cached_tokens) != null ? _b : 0),
1379
+ new OutputTokenDetails((_d = (_c = response.usage.completion_tokens_details) == null ? void 0 : _c.reasoning_tokens) != null ? _d : 0)
1380
+ );
1381
+ }
1820
1382
  extractContextItems(response) {
1821
1383
  var _a, _b, _c;
1822
1384
  const items = [];
@@ -1849,179 +1411,482 @@ var OpenAIChatCompletions = class {
1849
1411
  }
1850
1412
  };
1851
1413
 
1852
- // src/application/services/inference-runner.ts
1853
- var InferenceRunner = class {
1854
- async *run(context, modelInfo, signal) {
1855
- const { model, endpoint } = modelInfo;
1856
- const request = new InferenceRequest(model, context);
1857
- if (model.getStreaming()) {
1858
- yield* endpoint.stream(request);
1859
- return;
1860
- }
1861
- const response = await endpoint.infer(request);
1862
- for (const item of response.contextItems) {
1863
- if (signal == null ? void 0 : signal.aborted) {
1864
- break;
1865
- }
1866
- yield item;
1867
- }
1414
+ // src/infrastructure/providers/openai/endpoints/openai-chat-completions.ts
1415
+ var import_openai2 = __toESM(require("openai"));
1416
+ var OpenAIChatCompletions = class {
1417
+ constructor(endpointMapper = new OpenAIChatCompletionsMapper(), config = {}) {
1418
+ var _a;
1419
+ this.endpointMapper = endpointMapper;
1420
+ this.client = new import_openai2.default({
1421
+ baseURL: config.baseURL,
1422
+ apiKey: config.apiKey
1423
+ });
1424
+ this.extraBody = (_a = config.extraBody) != null ? _a : {};
1868
1425
  }
1869
- };
1870
-
1871
- // src/application/use-cases/run-inference.ts
1872
- var RunInference = class {
1873
- constructor(modelRepository, inferenceRunner) {
1874
- this.modelRepository = modelRepository;
1875
- this.inferenceRunner = inferenceRunner;
1426
+ buildRequest(inferenceParams) {
1427
+ return {
1428
+ ...this.extraBody,
1429
+ ...this.endpointMapper.toRequest(inferenceParams)
1430
+ };
1876
1431
  }
1877
- setModelCapabilities(model, inferenceParams) {
1878
- const { streaming, tools, reasoningEffort, structuredOutput } = inferenceParams;
1879
- if (streaming) {
1880
- model.setStreaming(true);
1881
- }
1882
- if (tools) {
1883
- model.setTools(tools);
1884
- }
1885
- if (reasoningEffort) {
1886
- model.setReasoningEffort(reasoningEffort);
1887
- }
1888
- if (structuredOutput) {
1889
- model.setStructuredOutput(structuredOutput);
1890
- }
1891
- return model;
1432
+ async infer(inferenceParams) {
1433
+ const response = await this.client.chat.completions.create(this.buildRequest(inferenceParams));
1434
+ return this.endpointMapper.toResponse(response);
1892
1435
  }
1893
- async execute(inferenceParams) {
1894
- const { model, context, caller, environment, signal } = inferenceParams;
1895
- const modelInfo = this.modelRepository.getModelInfo(model);
1896
- const generativeModel = this.setModelCapabilities(modelInfo.model, inferenceParams);
1897
- modelInfo.model = generativeModel;
1898
- const result = this.inferenceRunner.run(context, modelInfo, signal);
1899
- for await (const item of result) {
1436
+ async *stream(inferenceParams, signal) {
1437
+ var _a;
1438
+ const stream = await this.client.chat.completions.create(this.buildRequest(inferenceParams));
1439
+ for await (const event of stream) {
1900
1440
  if (signal == null ? void 0 : signal.aborted) {
1901
1441
  break;
1902
1442
  }
1903
- if (item instanceof ReasoningItem) {
1904
- environment.deliverReasoning(caller, item);
1905
- } else if (item instanceof FunctionCallItem) {
1906
- environment.deliverFunctionCall(caller, item);
1907
- } else if (item instanceof ModelMessageItem) {
1908
- environment.deliverModelMessage(caller, item);
1909
- } else if (item instanceof SemanticEvent) {
1910
- environment.deliverSemanticEvent(caller, item);
1911
- }
1443
+ yield new SemanticEvent((_a = event.object) != null ? _a : "chat.completion.chunk", event);
1912
1444
  }
1913
1445
  }
1914
1446
  };
1915
1447
 
1916
- // src/application/use-cases/execute-function-call.ts
1917
- var ExecuteFunctionCall = class {
1918
- constructor(functionCallRunner) {
1919
- this.functionCallRunner = functionCallRunner;
1920
- }
1921
- async execute(environment, functionCallItem, tool, caller, signal) {
1922
- const stream = this.functionCallRunner.run(functionCallItem, tool, signal);
1923
- for await (const item of stream) {
1924
- environment.deliverFunctionCallOutput(caller, item);
1925
- }
1926
- }
1448
+ // src/infrastructure/providers/anthropic/models/claude-4-6-sonnet.ts
1449
+ var claudeSonnet46Specification = {
1450
+ name: "claude-sonnet-4-6",
1451
+ provider: "anthropic",
1452
+ supportsReasoningEffort: true,
1453
+ supportedReasoningEfforts: ["max", "high", "medium", "low"],
1454
+ supportedContextItemTypes: [
1455
+ "user_message",
1456
+ "system_message",
1457
+ "developer_message",
1458
+ "reasoning",
1459
+ "function_call",
1460
+ "function_call_output",
1461
+ "model_message"
1462
+ ],
1463
+ supportsStreaming: true,
1464
+ contextWindowSize: 2e5,
1465
+ maxOutputTokens: 64e3,
1466
+ supportsFunctionCalling: true,
1467
+ supportsStructuredOutput: true
1468
+ };
1469
+
1470
+ // src/infrastructure/providers/anthropic/models/claude-4-8-opus.ts
1471
+ var claudeOpus48Specification = {
1472
+ name: "claude-opus-4-8",
1473
+ provider: "anthropic",
1474
+ supportsReasoningEffort: true,
1475
+ supportedReasoningEfforts: ["max", "xhigh", "high", "medium", "low"],
1476
+ supportedContextItemTypes: [
1477
+ "user_message",
1478
+ "system_message",
1479
+ "developer_message",
1480
+ "reasoning",
1481
+ "function_call",
1482
+ "function_call_output",
1483
+ "model_message"
1484
+ ],
1485
+ supportsStreaming: true,
1486
+ contextWindowSize: 2e5,
1487
+ maxOutputTokens: 32e3,
1488
+ supportsFunctionCalling: true,
1489
+ supportsStructuredOutput: true
1490
+ };
1491
+
1492
+ // src/infrastructure/providers/anthropic/models/claude-4-7-opus.ts
1493
+ var claudeOpus47Specification = {
1494
+ name: "claude-opus-4-7",
1495
+ provider: "anthropic",
1496
+ supportsReasoningEffort: true,
1497
+ supportedReasoningEfforts: ["max", "xhigh", "high", "medium", "low"],
1498
+ supportedContextItemTypes: [
1499
+ "user_message",
1500
+ "system_message",
1501
+ "developer_message",
1502
+ "reasoning",
1503
+ "function_call",
1504
+ "function_call_output",
1505
+ "model_message"
1506
+ ],
1507
+ supportsStreaming: true,
1508
+ contextWindowSize: 2e5,
1509
+ maxOutputTokens: 32e3,
1510
+ supportsFunctionCalling: true,
1511
+ supportsStructuredOutput: true
1512
+ };
1513
+
1514
+ // src/infrastructure/providers/gemini/models/gemini-3-5-flash.ts
1515
+ var gemini35FlashSpecification = {
1516
+ name: "gemini-3.5-flash",
1517
+ provider: "google",
1518
+ supportsReasoningEffort: true,
1519
+ supportedReasoningEfforts: ["high", "medium", "low", "minimal", "none"],
1520
+ supportedContextItemTypes: [
1521
+ "user_message",
1522
+ "system_message",
1523
+ "developer_message",
1524
+ "reasoning",
1525
+ "function_call",
1526
+ "function_call_output",
1527
+ "model_message"
1528
+ ],
1529
+ supportsStreaming: true,
1530
+ contextWindowSize: 1048576,
1531
+ maxOutputTokens: 64e3,
1532
+ supportsFunctionCalling: true,
1533
+ supportsStructuredOutput: true
1534
+ };
1535
+
1536
+ // src/infrastructure/providers/gemini/models/gemini-3-1-pro.ts
1537
+ var gemini31ProSpecification = {
1538
+ name: "gemini-3.1-pro-preview",
1539
+ provider: "google",
1540
+ supportsReasoningEffort: true,
1541
+ supportedReasoningEfforts: ["high", "medium", "low", "minimal", "none"],
1542
+ supportedContextItemTypes: [
1543
+ "user_message",
1544
+ "system_message",
1545
+ "developer_message",
1546
+ "reasoning",
1547
+ "function_call",
1548
+ "function_call_output",
1549
+ "model_message"
1550
+ ],
1551
+ supportsStreaming: true,
1552
+ contextWindowSize: 1048576,
1553
+ maxOutputTokens: 64e3,
1554
+ supportsFunctionCalling: true,
1555
+ supportsStructuredOutput: true
1556
+ };
1557
+
1558
+ // src/infrastructure/providers/deepseek/models/deepseek-v4-flash.ts
1559
+ var deepSeekV4FlashSpecification = {
1560
+ name: "deepseek-v4-flash",
1561
+ provider: "deepseek",
1562
+ supportsReasoningEffort: true,
1563
+ supportedReasoningEfforts: ["max", "high", "medium", "low", "none"],
1564
+ supportedContextItemTypes: [
1565
+ "user_message",
1566
+ "system_message",
1567
+ "developer_message",
1568
+ "reasoning",
1569
+ "function_call",
1570
+ "function_call_output",
1571
+ "model_message"
1572
+ ],
1573
+ supportsStreaming: true,
1574
+ contextWindowSize: 1e6,
1575
+ maxOutputTokens: 384e3,
1576
+ supportsFunctionCalling: true,
1577
+ supportsStructuredOutput: false
1578
+ };
1579
+
1580
+ // src/infrastructure/providers/deepseek/models/deepseek-v4-pro.ts
1581
+ var deepSeekV4ProSpecification = {
1582
+ name: "deepseek-v4-pro",
1583
+ provider: "deepseek",
1584
+ supportsReasoningEffort: true,
1585
+ supportedReasoningEfforts: ["max", "high", "medium", "low", "none"],
1586
+ supportedContextItemTypes: [
1587
+ "user_message",
1588
+ "system_message",
1589
+ "developer_message",
1590
+ "reasoning",
1591
+ "function_call",
1592
+ "function_call_output",
1593
+ "model_message"
1594
+ ],
1595
+ supportsStreaming: true,
1596
+ contextWindowSize: 1e6,
1597
+ maxOutputTokens: 384e3,
1598
+ supportsFunctionCalling: true,
1599
+ supportsStructuredOutput: false
1600
+ };
1601
+
1602
+ // src/infrastructure/providers/openai/models/gpt-5-4.ts
1603
+ var gpt54Specification = {
1604
+ name: "gpt-5.4",
1605
+ provider: "openai",
1606
+ supportsReasoningEffort: true,
1607
+ supportedReasoningEfforts: ["xhigh", "high", "medium", "low", "none"],
1608
+ supportedContextItemTypes: [
1609
+ "user_message",
1610
+ "system_message",
1611
+ "developer_message",
1612
+ "reasoning",
1613
+ "function_call",
1614
+ "function_call_output",
1615
+ "model_message"
1616
+ ],
1617
+ supportsStreaming: true,
1618
+ contextWindowSize: 105e4,
1619
+ maxOutputTokens: 128e3,
1620
+ supportsFunctionCalling: true,
1621
+ supportsStructuredOutput: true
1622
+ };
1623
+
1624
+ // src/infrastructure/providers/openai/models/gpt-5-4-mini.ts
1625
+ var gpt54MiniSpecification = {
1626
+ name: "gpt-5.4-mini",
1627
+ provider: "openai",
1628
+ supportsReasoningEffort: true,
1629
+ supportedReasoningEfforts: ["xhigh", "high", "medium", "low", "none"],
1630
+ supportedContextItemTypes: [
1631
+ "user_message",
1632
+ "system_message",
1633
+ "developer_message",
1634
+ "reasoning",
1635
+ "function_call",
1636
+ "function_call_output",
1637
+ "model_message"
1638
+ ],
1639
+ supportsStreaming: true,
1640
+ contextWindowSize: 4e5,
1641
+ maxOutputTokens: 128e3,
1642
+ supportsFunctionCalling: true,
1643
+ supportsStructuredOutput: true
1644
+ };
1645
+
1646
+ // src/infrastructure/providers/openai/models/gpt-5-4-nano.ts
1647
+ var gpt54NanoSpecification = {
1648
+ name: "gpt-5.4-nano",
1649
+ provider: "openai",
1650
+ supportsReasoningEffort: true,
1651
+ supportedReasoningEfforts: ["xhigh", "high", "medium", "low", "none"],
1652
+ supportedContextItemTypes: [
1653
+ "user_message",
1654
+ "system_message",
1655
+ "developer_message",
1656
+ "reasoning",
1657
+ "function_call",
1658
+ "function_call_output",
1659
+ "model_message"
1660
+ ],
1661
+ supportsStreaming: true,
1662
+ contextWindowSize: 4e5,
1663
+ maxOutputTokens: 128e3,
1664
+ supportsFunctionCalling: true,
1665
+ supportsStructuredOutput: true
1666
+ };
1667
+
1668
+ // src/infrastructure/providers/openai/models/gpt-5-5.ts
1669
+ var gpt55Specification = {
1670
+ name: "gpt-5.5",
1671
+ provider: "openai",
1672
+ supportsReasoningEffort: true,
1673
+ supportedReasoningEfforts: ["xhigh", "high", "medium", "low", "none"],
1674
+ supportedContextItemTypes: [
1675
+ "user_message",
1676
+ "system_message",
1677
+ "developer_message",
1678
+ "reasoning",
1679
+ "function_call",
1680
+ "function_call_output",
1681
+ "model_message"
1682
+ ],
1683
+ supportsStreaming: true,
1684
+ contextWindowSize: 105e4,
1685
+ maxOutputTokens: 128e3,
1686
+ supportsFunctionCalling: true,
1687
+ supportsStructuredOutput: true
1688
+ };
1689
+
1690
+ // src/infrastructure/providers/anthropic/models/claude-4-5-haiku.ts
1691
+ var claudeHaiku45Specification = {
1692
+ name: "claude-haiku-4-5",
1693
+ provider: "anthropic",
1694
+ supportsReasoningEffort: true,
1695
+ supportedReasoningEfforts: ["high", "medium", "low", "none"],
1696
+ supportedContextItemTypes: [
1697
+ "user_message",
1698
+ "system_message",
1699
+ "developer_message",
1700
+ "reasoning",
1701
+ "function_call",
1702
+ "function_call_output",
1703
+ "model_message"
1704
+ ],
1705
+ supportsStreaming: true,
1706
+ contextWindowSize: 2e5,
1707
+ maxOutputTokens: 64e3,
1708
+ supportsFunctionCalling: true,
1709
+ supportsStructuredOutput: true
1927
1710
  };
1928
1711
 
1929
- // src/application/services/model-repository.ts
1930
- var ModelRepository = class {
1931
- getModelInfo(model) {
1932
- switch (model) {
1933
- case "gpt-5-4":
1934
- return { endpoint: new OpenAIResponses(), model: new Gpt54() };
1935
- case "gpt-5-4-mini":
1936
- return { endpoint: new OpenAIResponses(), model: new Gpt54Mini() };
1937
- case "gpt-5-4-nano":
1938
- return { endpoint: new OpenAIResponses(), model: new Gpt54Nano() };
1939
- case "gpt-5-5":
1940
- return { endpoint: new OpenAIResponses(), model: new Gpt55() };
1941
- case "claude-4-5-haiku":
1942
- return { endpoint: new AnthropicMessages(), model: new ClaudeHaiku45() };
1943
- case "claude-4-6-sonnet":
1944
- return { endpoint: new AnthropicMessages(), model: new ClaudeSonnet46() };
1945
- case "claude-4-7-opus":
1946
- return { endpoint: new AnthropicMessages(), model: new ClaudeOpus47() };
1947
- case "claude-4-8-opus":
1948
- return { endpoint: new AnthropicMessages(), model: new ClaudeOpus48() };
1949
- case "gemini-3-5-flash":
1950
- return { endpoint: new GeminiGenerateContent(), model: new Gemini35Flash() };
1951
- case "gemini-3-1-pro":
1952
- return { endpoint: new GeminiGenerateContent(), model: new Gemini31Pro() };
1712
+ // src/infrastructure/repository/generative-model-repository.ts
1713
+ var InMemoryGenerativeModelRepository = class {
1714
+ getByModelName(modelName) {
1715
+ let generativeModel = void 0;
1716
+ switch (modelName) {
1717
+ case "gpt-5.4":
1718
+ generativeModel = {
1719
+ endpoint: new OpenAIResponses(),
1720
+ specification: gpt54Specification
1721
+ };
1722
+ break;
1723
+ case "gpt-5.4-mini":
1724
+ generativeModel = {
1725
+ endpoint: new OpenAIResponses(),
1726
+ specification: gpt54MiniSpecification
1727
+ };
1728
+ break;
1729
+ case "gpt-5.4-nano":
1730
+ generativeModel = {
1731
+ endpoint: new OpenAIResponses(),
1732
+ specification: gpt54NanoSpecification
1733
+ };
1734
+ break;
1735
+ case "gpt-5.5":
1736
+ generativeModel = {
1737
+ endpoint: new OpenAIResponses(),
1738
+ specification: gpt55Specification
1739
+ };
1740
+ break;
1741
+ case "claude-haiku-4-5":
1742
+ generativeModel = {
1743
+ endpoint: new AnthropicMessages(),
1744
+ specification: claudeHaiku45Specification
1745
+ };
1746
+ break;
1747
+ case "claude-sonnet-4-6":
1748
+ generativeModel = {
1749
+ endpoint: new AnthropicMessages(),
1750
+ specification: claudeSonnet46Specification
1751
+ };
1752
+ break;
1753
+ case "claude-opus-4-7":
1754
+ generativeModel = {
1755
+ endpoint: new AnthropicMessages(),
1756
+ specification: claudeOpus47Specification
1757
+ };
1758
+ break;
1759
+ case "claude-opus-4-8":
1760
+ generativeModel = {
1761
+ endpoint: new AnthropicMessages(),
1762
+ specification: claudeOpus48Specification
1763
+ };
1764
+ break;
1765
+ case "gemini-3.5-flash":
1766
+ generativeModel = {
1767
+ endpoint: new GeminiGenerateContent(),
1768
+ specification: gemini35FlashSpecification
1769
+ };
1770
+ break;
1771
+ case "gemini-3.1-pro-preview":
1772
+ generativeModel = {
1773
+ endpoint: new GeminiGenerateContent(),
1774
+ specification: gemini31ProSpecification
1775
+ };
1776
+ break;
1953
1777
  case "deepseek-v4-flash":
1954
- return { endpoint: new OpenAIChatCompletions(), model: new DeepSeekV4Flash() };
1778
+ generativeModel = {
1779
+ endpoint: new OpenAIChatCompletions(),
1780
+ specification: deepSeekV4FlashSpecification
1781
+ };
1782
+ break;
1955
1783
  case "deepseek-v4-pro":
1956
- return { endpoint: new OpenAIChatCompletions(), model: new DeepSeekV4Pro() };
1957
- default:
1958
- throw new Error(`Unsupported model: ${model}`);
1784
+ generativeModel = {
1785
+ endpoint: new OpenAIChatCompletions(),
1786
+ specification: deepSeekV4ProSpecification
1787
+ };
1959
1788
  }
1789
+ if (!generativeModel) {
1790
+ throw new Error(`Unsupported model: ${modelName}`);
1791
+ }
1792
+ return Promise.resolve(generativeModel);
1960
1793
  }
1961
1794
  };
1962
1795
 
1963
- // src/application/services/function-call-runner.ts
1964
- var FunctionCallRunner = class {
1965
- async *run(call, tool, signal) {
1966
- if (signal == null ? void 0 : signal.aborted) {
1967
- return;
1796
+ // src/domain/generative-model/request-validation/reasoning-effort.ts
1797
+ var ReasoningEffortValidation = class {
1798
+ constructor() {
1799
+ this.name = "reasoning-effort";
1800
+ }
1801
+ isValid(inferenceParams, model) {
1802
+ if (inferenceParams.reasoningEffort === void 0) {
1803
+ return true;
1968
1804
  }
1969
- if (!tool) throw new Error(`Unknown tool: ${call.name}`);
1970
- const result = await tool.invoke(JSON.parse(call.args));
1971
- yield FunctionCallOutputItem.create(call.callId, JSON.stringify(result));
1805
+ if (!model.supportsReasoningEffort) {
1806
+ return false;
1807
+ }
1808
+ return model.supportedReasoningEfforts.includes(inferenceParams.reasoningEffort);
1972
1809
  }
1973
1810
  };
1974
1811
 
1975
- // src/application/participants/participant.ts
1976
- var BaseParticipant = class extends Participant {
1977
- onFunctionCall(item) {
1978
- }
1979
- onExternalFunctionCall(source, item) {
1980
- }
1981
- onFunctionCallOutput(item) {
1982
- }
1983
- onExternalFunctionCallOutput(source, item) {
1984
- }
1985
- onReasoning(item) {
1986
- }
1987
- onExternalReasoning(source, item) {
1988
- }
1989
- onModelMessage(item) {
1990
- }
1991
- onExternalModelMessage(source, item) {
1812
+ // src/domain/generative-model/request-validation/tool-calling.ts
1813
+ var ToolCallingValidation = class {
1814
+ constructor() {
1815
+ this.name = "tool-calling";
1992
1816
  }
1993
- onMessage(message) {
1817
+ isValid(inferenceParams, model) {
1818
+ if (inferenceParams.tools === void 0) {
1819
+ return true;
1820
+ }
1821
+ return model.supportsFunctionCalling;
1994
1822
  }
1995
- onJoined() {
1823
+ };
1824
+
1825
+ // src/domain/generative-model/request-validation/streaming.ts
1826
+ var StreamingValidation = class {
1827
+ constructor() {
1828
+ this.name = "streaming";
1996
1829
  }
1997
- onLeft() {
1830
+ isValid(inferenceParams, model) {
1831
+ if (!inferenceParams.streaming) {
1832
+ return true;
1833
+ }
1834
+ return model.supportsStreaming;
1998
1835
  }
1999
- onParticipantJoined(participant) {
1836
+ };
1837
+
1838
+ // src/domain/generative-model/request-validation/context.ts
1839
+ function getContextItemValidationKey(item) {
1840
+ if (item instanceof UserMessageItem) {
1841
+ return "user_message";
2000
1842
  }
2001
- onParticipantLeft(participant) {
1843
+ if (item instanceof SystemMessageItem) {
1844
+ return "system_message";
2002
1845
  }
2003
- onInternalEvent(item) {
1846
+ if (item instanceof DeveloperMessageItem) {
1847
+ return "developer_message";
2004
1848
  }
2005
- onExternalEvent(source, item) {
1849
+ if (item instanceof ModelMessageItem) {
1850
+ return "model_message";
2006
1851
  }
2007
- onError(error) {
1852
+ return item.getType();
1853
+ }
1854
+ var ContextValidation = class {
1855
+ constructor() {
1856
+ this.name = "context";
2008
1857
  }
2009
- onParticipantError(source, error) {
1858
+ isValid(inferenceParams, model) {
1859
+ return inferenceParams.context.items.every(
1860
+ (item) => model.supportedContextItemTypes.includes(getContextItemValidationKey(item))
1861
+ );
2010
1862
  }
2011
1863
  };
2012
1864
 
2013
- // src/application/use-cases/send-message.ts
2014
- var SendMessage = class {
2015
- async execute(environment, message, caller) {
2016
- if (!caller.isJoinedTo(environment)) {
2017
- throw new Error("Not joined to environment");
1865
+ // src/domain/generative-model/request-validation/inference-request-validator.ts
1866
+ var defaultRequestValidationRules = [
1867
+ new ReasoningEffortValidation(),
1868
+ new ToolCallingValidation(),
1869
+ new StreamingValidation(),
1870
+ new StructuredOutputValidation(),
1871
+ new ContextValidation()
1872
+ ];
1873
+ var InferenceRequestValidator = class {
1874
+ constructor(rules = defaultRequestValidationRules) {
1875
+ this.rules = rules;
1876
+ }
1877
+ validate(inferenceParams, model) {
1878
+ for (const rule of this.rules) {
1879
+ if (!rule.isValid(inferenceParams, model)) {
1880
+ throw new Error(`Request validation "${rule.name}" failed for model "${model.name}"`);
1881
+ }
2018
1882
  }
2019
- environment.deliverMessage(caller, message);
2020
1883
  }
2021
1884
  };
2022
1885
 
2023
1886
  // src/index.ts
2024
- var runInferenceUseCase = new RunInference(new ModelRepository(), new InferenceRunner());
1887
+ var generativeModelRepository = new InMemoryGenerativeModelRepository();
1888
+ var inferenceRequestValidator = new InferenceRequestValidator();
1889
+ var runInferenceUseCase = new RunInference(generativeModelRepository, inferenceRequestValidator);
2025
1890
  var executeFunctionCallUseCase = new ExecuteFunctionCall(new FunctionCallRunner());
2026
1891
  var sendMessageUseCase = new SendMessage();
2027
1892
  var runInference = (inferenceParams) => {
@@ -2037,33 +1902,18 @@ var sendMessage = (environment, message, caller) => {
2037
1902
  0 && (module.exports = {
2038
1903
  AgenticEnvironment,
2039
1904
  AgenticError,
2040
- AnthropicMessages,
2041
1905
  BaseParticipant,
2042
- ClaudeHaiku45,
2043
- ClaudeOpus47,
2044
- ClaudeOpus48,
2045
- ClaudeSonnet46,
2046
1906
  ContextItem,
2047
- DeepSeekV4Flash,
2048
- DeepSeekV4Pro,
2049
1907
  DeveloperMessageItem,
2050
1908
  FunctionCallItem,
2051
1909
  FunctionCallOutputItem,
2052
- Gemini31Pro,
2053
- Gemini35Flash,
2054
- GeminiGenerateContent,
2055
- Gpt54,
2056
- Gpt54Mini,
2057
- Gpt54Nano,
2058
- Gpt55,
2059
1910
  InMemoryModelContextRepository,
2060
- InferenceRequest,
2061
1911
  InferenceResponse,
2062
1912
  InputTokenDetails,
1913
+ McpClient,
1914
+ McpToolRegistry,
2063
1915
  ModelContext,
2064
1916
  ModelMessageItem,
2065
- OpenAIChatCompletions,
2066
- OpenAIResponses,
2067
1917
  OutputTokenDetails,
2068
1918
  Participant,
2069
1919
  ReasoningItem,