@langchain/langgraph-sdk 1.8.10 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -43
- package/dist/client/assistants/index.cjs +180 -0
- package/dist/client/assistants/index.cjs.map +1 -0
- package/dist/client/assistants/index.d.cts +155 -0
- package/dist/client/assistants/index.d.cts.map +1 -0
- package/dist/client/assistants/index.d.ts +155 -0
- package/dist/client/assistants/index.d.ts.map +1 -0
- package/dist/client/assistants/index.js +180 -0
- package/dist/client/assistants/index.js.map +1 -0
- package/dist/client/base.cjs +190 -0
- package/dist/client/base.cjs.map +1 -0
- package/dist/client/base.d.cts +84 -0
- package/dist/client/base.d.cts.map +1 -0
- package/dist/client/base.d.ts +84 -0
- package/dist/client/base.d.ts.map +1 -0
- package/dist/client/base.js +188 -0
- package/dist/client/base.js.map +1 -0
- package/dist/client/crons/index.cjs +159 -0
- package/dist/client/crons/index.cjs.map +1 -0
- package/dist/client/crons/index.d.cts +71 -0
- package/dist/client/crons/index.d.cts.map +1 -0
- package/dist/client/crons/index.d.ts +71 -0
- package/dist/client/crons/index.d.ts.map +1 -0
- package/dist/client/crons/index.js +159 -0
- package/dist/client/crons/index.js.map +1 -0
- package/dist/client/index.cjs +84 -0
- package/dist/client/index.cjs.map +1 -0
- package/dist/client/index.d.cts +63 -0
- package/dist/client/index.d.cts.map +1 -0
- package/dist/client/index.d.ts +63 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +83 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/runs/index.cjs +275 -0
- package/dist/client/runs/index.cjs.map +1 -0
- package/dist/client/runs/index.d.cts +123 -0
- package/dist/client/runs/index.d.cts.map +1 -0
- package/dist/client/runs/index.d.ts +123 -0
- package/dist/client/runs/index.d.ts.map +1 -0
- package/dist/client/runs/index.js +275 -0
- package/dist/client/runs/index.js.map +1 -0
- package/dist/client/store/index.cjs +128 -0
- package/dist/client/store/index.cjs.map +1 -0
- package/dist/client/store/index.d.cts +75 -0
- package/dist/client/store/index.d.cts.map +1 -0
- package/dist/client/store/index.d.ts +75 -0
- package/dist/client/store/index.d.ts.map +1 -0
- package/dist/client/store/index.js +128 -0
- package/dist/client/store/index.js.map +1 -0
- package/dist/client/stream/error.cjs +18 -0
- package/dist/client/stream/error.cjs.map +1 -0
- package/dist/client/stream/error.d.cts +14 -0
- package/dist/client/stream/error.d.cts.map +1 -0
- package/dist/client/stream/error.d.ts +14 -0
- package/dist/client/stream/error.d.ts.map +1 -0
- package/dist/client/stream/error.js +18 -0
- package/dist/client/stream/error.js.map +1 -0
- package/dist/client/stream/handles/index.cjs +3 -0
- package/dist/client/stream/handles/index.d.ts +3 -0
- package/dist/client/stream/handles/index.js +4 -0
- package/dist/client/stream/handles/subagents.cjs +263 -0
- package/dist/client/stream/handles/subagents.cjs.map +1 -0
- package/dist/client/stream/handles/subagents.d.cts +45 -0
- package/dist/client/stream/handles/subagents.d.cts.map +1 -0
- package/dist/client/stream/handles/subagents.d.ts +45 -0
- package/dist/client/stream/handles/subagents.d.ts.map +1 -0
- package/dist/client/stream/handles/subagents.js +262 -0
- package/dist/client/stream/handles/subagents.js.map +1 -0
- package/dist/client/stream/handles/subgraphs.cjs +352 -0
- package/dist/client/stream/handles/subgraphs.cjs.map +1 -0
- package/dist/client/stream/handles/subgraphs.d.cts +82 -0
- package/dist/client/stream/handles/subgraphs.d.cts.map +1 -0
- package/dist/client/stream/handles/subgraphs.d.ts +82 -0
- package/dist/client/stream/handles/subgraphs.d.ts.map +1 -0
- package/dist/client/stream/handles/subgraphs.js +351 -0
- package/dist/client/stream/handles/subgraphs.js.map +1 -0
- package/dist/client/stream/handles/tools.cjs +92 -0
- package/dist/client/stream/handles/tools.cjs.map +1 -0
- package/dist/client/stream/handles/tools.d.cts +26 -0
- package/dist/client/stream/handles/tools.d.cts.map +1 -0
- package/dist/client/stream/handles/tools.d.ts +26 -0
- package/dist/client/stream/handles/tools.d.ts.map +1 -0
- package/dist/client/stream/handles/tools.js +92 -0
- package/dist/client/stream/handles/tools.js.map +1 -0
- package/dist/client/stream/index.cjs +1368 -0
- package/dist/client/stream/index.cjs.map +1 -0
- package/dist/client/stream/index.d.cts +238 -0
- package/dist/client/stream/index.d.cts.map +1 -0
- package/dist/client/stream/index.d.ts +238 -0
- package/dist/client/stream/index.d.ts.map +1 -0
- package/dist/client/stream/index.js +1367 -0
- package/dist/client/stream/index.js.map +1 -0
- package/dist/client/stream/media.cjs +506 -0
- package/dist/client/stream/media.cjs.map +1 -0
- package/dist/client/stream/media.d.cts +164 -0
- package/dist/client/stream/media.d.cts.map +1 -0
- package/dist/client/stream/media.d.ts +164 -0
- package/dist/client/stream/media.d.ts.map +1 -0
- package/dist/client/stream/media.js +505 -0
- package/dist/client/stream/media.js.map +1 -0
- package/dist/client/stream/messages.cjs +635 -0
- package/dist/client/stream/messages.cjs.map +1 -0
- package/dist/client/stream/messages.d.cts +139 -0
- package/dist/client/stream/messages.d.cts.map +1 -0
- package/dist/client/stream/messages.d.ts +139 -0
- package/dist/client/stream/messages.d.ts.map +1 -0
- package/dist/client/stream/messages.js +631 -0
- package/dist/client/stream/messages.js.map +1 -0
- package/dist/client/stream/multi-cursor-buffer.cjs +55 -0
- package/dist/client/stream/multi-cursor-buffer.cjs.map +1 -0
- package/dist/client/stream/multi-cursor-buffer.js +55 -0
- package/dist/client/stream/multi-cursor-buffer.js.map +1 -0
- package/dist/client/stream/subscription.cjs +85 -0
- package/dist/client/stream/subscription.cjs.map +1 -0
- package/dist/client/stream/subscription.d.cts +22 -0
- package/dist/client/stream/subscription.d.cts.map +1 -0
- package/dist/client/stream/subscription.d.ts +22 -0
- package/dist/client/stream/subscription.d.ts.map +1 -0
- package/dist/client/stream/subscription.js +84 -0
- package/dist/client/stream/subscription.js.map +1 -0
- package/dist/client/stream/transport/agent-server.cjs +45 -0
- package/dist/client/stream/transport/agent-server.cjs.map +1 -0
- package/dist/client/stream/transport/agent-server.d.cts +39 -0
- package/dist/client/stream/transport/agent-server.d.cts.map +1 -0
- package/dist/client/stream/transport/agent-server.d.ts +39 -0
- package/dist/client/stream/transport/agent-server.d.ts.map +1 -0
- package/dist/client/stream/transport/agent-server.js +45 -0
- package/dist/client/stream/transport/agent-server.js.map +1 -0
- package/dist/client/stream/transport/constants.cjs +10 -0
- package/dist/client/stream/transport/constants.cjs.map +1 -0
- package/dist/client/stream/transport/constants.js +10 -0
- package/dist/client/stream/transport/constants.js.map +1 -0
- package/dist/client/stream/transport/decoder.cjs +115 -0
- package/dist/client/stream/transport/decoder.cjs.map +1 -0
- package/dist/client/stream/transport/decoder.js +114 -0
- package/dist/client/stream/transport/decoder.js.map +1 -0
- package/dist/client/stream/transport/http.cjs +183 -0
- package/dist/client/stream/transport/http.cjs.map +1 -0
- package/dist/client/stream/transport/http.d.cts +45 -0
- package/dist/client/stream/transport/http.d.cts.map +1 -0
- package/dist/client/stream/transport/http.d.ts +45 -0
- package/dist/client/stream/transport/http.d.ts.map +1 -0
- package/dist/client/stream/transport/http.js +183 -0
- package/dist/client/stream/transport/http.js.map +1 -0
- package/dist/client/stream/transport/index.cjs +3 -0
- package/dist/client/stream/transport/index.js +4 -0
- package/dist/client/stream/transport/queue.cjs +55 -0
- package/dist/client/stream/transport/queue.cjs.map +1 -0
- package/dist/client/stream/transport/queue.js +55 -0
- package/dist/client/stream/transport/queue.js.map +1 -0
- package/dist/client/stream/transport/stream.cjs +79 -0
- package/dist/client/stream/transport/stream.cjs.map +1 -0
- package/dist/client/stream/transport/stream.js +79 -0
- package/dist/client/stream/transport/stream.js.map +1 -0
- package/dist/client/stream/transport/types.d.cts +29 -0
- package/dist/client/stream/transport/types.d.cts.map +1 -0
- package/dist/client/stream/transport/types.d.ts +29 -0
- package/dist/client/stream/transport/types.d.ts.map +1 -0
- package/dist/client/stream/transport/utils.cjs +45 -0
- package/dist/client/stream/transport/utils.cjs.map +1 -0
- package/dist/client/stream/transport/utils.js +39 -0
- package/dist/client/stream/transport/utils.js.map +1 -0
- package/dist/client/stream/transport/websocket.cjs +155 -0
- package/dist/client/stream/transport/websocket.cjs.map +1 -0
- package/dist/client/stream/transport/websocket.d.cts +36 -0
- package/dist/client/stream/transport/websocket.d.cts.map +1 -0
- package/dist/client/stream/transport/websocket.d.ts +36 -0
- package/dist/client/stream/transport/websocket.d.ts.map +1 -0
- package/dist/client/stream/transport/websocket.js +155 -0
- package/dist/client/stream/transport/websocket.js.map +1 -0
- package/dist/client/stream/transport.d.cts +104 -0
- package/dist/client/stream/transport.d.cts.map +1 -0
- package/dist/client/stream/transport.d.ts +104 -0
- package/dist/client/stream/transport.d.ts.map +1 -0
- package/dist/client/stream/types.d.cts +208 -0
- package/dist/client/stream/types.d.cts.map +1 -0
- package/dist/client/stream/types.d.ts +208 -0
- package/dist/client/stream/types.d.ts.map +1 -0
- package/dist/client/threads/index.cjs +271 -0
- package/dist/client/threads/index.cjs.map +1 -0
- package/dist/client/threads/index.d.cts +235 -0
- package/dist/client/threads/index.d.cts.map +1 -0
- package/dist/client/threads/index.d.ts +235 -0
- package/dist/client/threads/index.d.ts.map +1 -0
- package/dist/client/threads/index.js +270 -0
- package/dist/client/threads/index.js.map +1 -0
- package/dist/client/ui-internal/index.cjs +29 -0
- package/dist/client/ui-internal/index.cjs.map +1 -0
- package/dist/client/ui-internal/index.d.cts +11 -0
- package/dist/client/ui-internal/index.d.cts.map +1 -0
- package/dist/client/ui-internal/index.d.ts +11 -0
- package/dist/client/ui-internal/index.d.ts.map +1 -0
- package/dist/client/ui-internal/index.js +29 -0
- package/dist/client/ui-internal/index.js.map +1 -0
- package/dist/client.cjs +35 -1308
- package/dist/client.d.cts +19 -857
- package/dist/client.d.ts +19 -857
- package/dist/client.js +16 -1301
- package/dist/index.cjs +25 -4
- package/dist/index.d.cts +15 -3
- package/dist/index.d.ts +15 -3
- package/dist/index.js +14 -3
- package/dist/react/stream.cjs.map +1 -1
- package/dist/react/stream.custom.cjs +1 -1
- package/dist/react/stream.custom.js +1 -1
- package/dist/react/stream.d.cts +2 -1
- package/dist/react/stream.d.cts.map +1 -1
- package/dist/react/stream.d.ts +2 -1
- package/dist/react/stream.d.ts.map +1 -1
- package/dist/react/stream.js.map +1 -1
- package/dist/react/stream.lgp.cjs +6 -5
- package/dist/react/stream.lgp.cjs.map +1 -1
- package/dist/react/stream.lgp.js +4 -3
- package/dist/react/stream.lgp.js.map +1 -1
- package/dist/react/types.d.cts +1 -1
- package/dist/react/types.d.ts +1 -1
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react-ui/server/server.cjs +1 -1
- package/dist/react-ui/server/server.cjs.map +1 -1
- package/dist/react-ui/server/server.js +1 -1
- package/dist/react-ui/server/server.js.map +1 -1
- package/dist/react-ui/types.cjs.map +1 -1
- package/dist/react-ui/types.d.cts +1 -1
- package/dist/react-ui/types.d.cts.map +1 -1
- package/dist/react-ui/types.d.ts +1 -1
- package/dist/react-ui/types.d.ts.map +1 -1
- package/dist/react-ui/types.js.map +1 -1
- package/dist/stream/assembled-to-message.cjs +121 -0
- package/dist/stream/assembled-to-message.cjs.map +1 -0
- package/dist/stream/assembled-to-message.d.cts +35 -0
- package/dist/stream/assembled-to-message.d.cts.map +1 -0
- package/dist/stream/assembled-to-message.d.ts +35 -0
- package/dist/stream/assembled-to-message.d.ts.map +1 -0
- package/dist/stream/assembled-to-message.js +119 -0
- package/dist/stream/assembled-to-message.js.map +1 -0
- package/dist/stream/channel-registry.cjs +224 -0
- package/dist/stream/channel-registry.cjs.map +1 -0
- package/dist/stream/channel-registry.d.cts +102 -0
- package/dist/stream/channel-registry.d.cts.map +1 -0
- package/dist/stream/channel-registry.d.ts +102 -0
- package/dist/stream/channel-registry.d.ts.map +1 -0
- package/dist/stream/channel-registry.js +224 -0
- package/dist/stream/channel-registry.js.map +1 -0
- package/dist/stream/constants.cjs +11 -0
- package/dist/stream/constants.cjs.map +1 -0
- package/dist/stream/constants.d.cts +10 -0
- package/dist/stream/constants.d.cts.map +1 -0
- package/dist/stream/constants.d.ts +10 -0
- package/dist/stream/constants.d.ts.map +1 -0
- package/dist/stream/constants.js +11 -0
- package/dist/stream/constants.js.map +1 -0
- package/dist/stream/controller.cjs +933 -0
- package/dist/stream/controller.cjs.map +1 -0
- package/dist/stream/controller.d.cts +135 -0
- package/dist/stream/controller.d.cts.map +1 -0
- package/dist/stream/controller.d.ts +135 -0
- package/dist/stream/controller.d.ts.map +1 -0
- package/dist/stream/controller.js +910 -0
- package/dist/stream/controller.js.map +1 -0
- package/dist/stream/discovery/index.d.ts +2 -0
- package/dist/stream/discovery/subagents.cjs +235 -0
- package/dist/stream/discovery/subagents.cjs.map +1 -0
- package/dist/stream/discovery/subagents.d.cts +18 -0
- package/dist/stream/discovery/subagents.d.cts.map +1 -0
- package/dist/stream/discovery/subagents.d.ts +18 -0
- package/dist/stream/discovery/subagents.d.ts.map +1 -0
- package/dist/stream/discovery/subagents.js +235 -0
- package/dist/stream/discovery/subagents.js.map +1 -0
- package/dist/stream/discovery/subgraphs.cjs +153 -0
- package/dist/stream/discovery/subgraphs.cjs.map +1 -0
- package/dist/stream/discovery/subgraphs.d.cts +19 -0
- package/dist/stream/discovery/subgraphs.d.cts.map +1 -0
- package/dist/stream/discovery/subgraphs.d.ts +19 -0
- package/dist/stream/discovery/subgraphs.d.ts.map +1 -0
- package/dist/stream/discovery/subgraphs.js +153 -0
- package/dist/stream/discovery/subgraphs.js.map +1 -0
- package/dist/stream/index.cjs +36 -0
- package/dist/stream/index.d.cts +25 -0
- package/dist/stream/index.d.ts +25 -0
- package/dist/stream/index.js +16 -0
- package/dist/stream/lifecycle-loading-tracker.cjs +83 -0
- package/dist/stream/lifecycle-loading-tracker.cjs.map +1 -0
- package/dist/stream/lifecycle-loading-tracker.js +83 -0
- package/dist/stream/lifecycle-loading-tracker.js.map +1 -0
- package/dist/stream/message-metadata-tracker.cjs +165 -0
- package/dist/stream/message-metadata-tracker.cjs.map +1 -0
- package/dist/stream/message-metadata-tracker.d.cts +24 -0
- package/dist/stream/message-metadata-tracker.d.cts.map +1 -0
- package/dist/stream/message-metadata-tracker.d.ts +24 -0
- package/dist/stream/message-metadata-tracker.d.ts.map +1 -0
- package/dist/stream/message-metadata-tracker.js +165 -0
- package/dist/stream/message-metadata-tracker.js.map +1 -0
- package/dist/stream/message-reconciliation.cjs +118 -0
- package/dist/stream/message-reconciliation.cjs.map +1 -0
- package/dist/stream/message-reconciliation.js +115 -0
- package/dist/stream/message-reconciliation.js.map +1 -0
- package/dist/stream/namespace.cjs +54 -0
- package/dist/stream/namespace.cjs.map +1 -0
- package/dist/stream/namespace.js +49 -0
- package/dist/stream/namespace.js.map +1 -0
- package/dist/stream/projections/channel.cjs +53 -0
- package/dist/stream/projections/channel.cjs.map +1 -0
- package/dist/stream/projections/channel.d.cts +22 -0
- package/dist/stream/projections/channel.d.cts.map +1 -0
- package/dist/stream/projections/channel.d.ts +22 -0
- package/dist/stream/projections/channel.d.ts.map +1 -0
- package/dist/stream/projections/channel.js +53 -0
- package/dist/stream/projections/channel.js.map +1 -0
- package/dist/stream/projections/extension.cjs +29 -0
- package/dist/stream/projections/extension.cjs.map +1 -0
- package/dist/stream/projections/extension.d.cts +7 -0
- package/dist/stream/projections/extension.d.cts.map +1 -0
- package/dist/stream/projections/extension.d.ts +7 -0
- package/dist/stream/projections/extension.d.ts.map +1 -0
- package/dist/stream/projections/extension.js +29 -0
- package/dist/stream/projections/extension.js.map +1 -0
- package/dist/stream/projections/index.cjs +6 -0
- package/dist/stream/projections/index.d.ts +6 -0
- package/dist/stream/projections/index.js +7 -0
- package/dist/stream/projections/media.cjs +81 -0
- package/dist/stream/projections/media.cjs.map +1 -0
- package/dist/stream/projections/media.d.cts +18 -0
- package/dist/stream/projections/media.d.cts.map +1 -0
- package/dist/stream/projections/media.d.ts +18 -0
- package/dist/stream/projections/media.d.ts.map +1 -0
- package/dist/stream/projections/media.js +78 -0
- package/dist/stream/projections/media.js.map +1 -0
- package/dist/stream/projections/messages.cjs +121 -0
- package/dist/stream/projections/messages.cjs.map +1 -0
- package/dist/stream/projections/messages.d.cts +8 -0
- package/dist/stream/projections/messages.d.cts.map +1 -0
- package/dist/stream/projections/messages.d.ts +8 -0
- package/dist/stream/projections/messages.d.ts.map +1 -0
- package/dist/stream/projections/messages.js +121 -0
- package/dist/stream/projections/messages.js.map +1 -0
- package/dist/stream/projections/runtime.cjs +44 -0
- package/dist/stream/projections/runtime.cjs.map +1 -0
- package/dist/stream/projections/runtime.js +44 -0
- package/dist/stream/projections/runtime.js.map +1 -0
- package/dist/stream/projections/tool-calls.cjs +50 -0
- package/dist/stream/projections/tool-calls.cjs.map +1 -0
- package/dist/stream/projections/tool-calls.d.cts +8 -0
- package/dist/stream/projections/tool-calls.d.cts.map +1 -0
- package/dist/stream/projections/tool-calls.d.ts +8 -0
- package/dist/stream/projections/tool-calls.d.ts.map +1 -0
- package/dist/stream/projections/tool-calls.js +50 -0
- package/dist/stream/projections/tool-calls.js.map +1 -0
- package/dist/stream/projections/values.cjs +52 -0
- package/dist/stream/projections/values.cjs.map +1 -0
- package/dist/stream/projections/values.d.cts +7 -0
- package/dist/stream/projections/values.d.cts.map +1 -0
- package/dist/stream/projections/values.d.ts +6 -0
- package/dist/stream/projections/values.d.ts.map +1 -0
- package/dist/stream/projections/values.js +52 -0
- package/dist/stream/projections/values.js.map +1 -0
- package/dist/stream/root-message-projection.cjs +256 -0
- package/dist/stream/root-message-projection.cjs.map +1 -0
- package/dist/stream/root-message-projection.js +256 -0
- package/dist/stream/root-message-projection.js.map +1 -0
- package/dist/stream/store.cjs +32 -0
- package/dist/stream/store.cjs.map +1 -0
- package/dist/stream/store.d.cts +37 -0
- package/dist/stream/store.d.cts.map +1 -0
- package/dist/stream/store.d.ts +37 -0
- package/dist/stream/store.d.ts.map +1 -0
- package/dist/stream/store.js +32 -0
- package/dist/stream/store.js.map +1 -0
- package/dist/stream/submit-coordinator.cjs +399 -0
- package/dist/stream/submit-coordinator.cjs.map +1 -0
- package/dist/stream/submit-coordinator.d.cts +27 -0
- package/dist/stream/submit-coordinator.d.cts.map +1 -0
- package/dist/stream/submit-coordinator.d.ts +27 -0
- package/dist/stream/submit-coordinator.d.ts.map +1 -0
- package/dist/stream/submit-coordinator.js +397 -0
- package/dist/stream/submit-coordinator.js.map +1 -0
- package/dist/stream/tool-calls.cjs +15 -0
- package/dist/stream/tool-calls.cjs.map +1 -0
- package/dist/stream/tool-calls.js +15 -0
- package/dist/stream/tool-calls.js.map +1 -0
- package/dist/stream/types-inference.d.cts +43 -0
- package/dist/stream/types-inference.d.cts.map +1 -0
- package/dist/stream/types-inference.d.ts +43 -0
- package/dist/stream/types-inference.d.ts.map +1 -0
- package/dist/stream/types.d.cts +354 -0
- package/dist/stream/types.d.cts.map +1 -0
- package/dist/stream/types.d.ts +354 -0
- package/dist/stream/types.d.ts.map +1 -0
- package/dist/types.d.cts +2 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/index.cjs +1 -1
- package/dist/ui/index.d.cts +3 -3
- package/dist/ui/index.d.ts +3 -3
- package/dist/ui/index.js +1 -1
- package/dist/ui/manager.cjs +1 -1
- package/dist/ui/manager.js +1 -1
- package/dist/ui/messages.cjs +50 -7
- package/dist/ui/messages.cjs.map +1 -1
- package/dist/ui/messages.d.cts.map +1 -1
- package/dist/ui/messages.d.ts.map +1 -1
- package/dist/ui/messages.js +51 -9
- package/dist/ui/messages.js.map +1 -1
- package/dist/ui/orchestrator-custom.cjs +1 -1
- package/dist/ui/orchestrator-custom.js +1 -1
- package/dist/ui/orchestrator.cjs +2 -2
- package/dist/ui/orchestrator.d.cts +1 -1
- package/dist/ui/orchestrator.d.ts +1 -1
- package/dist/ui/orchestrator.d.ts.map +1 -1
- package/dist/ui/orchestrator.js +2 -2
- package/dist/ui/stream/agent.d.cts +1 -1
- package/dist/ui/stream/agent.d.cts.map +1 -1
- package/dist/ui/stream/agent.d.ts +1 -1
- package/dist/ui/stream/agent.d.ts.map +1 -1
- package/dist/ui/stream/base.d.cts +7 -6
- package/dist/ui/stream/base.d.cts.map +1 -1
- package/dist/ui/stream/base.d.ts +7 -6
- package/dist/ui/stream/base.d.ts.map +1 -1
- package/dist/ui/stream/deep-agent.d.cts +1 -1
- package/dist/ui/stream/deep-agent.d.cts.map +1 -1
- package/dist/ui/stream/deep-agent.d.ts +1 -1
- package/dist/ui/stream/deep-agent.d.ts.map +1 -1
- package/dist/ui/stream/index.d.cts +4 -4
- package/dist/ui/stream/index.d.cts.map +1 -1
- package/dist/ui/stream/index.d.ts +4 -4
- package/dist/ui/stream/index.d.ts.map +1 -1
- package/dist/ui/types.d.cts +3 -2
- package/dist/ui/types.d.cts.map +1 -1
- package/dist/ui/types.d.ts +2 -1
- package/dist/ui/types.d.ts.map +1 -1
- package/package.json +18 -8
- package/dist/client.cjs.map +0 -1
- package/dist/client.d.cts.map +0 -1
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js.map +0 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { AsyncCaller, AsyncCallerParams } from "../utils/async_caller.js";
|
|
2
|
+
import { StreamProtocol } from "../types.js";
|
|
3
|
+
|
|
4
|
+
//#region src/client/base.d.ts
|
|
5
|
+
type HeaderValue = string | undefined | null;
|
|
6
|
+
/**
|
|
7
|
+
* Get the API key from the environment.
|
|
8
|
+
* Precedence:
|
|
9
|
+
* 1. explicit argument (if string)
|
|
10
|
+
* 2. LANGGRAPH_API_KEY
|
|
11
|
+
* 3. LANGSMITH_API_KEY
|
|
12
|
+
* 4. LANGCHAIN_API_KEY
|
|
13
|
+
*
|
|
14
|
+
* @param apiKey - API key provided as an argument. If null, skips environment lookup. If undefined, tries environment.
|
|
15
|
+
* @returns The API key if found, otherwise undefined
|
|
16
|
+
*/
|
|
17
|
+
declare function getApiKey(apiKey?: string | null): string | undefined;
|
|
18
|
+
type RequestHook = (url: URL, init: RequestInit) => Promise<RequestInit> | RequestInit;
|
|
19
|
+
interface ClientConfig {
|
|
20
|
+
apiUrl?: string;
|
|
21
|
+
/**
|
|
22
|
+
* API key for authentication.
|
|
23
|
+
* - If a string is provided, that key will be used
|
|
24
|
+
* - If undefined (default), the key will be auto-loaded from environment variables (LANGGRAPH_API_KEY, LANGSMITH_API_KEY, or LANGCHAIN_API_KEY)
|
|
25
|
+
* - If null, no API key will be set (skips auto-loading)
|
|
26
|
+
*/
|
|
27
|
+
apiKey?: string | null;
|
|
28
|
+
callerOptions?: AsyncCallerParams;
|
|
29
|
+
timeoutMs?: number;
|
|
30
|
+
defaultHeaders?: Record<string, HeaderValue>;
|
|
31
|
+
onRequest?: RequestHook;
|
|
32
|
+
streamProtocol?: StreamProtocol;
|
|
33
|
+
}
|
|
34
|
+
declare class BaseClient {
|
|
35
|
+
protected asyncCaller: AsyncCaller;
|
|
36
|
+
protected timeoutMs: number | undefined;
|
|
37
|
+
protected apiUrl: string;
|
|
38
|
+
protected defaultHeaders: Record<string, HeaderValue>;
|
|
39
|
+
protected onRequest?: RequestHook;
|
|
40
|
+
protected streamProtocol: StreamProtocol;
|
|
41
|
+
constructor(config?: ClientConfig);
|
|
42
|
+
protected prepareFetchOptions(path: string, options?: RequestInit & {
|
|
43
|
+
json?: unknown;
|
|
44
|
+
params?: Record<string, unknown>;
|
|
45
|
+
timeoutMs?: number | null;
|
|
46
|
+
withResponse?: boolean;
|
|
47
|
+
}): [url: URL, init: RequestInit];
|
|
48
|
+
protected fetch<T>(path: string, options: RequestInit & {
|
|
49
|
+
json?: unknown;
|
|
50
|
+
params?: Record<string, unknown>;
|
|
51
|
+
timeoutMs?: number | null;
|
|
52
|
+
signal: AbortSignal | undefined;
|
|
53
|
+
withResponse: true;
|
|
54
|
+
}): Promise<[T, Response]>;
|
|
55
|
+
protected fetch<T>(path: string, options?: RequestInit & {
|
|
56
|
+
json?: unknown;
|
|
57
|
+
params?: Record<string, unknown>;
|
|
58
|
+
timeoutMs?: number | null;
|
|
59
|
+
signal: AbortSignal | undefined;
|
|
60
|
+
withResponse?: false;
|
|
61
|
+
}): Promise<T>;
|
|
62
|
+
protected streamWithRetry<T extends {
|
|
63
|
+
id?: string;
|
|
64
|
+
event: string;
|
|
65
|
+
data: unknown;
|
|
66
|
+
}>(config: {
|
|
67
|
+
endpoint: string;
|
|
68
|
+
method?: string;
|
|
69
|
+
signal?: AbortSignal;
|
|
70
|
+
headers?: Record<string, string>;
|
|
71
|
+
params?: Record<string, unknown>;
|
|
72
|
+
json?: unknown;
|
|
73
|
+
maxRetries?: number;
|
|
74
|
+
onReconnect?: (options: {
|
|
75
|
+
attempt: number;
|
|
76
|
+
lastEventId?: string;
|
|
77
|
+
cause: unknown;
|
|
78
|
+
}) => void;
|
|
79
|
+
onInitialResponse?: (response: Response) => void | Promise<void>;
|
|
80
|
+
}): AsyncGenerator<T>;
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { BaseClient, ClientConfig, HeaderValue, RequestHook, getApiKey };
|
|
84
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","names":[],"sources":["../../src/client/base.ts"],"mappings":";;;;KAOY,WAAA;;;AA6EZ;;;;;AAqBA;;;;iBArBgB,SAAA,CAAU,MAAA;AAAA,KAqBd,WAAA,IACV,GAAA,EAAK,GAAA,EACL,IAAA,EAAM,WAAA,KACH,OAAA,CAAQ,WAAA,IAAe,WAAA;AAAA,UAEX,YAAA;EACf,MAAA;EAHqC;;;;;;EAUrC,MAAA;EACA,aAAA,GAAgB,iBAAA;EAChB,SAAA;EACA,cAAA,GAAiB,MAAA,SAAe,WAAA;EAChC,SAAA,GAAY,WAAA;EACZ,cAAA,GAAiB,cAAA;AAAA;AAAA,cAGN,UAAA;EAAA,UACD,WAAA,EAAa,WAAA;EAAA,UAEb,SAAA;EAAA,UAEA,MAAA;EAAA,UAEA,cAAA,EAAgB,MAAA,SAAe,WAAA;EAAA,UAE/B,SAAA,GAAY,WAAA;EAAA,UAEZ,cAAA,EAAgB,cAAA;EAE1B,WAAA,CAAY,MAAA,GAAS,YAAA;EAAA,UAsCX,mBAAA,CACR,IAAA,UACA,OAAA,GAAU,WAAA;IACR,IAAA;IACA,MAAA,GAAS,MAAA;IACT,SAAA;IACA,YAAA;EAAA,KAEA,GAAA,EAAK,GAAA,EAAK,IAAA,EAAM,WAAA;EAAA,UA+CJ,KAAA,GAAA,CACd,IAAA,UACA,OAAA,EAAS,WAAA;IACP,IAAA;IACA,MAAA,GAAS,MAAA;IACT,SAAA;IACA,MAAA,EAAQ,WAAA;IACR,YAAA;EAAA,IAED,OAAA,EAAS,CAAA,EAAG,QAAA;EAAA,UAEC,KAAA,GAAA,CACd,IAAA,UACA,OAAA,GAAU,WAAA;IACR,IAAA;IACA,MAAA,GAAS,MAAA;IACT,SAAA;IACA,MAAA,EAAQ,WAAA;IACR,YAAA;EAAA,IAED,OAAA,CAAQ,CAAA;EAAA,UAmCM,eAAA;IACH,EAAA;IAAa,KAAA;IAAe,IAAA;EAAA,EAAA,CACxC,MAAA;IACA,QAAA;IACA,MAAA;IACA,MAAA,GAAS,WAAA;IACT,OAAA,GAAU,MAAA;IACV,MAAA,GAAS,MAAA;IACT,IAAA;IACA,UAAA;IACA,WAAA,IAAe,OAAA;MACb,OAAA;MACA,WAAA;MACA,KAAA;IAAA;IAEF,iBAAA,IAAqB,QAAA,EAAU,QAAA,YAAoB,OAAA;EAAA,IACjD,cAAA,CAAe,CAAA;AAAA"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { AsyncCaller } from "../utils/async_caller.js";
|
|
2
|
+
import { getEnvironmentVariable } from "../utils/env.js";
|
|
3
|
+
import { mergeSignals } from "../utils/signals.js";
|
|
4
|
+
import { BytesLineDecoder, SSEDecoder } from "../utils/sse.js";
|
|
5
|
+
import { streamWithRetry } from "../utils/stream.js";
|
|
6
|
+
//#region src/client/base.ts
|
|
7
|
+
function* iterateHeaders(headers) {
|
|
8
|
+
let iter;
|
|
9
|
+
let shouldClear = false;
|
|
10
|
+
if (headers instanceof Headers) {
|
|
11
|
+
const entries = [];
|
|
12
|
+
headers.forEach((value, name) => {
|
|
13
|
+
entries.push([name, value]);
|
|
14
|
+
});
|
|
15
|
+
iter = entries;
|
|
16
|
+
} else if (Array.isArray(headers)) iter = headers;
|
|
17
|
+
else {
|
|
18
|
+
shouldClear = true;
|
|
19
|
+
iter = Object.entries(headers ?? {});
|
|
20
|
+
}
|
|
21
|
+
for (const item of iter) {
|
|
22
|
+
const name = item[0];
|
|
23
|
+
if (typeof name !== "string") throw new TypeError(`Expected header name to be a string, got ${typeof name}`);
|
|
24
|
+
const values = Array.isArray(item[1]) ? item[1] : [item[1]];
|
|
25
|
+
let didClear = false;
|
|
26
|
+
for (const value of values) {
|
|
27
|
+
if (value === void 0) continue;
|
|
28
|
+
if (shouldClear && !didClear) {
|
|
29
|
+
didClear = true;
|
|
30
|
+
yield [name, null];
|
|
31
|
+
}
|
|
32
|
+
yield [name, value];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function mergeHeaders(...headerObjects) {
|
|
37
|
+
const outputHeaders = new Headers();
|
|
38
|
+
for (const headers of headerObjects) {
|
|
39
|
+
if (!headers) continue;
|
|
40
|
+
for (const [name, value] of iterateHeaders(headers)) if (value === null) outputHeaders.delete(name);
|
|
41
|
+
else outputHeaders.append(name, value);
|
|
42
|
+
}
|
|
43
|
+
const headerEntries = [];
|
|
44
|
+
outputHeaders.forEach((value, name) => {
|
|
45
|
+
headerEntries.push([name, value]);
|
|
46
|
+
});
|
|
47
|
+
return Object.fromEntries(headerEntries);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get the API key from the environment.
|
|
51
|
+
* Precedence:
|
|
52
|
+
* 1. explicit argument (if string)
|
|
53
|
+
* 2. LANGGRAPH_API_KEY
|
|
54
|
+
* 3. LANGSMITH_API_KEY
|
|
55
|
+
* 4. LANGCHAIN_API_KEY
|
|
56
|
+
*
|
|
57
|
+
* @param apiKey - API key provided as an argument. If null, skips environment lookup. If undefined, tries environment.
|
|
58
|
+
* @returns The API key if found, otherwise undefined
|
|
59
|
+
*/
|
|
60
|
+
function getApiKey(apiKey) {
|
|
61
|
+
if (apiKey === null) return;
|
|
62
|
+
if (apiKey) return apiKey;
|
|
63
|
+
for (const prefix of [
|
|
64
|
+
"LANGGRAPH",
|
|
65
|
+
"LANGSMITH",
|
|
66
|
+
"LANGCHAIN"
|
|
67
|
+
]) {
|
|
68
|
+
const envKey = getEnvironmentVariable(`${prefix}_API_KEY`);
|
|
69
|
+
if (envKey) return envKey.trim().replace(/^["']|["']$/g, "");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
var BaseClient = class {
|
|
73
|
+
asyncCaller;
|
|
74
|
+
timeoutMs;
|
|
75
|
+
apiUrl;
|
|
76
|
+
defaultHeaders;
|
|
77
|
+
onRequest;
|
|
78
|
+
streamProtocol;
|
|
79
|
+
constructor(config) {
|
|
80
|
+
const callerOptions = {
|
|
81
|
+
maxRetries: 4,
|
|
82
|
+
maxConcurrency: 4,
|
|
83
|
+
...config?.callerOptions
|
|
84
|
+
};
|
|
85
|
+
let defaultApiUrl = "http://localhost:8123";
|
|
86
|
+
if (!config?.apiUrl && typeof globalThis === "object" && globalThis != null) {
|
|
87
|
+
const fetchSmb = Symbol.for("langgraph_api:fetch");
|
|
88
|
+
const urlSmb = Symbol.for("langgraph_api:url");
|
|
89
|
+
const global = globalThis;
|
|
90
|
+
if (global[fetchSmb]) callerOptions.fetch ??= global[fetchSmb];
|
|
91
|
+
if (global[urlSmb]) defaultApiUrl = global[urlSmb];
|
|
92
|
+
}
|
|
93
|
+
this.asyncCaller = new AsyncCaller(callerOptions);
|
|
94
|
+
this.timeoutMs = config?.timeoutMs;
|
|
95
|
+
this.apiUrl = config?.apiUrl?.replace(/\/$/, "") || defaultApiUrl;
|
|
96
|
+
this.defaultHeaders = config?.defaultHeaders || {};
|
|
97
|
+
this.onRequest = config?.onRequest;
|
|
98
|
+
this.streamProtocol = config?.streamProtocol ?? "legacy";
|
|
99
|
+
const apiKey = getApiKey(config?.apiKey);
|
|
100
|
+
if (apiKey) this.defaultHeaders["x-api-key"] = apiKey;
|
|
101
|
+
}
|
|
102
|
+
prepareFetchOptions(path, options) {
|
|
103
|
+
const mutatedOptions = {
|
|
104
|
+
...options,
|
|
105
|
+
headers: mergeHeaders(this.defaultHeaders, options?.headers)
|
|
106
|
+
};
|
|
107
|
+
if (mutatedOptions.json) {
|
|
108
|
+
mutatedOptions.body = JSON.stringify(mutatedOptions.json);
|
|
109
|
+
mutatedOptions.headers = mergeHeaders(mutatedOptions.headers, { "content-type": "application/json" });
|
|
110
|
+
delete mutatedOptions.json;
|
|
111
|
+
}
|
|
112
|
+
if (mutatedOptions.withResponse) delete mutatedOptions.withResponse;
|
|
113
|
+
let timeoutSignal = null;
|
|
114
|
+
if (typeof options?.timeoutMs !== "undefined") {
|
|
115
|
+
if (options.timeoutMs != null) timeoutSignal = AbortSignal.timeout(options.timeoutMs);
|
|
116
|
+
} else if (this.timeoutMs != null) timeoutSignal = AbortSignal.timeout(this.timeoutMs);
|
|
117
|
+
mutatedOptions.signal = mergeSignals(timeoutSignal, mutatedOptions.signal);
|
|
118
|
+
const targetUrl = new URL(`${this.apiUrl}${path}`);
|
|
119
|
+
if (mutatedOptions.params) {
|
|
120
|
+
for (const [key, value] of Object.entries(mutatedOptions.params)) {
|
|
121
|
+
if (value == null) continue;
|
|
122
|
+
const strValue = typeof value === "string" || typeof value === "number" ? value.toString() : JSON.stringify(value);
|
|
123
|
+
targetUrl.searchParams.append(key, strValue);
|
|
124
|
+
}
|
|
125
|
+
delete mutatedOptions.params;
|
|
126
|
+
}
|
|
127
|
+
return [targetUrl, mutatedOptions];
|
|
128
|
+
}
|
|
129
|
+
async fetch(path, options) {
|
|
130
|
+
const [url, init] = this.prepareFetchOptions(path, options);
|
|
131
|
+
let finalInit = init;
|
|
132
|
+
if (this.onRequest) finalInit = await this.onRequest(url, init);
|
|
133
|
+
const response = await this.asyncCaller.fetch(url.toString(), finalInit);
|
|
134
|
+
const body = (() => {
|
|
135
|
+
if (response.status === 202 || response.status === 204) return;
|
|
136
|
+
return response.json();
|
|
137
|
+
})();
|
|
138
|
+
if (options?.withResponse) return [await body, response];
|
|
139
|
+
return body;
|
|
140
|
+
}
|
|
141
|
+
async *streamWithRetry(config) {
|
|
142
|
+
const makeRequest = async (reconnectParams) => {
|
|
143
|
+
const requestEndpoint = reconnectParams?.reconnectPath || config.endpoint;
|
|
144
|
+
const isReconnect = !!reconnectParams?.reconnectPath;
|
|
145
|
+
const method = isReconnect ? "GET" : config.method || "GET";
|
|
146
|
+
const requestHeaders = isReconnect && reconnectParams?.lastEventId ? {
|
|
147
|
+
...config.headers,
|
|
148
|
+
"Last-Event-ID": reconnectParams.lastEventId
|
|
149
|
+
} : config.headers;
|
|
150
|
+
let [url, init] = this.prepareFetchOptions(requestEndpoint, {
|
|
151
|
+
method,
|
|
152
|
+
timeoutMs: null,
|
|
153
|
+
signal: config.signal,
|
|
154
|
+
headers: requestHeaders,
|
|
155
|
+
params: config.params,
|
|
156
|
+
json: isReconnect ? void 0 : config.json
|
|
157
|
+
});
|
|
158
|
+
if (this.onRequest != null) init = await this.onRequest(url, init);
|
|
159
|
+
const response = await this.asyncCaller.fetch(url.toString(), init);
|
|
160
|
+
if (!response.body) throw new Error("Expected response body from stream endpoint");
|
|
161
|
+
if (!isReconnect && config.onInitialResponse) await config.onInitialResponse(response);
|
|
162
|
+
return {
|
|
163
|
+
response,
|
|
164
|
+
stream: response.body.pipeThrough(BytesLineDecoder()).pipeThrough(SSEDecoder())
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
yield* streamWithRetry(makeRequest, {
|
|
168
|
+
maxRetries: config.maxRetries ?? 5,
|
|
169
|
+
signal: config.signal,
|
|
170
|
+
onReconnect: config.onReconnect
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
const REGEX_RUN_METADATA = /(\/threads\/(?<thread_id>.+))?\/runs\/(?<run_id>.+)/;
|
|
175
|
+
function getRunMetadataFromResponse(response) {
|
|
176
|
+
const contentLocation = response.headers.get("Content-Location");
|
|
177
|
+
if (!contentLocation) return void 0;
|
|
178
|
+
const match = REGEX_RUN_METADATA.exec(contentLocation);
|
|
179
|
+
if (!match?.groups?.run_id) return void 0;
|
|
180
|
+
return {
|
|
181
|
+
run_id: match.groups.run_id,
|
|
182
|
+
thread_id: match.groups.thread_id || void 0
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
186
|
+
export { BaseClient, getApiKey, getRunMetadataFromResponse };
|
|
187
|
+
|
|
188
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","names":[],"sources":["../../src/client/base.ts"],"sourcesContent":["import { AsyncCaller, AsyncCallerParams } from \"../utils/async_caller.js\";\nimport { getEnvironmentVariable } from \"../utils/env.js\";\nimport { mergeSignals } from \"../utils/signals.js\";\nimport { BytesLineDecoder, SSEDecoder } from \"../utils/sse.js\";\nimport { streamWithRetry, StreamRequestParams } from \"../utils/stream.js\";\nimport type { StreamProtocol } from \"../types.js\";\n\nexport type HeaderValue = string | undefined | null;\n\nexport function* iterateHeaders(\n headers: HeadersInit | Record<string, HeaderValue>\n): IterableIterator<[string, string | null]> {\n let iter: Iterable<(HeaderValue | HeaderValue | null[])[]>;\n let shouldClear = false;\n\n // eslint-disable-next-line no-instanceof/no-instanceof\n if (headers instanceof Headers) {\n const entries: [string, string][] = [];\n headers.forEach((value, name) => {\n entries.push([name, value]);\n });\n iter = entries;\n } else if (Array.isArray(headers)) {\n iter = headers;\n } else {\n shouldClear = true;\n iter = Object.entries(headers ?? {});\n }\n\n for (const item of iter) {\n const name = item[0];\n if (typeof name !== \"string\")\n throw new TypeError(\n `Expected header name to be a string, got ${typeof name}`\n );\n const values = Array.isArray(item[1]) ? item[1] : [item[1]];\n let didClear = false;\n\n for (const value of values) {\n if (value === undefined) continue;\n\n if (shouldClear && !didClear) {\n didClear = true;\n yield [name, null];\n }\n yield [name, value];\n }\n }\n}\n\nexport function mergeHeaders(\n ...headerObjects: (\n | HeadersInit\n | Record<string, HeaderValue>\n | undefined\n | null\n )[]\n) {\n const outputHeaders = new Headers();\n for (const headers of headerObjects) {\n if (!headers) continue;\n for (const [name, value] of iterateHeaders(headers)) {\n if (value === null) outputHeaders.delete(name);\n else outputHeaders.append(name, value);\n }\n }\n const headerEntries: [string, string][] = [];\n outputHeaders.forEach((value, name) => {\n headerEntries.push([name, value]);\n });\n return Object.fromEntries(headerEntries);\n}\n\n/**\n * Get the API key from the environment.\n * Precedence:\n * 1. explicit argument (if string)\n * 2. LANGGRAPH_API_KEY\n * 3. LANGSMITH_API_KEY\n * 4. LANGCHAIN_API_KEY\n *\n * @param apiKey - API key provided as an argument. If null, skips environment lookup. If undefined, tries environment.\n * @returns The API key if found, otherwise undefined\n */\nexport function getApiKey(apiKey?: string | null): string | undefined {\n if (apiKey === null) {\n return undefined;\n }\n\n if (apiKey) {\n return apiKey;\n }\n\n const prefixes = [\"LANGGRAPH\", \"LANGSMITH\", \"LANGCHAIN\"];\n\n for (const prefix of prefixes) {\n const envKey = getEnvironmentVariable(`${prefix}_API_KEY`);\n if (envKey) {\n return envKey.trim().replace(/^[\"']|[\"']$/g, \"\");\n }\n }\n\n return undefined;\n}\n\nexport type RequestHook = (\n url: URL,\n init: RequestInit\n) => Promise<RequestInit> | RequestInit;\n\nexport interface ClientConfig {\n apiUrl?: string;\n /**\n * API key for authentication.\n * - If a string is provided, that key will be used\n * - If undefined (default), the key will be auto-loaded from environment variables (LANGGRAPH_API_KEY, LANGSMITH_API_KEY, or LANGCHAIN_API_KEY)\n * - If null, no API key will be set (skips auto-loading)\n */\n apiKey?: string | null;\n callerOptions?: AsyncCallerParams;\n timeoutMs?: number;\n defaultHeaders?: Record<string, HeaderValue>;\n onRequest?: RequestHook;\n streamProtocol?: StreamProtocol;\n}\n\nexport class BaseClient {\n protected asyncCaller: AsyncCaller;\n\n protected timeoutMs: number | undefined;\n\n protected apiUrl: string;\n\n protected defaultHeaders: Record<string, HeaderValue>;\n\n protected onRequest?: RequestHook;\n\n protected streamProtocol: StreamProtocol;\n\n constructor(config?: ClientConfig) {\n const callerOptions = {\n maxRetries: 4,\n maxConcurrency: 4,\n ...config?.callerOptions,\n };\n\n let defaultApiUrl = \"http://localhost:8123\";\n if (\n !config?.apiUrl &&\n typeof globalThis === \"object\" &&\n globalThis != null\n ) {\n const fetchSmb = Symbol.for(\"langgraph_api:fetch\");\n const urlSmb = Symbol.for(\"langgraph_api:url\");\n\n const global = globalThis as unknown as {\n [fetchSmb]?: typeof fetch;\n [urlSmb]?: string;\n };\n\n if (global[fetchSmb]) callerOptions.fetch ??= global[fetchSmb];\n if (global[urlSmb]) defaultApiUrl = global[urlSmb];\n }\n\n this.asyncCaller = new AsyncCaller(callerOptions);\n this.timeoutMs = config?.timeoutMs;\n\n this.apiUrl = config?.apiUrl?.replace(/\\/$/, \"\") || defaultApiUrl;\n this.defaultHeaders = config?.defaultHeaders || {};\n this.onRequest = config?.onRequest;\n this.streamProtocol = config?.streamProtocol ?? \"legacy\";\n const apiKey = getApiKey(config?.apiKey);\n if (apiKey) {\n this.defaultHeaders[\"x-api-key\"] = apiKey;\n }\n }\n\n protected prepareFetchOptions(\n path: string,\n options?: RequestInit & {\n json?: unknown;\n params?: Record<string, unknown>;\n timeoutMs?: number | null;\n withResponse?: boolean;\n }\n ): [url: URL, init: RequestInit] {\n const mutatedOptions = {\n ...options,\n headers: mergeHeaders(this.defaultHeaders, options?.headers),\n };\n\n if (mutatedOptions.json) {\n mutatedOptions.body = JSON.stringify(mutatedOptions.json);\n mutatedOptions.headers = mergeHeaders(mutatedOptions.headers, {\n \"content-type\": \"application/json\",\n });\n delete mutatedOptions.json;\n }\n\n if (mutatedOptions.withResponse) {\n delete mutatedOptions.withResponse;\n }\n\n let timeoutSignal: AbortSignal | null = null;\n if (typeof options?.timeoutMs !== \"undefined\") {\n if (options.timeoutMs != null) {\n timeoutSignal = AbortSignal.timeout(options.timeoutMs);\n }\n } else if (this.timeoutMs != null) {\n timeoutSignal = AbortSignal.timeout(this.timeoutMs);\n }\n\n mutatedOptions.signal = mergeSignals(timeoutSignal, mutatedOptions.signal);\n const targetUrl = new URL(`${this.apiUrl}${path}`);\n\n if (mutatedOptions.params) {\n for (const [key, value] of Object.entries(mutatedOptions.params)) {\n if (value == null) continue;\n\n const strValue =\n typeof value === \"string\" || typeof value === \"number\"\n ? value.toString()\n : JSON.stringify(value);\n\n targetUrl.searchParams.append(key, strValue);\n }\n delete mutatedOptions.params;\n }\n\n return [targetUrl, mutatedOptions];\n }\n\n protected async fetch<T>(\n path: string,\n options: RequestInit & {\n json?: unknown;\n params?: Record<string, unknown>;\n timeoutMs?: number | null;\n signal: AbortSignal | undefined;\n withResponse: true;\n }\n ): Promise<[T, Response]>;\n\n protected async fetch<T>(\n path: string,\n options?: RequestInit & {\n json?: unknown;\n params?: Record<string, unknown>;\n timeoutMs?: number | null;\n signal: AbortSignal | undefined;\n withResponse?: false;\n }\n ): Promise<T>;\n\n protected async fetch<T>(\n path: string,\n options?: RequestInit & {\n json?: unknown;\n params?: Record<string, unknown>;\n timeoutMs?: number | null;\n signal: AbortSignal | undefined;\n withResponse?: boolean;\n }\n ): Promise<T | [T, Response]> {\n const [url, init] = this.prepareFetchOptions(path, options);\n\n let finalInit = init;\n if (this.onRequest) {\n finalInit = await this.onRequest(url, init);\n }\n\n const response = await this.asyncCaller.fetch(url.toString(), finalInit);\n\n const body = (() => {\n if (response.status === 202 || response.status === 204) {\n return undefined as T;\n }\n return response.json() as Promise<T>;\n })();\n\n if (options?.withResponse) {\n return [await body, response];\n }\n\n return body;\n }\n\n protected async *streamWithRetry<\n T extends { id?: string; event: string; data: unknown },\n >(config: {\n endpoint: string;\n method?: string;\n signal?: AbortSignal;\n headers?: Record<string, string>;\n params?: Record<string, unknown>;\n json?: unknown;\n maxRetries?: number;\n onReconnect?: (options: {\n attempt: number;\n lastEventId?: string;\n cause: unknown;\n }) => void;\n onInitialResponse?: (response: Response) => void | Promise<void>;\n }): AsyncGenerator<T> {\n const makeRequest = async (reconnectParams?: StreamRequestParams) => {\n const requestEndpoint = reconnectParams?.reconnectPath || config.endpoint;\n\n const isReconnect = !!reconnectParams?.reconnectPath;\n const method = isReconnect ? \"GET\" : config.method || \"GET\";\n\n const requestHeaders =\n isReconnect && reconnectParams?.lastEventId\n ? { ...config.headers, \"Last-Event-ID\": reconnectParams.lastEventId }\n : config.headers;\n\n // oxlint-disable-next-line prefer-const -- init is reassigned by onRequest hook\n let [url, init] = this.prepareFetchOptions(requestEndpoint, {\n method,\n timeoutMs: null,\n signal: config.signal,\n headers: requestHeaders,\n params: config.params,\n json: isReconnect ? undefined : config.json,\n });\n\n if (this.onRequest != null) {\n init = await this.onRequest(url, init);\n }\n\n const response = await this.asyncCaller.fetch(url.toString(), init);\n if (!response.body) {\n throw new Error(\"Expected response body from stream endpoint\");\n }\n\n if (!isReconnect && config.onInitialResponse) {\n await config.onInitialResponse(response);\n }\n\n const stream: ReadableStream<T> = response.body\n .pipeThrough(BytesLineDecoder())\n .pipeThrough(SSEDecoder()) as ReadableStream<T>;\n\n return { response, stream };\n };\n\n yield* streamWithRetry(makeRequest, {\n maxRetries: config.maxRetries ?? 5,\n signal: config.signal,\n onReconnect: config.onReconnect,\n });\n }\n}\n\nexport const REGEX_RUN_METADATA =\n /(\\/threads\\/(?<thread_id>.+))?\\/runs\\/(?<run_id>.+)/;\n\nexport function getRunMetadataFromResponse(\n response: Response\n): { run_id: string; thread_id?: string } | undefined {\n const contentLocation = response.headers.get(\"Content-Location\");\n if (!contentLocation) return undefined;\n\n const match = REGEX_RUN_METADATA.exec(contentLocation);\n\n if (!match?.groups?.run_id) return undefined;\n return {\n run_id: match.groups.run_id,\n thread_id: match.groups.thread_id || undefined,\n };\n}\n\nexport const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,KAAK,oBAAoB,iBAAiB;IAC1D;IACA,WAAW;IACX,QAAQ,OAAO;IACf,SAAS;IACT,QAAQ,OAAO;IACf,MAAM,cAAc,KAAA,IAAY,OAAO;IACxC,CAAC;AAEF,OAAI,KAAK,aAAa,KACpB,QAAO,MAAM,KAAK,UAAU,KAAK,KAAK;GAGxC,MAAM,WAAW,MAAM,KAAK,YAAY,MAAM,IAAI,UAAU,EAAE,KAAK;AACnE,OAAI,CAAC,SAAS,KACZ,OAAM,IAAI,MAAM,8CAA8C;AAGhE,OAAI,CAAC,eAAe,OAAO,kBACzB,OAAM,OAAO,kBAAkB,SAAS;AAO1C,UAAO;IAAE;IAAU,QAJe,SAAS,KACxC,YAAY,kBAAkB,CAAC,CAC/B,YAAY,YAAY,CAAC;IAED;;AAG7B,SAAO,gBAAgB,aAAa;GAClC,YAAY,OAAO,cAAc;GACjC,QAAQ,OAAO;GACf,aAAa,OAAO;GACrB,CAAC;;;AAIN,MAAa,qBACX;AAEF,SAAgB,2BACd,UACoD;CACpD,MAAM,kBAAkB,SAAS,QAAQ,IAAI,mBAAmB;AAChE,KAAI,CAAC,gBAAiB,QAAO,KAAA;CAE7B,MAAM,QAAQ,mBAAmB,KAAK,gBAAgB;AAEtD,KAAI,CAAC,OAAO,QAAQ,OAAQ,QAAO,KAAA;AACnC,QAAO;EACL,QAAQ,MAAM,OAAO;EACrB,WAAW,MAAM,OAAO,aAAa,KAAA;EACtC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
const require_base = require("../base.cjs");
|
|
2
|
+
//#region src/client/crons/index.ts
|
|
3
|
+
var CronsClient = class extends require_base.BaseClient {
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param threadId The ID of the thread.
|
|
7
|
+
* @param assistantId Assistant ID to use for this cron job.
|
|
8
|
+
* @param payload Payload for creating a cron job.
|
|
9
|
+
* @returns The created background run.
|
|
10
|
+
*/
|
|
11
|
+
async createForThread(threadId, assistantId, payload) {
|
|
12
|
+
const json = {
|
|
13
|
+
schedule: payload?.schedule,
|
|
14
|
+
input: payload?.input,
|
|
15
|
+
config: payload?.config,
|
|
16
|
+
context: payload?.context,
|
|
17
|
+
metadata: payload?.metadata,
|
|
18
|
+
assistant_id: assistantId,
|
|
19
|
+
interrupt_before: payload?.interruptBefore,
|
|
20
|
+
interrupt_after: payload?.interruptAfter,
|
|
21
|
+
webhook: payload?.webhook,
|
|
22
|
+
multitask_strategy: payload?.multitaskStrategy,
|
|
23
|
+
checkpoint_during: payload?.checkpointDuring,
|
|
24
|
+
durability: payload?.durability,
|
|
25
|
+
enabled: payload?.enabled,
|
|
26
|
+
timezone: payload?.timezone,
|
|
27
|
+
stream_mode: payload?.streamMode,
|
|
28
|
+
stream_subgraphs: payload?.streamSubgraphs,
|
|
29
|
+
stream_resumable: payload?.streamResumable,
|
|
30
|
+
end_time: payload?.endTime,
|
|
31
|
+
on_run_completed: payload?.onRunCompleted
|
|
32
|
+
};
|
|
33
|
+
return this.fetch(`/threads/${threadId}/runs/crons`, {
|
|
34
|
+
method: "POST",
|
|
35
|
+
json,
|
|
36
|
+
signal: payload?.signal
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param assistantId Assistant ID to use for this cron job.
|
|
42
|
+
* @param payload Payload for creating a cron job.
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
async create(assistantId, payload) {
|
|
46
|
+
const json = {
|
|
47
|
+
schedule: payload?.schedule,
|
|
48
|
+
input: payload?.input,
|
|
49
|
+
config: payload?.config,
|
|
50
|
+
context: payload?.context,
|
|
51
|
+
metadata: payload?.metadata,
|
|
52
|
+
assistant_id: assistantId,
|
|
53
|
+
interrupt_before: payload?.interruptBefore,
|
|
54
|
+
interrupt_after: payload?.interruptAfter,
|
|
55
|
+
webhook: payload?.webhook,
|
|
56
|
+
on_run_completed: payload?.onRunCompleted,
|
|
57
|
+
multitask_strategy: payload?.multitaskStrategy,
|
|
58
|
+
checkpoint_during: payload?.checkpointDuring,
|
|
59
|
+
durability: payload?.durability,
|
|
60
|
+
enabled: payload?.enabled,
|
|
61
|
+
timezone: payload?.timezone,
|
|
62
|
+
stream_mode: payload?.streamMode,
|
|
63
|
+
stream_subgraphs: payload?.streamSubgraphs,
|
|
64
|
+
stream_resumable: payload?.streamResumable,
|
|
65
|
+
end_time: payload?.endTime
|
|
66
|
+
};
|
|
67
|
+
return this.fetch(`/runs/crons`, {
|
|
68
|
+
method: "POST",
|
|
69
|
+
json,
|
|
70
|
+
signal: payload?.signal
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Update a cron job by ID.
|
|
75
|
+
*
|
|
76
|
+
* @param cronId The cron ID to update.
|
|
77
|
+
* @param payload Payload for updating a cron job.
|
|
78
|
+
* @returns The updated cron job.
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
async update(cronId, payload) {
|
|
82
|
+
const json = {};
|
|
83
|
+
if (payload?.schedule !== void 0) json.schedule = payload.schedule;
|
|
84
|
+
if (payload?.timezone !== void 0) json.timezone = payload.timezone;
|
|
85
|
+
if (payload?.endTime !== void 0) json.end_time = payload.endTime;
|
|
86
|
+
if (payload?.input !== void 0) json.input = payload.input;
|
|
87
|
+
if (payload?.metadata !== void 0) json.metadata = payload.metadata;
|
|
88
|
+
if (payload?.config !== void 0) json.config = payload.config;
|
|
89
|
+
if (payload?.context !== void 0) json.context = payload.context;
|
|
90
|
+
if (payload?.webhook !== void 0) json.webhook = payload.webhook;
|
|
91
|
+
if (payload?.interruptBefore !== void 0) json.interrupt_before = payload.interruptBefore;
|
|
92
|
+
if (payload?.interruptAfter !== void 0) json.interrupt_after = payload.interruptAfter;
|
|
93
|
+
if (payload?.onRunCompleted !== void 0) json.on_run_completed = payload.onRunCompleted;
|
|
94
|
+
if (payload?.enabled !== void 0) json.enabled = payload.enabled;
|
|
95
|
+
if (payload?.streamMode !== void 0) json.stream_mode = payload.streamMode;
|
|
96
|
+
if (payload?.streamSubgraphs !== void 0) json.stream_subgraphs = payload.streamSubgraphs;
|
|
97
|
+
if (payload?.streamResumable !== void 0) json.stream_resumable = payload.streamResumable;
|
|
98
|
+
if (payload?.durability !== void 0) json.durability = payload.durability;
|
|
99
|
+
return this.fetch(`/runs/crons/${cronId}`, {
|
|
100
|
+
method: "PATCH",
|
|
101
|
+
json,
|
|
102
|
+
signal: payload?.signal
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Delete a cron job by ID.
|
|
107
|
+
*
|
|
108
|
+
* @param cronId Cron ID of Cron job to delete.
|
|
109
|
+
* @param options Optional parameters for the request.
|
|
110
|
+
*/
|
|
111
|
+
async delete(cronId, options) {
|
|
112
|
+
await this.fetch(`/runs/crons/${cronId}`, {
|
|
113
|
+
method: "DELETE",
|
|
114
|
+
signal: options?.signal
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
*
|
|
119
|
+
* @param query Query options.
|
|
120
|
+
* @returns List of crons.
|
|
121
|
+
*/
|
|
122
|
+
async search(query) {
|
|
123
|
+
return this.fetch("/runs/crons/search", {
|
|
124
|
+
method: "POST",
|
|
125
|
+
json: {
|
|
126
|
+
assistant_id: query?.assistantId ?? void 0,
|
|
127
|
+
thread_id: query?.threadId ?? void 0,
|
|
128
|
+
enabled: query?.enabled ?? void 0,
|
|
129
|
+
limit: query?.limit ?? 10,
|
|
130
|
+
offset: query?.offset ?? 0,
|
|
131
|
+
sort_by: query?.sortBy ?? void 0,
|
|
132
|
+
sort_order: query?.sortOrder ?? void 0,
|
|
133
|
+
select: query?.select ?? void 0
|
|
134
|
+
},
|
|
135
|
+
signal: query?.signal
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Count cron jobs matching filters.
|
|
140
|
+
*
|
|
141
|
+
* @param query.assistantId Assistant ID to filter by.
|
|
142
|
+
* @param query.threadId Thread ID to filter by.
|
|
143
|
+
* @returns Number of cron jobs matching the criteria.
|
|
144
|
+
*/
|
|
145
|
+
async count(query) {
|
|
146
|
+
return this.fetch(`/runs/crons/count`, {
|
|
147
|
+
method: "POST",
|
|
148
|
+
json: {
|
|
149
|
+
assistant_id: query?.assistantId ?? void 0,
|
|
150
|
+
thread_id: query?.threadId ?? void 0
|
|
151
|
+
},
|
|
152
|
+
signal: query?.signal
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
//#endregion
|
|
157
|
+
exports.CronsClient = CronsClient;
|
|
158
|
+
|
|
159
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["BaseClient"],"sources":["../../../src/client/crons/index.ts"],"sourcesContent":["import {\n Cron,\n CronSelectField,\n CronCreateForThreadResponse,\n CronCreateResponse,\n CronSortBy,\n SortOrder,\n} from \"../../schema.js\";\nimport type { CronsCreatePayload, CronsUpdatePayload } from \"../../types.js\";\nimport { BaseClient } from \"../base.js\";\n\nexport class CronsClient extends BaseClient {\n /**\n *\n * @param threadId The ID of the thread.\n * @param assistantId Assistant ID to use for this cron job.\n * @param payload Payload for creating a cron job.\n * @returns The created background run.\n */\n async createForThread(\n threadId: string,\n assistantId: string,\n payload?: CronsCreatePayload\n ): Promise<CronCreateForThreadResponse> {\n const json: Record<string, unknown> = {\n schedule: payload?.schedule,\n input: payload?.input,\n config: payload?.config,\n context: payload?.context,\n metadata: payload?.metadata,\n assistant_id: assistantId,\n interrupt_before: payload?.interruptBefore,\n interrupt_after: payload?.interruptAfter,\n webhook: payload?.webhook,\n multitask_strategy: payload?.multitaskStrategy,\n checkpoint_during: payload?.checkpointDuring,\n durability: payload?.durability,\n enabled: payload?.enabled,\n timezone: payload?.timezone,\n stream_mode: payload?.streamMode,\n stream_subgraphs: payload?.streamSubgraphs,\n stream_resumable: payload?.streamResumable,\n end_time: payload?.endTime,\n on_run_completed: payload?.onRunCompleted,\n };\n return this.fetch<CronCreateForThreadResponse>(\n `/threads/${threadId}/runs/crons`,\n {\n method: \"POST\",\n json,\n signal: payload?.signal,\n }\n );\n }\n\n /**\n *\n * @param assistantId Assistant ID to use for this cron job.\n * @param payload Payload for creating a cron job.\n * @returns\n */\n async create(\n assistantId: string,\n payload?: CronsCreatePayload\n ): Promise<CronCreateResponse> {\n const json: Record<string, unknown> = {\n schedule: payload?.schedule,\n input: payload?.input,\n config: payload?.config,\n context: payload?.context,\n metadata: payload?.metadata,\n assistant_id: assistantId,\n interrupt_before: payload?.interruptBefore,\n interrupt_after: payload?.interruptAfter,\n webhook: payload?.webhook,\n on_run_completed: payload?.onRunCompleted,\n multitask_strategy: payload?.multitaskStrategy,\n checkpoint_during: payload?.checkpointDuring,\n durability: payload?.durability,\n enabled: payload?.enabled,\n timezone: payload?.timezone,\n stream_mode: payload?.streamMode,\n stream_subgraphs: payload?.streamSubgraphs,\n stream_resumable: payload?.streamResumable,\n end_time: payload?.endTime,\n };\n return this.fetch<CronCreateResponse>(`/runs/crons`, {\n method: \"POST\",\n json,\n signal: payload?.signal,\n });\n }\n\n /**\n * Update a cron job by ID.\n *\n * @param cronId The cron ID to update.\n * @param payload Payload for updating a cron job.\n * @returns The updated cron job.\n * ```\n */\n async update(cronId: string, payload?: CronsUpdatePayload): Promise<Cron> {\n const json: Record<string, unknown> = {};\n\n if (payload?.schedule !== undefined) {\n json.schedule = payload.schedule;\n }\n if (payload?.timezone !== undefined) {\n json.timezone = payload.timezone;\n }\n if (payload?.endTime !== undefined) {\n json.end_time = payload.endTime;\n }\n if (payload?.input !== undefined) {\n json.input = payload.input;\n }\n if (payload?.metadata !== undefined) {\n json.metadata = payload.metadata;\n }\n if (payload?.config !== undefined) {\n json.config = payload.config;\n }\n if (payload?.context !== undefined) {\n json.context = payload.context;\n }\n if (payload?.webhook !== undefined) {\n json.webhook = payload.webhook;\n }\n if (payload?.interruptBefore !== undefined) {\n json.interrupt_before = payload.interruptBefore;\n }\n if (payload?.interruptAfter !== undefined) {\n json.interrupt_after = payload.interruptAfter;\n }\n if (payload?.onRunCompleted !== undefined) {\n json.on_run_completed = payload.onRunCompleted;\n }\n if (payload?.enabled !== undefined) {\n json.enabled = payload.enabled;\n }\n if (payload?.streamMode !== undefined) {\n json.stream_mode = payload.streamMode;\n }\n if (payload?.streamSubgraphs !== undefined) {\n json.stream_subgraphs = payload.streamSubgraphs;\n }\n if (payload?.streamResumable !== undefined) {\n json.stream_resumable = payload.streamResumable;\n }\n if (payload?.durability !== undefined) {\n json.durability = payload.durability;\n }\n\n return this.fetch<Cron>(`/runs/crons/${cronId}`, {\n method: \"PATCH\",\n json,\n signal: payload?.signal,\n });\n }\n\n /**\n * Delete a cron job by ID.\n *\n * @param cronId Cron ID of Cron job to delete.\n * @param options Optional parameters for the request.\n */\n async delete(\n cronId: string,\n options?: { signal?: AbortSignal }\n ): Promise<void> {\n await this.fetch<void>(`/runs/crons/${cronId}`, {\n method: \"DELETE\",\n signal: options?.signal,\n });\n }\n\n /**\n *\n * @param query Query options.\n * @returns List of crons.\n */\n async search(query?: {\n assistantId?: string;\n threadId?: string;\n enabled?: boolean;\n limit?: number;\n offset?: number;\n sortBy?: CronSortBy;\n sortOrder?: SortOrder;\n select?: CronSelectField[];\n signal?: AbortSignal;\n }): Promise<Cron[]> {\n return this.fetch<Cron[]>(\"/runs/crons/search\", {\n method: \"POST\",\n json: {\n assistant_id: query?.assistantId ?? undefined,\n thread_id: query?.threadId ?? undefined,\n enabled: query?.enabled ?? undefined,\n limit: query?.limit ?? 10,\n offset: query?.offset ?? 0,\n sort_by: query?.sortBy ?? undefined,\n sort_order: query?.sortOrder ?? undefined,\n select: query?.select ?? undefined,\n },\n signal: query?.signal,\n });\n }\n\n /**\n * Count cron jobs matching filters.\n *\n * @param query.assistantId Assistant ID to filter by.\n * @param query.threadId Thread ID to filter by.\n * @returns Number of cron jobs matching the criteria.\n */\n async count(query?: {\n assistantId?: string;\n threadId?: string;\n signal?: AbortSignal;\n }): Promise<number> {\n return this.fetch<number>(`/runs/crons/count`, {\n method: \"POST\",\n json: {\n assistant_id: query?.assistantId ?? undefined,\n thread_id: query?.threadId ?? undefined,\n },\n signal: query?.signal,\n });\n }\n}\n"],"mappings":";;AAWA,IAAa,cAAb,cAAiCA,aAAAA,WAAW;;;;;;;;CAQ1C,MAAM,gBACJ,UACA,aACA,SACsC;EACtC,MAAM,OAAgC;GACpC,UAAU,SAAS;GACnB,OAAO,SAAS;GAChB,QAAQ,SAAS;GACjB,SAAS,SAAS;GAClB,UAAU,SAAS;GACnB,cAAc;GACd,kBAAkB,SAAS;GAC3B,iBAAiB,SAAS;GAC1B,SAAS,SAAS;GAClB,oBAAoB,SAAS;GAC7B,mBAAmB,SAAS;GAC5B,YAAY,SAAS;GACrB,SAAS,SAAS;GAClB,UAAU,SAAS;GACnB,aAAa,SAAS;GACtB,kBAAkB,SAAS;GAC3B,kBAAkB,SAAS;GAC3B,UAAU,SAAS;GACnB,kBAAkB,SAAS;GAC5B;AACD,SAAO,KAAK,MACV,YAAY,SAAS,cACrB;GACE,QAAQ;GACR;GACA,QAAQ,SAAS;GAClB,CACF;;;;;;;;CASH,MAAM,OACJ,aACA,SAC6B;EAC7B,MAAM,OAAgC;GACpC,UAAU,SAAS;GACnB,OAAO,SAAS;GAChB,QAAQ,SAAS;GACjB,SAAS,SAAS;GAClB,UAAU,SAAS;GACnB,cAAc;GACd,kBAAkB,SAAS;GAC3B,iBAAiB,SAAS;GAC1B,SAAS,SAAS;GAClB,kBAAkB,SAAS;GAC3B,oBAAoB,SAAS;GAC7B,mBAAmB,SAAS;GAC5B,YAAY,SAAS;GACrB,SAAS,SAAS;GAClB,UAAU,SAAS;GACnB,aAAa,SAAS;GACtB,kBAAkB,SAAS;GAC3B,kBAAkB,SAAS;GAC3B,UAAU,SAAS;GACpB;AACD,SAAO,KAAK,MAA0B,eAAe;GACnD,QAAQ;GACR;GACA,QAAQ,SAAS;GAClB,CAAC;;;;;;;;;;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AAO,KAAK,MAAc,sBAAsB;GAC9C,QAAQ;GACR,MAAM;IACJ,cAAc,OAAO,eAAe,KAAA;IACpC,WAAW,OAAO,YAAY,KAAA;IAC9B,SAAS,OAAO,WAAW,KAAA;IAC3B,OAAO,OAAO,SAAS;IACvB,QAAQ,OAAO,UAAU;IACzB,SAAS,OAAO,UAAU,KAAA;IAC1B,YAAY,OAAO,aAAa,KAAA;IAChC,QAAQ,OAAO,UAAU,KAAA;IAC1B;GACD,QAAQ,OAAO;GAChB,CAAC;;;;;;;;;CAUJ,MAAM,MAAM,OAIQ;AAClB,SAAO,KAAK,MAAc,qBAAqB;GAC7C,QAAQ;GACR,MAAM;IACJ,cAAc,OAAO,eAAe,KAAA;IACpC,WAAW,OAAO,YAAY,KAAA;IAC/B;GACD,QAAQ,OAAO;GAChB,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Cron, CronCreateForThreadResponse, CronCreateResponse, CronSelectField, CronSortBy, SortOrder } from "../../schema.cjs";
|
|
2
|
+
import { CronsCreatePayload, CronsUpdatePayload } from "../../types.cjs";
|
|
3
|
+
import { BaseClient } from "../base.cjs";
|
|
4
|
+
|
|
5
|
+
//#region src/client/crons/index.d.ts
|
|
6
|
+
declare class CronsClient extends BaseClient {
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param threadId The ID of the thread.
|
|
10
|
+
* @param assistantId Assistant ID to use for this cron job.
|
|
11
|
+
* @param payload Payload for creating a cron job.
|
|
12
|
+
* @returns The created background run.
|
|
13
|
+
*/
|
|
14
|
+
createForThread(threadId: string, assistantId: string, payload?: CronsCreatePayload): Promise<CronCreateForThreadResponse>;
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param assistantId Assistant ID to use for this cron job.
|
|
18
|
+
* @param payload Payload for creating a cron job.
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
create(assistantId: string, payload?: CronsCreatePayload): Promise<CronCreateResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Update a cron job by ID.
|
|
24
|
+
*
|
|
25
|
+
* @param cronId The cron ID to update.
|
|
26
|
+
* @param payload Payload for updating a cron job.
|
|
27
|
+
* @returns The updated cron job.
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
update(cronId: string, payload?: CronsUpdatePayload): Promise<Cron>;
|
|
31
|
+
/**
|
|
32
|
+
* Delete a cron job by ID.
|
|
33
|
+
*
|
|
34
|
+
* @param cronId Cron ID of Cron job to delete.
|
|
35
|
+
* @param options Optional parameters for the request.
|
|
36
|
+
*/
|
|
37
|
+
delete(cronId: string, options?: {
|
|
38
|
+
signal?: AbortSignal;
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param query Query options.
|
|
43
|
+
* @returns List of crons.
|
|
44
|
+
*/
|
|
45
|
+
search(query?: {
|
|
46
|
+
assistantId?: string;
|
|
47
|
+
threadId?: string;
|
|
48
|
+
enabled?: boolean;
|
|
49
|
+
limit?: number;
|
|
50
|
+
offset?: number;
|
|
51
|
+
sortBy?: CronSortBy;
|
|
52
|
+
sortOrder?: SortOrder;
|
|
53
|
+
select?: CronSelectField[];
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
}): Promise<Cron[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Count cron jobs matching filters.
|
|
58
|
+
*
|
|
59
|
+
* @param query.assistantId Assistant ID to filter by.
|
|
60
|
+
* @param query.threadId Thread ID to filter by.
|
|
61
|
+
* @returns Number of cron jobs matching the criteria.
|
|
62
|
+
*/
|
|
63
|
+
count(query?: {
|
|
64
|
+
assistantId?: string;
|
|
65
|
+
threadId?: string;
|
|
66
|
+
signal?: AbortSignal;
|
|
67
|
+
}): Promise<number>;
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
export { CronsClient };
|
|
71
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/client/crons/index.ts"],"mappings":";;;;;cAWa,WAAA,SAAoB,UAAA;;AAAjC;;;;;;EAQQ,eAAA,CACJ,QAAA,UACA,WAAA,UACA,OAAA,GAAU,kBAAA,GACT,OAAA,CAAQ,2BAAA;EAyCA;;;;;;EAHL,MAAA,CACJ,WAAA,UACA,OAAA,GAAU,kBAAA,GACT,OAAA,CAAQ,kBAAA;EA2HA;;;;;;;;EAtFL,MAAA,CAAO,MAAA,UAAgB,OAAA,GAAU,kBAAA,GAAqB,OAAA,CAAQ,IAAA;EA1F3B;;;;;;EA2JnC,MAAA,CACJ,MAAA,UACA,OAAA;IAAY,MAAA,GAAS,WAAA;EAAA,IACpB,OAAA;EAlJQ;;;;;EA8JL,MAAA,CAAO,KAAA;IACX,WAAA;IACA,QAAA;IACA,OAAA;IACA,KAAA;IACA,MAAA;IACA,MAAA,GAAS,UAAA;IACT,SAAA,GAAY,SAAA;IACZ,MAAA,GAAS,eAAA;IACT,MAAA,GAAS,WAAA;EAAA,IACP,OAAA,CAAQ,IAAA;EAvBW;;;;;;;EA+CjB,KAAA,CAAM,KAAA;IACV,WAAA;IACA,QAAA;IACA,MAAA,GAAS,WAAA;EAAA,IACP,OAAA;AAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Cron, CronCreateForThreadResponse, CronCreateResponse, CronSelectField, CronSortBy, SortOrder } from "../../schema.js";
|
|
2
|
+
import { CronsCreatePayload, CronsUpdatePayload } from "../../types.js";
|
|
3
|
+
import { BaseClient } from "../base.js";
|
|
4
|
+
|
|
5
|
+
//#region src/client/crons/index.d.ts
|
|
6
|
+
declare class CronsClient extends BaseClient {
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param threadId The ID of the thread.
|
|
10
|
+
* @param assistantId Assistant ID to use for this cron job.
|
|
11
|
+
* @param payload Payload for creating a cron job.
|
|
12
|
+
* @returns The created background run.
|
|
13
|
+
*/
|
|
14
|
+
createForThread(threadId: string, assistantId: string, payload?: CronsCreatePayload): Promise<CronCreateForThreadResponse>;
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param assistantId Assistant ID to use for this cron job.
|
|
18
|
+
* @param payload Payload for creating a cron job.
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
create(assistantId: string, payload?: CronsCreatePayload): Promise<CronCreateResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Update a cron job by ID.
|
|
24
|
+
*
|
|
25
|
+
* @param cronId The cron ID to update.
|
|
26
|
+
* @param payload Payload for updating a cron job.
|
|
27
|
+
* @returns The updated cron job.
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
update(cronId: string, payload?: CronsUpdatePayload): Promise<Cron>;
|
|
31
|
+
/**
|
|
32
|
+
* Delete a cron job by ID.
|
|
33
|
+
*
|
|
34
|
+
* @param cronId Cron ID of Cron job to delete.
|
|
35
|
+
* @param options Optional parameters for the request.
|
|
36
|
+
*/
|
|
37
|
+
delete(cronId: string, options?: {
|
|
38
|
+
signal?: AbortSignal;
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param query Query options.
|
|
43
|
+
* @returns List of crons.
|
|
44
|
+
*/
|
|
45
|
+
search(query?: {
|
|
46
|
+
assistantId?: string;
|
|
47
|
+
threadId?: string;
|
|
48
|
+
enabled?: boolean;
|
|
49
|
+
limit?: number;
|
|
50
|
+
offset?: number;
|
|
51
|
+
sortBy?: CronSortBy;
|
|
52
|
+
sortOrder?: SortOrder;
|
|
53
|
+
select?: CronSelectField[];
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
}): Promise<Cron[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Count cron jobs matching filters.
|
|
58
|
+
*
|
|
59
|
+
* @param query.assistantId Assistant ID to filter by.
|
|
60
|
+
* @param query.threadId Thread ID to filter by.
|
|
61
|
+
* @returns Number of cron jobs matching the criteria.
|
|
62
|
+
*/
|
|
63
|
+
count(query?: {
|
|
64
|
+
assistantId?: string;
|
|
65
|
+
threadId?: string;
|
|
66
|
+
signal?: AbortSignal;
|
|
67
|
+
}): Promise<number>;
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
export { CronsClient };
|
|
71
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/client/crons/index.ts"],"mappings":";;;;;cAWa,WAAA,SAAoB,UAAA;;AAAjC;;;;;;EAQQ,eAAA,CACJ,QAAA,UACA,WAAA,UACA,OAAA,GAAU,kBAAA,GACT,OAAA,CAAQ,2BAAA;EAyCA;;;;;;EAHL,MAAA,CACJ,WAAA,UACA,OAAA,GAAU,kBAAA,GACT,OAAA,CAAQ,kBAAA;EA2HA;;;;;;;;EAtFL,MAAA,CAAO,MAAA,UAAgB,OAAA,GAAU,kBAAA,GAAqB,OAAA,CAAQ,IAAA;EA1F3B;;;;;;EA2JnC,MAAA,CACJ,MAAA,UACA,OAAA;IAAY,MAAA,GAAS,WAAA;EAAA,IACpB,OAAA;EAlJQ;;;;;EA8JL,MAAA,CAAO,KAAA;IACX,WAAA;IACA,QAAA;IACA,OAAA;IACA,KAAA;IACA,MAAA;IACA,MAAA,GAAS,UAAA;IACT,SAAA,GAAY,SAAA;IACZ,MAAA,GAAS,eAAA;IACT,MAAA,GAAS,WAAA;EAAA,IACP,OAAA,CAAQ,IAAA;EAvBW;;;;;;;EA+CjB,KAAA,CAAM,KAAA;IACV,WAAA;IACA,QAAA;IACA,MAAA,GAAS,WAAA;EAAA,IACP,OAAA;AAAA"}
|