@caupulican/pi-adaptative 0.80.98 → 0.80.99

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/core/agent-session.d.ts +27 -3
  3. package/dist/core/agent-session.d.ts.map +1 -1
  4. package/dist/core/agent-session.js +200 -11
  5. package/dist/core/agent-session.js.map +1 -1
  6. package/dist/core/autonomy/foreground-envelope.d.ts +22 -0
  7. package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -0
  8. package/dist/core/autonomy/foreground-envelope.js +65 -0
  9. package/dist/core/autonomy/foreground-envelope.js.map +1 -0
  10. package/dist/core/autonomy/status.d.ts +11 -0
  11. package/dist/core/autonomy/status.d.ts.map +1 -1
  12. package/dist/core/autonomy/status.js.map +1 -1
  13. package/dist/core/delegation/worker-actions.d.ts +50 -0
  14. package/dist/core/delegation/worker-actions.d.ts.map +1 -0
  15. package/dist/core/delegation/worker-actions.js +70 -0
  16. package/dist/core/delegation/worker-actions.js.map +1 -0
  17. package/dist/core/delegation/worker-runner.d.ts +9 -0
  18. package/dist/core/delegation/worker-runner.d.ts.map +1 -1
  19. package/dist/core/delegation/worker-runner.js +38 -4
  20. package/dist/core/delegation/worker-runner.js.map +1 -1
  21. package/dist/core/model-capability.d.ts +19 -0
  22. package/dist/core/model-capability.d.ts.map +1 -1
  23. package/dist/core/model-capability.js +19 -0
  24. package/dist/core/model-capability.js.map +1 -1
  25. package/dist/core/settings-manager.d.ts +3 -0
  26. package/dist/core/settings-manager.d.ts.map +1 -1
  27. package/dist/core/settings-manager.js +5 -0
  28. package/dist/core/settings-manager.js.map +1 -1
  29. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  30. package/dist/modes/interactive/components/settings-selector.js +20 -0
  31. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  32. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  33. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  34. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  35. package/examples/extensions/sandbox/package-lock.json +2 -2
  36. package/examples/extensions/sandbox/package.json +1 -1
  37. package/examples/extensions/with-deps/package-lock.json +2 -2
  38. package/examples/extensions/with-deps/package.json +1 -1
  39. package/npm-shrinkwrap.json +12 -12
  40. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ ## [0.80.99] - 2026-07-02
2
+
3
+ ### Added
4
+
5
+ - Added code-writing workers (G2 full): with `workerDelegation.writeEnabled` plus a `writePaths`
6
+ scope, a delegated worker may emit structured file actions (write/edit) that the RUNNER applies
7
+ through the capability envelope's path scope — an out-of-scope or denied path is refused with a
8
+ reason and downgrades the result to blocked (a partial change can never look like clean success),
9
+ and a write without the grant is ignored and flagged. `workerDelegation.maxConcurrent` (1-3)
10
+ replaces the single-flight limit. The read-only scout contract is unchanged when writes are off.
11
+ - Added speculative muscle-retry on executor turns: when an executor-routed turn ends without a
12
+ successful run_toolkit_script execution, pi retries once on the same executor with the brain's
13
+ refined instruction injected (the brain warms while the muscle tries, so the retry costs only
14
+ when the muscle actually missed); visible in the router decision as executor_speculative_retry.
15
+ - Added gate-outcome history (G8): a bounded 50-entry history of tool-gate outcomes replaces the
16
+ latest-only record (getGateOutcomeHistory()), and the three remaining autonomy telemetry types
17
+ (gateOutcome, workerRequest, approvalRequest) now emit at their honest sites.
18
+ - Added per-turn foreground capability envelopes (G7): each turn derives an observe-only envelope
19
+ (capabilities mapped from active tools, path scope = cwd, usd bound from the cost guard),
20
+ surfaced as a one-line /context observation and via getForegroundEnvelope().
21
+ - Added capability-scaled goal-continuation budgets (G9): lean-class models (16-32k) now cap
22
+ autonomous continuation at 2 turns / 5 minutes; below 16k stays gated off, full class unchanged.
23
+
1
24
  ## [0.80.98] - 2026-07-02
2
25
 
3
26
  ### Added
@@ -2,7 +2,7 @@ import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLe
2
2
  import type { CacheRetention, ImageContent, Message, Model, StopReason, TextContent, Usage } from "@caupulican/pi-ai";
3
3
  import type { CapabilityEnvelope, EvidenceBundle, LearningDecision, WorkerRequest, WorkerResult } from "./autonomy/contracts.ts";
4
4
  import { type LaneRecord } from "./autonomy/lane-tracker.ts";
