@mozaik-ai/core 4.0.0-beta.4 → 4.0.0-beta.6

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
@@ -189,6 +189,11 @@ type ModelSpecification = {
189
189
  supportsStructuredOutput: boolean;
190
190
  };
191
191
 
192
+ interface RequestValidationRule {
193
+ readonly name: string;
194
+ isValid(inferenceInput: InferenceInput, model: ModelSpecification): boolean;
195
+ }
196
+
192
197
  type StructuredOutputFormat = {
193
198
  name?: string;
194
199
  schema: Record<string, any>;
@@ -331,6 +336,7 @@ declare abstract class Participant {
331
336
  getManifest(): ParticipantManifest;
332
337
  getId(): string;
333
338
  getHandlers(): SituationHandler[];
339
+ setHandlers(handlers: SituationHandler[]): void;
334
340
  }
335
341
 
336
342
  declare class Memory {
@@ -407,8 +413,8 @@ declare class RuntimeService<TRuntimeState extends RuntimeState> {
407
413
  }
408
414
 
409
415
  type InferenceRunnerConfig = {
410
- supportedModels: GenerativeModel[];
411
- runner: InferenceRunner;
416
+ supportedModels?: GenerativeModel[];
417
+ runner?: InferenceRunner;
412
418
  };
413
419
  declare function defineRuntime<TRuntimeState extends RuntimeState>(): {
414
420
  initializeRuntime: (config: {
@@ -428,8 +434,9 @@ declare const supportedModels: GenerativeModel[];
428
434
 
429
435
  declare class OpenAIResponses implements Endpoint {
430
436
  endpointMapper: InferenceEndpointMapper;
431
- private readonly client;
437
+ private _client?;
432
438
  constructor(endpointMapper?: InferenceEndpointMapper);
439
+ private get client();
433
440
  infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
434
441
  stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
435
442
  }
@@ -473,9 +480,11 @@ interface OpenAICompatibleConfig {
473
480
  */
474
481
  declare class OpenAIChatCompletions implements Endpoint {
475
482
  endpointMapper: InferenceEndpointMapper;
476
- private readonly client;
483
+ private _client?;
484
+ private readonly clientConfig;
477
485
  private readonly extraBody;
478
486
  constructor(endpointMapper?: InferenceEndpointMapper, config?: OpenAICompatibleConfig);
487
+ private get client();
479
488
  private buildRequest;
480
489
  infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
481
490
  stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
@@ -492,8 +501,10 @@ interface AnthropicConnectionConfig {
492
501
  */
493
502
  declare class AnthropicMessages implements Endpoint {
494
503
  endpointMapper: InferenceEndpointMapper;
495
- private readonly client;
504
+ private _client?;
505
+ private readonly clientConfig;
496
506
  constructor(endpointMapper?: InferenceEndpointMapper, config?: AnthropicConnectionConfig);
507
+ private get client();
497
508
  infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
498
509
  stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
499
510
  }
@@ -512,10 +523,26 @@ interface GeminiConnectionConfig {
512
523
  */
513
524
  declare class GeminiGenerateContent implements Endpoint {
514
525
  endpointMapper: InferenceEndpointMapper;
515
- private readonly client;
526
+ private _client?;
527
+ private readonly clientConfig;
516
528
  constructor(endpointMapper?: InferenceEndpointMapper, config?: GeminiConnectionConfig);
529
+ private get client();
517
530
  infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
518
531
  stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
519
532
  }
520
533
 
521
- export { AnthropicMessages, ContextItem, DeveloperMessageItem, type Endpoint, FunctionCallItem, FunctionCallOutputItem, GeminiGenerateContent, type InferenceInput, type InferenceOutput, InputTokenDetails, McpClient, type McpServerConfig, McpToolRegistry, type McpToolSpec, ModelContext, type ModelContextRepository, ModelMessageItem, OpenAIChatCompletions, OpenAIResponses, OutputTokenDetails, Participant, ReasoningItem, RuntimeState, SemanticEvent, type StructuredOutputFormat, SystemMessageItem, TokenUsage, type Tool, UserMessageItem, createAgent, createHuman, defineRuntime, supportedModels };
534
+ declare class InferenceInputValidator {
535
+ private readonly rules;
536
+ constructor(rules?: RequestValidationRule[]);
537
+ validate(inferenceInput: InferenceInput, model: ModelSpecification): void;
538
+ }
539
+
540
+ declare class DefaultInferenceRunner implements InferenceRunner {
541
+ private readonly supportedModels;
542
+ private readonly requestValidator;
543
+ constructor(supportedModels: GenerativeModel[], requestValidator: InferenceInputValidator);
544
+ run(input: InferenceInput): Promise<InferenceOutput>;
545
+ stream(input: InferenceInput): AsyncGenerator<SemanticEvent>;
546
+ }
547
+
548
+ export { Agent, AnthropicMessages, ContextItem, DefaultInferenceRunner, DeveloperMessageItem, type Endpoint, FunctionCallItem, FunctionCallOutputItem, GeminiGenerateContent, Human, type InferenceInput, type InferenceOutput, type InferenceRunner, type InferenceRunnerConfig, InputTokenDetails, McpClient, type McpServerConfig, McpToolRegistry, type McpToolSpec, ModelContext, type ModelContextRepository, ModelMessageItem, OpenAIChatCompletions, OpenAIResponses, OutputTokenDetails, Participant, ReasoningItem, RuntimeState, SemanticEvent, type SituationContext, type SituationHandler, type SituationProcessor, SituationSpecification, type StructuredOutputFormat, SystemMessageItem, TokenUsage, type Tool, UserMessageItem, createAgent, createHuman, defineRuntime, supportedModels };
package/dist/index.d.ts CHANGED
@@ -189,6 +189,11 @@ type ModelSpecification = {
189
189
  supportsStructuredOutput: boolean;
190
190
  };
191
191
 
192
+ interface RequestValidationRule {
193
+ readonly name: string;
194
+ isValid(inferenceInput: InferenceInput, model: ModelSpecification): boolean;
195
+ }
196
+
192
197
  type StructuredOutputFormat = {
193
198
  name?: string;
194
199
  schema: Record<string, any>;
@@ -331,6 +336,7 @@ declare abstract class Participant {
331
336
  getManifest(): ParticipantManifest;
332
337
  getId(): string;
333
338
  getHandlers(): SituationHandler[];
339
+ setHandlers(handlers: SituationHandler[]): void;
334
340
  }
335
341
 
336
342
  declare class Memory {
@@ -407,8 +413,8 @@ declare class RuntimeService<TRuntimeState extends RuntimeState> {
407
413
  }
408
414
 
409
415
  type InferenceRunnerConfig = {
410
- supportedModels: GenerativeModel[];
411
- runner: InferenceRunner;
416
+ supportedModels?: GenerativeModel[];
417
+ runner?: InferenceRunner;
412
418
  };
413
419
  declare function defineRuntime<TRuntimeState extends RuntimeState>(): {
414
420
  initializeRuntime: (config: {
@@ -428,8 +434,9 @@ declare const supportedModels: GenerativeModel[];
428
434
 
429
435
  declare class OpenAIResponses implements Endpoint {
430
436
  endpointMapper: InferenceEndpointMapper;
431
- private readonly client;
437
+ private _client?;
432
438
  constructor(endpointMapper?: InferenceEndpointMapper);
439
+ private get client();
433
440
  infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
434
441
  stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
435
442
  }
@@ -473,9 +480,11 @@ interface OpenAICompatibleConfig {
473
480
  */
474
481
  declare class OpenAIChatCompletions implements Endpoint {
475
482
  endpointMapper: InferenceEndpointMapper;
476
- private readonly client;
483
+ private _client?;
484
+ private readonly clientConfig;
477
485
  private readonly extraBody;
478
486
  constructor(endpointMapper?: InferenceEndpointMapper, config?: OpenAICompatibleConfig);
487
+ private get client();
479
488
  private buildRequest;
480
489
  infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
481
490
  stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
@@ -492,8 +501,10 @@ interface AnthropicConnectionConfig {
492
501
  */
493
502
  declare class AnthropicMessages implements Endpoint {
494
503
  endpointMapper: InferenceEndpointMapper;
495
- private readonly client;
504
+ private _client?;
505
+ private readonly clientConfig;
496
506
  constructor(endpointMapper?: InferenceEndpointMapper, config?: AnthropicConnectionConfig);
507
+ private get client();
497
508
  infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
498
509
  stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
499
510
  }
@@ -512,10 +523,26 @@ interface GeminiConnectionConfig {
512
523
  */
513
524
  declare class GeminiGenerateContent implements Endpoint {
514
525
  endpointMapper: InferenceEndpointMapper;
515
- private readonly client;
526
+ private _client?;
527
+ private readonly clientConfig;
516
528
  constructor(endpointMapper?: InferenceEndpointMapper, config?: GeminiConnectionConfig);
529
+ private get client();
517
530
  infer(inferenceInput: InferenceInput): Promise<InferenceOutput>;
518
531
  stream(inferenceInput: InferenceInput): AsyncIterable<SemanticEvent>;
519
532
  }
520
533
 
521
- export { AnthropicMessages, ContextItem, DeveloperMessageItem, type Endpoint, FunctionCallItem, FunctionCallOutputItem, GeminiGenerateContent, type InferenceInput, type InferenceOutput, InputTokenDetails, McpClient, type McpServerConfig, McpToolRegistry, type McpToolSpec, ModelContext, type ModelContextRepository, ModelMessageItem, OpenAIChatCompletions, OpenAIResponses, OutputTokenDetails, Participant, ReasoningItem, RuntimeState, SemanticEvent, type StructuredOutputFormat, SystemMessageItem, TokenUsage, type Tool, UserMessageItem, createAgent, createHuman, defineRuntime, supportedModels };
534
+ declare class InferenceInputValidator {
535
+ private readonly rules;
536
+ constructor(rules?: RequestValidationRule[]);
537
+ validate(inferenceInput: InferenceInput, model: ModelSpecification): void;
538
+ }
539
+
540
+ declare class DefaultInferenceRunner implements InferenceRunner {
541
+ private readonly supportedModels;
542
+ private readonly requestValidator;
543
+ constructor(supportedModels: GenerativeModel[], requestValidator: InferenceInputValidator);
544
+ run(input: InferenceInput): Promise<InferenceOutput>;
545
+ stream(input: InferenceInput): AsyncGenerator<SemanticEvent>;
546
+ }
547
+
548
+ export { Agent, AnthropicMessages, ContextItem, DefaultInferenceRunner, DeveloperMessageItem, type Endpoint, FunctionCallItem, FunctionCallOutputItem, GeminiGenerateContent, Human, type InferenceInput, type InferenceOutput, type InferenceRunner, type InferenceRunnerConfig, InputTokenDetails, McpClient, type McpServerConfig, McpToolRegistry, type McpToolSpec, ModelContext, type ModelContextRepository, ModelMessageItem, OpenAIChatCompletions, OpenAIResponses, OutputTokenDetails, Participant, ReasoningItem, RuntimeState, SemanticEvent, type SituationContext, type SituationHandler, type SituationProcessor, SituationSpecification, type StructuredOutputFormat, SystemMessageItem, TokenUsage, type Tool, UserMessageItem, createAgent, createHuman, defineRuntime, supportedModels };
package/dist/index.js CHANGED
@@ -30,12 +30,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ Agent: () => Agent,
33
34
  AnthropicMessages: () => AnthropicMessages,
34
35
  ContextItem: () => ContextItem,
36
+ DefaultInferenceRunner: () => DefaultInferenceRunner,
35
37
  DeveloperMessageItem: () => DeveloperMessageItem,
36
38
  FunctionCallItem: () => FunctionCallItem,
37
39
  FunctionCallOutputItem: () => FunctionCallOutputItem,
38
40
  GeminiGenerateContent: () => GeminiGenerateContent,
41
+ Human: () => Human,
39
42
  InputTokenDetails: () => InputTokenDetails,
40
43
  McpClient: () => McpClient,
41
44
  McpToolRegistry: () => McpToolRegistry,
@@ -48,6 +51,7 @@ __export(index_exports, {
48
51
  ReasoningItem: () => ReasoningItem,
49
52
  RuntimeState: () => RuntimeState,
50
53
  SemanticEvent: () => SemanticEvent,
54
+ SituationSpecification: () => SituationSpecification,
51
55
  SystemMessageItem: () => SystemMessageItem,
52
56
  TokenUsage: () => TokenUsage,
53
57
  UserMessageItem: () => UserMessageItem,
@@ -413,6 +417,9 @@ var Participant = class {
413
417
  getHandlers() {
414
418
  return this.handlers;
415
419
  }
420
+ setHandlers(handlers) {
421
+ this.handlers = handlers;
422
+ }
416
423
  };
417
424
 
418
425
  // src/domain/agentic-environment/participant/memory.ts
@@ -849,34 +856,27 @@ var EventPublisherLoopVisitor = class {
849
856
  this.runtime = runtime;
850
857
  }
851
858
  visitContextPreparationStarted(input) {
852
- console.log("Visiting message received started: ", input);
853
859
  this.publish("context_preparation.started", input);
854
860
  }
855
861
  visitContextPreparationCompleted(output) {
856
- console.log("Visiting message received completed: ", output);
857
862
  this.publish("context_preparation.completed", output);
858
863
  }
859
864
  visitInferenceStarted(input) {
860
- console.log("Visiting inference started: ", input);
861
865
  this.publish("inference.started", input);
862
866
  }
863
867
  visitInferenceEvent(event) {
864
868
  this.publish("inference.stream", event);
865
869
  }
866
870
  visitInferenceCompleted(output) {
867
- console.log("Visiting inference completed: ", output);
868
871
  this.publish("inference.completed", output);
869
872
  }
870
873
  visitFunctionCallStarted(input) {
871
- console.log("Visiting function call started: ", input);
872
874
  this.publish("function_call.started", input);
873
875
  }
874
876
  visitFunctionCallCompleted(output) {
875
- console.log("Visiting function call completed: ", output);
876
877
  this.publish("function_call.completed", output);
877
878
  }
878
879
  visitModelAnswer(input) {
879
- console.log("Visiting model answer: ", input.answer);
880
880
  this.publish("model.answer", input);
881
881
  }
882
882
  publish(type, payload) {
@@ -1104,7 +1104,14 @@ var import_sdk = __toESM(require("@anthropic-ai/sdk"));
1104
1104
  var AnthropicMessages = class {
1105
1105
  constructor(endpointMapper = new AnthropicMessagesMapper(), config = {}) {
1106
1106
  this.endpointMapper = endpointMapper;
1107
- this.client = new import_sdk.default({ baseURL: config.baseURL, apiKey: config.apiKey });
1107
+ this.clientConfig = config;
1108
+ }
1109
+ get client() {
1110
+ var _a;
1111
+ return (_a = this._client) != null ? _a : this._client = new import_sdk.default({
1112
+ baseURL: this.clientConfig.baseURL,
1113
+ apiKey: this.clientConfig.apiKey
1114
+ });
1108
1115
  }
1109
1116
  async infer(inferenceInput) {
1110
1117
  const request = this.endpointMapper.toRequest(inferenceInput);
@@ -1285,7 +1292,10 @@ var OpenAIResponsesMapper = class {
1285
1292
  var OpenAIResponses = class {
1286
1293
  constructor(endpointMapper = new OpenAIResponsesMapper()) {
1287
1294
  this.endpointMapper = endpointMapper;
1288
- this.client = new import_openai.default();
1295
+ }
1296
+ get client() {
1297
+ var _a;
1298
+ return (_a = this._client) != null ? _a : this._client = new import_openai.default();
1289
1299
  }
1290
1300
  async infer(inferenceInput) {
1291
1301
  const request = this.endpointMapper.toRequest(inferenceInput);
@@ -1468,11 +1478,14 @@ var GeminiGenerateContentMapper = class {
1468
1478
  // src/infrastructure/providers/gemini/endpoints/gemini-generate-content.ts
1469
1479
  var GeminiGenerateContent = class {
1470
1480
  constructor(endpointMapper = new GeminiGenerateContentMapper(), config = {}) {
1471
- var _a;
1472
1481
  this.endpointMapper = endpointMapper;
1473
- this.client = new import_genai.GoogleGenAI({
1474
- apiKey: (_a = config.apiKey) != null ? _a : process.env.GEMINI_API_KEY,
1475
- ...config.baseURL ? { httpOptions: { baseUrl: config.baseURL } } : {}
1482
+ this.clientConfig = config;
1483
+ }
1484
+ get client() {
1485
+ var _a, _b;
1486
+ return (_b = this._client) != null ? _b : this._client = new import_genai.GoogleGenAI({
1487
+ apiKey: (_a = this.clientConfig.apiKey) != null ? _a : process.env.GEMINI_API_KEY,
1488
+ ...this.clientConfig.baseURL ? { httpOptions: { baseUrl: this.clientConfig.baseURL } } : {}
1476
1489
  });
1477
1490
  }
1478
1491
  async infer(inferenceInput) {
@@ -1614,12 +1627,16 @@ var OpenAIChatCompletions = class {
1614
1627
  constructor(endpointMapper = new OpenAIChatCompletionsMapper(), config = {}) {
1615
1628
  var _a;
1616
1629
  this.endpointMapper = endpointMapper;
1617
- this.client = new import_openai2.default({
1618
- baseURL: config.baseURL,
1619
- apiKey: config.apiKey
1620
- });
1630
+ this.clientConfig = config;
1621
1631
  this.extraBody = (_a = config.extraBody) != null ? _a : {};
1622
1632
  }
1633
+ get client() {
1634
+ var _a;
1635
+ return (_a = this._client) != null ? _a : this._client = new import_openai2.default({
1636
+ baseURL: this.clientConfig.baseURL,
1637
+ apiKey: this.clientConfig.apiKey
1638
+ });
1639
+ }
1623
1640
  buildRequest(inferenceInput) {
1624
1641
  return {
1625
1642
  ...this.extraBody,
@@ -2148,14 +2165,59 @@ function defineRuntime() {
2148
2165
  runLoop
2149
2166
  };
2150
2167
  }
2168
+
2169
+ // src/domain/agentic-environment/situation/situation-specification.ts
2170
+ var SituationSpecification = class {
2171
+ and(other) {
2172
+ return new AndSituationSpecification(this, other);
2173
+ }
2174
+ or(other) {
2175
+ return new OrSituationSpecification(this, other);
2176
+ }
2177
+ not() {
2178
+ return new NotSituationSpecification(this);
2179
+ }
2180
+ };
2181
+ var AndSituationSpecification = class extends SituationSpecification {
2182
+ constructor(left, right) {
2183
+ super();
2184
+ this.left = left;
2185
+ this.right = right;
2186
+ }
2187
+ isSatisfiedBy(situationContext) {
2188
+ return this.left.isSatisfiedBy(situationContext) && this.right.isSatisfiedBy(situationContext);
2189
+ }
2190
+ };
2191
+ var OrSituationSpecification = class extends SituationSpecification {
2192
+ constructor(left, right) {
2193
+ super();
2194
+ this.left = left;
2195
+ this.right = right;
2196
+ }
2197
+ isSatisfiedBy(situationContext) {
2198
+ return this.left.isSatisfiedBy(situationContext) || this.right.isSatisfiedBy(situationContext);
2199
+ }
2200
+ };
2201
+ var NotSituationSpecification = class extends SituationSpecification {
2202
+ constructor(rule) {
2203
+ super();
2204
+ this.rule = rule;
2205
+ }
2206
+ isSatisfiedBy(situationContext) {
2207
+ return !this.rule.isSatisfiedBy(situationContext);
2208
+ }
2209
+ };
2151
2210
  // Annotate the CommonJS export names for ESM import in node:
2152
2211
  0 && (module.exports = {
2212
+ Agent,
2153
2213
  AnthropicMessages,
2154
2214
  ContextItem,
2215
+ DefaultInferenceRunner,
2155
2216
  DeveloperMessageItem,
2156
2217
  FunctionCallItem,
2157
2218
  FunctionCallOutputItem,
2158
2219
  GeminiGenerateContent,
2220
+ Human,
2159
2221
  InputTokenDetails,
2160
2222
  McpClient,
2161
2223
  McpToolRegistry,
@@ -2168,6 +2230,7 @@ function defineRuntime() {
2168
2230
  ReasoningItem,
2169
2231
  RuntimeState,
2170
2232
  SemanticEvent,
2233
+ SituationSpecification,
2171
2234
  SystemMessageItem,
2172
2235
  TokenUsage,
2173
2236
  UserMessageItem,