Comparing version 0.8.8 to 0.9.0
2528
dist/index.d.ts
@@ -0,4 +1,23 @@ | ||
import z$1, { z } from 'zod'; | ||
import OpenAI from 'openai'; | ||
import { z } from 'zod'; | ||
import { FunctionJson as FunctionJson$1 } from 'function-json-schema'; | ||
export * from 'function-json-schema'; | ||
declare const chatTurnBaseSchema: z.ZodObject<{ | ||
id: z.ZodString; | ||
type: z.ZodString; | ||
sender: z.ZodString; | ||
timestamp: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
id: string; | ||
type: string; | ||
sender: string; | ||
timestamp: string; | ||
}, { | ||
id: string; | ||
type: string; | ||
sender: string; | ||
timestamp: string; | ||
}>; | ||
type ChatTurnBase = z.infer<typeof chatTurnBaseSchema>; | ||
/** | ||
@@ -14,4 +33,4 @@ * For simple text responses | ||
}, "strip", z.ZodTypeAny, { | ||
id: string; | ||
type: "text"; | ||
id: string; | ||
sender: string; | ||
@@ -21,4 +40,4 @@ timestamp: string; | ||
}, { | ||
id: string; | ||
type: "text"; | ||
id: string; | ||
sender: string; | ||
@@ -29,2 +48,78 @@ timestamp: string; | ||
type ChatText = z.infer<typeof chatTextSchema>; | ||
declare const chatErrorSchema: z.ZodObject<{ | ||
id: z.ZodString; | ||
sender: z.ZodString; | ||
timestamp: z.ZodString; | ||
type: z.ZodLiteral<"error">; | ||
name: z.ZodString; | ||
message: z.ZodString; | ||
cause: z.ZodOptional<z.ZodString>; | ||
stack: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
id: string; | ||
type: "error"; | ||
sender: string; | ||
timestamp: string; | ||
message: string; | ||
name: string; | ||
cause?: string | undefined; | ||
stack?: string | undefined; | ||
}, { | ||
id: string; | ||
type: "error"; | ||
sender: string; | ||
timestamp: string; | ||
message: string; | ||
name: string; | ||
cause?: string | undefined; | ||
stack?: string | undefined; | ||
}>; | ||
type ChatError = z.infer<typeof chatErrorSchema>; | ||
/** | ||
* For image message. | ||
* Inspired by https://ogp.me/ | ||
*/ | ||
declare const chatImageSchema: z.ZodObject<{ | ||
id: z.ZodString; | ||
sender: z.ZodString; | ||
timestamp: z.ZodString; | ||
type: z.ZodLiteral<"image">; | ||
image: z.ZodString; | ||
description: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
id: string; | ||
type: "image"; | ||
sender: string; | ||
timestamp: string; | ||
description: string; | ||
image: string; | ||
}, { | ||
id: string; | ||
type: "image"; | ||
sender: string; | ||
timestamp: string; | ||
description: string; | ||
image: string; | ||
}>; | ||
type ChatImage = z.infer<typeof chatImageSchema>; | ||
declare const chatListSchema: z.ZodObject<{ | ||
id: z.ZodString; | ||
sender: z.ZodString; | ||
timestamp: z.ZodString; | ||
type: z.ZodLiteral<"list">; | ||
list: z.ZodArray<z.ZodString, "many">; | ||
}, "strip", z.ZodTypeAny, { | ||
id: string; | ||
type: "list"; | ||
sender: string; | ||
timestamp: string; | ||
list: string[]; | ||
}, { | ||
id: string; | ||
type: "list"; | ||
sender: string; | ||
timestamp: string; | ||
list: string[]; | ||
}>; | ||
type ChatList = z.infer<typeof chatListSchema>; | ||
declare const chatFunctionCallSchema: z.ZodObject<{ | ||
@@ -39,4 +134,4 @@ id: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
id: string; | ||
type: "functionCall"; | ||
id: string; | ||
sender: string; | ||
@@ -48,4 +143,4 @@ timestamp: string; | ||
}, { | ||
id: string; | ||
type: "functionCall"; | ||
id: string; | ||
sender: string; | ||
@@ -66,4 +161,4 @@ timestamp: string; | ||
}, "strip", z.ZodTypeAny, { | ||
id: string; | ||
type: "functionReturn"; | ||
id: string; | ||
sender: string; | ||
@@ -74,4 +169,4 @@ timestamp: string; | ||
}, { | ||
id: string; | ||
type: "functionReturn"; | ||
id: string; | ||
sender: string; | ||
@@ -93,4 +188,4 @@ timestamp: string; | ||
}, "strip", z.ZodTypeAny, { | ||
id: string; | ||
type: "text"; | ||
id: string; | ||
sender: string; | ||
@@ -100,4 +195,4 @@ timestamp: string; | ||
}, { | ||
id: string; | ||
type: "text"; | ||
id: string; | ||
sender: string; | ||
@@ -116,4 +211,4 @@ timestamp: string; | ||
}, "strip", z.ZodTypeAny, { | ||
id: string; | ||
type: "error"; | ||
id: string; | ||
sender: string; | ||
@@ -126,4 +221,4 @@ timestamp: string; | ||
}, { | ||
id: string; | ||
type: "error"; | ||
id: string; | ||
sender: string; | ||
@@ -143,15 +238,15 @@ timestamp: string; | ||
}, "strip", z.ZodTypeAny, { | ||
id: string; | ||
type: "image"; | ||
id: string; | ||
sender: string; | ||
timestamp: string; | ||
description: string; | ||
image: string; | ||
description: string; | ||
}, { | ||
id: string; | ||
type: "image"; | ||
id: string; | ||
sender: string; | ||
timestamp: string; | ||
description: string; | ||
image: string; | ||
description: string; | ||
}>, z.ZodObject<{ | ||
@@ -164,4 +259,4 @@ id: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
id: string; | ||
type: "list"; | ||
id: string; | ||
sender: string; | ||
@@ -171,4 +266,4 @@ timestamp: string; | ||
}, { | ||
id: string; | ||
type: "list"; | ||
id: string; | ||
sender: string; | ||
@@ -186,4 +281,4 @@ timestamp: string; | ||
}, "strip", z.ZodTypeAny, { | ||
id: string; | ||
type: "functionCall"; | ||
id: string; | ||
sender: string; | ||
@@ -195,4 +290,4 @@ timestamp: string; | ||
}, { | ||
id: string; | ||
type: "functionCall"; | ||
id: string; | ||
sender: string; | ||
@@ -211,4 +306,4 @@ timestamp: string; | ||
}, "strip", z.ZodTypeAny, { | ||
id: string; | ||
type: "functionReturn"; | ||
id: string; | ||
sender: string; | ||
@@ -219,4 +314,4 @@ timestamp: string; | ||
}, { | ||
id: string; | ||
type: "functionReturn"; | ||
id: string; | ||
sender: string; | ||
@@ -228,3 +323,19 @@ timestamp: string; | ||
type ChatTurn = z.infer<typeof chatTurnSchema>; | ||
/** | ||
* String union for all chat turn types. | ||
*/ | ||
type ChatTurnType = ChatTurn['type']; | ||
/** | ||
* ChatTurn base type with unioned type field. The most generic, "all" type. | ||
*/ | ||
type ChatTurnUnion = ChatTurnBase & { | ||
type: ChatTurnType; | ||
}; | ||
declare function createFunctionClient(baseUrl: string, apiKey: string): MappedReturnType<{ | ||
returnFunctionCall: typeof returnFunctionCall; | ||
nextMessage: typeof nextMessage; | ||
startWorkflow: typeof startWorkflow; | ||
putFunctionJsons: typeof putFunctionJsons; | ||
}>; | ||
type ReturnFunctionCallBody = Pick<ChatFunctionReturn, 'functionCallId' | 'functionReturn'>; | ||
@@ -243,3 +354,3 @@ type ReturnFunctionCallRes = { | ||
declare function startWorkflow(baseUrl: string, apiKey: string): (query: string, modules?: string) => Promise<StartWorkflowRes>; | ||
type FunctionJson$1 = { | ||
type FunctionJson = { | ||
name: string; | ||
@@ -253,1309 +364,1145 @@ description?: string; | ||
type putFunctionJsonsReq = { | ||
jsons: FunctionJson$1[]; | ||
jsons: FunctionJson[]; | ||
module?: string; | ||
}; | ||
declare function putFunctionJsons(baseUrl: string, apiKey: string): (jsons: FunctionJson$1[], module?: string) => Promise<void>; | ||
declare function putFunctionJsons(baseUrl: string, apiKey: string): (jsons: FunctionJson[], module?: string) => Promise<void>; | ||
/** | ||
* Recursive JSON object schema | ||
*/ | ||
type ObjectJsonSchema = { | ||
type: 'object'; | ||
properties: Record<string, ValueJsonSchema>; | ||
description?: string; | ||
declare const TaskStatus: { | ||
readonly Pending: "Pending"; | ||
readonly Planning: "Planning"; | ||
readonly Executing: "Executing"; | ||
readonly Sequencing: "Sequencing"; | ||
readonly Resolved: "Resolved"; | ||
readonly Sequenced: "Sequenced"; | ||
}; | ||
type RecordJsonSchema = { | ||
type: 'object'; | ||
additionalProperties: ValueJsonSchema; | ||
description?: string; | ||
type TaskStatus = (typeof TaskStatus)[keyof typeof TaskStatus]; | ||
declare const baseTaskSchema: z$1.ZodObject<{ | ||
id: z$1.ZodString; | ||
description: z$1.ZodString; | ||
status: z$1.ZodNativeEnum<{ | ||
readonly Pending: "Pending"; | ||
readonly Planning: "Planning"; | ||
readonly Executing: "Executing"; | ||
readonly Sequencing: "Sequencing"; | ||
readonly Resolved: "Resolved"; | ||
readonly Sequenced: "Sequenced"; | ||
}>; | ||
stepIndex: z$1.ZodNumber; | ||
depth: z$1.ZodNumber; | ||
numRewrites: z$1.ZodNumber; | ||
}, "strip", z$1.ZodTypeAny, { | ||
id: string; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
}, { | ||
id: string; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
}>; | ||
type BaseTask = z$1.infer<typeof baseTaskSchema>; | ||
declare const Feasibility: { | ||
readonly Feasible: "Feasible"; | ||
readonly Rewritable: "Rewritable"; | ||
readonly Infeasible: "Infeasible"; | ||
}; | ||
type ArrayJsonSchema = { | ||
type: 'array'; | ||
items: ValueJsonSchema; | ||
description?: string; | ||
type Feasibility = (typeof Feasibility)[keyof typeof Feasibility]; | ||
declare const feasibilityCheckSchema: z$1.ZodObject<{ | ||
feasibility: z$1.ZodNativeEnum<{ | ||
readonly Feasible: "Feasible"; | ||
readonly Rewritable: "Rewritable"; | ||
readonly Infeasible: "Infeasible"; | ||
}>; | ||
reason: z$1.ZodString; | ||
fix: z$1.ZodOptional<z$1.ZodString>; | ||
}, "strip", z$1.ZodTypeAny, { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}, { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}>; | ||
type FeasibilityCheck = z$1.infer<typeof feasibilityCheckSchema>; | ||
declare const Resolution: { | ||
readonly Resolved: "Resolved"; | ||
readonly Rewritable: "Rewritable"; | ||
readonly Infeasible: "Infeasible"; | ||
}; | ||
type RealUnionJsonSchema = { | ||
anyOf: ValueJsonSchema[]; | ||
description?: string; | ||
}; | ||
declare const valueJsonSchema: z.ZodUnion<[z.ZodType<ObjectJsonSchema, z.ZodTypeDef, ObjectJsonSchema>, z.ZodType<RecordJsonSchema, z.ZodTypeDef, RecordJsonSchema>, z.ZodType<ArrayJsonSchema, z.ZodTypeDef, ArrayJsonSchema>, z.ZodObject<{ | ||
type: z.ZodLiteral<"array">; | ||
prefixItems: z.ZodArray<z.ZodString, "many">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
type Resolution = (typeof Resolution)[keyof typeof Resolution]; | ||
declare const resolutionCheckSchema: z$1.ZodObject<{ | ||
resolution: z$1.ZodNativeEnum<{ | ||
readonly Resolved: "Resolved"; | ||
readonly Rewritable: "Rewritable"; | ||
readonly Infeasible: "Infeasible"; | ||
}>; | ||
reason: z$1.ZodString; | ||
fix: z$1.ZodOptional<z$1.ZodString>; | ||
}, "strip", z$1.ZodTypeAny, { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
}, { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodLiteral<"string">; | ||
enum: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
}>; | ||
type ResolutionCheck = z$1.infer<typeof resolutionCheckSchema>; | ||
declare const taskPendingSchema: z$1.ZodObject<{ | ||
id: z$1.ZodString; | ||
description: z$1.ZodString; | ||
stepIndex: z$1.ZodNumber; | ||
depth: z$1.ZodNumber; | ||
numRewrites: z$1.ZodNumber; | ||
status: z$1.ZodLiteral<"Pending">; | ||
}, "strip", z$1.ZodTypeAny, { | ||
id: string; | ||
status: "Pending"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
}, { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodUnion<[z.ZodLiteral<"number">, z.ZodLiteral<"integer">]>; | ||
description: z.ZodOptional<z.ZodString>; | ||
minimum: z.ZodOptional<z.ZodNumber>; | ||
maximum: z.ZodOptional<z.ZodNumber>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
}, { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodLiteral<"boolean">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
}, { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodArray<z.ZodString, "many">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: string[]; | ||
description?: string | undefined; | ||
}, { | ||
type: string[]; | ||
description?: string | undefined; | ||
}>, z.ZodType<RealUnionJsonSchema, z.ZodTypeDef, RealUnionJsonSchema>, z.ZodObject<{ | ||
type: z.ZodLiteral<"unknown">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
}, { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodLiteral<"null">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "null"; | ||
description?: string | undefined; | ||
}, { | ||
type: "null"; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
$ref: z.ZodString; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
$ref: string; | ||
description?: string | undefined; | ||
}, { | ||
$ref: string; | ||
description?: string | undefined; | ||
}>]>; | ||
type ValueJsonSchema = z.infer<typeof valueJsonSchema>; | ||
/** | ||
* OpenAI function json schema | ||
*/ | ||
declare const functionJsonSchema: z.ZodObject<{ | ||
name: z.ZodString; | ||
description: z.ZodString; | ||
parameters: z.ZodUnion<[z.ZodObject<{ | ||
type: z.ZodLiteral<"object">; | ||
properties: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodType<ObjectJsonSchema, z.ZodTypeDef, ObjectJsonSchema>, z.ZodType<RecordJsonSchema, z.ZodTypeDef, RecordJsonSchema>, z.ZodType<ArrayJsonSchema, z.ZodTypeDef, ArrayJsonSchema>, z.ZodObject<{ | ||
type: z.ZodLiteral<"array">; | ||
prefixItems: z.ZodArray<z.ZodString, "many">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
}, { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodLiteral<"string">; | ||
enum: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
}, { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodUnion<[z.ZodLiteral<"number">, z.ZodLiteral<"integer">]>; | ||
description: z.ZodOptional<z.ZodString>; | ||
minimum: z.ZodOptional<z.ZodNumber>; | ||
maximum: z.ZodOptional<z.ZodNumber>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
}, { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodLiteral<"boolean">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
}, { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodArray<z.ZodString, "many">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: string[]; | ||
description?: string | undefined; | ||
}, { | ||
type: string[]; | ||
description?: string | undefined; | ||
}>, z.ZodType<RealUnionJsonSchema, z.ZodTypeDef, RealUnionJsonSchema>, z.ZodObject<{ | ||
type: z.ZodLiteral<"unknown">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
}, { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodLiteral<"null">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "null"; | ||
description?: string | undefined; | ||
}, { | ||
type: "null"; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
$ref: z.ZodString; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
$ref: string; | ||
description?: string | undefined; | ||
}, { | ||
$ref: string; | ||
description?: string | undefined; | ||
}>]>>; | ||
description: z.ZodOptional<z.ZodString>; | ||
required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "object"; | ||
properties: Record<string, ObjectJsonSchema | RecordJsonSchema | ArrayJsonSchema | { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
} | { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
} | { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
} | { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
} | { | ||
type: string[]; | ||
description?: string | undefined; | ||
} | RealUnionJsonSchema | { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
} | { | ||
type: "null"; | ||
description?: string | undefined; | ||
} | { | ||
$ref: string; | ||
description?: string | undefined; | ||
id: string; | ||
status: "Pending"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
}>; | ||
type TaskPending = z$1.infer<typeof taskPendingSchema>; | ||
declare const taskPlanningSchema: z$1.ZodObject<{ | ||
id: z$1.ZodString; | ||
description: z$1.ZodString; | ||
stepIndex: z$1.ZodNumber; | ||
depth: z$1.ZodNumber; | ||
numRewrites: z$1.ZodNumber; | ||
status: z$1.ZodLiteral<"Planning">; | ||
program: z$1.ZodOptional<z$1.ZodString>; | ||
feasibilityCheck: z$1.ZodOptional<z$1.ZodObject<{ | ||
feasibility: z$1.ZodNativeEnum<{ | ||
readonly Feasible: "Feasible"; | ||
readonly Rewritable: "Rewritable"; | ||
readonly Infeasible: "Infeasible"; | ||
}>; | ||
description?: string | undefined; | ||
required?: string[] | undefined; | ||
reason: z$1.ZodString; | ||
fix: z$1.ZodOptional<z$1.ZodString>; | ||
}, "strip", z$1.ZodTypeAny, { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}, { | ||
type: "object"; | ||
properties: Record<string, ObjectJsonSchema | RecordJsonSchema | ArrayJsonSchema | { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
} | { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
} | { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
} | { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
} | { | ||
type: string[]; | ||
description?: string | undefined; | ||
} | RealUnionJsonSchema | { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
} | { | ||
type: "null"; | ||
description?: string | undefined; | ||
} | { | ||
$ref: string; | ||
description?: string | undefined; | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}>>; | ||
resolutionCheck: z$1.ZodOptional<z$1.ZodObject<{ | ||
resolution: z$1.ZodNativeEnum<{ | ||
readonly Resolved: "Resolved"; | ||
readonly Rewritable: "Rewritable"; | ||
readonly Infeasible: "Infeasible"; | ||
}>; | ||
description?: string | undefined; | ||
required?: string[] | undefined; | ||
}>, z.ZodArray<z.ZodUnion<[z.ZodType<ObjectJsonSchema, z.ZodTypeDef, ObjectJsonSchema>, z.ZodType<RecordJsonSchema, z.ZodTypeDef, RecordJsonSchema>, z.ZodType<ArrayJsonSchema, z.ZodTypeDef, ArrayJsonSchema>, z.ZodObject<{ | ||
type: z.ZodLiteral<"array">; | ||
prefixItems: z.ZodArray<z.ZodString, "many">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
reason: z$1.ZodString; | ||
fix: z$1.ZodOptional<z$1.ZodString>; | ||
}, "strip", z$1.ZodTypeAny, { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
}, { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodLiteral<"string">; | ||
enum: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
}>>; | ||
}, "strip", z$1.ZodTypeAny, { | ||
id: string; | ||
status: "Planning"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program?: string | undefined; | ||
feasibilityCheck?: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
} | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
}, { | ||
id: string; | ||
status: "Planning"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program?: string | undefined; | ||
feasibilityCheck?: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
} | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
}>; | ||
type TaskPlanning = z$1.infer<typeof taskPlanningSchema>; | ||
declare const taskExecutingSchema: z$1.ZodObject<{ | ||
id: z$1.ZodString; | ||
description: z$1.ZodString; | ||
stepIndex: z$1.ZodNumber; | ||
depth: z$1.ZodNumber; | ||
numRewrites: z$1.ZodNumber; | ||
status: z$1.ZodLiteral<"Executing">; | ||
program: z$1.ZodString; | ||
usedFunctionNames: z$1.ZodArray<z$1.ZodString, "many">; | ||
feasibilityCheck: z$1.ZodObject<{ | ||
feasibility: z$1.ZodNativeEnum<{ | ||
readonly Feasible: "Feasible"; | ||
readonly Rewritable: "Rewritable"; | ||
readonly Infeasible: "Infeasible"; | ||
}>; | ||
reason: z$1.ZodString; | ||
fix: z$1.ZodOptional<z$1.ZodString>; | ||
}, "strip", z$1.ZodTypeAny, { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}, { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodUnion<[z.ZodLiteral<"number">, z.ZodLiteral<"integer">]>; | ||
description: z.ZodOptional<z.ZodString>; | ||
minimum: z.ZodOptional<z.ZodNumber>; | ||
maximum: z.ZodOptional<z.ZodNumber>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}>; | ||
}, "strip", z$1.ZodTypeAny, { | ||
id: string; | ||
status: "Executing"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames: string[]; | ||
}, { | ||
id: string; | ||
status: "Executing"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames: string[]; | ||
}>; | ||
type TaskExecuting = z$1.infer<typeof taskExecutingSchema>; | ||
declare const taskResolvedSchema: z$1.ZodObject<{ | ||
id: z$1.ZodString; | ||
description: z$1.ZodString; | ||
stepIndex: z$1.ZodNumber; | ||
depth: z$1.ZodNumber; | ||
numRewrites: z$1.ZodNumber; | ||
status: z$1.ZodLiteral<"Resolved">; | ||
program: z$1.ZodString; | ||
usedFunctionNames: z$1.ZodArray<z$1.ZodString, "many">; | ||
feasibilityCheck: z$1.ZodObject<{ | ||
feasibility: z$1.ZodNativeEnum<{ | ||
readonly Feasible: "Feasible"; | ||
readonly Rewritable: "Rewritable"; | ||
readonly Infeasible: "Infeasible"; | ||
}>; | ||
reason: z$1.ZodString; | ||
fix: z$1.ZodOptional<z$1.ZodString>; | ||
}, "strip", z$1.ZodTypeAny, { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}, { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodLiteral<"boolean">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}>; | ||
resolutionCheck: z$1.ZodObject<{ | ||
resolution: z$1.ZodNativeEnum<{ | ||
readonly Resolved: "Resolved"; | ||
readonly Rewritable: "Rewritable"; | ||
readonly Infeasible: "Infeasible"; | ||
}>; | ||
reason: z$1.ZodString; | ||
fix: z$1.ZodOptional<z$1.ZodString>; | ||
}, "strip", z$1.ZodTypeAny, { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
}, { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodArray<z.ZodString, "many">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: string[]; | ||
description?: string | undefined; | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
}>; | ||
}, "strip", z$1.ZodTypeAny, { | ||
id: string; | ||
status: "Resolved"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
resolutionCheck: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames: string[]; | ||
}, { | ||
id: string; | ||
status: "Resolved"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
resolutionCheck: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames: string[]; | ||
}>; | ||
type TaskResolved = z$1.infer<typeof taskResolvedSchema>; | ||
declare const taskSequencingSchema: z$1.ZodObject<{ | ||
id: z$1.ZodString; | ||
description: z$1.ZodString; | ||
stepIndex: z$1.ZodNumber; | ||
depth: z$1.ZodNumber; | ||
numRewrites: z$1.ZodNumber; | ||
status: z$1.ZodLiteral<"Sequencing">; | ||
program: z$1.ZodString; | ||
feasibilityCheck: z$1.ZodObject<{ | ||
feasibility: z$1.ZodNativeEnum<{ | ||
readonly Feasible: "Feasible"; | ||
readonly Rewritable: "Rewritable"; | ||
readonly Infeasible: "Infeasible"; | ||
}>; | ||
reason: z$1.ZodString; | ||
fix: z$1.ZodOptional<z$1.ZodString>; | ||
}, "strip", z$1.ZodTypeAny, { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}, { | ||
type: string[]; | ||
description?: string | undefined; | ||
}>, z.ZodType<RealUnionJsonSchema, z.ZodTypeDef, RealUnionJsonSchema>, z.ZodObject<{ | ||
type: z.ZodLiteral<"unknown">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}>; | ||
usedFunctionNames: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString, "many">>; | ||
resolutionCheck: z$1.ZodOptional<z$1.ZodObject<{ | ||
resolution: z$1.ZodNativeEnum<{ | ||
readonly Resolved: "Resolved"; | ||
readonly Rewritable: "Rewritable"; | ||
readonly Infeasible: "Infeasible"; | ||
}>; | ||
reason: z$1.ZodString; | ||
fix: z$1.ZodOptional<z$1.ZodString>; | ||
}, "strip", z$1.ZodTypeAny, { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
}, { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodLiteral<"null">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "null"; | ||
description?: string | undefined; | ||
}, { | ||
type: "null"; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
$ref: z.ZodString; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
$ref: string; | ||
description?: string | undefined; | ||
}, { | ||
$ref: string; | ||
description?: string | undefined; | ||
}>]>, "many">]>; | ||
returns: z.ZodUnion<[z.ZodType<ObjectJsonSchema, z.ZodTypeDef, ObjectJsonSchema>, z.ZodType<RecordJsonSchema, z.ZodTypeDef, RecordJsonSchema>, z.ZodType<ArrayJsonSchema, z.ZodTypeDef, ArrayJsonSchema>, z.ZodObject<{ | ||
type: z.ZodLiteral<"array">; | ||
prefixItems: z.ZodArray<z.ZodString, "many">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
}, { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodLiteral<"string">; | ||
enum: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
}, { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodUnion<[z.ZodLiteral<"number">, z.ZodLiteral<"integer">]>; | ||
description: z.ZodOptional<z.ZodString>; | ||
minimum: z.ZodOptional<z.ZodNumber>; | ||
maximum: z.ZodOptional<z.ZodNumber>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
}, { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodLiteral<"boolean">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
}, { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodArray<z.ZodString, "many">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: string[]; | ||
description?: string | undefined; | ||
}, { | ||
type: string[]; | ||
description?: string | undefined; | ||
}>, z.ZodType<RealUnionJsonSchema, z.ZodTypeDef, RealUnionJsonSchema>, z.ZodObject<{ | ||
type: z.ZodLiteral<"unknown">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
}, { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
type: z.ZodLiteral<"null">; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
type: "null"; | ||
description?: string | undefined; | ||
}, { | ||
type: "null"; | ||
description?: string | undefined; | ||
}>, z.ZodObject<{ | ||
$ref: z.ZodString; | ||
description: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
$ref: string; | ||
description?: string | undefined; | ||
}, { | ||
$ref: string; | ||
description?: string | undefined; | ||
}>]>; | ||
usageExample: z.ZodOptional<z.ZodString>; | ||
returnsExample: z.ZodOptional<z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
name: string; | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
}>>; | ||
}, "strip", z$1.ZodTypeAny, { | ||
id: string; | ||
status: "Sequencing"; | ||
description: string; | ||
parameters: ({ | ||
type: "object"; | ||
properties: Record<string, ObjectJsonSchema | RecordJsonSchema | ArrayJsonSchema | { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
} | { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
} | { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
} | { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
} | { | ||
type: string[]; | ||
description?: string | undefined; | ||
} | RealUnionJsonSchema | { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
} | { | ||
type: "null"; | ||
description?: string | undefined; | ||
} | { | ||
$ref: string; | ||
description?: string | undefined; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames?: string[] | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
}, { | ||
id: string; | ||
status: "Sequencing"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames?: string[] | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
}>; | ||
type TaskSequencing = z$1.infer<typeof taskSequencingSchema>; | ||
type TaskSequenced = z$1.infer<typeof baseTaskSchema> & { | ||
status: 'Sequenced'; | ||
program: string; | ||
subtasks: Task[]; | ||
feasibilityCheck: FeasibilityCheck; | ||
usedFunctionNames?: string[]; | ||
resolutionCheck?: ResolutionCheck; | ||
}; | ||
declare const taskSequencedSchema: z$1.ZodType<TaskSequenced>; | ||
type Task = TaskPending | TaskPlanning | TaskExecuting | TaskSequencing | TaskSequenced | TaskResolved; | ||
declare const taskSchema: z$1.ZodType<Task>; | ||
type TaskStatusToType = { | ||
[TaskStatus.Pending]: TaskPending; | ||
[TaskStatus.Planning]: TaskPlanning; | ||
[TaskStatus.Executing]: TaskExecuting; | ||
[TaskStatus.Sequencing]: TaskSequencing; | ||
[TaskStatus.Sequenced]: TaskSequenced; | ||
[TaskStatus.Resolved]: TaskResolved; | ||
}; | ||
type TaskStatusesToType<Statuses> = Statuses extends TaskStatus[] ? Statuses[number] extends TaskStatus ? TaskStatusToType[Statuses[number]] : never : Statuses extends TaskStatus ? TaskStatusToType[Statuses] : never; | ||
declare const getWorkflowsResSchema: z$1.ZodObject<{ | ||
workflowInfos: z$1.ZodArray<z$1.ZodObject<{ | ||
workflowId: z$1.ZodString; | ||
modules: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString, "many">>; | ||
createdAt: z$1.ZodString; | ||
updatedAt: z$1.ZodString; | ||
description: z$1.ZodString; | ||
status: z$1.ZodNativeEnum<{ | ||
readonly Running: "Running"; | ||
readonly Completed: "Completed"; | ||
readonly Failed: "Failed"; | ||
readonly Paused: "Paused"; | ||
readonly TimedOut: "TimedOut"; | ||
}>; | ||
description?: string | undefined; | ||
required?: string[] | undefined; | ||
} | (ObjectJsonSchema | RecordJsonSchema | ArrayJsonSchema | { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
numLeafTasks: z$1.ZodNumber; | ||
}, "strip", z$1.ZodTypeAny, { | ||
status: "Running" | "Completed" | "Failed" | "Paused" | "TimedOut"; | ||
workflowId: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
description: string; | ||
numLeafTasks: number; | ||
modules?: string[] | undefined; | ||
}, { | ||
status: "Running" | "Completed" | "Failed" | "Paused" | "TimedOut"; | ||
workflowId: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
description: string; | ||
numLeafTasks: number; | ||
modules?: string[] | undefined; | ||
}>, "many">; | ||
}, "strip", z$1.ZodTypeAny, { | ||
workflowInfos: { | ||
status: "Running" | "Completed" | "Failed" | "Paused" | "TimedOut"; | ||
workflowId: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
description: string; | ||
numLeafTasks: number; | ||
modules?: string[] | undefined; | ||
}[]; | ||
}, { | ||
workflowInfos: { | ||
status: "Running" | "Completed" | "Failed" | "Paused" | "TimedOut"; | ||
workflowId: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
description: string; | ||
numLeafTasks: number; | ||
modules?: string[] | undefined; | ||
}[]; | ||
}>; | ||
type GetWorkflowsRes = z$1.infer<typeof getWorkflowsResSchema>; | ||
declare const getWorkflowByIdReqSchema: z$1.ZodObject<{ | ||
workflowId: z$1.ZodString; | ||
}, "strip", z$1.ZodTypeAny, { | ||
workflowId: string; | ||
}, { | ||
workflowId: string; | ||
}>; | ||
declare const getWorkflowByIdResSchema: z$1.ZodObject<{ | ||
workflow: z$1.ZodType<Task, z$1.ZodTypeDef, Task>; | ||
}, "strip", z$1.ZodTypeAny, { | ||
workflow: { | ||
id: string; | ||
status: "Pending"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
} | { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
id: string; | ||
status: "Planning"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program?: string | undefined; | ||
feasibilityCheck?: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
} | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
} | { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
id: string; | ||
status: "Executing"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames: string[]; | ||
} | { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
id: string; | ||
status: "Sequencing"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames?: string[] | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
} | { | ||
type: string[]; | ||
description?: string | undefined; | ||
} | RealUnionJsonSchema | { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
id: string; | ||
status: "Resolved"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
resolutionCheck: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames: string[]; | ||
} | ({ | ||
id: string; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
} & { | ||
status: "Sequenced"; | ||
program: string; | ||
subtasks: Task[]; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames?: string[] | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
}); | ||
}, { | ||
workflow: { | ||
id: string; | ||
status: "Pending"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
} | { | ||
type: "null"; | ||
description?: string | undefined; | ||
id: string; | ||
status: "Planning"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program?: string | undefined; | ||
feasibilityCheck?: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
} | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
} | { | ||
$ref: string; | ||
description?: string | undefined; | ||
})[]) & ({ | ||
type: "object"; | ||
properties: Record<string, ObjectJsonSchema | RecordJsonSchema | ArrayJsonSchema | { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
} | { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
} | { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
} | { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
} | { | ||
type: string[]; | ||
description?: string | undefined; | ||
} | RealUnionJsonSchema | { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
} | { | ||
type: "null"; | ||
description?: string | undefined; | ||
} | { | ||
$ref: string; | ||
description?: string | undefined; | ||
}>; | ||
description?: string | undefined; | ||
required?: string[] | undefined; | ||
} | (ObjectJsonSchema | RecordJsonSchema | ArrayJsonSchema | { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
id: string; | ||
status: "Executing"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames: string[]; | ||
} | { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
id: string; | ||
status: "Sequencing"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames?: string[] | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
} | { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
id: string; | ||
status: "Resolved"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
resolutionCheck: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames: string[]; | ||
} | ({ | ||
id: string; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
} & { | ||
status: "Sequenced"; | ||
program: string; | ||
subtasks: Task[]; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames?: string[] | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
}); | ||
}>; | ||
type GetWorkflowByIdReq = z$1.infer<typeof getWorkflowByIdReqSchema>; | ||
type GetWorkflowByIdRes = z$1.infer<typeof getWorkflowByIdResSchema>; | ||
declare const postWorkflowsReqSchema: z$1.ZodObject<{ | ||
query: z$1.ZodString; | ||
modules: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString, "many">>; | ||
orgId: z$1.ZodOptional<z$1.ZodString>; | ||
}, "strip", z$1.ZodTypeAny, { | ||
query: string; | ||
modules?: string[] | undefined; | ||
orgId?: string | undefined; | ||
}, { | ||
query: string; | ||
modules?: string[] | undefined; | ||
orgId?: string | undefined; | ||
}>; | ||
declare const postWorkflowsResSchema: z$1.ZodObject<{ | ||
message: z$1.ZodString; | ||
workflowId: z$1.ZodString; | ||
}, "strip", z$1.ZodTypeAny, { | ||
message: string; | ||
workflowId: string; | ||
}, { | ||
message: string; | ||
workflowId: string; | ||
}>; | ||
type PostWorkflowsReq = z$1.infer<typeof postWorkflowsReqSchema>; | ||
type PostWorkflowsRes = z$1.infer<typeof postWorkflowsResSchema>; | ||
/** | ||
* Main client | ||
*/ | ||
declare function createWorkflowClient(baseUrl: string, apiKey: string): MappedReturnType<{ | ||
fetchGetWorkflows: typeof fetchGetWorkflows; | ||
fetchGetWorkflowById: typeof fetchGetWorkflowById; | ||
fetchPostWorkflows: typeof fetchPostWorkflows; | ||
}>; | ||
type WorkflowClient = ReturnType<typeof createWorkflowClient>; | ||
declare function fetchGetWorkflows(baseUrl: string, apiKey: string): () => Promise<GetWorkflowsRes>; | ||
declare function fetchGetWorkflowById(baseUrl: string, apiKey: string): (req: GetWorkflowByIdReq) => Promise<GetWorkflowByIdRes>; | ||
declare function fetchPostWorkflows(baseUrl: string, apiKey: string): (req: PostWorkflowsReq) => Promise<PostWorkflowsRes>; | ||
declare const WorkflowStatus: { | ||
readonly Running: "Running"; | ||
readonly Completed: "Completed"; | ||
readonly Failed: "Failed"; | ||
readonly Paused: "Paused"; | ||
readonly TimedOut: "TimedOut"; | ||
}; | ||
type WorkflowStatus = (typeof WorkflowStatus)[keyof typeof WorkflowStatus]; | ||
declare const workflowSchema: z$1.ZodObject<{ | ||
workflowId: z$1.ZodString; | ||
root: z$1.ZodType<Task, z$1.ZodTypeDef, Task>; | ||
modules: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString, "many">>; | ||
createdAt: z$1.ZodString; | ||
updatedAt: z$1.ZodString; | ||
orgId: z$1.ZodString; | ||
}, "strip", z$1.ZodTypeAny, { | ||
workflowId: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
orgId: string; | ||
root: { | ||
id: string; | ||
status: "Pending"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
} | { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
id: string; | ||
status: "Planning"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program?: string | undefined; | ||
feasibilityCheck?: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
} | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
} | { | ||
type: string[]; | ||
description?: string | undefined; | ||
} | RealUnionJsonSchema | { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
id: string; | ||
status: "Executing"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames: string[]; | ||
} | { | ||
type: "null"; | ||
description?: string | undefined; | ||
id: string; | ||
status: "Sequencing"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames?: string[] | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
} | { | ||
$ref: string; | ||
description?: string | undefined; | ||
})[] | undefined); | ||
returns: ObjectJsonSchema | RecordJsonSchema | ArrayJsonSchema | { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
id: string; | ||
status: "Resolved"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
resolutionCheck: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames: string[]; | ||
} | ({ | ||
id: string; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
} & { | ||
status: "Sequenced"; | ||
program: string; | ||
subtasks: Task[]; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames?: string[] | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
}); | ||
modules?: string[] | undefined; | ||
}, { | ||
workflowId: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
orgId: string; | ||
root: { | ||
id: string; | ||
status: "Pending"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
} | { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
id: string; | ||
status: "Planning"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program?: string | undefined; | ||
feasibilityCheck?: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
} | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
} | { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
id: string; | ||
status: "Executing"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames: string[]; | ||
} | { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
id: string; | ||
status: "Sequencing"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames?: string[] | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
} | { | ||
type: string[]; | ||
description?: string | undefined; | ||
} | RealUnionJsonSchema | { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
} | { | ||
type: "null"; | ||
description?: string | undefined; | ||
} | { | ||
$ref: string; | ||
description?: string | undefined; | ||
} | (ObjectJsonSchema & RecordJsonSchema) | (ObjectJsonSchema & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | (ObjectJsonSchema & RealUnionJsonSchema) | (ObjectJsonSchema & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | (RecordJsonSchema & ObjectJsonSchema) | (RecordJsonSchema & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | (RecordJsonSchema & RealUnionJsonSchema) | (RecordJsonSchema & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | (ArrayJsonSchema & { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
}) | (ArrayJsonSchema & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | (ArrayJsonSchema & RealUnionJsonSchema) | (ArrayJsonSchema & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
} & ArrayJsonSchema) | ({ | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
id: string; | ||
status: "Resolved"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
resolutionCheck: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames: string[]; | ||
} | ({ | ||
id: string; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
} & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
} & RealUnionJsonSchema) | ({ | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
} & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
} & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
} & RealUnionJsonSchema) | ({ | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
} & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
} & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
} & RealUnionJsonSchema) | ({ | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
} & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "boolean"; | ||
description?: string | undefined; | ||
} & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "boolean"; | ||
description?: string | undefined; | ||
} & RealUnionJsonSchema) | ({ | ||
type: "boolean"; | ||
description?: string | undefined; | ||
} & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & ObjectJsonSchema) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & RecordJsonSchema) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & ArrayJsonSchema) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
}) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & RealUnionJsonSchema) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & { | ||
type: "null"; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | (RealUnionJsonSchema & ObjectJsonSchema) | (RealUnionJsonSchema & RecordJsonSchema) | (RealUnionJsonSchema & ArrayJsonSchema) | (RealUnionJsonSchema & { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
}) | (RealUnionJsonSchema & { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
}) | (RealUnionJsonSchema & { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
}) | (RealUnionJsonSchema & { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
}) | (RealUnionJsonSchema & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | (RealUnionJsonSchema & { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
}) | (RealUnionJsonSchema & { | ||
type: "null"; | ||
description?: string | undefined; | ||
}) | (RealUnionJsonSchema & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "unknown"; | ||
description?: string | undefined; | ||
} & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "unknown"; | ||
description?: string | undefined; | ||
} & RealUnionJsonSchema) | ({ | ||
type: "unknown"; | ||
description?: string | undefined; | ||
} & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "null"; | ||
description?: string | undefined; | ||
} & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "null"; | ||
description?: string | undefined; | ||
} & RealUnionJsonSchema) | ({ | ||
type: "null"; | ||
description?: string | undefined; | ||
} & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & ObjectJsonSchema) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & RecordJsonSchema) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & ArrayJsonSchema) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
}) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
}) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
}) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
}) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & RealUnionJsonSchema) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
}) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & { | ||
type: "null"; | ||
description?: string | undefined; | ||
status: "Sequenced"; | ||
program: string; | ||
subtasks: Task[]; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames?: string[] | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
}); | ||
usageExample?: string | undefined; | ||
returnsExample?: string | undefined; | ||
modules?: string[] | undefined; | ||
}>; | ||
type Workflow = z$1.infer<typeof workflowSchema>; | ||
declare const workflowInfoSchema: z$1.ZodObject<{ | ||
workflowId: z$1.ZodString; | ||
modules: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString, "many">>; | ||
createdAt: z$1.ZodString; | ||
updatedAt: z$1.ZodString; | ||
description: z$1.ZodString; | ||
status: z$1.ZodNativeEnum<{ | ||
readonly Running: "Running"; | ||
readonly Completed: "Completed"; | ||
readonly Failed: "Failed"; | ||
readonly Paused: "Paused"; | ||
readonly TimedOut: "TimedOut"; | ||
}>; | ||
numLeafTasks: z$1.ZodNumber; | ||
}, "strip", z$1.ZodTypeAny, { | ||
status: "Running" | "Completed" | "Failed" | "Paused" | "TimedOut"; | ||
workflowId: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
description: string; | ||
numLeafTasks: number; | ||
modules?: string[] | undefined; | ||
}, { | ||
name: string; | ||
status: "Running" | "Completed" | "Failed" | "Paused" | "TimedOut"; | ||
workflowId: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
description: string; | ||
parameters: ({ | ||
type: "object"; | ||
properties: Record<string, ObjectJsonSchema | RecordJsonSchema | ArrayJsonSchema | { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
numLeafTasks: number; | ||
modules?: string[] | undefined; | ||
}>; | ||
type WorkflowInfo = z$1.infer<typeof workflowInfoSchema>; | ||
declare function createClient(baseUrl: string, apiKey: string): { | ||
fetchGetWorkflows: () => Promise<{ | ||
workflowInfos: { | ||
status: "Running" | "Completed" | "Failed" | "Paused" | "TimedOut"; | ||
workflowId: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
description: string; | ||
numLeafTasks: number; | ||
modules?: string[] | undefined; | ||
}[]; | ||
}>; | ||
fetchGetWorkflowById: (req: { | ||
workflowId: string; | ||
}) => Promise<{ | ||
workflow: { | ||
id: string; | ||
status: "Pending"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
} | { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
id: string; | ||
status: "Planning"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program?: string | undefined; | ||
feasibilityCheck?: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
} | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
} | { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
id: string; | ||
status: "Executing"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames: string[]; | ||
} | { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
id: string; | ||
status: "Sequencing"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames?: string[] | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
} | { | ||
type: string[]; | ||
description?: string | undefined; | ||
} | RealUnionJsonSchema | { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
} | { | ||
type: "null"; | ||
description?: string | undefined; | ||
} | { | ||
$ref: string; | ||
description?: string | undefined; | ||
}>; | ||
id: string; | ||
status: "Resolved"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
program: string; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
resolutionCheck: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames: string[]; | ||
} | ({ | ||
id: string; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
} & { | ||
status: "Sequenced"; | ||
program: string; | ||
subtasks: Task[]; | ||
feasibilityCheck: { | ||
feasibility: "Feasible" | "Rewritable" | "Infeasible"; | ||
reason: string; | ||
fix?: string | undefined; | ||
}; | ||
usedFunctionNames?: string[] | undefined; | ||
resolutionCheck?: { | ||
reason: string; | ||
resolution: "Resolved" | "Rewritable" | "Infeasible"; | ||
fix?: string | undefined; | ||
} | undefined; | ||
}); | ||
}>; | ||
fetchPostWorkflows: (req: { | ||
query: string; | ||
modules?: string[] | undefined; | ||
orgId?: string | undefined; | ||
}) => Promise<{ | ||
message: string; | ||
workflowId: string; | ||
}>; | ||
returnFunctionCall: (functionCallId: string, functionReturn: string) => Promise<void>; | ||
nextMessage: (workflowId: string) => Promise<NextMessageRes>; | ||
startWorkflow: (query: string, modules?: string | undefined) => Promise<StartWorkflowRes>; | ||
putFunctionJsons: (jsons: { | ||
name: string; | ||
description?: string | undefined; | ||
required?: string[] | undefined; | ||
} | (ObjectJsonSchema | RecordJsonSchema | ArrayJsonSchema | { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
} | { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
} | { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
} | { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
} | { | ||
type: string[]; | ||
description?: string | undefined; | ||
} | RealUnionJsonSchema | { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
} | { | ||
type: "null"; | ||
description?: string | undefined; | ||
} | { | ||
$ref: string; | ||
description?: string | undefined; | ||
})[]) & ({ | ||
type: "object"; | ||
properties: Record<string, ObjectJsonSchema | RecordJsonSchema | ArrayJsonSchema | { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
} | { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
} | { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
} | { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
} | { | ||
type: string[]; | ||
description?: string | undefined; | ||
} | RealUnionJsonSchema | { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
} | { | ||
type: "null"; | ||
description?: string | undefined; | ||
} | { | ||
$ref: string; | ||
description?: string | undefined; | ||
}>; | ||
description?: string | undefined; | ||
required?: string[] | undefined; | ||
} | (ObjectJsonSchema | RecordJsonSchema | ArrayJsonSchema | { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
} | { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
} | { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
} | { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
} | { | ||
type: string[]; | ||
description?: string | undefined; | ||
} | RealUnionJsonSchema | { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
} | { | ||
type: "null"; | ||
description?: string | undefined; | ||
} | { | ||
$ref: string; | ||
description?: string | undefined; | ||
})[] | undefined); | ||
returns: ObjectJsonSchema | RecordJsonSchema | ArrayJsonSchema | { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
} | { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
} | { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
} | { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
} | { | ||
type: string[]; | ||
description?: string | undefined; | ||
} | RealUnionJsonSchema | { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
} | { | ||
type: "null"; | ||
description?: string | undefined; | ||
} | { | ||
$ref: string; | ||
description?: string | undefined; | ||
} | (ObjectJsonSchema & RecordJsonSchema) | (ObjectJsonSchema & RealUnionJsonSchema) | (RecordJsonSchema & ObjectJsonSchema) | (RecordJsonSchema & RealUnionJsonSchema) | (ArrayJsonSchema & RealUnionJsonSchema) | (RealUnionJsonSchema & ObjectJsonSchema) | (RealUnionJsonSchema & RecordJsonSchema) | (RealUnionJsonSchema & ArrayJsonSchema) | (ObjectJsonSchema & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | (ObjectJsonSchema & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | (RecordJsonSchema & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | (RecordJsonSchema & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | (ArrayJsonSchema & { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
}) | (ArrayJsonSchema & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | (ArrayJsonSchema & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
} & ArrayJsonSchema) | ({ | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
} & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
} & RealUnionJsonSchema) | ({ | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
} & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
} & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
} & RealUnionJsonSchema) | ({ | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
} & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
} & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
} & RealUnionJsonSchema) | ({ | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
} & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "boolean"; | ||
description?: string | undefined; | ||
} & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "boolean"; | ||
description?: string | undefined; | ||
} & RealUnionJsonSchema) | ({ | ||
type: "boolean"; | ||
description?: string | undefined; | ||
} & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & ObjectJsonSchema) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & RecordJsonSchema) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & ArrayJsonSchema) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
}) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & RealUnionJsonSchema) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & { | ||
type: "null"; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: string[]; | ||
description?: string | undefined; | ||
} & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | (RealUnionJsonSchema & { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
}) | (RealUnionJsonSchema & { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
}) | (RealUnionJsonSchema & { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
}) | (RealUnionJsonSchema & { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
}) | (RealUnionJsonSchema & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | (RealUnionJsonSchema & { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
}) | (RealUnionJsonSchema & { | ||
type: "null"; | ||
description?: string | undefined; | ||
}) | (RealUnionJsonSchema & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "unknown"; | ||
description?: string | undefined; | ||
} & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "unknown"; | ||
description?: string | undefined; | ||
} & RealUnionJsonSchema) | ({ | ||
type: "unknown"; | ||
description?: string | undefined; | ||
} & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "null"; | ||
description?: string | undefined; | ||
} & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | ({ | ||
type: "null"; | ||
description?: string | undefined; | ||
} & RealUnionJsonSchema) | ({ | ||
type: "null"; | ||
description?: string | undefined; | ||
} & { | ||
$ref: string; | ||
description?: string | undefined; | ||
}) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & ObjectJsonSchema) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & RecordJsonSchema) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & ArrayJsonSchema) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & { | ||
type: "array"; | ||
prefixItems: string[]; | ||
description?: string | undefined; | ||
}) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & { | ||
type: "string"; | ||
enum?: string[] | undefined; | ||
description?: string | undefined; | ||
}) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & { | ||
type: "number" | "integer"; | ||
description?: string | undefined; | ||
minimum?: number | undefined; | ||
maximum?: number | undefined; | ||
}) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & { | ||
type: "boolean"; | ||
description?: string | undefined; | ||
}) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & { | ||
type: string[]; | ||
description?: string | undefined; | ||
}) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & RealUnionJsonSchema) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & { | ||
type: "unknown"; | ||
description?: string | undefined; | ||
}) | ({ | ||
$ref: string; | ||
description?: string | undefined; | ||
} & { | ||
type: "null"; | ||
description?: string | undefined; | ||
}); | ||
usageExample?: string | undefined; | ||
returnsExample?: string | undefined; | ||
}>; | ||
type FunctionJson = z.infer<typeof functionJsonSchema>; | ||
declare const nullFunctionJson: FunctionJson; | ||
parameters?: Record<string, any> | undefined; | ||
returns?: Record<string, any> | undefined; | ||
usageExample?: string | undefined; | ||
returnsExample?: string | undefined; | ||
}[], module?: string | undefined) => Promise<void>; | ||
}; | ||
@@ -1585,2 +1532,4 @@ declare const DEFAULT_BASE_URL = "https://api.iudex.ai"; | ||
maxTries: number; | ||
client: ReturnType<typeof createClient>; | ||
currentWorkflowId?: Promise<string>; | ||
functionLinker?: (fnName: string) => (...args: any[]) => unknown; | ||
@@ -1592,3 +1541,3 @@ constructor({ apiKey, baseUrl, maxTries, }?: { | ||
}); | ||
uploadFunctions: (jsons: Array<OpenAI.ChatCompletionCreateParams.Function | FunctionJson>, modules?: string) => Promise<void>; | ||
uploadFunctions: (jsons: Array<OpenAI.ChatCompletionCreateParams.Function | FunctionJson$1>, modules?: string) => Promise<void>; | ||
linkFunctions: (functionLinker: (fnName: string) => (...args: any[]) => unknown) => void; | ||
@@ -1608,2 +1557,3 @@ /** | ||
sendMessage: (message: string) => Promise<string>; | ||
streamCurrentTask(): AsyncGenerator<Task>; | ||
chatCompletionsCreate: (body: OpenAI.ChatCompletionCreateParamsNonStreaming & { | ||
@@ -1628,3 +1578,7 @@ messages: Array<ChatCompletionMessageWithIudex>; | ||
declare function extractMessageTextContent(content: OpenAI.ChatCompletionUserMessageParam['content']): string; | ||
declare function getLastTaskByStatus<Statuses extends TaskStatus | TaskStatus[]>(root: Task, status: Statuses): TaskStatusesToType<Statuses> | undefined; | ||
declare function getFirstTaskByStatus<S extends TaskStatus | TaskStatus[]>(root: Task, status: S | S[]): TaskStatusesToType<S | S[]> | undefined; | ||
declare function reversePreOrderTraversal<T>(getChildren: (node: T) => T[], predicate: (node: T) => boolean): (node: T) => T | undefined; | ||
declare function preOrderTraversal<T>(getChildren: (node: T) => T[], predicate: (node: T) => boolean): (node: T) => T | undefined; | ||
export { type ChatCompletionMessageWithIudex, type ChatCompletionWithIudex, DEFAULT_BASE_URL, type FunctionJson, Iudex, type IudexMessage, type NextMessageRes, type ObjectJsonSchema, type ReturnFunctionCallBody, type ReturnFunctionCallRes, type StartWorkflowRes, type ValueJsonSchema, Iudex as default, extractMessageTextContent, functionJsonSchema, mapIudexToOpenAi, nextMessage, nullFunctionJson, putFunctionJsons, type putFunctionJsonsReq, returnFunctionCall, startWorkflow }; | ||
export { type BaseTask, type ChatCompletionMessageWithIudex, type ChatCompletionWithIudex, type ChatError, type ChatFunctionCall, type ChatFunctionReturn, type ChatImage, type ChatList, type ChatText, type ChatTurn, type ChatTurnType, type ChatTurnUnion, DEFAULT_BASE_URL, Feasibility, type FeasibilityCheck, type GetWorkflowByIdReq, type GetWorkflowByIdRes, type GetWorkflowsRes, Iudex, type IudexMessage, type NextMessageRes, type PostWorkflowsReq, type PostWorkflowsRes, Resolution, type ResolutionCheck, type ReturnFunctionCallBody, type ReturnFunctionCallRes, type StartWorkflowRes, type Task, type TaskExecuting, type TaskPending, type TaskPlanning, type TaskResolved, type TaskSequenced, type TaskSequencing, TaskStatus, type TaskStatusToType, type TaskStatusesToType, type Workflow, type WorkflowClient, type WorkflowInfo, WorkflowStatus, baseTaskSchema, chatErrorSchema, chatFunctionCallSchema, chatFunctionReturnSchema, chatImageSchema, chatListSchema, chatTextSchema, chatTurnSchema, createClient, createFunctionClient, createWorkflowClient, extractMessageTextContent, feasibilityCheckSchema, fetchGetWorkflowById, fetchGetWorkflows, fetchPostWorkflows, getFirstTaskByStatus, getLastTaskByStatus, getWorkflowByIdReqSchema, getWorkflowByIdResSchema, getWorkflowsResSchema, mapIudexToOpenAi, nextMessage, postWorkflowsReqSchema, postWorkflowsResSchema, preOrderTraversal, putFunctionJsons, type putFunctionJsonsReq, resolutionCheckSchema, returnFunctionCall, reversePreOrderTraversal, startWorkflow, taskExecutingSchema, taskPendingSchema, taskPlanningSchema, taskResolvedSchema, taskSchema, taskSequencedSchema, taskSequencingSchema, workflowInfoSchema, workflowSchema }; |
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
@@ -18,2 +20,11 @@ var __export = (target, all) => { | ||
}; | ||
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")); | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
@@ -25,16 +36,229 @@ | ||
DEFAULT_BASE_URL: () => DEFAULT_BASE_URL, | ||
Feasibility: () => Feasibility, | ||
Iudex: () => Iudex, | ||
default: () => src_default, | ||
Resolution: () => Resolution, | ||
TaskStatus: () => TaskStatus, | ||
WorkflowStatus: () => WorkflowStatus, | ||
baseTaskSchema: () => baseTaskSchema, | ||
chatErrorSchema: () => chatErrorSchema, | ||
chatFunctionCallSchema: () => chatFunctionCallSchema, | ||
chatFunctionReturnSchema: () => chatFunctionReturnSchema, | ||
chatImageSchema: () => chatImageSchema, | ||
chatListSchema: () => chatListSchema, | ||
chatTextSchema: () => chatTextSchema, | ||
chatTurnSchema: () => chatTurnSchema, | ||
createClient: () => createClient, | ||
createFunctionClient: () => createFunctionClient, | ||
createWorkflowClient: () => createWorkflowClient, | ||
extractMessageTextContent: () => extractMessageTextContent, | ||
functionJsonSchema: () => functionJsonSchema, | ||
feasibilityCheckSchema: () => feasibilityCheckSchema, | ||
fetchGetWorkflowById: () => fetchGetWorkflowById, | ||
fetchGetWorkflows: () => fetchGetWorkflows, | ||
fetchPostWorkflows: () => fetchPostWorkflows, | ||
getFirstTaskByStatus: () => getFirstTaskByStatus, | ||
getLastTaskByStatus: () => getLastTaskByStatus, | ||
getWorkflowByIdReqSchema: () => getWorkflowByIdReqSchema, | ||
getWorkflowByIdResSchema: () => getWorkflowByIdResSchema, | ||
getWorkflowsResSchema: () => getWorkflowsResSchema, | ||
mapIudexToOpenAi: () => mapIudexToOpenAi, | ||
nextMessage: () => nextMessage, | ||
nullFunctionJson: () => nullFunctionJson, | ||
postWorkflowsReqSchema: () => postWorkflowsReqSchema, | ||
postWorkflowsResSchema: () => postWorkflowsResSchema, | ||
preOrderTraversal: () => preOrderTraversal, | ||
putFunctionJsons: () => putFunctionJsons, | ||
resolutionCheckSchema: () => resolutionCheckSchema, | ||
returnFunctionCall: () => returnFunctionCall, | ||
startWorkflow: () => startWorkflow | ||
reversePreOrderTraversal: () => reversePreOrderTraversal, | ||
startWorkflow: () => startWorkflow, | ||
taskExecutingSchema: () => taskExecutingSchema, | ||
taskPendingSchema: () => taskPendingSchema, | ||
taskPlanningSchema: () => taskPlanningSchema, | ||
taskResolvedSchema: () => taskResolvedSchema, | ||
taskSchema: () => taskSchema, | ||
taskSequencedSchema: () => taskSequencedSchema, | ||
taskSequencingSchema: () => taskSequencingSchema, | ||
workflowInfoSchema: () => workflowInfoSchema, | ||
workflowSchema: () => workflowSchema | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
__reExport(src_exports, require("function-json-schema"), module.exports); | ||
// src/client.ts | ||
// src/utils.ts | ||
function setTimeoutPromise(ms) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} | ||
function poll(fn, args, { | ||
maxTries, | ||
tries, | ||
waitMs | ||
} = { maxTries: 60, tries: 0, waitMs: 1e3 }) { | ||
if (tries >= maxTries) { | ||
throw Error( | ||
`Polling failed after ${maxTries} tries for function ${fn.name}.` | ||
); | ||
} | ||
return fn(...args).then((res) => { | ||
if (res == null) { | ||
return setTimeoutPromise(waitMs).then(() => poll(fn, args, { maxTries, tries: tries + 1, waitMs })); | ||
} | ||
return res; | ||
}); | ||
} | ||
function deconstructedPromise() { | ||
let promiseResolve; | ||
let promiseReject; | ||
const promise = new Promise((resolve, reject) => { | ||
promiseResolve = resolve; | ||
promiseReject = reject; | ||
}); | ||
return { | ||
promise, | ||
resolve: promiseResolve, | ||
reject: promiseReject | ||
}; | ||
} | ||
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isPlaceholder.js | ||
function _isPlaceholder(a) { | ||
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true; | ||
} | ||
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry1.js | ||
function _curry1(fn) { | ||
return function f1(a) { | ||
if (arguments.length === 0 || _isPlaceholder(a)) { | ||
return f1; | ||
} else { | ||
return fn.apply(this, arguments); | ||
} | ||
}; | ||
} | ||
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_curry2.js | ||
function _curry2(fn) { | ||
return function f2(a, b) { | ||
switch (arguments.length) { | ||
case 0: | ||
return f2; | ||
case 1: | ||
return _isPlaceholder(a) ? f2 : _curry1(function(_b) { | ||
return fn(a, _b); | ||
}); | ||
default: | ||
return _isPlaceholder(a) && _isPlaceholder(b) ? f2 : _isPlaceholder(a) ? _curry1(function(_a) { | ||
return fn(_a, b); | ||
}) : _isPlaceholder(b) ? _curry1(function(_b) { | ||
return fn(a, _b); | ||
}) : fn(a, b); | ||
} | ||
}; | ||
} | ||
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArray.js | ||
var isArray_default = Array.isArray || function _isArray(val) { | ||
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]"; | ||
}; | ||
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_has.js | ||
function _has(prop, obj) { | ||
return Object.prototype.hasOwnProperty.call(obj, prop); | ||
} | ||
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isArguments.js | ||
var toString = Object.prototype.toString; | ||
var _isArguments = /* @__PURE__ */ function() { | ||
return toString.call(arguments) === "[object Arguments]" ? function _isArguments2(x) { | ||
return toString.call(x) === "[object Arguments]"; | ||
} : function _isArguments2(x) { | ||
return _has("callee", x); | ||
}; | ||
}(); | ||
var isArguments_default = _isArguments; | ||
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/keys.js | ||
var hasEnumBug = !/* @__PURE__ */ { | ||
toString: null | ||
}.propertyIsEnumerable("toString"); | ||
var nonEnumerableProps = ["constructor", "valueOf", "isPrototypeOf", "toString", "propertyIsEnumerable", "hasOwnProperty", "toLocaleString"]; | ||
var hasArgsEnumBug = /* @__PURE__ */ function() { | ||
"use strict"; | ||
return arguments.propertyIsEnumerable("length"); | ||
}(); | ||
var contains = function contains2(list, item) { | ||
var idx = 0; | ||
while (idx < list.length) { | ||
if (list[idx] === item) { | ||
return true; | ||
} | ||
idx += 1; | ||
} | ||
return false; | ||
}; | ||
var keys = typeof Object.keys === "function" && !hasArgsEnumBug ? /* @__PURE__ */ _curry1(function keys2(obj) { | ||
return Object(obj) !== obj ? [] : Object.keys(obj); | ||
}) : /* @__PURE__ */ _curry1(function keys3(obj) { | ||
if (Object(obj) !== obj) { | ||
return []; | ||
} | ||
var prop, nIdx; | ||
var ks = []; | ||
var checkArgsLength = hasArgsEnumBug && isArguments_default(obj); | ||
for (prop in obj) { | ||
if (_has(prop, obj) && (!checkArgsLength || prop !== "length")) { | ||
ks[ks.length] = prop; | ||
} | ||
} | ||
if (hasEnumBug) { | ||
nIdx = nonEnumerableProps.length - 1; | ||
while (nIdx >= 0) { | ||
prop = nonEnumerableProps[nIdx]; | ||
if (_has(prop, obj) && !contains(ks, prop)) { | ||
ks[ks.length] = prop; | ||
} | ||
nIdx -= 1; | ||
} | ||
} | ||
return ks; | ||
}); | ||
var keys_default = keys; | ||
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_toISOString.js | ||
var pad = function pad2(n) { | ||
return (n < 10 ? "0" : "") + n; | ||
}; | ||
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) { | ||
return d.toISOString(); | ||
} : function _toISOString3(d) { | ||
return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds()) + "." + (d.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5) + "Z"; | ||
}; | ||
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_arrayReduce.js | ||
function _arrayReduce(reducer, acc, list) { | ||
var index = 0; | ||
var length = list.length; | ||
while (index < length) { | ||
acc = reducer(acc, list[index]); | ||
index += 1; | ||
} | ||
return acc; | ||
} | ||
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/internal/_isInteger.js | ||
var isInteger_default = Number.isInteger || function _isInteger(n) { | ||
return n << 0 === n; | ||
}; | ||
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/mapObjIndexed.js | ||
var mapObjIndexed = /* @__PURE__ */ _curry2(function mapObjIndexed2(fn, obj) { | ||
return _arrayReduce(function(acc, key) { | ||
acc[key] = fn(obj[key], key, obj); | ||
return acc; | ||
}, {}, keys_default(obj)); | ||
}); | ||
var mapObjIndexed_default = mapObjIndexed; | ||
// ../../node_modules/.pnpm/ramda@0.29.0/node_modules/ramda/es/trim.js | ||
var hasProtoTrim = typeof String.prototype.trim === "function"; | ||
// src/clients/function-client.ts | ||
function checkResponse(r) { | ||
@@ -71,2 +295,11 @@ if (!r.ok) { | ||
} | ||
function createFunctionClient(baseUrl, apiKey) { | ||
const fns = { | ||
returnFunctionCall, | ||
nextMessage, | ||
startWorkflow, | ||
putFunctionJsons | ||
}; | ||
return mapObjIndexed_default((fn) => fn(baseUrl, apiKey), fns); | ||
} | ||
function returnFunctionCall(baseUrl, apiKey) { | ||
@@ -113,120 +346,248 @@ return function(functionCallId, functionReturn) { | ||
// src/utils.ts | ||
function setTimeoutPromise(ms) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
// src/clients/workflow-client.ts | ||
function createWorkflowClient(baseUrl, apiKey) { | ||
const fns = { | ||
fetchGetWorkflows, | ||
fetchGetWorkflowById, | ||
fetchPostWorkflows | ||
}; | ||
return mapObjIndexed_default((fn) => fn(baseUrl, apiKey), fns); | ||
} | ||
function poll(fn, args, { | ||
maxTries, | ||
tries, | ||
waitMs | ||
} = { maxTries: 60, tries: 0, waitMs: 1e3 }) { | ||
if (tries >= maxTries) { | ||
throw Error( | ||
`Polling failed after ${maxTries} tries for function ${fn.name}.` | ||
); | ||
async function checkResponseStatus(res) { | ||
const body = await res.json(); | ||
if (!res.ok) { | ||
const error = body.error || res.statusText; | ||
throw new Error(`Request failed with: ${error}`); | ||
} | ||
return fn(...args).then((res) => { | ||
if (res == null) { | ||
return setTimeoutPromise(waitMs).then(() => poll(fn, args, { maxTries, tries: tries + 1, waitMs })); | ||
} | ||
return res; | ||
}); | ||
return body; | ||
} | ||
function fetchGetWorkflows(baseUrl, apiKey) { | ||
return function() { | ||
return fetch(`${baseUrl}/workflows`, { | ||
method: "GET", | ||
headers: { "x-api-key": apiKey } | ||
}).then(checkResponseStatus); | ||
}; | ||
} | ||
function fetchGetWorkflowById(baseUrl, apiKey) { | ||
return function(req) { | ||
return fetch(`${baseUrl}/workflows/${req.workflowId}`, { | ||
method: "GET", | ||
headers: { "x-api-key": apiKey } | ||
}).then(checkResponseStatus); | ||
}; | ||
} | ||
function fetchPostWorkflows(baseUrl, apiKey) { | ||
return function(req) { | ||
return fetch(`${baseUrl}/workflows`, { | ||
method: "POST", | ||
body: JSON.stringify(req), | ||
headers: { "x-api-key": apiKey } | ||
}).then(checkResponseStatus); | ||
}; | ||
} | ||
// src/function-types.ts | ||
var import_zod = require("zod"); | ||
var objectJsonSchema = import_zod.z.object({ | ||
type: import_zod.z.literal("object"), | ||
properties: import_zod.z.record(import_zod.z.lazy(() => valueJsonSchema)), | ||
description: import_zod.z.string().optional(), | ||
required: import_zod.z.array(import_zod.z.string()).optional() | ||
// src/clients/workflow-schemas.ts | ||
var import_zod3 = __toESM(require("zod")); | ||
// src/types/task-types.ts | ||
var import_zod = __toESM(require("zod")); | ||
var TaskStatus = { | ||
// Queued state | ||
Pending: "Pending", | ||
// awaiting processing | ||
// Processing states | ||
Planning: "Planning", | ||
// in programmer | ||
Executing: "Executing", | ||
// in executor | ||
Sequencing: "Sequencing", | ||
// in sequencer | ||
// Terminal states | ||
Resolved: "Resolved", | ||
// execution resolved task | ||
Sequenced: "Sequenced" | ||
// no resolution; sequuencer created subtasks | ||
}; | ||
var baseTaskSchema = import_zod.default.object({ | ||
id: import_zod.default.string(), | ||
description: import_zod.default.string(), | ||
status: import_zod.default.nativeEnum(TaskStatus), | ||
stepIndex: import_zod.default.number(), | ||
depth: import_zod.default.number(), | ||
numRewrites: import_zod.default.number() | ||
}); | ||
var recordJsonSchema = import_zod.z.object({ | ||
type: import_zod.z.literal("object"), | ||
additionalProperties: import_zod.z.lazy(() => valueJsonSchema), | ||
description: import_zod.z.string().optional() | ||
var Feasibility = { | ||
Feasible: "Feasible", | ||
Rewritable: "Rewritable", | ||
Infeasible: "Infeasible" | ||
}; | ||
var feasibilityCheckSchema = import_zod.default.object({ | ||
feasibility: import_zod.default.nativeEnum(Feasibility), | ||
reason: import_zod.default.coerce.string(), | ||
fix: import_zod.default.string().optional() | ||
}); | ||
var arrayJsonSchema = import_zod.z.object({ | ||
type: import_zod.z.literal("array"), | ||
items: import_zod.z.lazy(() => valueJsonSchema), | ||
description: import_zod.z.string().optional() | ||
var Resolution = { | ||
Resolved: "Resolved", | ||
Rewritable: "Rewritable", | ||
Infeasible: "Infeasible" | ||
}; | ||
var resolutionCheckSchema = import_zod.default.object({ | ||
resolution: import_zod.default.nativeEnum(Resolution), | ||
reason: import_zod.default.coerce.string(), | ||
fix: import_zod.default.string().optional() | ||
}); | ||
var tupleJsonSchema = import_zod.z.object({ | ||
type: import_zod.z.literal("array"), | ||
prefixItems: import_zod.z.array(import_zod.z.string()), | ||
description: import_zod.z.string().optional() | ||
var taskPendingSchema = baseTaskSchema.extend({ | ||
status: import_zod.default.literal(TaskStatus.Pending) | ||
}); | ||
var stringJsonSchema = import_zod.z.object({ | ||
type: import_zod.z.literal("string"), | ||
enum: import_zod.z.array(import_zod.z.string()).optional(), | ||
description: import_zod.z.string().optional() | ||
var taskPlanningSchema = baseTaskSchema.extend({ | ||
status: import_zod.default.literal(TaskStatus.Planning), | ||
// present if rewriting | ||
program: import_zod.default.string().optional(), | ||
feasibilityCheck: feasibilityCheckSchema.optional(), | ||
// present if rewriting from executor | ||
resolutionCheck: resolutionCheckSchema.optional() | ||
}); | ||
var numberJsonSchema = import_zod.z.object({ | ||
type: import_zod.z.union([import_zod.z.literal("number"), import_zod.z.literal("integer")]), | ||
description: import_zod.z.string().optional(), | ||
minimum: import_zod.z.number().optional(), | ||
maximum: import_zod.z.number().optional() | ||
var taskExecutingSchema = baseTaskSchema.extend({ | ||
status: import_zod.default.literal(TaskStatus.Executing), | ||
program: import_zod.default.string(), | ||
usedFunctionNames: import_zod.default.array(import_zod.default.string()), | ||
feasibilityCheck: feasibilityCheckSchema | ||
}); | ||
var booleanJsonSchema = import_zod.z.object({ | ||
type: import_zod.z.literal("boolean"), | ||
description: import_zod.z.string().optional() | ||
var taskResolvedSchema = baseTaskSchema.extend({ | ||
status: import_zod.default.literal(TaskStatus.Resolved), | ||
program: import_zod.default.string(), | ||
usedFunctionNames: import_zod.default.array(import_zod.default.string()), | ||
feasibilityCheck: feasibilityCheckSchema, | ||
resolutionCheck: resolutionCheckSchema | ||
}); | ||
var unionJsonSchema = import_zod.z.object({ | ||
type: import_zod.z.array(import_zod.z.string()), | ||
description: import_zod.z.string().optional() | ||
var taskSequencingSchema = baseTaskSchema.extend({ | ||
status: import_zod.default.literal(TaskStatus.Sequencing), | ||
program: import_zod.default.string(), | ||
feasibilityCheck: feasibilityCheckSchema, | ||
// present if sequencing from executor | ||
usedFunctionNames: import_zod.default.array(import_zod.default.string()).optional(), | ||
resolutionCheck: resolutionCheckSchema.optional() | ||
}); | ||
var realUnionJsonSchema = import_zod.z.object({ | ||
anyOf: import_zod.z.array(import_zod.z.lazy(() => valueJsonSchema)), | ||
description: import_zod.z.string().optional() | ||
var taskSequencedSchema = baseTaskSchema.extend({ | ||
status: import_zod.default.literal(TaskStatus.Sequenced), | ||
program: import_zod.default.string(), | ||
subtasks: import_zod.default.lazy(() => taskSchema.array()), | ||
feasibilityCheck: feasibilityCheckSchema, | ||
usedFunctionNames: import_zod.default.array(import_zod.default.string()).optional(), | ||
resolutionCheck: resolutionCheckSchema.optional() | ||
}); | ||
var unknownJsonSchema = import_zod.z.object({ | ||
type: import_zod.z.literal("unknown"), | ||
description: import_zod.z.string().optional() | ||
var taskSchema = import_zod.default.union([ | ||
taskPendingSchema, | ||
taskPlanningSchema, | ||
taskExecutingSchema, | ||
taskResolvedSchema, | ||
taskSequencingSchema, | ||
taskSequencedSchema | ||
]); | ||
// src/types/workflow-types.ts | ||
var import_zod2 = __toESM(require("zod")); | ||
var WorkflowStatus = { | ||
Running: "Running", | ||
Completed: "Completed", | ||
Failed: "Failed", | ||
Paused: "Paused", | ||
TimedOut: "TimedOut" | ||
}; | ||
var workflowSchema = import_zod2.default.object({ | ||
workflowId: import_zod2.default.string(), | ||
root: taskSchema, | ||
modules: import_zod2.default.array(import_zod2.default.string()).optional(), | ||
createdAt: import_zod2.default.string(), | ||
updatedAt: import_zod2.default.string(), | ||
orgId: import_zod2.default.string() | ||
}); | ||
var nullJsonSchema = import_zod.z.object({ | ||
type: import_zod.z.literal("null"), | ||
description: import_zod.z.string().optional() | ||
var workflowInfoSchema = import_zod2.default.object({ | ||
workflowId: import_zod2.default.string(), | ||
modules: import_zod2.default.array(import_zod2.default.string()).optional(), | ||
createdAt: import_zod2.default.string(), | ||
updatedAt: import_zod2.default.string(), | ||
// Task summary | ||
description: import_zod2.default.string(), | ||
status: import_zod2.default.nativeEnum(WorkflowStatus), | ||
numLeafTasks: import_zod2.default.number() | ||
}); | ||
var refJsonSchema = import_zod.z.object({ | ||
$ref: import_zod.z.string(), | ||
description: import_zod.z.string().optional() | ||
// src/clients/workflow-schemas.ts | ||
var getWorkflowsResSchema = import_zod3.default.object({ | ||
workflowInfos: import_zod3.default.array(workflowInfoSchema) | ||
}); | ||
var valueJsonSchema = import_zod.z.union([ | ||
objectJsonSchema, | ||
recordJsonSchema, | ||
arrayJsonSchema, | ||
tupleJsonSchema, | ||
stringJsonSchema, | ||
numberJsonSchema, | ||
booleanJsonSchema, | ||
unionJsonSchema, | ||
realUnionJsonSchema, | ||
unknownJsonSchema, | ||
nullJsonSchema, | ||
refJsonSchema | ||
]); | ||
var functionJsonSchema = import_zod.z.object({ | ||
name: import_zod.z.string(), | ||
description: import_zod.z.string(), | ||
parameters: import_zod.z.union([ | ||
import_zod.z.object({ | ||
type: import_zod.z.literal("object"), | ||
properties: import_zod.z.record(valueJsonSchema), | ||
description: import_zod.z.string().optional(), | ||
required: import_zod.z.array(import_zod.z.string()).optional() | ||
}), | ||
import_zod.z.array(valueJsonSchema) | ||
]), | ||
returns: valueJsonSchema, | ||
usageExample: import_zod.z.string().optional(), | ||
returnsExample: import_zod.z.string().optional() | ||
var getWorkflowByIdReqSchema = import_zod3.default.object({ | ||
workflowId: import_zod3.default.string() | ||
}); | ||
var nullFunctionJson = { | ||
name: "", | ||
description: "", | ||
parameters: [], | ||
returns: { type: "null" } | ||
}; | ||
var getWorkflowByIdResSchema = import_zod3.default.object({ | ||
workflow: taskSchema | ||
// root task | ||
}); | ||
var postWorkflowsReqSchema = import_zod3.default.object({ | ||
query: import_zod3.default.string(), | ||
modules: import_zod3.default.array(import_zod3.default.string()).optional(), | ||
orgId: import_zod3.default.string().optional() | ||
}); | ||
var postWorkflowsResSchema = import_zod3.default.object({ | ||
message: import_zod3.default.string(), | ||
workflowId: import_zod3.default.string() | ||
}); | ||
// src/types/chat-types.ts | ||
var import_zod4 = require("zod"); | ||
var chatTurnBaseSchema = import_zod4.z.object({ | ||
id: import_zod4.z.string(), | ||
type: import_zod4.z.string(), | ||
sender: import_zod4.z.string(), | ||
timestamp: import_zod4.z.string() | ||
}); | ||
var chatTextSchema = chatTurnBaseSchema.extend({ | ||
type: import_zod4.z.literal("text"), | ||
text: import_zod4.z.string() | ||
}); | ||
var chatErrorSchema = chatTurnBaseSchema.extend({ | ||
type: import_zod4.z.literal("error"), | ||
name: import_zod4.z.string(), | ||
message: import_zod4.z.string(), | ||
cause: import_zod4.z.string().optional(), | ||
stack: import_zod4.z.string().optional() | ||
}); | ||
var chatImageSchema = chatTurnBaseSchema.extend({ | ||
type: import_zod4.z.literal("image"), | ||
image: import_zod4.z.string(), | ||
description: import_zod4.z.string() | ||
}); | ||
var chatListSchema = chatTurnBaseSchema.extend({ | ||
type: import_zod4.z.literal("list"), | ||
list: import_zod4.z.array(import_zod4.z.string()) | ||
}); | ||
var chatFunctionCallSchema = chatTurnBaseSchema.extend({ | ||
type: import_zod4.z.literal("functionCall"), | ||
functionCallId: import_zod4.z.string(), | ||
functionName: import_zod4.z.string(), | ||
functionArgs: import_zod4.z.record(import_zod4.z.unknown()) | ||
}); | ||
var chatFunctionReturnSchema = chatTurnBaseSchema.extend({ | ||
type: import_zod4.z.literal("functionReturn"), | ||
functionCallId: import_zod4.z.string(), | ||
functionReturn: import_zod4.z.string() | ||
}); | ||
var chatTurnSchema = import_zod4.z.discriminatedUnion("type", [ | ||
chatTextSchema, | ||
chatErrorSchema, | ||
chatImageSchema, | ||
chatListSchema, | ||
chatFunctionCallSchema, | ||
chatFunctionReturnSchema | ||
]); | ||
// src/index.ts | ||
function createClient(baseUrl, apiKey) { | ||
return { | ||
...createFunctionClient(baseUrl, apiKey), | ||
...createWorkflowClient(baseUrl, apiKey) | ||
}; | ||
} | ||
var DEFAULT_BASE_URL = "https://api.iudex.ai"; | ||
@@ -237,2 +598,4 @@ var Iudex = class { | ||
maxTries; | ||
client; | ||
currentWorkflowId; | ||
functionLinker; | ||
@@ -252,5 +615,7 @@ constructor({ | ||
this.maxTries = maxTries; | ||
this.client = createClient(this.baseUrl, this.apiKey); | ||
this.streamCurrentTask = this.streamCurrentTask.bind(this); | ||
} | ||
uploadFunctions = (jsons, modules) => { | ||
return putFunctionJsons(this.baseUrl, this.apiKey)(jsons, modules); | ||
return this.client.putFunctionJsons(jsons, modules); | ||
}; | ||
@@ -266,2 +631,8 @@ linkFunctions = (functionLinker) => { | ||
const { onChatTurn } = opts; | ||
const { | ||
promise: currentWorkflowId, | ||
resolve: setCurrentWorkflowId, | ||
reject: rejectCurrentWorkflowId | ||
} = deconstructedPromise(); | ||
this.currentWorkflowId = currentWorkflowId; | ||
const userTurn = { | ||
@@ -275,5 +646,9 @@ id: "msg_ephemeral_" + (/* @__PURE__ */ new Date()).toISOString(), | ||
onChatTurn?.(userTurn); | ||
const { workflowId } = await startWorkflow(this.baseUrl, this.apiKey)(userTurn.text); | ||
const { workflowId } = await this.client.startWorkflow(userTurn.text).catch((e) => { | ||
rejectCurrentWorkflowId(e); | ||
throw e; | ||
}); | ||
setCurrentWorkflowId(workflowId); | ||
let nextMessage2 = await poll( | ||
nextMessage(this.baseUrl, this.apiKey), | ||
this.client.nextMessage, | ||
[workflowId], | ||
@@ -300,3 +675,3 @@ { maxTries: 60, tries: 0, waitMs: 1e3 } | ||
onChatTurn?.(fnReturnTurn); | ||
await returnFunctionCall(this.baseUrl, this.apiKey)( | ||
await this.client.returnFunctionCall( | ||
fnReturnTurn.functionCallId, | ||
@@ -306,3 +681,3 @@ fnReturnTurn.functionReturn | ||
nextMessage2 = await poll( | ||
nextMessage(this.baseUrl, this.apiKey), | ||
this.client.nextMessage, | ||
[workflowId], | ||
@@ -323,3 +698,37 @@ { maxTries: 60, tries: 0, waitMs: 1e3 } | ||
}; | ||
// OpenAI interface shim | ||
async *streamCurrentTask() { | ||
if (!this.currentWorkflowId) { | ||
throw Error("No current workflow id. Send a message first."); | ||
} | ||
const workflowId = await this.currentWorkflowId; | ||
let rootTask = await this.client.fetchGetWorkflowById({ workflowId }).then((r) => r.workflow); | ||
let processingTask = getFirstTaskByStatus(rootTask, [ | ||
"Pending", | ||
"Planning", | ||
"Executing", | ||
"Sequencing" | ||
]); | ||
let oldProcessingTask; | ||
while (processingTask) { | ||
if (oldProcessingTask?.id !== processingTask.id || oldProcessingTask?.status !== processingTask.status) { | ||
yield processingTask; | ||
oldProcessingTask = processingTask; | ||
} | ||
await setTimeoutPromise(1e3); | ||
rootTask = await this.client.fetchGetWorkflowById({ workflowId }).then((r) => r.workflow); | ||
processingTask = getFirstTaskByStatus(rootTask, [ | ||
"Pending", | ||
"Planning", | ||
"Executing", | ||
"Sequencing" | ||
]); | ||
} | ||
const resolvedTask = getLastTaskByStatus(rootTask, "Resolved"); | ||
if (!resolvedTask) { | ||
throw Error("No processing nor resolved task found."); | ||
} | ||
yield resolvedTask; | ||
return; | ||
} | ||
// ======================= OpenAI interface shim ====================== | ||
chatCompletionsCreate = (body) => { | ||
@@ -335,5 +744,5 @@ const lastMessage = body.messages[body.messages.length - 1]; | ||
const functionReturn = lastMessage.content || ""; | ||
const functionCallRes = returnFunctionCall(this.baseUrl, this.apiKey)(callId, String(functionReturn)); | ||
const functionCallRes = this.client.returnFunctionCall(callId, String(functionReturn)); | ||
const nextMessageRes = functionCallRes.then(() => poll( | ||
nextMessage(this.baseUrl, this.apiKey), | ||
this.client.nextMessage, | ||
[workflowId], | ||
@@ -352,6 +761,13 @@ { maxTries: 60, tries: 0, waitMs: 1e3 } | ||
} | ||
const { | ||
promise: currentWorkflowId, | ||
resolve: setCurrentWorkflowId, | ||
reject: rejectCurrentWorkflowId | ||
} = deconstructedPromise(); | ||
this.currentWorkflowId = currentWorkflowId; | ||
const messageContent = extractMessageTextContent(lastMessage.content); | ||
return startWorkflow(this.baseUrl, this.apiKey)(messageContent).then( | ||
({ workflowId }) => poll( | ||
nextMessage(this.baseUrl, this.apiKey), | ||
return this.client.startWorkflow(messageContent).then(({ workflowId }) => { | ||
setCurrentWorkflowId(workflowId); | ||
return poll( | ||
this.client.nextMessage, | ||
[workflowId], | ||
@@ -364,4 +780,7 @@ { maxTries: 60, tries: 0, waitMs: 1e3 } | ||
}; | ||
}) | ||
); | ||
}); | ||
}).catch((e) => { | ||
rejectCurrentWorkflowId(e); | ||
throw e; | ||
}); | ||
}; | ||
@@ -424,16 +843,98 @@ chat = { | ||
} | ||
var src_default = Iudex; | ||
function getLastTaskByStatus(root, status) { | ||
const arrayStatus = !Array.isArray(status) ? [status] : status; | ||
const traverse = reversePreOrderTraversal( | ||
(t) => t.subtasks || [], | ||
(t) => arrayStatus.includes(t.status) | ||
); | ||
return traverse(root); | ||
} | ||
function getFirstTaskByStatus(root, status) { | ||
const arrayStatus = !Array.isArray(status) ? [status] : status; | ||
const traverse = preOrderTraversal( | ||
(t) => t.subtasks || [], | ||
(t) => arrayStatus.includes(t.status) | ||
); | ||
return traverse(root); | ||
} | ||
function reversePreOrderTraversal(getChildren, predicate) { | ||
return function traverse(node) { | ||
if (predicate(node)) { | ||
return node; | ||
} | ||
const reversedChildren = getChildren(node).reverse(); | ||
for (const child of reversedChildren) { | ||
const maybeFound = traverse(child); | ||
if (maybeFound !== void 0) { | ||
return maybeFound; | ||
} | ||
} | ||
return void 0; | ||
}; | ||
} | ||
function preOrderTraversal(getChildren, predicate) { | ||
return function traverse(node) { | ||
if (predicate(node)) { | ||
return node; | ||
} | ||
const children = getChildren(node); | ||
for (const child of children) { | ||
const maybeFound = traverse(child); | ||
if (maybeFound !== void 0) { | ||
return maybeFound; | ||
} | ||
} | ||
return void 0; | ||
}; | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
DEFAULT_BASE_URL, | ||
Feasibility, | ||
Iudex, | ||
Resolution, | ||
TaskStatus, | ||
WorkflowStatus, | ||
baseTaskSchema, | ||
chatErrorSchema, | ||
chatFunctionCallSchema, | ||
chatFunctionReturnSchema, | ||
chatImageSchema, | ||
chatListSchema, | ||
chatTextSchema, | ||
chatTurnSchema, | ||
createClient, | ||
createFunctionClient, | ||
createWorkflowClient, | ||
extractMessageTextContent, | ||
functionJsonSchema, | ||
feasibilityCheckSchema, | ||
fetchGetWorkflowById, | ||
fetchGetWorkflows, | ||
fetchPostWorkflows, | ||
getFirstTaskByStatus, | ||
getLastTaskByStatus, | ||
getWorkflowByIdReqSchema, | ||
getWorkflowByIdResSchema, | ||
getWorkflowsResSchema, | ||
mapIudexToOpenAi, | ||
nextMessage, | ||
nullFunctionJson, | ||
postWorkflowsReqSchema, | ||
postWorkflowsResSchema, | ||
preOrderTraversal, | ||
putFunctionJsons, | ||
resolutionCheckSchema, | ||
returnFunctionCall, | ||
startWorkflow | ||
reversePreOrderTraversal, | ||
startWorkflow, | ||
taskExecutingSchema, | ||
taskPendingSchema, | ||
taskPlanningSchema, | ||
taskResolvedSchema, | ||
taskSchema, | ||
taskSequencedSchema, | ||
taskSequencingSchema, | ||
workflowInfoSchema, | ||
workflowSchema, | ||
...require("function-json-schema") | ||
}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "iudex", | ||
"version": "0.8.8", | ||
"version": "0.9.0", | ||
"description": "Iudex client", | ||
@@ -33,2 +33,3 @@ "scripts": { | ||
"devDependencies": { | ||
"@tsconfig/recommended": "^1.0.4", | ||
"@types/node": "^20.11.16", | ||
@@ -43,2 +44,3 @@ "bun": "^1.0.26", | ||
"dependencies": { | ||
"function-json-schema": "^1.0.1", | ||
"p-map": "^7.0.1", | ||
@@ -45,0 +47,0 @@ "p-retry": "^6.2.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
273381
3279
4
8
15
+ Addedfunction-json-schema@^1.0.1
+ Addedfunction-json-schema@1.0.4(transitive)