@google/adk 0.2.0 → 0.2.2

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.
Files changed (75) hide show
  1. package/README.md +1 -7
  2. package/dist/cjs/agents/base_agent.js +14 -2
  3. package/dist/cjs/agents/content_processor_utils.js +2 -2
  4. package/dist/cjs/agents/functions.js +6 -3
  5. package/dist/cjs/agents/llm_agent.js +331 -4
  6. package/dist/cjs/auth/exchanger/base_credential_exchanger.js +40 -0
  7. package/dist/cjs/auth/exchanger/credential_exchanger_registry.js +59 -0
  8. package/dist/cjs/code_executors/code_execution_utils.js +2 -2
  9. package/dist/cjs/code_executors/code_executor_context.js +2 -2
  10. package/dist/cjs/common.js +7 -0
  11. package/dist/cjs/index.js +63 -5
  12. package/dist/cjs/index.js.map +4 -4
  13. package/dist/cjs/models/base_llm.js +16 -4
  14. package/dist/cjs/runner/runner.js +10 -1
  15. package/dist/cjs/sessions/in_memory_session_service.js +3 -3
  16. package/dist/cjs/sessions/state.js +1 -1
  17. package/dist/cjs/tools/agent_tool.js +2 -2
  18. package/dist/cjs/tools/mcp/mcp_session_manager.js +7 -1
  19. package/dist/cjs/utils/gemini_schema_util.js +16 -0
  20. package/dist/cjs/version.js +2 -2
  21. package/dist/esm/agents/base_agent.js +12 -1
  22. package/dist/esm/agents/content_processor_utils.js +2 -2
  23. package/dist/esm/agents/functions.js +6 -3
  24. package/dist/esm/agents/llm_agent.js +330 -4
  25. package/dist/esm/auth/exchanger/base_credential_exchanger.js +10 -0
  26. package/dist/esm/auth/exchanger/credential_exchanger_registry.js +29 -0
  27. package/dist/esm/code_executors/code_execution_utils.js +2 -2
  28. package/dist/esm/code_executors/code_executor_context.js +2 -2
  29. package/dist/esm/common.js +6 -2
  30. package/dist/esm/index.js +63 -5
  31. package/dist/esm/index.js.map +4 -4
  32. package/dist/esm/models/base_llm.js +14 -3
  33. package/dist/esm/runner/runner.js +10 -1
  34. package/dist/esm/sessions/in_memory_session_service.js +3 -3
  35. package/dist/esm/sessions/state.js +1 -1
  36. package/dist/esm/tools/agent_tool.js +2 -2
  37. package/dist/esm/tools/function_tool.js +3 -1
  38. package/dist/esm/tools/mcp/mcp_session_manager.js +7 -1
  39. package/dist/esm/utils/gemini_schema_util.js +16 -0
  40. package/dist/esm/version.js +2 -2
  41. package/dist/types/agents/base_agent.d.ts +15 -0
  42. package/dist/types/agents/functions.d.ts +2 -0
  43. package/dist/types/agents/llm_agent.d.ts +23 -0
  44. package/dist/types/auth/exchanger/base_credential_exchanger.d.ts +32 -0
  45. package/dist/types/auth/exchanger/credential_exchanger_registry.d.ts +28 -0
  46. package/dist/types/code_executors/code_executor_context.d.ts +0 -5
  47. package/dist/types/common.d.ts +3 -2
  48. package/dist/types/models/base_llm.d.ts +16 -0
  49. package/dist/types/sessions/in_memory_session_service.d.ts +0 -5
  50. package/dist/types/sessions/state.d.ts +2 -2
  51. package/dist/types/tools/function_tool.d.ts +3 -3
  52. package/dist/types/tools/tool_confirmation.d.ts +1 -1
  53. package/dist/types/utils/gemini_schema_util.d.ts +2 -2
  54. package/dist/types/version.d.ts +2 -2
  55. package/dist/web/agents/base_agent.js +12 -1
  56. package/dist/web/agents/content_processor_utils.js +2 -2
  57. package/dist/web/agents/functions.js +6 -3
  58. package/dist/web/agents/llm_agent.js +315 -4
  59. package/dist/web/auth/exchanger/base_credential_exchanger.js +10 -0
  60. package/dist/web/auth/exchanger/credential_exchanger_registry.js +29 -0
  61. package/dist/web/code_executors/code_execution_utils.js +2 -2
  62. package/dist/web/code_executors/code_executor_context.js +2 -2
  63. package/dist/web/common.js +6 -2
  64. package/dist/web/index.js +6 -1
  65. package/dist/web/index.js.map +4 -4
  66. package/dist/web/models/base_llm.js +14 -3
  67. package/dist/web/runner/runner.js +10 -1
  68. package/dist/web/sessions/in_memory_session_service.js +3 -3
  69. package/dist/web/sessions/state.js +1 -1
  70. package/dist/web/tools/agent_tool.js +2 -2
  71. package/dist/web/tools/function_tool.js +3 -1
  72. package/dist/web/tools/mcp/mcp_session_manager.js +7 -1
  73. package/dist/web/utils/gemini_schema_util.js +16 -0
  74. package/dist/web/version.js +2 -2
  75. package/package.json +3 -1
