@langgraph-js/sdk 1.7.6 → 1.7.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/README.md +163 -163
- package/dist/LangGraphClient.js +1 -1
- package/dist/ToolManager.d.ts +1 -1
- package/dist/ToolManager.js +2 -1
- package/dist/tool/createTool.d.ts +4 -0
- package/dist/ui-store/createChatStore.js +0 -3
- package/package.json +1 -1
- package/src/LangGraphClient.ts +655 -655
- package/src/SpendTime.ts +60 -60
- package/src/ToolManager.ts +132 -131
- package/src/index.ts +5 -5
- package/src/tool/ToolUI.ts +55 -55
- package/src/tool/copilotkit-actions.ts +72 -72
- package/src/tool/createTool.ts +104 -102
- package/src/tool/index.ts +3 -3
- package/src/tool/utils.ts +158 -158
- package/src/ui-store/UnionStore.ts +29 -29
- package/src/ui-store/createChatStore.ts +295 -298
- package/src/ui-store/index.ts +2 -2
- package/src/ui-store/rafDebounce.ts +29 -29
- package/test/testResponse.json +5418 -5418
- package/tsconfig.json +112 -112
- package/.env +0 -0
- package/.turbo/turbo-build.log +0 -5
- package/dist/server/createState.d.ts +0 -13
- package/dist/server/createState.js +0 -20
- package/dist/server/feTools.d.ts +0 -16
- package/dist/server/feTools.js +0 -37
- package/dist/server/index.d.ts +0 -3
- package/dist/server/index.js +0 -3
- package/dist/server/interrupt/index.d.ts +0 -23
- package/dist/server/interrupt/index.js +0 -36
- package/dist/server/swarm/handoff.d.ts +0 -11
- package/dist/server/swarm/handoff.js +0 -84
- package/dist/server/swarm/keepState.d.ts +0 -6
- package/dist/server/swarm/keepState.js +0 -21
- package/dist/server/tools/index.d.ts +0 -1
- package/dist/server/tools/index.js +0 -1
- package/dist/server/tools/sequential-thinking.d.ts +0 -52
- package/dist/server/tools/sequential-thinking.js +0 -69
- package/dist/server/utils.d.ts +0 -3
- package/dist/server/utils.js +0 -24
package/tsconfig.json
CHANGED
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
-
|
|
5
|
-
/* Projects */
|
|
6
|
-
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
-
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
-
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
-
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
-
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
-
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
-
|
|
13
|
-
/* Language and Environment */
|
|
14
|
-
"target": "ES2019" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
15
|
-
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
-
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
|
-
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
18
|
-
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
19
|
-
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
20
|
-
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
21
|
-
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
22
|
-
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
23
|
-
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
24
|
-
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
25
|
-
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
26
|
-
|
|
27
|
-
/* Modules */
|
|
28
|
-
"module": "NodeNext" /* Specify what module code is generated. */,
|
|
29
|
-
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
30
|
-
"moduleResolution": "nodenext" /* Specify how TypeScript looks up a file from a given module specifier. */,
|
|
31
|
-
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
32
|
-
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
33
|
-
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
34
|
-
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
35
|
-
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
36
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
37
|
-
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
38
|
-
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
39
|
-
// "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
|
|
40
|
-
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
41
|
-
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
42
|
-
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
43
|
-
// "noUncheckedSideEffectImports": true, /* Check side effect imports. */
|
|
44
|
-
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
45
|
-
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
46
|
-
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
47
|
-
|
|
48
|
-
/* JavaScript Support */
|
|
49
|
-
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
50
|
-
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
51
|
-
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
52
|
-
|
|
53
|
-
/* Emit */
|
|
54
|
-
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
|
|
55
|
-
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
56
|
-
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
57
|
-
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
58
|
-
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
59
|
-
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
60
|
-
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
61
|
-
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
|
|
62
|
-
// "removeComments": true, /* Disable emitting comments. */
|
|
63
|
-
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
64
|
-
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
65
|
-
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
66
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
67
|
-
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
68
|
-
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
69
|
-
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
70
|
-
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
71
|
-
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
72
|
-
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
73
|
-
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
74
|
-
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
75
|
-
|
|
76
|
-
/* Interop Constraints */
|
|
77
|
-
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
78
|
-
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
79
|
-
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
|
|
80
|
-
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
81
|
-
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
82
|
-
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
83
|
-
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
84
|
-
|
|
85
|
-
/* Type Checking */
|
|
86
|
-
"strict": true /* Enable all strict type-checking options. */,
|
|
87
|
-
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
88
|
-
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
89
|
-
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
90
|
-
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
91
|
-
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
92
|
-
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
|
|
93
|
-
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
94
|
-
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
95
|
-
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
96
|
-
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
97
|
-
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
98
|
-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
99
|
-
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
100
|
-
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
101
|
-
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
102
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
103
|
-
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
104
|
-
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
105
|
-
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
106
|
-
|
|
107
|
-
/* Completeness */
|
|
108
|
-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
109
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
110
|
-
},
|
|
111
|
-
"include": ["src/**/*.ts"]
|
|
112
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Projects */
|
|
6
|
+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
+
|
|
13
|
+
/* Language and Environment */
|
|
14
|
+
"target": "ES2019" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
15
|
+
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
+
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
|
+
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
18
|
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
19
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
20
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
21
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
22
|
+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
23
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
24
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
25
|
+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
26
|
+
|
|
27
|
+
/* Modules */
|
|
28
|
+
"module": "NodeNext" /* Specify what module code is generated. */,
|
|
29
|
+
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
30
|
+
"moduleResolution": "nodenext" /* Specify how TypeScript looks up a file from a given module specifier. */,
|
|
31
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
32
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
33
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
34
|
+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
35
|
+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
36
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
37
|
+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
38
|
+
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
39
|
+
// "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
|
|
40
|
+
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
41
|
+
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
42
|
+
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
43
|
+
// "noUncheckedSideEffectImports": true, /* Check side effect imports. */
|
|
44
|
+
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
45
|
+
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
46
|
+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
47
|
+
|
|
48
|
+
/* JavaScript Support */
|
|
49
|
+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
50
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
51
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
52
|
+
|
|
53
|
+
/* Emit */
|
|
54
|
+
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
|
|
55
|
+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
56
|
+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
57
|
+
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
58
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
59
|
+
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
60
|
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
61
|
+
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
|
|
62
|
+
// "removeComments": true, /* Disable emitting comments. */
|
|
63
|
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
64
|
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
65
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
66
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
67
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
68
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
69
|
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
70
|
+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
71
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
72
|
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
73
|
+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
74
|
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
75
|
+
|
|
76
|
+
/* Interop Constraints */
|
|
77
|
+
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
78
|
+
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
79
|
+
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
|
|
80
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
81
|
+
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
82
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
83
|
+
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
84
|
+
|
|
85
|
+
/* Type Checking */
|
|
86
|
+
"strict": true /* Enable all strict type-checking options. */,
|
|
87
|
+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
88
|
+
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
89
|
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
90
|
+
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
91
|
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
92
|
+
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
|
|
93
|
+
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
94
|
+
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
95
|
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
96
|
+
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
97
|
+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
98
|
+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
99
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
100
|
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
101
|
+
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
102
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
103
|
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
104
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
105
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
106
|
+
|
|
107
|
+
/* Completeness */
|
|
108
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
109
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
110
|
+
},
|
|
111
|
+
"include": ["src/**/*.ts"]
|
|
112
|
+
}
|
package/.env
DELETED
|
File without changes
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AnnotationRoot, StateDefinition } from "@langchain/langgraph";
|
|
2
|
-
/**
|
|
3
|
-
* create state for langgraph
|
|
4
|
-
* @example
|
|
5
|
-
* export const GraphState = createState(createReactAgentAnnotation(), ModelState, SwarmState).build({
|
|
6
|
-
* current_plan: createDefaultAnnotation<Plan | null>(() => null),
|
|
7
|
-
* title: createDefaultAnnotation<string>(() => ""),
|
|
8
|
-
*});
|
|
9
|
-
*/
|
|
10
|
-
export declare const createState: <T extends readonly AnnotationRoot<any>[]>(...parents: T) => {
|
|
11
|
-
build: <D extends StateDefinition>(state?: D) => any;
|
|
12
|
-
};
|
|
13
|
-
export declare const createDefaultAnnotation: <T>(defaultValue: () => T) => any;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Annotation } from "@langchain/langgraph";
|
|
2
|
-
/**
|
|
3
|
-
* create state for langgraph
|
|
4
|
-
* @example
|
|
5
|
-
* export const GraphState = createState(createReactAgentAnnotation(), ModelState, SwarmState).build({
|
|
6
|
-
* current_plan: createDefaultAnnotation<Plan | null>(() => null),
|
|
7
|
-
* title: createDefaultAnnotation<string>(() => ""),
|
|
8
|
-
*});
|
|
9
|
-
*/
|
|
10
|
-
export const createState = (...parents) => {
|
|
11
|
-
return {
|
|
12
|
-
build: (state = {}) => {
|
|
13
|
-
return Annotation.Root(Object.assign({}, ...parents.map((p) => p.spec), state));
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
export const createDefaultAnnotation = (defaultValue) => Annotation({
|
|
18
|
-
reducer: (_, a) => a,
|
|
19
|
-
default: defaultValue,
|
|
20
|
-
});
|
package/dist/server/feTools.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { DynamicStructuredTool } from "@langchain/core/tools";
|
|
2
|
-
export declare const FEToolsState: any;
|
|
3
|
-
export interface FEToolParameters {
|
|
4
|
-
name: string;
|
|
5
|
-
type: string;
|
|
6
|
-
description: string;
|
|
7
|
-
required: boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface FETool {
|
|
10
|
-
name: string;
|
|
11
|
-
description: string;
|
|
12
|
-
parameters: FEToolParameters[];
|
|
13
|
-
}
|
|
14
|
-
export declare const createFETool: (tool: FETool) => FETool;
|
|
15
|
-
export declare const createFeTools: (tools: FETool[]) => DynamicStructuredTool[];
|
|
16
|
-
export declare const actionToTool: (tool: FETool) => DynamicStructuredTool;
|
package/dist/server/feTools.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { interrupt } from "@langchain/langgraph";
|
|
2
|
-
import { createDefaultAnnotation } from "./createState.js";
|
|
3
|
-
import { DynamicStructuredTool } from "@langchain/core/tools";
|
|
4
|
-
import { createState } from "./createState.js";
|
|
5
|
-
export const FEToolsState = createState().build({
|
|
6
|
-
fe_tools: createDefaultAnnotation(() => []),
|
|
7
|
-
});
|
|
8
|
-
export const createFETool = (tool) => {
|
|
9
|
-
return tool;
|
|
10
|
-
};
|
|
11
|
-
export const createFeTools = (tools) => {
|
|
12
|
-
return tools
|
|
13
|
-
.map((tool) => {
|
|
14
|
-
try {
|
|
15
|
-
return actionToTool(tool);
|
|
16
|
-
}
|
|
17
|
-
catch (e) {
|
|
18
|
-
console.error(e);
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
})
|
|
22
|
-
.filter((tool) => tool !== null);
|
|
23
|
-
};
|
|
24
|
-
export const actionToTool = (tool) => {
|
|
25
|
-
const callTool = async (args) => {
|
|
26
|
-
const data = interrupt(JSON.stringify(args));
|
|
27
|
-
return [data, null];
|
|
28
|
-
};
|
|
29
|
-
const schema = tool.parameters;
|
|
30
|
-
return new DynamicStructuredTool({
|
|
31
|
-
name: tool.name,
|
|
32
|
-
description: tool.description || "",
|
|
33
|
-
schema,
|
|
34
|
-
func: callTool,
|
|
35
|
-
responseFormat: "content_and_artifact",
|
|
36
|
-
});
|
|
37
|
-
};
|
package/dist/server/index.d.ts
DELETED
package/dist/server/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { AIMessage, HumanMessage } from "@langchain/core/messages";
|
|
2
|
-
export declare class InterruptModal {
|
|
3
|
-
private inputParams;
|
|
4
|
-
constructor(inputParams: {
|
|
5
|
-
action: "prompt" | string;
|
|
6
|
-
});
|
|
7
|
-
rawResponse?: {
|
|
8
|
-
response: string;
|
|
9
|
-
request: {
|
|
10
|
-
message: string;
|
|
11
|
-
action: "prompt" | string;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
get response(): {
|
|
15
|
-
answer?: string;
|
|
16
|
-
};
|
|
17
|
-
interrupt(message: string): this;
|
|
18
|
-
isApprove(): string | undefined;
|
|
19
|
-
isReject(): boolean;
|
|
20
|
-
toMessages(options?: {
|
|
21
|
-
AIAskMessage?: boolean;
|
|
22
|
-
}): (false | HumanMessage | AIMessage | undefined)[];
|
|
23
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { AIMessage, HumanMessage } from "@langchain/core/messages";
|
|
2
|
-
import { interrupt } from "@langchain/langgraph";
|
|
3
|
-
export class InterruptModal {
|
|
4
|
-
constructor(inputParams) {
|
|
5
|
-
this.inputParams = inputParams;
|
|
6
|
-
}
|
|
7
|
-
get response() {
|
|
8
|
-
if (!this.rawResponse)
|
|
9
|
-
throw new Error("rawResponse is undefined");
|
|
10
|
-
return JSON.parse(this.rawResponse.response);
|
|
11
|
-
}
|
|
12
|
-
interrupt(message) {
|
|
13
|
-
const inputData = Object.assign({ message }, this.inputParams);
|
|
14
|
-
const input = JSON.stringify(inputData);
|
|
15
|
-
const response = interrupt(input);
|
|
16
|
-
this.rawResponse = {
|
|
17
|
-
request: inputData,
|
|
18
|
-
response,
|
|
19
|
-
};
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
isApprove() {
|
|
23
|
-
return this.response.answer;
|
|
24
|
-
}
|
|
25
|
-
isReject() {
|
|
26
|
-
return !this.response.answer;
|
|
27
|
-
}
|
|
28
|
-
toMessages(options) {
|
|
29
|
-
if (!this.rawResponse)
|
|
30
|
-
throw new Error("rawResponse is undefined");
|
|
31
|
-
return [
|
|
32
|
-
(options === null || options === void 0 ? void 0 : options.AIAskMessage) && new AIMessage(this.rawResponse.request.message),
|
|
33
|
-
new HumanMessage(this.response.answer),
|
|
34
|
-
].filter(Boolean);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { AnnotationRoot, CompiledStateGraph } from "@langchain/langgraph";
|
|
3
|
-
declare const METADATA_KEY_HANDOFF_DESTINATION = "__handoff_destination";
|
|
4
|
-
interface CreateHandoffToolParams {
|
|
5
|
-
agentName: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
updateState?: (state: any) => Record<string, any>;
|
|
8
|
-
}
|
|
9
|
-
declare const createHandoffTool: ({ agentName, description, updateState }: CreateHandoffToolParams) => import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, {}, {}, any>;
|
|
10
|
-
declare const getHandoffDestinations: <AnnotationRootT extends AnnotationRoot<any>>(agent: CompiledStateGraph<AnnotationRootT["State"], AnnotationRootT["Update"], string, AnnotationRootT["spec"], AnnotationRootT["spec"]>, toolNodeName?: string) => string[];
|
|
11
|
-
export { createHandoffTool, getHandoffDestinations, METADATA_KEY_HANDOFF_DESTINATION };
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { ToolMessage } from "@langchain/core/messages";
|
|
3
|
-
import { tool } from "@langchain/core/tools";
|
|
4
|
-
import { Command, getCurrentTaskInput, } from "@langchain/langgraph";
|
|
5
|
-
const WHITESPACE_RE = /\s+/g;
|
|
6
|
-
const METADATA_KEY_HANDOFF_DESTINATION = "__handoff_destination";
|
|
7
|
-
function _normalizeAgentName(agentName) {
|
|
8
|
-
/**
|
|
9
|
-
* Normalize an agent name to be used inside the tool name.
|
|
10
|
-
*/
|
|
11
|
-
return agentName.trim().replace(WHITESPACE_RE, "_").toLowerCase();
|
|
12
|
-
}
|
|
13
|
-
// type guard
|
|
14
|
-
function isDynamicTool(tool) {
|
|
15
|
-
return "schema" in tool && "name" in tool && "description" in tool && "responseFormat" in tool;
|
|
16
|
-
}
|
|
17
|
-
const createHandoffTool = ({ agentName, description, updateState }) => {
|
|
18
|
-
/**
|
|
19
|
-
* Create a tool that can handoff control to the requested agent.
|
|
20
|
-
*
|
|
21
|
-
* @param agentName - The name of the agent to handoff control to, i.e.
|
|
22
|
-
* the name of the agent node in the multi-agent graph.
|
|
23
|
-
* Agent names should be simple, clear and unique, preferably in snake_case,
|
|
24
|
-
* although you are only limited to the names accepted by LangGraph
|
|
25
|
-
* nodes as well as the tool names accepted by LLM providers
|
|
26
|
-
* (the tool name will look like this: `transfer_to_<agent_name>`).
|
|
27
|
-
* @param description - Optional description for the handoff tool.
|
|
28
|
-
* @param updateState - Optional function to customize state updates during handoff.
|
|
29
|
-
*/
|
|
30
|
-
const toolName = `transfer_to_${_normalizeAgentName(agentName)}`;
|
|
31
|
-
const toolDescription = description || `Ask agent '${agentName}' for help`;
|
|
32
|
-
const handoffTool = tool(async (_, config) => {
|
|
33
|
-
/**
|
|
34
|
-
* Ask another agent for help.
|
|
35
|
-
*/
|
|
36
|
-
const toolMessage = new ToolMessage({
|
|
37
|
-
content: `Successfully transferred to ${agentName}`,
|
|
38
|
-
name: toolName,
|
|
39
|
-
tool_call_id: config.toolCall.id,
|
|
40
|
-
});
|
|
41
|
-
// inject the current agent state
|
|
42
|
-
const state = getCurrentTaskInput();
|
|
43
|
-
// Base update object containing essential state updates
|
|
44
|
-
const baseUpdate = {
|
|
45
|
-
messages: state.messages.concat(toolMessage),
|
|
46
|
-
activeAgent: agentName,
|
|
47
|
-
};
|
|
48
|
-
// Merge custom updates with base updates if updateState function is provided
|
|
49
|
-
const finalUpdate = updateState ? { ...baseUpdate, ...updateState(state) } : baseUpdate;
|
|
50
|
-
return new Command({
|
|
51
|
-
goto: agentName,
|
|
52
|
-
graph: Command.PARENT,
|
|
53
|
-
update: finalUpdate,
|
|
54
|
-
});
|
|
55
|
-
}, {
|
|
56
|
-
name: toolName,
|
|
57
|
-
schema: z.object({}),
|
|
58
|
-
description: toolDescription,
|
|
59
|
-
});
|
|
60
|
-
handoffTool.metadata = { [METADATA_KEY_HANDOFF_DESTINATION]: agentName };
|
|
61
|
-
return handoffTool;
|
|
62
|
-
};
|
|
63
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
|
-
const getHandoffDestinations = (agent, toolNodeName = "tools") => {
|
|
65
|
-
/**
|
|
66
|
-
* Get a list of destinations from agent's handoff tools.
|
|
67
|
-
*
|
|
68
|
-
* @param agent - The compiled state graph
|
|
69
|
-
* @param toolNodeName - The name of the tool node in the graph
|
|
70
|
-
*/
|
|
71
|
-
const { nodes } = agent.getGraph();
|
|
72
|
-
if (!(toolNodeName in nodes)) {
|
|
73
|
-
return [];
|
|
74
|
-
}
|
|
75
|
-
const toolNode = nodes[toolNodeName].data;
|
|
76
|
-
if (!toolNode || !("tools" in toolNode) || !toolNode.tools) {
|
|
77
|
-
return [];
|
|
78
|
-
}
|
|
79
|
-
const { tools } = toolNode;
|
|
80
|
-
return tools
|
|
81
|
-
.filter((tool) => isDynamicTool(tool) && tool.metadata !== undefined && METADATA_KEY_HANDOFF_DESTINATION in tool.metadata)
|
|
82
|
-
.map((tool) => tool.metadata[METADATA_KEY_HANDOFF_DESTINATION]);
|
|
83
|
-
};
|
|
84
|
-
export { createHandoffTool, getHandoffDestinations, METADATA_KEY_HANDOFF_DESTINATION };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { SwarmState } from "@langchain/langgraph-swarm";
|
|
2
|
-
/**
|
|
3
|
-
* 保留 langgraph-swarm 在 handoff 时丢失的 state
|
|
4
|
-
*/
|
|
5
|
-
export declare const keepAllStateInHandOff: (state: typeof SwarmState.State) => any;
|
|
6
|
-
export declare const createHandoffCommand: <T>(name: string, state: T) => any;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Command } from "@langchain/langgraph";
|
|
2
|
-
/**
|
|
3
|
-
* 保留 langgraph-swarm 在 handoff 时丢失的 state
|
|
4
|
-
*/
|
|
5
|
-
export const keepAllStateInHandOff = (state) => {
|
|
6
|
-
// omit activeAgent and messages
|
|
7
|
-
const { activeAgent, messages, ...rest } = state;
|
|
8
|
-
return {
|
|
9
|
-
...rest,
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
export const createHandoffCommand = (name, state) => {
|
|
13
|
-
return new Command({
|
|
14
|
-
goto: name,
|
|
15
|
-
graph: Command.PARENT,
|
|
16
|
-
update: {
|
|
17
|
-
active_agent: name,
|
|
18
|
-
...state,
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./sequential-thinking.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./sequential-thinking.js";
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const SequentialThinkingTool: import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
3
|
-
thought: z.ZodString;
|
|
4
|
-
nextThoughtNeeded: z.ZodBoolean;
|
|
5
|
-
thoughtNumber: z.ZodNumber;
|
|
6
|
-
totalThoughts: z.ZodNumber;
|
|
7
|
-
isRevision: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
-
revisesThought: z.ZodOptional<z.ZodNumber>;
|
|
9
|
-
branchFromThought: z.ZodOptional<z.ZodNumber>;
|
|
10
|
-
branchId: z.ZodOptional<z.ZodString>;
|
|
11
|
-
needsMoreThoughts: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
-
}, "strip", z.ZodTypeAny, {
|
|
13
|
-
thought: string;
|
|
14
|
-
nextThoughtNeeded: boolean;
|
|
15
|
-
thoughtNumber: number;
|
|
16
|
-
totalThoughts: number;
|
|
17
|
-
isRevision?: boolean | undefined;
|
|
18
|
-
revisesThought?: number | undefined;
|
|
19
|
-
branchFromThought?: number | undefined;
|
|
20
|
-
branchId?: string | undefined;
|
|
21
|
-
needsMoreThoughts?: boolean | undefined;
|
|
22
|
-
}, {
|
|
23
|
-
thought: string;
|
|
24
|
-
nextThoughtNeeded: boolean;
|
|
25
|
-
thoughtNumber: number;
|
|
26
|
-
totalThoughts: number;
|
|
27
|
-
isRevision?: boolean | undefined;
|
|
28
|
-
revisesThought?: number | undefined;
|
|
29
|
-
branchFromThought?: number | undefined;
|
|
30
|
-
branchId?: string | undefined;
|
|
31
|
-
needsMoreThoughts?: boolean | undefined;
|
|
32
|
-
}>, {
|
|
33
|
-
thought: string;
|
|
34
|
-
nextThoughtNeeded: boolean;
|
|
35
|
-
thoughtNumber: number;
|
|
36
|
-
totalThoughts: number;
|
|
37
|
-
isRevision?: boolean | undefined;
|
|
38
|
-
revisesThought?: number | undefined;
|
|
39
|
-
branchFromThought?: number | undefined;
|
|
40
|
-
branchId?: string | undefined;
|
|
41
|
-
needsMoreThoughts?: boolean | undefined;
|
|
42
|
-
}, {
|
|
43
|
-
thought: string;
|
|
44
|
-
nextThoughtNeeded: boolean;
|
|
45
|
-
thoughtNumber: number;
|
|
46
|
-
totalThoughts: number;
|
|
47
|
-
isRevision?: boolean | undefined;
|
|
48
|
-
revisesThought?: number | undefined;
|
|
49
|
-
branchFromThought?: number | undefined;
|
|
50
|
-
branchId?: string | undefined;
|
|
51
|
-
needsMoreThoughts?: boolean | undefined;
|
|
52
|
-
}, string>;
|