Add TypeScript definitions and update package configuration
Added TypeScript type definitions in `lib.d.ts` to improve developer experience and ensure type safety. Updated `package.json` to include the new "types" field and modified `.gitignore` to exclude additional unwanted files.
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,2 +1,4 @@
|
||||
/.idea/
|
||||
/node_modules/
|
||||
/node_modules/
|
||||
/prompt.md
|
||||
/todo
|
||||
|
50
lib.d.ts
vendored
Normal file
50
lib.d.ts
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
export interface QueryResult {
|
||||
confidence: number;
|
||||
action: string;
|
||||
}
|
||||
|
||||
export interface LLMService {
|
||||
query(prompt: string): Promise<QueryResult>;
|
||||
}
|
||||
|
||||
export interface State {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export class DummyLlmService implements LLMService {
|
||||
query(prompt: string): Promise<QueryResult>;
|
||||
}
|
||||
|
||||
export class WorkflowOperator {
|
||||
constructor(name: string, operation: (state: State) => Promise<State>);
|
||||
name: string;
|
||||
execute(state: State): Promise<State>;
|
||||
}
|
||||
|
||||
export class ManifoldRegion {
|
||||
constructor(name: string, operators?: WorkflowOperator[]);
|
||||
name: string;
|
||||
operators: WorkflowOperator[];
|
||||
adjacentRegions: Set<ManifoldRegion>;
|
||||
addOperator(operator: WorkflowOperator): void;
|
||||
connectTo(region: ManifoldRegion): void;
|
||||
getValidOperators(state: State): Promise<WorkflowOperator[]>;
|
||||
}
|
||||
|
||||
export class NestedManifoldRegion extends ManifoldRegion {
|
||||
constructor(name: string, nestedManifold: WorkflowFunctionManifold);
|
||||
nestedManifold: WorkflowFunctionManifold;
|
||||
navigate(prompt: string): Promise<boolean>;
|
||||
executeWorkflow(prompt: string): Promise<boolean>;
|
||||
}
|
||||
|
||||
export class WorkflowFunctionManifold {
|
||||
constructor(llmService: LLMService);
|
||||
llmService: LLMService;
|
||||
regions: Map<string, ManifoldRegion | NestedManifoldRegion>;
|
||||
currentRegion: ManifoldRegion | NestedManifoldRegion | null;
|
||||
state: State;
|
||||
addRegion(region: ManifoldRegion | NestedManifoldRegion): void;
|
||||
navigate(prompt: string): Promise<boolean>;
|
||||
executeWorkflow(prompt: string): Promise<boolean>;
|
||||
}
|
@@ -5,6 +5,7 @@
|
||||
"description": "for building dynamic, LLM-driven workflows using a region-based execution model",
|
||||
"main": "lib.js",
|
||||
"module": "lib.js",
|
||||
"types": "lib.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./lib.js",
|
||||
|
Reference in New Issue
Block a user