@quantiya/codevibe-claude-plugin 2.0.32 → 2.0.34

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.
@@ -21,6 +21,31 @@ export type OllamaRuntimeConfigResult = {
21
21
  * turn re-ups the window) and on the shell-start pre-warm.
22
22
  */
23
23
  export declare const OLLAMA_KEEP_ALIVE = "30m";
24
+ /**
25
+ * Explicit context window for EVERY local generate (2026-09-12). Nothing set
26
+ * `num_ctx` before, so the shared model server ran at Ollama's 4,096-token
27
+ * default while the classify prompt alone was ~3,000 tokens: a wider session
28
+ * projection, a fetched page or a longer answer would have overflowed, and
29
+ * Ollama clips an overflowing prompt from the HEAD — silently dropping the
30
+ * routing rules. Measured on the dogfood machine (gemma4:12b-it-qat, Ollama
31
+ * 0.31.1): 16,384 → 7.4 GB resident, 100 % GPU, ~5 s load — the same footprint
32
+ * as 4,096 thanks to the model's sliding-window attention.
33
+ */
34
+ export declare const OLLAMA_NUM_CTX = 16384;
35
+ /**
36
+ * Disable the model's THINKING channel on every generate (2026-09-12, the decisive
37
+ * finding behind the "empty / cut-short answer" incidents). `gemma4:12b-it-qat` is a
38
+ * thinking model in Ollama 0.31.1: with `think` unspecified it still generates its
39
+ * reasoning channel, Ollama strips it from `response`, and every one of those tokens
40
+ * counts against `num_predict` — the dogfood article answer rendered 477 visible tokens
41
+ * out of 1,400 and ended mid-word with `done_reason: "length"`; an end-of-life lookup
42
+ * rendered NOTHING. With `think: false` the same lookup answers in 34 tokens / 8 s and
43
+ * the article answer completes (535 tokens, `done_reason: "stop"`, 33 s) — measured in
44
+ * the hot-fix packet (`browse-diag-think-r1.txt`). The classifier's forced-JSON
45
+ * generate is not affected either way (its token counts match its visible JSON), but
46
+ * it gets the same flag so every local call is explicit.
47
+ */
48
+ export declare const OLLAMA_THINK = false;
24
49
  /**
25
50
  * Dogfood #618 — floor for ADVISORY generations (brainstorm/familiarize
26
51
  * fallback, up to 700–1400 output tokens on a 12B + long conversation-context
@@ -47,6 +72,16 @@ export declare const PULL_STALL_TIMEOUT_MS: number;
47
72
  export declare function isSafeOllamaModelName(model: string | null | undefined): model is string;
48
73
  export declare function parseLocalOllamaHost(raw: string | undefined): string | null;
49
74
  export declare function loadOllamaRuntimeConfigFromEnv(env?: NodeJS.ProcessEnv): OllamaRuntimeConfigResult;
75
+ /**
76
+ * Ollama does not report that it clipped a prompt to the window; the only
77
+ * signal is a prompt evaluation that fills the window. A prompt that evaluated
78
+ * `num_ctx - num_predict` tokens or more was (or could have been) head-clipped,
79
+ * and a head-clipped classify prompt has lost its routing rules — refuse to
80
+ * route on it. Normal prompts are a fifth of the window, so this never fires
81
+ * on a healthy call; cached-prefix calls report fewer tokens and cannot fire
82
+ * spuriously either.
83
+ */
84
+ export declare function promptFilledContextWindow(promptEvalCount: number | undefined, numPredict: number): boolean;
50
85
  /** A single streamed `/api/pull` progress record surfaced to callers. */
