@witqq/agent-sdk 0.8.0 → 0.9.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/dist/{agent-DxY68NZL.d.cts → agent-C6H2CgJA.d.cts} +2 -0
- package/dist/{agent-CW9XbmG_.d.ts → agent-F7oB6eKp.d.ts} +2 -0
- package/dist/backends/claude.cjs.map +1 -1
- package/dist/backends/claude.d.cts +2 -2
- package/dist/backends/claude.d.ts +2 -2
- package/dist/backends/claude.js.map +1 -1
- package/dist/backends/copilot.cjs +8 -15
- package/dist/backends/copilot.cjs.map +1 -1
- package/dist/backends/copilot.d.cts +2 -2
- package/dist/backends/copilot.d.ts +2 -2
- package/dist/backends/copilot.js +8 -15
- package/dist/backends/copilot.js.map +1 -1
- package/dist/backends/mock-llm.cjs +719 -0
- package/dist/backends/mock-llm.cjs.map +1 -0
- package/dist/backends/mock-llm.d.cts +37 -0
- package/dist/backends/mock-llm.d.ts +37 -0
- package/dist/backends/mock-llm.js +717 -0
- package/dist/backends/mock-llm.js.map +1 -0
- package/dist/backends/vercel-ai.cjs +8 -1
- package/dist/backends/vercel-ai.cjs.map +1 -1
- package/dist/backends/vercel-ai.d.cts +2 -2
- package/dist/backends/vercel-ai.d.ts +2 -2
- package/dist/backends/vercel-ai.js +8 -1
- package/dist/backends/vercel-ai.js.map +1 -1
- package/dist/backends-Cno0gZjy.d.cts +114 -0
- package/dist/backends-Cno0gZjy.d.ts +114 -0
- package/dist/chat/accumulator.cjs.map +1 -1
- package/dist/chat/accumulator.d.cts +2 -2
- package/dist/chat/accumulator.d.ts +2 -2
- package/dist/chat/accumulator.js.map +1 -1
- package/dist/chat/backends.cjs +350 -77
- package/dist/chat/backends.cjs.map +1 -1
- package/dist/chat/backends.d.cts +7 -7
- package/dist/chat/backends.d.ts +7 -7
- package/dist/chat/backends.js +349 -78
- package/dist/chat/backends.js.map +1 -1
- package/dist/chat/context.d.cts +2 -2
- package/dist/chat/context.d.ts +2 -2
- package/dist/chat/core.cjs +35 -25
- package/dist/chat/core.cjs.map +1 -1
- package/dist/chat/core.d.cts +15 -5
- package/dist/chat/core.d.ts +15 -5
- package/dist/chat/core.js +35 -26
- package/dist/chat/core.js.map +1 -1
- package/dist/chat/events.d.cts +2 -2
- package/dist/chat/events.d.ts +2 -2
- package/dist/chat/index.cjs +418 -122
- package/dist/chat/index.cjs.map +1 -1
- package/dist/chat/index.d.cts +7 -7
- package/dist/chat/index.d.ts +7 -7
- package/dist/chat/index.js +418 -124
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/react.cjs +216 -12
- package/dist/chat/react.cjs.map +1 -1
- package/dist/chat/react.d.cts +78 -4
- package/dist/chat/react.d.ts +78 -4
- package/dist/chat/react.js +215 -13
- package/dist/chat/react.js.map +1 -1
- package/dist/chat/runtime.cjs +6 -2
- package/dist/chat/runtime.cjs.map +1 -1
- package/dist/chat/runtime.d.cts +2 -2
- package/dist/chat/runtime.d.ts +2 -2
- package/dist/chat/runtime.js +6 -2
- package/dist/chat/runtime.js.map +1 -1
- package/dist/chat/server.cjs +15 -5
- package/dist/chat/server.cjs.map +1 -1
- package/dist/chat/server.d.cts +3 -3
- package/dist/chat/server.d.ts +3 -3
- package/dist/chat/server.js +15 -5
- package/dist/chat/server.js.map +1 -1
- package/dist/chat/sessions.cjs +39 -23
- package/dist/chat/sessions.cjs.map +1 -1
- package/dist/chat/sessions.d.cts +2 -2
- package/dist/chat/sessions.d.ts +2 -2
- package/dist/chat/sessions.js +40 -24
- package/dist/chat/sessions.js.map +1 -1
- package/dist/chat/sqlite.cjs +95 -0
- package/dist/chat/sqlite.cjs.map +1 -1
- package/dist/chat/sqlite.d.cts +39 -3
- package/dist/chat/sqlite.d.ts +39 -3
- package/dist/chat/sqlite.js +93 -1
- package/dist/chat/sqlite.js.map +1 -1
- package/dist/chat/state.d.cts +2 -2
- package/dist/chat/state.d.ts +2 -2
- package/dist/chat/storage.cjs +39 -23
- package/dist/chat/storage.cjs.map +1 -1
- package/dist/chat/storage.d.cts +7 -3
- package/dist/chat/storage.d.ts +7 -3
- package/dist/chat/storage.js +40 -24
- package/dist/chat/storage.js.map +1 -1
- package/dist/{in-process-transport-C1JnJGVR.d.ts → in-process-transport-7EIit9Xk.d.ts} +51 -17
- package/dist/{in-process-transport-C7DSqPyX.d.cts → in-process-transport-Ct9YcX8I.d.cts} +51 -17
- package/dist/index.cjs +14 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +724 -0
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +14 -2
- package/dist/testing.d.ts +14 -2
- package/dist/testing.js +724 -0
- package/dist/testing.js.map +1 -1
- package/dist/{transport-Cdh3M0tS.d.cts → transport-DLWCN18G.d.cts} +1 -1
- package/dist/{transport-Ciap4PWK.d.ts → transport-DsuS-GeM.d.ts} +1 -1
- package/dist/{types-ajANVzf7.d.ts → types-DgtI1hzh.d.ts} +2 -1
- package/dist/{types-DRgd_9R7.d.cts → types-DkSXALKg.d.cts} +2 -1
- package/package.json +18 -7
- package/LICENSE +0 -21
- package/README.md +0 -1054
- package/dist/backends-BSrsBYFn.d.cts +0 -39
- package/dist/backends-BSrsBYFn.d.ts +0 -39
package/dist/chat/server.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { IChatRuntime, ChatRuntimeOptions } from './runtime.cjs';
|
|
2
|
-
import { W as WritableResponse, I as IChatTransport } from '../transport-
|
|
2
|
+
import { W as WritableResponse, I as IChatTransport } from '../transport-DLWCN18G.cjs';
|
|
3
3
|
import { I as IProviderStore, P as ProviderConfig } from '../provider-types-PTSlRPNB.cjs';
|
|
4
4
|
import { I as ITokenStore } from '../token-store-CuC4hB9Z.cjs';
|
|
5
5
|
export { F as FileTokenStore, a as FileTokenStoreOptions, b as InMemoryTokenStore } from '../token-store-CuC4hB9Z.cjs';
|
|
6
|
-
import { M as ModelInfo } from '../agent-
|
|
6
|
+
import { M as ModelInfo } from '../agent-C6H2CgJA.cjs';
|
|
7
7
|
import { C as CopilotAuthToken, b as ClaudeAuthToken, A as AuthToken } from '../types-4vbcmPTp.cjs';
|
|
8
8
|
import { b as TokenRefreshOptions, a as TokenRefreshManager } from '../refresh-manager-B81PpYBr.cjs';
|
|
9
|
-
import '../types-
|
|
9
|
+
import '../types-DkSXALKg.cjs';
|
|
10
10
|
import '../errors-C-so0M4t.cjs';
|
|
11
11
|
import './sessions.cjs';
|
|
12
12
|
import './storage.cjs';
|
package/dist/chat/server.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { IChatRuntime, ChatRuntimeOptions } from './runtime.js';
|
|
2
|
-
import { W as WritableResponse, I as IChatTransport } from '../transport-
|
|
2
|
+
import { W as WritableResponse, I as IChatTransport } from '../transport-DsuS-GeM.js';
|
|
3
3
|
import { I as IProviderStore, P as ProviderConfig } from '../provider-types-PTSlRPNB.js';
|
|
4
4
|
import { I as ITokenStore } from '../token-store-CSUBgYwn.js';
|
|
5
5
|
export { F as FileTokenStore, a as FileTokenStoreOptions, b as InMemoryTokenStore } from '../token-store-CSUBgYwn.js';
|
|
6
|
-
import { M as ModelInfo } from '../agent-
|
|
6
|
+
import { M as ModelInfo } from '../agent-F7oB6eKp.js';
|
|
7
7
|
import { C as CopilotAuthToken, b as ClaudeAuthToken, A as AuthToken } from '../types-BxggH0Yh.js';
|
|
8
8
|
import { b as TokenRefreshOptions, a as TokenRefreshManager } from '../refresh-manager-Dlv_iNZi.js';
|
|
9
|
-
import '../types-
|
|
9
|
+
import '../types-DgtI1hzh.js';
|
|
10
10
|
import '../errors-C-so0M4t.js';
|
|
11
11
|
import './sessions.js';
|
|
12
12
|
import './storage.js';
|
package/dist/chat/server.js
CHANGED
|
@@ -174,16 +174,22 @@ var SSEChatTransport = class {
|
|
|
174
174
|
};
|
|
175
175
|
async function streamToTransport(events, transport) {
|
|
176
176
|
try {
|
|
177
|
-
|
|
177
|
+
const textChunks = [];
|
|
178
|
+
let finishReason;
|
|
178
179
|
for await (const event of events) {
|
|
179
180
|
if (!transport.isOpen) break;
|
|
181
|
+
if (event.type === "done") {
|
|
182
|
+
finishReason = event.finishReason;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
180
185
|
transport.send(event);
|
|
181
186
|
if (event.type === "message:delta") {
|
|
182
|
-
|
|
187
|
+
textChunks.push(event.text);
|
|
183
188
|
}
|
|
184
189
|
}
|
|
185
190
|
if (transport.isOpen) {
|
|
186
|
-
|
|
191
|
+
const finalOutput = textChunks.length > 0 ? textChunks.join("") : void 0;
|
|
192
|
+
transport.send({ type: "done", finalOutput, finishReason });
|
|
187
193
|
}
|
|
188
194
|
transport.close();
|
|
189
195
|
} catch (err) {
|
|
@@ -1373,6 +1379,7 @@ var ChatRuntime = class {
|
|
|
1373
1379
|
_backends;
|
|
1374
1380
|
_sessionStore;
|
|
1375
1381
|
_contextConfig;
|
|
1382
|
+
_ctxManager;
|
|
1376
1383
|
_middleware;
|
|
1377
1384
|
_tools = /* @__PURE__ */ new Map();
|
|
1378
1385
|
_retryConfig;
|
|
@@ -1392,6 +1399,9 @@ var ChatRuntime = class {
|
|
|
1392
1399
|
this._defaultBackend = options.defaultBackend;
|
|
1393
1400
|
this._sessionStore = options.sessionStore;
|
|
1394
1401
|
this._contextConfig = options.context;
|
|
1402
|
+
if (this._contextConfig) {
|
|
1403
|
+
this._ctxManager = new ContextWindowManager(this._contextConfig);
|
|
1404
|
+
}
|
|
1395
1405
|
this._middleware = [...options.middleware ?? []];
|
|
1396
1406
|
this._retryConfig = options.retryConfig;
|
|
1397
1407
|
this._onContextTrimmed = options.onContextTrimmed;
|
|
@@ -1572,8 +1582,8 @@ var ChatRuntime = class {
|
|
|
1572
1582
|
}
|
|
1573
1583
|
/** Stage 5: Auto-trim context window if configured. Returns session snapshot for adapter. */
|
|
1574
1584
|
async trimSessionContext(cid, session, model) {
|
|
1575
|
-
if (!this.
|
|
1576
|
-
const ctxManager =
|
|
1585
|
+
if (!this._ctxManager) return session;
|
|
1586
|
+
const ctxManager = this._ctxManager;
|
|
1577
1587
|
const lastUsage = this._sessionUsage.get(cid);
|
|
1578
1588
|
const modelContextWindow = model ? this._modelContextWindows.get(model) : void 0;
|
|
1579
1589
|
if (lastUsage && modelContextWindow) {
|