@witqq/agent-sdk 0.7.0 → 0.8.0

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.
Files changed (147) hide show
  1. package/README.md +140 -34
  2. package/dist/{types-CqvUAYxt.d.cts → agent-CW9XbmG_.d.ts} +137 -102
  3. package/dist/{types-CqvUAYxt.d.ts → agent-DxY68NZL.d.cts} +137 -102
  4. package/dist/auth/index.cjs +72 -1
  5. package/dist/auth/index.cjs.map +1 -1
  6. package/dist/auth/index.d.cts +21 -154
  7. package/dist/auth/index.d.ts +21 -154
  8. package/dist/auth/index.js +72 -1
  9. package/dist/auth/index.js.map +1 -1
  10. package/dist/backends/claude.cjs +480 -261
  11. package/dist/backends/claude.cjs.map +1 -1
  12. package/dist/backends/claude.d.cts +3 -1
  13. package/dist/backends/claude.d.ts +3 -1
  14. package/dist/backends/claude.js +480 -261
  15. package/dist/backends/claude.js.map +1 -1
  16. package/dist/backends/copilot.cjs +329 -97
  17. package/dist/backends/copilot.cjs.map +1 -1
  18. package/dist/backends/copilot.d.cts +12 -4
  19. package/dist/backends/copilot.d.ts +12 -4
  20. package/dist/backends/copilot.js +329 -97
  21. package/dist/backends/copilot.js.map +1 -1
  22. package/dist/backends/vercel-ai.cjs +294 -61
  23. package/dist/backends/vercel-ai.cjs.map +1 -1
  24. package/dist/backends/vercel-ai.d.cts +3 -1
  25. package/dist/backends/vercel-ai.d.ts +3 -1
  26. package/dist/backends/vercel-ai.js +294 -61
  27. package/dist/backends/vercel-ai.js.map +1 -1
  28. package/dist/backends-BSrsBYFn.d.cts +39 -0
  29. package/dist/backends-BSrsBYFn.d.ts +39 -0
  30. package/dist/chat/accumulator.cjs +1 -1
  31. package/dist/chat/accumulator.cjs.map +1 -1
  32. package/dist/chat/accumulator.d.cts +5 -2
  33. package/dist/chat/accumulator.d.ts +5 -2
  34. package/dist/chat/accumulator.js +1 -1
  35. package/dist/chat/accumulator.js.map +1 -1
  36. package/dist/chat/backends.cjs +736 -746
  37. package/dist/chat/backends.cjs.map +1 -1
  38. package/dist/chat/backends.d.cts +10 -6
  39. package/dist/chat/backends.d.ts +10 -6
  40. package/dist/chat/backends.js +736 -725
  41. package/dist/chat/backends.js.map +1 -1
  42. package/dist/chat/context.cjs +50 -0
  43. package/dist/chat/context.cjs.map +1 -1
  44. package/dist/chat/context.d.cts +27 -3
  45. package/dist/chat/context.d.ts +27 -3
  46. package/dist/chat/context.js +50 -0
  47. package/dist/chat/context.js.map +1 -1
  48. package/dist/chat/core.cjs +25 -2
  49. package/dist/chat/core.cjs.map +1 -1
  50. package/dist/chat/core.d.cts +30 -381
  51. package/dist/chat/core.d.ts +30 -381
  52. package/dist/chat/core.js +24 -3
  53. package/dist/chat/core.js.map +1 -1
  54. package/dist/chat/errors.cjs +48 -26
  55. package/dist/chat/errors.cjs.map +1 -1
  56. package/dist/chat/errors.d.cts +6 -31
  57. package/dist/chat/errors.d.ts +6 -31
  58. package/dist/chat/errors.js +48 -25
  59. package/dist/chat/errors.js.map +1 -1
  60. package/dist/chat/events.cjs.map +1 -1
  61. package/dist/chat/events.d.cts +6 -2
  62. package/dist/chat/events.d.ts +6 -2
  63. package/dist/chat/events.js.map +1 -1
  64. package/dist/chat/index.cjs +1199 -1008
  65. package/dist/chat/index.cjs.map +1 -1
  66. package/dist/chat/index.d.cts +35 -10
  67. package/dist/chat/index.d.ts +35 -10
  68. package/dist/chat/index.js +1196 -987
  69. package/dist/chat/index.js.map +1 -1
  70. package/dist/chat/react/theme.css +2517 -0
  71. package/dist/chat/react.cjs +2003 -1153
  72. package/dist/chat/react.cjs.map +1 -1
  73. package/dist/chat/react.d.cts +590 -121
  74. package/dist/chat/react.d.ts +590 -121
  75. package/dist/chat/react.js +1984 -1151
  76. package/dist/chat/react.js.map +1 -1
  77. package/dist/chat/runtime.cjs +401 -186
  78. package/dist/chat/runtime.cjs.map +1 -1
  79. package/dist/chat/runtime.d.cts +92 -28
  80. package/dist/chat/runtime.d.ts +92 -28
  81. package/dist/chat/runtime.js +401 -186
  82. package/dist/chat/runtime.js.map +1 -1
  83. package/dist/chat/server.cjs +2234 -209
  84. package/dist/chat/server.cjs.map +1 -1
  85. package/dist/chat/server.d.cts +451 -90
  86. package/dist/chat/server.d.ts +451 -90
  87. package/dist/chat/server.js +2221 -210
  88. package/dist/chat/server.js.map +1 -1
  89. package/dist/chat/sessions.cjs +25 -43
  90. package/dist/chat/sessions.cjs.map +1 -1
  91. package/dist/chat/sessions.d.cts +37 -118
  92. package/dist/chat/sessions.d.ts +37 -118
  93. package/dist/chat/sessions.js +25 -43
  94. package/dist/chat/sessions.js.map +1 -1
  95. package/dist/chat/sqlite.cjs +441 -0
  96. package/dist/chat/sqlite.cjs.map +1 -0
  97. package/dist/chat/sqlite.d.cts +128 -0
  98. package/dist/chat/sqlite.d.ts +128 -0
  99. package/dist/chat/sqlite.js +435 -0
  100. package/dist/chat/sqlite.js.map +1 -0
  101. package/dist/chat/state.cjs +14 -1
  102. package/dist/chat/state.cjs.map +1 -1
  103. package/dist/chat/state.d.cts +5 -2
  104. package/dist/chat/state.d.ts +5 -2
  105. package/dist/chat/state.js +14 -1
  106. package/dist/chat/state.js.map +1 -1
  107. package/dist/chat/storage.cjs +19 -10
  108. package/dist/chat/storage.cjs.map +1 -1
  109. package/dist/chat/storage.d.cts +11 -5
  110. package/dist/chat/storage.d.ts +11 -5
  111. package/dist/chat/storage.js +19 -10
  112. package/dist/chat/storage.js.map +1 -1
  113. package/dist/errors-C-so0M4t.d.cts +33 -0
  114. package/dist/errors-C-so0M4t.d.ts +33 -0
  115. package/dist/errors-CmVvczxZ.d.cts +28 -0
  116. package/dist/errors-CmVvczxZ.d.ts +28 -0
  117. package/dist/{in-process-transport-C2oPTYs6.d.ts → in-process-transport-C1JnJGVR.d.ts} +28 -23
  118. package/dist/{in-process-transport-DG-w5G6k.d.cts → in-process-transport-C7DSqPyX.d.cts} +28 -23
  119. package/dist/index.cjs +340 -46
  120. package/dist/index.cjs.map +1 -1
  121. package/dist/index.d.cts +292 -123
  122. package/dist/index.d.ts +292 -123
  123. package/dist/index.js +334 -47
  124. package/dist/index.js.map +1 -1
  125. package/dist/provider-types-PTSlRPNB.d.cts +39 -0
  126. package/dist/provider-types-PTSlRPNB.d.ts +39 -0
  127. package/dist/refresh-manager-B81PpYBr.d.cts +153 -0
  128. package/dist/refresh-manager-Dlv_iNZi.d.ts +153 -0
  129. package/dist/testing.cjs +383 -0
  130. package/dist/testing.cjs.map +1 -0
  131. package/dist/testing.d.cts +132 -0
  132. package/dist/testing.d.ts +132 -0
  133. package/dist/testing.js +377 -0
  134. package/dist/testing.js.map +1 -0
  135. package/dist/token-store-CSUBgYwn.d.ts +48 -0
  136. package/dist/token-store-CuC4hB9Z.d.cts +48 -0
  137. package/dist/{transport-DX1Nhm4N.d.cts → transport-Cdh3M0tS.d.cts} +5 -4
  138. package/dist/{transport-D1OaUgRk.d.ts → transport-Ciap4PWK.d.ts} +5 -4
  139. package/dist/{types-CGF7AEX1.d.cts → types-4vbcmPTp.d.cts} +4 -2
  140. package/dist/{types-Bh5AhqD-.d.ts → types-BxggH0Yh.d.ts} +4 -2
  141. package/dist/types-DRgd_9R7.d.cts +363 -0
  142. package/dist/types-ajANVzf7.d.ts +363 -0
  143. package/package.json +31 -6
  144. package/dist/errors-BDLbNu9w.d.cts +0 -13
  145. package/dist/errors-BDLbNu9w.d.ts +0 -13
  146. package/dist/types-DLZzlJxt.d.ts +0 -39
  147. package/dist/types-tE0CXwBl.d.cts +0 -39
