@mozaik-ai/core 4.0.0-beta.11 → 4.0.0-beta.12

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
@@ -240,6 +240,14 @@ type InterceptionOutput = {
240
240
  interface InterceptionParams {
241
241
  pendingTransition: LoopTransition;
242
242
  }
243
+ type ExecutableLoopStateId = Exclude<LoopStateId, "idle">;
244
+ type LoopStateExecution<TStateId extends ExecutableLoopStateId = ExecutableLoopStateId> = {
245
+ [K in TStateId]: {
246
+ stateId: K;
247
+ input: LoopStateContract[K]["input"];
248
+ output: LoopStateContract[K]["output"];
249
+ };
250
+ }[TStateId];
243
251
  type LoopTransition<TStateId extends LoopStateId = LoopStateId> = {
244
252
  [K in TStateId]: {
245
253
  nextStateId: K;
@@ -247,6 +255,23 @@ type LoopTransition<TStateId extends LoopStateId = LoopStateId> = {
247
255
  };
248
256
  }[TStateId];
249
257
 
258
+ declare class InputTokenDetails {
259
+ readonly cached_tokens: number;
260
+ constructor(cached_tokens: number);
261
+ }
262
+ declare class OutputTokenDetails {
263
+ readonly reasoning_tokens: number;
264
+ constructor(reasoning_tokens: number);
265
+ }
266
+ declare class TokenUsage {
267
+ readonly inputTokens: number;
268
+ readonly outputTokens: number;
269
+ readonly totalTokens: number;
270
+ readonly inputTokenDetails: InputTokenDetails;
271
+ readonly outputTokenDetails: OutputTokenDetails;
272
+ constructor(inputTokens: number, outputTokens: number, totalTokens: number, inputTokenDetails: InputTokenDetails, outputTokenDetails: OutputTokenDetails);
273
+ }
274
+
250
275
  type InferenceInput = {
251
276
  model: string;
252
277
  maxOutputTokens?: number;
@@ -259,6 +284,7 @@ type InferenceInput = {
259
284
  type InferenceItem = FunctionCallItem | ReasoningItem | ModelMessageItem;
260
285
  type InferenceOutput = {
261
286
  items: InferenceItem[];
287
+ tokenUsage: TokenUsage | undefined;
262
288
  rowResponse: any;
263
289
  };
264
290
  interface InferenceRunner {
@@ -311,23 +337,6 @@ interface ModelContextRepository {
311
337
  getByProjectId(projectId: string): Promise<ModelContext[]>;
312
338
  }
313
339
 
314
- declare class InputTokenDetails {
315
- readonly cached_tokens: number;
316
- constructor(cached_tokens: number);
317
- }
318
- declare class OutputTokenDetails {
319
- readonly reasoning_tokens: number;
320
- constructor(reasoning_tokens: number);
321
- }
322
- declare class TokenUsage {
323
- readonly inputTokens: number;
324
- readonly outputTokens: number;
325
- readonly totalTokens: number;
326
- readonly inputTokenDetails: InputTokenDetails;
327
- readonly outputTokenDetails: OutputTokenDetails;
328
- constructor(inputTokens: number, outputTokens: number, totalTokens: number, inputTokenDetails: InputTokenDetails, outputTokenDetails: OutputTokenDetails);
329
- }
330
-
331
340
  interface McpServerConfig {
332
341
  /** The MCP server URL, e.g. https://api.githubcopilot.com/mcp/ */
333
342
  url: string;
@@ -611,8 +620,8 @@ declare class DefaultInferenceRunner implements InferenceRunner {
611
620
  }
612
621
 
613
622
  interface InterceptionHandler {
614
- isSatisfiedBy(transition: LoopTransition): boolean;
615
- handle(transition: LoopTransition): Promise<LoopTransition>;
623
+ isSatisfiedBy(transition: LoopTransition<ExecutableLoopStateId>): boolean;
624
+ handle(transition: LoopTransition<ExecutableLoopStateId>): Promise<LoopTransition<ExecutableLoopStateId>>;
616
625
  }
617
626
 
618
- export { Agent, AnthropicMessages, ContextItem, DefaultInferenceRunner, DeveloperMessageItem, type Endpoint, FunctionCallItem, FunctionCallOutputItem, GeminiGenerateContent, Human, type InferenceInput, type InferenceOutput, type InferenceRunner, type InferenceRunnerConfig, InputTokenDetails, type InterceptionHandler, 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 };
627
+ export { Agent, AnthropicMessages, ContextItem, DefaultInferenceRunner, DeveloperMessageItem, type Endpoint, type ExecutableLoopStateId, FunctionCallItem, FunctionCallOutputItem, GeminiGenerateContent, Human, type InferenceInput, type InferenceOutput, type InferenceRunner, type InferenceRunnerConfig, InputTokenDetails, type InterceptionHandler, type LoopStateExecution, type LoopTransition, 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
@@ -240,6 +240,14 @@ type InterceptionOutput = {
240
240
  interface InterceptionParams {
241
241
  pendingTransition: LoopTransition;
242
242
  }
243
+ type ExecutableLoopStateId = Exclude<LoopStateId, "idle">;
244
+ type LoopStateExecution<TStateId extends ExecutableLoopStateId = ExecutableLoopStateId> = {
245
+ [K in TStateId]: {
246
+ stateId: K;
247
+ input: LoopStateContract[K]["input"];
248
+ output: LoopStateContract[K]["output"];
249
+ };
250
+ }[TStateId];
243
251
  type LoopTransition<TStateId extends LoopStateId = LoopStateId> = {
244
252
  [K in TStateId]: {
245
253
  nextStateId: K;
@@ -247,6 +255,23 @@ type LoopTransition<TStateId extends LoopStateId = LoopStateId> = {
247
255
  };
248
256
  }[TStateId];
249
257
 
258
+ declare class InputTokenDetails {
259
+ readonly cached_tokens: number;
260
+ constructor(cached_tokens: number);
261
+ }
262
+ declare class OutputTokenDetails {
263
+ readonly reasoning_tokens: number;
264
+ constructor(reasoning_tokens: number);
265
+ }
266
+ declare class TokenUsage {
267
+ readonly inputTokens: number;
268
+ readonly outputTokens: number;
269
+ readonly totalTokens: number;
270
+ readonly inputTokenDetails: InputTokenDetails;
271
+ readonly outputTokenDetails: OutputTokenDetails;
272
+ constructor(inputTokens: number, outputTokens: number, totalTokens: number, inputTokenDetails: InputTokenDetails, outputTokenDetails: OutputTokenDetails);
273
+ }
274
+
250
275
  type InferenceInput = {
251
276
  model: string;
252
277
  maxOutputTokens?: number;
@@ -259,6 +284,7 @@ type InferenceInput = {
259
284
  type InferenceItem = FunctionCallItem | ReasoningItem | ModelMessageItem;
260
285
  type InferenceOutput = {
261
286
  items: InferenceItem[];
287
+ tokenUsage: TokenUsage | undefined;
262
288
  rowResponse: any;
263
289
  };
264
290
  interface InferenceRunner {
@@ -311,23 +337,6 @@ interface ModelContextRepository {
311
337
  getByProjectId(projectId: string): Promise<ModelContext[]>;
312
338
  }
313
339
 
314
- declare class InputTokenDetails {
315
- readonly cached_tokens: number;
316
- constructor(cached_tokens: number);
317
- }
318
- declare class OutputTokenDetails {
319
- readonly reasoning_tokens: number;
320
- constructor(reasoning_tokens: number);
321
- }
322
- declare class TokenUsage {
323
- readonly inputTokens: number;
324
- readonly outputTokens: number;
325
- readonly totalTokens: number;
326
- readonly inputTokenDetails: InputTokenDetails;
327
- readonly outputTokenDetails: OutputTokenDetails;
328
- constructor(inputTokens: number, outputTokens: number, totalTokens: number, inputTokenDetails: InputTokenDetails, outputTokenDetails: OutputTokenDetails);
329
- }
330
-
331
340
  interface McpServerConfig {
332
341
  /** The MCP server URL, e.g. https://api.githubcopilot.com/mcp/ */
333
342
  url: string;
@@ -611,8 +620,8 @@ declare class DefaultInferenceRunner implements InferenceRunner {
611
620
  }
612
621
 
613
622
  interface InterceptionHandler {
614
- isSatisfiedBy(transition: LoopTransition): boolean;
615
- handle(transition: LoopTransition): Promise<LoopTransition>;
623
+ isSatisfiedBy(transition: LoopTransition<ExecutableLoopStateId>): boolean;
624
+ handle(transition: LoopTransition<ExecutableLoopStateId>): Promise<LoopTransition<ExecutableLoopStateId>>;
616
625
  }
617
626
 
618
- export { Agent, AnthropicMessages, ContextItem, DefaultInferenceRunner, DeveloperMessageItem, type Endpoint, FunctionCallItem, FunctionCallOutputItem, GeminiGenerateContent, Human, type InferenceInput, type InferenceOutput, type InferenceRunner, type InferenceRunnerConfig, InputTokenDetails, type InterceptionHandler, 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 };
627
+ export { Agent, AnthropicMessages, ContextItem, DefaultInferenceRunner, DeveloperMessageItem, type Endpoint, type ExecutableLoopStateId, FunctionCallItem, FunctionCallOutputItem, GeminiGenerateContent, Human, type InferenceInput, type InferenceOutput, type InferenceRunner, type InferenceRunnerConfig, InputTokenDetails, type InterceptionHandler, type LoopStateExecution, type LoopTransition, 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
@@ -633,10 +633,9 @@ var AgentLoop = class _AgentLoop {
633
633
  loopVisitor.visitInterceptionStarted(transition);
634
634
  transition = await this.interceptionHandler.handle(transition);
635
635
  loopVisitor.visitInterceptionFinished(transition);
636
- } else {
637
- const execution = await this.stateExecutor.execute(transition, loopVisitor);
638
- transition = this.transitionResolver.resolve(execution);
639
636
  }
637
+ const execution = await this.stateExecutor.execute(transition, loopVisitor);
638
+ transition = this.transitionResolver.resolve(execution);
640
639
  }
641
640
  }
642
641
  getLoopId() {
@@ -1131,7 +1130,7 @@ var AnthropicMessagesMapper = class {
1131
1130
  );
1132
1131
  }
1133
1132
  }
1134
- return { items, rowResponse: response };
1133
+ return { items, tokenUsage: this.extractTokenUsage(response), rowResponse: response };
1135
1134
  }
1136
1135
  };
1137
1136
 
@@ -1319,6 +1318,7 @@ var OpenAIResponsesMapper = class {
1319
1318
  }
1320
1319
  return {
1321
1320
  items,
1321
+ tokenUsage: this.extractTokenUsage(response),
1322
1322
  rowResponse: response
1323
1323
  };
1324
1324
  }
@@ -1507,7 +1507,7 @@ var GeminiGenerateContentMapper = class {
1507
1507
  );
1508
1508
  }
1509
1509
  }
1510
- return { items, rowResponse: response };
1510
+ return { items, tokenUsage: this.extractTokenUsage(response), rowResponse: response };
1511
1511
  }
1512
1512
  };
1513
1513
 
@@ -1630,7 +1630,7 @@ var OpenAIChatCompletionsMapper = class {
1630
1630
  const items = [];
1631
1631
  const message = (_b = (_a = response.choices) == null ? void 0 : _a[0]) == null ? void 0 : _b.message;
1632
1632
  if (!message) {
1633
- return { items: [], rowResponse: response };
1633
+ return { items: [], tokenUsage: this.extractTokenUsage(response), rowResponse: response };
1634
1634
  }
1635
1635
  if (message.reasoning_content) {
1636
1636
  items.push(
@@ -1653,7 +1653,7 @@ var OpenAIChatCompletionsMapper = class {
1653
1653
  })
1654
1654
  );
1655
1655
  }
1656
- return { items, rowResponse: response };
1656
+ return { items, tokenUsage: this.extractTokenUsage(response), rowResponse: response };
1657
1657
  }
1658
1658
  };
1659
1659