Comparing version 0.9.1 to 0.9.3
@@ -334,3 +334,3 @@ import z$1, { z } from 'zod'; | ||
}; | ||
declare function startWorkflow(baseUrl: string, apiKey: string): (query: string, modules?: string) => Promise<StartWorkflowRes>; | ||
declare function startWorkflow(baseUrl: string, apiKey: string): (query: string, modules?: string[]) => Promise<StartWorkflowRes>; | ||
type FunctionJson = { | ||
@@ -357,4 +357,6 @@ name: string; | ||
readonly Sequenced: "Sequenced"; | ||
readonly Errored: "Errored"; | ||
}; | ||
type TaskStatus = (typeof TaskStatus)[keyof typeof TaskStatus]; | ||
declare const TerminalTaskStatuses: readonly ["Resolved", "Sequenced", "Errored"]; | ||
declare const baseTaskSchema: z$1.ZodObject<{ | ||
@@ -370,2 +372,3 @@ id: z$1.ZodString; | ||
readonly Sequenced: "Sequenced"; | ||
readonly Errored: "Errored"; | ||
}>; | ||
@@ -377,3 +380,3 @@ stepIndex: z$1.ZodNumber; | ||
id: string; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced"; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced" | "Errored"; | ||
description: string; | ||
@@ -385,3 +388,3 @@ stepIndex: number; | ||
id: string; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced"; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced" | "Errored"; | ||
description: string; | ||
@@ -775,3 +778,35 @@ stepIndex: number; | ||
declare const taskSequencedSchema: z$1.ZodType<TaskSequenced>; | ||
type Task = TaskPending | TaskPlanning | TaskExecuting | TaskSequencing | TaskSequenced | TaskResolved; | ||
declare const taskErroredSchema: 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<"Errored">; | ||
errorMsg: z$1.ZodString; | ||
errorName: z$1.ZodString; | ||
errorStack: z$1.ZodOptional<z$1.ZodString>; | ||
}, "strip", z$1.ZodTypeAny, { | ||
id: string; | ||
status: "Errored"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
errorMsg: string; | ||
errorName: string; | ||
errorStack?: string | undefined; | ||
}, { | ||
id: string; | ||
status: "Errored"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
errorMsg: string; | ||
errorName: string; | ||
errorStack?: string | undefined; | ||
}>; | ||
type TaskErrored = z$1.infer<typeof taskErroredSchema>; | ||
type Task = TaskPending | TaskPlanning | TaskExecuting | TaskSequencing | TaskSequenced | TaskResolved | TaskErrored; | ||
declare const taskSchema: z$1.ZodType<Task>; | ||
@@ -785,2 +820,3 @@ type TaskStatusToType = { | ||
[TaskStatus.Resolved]: TaskResolved; | ||
[TaskStatus.Errored]: TaskErrored; | ||
}; | ||
@@ -930,5 +966,15 @@ type TaskStatusesToType<Statuses> = Statuses extends TaskStatus[] ? Statuses[number] extends TaskStatus ? TaskStatusToType[Statuses[number]] : never : Statuses extends TaskStatus ? TaskStatusToType[Statuses] : never; | ||
usedFunctionNames: string[]; | ||
} | { | ||
id: string; | ||
status: "Errored"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
errorMsg: string; | ||
errorName: string; | ||
errorStack?: string | undefined; | ||
} | ({ | ||
id: string; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced"; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced" | "Errored"; | ||
description: string; | ||
@@ -1032,5 +1078,15 @@ stepIndex: number; | ||
usedFunctionNames: string[]; | ||
} | { | ||
id: string; | ||
status: "Errored"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
errorMsg: string; | ||
errorName: string; | ||
errorStack?: string | undefined; | ||
} | ({ | ||
id: string; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced"; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced" | "Errored"; | ||
description: string; | ||
@@ -1219,5 +1275,15 @@ stepIndex: number; | ||
usedFunctionNames: string[]; | ||
} | { | ||
id: string; | ||
status: "Errored"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
errorMsg: string; | ||
errorName: string; | ||
errorStack?: string | undefined; | ||
} | ({ | ||
id: string; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced"; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced" | "Errored"; | ||
description: string; | ||
@@ -1329,5 +1395,15 @@ stepIndex: number; | ||
usedFunctionNames: string[]; | ||
} | { | ||
id: string; | ||
status: "Errored"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
errorMsg: string; | ||
errorName: string; | ||
errorStack?: string | undefined; | ||
} | ({ | ||
id: string; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced"; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced" | "Errored"; | ||
description: string; | ||
@@ -1501,5 +1577,15 @@ stepIndex: number; | ||
usedFunctionNames: string[]; | ||
} | { | ||
id: string; | ||
status: "Errored"; | ||
description: string; | ||
stepIndex: number; | ||
depth: number; | ||
numRewrites: number; | ||
errorMsg: string; | ||
errorName: string; | ||
errorStack?: string | undefined; | ||
} | ({ | ||
id: string; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced"; | ||
status: "Pending" | "Planning" | "Executing" | "Sequencing" | "Resolved" | "Sequenced" | "Errored"; | ||
description: string; | ||
@@ -1538,3 +1624,3 @@ stepIndex: number; | ||
nextMessage: (workflowId: string) => Promise<NextMessageRes>; | ||
startWorkflow: (query: string, modules?: string | undefined) => Promise<StartWorkflowRes>; | ||
startWorkflow: (query: string, modules?: string[] | undefined) => Promise<StartWorkflowRes>; | ||
putFunctionJsons: (jsons: { | ||
@@ -1573,2 +1659,3 @@ name: string; | ||
initAuth?: string | undefined; | ||
modules?: string[] | undefined; | ||
}) => Promise<ChatText>; | ||
@@ -1579,3 +1666,7 @@ /** | ||
*/ | ||
sendMessage: (message: string) => Promise<string>; | ||
sendMessage: (message: string, opts?: { | ||
onChatTurn?: ((c: ChatTurn) => void) | undefined; | ||
initAuth?: string | undefined; | ||
modules?: string[] | undefined; | ||
}) => Promise<string>; | ||
streamCurrentTask(): AsyncGenerator<Task>; | ||
@@ -1606,2 +1697,2 @@ chatCompletionsCreate: (body: OpenAI.ChatCompletionCreateParamsNonStreaming & { | ||
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, type WorkflowMetadata, 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, workflowMetadataSchema, workflowSchema }; | ||
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 TaskErrored, type TaskExecuting, type TaskPending, type TaskPlanning, type TaskResolved, type TaskSequenced, type TaskSequencing, TaskStatus, type TaskStatusToType, type TaskStatusesToType, TerminalTaskStatuses, type Workflow, type WorkflowClient, type WorkflowInfo, type WorkflowMetadata, 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, taskErroredSchema, taskExecutingSchema, taskPendingSchema, taskPlanningSchema, taskResolvedSchema, taskSchema, taskSequencedSchema, taskSequencingSchema, workflowInfoSchema, workflowMetadataSchema, workflowSchema }; |
@@ -39,2 +39,3 @@ "use strict"; | ||
TaskStatus: () => TaskStatus, | ||
TerminalTaskStatuses: () => TerminalTaskStatuses, | ||
WorkflowStatus: () => WorkflowStatus, | ||
@@ -72,2 +73,3 @@ baseTaskSchema: () => baseTaskSchema, | ||
startWorkflow: () => startWorkflow, | ||
taskErroredSchema: () => taskErroredSchema, | ||
taskExecutingSchema: () => taskExecutingSchema, | ||
@@ -408,5 +410,12 @@ taskPendingSchema: () => taskPendingSchema, | ||
// execution resolved task | ||
Sequenced: "Sequenced" | ||
Sequenced: "Sequenced", | ||
// no resolution; sequuencer created subtasks | ||
Errored: "Errored" | ||
// unrecoverable error during processing | ||
}; | ||
var TerminalTaskStatuses = [ | ||
TaskStatus.Resolved, | ||
TaskStatus.Sequenced, | ||
TaskStatus.Errored | ||
]; | ||
var baseTaskSchema = import_zod.default.object({ | ||
@@ -480,2 +489,8 @@ id: import_zod.default.string(), | ||
}); | ||
var taskErroredSchema = baseTaskSchema.extend({ | ||
status: import_zod.default.literal(TaskStatus.Errored), | ||
errorMsg: import_zod.default.string(), | ||
errorName: import_zod.default.string(), | ||
errorStack: import_zod.default.string().optional() | ||
}); | ||
var taskSchema = import_zod.default.union([ | ||
@@ -487,3 +502,4 @@ taskPendingSchema, | ||
taskSequencingSchema, | ||
taskSequencedSchema | ||
taskSequencedSchema, | ||
taskErroredSchema | ||
]); | ||
@@ -536,2 +552,3 @@ | ||
query: import_zod3.default.string(), | ||
// Undefined means use all org modules. [] means use all modules. | ||
modules: import_zod3.default.array(import_zod3.default.string()).optional(), | ||
@@ -637,3 +654,3 @@ opts: import_zod3.default.object({ | ||
sendChatTurn = async (message, opts = {}) => { | ||
const { onChatTurn } = opts; | ||
const { onChatTurn, modules } = opts; | ||
const { | ||
@@ -653,3 +670,3 @@ promise: currentWorkflowId, | ||
onChatTurn?.(userTurn); | ||
const { workflowId } = await this.client.startWorkflow(userTurn.text).catch((e) => { | ||
const { workflowId } = await this.client.startWorkflow(userTurn.text, modules).catch((e) => { | ||
rejectCurrentWorkflowId(e); | ||
@@ -699,4 +716,4 @@ throw e; | ||
*/ | ||
sendMessage = async (message) => { | ||
const chatTurn = await this.sendChatTurn(message); | ||
sendMessage = async (message, opts = {}) => { | ||
const chatTurn = await this.sendChatTurn(message, opts); | ||
return chatTurn.text; | ||
@@ -724,2 +741,7 @@ }; | ||
rootTask = await this.client.fetchGetWorkflowById({ workflowId }).then((r) => r.workflow); | ||
const maybeErroredTask = getLastTaskByStatus(rootTask, "Errored"); | ||
if (maybeErroredTask) { | ||
yield maybeErroredTask; | ||
return; | ||
} | ||
processingTask = getFirstTaskByStatus(rootTask, [ | ||
@@ -899,2 +921,3 @@ "Pending", | ||
TaskStatus, | ||
TerminalTaskStatuses, | ||
WorkflowStatus, | ||
@@ -932,2 +955,3 @@ baseTaskSchema, | ||
startWorkflow, | ||
taskErroredSchema, | ||
taskExecutingSchema, | ||
@@ -934,0 +958,0 @@ taskPendingSchema, |
{ | ||
"name": "iudex", | ||
"version": "0.9.1", | ||
"version": "0.9.3", | ||
"description": "Iudex client", | ||
@@ -40,3 +40,3 @@ "scripts": { | ||
"tsup": "^8.0.1", | ||
"typescript": "^5.3.3" | ||
"typescript": "5.4.3" | ||
}, | ||
@@ -47,4 +47,4 @@ "dependencies": { | ||
"p-retry": "^6.2.0", | ||
"zod": "^3.21.4" | ||
"zod": "3.21.4" | ||
} | ||
} |
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
287204
3464
+ Addedzod@3.21.4(transitive)
- Removedzod@3.24.2(transitive)
Updatedzod@3.21.4