@@ -1,17 +1,42 @@
1
- export { ChatEvent, ChatEventType, ChatId, ChatIdLike, ChatMessage, ChatMessageMetadata, ChatMessageStatus, ChatMiddleware, ChatMiddlewareContext, ChatRole, ChatSession, ChatSessionConfig, FilePart, IChatProvider, MessagePart, MessageStatus, PartStatus, ReasoningPart, RuntimeStatus, SendMessageOptions, SessionInfo, SessionStatus, SourcePart, TextPart, ToolCallPart, ToolCallStatus, adaptAgentEvents, agentEventToChatEvent, createChatId, fromAgentMessage, getMessageReasoning, getMessageText, getMessageToolCalls, isChatEvent, isChatMessage, isChatSession, isFilePart, isMessagePart, isReasoningPart, isSourcePart, isTextPart, isToolCallPart, toAgentMessage, toChatId } from './core.cjs';
2
- export { BackendAdapterFactory, ChatRuntimeOptions, IChatRuntime, RetryConfig, createChatRuntime } from './runtime.cjs';
3
- export { CreateSessionOptions, FileSessionStore, IChatSessionStore, InMemorySessionStore, PaginatedMessages } from './sessions.cjs';
4
- export { ChatError, ChatErrorCode, ChatError as ChatSDKError, ExponentialBackoffStrategy, classifyError, isRetryable, withRetry } from './errors.cjs';
5
- export { B as BackendAdapterOptions, I as IBackendAdapter } from '../types-tE0CXwBl.cjs';
6
- export { B as BaseBackendAdapter, C as ClaudeChatAdapter, a as CopilotChatAdapter, I as InProcessChatTransport, V as VercelAIChatAdapter, W as WsChatTransport } from '../in-process-transport-DG-w5G6k.cjs';
7
- export { I as IChatTransport, S as SSEChatTransport, s as streamToTransport } from '../transport-DX1Nhm4N.cjs';
1
+ export { B as BackendAdapterOptions, a as ChatEvent, C as ChatEventType, b as ChatId, f as ChatIdLike, c as ChatMessage, k as ChatMessageMetadata, l as ChatMessageStatus, e as ChatMiddleware, m as ChatMiddlewareContext, n as ChatRole, g as ChatSession, j as ChatSessionConfig, F as FilePart, I as IChatBackend, o as IChatProvider, d as IResumableBackend, p as MessagePart, M as MessageStatus, O as ObservableSession, P as PartStatus, q as ReasoningPart, h as RuntimeSendOptions, R as RuntimeStatus, S as SendMessageOptions, r as SessionInfo, s as SessionStatus, t as SourcePart, u as TextPart, v as ToolCallPart, T as ToolCallStatus, w as createChatId, x as createTextMessage, y as isObservableSession, i as isResumableBackend, z as toChatId } from '../types-DRgd_9R7.cjs';
2
+ export { adaptAgentEvents, agentEventToChatEvent, fromAgentMessage, getMessageReasoning, getMessageText, getMessageToolCalls, isChatEvent, isChatMessage, isChatSession, isFilePart, isMessagePart, isReasoningPart, isSourcePart, isTextPart, isToolCallPart, toAgentMessage } from './core.cjs';
3
+ export { BackendAdapterFactory, BackendInfo, ChatRuntimeOptions, IChatClient, IChatRuntime, IProviderClient, RetryConfig, SelectionChangeCallback, StreamRetryConfig, createChatRuntime } from './runtime.cjs';
4
+ export { CreateSessionOptions, FileSessionStore, IChatSessionStore, ISessionReader, ISessionWriter, InMemorySessionStore, PaginatedMessages } from './sessions.cjs';
5
+ export { ChatError, ExponentialBackoffStrategy, classifyError, isRetryable, withRetry } from './errors.cjs';
6
+ export { B as BaseBackendAdapter, C as ClaudeChatAdapter, b as CopilotChatAdapter, I as InProcessChatTransport, V as VercelAIChatAdapter, f as WsChatTransport } from '../in-process-transport-C7DSqPyX.cjs';
7
+ export { I as IChatTransport, S as SSEChatTransport, s as streamToTransport } from '../transport-Cdh3M0tS.cjs';
8
8
  export { ContextStats, ContextWindowConfig, ContextWindowManager, ContextWindowResult, OverflowStrategy, estimateTokens } from './context.cjs';
