@agtlantis/core 0.4.1 → 0.5.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.
@@ -1,4 +1,4 @@
1
- import { af as LLMCallRecord, ad as ToolCallSummary, ag as AdditionalCost, ah as SessionSummary, m as CompletionEvent, S as StreamingExecution, f as SessionEvent, E as ErrorEvent, p as FileManager, L as Logger, B as BaseProvider, b as ProviderPricing, j as SimpleSession, d as StreamingSession, h as ExtractResult, v as EmittableEventInput } from '../base-provider-C3mFLNiN.cjs';
1
+ import { ag as LLMCallRecord, ae as ToolCallSummary, ah as AdditionalCost, ai as SessionSummary, m as CompletionEvent, S as StreamingExecution, f as SessionEvent, E as ErrorEvent, p as FileManager, L as Logger, B as BaseProvider, b as ProviderPricing, G as GenerationOptions, j as SimpleSession, d as StreamingSession, h as ExtractResult, v as EmittableEventInput } from '../base-provider-2TTw5HAa.cjs';
2
2
  import { LanguageModelUsage, LanguageModel } from 'ai';
3
3
  import { MockLanguageModelV3 } from 'ai/test';
4
4
  export { MockLanguageModelV3, simulateReadableStream } from 'ai/test';
@@ -111,6 +111,10 @@ declare class MockProvider extends BaseProvider {
111
111
  * Mock implementation - returns same provider since mocks don't use provider options.
112
112
  */
113
113
  withDefaultOptions(_options: Record<string, unknown>): MockProvider;
114
+ /**
115
+ * Mock implementation - returns same provider since mocks don't use generation options.
116
+ */
117
+ withDefaultGenerationOptions(_options: GenerationOptions): MockProvider;
114
118
  protected createSimpleSession(signal?: AbortSignal): SimpleSession;
115
119
  protected createStreamingSession<TEvent extends {
116
120
  type: string;
@@ -1,4 +1,4 @@
1
- import { af as LLMCallRecord, ad as ToolCallSummary, ag as AdditionalCost, ah as SessionSummary, m as CompletionEvent, S as StreamingExecution, f as SessionEvent, E as ErrorEvent, p as FileManager, L as Logger, B as BaseProvider, b as ProviderPricing, j as SimpleSession, d as StreamingSession, h as ExtractResult, v as EmittableEventInput } from '../base-provider-C3mFLNiN.js';
1
+ import { ag as LLMCallRecord, ae as ToolCallSummary, ah as AdditionalCost, ai as SessionSummary, m as CompletionEvent, S as StreamingExecution, f as SessionEvent, E as ErrorEvent, p as FileManager, L as Logger, B as BaseProvider, b as ProviderPricing, G as GenerationOptions, j as SimpleSession, d as StreamingSession, h as ExtractResult, v as EmittableEventInput } from '../base-provider-2TTw5HAa.js';
2
2
  import { LanguageModelUsage, LanguageModel } from 'ai';
3
3
  import { MockLanguageModelV3 } from 'ai/test';
4
4
  export { MockLanguageModelV3, simulateReadableStream } from 'ai/test';
@@ -111,6 +111,10 @@ declare class MockProvider extends BaseProvider {
111
111
  * Mock implementation - returns same provider since mocks don't use provider options.
112
112
  */
113
113
  withDefaultOptions(_options: Record<string, unknown>): MockProvider;
114
+ /**
115
+ * Mock implementation - returns same provider since mocks don't use generation options.
116
+ */
117
+ withDefaultGenerationOptions(_options: GenerationOptions): MockProvider;
114
118
  protected createSimpleSession(signal?: AbortSignal): SimpleSession;
115
119
  protected createStreamingSession<TEvent extends {
116
120
  type: string;
@@ -1,7 +1,6 @@
1
1
  import { MockLanguageModelV3, simulateReadableStream } from 'ai/test';
2
2
  export { MockLanguageModelV3, simulateReadableStream } from 'ai/test';
3
3
  import { generateText, streamText } from 'ai';
4
- import merge from 'lodash/merge';
5
4
 
6
5
  // src/session/usage-extractors.ts
7
6
  function mergeUsages(usages) {
@@ -713,6 +712,23 @@ var BaseProvider = class {
713
712
  }
714
713
  };
715
714
 
715
+ // src/utils/deep-merge.ts
716
+ function isPlainObject(value) {
717
+ return typeof value === "object" && value !== null && !Array.isArray(value);
718
+ }
719
+ function deepMerge(...sources) {
720
+ const result = {};
721
+ for (const source of sources) {
722
+ if (!source) continue;
723
+ for (const key of Object.keys(source)) {
724
+ const existing = result[key];
725
+ const incoming = source[key];
726
+ result[key] = isPlainObject(existing) && isPlainObject(incoming) ? deepMerge(existing, incoming) : incoming;
727
+ }
728
+ }
729
+ return result;
730
+ }
731
+
716
732
  // src/pricing/defaults.ts
717
733
  var OPENAI_PRICING = {
718
734
  "gpt-4o": { inputPricePerMillion: 2.5, outputPricePerMillion: 10 },
@@ -921,6 +937,7 @@ var SimpleSession = class {
921
937
  providerPricing;
922
938
  defaultProviderOptions;
923
939
  defaultTools;
940
+ defaultGenerationOptions;
924
941
  _fileManager;
925
942
  logger;
926
943
  sessionStartTime;
@@ -935,6 +952,7 @@ var SimpleSession = class {
935
952
  this.providerPricing = options.providerPricing;
936
953
  this.defaultProviderOptions = options.defaultProviderOptions;
937
954
  this.defaultTools = options.defaultTools;
955
+ this.defaultGenerationOptions = options.defaultGenerationOptions;
938
956
  this._fileManager = options.fileManager;
939
957
  this.logger = options.logger ?? noopLogger;
940
958
  this.sessionStartTime = options.startTime ?? Date.now();
@@ -971,7 +989,7 @@ var SimpleSession = class {
971
989
  const { model: requestedModel, providerOptions, tools, ...restParams } = params;
972
990
  const languageModel = this.getModel(requestedModel);
973
991
  const modelId = this.extractModelId(languageModel);
974
- const mergedProviderOptions = this.defaultProviderOptions || providerOptions ? merge({}, this.defaultProviderOptions ?? {}, providerOptions ?? {}) : void 0;
992
+ const mergedProviderOptions = this.defaultProviderOptions || providerOptions ? deepMerge(this.defaultProviderOptions ?? {}, providerOptions ?? {}) : void 0;
975
993
  const mergedTools = this.defaultTools || tools ? { ...this.defaultTools, ...tools } : void 0;
976
994
  this.logger.onLLMCallStart?.({
977
995
  type: "llm_call_start",
@@ -982,6 +1000,7 @@ var SimpleSession = class {
982
1000
  });
983
1001
  try {
984
1002
  const result = await generateText({
1003
+ ...this.defaultGenerationOptions,
985
1004
  ...restParams,
986
1005
  tools: mergedTools,
987
1006
  providerOptions: mergedProviderOptions,
@@ -1032,7 +1051,7 @@ var SimpleSession = class {
1032
1051
  const { model: requestedModel, providerOptions, tools, ...restParams } = params;
1033
1052
  const languageModel = this.getModel(requestedModel);
1034
1053
  const modelId = this.extractModelId(languageModel);
1035
- const mergedProviderOptions = this.defaultProviderOptions || providerOptions ? merge({}, this.defaultProviderOptions ?? {}, providerOptions ?? {}) : void 0;
1054
+ const mergedProviderOptions = this.defaultProviderOptions || providerOptions ? deepMerge(this.defaultProviderOptions ?? {}, providerOptions ?? {}) : void 0;
1036
1055
  const mergedTools = this.defaultTools || tools ? { ...this.defaultTools, ...tools } : void 0;
1037
1056
  this.logger.onLLMCallStart?.({
1038
1057
  type: "llm_call_start",
@@ -1042,6 +1061,7 @@ var SimpleSession = class {
1042
1061
  request: { params: restParams }
1043
1062
  });
1044
1063
  const result = streamText({
1064
+ ...this.defaultGenerationOptions,
1045
1065
  ...restParams,
1046
1066
  tools: mergedTools,
1047
1067
  providerOptions: mergedProviderOptions,
@@ -1209,7 +1229,8 @@ var StreamingSession = class extends SimpleSession {
1209
1229
  startTime: options.startTime,
1210
1230
  signal: options.signal,
1211
1231
  defaultProviderOptions: options.defaultProviderOptions,
1212
- defaultTools: options.defaultTools
1232
+ defaultTools: options.defaultTools,
1233
+ defaultGenerationOptions: options.defaultGenerationOptions
1213
1234
  });
1214
1235
  this.lastEventTime = this._startTime;
1215
1236
  this._logger.onExecutionStart?.({
@@ -1489,6 +1510,12 @@ var MockProvider = class _MockProvider extends BaseProvider {
1489
1510
  withDefaultOptions(_options) {
1490
1511
  return this;
1491
1512
  }
1513
+ /**
1514
+ * Mock implementation - returns same provider since mocks don't use generation options.
1515
+ */
1516
+ withDefaultGenerationOptions(_options) {
1517
+ return this;
1518
+ }
1492
1519
  createSimpleSession(signal) {
1493
1520
  return new SimpleSession({ ...this.buildSessionConfig(), signal });
1494
1521
  }