@kenkaiiii/ggcoder 5.67.1 → 5.68.1

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 (64) hide show
  1. package/dist/app-sidecar.js +121 -3
  2. package/dist/app-sidecar.js.map +1 -1
  3. package/dist/core/agent-session.d.ts +50 -3
  4. package/dist/core/agent-session.js +344 -21
  5. package/dist/core/agent-session.js.map +1 -1
  6. package/dist/core/ask-user.d.ts +90 -8
  7. package/dist/core/ask-user.js +124 -13
  8. package/dist/core/ask-user.js.map +1 -1
  9. package/dist/core/cache-diagnostics.d.ts +62 -0
  10. package/dist/core/cache-diagnostics.js +165 -0
  11. package/dist/core/cache-diagnostics.js.map +1 -0
  12. package/dist/core/compaction/plan-step-policy.d.ts +46 -0
  13. package/dist/core/compaction/plan-step-policy.js +57 -0
  14. package/dist/core/compaction/plan-step-policy.js.map +1 -0
  15. package/dist/core/destructive-git-guard.d.ts +63 -0
  16. package/dist/core/destructive-git-guard.js +831 -0
  17. package/dist/core/destructive-git-guard.js.map +1 -0
  18. package/dist/core/event-bus.d.ts +3 -0
  19. package/dist/core/event-bus.js +5 -0
  20. package/dist/core/event-bus.js.map +1 -1
  21. package/dist/core/keep-awake.d.ts +88 -0
  22. package/dist/core/keep-awake.js +251 -0
  23. package/dist/core/keep-awake.js.map +1 -0
  24. package/dist/core/package-threats.d.ts +18 -0
  25. package/dist/core/package-threats.js +168 -0
  26. package/dist/core/package-threats.js.map +1 -0
  27. package/dist/core/session-manager.d.ts +13 -1
  28. package/dist/core/session-manager.js +38 -18
  29. package/dist/core/session-manager.js.map +1 -1
  30. package/dist/core/session-summary-index.d.ts +37 -0
  31. package/dist/core/session-summary-index.js +172 -0
  32. package/dist/core/session-summary-index.js.map +1 -0
  33. package/dist/core/settings-manager.d.ts +2 -0
  34. package/dist/core/settings-manager.js +8 -0
  35. package/dist/core/settings-manager.js.map +1 -1
  36. package/dist/core/shell-threats-popular-packages.d.ts +11 -0
  37. package/dist/core/shell-threats-popular-packages.js +675 -0
  38. package/dist/core/shell-threats-popular-packages.js.map +1 -0
  39. package/dist/core/shell-threats.d.ts +8 -0
  40. package/dist/core/shell-threats.js +186 -0
  41. package/dist/core/shell-threats.js.map +1 -0
  42. package/dist/core/stream-rules.d.ts +30 -0
  43. package/dist/core/stream-rules.js +151 -0
  44. package/dist/core/stream-rules.js.map +1 -0
  45. package/dist/motion-agent/motion-check-tool.d.ts +7 -0
  46. package/dist/motion-agent/motion-check-tool.js +80 -30
  47. package/dist/motion-agent/motion-check-tool.js.map +1 -1
  48. package/dist/motion-agent/motion-review.d.ts +5 -2
  49. package/dist/motion-agent/motion-review.js +7 -4
  50. package/dist/motion-agent/motion-review.js.map +1 -1
  51. package/dist/tools/ask-user.js +3 -3
  52. package/dist/tools/ask-user.js.map +1 -1
  53. package/dist/tools/bash.js +37 -0
  54. package/dist/tools/bash.js.map +1 -1
  55. package/dist/tools/index.js +1 -1
  56. package/dist/tools/index.js.map +1 -1
  57. package/dist/tools/task-send.d.ts +1 -1
  58. package/dist/tools/task-send.js +15 -1
  59. package/dist/tools/task-send.js.map +1 -1
  60. package/dist/ui/components/ActivityIndicator.js +1 -0
  61. package/dist/ui/components/ActivityIndicator.js.map +1 -1
  62. package/dist/ui/hooks/useAgentLoop.d.ts +1 -1
  63. package/dist/ui/hooks/useAgentLoop.js.map +1 -1
  64. package/package.json +4 -4
@@ -1,5 +1,5 @@
1
1
  import { type AgentTool } from "@kenkaiiii/gg-agent";
2
- import { type Message, type MessageProvenance, type Provider, type ThinkingLevel } from "@kenkaiiii/gg-ai";
2
+ import { type Message, type MessageProvenance, type Provider, type Usage, type ThinkingLevel } from "@kenkaiiii/gg-ai";
3
3
  import { EventBus } from "./event-bus.js";
4
4
  import { type CompletionReview } from "./completion-review.js";
5
5
  import { SlashCommandRegistry } from "./slash-commands.js";
