@caupulican/pi-adaptative 0.80.74 → 0.80.76
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/CHANGELOG.md +35 -0
- package/dist/core/agent-session.d.ts +32 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +96 -9
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +22 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +31 -3
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/cost-guard.d.ts +55 -0
- package/dist/core/cost-guard.d.ts.map +1 -0
- package/dist/core/cost-guard.js +50 -0
- package/dist/core/cost-guard.js.map +1 -0
- package/dist/core/learning/reflection-engine.d.ts +7 -0
- package/dist/core/learning/reflection-engine.d.ts.map +1 -1
- package/dist/core/learning/reflection-engine.js +22 -13
- package/dist/core/learning/reflection-engine.js.map +1 -1
- package/dist/core/memory/providers/file-store.d.ts.map +1 -1
- package/dist/core/memory/providers/file-store.js +33 -2
- package/dist/core/memory/providers/file-store.js.map +1 -1
- package/dist/core/resource-loader.d.ts +19 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +69 -5
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/settings-manager.d.ts +16 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +15 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
## [0.80.76] - 2026-06-28
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- Proactive per-turn cost guard (opt-in): set `costGuard.maxTurnUsd` to estimate the dollar cost of each
|
|
6
|
+
turn before it is submitted and, when it exceeds the ceiling, surface a warning or (with
|
|
7
|
+
`costGuard.action: "downgrade"`) automatically step reasoning effort down once to curb a runaway
|
|
8
|
+
billing spike. Disabled by default.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Background reflection now uses a static system prompt with the variable memory/turn content moved to the
|
|
13
|
+
user message, so repeated reflection passes reuse the provider prompt-cache prefix instead of re-billing
|
|
14
|
+
it — and added guidance to avoid persisting transient/environment-specific noise as memory.
|
|
15
|
+
|
|
16
|
+
## [0.80.75] - 2026-06-28
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- Compaction cost guard (long-session savings): compaction now also triggers once context passes a
|
|
21
|
+
configurable fraction of the model's window (`compaction.triggerPercent`, default 0.7) — not only when
|
|
22
|
+
it's nearly full — so per-turn input cost stays bounded on large-window models, while an anti-thrashing
|
|
23
|
+
gate skips an early compaction that would barely shrink the context. The summary is now produced by a
|
|
24
|
+
cheap auxiliary model when one is available (`compaction.model`, default `"auto"` picks the cheapest
|
|
25
|
+
authed model that can hold the context and is cheaper than the session model; falls back to the session
|
|
26
|
+
model), instead of always using the main model.
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- Hardened context/memory threat scanning: added detection and neutralization of invisible/bidirectional
|
|
31
|
+
control characters (zero-width, bidi overrides/isolates — the "Trojan Source" vector), and a broader,
|
|
32
|
+
scoped pattern set. Context-file and memory reads strip hidden characters and continue; high-privilege
|
|
33
|
+
memory writes are scanned in a stricter scope (exfil/backdoor/persistence patterns) and rejected
|
|
34
|
+
outright.
|
|
35
|
+
|
|
1
36
|
## [0.80.74] - 2026-06-28
|
|
2
37
|
|
|
3
38
|
### Fixed
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
* Modes use this class and add their own I/O layer on top.
|
|
14
14
|
*/
|
|
15
15
|
import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from "@caupulican/pi-agent-core";
|
|
16
|
-
import type { ImageContent, Message, Model, StopReason, TextContent, Usage } from "@caupulican/pi-ai";
|
|
16
|
+
import type { CacheRetention, ImageContent, Message, Model, StopReason, TextContent, Usage } from "@caupulican/pi-ai";
|
|
17
17
|
import { type BashResult } from "./bash-executor.ts";
|
|
18
18
|
import { type CompactionResult } from "./compaction/index.ts";
|
|
19
19
|
import { type ContextGcReport } from "./context-gc.ts";
|
|
20
|
+
import { type CostGuardDecision } from "./cost-guard.ts";
|
|
20
21
|
import { type ContextUsage, type ExtensionCommandContextActions, type ExtensionContext, type ExtensionErrorListener, ExtensionRunner, type ExtensionUIContext, type InputSource, type ReplacedSessionContext, type SessionStartEvent, type ShutdownHandler, type ToolDefinition, type ToolInfo } from "./extensions/index.ts";
|
|
21
22
|
import { type ChannelProvider, GatewayRegistry, type JobSchedulerProvider } from "./gateways/channel-provider.ts";
|
|
22
23
|
import { type DemandSignals, type ReflectionResult } from "./learning/reflection-engine.ts";
|
|
@@ -225,6 +226,12 @@ export interface IsolatedCompletionOptions {
|
|
|
225
226
|
maxTokens?: number;
|
|
226
227
|
/** Abort signal. */
|
|
227
228
|
signal?: AbortSignal;
|
|
229
|
+
/**
|
|
230
|
+
* Prompt-cache retention for this isolated call. Defaults to `"none"` (no caching — preserves full
|
|
231
|
+
* isolation). Callers whose `systemPrompt` is STATIC across calls (e.g. reflection, #33) can pass
|
|
232
|
+
* `"short"`/`"long"` so the provider reuses the cached prefix and bills only the variable tail.
|
|
233
|
+
*/
|
|
234
|
+
cacheRetention?: CacheRetention;
|
|
228
235
|
}
|
|
229
236
|
/** Result of an isolated completion: the text, the usage spent, and the stop reason. */
|
|
230
237
|
export interface IsolatedCompletionResult {
|
|
@@ -281,6 +288,10 @@ export declare class AgentSession {
|
|
|
281
288
|
private readonly _gatewayRegistry;
|
|
282
289
|
/** Cache for getSpawnedUsage(), keyed by session entry count (Bug #22 — avoid O(N) per render frame). */
|
|
283
290
|
private _spawnedUsageCache?;
|
|
291
|
+
/** Latest proactive cost-guard decision (#34), for the host UI to surface. Undefined when disabled. */
|
|
292
|
+
private _lastCostGuardDecision?;
|
|
293
|
+
/** One-shot latch so the cost guard downgrades reasoning once per over-threshold episode, not every call. */
|
|
294
|
+
private _costGuardDowngraded;
|
|
284
295
|
/** Set on dispose so in-flight background reflection bails instead of writing to a dead session (Bug #21). */
|
|
285
296
|
private _disposed;
|
|
286
297
|
/** Aborts in-flight background reflection completions on dispose (Bug #21). */
|
|
@@ -309,6 +320,16 @@ export declare class AgentSession {
|
|
|
309
320
|
get modelRegistry(): ModelRegistry;
|
|
310
321
|
private _getRequiredRequestAuth;
|
|
311
322
|
private _getCompactionRequestAuth;
|
|
323
|
+
/**
|
|
324
|
+
* Resolve the model used to SUMMARIZE during compaction (cost guard, #30). A compaction summary is an
|
|
325
|
+
* extraction task — it does not need the main (expensive) model. Selection:
|
|
326
|
+
* - an explicit `compaction.model` setting wins, but only if its provider is authed (else fall back);
|
|
327
|
+
* - `"auto"` (default) picks the CHEAPEST authed model whose context window can hold a compaction
|
|
328
|
+
* (capability floor), and ONLY if it is strictly cheaper than the session model — so we never
|
|
329
|
+
* downgrade to an equally-priced but weaker summarizer (agy's floor: don't degrade the checkpoint);
|
|
330
|
+
* - otherwise the session model is used (safe default).
|
|
331
|
+
*/
|
|
332
|
+
private _resolveCompactionModel;
|
|
312
333
|
/**
|
|
313
334
|
* Install tool hooks once on the Agent instance.
|
|
314
335
|
*
|
|
@@ -318,6 +339,16 @@ export declare class AgentSession {
|
|
|
318
339
|
* happens here instead of in wrappers.
|
|
319
340
|
*/
|
|
320
341
|
private _installAgentContextTransform;
|
|
342
|
+
/**
|
|
343
|
+
* Proactive per-turn cost guard (#34): estimate the USD cost of the about-to-be-submitted turn and,
|
|
344
|
+
* when it exceeds the user's ceiling, record a warning decision (for the host UI to surface) and —
|
|
345
|
+
* if configured to `downgrade` — step reasoning effort down ONCE per over-threshold episode to curb a
|
|
346
|
+
* runaway billing spike. Disabled by default (`maxTurnUsd<=0`), so it never alters behavior unless the
|
|
347
|
+
* user opts in. Best-effort: never throws into the turn.
|
|
348
|
+
*/
|
|
349
|
+
private _applyCostGuard;
|
|
350
|
+
/** Latest cost-guard decision (for the host footer/UI to surface a warning). Undefined if disabled. */
|
|
351
|
+
getLastCostGuardDecision(): CostGuardDecision | undefined;
|
|
321
352
|
private _installAgentTurnRefresh;
|
|
322
353
|
private _createAgentContextSnapshot;
|
|
323
354
|
private _contextGcStorageDir;
|