@ank1015/providers 0.0.1 → 0.0.3
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/LICENSE +21 -0
- package/README.md +93 -383
- package/dist/agent/conversation.d.ts +97 -0
- package/dist/agent/conversation.d.ts.map +1 -0
- package/dist/agent/conversation.js +328 -0
- package/dist/agent/conversation.js.map +1 -0
- package/dist/agent/runner.d.ts +37 -0
- package/dist/agent/runner.d.ts.map +1 -0
- package/dist/agent/runner.js +169 -0
- package/dist/agent/runner.js.map +1 -0
- package/dist/agent/tools/calculate.d.ts +15 -0
- package/dist/agent/tools/calculate.d.ts.map +1 -0
- package/dist/agent/tools/calculate.js +23 -0
- package/dist/agent/tools/calculate.js.map +1 -0
- package/dist/agent/tools/get-current-time.d.ts +15 -0
- package/dist/agent/tools/get-current-time.d.ts.map +1 -0
- package/dist/agent/tools/get-current-time.js +38 -0
- package/dist/agent/tools/get-current-time.js.map +1 -0
- package/dist/agent/tools/index.d.ts +3 -0
- package/dist/agent/tools/index.d.ts.map +1 -0
- package/dist/agent/tools/index.js +3 -0
- package/dist/agent/tools/index.js.map +1 -0
- package/dist/agent/types.d.ts +53 -31
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js +1 -2
- package/dist/agent/utils.d.ts +14 -0
- package/dist/agent/utils.d.ts.map +1 -0
- package/dist/agent/utils.js +59 -0
- package/dist/agent/utils.js.map +1 -0
- package/dist/index.d.ts +16 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -28
- package/dist/index.js.map +1 -1
- package/dist/llm.d.ts +15 -0
- package/dist/llm.d.ts.map +1 -0
- package/dist/llm.js +92 -0
- package/dist/llm.js.map +1 -0
- package/dist/models.d.ts +8 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.generated.d.ts +25 -112
- package/dist/models.generated.d.ts.map +1 -1
- package/dist/models.generated.js +72 -227
- package/dist/models.generated.js.map +1 -1
- package/dist/models.js +30 -32
- package/dist/models.js.map +1 -1
- package/dist/providers/google/complete.d.ts +3 -0
- package/dist/providers/google/complete.d.ts.map +1 -0
- package/dist/providers/google/complete.js +53 -0
- package/dist/providers/google/complete.js.map +1 -0
- package/dist/providers/google/index.d.ts +6 -0
- package/dist/providers/google/index.d.ts.map +1 -0
- package/dist/providers/google/index.js +6 -0
- package/dist/providers/google/index.js.map +1 -0
- package/dist/providers/google/stream.d.ts +3 -0
- package/dist/providers/google/stream.d.ts.map +1 -0
- package/dist/providers/{google.js → google/stream.js} +67 -231
- package/dist/providers/google/stream.js.map +1 -0
- package/dist/providers/google/types.d.ts +8 -0
- package/dist/providers/google/types.d.ts.map +1 -0
- package/dist/providers/google/types.js +2 -0
- package/dist/providers/google/types.js.map +1 -0
- package/dist/providers/google/utils.d.ts +30 -0
- package/dist/providers/google/utils.d.ts.map +1 -0
- package/dist/providers/google/utils.js +354 -0
- package/dist/providers/google/utils.js.map +1 -0
- package/dist/providers/openai/complete.d.ts +3 -0
- package/dist/providers/openai/complete.d.ts.map +1 -0
- package/dist/providers/openai/complete.js +57 -0
- package/dist/providers/openai/complete.js.map +1 -0
- package/dist/providers/openai/index.d.ts +4 -0
- package/dist/providers/openai/index.d.ts.map +1 -0
- package/dist/providers/openai/index.js +4 -0
- package/dist/providers/openai/index.js.map +1 -0
- package/dist/providers/openai/stream.d.ts +3 -0
- package/dist/providers/openai/stream.d.ts.map +1 -0
- package/dist/providers/{openai.js → openai/stream.js} +74 -152
- package/dist/providers/openai/stream.js.map +1 -0
- package/dist/providers/openai/types.d.ts +8 -0
- package/dist/providers/openai/types.d.ts.map +1 -0
- package/dist/providers/openai/types.js +2 -0
- package/dist/providers/openai/types.js.map +1 -0
- package/dist/providers/openai/utils.d.ts +13 -0
- package/dist/providers/openai/utils.d.ts.map +1 -0
- package/dist/providers/openai/utils.js +285 -0
- package/dist/providers/openai/utils.js.map +1 -0
- package/dist/types.d.ts +95 -87
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -9
- package/dist/types.js.map +1 -1
- package/dist/utils/event-stream.d.ts +2 -2
- package/dist/utils/event-stream.d.ts.map +1 -1
- package/dist/utils/event-stream.js +2 -7
- package/dist/utils/event-stream.js.map +1 -1
- package/dist/utils/json-parse.js +3 -6
- package/dist/utils/json-parse.js.map +1 -1
- package/dist/utils/overflow.d.ts +51 -0
- package/dist/utils/overflow.d.ts.map +1 -0
- package/dist/utils/overflow.js +106 -0
- package/dist/utils/overflow.js.map +1 -0
- package/dist/utils/sanitize-unicode.js +1 -4
- package/dist/utils/sanitize-unicode.js.map +1 -1
- package/dist/utils/uuid.d.ts +6 -0
- package/dist/utils/uuid.d.ts.map +1 -0
- package/dist/utils/uuid.js +9 -0
- package/dist/utils/uuid.js.map +1 -0
- package/dist/utils/validation.d.ts +10 -3
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +20 -12
- package/dist/utils/validation.js.map +1 -1
- package/package.json +47 -8
- package/biome.json +0 -43
- package/dist/agent/agent-loop.d.ts +0 -5
- package/dist/agent/agent-loop.d.ts.map +0 -1
- package/dist/agent/agent-loop.js +0 -219
- package/dist/agent/agent-loop.js.map +0 -1
- package/dist/providers/convert.d.ts +0 -6
- package/dist/providers/convert.d.ts.map +0 -1
- package/dist/providers/convert.js +0 -207
- package/dist/providers/convert.js.map +0 -1
- package/dist/providers/google.d.ts +0 -26
- package/dist/providers/google.d.ts.map +0 -1
- package/dist/providers/google.js.map +0 -1
- package/dist/providers/openai.d.ts +0 -17
- package/dist/providers/openai.d.ts.map +0 -1
- package/dist/providers/openai.js.map +0 -1
- package/dist/stream.d.ts +0 -4
- package/dist/stream.d.ts.map +0 -1
- package/dist/stream.js +0 -40
- package/dist/stream.js.map +0 -1
- package/dist/test-google-agent-loop.d.ts +0 -2
- package/dist/test-google-agent-loop.d.ts.map +0 -1
- package/dist/test-google-agent-loop.js +0 -186
- package/dist/test-google-agent-loop.js.map +0 -1
- package/dist/test-google.d.ts +0 -2
- package/dist/test-google.d.ts.map +0 -1
- package/dist/test-google.js +0 -41
- package/dist/test-google.js.map +0 -1
- package/src/agent/agent-loop.ts +0 -275
- package/src/agent/types.ts +0 -80
- package/src/index.ts +0 -72
- package/src/models.generated.ts +0 -314
- package/src/models.ts +0 -45
- package/src/providers/convert.ts +0 -222
- package/src/providers/google.ts +0 -496
- package/src/providers/openai.ts +0 -437
- package/src/stream.ts +0 -60
- package/src/types.ts +0 -198
- package/src/utils/event-stream.ts +0 -60
- package/src/utils/json-parse.ts +0 -28
- package/src/utils/sanitize-unicode.ts +0 -25
- package/src/utils/validation.ts +0 -69
- package/test/core/agent-loop.test.ts +0 -958
- package/test/core/stream.test.ts +0 -409
- package/test/data/red-circle.png +0 -0
- package/test/data/superintelligentwill.pdf +0 -0
- package/test/edge-cases/general.test.ts +0 -565
- package/test/integration/e2e.test.ts +0 -530
- package/test/models/cost.test.ts +0 -499
- package/test/models/registry.test.ts +0 -298
- package/test/providers/convert.test.ts +0 -846
- package/test/providers/google-schema.test.ts +0 -666
- package/test/providers/google-stream.test.ts +0 -369
- package/test/providers/openai-stream.test.ts +0 -251
- package/test/utils/event-stream.test.ts +0 -289
- package/test/utils/json-parse.test.ts +0 -344
- package/test/utils/sanitize-unicode.test.ts +0 -329
- package/test/utils/validation.test.ts +0 -614
- package/tsconfig.json +0 -21
- package/vitest.config.ts +0 -9
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AssistantMessageEventStream = exports.EventStream = void 0;
|
|
4
1
|
// Generic event stream class for async iteration
|
|
5
|
-
class EventStream {
|
|
2
|
+
export class EventStream {
|
|
6
3
|
constructor() {
|
|
7
4
|
this.queue = [];
|
|
8
5
|
this.waiting = [];
|
|
@@ -54,8 +51,6 @@ class EventStream {
|
|
|
54
51
|
return this.finalResultPromise;
|
|
55
52
|
}
|
|
56
53
|
}
|
|
57
|
-
|
|
58
|
-
class AssistantMessageEventStream extends EventStream {
|
|
54
|
+
export class AssistantMessageEventStream extends EventStream {
|
|
59
55
|
}
|
|
60
|
-
exports.AssistantMessageEventStream = AssistantMessageEventStream;
|
|
61
56
|
//# sourceMappingURL=event-stream.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-stream.js","sourceRoot":"","sources":["../../src/utils/event-stream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event-stream.js","sourceRoot":"","sources":["../../src/utils/event-stream.ts"],"names":[],"mappings":"AAEA,iDAAiD;AACjD,MAAM,OAAO,WAAW;IAOvB;QANQ,UAAK,GAAQ,EAAE,CAAC;QAChB,YAAO,GAA2C,EAAE,CAAC;QACrD,SAAI,GAAG,KAAK,CAAC;QAKpB,IAAI,CAAC,kBAAkB,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACjD,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC;QACnC,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,KAAQ;QACZ,IAAI,IAAI,CAAC,IAAI;YAAE,OAAO;QAEtB,0CAA0C;QAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACpC,IAAI,MAAM,EAAE,CAAC;YACZ,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACvC,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;IACF,CAAC;IAED,GAAG,CAAC,MAAS;QACZ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,sDAAsD;QACtD,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAChC,+CAA+C;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAG,CAAC;YACrC,+EAA+E;YAC/E,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAU,EAAE,CAAC,CAAC;QAC3C,CAAC;IACF,CAAC;IAED,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;QAC5B,OAAO,IAAI,EAAE,CAAC;YACb,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC3B,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,EAAG,CAAC;YAC3B,CAAC;iBAAM,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACtB,OAAO;YACR,CAAC;iBAAM,CAAC;gBACP,MAAM,MAAM,GAAG,MAAM,IAAI,OAAO,CAAoB,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC7F,IAAI,MAAM,CAAC,IAAI;oBAAE,OAAO;gBACxB,MAAM,MAAM,CAAC,KAAK,CAAC;YACpB,CAAC;QACF,CAAC;IACF,CAAC;IAED,MAAM;QACL,OAAO,IAAI,CAAC,kBAAkB,CAAC;IAChC,CAAC;CACD;AAED,MAAM,OAAO,2BAA8C,SAAQ,WAAiE;CAAG"}
|
package/dist/utils/json-parse.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseStreamingJson = parseStreamingJson;
|
|
4
|
-
const partial_json_1 = require("partial-json");
|
|
1
|
+
import { parse as partialParse } from "partial-json";
|
|
5
2
|
/**
|
|
6
3
|
* Attempts to parse potentially incomplete JSON during streaming.
|
|
7
4
|
* Always returns a valid object, even if the JSON is incomplete.
|
|
@@ -9,7 +6,7 @@ const partial_json_1 = require("partial-json");
|
|
|
9
6
|
* @param partialJson The partial JSON string from streaming
|
|
10
7
|
* @returns Parsed object or empty object if parsing fails
|
|
11
8
|
*/
|
|
12
|
-
function parseStreamingJson(partialJson) {
|
|
9
|
+
export function parseStreamingJson(partialJson) {
|
|
13
10
|
if (!partialJson || partialJson.trim() === "") {
|
|
14
11
|
return {};
|
|
15
12
|
}
|
|
@@ -20,7 +17,7 @@ function parseStreamingJson(partialJson) {
|
|
|
20
17
|
catch {
|
|
21
18
|
// Try partial-json for incomplete JSON
|
|
22
19
|
try {
|
|
23
|
-
const result = (
|
|
20
|
+
const result = partialParse(partialJson);
|
|
24
21
|
return (result ?? {});
|
|
25
22
|
}
|
|
26
23
|
catch {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-parse.js","sourceRoot":"","sources":["../../src/utils/json-parse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"json-parse.js","sourceRoot":"","sources":["../../src/utils/json-parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,cAAc,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAU,WAA+B;IAC1E,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC/C,OAAO,EAAO,CAAC;IAChB,CAAC;IAED,yDAAyD;IACzD,IAAI,CAAC;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAM,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACR,uCAAuC;QACvC,IAAI,CAAC;YACJ,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;YACzC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAM,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC;YACR,4CAA4C;YAC5C,OAAO,EAAO,CAAC;QAChB,CAAC;IACF,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { BaseAssistantMessage, Api } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Check if an assistant message represents a context overflow error.
|
|
4
|
+
*
|
|
5
|
+
* This handles two cases:
|
|
6
|
+
* 1. Error-based overflow: Most providers return stopReason "error" with a
|
|
7
|
+
* specific error message pattern.
|
|
8
|
+
* 2. Silent overflow: Some providers accept overflow requests and return
|
|
9
|
+
* successfully. For these, we check if usage.input exceeds the context window.
|
|
10
|
+
*
|
|
11
|
+
* ## Reliability by Provider
|
|
12
|
+
*
|
|
13
|
+
* **Reliable detection (returns error with detectable message):**
|
|
14
|
+
* - Anthropic: "prompt is too long: X tokens > Y maximum"
|
|
15
|
+
* - OpenAI (Completions & Responses): "exceeds the context window"
|
|
16
|
+
* - Google Gemini: "input token count exceeds the maximum"
|
|
17
|
+
* - xAI (Grok): "maximum prompt length is X but request contains Y"
|
|
18
|
+
* - Groq: "reduce the length of the messages"
|
|
19
|
+
* - Cerebras: 400/413 status code (no body)
|
|
20
|
+
* - Mistral: 400/413 status code (no body)
|
|
21
|
+
* - OpenRouter (all backends): "maximum context length is X tokens"
|
|
22
|
+
* - llama.cpp: "exceeds the available context size"
|
|
23
|
+
* - LM Studio: "greater than the context length"
|
|
24
|
+
*
|
|
25
|
+
* **Unreliable detection:**
|
|
26
|
+
* - z.ai: Sometimes accepts overflow silently (detectable via usage.input > contextWindow),
|
|
27
|
+
* sometimes returns rate limit errors. Pass contextWindow param to detect silent overflow.
|
|
28
|
+
* - Ollama: Silently truncates input without error. Cannot be detected via this function.
|
|
29
|
+
* The response will have usage.input < expected, but we don't know the expected value.
|
|
30
|
+
*
|
|
31
|
+
* ## Custom Providers
|
|
32
|
+
*
|
|
33
|
+
* If you've added custom models via settings.json, this function may not detect
|
|
34
|
+
* overflow errors from those providers. To add support:
|
|
35
|
+
*
|
|
36
|
+
* 1. Send a request that exceeds the model's context window
|
|
37
|
+
* 2. Check the errorMessage in the response
|
|
38
|
+
* 3. Create a regex pattern that matches the error
|
|
39
|
+
* 4. The pattern should be added to OVERFLOW_PATTERNS in this file, or
|
|
40
|
+
* check the errorMessage yourself before calling this function
|
|
41
|
+
*
|
|
42
|
+
* @param message - The assistant message to check
|
|
43
|
+
* @param contextWindow - Optional context window size for detecting silent overflow (z.ai)
|
|
44
|
+
* @returns true if the message indicates a context overflow
|
|
45
|
+
*/
|
|
46
|
+
export declare function isContextOverflow(message: BaseAssistantMessage<Api>, contextWindow?: number): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Get the overflow patterns for testing purposes.
|
|
49
|
+
*/
|
|
50
|
+
export declare function getOverflowPatterns(): RegExp[];
|
|
51
|
+
//# sourceMappingURL=overflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overflow.d.ts","sourceRoot":"","sources":["../../src/utils/overflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAqC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,oBAAoB,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAuBrG;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAE9C"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regex patterns to detect context overflow errors from different providers.
|
|
3
|
+
*
|
|
4
|
+
* These patterns match error messages returned when the input exceeds
|
|
5
|
+
* the model's context window.
|
|
6
|
+
*
|
|
7
|
+
* Provider-specific patterns (with example error messages):
|
|
8
|
+
*
|
|
9
|
+
* - Anthropic: "prompt is too long: 213462 tokens > 200000 maximum"
|
|
10
|
+
* - OpenAI: "Your input exceeds the context window of this model"
|
|
11
|
+
* - Google: "The input token count (1196265) exceeds the maximum number of tokens allowed (1048575)"
|
|
12
|
+
* - xAI: "This model's maximum prompt length is 131072 but the request contains 537812 tokens"
|
|
13
|
+
* - Groq: "Please reduce the length of the messages or completion"
|
|
14
|
+
* - OpenRouter: "This endpoint's maximum context length is X tokens. However, you requested about Y tokens"
|
|
15
|
+
* - llama.cpp: "the request exceeds the available context size, try increasing it"
|
|
16
|
+
* - LM Studio: "tokens to keep from the initial prompt is greater than the context length"
|
|
17
|
+
* - Cerebras: Returns "400 status code (no body)" - handled separately below
|
|
18
|
+
* - Mistral: Returns "400 status code (no body)" - handled separately below
|
|
19
|
+
* - z.ai: Does NOT error, accepts overflow silently - handled via usage.input > contextWindow
|
|
20
|
+
* - Ollama: Silently truncates input - not detectable via error message
|
|
21
|
+
*/
|
|
22
|
+
const OVERFLOW_PATTERNS = [
|
|
23
|
+
/prompt is too long/i, // Anthropic
|
|
24
|
+
/exceeds the context window/i, // OpenAI (Completions & Responses API)
|
|
25
|
+
/input token count.*exceeds the maximum/i, // Google (Gemini)
|
|
26
|
+
/maximum prompt length is \d+/i, // xAI (Grok)
|
|
27
|
+
/reduce the length of the messages/i, // Groq
|
|
28
|
+
/maximum context length is \d+ tokens/i, // OpenRouter (all backends)
|
|
29
|
+
/exceeds the available context size/i, // llama.cpp server
|
|
30
|
+
/greater than the context length/i, // LM Studio
|
|
31
|
+
/context length exceeded/i, // Generic fallback
|
|
32
|
+
/too many tokens/i, // Generic fallback
|
|
33
|
+
/token limit exceeded/i, // Generic fallback
|
|
34
|
+
];
|
|
35
|
+
/**
|
|
36
|
+
* Check if an assistant message represents a context overflow error.
|
|
37
|
+
*
|
|
38
|
+
* This handles two cases:
|
|
39
|
+
* 1. Error-based overflow: Most providers return stopReason "error" with a
|
|
40
|
+
* specific error message pattern.
|
|
41
|
+
* 2. Silent overflow: Some providers accept overflow requests and return
|
|
42
|
+
* successfully. For these, we check if usage.input exceeds the context window.
|
|
43
|
+
*
|
|
44
|
+
* ## Reliability by Provider
|
|
45
|
+
*
|
|
46
|
+
* **Reliable detection (returns error with detectable message):**
|
|
47
|
+
* - Anthropic: "prompt is too long: X tokens > Y maximum"
|
|
48
|
+
* - OpenAI (Completions & Responses): "exceeds the context window"
|
|
49
|
+
* - Google Gemini: "input token count exceeds the maximum"
|
|
50
|
+
* - xAI (Grok): "maximum prompt length is X but request contains Y"
|
|
51
|
+
* - Groq: "reduce the length of the messages"
|
|
52
|
+
* - Cerebras: 400/413 status code (no body)
|
|
53
|
+
* - Mistral: 400/413 status code (no body)
|
|
54
|
+
* - OpenRouter (all backends): "maximum context length is X tokens"
|
|
55
|
+
* - llama.cpp: "exceeds the available context size"
|
|
56
|
+
* - LM Studio: "greater than the context length"
|
|
57
|
+
*
|
|
58
|
+
* **Unreliable detection:**
|
|
59
|
+
* - z.ai: Sometimes accepts overflow silently (detectable via usage.input > contextWindow),
|
|
60
|
+
* sometimes returns rate limit errors. Pass contextWindow param to detect silent overflow.
|
|
61
|
+
* - Ollama: Silently truncates input without error. Cannot be detected via this function.
|
|
62
|
+
* The response will have usage.input < expected, but we don't know the expected value.
|
|
63
|
+
*
|
|
64
|
+
* ## Custom Providers
|
|
65
|
+
*
|
|
66
|
+
* If you've added custom models via settings.json, this function may not detect
|
|
67
|
+
* overflow errors from those providers. To add support:
|
|
68
|
+
*
|
|
69
|
+
* 1. Send a request that exceeds the model's context window
|
|
70
|
+
* 2. Check the errorMessage in the response
|
|
71
|
+
* 3. Create a regex pattern that matches the error
|
|
72
|
+
* 4. The pattern should be added to OVERFLOW_PATTERNS in this file, or
|
|
73
|
+
* check the errorMessage yourself before calling this function
|
|
74
|
+
*
|
|
75
|
+
* @param message - The assistant message to check
|
|
76
|
+
* @param contextWindow - Optional context window size for detecting silent overflow (z.ai)
|
|
77
|
+
* @returns true if the message indicates a context overflow
|
|
78
|
+
*/
|
|
79
|
+
export function isContextOverflow(message, contextWindow) {
|
|
80
|
+
// Case 1: Check error message patterns
|
|
81
|
+
if (message.stopReason === "error" && message.errorMessage) {
|
|
82
|
+
// Check known patterns
|
|
83
|
+
if (OVERFLOW_PATTERNS.some((p) => p.test(message.errorMessage))) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
// Cerebras and Mistral return 400/413 with no body - check for status code pattern
|
|
87
|
+
if (/^4(00|13)\s*(status code)?\s*\(no body\)/i.test(message.errorMessage)) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Case 2: Silent overflow (z.ai style) - successful but usage exceeds context
|
|
92
|
+
if (contextWindow && message.stopReason === "stop") {
|
|
93
|
+
const inputTokens = message.usage.input + message.usage.cacheRead;
|
|
94
|
+
if (inputTokens > contextWindow) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get the overflow patterns for testing purposes.
|
|
102
|
+
*/
|
|
103
|
+
export function getOverflowPatterns() {
|
|
104
|
+
return [...OVERFLOW_PATTERNS];
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=overflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overflow.js","sourceRoot":"","sources":["../../src/utils/overflow.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,iBAAiB,GAAG;IACzB,qBAAqB,EAAE,YAAY;IACnC,6BAA6B,EAAE,uCAAuC;IACtE,yCAAyC,EAAE,kBAAkB;IAC7D,+BAA+B,EAAE,aAAa;IAC9C,oCAAoC,EAAE,OAAO;IAC7C,uCAAuC,EAAE,4BAA4B;IACrE,qCAAqC,EAAE,mBAAmB;IAC1D,kCAAkC,EAAE,YAAY;IAChD,0BAA0B,EAAE,mBAAmB;IAC/C,kBAAkB,EAAE,mBAAmB;IACvC,uBAAuB,EAAE,mBAAmB;CAC5C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAkC,EAAE,aAAsB;IAC3F,uCAAuC;IACvC,IAAI,OAAO,CAAC,UAAU,KAAK,OAAO,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QAC5D,uBAAuB;QACvB,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAa,CAAC,CAAC,EAAE,CAAC;YAClE,OAAO,IAAI,CAAC;QACb,CAAC;QAED,mFAAmF;QACnF,IAAI,2CAA2C,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;YAC5E,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC;IAED,8EAA8E;IAC9E,IAAI,aAAa,IAAI,OAAO,CAAC,UAAU,KAAK,MAAM,EAAE,CAAC;QACpD,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC;QAClE,IAAI,WAAW,GAAG,aAAa,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACb,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IAClC,OAAO,CAAC,GAAG,iBAAiB,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sanitizeSurrogates = sanitizeSurrogates;
|
|
4
1
|
/**
|
|
5
2
|
* Removes unpaired Unicode surrogate characters from a string.
|
|
6
3
|
*
|
|
@@ -21,7 +18,7 @@ exports.sanitizeSurrogates = sanitizeSurrogates;
|
|
|
21
18
|
* const unpaired = String.fromCharCode(0xD83D); // high surrogate without low
|
|
22
19
|
* sanitizeSurrogates(`Text ${unpaired} here`) // => "Text here"
|
|
23
20
|
*/
|
|
24
|
-
function sanitizeSurrogates(text) {
|
|
21
|
+
export function sanitizeSurrogates(text) {
|
|
25
22
|
// Replace unpaired high surrogates (0xD800-0xDBFF not followed by low surrogate)
|
|
26
23
|
// Replace unpaired low surrogates (0xDC00-0xDFFF not preceded by high surrogate)
|
|
27
24
|
return text.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, "");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize-unicode.js","sourceRoot":"","sources":["../../src/utils/sanitize-unicode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sanitize-unicode.js","sourceRoot":"","sources":["../../src/utils/sanitize-unicode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC9C,iFAAiF;IACjF,iFAAiF;IACjF,OAAO,IAAI,CAAC,OAAO,CAAC,yEAAyE,EAAE,EAAE,CAAC,CAAC;AACpG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../src/utils/uuid.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.js","sourceRoot":"","sources":["../../src/utils/uuid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC;;;GAGG;AACH,MAAM,UAAU,YAAY;IAC3B,OAAO,MAAM,EAAE,CAAC;AACjB,CAAC"}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import type { Tool, AssistantToolCall } from "../types.js";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Finds a tool by name and validates the tool call arguments against its TypeBox schema
|
|
4
|
+
* @param tools Array of tool definitions
|
|
5
|
+
* @param toolCall The tool call from the LLM
|
|
6
|
+
* @returns The validated arguments
|
|
7
|
+
* @throws Error if tool is not found or validation fails
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateToolCall(tools: Tool[], toolCall: AssistantToolCall): any;
|
|
3
10
|
/**
|
|
4
11
|
* Validates tool call arguments against the tool's TypeBox schema
|
|
5
12
|
* @param tool The tool definition with TypeBox schema
|
|
6
13
|
* @param toolCall The tool call from the LLM
|
|
7
|
-
* @returns The validated arguments
|
|
14
|
+
* @returns The validated arguments
|
|
8
15
|
* @throws Error with formatted message if validation fails
|
|
9
16
|
*/
|
|
10
|
-
export declare function validateToolArguments
|
|
17
|
+
export declare function validateToolArguments(tool: Tool, toolCall: AssistantToolCall): any;
|
|
11
18
|
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAsB3D;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,iBAAiB,GAAG,GAAG,CAMhF;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,iBAAiB,GAAG,GAAG,CA4BlF"}
|
package/dist/utils/validation.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validateToolArguments = validateToolArguments;
|
|
7
|
-
const ajv_1 = __importDefault(require("ajv"));
|
|
8
|
-
const ajv_formats_1 = __importDefault(require("ajv-formats"));
|
|
1
|
+
import AjvModule from "ajv";
|
|
2
|
+
import addFormatsModule from "ajv-formats";
|
|
9
3
|
// Handle both default and named exports
|
|
10
|
-
const Ajv =
|
|
11
|
-
const addFormats =
|
|
4
|
+
const Ajv = AjvModule.default || AjvModule;
|
|
5
|
+
const addFormats = addFormatsModule.default || addFormatsModule;
|
|
12
6
|
// Detect if we're in a browser extension environment with strict CSP
|
|
13
7
|
// Chrome extensions with Manifest V3 don't allow eval/Function constructor
|
|
14
8
|
const isBrowserExtension = typeof globalThis !== "undefined" && globalThis.chrome?.runtime?.id !== undefined;
|
|
@@ -28,14 +22,28 @@ if (!isBrowserExtension) {
|
|
|
28
22
|
console.warn("AJV validation disabled due to CSP restrictions");
|
|
29
23
|
}
|
|
30
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Finds a tool by name and validates the tool call arguments against its TypeBox schema
|
|
27
|
+
* @param tools Array of tool definitions
|
|
28
|
+
* @param toolCall The tool call from the LLM
|
|
29
|
+
* @returns The validated arguments
|
|
30
|
+
* @throws Error if tool is not found or validation fails
|
|
31
|
+
*/
|
|
32
|
+
export function validateToolCall(tools, toolCall) {
|
|
33
|
+
const tool = tools.find((t) => t.name === toolCall.name);
|
|
34
|
+
if (!tool) {
|
|
35
|
+
throw new Error(`Tool "${toolCall.name}" not found`);
|
|
36
|
+
}
|
|
37
|
+
return validateToolArguments(tool, toolCall);
|
|
38
|
+
}
|
|
31
39
|
/**
|
|
32
40
|
* Validates tool call arguments against the tool's TypeBox schema
|
|
33
41
|
* @param tool The tool definition with TypeBox schema
|
|
34
42
|
* @param toolCall The tool call from the LLM
|
|
35
|
-
* @returns The validated arguments
|
|
43
|
+
* @returns The validated arguments
|
|
36
44
|
* @throws Error with formatted message if validation fails
|
|
37
45
|
*/
|
|
38
|
-
function validateToolArguments(tool, toolCall) {
|
|
46
|
+
export function validateToolArguments(tool, toolCall) {
|
|
39
47
|
// Skip validation in browser extension environment (CSP restrictions prevent AJV from working)
|
|
40
48
|
if (!ajv || isBrowserExtension) {
|
|
41
49
|
// Trust the LLM's output without validation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,KAAK,CAAC;AAC5B,OAAO,gBAAgB,MAAM,aAAa,CAAC;AAE3C,wCAAwC;AACxC,MAAM,GAAG,GAAI,SAAiB,CAAC,OAAO,IAAI,SAAS,CAAC;AACpD,MAAM,UAAU,GAAI,gBAAwB,CAAC,OAAO,IAAI,gBAAgB,CAAC;AAIzE,qEAAqE;AACrE,2EAA2E;AAC3E,MAAM,kBAAkB,GAAG,OAAO,UAAU,KAAK,WAAW,IAAK,UAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,KAAK,SAAS,CAAC;AAEtH,kFAAkF;AAClF,qEAAqE;AACrE,IAAI,GAAG,GAAQ,IAAI,CAAC;AACpB,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACzB,IAAI,CAAC;QACJ,GAAG,GAAG,IAAI,GAAG,CAAC;YACb,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,KAAK;SACb,CAAC,CAAC;QACH,UAAU,CAAC,GAAG,CAAC,CAAC;IACjB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,qDAAqD;QACrD,OAAO,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;IACjE,CAAC;AACF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa,EAAE,QAA2B;IAC1E,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC,CAAC;IACzD,IAAI,CAAC,IAAI,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,SAAS,QAAQ,CAAC,IAAI,aAAa,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,qBAAqB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAU,EAAE,QAA2B;IAC5E,+FAA+F;IAC/F,IAAI,CAAC,GAAG,IAAI,kBAAkB,EAAE,CAAC;QAChC,4CAA4C;QAC5C,uEAAuE;QACvE,OAAO,QAAQ,CAAC,SAAS,CAAC;IAC3B,CAAC;IAED,qBAAqB;IACrB,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAE9C,yBAAyB;IACzB,IAAI,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAClC,OAAO,QAAQ,CAAC,SAAS,CAAC;IAC3B,CAAC;IAED,kCAAkC;IAClC,MAAM,MAAM,GACX,QAAQ,CAAC,MAAM;QACd,EAAE,GAAG,CAAC,CAAC,GAAQ,EAAE,EAAE;QAClB,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC;QACrG,OAAO,OAAO,IAAI,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,IAAI,0BAA0B,CAAC;IAE5C,MAAM,YAAY,GAAG,+BAA+B,QAAQ,CAAC,IAAI,OAAO,MAAM,4BAA4B,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;IAExJ,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AAC/B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,20 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ank1015/providers",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Multi-provider LLM SDK with native provider options support.",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
7
18
|
"scripts": {
|
|
8
19
|
"build": "tsc",
|
|
9
20
|
"dev": "tsc --watch",
|
|
10
21
|
"start": "node dist/index.js",
|
|
11
22
|
"clean": "rm -rf dist",
|
|
12
23
|
"check": "biome check --write . && tsc --noEmit",
|
|
13
|
-
"test": "vitest --run"
|
|
24
|
+
"test": "vitest --run",
|
|
25
|
+
"test:unit": "vitest run tests/unit/",
|
|
26
|
+
"prepublishOnly": "npm run check && npm run test:unit && npm run build"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/ank1015/providers.git"
|
|
14
31
|
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
|
|
32
|
+
"keywords": [
|
|
33
|
+
"ai",
|
|
34
|
+
"llm",
|
|
35
|
+
"agent",
|
|
36
|
+
"openai",
|
|
37
|
+
"gemini",
|
|
38
|
+
"providers",
|
|
39
|
+
"sdk",
|
|
40
|
+
"autonomous"
|
|
41
|
+
],
|
|
42
|
+
"author": "ank1015",
|
|
17
43
|
"license": "MIT",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/ank1015/providers/issues"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/ank1015/providers#readme",
|
|
18
48
|
"dependencies": {
|
|
19
49
|
"@anthropic-ai/sdk": "^0.71.0",
|
|
20
50
|
"@biomejs/biome": "^2.3.8",
|
|
@@ -24,10 +54,19 @@
|
|
|
24
54
|
"ajv-formats": "^3.0.1",
|
|
25
55
|
"openai": "^6.9.1",
|
|
26
56
|
"partial-json": "^0.1.7",
|
|
27
|
-
"
|
|
57
|
+
"uuid": "^13.0.0"
|
|
28
58
|
},
|
|
29
59
|
"devDependencies": {
|
|
60
|
+
"@mendable/firecrawl-js": "^4.9.3",
|
|
30
61
|
"@types/node": "^24.10.1",
|
|
62
|
+
"@types/uuid": "^11.0.0",
|
|
63
|
+
"chalk": "^5.6.2",
|
|
64
|
+
"diff": "^8.0.2",
|
|
65
|
+
"file-type": "^21.1.1",
|
|
66
|
+
"glob": "^13.0.0",
|
|
67
|
+
"parallel-web": "^0.2.4",
|
|
68
|
+
"tsx": "^4.21.0",
|
|
69
|
+
"typescript": "^5.9.3",
|
|
31
70
|
"vitest": "^4.0.14"
|
|
32
71
|
}
|
|
33
72
|
}
|
package/biome.json
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
|
|
3
|
-
"linter": {
|
|
4
|
-
"enabled": true,
|
|
5
|
-
"rules": {
|
|
6
|
-
"recommended": true,
|
|
7
|
-
"style": {
|
|
8
|
-
"noNonNullAssertion": "off",
|
|
9
|
-
"useConst": "error",
|
|
10
|
-
"useNodejsImportProtocol": "off",
|
|
11
|
-
"useTemplate": "off"
|
|
12
|
-
},
|
|
13
|
-
"correctness": {
|
|
14
|
-
"noUnusedVariables": "off"
|
|
15
|
-
},
|
|
16
|
-
"suspicious": {
|
|
17
|
-
"noExplicitAny": "off",
|
|
18
|
-
"noControlCharactersInRegex": "off",
|
|
19
|
-
"noEmptyInterface": "off"
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"formatter": {
|
|
24
|
-
"enabled": true,
|
|
25
|
-
"formatWithErrors": false,
|
|
26
|
-
"indentStyle": "tab",
|
|
27
|
-
"indentWidth": 3,
|
|
28
|
-
"lineWidth": 120
|
|
29
|
-
},
|
|
30
|
-
"files": {
|
|
31
|
-
"includes": [
|
|
32
|
-
"packages/*/src/**/*",
|
|
33
|
-
"packages/*/test/**/*",
|
|
34
|
-
"*.json",
|
|
35
|
-
"*.md",
|
|
36
|
-
"!**/node_modules/**/*",
|
|
37
|
-
"!**/test-sessions.ts",
|
|
38
|
-
"!packages/web-ui/src/app.css",
|
|
39
|
-
"!packages/mom/data/**/*",
|
|
40
|
-
"!!**/node_modules"
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { EventStream } from "../utils/event-stream";
|
|
2
|
-
import { UserMessage, Api } from "../types";
|
|
3
|
-
import { AgentContext, AgentEvent, AgentLoopConfig } from "./types";
|
|
4
|
-
export declare function agentLoop<TApi extends Api>(prompt: UserMessage, context: AgentContext, config: AgentLoopConfig<TApi>, signal?: AbortSignal): EventStream<AgentEvent, AgentContext["messages"]>;
|
|
5
|
-
//# sourceMappingURL=agent-loop.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-loop.d.ts","sourceRoot":"","sources":["../../src/agent/agent-loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,GAAG,EAAwE,MAAM,UAAU,CAAC;AAClH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAA6C,MAAM,SAAS,CAAC;AAK/G,wBAAgB,SAAS,CAAC,IAAI,SAAS,GAAG,EACzC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,EAC7B,MAAM,CAAC,EAAE,WAAW,GAClB,WAAW,CAAC,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC,CA4GnD"}
|