pi-smart-compact 9.7.1 → 10.0.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 (206) hide show
  1. package/ARCHITECTURE.md +973 -372
  2. package/CHANGELOG.md +721 -0
  3. package/LICENSE +8 -0
  4. package/README.md +128 -640
  5. package/SECURITY.md +34 -12
  6. package/SUPPORT.md +26 -9
  7. package/assets/DejaVu-LICENSE.txt +187 -0
  8. package/assets/DejaVuSansMono.ttf +0 -0
  9. package/assets/README.md +26 -0
  10. package/assets/skills/context-management/SKILL.md +34 -0
  11. package/dist/app/anchor-cache.d.ts +36 -0
  12. package/dist/app/anchor-cache.d.ts.map +1 -0
  13. package/dist/app/artifact-storage.d.ts +47 -0
  14. package/dist/app/artifact-storage.d.ts.map +1 -0
  15. package/dist/app/background-preparation.d.ts +39 -0
  16. package/dist/app/background-preparation.d.ts.map +1 -0
  17. package/dist/app/compaction-commit-store.d.ts +5 -1
  18. package/dist/app/compaction-commit-store.d.ts.map +1 -1
  19. package/dist/app/context-evidence.d.ts +57 -0
  20. package/dist/app/context-evidence.d.ts.map +1 -0
  21. package/dist/app/context-guide.d.ts +3 -0
  22. package/dist/app/context-guide.d.ts.map +1 -0
  23. package/dist/app/context-operations.d.ts +106 -0
  24. package/dist/app/context-operations.d.ts.map +1 -0
  25. package/dist/app/effective-state.d.ts +23 -0
  26. package/dist/app/effective-state.d.ts.map +1 -0
  27. package/dist/app/global-settings-runtime.d.ts +3 -3
  28. package/dist/app/global-settings-runtime.d.ts.map +1 -1
  29. package/dist/app/hindsight-memory.d.ts +100 -0
  30. package/dist/app/hindsight-memory.d.ts.map +1 -0
  31. package/dist/app/host-cache-ledger.d.ts +68 -0
  32. package/dist/app/host-cache-ledger.d.ts.map +1 -0
  33. package/dist/app/lazy-tools.d.ts +36 -0
  34. package/dist/app/lazy-tools.d.ts.map +1 -0
  35. package/dist/app/memory-backend.d.ts +58 -0
  36. package/dist/app/memory-backend.d.ts.map +1 -0
  37. package/dist/app/mnemopi-memory.d.ts +13 -0
  38. package/dist/app/mnemopi-memory.d.ts.map +1 -0
  39. package/dist/app/mnemopi-protocol.d.ts +78 -0
  40. package/dist/app/mnemopi-protocol.d.ts.map +1 -0
  41. package/dist/app/mnemopi-worker.d.ts +2 -0
  42. package/dist/app/mnemopi-worker.d.ts.map +1 -0
  43. package/dist/app/model-feasibility.d.ts +20 -0
  44. package/dist/app/model-feasibility.d.ts.map +1 -0
  45. package/dist/app/native-compaction.d.ts +88 -0
  46. package/dist/app/native-compaction.d.ts.map +1 -0
  47. package/dist/app/native-continuity-bridge.d.ts.map +1 -1
  48. package/dist/app/navigation-data.d.ts +28 -0
  49. package/dist/app/navigation-data.d.ts.map +1 -0
  50. package/dist/app/navigation-types.d.ts +60 -0
  51. package/dist/app/navigation-types.d.ts.map +1 -0
  52. package/dist/app/pending-slot.d.ts +11 -1
  53. package/dist/app/pending-slot.d.ts.map +1 -1
  54. package/dist/app/preflight.d.ts.map +1 -1
  55. package/dist/app/register-context-tools.d.ts +16 -3
  56. package/dist/app/register-context-tools.d.ts.map +1 -1
  57. package/dist/app/register-navigation.d.ts +20 -0
  58. package/dist/app/register-navigation.d.ts.map +1 -0
  59. package/dist/app/register-smart-compact-command.d.ts +17 -2
  60. package/dist/app/register-smart-compact-command.d.ts.map +1 -1
  61. package/dist/app/register-smart-compact-tool.d.ts.map +1 -1
  62. package/dist/app/register-smart-context-tool.d.ts +55 -0
  63. package/dist/app/register-smart-context-tool.d.ts.map +1 -0
  64. package/dist/app/run-context.d.ts +1 -0
  65. package/dist/app/run-context.d.ts.map +1 -1
  66. package/dist/app/run-smart-compact.d.ts +3 -3
  67. package/dist/app/run-smart-compact.d.ts.map +1 -1
  68. package/dist/app/session-handoff.d.ts +64 -0
  69. package/dist/app/session-handoff.d.ts.map +1 -0
  70. package/dist/app/session-lineage.d.ts +17 -0
  71. package/dist/app/session-lineage.d.ts.map +1 -0
  72. package/dist/app/session-run-lock.d.ts +0 -2
  73. package/dist/app/session-run-lock.d.ts.map +1 -1
  74. package/dist/app/settled-auto-trigger.d.ts +2 -0
  75. package/dist/app/settled-auto-trigger.d.ts.map +1 -1
  76. package/dist/app/smart-compact-input.d.ts +1 -1
  77. package/dist/app/smart-compact-input.d.ts.map +1 -1
  78. package/dist/app/smart-compact-policy.d.ts +1 -1
  79. package/dist/app/smart-compact-policy.d.ts.map +1 -1
  80. package/dist/app/steps/extract.d.ts +45 -1
  81. package/dist/app/steps/extract.d.ts.map +1 -1
  82. package/dist/app/steps/metrics.d.ts +1 -0
  83. package/dist/app/steps/metrics.d.ts.map +1 -1
  84. package/dist/app/steps/persist.d.ts.map +1 -1
  85. package/dist/app/steps/prepare.d.ts.map +1 -1
  86. package/dist/app/steps/recover.d.ts +9 -0
  87. package/dist/app/steps/recover.d.ts.map +1 -1
  88. package/dist/app/steps/synthesize.d.ts.map +1 -1
  89. package/dist/app/steps/tier.d.ts.map +1 -1
  90. package/dist/app/steps/verify.d.ts.map +1 -1
  91. package/dist/app/steps/visual.d.ts +4 -0
  92. package/dist/app/steps/visual.d.ts.map +1 -0
  93. package/dist/app/steps/window.d.ts.map +1 -1
  94. package/dist/app/tool-artifacts.d.ts +27 -0
  95. package/dist/app/tool-artifacts.d.ts.map +1 -0
  96. package/dist/app/visual-archive.d.ts +29 -0
  97. package/dist/app/visual-archive.d.ts.map +1 -0
  98. package/dist/constants.d.ts +96 -1
  99. package/dist/constants.d.ts.map +1 -1
  100. package/dist/domain/compaction-usage.d.ts +16 -0
  101. package/dist/domain/compaction-usage.d.ts.map +1 -0
  102. package/dist/domain/model-capacity.d.ts +12 -0
  103. package/dist/domain/model-capacity.d.ts.map +1 -0
  104. package/dist/domain/provider-evaluation.d.ts +7 -0
  105. package/dist/domain/provider-evaluation.d.ts.map +1 -1
  106. package/dist/domain/telemetry.d.ts +43 -2
  107. package/dist/domain/telemetry.d.ts.map +1 -1
  108. package/dist/domain/tool-semantics.d.ts +23 -0
  109. package/dist/domain/tool-semantics.d.ts.map +1 -1
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +15757 -6942
  112. package/dist/infra/ai-messages.d.ts +1 -1
  113. package/dist/infra/ai-messages.d.ts.map +1 -1
  114. package/dist/infra/context-graph.d.ts +38 -7
  115. package/dist/infra/context-graph.d.ts.map +1 -1
  116. package/dist/infra/fs.d.ts.map +1 -1
  117. package/dist/infra/hindsight-client.d.ts +73 -0
  118. package/dist/infra/hindsight-client.d.ts.map +1 -0
  119. package/dist/infra/hindsight-receipts.d.ts +68 -0
  120. package/dist/infra/hindsight-receipts.d.ts.map +1 -0
  121. package/dist/infra/llm-client.d.ts +26 -23
  122. package/dist/infra/llm-client.d.ts.map +1 -1
  123. package/dist/infra/memory-ref.d.ts +27 -0
  124. package/dist/infra/memory-ref.d.ts.map +1 -0
  125. package/dist/infra/native-protocol.d.ts +54 -0
  126. package/dist/infra/native-protocol.d.ts.map +1 -0
  127. package/dist/infra/optional-components.d.ts +15 -0
  128. package/dist/infra/optional-components.d.ts.map +1 -0
  129. package/dist/infra/paths.d.ts +2 -0
  130. package/dist/infra/paths.d.ts.map +1 -1
  131. package/dist/infra/services.d.ts +15 -5
  132. package/dist/infra/services.d.ts.map +1 -1
  133. package/dist/infra/visual-renderer.d.ts +16 -0
  134. package/dist/infra/visual-renderer.d.ts.map +1 -0
  135. package/dist/mnemopi-worker.js +213 -0
  136. package/dist/phases/explore.d.ts +12 -9
  137. package/dist/phases/explore.d.ts.map +1 -1
  138. package/dist/phases/synthesize.d.ts +18 -3
  139. package/dist/phases/synthesize.d.ts.map +1 -1
  140. package/dist/phases/verify.d.ts +5 -1
  141. package/dist/phases/verify.d.ts.map +1 -1
  142. package/dist/rtk.d.ts +7 -0
  143. package/dist/rtk.d.ts.map +1 -0
  144. package/dist/rtk.js +767 -0
  145. package/dist/types.d.ts +128 -4
  146. package/dist/types.d.ts.map +1 -1
  147. package/dist/ui/dashboard-format.d.ts +2 -1
  148. package/dist/ui/dashboard-format.d.ts.map +1 -1
  149. package/dist/ui/dashboard-insights.d.ts +9 -1
  150. package/dist/ui/dashboard-insights.d.ts.map +1 -1
  151. package/dist/ui/error-format.d.ts +7 -2
  152. package/dist/ui/error-format.d.ts.map +1 -1
  153. package/dist/ui/handoff-overlay.d.ts +26 -0
  154. package/dist/ui/handoff-overlay.d.ts.map +1 -0
  155. package/dist/ui/home-overlay.d.ts +54 -0
  156. package/dist/ui/home-overlay.d.ts.map +1 -0
  157. package/dist/ui/metrics-dashboard-overlay.d.ts.map +1 -1
  158. package/dist/ui/metrics-report.d.ts.map +1 -1
  159. package/dist/ui/navigation-overlay.d.ts +92 -0
  160. package/dist/ui/navigation-overlay.d.ts.map +1 -0
  161. package/dist/ui/overlays.d.ts +12 -2
  162. package/dist/ui/overlays.d.ts.map +1 -1
  163. package/dist/ui/profiles.d.ts +51 -0
  164. package/dist/ui/profiles.d.ts.map +1 -0
  165. package/dist/ui/settings-complex.d.ts +49 -3
  166. package/dist/ui/settings-complex.d.ts.map +1 -1
  167. package/dist/ui/settings-list.d.ts +28 -0
  168. package/dist/ui/settings-list.d.ts.map +1 -0
  169. package/dist/ui/settings-overlay.d.ts +13 -6
  170. package/dist/ui/settings-overlay.d.ts.map +1 -1
  171. package/dist/ui/storage-report.d.ts +4 -0
  172. package/dist/ui/storage-report.d.ts.map +1 -0
  173. package/dist/utils/backups.d.ts.map +1 -1
  174. package/dist/utils/cache.d.ts +6 -2
  175. package/dist/utils/cache.d.ts.map +1 -1
  176. package/dist/utils/config.d.ts +12 -0
  177. package/dist/utils/config.d.ts.map +1 -1
  178. package/dist/utils/helpers.d.ts.map +1 -1
  179. package/dist/utils/id-fingerprint.d.ts +3 -1
  180. package/dist/utils/id-fingerprint.d.ts.map +1 -1
  181. package/dist/utils/issues.d.ts +61 -0
  182. package/dist/utils/issues.d.ts.map +1 -0
  183. package/dist/utils/pruning.d.ts.map +1 -1
  184. package/dist/utils/session-log.d.ts +0 -2
  185. package/dist/utils/session-log.d.ts.map +1 -1
  186. package/dist/utils/state.d.ts +3 -1
  187. package/dist/utils/state.d.ts.map +1 -1
  188. package/dist/utils/tokens.d.ts +10 -2
  189. package/dist/utils/tokens.d.ts.map +1 -1
  190. package/docs/MIGRATING_TO_V8.md +7 -1
  191. package/docs/README.md +69 -0
  192. package/docs/RELEASE.md +173 -56
  193. package/docs/assets/banner.png +0 -0
  194. package/docs/assets/banner.svg +1158 -70
  195. package/docs/assets/pi-smart-compact.png +0 -0
  196. package/docs/assets/pi-smart-compact.svg +24 -0
  197. package/docs/configuration.md +637 -0
  198. package/docs/evaluation.md +408 -0
  199. package/docs/guide.md +860 -0
  200. package/docs/hindsight-memory.md +314 -0
  201. package/docs/identity.md +124 -0
  202. package/package.json +44 -11
  203. package/dist/provider-eval.js +0 -2122
  204. package/dist/provider-scenario-eval.js +0 -2900
  205. package/dist/telemetry-report.js +0 -1973
  206. package/docs/provider-evaluation-2026-08-06.md +0 -63
