@agentforge/core 0.5.1 → 0.5.2

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/dist/index.cjs CHANGED
@@ -65,16 +65,19 @@ __export(index_exports, {
65
65
  composeWithOptions: () => composeWithOptions,
66
66
  conditional: () => conditional,
67
67
  configureLangSmith: () => configureLangSmith,
68
+ createApprovalRequiredInterrupt: () => createApprovalRequiredInterrupt,
68
69
  createBatchProcessor: () => createBatchProcessor,
69
70
  createBinaryRouter: () => createBinaryRouter,
70
71
  createCircuitBreaker: () => createCircuitBreaker,
71
72
  createConditionalRouter: () => createConditionalRouter,
72
73
  createConnectionPool: () => createConnectionPool,
73
74
  createConversationConfig: () => createConversationConfig,
75
+ createCustomInterrupt: () => createCustomInterrupt,
74
76
  createDatabasePool: () => createDatabasePool,
75
77
  createErrorReporter: () => createErrorReporter,
76
78
  createHeartbeat: () => createHeartbeat,
77
79
  createHttpPool: () => createHttpPool,
80
+ createHumanRequestInterrupt: () => createHumanRequestInterrupt,
78
81
  createLogger: () => createLogger,
79
82
  createManagedTool: () => createManagedTool,
80
83
  createMemoryCheckpointer: () => createMemoryCheckpointer,
@@ -99,13 +102,23 @@ __export(index_exports, {
99
102
  createWebSocketHandler: () => createWebSocketHandler,
100
103
  development: () => development,
101
104
  filter: () => filter,
105
+ formatAgentResumedEvent: () => formatAgentResumedEvent,
106
+ formatAgentWaitingEvent: () => formatAgentWaitingEvent,
107
+ formatHumanRequestEvent: () => formatHumanRequestEvent,
108
+ formatHumanResponseEvent: () => formatHumanResponseEvent,
109
+ formatInterruptEvent: () => formatInterruptEvent,
110
+ formatResumeEvent: () => formatResumeEvent,
102
111
  generateThreadId: () => generateThreadId,
103
112
  getCheckpointHistory: () => getCheckpointHistory,
104
113
  getLangSmithConfig: () => getLangSmithConfig,
105
114
  getLatestCheckpoint: () => getLatestCheckpoint,
106
115
  getMissingDescriptions: () => getMissingDescriptions,
116
+ getThreadStatus: () => getThreadStatus,
107
117
  getToolDescription: () => getToolDescription,
108
118
  getToolJsonSchema: () => getToolJsonSchema,
119
+ isApprovalRequiredInterrupt: () => isApprovalRequiredInterrupt,
120
+ isCustomInterrupt: () => isCustomInterrupt,
121
+ isHumanRequestInterrupt: () => isHumanRequestInterrupt,
109
122
  isMemoryCheckpointer: () => isMemoryCheckpointer,
110
123
  isTracingEnabled: () => isTracingEnabled,
111
124
  map: () => map,
@@ -2961,6 +2974,52 @@ var presets = {
2961
2974
  testing
2962
2975
  };
2963
2976
 
2977
+ // src/langgraph/interrupts/utils.ts
2978
+ function createHumanRequestInterrupt(request) {
2979
+ return {
2980
+ type: "human_request",
2981
+ id: request.id,
2982
+ createdAt: request.createdAt,
2983
+ data: request
2984
+ };
2985
+ }
2986
+ function createApprovalRequiredInterrupt(action, description, context) {
2987
+ return {
2988
+ type: "approval_required",
2989
+ id: `approval-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
2990
+ createdAt: Date.now(),
2991
+ data: {
2992
+ action,
2993
+ description,
2994
+ context
2995
+ }
2996
+ };
2997
+ }
2998
+ function createCustomInterrupt(id, data, metadata) {
2999
+ return {
3000
+ type: "custom",
3001
+ id,
3002
+ createdAt: Date.now(),
3003
+ data,
3004
+ metadata
3005
+ };
3006
+ }
3007
+ function isHumanRequestInterrupt(interrupt) {
3008
+ return interrupt.type === "human_request";
3009
+ }
3010
+ function isApprovalRequiredInterrupt(interrupt) {
3011
+ return interrupt.type === "approval_required";
3012
+ }
3013
+ function isCustomInterrupt(interrupt) {
3014
+ return interrupt.type === "custom";
3015
+ }
3016
+ function getThreadStatus(hasInterrupts, isComplete, hasError) {
3017
+ if (hasError) return "error";
3018
+ if (isComplete) return "completed";
3019
+ if (hasInterrupts) return "interrupted";
3020
+ return "running";
3021
+ }
3022
+
2964
3023
  // src/streaming/transformers.ts
2965
3024
  async function* chunk(stream, options) {
2966
3025
  const { size } = options;
@@ -3297,6 +3356,79 @@ ${data}` : data;
3297
3356
  return event.data !== void 0 ? event : null;
3298
3357
  }
3299
3358
 
3359
+ // src/streaming/human-in-loop.ts
3360
+ function formatHumanRequestEvent(request, threadId) {
3361
+ const data = {
3362
+ type: "human_request",
3363
+ request,
3364
+ threadId
3365
+ };
3366
+ return {
3367
+ event: "human_request",
3368
+ data: JSON.stringify(data),
3369
+ id: request.id
3370
+ };
3371
+ }
3372
+ function formatHumanResponseEvent(requestId, response, threadId) {
3373
+ const data = {
3374
+ type: "human_response",
3375
+ requestId,
3376
+ response,
3377
+ threadId
3378
+ };
3379
+ return {
3380
+ event: "human_response",
3381
+ data: JSON.stringify(data),
3382
+ id: `response-${requestId}`
3383
+ };
3384
+ }
3385
+ function formatInterruptEvent(interrupt, threadId) {
3386
+ const data = {
3387
+ type: "interrupt",
3388
+ interrupt,
3389
+ threadId
3390
+ };
3391
+ return {
3392
+ event: "interrupt",
3393
+ data: JSON.stringify(data),
3394
+ id: interrupt.id
3395
+ };
3396
+ }
3397
+ function formatResumeEvent(interruptId, value, threadId) {
3398
+ const data = {
3399
+ type: "resume",
3400
+ interruptId,
3401
+ value,
3402
+ threadId
3403
+ };
3404
+ return {
3405
+ event: "resume",
3406
+ data: JSON.stringify(data),
3407
+ id: `resume-${interruptId}`
3408
+ };
3409
+ }
3410
+ function formatAgentWaitingEvent(reason, threadId) {
3411
+ const data = {
3412
+ type: "agent_waiting",
3413
+ reason,
3414
+ threadId
3415
+ };
3416
+ return {
3417
+ event: "agent_waiting",
3418
+ data: JSON.stringify(data)
3419
+ };
3420
+ }
3421
+ function formatAgentResumedEvent(threadId) {
3422
+ const data = {
3423
+ type: "agent_resumed",
3424
+ threadId
3425
+ };
3426
+ return {
3427
+ event: "agent_resumed",
3428
+ data: JSON.stringify(data)
3429
+ };
3430
+ }
3431
+
3300
3432
  // src/streaming/websocket.ts
3301
3433
  function createWebSocketHandler(options) {
3302
3434
  const { onConnect, onMessage, onError, onClose, heartbeat = 0 } = options;
@@ -4160,16 +4292,19 @@ function createCircuitBreaker(options) {
4160
4292
  composeWithOptions,
4161
4293
  conditional,
4162
4294
  configureLangSmith,
4295
+ createApprovalRequiredInterrupt,
4163
4296
  createBatchProcessor,
4164
4297
  createBinaryRouter,
4165
4298
  createCircuitBreaker,
4166
4299
  createConditionalRouter,
4167
4300
  createConnectionPool,
4168
4301
  createConversationConfig,
4302
+ createCustomInterrupt,
4169
4303
  createDatabasePool,
4170
4304
  createErrorReporter,
4171
4305
  createHeartbeat,
4172
4306
  createHttpPool,
4307
+ createHumanRequestInterrupt,
4173
4308
  createLogger,
4174
4309
  createManagedTool,
4175
4310
  createMemoryCheckpointer,
@@ -4194,13 +4329,23 @@ function createCircuitBreaker(options) {
4194
4329
  createWebSocketHandler,
4195
4330
  development,
4196
4331
  filter,
4332
+ formatAgentResumedEvent,
4333
+ formatAgentWaitingEvent,
4334
+ formatHumanRequestEvent,
4335
+ formatHumanResponseEvent,
4336
+ formatInterruptEvent,
4337
+ formatResumeEvent,
4197
4338
  generateThreadId,
4198
4339
  getCheckpointHistory,
4199
4340
  getLangSmithConfig,
4200
4341
  getLatestCheckpoint,
4201
4342
  getMissingDescriptions,
4343
+ getThreadStatus,
4202
4344
  getToolDescription,
4203
4345
  getToolJsonSchema,
4346
+ isApprovalRequiredInterrupt,
4347
+ isCustomInterrupt,
4348
+ isHumanRequestInterrupt,
4204
4349
  isMemoryCheckpointer,
4205
4350
  isTracingEnabled,
4206
4351
  map,
package/dist/index.d.cts CHANGED
@@ -3695,6 +3695,292 @@ declare const presets: {
3695
3695
  testing: typeof testing;
3696
3696
  };
3697
3697
 
3698
+ /**
3699
+ * Types for LangGraph interrupt handling
3700
+ * @module langgraph/interrupts/types
3701
+ */
3702
+ /**
3703
+ * Priority level for human requests
3704
+ */
3705
+ type HumanRequestPriority = 'low' | 'normal' | 'high' | 'critical';
3706
+ /**
3707
+ * Status of a human request
3708
+ */
3709
+ type HumanRequestStatus = 'pending' | 'answered' | 'timeout' | 'cancelled';
3710
+ /**
3711
+ * Human request stored in state
3712
+ */
3713
+ interface HumanRequest {
3714
+ /**
3715
+ * Unique ID for this request
3716
+ */
3717
+ id: string;
3718
+ /**
3719
+ * The question being asked
3720
+ */
3721
+ question: string;
3722
+ /**
3723
+ * Optional context
3724
+ */
3725
+ context?: Record<string, any>;
3726
+ /**
3727
+ * Priority level
3728
+ */
3729
+ priority: HumanRequestPriority;
3730
+ /**
3731
+ * When the request was created
3732
+ */
3733
+ createdAt: number;
3734
+ /**
3735
+ * Timeout in milliseconds (0 = no timeout)
3736
+ */
3737
+ timeout: number;
3738
+ /**
3739
+ * Default response if timeout occurs
3740
+ */
3741
+ defaultResponse?: string;
3742
+ /**
3743
+ * Suggested responses
3744
+ */
3745
+ suggestions?: string[];
3746
+ /**
3747
+ * Current status
3748
+ */
3749
+ status: HumanRequestStatus;
3750
+ /**
3751
+ * The response (if answered)
3752
+ */
3753
+ response?: string;
3754
+ /**
3755
+ * When the response was received
3756
+ */
3757
+ respondedAt?: number;
3758
+ }
3759
+ /**
3760
+ * Interrupt type - identifies what kind of interrupt occurred
3761
+ */
3762
+ type InterruptType = 'human_request' | 'approval_required' | 'custom';
3763
+ /**
3764
+ * Interrupt data stored in the checkpoint
3765
+ */
3766
+ interface InterruptData {
3767
+ /**
3768
+ * Type of interrupt
3769
+ */
3770
+ type: InterruptType;
3771
+ /**
3772
+ * Unique ID for this interrupt
3773
+ */
3774
+ id: string;
3775
+ /**
3776
+ * When the interrupt was created
3777
+ */
3778
+ createdAt: number;
3779
+ /**
3780
+ * The data associated with this interrupt
3781
+ */
3782
+ data: any;
3783
+ /**
3784
+ * Optional metadata
3785
+ */
3786
+ metadata?: Record<string, any>;
3787
+ }
3788
+ /**
3789
+ * Human request interrupt data
3790
+ */
3791
+ interface HumanRequestInterrupt extends InterruptData {
3792
+ type: 'human_request';
3793
+ data: HumanRequest;
3794
+ }
3795
+ /**
3796
+ * Approval required interrupt data
3797
+ */
3798
+ interface ApprovalRequiredInterrupt extends InterruptData {
3799
+ type: 'approval_required';
3800
+ data: {
3801
+ action: string;
3802
+ description: string;
3803
+ context?: Record<string, any>;
3804
+ };
3805
+ }
3806
+ /**
3807
+ * Custom interrupt data
3808
+ */
3809
+ interface CustomInterrupt extends InterruptData {
3810
+ type: 'custom';
3811
+ data: any;
3812
+ }
3813
+ /**
3814
+ * Union type of all interrupt types
3815
+ */
3816
+ type AnyInterrupt = HumanRequestInterrupt | ApprovalRequiredInterrupt | CustomInterrupt;
3817
+ /**
3818
+ * Resume command for continuing after an interrupt
3819
+ */
3820
+ interface ResumeCommand {
3821
+ /**
3822
+ * The response to the interrupt
3823
+ */
3824
+ resume: any;
3825
+ /**
3826
+ * Optional metadata about the response
3827
+ */
3828
+ metadata?: Record<string, any>;
3829
+ }
3830
+ /**
3831
+ * Thread status
3832
+ */
3833
+ type ThreadStatus = 'running' | 'interrupted' | 'completed' | 'error';
3834
+ /**
3835
+ * Thread info with interrupt status
3836
+ */
3837
+ interface ThreadInfo {
3838
+ /**
3839
+ * Thread ID
3840
+ */
3841
+ threadId: string;
3842
+ /**
3843
+ * Current status
3844
+ */
3845
+ status: ThreadStatus;
3846
+ /**
3847
+ * Active interrupts (if any)
3848
+ */
3849
+ interrupts?: AnyInterrupt[];
3850
+ /**
3851
+ * Last updated timestamp
3852
+ */
3853
+ updatedAt: number;
3854
+ /**
3855
+ * Optional metadata
3856
+ */
3857
+ metadata?: Record<string, any>;
3858
+ }
3859
+ /**
3860
+ * Options for checking interrupt status
3861
+ */
3862
+ interface CheckInterruptOptions {
3863
+ /**
3864
+ * Thread ID to check
3865
+ */
3866
+ threadId: string;
3867
+ /**
3868
+ * Filter by interrupt type
3869
+ */
3870
+ type?: InterruptType;
3871
+ }
3872
+ /**
3873
+ * Options for resuming from an interrupt
3874
+ */
3875
+ interface ResumeOptions {
3876
+ /**
3877
+ * Thread ID to resume
3878
+ */
3879
+ threadId: string;
3880
+ /**
3881
+ * Interrupt ID to resume from
3882
+ */
3883
+ interruptId?: string;
3884
+ /**
3885
+ * The response/value to resume with
3886
+ */
3887
+ value: any;
3888
+ /**
3889
+ * Optional metadata
3890
+ */
3891
+ metadata?: Record<string, any>;
3892
+ }
3893
+
3894
+ /**
3895
+ * Utilities for working with LangGraph interrupts
3896
+ * @module langgraph/interrupts/utils
3897
+ */
3898
+
3899
+ /**
3900
+ * Create a human request interrupt
3901
+ *
3902
+ * @param request - The human request data
3903
+ * @returns A human request interrupt object
3904
+ *
3905
+ * @example
3906
+ * ```typescript
3907
+ * const interrupt = createHumanRequestInterrupt({
3908
+ * id: 'req-123',
3909
+ * question: 'Should I proceed?',
3910
+ * priority: 'high',
3911
+ * createdAt: Date.now(),
3912
+ * timeout: 0,
3913
+ * status: 'pending',
3914
+ * });
3915
+ * ```
3916
+ */
3917
+ declare function createHumanRequestInterrupt(request: HumanRequest): HumanRequestInterrupt;
3918
+ /**
3919
+ * Create an approval required interrupt
3920
+ *
3921
+ * @param action - The action requiring approval
3922
+ * @param description - Description of the action
3923
+ * @param context - Optional context
3924
+ * @returns An approval required interrupt object
3925
+ *
3926
+ * @example
3927
+ * ```typescript
3928
+ * const interrupt = createApprovalRequiredInterrupt(
3929
+ * 'delete-database',
3930
+ * 'Delete production database',
3931
+ * { database: 'prod-db-1' }
3932
+ * );
3933
+ * ```
3934
+ */
3935
+ declare function createApprovalRequiredInterrupt(action: string, description: string, context?: Record<string, any>): ApprovalRequiredInterrupt;
3936
+ /**
3937
+ * Create a custom interrupt
3938
+ *
3939
+ * @param id - Unique ID for the interrupt
3940
+ * @param data - Custom data
3941
+ * @param metadata - Optional metadata
3942
+ * @returns A custom interrupt object
3943
+ *
3944
+ * @example
3945
+ * ```typescript
3946
+ * const interrupt = createCustomInterrupt(
3947
+ * 'custom-123',
3948
+ * { type: 'review', content: 'Please review this' }
3949
+ * );
3950
+ * ```
3951
+ */
3952
+ declare function createCustomInterrupt(id: string, data: any, metadata?: Record<string, any>): CustomInterrupt;
3953
+ /**
3954
+ * Check if an interrupt is a human request
3955
+ *
3956
+ * @param interrupt - The interrupt to check
3957
+ * @returns True if the interrupt is a human request
3958
+ */
3959
+ declare function isHumanRequestInterrupt(interrupt: AnyInterrupt): interrupt is HumanRequestInterrupt;
3960
+ /**
3961
+ * Check if an interrupt is an approval request
3962
+ *
3963
+ * @param interrupt - The interrupt to check
3964
+ * @returns True if the interrupt is an approval request
3965
+ */
3966
+ declare function isApprovalRequiredInterrupt(interrupt: AnyInterrupt): interrupt is ApprovalRequiredInterrupt;
3967
+ /**
3968
+ * Check if an interrupt is a custom interrupt
3969
+ *
3970
+ * @param interrupt - The interrupt to check
3971
+ * @returns True if the interrupt is a custom interrupt
3972
+ */
3973
+ declare function isCustomInterrupt(interrupt: AnyInterrupt): interrupt is CustomInterrupt;
3974
+ /**
3975
+ * Get the status of a thread based on its state
3976
+ *
3977
+ * @param hasInterrupts - Whether the thread has active interrupts
3978
+ * @param isComplete - Whether the thread has completed
3979
+ * @param hasError - Whether the thread has an error
3980
+ * @returns The thread status
3981
+ */
3982
+ declare function getThreadStatus(hasInterrupts: boolean, isComplete: boolean, hasError: boolean): ThreadStatus;
3983
+
3698
3984
  /**
3699
3985
  * Streaming utilities for LangGraph applications
3700
3986
  * @module streaming
@@ -4020,6 +4306,125 @@ declare function createHeartbeat(): string;
4020
4306
  */
4021
4307
  declare function parseSSEEvent(eventString: string): SSEEvent | null;
4022
4308
 
4309
+ /**
4310
+ * SSE utilities for human-in-the-loop workflows
4311
+ * @module streaming/human-in-loop
4312
+ */
4313
+
4314
+ /**
4315
+ * Human-in-the-loop SSE event types
4316
+ */
4317
+ type HumanInLoopEventType = 'human_request' | 'human_response' | 'interrupt' | 'resume' | 'agent_waiting' | 'agent_resumed';
4318
+ /**
4319
+ * Human request SSE event data
4320
+ */
4321
+ interface HumanRequestEventData {
4322
+ type: 'human_request';
4323
+ request: HumanRequest;
4324
+ threadId: string;
4325
+ }
4326
+ /**
4327
+ * Human response SSE event data
4328
+ */
4329
+ interface HumanResponseEventData {
4330
+ type: 'human_response';
4331
+ requestId: string;
4332
+ response: string;
4333
+ threadId: string;
4334
+ }
4335
+ /**
4336
+ * Interrupt SSE event data
4337
+ */
4338
+ interface InterruptEventData {
4339
+ type: 'interrupt';
4340
+ interrupt: AnyInterrupt;
4341
+ threadId: string;
4342
+ }
4343
+ /**
4344
+ * Resume SSE event data
4345
+ */
4346
+ interface ResumeEventData {
4347
+ type: 'resume';
4348
+ interruptId: string;
4349
+ value: any;
4350
+ threadId: string;
4351
+ }
4352
+ /**
4353
+ * Agent waiting SSE event data
4354
+ */
4355
+ interface AgentWaitingEventData {
4356
+ type: 'agent_waiting';
4357
+ reason: string;
4358
+ threadId: string;
4359
+ }
4360
+ /**
4361
+ * Agent resumed SSE event data
4362
+ */
4363
+ interface AgentResumedEventData {
4364
+ type: 'agent_resumed';
4365
+ threadId: string;
4366
+ }
4367
+ /**
4368
+ * Union type of all human-in-the-loop event data
4369
+ */
4370
+ type HumanInLoopEventData = HumanRequestEventData | HumanResponseEventData | InterruptEventData | ResumeEventData | AgentWaitingEventData | AgentResumedEventData;
4371
+ /**
4372
+ * Format a human request as an SSE event
4373
+ *
4374
+ * @param request - The human request
4375
+ * @param threadId - The thread ID
4376
+ * @returns An SSE event
4377
+ *
4378
+ * @example
4379
+ * ```typescript
4380
+ * const event = formatHumanRequestEvent(humanRequest, 'thread-123');
4381
+ * // Send to client via SSE
4382
+ * res.write(formatSSEEvent(event));
4383
+ * ```
4384
+ */
4385
+ declare function formatHumanRequestEvent(request: HumanRequest, threadId: string): SSEEvent;
4386
+ /**
4387
+ * Format a human response as an SSE event
4388
+ *
4389
+ * @param requestId - The request ID
4390
+ * @param response - The human's response
4391
+ * @param threadId - The thread ID
4392
+ * @returns An SSE event
4393
+ */
4394
+ declare function formatHumanResponseEvent(requestId: string, response: string, threadId: string): SSEEvent;
4395
+ /**
4396
+ * Format an interrupt as an SSE event
4397
+ *
4398
+ * @param interrupt - The interrupt data
4399
+ * @param threadId - The thread ID
4400
+ * @returns An SSE event
4401
+ */
4402
+ declare function formatInterruptEvent(interrupt: AnyInterrupt, threadId: string): SSEEvent;
4403
+ /**
4404
+ * Format a resume event as an SSE event
4405
+ *
4406
+ * @param interruptId - The interrupt ID being resumed
4407
+ * @param value - The resume value
4408
+ * @param threadId - The thread ID
4409
+ * @returns An SSE event
4410
+ */
4411
+ declare function formatResumeEvent(interruptId: string, value: any, threadId: string): SSEEvent;
4412
+ /**
4413
+ * Format an agent waiting event as an SSE event
4414
+ *
4415
+ * @param reason - Why the agent is waiting
4416
+ * @param threadId - The thread ID
4417
+ * @returns An SSE event
4418
+ */
4419
+ declare function formatAgentWaitingEvent(reason: string, threadId: string): SSEEvent;
4420
+ /**
4421
+ * Format an agent resumed event as an SSE event
4422
+ *
4423
+ * @param threadId - The thread ID
4424
+ * @returns An SSE event
4425
+ */
4426
+ declare function formatAgentResumedEvent(threadId: string): SSEEvent;
4427
+
4023
4428
  /**
4024
4429
  * WebSocket support for bidirectional streaming
4025
4430
  * @module streaming/websocket
@@ -4352,4 +4757,4 @@ declare class CircuitBreaker {
4352
4757
  }
4353
4758
  declare function createCircuitBreaker(options: CircuitBreakerOptions): CircuitBreaker;
4354
4759
 
4355
- export { AgentError, type AggregateNode, type BackoffStrategy, type BatchOptions, BatchProcessor, type BatchProcessorOptions, type BatchStats, type CheckpointHistoryOptions, type CheckpointerOptions, type ChunkOptions, CircuitBreaker, type CircuitBreakerOptions, type CircuitBreakerStats, type CircuitState, type ComposeGraphsOptions, type ComposeOptions, type ComposeToolConfig, type ComposedTool, type ConditionalConfig, type ConditionalRouter, type ConditionalRouterConfig, ConnectionPool, type ConnectionPoolOptions, type ConversationConfig, type DatabaseConfig, type DatabaseConnection, DatabasePool, type DatabasePoolOptions, type DevelopmentPresetOptions, type ErrorContext, type ErrorHandlerOptions, type ErrorReporter, type ErrorReporterOptions, type EventHandler, type ExecutionMetrics, type HealthCheckConfig, type HealthCheckResult, type HttpClient, type HttpConfig, HttpPool, type HttpPoolConfig, type HttpPoolOptions, type HttpResponse, type LangSmithConfig, type LogEntry, LogLevel, type Logger, type LoggerOptions, ManagedTool, type ManagedToolConfig, type ManagedToolStats, MemoryManager, type MemoryManagerOptions, type MemoryStats, type MetricEntry, MetricType, type Metrics, type MetricsNodeOptions, type Middleware, MiddlewareChain, type MiddlewareContext, type MiddlewareFactory, type MiddlewareMetadata, type MiddlewareWithMetadata, MissingDescriptionError, type MockToolConfig, type MockToolResponse, type NodeFunction, type NodeFunctionWithContext, type ParallelNode, type ParallelWorkflowConfig, type ParallelWorkflowOptions, type PoolConfig, type PoolStats, type Priority, type ProductionPresetOptions, type Progress, type ProgressTracker, type ProgressTrackerOptions, type PromptOptions, type ReducerFunction, RegistryEvent, type RequestConfig, type RetryOptions, type RetryPolicy, type RouteCondition, type RouteMap, type RouteName, type SSEEvent, type SSEFormatter, type SSEFormatterOptions, type SequentialNode, type SequentialWorkflowOptions, type SimpleMiddleware, type SqliteCheckpointerOptions, type StateChannelConfig, type SubgraphBuilder, type TestingPresetOptions, type ThreadConfig, type ThrottleOptions, TimeoutError, type TimeoutOptions, type Timer, type Tool, type BackoffStrategy$1 as ToolBackoffStrategy, ToolBuilder, ToolCategory, ToolCategorySchema, type ToolExample, ToolExampleSchema, type ToolExecution, type ToolExecutorConfig, type ToolInvocation, type ToolMetadata, ToolMetadataSchema, ToolNameSchema, ToolRegistry, type ToolRelations, ToolRelationsSchema, type ToolSimulatorConfig, type TracingOptions, type WebSocketHandlerOptions, type WebSocketMessage, batch, broadcast, cache, chain, chunk, clearThread, collect, compose, composeGraphs, composeTool, composeWithOptions, conditional, configureLangSmith, createBatchProcessor, createBinaryRouter, createCircuitBreaker, createConditionalRouter, createConnectionPool, createConversationConfig, createDatabasePool, createErrorReporter, createHeartbeat, createHttpPool, createLogger, createManagedTool, createMemoryCheckpointer, createMemoryManager, createMessage, createMetrics, createMiddlewareContext, createMockTool, createMultiRouter, createParallelWorkflow, createProgressTracker, createSSEFormatter, createSequentialWorkflow, createSqliteCheckpointer, createStateAnnotation, createSubgraph, createThreadConfig, createTool, createToolExecutor, createToolSimulator, createToolUnsafe, createWebSocketHandler, development, filter, generateThreadId, getCheckpointHistory, getLangSmithConfig, getLatestCheckpoint, getMissingDescriptions, getToolDescription, getToolJsonSchema, isMemoryCheckpointer, isTracingEnabled, map, merge, mergeState, parallel, parseSSEEvent, presets, production, reduce, retry, safeValidateSchemaDescriptions, sendMessage, sequential, sequentialBuilder, take, testing, throttle, timeout, toLangChainTool, toLangChainTools, toolBuilder, validateSchemaDescriptions, validateState, validateTool, validateToolMetadata, validateToolName, withErrorHandler, withMetrics, withRetry, withTimeout, withTracing };
4760
+ export { AgentError, type AgentResumedEventData, type AgentWaitingEventData, type AggregateNode, type AnyInterrupt, type ApprovalRequiredInterrupt, type BackoffStrategy, type BatchOptions, BatchProcessor, type BatchProcessorOptions, type BatchStats, type CheckInterruptOptions, type CheckpointHistoryOptions, type CheckpointerOptions, type ChunkOptions, CircuitBreaker, type CircuitBreakerOptions, type CircuitBreakerStats, type CircuitState, type ComposeGraphsOptions, type ComposeOptions, type ComposeToolConfig, type ComposedTool, type ConditionalConfig, type ConditionalRouter, type ConditionalRouterConfig, ConnectionPool, type ConnectionPoolOptions, type ConversationConfig, type CustomInterrupt, type DatabaseConfig, type DatabaseConnection, DatabasePool, type DatabasePoolOptions, type DevelopmentPresetOptions, type ErrorContext, type ErrorHandlerOptions, type ErrorReporter, type ErrorReporterOptions, type EventHandler, type ExecutionMetrics, type HealthCheckConfig, type HealthCheckResult, type HttpClient, type HttpConfig, HttpPool, type HttpPoolConfig, type HttpPoolOptions, type HttpResponse, type HumanInLoopEventData, type HumanInLoopEventType, type HumanRequest, type HumanRequestEventData, type HumanRequestInterrupt, type HumanRequestPriority, type HumanRequestStatus, type HumanResponseEventData, type InterruptData, type InterruptEventData, type InterruptType, type LangSmithConfig, type LogEntry, LogLevel, type Logger, type LoggerOptions, ManagedTool, type ManagedToolConfig, type ManagedToolStats, MemoryManager, type MemoryManagerOptions, type MemoryStats, type MetricEntry, MetricType, type Metrics, type MetricsNodeOptions, type Middleware, MiddlewareChain, type MiddlewareContext, type MiddlewareFactory, type MiddlewareMetadata, type MiddlewareWithMetadata, MissingDescriptionError, type MockToolConfig, type MockToolResponse, type NodeFunction, type NodeFunctionWithContext, type ParallelNode, type ParallelWorkflowConfig, type ParallelWorkflowOptions, type PoolConfig, type PoolStats, type Priority, type ProductionPresetOptions, type Progress, type ProgressTracker, type ProgressTrackerOptions, type PromptOptions, type ReducerFunction, RegistryEvent, type RequestConfig, type ResumeCommand, type ResumeEventData, type ResumeOptions, type RetryOptions, type RetryPolicy, type RouteCondition, type RouteMap, type RouteName, type SSEEvent, type SSEFormatter, type SSEFormatterOptions, type SequentialNode, type SequentialWorkflowOptions, type SimpleMiddleware, type SqliteCheckpointerOptions, type StateChannelConfig, type SubgraphBuilder, type TestingPresetOptions, type ThreadConfig, type ThreadInfo, type ThreadStatus, type ThrottleOptions, TimeoutError, type TimeoutOptions, type Timer, type Tool, type BackoffStrategy$1 as ToolBackoffStrategy, ToolBuilder, ToolCategory, ToolCategorySchema, type ToolExample, ToolExampleSchema, type ToolExecution, type ToolExecutorConfig, type ToolInvocation, type ToolMetadata, ToolMetadataSchema, ToolNameSchema, ToolRegistry, type ToolRelations, ToolRelationsSchema, type ToolSimulatorConfig, type TracingOptions, type WebSocketHandlerOptions, type WebSocketMessage, batch, broadcast, cache, chain, chunk, clearThread, collect, compose, composeGraphs, composeTool, composeWithOptions, conditional, configureLangSmith, createApprovalRequiredInterrupt, createBatchProcessor, createBinaryRouter, createCircuitBreaker, createConditionalRouter, createConnectionPool, createConversationConfig, createCustomInterrupt, createDatabasePool, createErrorReporter, createHeartbeat, createHttpPool, createHumanRequestInterrupt, createLogger, createManagedTool, createMemoryCheckpointer, createMemoryManager, createMessage, createMetrics, createMiddlewareContext, createMockTool, createMultiRouter, createParallelWorkflow, createProgressTracker, createSSEFormatter, createSequentialWorkflow, createSqliteCheckpointer, createStateAnnotation, createSubgraph, createThreadConfig, createTool, createToolExecutor, createToolSimulator, createToolUnsafe, createWebSocketHandler, development, filter, formatAgentResumedEvent, formatAgentWaitingEvent, formatHumanRequestEvent, formatHumanResponseEvent, formatInterruptEvent, formatResumeEvent, generateThreadId, getCheckpointHistory, getLangSmithConfig, getLatestCheckpoint, getMissingDescriptions, getThreadStatus, getToolDescription, getToolJsonSchema, isApprovalRequiredInterrupt, isCustomInterrupt, isHumanRequestInterrupt, isMemoryCheckpointer, isTracingEnabled, map, merge, mergeState, parallel, parseSSEEvent, presets, production, reduce, retry, safeValidateSchemaDescriptions, sendMessage, sequential, sequentialBuilder, take, testing, throttle, timeout, toLangChainTool, toLangChainTools, toolBuilder, validateSchemaDescriptions, validateState, validateTool, validateToolMetadata, validateToolName, withErrorHandler, withMetrics, withRetry, withTimeout, withTracing };
package/dist/index.d.ts CHANGED
@@ -3695,6 +3695,292 @@ declare const presets: {
3695
3695
  testing: typeof testing;
3696
3696
  };
3697
3697
 
3698
+ /**
3699
+ * Types for LangGraph interrupt handling
3700
+ * @module langgraph/interrupts/types
3701
+ */
3702
+ /**
3703
+ * Priority level for human requests
3704
+ */
3705
+ type HumanRequestPriority = 'low' | 'normal' | 'high' | 'critical';
3706
+ /**
3707
+ * Status of a human request
3708
+ */
3709
+ type HumanRequestStatus = 'pending' | 'answered' | 'timeout' | 'cancelled';
3710
+ /**
3711
+ * Human request stored in state
3712
+ */
3713
+ interface HumanRequest {
3714
+ /**
3715
+ * Unique ID for this request
3716
+ */
3717
+ id: string;
3718
+ /**
3719
+ * The question being asked
3720
+ */
3721
+ question: string;
3722
+ /**
3723
+ * Optional context
3724
+ */
3725
+ context?: Record<string, any>;
3726
+ /**
3727
+ * Priority level
3728
+ */
3729
+ priority: HumanRequestPriority;
3730
+ /**
3731
+ * When the request was created
3732
+ */
3733
+ createdAt: number;
3734
+ /**
3735
+ * Timeout in milliseconds (0 = no timeout)
3736
+ */
3737
+ timeout: number;
3738
+ /**
3739
+ * Default response if timeout occurs
3740
+ */
3741
+ defaultResponse?: string;
3742
+ /**
3743
+ * Suggested responses
3744
+ */
3745
+ suggestions?: string[];
3746
+ /**
3747
+ * Current status
3748
+ */
3749
+ status: HumanRequestStatus;
3750
+ /**
3751
+ * The response (if answered)
3752
+ */
3753
+ response?: string;
3754
+ /**
3755
+ * When the response was received
3756
+ */
3757
+ respondedAt?: number;
3758
+ }
3759
+ /**
3760
+ * Interrupt type - identifies what kind of interrupt occurred
3761
+ */
3762
+ type InterruptType = 'human_request' | 'approval_required' | 'custom';
3763
+ /**
3764
+ * Interrupt data stored in the checkpoint
3765
+ */
3766
+ interface InterruptData {
3767
+ /**
3768
+ * Type of interrupt
3769
+ */
3770
+ type: InterruptType;
3771
+ /**
3772
+ * Unique ID for this interrupt
3773
+ */
3774
+ id: string;
3775
+ /**
3776
+ * When the interrupt was created
3777
+ */
3778
+ createdAt: number;
3779
+ /**
3780
+ * The data associated with this interrupt
3781
+ */
3782
+ data: any;
3783
+ /**
3784
+ * Optional metadata
3785
+ */
3786
+ metadata?: Record<string, any>;
3787
+ }
3788
+ /**
3789
+ * Human request interrupt data
3790
+ */
3791
+ interface HumanRequestInterrupt extends InterruptData {
3792
+ type: 'human_request';
3793
+ data: HumanRequest;
3794
+ }
3795
+ /**
3796
+ * Approval required interrupt data
3797
+ */
3798
+ interface ApprovalRequiredInterrupt extends InterruptData {
3799
+ type: 'approval_required';
3800
+ data: {
3801
+ action: string;
3802
+ description: string;
3803
+ context?: Record<string, any>;
3804
+ };
3805
+ }
3806
+ /**
3807
+ * Custom interrupt data
3808
+ */
3809
+ interface CustomInterrupt extends InterruptData {
3810
+ type: 'custom';
3811
+ data: any;
3812
+ }
3813
+ /**
3814
+ * Union type of all interrupt types
3815
+ */
3816
+ type AnyInterrupt = HumanRequestInterrupt | ApprovalRequiredInterrupt | CustomInterrupt;
3817
+ /**
3818
+ * Resume command for continuing after an interrupt
3819
+ */
3820
+ interface ResumeCommand {
3821
+ /**
3822
+ * The response to the interrupt
3823
+ */
3824
+ resume: any;
3825
+ /**
3826
+ * Optional metadata about the response
3827
+ */
3828
+ metadata?: Record<string, any>;
3829
+ }
3830
+ /**
3831
+ * Thread status
3832
+ */
3833
+ type ThreadStatus = 'running' | 'interrupted' | 'completed' | 'error';
3834
+ /**
3835
+ * Thread info with interrupt status
3836
+ */
3837
+ interface ThreadInfo {
3838
+ /**
3839
+ * Thread ID
3840
+ */
3841
+ threadId: string;
3842
+ /**
3843
+ * Current status
3844
+ */
3845
+ status: ThreadStatus;
3846
+ /**
3847
+ * Active interrupts (if any)
3848
+ */
3849
+ interrupts?: AnyInterrupt[];
3850
+ /**
3851
+ * Last updated timestamp
3852
+ */
3853
+ updatedAt: number;
3854
+ /**
3855
+ * Optional metadata
3856
+ */
3857
+ metadata?: Record<string, any>;
3858
+ }
3859
+ /**
3860
+ * Options for checking interrupt status
3861
+ */
3862
+ interface CheckInterruptOptions {
3863
+ /**
3864
+ * Thread ID to check
3865
+ */
3866
+ threadId: string;
3867
+ /**
3868
+ * Filter by interrupt type
3869
+ */
3870
+ type?: InterruptType;
3871
+ }
3872
+ /**
3873
+ * Options for resuming from an interrupt
3874
+ */
3875
+ interface ResumeOptions {
3876
+ /**
3877
+ * Thread ID to resume
3878
+ */
3879
+ threadId: string;
3880
+ /**
3881
+ * Interrupt ID to resume from
3882
+ */
3883
+ interruptId?: string;
3884
+ /**
3885
+ * The response/value to resume with
3886
+ */
3887
+ value: any;
3888
+ /**
3889
+ * Optional metadata
3890
+ */
3891
+ metadata?: Record<string, any>;
3892
+ }
3893
+
3894
+ /**
3895
+ * Utilities for working with LangGraph interrupts
3896
+ * @module langgraph/interrupts/utils
3897
+ */
3898
+
3899
+ /**
3900
+ * Create a human request interrupt
3901
+ *
3902
+ * @param request - The human request data
3903
+ * @returns A human request interrupt object
3904
+ *
3905
+ * @example
3906
+ * ```typescript
3907
+ * const interrupt = createHumanRequestInterrupt({
3908
+ * id: 'req-123',
3909
+ * question: 'Should I proceed?',
3910
+ * priority: 'high',
3911
+ * createdAt: Date.now(),
3912
+ * timeout: 0,
3913
+ * status: 'pending',
3914
+ * });
3915
+ * ```
3916
+ */
3917
+ declare function createHumanRequestInterrupt(request: HumanRequest): HumanRequestInterrupt;
3918
+ /**
3919
+ * Create an approval required interrupt
3920
+ *
3921
+ * @param action - The action requiring approval
3922
+ * @param description - Description of the action
3923
+ * @param context - Optional context
3924
+ * @returns An approval required interrupt object
3925
+ *
3926
+ * @example
3927
+ * ```typescript
3928
+ * const interrupt = createApprovalRequiredInterrupt(
3929
+ * 'delete-database',
3930
+ * 'Delete production database',
3931
+ * { database: 'prod-db-1' }
3932
+ * );
3933
+ * ```
3934
+ */
3935
+ declare function createApprovalRequiredInterrupt(action: string, description: string, context?: Record<string, any>): ApprovalRequiredInterrupt;
3936
+ /**
3937
+ * Create a custom interrupt
3938
+ *
3939
+ * @param id - Unique ID for the interrupt
3940
+ * @param data - Custom data
3941
+ * @param metadata - Optional metadata
3942
+ * @returns A custom interrupt object
3943
+ *
3944
+ * @example
3945
+ * ```typescript
3946
+ * const interrupt = createCustomInterrupt(
3947
+ * 'custom-123',
3948
+ * { type: 'review', content: 'Please review this' }
3949
+ * );
3950
+ * ```
3951
+ */
3952
+ declare function createCustomInterrupt(id: string, data: any, metadata?: Record<string, any>): CustomInterrupt;
3953
+ /**
3954
+ * Check if an interrupt is a human request
3955
+ *
3956
+ * @param interrupt - The interrupt to check
3957
+ * @returns True if the interrupt is a human request
3958
+ */
3959
+ declare function isHumanRequestInterrupt(interrupt: AnyInterrupt): interrupt is HumanRequestInterrupt;
3960
+ /**
3961
+ * Check if an interrupt is an approval request
3962
+ *
3963
+ * @param interrupt - The interrupt to check
3964
+ * @returns True if the interrupt is an approval request
3965
+ */
3966
+ declare function isApprovalRequiredInterrupt(interrupt: AnyInterrupt): interrupt is ApprovalRequiredInterrupt;
3967
+ /**
3968
+ * Check if an interrupt is a custom interrupt
3969
+ *
3970
+ * @param interrupt - The interrupt to check
3971
+ * @returns True if the interrupt is a custom interrupt
3972
+ */
3973
+ declare function isCustomInterrupt(interrupt: AnyInterrupt): interrupt is CustomInterrupt;
3974
+ /**
3975
+ * Get the status of a thread based on its state
3976
+ *
3977
+ * @param hasInterrupts - Whether the thread has active interrupts
3978
+ * @param isComplete - Whether the thread has completed
3979
+ * @param hasError - Whether the thread has an error
3980
+ * @returns The thread status
3981
+ */
3982
+ declare function getThreadStatus(hasInterrupts: boolean, isComplete: boolean, hasError: boolean): ThreadStatus;
3983
+
3698
3984
  /**
3699
3985
  * Streaming utilities for LangGraph applications
3700
3986
  * @module streaming
@@ -4020,6 +4306,125 @@ declare function createHeartbeat(): string;
4020
4306
  */
4021
4307
  declare function parseSSEEvent(eventString: string): SSEEvent | null;
4022
4308
 
4309
+ /**
4310
+ * SSE utilities for human-in-the-loop workflows
4311
+ * @module streaming/human-in-loop
4312
+ */
4313
+
4314
+ /**
4315
+ * Human-in-the-loop SSE event types
4316
+ */
4317
+ type HumanInLoopEventType = 'human_request' | 'human_response' | 'interrupt' | 'resume' | 'agent_waiting' | 'agent_resumed';
4318
+ /**
4319
+ * Human request SSE event data
4320
+ */
4321
+ interface HumanRequestEventData {
4322
+ type: 'human_request';
4323
+ request: HumanRequest;
4324
+ threadId: string;
4325
+ }
4326
+ /**
4327
+ * Human response SSE event data
4328
+ */
4329
+ interface HumanResponseEventData {
4330
+ type: 'human_response';
4331
+ requestId: string;
4332
+ response: string;
4333
+ threadId: string;
4334
+ }
4335
+ /**
4336
+ * Interrupt SSE event data
4337
+ */
4338
+ interface InterruptEventData {
4339
+ type: 'interrupt';
4340
+ interrupt: AnyInterrupt;
4341
+ threadId: string;
4342
+ }
4343
+ /**
4344
+ * Resume SSE event data
4345
+ */
4346
+ interface ResumeEventData {
4347
+ type: 'resume';
4348
+ interruptId: string;
4349
+ value: any;
4350
+ threadId: string;
4351
+ }
4352
+ /**
4353
+ * Agent waiting SSE event data
4354
+ */
4355
+ interface AgentWaitingEventData {
4356
+ type: 'agent_waiting';
4357
+ reason: string;
4358
+ threadId: string;
4359
+ }
4360
+ /**
4361
+ * Agent resumed SSE event data
4362
+ */
4363
+ interface AgentResumedEventData {
4364
+ type: 'agent_resumed';
4365
+ threadId: string;
4366
+ }
4367
+ /**
4368
+ * Union type of all human-in-the-loop event data
4369
+ */
4370
+ type HumanInLoopEventData = HumanRequestEventData | HumanResponseEventData | InterruptEventData | ResumeEventData | AgentWaitingEventData | AgentResumedEventData;
4371
+ /**
4372
+ * Format a human request as an SSE event
4373
+ *
4374
+ * @param request - The human request
4375
+ * @param threadId - The thread ID
4376
+ * @returns An SSE event
4377
+ *
4378
+ * @example
4379
+ * ```typescript
4380
+ * const event = formatHumanRequestEvent(humanRequest, 'thread-123');
4381
+ * // Send to client via SSE
4382
+ * res.write(formatSSEEvent(event));
4383
+ * ```
4384
+ */
4385
+ declare function formatHumanRequestEvent(request: HumanRequest, threadId: string): SSEEvent;
4386
+ /**
4387
+ * Format a human response as an SSE event
4388
+ *
4389
+ * @param requestId - The request ID
4390
+ * @param response - The human's response
4391
+ * @param threadId - The thread ID
4392
+ * @returns An SSE event
4393
+ */
4394
+ declare function formatHumanResponseEvent(requestId: string, response: string, threadId: string): SSEEvent;
4395
+ /**
4396
+ * Format an interrupt as an SSE event
4397
+ *
4398
+ * @param interrupt - The interrupt data
4399
+ * @param threadId - The thread ID
4400
+ * @returns An SSE event
4401
+ */
4402
+ declare function formatInterruptEvent(interrupt: AnyInterrupt, threadId: string): SSEEvent;
4403
+ /**
4404
+ * Format a resume event as an SSE event
4405
+ *
4406
+ * @param interruptId - The interrupt ID being resumed
4407
+ * @param value - The resume value
4408
+ * @param threadId - The thread ID
4409
+ * @returns An SSE event
4410
+ */
4411
+ declare function formatResumeEvent(interruptId: string, value: any, threadId: string): SSEEvent;
4412
+ /**
4413
+ * Format an agent waiting event as an SSE event
4414
+ *
4415
+ * @param reason - Why the agent is waiting
4416
+ * @param threadId - The thread ID
4417
+ * @returns An SSE event
4418
+ */
4419
+ declare function formatAgentWaitingEvent(reason: string, threadId: string): SSEEvent;
4420
+ /**
4421
+ * Format an agent resumed event as an SSE event
4422
+ *
4423
+ * @param threadId - The thread ID
4424
+ * @returns An SSE event
4425
+ */
4426
+ declare function formatAgentResumedEvent(threadId: string): SSEEvent;
4427
+
4023
4428
  /**
4024
4429
  * WebSocket support for bidirectional streaming
4025
4430
  * @module streaming/websocket
@@ -4352,4 +4757,4 @@ declare class CircuitBreaker {
4352
4757
  }
4353
4758
  declare function createCircuitBreaker(options: CircuitBreakerOptions): CircuitBreaker;
4354
4759
 
4355
- export { AgentError, type AggregateNode, type BackoffStrategy, type BatchOptions, BatchProcessor, type BatchProcessorOptions, type BatchStats, type CheckpointHistoryOptions, type CheckpointerOptions, type ChunkOptions, CircuitBreaker, type CircuitBreakerOptions, type CircuitBreakerStats, type CircuitState, type ComposeGraphsOptions, type ComposeOptions, type ComposeToolConfig, type ComposedTool, type ConditionalConfig, type ConditionalRouter, type ConditionalRouterConfig, ConnectionPool, type ConnectionPoolOptions, type ConversationConfig, type DatabaseConfig, type DatabaseConnection, DatabasePool, type DatabasePoolOptions, type DevelopmentPresetOptions, type ErrorContext, type ErrorHandlerOptions, type ErrorReporter, type ErrorReporterOptions, type EventHandler, type ExecutionMetrics, type HealthCheckConfig, type HealthCheckResult, type HttpClient, type HttpConfig, HttpPool, type HttpPoolConfig, type HttpPoolOptions, type HttpResponse, type LangSmithConfig, type LogEntry, LogLevel, type Logger, type LoggerOptions, ManagedTool, type ManagedToolConfig, type ManagedToolStats, MemoryManager, type MemoryManagerOptions, type MemoryStats, type MetricEntry, MetricType, type Metrics, type MetricsNodeOptions, type Middleware, MiddlewareChain, type MiddlewareContext, type MiddlewareFactory, type MiddlewareMetadata, type MiddlewareWithMetadata, MissingDescriptionError, type MockToolConfig, type MockToolResponse, type NodeFunction, type NodeFunctionWithContext, type ParallelNode, type ParallelWorkflowConfig, type ParallelWorkflowOptions, type PoolConfig, type PoolStats, type Priority, type ProductionPresetOptions, type Progress, type ProgressTracker, type ProgressTrackerOptions, type PromptOptions, type ReducerFunction, RegistryEvent, type RequestConfig, type RetryOptions, type RetryPolicy, type RouteCondition, type RouteMap, type RouteName, type SSEEvent, type SSEFormatter, type SSEFormatterOptions, type SequentialNode, type SequentialWorkflowOptions, type SimpleMiddleware, type SqliteCheckpointerOptions, type StateChannelConfig, type SubgraphBuilder, type TestingPresetOptions, type ThreadConfig, type ThrottleOptions, TimeoutError, type TimeoutOptions, type Timer, type Tool, type BackoffStrategy$1 as ToolBackoffStrategy, ToolBuilder, ToolCategory, ToolCategorySchema, type ToolExample, ToolExampleSchema, type ToolExecution, type ToolExecutorConfig, type ToolInvocation, type ToolMetadata, ToolMetadataSchema, ToolNameSchema, ToolRegistry, type ToolRelations, ToolRelationsSchema, type ToolSimulatorConfig, type TracingOptions, type WebSocketHandlerOptions, type WebSocketMessage, batch, broadcast, cache, chain, chunk, clearThread, collect, compose, composeGraphs, composeTool, composeWithOptions, conditional, configureLangSmith, createBatchProcessor, createBinaryRouter, createCircuitBreaker, createConditionalRouter, createConnectionPool, createConversationConfig, createDatabasePool, createErrorReporter, createHeartbeat, createHttpPool, createLogger, createManagedTool, createMemoryCheckpointer, createMemoryManager, createMessage, createMetrics, createMiddlewareContext, createMockTool, createMultiRouter, createParallelWorkflow, createProgressTracker, createSSEFormatter, createSequentialWorkflow, createSqliteCheckpointer, createStateAnnotation, createSubgraph, createThreadConfig, createTool, createToolExecutor, createToolSimulator, createToolUnsafe, createWebSocketHandler, development, filter, generateThreadId, getCheckpointHistory, getLangSmithConfig, getLatestCheckpoint, getMissingDescriptions, getToolDescription, getToolJsonSchema, isMemoryCheckpointer, isTracingEnabled, map, merge, mergeState, parallel, parseSSEEvent, presets, production, reduce, retry, safeValidateSchemaDescriptions, sendMessage, sequential, sequentialBuilder, take, testing, throttle, timeout, toLangChainTool, toLangChainTools, toolBuilder, validateSchemaDescriptions, validateState, validateTool, validateToolMetadata, validateToolName, withErrorHandler, withMetrics, withRetry, withTimeout, withTracing };
4760
+ export { AgentError, type AgentResumedEventData, type AgentWaitingEventData, type AggregateNode, type AnyInterrupt, type ApprovalRequiredInterrupt, type BackoffStrategy, type BatchOptions, BatchProcessor, type BatchProcessorOptions, type BatchStats, type CheckInterruptOptions, type CheckpointHistoryOptions, type CheckpointerOptions, type ChunkOptions, CircuitBreaker, type CircuitBreakerOptions, type CircuitBreakerStats, type CircuitState, type ComposeGraphsOptions, type ComposeOptions, type ComposeToolConfig, type ComposedTool, type ConditionalConfig, type ConditionalRouter, type ConditionalRouterConfig, ConnectionPool, type ConnectionPoolOptions, type ConversationConfig, type CustomInterrupt, type DatabaseConfig, type DatabaseConnection, DatabasePool, type DatabasePoolOptions, type DevelopmentPresetOptions, type ErrorContext, type ErrorHandlerOptions, type ErrorReporter, type ErrorReporterOptions, type EventHandler, type ExecutionMetrics, type HealthCheckConfig, type HealthCheckResult, type HttpClient, type HttpConfig, HttpPool, type HttpPoolConfig, type HttpPoolOptions, type HttpResponse, type HumanInLoopEventData, type HumanInLoopEventType, type HumanRequest, type HumanRequestEventData, type HumanRequestInterrupt, type HumanRequestPriority, type HumanRequestStatus, type HumanResponseEventData, type InterruptData, type InterruptEventData, type InterruptType, type LangSmithConfig, type LogEntry, LogLevel, type Logger, type LoggerOptions, ManagedTool, type ManagedToolConfig, type ManagedToolStats, MemoryManager, type MemoryManagerOptions, type MemoryStats, type MetricEntry, MetricType, type Metrics, type MetricsNodeOptions, type Middleware, MiddlewareChain, type MiddlewareContext, type MiddlewareFactory, type MiddlewareMetadata, type MiddlewareWithMetadata, MissingDescriptionError, type MockToolConfig, type MockToolResponse, type NodeFunction, type NodeFunctionWithContext, type ParallelNode, type ParallelWorkflowConfig, type ParallelWorkflowOptions, type PoolConfig, type PoolStats, type Priority, type ProductionPresetOptions, type Progress, type ProgressTracker, type ProgressTrackerOptions, type PromptOptions, type ReducerFunction, RegistryEvent, type RequestConfig, type ResumeCommand, type ResumeEventData, type ResumeOptions, type RetryOptions, type RetryPolicy, type RouteCondition, type RouteMap, type RouteName, type SSEEvent, type SSEFormatter, type SSEFormatterOptions, type SequentialNode, type SequentialWorkflowOptions, type SimpleMiddleware, type SqliteCheckpointerOptions, type StateChannelConfig, type SubgraphBuilder, type TestingPresetOptions, type ThreadConfig, type ThreadInfo, type ThreadStatus, type ThrottleOptions, TimeoutError, type TimeoutOptions, type Timer, type Tool, type BackoffStrategy$1 as ToolBackoffStrategy, ToolBuilder, ToolCategory, ToolCategorySchema, type ToolExample, ToolExampleSchema, type ToolExecution, type ToolExecutorConfig, type ToolInvocation, type ToolMetadata, ToolMetadataSchema, ToolNameSchema, ToolRegistry, type ToolRelations, ToolRelationsSchema, type ToolSimulatorConfig, type TracingOptions, type WebSocketHandlerOptions, type WebSocketMessage, batch, broadcast, cache, chain, chunk, clearThread, collect, compose, composeGraphs, composeTool, composeWithOptions, conditional, configureLangSmith, createApprovalRequiredInterrupt, createBatchProcessor, createBinaryRouter, createCircuitBreaker, createConditionalRouter, createConnectionPool, createConversationConfig, createCustomInterrupt, createDatabasePool, createErrorReporter, createHeartbeat, createHttpPool, createHumanRequestInterrupt, createLogger, createManagedTool, createMemoryCheckpointer, createMemoryManager, createMessage, createMetrics, createMiddlewareContext, createMockTool, createMultiRouter, createParallelWorkflow, createProgressTracker, createSSEFormatter, createSequentialWorkflow, createSqliteCheckpointer, createStateAnnotation, createSubgraph, createThreadConfig, createTool, createToolExecutor, createToolSimulator, createToolUnsafe, createWebSocketHandler, development, filter, formatAgentResumedEvent, formatAgentWaitingEvent, formatHumanRequestEvent, formatHumanResponseEvent, formatInterruptEvent, formatResumeEvent, generateThreadId, getCheckpointHistory, getLangSmithConfig, getLatestCheckpoint, getMissingDescriptions, getThreadStatus, getToolDescription, getToolJsonSchema, isApprovalRequiredInterrupt, isCustomInterrupt, isHumanRequestInterrupt, isMemoryCheckpointer, isTracingEnabled, map, merge, mergeState, parallel, parseSSEEvent, presets, production, reduce, retry, safeValidateSchemaDescriptions, sendMessage, sequential, sequentialBuilder, take, testing, throttle, timeout, toLangChainTool, toLangChainTools, toolBuilder, validateSchemaDescriptions, validateState, validateTool, validateToolMetadata, validateToolName, withErrorHandler, withMetrics, withRetry, withTimeout, withTracing };
package/dist/index.js CHANGED
@@ -2818,6 +2818,52 @@ var presets = {
2818
2818
  testing
2819
2819
  };
2820
2820
 
2821
+ // src/langgraph/interrupts/utils.ts
2822
+ function createHumanRequestInterrupt(request) {
2823
+ return {
2824
+ type: "human_request",
2825
+ id: request.id,
2826
+ createdAt: request.createdAt,
2827
+ data: request
2828
+ };
2829
+ }
2830
+ function createApprovalRequiredInterrupt(action, description, context) {
2831
+ return {
2832
+ type: "approval_required",
2833
+ id: `approval-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
2834
+ createdAt: Date.now(),
2835
+ data: {
2836
+ action,
2837
+ description,
2838
+ context
2839
+ }
2840
+ };
2841
+ }
2842
+ function createCustomInterrupt(id, data, metadata) {
2843
+ return {
2844
+ type: "custom",
2845
+ id,
2846
+ createdAt: Date.now(),
2847
+ data,
2848
+ metadata
2849
+ };
2850
+ }
2851
+ function isHumanRequestInterrupt(interrupt) {
2852
+ return interrupt.type === "human_request";
2853
+ }
2854
+ function isApprovalRequiredInterrupt(interrupt) {
2855
+ return interrupt.type === "approval_required";
2856
+ }
2857
+ function isCustomInterrupt(interrupt) {
2858
+ return interrupt.type === "custom";
2859
+ }
2860
+ function getThreadStatus(hasInterrupts, isComplete, hasError) {
2861
+ if (hasError) return "error";
2862
+ if (isComplete) return "completed";
2863
+ if (hasInterrupts) return "interrupted";
2864
+ return "running";
2865
+ }
2866
+
2821
2867
  // src/streaming/transformers.ts
2822
2868
  async function* chunk(stream, options) {
2823
2869
  const { size } = options;
@@ -3154,6 +3200,79 @@ ${data}` : data;
3154
3200
  return event.data !== void 0 ? event : null;
3155
3201
  }
3156
3202
 
3203
+ // src/streaming/human-in-loop.ts
3204
+ function formatHumanRequestEvent(request, threadId) {
3205
+ const data = {
3206
+ type: "human_request",
3207
+ request,
3208
+ threadId
3209
+ };
3210
+ return {
3211
+ event: "human_request",
3212
+ data: JSON.stringify(data),
3213
+ id: request.id
3214
+ };
3215
+ }
3216
+ function formatHumanResponseEvent(requestId, response, threadId) {
3217
+ const data = {
3218
+ type: "human_response",
3219
+ requestId,
3220
+ response,
3221
+ threadId
3222
+ };
3223
+ return {
3224
+ event: "human_response",
3225
+ data: JSON.stringify(data),
3226
+ id: `response-${requestId}`
3227
+ };
3228
+ }
3229
+ function formatInterruptEvent(interrupt, threadId) {
3230
+ const data = {
3231
+ type: "interrupt",
3232
+ interrupt,
3233
+ threadId
3234
+ };
3235
+ return {
3236
+ event: "interrupt",
3237
+ data: JSON.stringify(data),
3238
+ id: interrupt.id
3239
+ };
3240
+ }
3241
+ function formatResumeEvent(interruptId, value, threadId) {
3242
+ const data = {
3243
+ type: "resume",
3244
+ interruptId,
3245
+ value,
3246
+ threadId
3247
+ };
3248
+ return {
3249
+ event: "resume",
3250
+ data: JSON.stringify(data),
3251
+ id: `resume-${interruptId}`
3252
+ };
3253
+ }
3254
+ function formatAgentWaitingEvent(reason, threadId) {
3255
+ const data = {
3256
+ type: "agent_waiting",
3257
+ reason,
3258
+ threadId
3259
+ };
3260
+ return {
3261
+ event: "agent_waiting",
3262
+ data: JSON.stringify(data)
3263
+ };
3264
+ }
3265
+ function formatAgentResumedEvent(threadId) {
3266
+ const data = {
3267
+ type: "agent_resumed",
3268
+ threadId
3269
+ };
3270
+ return {
3271
+ event: "agent_resumed",
3272
+ data: JSON.stringify(data)
3273
+ };
3274
+ }
3275
+
3157
3276
  // src/streaming/websocket.ts
3158
3277
  function createWebSocketHandler(options) {
3159
3278
  const { onConnect, onMessage, onError, onClose, heartbeat = 0 } = options;
@@ -4016,16 +4135,19 @@ export {
4016
4135
  composeWithOptions,
4017
4136
  conditional,
4018
4137
  configureLangSmith,
4138
+ createApprovalRequiredInterrupt,
4019
4139
  createBatchProcessor,
4020
4140
  createBinaryRouter,
4021
4141
  createCircuitBreaker,
4022
4142
  createConditionalRouter,
4023
4143
  createConnectionPool,
4024
4144
  createConversationConfig,
4145
+ createCustomInterrupt,
4025
4146
  createDatabasePool,
4026
4147
  createErrorReporter,
4027
4148
  createHeartbeat,
4028
4149
  createHttpPool,
4150
+ createHumanRequestInterrupt,
4029
4151
  createLogger,
4030
4152
  createManagedTool,
4031
4153
  createMemoryCheckpointer,
@@ -4050,13 +4172,23 @@ export {
4050
4172
  createWebSocketHandler,
4051
4173
  development,
4052
4174
  filter,
4175
+ formatAgentResumedEvent,
4176
+ formatAgentWaitingEvent,
4177
+ formatHumanRequestEvent,
4178
+ formatHumanResponseEvent,
4179
+ formatInterruptEvent,
4180
+ formatResumeEvent,
4053
4181
  generateThreadId,
4054
4182
  getCheckpointHistory,
4055
4183
  getLangSmithConfig,
4056
4184
  getLatestCheckpoint,
4057
4185
  getMissingDescriptions,
4186
+ getThreadStatus,
4058
4187
  getToolDescription,
4059
4188
  getToolJsonSchema,
4189
+ isApprovalRequiredInterrupt,
4190
+ isCustomInterrupt,
4191
+ isHumanRequestInterrupt,
4060
4192
  isMemoryCheckpointer,
4061
4193
  isTracingEnabled,
4062
4194
  map,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentforge/core",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Core abstractions for AgentForge - production-ready deep agents framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",