@crewai-ts/core 0.1.2 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/a2a.d.ts +1684 -0
  2. package/dist/a2ui-schemas.d.ts +3312 -0
  3. package/dist/a2ui.d.ts +379 -0
  4. package/dist/agent-adapters.d.ts +178 -0
  5. package/dist/agent-executors.d.ts +508 -0
  6. package/dist/agent-parser.d.ts +44 -0
  7. package/dist/agent-planning.d.ts +358 -0
  8. package/dist/agent-utils.d.ts +210 -0
  9. package/dist/agent.d.ts +444 -0
  10. package/dist/auth.d.ts +179 -0
  11. package/dist/config-utils.d.ts +5 -0
  12. package/dist/content-processor.d.ts +12 -0
  13. package/dist/context.d.ts +157 -0
  14. package/dist/converter.d.ts +97 -0
  15. package/dist/crew-chat.d.ts +97 -0
  16. package/dist/crew.d.ts +424 -0
  17. package/dist/decorators.d.ts +20 -0
  18. package/dist/env.d.ts +13 -0
  19. package/dist/errors.d.ts +27 -0
  20. package/dist/evaluators.d.ts +477 -0
  21. package/dist/events.d.ts +2657 -0
  22. package/dist/execution-utils.d.ts +85 -0
  23. package/dist/experimental-conversational.d.ts +181 -0
  24. package/dist/file-handler.d.ts +36 -0
  25. package/dist/file-store.d.ts +37 -0
  26. package/dist/files.d.ts +554 -0
  27. package/dist/flow-conversation.d.ts +90 -0
  28. package/dist/flow-definition.d.ts +195 -0
  29. package/dist/flow-persistence.d.ts +107 -0
  30. package/dist/flow-visualization.d.ts +77 -0
  31. package/dist/flow.d.ts +927 -0
  32. package/dist/formatter.d.ts +7 -0
  33. package/dist/guardrail.d.ts +95 -0
  34. package/dist/hooks.d.ts +241 -0
  35. package/dist/human-input.d.ts +74 -0
  36. package/dist/i18n.d.ts +26 -0
  37. package/dist/index.cjs +83 -36
  38. package/dist/index.d.ts +99 -13004
  39. package/dist/index.js +82 -36
  40. package/dist/input-files.d.ts +24 -0
  41. package/dist/input-provider.d.ts +22 -0
  42. package/dist/knowledge.d.ts +353 -0
  43. package/dist/lite-agent-output.d.ts +69 -0
  44. package/dist/lite-agent.d.ts +154 -0
  45. package/dist/llm.d.ts +630 -0
  46. package/dist/llms-hooks-transport.d.ts +1 -2
  47. package/dist/lock-store.d.ts +14 -0
  48. package/dist/logger.d.ts +55 -0
  49. package/dist/mcp.d.ts +315 -0
  50. package/dist/memory.d.ts +915 -0
  51. package/dist/metadata.d.ts +9 -0
  52. package/dist/misc-compat.d.ts +125 -0
  53. package/dist/openai-completion.d.ts +324 -0
  54. package/dist/outputs.d.ts +69 -0
  55. package/dist/planning.d.ts +60 -0
  56. package/dist/plus-api.d.ts +194 -0
  57. package/dist/project-compat.d.ts +133 -0
  58. package/dist/project.d.ts +221 -0
  59. package/dist/prompts.d.ts +66 -0
  60. package/dist/provider-completions.d.ts +593 -0
  61. package/dist/rag.d.ts +1074 -0
  62. package/dist/rpm.d.ts +27 -0
  63. package/dist/rw-lock.d.ts +21 -0
  64. package/dist/schema-utils.d.ts +121 -0
  65. package/dist/security.d.ts +66 -0
  66. package/dist/settings.d.ts +103 -0
  67. package/dist/skills.d.ts +145 -0
  68. package/dist/state-provider-core.d.ts +1 -1
  69. package/dist/state.d.ts +204 -0
  70. package/dist/step-execution-context.d.ts +36 -0
  71. package/dist/streaming.d.ts +153 -0
  72. package/dist/string-utils.d.ts +12 -0
  73. package/dist/task-output-storage.d.ts +62 -0
  74. package/dist/task.d.ts +305 -0
  75. package/dist/telemetry.d.ts +91 -0
  76. package/dist/token-counter-callback.d.ts +36 -0
  77. package/dist/tools.d.ts +563 -0
  78. package/dist/tracing-utils.d.ts +56 -0
  79. package/dist/training-converter.d.ts +36 -0
  80. package/dist/training-handler.d.ts +10 -0
  81. package/dist/types.d.ts +72 -0
  82. package/dist/utilities.d.ts +130 -0
  83. package/dist/utility-types.d.ts +10 -0
  84. package/dist/version.d.ts +12 -0
  85. package/package.json +326 -4904
  86. package/dist/index.d.cts +0 -13068
  87. package/dist/llms-hooks-transport-ChGiFBiU.d.ts +0 -233
  88. package/dist/llms-hooks-transport-DZlurMUQ.d.cts +0 -233
  89. package/dist/llms-hooks-transport.d.cts +0 -2
  90. package/dist/state-provider-core-Be9RKRAm.d.cts +0 -4876
  91. package/dist/state-provider-core-Be9RKRAm.d.ts +0 -4876
  92. package/dist/state-provider-core.d.cts +0 -1