5
- import type { AutonomyDiagnosticSnapshot, AutonomyStatusSnapshot } from "./autonomy/status.ts";
5
+ import type { AutonomyDiagnosticSnapshot, AutonomyStatusSnapshot, GateOutcomeHistoryEntry } from "./autonomy/status.ts";
6
6
  import { type BashResult } from "./bash-executor.ts";
7
7
  import { type CompactionResult } from "./compaction/index.ts";
8
8
  import { type CurationTelemetrySnapshot } from "./context/brain-curator.ts";
@@ -329,8 +329,6 @@ export declare class AgentSession {
329
329
  private readonly _laneTracker;
330
330
  /** Session-lifetime abort for in-flight research passes (same pattern as _reflectionAbort). */
331
331
  private readonly _researchLaneAbort;
332
- /** Single-flight guard: at most one delegated worker runs at a time per session. */
333
- private _isWorkerDelegationRunning;
334
332
  /** Session-lifetime abort for in-flight delegated workers. */
335
333
  private readonly _workerDelegationAbort;
336
334
  /**
@@ -364,6 +362,8 @@ export declare class AgentSession {
364
362
  private _pendingBashMessages;
365
363
  private _extensionRunner;
366
364
  private _turnIndex;
365
+ /** G7: per-turn foreground CapabilityEnvelope auto-built for visibility (observe-only; not enforced). */
366
+ private _currentForegroundEnvelope?;
367
367
  private _resourceLoader;
368
368
  private _customTools;
369
369
  private _baseToolDefinitions;
@@ -398,6 +398,8 @@ export declare class AgentSession {
398
398
  private _isModelRouterRetry;
399
399
  private _lastModelRouterDecision?;
400
400
  private _lastAutonomyGateOutcome?;
401
+ /** G8: bounded (cap {@link GATE_OUTCOME_HISTORY_LIMIT}) history of gate outcomes; tail is latest. */
402
+ private readonly _gateOutcomeHistory;
401
403
  private _lastModelRouterSkipReason?;
402
404
  private _lastModelRouterIntent?;
403
405
  /** Lazily-built skill curator (#32) over `<agentDir>/skills`. */
@@ -729,6 +731,15 @@ export declare class AgentSession {
729
731
  * Returns the names of tools currently set on the agent.
730
732
  */
731
733
  getActiveToolNames(): string[];
734
+ /** G7: build a foreground {@link CapabilityEnvelope} from the live session state (active tools, cwd, cost ceiling). */
735
+ private _buildForegroundEnvelopeFromState;
736
+ /**
737
+ * G7: (re)build the foreground envelope for the current turn. Visibility only -- the foreground
738
+ * envelope is NOT enforced this round. Best-effort: never throws into the turn.
739
+ */
740
+ private _refreshForegroundEnvelope;
741
+ /** G7: the auto-constructed foreground envelope for the current/most-recent turn (visibility only). */
742
+ getForegroundEnvelope(): CapabilityEnvelope | undefined;
732
743
  /**
733
744
  * Get all configured tools with name, description, parameter schema, prompt guidelines, and source metadata.
734
745
  */
@@ -790,6 +801,9 @@ export declare class AgentSession {
790
801
  private _runAgentPrompt;
791
802
  private _isModelAvailableAndAuthed;
792
803
  private _resolveExecutorRoute;
804
+ /** True if a run_toolkit_script tool result since `fromIndex` actually EXECUTED (not error/ambiguous). */
805
+ private _executorTurnExecutedScript;
806
+ private _buildExecutorRefinedPrompt;
793
807
  private _resolveModelRouterTurnRoute;
794
808
  private _resolveModelRouterModelForIntent;
795
809
  private _resolveConfiguredTierModel;
@@ -1199,6 +1213,16 @@ export declare class AgentSession {
1199
1213
  * numbers) — never prompt/summary text; callers own that discipline.
1200
1214
  */
1201
1215
  private _emitAutonomyTelemetry;
1216
+ /**
1217
+ * G8: single sink for a gate outcome. Keeps the latest-outcome getter behavior identical (the
1218
+ * full {@link GateOutcome} still lands in `_lastAutonomyGateOutcome`), and additionally appends a
1219
+ * bounded codes-only entry to {@link _gateOutcomeHistory} (oldest evicted at
1220
+ * {@link GATE_OUTCOME_HISTORY_LIMIT}) and emits the `gate_outcome` telemetry event. The history
1221
+ * tail therefore always mirrors the latest outcome. Only called with an active envelope.
1222
+ */
1223
+ private _recordGateOutcome;
1224
+ /** G8: copies of the bounded gate-outcome history, oldest first, latest last. */
1225
+ getGateOutcomeHistory(): GateOutcomeHistoryEntry[];
1202
1226
  saveWorkerResultSnapshot(result: WorkerResult, request?: WorkerRequest): string;
1203
1227
  getWorkerResultSnapshots(): WorkerResult[];
1204
1228
  saveLearningDecisionSnapshot(decision: LearningDecision): string;