Skip to content

Conversation

akitaSummer
Copy link
Contributor

@akitaSummer akitaSummer commented Oct 19, 2025

Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
Description of change

Summary by CodeRabbit

  • New Features
    • New LangChain decorator package providing graph primitives (graphs, nodes, edges, tools), bound chat-model support, qualifiers, metadata builders, and consolidated public API for building type-safe graph workflows with checkpoint support.
  • Documentation
    • Added package README and CHANGELOG documenting releases and installation.
  • Tests
    • Added comprehensive tests and fixtures validating graph/edge/node/tool metadata, bound models, qualifiers, and integration flows.

Copy link

coderabbitai bot commented Oct 19, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a new package @eggjs/tegg-langchain-decorator with TypeScript decorators, metadata models, InfoUtil utilities, meta-builders, qualifier helper, tests, fixtures, package configuration, and docs to integrate LangChain graph primitives with Egg.js Tegg.

Changes

Cohort / File(s) Summary
Package configuration & docs
core/langchain-decorator/package.json, core/langchain-decorator/README.md, core/langchain-decorator/CHANGELOG.md, core/langchain-decorator/tsconfig.json, core/langchain-decorator/tsconfig.pub.json
New package manifest, README, CHANGELOG and TypeScript configs for the new package.
Entry point
core/langchain-decorator/src/index.ts
New central re-export aggregator exposing builders, decorators, models, utilities, and qualifier.
Builders
core/langchain-decorator/src/builder/*MetaBuilder.ts
core/langchain-decorator/src/builder/GraphMetaBuilder.ts, .../GraphNodeMetaBuilder.ts, .../GraphEdgeMetaBuilder.ts, .../GraphToolMetaBuilder.ts, .../BoundModelMetaBuilder.ts
New builder classes that accept an EggProtoImplClass, query corresponding InfoUtil, and return typed Metadata model instances; each has build() and static create() methods.
Decorators & public APIs
core/langchain-decorator/src/decorator/*.ts
Graph.ts, GraphNode.ts, GraphEdge.ts, GraphTool.ts, BoundModel.ts
New decorator factories applying SingletonProto/prototype metadata, recording file path, and registering metadata; accompanying interfaces, abstract classes and exported types added.
Metadata models
core/langchain-decorator/src/model/*.ts
GraphMetadata.ts, GraphNodeMetadata.ts, GraphEdgeMetadata.ts, GraphToolMetadata.ts, BoundModelMetadata.ts
New interface/class pairs defining metadata shapes and constructors for graphs, nodes, edges, tools, and bound models.
Metadata utilities
core/langchain-decorator/src/util/*.ts
GraphInfoUtil.ts, GraphNodeInfoUtil.ts, GraphEdgeInfoUtil.ts, GraphToolInfoUtil.ts, BoundModelInfoUtil.ts, index.ts
New static utility classes using MetadataUtil to set/get metadata; GraphInfoUtil also maintains an in-memory map; index re-exports utilities.
Metadata keys & qualifier
core/langchain-decorator/src/type/metadataKey.ts, core/langchain-decorator/src/qualifier/ChatModelQualifier.ts
New Symbol constants for metadata keys and a ChatModelQualifier decorator that registers injection qualifiers.
Qualifier / Chat model utility
core/langchain-decorator/src/qualifier/ChatModelQualifier.ts
Exports ChatModelQualifierAttribute, ChatModelInjectName, and ChatModelQualifier(chatModelName) decorator.
Tests & fixtures
core/langchain-decorator/test/fixtures/modules/langchain/*, core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts, core/langchain-decorator/test/*.test.ts, core/langchain-decorator/test/package.json
New fixture modules demonstrating decorator usage and a test suite validating metadata builders, decorators, and qualifier behavior.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant Decorator as Decorator (e.g., @Graph)
    participant Proto as SingletonProto / PrototypeUtil
    participant InfoUtil as InfoUtil (GraphInfoUtil etc.)
    participant Builder as MetaBuilder
    participant Model as MetadataModel

    Dev->>Decorator: apply decorator to class (params)
    Decorator->>Proto: apply SingletonProto / set file path
    Decorator->>InfoUtil: set*Metadata(params, Class)
    InfoUtil->>InfoUtil: MetadataUtil.defineMetaData(key, metadata, Class)

    Note over Dev,Model: Later, during tests or runtime

    Dev->>Builder: Builder.create(Class).build()
    Builder->>InfoUtil: get*Metadata(Class)
    InfoUtil->>InfoUtil: MetadataUtil.getMetaData(key, Class)
    InfoUtil-->>Builder: metadata?
    Builder->>Model: new MetadataModel(metadata)
    Model-->>Dev: MetadataModel instance
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • killagu

Poem

🐰
I nibble bytes and bind a node,
Decorators planted on the road.
Metadata hops into a row,
Builders bloom and tests will show.
Hooray — a tiny rabbit taps the code!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "feat: add langchain decorator" clearly and directly summarizes the main change in the changeset. The entire pull request focuses on introducing a new npm package @eggjs/tegg-langchain-decorator with comprehensive decorator support for LangChain integration within the Egg.js/Tegg framework, including decorators (Graph, GraphEdge, GraphNode, GraphTool, BoundModel), builders, metadata models, utilities, and test fixtures. The title is concise, specific, and follows conventional commit conventions, allowing a developer scanning the repository history to immediately understand that this PR adds LangChain decorator functionality without ambiguity or vague terminology.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/langchain

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Summary of Changes

Hello @akitaSummer, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces the "@eggjs/tegg-langchain-decorator" package, which aims to streamline the development of AI-powered applications by integrating LangChain's powerful capabilities directly into the Egg.js ecosystem. By leveraging a new set of TypeScript decorators, developers can now define complex AI workflows, including state graphs, processing nodes, conditional edges, and AI tools, in a declarative and maintainable manner. This enhancement fosters a more idiomatic approach to building intelligent services, allowing for easier configuration and dependency management of LangChain components within Egg.js applications.

Highlights

  • New Package Introduction: A new package, "@eggjs/tegg-langchain-decorator", has been added to the project, specifically designed for integrating LangChain functionalities.
  • Declarative LangChain Components: Introduces a suite of decorators ("@graph", "@graphnode", "@graphedge", "@graphtool", "@BoundModel") for declaratively defining LangChain graphs, nodes, edges, tools, and bound models within the Egg.js framework.
  • Metadata-Driven Configuration: Implements a metadata system to capture and manage the configuration of these LangChain components, simplifying their integration and usage through builders and utility classes.
  • Chat Model Injection: Provides a "@ChatModelQualifier" decorator to enable precise injection of specific chat models into services and components, enhancing dependency management.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new package, @eggjs/tegg-langchain-decorator, to integrate LangChain with the Tegg framework. It provides a set of decorators (@Graph, @GraphNode, @GraphEdge, @GraphTool, @BoundModel) to declaratively build and configure LangChain graphs. The overall approach is solid and aligns well with the Tegg ecosystem.

However, I've found a few issues that need to be addressed:

  • The CHANGELOG.md for the new package seems to be incorrectly copied from another package.
  • The package.json uses "next" for LangChain dependencies, which can cause build instability.
  • There are several instances of commented-out code and deep imports that should be cleaned up for better maintainability.
  • One of the utility classes introduces a global state, which could be problematic.
  • A test fixture is missing a required configuration for a graph.

Details and suggestions are provided in the specific comments.

Comment on lines +1 to +8
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [3.62.0](https://github.com/eggjs/tegg/compare/v3.61.0...v3.62.0) (2025-09-24)

**Note:** Version bump only for package @eggjs/tegg-orm-decorator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This changelog appears to be for @eggjs/tegg-orm-decorator, not the new @eggjs/tegg-langchain-decorator package. It seems to be a copy-paste error. Please create a correct changelog for this new package, starting with its initial version.

Comment on lines 43 to 47
"@langchain/community": "next",
"@langchain/core": "next",
"@langchain/langgraph": "next",
"@langchain/openai": "next",
"langchain": "next",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using "next" as a version for dependencies is risky, especially for a library. It can pull in breaking changes unexpectedly, leading to non-reproducible builds. It's highly recommended to pin these dependencies to a specific version or a version range (e.g., "^0.1.0") to ensure stability.

@@ -0,0 +1,44 @@
// import type { EggProtoImplClass } from '@alipay/tegg-types';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This commented-out import should be removed. It appears to be a leftover from development.

import { IGraphNodeMetadata } from '../model/GraphNodeMetadata';
import { GraphNodeInfoUtil } from '../util/GraphNodeInfoUtil';
import { AnnotationRoot, StateDefinition, UpdateType } from '@langchain/langgraph';
import { ConfigurableModel } from 'langchain/dist/chat_models/universal.js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This is a deep import from the langchain package. This can be brittle and break if langchain changes its internal file structure. It's better to import from the public API of langchain if ConfigurableModel is exported at the top level (e.g., import { ConfigurableModel } from 'langchain';). Please check if this is possible.


export interface IGraphNode<S extends StateDefinition = StateDefinition, T = any> {

// execute(state: T extends AbstractStateGraph<infer S> ? GraphStateType<S> : never): Promise<GraphUpdateType<T> extends object ? GraphUpdateType<T> & Record<string, any> : GraphUpdateType<T>>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This commented-out code should be removed to improve code clarity and maintainability.

export interface IGraphToolMetadata extends SingletonProtoParams {
toolName: string;
description: string;
// schema: Parameters<McpServer['tool']>['2'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This commented-out property should be removed to keep the code clean.

Comment on lines +7 to +20
static graphMap = new Map<EggProtoImplClass, IGraphMetadata>();

static setGraphMetadata(metadata: IGraphMetadata, clazz: EggProtoImplClass) {
MetadataUtil.defineMetaData(GRAPH_GRAPH_METADATA, metadata, clazz);
GraphInfoUtil.graphMap.set(clazz, metadata);
}

static getGraphMetadata(clazz: EggProtoImplClass): IGraphMetadata | undefined {
return MetadataUtil.getMetaData(GRAPH_GRAPH_METADATA, clazz);
}

static getAllGraphMetadata(): Map<EggProtoImplClass, IGraphMetadata> {
return GraphInfoUtil.graphMap;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The static graphMap introduces a global state that collects all graph metadata. This can lead to unpredictable behavior and flaky tests, as the state persists across different contexts and is not reset. It's better to avoid global state. If the goal is to discover all graphs, this should ideally be handled by the tegg IoC container during its scanning phase. If this pattern is unavoidable, please ensure there's a mechanism to reset this map, especially for testing purposes.

Comment on lines +1 to +5
export * from './GraphEdgeInfoUtil.js';
export * from './GraphInfoUtil.js';
export * from './GraphNodeInfoUtil.js';
export * from './GraphToolInfoUtil.js';
export * from './BoundModelInfoUtil.js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The .js extension in the export paths is inconsistent with other files in this package, which use extensionless imports/exports (e.g., src/index.ts). While this might work depending on the module resolution settings, it's better to be consistent. Please remove the .js extensions for consistency.

Suggested change
export * from './GraphEdgeInfoUtil.js';
export * from './GraphInfoUtil.js';
export * from './GraphNodeInfoUtil.js';
export * from './GraphToolInfoUtil.js';
export * from './BoundModelInfoUtil.js';
export * from './GraphEdgeInfoUtil';
export * from './GraphInfoUtil';
export * from './GraphNodeInfoUtil';
export * from './GraphToolInfoUtil';
export * from './BoundModelInfoUtil';

Comment on lines +6 to +9
import { BaseMessage } from '@langchain/core/dist/messages/base';
import { AccessLevel, ToolArgs } from '@eggjs/tegg-types';
import { ToolArgsSchema } from '@eggjs/controller-decorator';
import { AIMessage } from '@langchain/core/dist/messages/ai';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The imports for BaseMessage and AIMessage are deep imports from @langchain/core. This is fragile and can break with package updates. Please import them from the public API of @langchain/core if possible (e.g., import { BaseMessage, AIMessage } from '@langchain/core/messages').

}

async build() {
this.addNode(FooGraphNodeName.ACTION, this.barNode.execute);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The build method for BarGraph seems to be missing a call to setEntryPoint. For a graph with cycles, an entry point must be defined, otherwise compile() will likely throw an error. You should add this.setEntryPoint(FooGraphNodeName.ACTION); before adding nodes and edges.

Suggested change
this.addNode(FooGraphNodeName.ACTION, this.barNode.execute);
this.setEntryPoint(FooGraphNodeName.ACTION);
this.addNode(FooGraphNodeName.ACTION, this.barNode.execute);

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

🧹 Nitpick comments (18)
core/langchain-decorator/test/index.test.ts (2)

6-6: Use strict assertion API.

Prefer importing the strict variant to avoid coercion.

-import assert from 'node:assert';
+import { strict as assert } from 'node:assert';

8-12: Make test intent explicit and assert strictly.

Rename the test and use strictEqual for clarity.

-describe('index.test.ts', () => {
-  it('should success', () => {
+describe('ChatModel qualifier', () => {
+  it('returns "chat" for Foo.chatModel', () => {
     const chatModelQualifier = QualifierUtil.getProperQualifier(Foo, 'chatModel', ChatModelQualifierAttribute);
-    assert.equal(chatModelQualifier, 'chat');
+    assert.strictEqual(chatModelQualifier, 'chat');
   });
 });
core/langchain-decorator/src/model/GraphEdgeMetadata.ts (1)

8-16: Implement interface fields, ensure immutability, and align with other metadata classes.

Currently only two fields are assigned; params extend SingletonProtoParams and future fields could be lost. Also clone arrays to prevent external mutation.

-export class GraphEdgeMetadata {
-  fromNodeName: string;
-  toNodeNames: string[];
-
-  constructor(params: IGraphEdgeMetadata) {
-    this.fromNodeName = params.fromNodeName;
-    this.toNodeNames = params.toNodeNames;
-  }
-}
+export class GraphEdgeMetadata implements IGraphEdgeMetadata {
+  readonly fromNodeName: string;
+  readonly toNodeNames: string[];
+  // Optional: include any fields from SingletonProtoParams in the future
+  // readonly name?: string;
+  // readonly accessLevel?: string;
+
+  constructor(params: IGraphEdgeMetadata) {
+    this.fromNodeName = params.fromNodeName;
+    this.toNodeNames = [ ...params.toNodeNames ];
+    // Optional validation:
+    // if (!this.toNodeNames.length) throw new Error('GraphEdgeMetadata.toNodeNames must be non-empty');
+  }
+}
core/langchain-decorator/CHANGELOG.md (1)

871-876: Fix heading levels to satisfy markdownlint (MD001).

“### Features/Bug Fixes” should not jump from H1; change to H2 (and similarly elsewhere).

Example fix:

-### Features
+## Features

Apply the same adjustment to all similar sections. Based on static analysis hints.

core/langchain-decorator/src/builder/GraphToolMetaBuilder.ts (1)

12-17: Return explicitly when metadata is absent.

Add an explicit return undefined; to satisfy noImplicitReturns and improve clarity.

   build(): GraphToolMetadata | undefined {
     const metadata = GraphToolInfoUtil.getGraphToolMetadata(this.clazz);
     if (metadata) {
       return new GraphToolMetadata(metadata);
     }
+    return undefined;
   }
core/langchain-decorator/src/builder/GraphNodeMetaBuilder.ts (2)

12-17: Return explicitly when metadata is absent.

Mirror GraphToolMetaBuilder and return undefined explicitly for consistency and noImplicitReturns.

   build(): GraphNodeMetadata | undefined {
     const metadata = GraphNodeInfoUtil.getGraphNodeMetadata(this.clazz);
     if (metadata) {
       return new GraphNodeMetadata(metadata);
     }
+    return undefined;
   }

5-22: Reduce duplication across MetaBuilders.

GraphNodeMetaBuilder and GraphToolMetaBuilder are structurally identical. Consider a small generic/base builder to DRY.

Sketch:

abstract class BaseMetaBuilder<TMeta> {
  constructor(protected readonly clazz: EggProtoImplClass) {}
  protected abstract fetch(): TMeta | undefined;
  protected abstract wrap(meta: TMeta): any;
  build() { const m = this.fetch(); return m ? this.wrap(m) : undefined; }
}

Then extend for node/tool with tiny overrides.

core/langchain-decorator/src/model/BoundModelMetadata.ts (1)

14-18: Consider using Object.assign for consistency.

The constructor manually assigns each property, while GraphToolMetadata uses Object.assign(this, params). Consider adopting a consistent approach across all metadata model classes.

Apply this diff for consistency:

  constructor(params: IBoundModelMetadata) {
-   this.modelName = params.modelName;
-   this.tools = params.tools;
-   this.mcpServers = params.mcpServers;
+   Object.assign(this, params);
  }
core/langchain-decorator/src/model/GraphToolMetadata.ts (2)

6-6: Remove or address the commented code.

The commented schema property suggests incomplete work or a placeholder. Please either implement the property if needed, document why it's commented, or remove it.


10-11: Remove redundant default values.

The default values toolName = '' and description = '' are immediately overwritten by Object.assign(this, params) in the constructor, making them redundant.

Apply this diff:

export class GraphToolMetadata implements IGraphToolMetadata {
-  toolName = '';
-  description = '';
+  toolName: string;
+  description: string;

  constructor(params: IGraphToolMetadata) {
    Object.assign(this, params);
  }
}
core/langchain-decorator/src/decorator/GraphTool.ts (1)

1-1: Remove commented-out import.

The commented import is dead code that should be removed for cleaner codebase maintenance.

Apply this diff:

-// import type { ToolSchemaBase, DynamicStructuredTool } from '../../core/tools.js';
-
core/langchain-decorator/src/model/GraphNodeMetadata.ts (1)

14-18: Consider using Object.assign for consistency.

The constructor manually assigns each property, while GraphToolMetadata uses Object.assign(this, params). For consistency across metadata models, consider using Object.assign here as well.

Apply this diff:

 constructor(params: IGraphNodeMetadata) {
-  this.nodeName = params.nodeName;
-  this.tools = params.tools;
-  this.mcpServers = params.mcpServers;
+  Object.assign(this, params);
 }
core/langchain-decorator/src/decorator/GraphNode.ts (2)

1-1: Remove commented-out import.

This dead code should be removed for cleaner maintenance.

Apply this diff:

-// import type { EggProtoImplClass } from '@alipay/tegg-types';
-

30-36: Remove commented-out type signature.

The commented code at line 32 is dead code that should be removed.

Apply this diff:

 export interface IGraphNode<S extends StateDefinition = StateDefinition, T = any> {
 
-  // execute(state: T extends AbstractStateGraph<infer S> ? GraphStateType<S> : never): Promise<GraphUpdateType<T> extends object ? GraphUpdateType<T> & Record<string, any> : GraphUpdateType<T>>;
   execute(state: AnnotationRoot<S>['State']): Promise<UpdateType<S> & Record<string, any>> | Promise<ToolNode<T>>;
core/langchain-decorator/src/decorator/GraphEdge.ts (1)

25-35: Enforce execute when multiple toNodeNames.

Today it’s a doc comment only. Consider a runtime assert in the builder or a conditional type to require execute when params.toNodeNames has length > 1.

Example runtime guard (in GraphEdgeMetaBuilder):

if (params.toNodeNames.length > 1 && typeof clazz.prototype.execute !== 'function') {
  throw new Error(`GraphEdge ${clazz.name} must implement execute() when multiple toNodeNames are provided`);
}

Also applies to: 42-44

core/langchain-decorator/src/decorator/Graph.ts (1)

31-38: Remove ts-ignore; use declare fields to anchor generics.

Avoids disabling checks while keeping the intent.

Apply:

-  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
-  // @ts-ignore
-  private _names: N;
+  protected declare _names: N;
 
-  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
-  // @ts-ignore
-  private _state: S;
+  protected declare _state: S;
core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (2)

6-10: Avoid importing from internal dist paths; use public module paths.

Swap to public exports to prevent breakage on package rearranges.

Apply:

-import { BaseMessage } from '@langchain/core/dist/messages/base';
+import { BaseMessage } from '@langchain/core/messages';
...
-import { AIMessage } from '@langchain/core/dist/messages/ai';
+import { AIMessage } from '@langchain/core/messages';

7-7: Keep AccessLevel import consistent with production code.

Elsewhere it’s imported from @eggjs/tegg; consider aligning.

Example:

-import { AccessLevel, ToolArgs } from '@eggjs/tegg-types';
+import { AccessLevel } from '@eggjs/tegg';
+import { ToolArgs } from '@eggjs/tegg-types';
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f8bce5c and 29a8e22.

📒 Files selected for processing (35)
  • core/langchain-decorator/CHANGELOG.md (1 hunks)
  • core/langchain-decorator/README.md (1 hunks)
  • core/langchain-decorator/package.json (1 hunks)
  • core/langchain-decorator/src/builder/BoundModelMetaBuilder.ts (1 hunks)
  • core/langchain-decorator/src/builder/GraphEdgeMetaBuilder.ts (1 hunks)
  • core/langchain-decorator/src/builder/GraphMetaBuilder.ts (1 hunks)
  • core/langchain-decorator/src/builder/GraphNodeMetaBuilder.ts (1 hunks)
  • core/langchain-decorator/src/builder/GraphToolMetaBuilder.ts (1 hunks)
  • core/langchain-decorator/src/decorator/BoundModel.ts (1 hunks)
  • core/langchain-decorator/src/decorator/Graph.ts (1 hunks)
  • core/langchain-decorator/src/decorator/GraphEdge.ts (1 hunks)
  • core/langchain-decorator/src/decorator/GraphNode.ts (1 hunks)
  • core/langchain-decorator/src/decorator/GraphTool.ts (1 hunks)
  • core/langchain-decorator/src/index.ts (1 hunks)
  • core/langchain-decorator/src/model/BoundModelMetadata.ts (1 hunks)
  • core/langchain-decorator/src/model/GraphEdgeMetadata.ts (1 hunks)
  • core/langchain-decorator/src/model/GraphMetadata.ts (1 hunks)
  • core/langchain-decorator/src/model/GraphNodeMetadata.ts (1 hunks)
  • core/langchain-decorator/src/model/GraphToolMetadata.ts (1 hunks)
  • core/langchain-decorator/src/qualifier/ChatModelQualifier.ts (1 hunks)
  • core/langchain-decorator/src/type/metadataKey.ts (1 hunks)
  • core/langchain-decorator/src/util/BoundModelInfoUtil.ts (1 hunks)
  • core/langchain-decorator/src/util/GraphEdgeInfoUtil.ts (1 hunks)
  • core/langchain-decorator/src/util/GraphInfoUtil.ts (1 hunks)
  • core/langchain-decorator/src/util/GraphNodeInfoUtil.ts (1 hunks)
  • core/langchain-decorator/src/util/GraphToolInfoUtil.ts (1 hunks)
  • core/langchain-decorator/src/util/index.ts (1 hunks)
  • core/langchain-decorator/test/fixtures/modules/langchain/index.ts (1 hunks)
  • core/langchain-decorator/test/fixtures/modules/langchain/package.json (1 hunks)
  • core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (1 hunks)
  • core/langchain-decorator/test/graph.test.ts (1 hunks)
  • core/langchain-decorator/test/index.test.ts (1 hunks)
  • core/langchain-decorator/test/package.json (1 hunks)
  • core/langchain-decorator/tsconfig.json (1 hunks)
  • core/langchain-decorator/tsconfig.pub.json (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (23)
core/langchain-decorator/src/builder/BoundModelMetaBuilder.ts (3)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/langchain-decorator/src/model/BoundModelMetadata.ts (1)
  • BoundModelMetadata (9-19)
core/langchain-decorator/src/util/BoundModelInfoUtil.ts (1)
  • BoundModelInfoUtil (6-14)
core/langchain-decorator/src/model/BoundModelMetadata.ts (1)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/langchain-decorator/src/util/GraphInfoUtil.ts (4)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/langchain-decorator/src/model/GraphMetadata.ts (1)
  • IGraphMetadata (4-8)
core/core-decorator/src/util/MetadataUtil.ts (1)
  • MetadataUtil (5-97)
core/langchain-decorator/src/type/metadataKey.ts (1)
  • GRAPH_GRAPH_METADATA (4-4)
core/langchain-decorator/test/index.test.ts (2)
core/core-decorator/src/util/QualifierUtil.ts (1)
  • QualifierUtil (6-100)
core/langchain-decorator/src/qualifier/ChatModelQualifier.ts (1)
  • ChatModelQualifierAttribute (3-3)
core/langchain-decorator/src/util/GraphNodeInfoUtil.ts (4)
core/langchain-decorator/src/model/GraphNodeMetadata.ts (1)
  • IGraphNodeMetadata (3-7)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/core-decorator/src/util/MetadataUtil.ts (1)
  • MetadataUtil (5-97)
core/langchain-decorator/src/type/metadataKey.ts (1)
  • GRAPH_NODE_METADATA (3-3)
core/langchain-decorator/src/builder/GraphToolMetaBuilder.ts (3)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/langchain-decorator/src/model/GraphToolMetadata.ts (1)
  • GraphToolMetadata (9-16)
core/langchain-decorator/src/util/GraphToolInfoUtil.ts (1)
  • GraphToolInfoUtil (6-14)
core/langchain-decorator/src/util/GraphToolInfoUtil.ts (4)
core/langchain-decorator/src/model/GraphToolMetadata.ts (1)
  • IGraphToolMetadata (3-7)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/core-decorator/src/util/MetadataUtil.ts (1)
  • MetadataUtil (5-97)
core/langchain-decorator/src/type/metadataKey.ts (1)
  • GRAPH_TOOL_METADATA (1-1)
core/langchain-decorator/src/builder/GraphNodeMetaBuilder.ts (3)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/langchain-decorator/src/model/GraphNodeMetadata.ts (1)
  • GraphNodeMetadata (9-19)
core/langchain-decorator/src/util/GraphNodeInfoUtil.ts (1)
  • GraphNodeInfoUtil (6-14)
core/langchain-decorator/src/builder/GraphEdgeMetaBuilder.ts (3)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/langchain-decorator/src/model/GraphEdgeMetadata.ts (1)
  • GraphEdgeMetadata (8-16)
core/langchain-decorator/src/util/GraphEdgeInfoUtil.ts (1)
  • GraphEdgeInfoUtil (6-14)
core/langchain-decorator/test/graph.test.ts (10)
core/langchain-decorator/src/builder/GraphMetaBuilder.ts (1)
  • GraphMetaBuilder (5-22)
core/langchain-decorator/src/builder/GraphEdgeMetaBuilder.ts (1)
  • GraphEdgeMetaBuilder (5-22)
core/langchain-decorator/src/builder/GraphNodeMetaBuilder.ts (1)
  • GraphNodeMetaBuilder (5-22)
core/langchain-decorator/src/builder/BoundModelMetaBuilder.ts (1)
  • BoundModelMetaBuilder (5-22)
core/langchain-decorator/src/builder/GraphToolMetaBuilder.ts (1)
  • GraphToolMetaBuilder (5-22)
core/langchain-decorator/src/model/GraphToolMetadata.ts (1)
  • GraphToolMetadata (9-16)
core/controller-decorator/src/util/MCPInfoUtil.ts (1)
  • MCPInfoUtil (42-166)
core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (1)
  • ToolType (38-42)
core/langchain-decorator/src/model/GraphMetadata.ts (1)
  • GraphMetadata (10-20)
core/langchain-decorator/src/decorator/GraphNode.ts (1)
  • TeggToolNode (38-44)
core/langchain-decorator/src/util/GraphEdgeInfoUtil.ts (4)
core/langchain-decorator/src/model/GraphEdgeMetadata.ts (1)
  • IGraphEdgeMetadata (3-6)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/core-decorator/src/util/MetadataUtil.ts (1)
  • MetadataUtil (5-97)
core/langchain-decorator/src/type/metadataKey.ts (1)
  • GRAPH_EDGE_METADATA (2-2)
core/langchain-decorator/src/decorator/GraphEdge.ts (5)
core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (5)
  • GraphEdge (92-107)
  • constructor (117-119)
  • constructor (166-168)
  • SingletonProto (23-24)
  • SingletonProto (177-190)
core/langchain-decorator/src/model/GraphEdgeMetadata.ts (2)
  • IGraphEdgeMetadata (3-6)
  • constructor (12-15)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/core-decorator/src/util/PrototypeUtil.ts (1)
  • PrototypeUtil (16-291)
core/langchain-decorator/src/util/GraphEdgeInfoUtil.ts (1)
  • GraphEdgeInfoUtil (6-14)
core/langchain-decorator/src/qualifier/ChatModelQualifier.ts (1)
core/core-decorator/src/util/QualifierUtil.ts (1)
  • QualifierUtil (6-100)
core/langchain-decorator/src/util/BoundModelInfoUtil.ts (4)
core/langchain-decorator/src/model/BoundModelMetadata.ts (1)
  • IBoundModelMetadata (3-7)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/core-decorator/src/util/MetadataUtil.ts (1)
  • MetadataUtil (5-97)
core/langchain-decorator/src/type/metadataKey.ts (1)
  • BOUND_MODEL_METADATA (6-6)
core/langchain-decorator/src/decorator/GraphTool.ts (4)
core/langchain-decorator/src/model/GraphToolMetadata.ts (2)
  • IGraphToolMetadata (3-7)
  • constructor (13-15)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/core-decorator/src/util/PrototypeUtil.ts (1)
  • PrototypeUtil (16-291)
core/langchain-decorator/src/util/GraphToolInfoUtil.ts (1)
  • GraphToolInfoUtil (6-14)
core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (9)
core/langchain-decorator/test/fixtures/modules/langchain/index.ts (1)
  • SingletonProto (7-14)
core/langchain-decorator/src/decorator/GraphTool.ts (2)
  • GraphTool (15-26)
  • IGraphTool (28-31)
core/controller-decorator/src/decorator/mcp/MCPTool.ts (1)
  • ToolArgsSchema (35-52)
core/types/controller-decorator/MCPToolParams.ts (1)
  • ToolArgs (5-5)
core/langchain-decorator/src/decorator/BoundModel.ts (2)
  • BoundModel (14-25)
  • TeggBoundModel (30-30)
core/langchain-decorator/src/decorator/GraphNode.ts (3)
  • GraphNode (17-28)
  • TeggToolNode (38-44)
  • IGraphNode (30-36)
core/langchain-decorator/src/qualifier/ChatModelQualifier.ts (1)
  • ChatModelQualifier (6-10)
core/langchain-decorator/src/decorator/GraphEdge.ts (3)
  • GraphStateType (38-38)
  • GraphEdge (25-36)
  • IGraphEdge (42-44)
core/langchain-decorator/src/decorator/Graph.ts (2)
  • Graph (12-23)
  • TeggCompiledStateGraph (40-40)
core/langchain-decorator/src/model/GraphMetadata.ts (1)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/langchain-decorator/src/decorator/GraphNode.ts (5)
core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (7)
  • GraphNode (63-68)
  • GraphNode (71-90)
  • GraphNode (123-147)
  • constructor (117-119)
  • constructor (166-168)
  • SingletonProto (23-24)
  • SingletonProto (177-190)
core/langchain-decorator/src/model/GraphNodeMetadata.ts (2)
  • IGraphNodeMetadata (3-7)
  • constructor (14-18)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/core-decorator/src/util/PrototypeUtil.ts (1)
  • PrototypeUtil (16-291)
core/langchain-decorator/src/util/GraphNodeInfoUtil.ts (1)
  • GraphNodeInfoUtil (6-14)
core/langchain-decorator/src/model/GraphNodeMetadata.ts (1)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/langchain-decorator/src/decorator/BoundModel.ts (4)
core/langchain-decorator/src/model/BoundModelMetadata.ts (2)
  • IBoundModelMetadata (3-7)
  • constructor (14-18)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/core-decorator/src/util/PrototypeUtil.ts (1)
  • PrototypeUtil (16-291)
core/langchain-decorator/src/util/BoundModelInfoUtil.ts (1)
  • BoundModelInfoUtil (6-14)
core/langchain-decorator/src/builder/GraphMetaBuilder.ts (3)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/langchain-decorator/src/model/GraphMetadata.ts (1)
  • GraphMetadata (10-20)
core/langchain-decorator/src/util/GraphInfoUtil.ts (1)
  • GraphInfoUtil (6-21)
core/langchain-decorator/test/fixtures/modules/langchain/index.ts (1)
core/langchain-decorator/src/qualifier/ChatModelQualifier.ts (1)
  • ChatModelQualifier (6-10)
core/langchain-decorator/src/decorator/Graph.ts (4)
core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (6)
  • Graph (110-120)
  • Graph (150-175)
  • constructor (117-119)
  • constructor (166-168)
  • SingletonProto (23-24)
  • SingletonProto (177-190)
core/langchain-decorator/src/model/GraphMetadata.ts (2)
  • IGraphMetadata (4-8)
  • constructor (15-19)
core/core-decorator/src/util/PrototypeUtil.ts (1)
  • PrototypeUtil (16-291)
core/langchain-decorator/src/util/GraphInfoUtil.ts (1)
  • GraphInfoUtil (6-21)
🪛 Biome (2.1.2)
core/langchain-decorator/src/decorator/GraphEdge.ts

[error] 27-28: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

core/langchain-decorator/src/decorator/GraphTool.ts

[error] 16-16: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

core/langchain-decorator/src/decorator/GraphNode.ts

[error] 18-18: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

core/langchain-decorator/src/decorator/BoundModel.ts

[error] 15-15: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

core/langchain-decorator/src/decorator/Graph.ts

[error] 13-13: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

🪛 markdownlint-cli2 (0.18.1)
core/langchain-decorator/CHANGELOG.md

873-873: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


900-900: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


911-911: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


938-938: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


963-963: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


991-991: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (24)
core/langchain-decorator/test/package.json (1)

1-3: LGTM!

The test package configuration correctly sets the module type to CommonJS, which is a standard pattern for test directories.

core/langchain-decorator/test/fixtures/modules/langchain/package.json (1)

1-6: LGTM!

The test fixture package correctly defines an Egg module for testing purposes.

core/langchain-decorator/tsconfig.json (1)

1-12: LGTM!

The TypeScript configuration is correct. Note the duplication concern raised in tsconfig.pub.json.

core/langchain-decorator/src/qualifier/ChatModelQualifier.ts (1)

1-10: LGTM!

The qualifier implementation correctly uses Symbol.for for a globally shared symbol and properly delegates to QualifierUtil.addInjectQualifier. The decorator signature matches the standard pattern for supporting both property and parameter injection.

core/langchain-decorator/src/model/GraphMetadata.ts (1)

1-20: LGTM!

The GraphMetadata model is well-structured with optional properties for flexible graph configuration. The union type for checkpoint (class or string) provides good flexibility for different use cases.

core/langchain-decorator/tsconfig.pub.json (1)

1-12: No changes needed—the separate tsconfig files are intentionally part of the monorepo design.

The tsconfig.json and tsconfig.pub.json files are separate by design, not redundant duplication. Each package uses them for distinct purposes:

  • tsconfig.json: used for development builds (npm run tsc)
  • tsconfig.pub.json: used for publishing builds (npm run tsc:pub, invoked by prepublishOnly)

This pattern is consistent across all 20+ packages in the monorepo and is coordinated through root-level lerna scripts (tsc vs tsc:pub). While they currently have identical content, the separation provides architectural flexibility—configs can diverge for publishing workflows without affecting development builds, and the distinction is semantically clear in the build pipeline.

Likely an incorrect or invalid review comment.

core/langchain-decorator/src/util/index.ts (1)

1-5: LGTM!

The barrel export pattern is clean and follows ES module conventions with .js extensions.

core/langchain-decorator/test/fixtures/modules/langchain/index.ts (1)

1-14: LGTM!

The test fixture correctly demonstrates the usage of @ChatModelQualifier with dependency injection for testing purposes.

core/langchain-decorator/src/builder/BoundModelMetaBuilder.ts (1)

1-22: LGTM!

The builder pattern is clean and consistent. The build() method correctly returns undefined when metadata is not found, matching the declared return type.

core/langchain-decorator/src/util/GraphNodeInfoUtil.ts (1)

1-14: LGTM!

The utility class provides a clean abstraction over MetadataUtil for graph node metadata management.

core/langchain-decorator/src/util/BoundModelInfoUtil.ts (1)

1-14: LGTM!

The utility class follows the same clean pattern as other metadata utilities in the package.

core/langchain-decorator/src/builder/GraphMetaBuilder.ts (1)

1-22: LGTM!

The builder pattern is consistent with other builders in the package and correctly handles the optional metadata case.

core/langchain-decorator/src/decorator/GraphTool.ts (2)

15-26: LGTM!

The decorator factory correctly applies SingletonProto, records file path, and stores graph tool metadata. The parameter name constructor at line 16 is idiomatic for TypeScript class decorators and the static analysis warning is a false positive in this context.


28-31: LGTM!

The interface cleanly defines the GraphTool contract with proper typing using LangChain's DynamicStructuredTool.

core/langchain-decorator/src/builder/GraphEdgeMetaBuilder.ts (1)

1-22: LGTM!

The builder follows a clean, consistent pattern for extracting and constructing GraphEdgeMetadata from decorated classes.

core/langchain-decorator/src/util/GraphEdgeInfoUtil.ts (1)

1-14: LGTM!

The utility provides clean getter/setter methods for graph edge metadata, following the established pattern across the codebase.

core/langchain-decorator/src/util/GraphInfoUtil.ts (1)

7-21: Verify necessity of dual storage pattern.

The class maintains metadata in both MetadataUtil (line 10) and the static graphMap (line 11), which creates redundancy and potential for inconsistency. If metadata is set via MetadataUtil directly elsewhere, graphMap won't reflect it.

Consider:

  • Is the separate graphMap necessary for performance or iteration purposes?
  • If so, document why dual storage is required.
  • If not, remove graphMap and rely solely on MetadataUtil.

For now, ensure all code paths use GraphInfoUtil.setGraphMetadata exclusively to maintain consistency.

core/langchain-decorator/src/util/GraphToolInfoUtil.ts (1)

1-14: LGTM!

The utility provides clean metadata management for graph tools, following the established pattern.

core/langchain-decorator/test/graph.test.ts (1)

1-54: LGTM!

The test suite provides solid coverage of the graph metadata system, including metadata construction, parameter validation, and prototype inheritance. The assertions are clear and comprehensive.

core/langchain-decorator/src/decorator/GraphNode.ts (1)

17-28: LGTM!

The decorator factory correctly applies SingletonProto, records file path, and stores graph node metadata. The parameter name constructor at line 18 is idiomatic for TypeScript class decorators and the static analysis warning is a false positive.

core/langchain-decorator/src/type/metadataKey.ts (1)

1-6: LGTM: clear, distinct metadata keys.

core/langchain-decorator/src/index.ts (1)

1-25: Index export surface looks coherent.

Re-exports are consistent and help DX.

core/langchain-decorator/src/decorator/BoundModel.ts (1)

11-11: BaseChatOpenAI is stable and does not require refactoring.

BaseChatOpenAI is not marked as deprecated or unstable in LangChain changelogs or API docs, and the class remains in the public API with active maintenance. The premise of the review comment is incorrect. The original import and type definition using BaseChatOpenAI do not need to be changed.

Likely an incorrect or invalid review comment.

core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (1)

144-146: The review comment conflates unrelated code locations and mischaracterizes the type safety.

The bindTools() method on ChatOpenAI has the declared signature: bindTools(tools: ChatOpenAIToolType[], kwargs?: Partial<CallOptions>) => Runnable<BaseLanguageModelInput, AIMessageChunk, CallOptions>, which is a concrete type—not any.

Lines 144-146 (BarNode.build()) and lines 164-165 (BarGraph.fooChatModel property) are in separate classes and are unrelated. BarNode.build() uses ChatOpenAI.bindTools() directly, and TypeScript will correctly infer the return type as Runnable<...> without widening to any. TeggBoundModel is used only for the fooChatModel property type in BarGraph and does not affect BarNode.build()'s type inference. The usage of bindTools([ this.fooTool ]) is correct and type-safe per the @langchain/openai API.

Likely an incorrect or invalid review comment.

Comment on lines +6 to +9
# [3.62.0](https://github.com/eggjs/tegg/compare/v3.61.0...v3.62.0) (2025-09-24)

**Note:** Version bump only for package @eggjs/tegg-orm-decorator

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Package name mismatch throughout this changelog.

Entries repeatedly say “@eggjs/tegg-orm-decorator” but this file is for langchain-decorator. Please replace across the file or regenerate via your release tooling.

Example fix:

-**Note:** Version bump only for package @eggjs/tegg-orm-decorator
+**Note:** Version bump only for package @eggjs/tegg-langchain-decorator
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# [3.62.0](https://github.com/eggjs/tegg/compare/v3.61.0...v3.62.0) (2025-09-24)
**Note:** Version bump only for package @eggjs/tegg-orm-decorator
# [3.62.0](https://github.com/eggjs/tegg/compare/v3.61.0...v3.62.0) (2025-09-24)
**Note:** Version bump only for package @eggjs/tegg-langchain-decorator
🤖 Prompt for AI Agents
In core/langchain-decorator/CHANGELOG.md around lines 6 to 9, the changelog
wrongly references “@eggjs/tegg-orm-decorator” instead of the package for this
directory; replace every occurrence of “@eggjs/tegg-orm-decorator” with
“@eggjs/langchain-decorator” (including the Note line, any release header text,
and compare link paths), or regenerate the changelog with the release tooling so
the package name, links, and metadata correctly reflect langchain-decorator.

"ts-node": "^10.9.1",
"typescript": "^5.0.4"
},
"gitHead": "5f24bacd9131435188be15568d86ef4575f85636"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove the gitHead field from package.json.

The gitHead field is automatically added by npm during publishing and should not be committed to version control. It will cause conflicts and stale values across different commits.

-  },
-  "gitHead": "5f24bacd9131435188be15568d86ef4575f85636"
+  }

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In core/langchain-decorator/package.json around line 63, remove the hardcoded
"gitHead" field from package.json; delete the "gitHead":
"5f24bacd9131435188be15568d86ef4575f85636" entry so the file no longer contains
this automatically generated value (ensure valid JSON after removal and run a
quick lint/format or npm pack to verify).

Comment on lines +1 to +7
# `@eggjs/tegg-langchain-decorator`

## Install

```shell
npm i --save @eggjs/tegg-langchain-decorator
```
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Expand the README with usage documentation and examples.

The README currently only includes installation instructions. For a new package introducing LangChain integration decorators, users need:

  • Overview of what the package does and its purpose
  • Available decorators (@Graph, @GraphNode, @GraphEdge, @GraphTool, @BoundModel, @ChatModelQualifier)
  • Basic usage examples showing how to define graphs, nodes, edges, and tools
  • Integration examples with Tegg's dependency injection
  • Links to LangChain/LangGraph documentation where relevant

Would you like me to draft a more comprehensive README structure with usage examples?

🤖 Prompt for AI Agents
In core/langchain-decorator/README.md around lines 1 to 7, the README only shows
installation and lacks usage, purpose, decorator list, examples and links;
expand it by adding a short overview of the package and its purpose, a clear
list and brief description of provided decorators (@Graph, @GraphNode,
@GraphEdge, @GraphTool, @BoundModel, @ChatModelQualifier), at least two concise
usage sections (one showing how to define a graph with nodes/edges and one
showing how to register and inject tools/models with Tegg DI), add a simple
chat/chain integration example referencing how to wire LangChain/LangGraph
components, and include links to LangChain and LangGraph docs; keep sections
titled Installation, Overview, Decorators, Examples (Graph definition, Tools &
DI, Chat integration), and References so users can quickly find examples and
external docs.

Comment on lines +15 to +24
return (constructor: EggProtoImplClass) => {
const func = SingletonProto({
accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
name: params?.name,
});
func(constructor);
PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));

BoundModelInfoUtil.setBoundModelMetadata(params, constructor);
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Rename decorator param from “constructor” to avoid shadowing and Biome error.

Apply:

-export function BoundModel(params: IBoundModelMetadata) {
-  return (constructor: EggProtoImplClass) => {
+export function BoundModel(params: IBoundModelMetadata) {
+  return (clazz: EggProtoImplClass) => {
     const func = SingletonProto({
       accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
       name: params?.name,
     });
-    func(constructor);
-    PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
+    func(clazz);
+    PrototypeUtil.setFilePath(clazz, StackUtil.getCalleeFromStack(false, 5));
 
-    BoundModelInfoUtil.setBoundModelMetadata(params, constructor);
+    BoundModelInfoUtil.setBoundModelMetadata(params, clazz);
   };
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return (constructor: EggProtoImplClass) => {
const func = SingletonProto({
accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
name: params?.name,
});
func(constructor);
PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
BoundModelInfoUtil.setBoundModelMetadata(params, constructor);
};
return (clazz: EggProtoImplClass) => {
const func = SingletonProto({
accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
name: params?.name,
});
func(clazz);
PrototypeUtil.setFilePath(clazz, StackUtil.getCalleeFromStack(false, 5));
BoundModelInfoUtil.setBoundModelMetadata(params, clazz);
};
🧰 Tools
🪛 Biome (2.1.2)

[error] 15-15: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

🤖 Prompt for AI Agents
In core/langchain-decorator/src/decorator/BoundModel.ts around lines 15 to 24,
the decorator callback parameter is named "constructor" which shadows the global
and triggers Biome errors; rename that parameter to a non-shadowing identifier
(e.g., target or TargetClass) and update all references inside the function
(calls to func(...), PrototypeUtil.setFilePath(...), and
BoundModelInfoUtil.setBoundModelMetadata(...)) to use the new name while keeping
the parameter type (EggProtoImplClass) unchanged.

Comment on lines +13 to +22
return (constructor: EggProtoImplClass<AbstractStateGraph<N, S>>) => {
const func = SingletonProto({
accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
name: params?.name,
});
func(constructor);
PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));

GraphInfoUtil.setGraphMetadata(params, constructor);
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Rename decorator param from “constructor” to avoid shadowing and Biome error.

Apply:

-export function Graph<N extends string = '', S extends StateDefinition = StateDefinition>(params: IGraphMetadata) {
-  return (constructor: EggProtoImplClass<AbstractStateGraph<N, S>>) => {
+export function Graph<N extends string = '', S extends StateDefinition = StateDefinition>(params: IGraphMetadata) {
+  return (clazz: EggProtoImplClass<AbstractStateGraph<N, S>>) => {
     const func = SingletonProto({
       accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
       name: params?.name,
     });
-    func(constructor);
-    PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
+    func(clazz);
+    PrototypeUtil.setFilePath(clazz, StackUtil.getCalleeFromStack(false, 5));
 
-    GraphInfoUtil.setGraphMetadata(params, constructor);
+    GraphInfoUtil.setGraphMetadata(params, clazz);
   };
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return (constructor: EggProtoImplClass<AbstractStateGraph<N, S>>) => {
const func = SingletonProto({
accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
name: params?.name,
});
func(constructor);
PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
GraphInfoUtil.setGraphMetadata(params, constructor);
};
return (clazz: EggProtoImplClass<AbstractStateGraph<N, S>>) => {
const func = SingletonProto({
accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
name: params?.name,
});
func(clazz);
PrototypeUtil.setFilePath(clazz, StackUtil.getCalleeFromStack(false, 5));
GraphInfoUtil.setGraphMetadata(params, clazz);
};
🧰 Tools
🪛 Biome (2.1.2)

[error] 13-13: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

🤖 Prompt for AI Agents
In core/langchain-decorator/src/decorator/Graph.ts around lines 13 to 22, the
decorator callback parameter is named "constructor" which shadows the global
constructor and triggers Biome linting errors; rename that parameter (e.g., to
"target" or "cls") and update all usages inside the function accordingly (call
SingletonProto(target), PrototypeUtil.setFilePath(target, ...),
GraphInfoUtil.setGraphMetadata(params, target)) while keeping the existing type
annotation EggProtoImplClass<AbstractStateGraph<N, S>> unchanged.

Comment on lines +25 to +27
export interface IGraph<N extends string = '', S extends StateDefinition = StateDefinition> extends StateGraph<S, AnnotationRoot<S>['State'], UpdateType<S>, N> {
build?(): Promise<CompiledStateGraph<StateType<StateDefinition>, UpdateType<StateDefinition>, string, StateDefinition, StateDefinition, StateDefinition> | undefined>;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix build() return type to preserve generics S and N.

Current signature erases generics and appears to use an older arity.

Apply:

-export interface IGraph<N extends string = '', S extends StateDefinition = StateDefinition> extends StateGraph<S, AnnotationRoot<S>['State'], UpdateType[S], N> {
-  build?(): Promise<CompiledStateGraph<StateType<StateDefinition>, UpdateType<StateDefinition>, string, StateDefinition, StateDefinition, StateDefinition> | undefined>;
-}
+export interface IGraph<N extends string = '', S extends StateDefinition = StateDefinition>
+  extends StateGraph<S, AnnotationRoot<S>['State'], UpdateType<S>, N> {
+  build?(): Promise<CompiledStateGraph<StateType<S>, UpdateType<S>, N, S, S> | undefined>;
+}

Alternative: return Promise<TeggCompiledStateGraph | undefined> for stronger typing.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In core/langchain-decorator/src/decorator/Graph.ts around lines 25 to 27, the
build() return type currently erases the Graph generics (uses concrete
StateDefinition and string for N); update the signature to preserve S and N so
callers keep proper types — either change it to return
Promise<CompiledStateGraph<StateType<S>, UpdateType<S>, N, S, S, S> | undefined>
(preserving N and S) or use the stronger alias
Promise<TeggCompiledStateGraph<this> | undefined>; update imports/types if
needed and ensure the generic parameters match the file's existing type
utilities.

Comment on lines +26 to +35
return (constructor: EggProtoImplClass<IGraphEdge<S, N>>) => {
const func = SingletonProto({
accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
name: params?.name,
});
func(constructor);
PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));

GraphEdgeInfoUtil.setGraphEdgeMetadata(params, constructor);
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Rename decorator param from “constructor” to avoid shadowing and Biome error.

Prevents confusion with Function.prototype.constructor and fixes lint error.

Apply:

-export function GraphEdge<S extends StateDefinition = StateDefinition, N extends string = '__start__' | '__end__'>(params: IGraphEdgeMetadata) {
-  return (constructor: EggProtoImplClass<IGraphEdge<S, N>>) => {
+export function GraphEdge<S extends StateDefinition = StateDefinition, N extends string = '__start__' | '__end__'>(params: IGraphEdgeMetadata) {
+  return (clazz: EggProtoImplClass<IGraphEdge<S, N>>) => {
     const func = SingletonProto({
       accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
       name: params?.name,
     });
-    func(constructor);
-    PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
+    func(clazz);
+    PrototypeUtil.setFilePath(clazz, StackUtil.getCalleeFromStack(false, 5));
 
-    GraphEdgeInfoUtil.setGraphEdgeMetadata(params, constructor);
+    GraphEdgeInfoUtil.setGraphEdgeMetadata(params, clazz);
   };
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return (constructor: EggProtoImplClass<IGraphEdge<S, N>>) => {
const func = SingletonProto({
accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
name: params?.name,
});
func(constructor);
PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
GraphEdgeInfoUtil.setGraphEdgeMetadata(params, constructor);
};
return (clazz: EggProtoImplClass<IGraphEdge<S, N>>) => {
const func = SingletonProto({
accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
name: params?.name,
});
func(clazz);
PrototypeUtil.setFilePath(clazz, StackUtil.getCalleeFromStack(false, 5));
GraphEdgeInfoUtil.setGraphEdgeMetadata(params, clazz);
};
🧰 Tools
🪛 Biome (2.1.2)

[error] 27-28: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

🤖 Prompt for AI Agents
In core/langchain-decorator/src/decorator/GraphEdge.ts around lines 26 to 35,
the decorator parameter is named "constructor" which shadows
Function.prototype.constructor and triggers a lint/Biome error; rename the
parameter to something like "target" or "cls" and update all references inside
the function (calls to func(...), PrototypeUtil.setFilePath(...), and
GraphEdgeInfoUtil.setGraphEdgeMetadata(...)) to use the new name, keeping types
unchanged (EggProtoImplClass<IGraphEdge<S, N>>).

Comment on lines +38 to +44
export class TeggToolNode implements IGraphNode {
toolNode: ToolNode;

async execute() {
return this.toolNode;
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify execute() signature in TeggToolNode.

The execute() method at line 41 doesn't accept a state parameter, but the IGraphNode interface requires execute(state: AnnotationRoot<S>['State']). This creates a signature mismatch.

TypeScript should catch this, but if it doesn't (perhaps due to the loose interface implementation), this could cause runtime issues when nodes are invoked with state.

Please verify:

  • Is the missing state parameter intentional?
  • Should TeggToolNode accept and ignore the state parameter?
  • Or should the interface have different variants for tool nodes vs regular nodes?

If the state parameter should be ignored, apply this diff:

 export class TeggToolNode implements IGraphNode {
   toolNode: ToolNode;
 
-  async execute() {
+  async execute(_state?: any) {
     return this.toolNode;
   }
 }

I'll verify the interface definition and implementation details to confirm the signature mismatch claim.


---

🏁 Script executed:

```shell
#!/bin/bash
# Find IGraphNode interface definition
rg -n "interface IGraphNode" --type=ts -A 10

Length of output: 2076


🏁 Script executed:

#!/bin/bash
# Find TeggToolNode class implementation
rg -n "class TeggToolNode" --type=ts -A 10

Length of output: 509


🏁 Script executed:

#!/bin/bash
# Find ToolNode type/class definition
rg -n "class ToolNode|type ToolNode|interface ToolNode" --type=ts -A 8

Length of output: 852


🏁 Script executed:

#!/bin/bash
# Check GraphNode.ts file structure
fd "GraphNode.ts" --type=f | head -1 | xargs cat

Length of output: 1685


The signature mismatch is confirmed and valid—add the missing state parameter.

The IGraphNode interface requires execute(state: AnnotationRoot<S>['State']), but TeggToolNode's execute() method (line 41) omits this parameter entirely. This violates the interface contract. While the return type (Promise<ToolNode>) is correct, the missing state parameter breaks type safety.

Apply the suggested fix to accept (and ignore) the state parameter:

 export class TeggToolNode implements IGraphNode {
   toolNode: ToolNode;
 
-  async execute() {
+  async execute(_state?: any) {
     return this.toolNode;
   }
 }
🤖 Prompt for AI Agents
In core/langchain-decorator/src/decorator/GraphNode.ts around lines 38 to 44,
the TeggToolNode.execute method is missing the required state parameter from
IGraphNode; update the signature to accept the state argument as execute(state:
AnnotationRoot<S>['State']) (or execute(_state: AnnotationRoot<S>['State']) to
avoid unused-var linting) and leave the implementation unchanged so it still
returns the ToolNode promise — ensure the type AnnotationRoot and generic S are
available in scope or imported if needed.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

♻️ Duplicate comments (11)
core/langchain-decorator/README.md (1)

1-7: Expand README with overview, API, and examples.

Add purpose, decorator list, quick-start graph/node/tool examples, DI integration, and links to LangChain/LangGraph docs. Happy to draft.

Apply (append sections):

+# Overview
+Short description of what the package does and when to use it.
+
+# Decorators
+- @Graph: ...
+- @GraphNode: ...
+- @GraphEdge: ...
+- @GraphTool: ...
+- @BoundModel: ...
+- @ChatModelQualifier: ...
+
+# Examples
+## Graph definition
+// minimal graph + node/edge example
+
+## Tools & DI
+// binding a tool/model and injecting via Tegg
+
+## Chat integration
+// invoking a compiled graph
+
+# References
+- LangChain docs
+- LangGraph docs
core/langchain-decorator/src/model/GraphToolMetadata.ts (1)

6-6: Remove commented-out property.

Delete the stale comment to keep the model clean.

-  // schema: Parameters<McpServer['tool']>['2'];
core/langchain-decorator/src/util/GraphInfoUtil.ts (1)

6-20: Avoid leaking mutable global state; add reset and return ReadonlyMap.

Global cache can flake tests and enable unintended mutation. Provide a reset for tests and expose a readonly view.

 export class GraphInfoUtil {
   static graphMap = new Map<EggProtoImplClass, IGraphMetadata>();
 
   static setGraphMetadata(metadata: IGraphMetadata, clazz: EggProtoImplClass) {
     MetadataUtil.defineMetaData(GRAPH_GRAPH_METADATA, metadata, clazz);
     GraphInfoUtil.graphMap.set(clazz, metadata);
   }
 
   static getGraphMetadata(clazz: EggProtoImplClass): IGraphMetadata | undefined {
     return MetadataUtil.getMetaData(GRAPH_GRAPH_METADATA, clazz);
   }
 
-  static getAllGraphMetadata(): Map<EggProtoImplClass, IGraphMetadata> {
-    return GraphInfoUtil.graphMap;
-  }
+  static getAllGraphMetadata(): ReadonlyMap<EggProtoImplClass, IGraphMetadata> {
+    return GraphInfoUtil.graphMap;
+  }
+
+  /** For tests/framework reset */
+  static reset() {
+    GraphInfoUtil.graphMap.clear();
+  }
 }