@@ -36,15 +36,23 @@ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")])
36
36
  * Copyright 2025 Google LLC
37
37
  * SPDX-License-Identifier: Apache-2.0
38
38
  */
39
+ import { cloneDeep } from "lodash";
39
40
  import { z } from "zod";
41
+ import { BaseCodeExecutor } from "../code_executors/base_code_executor.js";
42
+ import { BuiltInCodeExecutor } from "../code_executors/built_in_code_executor.js";
43
+ import { buildCodeExecutionResultPart, buildExecutableCodePart, convertCodeExecutionParts, extractCodeAndTruncateContent } from "../code_executors/code_execution_utils.js";
44
+ import { CodeExecutorContext } from "../code_executors/code_executor_context.js";
40
45
  import { createEvent, createNewEventId, getFunctionCalls, getFunctionResponses, isFinalResponse } from "../events/event.js";
41
- import { BaseLlm } from "../models/base_llm.js";
46
+ import { createEventActions } from "../events/event_actions.js";
47
+ import { isBaseLlm } from "../models/base_llm.js";
42
48
  import { appendInstructions, setOutputSchema } from "../models/llm_request.js";
43
49
  import { LLMRegistry } from "../models/registry.js";
50
+ import { State } from "../sessions/state.js";
44
51
  import { BaseTool } from "../tools/base_tool.js";
45
52
  import { FunctionTool } from "../tools/function_tool.js";
46
53
  import { ToolConfirmation } from "../tools/tool_confirmation.js";
47
54
  import { ToolContext } from "../tools/tool_context.js";
55
+ import { base64Decode } from "../utils/env_aware_utils.js";
48
56
  import { logger } from "../utils/logger.js";
49
57
  import { BaseAgent } from "./base_agent.js";
50
58
  import { BaseLlmRequestProcessor } from "./base_llm_processor.js";
@@ -349,6 +357,306 @@ class RequestConfirmationLlmRequestProcessor extends BaseLlmRequestProcessor {
349
357
  }
350
358
  }
351
359
  const REQUEST_CONFIRMATION_LLM_REQUEST_PROCESSOR = new RequestConfirmationLlmRequestProcessor();
