@mozaik-ai/core 0.7.2 → 0.8.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
@@ -30,7 +30,7 @@ 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
+ MozaikAgent: () => MozaikAgent,
34
34
  PlanningAgent: () => PlanningAgent,
35
35
  Task: () => Task,
36
36
  WorkUnit: () => WorkUnit,
@@ -49,9 +49,9 @@ var RequestGateway = class {
49
49
  constructor(endpointResolver) {
50
50
  this.endpointResolver = endpointResolver;
51
51
  }
52
- async invoke(command) {
53
- this.endpoint = this.endpointResolver.resolve(command.model);
54
- return await this.endpoint.sendRequest(command);
52
+ async invoke(request) {
53
+ this.endpoint = this.endpointResolver.resolve(request.model);
54
+ return await this.endpoint.sendRequest(request);
55
55
  }
56
56
  };
57
57
 
@@ -77,55 +77,55 @@ var CapabilityHandler = class {
77
77
  this.nextHandler = capability;
78
78
  return this.nextHandler;
79
79
  }
80
- handle(command, builder) {
81
- this.apply(command, builder);
80
+ handle(request, builder) {
81
+ this.apply(request, builder);
82
82
  if (this.nextHandler) {
83
- this.nextHandler.handle(command, builder);
83
+ this.nextHandler.handle(request, builder);
84
84
  }
85
85
  }
86
86
  };
87
87
 
88
88
  // src/core/command-handler/messages.ts
89
89
  var MessagesHandler = class extends CapabilityHandler {
90
- apply(command, builder) {
91
- if (command.messages) {
92
- builder.addMessages(command.messages);
90
+ apply(request, builder) {
91
+ if (request.messages) {
92
+ builder.addMessages(request.messages);
93
93
  }
94
94
  }
95
95
  };
96
96
 
97
97
  // src/core/command-handler/task.ts
98
98
  var TaskHandler = class extends CapabilityHandler {
99
- apply(command, builder) {
100
- if (command.task) {
101
- builder.addTask(command.task);
99
+ apply(request, builder) {
100
+ if (request.task) {
101
+ builder.addTask(request.task);
102
102
  }
103
103
  }
104
104
  };
105
105
 
106
106
  // src/core/command-handler/model.ts
107
107
  var ModelHandler = class extends CapabilityHandler {
108
- apply(command, builder) {
109
- if (command.model) {
110
- builder.addModel(command.model);
108
+ apply(request, builder) {
109
+ if (request.model) {
110
+ builder.addModel(request.model);
111
111
  }
112
112
  }
113
113
  };
114
114
 
115
115
  // src/core/command-handler/structured-output.ts
116
116
  var StructuredOutputlHandler = class extends CapabilityHandler {
117
- apply(command, builder) {
118
- if (command.structuredOutput) {
119
- builder.addStructuredOutput(command.structuredOutput);
117
+ apply(request, builder) {
118
+ if (request.structuredOutput) {
119
+ builder.addStructuredOutput(request.structuredOutput);
120
120
  }
121
121
  }
122
122
  };
123
123
 
124
124
  // src/core/command-handler/tools.ts
125
125
  var ToolsHandler = class extends CapabilityHandler {
126
- apply(command, requestBuilder) {
127
- if (command.tools && command.tools.length > 0) {
128
- requestBuilder.addTools(command.tools);
126
+ apply(mozaikRequest, requestBuilder) {
127
+ if (mozaikRequest.tools && mozaikRequest.tools.length > 0) {
128
+ requestBuilder.addTools(mozaikRequest.tools);
129
129
  }
130
130
  }
131
131
  };
@@ -133,10 +133,10 @@ var ToolsHandler = class extends CapabilityHandler {
133
133
  // src/core/endpoint/endpoint.ts
134
134
  var Endpoint = class {
135
135
  constructor() {
136
- this.command = null;
136
+ this.request = null;
137
137
  }
138
- buildRequest(command) {
139
- this.command = command;
138
+ buildRequest(request) {
139
+ this.request = request;
140
140
  this.requestBuilder.initialize();
141
141
  const messagesHandler = new MessagesHandler();
142
142
  const taskHandler = new TaskHandler();
@@ -144,7 +144,7 @@ var Endpoint = class {
144
144
  const structuredOutputHandler = new StructuredOutputlHandler();
145
145
  const toolsHandler = new ToolsHandler();
146
146
  messagesHandler.setNextHandler(taskHandler).setNextHandler(modelHandler).setNextHandler(structuredOutputHandler).setNextHandler(toolsHandler);
147
- messagesHandler.handle(command, this.requestBuilder);
147
+ messagesHandler.handle(request, this.requestBuilder);
148
148
  return this.requestBuilder.build();
149
149
  }
150
150
  };
@@ -294,7 +294,7 @@ var OutputParsedHandler = class extends ResponseHandler {
294
294
  async handle(responseContext) {
295
295
  const providerResponse = responseContext.providerResponse;
296
296
  if (providerResponse.output_parsed) {
297
- responseContext.setResponse(providerResponse.output_parsed);
297
+ responseContext.setResponseData(providerResponse.output_parsed);
298
298
  return responseContext;
299
299
  }
300
300
  return await this.nextHandler.handle(responseContext);
@@ -303,40 +303,72 @@ var OutputParsedHandler = class extends ResponseHandler {
303
303
 
304
304
  // src/providers/openai/response-handler/content.ts
305
305
  var ContentHandler = class extends ResponseHandler {
306
- async handle(responseContext) {
306
+ async handle(mozaikResponse) {
307
307
  var _a, _b;
308
- const providerResponse = responseContext.providerResponse;
308
+ const providerResponse = mozaikResponse.providerResponse;
309
309
  const firstOutput = (_a = providerResponse.output) == null ? void 0 : _a[0];
310
310
  if (firstOutput && "content" in firstOutput) {
311
311
  const firstContent = (_b = firstOutput.content) == null ? void 0 : _b[0];
312
312
  if (firstContent && "text" in firstContent) {
313
- responseContext.setResponse(firstContent.text);
314
- return responseContext;
313
+ mozaikResponse.setResponseData(firstContent.text);
314
+ return mozaikResponse;
315
315
  }
316
316
  }
317
- return await this.nextHandler.handle(responseContext);
317
+ return await this.nextHandler.handle(mozaikResponse);
318
318
  }
319
319
  };
320
320
 
321
321
  // src/providers/openai/response-handler/output-text.ts
322
322
  var OutputTextHandler = class extends ResponseHandler {
323
- async handle(responseContext) {
324
- const providerResponse = responseContext.providerResponse;
323
+ async handle(mozaikResponse) {
324
+ const providerResponse = mozaikResponse.providerResponse;
325
325
  if (providerResponse.output_text) {
326
- responseContext.setResponse(providerResponse.output_text);
327
- return responseContext;
326
+ mozaikResponse.setResponseData(providerResponse.output_text);
327
+ return mozaikResponse;
328
328
  }
329
- return await this.nextHandler.handle(responseContext);
329
+ return await this.nextHandler.handle(mozaikResponse);
330
330
  }
331
331
  };
332
332
 
333
- // src/core/endpoint/usage.ts
333
+ // src/core/usage-entry.ts
334
334
  var UsageEntry = class {
335
- constructor(inputTokens, outputTokens, model) {
336
- this.inputTokens = inputTokens;
337
- this.outputTokens = outputTokens;
335
+ constructor(priceInUsd, model) {
336
+ this.priceInUsd = priceInUsd;
338
337
  this.model = model;
339
- this.totalTokens = inputTokens + outputTokens;
338
+ }
339
+ };
340
+
341
+ // src/providers/openai/model-pricing.ts
342
+ var OpenAIModelPricing = class {
343
+ calculateTotalCost(inputTokens, outputTokens, cachedInputTokens) {
344
+ const inputCost = (inputTokens - cachedInputTokens) * this.inputPricePer1MToken / 1e6;
345
+ const outputCost = outputTokens * this.outputPricePer1MToken / 1e6;
346
+ const cachedCost = cachedInputTokens * this.cachedPricePer1MToken / 1e6;
347
+ return inputCost + outputCost + cachedCost;
348
+ }
349
+ getPriceInUsd(modelName, inputTokens, outputTokens, cachedInputTokens) {
350
+ if (modelName === "gpt-5") {
351
+ this.inputPricePer1MToken = 1.25;
352
+ this.outputPricePer1MToken = 10;
353
+ this.cachedPricePer1MToken = 0.125;
354
+ return this.calculateTotalCost(inputTokens, outputTokens, cachedInputTokens);
355
+ } else if (modelName === "gpt-5-mini") {
356
+ this.inputPricePer1MToken = 0.25;
357
+ this.outputPricePer1MToken = 2;
358
+ this.cachedPricePer1MToken = 0.025;
359
+ return this.calculateTotalCost(inputTokens, outputTokens, cachedInputTokens);
360
+ } else if (modelName === "gpt-5-nano") {
361
+ this.inputPricePer1MToken = 0.05;
362
+ this.outputPricePer1MToken = 0.4;
363
+ this.cachedPricePer1MToken = 5e-3;
364
+ return this.calculateTotalCost(inputTokens, outputTokens, cachedInputTokens);
365
+ } else if (modelName === "gpt-5.1") {
366
+ this.inputPricePer1MToken = 1.25;
367
+ this.outputPricePer1MToken = 10;
368
+ this.cachedPricePer1MToken = 0.125;
369
+ return this.calculateTotalCost(inputTokens, outputTokens, cachedInputTokens);
370
+ }
371
+ throw new Error(`Model name ${modelName} is not supported for this pricing`);
340
372
  }
341
373
  };
342
374
 
@@ -397,8 +429,9 @@ var FunctionCallsHandler = class extends ResponseHandler {
397
429
  }
398
430
  return results;
399
431
  }
400
- async handle(responseContext) {
401
- let providerResponse = responseContext.providerResponse;
432
+ async handle(mozaikResponse) {
433
+ var _a, _b;
434
+ let providerResponse = mozaikResponse.providerResponse;
402
435
  let toolCallingResponse;
403
436
  while (this.hasToolCalls(providerResponse)) {
404
437
  const toolCalls = this.extractToolCalls(providerResponse);
@@ -406,23 +439,25 @@ var FunctionCallsHandler = class extends ResponseHandler {
406
439
  this.request.input = toolResults;
407
440
  this.request.previous_response_id = providerResponse.id;
408
441
  toolCallingResponse = await this.client.send(this.request);
409
- responseContext.addUsageEntry(
410
- new UsageEntry(
411
- toolCallingResponse.usage.input_tokens,
412
- toolCallingResponse.usage.output_tokens,
413
- toolCallingResponse.model
414
- )
442
+ const openAIModelPricing = new OpenAIModelPricing();
443
+ const usage = toolCallingResponse.usage;
444
+ const totalCost = openAIModelPricing.getPriceInUsd(
445
+ providerResponse.model,
446
+ usage.input_tokens,
447
+ usage.output_tokens,
448
+ (_b = (_a = usage.input_token_details) == null ? void 0 : _a.cached_tokens) != null ? _b : 0
415
449
  );
416
- responseContext.setProviderResponse(toolCallingResponse);
417
- responseContext.setResponse(toolCallingResponse);
450
+ mozaikResponse.addUsageEntry(new UsageEntry(totalCost, providerResponse.model));
451
+ mozaikResponse.setProviderResponse(toolCallingResponse);
452
+ mozaikResponse.setResponseData(toolCallingResponse);
418
453
  providerResponse = toolCallingResponse;
419
454
  }
420
- return await this.nextHandler.handle(responseContext);
455
+ return await this.nextHandler.handle(mozaikResponse);
421
456
  }
422
457
  };
423
458
 
424
- // src/core/endpoint/response-context.ts
425
- var ResponseContext = class {
459
+ // src/core/response.ts
460
+ var MozaikResponse = class {
426
461
  constructor() {
427
462
  this.usageEntries = [];
428
463
  }
@@ -434,12 +469,18 @@ var ResponseContext = class {
434
469
  this.usageEntries.push(usageEntry);
435
470
  return this;
436
471
  }
437
- setResponse(response) {
438
- this.response = response;
472
+ setResponseData(response) {
473
+ this.responseData = response;
439
474
  return this;
440
475
  }
441
476
  getResponse() {
442
- return this.response;
477
+ return {
478
+ data: this.responseData,
479
+ usage: {
480
+ entries: this.usageEntries
481
+ },
482
+ totalCost: this.usageEntries.reduce((acc, entry) => acc + entry.priceInUsd, 0)
483
+ };
443
484
  }
444
485
  getUsageEntries() {
445
486
  return this.usageEntries;
@@ -448,15 +489,19 @@ var ResponseContext = class {
448
489
 
449
490
  // src/providers/openai/response-handler/usage.ts
450
491
  var UsageHandler = class extends ResponseHandler {
451
- async handle(responseContext) {
452
- const providerResponse = responseContext.providerResponse;
492
+ async handle(mozaikResponse) {
493
+ var _a, _b;
494
+ const providerResponse = mozaikResponse.providerResponse;
453
495
  const usage = providerResponse.usage;
454
- if (usage) {
455
- responseContext.addUsageEntry(
456
- new UsageEntry(usage.input_tokens, usage.output_tokens, providerResponse.model)
457
- );
458
- }
459
- return await this.nextHandler.handle(responseContext);
496
+ const openAIModelPricing = new OpenAIModelPricing();
497
+ const totalCost = openAIModelPricing.getPriceInUsd(
498
+ providerResponse.model,
499
+ usage.input_tokens,
500
+ usage.output_tokens,
501
+ (_b = (_a = usage.input_token_details) == null ? void 0 : _a.cached_tokens) != null ? _b : 0
502
+ );
503
+ mozaikResponse.addUsageEntry(new UsageEntry(totalCost, providerResponse.model));
504
+ return await this.nextHandler.handle(mozaikResponse);
460
505
  }
461
506
  };
462
507
 
@@ -471,8 +516,8 @@ var OpenAIResponses = class extends Endpoint {
471
516
  const request = this.buildRequest(command);
472
517
  const client = OpenAIClientResolver.resolve(request);
473
518
  const response = await client.send(request);
474
- const responseContext = new ResponseContext();
475
- responseContext.setProviderResponse(response);
519
+ const mozaikResponse = new MozaikResponse();
520
+ mozaikResponse.setProviderResponse(response);
476
521
  const usageHandler = new UsageHandler();
477
522
  const functionCallsHandler = new FunctionCallsHandler(
478
523
  request,
@@ -483,16 +528,8 @@ var OpenAIResponses = class extends Endpoint {
483
528
  const contentHandler = new ContentHandler();
484
529
  usageHandler.setNextHandler(functionCallsHandler).setNextHandler(outputParsedHandler).setNextHandler(outputTextHandler).setNextHandler(contentHandler);
485
530
  const responseHandler = usageHandler;
486
- const result = await responseHandler.handle(responseContext);
487
- const usageEntries = result.getUsageEntries().map((e) => ({
488
- inputTokens: e.inputTokens,
489
- outputTokens: e.outputTokens,
490
- model: e.model
491
- }));
492
- return {
493
- data: result.getResponse(),
494
- usageEntries
495
- };
531
+ const result = await responseHandler.handle(mozaikResponse);
532
+ return result.getResponse();
496
533
  } catch (error) {
497
534
  console.warn("[OpenAIProvider] Responses API request failed:", error);
498
535
  throw error;
@@ -683,26 +720,51 @@ var AnthropicClientResolver = class {
683
720
 
684
721
  // src/providers/anthropic/response-handler/parsed-output.ts
685
722
  var ParsedOutputHandler = class extends ResponseHandler {
686
- async handle(responseContext) {
687
- const providerResponse = responseContext.providerResponse;
723
+ async handle(mozaikResponse) {
724
+ const providerResponse = mozaikResponse.providerResponse;
688
725
  if (providerResponse.parsed_output) {
689
- responseContext.setResponse(providerResponse.parsed_output);
690
- return responseContext;
726
+ mozaikResponse.setResponseData(providerResponse.parsed_output);
727
+ return mozaikResponse;
691
728
  }
692
- return await this.nextHandler.handle(responseContext);
729
+ return await this.nextHandler.handle(mozaikResponse);
693
730
  }
694
731
  };
695
732
 
696
733
  // src/providers/anthropic/response-handler/content.ts
697
734
  var ContentHandler2 = class extends ResponseHandler {
698
- async handle(responseContext) {
699
- const providerResponse = responseContext.providerResponse;
735
+ async handle(mozaikResponse) {
736
+ const providerResponse = mozaikResponse.providerResponse;
700
737
  const content = providerResponse.content.filter((block) => block.type === "text").map((block) => block.type === "text" ? block.text : "").join("");
701
738
  if (content) {
702
- responseContext.setResponse(content);
703
- return responseContext;
739
+ mozaikResponse.setResponseData(content);
740
+ return mozaikResponse;
704
741
  }
705
- return await this.nextHandler.handle(responseContext);
742
+ return await this.nextHandler.handle(mozaikResponse);
743
+ }
744
+ };
745
+
746
+ // src/providers/anthropic/model-pricing.ts
747
+ var AnthropicModelPricing = class {
748
+ calculateTotalCost(inputTokens, outputTokens) {
749
+ const inputCost = inputTokens * this.inputPricePer1MToken / 1e6;
750
+ const outputCost = outputTokens * this.outputPricePer1MToken / 1e6;
751
+ return inputCost + outputCost;
752
+ }
753
+ getPriceInUsd(modelName, inputTokens, outputTokens) {
754
+ if (modelName === "claude-sonnet-4.5") {
755
+ this.inputPricePer1MToken = 3;
756
+ this.outputPricePer1MToken = 15;
757
+ return this.calculateTotalCost(inputTokens, outputTokens);
758
+ } else if (modelName === "claude-haiku-4.5") {
759
+ this.inputPricePer1MToken = 1;
760
+ this.outputPricePer1MToken = 5;
761
+ return this.calculateTotalCost(inputTokens, outputTokens);
762
+ } else if (modelName === "claude-opus-4.5") {
763
+ this.inputPricePer1MToken = 5;
764
+ this.outputPricePer1MToken = 25;
765
+ return this.calculateTotalCost(inputTokens, outputTokens);
766
+ }
767
+ throw new Error(`Model name ${modelName} is not supported for this pricing`);
706
768
  }
707
769
  };
708
770
 
@@ -743,8 +805,8 @@ var ToolUseHandler = class extends ResponseHandler {
743
805
  }
744
806
  return results;
745
807
  }
746
- async handle(responseContext) {
747
- let providerResponse = responseContext.providerResponse;
808
+ async handle(mozaikResponse) {
809
+ let providerResponse = mozaikResponse.providerResponse;
748
810
  while (providerResponse.stop_reason === "tool_use") {
749
811
  const toolUseBlocks = providerResponse.content.filter(
750
812
  (block) => block.type === "tool_use"
@@ -759,39 +821,44 @@ var ToolUseHandler = class extends ResponseHandler {
759
821
  content: toolResults
760
822
  });
761
823
  const toolCallingResponse = await this.client.send(this.request);
762
- responseContext.addUsageEntry(
763
- new UsageEntry(
764
- toolCallingResponse.usage.input_tokens,
765
- toolCallingResponse.usage.output_tokens,
766
- toolCallingResponse.model
767
- )
824
+ const usage = toolCallingResponse.usage;
825
+ const anthropicModelPricing = new AnthropicModelPricing();
826
+ const totalCost = anthropicModelPricing.getPriceInUsd(
827
+ providerResponse.model,
828
+ usage.input_tokens,
829
+ usage.output_tokens
768
830
  );
769
- responseContext.setProviderResponse(toolCallingResponse);
831
+ mozaikResponse.addUsageEntry(new UsageEntry(totalCost, toolCallingResponse.model.name));
832
+ mozaikResponse.setProviderResponse(toolCallingResponse);
770
833
  providerResponse = toolCallingResponse;
771
834
  }
772
- return await this.nextHandler.handle(responseContext);
835
+ return await this.nextHandler.handle(mozaikResponse);
773
836
  }
774
837
  };
775
838
 
776
839
  // src/providers/anthropic/response-handler/usage.ts
777
840
  var UsageHandler2 = class extends ResponseHandler {
778
- async handle(responseContext) {
779
- const providerResponse = responseContext.providerResponse;
841
+ async handle(mozaikResponse) {
842
+ const providerResponse = mozaikResponse.providerResponse;
780
843
  const usage = providerResponse.usage;
844
+ const anthropicModelPricing = new AnthropicModelPricing();
845
+ const totalCost = anthropicModelPricing.getPriceInUsd(
846
+ providerResponse.model,
847
+ usage.input_tokens,
848
+ usage.output_tokens
849
+ );
781
850
  if (usage) {
782
- responseContext.addUsageEntry(
783
- new UsageEntry(usage.input_tokens, usage.output_tokens, providerResponse.model)
784
- );
851
+ mozaikResponse.addUsageEntry(new UsageEntry(totalCost, providerResponse.model));
785
852
  }
786
- return await this.nextHandler.handle(responseContext);
853
+ return await this.nextHandler.handle(mozaikResponse);
787
854
  }
788
855
  };
789
856
 
790
857
  // src/providers/anthropic/response-handler/undhandled.ts
791
858
  var UnhandledResponseHandler = class extends ResponseHandler {
792
- async handle(responseContext) {
859
+ async handle(mozaikResponse) {
793
860
  var _a, _b;
794
- const providerResponse = responseContext.providerResponse;
861
+ const providerResponse = mozaikResponse.providerResponse;
795
862
  const id = (_a = providerResponse == null ? void 0 : providerResponse.id) != null ? _a : "unknown";
796
863
  const model = (_b = providerResponse == null ? void 0 : providerResponse.model) != null ? _b : "unknown";
797
864
  throw new Error(`No response handler matched. response_id=${id} model=${model}`);
@@ -804,29 +871,24 @@ var AnthropicEndpoint = class extends Endpoint {
804
871
  super(...arguments);
805
872
  this.requestBuilder = new AnthropicRequestBuilder();
806
873
  }
807
- async sendRequest(command) {
808
- const request = this.buildRequest(command);
809
- const client = AnthropicClientResolver.resolve(request);
810
- const response = await client.send(request);
811
- const responseContext = new ResponseContext();
812
- responseContext.setProviderResponse(response);
874
+ async sendRequest(mozaikRequest) {
875
+ const providerRequest = this.buildRequest(mozaikRequest);
876
+ const client = AnthropicClientResolver.resolve(providerRequest);
877
+ const response = await client.send(providerRequest);
878
+ const mozaikResponse = new MozaikResponse();
879
+ mozaikResponse.setProviderResponse(response);
813
880
  const usageHandler = new UsageHandler2();
814
- const toolUseHandler = new ToolUseHandler(request, command.tools ? command.tools : []);
881
+ const toolUseHandler = new ToolUseHandler(
882
+ providerRequest,
883
+ mozaikRequest.tools ? mozaikRequest.tools : []
884
+ );
815
885
  const parsedOutputHandler = new ParsedOutputHandler();
816
886
  const contentHandler = new ContentHandler2();
817
887
  const unhandledResponseHandler = new UnhandledResponseHandler();
818
888
  usageHandler.setNextHandler(toolUseHandler).setNextHandler(parsedOutputHandler).setNextHandler(contentHandler).setNextHandler(unhandledResponseHandler);
819
889
  const responseHandler = usageHandler;
820
- const result = await responseHandler.handle(responseContext);
821
- const usageEntries = result.getUsageEntries().map((e) => ({
822
- inputTokens: e.inputTokens,
823
- outputTokens: e.outputTokens,
824
- model: e.model
825
- }));
826
- return {
827
- data: result.getResponse(),
828
- usageEntries
829
- };
890
+ const result = await responseHandler.handle(mozaikResponse);
891
+ return result.getResponse();
830
892
  }
831
893
  };
832
894
 
@@ -849,28 +911,28 @@ var DefaultEndpointResolver = class extends EndpointResolver {
849
911
  };
850
912
 
851
913
  // src/core/agents/agent.ts
852
- var Agent = class {
853
- constructor(command) {
914
+ var MozaikAgent = class {
915
+ constructor(request) {
854
916
  this.gateway = new RequestGateway(new DefaultEndpointResolver());
855
- this.command = command;
917
+ this.request = request;
856
918
  }
857
919
  setModel(model) {
858
- this.command.model = model;
920
+ this.request.model = model;
859
921
  }
860
922
  setMessages(messages) {
861
- this.command.messages = messages;
923
+ this.request.messages = messages;
862
924
  }
863
925
  setTask(task) {
864
- this.command.task = task;
926
+ this.request.task = task;
865
927
  }
866
928
  setStructuredOutput(schema) {
867
- this.command.structuredOutput = schema;
929
+ this.request.structuredOutput = schema;
868
930
  }
869
931
  async act(task) {
870
932
  if (task) {
871
- this.command.task = task;
933
+ this.request.task = task;
872
934
  }
873
- return await this.gateway.invoke(this.command);
935
+ return await this.gateway.invoke(this.request);
874
936
  }
875
937
  };
876
938
 
@@ -1002,11 +1064,11 @@ var Task = class extends WorkUnit {
1002
1064
  }
1003
1065
  async execute(hook = DEFAULT_CLUSTER_HOOK) {
1004
1066
  hook.beforeTask(this);
1005
- const command = {
1067
+ const request = {
1006
1068
  model: this.model,
1007
1069
  task: this.task
1008
1070
  };
1009
- const agent = new Agent(command);
1071
+ const agent = new MozaikAgent(request);
1010
1072
  const result = await agent.act(this.task);
1011
1073
  hook.afterTask(this, result);
1012
1074
  return result;
@@ -1041,9 +1103,9 @@ Rules:
1041
1103
  - Keep prompts actionable.
1042
1104
  - Don't ask user for any input, just do the thing with available data you have.
1043
1105
  `;
1044
- var PlanningAgent = class extends Agent {
1045
- constructor(command) {
1046
- super(command);
1106
+ var PlanningAgent = class extends MozaikAgent {
1107
+ constructor(request) {
1108
+ super(request);
1047
1109
  }
1048
1110
  async planFromGoal(goal) {
1049
1111
  this.setStructuredOutput(PlanSchema);
@@ -1054,7 +1116,7 @@ Goal: ${goal}`);
1054
1116
  };
1055
1117
  // Annotate the CommonJS export names for ESM import in node:
1056
1118
  0 && (module.exports = {
1057
- Agent,
1119
+ MozaikAgent,
1058
1120
  PlanningAgent,
1059
1121
  Task,
1060
1122
  WorkUnit,