@witqq/agent-sdk 0.6.1 → 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.
- package/README.md +539 -6
- package/dist/{types-BvwNzZCj.d.cts → agent-CW9XbmG_.d.ts} +148 -95
- package/dist/{types-BvwNzZCj.d.ts → agent-DxY68NZL.d.cts} +148 -95
- package/dist/auth/index.cjs +260 -2
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.cts +21 -138
- package/dist/auth/index.d.ts +21 -138
- package/dist/auth/index.js +260 -3
- package/dist/auth/index.js.map +1 -1
- package/dist/backends/claude.cjs +653 -140
- package/dist/backends/claude.cjs.map +1 -1
- package/dist/backends/claude.d.cts +4 -1
- package/dist/backends/claude.d.ts +4 -1
- package/dist/backends/claude.js +653 -140
- package/dist/backends/claude.js.map +1 -1
- package/dist/backends/copilot.cjs +428 -88
- package/dist/backends/copilot.cjs.map +1 -1
- package/dist/backends/copilot.d.cts +13 -4
- package/dist/backends/copilot.d.ts +13 -4
- package/dist/backends/copilot.js +428 -88
- package/dist/backends/copilot.js.map +1 -1
- package/dist/backends/vercel-ai.cjs +349 -77
- package/dist/backends/vercel-ai.cjs.map +1 -1
- package/dist/backends/vercel-ai.d.cts +3 -1
- package/dist/backends/vercel-ai.d.ts +3 -1
- package/dist/backends/vercel-ai.js +349 -77
- package/dist/backends/vercel-ai.js.map +1 -1
- package/dist/backends-BSrsBYFn.d.cts +39 -0
- package/dist/backends-BSrsBYFn.d.ts +39 -0
- package/dist/chat/accumulator.cjs +147 -0
- package/dist/chat/accumulator.cjs.map +1 -0
- package/dist/chat/accumulator.d.cts +64 -0
- package/dist/chat/accumulator.d.ts +64 -0
- package/dist/chat/accumulator.js +145 -0
- package/dist/chat/accumulator.js.map +1 -0
- package/dist/chat/backends.cjs +3524 -0
- package/dist/chat/backends.cjs.map +1 -0
- package/dist/chat/backends.d.cts +66 -0
- package/dist/chat/backends.d.ts +66 -0
- package/dist/chat/backends.js +3512 -0
- package/dist/chat/backends.js.map +1 -0
- package/dist/chat/context.cjs +280 -0
- package/dist/chat/context.cjs.map +1 -0
- package/dist/chat/context.d.cts +191 -0
- package/dist/chat/context.d.ts +191 -0
- package/dist/chat/context.js +277 -0
- package/dist/chat/context.js.map +1 -0
- package/dist/chat/core.cjs +305 -0
- package/dist/chat/core.cjs.map +1 -0
- package/dist/chat/core.d.cts +84 -0
- package/dist/chat/core.d.ts +84 -0
- package/dist/chat/core.js +282 -0
- package/dist/chat/core.js.map +1 -0
- package/dist/chat/errors.cjs +273 -0
- package/dist/chat/errors.cjs.map +1 -0
- package/dist/chat/errors.d.cts +97 -0
- package/dist/chat/errors.d.ts +97 -0
- package/dist/chat/errors.js +266 -0
- package/dist/chat/errors.js.map +1 -0
- package/dist/chat/events.cjs +203 -0
- package/dist/chat/events.cjs.map +1 -0
- package/dist/chat/events.d.cts +245 -0
- package/dist/chat/events.d.ts +245 -0
- package/dist/chat/events.js +196 -0
- package/dist/chat/events.js.map +1 -0
- package/dist/chat/index.cjs +5550 -0
- package/dist/chat/index.cjs.map +1 -0
- package/dist/chat/index.d.cts +77 -0
- package/dist/chat/index.d.ts +77 -0
- package/dist/chat/index.js +5505 -0
- package/dist/chat/index.js.map +1 -0
- package/dist/chat/react/theme.css +2517 -0
- package/dist/chat/react.cjs +3589 -0
- package/dist/chat/react.cjs.map +1 -0
- package/dist/chat/react.d.cts +1088 -0
- package/dist/chat/react.d.ts +1088 -0
- package/dist/chat/react.js +3547 -0
- package/dist/chat/react.js.map +1 -0
- package/dist/chat/runtime.cjs +1245 -0
- package/dist/chat/runtime.cjs.map +1 -0
- package/dist/chat/runtime.d.cts +182 -0
- package/dist/chat/runtime.d.ts +182 -0
- package/dist/chat/runtime.js +1243 -0
- package/dist/chat/runtime.js.map +1 -0
- package/dist/chat/server.cjs +2668 -0
- package/dist/chat/server.cjs.map +1 -0
- package/dist/chat/server.d.cts +648 -0
- package/dist/chat/server.d.ts +648 -0
- package/dist/chat/server.js +2628 -0
- package/dist/chat/server.js.map +1 -0
- package/dist/chat/sessions.cjs +380 -0
- package/dist/chat/sessions.cjs.map +1 -0
- package/dist/chat/sessions.d.cts +158 -0
- package/dist/chat/sessions.d.ts +158 -0
- package/dist/chat/sessions.js +376 -0
- package/dist/chat/sessions.js.map +1 -0
- package/dist/chat/sqlite.cjs +441 -0
- package/dist/chat/sqlite.cjs.map +1 -0
- package/dist/chat/sqlite.d.cts +128 -0
- package/dist/chat/sqlite.d.ts +128 -0
- package/dist/chat/sqlite.js +435 -0
- package/dist/chat/sqlite.js.map +1 -0
- package/dist/chat/state.cjs +190 -0
- package/dist/chat/state.cjs.map +1 -0
- package/dist/chat/state.d.cts +95 -0
- package/dist/chat/state.d.ts +95 -0
- package/dist/chat/state.js +180 -0
- package/dist/chat/state.js.map +1 -0
- package/dist/chat/storage.cjs +249 -0
- package/dist/chat/storage.cjs.map +1 -0
- package/dist/chat/storage.d.cts +197 -0
- package/dist/chat/storage.d.ts +197 -0
- package/dist/chat/storage.js +245 -0
- package/dist/chat/storage.js.map +1 -0
- package/dist/errors-C-so0M4t.d.cts +33 -0
- package/dist/errors-C-so0M4t.d.ts +33 -0
- package/dist/errors-CmVvczxZ.d.cts +28 -0
- package/dist/errors-CmVvczxZ.d.ts +28 -0
- package/dist/in-process-transport-C1JnJGVR.d.ts +228 -0
- package/dist/in-process-transport-C7DSqPyX.d.cts +228 -0
- package/dist/index.cjs +365 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +322 -125
- package/dist/index.d.ts +322 -125
- package/dist/index.js +359 -60
- package/dist/index.js.map +1 -1
- package/dist/provider-types-PTSlRPNB.d.cts +39 -0
- package/dist/provider-types-PTSlRPNB.d.ts +39 -0
- package/dist/refresh-manager-B81PpYBr.d.cts +153 -0
- package/dist/refresh-manager-Dlv_iNZi.d.ts +153 -0
- package/dist/testing.cjs +383 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +132 -0
- package/dist/testing.d.ts +132 -0
- package/dist/testing.js +377 -0
- package/dist/testing.js.map +1 -0
- package/dist/token-store-CSUBgYwn.d.ts +48 -0
- package/dist/token-store-CuC4hB9Z.d.cts +48 -0
- package/dist/transport-Cdh3M0tS.d.cts +68 -0
- package/dist/transport-Ciap4PWK.d.ts +68 -0
- package/dist/types-4vbcmPTp.d.cts +143 -0
- package/dist/types-BxggH0Yh.d.ts +143 -0
- package/dist/types-DRgd_9R7.d.cts +363 -0
- package/dist/types-ajANVzf7.d.ts +363 -0
- package/package.json +178 -6
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
export { ContextStats, ContextWindowConfig, ContextWindowManager, ContextWindowResult, OverflowStrategy, estimateTokens } from './context.cjs';
|
|
9
|
+
export { MessageAccumulator } from './accumulator.cjs';
|
|
10
|
+
export { ChatEventBus, TypedEventEmitter } from './events.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';
|
|
14
|
+
import 'zod';
|
|
15
|
+
import '../types-4vbcmPTp.cjs';
|
|
16
|
+
import '../errors-CmVvczxZ.cjs';
|
|
17
|
+
import './storage.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
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @witqq/agent-sdk - Stream Watchdog
|
|
43
|
+
*
|
|
44
|
+
* Activity-based timeout wrapper for async event streams.
|
|
45
|
+
* Aborts the stream if no events arrive within a configurable inactivity window.
|
|
46
|
+
* Timer resets on each received event.
|
|
47
|
+
*/
|
|
48
|
+
/** Stream watchdog configuration */
|
|
49
|
+
interface StreamWatchdogConfig {
|
|
50
|
+
/** Maximum inactivity time in milliseconds before aborting the stream */
|
|
51
|
+
timeoutMs: number;
|
|
52
|
+
/** AbortSignal to link with (watchdog aborts when this signal fires) */
|
|
53
|
+
signal?: AbortSignal;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Wraps an async iterable with an activity timeout.
|
|
57
|
+
* If no event arrives within `timeoutMs`, the stream is aborted with a ChatError.
|
|
58
|
+
* The timer resets after each received event.
|
|
59
|
+
*
|
|
60
|
+
* Uses Promise.race() so even if the source iterator is stuck on an
|
|
61
|
+
* unresolvable promise, the timeout fires and aborts iteration.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const watched = withStreamWatchdog(adapter.streamMessage(session, msg), {
|
|
66
|
+
* timeoutMs: 30000,
|
|
67
|
+
* signal: abortController.signal,
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* for await (const event of watched) {
|
|
71
|
+
* // Each event resets the 30s inactivity timer
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
declare function withStreamWatchdog<T>(source: AsyncIterable<T>, config: StreamWatchdogConfig): AsyncGenerator<T>;
|
|
76
|
+
|
|
77
|
+
export { ListenerSet, type StreamWatchdogConfig, withStreamWatchdog };
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
export { ContextStats, ContextWindowConfig, ContextWindowManager, ContextWindowResult, OverflowStrategy, estimateTokens } from './context.js';
|
|
9
|
+
export { MessageAccumulator } from './accumulator.js';
|
|
10
|
+
export { ChatEventBus, TypedEventEmitter } from './events.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';
|
|
14
|
+
import 'zod';
|
|
15
|
+
import '../types-BxggH0Yh.js';
|
|
16
|
+
import '../errors-CmVvczxZ.js';
|
|
17
|
+
import './storage.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
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @witqq/agent-sdk - Stream Watchdog
|
|
43
|
+
*
|
|
44
|
+
* Activity-based timeout wrapper for async event streams.
|
|
45
|
+
* Aborts the stream if no events arrive within a configurable inactivity window.
|
|
46
|
+
* Timer resets on each received event.
|
|
47
|
+
*/
|
|
48
|
+
/** Stream watchdog configuration */
|
|
49
|
+
interface StreamWatchdogConfig {
|
|
50
|
+
/** Maximum inactivity time in milliseconds before aborting the stream */
|
|
51
|
+
timeoutMs: number;
|
|
52
|
+
/** AbortSignal to link with (watchdog aborts when this signal fires) */
|
|
53
|
+
signal?: AbortSignal;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Wraps an async iterable with an activity timeout.
|
|
57
|
+
* If no event arrives within `timeoutMs`, the stream is aborted with a ChatError.
|
|
58
|
+
* The timer resets after each received event.
|
|
59
|
+
*
|
|
60
|
+
* Uses Promise.race() so even if the source iterator is stuck on an
|
|
61
|
+
* unresolvable promise, the timeout fires and aborts iteration.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const watched = withStreamWatchdog(adapter.streamMessage(session, msg), {
|
|
66
|
+
* timeoutMs: 30000,
|
|
67
|
+
* signal: abortController.signal,
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* for await (const event of watched) {
|
|
71
|
+
* // Each event resets the 30s inactivity timer
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
declare function withStreamWatchdog<T>(source: AsyncIterable<T>, config: StreamWatchdogConfig): AsyncGenerator<T>;
|
|
76
|
+
|
|
77
|
+
export { ListenerSet, type StreamWatchdogConfig, withStreamWatchdog };
|