360
+ class CodeExecutionRequestProcessor extends BaseLlmRequestProcessor {
361
+ runAsync(invocationContext, llmRequest) {
362
+ return __asyncGenerator(this, null, function* () {
363
+ if (!(invocationContext.agent instanceof LlmAgent)) {
364
+ return;
365
+ }
366
+ if (!invocationContext.agent.codeExecutor) {
367
+ return;
368
+ }
369
+ try {
370
+ for (var iter = __forAwait(runPreProcessor(invocationContext, llmRequest)), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
371
+ const event = temp.value;
372
+ yield event;
373
+ }
374
+ } catch (temp) {
375
+ error = [temp];
376
+ } finally {
377
+ try {
378
+ more && (temp = iter.return) && (yield new __await(temp.call(iter)));
379
+ } finally {
380
+ if (error)
381
+ throw error[0];
382
+ }
383
+ }
384
+ if (!(invocationContext.agent.codeExecutor instanceof BaseCodeExecutor)) {
385
+ return;
386
+ }
387
+ for (const content of llmRequest.contents) {
388
+ const delimeters = invocationContext.agent.codeExecutor.codeBlockDelimiters.length ? invocationContext.agent.codeExecutor.codeBlockDelimiters[0] : ["", ""];
389
+ const codeExecutionParts = convertCodeExecutionParts(
390
+ content,
391
+ delimeters,
392
+ invocationContext.agent.codeExecutor.executionResultDelimiters
393
+ );
394
+ }
395
+ });
396
+ }
397
+ }
398
+ const DATA_FILE_UTIL_MAP = {
399
+ "text/csv": {
400
+ extension: ".csv",
401
+ loaderCodeTemplate: "pd.read_csv('{filename}')"
402
+ }
403
+ };
404
+ const DATA_FILE_HELPER_LIB = "\nimport pandas as pd\n\ndef explore_df(df: pd.DataFrame) -> None:\n \"\"\"Prints some information about a pandas DataFrame.\"\"\"\n\n with pd.option_context(\n 'display.max_columns', None, 'display.expand_frame_repr', False\n ):\n # Print the column names to never encounter KeyError when selecting one.\n df_dtypes = df.dtypes\n\n # Obtain information about data types and missing values.\n df_nulls = (len(df) - df.isnull().sum()).apply(\n lambda x: f'{x} / {df.shape[0]} non-null'\n )\n\n # Explore unique total values in columns using `.unique()`.\n df_unique_count = df.apply(lambda x: len(x.unique()))\n\n # Explore unique values in columns using `.unique()`.\n df_unique = df.apply(lambda x: crop(str(list(x.unique()))))\n\n df_info = pd.concat(\n (\n df_dtypes.rename('Dtype'),\n df_nulls.rename('Non-Null Count'),\n df_unique_count.rename('Unique Values Count'),\n df_unique.rename('Unique Values'),\n ),\n axis=1,\n )\n df_info.index.name = 'Columns'\n print(f\"\"\"Total rows: {df.shape[0]}\nTotal columns: {df.shape[1]}\n\n{df_info}\"\"\")\n";
405
+ class CodeExecutionResponseProcessor {
406
+ /**
407
+ * Processes the LLM response asynchronously.
408
+ *
409
+ * @param invocationContext The invocation context
410
+ * @param llmResponse The LLM response to process
411
+ * @returns An async generator yielding events
412
+ */
413
+ runAsync(invocationContext, llmResponse) {
414
+ return __asyncGenerator(this, null, function* () {
415
+ if (llmResponse.partial) {
416
+ return;
417
+ }
418
+ try {
419
+ for (var iter = __forAwait(runPostProcessor(invocationContext, llmResponse)), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
420
+ const event = temp.value;
421
+ yield event;
422
+ }
423
+ } catch (temp) {
424
+ error = [temp];
425
+ } finally {
426
+ try {
427
+ more && (temp = iter.return) && (yield new __await(temp.call(iter)));
428
+ } finally {
429
+ if (error)
430
+ throw error[0];
431
+ }
432
+ }
433
+ });
434
+ }
435
+ }
436
+ const responseProcessor = new CodeExecutionResponseProcessor();
437
+ function runPreProcessor(invocationContext, llmRequest) {
438
+ return __asyncGenerator(this, null, function* () {
439
+ const agent = invocationContext.agent;
440
+ if (!(agent instanceof LlmAgent)) {
441
+ return;
442
+ }
443
+ const codeExecutor = agent.codeExecutor;
444
+ if (!codeExecutor || !(codeExecutor instanceof BaseCodeExecutor)) {
445
+ return;
446
+ }
447
+ if (codeExecutor instanceof BuiltInCodeExecutor) {
448
+ codeExecutor.processLlmRequest(llmRequest);
449
+ return;
450
+ }
451
+ if (!codeExecutor.optimizeDataFile) {
452
+ return;
453
+ }
454
+ const codeExecutorContext = new CodeExecutorContext(new State(invocationContext.session.state));
455
+ if (codeExecutorContext.getErrorCount(invocationContext.invocationId) >= codeExecutor.errorRetryAttempts) {
456
+ return;
457
+ }
458
+ const allInputFiles = extractAndReplaceInlineFiles(codeExecutorContext, llmRequest);
459
+ const processedFileNames = new Set(codeExecutorContext.getProcessedFileNames());
460
+ const filesToProcess = allInputFiles.filter((f) => !processedFileNames.has(f.name));
461
+ for (const file of filesToProcess) {
462
+ const codeStr = getDataFilePreprocessingCode(file);
463
+ if (!codeStr) {
464
+ return;
465
+ }
466
+ const codeContent = {
467
+ role: "model",
468
+ parts: [
469
+ { text: "Processing input file: `".concat(file.name, "`") },
470
+ buildExecutableCodePart(codeStr)
471
+ ]
472
+ };
473
+ llmRequest.contents.push(cloneDeep(codeContent));
474
+ yield createEvent({
475
+ invocationId: invocationContext.invocationId,
476
+ author: agent.name,
477
+ branch: invocationContext.branch,
478
+ content: codeContent
479
+ });
480
+ const executionId = getOrSetExecutionId(invocationContext, codeExecutorContext);
481
+ const codeExecutionResult = yield new __await(codeExecutor.executeCode({
482
+ invocationContext,
483
+ codeExecutionInput: {
484
+ code: codeStr,
485
+ inputFiles: [file],
486
+ executionId
487
+ }
488
+ }));
489
+ codeExecutorContext.updateCodeExecutionResult({
490
+ invocationId: invocationContext.invocationId,
491
+ code: codeStr,
492
+ resultStdout: codeExecutionResult.stdout,
493
+ resultStderr: codeExecutionResult.stderr
494
+ });
495
+ codeExecutorContext.addProcessedFileNames([file.name]);
496
+ const executionResultEvent = yield new __await(postProcessCodeExecutionResult(
497
+ invocationContext,
498
+ codeExecutorContext,
499
+ codeExecutionResult
500
+ ));
501
+ yield executionResultEvent;
502
+ llmRequest.contents.push(cloneDeep(executionResultEvent.content));
503
+ }
504
+ });
505
+ }
506
+ function runPostProcessor(invocationContext, llmResponse) {
507
+ return __asyncGenerator(this, null, function* () {
508
+ const agent = invocationContext.agent;
509
+ if (!(agent instanceof LlmAgent)) {
510
+ return;
511
+ }
512
+ const codeExecutor = agent.codeExecutor;
513
+ if (!codeExecutor || !(codeExecutor instanceof BaseCodeExecutor)) {
514
+ return;
515
+ }
516
+ if (!llmResponse || !llmResponse.content) {
517
+ return;
518
+ }
519
+ if (codeExecutor instanceof BuiltInCodeExecutor) {
520
+ return;
521
+ }
522
+ const codeExecutorContext = new CodeExecutorContext(new State(invocationContext.session.state));
523
+ if (codeExecutorContext.getErrorCount(invocationContext.invocationId) >= codeExecutor.errorRetryAttempts) {
524
+ return;
525
+ }
526
+ const responseContent = llmResponse.content;
527
+ const codeStr = extractCodeAndTruncateContent(
528
+ responseContent,
529
+ codeExecutor.codeBlockDelimiters
530
+ );
531
+ if (!codeStr) {
532
+ return;
533
+ }
534
+ yield createEvent({
535
+ invocationId: invocationContext.invocationId,
536
+ author: agent.name,
537
+ branch: invocationContext.branch,
538
+ content: responseContent
539
+ });
540
+ const executionId = getOrSetExecutionId(invocationContext, codeExecutorContext);
541
+ const codeExecutionResult = yield new __await(codeExecutor.executeCode({
542
+ invocationContext,
543
+ codeExecutionInput: {
544
+ code: codeStr,
545
+ inputFiles: codeExecutorContext.getInputFiles(),
546
+ executionId
547
+ }
548
+ }));
549
+ codeExecutorContext.updateCodeExecutionResult({
550
+ invocationId: invocationContext.invocationId,
551
+ code: codeStr,
552
+ resultStdout: codeExecutionResult.stdout,
553
+ resultStderr: codeExecutionResult.stderr
554
+ });
555
+ yield yield new __await(postProcessCodeExecutionResult(
556
+ invocationContext,
557
+ codeExecutorContext,
558
+ codeExecutionResult
559
+ ));
560
+ llmResponse.content = null;
561
+ });
562
+ }
563
+ function extractAndReplaceInlineFiles(codeExecutorContext, llmRequest) {
564
+ var _a;
565
+ const allInputFiles = codeExecutorContext.getInputFiles();
566
+ const savedFileNames = new Set(allInputFiles.map((f) => f.name));
567
+ for (let i = 0; i < llmRequest.contents.length; i++) {
568
+ const content = llmRequest.contents[i];
569
+ if (content.role !== "user" || !content.parts) {
570
+ continue;
571
+ }
572
+ for (let j = 0; j < content.parts.length; j++) {
573
+ const part = content.parts[j];
574
+ const mimeType = (_a = part.inlineData) == null ? void 0 : _a.mimeType;
575
+ if (!mimeType || !part.inlineData || !DATA_FILE_UTIL_MAP[mimeType]) {
576
+ continue;
577
+ }
578
+ const fileName = "data_".concat(i + 1, "_").concat(j + 1).concat(DATA_FILE_UTIL_MAP[mimeType].extension);
579
+ part.text = "\nAvailable file: `".concat(fileName, "`\n");
580
+ const file = {
581
+ name: fileName,
582
+ content: base64Decode(part.inlineData.data),
583
+ mimeType
584
+ };
585
+ if (!savedFileNames.has(fileName)) {
586
+ codeExecutorContext.addInputFiles([file]);
587
+ allInputFiles.push(file);
588
+ }
589
+ }
590
+ }
591
+ return allInputFiles;
592
+ }
593
+ function getOrSetExecutionId(invocationContext, codeExecutorContext) {
594
+ var _a;
595
+ const agent = invocationContext.agent;
596
+ if (!(agent instanceof LlmAgent) || !((_a = agent.codeExecutor) == null ? void 0 : _a.stateful)) {
597
+ return void 0;
598
+ }
599
+ let executionId = codeExecutorContext.getExecutionId();
600
+ if (!executionId) {
601
+ executionId = invocationContext.session.id;
602
+ codeExecutorContext.setExecutionId(executionId);
603
+ }
604
+ return executionId;
605
+ }
606
+ async function postProcessCodeExecutionResult(invocationContext, codeExecutorContext, codeExecutionResult) {
607
+ if (!invocationContext.artifactService) {
608
+ throw new Error("Artifact service is not initialized.");
609
+ }
610
+ const resultContent = {
611
+ role: "model",
612
+ parts: [buildCodeExecutionResultPart(codeExecutionResult)]
613
+ };
614
+ const eventActions = createEventActions({ stateDelta: codeExecutorContext.getStateDelta() });
615
+ if (codeExecutionResult.stderr) {
616
+ codeExecutorContext.incrementErrorCount(invocationContext.invocationId);
617
+ } else {
618
+ codeExecutorContext.resetErrorCount(invocationContext.invocationId);
619
+ }
620
+ for (const outputFile of codeExecutionResult.outputFiles) {
621
+ const version = await invocationContext.artifactService.saveArtifact({
622
+ appName: invocationContext.appName || "",
623
+ userId: invocationContext.userId || "",
624
+ sessionId: invocationContext.session.id,
625
+ filename: outputFile.name,
626
+ artifact: {
627
+ inlineData: { data: outputFile.content, mimeType: outputFile.mimeType }
628
+ }
629
+ });
630
+ eventActions.artifactDelta[outputFile.name] = version;
631
+ }
632
+ return createEvent({
633
+ invocationId: invocationContext.invocationId,
634
+ author: invocationContext.agent.name,
635
+ branch: invocationContext.branch,
636
+ content: resultContent,
637
+ actions: eventActions
638
+ });
639
+ }
640
+ function getDataFilePreprocessingCode(file) {
641
+ function getNormalizedFileName(fileName) {
642
+ const [varName2] = fileName.split(".");
643
+ let normalizedName = varName2.replace(/[^a-zA-Z0-9_]/g, "_");
644
+ if (/^\d/.test(normalizedName)) {
645
+ normalizedName = "_" + normalizedName;
646
+ }
647
+ return normalizedName;
648
+ }
649
+ if (!DATA_FILE_UTIL_MAP[file.mimeType]) {
650
+ return void 0;
651
+ }
652
+ const varName = getNormalizedFileName(file.name);
653
+ const loaderCode = DATA_FILE_UTIL_MAP[file.mimeType].loaderCodeTemplate.replace(
654
+ "{filename}",
655
+ file.name
656
+ );
657
+ return "\n".concat(DATA_FILE_HELPER_LIB, "\n\n# Load the dataframe.\n").concat(varName, " = ").concat(loaderCode, "\n\n# Use `explore_df` to guide my analysis.\nexplore_df(").concat(varName, ")\n");
658
+ }
659
+ const CODE_EXECUTION_REQUEST_PROCESSOR = new CodeExecutionRequestProcessor();
352
660
  class LlmAgent extends BaseAgent {
353
661
  constructor(config) {
354
662
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
@@ -368,12 +676,14 @@ class LlmAgent extends BaseAgent {
368
676
  this.afterModelCallback = config.afterModelCallback;
369
677
  this.beforeToolCallback = config.beforeToolCallback;
370
678
  this.afterToolCallback = config.afterToolCallback;
679
+ this.codeExecutor = config.codeExecutor;
371
680
  this.requestProcessors = (_g = config.requestProcessors) != null ? _g : [
372
681
  BASIC_LLM_REQUEST_PROCESSOR,
373
682
  IDENTITY_LLM_REQUEST_PROCESSOR,
374
683
  INSTRUCTIONS_LLM_REQUEST_PROCESSOR,
375
684
  REQUEST_CONFIRMATION_LLM_REQUEST_PROCESSOR,
376
- CONTENT_REQUEST_PROCESSOR
685
+ CONTENT_REQUEST_PROCESSOR,
686
+ CODE_EXECUTION_REQUEST_PROCESSOR
377
687
  ];
378
688
  this.responseProcessors = (_h = config.responseProcessors) != null ? _h : [];
379
689
  const agentTransferDisabled = this.disallowTransferToParent && this.disallowTransferToPeers && !((_i = this.subAgents) == null ? void 0 : _i.length);
@@ -423,7 +733,7 @@ class LlmAgent extends BaseAgent {
423
733
  * When not set, the agent will inherit the model from its ancestor.
424
734
  */
425
735
  get canonicalModel() {
426
- if (this.model instanceof BaseLlm) {
736
+ if (isBaseLlm(this.model)) {
427
737
  return this.model;
428
738
  }
429
739
  if (typeof this.model === "string" && this.model) {
@@ -975,5 +1285,6 @@ class LlmAgent extends BaseAgent {
975
1285
  }
976
1286
  export {
977
1287
  LlmAgent,
978
- REQUEST_CONFIRMATION_LLM_REQUEST_PROCESSOR
1288
+ REQUEST_CONFIRMATION_LLM_REQUEST_PROCESSOR,
1289
+ responseProcessor
979
1290
  };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ class CredentialExchangeError extends Error {
7
+ }
8
+ export {
9
+ CredentialExchangeError
10
+ };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ class CredentialExchangerRegistry {
7
+ constructor() {
8
+ this.exchangers = {};
9
+ }
10
+ /**
11
+ * Register an exchanger instance for a credential type.
12
+ * @param credentialType - The credential type to register for.
13
+ * @param exchangerInstance - The exchanger instance to register.
14
+ */
15
+ register(credentialType, exchangerInstance) {
16
+ this.exchangers[credentialType] = exchangerInstance;
17
+ }
18
+ /**
19
+ * Get the exchanger instance for a credential type.
20
+ * @param credentialType - The credential type to get exchanger for.
21
+ * @returns The exchanger instance if registered, undefined otherwise.
22
+ */
23
+ getExchanger(credentialType) {
24
+ return this.exchangers[credentialType];
25
+ }
26
+ }
27
+ export {
28
+ CredentialExchangerRegistry
29
+ };
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { Language, Outcome } from "@google/genai";
7
- import { deepClone } from "../utils/deep_clone.js";
7
+ import { cloneDeep } from "lodash";
8
8
  import { base64Encode, isBase64Encoded } from "../utils/env_aware_utils.js";
9
9
  function getEncodedFileContent(data) {
10
10
  return isBase64Encoded(data) ? data : base64Encode(data);
@@ -25,7 +25,7 @@ function extractCodeAndTruncateContent(content, codeBlockDelimiters) {
25
25
  if (!textParts.length) {
26
26
  return "";
27
27
  }
28
- const firstTextPart = deepClone(textParts[0]);
28
+ const firstTextPart = cloneDeep(textParts[0]);
29
29
  const responseText = textParts.map((part) => part.text).join("\n");
30
30
  const leadingDelimiterPattern = codeBlockDelimiters.map((d) => d[0]).join("|");
31
31
  const trailingDelimiterPattern = codeBlockDelimiters.map((d) => d[1]).join("|");
@@ -3,7 +3,7 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { deepClone } from "../utils/deep_clone.js";
6
+ import { cloneDeep } from "lodash";
7
7
  const CONTEXT_KEY = "_code_execution_context";
8
8
  const SESSION_ID_KEY = "execution_session_id";
9
9
  const PROCESSED_FILE_NAMES_KEY = "processed_input_files";
@@ -23,7 +23,7 @@ class CodeExecutorContext {
23
23
  */
24
24
  getStateDelta() {
25
25
  return {
26
- [CONTEXT_KEY]: deepClone(this.context)
26
+ [CONTEXT_KEY]: cloneDeep(this.context)
27
27
  };
28
28
  }
29
29
  /**
@@ -3,7 +3,7 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { BaseAgent } from "./agents/base_agent.js";
6
+ import { BaseAgent, isBaseAgent } from "./agents/base_agent.js";
7
7
  import { CallbackContext } from "./agents/callback_context.js";
8
8
  import { functionsExportedForTestingOnly } from "./agents/functions.js";
9
9
  import { InvocationContext } from "./agents/invocation_context.js";
@@ -14,10 +14,11 @@ import { ParallelAgent } from "./agents/parallel_agent.js";
14
14
  import { StreamingMode } from "./agents/run_config.js";
15
15
  import { SequentialAgent } from "./agents/sequential_agent.js";
16
16
  import { InMemoryArtifactService } from "./artifacts/in_memory_artifact_service.js";
17
+ import { BuiltInCodeExecutor } from "./code_executors/built_in_code_executor.js";
17
18
  import { createEvent, getFunctionCalls, getFunctionResponses, hasTrailingCodeExecutionResult, isFinalResponse, stringifyContent } from "./events/event.js";
18
19
  import { createEventActions } from "./events/event_actions.js";
19
20
  import { InMemoryMemoryService } from "./memory/in_memory_memory_service.js";
20
- import { BaseLlm } from "./models/base_llm.js";
21
+ import { BaseLlm, isBaseLlm } from "./models/base_llm.js";
21
22
  import { Gemini } from "./models/google_llm.js";
22
23
  import { LLMRegistry } from "./models/registry.js";
23
24
  import { BasePlugin } from "./plugins/base_plugin.js";
@@ -51,6 +52,7 @@ export {
51
52
  BasePlugin,
52
53
  BaseTool,
53
54
  BaseToolset,
55
+ BuiltInCodeExecutor,
54
56
  CallbackContext,
55
57
  FunctionTool,
56
58
  GOOGLE_SEARCH,
@@ -87,6 +89,8 @@ export {
87
89
  getFunctionCalls,
88
90
  getFunctionResponses,
89
91
  hasTrailingCodeExecutionResult,
92
+ isBaseAgent,
93
+ isBaseLlm,
90
94
  isFinalResponse,
91
95
  setLogLevel,
92
96
  stringifyContent,