core/langchain-decorator/src/decorator/GraphNode.ts (2)

1-1: Remove commented-out import.

-// import type { EggProtoImplClass } from '@alipay/tegg-types';

38-44: Implement interface contract: add state parameter and initialize field.

execute must accept state; also ensure toolNode is initialized or marked definite.

-export class TeggToolNode implements IGraphNode {
-  toolNode: ToolNode;
-
-  async execute() {
+export class TeggToolNode implements IGraphNode {
+  toolNode!: ToolNode;
+
+  async execute(_state?: AnnotationRoot<StateDefinition>['State']) {
     return this.toolNode;
   }
 }
core/langchain-decorator/src/decorator/Graph.ts (2)

12-22: Rename callback param to avoid Biome “constructor” shadow.

-export function Graph<N extends string = '', S extends StateDefinition = StateDefinition>(params: IGraphMetadata) {
-  return (constructor: EggProtoImplClass<AbstractStateGraph<N, S>>) => {
+export function Graph<N extends string = '', S extends StateDefinition = StateDefinition>(params: IGraphMetadata) {
+  return (clazz: EggProtoImplClass<AbstractStateGraph<N, S>>) => {
     const func = SingletonProto({
       accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
       name: params?.name,
     });
-    func(constructor);
-    PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
+    func(clazz);
+    PrototypeUtil.setFilePath(clazz, StackUtil.getCalleeFromStack(false, 5));
 
-    GraphInfoUtil.setGraphMetadata(params, constructor);
+    GraphInfoUtil.setGraphMetadata(params, clazz);
   };
 }

25-27: Apply Option A: replace build() return type with TeggCompiledStateGraph helper.

Line 26 currently erases N and S generics by using hardcoded StateDefinition. The TeggCompiledStateGraph helper at line 40 already exists in the file and correctly preserves generics. Apply the change:

 export interface IGraph<N extends string = '', S extends StateDefinition = StateDefinition> extends StateGraph<S, AnnotationRoot<S>['State'], UpdateType<S>, N> {
-  build?(): Promise<CompiledStateGraph<StateType<StateDefinition>, UpdateType<StateDefinition>, string, StateDefinition, StateDefinition, StateDefinition> | undefined>;
+  build?(): Promise<TeggCompiledStateGraph<AbstractStateGraph<N, S>> | undefined>;
 }
core/langchain-decorator/src/decorator/GraphTool.ts (2)

1-1: Remove commented-out import

Leftover comment; drop it to keep the file clean. (Same point as earlier review.)

-// import type { ToolSchemaBase, DynamicStructuredTool } from '../../core/tools.js';

13-13: Avoid deep import from '@langchain/core/dist/tools'

Deep paths are brittle. Prefer the public entry and make it type-only.

-import { DynamicStructuredTool, ToolSchemaBase } from '@langchain/core/dist/tools';
+import type { DynamicStructuredTool, ToolSchemaBase } from '@langchain/core/tools';

To verify which public path your installed version exposes, run:

#!/bin/bash
set -euo pipefail
echo "Resolve public tool entry:"
node -p "require.resolve('@langchain/core/tools')"
echo "Resolve deep path (should be avoided):"
node -p "require.resolve('@langchain/core/dist/tools')" || echo "deep path not resolvable (good)"
core/langchain-decorator/src/decorator/BoundModel.ts (1)

14-25: Rename constructor parameter to avoid shadowing.

The decorator callback parameter named constructor shadows the global property and triggers Biome linting errors. This issue was previously flagged and should be addressed by renaming to clazz or target.

core/langchain-decorator/src/decorator/GraphEdge.ts (1)

25-36: Rename constructor parameter to avoid shadowing.

The decorator callback parameter constructor shadows the global property and triggers Biome linting errors. This was flagged in previous review comments and should be renamed to clazz or target.

🧹 Nitpick comments (11)
core/langchain-decorator/CHANGELOG.md (1)

870-916: Normalize heading levels to satisfy MD001.

Headings jump levels; adjust to increment by one (e.g., use “##” for versions after the first “#”).

Also applies to: 937-971, 991-991

core/langchain-decorator/test/index.test.ts (2)

8-9: Name the test for intent

Rename to describe behavior, e.g., “should read ChatModel qualifier from property injection”.


10-11: Prefer explicit strict assertion

Use strictEqual for clarity.

-    assert.equal(chatModelQualifier, 'chat');
+    assert.strictEqual(chatModelQualifier, 'chat');
core/langchain-decorator/test/fixtures/modules/langchain/index.ts (1)

1-1: Avoid runtime dependency in tests

Only the type is needed. Use a type-only import to prevent requiring @langchain/openai at runtime.

-import { ChatOpenAI } from '@langchain/openai';
+import type { ChatOpenAI } from '@langchain/openai';
core/langchain-decorator/src/decorator/GraphTool.ts (1)

15-26: Rename parameter to avoid shadowing “constructor”

Prevents confusion and satisfies the linter. Update references accordingly.

-export function GraphTool<ToolSchema = ToolSchemaBase>(params: IGraphToolMetadata) {
-  return (constructor: EggProtoImplClass<IGraphTool<ToolSchema>>) => {
+export function GraphTool<ToolSchema = ToolSchemaBase>(params: IGraphToolMetadata) {
+  return (Ctor: EggProtoImplClass<IGraphTool<ToolSchema>>) => {
     const func = SingletonProto({
       accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
       name: params?.name,
     });
-    func(constructor);
-    PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
+    func(Ctor);
+    PrototypeUtil.setFilePath(Ctor, StackUtil.getCalleeFromStack(false, 5));
 
-    GraphToolInfoUtil.setGraphToolMetadata(params, constructor);
+    GraphToolInfoUtil.setGraphToolMetadata(params, Ctor);
   };
 }
core/langchain-decorator/test/graph.test.ts (3)

35-37: Use assert.ok for boolean predicate

Improves readability for boolean checks.

-    assert.deepEqual(meta instanceof GraphToolMetadata, true);
+    assert.ok(meta instanceof GraphToolMetadata);

47-49: Use assert.ok for boolean predicate

Same here.

-    assert.deepEqual(meta instanceof GraphMetadata, true);
+    assert.ok(meta instanceof GraphMetadata);

51-53: Use assert.ok for prototype check

Cleaner than comparing to true.

-    assert.equal(TeggToolNode.prototype.isPrototypeOf(ToolNode.prototype), true);
+    assert.ok(TeggToolNode.prototype.isPrototypeOf(ToolNode.prototype));
core/langchain-decorator/src/decorator/BoundModel.ts (2)

27-28: Simplify the BaseChatModel type alias.

The conditional type extends infer C ? C : never is redundant. InstanceType<typeof BaseChatOpenAI<T>> already resolves to a concrete type without needing the conditional.

Apply this diff to simplify:

-type BaseChatModel<T extends ChatOpenAICallOptions = ChatOpenAICallOptions> = InstanceType<typeof BaseChatOpenAI<T>> extends infer C
-  ? C : never;
+type BaseChatModel<T extends ChatOpenAICallOptions = ChatOpenAICallOptions> = InstanceType<typeof BaseChatOpenAI<T>>;

30-30: Remove unnecessary NonNullable wrapper for consistency.

The bindTools method is always defined on BaseChatOpenAI and its derived types; it's not optional. In TypeScript, BaseChatOpenAI / ChatOpenAI has bindTools(tools, kwargs?) as a standard method signature. Line 35 of GraphNode.ts accesses ConfigurableModel['bindTools'] without wrapping it, showing the codebase treats bindTools as non-optional elsewhere. Remove NonNullable for consistency:

export type TeggBoundModel<S, CallOptions extends ChatOpenAICallOptions = ChatOpenAICallOptions> = S & ReturnType<BaseChatModel<CallOptions>['bindTools']>;
core/langchain-decorator/src/decorator/GraphEdge.ts (1)

13-24: Consider using English for inline documentation.

The JSDoc contains Chinese comments on lines 19-20, which may reduce accessibility for international contributors. For consistency and broader maintainability, consider translating these to English.

Example translation:

  • Line 19: // Marks the start point. If only fromNodeName and toNodeNames are specified, this creates a unidirectional edge
  • Line 20: // Marks the end point(s). Can be multiple. When multiple, execute method must be implemented
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 29a8e22 and 46fbbf2.

📒 Files selected for processing (35)
  • core/langchain-decorator/CHANGELOG.md (1 hunks)
  • core/langchain-decorator/README.md (1 hunks)
  • core/langchain-decorator/package.json (1 hunks)
  • core/langchain-decorator/src/builder/BoundModelMetaBuilder.ts (1 hunks)
  • core/langchain-decorator/src/builder/GraphEdgeMetaBuilder.ts (1 hunks)
  • core/langchain-decorator/src/builder/GraphMetaBuilder.ts (1 hunks)
  • core/langchain-decorator/src/builder/GraphNodeMetaBuilder.ts (1 hunks)
  • core/langchain-decorator/src/builder/GraphToolMetaBuilder.ts (1 hunks)
  • core/langchain-decorator/src/decorator/BoundModel.ts (1 hunks)
  • core/langchain-decorator/src/decorator/Graph.ts (1 hunks)
  • core/langchain-decorator/src/decorator/GraphEdge.ts (1 hunks)
  • core/langchain-decorator/src/decorator/GraphNode.ts (1 hunks)
  • core/langchain-decorator/src/decorator/GraphTool.ts (1 hunks)
  • core/langchain-decorator/src/index.ts (1 hunks)
  • core/langchain-decorator/src/model/BoundModelMetadata.ts (1 hunks)
  • core/langchain-decorator/src/model/GraphEdgeMetadata.ts (1 hunks)
  • core/langchain-decorator/src/model/GraphMetadata.ts (1 hunks)
  • core/langchain-decorator/src/model/GraphNodeMetadata.ts (1 hunks)
  • core/langchain-decorator/src/model/GraphToolMetadata.ts (1 hunks)
  • core/langchain-decorator/src/qualifier/ChatModelQualifier.ts (1 hunks)
  • core/langchain-decorator/src/type/metadataKey.ts (1 hunks)
  • core/langchain-decorator/src/util/BoundModelInfoUtil.ts (1 hunks)
  • core/langchain-decorator/src/util/GraphEdgeInfoUtil.ts (1 hunks)
  • core/langchain-decorator/src/util/GraphInfoUtil.ts (1 hunks)
  • core/langchain-decorator/src/util/GraphNodeInfoUtil.ts (1 hunks)
  • core/langchain-decorator/src/util/GraphToolInfoUtil.ts (1 hunks)
  • core/langchain-decorator/src/util/index.ts (1 hunks)
  • core/langchain-decorator/test/fixtures/modules/langchain/index.ts (1 hunks)
  • core/langchain-decorator/test/fixtures/modules/langchain/package.json (1 hunks)
  • core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (1 hunks)
  • core/langchain-decorator/test/graph.test.ts (1 hunks)
  • core/langchain-decorator/test/index.test.ts (1 hunks)
  • core/langchain-decorator/test/package.json (1 hunks)
  • core/langchain-decorator/tsconfig.json (1 hunks)
  • core/langchain-decorator/tsconfig.pub.json (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • core/langchain-decorator/test/fixtures/modules/langchain/package.json
  • core/langchain-decorator/test/package.json
🚧 Files skipped from review as they are similar to previous changes (16)
  • core/langchain-decorator/src/util/index.ts
  • core/langchain-decorator/src/util/GraphEdgeInfoUtil.ts
  • core/langchain-decorator/src/builder/GraphToolMetaBuilder.ts
  • core/langchain-decorator/src/builder/GraphMetaBuilder.ts
  • core/langchain-decorator/src/type/metadataKey.ts
  • core/langchain-decorator/src/builder/GraphNodeMetaBuilder.ts
  • core/langchain-decorator/src/qualifier/ChatModelQualifier.ts
  • core/langchain-decorator/src/util/BoundModelInfoUtil.ts
  • core/langchain-decorator/tsconfig.pub.json
  • core/langchain-decorator/package.json
  • core/langchain-decorator/src/model/BoundModelMetadata.ts
  • core/langchain-decorator/src/model/GraphNodeMetadata.ts
  • core/langchain-decorator/src/model/GraphEdgeMetadata.ts
  • core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts
  • core/langchain-decorator/src/builder/GraphEdgeMetaBuilder.ts
  • core/langchain-decorator/src/util/GraphToolInfoUtil.ts
🧰 Additional context used
🧬 Code graph analysis (12)
core/langchain-decorator/test/graph.test.ts (10)
core/langchain-decorator/src/builder/GraphMetaBuilder.ts (1)
  • GraphMetaBuilder (5-22)
core/langchain-decorator/src/builder/GraphEdgeMetaBuilder.ts (1)
  • GraphEdgeMetaBuilder (5-22)
core/langchain-decorator/src/builder/GraphNodeMetaBuilder.ts (1)
  • GraphNodeMetaBuilder (5-22)
core/langchain-decorator/src/builder/BoundModelMetaBuilder.ts (1)
  • BoundModelMetaBuilder (5-22)
core/langchain-decorator/src/builder/GraphToolMetaBuilder.ts (1)
  • GraphToolMetaBuilder (5-22)
core/langchain-decorator/src/model/GraphToolMetadata.ts (1)
  • GraphToolMetadata (9-16)
core/controller-decorator/src/util/MCPInfoUtil.ts (1)
  • MCPInfoUtil (42-166)
core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (1)
  • ToolType (38-42)
core/langchain-decorator/src/model/GraphMetadata.ts (1)
  • GraphMetadata (10-20)
core/langchain-decorator/src/decorator/GraphNode.ts (1)
  • TeggToolNode (38-44)
core/langchain-decorator/src/builder/BoundModelMetaBuilder.ts (3)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/langchain-decorator/src/model/BoundModelMetadata.ts (1)
  • BoundModelMetadata (9-19)
core/langchain-decorator/src/util/BoundModelInfoUtil.ts (1)
  • BoundModelInfoUtil (6-14)
core/langchain-decorator/src/util/GraphInfoUtil.ts (4)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/langchain-decorator/src/model/GraphMetadata.ts (1)
  • IGraphMetadata (4-8)
core/core-decorator/src/util/MetadataUtil.ts (1)
  • MetadataUtil (5-97)
core/langchain-decorator/src/type/metadataKey.ts (1)
  • GRAPH_GRAPH_METADATA (4-4)
core/langchain-decorator/test/index.test.ts (2)
core/core-decorator/src/util/QualifierUtil.ts (1)
  • QualifierUtil (6-100)
core/langchain-decorator/src/qualifier/ChatModelQualifier.ts (1)
  • ChatModelQualifierAttribute (3-3)
core/langchain-decorator/test/fixtures/modules/langchain/index.ts (2)
core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (2)
  • SingletonProto (23-24)
  • SingletonProto (177-190)
core/langchain-decorator/src/qualifier/ChatModelQualifier.ts (1)
  • ChatModelQualifier (6-10)
core/langchain-decorator/src/model/GraphMetadata.ts (1)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/langchain-decorator/src/decorator/GraphEdge.ts (5)
core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (5)
  • GraphEdge (92-107)
  • constructor (117-119)
  • constructor (166-168)
  • SingletonProto (23-24)
  • SingletonProto (177-190)
core/langchain-decorator/src/model/GraphEdgeMetadata.ts (2)
  • IGraphEdgeMetadata (3-6)
  • constructor (12-15)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/core-decorator/src/util/PrototypeUtil.ts (1)
  • PrototypeUtil (16-291)
core/langchain-decorator/src/util/GraphEdgeInfoUtil.ts (1)
  • GraphEdgeInfoUtil (6-14)
core/langchain-decorator/src/decorator/Graph.ts (4)
core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (6)
  • Graph (110-120)
  • Graph (150-175)
  • constructor (117-119)
  • constructor (166-168)
  • SingletonProto (23-24)
  • SingletonProto (177-190)
core/langchain-decorator/src/model/GraphMetadata.ts (2)
  • IGraphMetadata (4-8)
  • constructor (15-19)
core/core-decorator/src/util/PrototypeUtil.ts (1)
  • PrototypeUtil (16-291)
core/langchain-decorator/src/util/GraphInfoUtil.ts (1)
  • GraphInfoUtil (6-21)
core/langchain-decorator/src/util/GraphNodeInfoUtil.ts (4)
core/langchain-decorator/src/model/GraphNodeMetadata.ts (1)
  • IGraphNodeMetadata (3-7)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/core-decorator/src/util/MetadataUtil.ts (1)
  • MetadataUtil (5-97)
core/langchain-decorator/src/type/metadataKey.ts (1)
  • GRAPH_NODE_METADATA (3-3)
core/langchain-decorator/src/decorator/BoundModel.ts (4)
core/langchain-decorator/src/model/BoundModelMetadata.ts (2)
  • IBoundModelMetadata (3-7)
  • constructor (14-18)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/core-decorator/src/util/PrototypeUtil.ts (1)
  • PrototypeUtil (16-291)
core/langchain-decorator/src/util/BoundModelInfoUtil.ts (1)
  • BoundModelInfoUtil (6-14)
core/langchain-decorator/src/decorator/GraphNode.ts (4)
core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (7)
  • GraphNode (63-68)
  • GraphNode (71-90)
  • GraphNode (123-147)
  • constructor (117-119)
  • constructor (166-168)
  • SingletonProto (23-24)
  • SingletonProto (177-190)
core/langchain-decorator/src/model/GraphNodeMetadata.ts (2)
  • IGraphNodeMetadata (3-7)
  • constructor (14-18)
core/core-decorator/src/util/PrototypeUtil.ts (1)
  • PrototypeUtil (16-291)
core/langchain-decorator/src/util/GraphNodeInfoUtil.ts (1)
  • GraphNodeInfoUtil (6-14)
core/langchain-decorator/src/decorator/GraphTool.ts (3)
core/langchain-decorator/src/model/GraphToolMetadata.ts (2)
  • IGraphToolMetadata (3-7)
  • constructor (13-15)
core/core-decorator/src/util/PrototypeUtil.ts (1)
  • PrototypeUtil (16-291)
core/langchain-decorator/src/util/GraphToolInfoUtil.ts (1)
  • GraphToolInfoUtil (6-14)
🪛 Biome (2.1.2)
core/langchain-decorator/src/decorator/GraphEdge.ts

[error] 27-28: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

core/langchain-decorator/src/decorator/Graph.ts

[error] 13-13: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

core/langchain-decorator/src/decorator/BoundModel.ts

[error] 15-15: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

core/langchain-decorator/src/decorator/GraphNode.ts

[error] 18-18: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

core/langchain-decorator/src/decorator/GraphTool.ts

[error] 16-16: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

🪛 markdownlint-cli2 (0.18.1)
core/langchain-decorator/CHANGELOG.md

873-873: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


900-900: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


911-911: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


938-938: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


963-963: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


991-991: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Socket Security: Pull Request Alerts
  • GitHub Check: Runner-ubuntu (18)
  • GitHub Check: Runner-ubuntu (20)
  • GitHub Check: Runner-ubuntu (16)
  • GitHub Check: Runner-macos (16)
  • GitHub Check: Runner-macos (20)
  • GitHub Check: Runner-macos (18)
🔇 Additional comments (7)
core/langchain-decorator/tsconfig.json (1)

1-12: Configuration is consistent with all sibling packages—no action required.

The tsconfig.json follows the established pattern used across all core packages in the monorepo (verified against 5 sibling packages). The configuration properly extends the root tsconfig and uses consistent compiler options and exclusions.

core/langchain-decorator/src/model/GraphMetadata.ts (1)

4-19: LGTM.

Types align with usage; optional fields make sense.

core/langchain-decorator/src/decorator/Graph.ts (1)

12-22: Clarify the specific Biome shadowing issue being checked.

The executed script confirms the code matches the provided snippet (line 13 shows return (constructor: ...)). However, the review comment lacks an explicit problem statement. The parameter constructor in the arrow function doesn't shadow any outer scope variable, and const func is a standard local variable.

Please clarify which Biome rule or specific shadowing concern should be verified, or confirm if this review comment can be dismissed.

core/langchain-decorator/src/util/GraphNodeInfoUtil.ts (1)

6-13: Verify whether graph node metadata should inherit from parent classes or remain class-specific.

The codebase pattern shows class-level metadata (e.g., ControllerMetadata, DaoInfoUtil) uses getOwnMetaData() to retrieve only the class's own metadata. GraphNodeInfoUtil currently uses getMetaData(), which traverses the prototype chain and inherits from parent classes. Confirm whether this inheritance behavior is intentional or if it should use getOwnMetaData() to be consistent with similar class-level metadata patterns.

core/langchain-decorator/src/builder/BoundModelMetaBuilder.ts (1)

5-21: Builder looks good and consistent with peers

API and behavior align with other MetaBuilders.

core/langchain-decorator/src/decorator/GraphEdge.ts (1)

38-44: LGTM!

The type aliases and interface definition properly integrate LangGraph's state types with Tegg's decorator pattern. The optional execute method appropriately supports conditional edge routing.

core/langchain-decorator/src/index.ts (1)

1-25: LGTM!

The barrel export structure is clean and well-organized. Exports are logically grouped by category (builders, decorators, models, utils, qualifier) with consistent naming conventions and visual separation, making the public API easy to navigate.

Comment on lines +6 to +8
# [3.62.0](https://github.com/eggjs/tegg/compare/v3.61.0...v3.62.0) (2025-09-24)

**Note:** Version bump only for package @eggjs/tegg-orm-decorator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix package name throughout the changelog.

This file is for langchain-decorator but entries say tegg-orm-decorator; bulk replace the package name and adjust compare links if needed.

Example fix:

-**Note:** Version bump only for package @eggjs/tegg-orm-decorator
+**Note:** Version bump only for package @eggjs/tegg-langchain-decorator

Also consider starting with the initial release entry for this new package (e.g., 0.1.0) summarizing Graph/Node/Edge/Tool/BoundModel/Qualifier.

Also applies to: 16-16, 24-24

Comment on lines +14 to +16
import { ConfigurableModel } from 'langchain/dist/chat_models/universal.js';
import { ToolNode } from '@langchain/langgraph/dist/prebuilt';

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Replace deep imports with public API types.

Deep paths are brittle. Prefer stable public exports.

Proposed:

-import { ConfigurableModel } from 'langchain/dist/chat_models/universal.js';
-import { ToolNode } from '@langchain/langgraph/dist/prebuilt';
+import type { Tool } from '@langchain/core/tools';
+import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
+import { ToolNode } from '@langchain/langgraph/prebuilt';
@@
-  build?: (tools: Parameters<ConfigurableModel['bindTools']>['0']) => Promise<ConfigurableModel>;
+  build?: (tools: Tool[]) => Promise<BaseChatModel>;

Please confirm the exact exports for your pinned LangChain/LangGraph versions.

Also applies to: 35-36


🌐 Web query:

What are the stable public import paths for ToolNode (LangGraph JS) and for Tool/BaseChatModel (LangChain JS) as of Oct 2025?

💡 Result:

As of Oct 19, 2025:

  • ToolNode (LangGraph JS): import from "langchain" (previously available from "@langchain/langgraph/prebuilt" but marked deprecated). [1][2]

  • Tool (LangChain JS): import from "@langchain/core/tools". [3]

  • BaseChatModel (LangChain JS): import from "@langchain/core/language_models/chat_models". [3][4]

Sources:

  1. ToolNode deprecation / import note — LangChain.js reference. [https://reference.langchain.com/javascript/classes/_langchain_langgraph.prebuilt.ToolNode.html] [1]
  2. LangGraph prebuilt / ToolNode docs and examples (shows "@langchain/langgraph/prebuilt" usage). [https://langchain-ai.github.io/langgraphjs/reference/modules/langgraph_prebuilt.html] [2]
  3. LangChain tools & examples (shows import of tool and usage). [https://docs.langchain.com/oss/javascript/langchain-tools] [3]
  4. LangChain JS how-to (example importing BaseChatModel). [https://js.langchain.com/docs/how_to/tool_runtime/] [4]

I need to check the codebase dependency versions to clarify the ToolNode import path, as the web search indicates a deprecation but version pins may affect availability.


---

🏁 Script executed:

```shell
#!/bin/bash
# Find package.json to check LangGraph/LangChain versions
fd -name "package.json" -type f | head -5 | xargs grep -l "@langchain/langgraph\|langchain" 2>/dev/null

Length of output: 230


🏁 Script executed:

#!/bin/bash
# Extract version constraints for langgraph and langchain
fd -name "package.json" -type f | head -1 | xargs cat | grep -A 2 -B 2 "@langchain/langgraph\|\"langchain"

Length of output: 230


🏁 Script executed:

#!/bin/bash
# Check the actual imports currently in GraphNode.ts and related files
rg -n "import.*ToolNode|import.*Tool\b|import.*BaseChatModel|import.*ConfigurableModel" src/ --type ts --type js

Length of output: 44


Let me fix the scripts to explore the codebase structure correctly:


---

🏁 Script executed:

```shell
#!/bin/bash
# Find package.json files
find . -name "package.json" -type f 2>/dev/null | head -5

Length of output: 206


🏁 Script executed:

#!/bin/bash
# List root directory structure
ls -la | head -20

Length of output: 1184


🏁 Script executed:

#!/bin/bash
# Find GraphNode.ts
find . -name "GraphNode.ts" -type f 2>/dev/null

Length of output: 53


🏁 Script executed:

#!/bin/bash
# Find all TypeScript files with ToolNode/Tool/BaseChatModel imports
find . -name "*.ts" -o -name "*.js" 2>/dev/null | xargs grep -l "ToolNode\|BaseChatModel" 2>/dev/null | head -10

Length of output: 222



---

🏁 Script executed:

```shell
#!/bin/bash
# View GraphNode.ts with line numbers, especially lines 14-36
cat -n ./core/langchain-decorator/src/decorator/GraphNode.ts | head -50

Length of output: 1993


🏁 Script executed:

#!/bin/bash
# View langchain-decorator package.json
cat ./core/langchain-decorator/package.json

Length of output: 1646


🏁 Script executed:

#!/bin/bash
# Check ToolNode imports in BoundModel.ts
grep -n "import.*ToolNode\|import.*Tool\|import.*BaseChatModel\|import.*ConfigurableModel" ./core/langchain-decorator/src/decorator/BoundModel.ts

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Check imports in test file
grep -n "import.*ToolNode\|import.*Tool\|import.*BaseChatModel" ./core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts | head -20

Length of output: 358


Replace deep imports with stable public API types; update ToolNode import path.

Deep paths are brittle. Stable public exports are preferred. The proposed fix correctly identifies Tool and BaseChatModel, but the ToolNode import path requires updating: as of Oct 2025, ToolNode should be imported from "langchain" (the path "@langchain/langgraph/prebuilt" is marked deprecated).

Corrected imports (lines 14–15):

-import { ConfigurableModel } from 'langchain/dist/chat_models/universal.js';
-import { ToolNode } from '@langchain/langgraph/dist/prebuilt';
+import { ToolNode } from 'langchain';
+import type { Tool } from '@langchain/core/tools';
+import type { BaseChatModel } from '@langchain/core/language_models/chat_models';

Update the type signature (line 35):

-  build?: (tools: Parameters<ConfigurableModel['bindTools']>['0']) => Promise<ConfigurableModel>;
+  build?: (tools: Tool[]) => Promise<BaseChatModel>;

Also applies to: 35–36

Comment on lines +17 to +27
export function GraphNode<S extends StateDefinition = StateDefinition>(params: IGraphNodeMetadata) {
return (constructor: EggProtoImplClass<IGraphNode<S> | TeggToolNode>) => {
const func = SingletonProto({
accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
name: params?.name,
});
func(constructor);
PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));

GraphNodeInfoUtil.setGraphNodeMetadata(params, constructor);
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Rename callback param to avoid Biome “constructor” shadow.

Use a safe name and update references.

-export function GraphNode<S extends StateDefinition = StateDefinition>(params: IGraphNodeMetadata) {
-  return (constructor: EggProtoImplClass<IGraphNode<S> | TeggToolNode>) => {
+export function GraphNode<S extends StateDefinition = StateDefinition>(params: IGraphNodeMetadata) {
+  return (clazz: EggProtoImplClass<IGraphNode<S> | TeggToolNode>) => {
     const func = SingletonProto({
       accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
       name: params?.name,
     });
-    func(constructor);
-    PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
+    func(clazz);
+    PrototypeUtil.setFilePath(clazz, StackUtil.getCalleeFromStack(false, 5));
 
-    GraphNodeInfoUtil.setGraphNodeMetadata(params, constructor);
+    GraphNodeInfoUtil.setGraphNodeMetadata(params, clazz);
   };
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function GraphNode<S extends StateDefinition = StateDefinition>(params: IGraphNodeMetadata) {
return (constructor: EggProtoImplClass<IGraphNode<S> | TeggToolNode>) => {
const func = SingletonProto({
accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
name: params?.name,
});
func(constructor);
PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
GraphNodeInfoUtil.setGraphNodeMetadata(params, constructor);
};
export function GraphNode<S extends StateDefinition = StateDefinition>(params: IGraphNodeMetadata) {
return (clazz: EggProtoImplClass<IGraphNode<S> | TeggToolNode>) => {
const func = SingletonProto({
accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
name: params?.name,
});
func(clazz);
PrototypeUtil.setFilePath(clazz, StackUtil.getCalleeFromStack(false, 5));
GraphNodeInfoUtil.setGraphNodeMetadata(params, clazz);
};
}
🧰 Tools
🪛 Biome (2.1.2)

[error] 18-18: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

🤖 Prompt for AI Agents
In core/langchain-decorator/src/decorator/GraphNode.ts around lines 17 to 27,
the callback parameter is named "constructor", which shadows the built-in Biome
"constructor" property; rename that parameter to a safe identifier (e.g.,
"target" or "klass") and update all references inside the function (calls to
func(...) and PrototypeUtil/GraphNodeInfoUtil uses) to use the new name so no
behavior changes occur.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Quick check script for lints and deep imports.

Also applies to: 38-44


🏁 Script executed:

#!/bin/bash
# Biome shadowing and deep import checks
rg -nP "return\s*\(constructor:" core/langchain-decorator/src/decorator/GraphNode.ts -n -C1 || true
rg -nP "langchain/(?:dist|core)/|@langchain/langgraph/(?:dist|prebuilt)" core/langchain-decorator/src/decorator/GraphNode.ts -n || true

Length of output: 366


I need to gather more complete information before rewriting the review comment. Let me inspect the full file structure and the lines mentioned in "Also applies to".


---

🏁 Script executed:

```shell
#!/bin/bash
# View full GraphNode.ts to understand all imports and code context
cat core/langchain-decorator/src/decorator/GraphNode.ts

Length of output: 1685


I've confirmed deep imports exist in the file. Now let me verify the proper public API alternatives.


---

🌐 Web query:

```web
langchain ConfigurableModel proper import path public API

💡 Result:

Use the exported symbol from the universal chat-model module:

import { ConfigurableModel } from "langchain/chat_models/universal". [1]

(See the LangChain JS API docs for the universal chat models / initChatModel examples.) [2]

Sources:
[1] LangChain JS API — chat_models/universal (ConfigurableModel).
[2] LangChain docs — initChatModel / configurable model examples.



---

🌐 Web query:

```web
@langchain/langgraph ToolNode proper import path public API

💡 Result:

Use the ToolNode exported from the langchain package:

import { ToolNode } from "langchain";

(Older docs/examples show the prebuilt path import { ToolNode } from "@langchain/langgraph/prebuilt", but recent/public API moved it into "langchain".) [1][2][3]

Sources:
[1] LangGraph how-to (example using @langchain/langgraph/prebuilt).
[2] langchain.js API reference (notes ToolNode moved to langchain; deprecated).
[3] LangChain docs (ToolNode usage showing import from "langchain").


Replace deep imports with public API exports at lines 14-15.

Deep imports from /dist and /prebuilt are unstable and should use the public API:

  • Line 14: Change from 'langchain/dist/chat_models/universal.js' to from 'langchain/chat_models/universal'
  • Line 15: Change from '@langchain/langgraph/dist/prebuilt' to from 'langchain'
🧰 Tools
🪛 Biome (2.1.2)

[error] 18-18: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

🤖 Prompt for AI Agents
In core/langchain-decorator/src/decorator/GraphNode.ts around lines 17 to 27,
the file uses deep imports that are unstable; update the import on line 14 from
"langchain/dist/chat_models/universal.js" to the public API
"langchain/chat_models/universal" and update the import on line 15 from
"@langchain/langgraph/dist/prebuilt" to the public "langchain" export, then run
a quick build/typecheck to ensure the updated import paths resolve and adjust
any named imports to match the public API exports.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (17)
core/langchain-decorator/CHANGELOG.md (1)

1-1002: The package name mismatch has already been flagged in previous reviews.

Multiple past reviews have identified that this changelog incorrectly references "@eggjs/tegg-orm-decorator" throughout instead of "@eggjs/tegg-langchain-decorator". Please address the existing comments.

core/langchain-decorator/src/decorator/GraphNode.ts (5)

1-1: Remove commented-out import.

This appears to be leftover development code.


14-15: Replace deep imports with stable public API paths.

Past reviews have identified that these deep /dist paths are brittle. Use public API exports instead.


17-27: Rename 'constructor' parameter to avoid shadowing the global property.

Biome flags this as shadowing the built-in "constructor" property. Past reviews have suggested renaming to 'clazz' or 'target'.


32-32: Remove commented-out code.

This dead code should be cleaned up for maintainability.


38-44: Add missing state parameter to match IGraphNode interface.

Past reviews have confirmed that TeggToolNode.execute() is missing the required state parameter from the IGraphNode interface contract.

core/langchain-decorator/src/decorator/BoundModel.ts (1)

14-25: Rename 'constructor' parameter to avoid shadowing the global property.

This has been flagged in past reviews. The parameter should be renamed to avoid the Biome linting error.

core/langchain-decorator/src/util/index.ts (1)

1-5: Remove .js extensions from export paths for consistency.

Past reviews have noted that these extensions are inconsistent with other files in the package.

core/langchain-decorator/src/model/GraphToolMetadata.ts (1)

6-6: Remove the commented-out schema property.

The commented property should be removed to keep the code clean.

core/langchain-decorator/src/util/GraphInfoUtil.ts (1)

7-20: Global state and duplicate storage concerns.

The static graphMap introduces global mutable state that persists across contexts and can cause issues in testing. Additionally, metadata is stored in both MetadataUtil (via Reflect) and graphMap, creating redundancy. Note that getGraphMetadata only retrieves from MetadataUtil, not from graphMap, which could lead to inconsistencies if metadata is set directly via MetadataUtil.

Consider whether graphMap is necessary, or implement a reset mechanism for testing.

core/langchain-decorator/src/decorator/GraphTool.ts (2)

1-1: Remove the commented-out import.

This commented import should be removed as it's a leftover that references a potentially incorrect path.


13-13: Avoid deep imports from @langchain/core.

The deep import @langchain/core/dist/tools is fragile and may break with package updates. Check if DynamicStructuredTool and ToolSchemaBase can be imported from the public API, such as @langchain/core/tools.

What is the correct public API import path for DynamicStructuredTool and ToolSchemaBase in @langchain/core?
core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (2)

6-6: Avoid deep imports from @langchain/core.

The deep imports from @langchain/core/dist/messages/base and @langchain/core/dist/messages/ai are fragile and may break with package updates. Import from the public API instead.

Apply this diff:

-import { BaseMessage } from '@langchain/core/dist/messages/base';
-import { AIMessage } from '@langchain/core/dist/messages/ai';
+import { BaseMessage, AIMessage } from '@langchain/core/messages';

Also applies to: 9-9


170-173: Consider adding setEntryPoint for graph clarity.

The build() method adds a node and conditional edges but doesn't explicitly set an entry point. For graphs with cycles or non-standard flows, calling this.setEntryPoint(FooGraphNodeName.ACTION) before adding nodes would make the graph structure more explicit.

   async build() {
+    this.setEntryPoint(FooGraphNodeName.ACTION);
     this.addNode(FooGraphNodeName.ACTION, this.barNode.execute);
     this.addConditionalEdges(FooGraphNodeName.ACTION, this.fooContinueEdge.execute);
     return this.compile({ checkpointer: this.fooSaver });
   }
core/langchain-decorator/src/decorator/GraphEdge.ts (1)

26-26: Rename parameter from "constructor" to avoid shadowing.

The parameter name constructor shadows the global Function.prototype.constructor property and triggers a lint error. Rename it to target or clazz.

Apply this diff:

-  return (constructor: EggProtoImplClass<IGraphEdge<S, N>>) => {
+  return (target: EggProtoImplClass<IGraphEdge<S, N>>) => {
     const func = SingletonProto({
       accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
       name: params?.name,
     });
-    func(constructor);
-    PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
+    func(target);
+    PrototypeUtil.setFilePath(target, StackUtil.getCalleeFromStack(false, 5));
 
-    GraphEdgeInfoUtil.setGraphEdgeMetadata(params, constructor);
+    GraphEdgeInfoUtil.setGraphEdgeMetadata(params, target);
   };
core/langchain-decorator/src/decorator/Graph.ts (2)

13-13: Rename parameter from "constructor" to avoid shadowing.

The parameter name constructor shadows the global Function.prototype.constructor property and triggers a lint error. Rename it to target or clazz.

Apply this diff:

-  return (constructor: EggProtoImplClass<AbstractStateGraph<N, S>>) => {
+  return (target: EggProtoImplClass<AbstractStateGraph<N, S>>) => {
     const func = SingletonProto({
       accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
       name: params?.name,
     });
-    func(constructor);
-    PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
+    func(target);
+    PrototypeUtil.setFilePath(target, StackUtil.getCalleeFromStack(false, 5));
 
-    GraphInfoUtil.setGraphMetadata(params, constructor);
+    GraphInfoUtil.setGraphMetadata(params, target);
   };

25-27: Fix build() return type to preserve generics S and N.

The current build() signature erases the generic parameters N and S, replacing them with concrete types string and StateDefinition. This loses type information for callers.

Apply this diff to preserve the generics:

 export interface IGraph<N extends string = '', S extends StateDefinition = StateDefinition> extends StateGraph<S, AnnotationRoot<S>['State'], UpdateType<S>, N> {
-  build?(): Promise<CompiledStateGraph<StateType<StateDefinition>, UpdateType<StateDefinition>, string, StateDefinition, StateDefinition, StateDefinition> | undefined>;
+  build?(): Promise<CompiledStateGraph<StateType<S>, UpdateType<S>, N, S, S> | undefined>;
 }
🧹 Nitpick comments (2)
core/langchain-decorator/src/model/GraphToolMetadata.ts (1)

13-15: Consider consistent constructor patterns across metadata models.

This constructor uses Object.assign(this, params) while GraphMetadata.ts uses explicit property assignment. For consistency and maintainability, consider aligning the constructor pattern across all metadata model classes.

core/langchain-decorator/src/decorator/Graph.ts (1)

31-37: Remove unused private fields with ts-ignore directives.

The private fields _names and _state are not used and require @ts-ignore comments to suppress errors. If these fields serve no purpose, they should be removed to reduce code clutter.

If they are placeholders for future use or serve a type-level purpose, please add a comment explaining their intent.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 46fbbf2 and 84604d2.

📒 Files selected for processing (35)
  • core/langchain-decorator/CHANGELOG.md (1 hunks)
  • core/langchain-decorator/README.md (1 hunks)
  • core/langchain-decorator/package.json (1 hunks)
  • core/langchain-decorator/src/builder/BoundModelMetaBuilder.ts (1 hunks)
  • core/langchain-decorator/src/builder/GraphEdgeMetaBuilder.ts (1 hunks)
  • core/langchain-decorator/src/builder/GraphMetaBuilder.ts (1 hunks)
  • core/langchain-decorator/src/builder/GraphNodeMetaBuilder.ts (1 hunks)
  • core/langchain-decorator/src/builder/GraphToolMetaBuilder.ts (1 hunks)
  • core/langchain-decorator/src/decorator/BoundModel.ts (1 hunks)
  • core/langchain-decorator/src/decorator/Graph.ts (1 hunks)
  • core/langchain-decorator/src/decorator/GraphEdge.ts (1 hunks)
  • core/langchain-decorator/src/decorator/GraphNode.ts (1 hunks)
  • core/langchain-decorator/src/decorator/GraphTool.ts (1 hunks)
  • core/langchain-decorator/src/index.ts (1 hunks)
  • core/langchain-decorator/src/model/BoundModelMetadata.ts (1 hunks)
  • core/langchain-decorator/src/model/GraphEdgeMetadata.ts (1 hunks)
  • core/langchain-decorator/src/model/GraphMetadata.ts (1 hunks)
  • core/langchain-decorator/src/model/GraphNodeMetadata.ts (1 hunks)
  • core/langchain-decorator/src/model/GraphToolMetadata.ts (1 hunks)
  • core/langchain-decorator/src/qualifier/ChatModelQualifier.ts (1 hunks)
  • core/langchain-decorator/src/type/metadataKey.ts (1 hunks)
  • core/langchain-decorator/src/util/BoundModelInfoUtil.ts (1 hunks)
  • core/langchain-decorator/src/util/GraphEdgeInfoUtil.ts (1 hunks)
  • core/langchain-decorator/src/util/GraphInfoUtil.ts (1 hunks)
  • core/langchain-decorator/src/util/GraphNodeInfoUtil.ts (1 hunks)
  • core/langchain-decorator/src/util/GraphToolInfoUtil.ts (1 hunks)
  • core/langchain-decorator/src/util/index.ts (1 hunks)
  • core/langchain-decorator/test/fixtures/modules/langchain/index.ts (1 hunks)
  • core/langchain-decorator/test/fixtures/modules/langchain/package.json (1 hunks)
  • core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (1 hunks)
  • core/langchain-decorator/test/graph.test.ts (1 hunks)
  • core/langchain-decorator/test/index.test.ts (1 hunks)
  • core/langchain-decorator/test/package.json (1 hunks)
  • core/langchain-decorator/tsconfig.json (1 hunks)
  • core/langchain-decorator/tsconfig.pub.json (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • core/langchain-decorator/test/fixtures/modules/langchain/package.json
  • core/langchain-decorator/test/package.json
🚧 Files skipped from review as they are similar to previous changes (17)
  • core/langchain-decorator/README.md
  • core/langchain-decorator/src/builder/BoundModelMetaBuilder.ts
  • core/langchain-decorator/src/util/GraphToolInfoUtil.ts
  • core/langchain-decorator/tsconfig.pub.json
  • core/langchain-decorator/tsconfig.json
  • core/langchain-decorator/src/model/BoundModelMetadata.ts
  • core/langchain-decorator/src/builder/GraphEdgeMetaBuilder.ts
  • core/langchain-decorator/src/qualifier/ChatModelQualifier.ts
  • core/langchain-decorator/src/model/GraphNodeMetadata.ts
  • core/langchain-decorator/test/graph.test.ts
  • core/langchain-decorator/package.json
  • core/langchain-decorator/test/fixtures/modules/langchain/index.ts
  • core/langchain-decorator/src/util/GraphEdgeInfoUtil.ts
  • core/langchain-decorator/src/model/GraphEdgeMetadata.ts
  • core/langchain-decorator/src/builder/GraphNodeMetaBuilder.ts
  • core/langchain-decorator/src/util/BoundModelInfoUtil.ts
  • core/langchain-decorator/src/index.ts
🧰 Additional context used
🧬 Code graph analysis (12)
core/langchain-decorator/src/util/GraphInfoUtil.ts (4)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/langchain-decorator/src/model/GraphMetadata.ts (1)
  • IGraphMetadata (4-8)
core/core-decorator/src/util/MetadataUtil.ts (1)
  • MetadataUtil (5-97)
core/langchain-decorator/src/type/metadataKey.ts (1)
  • GRAPH_GRAPH_METADATA (4-4)
core/langchain-decorator/src/util/GraphNodeInfoUtil.ts (4)
core/langchain-decorator/src/model/GraphNodeMetadata.ts (1)
  • IGraphNodeMetadata (3-7)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/core-decorator/src/util/MetadataUtil.ts (1)
  • MetadataUtil (5-97)
core/langchain-decorator/src/type/metadataKey.ts (1)
  • GRAPH_NODE_METADATA (3-3)
core/langchain-decorator/src/builder/GraphMetaBuilder.ts (3)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/langchain-decorator/src/model/GraphMetadata.ts (1)
  • GraphMetadata (10-20)
core/langchain-decorator/src/util/GraphInfoUtil.ts (1)
  • GraphInfoUtil (6-21)
core/langchain-decorator/src/builder/GraphToolMetaBuilder.ts (3)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/langchain-decorator/src/model/GraphToolMetadata.ts (1)
  • GraphToolMetadata (9-16)
core/langchain-decorator/src/util/GraphToolInfoUtil.ts (1)
  • GraphToolInfoUtil (6-14)
core/langchain-decorator/test/index.test.ts (2)
core/core-decorator/src/util/QualifierUtil.ts (1)
  • QualifierUtil (6-100)
core/langchain-decorator/src/qualifier/ChatModelQualifier.ts (1)
  • ChatModelQualifierAttribute (3-3)
core/langchain-decorator/src/model/GraphMetadata.ts (1)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (8)
core/langchain-decorator/src/decorator/GraphTool.ts (2)
  • GraphTool (15-26)
  • IGraphTool (28-31)
core/controller-decorator/src/decorator/mcp/MCPTool.ts (1)
  • ToolArgsSchema (35-52)
core/types/controller-decorator/MCPToolParams.ts (1)
  • ToolArgs (5-5)
core/langchain-decorator/src/decorator/BoundModel.ts (2)
  • BoundModel (14-25)
  • TeggBoundModel (30-30)
core/langchain-decorator/src/decorator/GraphNode.ts (3)
  • GraphNode (17-28)
  • TeggToolNode (38-44)
  • IGraphNode (30-36)
core/langchain-decorator/src/qualifier/ChatModelQualifier.ts (1)
  • ChatModelQualifier (6-10)
core/langchain-decorator/src/decorator/GraphEdge.ts (3)
  • GraphStateType (38-38)
  • GraphEdge (25-36)
  • IGraphEdge (42-44)
core/langchain-decorator/src/decorator/Graph.ts (2)
  • Graph (12-23)
  • TeggCompiledStateGraph (40-40)
core/langchain-decorator/src/decorator/BoundModel.ts (4)
core/langchain-decorator/src/model/BoundModelMetadata.ts (2)
  • IBoundModelMetadata (3-7)
  • constructor (14-18)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/core-decorator/src/util/PrototypeUtil.ts (1)
  • PrototypeUtil (16-291)
core/langchain-decorator/src/util/BoundModelInfoUtil.ts (1)
  • BoundModelInfoUtil (6-14)
core/langchain-decorator/src/decorator/Graph.ts (5)
core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (6)
  • Graph (110-120)
  • Graph (150-175)
  • constructor (117-119)
  • constructor (166-168)
  • SingletonProto (23-24)
  • SingletonProto (177-190)
core/langchain-decorator/src/model/GraphMetadata.ts (2)
  • IGraphMetadata (4-8)
  • constructor (15-19)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/core-decorator/src/util/PrototypeUtil.ts (1)
  • PrototypeUtil (16-291)
core/langchain-decorator/src/util/GraphInfoUtil.ts (1)
  • GraphInfoUtil (6-21)
core/langchain-decorator/src/decorator/GraphEdge.ts (5)
core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (5)
  • GraphEdge (92-107)
  • constructor (117-119)
  • constructor (166-168)
  • SingletonProto (23-24)
  • SingletonProto (177-190)
core/langchain-decorator/src/model/GraphEdgeMetadata.ts (2)
  • IGraphEdgeMetadata (3-6)
  • constructor (12-15)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/core-decorator/src/util/PrototypeUtil.ts (1)
  • PrototypeUtil (16-291)
core/langchain-decorator/src/util/GraphEdgeInfoUtil.ts (1)
  • GraphEdgeInfoUtil (6-14)
core/langchain-decorator/src/decorator/GraphNode.ts (5)
core/langchain-decorator/test/fixtures/modules/langgraph/Graph.ts (7)
  • GraphNode (63-68)
  • GraphNode (71-90)
  • GraphNode (123-147)
  • constructor (117-119)
  • constructor (166-168)
  • SingletonProto (23-24)
  • SingletonProto (177-190)
core/langchain-decorator/src/model/GraphNodeMetadata.ts (2)
  • IGraphNodeMetadata (3-7)
  • constructor (14-18)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/core-decorator/src/util/PrototypeUtil.ts (1)
  • PrototypeUtil (16-291)
core/langchain-decorator/src/util/GraphNodeInfoUtil.ts (1)
  • GraphNodeInfoUtil (6-14)
core/langchain-decorator/src/decorator/GraphTool.ts (4)
core/langchain-decorator/src/model/GraphToolMetadata.ts (2)
  • IGraphToolMetadata (3-7)
  • constructor (13-15)
core/types/core-decorator/model/EggPrototypeInfo.ts (1)
  • EggProtoImplClass (5-5)
core/core-decorator/src/util/PrototypeUtil.ts (1)
  • PrototypeUtil (16-291)
core/langchain-decorator/src/util/GraphToolInfoUtil.ts (1)
  • GraphToolInfoUtil (6-14)
🪛 Biome (2.1.2)
core/langchain-decorator/src/decorator/BoundModel.ts

[error] 15-15: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

core/langchain-decorator/src/decorator/Graph.ts

[error] 13-13: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

core/langchain-decorator/src/decorator/GraphEdge.ts

[error] 27-28: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

core/langchain-decorator/src/decorator/GraphNode.ts

[error] 18-18: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

core/langchain-decorator/src/decorator/GraphTool.ts

[error] 16-16: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

🪛 markdownlint-cli2 (0.18.1)
core/langchain-decorator/CHANGELOG.md

873-873: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


900-900: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


911-911: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


938-938: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


963-963: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)


991-991: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Runner-ubuntu (20)
  • GitHub Check: Runner-macos (20)
  • GitHub Check: Runner-ubuntu (18)
  • GitHub Check: Runner-ubuntu (16)
  • GitHub Check: Runner-macos (18)
  • GitHub Check: Runner-macos (16)
🔇 Additional comments (6)
core/langchain-decorator/test/index.test.ts (1)

1-15: LGTM!

The test correctly validates the ChatModelQualifier mechanism using QualifierUtil. The Node version check and dynamic imports are appropriate for this test context.

core/langchain-decorator/src/builder/GraphToolMetaBuilder.ts (1)

5-22: LGTM!

The builder follows a clean, consistent pattern for retrieving and wrapping GraphTool metadata. The implementation aligns well with the other metadata builders in this PR.

core/langchain-decorator/src/builder/GraphMetaBuilder.ts (1)

5-22: LGTM!

The builder follows the same clean pattern as the other metadata builders in this PR. The implementation is consistent and correct.

core/langchain-decorator/src/util/GraphNodeInfoUtil.ts (1)

6-14: LGTM!

The utility provides clean metadata storage and retrieval for GraphNode decorators. The implementation is consistent with the other InfoUtil classes in this package.

core/langchain-decorator/src/model/GraphMetadata.ts (1)

1-20: LGTM!

The model definition is clean and the explicit property assignment in the constructor is clear and type-safe.

core/langchain-decorator/src/type/metadataKey.ts (1)

1-6: LGTM!

The metadata keys are well-defined using Symbol.for() with unique, descriptive identifiers.

import { DynamicStructuredTool, ToolSchemaBase } from '@langchain/core/dist/tools';

export function GraphTool<ToolSchema = ToolSchemaBase>(params: IGraphToolMetadata) {
return (constructor: EggProtoImplClass<IGraphTool<ToolSchema>>) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Rename parameter from "constructor" to avoid shadowing.

The parameter name constructor shadows the global Function.prototype.constructor property and triggers a lint error. Rename it to target or clazz for clarity.

Apply this diff:

-  return (constructor: EggProtoImplClass<IGraphTool<ToolSchema>>) => {
+  return (target: EggProtoImplClass<IGraphTool<ToolSchema>>) => {
     const func = SingletonProto({
       accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
       name: params?.name,
     });
-    func(constructor);
-    PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
+    func(target);
+    PrototypeUtil.setFilePath(target, StackUtil.getCalleeFromStack(false, 5));
 
-    GraphToolInfoUtil.setGraphToolMetadata(params, constructor);
+    GraphToolInfoUtil.setGraphToolMetadata(params, target);
   };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return (constructor: EggProtoImplClass<IGraphTool<ToolSchema>>) => {
return (target: EggProtoImplClass<IGraphTool<ToolSchema>>) => {
const func = SingletonProto({
accessLevel: params?.accessLevel ?? AccessLevel.PUBLIC,
name: params?.name,
});
func(target);
PrototypeUtil.setFilePath(target, StackUtil.getCalleeFromStack(false, 5));
GraphToolInfoUtil.setGraphToolMetadata(params, target);
};
🧰 Tools
🪛 Biome (2.1.2)

[error] 16-16: Do not shadow the global "constructor" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

🤖 Prompt for AI Agents
In core/langchain-decorator/src/decorator/GraphTool.ts around line 16, the
arrow-function parameter is named "constructor" which shadows
Function.prototype.constructor and causes a lint error; rename the parameter to
a non-shadowing name such as "target" (or "clazz") and update all uses inside
the function to that new name so references remain correct and the lint error is
resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant