@crewai-ts/core 0.1.12 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +174 -0
- package/dist/agent.d.ts +16 -18
- package/dist/auth.cjs +598 -0
- package/dist/auth.js +40 -0
- package/dist/{chunk-3PVW4JKT.js → chunk-C43UEMCX.js} +6712 -7268
- package/dist/chunk-CCOE6MLE.js +896 -0
- package/dist/chunk-HFQTF332.js +4455 -0
- package/dist/{chunk-BE4JYKSG.js → chunk-MM4ROIFG.js} +12 -1490
- package/dist/chunk-RH43TNKN.js +238 -0
- package/dist/chunk-S477WFUT.js +565 -0
- package/dist/chunk-SB7ADUQA.js +110 -0
- package/dist/chunk-T32G6KDW.js +40 -0
- package/dist/crew.d.ts +24 -26
- package/dist/events.cjs +7513 -0
- package/dist/events.js +406 -0
- package/dist/experimental-conversational.cjs +272 -0
- package/dist/experimental-conversational.js +26 -0
- package/dist/feature-hooks.cjs +149 -0
- package/dist/feature-hooks.d.ts +94 -0
- package/dist/feature-hooks.js +36 -0
- package/dist/index.cjs +33923 -64381
- package/dist/index.d.ts +2 -15
- package/dist/index.js +16720 -49562
- package/dist/input-provider.d.ts +3 -4
- package/dist/lite-agent.d.ts +4 -4
- package/dist/llm.cjs +7467 -0
- package/dist/llm.d.ts +0 -4
- package/dist/llm.js +225 -0
- package/dist/optional-yaml.d.ts +8 -0
- package/dist/project.d.ts +1 -1
- package/dist/schema-utils.cjs +968 -0
- package/dist/schema-utils.d.ts +1 -1
- package/dist/schema-utils.js +102 -0
- package/dist/state-provider-core.js +3 -2
- package/dist/task.d.ts +3 -4
- package/dist/tools.cjs +6872 -0
- package/dist/tools.d.ts +0 -60
- package/dist/tools.js +114 -0
- package/dist/types.cjs +68 -0
- package/dist/types.js +14 -0
- package/package.json +52 -111
- package/dist/a2a.d.ts +0 -1684
- package/dist/a2ui-schemas.d.ts +0 -3312
- package/dist/a2ui.d.ts +0 -379
- package/dist/flow-conversation.d.ts +0 -90
- package/dist/flow-definition.d.ts +0 -195
- package/dist/flow-persistence.d.ts +0 -107
- package/dist/flow-visualization.d.ts +0 -77
- package/dist/flow.d.ts +0 -927
- package/dist/knowledge.d.ts +0 -353
- package/dist/mcp-DS7UMYAM.js +0 -62
- package/dist/mcp.d.ts +0 -315
- package/dist/memory.d.ts +0 -915
- package/dist/openai-completion.d.ts +0 -327
- package/dist/provider-completions.d.ts +0 -596
- package/dist/rag.d.ts +0 -1074
package/README.md
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# @crewai-ts/core
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@crewai-ts/core)
|
|
4
|
+
[](https://www.npmjs.com/package/@crewai-ts/core)
|
|
5
|
+
|
|
6
|
+
An **unofficial** TypeScript port of [CrewAI](https://github.com/crewAIInc/crewAI) for building multi-agent workflows with agents, tasks, crews, flows, memory, knowledge, tools, checkpoints, and streaming.
|
|
7
|
+
|
|
8
|
+
This project is not affiliated with, endorsed by, or maintained by crewAI, Inc.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install @crewai-ts/core
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Requirements:
|
|
17
|
+
|
|
18
|
+
- Node.js 22 or later
|
|
19
|
+
- ESM and CommonJS projects are both supported
|
|
20
|
+
- Type declarations are included
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { Agent, Crew, Process, Task } from "@crewai-ts/core";
|
|
26
|
+
|
|
27
|
+
const researcher = new Agent({
|
|
28
|
+
role: "Researcher",
|
|
29
|
+
goal: "Find useful implementation details",
|
|
30
|
+
backstory: "A careful technical analyst.",
|
|
31
|
+
llm: (messages) => `researched: ${messages.at(-1)?.content ?? ""}`,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const task = new Task({
|
|
35
|
+
description: "Research {topic}",
|
|
36
|
+
expectedOutput: "A concise implementation brief",
|
|
37
|
+
agent: researcher,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const crew = new Crew({
|
|
41
|
+
agents: [researcher],
|
|
42
|
+
tasks: [task],
|
|
43
|
+
process: Process.sequential,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const result = await crew.kickoff({
|
|
47
|
+
inputs: { topic: "CrewAI with TypeScript" },
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
console.log(result.raw);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Decorator Style
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { Agent, Crew, Process, Task, agent, crew, task } from "@crewai-ts/core";
|
|
57
|
+
|
|
58
|
+
class ResearchCrew {
|
|
59
|
+
@agent
|
|
60
|
+
researcher() {
|
|
61
|
+
return new Agent({
|
|
62
|
+
role: "Researcher",
|
|
63
|
+
goal: "Find facts",
|
|
64
|
+
backstory: "Careful analyst",
|
|
65
|
+
llm: (messages) => `result: ${messages.at(-1)?.content ?? ""}`,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@task
|
|
70
|
+
researchTask() {
|
|
71
|
+
return new Task({
|
|
72
|
+
description: "Research {topic}",
|
|
73
|
+
expectedOutput: "A concise brief",
|
|
74
|
+
agent: this.researcher(),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@crew
|
|
79
|
+
crew() {
|
|
80
|
+
return new Crew({
|
|
81
|
+
agents: [this.researcher()],
|
|
82
|
+
tasks: [this.researchTask()],
|
|
83
|
+
process: Process.sequential,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const result = await new ResearchCrew().crew().kickoff({
|
|
89
|
+
inputs: { topic: "CrewAI" },
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## LLM Providers
|
|
94
|
+
|
|
95
|
+
Pass a function LLM directly:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
const llm = (messages: Array<{ content?: string }>) => {
|
|
99
|
+
return `answer: ${messages.at(-1)?.content ?? ""}`;
|
|
100
|
+
};
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Or register a named provider:
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import { Agent, registerLLMProvider } from "@crewai-ts/core";
|
|
107
|
+
|
|
108
|
+
registerLLMProvider("demo/provider", () => ({
|
|
109
|
+
call: async (messages) => `provider result: ${messages.at(-1)?.content ?? ""}`,
|
|
110
|
+
}));
|
|
111
|
+
|
|
112
|
+
const agent = new Agent({
|
|
113
|
+
role: "Assistant",
|
|
114
|
+
goal: "Use a registered provider",
|
|
115
|
+
backstory: "A deterministic assistant.",
|
|
116
|
+
llm: "demo/provider",
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Tools
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import { Agent, StructuredTool, Task } from "@crewai-ts/core";
|
|
124
|
+
|
|
125
|
+
const search = new StructuredTool({
|
|
126
|
+
name: "search",
|
|
127
|
+
description: "Search internal notes",
|
|
128
|
+
schema: {
|
|
129
|
+
type: "object",
|
|
130
|
+
properties: {
|
|
131
|
+
query: { type: "string" },
|
|
132
|
+
},
|
|
133
|
+
required: ["query"],
|
|
134
|
+
},
|
|
135
|
+
func: async ({ query }) => `result for ${query}`,
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const researcher = new Agent({
|
|
139
|
+
role: "Researcher",
|
|
140
|
+
goal: "Use tools when useful",
|
|
141
|
+
backstory: "Tool-using analyst.",
|
|
142
|
+
tools: [search],
|
|
143
|
+
llm: () => ({ toolName: "search", arguments: { query: "CrewAI" } }),
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const task = new Task({
|
|
147
|
+
description: "Search for CrewAI information",
|
|
148
|
+
expectedOutput: "Search result",
|
|
149
|
+
agent: researcher,
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Features
|
|
154
|
+
|
|
155
|
+
- `Agent`, `Task`, `ConditionalTask`, `Crew`, `TaskOutput`, and `CrewOutput`
|
|
156
|
+
- Sequential and hierarchical process support
|
|
157
|
+
- Crew kickoff, batch kickoff, replay, planning, and usage metrics
|
|
158
|
+
- Standard TypeScript decorators: `@agent`, `@task`, `@crew`, `@beforeKickoff`, `@afterKickoff`
|
|
159
|
+
- Tool calling with `BaseTool` and `StructuredTool`
|
|
160
|
+
- Memory and knowledge sources
|
|
161
|
+
- JSON and SQLite checkpoint providers
|
|
162
|
+
- Flow APIs with `@start`, `@listen`, `@router`, `and_`, and `or_`
|
|
163
|
+
- Human input providers and task guardrails
|
|
164
|
+
- Streaming crew and flow output helpers
|
|
165
|
+
- Python-style snake_case compatibility aliases for common CrewAI entry points
|
|
166
|
+
|
|
167
|
+
## Related Packages
|
|
168
|
+
|
|
169
|
+
- `@crewai-ts/nestjs`: NestJS dependency-injection integration
|
|
170
|
+
- `@crewai-ts/cli`: CLI helpers for CrewAI-style TypeScript projects
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
MIT
|
package/dist/agent.d.ts
CHANGED
|
@@ -3,16 +3,14 @@ import { CacheHandler, ToolsHandler } from "./tools.js";
|
|
|
3
3
|
import { RpmController } from "./rpm.js";
|
|
4
4
|
import { type UsageMetrics } from "./llm.js";
|
|
5
5
|
import { Converter } from "./converter.js";
|
|
6
|
-
import { Knowledge, type KnowledgeSource } from "./knowledge.js";
|
|
7
6
|
import { type Fingerprint, type SecurityConfig } from "./security.js";
|
|
8
7
|
import { type CheckpointConfig, type CheckpointOption } from "./state.js";
|
|
9
8
|
import type { ExecutionContext } from "./context.js";
|
|
10
9
|
import type { AgentStepCallback, InputValues, LLM, LLMMessage, Tool } from "./types.js";
|
|
11
|
-
import { type Memory, type MemoryScope } from "./memory.js";
|
|
12
10
|
import { type InputFiles } from "./input-files.js";
|
|
13
|
-
import type { EmbedderConfig } from "./rag.js";
|
|
14
11
|
import { type StandardPromptResult, type SystemPromptResult } from "./prompts.js";
|
|
15
12
|
import { LiteAgentOutput } from "./lite-agent-output.js";
|
|
13
|
+
import { type EmbedderConfig, type KnowledgeLike, type KnowledgeSourceLike, type MemoryLike, type MemoryScopeLike } from "./feature-hooks.js";
|
|
16
14
|
export type AgentGuardrailResult = readonly [boolean, unknown] | {
|
|
17
15
|
success: boolean;
|
|
18
16
|
result?: unknown;
|
|
@@ -35,10 +33,10 @@ export type AgentOptions = {
|
|
|
35
33
|
crew?: unknown;
|
|
36
34
|
functionCallingLlm?: LLM | string | null;
|
|
37
35
|
function_calling_llm?: LLM | string | null;
|
|
38
|
-
memory?:
|
|
39
|
-
knowledge?:
|
|
40
|
-
knowledgeSources?: readonly
|
|
41
|
-
knowledge_sources?: readonly
|
|
36
|
+
memory?: MemoryLike | MemoryScopeLike | null;
|
|
37
|
+
knowledge?: KnowledgeLike | null;
|
|
38
|
+
knowledgeSources?: readonly KnowledgeSourceLike[];
|
|
39
|
+
knowledge_sources?: readonly KnowledgeSourceLike[];
|
|
42
40
|
knowledgeStorage?: unknown;
|
|
43
41
|
knowledge_storage?: unknown;
|
|
44
42
|
knowledgeConfig?: Record<string, unknown> | null;
|
|
@@ -134,8 +132,8 @@ export type AgentExecutionOptions = {
|
|
|
134
132
|
response_format?: unknown;
|
|
135
133
|
stepCallbacks?: readonly AgentStepCallback[];
|
|
136
134
|
functionCallingLlm?: LLM | string | null;
|
|
137
|
-
memory?:
|
|
138
|
-
knowledge?:
|
|
135
|
+
memory?: MemoryLike | MemoryScopeLike | null;
|
|
136
|
+
knowledge?: KnowledgeLike | null;
|
|
139
137
|
inputFiles?: InputFiles;
|
|
140
138
|
input_files?: InputFiles;
|
|
141
139
|
task?: unknown;
|
|
@@ -165,10 +163,10 @@ export declare class Agent {
|
|
|
165
163
|
readonly crew: unknown;
|
|
166
164
|
readonly functionCallingLlm: LLM | string | null;
|
|
167
165
|
readonly function_calling_llm: LLM | string | null;
|
|
168
|
-
memory:
|
|
169
|
-
knowledge:
|
|
170
|
-
readonly knowledgeSources: readonly
|
|
171
|
-
readonly knowledge_sources: readonly
|
|
166
|
+
memory: MemoryLike | MemoryScopeLike | null;
|
|
167
|
+
knowledge: KnowledgeLike | null;
|
|
168
|
+
readonly knowledgeSources: readonly KnowledgeSourceLike[];
|
|
169
|
+
readonly knowledge_sources: readonly KnowledgeSourceLike[];
|
|
172
170
|
readonly knowledgeStorage: unknown;
|
|
173
171
|
readonly knowledge_storage: unknown;
|
|
174
172
|
readonly knowledgeConfig: Record<string, unknown> | null;
|
|
@@ -301,11 +299,11 @@ export declare class Agent {
|
|
|
301
299
|
_setup_agent_executor(): void;
|
|
302
300
|
validateAndSetAttributes(): this;
|
|
303
301
|
validate_and_set_attributes(): this;
|
|
304
|
-
resolveMemory():
|
|
305
|
-
resolve_memory():
|
|
306
|
-
createKnowledgeFromSources():
|
|
307
|
-
setKnowledge(knowledgeOrCrewEmbedder?:
|
|
308
|
-
set_knowledge(knowledgeOrCrewEmbedder?:
|
|
302
|
+
resolveMemory(): MemoryLike | MemoryScopeLike | null;
|
|
303
|
+
resolve_memory(): MemoryLike | MemoryScopeLike | null;
|
|
304
|
+
createKnowledgeFromSources(): KnowledgeLike | null;
|
|
305
|
+
setKnowledge(knowledgeOrCrewEmbedder?: KnowledgeLike | EmbedderConfig | null): void;
|
|
306
|
+
set_knowledge(knowledgeOrCrewEmbedder?: KnowledgeLike | EmbedderConfig | null): void;
|
|
309
307
|
setRpmController(controller: RpmController | null): void;
|
|
310
308
|
set_rpm_controller(controller: RpmController | null): void;
|
|
311
309
|
isAnyAvailableMemory(): boolean;
|