package/dist/index.js CHANGED
@@ -31009,33 +31009,37 @@ var GeminiCompletion = class _GeminiCompletion extends ConfiguredLLM {
31009
31009
  delete generationConfigBody.safety_settings;
31010
31010
  const model = this.model.replace(/^(?:gemini|google)\//, "");
31011
31011
  const baseUrl = this.baseUrl ?? "https://generativelanguage.googleapis.com/v1beta";
31012
- const requestInit = {
31012
+ const buildRequestInit = (currentContents) => ({
31013
31013
  method: "POST",
31014
31014
  headers: { "Content-Type": "application/json" },
31015
31015
  body: JSON.stringify({
31016
- contents,
31016
+ contents: currentContents,
31017
31017
  ...Object.keys(generationConfigBody).length > 0 ? { generationConfig: generationConfigBody } : {},
31018
31018
  ..."system_instruction" in requestBody ? { system_instruction: requestBody.system_instruction } : {},
31019
31019
  ..."tools" in requestBody ? { tools: requestBody.tools } : {},
31020
31020
  ..."safety_settings" in requestBody ? { safety_settings: requestBody.safety_settings } : {}
31021
- })
31022
- };
31023
- if (options?.signal) {
31024
- requestInit.signal = options.signal;
31025
- }
31026
- return fetch(
31027
- `${baseUrl.replace(/\/$/, "")}/models/${encodeURIComponent(model)}:generateContent?key=${encodeURIComponent(apiKey)}`,
31028
- requestInit
31029
- ).then(async (response) => {
31021
+ }),
31022
+ ...options?.signal ? { signal: options.signal } : {}
31023
+ });
31024
+ const generateContent = async (currentContents) => {
31025
+ const response = await fetch(
31026
+ `${baseUrl.replace(/\/$/, "")}/models/${encodeURIComponent(model)}:generateContent?key=${encodeURIComponent(apiKey)}`,
31027
+ buildRequestInit(currentContents)
31028
+ );
31030
31029
  const body = await response.json();
31031
31030
  if (!response.ok) {
31032
31031
  const error = readObject2(readObject2(body).error);
31033
31032
  throw new Error(scalarToString(error.message) ?? `Gemini request failed with HTTP ${response.status.toString()}.`);
31034
31033
  }
31034
+ return body;
31035
+ };
31036
+ return generateContent(contents).then(async (body) => {
31035
31037
  return await this.processResponseWithTools(
31036
31038
  body,
31037
31039
  contents,
31038
- options?.availableFunctions ?? options?.available_functions ?? null
31040
+ options?.availableFunctions ?? options?.available_functions ?? null,
31041
+ generateContent,
31042
+ geminiMaxToolRounds(options)
31039
31043
  );
31040
31044
  });
31041
31045
  }
@@ -31335,42 +31339,69 @@ ${textContent}` : textContent;
31335
31339
  static extract_structured_output_from_response(response) {
31336
31340
  return _GeminiCompletion.extractStructuredOutputFromResponse(response);
31337
31341
  }
31338
- async processResponseWithTools(response, contents = [], availableFunctions = null) {
31339
- void contents;
31340
- const candidates = readObject2(response).candidates;
31341
- if (!Array.isArray(candidates)) {
31342
- return _GeminiCompletion.extractTextFromResponse(response);
31343
- }
31344
- const first = readObject2(candidates[0]);
31345
- const rawParts = Array.isArray(readObject2(first.content).parts) ? readObject2(first.content).parts : [];
31346
- const functionCallParts = rawParts.filter((part) => Object.keys(readObject2(readObject2(part).functionCall ?? readObject2(part).function_call)).length > 0);
31347
- const nonStructuredParts = functionCallParts.filter((part) => {
31348
- const partRecord = readObject2(part);
31349
- const functionCall = readObject2(partRecord.functionCall ?? partRecord.function_call);
31350
- return (scalarToString(functionCall.name) ?? "") !== STRUCTURED_OUTPUT_TOOL_NAME;
31351
- });
31352
- if (nonStructuredParts.length > 0 && !availableFunctions) {
31353
- return nonStructuredParts;
31354
- }
31355
- if (nonStructuredParts.length > 0 && availableFunctions) {
31342
+ async processResponseWithTools(response, contents = [], availableFunctions = null, generateContent = null, maxToolRounds = DEFAULT_GEMINI_MAX_TOOL_ROUNDS) {
31343
+ let currentResponse = response;
31344
+ let currentContents = [...contents];
31345
+ for (let round = 0; round <= maxToolRounds; round += 1) {
31346
+ const candidates = readObject2(currentResponse).candidates;
31347
+ if (!Array.isArray(candidates)) {
31348
+ return _GeminiCompletion.extractTextFromResponse(currentResponse);
31349
+ }
31350
+ const first = readObject2(candidates[0]);
31351
+ const rawParts = Array.isArray(readObject2(first.content).parts) ? readObject2(first.content).parts : [];
31352
+ const functionCallParts = rawParts.filter((part) => Object.keys(readObject2(readObject2(part).functionCall ?? readObject2(part).function_call)).length > 0);
31353
+ const structuredOutput = _GeminiCompletion.extractStructuredOutputFromResponse(currentResponse);
31354
+ const nonStructuredParts = functionCallParts.filter((part) => {
31355
+ const partRecord = readObject2(part);
31356
+ const functionCall = readObject2(partRecord.functionCall ?? partRecord.function_call);
31357
+ return (scalarToString(functionCall.name) ?? "") !== STRUCTURED_OUTPUT_TOOL_NAME;
31358
+ });
31359
+ if (nonStructuredParts.length === 0) {
31360
+ return structuredOutput ?? _GeminiCompletion.extractTextFromResponse(currentResponse);
31361
+ }
31362
+ if (!availableFunctions) {
31363
+ return nonStructuredParts;
31364
+ }
31365
+ if (round >= maxToolRounds) {
31366
+ throw new Error(`Gemini tool loop exceeded max tool rounds (${String(maxToolRounds)}).`);
31367
+ }
31368
+ const functionResponseParts = [];
31369
+ let firstToolResult = null;
31356
31370
  for (const part of nonStructuredParts) {
31357
31371
  const partRecord = readObject2(part);
31358
31372
  const functionCall = readObject2(partRecord.functionCall ?? partRecord.function_call);
31359
- const functionName = scalarToString(functionCall.name);
31373
+ const rawFunctionName = scalarToString(functionCall.name) ?? "";
31374
+ const functionName = resolveGeminiFunctionName(rawFunctionName, availableFunctions);
31360
31375
  if (!functionName) {
31361
- continue;
31376
+ throw new Error(`Gemini requested unknown function '${rawFunctionName}'.`);
31362
31377
  }
31363
31378
  const result = await this.handleToolExecution({
31364
31379
  functionName,
31365
31380
  functionArgs: readObject2(functionCall.args),
31366
31381
  availableFunctions
31367
31382
  });
31368
- if (result !== null) {
31369
- return result;
31383
+ if (result === null) {
31384
+ throw new Error(`Gemini failed to execute function '${rawFunctionName}'.`);
31370
31385
  }
31386
+ firstToolResult ??= result;
31387
+ functionResponseParts.push({
31388
+ functionResponse: {
31389
+ name: rawFunctionName,
31390
+ response: { result }
31391
+ }
31392
+ });
31371
31393
  }
31394
+ if (!generateContent) {
31395
+ return firstToolResult;
31396
+ }
31397
+ currentContents = [
31398
+ ...currentContents,
31399
+ { role: "model", parts: rawParts },
31400
+ { role: "user", parts: functionResponseParts }
31401
+ ];
31402
+ currentResponse = await generateContent(currentContents);
31372
31403
  }
31373
- return _GeminiCompletion.extractTextFromResponse(response);
31404
+ throw new Error(`Gemini tool loop exceeded max tool rounds (${String(maxToolRounds)}).`);
31374
31405
  }
31375
31406
  async _process_response_with_tools(response, contents = [], availableFunctions = null) {
31376
31407
  return await this.processResponseWithTools(response, contents, availableFunctions);
@@ -32459,6 +32490,19 @@ function geminiVersion(model) {
32459
32490
  const match = /gemini-(\d+(?:\.\d+)?)/iu.exec(model.toLowerCase());
32460
32491
  return match ? Number.parseFloat(match[1] ?? "0") : 0;
32461
32492
  }
32493
+ var DEFAULT_GEMINI_MAX_TOOL_ROUNDS = 8;
32494
+ function geminiMaxToolRounds(options) {
32495
+ const record = readObject2(options);
32496
+ const configured = record.maxToolRounds ?? record.max_tool_rounds;
32497
+ return typeof configured === "number" && Number.isInteger(configured) && configured > 0 ? configured : DEFAULT_GEMINI_MAX_TOOL_ROUNDS;
32498
+ }
32499
+ function resolveGeminiFunctionName(functionName, availableFunctions) {
32500
+ if (functionName in availableFunctions) {
32501
+ return functionName;
32502
+ }
32503
+ const sanitizedName = sanitizeToolName(functionName);
32504
+ return sanitizedName in availableFunctions ? sanitizedName : null;
32505
+ }
32462
32506
  function geminiTextParts(content) {
32463
32507
  if (Array.isArray(content)) {
32464
32508
  return content.map((item) => {
@@ -35736,9 +35780,11 @@ ${todo.description}`);
35736
35780
  if (this.tools.length === 0) {
35737
35781
  return Object.keys(options).length > 0 ? options : void 0;
35738
35782
  }
35739
- const [tools] = setupNativeTools(this.tools);
35783
+ const [tools, availableFunctions] = setupNativeTools(this.tools);
35740
35784
  if (tools.length > 0) {
35741
35785
  options.tools = tools;
35786
+ options.availableFunctions = availableFunctions;
35787
+ options.available_functions = availableFunctions;
35742
35788
  }
35743
35789
  return Object.keys(options).length > 0 ? options : void 0;
35744
35790
  }
@@ -0,0 +1,24 @@
1
+ import type { Tool } from "./types.js";
2
+ export type InputFileLike = {
3
+ read(): Uint8Array | Buffer | string;
4
+ content_type?: string | null;
5
+ contentType?: string | null;
6
+ filename?: string | null;
7
+ };
8
+ export type StructuredInputFile = {
9
+ path?: string;
10
+ content?: string;
11
+ filename?: string;
12
+ contentType?: string;
13
+ };
14
+ export type InputFile = string | InputFileLike | StructuredInputFile;
15
+ export type InputFiles = Record<string, InputFile>;
16
+ export type ExtractedInputFiles = {
17
+ inputs: Record<string, unknown>;
18
+ inputFiles: InputFiles;
19
+ };
20
+ export declare function renderInputFiles(inputFiles: InputFiles): string | null;
21
+ export declare function createReadFileTool(inputFiles: InputFiles): Tool;
22
+ export declare function withReadFileTool(tools: readonly Tool[], inputFiles: InputFiles | undefined): readonly Tool[];
23
+ export declare function extractInputFilesFromInputs(inputs: Record<string, unknown>): ExtractedInputFiles;
24
+ export declare function isStructuredInputFile(value: unknown): value is Exclude<InputFile, string>;
@@ -0,0 +1,22 @@
1
+ import type { Flow, HumanFeedbackProvider } from "./flow.js";
2
+ import type { MaybePromise } from "./types.js";
3
+ export type InputResponse = {
4
+ text: string | null;
5
+ metadata?: Record<string, unknown> | null;
6
+ };
7
+ export type InputProvider = {
8
+ requestInput?(message: string, flow: Flow<object>, metadata?: Record<string, unknown> | null): MaybePromise<string | InputResponse | null>;
9
+ request_input?(message: string, flow: Flow<object>, metadata?: Record<string, unknown> | null): MaybePromise<string | InputResponse | null>;
10
+ };
11
+ export type FlowConfig = {
12
+ inputProvider: InputProvider | null;
13
+ hitlProvider: HumanFeedbackProvider | null;
14
+ };
15
+ export declare const FlowConfig: Readonly<{
16
+ kind: "FlowConfig";
17
+ }>;
18
+ export declare const flowConfig: FlowConfig;
19
+ export declare class ConsoleInputProvider implements InputProvider {
20
+ requestInput(message: string): Promise<string>;
21
+ }
22
+ export declare function isInputResponse(value: unknown): value is InputResponse;
@@ -0,0 +1,353 @@
1
+ import { type EmbedderConfig, type RagClient, type SearchResult } from "./rag.js";
2
+ export type KnowledgeSearchResult = {
3
+ content: string;
4
+ score: number;
5
+ source: string | null;
6
+ metadata: Record<string, unknown>;
7
+ };
8
+ export type KnowledgeQueryOptions = {
9
+ resultsLimit?: number;
10
+ results_limit?: number;
11
+ scoreThreshold?: number | null;
12
+ score_threshold?: number | null;
13
+ };
14
+ export declare const DEFAULT_KNOWLEDGE_SCORE_THRESHOLD = 0.6;
15
+ export type KnowledgeSource = {
16
+ readonly sourceType?: string;
17
+ readonly metadata?: Record<string, unknown>;
18
+ storage?: BaseKnowledgeStorage | null;
19
+ chunks(): readonly string[];
20
+ add?(): void;
21
+ aadd?(): Promise<void>;
22
+ get_embeddings?(): readonly unknown[];
23
+ validate_content?(): unknown;
24
+ };
25
+ export type StringKnowledgeSourceOptions = {
26
+ content: string;
27
+ chunkSize?: number;
28
+ chunkOverlap?: number;
29
+ metadata?: Record<string, unknown>;
30
+ storage?: BaseKnowledgeStorage | null;
31
+ collectionName?: string | null;
32
+ collection_name?: string | null;
33
+ };
34
+ export type FileKnowledgeSourceOptions = {
35
+ filePaths?: string | readonly string[];
36
+ file_path?: string | readonly string[];
37
+ file_paths?: string | readonly string[];
38
+ chunkSize?: number;
39
+ chunkOverlap?: number;
40
+ metadata?: Record<string, unknown>;
41
+ storage?: BaseKnowledgeStorage | null;
42
+ collectionName?: string | null;
43
+ collection_name?: string | null;
44
+ };
45
+ export type BaseKnowledgeSourceOptions = {
46
+ chunkSize?: number;
47
+ chunk_size?: number;
48
+ chunkOverlap?: number;
49
+ chunk_overlap?: number;
50
+ chunks?: readonly string[];
51
+ chunkEmbeddings?: readonly unknown[];
52
+ chunk_embeddings?: readonly unknown[];
53
+ metadata?: Record<string, unknown>;
54
+ storage?: BaseKnowledgeStorage | null;
55
+ collectionName?: string | null;
56
+ collection_name?: string | null;
57
+ };
58
+ export type PDFTextExtractor = (filePath: string, bytes: Buffer) => string;
59
+ export type PDFKnowledgeSourceOptions = FileKnowledgeSourceOptions & {
60
+ extractor?: PDFTextExtractor;
61
+ };
62
+ export type ExcelSheetData = readonly (readonly unknown[])[];
63
+ export type ExcelWorkbookData = Record<string, ExcelSheetData>;
64
+ export type ExcelTextExtractor = (filePath: string, bytes: Buffer) => ExcelWorkbookData | string;
65
+ export type ExcelKnowledgeSourceOptions = FileKnowledgeSourceOptions & {
66
+ extractor?: ExcelTextExtractor;
67
+ };
68
+ export type DoclingConversionResult = unknown;
69
+ export type DoclingDocumentConverter = {
70
+ convert_all?: (paths: readonly string[]) => Iterable<DoclingConversionResult>;
71
+ convertAll?: (paths: readonly string[]) => Iterable<DoclingConversionResult>;
72
+ } | ((paths: readonly string[]) => Iterable<DoclingConversionResult>);
73
+ export type DoclingChunk = {
74
+ text?: string | number | boolean | bigint | null | undefined;
75
+ } | string;
76
+ export type DoclingChunker = {
77
+ chunk?: (document: unknown) => Iterable<DoclingChunk>;
78
+ } | ((document: unknown) => Iterable<DoclingChunk>);
79
+ export type CrewDoclingSourceOptions = FileKnowledgeSourceOptions & {
80
+ documentConverter?: DoclingDocumentConverter | null;
81
+ document_converter?: DoclingDocumentConverter | null;
82
+ chunker?: DoclingChunker | null;
83
+ };
84
+ export declare class BaseKnowledgeSource {
85
+ readonly chunkSize: number;
86
+ readonly chunk_size: number;
87
+ readonly chunkOverlap: number;
88
+ readonly chunk_overlap: number;
89
+ readonly metadata: Record<string, unknown>;
90
+ readonly collectionName: string | null;
91
+ readonly collection_name: string | null;
92
+ storage: BaseKnowledgeStorage | null;
93
+ chunks: string[];
94
+ private chunkEmbeddingsValue;
95
+ constructor(options?: BaseKnowledgeSourceOptions);
96
+ get chunkEmbeddings(): unknown[];
97
+ set chunkEmbeddings(value: readonly unknown[]);
98
+ get chunk_embeddings(): unknown[];
99
+ set chunk_embeddings(value: readonly unknown[]);
100
+ validateContent(): unknown;
101
+ validate_content(): unknown;
102
+ add(): void;
103
+ aadd(): Promise<void>;
104
+ getEmbeddings(): readonly unknown[];
105
+ get_embeddings(): readonly unknown[];
106
+ chunkText(text: string): string[];
107
+ _chunk_text(text: string): string[];
108
+ saveDocuments(): void;
109
+ _save_documents(): void;
110
+ asaveDocuments(): Promise<void>;
111
+ _asave_documents(): Promise<void>;
112
+ }
113
+ export type KnowledgeOptions = {
114
+ sources?: readonly KnowledgeSource[];
115
+ collectionName?: string | null;
116
+ collection_name?: string | null;
117
+ storage?: BaseKnowledgeStorage | null;
118
+ embedder?: EmbedderConfig | null;
119
+ };
120
+ export type KnowledgeStorageOptions = {
121
+ collectionName?: string | null;
122
+ collection_name?: string | null;
123
+ client?: RagClient | null;
124
+ embedder?: EmbedderConfig | null;
125
+ };
126
+ export declare class StringKnowledgeSource implements KnowledgeSource {
127
+ readonly sourceType = "string";
128
+ readonly source_type = "string";
129
+ readonly content: string;
130
+ readonly chunkSize: number;
131
+ readonly chunkOverlap: number;
132
+ readonly metadata: Record<string, unknown>;
133
+ readonly collectionName: string | null;
134
+ readonly collection_name: string | null;
135
+ storage: BaseKnowledgeStorage | null;
136
+ constructor(options: StringKnowledgeSourceOptions | string);
137
+ model_post_init(_context?: unknown): void;
138
+ validateContent(): void;
139
+ validate_content(): void;
140
+ chunks(): readonly string[];
141
+ _chunk_text(text: string): string[];
142
+ add(): void;
143
+ aadd(): Promise<void>;
144
+ getEmbeddings(): readonly unknown[];
145
+ get_embeddings(): readonly unknown[];
146
+ saveDocuments(documents?: readonly string[]): void;
147
+ _save_documents(): void;
148
+ asaveDocuments(documents?: readonly string[]): Promise<void>;
149
+ _asave_documents(): Promise<void>;
150
+ }
151
+ declare abstract class BaseTextKnowledgeSource implements KnowledgeSource {
152
+ abstract readonly sourceType: string;
153
+ readonly chunkSize: number;
154
+ readonly chunkOverlap: number;
155
+ readonly metadata: Record<string, unknown>;
156
+ readonly collectionName: string | null;
157
+ readonly collection_name: string | null;
158
+ storage: BaseKnowledgeStorage | null;
159
+ protected constructor(options: Pick<FileKnowledgeSourceOptions, "chunkSize" | "chunkOverlap" | "metadata" | "storage" | "collectionName" | "collection_name">);
160
+ chunks(): readonly string[];
161
+ _chunk_text(text: string): string[];
162
+ validateContent(): void;
163
+ validate_content(): void;
164
+ add(): void;
165
+ aadd(): Promise<void>;
166
+ getEmbeddings(): readonly unknown[];
167
+ get_embeddings(): readonly unknown[];
168
+ protected abstract loadText(): string;
169
+ saveDocuments(documents?: readonly string[]): void;
170
+ _save_documents(): void;
171
+ asaveDocuments(documents?: readonly string[]): Promise<void>;
172
+ _asave_documents(): Promise<void>;
173
+ }
174
+ export declare abstract class BaseFileKnowledgeSource extends BaseTextKnowledgeSource {
175
+ readonly filePath: string | readonly string[] | null;
176
+ readonly file_path: string | readonly string[] | null;
177
+ readonly filePaths: readonly string[];
178
+ readonly file_paths: readonly string[];
179
+ safeFilePaths: string[];
180
+ safe_file_paths: string[];
181
+ content: Record<string, string>;
182
+ protected constructor(options: FileKnowledgeSourceOptions | string | readonly string[]);
183
+ model_post_init(_context?: unknown): void;
184
+ validateFilePath(value: string | readonly string[] | null, info?: {
185
+ field_name?: string;
186
+ data?: Record<string, unknown>;
187
+ }): string | readonly string[] | null;
188
+ validate_file_path(value: string | readonly string[] | null, info?: {
189
+ field_name?: string;
190
+ data?: Record<string, unknown>;
191
+ }): string | readonly string[] | null;
192
+ validateContent(): void;
193
+ validate_content(): void;
194
+ abstract loadContent(): Record<string, string>;
195
+ load_content(): Record<string, string>;
196
+ _load_content(): unknown;
197
+ convertToPath(filePath: string): string;
198
+ convert_to_path(filePath: string): string;
199
+ protected loadText(): string;
200
+ protected processFilePaths(): string[];
201
+ _process_file_paths(): string[];
202
+ }
203
+ export declare class TextFileKnowledgeSource extends BaseFileKnowledgeSource {
204
+ readonly sourceType = "text_file";
205
+ readonly source_type = "text_file";
206
+ constructor(options: FileKnowledgeSourceOptions | string | readonly string[]);
207
+ loadContent(): Record<string, string>;
208
+ }
209
+ export declare class JSONKnowledgeSource extends BaseFileKnowledgeSource {
210
+ readonly sourceType = "json";
211
+ readonly source_type = "json";
212
+ constructor(options: FileKnowledgeSourceOptions | string | readonly string[]);
213
+ loadContent(): Record<string, string>;
214
+ _json_to_text(data: unknown, level?: number): string;
215
+ }
216
+ export declare class CSVKnowledgeSource extends BaseFileKnowledgeSource {
217
+ readonly sourceType = "csv";
218
+ readonly source_type = "csv";
219
+ constructor(options: FileKnowledgeSourceOptions | string | readonly string[]);
220
+ loadContent(): Record<string, string>;
221
+ }
222
+ export declare class PDFKnowledgeSource extends BaseFileKnowledgeSource {
223
+ readonly sourceType = "pdf";
224
+ readonly source_type = "pdf";
225
+ private readonly extractor;
226
+ constructor(options: PDFKnowledgeSourceOptions | string | readonly string[]);
227
+ loadContent(): Record<string, string>;
228
+ _import_pdfplumber(): never;
229
+ _chunk_text(text: string): string[];
230
+ add(): void;
231
+ aadd(): Promise<void>;
232
+ private loadContentAsync;
233
+ }
234
+ export declare class ExcelKnowledgeSource extends BaseFileKnowledgeSource {
235
+ readonly sourceType = "excel";
236
+ readonly source_type = "excel";
237
+ private readonly extractor;
238
+ constructor(options: ExcelKnowledgeSourceOptions | string | readonly string[]);
239
+ loadContent(): Record<string, string>;
240
+ _import_dependencies(): {
241
+ readWorkbook: typeof parseXlsxWorkbook;
242
+ };
243
+ }
244
+ export declare class CrewDoclingSource extends BaseFileKnowledgeSource {
245
+ readonly sourceType = "docling";
246
+ readonly source_type = "docling";
247
+ private readonly documentConverter;
248
+ private readonly chunker;
249
+ private doclingDocuments;
250
+ constructor(options: CrewDoclingSourceOptions | string | readonly string[]);
251
+ model_post_init(_context?: unknown): void;
252
+ validateContent(): string[];
253
+ validate_content(): string[];
254
+ loadContent(): Record<string, string>;
255
+ load_content(): Record<string, string>;
256
+ _load_content(): unknown[];
257
+ add(): void;
258
+ aadd(): Promise<void>;
259
+ _convert_source_to_docling_documents(): unknown[];
260
+ _chunk_doc(document: unknown): Iterable<string>;
261
+ _save_documents(): void;
262
+ _asave_documents(): Promise<void>;
263
+ _validate_url(url: string): boolean;
264
+ private convertSourceToDoclingDocuments;
265
+ private chunkDoc;
266
+ private saveDoclingDocuments;
267
+ private asaveDoclingDocuments;
268
+ }
269
+ export declare class SourceHelper {
270
+ static readonly SUPPORTED_FILE_TYPES: readonly [".csv", ".pdf", ".json", ".txt", ".xlsx", ".xls"];
271
+ static readonly _FILE_TYPE_MAP: {
272
+ readonly ".csv": typeof CSVKnowledgeSource;
273
+ readonly ".pdf": typeof PDFKnowledgeSource;
274
+ readonly ".json": typeof JSONKnowledgeSource;
275
+ readonly ".txt": typeof TextFileKnowledgeSource;
276
+ readonly ".xlsx": typeof ExcelKnowledgeSource;
277
+ readonly ".xls": typeof ExcelKnowledgeSource;
278
+ };
279
+ readonly supportedFileTypes: readonly [".csv", ".pdf", ".json", ".txt", ".xlsx", ".xls"];
280
+ readonly _fileTypeMap: {
281
+ readonly ".csv": typeof CSVKnowledgeSource;
282
+ readonly ".pdf": typeof PDFKnowledgeSource;
283
+ readonly ".json": typeof JSONKnowledgeSource;
284
+ readonly ".txt": typeof TextFileKnowledgeSource;
285
+ readonly ".xlsx": typeof ExcelKnowledgeSource;
286
+ readonly ".xls": typeof ExcelKnowledgeSource;
287
+ };
288
+ readonly _file_type_map: {
289
+ readonly ".csv": typeof CSVKnowledgeSource;
290
+ readonly ".pdf": typeof PDFKnowledgeSource;
291
+ readonly ".json": typeof JSONKnowledgeSource;
292
+ readonly ".txt": typeof TextFileKnowledgeSource;
293
+ readonly ".xlsx": typeof ExcelKnowledgeSource;
294
+ readonly ".xls": typeof ExcelKnowledgeSource;
295
+ };
296
+ isSupportedFile(filePath: string): boolean;
297
+ getSource(filePath: string, metadata?: Record<string, unknown> | null): KnowledgeSource;
298
+ static isSupportedFile(filePath: string): boolean;
299
+ static is_supported_file(filePath: string): boolean;
300
+ static getSource(filePath: string, metadata?: Record<string, unknown> | null): KnowledgeSource;
301
+ static get_source(filePath: string, metadata?: Record<string, unknown> | null): KnowledgeSource;
302
+ }
303
+ export declare class Knowledge {
304
+ readonly sources: readonly KnowledgeSource[];
305
+ readonly collectionName: string | null;
306
+ readonly collection_name: string | null;
307
+ readonly storage: BaseKnowledgeStorage | null;
308
+ private entries;
309
+ constructor(options?: KnowledgeOptions);
310
+ addSources(sources?: readonly KnowledgeSource[]): void;
311
+ add_sources(sources?: readonly KnowledgeSource[]): void;
312
+ aaddSources(sources?: readonly KnowledgeSource[]): Promise<void>;
313
+ aadd_sources(sources?: readonly KnowledgeSource[]): Promise<void>;
314
+ add(content: string, options?: {
315
+ source?: string | null;
316
+ metadata?: Record<string, unknown> | null;
317
+ }): void;
318
+ query(query: string | readonly string[], options?: KnowledgeQueryOptions): KnowledgeSearchResult[];
319
+ aquery(query: string | readonly string[], options?: KnowledgeQueryOptions): Promise<KnowledgeSearchResult[]>;
320
+ reset(): void;
321
+ areset(): Promise<void>;
322
+ private documentsFromSources;
323
+ }
324
+ export declare abstract class BaseKnowledgeStorage {
325
+ abstract search(query: readonly string[], limit?: number, metadataFilter?: Record<string, unknown> | null, scoreThreshold?: number): SearchResult[];
326
+ abstract asearch(query: readonly string[], limit?: number, metadataFilter?: Record<string, unknown> | null, scoreThreshold?: number): Promise<SearchResult[]>;
327
+ abstract save(documents: readonly string[]): void;
328
+ abstract asave(documents: readonly string[]): Promise<void>;
329
+ abstract reset(): void;
330
+ abstract areset(): Promise<void>;
331
+ }
332
+ export declare class KnowledgeStorage extends BaseKnowledgeStorage {
333
+ readonly collectionName: string | null;
334
+ readonly collection_name: string | null;
335
+ readonly embedder: EmbedderConfig | null;
336
+ private client;
337
+ constructor(options?: KnowledgeStorageOptions);
338
+ _init_client(): this;
339
+ search(query: readonly string[], limit?: number, metadataFilter?: Record<string, unknown> | null, scoreThreshold?: number): SearchResult[];
340
+ asearch(query: readonly string[], limit?: number, metadataFilter?: Record<string, unknown> | null, scoreThreshold?: number): Promise<SearchResult[]>;
341
+ save(documents: readonly string[]): void;
342
+ asave(documents: readonly string[]): Promise<void>;
343
+ reset(): void;
344
+ areset(): Promise<void>;
345
+ _get_client(): RagClient;
346
+ get _client(): RagClient | null;
347
+ set _client(client: RagClient | null);
348
+ ragCollectionName(): string;
349
+ rag_collection_name(): string;
350
+ }
351
+ export declare function extractKnowledgeContext(results: readonly unknown[]): string;
352
+ declare function parseXlsxWorkbook(bytes: Buffer): ExcelWorkbookData;
353
+ export {};
@@ -0,0 +1,69 @@
1
+ import type { UsageMetrics } from "./llm.js";
2
+ import type { LLMMessage } from "./types.js";
3
+ export type TodoExecutionResultOptions = {
4
+ stepNumber?: number;
5
+ step_number?: number;
6
+ description: string;
7
+ toolUsed?: string | null;
8
+ tool_used?: string | null;
9
+ status: string;
10
+ result?: string | null;
11
+ dependsOn?: readonly number[];
12
+ depends_on?: readonly number[];
13
+ };
14
+ export declare class TodoExecutionResult {
15
+ readonly stepNumber: number;
16
+ readonly step_number: number;
17
+ readonly description: string;
18
+ readonly toolUsed: string | null;
19
+ readonly tool_used: string | null;
20
+ readonly status: string;
21
+ readonly result: string | null;
22
+ readonly dependsOn: readonly number[];
23
+ readonly depends_on: readonly number[];
24
+ constructor(options: TodoExecutionResultOptions);
25
+ }
26
+ export type LiteAgentOutputOptions = {
27
+ raw?: string;
28
+ pydantic?: unknown;
29
+ agentRole?: string;
30
+ agent_role?: string;
31
+ usageMetrics?: UsageMetrics | null;
32
+ usage_metrics?: UsageMetrics | null;
33
+ messages?: readonly LLMMessage[];
34
+ plan?: string | null;
35
+ todos?: readonly (TodoExecutionResult | TodoExecutionResultOptions)[];
36
+ replanCount?: number;
37
+ replan_count?: number;
38
+ lastReplanReason?: string | null;
39
+ last_replan_reason?: string | null;
40
+ };
41
+ export declare class LiteAgentOutput {
42
+ readonly raw: string;
43
+ readonly pydantic: unknown;
44
+ readonly agentRole: string;
45
+ readonly agent_role: string;
46
+ readonly usageMetrics: UsageMetrics | null;
47
+ readonly usage_metrics: UsageMetrics | null;
48
+ readonly messages: readonly LLMMessage[];
49
+ readonly plan: string | null;
50
+ readonly todos: readonly TodoExecutionResult[];
51
+ readonly replanCount: number;
52
+ readonly replan_count: number;
53
+ readonly lastReplanReason: string | null;
54
+ readonly last_replan_reason: string | null;
55
+ constructor(options: LiteAgentOutputOptions);
56
+ static fromTodoItems(items: readonly TodoExecutionResultOptions[]): TodoExecutionResult[];
57
+ static from_todo_items(items: readonly TodoExecutionResultOptions[]): TodoExecutionResult[];
58
+ toDict(): Record<string, unknown>;
59
+ to_dict(): Record<string, unknown>;
60
+ get completedTodos(): readonly TodoExecutionResult[];
61
+ get completed_todos(): readonly TodoExecutionResult[];
62
+ get failedTodos(): readonly TodoExecutionResult[];
63
+ get failed_todos(): readonly TodoExecutionResult[];
64
+ get hadPlan(): boolean;
65
+ get had_plan(): boolean;
66
+ toString(): string;
67
+ __str__(): string;
68
+ __repr__(): string;
69
+ }