deepccc 0.2.27 → 0.2.28
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.
|
@@ -25,7 +25,7 @@ export type CompletionResult = {
|
|
|
25
25
|
content: string;
|
|
26
26
|
reasoning: string;
|
|
27
27
|
} | {
|
|
28
|
-
status: 'timed_out' | 'cancelled' | 'invalid_output' | 'error';
|
|
28
|
+
status: 'timed_out' | 'cancelled' | 'invalid_output' | 'context_limit' | 'error';
|
|
29
29
|
diagnostic: {
|
|
30
30
|
code: string;
|
|
31
31
|
httpStatus?: number;
|
|
@@ -26,14 +26,17 @@ export class CompletionSession {
|
|
|
26
26
|
if (timeout > 2147483647)
|
|
27
27
|
throw new Error('Deadline exceeds timer capacity');
|
|
28
28
|
const messages = JSON.parse(JSON.stringify(request.messages));
|
|
29
|
-
|
|
30
|
-
throw new Error('Context budget exceeded');
|
|
29
|
+
const contextLimit = positive(request.maxContextChars ?? 1_000_000);
|
|
31
30
|
const extensions = JSON.parse(JSON.stringify(request.extensions ?? {}));
|
|
32
31
|
if (Object.keys(extensions).some(key => protectedKeys.has(key)) || JSON.stringify(extensions).length > 8192)
|
|
33
32
|
throw new Error('Invalid request extension');
|
|
34
33
|
const responseLimit = positive(request.maxResponseChars ?? 1_000_000);
|
|
35
34
|
if (request.maxOutputTokens !== undefined)
|
|
36
35
|
positive(request.maxOutputTokens);
|
|
36
|
+
// Size is a runtime outcome, not invalid configuration. Never echo input
|
|
37
|
+
// or contact the provider when the caller-owned context exceeds its budget.
|
|
38
|
+
if (JSON.stringify(messages).length > contextLimit)
|
|
39
|
+
return { status: 'context_limit', diagnostic: { code: 'context_budget_exceeded' }, metrics: { durationMs: performance.now() - started, modelCalls: 0 } };
|
|
37
40
|
const controller = new AbortController();
|
|
38
41
|
let expired = false;
|
|
39
42
|
const cancel = () => controller.abort();
|
|
@@ -26,8 +26,12 @@ performed here. Completion is accepted only after a normal stop, never a length
|
|
|
26
26
|
limit or interrupted stream. Text mode preserves plain-text output. Parallel
|
|
27
27
|
calls do not share mutable history. `timeoutMs` covers stream consumption;
|
|
28
28
|
optional cancellation is the second argument. Context/response character limits
|
|
29
|
-
default to one million each.
|
|
30
|
-
|
|
29
|
+
default to one million each. Since 0.2.28, oversized input returns
|
|
30
|
+
`status: 'context_limit'`, `diagnostic.code: 'context_budget_exceeded'` and zero
|
|
31
|
+
model calls before network activity. It does not return the input or partial
|
|
32
|
+
content. Invalid configuration budgets still throw. Other runtime failures return
|
|
33
|
+
fixed diagnostics without raw errors. Character limits are not token estimates;
|
|
34
|
+
callers must assemble bounded evidence rather than merely increase the limit.
|
|
31
35
|
|
|
32
36
|
JSON responses are collected as text without constructing partial objects for
|
|
33
37
|
each streamed fragment. This avoids unnecessary parsing and allocation for large
|