@@ -224,6 +224,7 @@ export declare class AgentSession {
224
224
  private autopilotMarkers;
225
225
  private appMarkers;
226
226
  private turnMetrics;
227
+ private readonly cacheDiagnostics;
227
228
  /** Internal-only (GG_INTERNAL): live per-session cost/reliability recorder.
228
229
  * Absent entirely in public builds — see core/internal-diagnostics.ts. */
229
230
  private diagnosticsRecorder?;
@@ -299,6 +300,12 @@ export declare class AgentSession {
299
300
  private postTurnCompaction?;
300
301
  private lastCompactionCompacted;
301
302
  private compactionRetryAfter;
303
+ /**
304
+ * SoL-Pi plan-step compaction bookkeeping (see compaction/plan-step-policy.ts).
305
+ * Step progress comes from `[DONE:n]` markers in assistant text — the same
306
+ * contract the approved-plan UI tracks.
307
+ */
308
+ private planStepState;
302
309
  /** A restored oversized checkpoint must be canonicalized before its first prompt is persisted. */
303
310
  private deferredCompactionPending;
304
311
  /** Latest provider count, anchored to the assistant response it measured. */
@@ -601,8 +608,11 @@ export declare class AgentSession {
601
608
  private getHookFollowUpMessages;
602
609
  private reviewLspEvidence;
603
610
  private withReviewLspEvidence;
604
- /** Auto-compact if needed, run agent loop with auth retry, and persist messages. */
611
+ /** Wraps the real run: cancels an in-flight cache prewarm and tracks run
612
+ * activity / last real request time for {@link prewarm}. */
605
613
  private runLoop;
614
+ /** Auto-compact if needed, run agent loop with auth retry, and persist messages. */
615
+ private runLoopInner;
606
616
  switchModel(provider: string, model: string): Promise<void>;
607
617
  /**
608
618
  * Record the switch as its own trailing message at the point it happened,
@@ -629,6 +639,20 @@ export declare class AgentSession {
629
639
  * protect it.
630
640
  */
631
641
  private settlePostTurnCompaction;
642
+ /**
643
+ * Advance plan-step bookkeeping over the messages added since the last
644
+ * observation and, when a plan step was newly completed (`[DONE:n]`), run
645
+ * the SoL-Pi cost rule. Called between model steps (in-flight) and once
646
+ * after the run; `scanIndex` and `doneSteps` make each message and each
647
+ * step count once across both paths. Returns undefined when no step
648
+ * completed since the last observation.
649
+ */
650
+ private observePlanStepProgress;
651
+ /**
652
+ * Plan-step bookkeeping after ANY successful compaction (as in the bench:
653
+ * every compaction leaves a cache-write cost to be repaid by later savings).
654
+ */
655
+ private recordPlanStepCompaction;
632
656
  /**
633
657
  * Post-turn compaction: once the final response has been delivered, compact
634
658
  * in the background while the user reads the answer, instead of making the
@@ -637,7 +661,9 @@ export declare class AgentSession {
637
661
  * Codex `model_post_turn_compact_threshold_percent` guards: skip when user
638
662
  * input is already queued (it would race the next turn), when the run was
639
663
  * aborted, or during the failure cooldown — and never let a compaction
640
- * error surface in the completed turn.
664
+ * error surface in the completed turn. Besides the size trigger, a newly
665
+ * completed approved-plan step may compact when the cache-cost rule in
666
+ * compaction/plan-step-policy.ts says the shrink pays for itself.
641
667
  */
642
668
  private maybeCompactPostTurn;
643
669
  compact(existingCredentials?: {
@@ -789,6 +815,11 @@ export declare class AgentSession {
789
815
  * the standard prompt therefore needs a rebuild. Custom and sub-agent
790
816
  * prompts never render packs, so detection is skipped for them.
791
817
  */
818
+ /**
819
+ * Bring the system prompt to the exact state the next provider request will
820
+ * send. Shared by real runs and {@link prewarm} so both see one prefix.
821
+ */
822
+ private prepareSystemPromptForRequest;
792
823
  private refreshActiveLanguages;
793
824
  /** Rebuild messages[0] from current plan-mode + approved-plan state. */
794
825
  private rebuildSystemPromptInPlace;
@@ -924,6 +955,22 @@ export declare class AgentSession {
924
955
  /** Replace the abort signal (e.g. after cancellation). */
925
956
  setSignal(signal: AbortSignal): void;
926
957
  private bindManagerCancellation;
958
+ private runLoopDepth;
959
+ private lastRealRequestAt;
960
+ private lastPrewarmAt;
961
+ private prewarmController;
962
+ /**
963
+ * Best-effort Anthropic prompt-cache prewarm before the user's next turn
964
+ * (desktop app calls this on the first keystroke after opening a chat or an
965
+ * idle pause). Sends the exact request prefix the next real turn will use —
966
+ * same system/tools/thinking/cache options — with `max_tokens: 1`, so the
967
+ * first real reply is a cache read instead of a cold write.
968
+ */
969
+ prewarm(signal?: AbortSignal): Promise<{
970
+ ok: boolean;
971
+ reason: string;
972
+ usage?: Usage;
973
+ }>;
927
974
  /** True when speedProfile is "optimized" (1-h cache TTL + pre-warm), or the
928
975
  * session was constructed with `forceLongCacheRetention` (Ken sessions). */
929
976
  private isSpeedOptimized;