@@ -0,0 +1,106 @@
1
+ /** Session-local, append-only context edits. Original evidence stays in Pi's JSONL. */
2
+ import { type SessionBoundaryDraft, type SessionEntry } from "@earendil-works/pi-coding-agent";
3
+ import type { ModelCostRates } from "@earendil-works/pi-ai";
4
+ import { fingerprintContext } from "./pending-slot.ts";
5
+ export declare const CONTEXT_CONTROL_TYPE = "smart-compact-context";
6
+ export declare const CONTEXT_REPORT_TYPE = "smart-compact-rewind";
7
+ export declare const MAX_CONTEXT_EDITS = 512;
8
+ export declare const MAX_TRIM_EDITS = 32;
9
+ export declare const MIN_TRIM_CHARS = 4096;
10
+ export declare const MIN_AUTO_TRIM_SAVING_CHARS = 16384;
11
+ export declare const AUTO_TRIM_COOLDOWN_TURNS = 8;
12
+ /** Pin the latest owned or historically recorded anchor prefix during cleanup. */
13
+ export declare function lastAnchorBoundary(branch: SessionEntry[]): string | undefined;
14
+ export interface ContextCheckpoint {
15
+ id: string;
16
+ label: string;
17
+ sessionId: string;
18
+ originId: string;
19
+ snapshot: ReturnType<typeof fingerprintContext>;
20
+ }
21
+ /** Why a trim was committed: context pressure, warm-cache break-even, cold-cache apply, or an explicit request. */
22
+ export type TrimCause = "pressure" | "break-even" | "cold" | "manual" | "agent";
23
+ /** Content evidence for an archived output at commit time; `references` stays the authorization list. */
24
+ export interface ArchiveRecord {
25
+ id: string;
26
+ sha256: string;
27
+ chars: number;
28
+ }
29
+ type ControlData = {
30
+ version: 1;
31
+ action: "checkpoint";
32
+ checkpoint: ContextCheckpoint;
33
+ } | {
34
+ version: 1;
35
+ action: "trim";
36
+ references: string[];
37
+ archives?: ArchiveRecord[];
38
+ cause?: TrimCause;
39
+ } | {
40
+ version: 1;
41
+ action: "rewind";
42
+ references: string[];
43
+ archives?: ArchiveRecord[];
44
+ };
45
+ export declare function contextControlEntry(data: ControlData): SessionBoundaryDraft;
46
+ export declare function inspectContext(branch: SessionEntry[], sessionId: string): {
47
+ checkpoint: ContextCheckpoint | null;
48
+ checkpointIndex: number;
49
+ invalidReason: string | undefined;
50
+ references: Set<string>;
51
+ archives: Map<string, Omit<ArchiveRecord, "id">>;
52
+ };
53
+ /** Keep complete call/result groups, including all siblings if any tool may have side effects. */
54
+ export declare function removableResearch(branch: SessionEntry[]): Set<string>;
55
+ /**
56
+ * Deterministic trim marker: a retrieval line, then the call's subject (with an optional note),
57
+ * the first output line and up to three risk lines, bounded by TRIM_MARKER_MAX_LINES / TRIM_MARKER_MAX_CHARS.
58
+ */
59
+ export declare function buildTrimMarker(input: {
60
+ toolName: string;
61
+ entryId: string;
62
+ text: string;
63
+ call?: {
64
+ name: string;
65
+ arguments: unknown;
66
+ };
67
+ note?: string;
68
+ }): string;
69
+ export declare function planContextTrim(branch: SessionEntry[], afterId?: string): {
70
+ entries: SessionBoundaryDraft[];
71
+ references: string[];
72
+ archives: ArchiveRecord[];
73
+ savedChars: number;
74
+ automatic: string;
75
+ cooldownTurns: number;
76
+ superseded: number;
77
+ };
78
+ /** The plan's context edits followed by a trim control entry recording `cause`. */
79
+ export declare function trimEntries(plan: {
80
+ entries: SessionBoundaryDraft[];
81
+ references: string[];
82
+ archives: ArchiveRecord[];
83
+ }, cause: TrimCause): SessionBoundaryDraft[];
84
+ /**
85
+ * Estimated tokens a trim removes (net of markers) and tokens of the rebuilt tail:
86
+ * every projected message from the first edited target on, with markers in place.
87
+ */
88
+ export declare function trimTokens(branch: SessionEntry[], entries: SessionBoundaryDraft[], provider?: string, model?: string): {
89
+ savedTokens: number;
90
+ tailTokens: number;
91
+ };
92
+ /**
93
+ * Requests, counting the trimmed one, after which a warm-cache trim pays back its
94
+ * prefix rewrite: N* = ((w - r) * T) / (r * X), r = cacheRead/input, w = cacheWrite/input
95
+ * (1 when the catalog lists no write surcharge). 0 when cache reads are free; null when
96
+ * the price is unknown.
97
+ */
98
+ export declare function trimBreakEvenRequests(cost: Partial<ModelCostRates> | undefined, savedTokens: number, tailTokens: number): number | null;
99
+ export declare function planContextRewind(branch: SessionEntry[], sessionId: string, checkpointId: string, report: string): {
100
+ entries: SessionBoundaryDraft[];
101
+ removed: number;
102
+ };
103
+ /** Explicit, branch-local recovery only; never reveal assistant reasoning or arbitrary session entries. */
104
+ export declare function readContextReference(branch: SessionEntry[], sessionId: string, id: string): string;
105
+ export {};
106
+ //# sourceMappingURL=context-operations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-operations.d.ts","sourceRoot":"","sources":["../../src/app/context-operations.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,OAAO,EAC+C,KAAK,oBAAoB,EAAE,KAAK,YAAY,EACjG,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAY,MAAM,uBAAuB,CAAC;AAStE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAIvD,eAAO,MAAM,oBAAoB,0BAA0B,CAAC;AAC5D,eAAO,MAAM,mBAAmB,yBAAyB,CAAC;AAC1D,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,cAAc,KAAK,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AE,MAAM,EAAE,MAAM;;;EA6BhH;AAED,2GAA2G;AAC3G,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAYlG"}
@@ -0,0 +1,23 @@
1
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import type { CompactConfig } from "../types.ts";
3
+ import type { SmartCompactPolicySnapshot } from "./smart-compact-policy.ts";
4
+ import { type MemoryBackendReadiness } from "./memory-backend.ts";
5
+ import type { ModelFeasibility } from "./model-feasibility.ts";
6
+ export interface EffectiveRuntimeState {
7
+ running: boolean;
8
+ preparation: "idle" | "preparing" | "ready";
9
+ paused: boolean;
10
+ /** Host prompt-cache ledger lines for the current session, when attached. */
11
+ cacheLedger?: string[];
12
+ }
13
+ export interface EffectiveReadiness {
14
+ canCompact: boolean;
15
+ blockers: string[];
16
+ warnings: string[];
17
+ memory: MemoryBackendReadiness;
18
+ }
19
+ /** Read-only local checks. Memory is optional and never blocks compaction. */
20
+ export declare function describeReadiness(ctx: ExtensionContext, config: CompactConfig, runtime?: EffectiveRuntimeState, feasibility?: ModelFeasibility): Promise<EffectiveReadiness>;
21
+ /** Local evidence, not a connectivity/authentication probe; never acquire a lease or create a store. */
22
+ export declare function describeEffectiveState(ctx: ExtensionContext, config: CompactConfig, policy: SmartCompactPolicySnapshot, runtime?: EffectiveRuntimeState): Promise<string>;
23
+ //# sourceMappingURL=effective-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effective-state.d.ts","sourceRoot":"","sources":["../../src/app/effective-state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAOxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAQjD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAkC,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAClG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC;IAC5C,MAAM,EAAE,OAAO,CAAC;IAChB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AACD,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,sBAAsB,CAAC;CAChC;AAED,8EAA8E;AAC9E,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,qBAAqB,EAC/B,WAAW,CAAC,EAAE,gBAAgB,GAC7B,OAAO,CAAC,kBAAkB,CAAC,CAsC7B;AAaD,wGAAwG;AACxG,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,0BAA0B,EAClC,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,MAAM,CAAC,CA4FjB"}
@@ -1,7 +1,7 @@
1
1
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
- import type { ContextToolAvailability } from "./register-context-tools.ts";
2
+ import type { ContextToolExposure } from "./lazy-tools.ts";
3
3
  import type { SmartCompactPolicy } from "./smart-compact-policy.ts";
