UNPKG

@langchain/langgraph-sdk

Version:

Client library for interacting with the LangGraph API

50 lines (49 loc) • 1.4 kB
require("../_virtual/_rolldown/runtime.cjs"); const require_queue_adapter = require("./queue-adapter.cjs"); let _langchain_core_utils_uuid = require("@langchain/core/utils/uuid"); //#region src/stream/queue-adapter-local.ts /** * Client-only defer. The default backing for `"enqueue"` — used * unless `queue: "server"` is set. */ var LocalQueueAdapter = class { #store; #onError; constructor(store, onError) { this.#store = store; this.#onError = onError; } async hydrate() {} async enqueue(_threadId, values, options) { const entry = { id: (0, _langchain_core_utils_uuid.v7)(), values, options, createdAt: /* @__PURE__ */ new Date() }; this.#store.setState((current) => [...current, entry]); } onIdle(dispatch) { const [head, ...rest] = this.#store.getSnapshot(); if (!head) return; this.#store.setState(() => rest); dispatch(head.values, { ...head.options, multitaskStrategy: void 0 }).catch(this.#onError); } async cancel(id) { const current = this.#store.getSnapshot(); const next = current.filter((entry) => entry.id !== id); if (next.length === current.length) return false; this.#store.setState(() => next); return true; } async clear() { this.#store.setState(() => require_queue_adapter.EMPTY_QUEUE); } detach() {} }; //#endregion exports.LocalQueueAdapter = LocalQueueAdapter; //# sourceMappingURL=queue-adapter-local.cjs.map