9
9
  export { MessageAccumulator } from './accumulator.cjs';
10
10
  export { ChatEventBus, TypedEventEmitter } from './events.cjs';
11
- import '../types-CqvUAYxt.cjs';
11
+ export { I as IProviderStore, P as ProviderConfig } from '../provider-types-PTSlRPNB.cjs';
12
+ export { E as ErrorCode } from '../errors-C-so0M4t.cjs';
13
+ import '../agent-DxY68NZL.cjs';
12
14
  import 'zod';
15
+ import '../types-4vbcmPTp.cjs';
16
+ import '../errors-CmVvczxZ.cjs';
13
17
  import './storage.cjs';
14
- import '../errors-BDLbNu9w.cjs';
18
+ import '../backends-BSrsBYFn.cjs';
19
+
20
+ /**
21
+ * Generic listener set utility for subscribe/notify patterns.
22
+ *
23
+ * Encapsulates the recurring pattern of:
24
+ * - Set<callback> storage
25
+ * - add(callback) → unsubscribe function
26
+ * - notify(...args) with try/catch per listener
27
+ * - clear() for disposal
28
+ */
29
+ declare class ListenerSet<T extends (...args: any[]) => void> {
30
+ private readonly _listeners;
31
+ /** Add a listener. Returns an unsubscribe function. */
32
+ add(callback: T): () => void;
33
+ /** Notify all listeners with the given arguments. Errors are isolated per listener. */
34
+ notify(...args: Parameters<T>): void;
35
+ /** Remove all listeners. */
36
+ clear(): void;
37
+ /** Current number of listeners. */
38
+ get size(): number;
39
+ }
15
40
 