51
86
  export interface OllamaPullProgress {
52
87
  /** e.g. `pulling <digest>`, `downloading`, `verifying sha256 digest`, `writing manifest`, `success`. */
@@ -58,6 +93,64 @@ export interface OllamaPullProgress {
58
93
  }
59
94
  /** Progress sink for {@link requestOllamaPull}. Defaults to a no-op so existing callers/tests are unaffected. */
60
95
  export type OllamaPullProgressListener = (progress: OllamaPullProgress) => void;
96
+ /**
97
+ * Consecutive streamed tokens that render NO visible text before the generation is cut
98
+ * off. Observed 2026-09-12 on gemma4:12b-it-qat / Ollama 0.31.1 at temperature 0: the model
99
+ * can fall into a loop of hidden tokens (`done_reason: "length"`, `eval_count` = the full
100
+ * `num_predict`, zero or few visible characters) — from the first token on an end-of-life
101
+ * lookup, or mid-answer after "between 2" on the dogfood article — burning 60–120 s of
102
+ * generation for nothing. A real answer never emits this many empty chunks in a row.
103
+ */
104
+ export declare const EMPTY_TOKEN_WATCHDOG = 24;
105
+ /**
106
+ * Idle guard for the same loop when the server streams NOTHING for the hidden tokens
107
+ * (observed on Ollama 0.31.1: no chunks at all until `done`): once visible text has
108
+ * started arriving, a healthy generation streams a token every few hundred ms at most,
109
+ * so a silence this long after the first chunk is the loop — cut off and keep the text.
110
+ * Not armed before the first chunk: prompt evaluation of a long prompt is legitimately
111
+ * silent for tens of seconds.
112
+ */
113
+ export declare const STREAM_IDLE_CUTOFF_MS = 12000;
114
+ /** Test seam — shorten the idle guard. */
115
+ export declare function __setStreamIdleCutoffMsForTests(ms: number | null): void;
116
+ /** Marker appended to an answer the watchdog cut short, so the reader can tell. */
117
+ export declare const CUT_OFF_MARKER = " [\u2026]";
118
+ /**
119
+ * Stage-1 r1 F6 (2026-09-12) — a conservative token ESTIMATE for prompt budgeting.
120
+ * Character budgets assume ~4 chars per token, which holds for English but not for
121
+ * CJK text (zh-TW is the owner's locale): a CJK / kana / Hangul / full-width
122
+ * character is counted as ONE token, everything else at 3.5 chars per token.
123
+ * Calibrated against `prompt_eval_count` on the real model (packet evidence
124
+ * `cjk-probe-r1.txt`). Over-estimating is the safe direction: a prompt that
125
+ * fills the window is refused, not clipped.
126
+ */
127
+ export declare function estimateTokens(text: string): number;
128
+ /** Message of the error thrown when a full `num_predict` budget rendered no visible text. */
129
+ export declare const HIDDEN_TOKEN_LOOP_MESSAGE = "Ollama generate produced no visible text for its whole token budget (hidden-token loop)";
130
+ export interface OllamaStreamedGeneration {
131
+ text: string;
132
+ doneReason?: string;
133
+ promptEvalCount?: number;
134
+ evalCount?: number;
135
+ /** Set when a watchdog cut the generation off. */
136
+ cutOff?: 'empty-token-loop' | 'idle';
137
+ }
138
+ /**
139
+ * STREAMED generate for the long text answerers (advisory / browse). Reads Ollama's
140
+ * newline-delimited chunks, concatenates `response`, and — the reason it streams —
141
+ * aborts the request as soon as {@link EMPTY_TOKEN_WATCHDOG} consecutive chunks carried
142
+ * no visible text, returning what was rendered so far (the caller decides whether an
143
+ * empty result is a failure). A single non-streamed JSON body (test stubs, older
144
+ * servers) is accepted as one final chunk. Error chunks, non-200 status, the size cap
145
+ * and the timeout keep the same semantics as {@link requestOllamaGenerate}.
146
+ */
147
+ export declare function requestOllamaGenerateStream(config: OllamaRuntimeConfig, promptText: string, opts?: {
148
+ numPredict?: number;
149
+ formatJson?: boolean;
150
+ jsonSchema?: object;
151
+ images?: string[];
152
+ timeoutMs?: number;
153
+ }): Promise<OllamaStreamedGeneration>;
61
154
  /**
62
155
  * STREAM a model pull from Ollama `/api/pull`, surfacing per-chunk download progress and
63
156
  * aborting only on a STALL (no bytes for {@link PULL_STALL_TIMEOUT_MS}) — never on a total