From 68fb04bb0ce616e4674826bbe75148fb79cb6ef2 Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Wed, 25 Sep 2024 17:33:13 +0200 Subject: [PATCH] fix(sdk-js): match schema types, bump to 0.0.12 --- libs/sdk-js/package.json | 2 +- libs/sdk-js/src/schema.ts | 94 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 90 insertions(+), 6 deletions(-) diff --git a/libs/sdk-js/package.json b/libs/sdk-js/package.json index 132fe312b..903aff12a 100644 --- a/libs/sdk-js/package.json +++ b/libs/sdk-js/package.json @@ -1,6 +1,6 @@ { "name": "@langchain/langgraph-sdk", - "version": "0.0.11", + "version": "0.0.12", "description": "Client library for interacting with the LangGraph API", "type": "module", "packageManager": "yarn@1.22.19", diff --git a/libs/sdk-js/src/schema.ts b/libs/sdk-js/src/schema.ts index e25aff0c3..b016cea9b 100644 --- a/libs/sdk-js/src/schema.ts +++ b/libs/sdk-js/src/schema.ts @@ -12,6 +12,8 @@ type RunStatus = type ThreadStatus = "idle" | "busy" | "interrupted"; +type MultitaskStrategy = "reject" | "interrupt" | "rollback" | "enqueue"; + export interface Config { /** * Tags for this call and any sub-calls (eg. a Chain calling an LLM). @@ -76,60 +78,142 @@ export interface GraphSchema { export type Metadata = Optional>; export interface AssistantBase { + /** The ID of the assistant. */ assistant_id: string; + + /** The ID of the graph. */ graph_id: string; + + /** The assistant config. */ config: Config; + + /** The time the assistant was created. */ created_at: string; + + /** The assistant metadata. */ metadata: Metadata; + + /** The version of the assistant. */ version: number; } export interface AssistantVersion extends AssistantBase {} export interface Assistant extends AssistantBase { + /** The last time the assistant was updated. */ updated_at: string; + + /** The name of the assistant */ name: string; } export type AssistantGraph = Record>>; -export interface Thread { +export interface Thread { + /** The ID of the thread. */ thread_id: string; + + /** The time the thread was created. */ created_at: string; + + /** The last time the thread was updated. */ updated_at: string; + + /** The thread metadata. */ metadata: Metadata; + + /** The status of the thread */ status: ThreadStatus; + + /** The current state of the thread. */ + values: ValuesType; } export interface Cron { + /** The ID of the cron */ cron_id: string; + + /** The ID of the thread */ thread_id: Optional; + + /** The end date to stop running the cron. */ end_time: Optional; + + /** The schedule to run, cron format. */ schedule: string; + + /** The time the cron was created. */ created_at: string; + + /** The last time the cron was updated. */ updated_at: string; + + /** The run payload to use for creating new run. */ payload: Record; } export type DefaultValues = Record[] | Record; export interface ThreadState { + /** The state values */ values: ValuesType; + + /** The next nodes to execute. If empty, the thread is done until new input is received */ next: string[]; - checkpoint_id: string; + + /** Checkpoint of the thread state */ + checkpoint: Checkpoint; + + /** Metadata for this state */ metadata: Metadata; + + /** Time of state creation */ created_at: Optional; - parent_checkpoint_id: Optional; - config: Config; - parent_config?: Config; + /** The parent checkpoint. If missing, this is the root checkpoint */ + parent_checkpoint: Optional; + + /** Tasks to execute in this step. If already attempted, may contain an error */ + tasks: Array; +} + +export interface ThreadTask { + id: string; + name: string; + error: Optional; + interrupts: Array>; + checkpoint: Optional; + state: Optional; } export interface Run { + /** The ID of the run */ run_id: string; + + /** The ID of the thread */ thread_id: string; + + /** The assistant that wwas used for this run */ assistant_id: string; + + /** The time the run was created */ created_at: string; + + /** The last time the run was updated */ updated_at: string; + + /** The status of the run. */ status: RunStatus; + + /** Run metadata */ metadata: Metadata; + + /** Strategy to handle concurrent runs on the same thread */ + multitask_strategy: Optional; +} + +export interface Checkpoint { + thread_id: string; + checkpoint_ns: string; + checkpoint_id: Optional; + checkpoint_map: Optional>; }