16
41
  /**
17
42
  * @witqq/agent-sdk - Stream Watchdog
@@ -49,4 +74,4 @@ interface StreamWatchdogConfig {
49
74
  */
50
75
  declare function withStreamWatchdog<T>(source: AsyncIterable<T>, config: StreamWatchdogConfig): AsyncGenerator<T>;
51
76
 
52
- export { type StreamWatchdogConfig, withStreamWatchdog };
77
+ export { ListenerSet, type StreamWatchdogConfig, withStreamWatchdog };
@@ -1,17 +1,42 @@
1
- export { ChatEvent, ChatEventType, ChatId, ChatIdLike, ChatMessage, ChatMessageMetadata, ChatMessageStatus, ChatMiddleware, ChatMiddlewareContext, ChatRole, ChatSession, ChatSessionConfig, FilePart, IChatProvider, MessagePart, MessageStatus, PartStatus, ReasoningPart, RuntimeStatus, SendMessageOptions, SessionInfo, SessionStatus, SourcePart, TextPart, ToolCallPart, ToolCallStatus, adaptAgentEvents, agentEventToChatEvent, createChatId, fromAgentMessage, getMessageReasoning, getMessageText, getMessageToolCalls, isChatEvent, isChatMessage, isChatSession, isFilePart, isMessagePart, isReasoningPart, isSourcePart, isTextPart, isToolCallPart, toAgentMessage, toChatId } from './core.js';
2
- export { BackendAdapterFactory, ChatRuntimeOptions, IChatRuntime, RetryConfig, createChatRuntime } from './runtime.js';
3
- export { CreateSessionOptions, FileSessionStore, IChatSessionStore, InMemorySessionStore, PaginatedMessages } from './sessions.js';
4
- export { ChatError, ChatErrorCode, ChatError as ChatSDKError, ExponentialBackoffStrategy, classifyError, isRetryable, withRetry } from './errors.js';
5
- export { B as BackendAdapterOptions, I as IBackendAdapter } from '../types-DLZzlJxt.js';
6
- export { B as BaseBackendAdapter, C as ClaudeChatAdapter, a as CopilotChatAdapter, I as InProcessChatTransport, V as VercelAIChatAdapter, W as WsChatTransport } from '../in-process-transport-C2oPTYs6.js';
7
- export { I as IChatTransport, S as SSEChatTransport, s as streamToTransport } from '../transport-D1OaUgRk.js';
1
+ export { B as BackendAdapterOptions, a as ChatEvent, C as ChatEventType, b as ChatId, f as ChatIdLike, c as ChatMessage, k as ChatMessageMetadata, l as ChatMessageStatus, e as ChatMiddleware, m as ChatMiddlewareContext, n as ChatRole, g as ChatSession, j as ChatSessionConfig, F as FilePart, I as IChatBackend, o as IChatProvider, d as IResumableBackend, p as MessagePart, M as MessageStatus, O as ObservableSession, P as PartStatus, q as ReasoningPart, h as RuntimeSendOptions, R as RuntimeStatus, S as SendMessageOptions, r as SessionInfo, s as SessionStatus, t as SourcePart, u as TextPart, v as ToolCallPart, T as ToolCallStatus, w as createChatId, x as createTextMessage, y as isObservableSession, i as isResumableBackend, z as toChatId } from '../types-ajANVzf7.js';
2
+ export { adaptAgentEvents, agentEventToChatEvent, fromAgentMessage, getMessageReasoning, getMessageText, getMessageToolCalls, isChatEvent, isChatMessage, isChatSession, isFilePart, isMessagePart, isReasoningPart, isSourcePart, isTextPart, isToolCallPart, toAgentMessage } from './core.js';
3
+ export { BackendAdapterFactory, BackendInfo, ChatRuntimeOptions, IChatClient, IChatRuntime, IProviderClient, RetryConfig, SelectionChangeCallback, StreamRetryConfig, createChatRuntime } from './runtime.js';
4
+ export { CreateSessionOptions, FileSessionStore, IChatSessionStore, ISessionReader, ISessionWriter, InMemorySessionStore, PaginatedMessages } from './sessions.js';
5
+ export { ChatError, ExponentialBackoffStrategy, classifyError, isRetryable, withRetry } from './errors.js';
6
+ export { B as BaseBackendAdapter, C as ClaudeChatAdapter, b as CopilotChatAdapter, I as InProcessChatTransport, V as VercelAIChatAdapter, f as WsChatTransport } from '../in-process-transport-C1JnJGVR.js';
7
+ export { I as IChatTransport, S as SSEChatTransport, s as streamToTransport } from '../transport-Ciap4PWK.js';
8
8
  export { ContextStats, ContextWindowConfig, ContextWindowManager, ContextWindowResult, OverflowStrategy, estimateTokens } from './context.js';