4
4
  import type { GlobalConfigPath } from "../utils/config.ts";
5
- /** Apply the small subset of global settings that own live host state. */
6
- export declare function applyGlobalSettingRuntime(path: GlobalConfigPath, ctx: ExtensionContext, policy: SmartCompactPolicy, contextTools: ContextToolAvailability): void;
5
+ /** Refresh each owner at most once after one atomic global-settings patch. */
6
+ export declare function applyGlobalSettingsRuntime(paths: readonly GlobalConfigPath[], ctx: ExtensionContext, policy: SmartCompactPolicy, contextTools: Pick<ContextToolExposure, "apply">): void;
7
7
  //# sourceMappingURL=global-settings-runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"global-settings-runtime.d.ts","sourceRoot":"","sources":["../../src/app/global-settings-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAQ3D,0EAA0E;AAC1E,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,gBAAgB,EACtB,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,kBAAkB,EAC1B,YAAY,EAAE,uBAAuB,GACpC,IAAI,CAGN"}
1
+ {"version":3,"file":"global-settings-runtime.d.ts","sourceRoot":"","sources":["../../src/app/global-settings-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAS3D,8EAA8E;AAC9E,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,SAAS,gBAAgB,EAAE,EAClC,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,kBAAkB,EAC1B,YAAY,EAAE,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC,GAC/C,IAAI,CAGN"}
@@ -0,0 +1,100 @@
1
+ import type { CompactConfig } from "../types.ts";
2
+ import { type HindsightRecallFact, type HindsightTarget } from "../infra/hindsight-client.ts";
3
+ import { type HindsightReceipt, type HindsightReceiptScope } from "../infra/hindsight-receipts.ts";
4
+ export declare const HINDSIGHT_SOURCE_TAG = "psc-source:smart-compact";
5
+ export type ConfiguredHindsightTargetResolution = {
6
+ enabled: true;
7
+ ok: true;
8
+ target: HindsightTarget;
9
+ } | {
10
+ enabled: true;
11
+ ok: false;
12
+ reason: string;
13
+ };
14
+ export type HindsightConfigResolution = {
15
+ enabled: false;
16
+ } | ConfiguredHindsightTargetResolution;
17
+ /** Resolve the configured target. The API key is read from the named env var only. */
18
+ export declare function resolveHindsightTarget(config: Pick<CompactConfig, "memoryBackend" | "hindsightBaseUrl" | "hindsightBankId" | "hindsightApiKeyEnv" | "hindsightTimeoutMs">, env?: Record<string, string | undefined>): HindsightConfigResolution;
19
+ /**
20
+ * Target for dispatching a hindsight memory ref, regardless of the currently
21
+ * active backend: a ref from an older save must reach the server that holds
22
+ * it instead of silently retargeting. The target still comes only from
23
+ * current configuration — never from the ref itself.
24
+ */
25
+ export declare function resolveHindsightRefTarget(config: Pick<CompactConfig, "memoryBackend" | "hindsightBaseUrl" | "hindsightBankId" | "hindsightApiKeyEnv" | "hindsightTimeoutMs">, env?: Record<string, string | undefined>): ConfiguredHindsightTargetResolution;
26
+ export declare function projectTag(projectId: string): string;
27
+ /** Stable remote document id for one explicit local memory identity. */
28
+ export declare function hindsightDocumentId(memoryId: string): string;
29
+ export declare function receiptScope(target: HindsightTarget, projectId: string): HindsightReceiptScope;
30
+ export interface HindsightMemoryInput {
31
+ projectId: string;
32
+ memoryId: string;
33
+ kind: string;
34
+ title: string;
35
+ content: string;
36
+ relatedPaths: string[];
37
+ }
38
+ /** Exact text sent to the server; shown verbatim in the confirmation. */
39
+ export declare function hindsightRetainContent(memory: HindsightMemoryInput): string;
40
+ export type RemoteSaveOutcome = {
41
+ state: "completed";
42
+ receipt: HindsightReceipt;
43
+ } | {
44
+ state: "accepted";
45
+ receipt: HindsightReceipt;
46
+ operationStatus: string;
47
+ } | {
48
+ state: "failed";
49
+ receipt?: HindsightReceipt;
50
+ reason: string;
51
+ } | {
52
+ state: "unknown";
53
+ receipt: HindsightReceipt;
54
+ reason: string;
55
+ };
56
+ /** Submit one confirmed memory. Never retried automatically beyond one request. */
57
+ export declare function saveHindsightMemory(target: HindsightTarget, memory: HindsightMemoryInput, signal?: AbortSignal): Promise<RemoteSaveOutcome>;
58
+ export type RemoteResolveOutcome = {
59
+ state: "deleted";
60
+ documentId: string;
61
+ memoryUnitsDeleted: number;
62
+ ledgerWarning?: string;
63
+ } | {
64
+ state: "not-found";
65
+ documentId: string;
66
+ ledgerWarning?: string;
67
+ } | {
68
+ state: "pending";
69
+ documentId: string;
70
+ operationIds: string[];
71
+ } | {
72
+ state: "failed";
73
+ documentId: string;
74
+ reason: string;
75
+ };
76
+ /**
77
+ * Delete the owned remote document for one memory. Refuses while a retain for
78
+ * it may still be extracting, so async completion cannot recreate the fact.
79
+ */
80
+ export declare function resolveHindsightMemory(target: HindsightTarget, projectId: string, memoryId: string, signal?: AbortSignal): Promise<RemoteResolveOutcome>;
81
+ /**
82
+ * Refresh a few open receipts for this scope (called from recall). Unknown
83
+ * receipts count as open — they can fill the ledger cap — so they share the
84
+ * same bounded refresh; a terminal server status frees them, and so does an
85
+ * operation the server has reported missing for NOT_FOUND_DRAIN_HOURS.
86
+ */
87
+ export declare function refreshPendingReceipts(target: HindsightTarget, projectId: string, signal?: AbortSignal): Promise<HindsightReceipt[]>;
88
+ export type RemoteRecallOutcome = {
89
+ state: "ok";
90
+ facts: HindsightRecallFact[];
91
+ } | {
92
+ state: "failed";
93
+ reason: string;
94
+ };
95
+ export declare function recallHindsightMemory(target: HindsightTarget, projectId: string, query: string, maxTokens: number, signal?: AbortSignal): Promise<RemoteRecallOutcome>;
96
+ /** Bounded untrusted-evidence rendering with provenance. */
97
+ export declare function formatHindsightFacts(target: HindsightTarget, projectId: string, facts: HindsightRecallFact[], maxChars?: number): string;
98
+ export declare function describeRemoteSave(outcome: RemoteSaveOutcome): string;
99
+ export declare function describeRemoteResolve(outcome: RemoteResolveOutcome): string;
100
+ //# sourceMappingURL=hindsight-memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hindsight-memory.d.ts","sourceRoot":"","sources":["../../src/app/hindsight-memory.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAIN,KAAK,mBAAmB,EACxB,KAAK,eAAe,EAKpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAY1B,MAAM,gCAAgC,CAAC;AAExC,eAAO,MAAM,oBAAoB,6BAA6B,CAAC;AAM/D,MAAM,MAAM,mCAAmC,GAC5C;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,GACpD;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhD,MAAM,MAAM,yBAAyB,GAClC;IAAE,OAAO,EAAE,KAAK,CAAA;CAAE,GAClB,mCAAmC,CAAC;AAEvC,sFAAsF;AACtF,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,IAAI,CACX,aAAa,EACX,eAAe,GACf,kBAAkB,GAClB,iBAAiB,GACjB,oBAAoB,GACpB,oBAAoB,CACtB,EACD,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACnD,yBAAyB,CAG3B;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACxC,MAAM,EAAE,IAAI,CACX,aAAa,EACX,eAAe,GACf,kBAAkB,GAClB,iBAAiB,GACjB,oBAAoB,GACpB,oBAAoB,CACtB,EACD,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAA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AE,MAAM,EACjB,KAAK,EAAE,mBAAmB,EAAE,EAC5B,QAAQ,SAAoB,GAC1B,MAAM,CAuCR;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAyBrE;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAwB3E"}
@@ -0,0 +1,68 @@
1
+ /** Session-local ledger of the host's own provider prompt-cache usage, built only from reported usage. */
2
+ import type { Usage } from "@earendil-works/pi-ai";
3
+ export type ContextEditKind = "trim" | "rewind" | "navigation" | "compaction";
4
+ export type RebuildCause = "continuity" | "idle-expiry" | "foreign";
5
+ /** Foreign rebuilds needed before the ledger asks the integrator to warn once. */
6
+ export declare const FOREIGN_REBUILD_WARN_COUNT = 3;
7
+ export interface LedgerEntry {
8
+ at: number;
9
+ provider?: string;
10
+ model?: string;
11
+ /** input + cacheRead + cacheWrite */
12
+ prompt: number;
13
+ /** input + cacheWrite */
14
+ uncached: number;
15
+ cacheRead: number;
16
+ /** Milliseconds since the previous observed request; absent for the first. */
17
+ gapMs?: number;
18
+ rebuild: boolean;
19
+ cause?: RebuildCause;
20
+ /** Most recent Continuity edit before a `continuity` rebuild. */
21
+ editKind?: ContextEditKind;
22
+ /** Set only on the rebuild that makes the foreign count reach FOREIGN_REBUILD_WARN_COUNT. */
23
+ warn?: true;
24
+ }
25
+ export interface TokenTally {
26
+ count: number;
27
+ uncached: number;
28
+ }
29
+ export interface LedgerSummary {
30
+ sessionId: string | null;
31
+ requests: number;
32
+ input: number;
33
+ cacheRead: number;
34
+ cacheWrite: number;
35
+ rebuilds: Record<RebuildCause, TokenTally>;
36
+ continuity: Record<ContextEditKind, TokenTally>;
37
+ /** Sums of `usage.cost` (Pi prices reported tokens with the model price table); `requests` counts entries that carried a cost. */
38
+ cost: {
39
+ requests: number;
40
+ total: number;
41
+ rebuildUncached: number;
42
+ };
43
+ }
44
+ export interface ObservedMessage {
45
+ usage?: Partial<Usage>;
46
+ provider?: string;
47
+ model?: string;
48
+ timestamp?: number;
49
+ }
50
+ export interface HostCacheLedger {
51
+ /** New or switched session: forget all state. */
52
+ reset(sessionId: string): void;
53
+ /** Session the ledger currently tracks; null before the first reset. */
54
+ sessionId(): string | null;
55
+ /** A Continuity edit reached the branch; attributes the next observed rebuild. */
56
+ noteContextEdit(kind: ContextEditKind): void;
57
+ /** Pi sent a `cache_warm` refresh at `at`; it keeps the live prefix alive like a request. */
58
+ noteCacheWarm(at: number): void;
59
+ /** Assistant message at message_end; null when it carries no usable usage. */
60
+ observe(message: ObservedMessage, at?: number): LedgerEntry | null;
61
+ summary(): LedgerSummary;
62
+ }
63
+ /** Lifetime of the prefix a request cached: 1 h when it reported 1h-retention writes, else 5 min. */
64
+ export declare const cacheLifetimeMs: (usage: Partial<Usage> | undefined) => number;
65
+ export declare function createHostCacheLedger(): HostCacheLedger;
66
+ /** 1–3 short Home lines; empty until the host reported usage for a request. */
67
+ export declare function formatCacheLedgerSummary(summary: LedgerSummary): string[];
68
+ //# sourceMappingURL=host-cache-ledger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-cache-ledger.d.ts","sourceRoot":"","sources":["../../src/app/host-cache-ledger.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAE1G,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,CAAC;AAC9E,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,aAAa,GAAG,SAAS,CAAC;AAEpE,kFAAkF;AAClF,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,yBAAyB;I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AAI,CAAC;IAC7C,6FAA6F;IAC7F,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,8EAA8E;IAC9E,OAAO,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;IACnE,OAAO,IAAI,aAAa,CAAC;CAC1B;AAMD,qGAAqG;AACrG,eAAO,MAAM,eAAe,UAAW,OAAO,CAAC,KAAK,CAAC,GAAG,SAAS,KAAG,MACN,CAAC;AAE/D,wBAAgB,qBAAqB,IAAI,eAAe,CAgFvD;AAKD,+EAA+E;AAC/E,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,EAAE,CAmBzE"}
@@ -0,0 +1,36 @@
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import type { CompactConfig } from "../types.ts";
3
+ declare const GROUPS: {
4
+ readonly navigation: readonly ["smart_navigation"];
5
+ readonly history: readonly ["smart_context"];
6
+ readonly memory: readonly ["smart_recall", "smart_save_memory"];
7
+ readonly compaction: readonly ["smart_compact"];
8
+ };
9
+ export type ContextToolGroup = keyof typeof GROUPS;
10
+ export interface ContextToolExposure {
11
+ /** Reconcile settings without changing which lazy groups were requested. */
12
+ apply(): void;
13
+ /** Forget lazy requests before the branch policy calls apply(). */
14
+ atBoundary(): void;
15
+ load(group: ContextToolGroup): string[];
16
+ /** Whether the agent can call the group now or load it through the visible loader. */
17
+ reachable(group: ContextToolGroup): boolean;
18
+ unload(group: ContextToolGroup): void;
19
+ summary(): string;
20
+ status(): {
21
+ mode: CompactConfig["toolLoading"];
22
+ groups: Array<{
23
+ group: ContextToolGroup;
24
+ available: boolean;
25
+ active: string[];
26
+ }>;
27
+ };
28
+ }
29
+ /** The sole owner of our tool visibility. Never scans memory or session files. */
30
+ export declare function createContextToolExposure(pi: Pick<ExtensionAPI, "getActiveTools" | "setActiveTools">, options: {
31
+ config?: () => CompactConfig;
32
+ compactionAccess: () => CompactConfig["agentToolAccess"];
33
+ }): ContextToolExposure;
34
+ export declare function registerContextToolLoader(pi: ExtensionAPI, exposure: ContextToolExposure): void;
35
+ export {};
36
+ //# sourceMappingURL=lazy-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazy-tools.d.ts","sourceRoot":"","sources":["../../src/app/lazy-tools.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,QAAA,MAAM,MAAM;aACX,UAAU,YAAG,kBAAkB;aAC/B,OAAO,YAAG,eAAe;aACzB,MAAM,YAAG,cAAc,EAAE,mBAAmB;aAC5C,UAAU,YAAG,eAAe;CACnB,CAAC;AACX,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,MAAM,CAAC;AAKnD,MAAM,WAAW,mBAAmB;IACnC,4EAA4E;IAC5E,KAAK,IAAI,IAAI,CAAC;IACd,mEAAmE;IACnE,UAAU,IAAI,IAAI,CAAC;IACnB,IAAI,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,EAAE,CAAC;IACxC,sFAAsF;IACtF,SAAS,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC;IAC5C,MAAM,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACtC,OAAO,IAAI,MAAM,CAAC;IAClB,MAAM,IAAI;QAAE,IAAI,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;QAAC,MAAM,EAAE,KAAK,CAAC;YAAE,KAAK,EAAE,gBAAgB,CAAC;YAAC,SAAS,EAAE,OAAO,CAAC;YAAC,MAAM,EAAE,MAAM,EAAE,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;CACnI;AAED,kFAAkF;AAClF,wBAAgB,yBAAyB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,EAAE,gBAAgB,GAAG,gBAAgB,CAAC,EAAE,OAAO,EAAE;IAC/G,MAAM,CAAC,EAAE,MAAM,aAAa,CAAC;IAC7B,gBAAgB,EAAE,MAAM,aAAa,CAAC,iBAAiB,CAAC,CAAC;CACzD,GAAG,mBAAmB,CAmGtB;AAED,wBAAgB,yBAAyB,CAAC,EAAE,EAAE,YAAY,EAAE,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CA4B/F"}
@@ -0,0 +1,58 @@
1
+ import type { CompactConfig, MemoryBackend } from "../types.ts";
2
+ import type { MemoryRef } from "../infra/memory-ref.ts";
3
+ /** Local context-graph operations run only for an exclusively selected local backend. */
4
+ export declare function localGraphOpsAllowed(config: Pick<CompactConfig, "memoryBackend" | "contextGraphEnabled">): boolean;
5
+ export interface MemoryBackendReadiness {
6
+ backend: MemoryBackend;
7
+ /** Selected backend only: its prerequisites are satisfiable without side effects. */
8
+ ready: boolean;
9
+ /**
10
+ * Human-readable evidence naming exactly what was checked. Model,
11
+ * credential and store checks are never claimed: presence-level checks
12
+ * only, and only for the selected backend.
13
+ */
14
+ reason: string;
15
+ /** Local context-graph read/write is permitted for this selection. */
16
+ localOpsAllowed: boolean;
17
+ }
18
+ /**
19
+ * Readonly readiness for the selected backend only. Never contacts a server,
20
+ * never reads a key beyond the named environment variable's presence, never
21
+ * creates or opens a store, and never probes an unselected backend (Mnemopi
22
+ * stays unprobed unless it is the selection). Server installation is never
23
+ * performed or implied: an existing URL, explicit bank and env key are
24
+ * required configuration.
25
+ */
26
+ export declare function describeMemoryBackendReadiness(config: Pick<CompactConfig, "memoryBackend" | "contextGraphEnabled" | "hindsightBaseUrl" | "hindsightBankId" | "hindsightApiKeyEnv" | "hindsightTimeoutMs">, env?: Record<string, string | undefined>): Promise<MemoryBackendReadiness>;
27
+ /**
28
+ * Refuse a ref that lives in an unselected store instead of operating it:
29
+ * the caller must switch the memory backend to the ref's own backend. Returns
30
+ * null when the ref matches the selected backend.
31
+ */
32
+ export declare function inactiveBackendRefusal(config: Pick<CompactConfig, "memoryBackend">, ref: MemoryRef): string | null;
33
+ export interface BunExecutable {
34
+ /** Absolute executable path, or "bun" so execFile's PATH search resolves it. */
35
+ executable: string;
36
+ source: "package" | "platform-package" | "path";
37
+ }
38
+ /**
39
+ * Resolve the executable for the Bun-only Mnemopi worker: the optional bun
40
+ * component installed beside the extension first (metadata + actual installed
41
+ * layout, with the platform @oven package as fallback), then a supported PATH
42
+ * Bun. Read-only filesystem checks only: no shell, no download, no
43
+ * self-install, no network.
44
+ */
45
+ export declare function resolveBunExecutable(parentUrl?: string): BunExecutable | null;
46
+ export declare function bunVersionSupported(version: string): boolean;
47
+ /**
48
+ * Presence/version evidence for the Mnemopi runtime: the optional
49
+ * @oh-my-pi/pi-mnemopi component, the worker file, and a usable Bun executable
50
+ * (the optional bun component first, PATH fallback). The engine is never
51
+ * loaded and no database is opened or created. `ready` means only these
52
+ * checks passed. Missing components name the install command.
53
+ */
54
+ export declare function describeMnemopiRuntime(parentUrl?: string): Promise<{
55
+ ready: boolean;
56
+ reason: string;
57
+ }>;
58
+ //# sourceMappingURL=memory-backend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-backend.d.ts","sourceRoot":"","sources":["../../src/app/memory-backend.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAIxD,yFAAyF;AACzF,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,eAAe,GAAG,qBAAqB,CAAC,GAClE,OAAO,CAET;AAED,MAAM,WAAW,sBAAsB;IACtC,OAAO,EAAE,aAAa,CAAC;IACvB,qFAAqF;IACrF,KAAK,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,eAAe,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,wBAAsB,8BAA8B,CACnD,MAAM,EAAE,IAAI,CACX,aAAa,EACX,eAAe,GACf,qBAAqB,GACrB,kBAAkB,GAClB,iBAAiB,GACjB,oBAAoB,GACpB,oBAAoB,CACtB,EACD,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACnD,OAAO,CAAC,sBAAsB,CAAC,CA2BjC;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,eAAe,CAAC,EAC5C,GAAG,EAAE,SAAS,GACZ,MAAM,GAAG,IAAI,CAgBf;AAED,MAAM,WAAW,aAAa;IAC7B,gFAAgF;IAChF,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,SAAS,GAAG,kBAAkB,GAAG,MAAM,CAAC;CAChD;AA0CD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,GAAE,MAAwB,GAAG,aAAa,GAAG,IAAI,CAoC9F;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAQ5D;AAyBD;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC3C,SAAS,GAAE,MAAwB,GACjC,OAAO,CAAC;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAmC7C"}
@@ -0,0 +1,13 @@
1
+ import type { CompactConfig } from "../types.ts";
2
+ import { type BunExecutable } from "./memory-backend.ts";
3
+ import { type MnemopiOutcome, type MnemopiRequest } from "./mnemopi-protocol.ts";
4
+ export declare function mnemopiTarget(config: Pick<CompactConfig, "mnemopiDataDir">, projectId: string): {
5
+ dbPath: string;
6
+ projectId: string;
7
+ };
8
+ /** The Bun-only optional engine never loads into stock Pi's Node process. */
9
+ export declare function runMnemopi(request: MnemopiRequest, signal?: AbortSignal, options?: {
10
+ bunExecutable?: BunExecutable | null;
11
+ }): Promise<MnemopiOutcome>;
12
+ export declare function formatMnemopiOutcome(outcome: MnemopiOutcome): string;
13
+ //# sourceMappingURL=mnemopi-memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mnemopi-memory.d.ts","sourceRoot":"","sources":["../../src/app/mnemopi-memory.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAKjD,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAE/B,wBAAgB,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,gBAAgB,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAMrI;AAED,6EAA6E;AAC7E,wBAAsB,UAAU,CAC9B,OAAO,EAAE,cAAc,EACvB,MAAM,CAAC,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,CAAA;CAAE,GACjD,OAAO,CAAC,cAAc,CAAC,CAkEzB;AAiBD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CA0BpE"}
@@ -0,0 +1,78 @@
1
+ import { Type, type Static } from "typebox";
2
+ export declare const MNEMOPI_READY = "psc-mnemopi-ready-v1";
3
+ export declare const MnemopiMetadataSchema: Type.TObject<{
4
+ projectId: Type.TString;
5
+ memoryId: Type.TString;
6
+ kind: Type.TString;
7
+ title: Type.TString;
8
+ relatedPaths: Type.TArray<Type.TString>;
9
+ }>;
10
+ export declare const MnemopiRequestSchema: Type.TUnion<[Type.TObject<{
11
+ dbPath: Type.TString;
12
+ projectId: Type.TString;
13
+ memoryId: Type.TString;
14
+ kind: Type.TString;
15
+ title: Type.TString;
16
+ content: Type.TString;
17
+ relatedPaths: Type.TArray<Type.TString>;
18
+ operation: Type.TLiteral<"save">;
19
+ }>, Type.TObject<{
20
+ dbPath: Type.TString;
21
+ projectId: Type.TString;
22
+ operation: Type.TLiteral<"resolve">;
23
+ memoryId: Type.TString;
24
+ }>, Type.TObject<{
25
+ dbPath: Type.TString;
26
+ projectId: Type.TString;
27
+ operation: Type.TLiteral<"inspect">;
28
+ memoryId: Type.TString;
29
+ }>, Type.TObject<{
30
+ dbPath: Type.TString;
31
+ projectId: Type.TString;
32
+ operation: Type.TLiteral<"recall">;
33
+ query: Type.TString;
34
+ limit: Type.TInteger;
35
+ kinds: Type.TOptional<Type.TArray<Type.TString>>;
36
+ }>]>;
37
+ export declare const MnemopiOutcomeSchema: Type.TUnion<[Type.TObject<{
38
+ state: Type.TLiteral<"saved">;
39
+ dbPath: Type.TString;
40
+ id: Type.TString;
41
+ memoryId: Type.TString;
42
+ existing: Type.TBoolean;
43
+ }>, Type.TObject<{
44
+ state: Type.TLiteral<"resolved">;
45
+ dbPath: Type.TString;
46
+ closed: Type.TBoolean;
47
+ }>, Type.TObject<{
48
+ state: Type.TLiteral<"inspected">;
49
+ dbPath: Type.TString;
50
+ fact: Type.TUnion<[Type.TObject<{
51
+ memoryId: Type.TString;
52
+ kind: Type.TString;
53
+ title: Type.TString;
54
+ content: Type.TString;
55
+ }>, Type.TNull]>;
56
+ }>, Type.TObject<{
57
+ state: Type.TLiteral<"recalled">;
58
+ dbPath: Type.TString;
59
+ facts: Type.TArray<Type.TObject<{
60
+ id: Type.TString;
61
+ memoryId: Type.TString;
62
+ kind: Type.TString;
63
+ title: Type.TString;
64
+ content: Type.TString;
65
+ score: Type.TNumber;
66
+ }>>;
67
+ }>, Type.TObject<{
68
+ state: Type.TLiteral<"failed">;
69
+ reason: Type.TString;
70
+ dbPath: Type.TOptional<Type.TString>;
71
+ }>, Type.TObject<{
72
+ state: Type.TLiteral<"unknown">;
73
+ reason: Type.TString;
74
+ dbPath: Type.TOptional<Type.TString>;
75
+ }>]>;
76
+ export type MnemopiRequest = Static<typeof MnemopiRequestSchema>;
77
+ export type MnemopiOutcome = Static<typeof MnemopiOutcomeSchema>;
78
+ //# sourceMappingURL=mnemopi-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mnemopi-protocol.d.ts","sourceRoot":"","sources":["../../src/app/mnemopi-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,aAAa,yBAAyB,CAAC;AAWpD,eAAO,MAAM,qBAAqB;;;;;;EAGhC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;IAoB/B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAiC/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACjE,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mnemopi-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mnemopi-worker.d.ts","sourceRoot":"","sources":["../../src/app/mnemopi-worker.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import type { Api, Model } from "@earendil-works/pi-ai";
2
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
3
+ import type { CompactConfig, CompactionMode } from "../types.ts";
4
+ export interface ModelEligibility {
5
+ selectable: boolean;
6
+ reason?: string;
7
+ }
8
+ export type ModelFeasibility = (model: Model<Api>, stage: "summary" | "segmentation" | "verification", mode?: CompactionMode) => ModelEligibility;
9
+ /**
10
+ * Read the branch/source log once, then lazily inspect the real planned requests.
11
+ * This is not a whole-conversation window test: hierarchical EESV sends batches.
12
+ * No auth resolution, metrics, cache writes, migrations, or memory-backend calls.
13
+ * Recreate after a branch/config/mode change. Generated follow-ups are unknowable
14
+ * here; trackedComplete revalidates every concrete request before dispatch.
15
+ */
16
+ export declare function createModelFeasibilityResolver(ctx: ExtensionContext, config: CompactConfig, requestedMode?: CompactionMode, steering?: {
17
+ focus?: string;
18
+ userNote?: string;
19
+ }): Promise<ModelFeasibility>;
20
+ //# sourceMappingURL=model-feasibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-feasibility.d.ts","sourceRoot":"","sources":["../../src/app/model-feasibility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAoE,MAAM,aAAa,CAAC;AAmBnI,MAAM,WAAW,gBAAgB;IAAG,UAAU,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;AAE1E,MAAM,MAAM,gBAAgB,GAAG,CAC9B,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,GAAG,cAAc,GAAG,cAAc,EAAE,IAAI,CAAC,EAAE,cAAc,KACxF,gBAAgB,CAAC;AAiBtB;;;;;;GAMG;AACH,wBAAsB,8BAA8B,CACnD,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,aAAa,EACrB,aAAa,GAAE,cAA4B,EAC3C,QAAQ,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAClD,OAAO,CAAC,gBAAgB,CAAC,CAwH3B"}