billion-context-pi 0.1.57 → 0.1.58-pr.268.115

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/config.d.ts CHANGED
@@ -107,6 +107,13 @@ export interface CompressSettings {
107
107
  /** Token growth threshold for soft compression nudges. Default: 50000.
108
108
  * Maps to kernel nudge.growthFloor + nudge.growthCap. */
109
109
  nudgeGrowthTokens?: number;
110
+ /** Minimum reclaimable tokens for a pressure-band nudge (kernel #198).
111
+ * Default: max(5000, round(limit×0.01)). Explicit 0 restores the legacy
112
+ * any-pending behavior — useful for tiny windows (e.g. e2e scenarios with
113
+ * modelContextLimit 1500) where a fixed 5000-token floor exceeds the whole
114
+ * window and would suppress every nudge. Maps to kernel
115
+ * nudge.minPressureBenefitTokens. */
116
+ minPressureBenefitTokens?: number;
110
117
  }
111
118
  /** Per-provider compression overrides. Carries the same tuning fields as the
112
119
  * global level, plus an optional per-model map keyed by model id. */
@@ -125,9 +132,31 @@ export interface CompressConfig extends CompressSettings {
125
132
  * models.json and `pi --provider`. */
126
133
  providers?: Record<string, ProviderCompress>;
127
134
  }
135
+ /** Generic tool-call repetition guard. Detects the same tool being called
136
+ * repeatedly with byte-identical arguments — a sequence-level attractor that
137
+ * token-level penalties cannot break (greedy small models loop on e.g.
138
+ * acp_status or bash polls forever, each round adding protected tokens that
139
+ * the compression protection band then refuses to reclaim). Consecutive
140
+ * identical calls accumulate per session: at `warn` a strong warning is
141
+ * appended to that call's toolResult; at `abort` the call is refused (blocked,
142
+ * error toolResult) and the turn aborted so the attractor breaks. Any change
143
+ * to the arguments (or a switch to a different tool) resets the counter.
144
+ * Accepts a boolean shorthand (`false` disables) or an object. Default:
145
+ * enabled, warn=3, abort=5. See issue #308. */
146
+ export interface RepetitionGuardConfig {
147
+ /** Enable/disable the guard. Default: true. */
148
+ enabled?: boolean;
149
+ /** Consecutive identical calls before a strong warning is appended to the
150
+ * matching toolResult. Default: 3. */
151
+ warn?: number;
152
+ /** Consecutive identical calls before the call is refused and the turn
153
+ * aborted. Default: 5. Must be greater than `warn`; clamped up
154
+ * automatically if not. */
155
+ abort?: number;
156
+ }
128
157
  /**
129
158
  * Adapter configuration. Maps onto acp-kernel's `Config` plus Pi-specific knobs
130
- * (live model context window, protected tools, state persistence).
159
+ * (live model context window, protected tools, state persistence).
131
160
  */
132
161
  export interface AdapterConfig {
133
162
  /** Master switch. Default: true. Set `enabled: false` in acp.json (or
@@ -177,6 +206,11 @@ export interface AdapterConfig {
177
206
  * disables) or a ThrottleRetryConfig object. Default: enabled, 10 retries,
178
207
  * 60s exponential base capped at 300s per kick. */
179
208
  throttleRetry?: boolean | ThrottleRetryConfig;
209
+ /** Generic tool-call repetition guard (see RepetitionGuardConfig). Accepts a
210
+ * boolean shorthand (`false` disables) or an object. Default: enabled,
211
+ * warn=3, abort=5. Stops greedy small models looping on byte-identical
212
+ * tool calls (issue #308). */
213
+ repetitionGuard?: boolean | RepetitionGuardConfig;
180
214
  /** Legacy flat alias for `delegate.displayUsage`. Kept for backward
181
215
  * compatibility with existing acp.json files. Prefer `delegate.displayUsage`. */
182
216
  displayUsage?: "merged" | "separate";
@@ -198,6 +232,20 @@ export declare const DEFAULT_TOOL_OUTPUT_MAX_BYTES = 200000;
198
232
  * default (same convention as ACP_MODEL_CONTEXT_LIMIT). Invalid values fall
199
233
  * back to the default with a logged warning — they never fail the session. */
200
234
  export declare function resolveDelegate(adapter: AdapterConfig): DelegatePolicy;
235
+ /** Defaults for the generic tool-call repetition guard (issue #308). */
236
+ export declare const REPETITION_GUARD_DEFAULTS: {
237
+ readonly warn: 3;
238
+ readonly abort: 5;
239
+ };
240
+ /** Resolve the repetition-guard configuration from the adapter, handling the
241
+ * boolean shorthand (`false` disables) and clamping `abort` to stay strictly
242
+ * above `warn` (a guard that aborts at or before its warn threshold would be
243
+ * meaningless). Non-numeric / out-of-range values fall back to defaults. */
244
+ export declare function resolveRepetitionGuard(adapter: AdapterConfig): {
245
+ enabled: boolean;
246
+ warn: number;
247
+ abort: number;
248
+ };
201
249
  /** Per-field deepest-wins merge of the three compression levels (global →
202
250
  * provider → model). An undefined field at a deeper level does NOT clear a
203
251
  * value set at a shallower level — only a defined value overrides. */
@@ -171,6 +171,10 @@ export declare function makeEventApplier(opts: {
171
171
  * duration, so rescale them to seconds before clamping — otherwise 180 clamps
172
172
  * to 1000ms and the wait times out in 1s. */
173
173
  export declare function resolveWaitTimeoutMs(raw: number | undefined): number;
174
+ /** Resolve a per-call timeout override (minutes) to ms. Absent/invalid values
175
+ * fall back to the configured default (fallbackMs); valid values are clamped
176
+ * to MAX_PER_CALL_TIMEOUT_MINUTES. */
177
+ export declare function resolvePerCallTimeoutMs(raw: number | undefined, fallbackMs: number | null): number | null;
174
178
  declare const DelegateParams: Type.TObject<{
175
179
  agent: Type.TString;
176
180
  task: Type.TOptional<Type.TString>;
@@ -180,6 +184,7 @@ declare const DelegateParams: Type.TObject<{
180
184
  thinkingLevel: Type.TOptional<Type.TString>;
181
185
  async: Type.TOptional<Type.TBoolean>;
182
186
  showThinking: Type.TOptional<Type.TBoolean>;
187
+ timeoutMinutes: Type.TOptional<Type.TNumber>;
183
188
  }>;
184
189
  type DelegateArgs = Static<typeof DelegateParams>;
185
190
  declare const CancelParams: Type.TObject<{
@@ -276,7 +281,7 @@ export declare function buildChildArgs(args: DelegateArgs, rolePrompt: string, c
276
281
  /** Model-facing summary of the ACTIVE async watchdog limits — built from the
277
282
  * resolved policy so it stays truthful when timeouts are customized or
278
283
  * disabled via acp.json/env. */
279
- export declare function asyncWatchdogDescription(): string;
284
+ export declare function asyncWatchdogDescription(overrideAsyncMs?: number | null): string;
280
285
  /** Watchdog/EOF finalize arrives with code === null (the child was killed or
281
286
  * never exited). If a result was delivered (non-empty reply or stderr), the
282
287
  * run counts as completed (0); otherwise it stays null = genuine failure. */