9
9
  export { MessageAccumulator } from './accumulator.js';
10
10
  export { ChatEventBus, TypedEventEmitter } from './events.js';
11
- import '../types-CqvUAYxt.js';
11
+ export { I as IProviderStore, P as ProviderConfig } from '../provider-types-PTSlRPNB.js';
12
+ export { E as ErrorCode } from '../errors-C-so0M4t.js';
13
+ import '../agent-CW9XbmG_.js';
12
14
  import 'zod';
15
+ import '../types-BxggH0Yh.js';
16
+ import '../errors-CmVvczxZ.js';
13
17
  import './storage.js';
14
- import '../errors-BDLbNu9w.js';
18
+ import '../backends-BSrsBYFn.js';
19
+
20
+ /**
21
+ * Generic listener set utility for subscribe/notify patterns.
22
+ *
23
+ * Encapsulates the recurring pattern of:
24
+ * - Set<callback> storage
25
+ * - add(callback) → unsubscribe function
26
+ * - notify(...args) with try/catch per listener
27
+ * - clear() for disposal
28
+ */
29
+ declare class ListenerSet<T extends (...args: any[]) => void> {
30
+ private readonly _listeners;
31
+ /** Add a listener. Returns an unsubscribe function. */
32
+ add(callback: T): () => void;
33
+ /** Notify all listeners with the given arguments. Errors are isolated per listener. */
34
+ notify(...args: Parameters<T>): void;
35
+ /** Remove all listeners. */
36
+ clear(): void;
37
+ /** Current number of listeners. */
38
+ get size(): number;
39
+ }
15
40
 
16
41
  /**
17
42
  * @witqq/agent-sdk - Stream Watchdog
@@ -49,4 +74,4 @@ interface StreamWatchdogConfig {
49
74
  */
50
75
  declare function withStreamWatchdog<T>(source: AsyncIterable<T>, config: StreamWatchdogConfig): AsyncGenerator<T>;
51
76
 
52
- export { type StreamWatchdogConfig, withStreamWatchdog };
77
+ export { ListenerSet, type StreamWatchdogConfig, withStreamWatchdog };