@infituit/opencode-acp 0.0.0-stage → 2.0.0-alpha.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 (194) hide show
  1. package/LICENSE +622 -0
  2. package/NOTICE +29 -0
  3. package/README.md +537 -2
  4. package/dist/index.d.ts +3 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +14433 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/lib/auth.d.ts +4 -0
  9. package/dist/lib/auth.d.ts.map +1 -0
  10. package/dist/lib/bili-proxy.d.ts +64 -0
  11. package/dist/lib/bili-proxy.d.ts.map +1 -0
  12. package/dist/lib/commands/compression-targets.d.ts +13 -0
  13. package/dist/lib/commands/compression-targets.d.ts.map +1 -0
  14. package/dist/lib/commands/context.d.ts +52 -0
  15. package/dist/lib/commands/context.d.ts.map +1 -0
  16. package/dist/lib/commands/export.d.ts +56 -0
  17. package/dist/lib/commands/export.d.ts.map +1 -0
  18. package/dist/lib/commands/index.d.ts +4 -0
  19. package/dist/lib/commands/index.d.ts.map +1 -0
  20. package/dist/lib/commands/stats.d.ts +19 -0
  21. package/dist/lib/commands/stats.d.ts.map +1 -0
  22. package/dist/lib/compress/decompress-logic.d.ts +62 -0
  23. package/dist/lib/compress/decompress-logic.d.ts.map +1 -0
  24. package/dist/lib/compress/decompress.d.ts +4 -0
  25. package/dist/lib/compress/decompress.d.ts.map +1 -0
  26. package/dist/lib/compress/hide-consumed.d.ts +15 -0
  27. package/dist/lib/compress/hide-consumed.d.ts.map +1 -0
  28. package/dist/lib/compress/hide-failed.d.ts +3 -0
  29. package/dist/lib/compress/hide-failed.d.ts.map +1 -0
  30. package/dist/lib/compress/image-archive.d.ts +43 -0
  31. package/dist/lib/compress/image-archive.d.ts.map +1 -0
  32. package/dist/lib/compress/index.d.ts +9 -0
  33. package/dist/lib/compress/index.d.ts.map +1 -0
  34. package/dist/lib/compress/keep-markers.d.ts +11 -0
  35. package/dist/lib/compress/keep-markers.d.ts.map +1 -0
  36. package/dist/lib/compress/parts.d.ts +4 -0
  37. package/dist/lib/compress/parts.d.ts.map +1 -0
  38. package/dist/lib/compress/pipeline.d.ts +141 -0
  39. package/dist/lib/compress/pipeline.d.ts.map +1 -0
  40. package/dist/lib/compress/protected-content.d.ts +12 -0
  41. package/dist/lib/compress/protected-content.d.ts.map +1 -0
  42. package/dist/lib/compress/quality-gate/algorithms/index.d.ts +3 -0
  43. package/dist/lib/compress/quality-gate/algorithms/index.d.ts.map +1 -0
  44. package/dist/lib/compress/quality-gate/evaluate.d.ts +21 -0
  45. package/dist/lib/compress/quality-gate/evaluate.d.ts.map +1 -0
  46. package/dist/lib/compress/quality-gate/index.d.ts +7 -0
  47. package/dist/lib/compress/quality-gate/index.d.ts.map +1 -0
  48. package/dist/lib/compress/quality-gate/registry.d.ts +6 -0
  49. package/dist/lib/compress/quality-gate/registry.d.ts.map +1 -0
  50. package/dist/lib/compress/quality-gate/rejection.d.ts +18 -0
  51. package/dist/lib/compress/quality-gate/rejection.d.ts.map +1 -0
  52. package/dist/lib/compress/quality-gate/types.d.ts +51 -0
  53. package/dist/lib/compress/quality-gate/types.d.ts.map +1 -0
  54. package/dist/lib/compress/range-utils.d.ts +28 -0
  55. package/dist/lib/compress/range-utils.d.ts.map +1 -0
  56. package/dist/lib/compress/range.d.ts +8 -0
  57. package/dist/lib/compress/range.d.ts.map +1 -0
  58. package/dist/lib/compress/recap.d.ts +4 -0
  59. package/dist/lib/compress/recap.d.ts.map +1 -0
  60. package/dist/lib/compress/search.d.ts +17 -0
  61. package/dist/lib/compress/search.d.ts.map +1 -0
  62. package/dist/lib/compress/smart-plan.d.ts +28 -0
  63. package/dist/lib/compress/smart-plan.d.ts.map +1 -0
  64. package/dist/lib/compress/state.d.ts +10 -0
  65. package/dist/lib/compress/state.d.ts.map +1 -0
  66. package/dist/lib/compress/status.d.ts +19 -0
  67. package/dist/lib/compress/status.d.ts.map +1 -0
  68. package/dist/lib/compress/timing.d.ts +17 -0
  69. package/dist/lib/compress/timing.d.ts.map +1 -0
  70. package/dist/lib/compress/types.d.ts +120 -0
  71. package/dist/lib/compress/types.d.ts.map +1 -0
  72. package/dist/lib/compress-permission.d.ts +6 -0
  73. package/dist/lib/compress-permission.d.ts.map +1 -0
  74. package/dist/lib/config-validation.d.ts +13 -0
  75. package/dist/lib/config-validation.d.ts.map +1 -0
  76. package/dist/lib/config.d.ts +248 -0
  77. package/dist/lib/config.d.ts.map +1 -0
  78. package/dist/lib/gc/merge.d.ts +17 -0
  79. package/dist/lib/gc/merge.d.ts.map +1 -0
  80. package/dist/lib/hooks.d.ts +41 -0
  81. package/dist/lib/hooks.d.ts.map +1 -0
  82. package/dist/lib/host-permissions.d.ts +31 -0
  83. package/dist/lib/host-permissions.d.ts.map +1 -0
  84. package/dist/lib/logger.d.ts +48 -0
  85. package/dist/lib/logger.d.ts.map +1 -0
  86. package/dist/lib/message-ids.d.ts +27 -0
  87. package/dist/lib/message-ids.d.ts.map +1 -0
  88. package/dist/lib/messages/enforce-budget.d.ts +65 -0
  89. package/dist/lib/messages/enforce-budget.d.ts.map +1 -0
  90. package/dist/lib/messages/filter/apply.d.ts +14 -0
  91. package/dist/lib/messages/filter/apply.d.ts.map +1 -0
  92. package/dist/lib/messages/filter/builtin/index.d.ts +2 -0
  93. package/dist/lib/messages/filter/builtin/index.d.ts.map +1 -0
  94. package/dist/lib/messages/filter/builtin/omo-context.d.ts +4 -0
  95. package/dist/lib/messages/filter/builtin/omo-context.d.ts.map +1 -0
  96. package/dist/lib/messages/filter/builtin/omo-mode-injection.d.ts +4 -0
  97. package/dist/lib/messages/filter/builtin/omo-mode-injection.d.ts.map +1 -0
  98. package/dist/lib/messages/filter/builtin/omo-system-reminder.d.ts +4 -0
  99. package/dist/lib/messages/filter/builtin/omo-system-reminder.d.ts.map +1 -0
  100. package/dist/lib/messages/filter/builtin/omo-task-directive.d.ts +4 -0
  101. package/dist/lib/messages/filter/builtin/omo-task-directive.d.ts.map +1 -0
  102. package/dist/lib/messages/filter/builtin/omo-todo-continuation.d.ts +4 -0
  103. package/dist/lib/messages/filter/builtin/omo-todo-continuation.d.ts.map +1 -0
  104. package/dist/lib/messages/filter/index.d.ts +6 -0
  105. package/dist/lib/messages/filter/index.d.ts.map +1 -0
  106. package/dist/lib/messages/filter/registry.d.ts +6 -0
  107. package/dist/lib/messages/filter/registry.d.ts.map +1 -0
  108. package/dist/lib/messages/filter/types.d.ts +95 -0
  109. package/dist/lib/messages/filter/types.d.ts.map +1 -0
  110. package/dist/lib/messages/index.d.ts +9 -0
  111. package/dist/lib/messages/index.d.ts.map +1 -0
  112. package/dist/lib/messages/inject/candidates.d.ts +30 -0
  113. package/dist/lib/messages/inject/candidates.d.ts.map +1 -0
  114. package/dist/lib/messages/inject/inject.d.ts +26 -0
  115. package/dist/lib/messages/inject/inject.d.ts.map +1 -0
  116. package/dist/lib/messages/inject/policy/index.d.ts +5 -0
  117. package/dist/lib/messages/inject/policy/index.d.ts.map +1 -0
  118. package/dist/lib/messages/inject/policy/registry.d.ts +8 -0
  119. package/dist/lib/messages/inject/policy/registry.d.ts.map +1 -0
  120. package/dist/lib/messages/inject/policy/types.d.ts +2 -0
  121. package/dist/lib/messages/inject/policy/types.d.ts.map +1 -0
  122. package/dist/lib/messages/inject/utils.d.ts +235 -0
  123. package/dist/lib/messages/inject/utils.d.ts.map +1 -0
  124. package/dist/lib/messages/priority.d.ts +13 -0
  125. package/dist/lib/messages/priority.d.ts.map +1 -0
  126. package/dist/lib/messages/prune.d.ts +5 -0
  127. package/dist/lib/messages/prune.d.ts.map +1 -0
  128. package/dist/lib/messages/query.d.ts +36 -0
  129. package/dist/lib/messages/query.d.ts.map +1 -0
  130. package/dist/lib/messages/reasoning-strip.d.ts +32 -0
  131. package/dist/lib/messages/reasoning-strip.d.ts.map +1 -0
  132. package/dist/lib/messages/shape.d.ts +5 -0
  133. package/dist/lib/messages/shape.d.ts.map +1 -0
  134. package/dist/lib/messages/sticky-truncation.d.ts +55 -0
  135. package/dist/lib/messages/sticky-truncation.d.ts.map +1 -0
  136. package/dist/lib/messages/sync.d.ts +4 -0
  137. package/dist/lib/messages/sync.d.ts.map +1 -0
  138. package/dist/lib/messages/truncate-tools.d.ts +12 -0
  139. package/dist/lib/messages/truncate-tools.d.ts.map +1 -0
  140. package/dist/lib/messages/utils.d.ts +30 -0
  141. package/dist/lib/messages/utils.d.ts.map +1 -0
  142. package/dist/lib/prompts/compress-range.d.ts +10 -0
  143. package/dist/lib/prompts/compress-range.d.ts.map +1 -0
  144. package/dist/lib/prompts/context-limit-nudge.d.ts +8 -0
  145. package/dist/lib/prompts/context-limit-nudge.d.ts.map +1 -0
  146. package/dist/lib/prompts/extensions/nudge.d.ts +16 -0
  147. package/dist/lib/prompts/extensions/nudge.d.ts.map +1 -0
  148. package/dist/lib/prompts/extensions/system.d.ts +4 -0
  149. package/dist/lib/prompts/extensions/system.d.ts.map +1 -0
  150. package/dist/lib/prompts/extensions/tool.d.ts +3 -0
  151. package/dist/lib/prompts/extensions/tool.d.ts.map +1 -0
  152. package/dist/lib/prompts/index.d.ts +4 -0
  153. package/dist/lib/prompts/index.d.ts.map +1 -0
  154. package/dist/lib/prompts/iteration-nudge.d.ts +7 -0
  155. package/dist/lib/prompts/iteration-nudge.d.ts.map +1 -0
  156. package/dist/lib/prompts/store.d.ts +25 -0
  157. package/dist/lib/prompts/store.d.ts.map +1 -0
  158. package/dist/lib/prompts/system.d.ts +11 -0
  159. package/dist/lib/prompts/system.d.ts.map +1 -0
  160. package/dist/lib/prompts/turn-nudge.d.ts +7 -0
  161. package/dist/lib/prompts/turn-nudge.d.ts.map +1 -0
  162. package/dist/lib/protected-patterns.d.ts +5 -0
  163. package/dist/lib/protected-patterns.d.ts.map +1 -0
  164. package/dist/lib/state/index.d.ts +6 -0
  165. package/dist/lib/state/index.d.ts.map +1 -0
  166. package/dist/lib/state/message-types.d.ts +90 -0
  167. package/dist/lib/state/message-types.d.ts.map +1 -0
  168. package/dist/lib/state/model-limits.d.ts +27 -0
  169. package/dist/lib/state/model-limits.d.ts.map +1 -0
  170. package/dist/lib/state/persistence.d.ts +93 -0
  171. package/dist/lib/state/persistence.d.ts.map +1 -0
  172. package/dist/lib/state/rebuild.d.ts +40 -0
  173. package/dist/lib/state/rebuild.d.ts.map +1 -0
  174. package/dist/lib/state/state.d.ts +36 -0
  175. package/dist/lib/state/state.d.ts.map +1 -0
  176. package/dist/lib/state/tool-cache.d.ts +13 -0
  177. package/dist/lib/state/tool-cache.d.ts.map +1 -0
  178. package/dist/lib/state/types.d.ts +221 -0
  179. package/dist/lib/state/types.d.ts.map +1 -0
  180. package/dist/lib/state/utils.d.ts +57 -0
  181. package/dist/lib/state/utils.d.ts.map +1 -0
  182. package/dist/lib/token-utils.d.ts +42 -0
  183. package/dist/lib/token-utils.d.ts.map +1 -0
  184. package/dist/lib/ui/notification.d.ts +13 -0
  185. package/dist/lib/ui/notification.d.ts.map +1 -0
  186. package/dist/lib/ui/utils.d.ts +6 -0
  187. package/dist/lib/ui/utils.d.ts.map +1 -0
  188. package/dist/lib/update.d.ts +24 -0
  189. package/dist/lib/update.d.ts.map +1 -0
  190. package/dist/lib/v2/messages.d.ts +7 -0
  191. package/dist/lib/v2/messages.d.ts.map +1 -0
  192. package/dist/lib/v2/plugin.d.ts +3 -0
  193. package/dist/lib/v2/plugin.d.ts.map +1 -0
  194. package/package.json +76 -5
@@ -0,0 +1,4 @@
1
+ export declare function isSecureMode(): boolean;
2
+ export declare function getAuthorizationHeader(): string | undefined;
3
+ export declare function configureClientAuth(client: any): any;
4
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../lib/auth.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,IAAI,OAAO,CAEtC;AAED,wBAAgB,sBAAsB,IAAI,MAAM,GAAG,SAAS,CAQ3D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,CAsBpD"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Billion-context (`bili`) proxy detection in opencode provider config.
3
+ *
4
+ * Manual proxy mode (`bili start` + a provider whose baseURL is pointed at
5
+ * the proxy) does NOT set `BILLION_CONTEXT_PROXY` — that env var is only set
6
+ * by the `bili <client>` launcher. The `/bili/` path prefix in a provider
7
+ * baseURL is the documented zero-config self-detection signal (billion-context
8
+ * configuration reference): `http://<proxy-host>:<port>/bili/<upstream-url>`.
9
+ *
10
+ * When a provider routes through the proxy, the proxy handles context
11
+ * compression itself, so ACP must disable itself (same behavior as the
12
+ * `BILLION_CONTEXT_PROXY` env-var guard in index.ts).
13
+ */
14
+ export declare const BILI_PROXY_MARKER = "/bili/";
15
+ export interface BiliProxyMatch {
16
+ provider: string;
17
+ baseURL: string;
18
+ }
19
+ /**
20
+ * Scan opencode's provider config for every provider whose baseURL routes
21
+ * through the bili proxy (contains the `/bili/` path prefix).
22
+ *
23
+ * Pure function — safe to unit test. Returns `[]` for null/undefined/non-object
24
+ * input and for providers without a string baseURL.
25
+ */
26
+ export declare function findBiliProxyProviders(provider: unknown): BiliProxyMatch[];
27
+ /**
28
+ * [FIX #405] Process-env ownership markers left by billion-context.
29
+ *
30
+ * Two owner modes are invisible to the provider-config signal above:
31
+ *
32
+ * - Launcher mode (`bili <client>`): sets `BILLION_CONTEXT_PROXY` for the
33
+ * launched child process. ACP's setup-time sample catches it only if the
34
+ * variable already exists when the plugin factory runs — re-sampling env at
35
+ * action time removes that timing assumption entirely.
36
+ *
37
+ * - Native mode (billion-context opencode-native plugin, #820/#824): the
38
+ * plugin replaces model-API requests at `http.request` time, so the
39
+ * configured provider baseURL never contains `/bili/`, and
40
+ * `BILLION_CONTEXT_PROXY` is written only after the async proxy bootstrap.
41
+ * The native entry marks ownership synchronously at module evaluation
42
+ * (`markNativeHost()`, first-writer-wins) — but that evaluation can still
43
+ * land AFTER ACP's setup sampled env, depending on plugin load order.
44
+ *
45
+ * Consumers must therefore sample env at ACTION time (hook invocations,
46
+ * config runs, tool calls) and never trust a startup snapshot.
47
+ */
48
+ export declare const BILI_PROXY_ENV_VAR = "BILLION_CONTEXT_PROXY";
49
+ export declare const BILI_NATIVE_ENV_VAR = "BILLION_CONTEXT_NATIVE";
50
+ export type BiliEnvYield = "launcher" | "native";
51
+ /**
52
+ * Detect a billion-context ownership marker in the given environment
53
+ * (defaults to `process.env`). Pure — safe to unit test.
54
+ *
55
+ * Returns `"launcher"` when `BILLION_CONTEXT_PROXY` is set (takes precedence —
56
+ * native bootstrap refuses to run while it is set, so both cannot normally
57
+ * coexist), `"native"` when only `BILLION_CONTEXT_NATIVE` is set, else `null`.
58
+ */
59
+ export declare function detectBiliEnvYield(env?: Record<string, string | undefined>): BiliEnvYield | null;
60
+ /** Human-readable ownership source for error messages thrown by tool gates. */
61
+ export declare function describeBiliEnvYield(source: BiliEnvYield): string;
62
+ /** Console announcement text per ownership source (callers log once each). */
63
+ export declare function biliYieldLogMessage(source: BiliEnvYield): string;
64
+ //# sourceMappingURL=bili-proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bili-proxy.d.ts","sourceRoot":"","sources":["../../lib/bili-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,iBAAiB,WAAW,CAAA;AAEzC,MAAM,WAAW,cAAc;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAClB;AAqBD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,OAAO,GAAG,cAAc,EAAE,CAU1E;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,kBAAkB,0BAA0B,CAAA;AACzD,eAAO,MAAM,mBAAmB,2BAA2B,CAAA;AAE3D,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAA;AAEhD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAC9B,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACtD,YAAY,GAAG,IAAI,CAIrB;AAED,+EAA+E;AAC/E,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAIjE;AAED,8EAA8E;AAC9E,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAIhE"}
@@ -0,0 +1,13 @@
1
+ import type { CompressionBlock, PruneMessagesState } from "../state";
2
+ export interface CompressionTarget {
3
+ displayId: number;
4
+ runId: number;
5
+ topic: string;
6
+ compressedTokens: number;
7
+ durationMs: number;
8
+ grouped: boolean;
9
+ blocks: CompressionBlock[];
10
+ }
11
+ export declare function getActiveCompressionTargets(messagesState: PruneMessagesState): CompressionTarget[];
12
+ export declare function resolveCompressionTarget(messagesState: PruneMessagesState, blockId: number): CompressionTarget | null;
13
+ //# sourceMappingURL=compression-targets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compression-targets.d.ts","sourceRoot":"","sources":["../../../lib/commands/compression-targets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAEpE,MAAM,WAAW,iBAAiB;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,gBAAgB,EAAE,CAAA;CAC7B;AA8DD,wBAAgB,2BAA2B,CACvC,aAAa,EAAE,kBAAkB,GAClC,iBAAiB,EAAE,CAMrB;AAED,wBAAgB,wBAAwB,CACpC,aAAa,EAAE,kBAAkB,EACjC,OAAO,EAAE,MAAM,GAChB,iBAAiB,GAAG,IAAI,CAkB1B"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * ACP Context Command
3
+ * Shows a visual breakdown of token usage in the current session.
4
+ *
5
+ * TOKEN CALCULATION STRATEGY
6
+ * ==========================
7
+ * We minimize tokenizer estimation by leveraging API-reported values wherever possible.
8
+ *
9
+ * WHAT WE GET FROM THE API (exact):
10
+ * - tokens.input : Input tokens for each assistant response
11
+ * - tokens.output : Output tokens generated (includes text + tool calls)
12
+ * - tokens.reasoning: Reasoning tokens used
13
+ * - tokens.cache : Cache read/write tokens
14
+ *
15
+ * HOW WE CALCULATE EACH CATEGORY:
16
+ *
17
+ * SYSTEM = firstAssistant.input + cache.read + cache.write - tokenizer(firstUserMessage)
18
+ * The first response's total input (input + cache.read + cache.write)
19
+ * contains system + first user message. On the first request of a
20
+ * session, the system prompt appears in cache.write (cache creation),
21
+ * not cache.read.
22
+ *
23
+ * TOOLS = tokenizer(toolInputs + toolOutputs) - prunedTokens
24
+ * We must tokenize tools anyway for pruning decisions.
25
+ *
26
+ * USER = tokenizer(all user messages)
27
+ * User messages are typically small, so estimation is acceptable.
28
+ *
29
+ * ASSISTANT = total - system - user - tools
30
+ * Calculated as residual. This absorbs:
31
+ * - Assistant text output tokens
32
+ * - Reasoning tokens (if persisted by the model)
33
+ * - Any estimation errors
34
+ *
35
+ * TOTAL = input + output + reasoning + cache.read + cache.write
36
+ * Matches opencode's UI display.
37
+ *
38
+ * WHY ASSISTANT IS THE RESIDUAL:
39
+ * If reasoning tokens persist in context (model-dependent), they semantically
40
+ * belong with "Assistant" since reasoning IS assistant-generated content.
41
+ */
42
+ import type { Logger } from "../logger";
43
+ import type { SessionState, WithParts } from "../state";
44
+ export interface ContextCommandContext {
45
+ client: any;
46
+ state: SessionState;
47
+ logger: Logger;
48
+ sessionId: string;
49
+ messages: WithParts[];
50
+ }
51
+ export declare function handleContextCommand(ctx: ContextCommandContext): Promise<void>;
52
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../lib/commands/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAQvD,MAAM,WAAW,qBAAqB;IAClC,MAAM,EAAE,GAAG,CAAA;IACX,KAAK,EAAE,YAAY,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,SAAS,EAAE,CAAA;CACxB;AAqOD,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CASpF"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * /acp export command — user-initiated export of active compression-block
3
+ * summaries to a markdown file.
4
+ *
5
+ * - Exports ACTIVE blocks only. Consumed/inactive blocks are already
6
+ * distilled into the T2/T3 blocks that superseded them.
7
+ * - Default tier selection = ALL active tiers (T1+T2+T3). A session may have
8
+ * only T1 blocks; defaulting to T2+T3 (as initially proposed in #40) would
9
+ * export nothing for those sessions. Users who want only distilled output
10
+ * can pass `--tier t2,t3`.
11
+ * - Default output path = {cwd}/.opencode/acp-export-{shortSessionId}.md.
12
+ * - `--output -` streams the markdown back to chat instead of writing a file.
13
+ * - Zero new dependencies — pure fs/promises I/O.
14
+ */
15
+ import type { Logger } from "../logger";
16
+ import type { PluginConfig } from "../config";
17
+ import type { CompressionBlock, CompressionTier, SessionState, WithParts } from "../state/types";
18
+ export interface ExportCommandContext {
19
+ client: any;
20
+ state: SessionState;
21
+ config: PluginConfig;
22
+ logger: Logger;
23
+ sessionId: string;
24
+ messages: WithParts[];
25
+ workingDirectory: string;
26
+ }
27
+ export interface ExportOptions {
28
+ /** Resolved output path. `"-"` means stream to chat (stdout equivalent). */
29
+ outputPath: string;
30
+ /** Which tiers to include. Empty set = include all. */
31
+ tiers: Set<CompressionTier>;
32
+ includeMetadata: boolean;
33
+ append: boolean;
34
+ }
35
+ /** @internal exported for tests */
36
+ export declare function parseExportArgs(rawArgs: string): ExportOptions;
37
+ /** @internal exported for tests */
38
+ export declare function parseTiers(raw: string): Set<CompressionTier>;
39
+ /** @internal exported for tests */
40
+ export declare function resolveDefaultOutputPath(sessionId: string, cwd: string): string;
41
+ /**
42
+ * Render the export markdown. Pure function — no I/O. Exported for testing.
43
+ */
44
+ export declare function renderExportMarkdown(params: {
45
+ sessionId: string;
46
+ generatedAt: Date;
47
+ blocks: CompressionBlock[];
48
+ tiers: Set<CompressionTier>;
49
+ includeMetadata: boolean;
50
+ }): string;
51
+ /**
52
+ * Main handler invoked by the command hook.
53
+ * @param args raw argument string following `/acp export` (may be empty).
54
+ */
55
+ export declare function handleExportCommand(ctx: ExportCommandContext, args: string): Promise<void>;
56
+ //# sourceMappingURL=export.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../../lib/commands/export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,KAAK,EACR,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,SAAS,EACZ,MAAM,gBAAgB,CAAA;AAWvB,MAAM,WAAW,oBAAoB;IACjC,MAAM,EAAE,GAAG,CAAA;IACX,KAAK,EAAE,YAAY,CAAA;IACnB,MAAM,EAAE,YAAY,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,SAAS,EAAE,CAAA;IACrB,gBAAgB,EAAE,MAAM,CAAA;CAC3B;AAED,MAAM,WAAW,aAAa;IAC1B,4EAA4E;IAC5E,UAAU,EAAE,MAAM,CAAA;IAClB,uDAAuD;IACvD,KAAK,EAAE,GAAG,CAAC,eAAe,CAAC,CAAA;IAC3B,eAAe,EAAE,OAAO,CAAA;IACxB,MAAM,EAAE,OAAO,CAAA;CAClB;AAED,mCAAmC;AACnC,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAuE9D;AAkBD,mCAAmC;AACnC,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC,eAAe,CAAC,CAwB5D;AAED,mCAAmC;AACnC,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAG/E;AAsDD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IACzC,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,IAAI,CAAA;IACjB,MAAM,EAAE,gBAAgB,EAAE,CAAA;IAC1B,KAAK,EAAE,GAAG,CAAC,eAAe,CAAC,CAAA;IAC3B,eAAe,EAAE,OAAO,CAAA;CAC3B,GAAG,MAAM,CA0ET;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACrC,GAAG,EAAE,oBAAoB,EACzB,IAAI,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAyEf"}
@@ -0,0 +1,4 @@
1
+ export { handleContextCommand } from "./context";
2
+ export { handleStatsCommand } from "./stats";
3
+ export type { StatsCommandContext } from "./stats";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAC5C,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA"}
@@ -0,0 +1,19 @@
1
+ import type { Logger } from "../logger";
2
+ import type { PluginConfig } from "../config";
3
+ import type { SessionState, WithParts } from "../state";
4
+ export interface StatsCommandContext {
5
+ client: any;
6
+ state: SessionState;
7
+ config: PluginConfig;
8
+ logger: Logger;
9
+ sessionId: string;
10
+ messages: WithParts[];
11
+ userInfo?: {
12
+ providerId?: string;
13
+ modelId?: string;
14
+ agent?: string;
15
+ variant?: string;
16
+ };
17
+ }
18
+ export declare function handleStatsCommand(ctx: StatsCommandContext): Promise<void>;
19
+ //# sourceMappingURL=stats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../lib/commands/stats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAIvD,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,GAAG,CAAA;IACX,KAAK,EAAE,YAAY,CAAA;IACnB,MAAM,EAAE,YAAY,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,SAAS,EAAE,CAAA;IACrB,QAAQ,CAAC,EAAE;QACP,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,OAAO,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;CACJ;AAED,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBhF"}
@@ -0,0 +1,62 @@
1
+ import type { CompressionBlock, PruneMessagesState, WithParts } from "../state";
2
+ import type { CompressionTarget } from "../commands/compression-targets";
3
+ export declare function parseBlockIdArg(arg: string): number | null;
4
+ export type DecompressMode = "block" | "range";
5
+ export declare function resolveDecompressMode(args: Record<string, unknown>): {
6
+ ok: true;
7
+ mode: DecompressMode;
8
+ } | {
9
+ ok: false;
10
+ error: string;
11
+ };
12
+ export declare function findActiveBlocksOverlappingMessages(messagesState: PruneMessagesState, messageIds: Set<string>): CompressionBlock[];
13
+ export declare function findActiveParentBlockId(messagesState: PruneMessagesState, block: CompressionBlock): number | null;
14
+ export declare function findActiveAncestorBlockId(messagesState: PruneMessagesState, target: CompressionTarget): number | null;
15
+ export declare function snapshotActiveMessages(messagesState: PruneMessagesState): Map<string, number>;
16
+ export declare function deactivateCompressionTarget(messagesState: PruneMessagesState, target: CompressionTarget, options?: {
17
+ full?: boolean;
18
+ }): void;
19
+ export interface RestoredMessagesResult {
20
+ restoredMessageCount: number;
21
+ restoredTokens: number;
22
+ }
23
+ export declare function computeRestoredMessages(messagesState: PruneMessagesState, activeMessagesBefore: Map<string, number>): RestoredMessagesResult;
24
+ export interface DecompressAvailabilityResult {
25
+ /** Message IDs whose visibility this decompression would restore (membership-wise). */
26
+ requiredMessageIds: string[];
27
+ /** Subset of requiredMessageIds present in the fetched host history. */
28
+ availableMessageIds: string[];
29
+ /** Subset of requiredMessageIds absent from the fetched host history.
30
+ * Non-empty ⇒ committing would claim restored content that does not exist. */
31
+ missingMessageIds: string[];
32
+ }
33
+ /**
34
+ * Compute the message IDs whose visibility changes if `targets` are deactivated.
35
+ *
36
+ * A message becomes visible iff every block currently covering it belongs to the
37
+ * deactivation set AND (one-tier only) it is not re-covered by a consumed block
38
+ * that syncCompressionBlocks will reactivate. One-tier decompression leaves
39
+ * non-user-deactivated consumed blocks alive, so their covered messages stay
40
+ * hidden and are not required sources; full decompression deep-deactivates them,
41
+ * so everything under the targets must be present in history.
42
+ *
43
+ * The result is conservative by design: over-requiring an ID can only cause a
44
+ * safe-direction abort, never a false "restored" claim.
45
+ */
46
+ export declare function collectRequiredDecompressMessageIds(messagesState: PruneMessagesState, targets: CompressionTarget[], options?: {
47
+ full?: boolean;
48
+ }): string[];
49
+ /**
50
+ * [Issue #446] Verify that every source message a decompression would restore is
51
+ * actually present in the fetched host history. Membership transitions alone prove
52
+ * nothing about content: if the host removed the originals (native compaction,
53
+ * external deletion), deactivating the target still reports "Restored N" while
54
+ * nothing returns to context, stats are decremented by phantom tokens, and the
55
+ * terminal user-deactivation discards the summary coverage.
56
+ */
57
+ export declare function checkDecompressSourceAvailability(messagesState: PruneMessagesState, targets: CompressionTarget[], options: {
58
+ full?: boolean;
59
+ }, presentInHistory: Set<string>): DecompressAvailabilityResult;
60
+ export declare function computeReactivatedBlockIds(messagesState: PruneMessagesState, activeBlockIdsBefore: Set<number>): number[];
61
+ export declare function buildRestoredContentPreview(messages: WithParts[], activeMessagesBefore: Map<string, number>, messagesState: PruneMessagesState): string;
62
+ //# sourceMappingURL=decompress-logic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decompress-logic.d.ts","sourceRoot":"","sources":["../../../lib/compress/decompress-logic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAG/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAExE,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAa1D;AAED,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,OAAO,CAAA;AAE9C,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7D;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,cAAc,CAAA;CAAE,GAClC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAYjC;AAED,wBAAgB,mCAAmC,CAC/C,aAAa,EAAE,kBAAkB,EACjC,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,GACxB,gBAAgB,EAAE,CAoBpB;AAED,wBAAgB,uBAAuB,CACnC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EAAE,GAAG,CAAC,MAAM,CAAC,GAC9B,4BAA4B,CAY9B;AAED,wBAAgB,0BAA0B,CACtC,aAAa,EAAE,kBAAkB,EACjC,oBAAoB,EAAE,GAAG,CAAC,MAAM,CAAC,GAClC,MAAM,EAAE,CAIV;AAKD,wBAAgB,2BAA2B,CACvC,QAAQ,EAAE,SAAS,EAAE,EACrB,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACzC,aAAa,EAAE,kBAAkB,GAClC,MAAM,CAoCR"}
@@ -0,0 +1,4 @@
1
+ import type { Info as V2ToolInfo } from "@opencode/plugin/promise/tool";
2
+ import { type ToolFactoryContext } from "./types";
3
+ export declare function createDecompressTool(factoryCtx: ToolFactoryContext): V2ToolInfo;
4
+ //# sourceMappingURL=decompress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decompress.d.ts","sourceRoot":"","sources":["../../../lib/compress/decompress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,IAAI,IAAI,UAAU,EAErB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAoB,KAAK,kBAAkB,EAAsB,MAAM,SAAS,CAAA;AAmSvF,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,kBAAkB,GAAG,UAAU,CA0M/E"}
@@ -0,0 +1,15 @@
1
+ import type { SessionState, WithParts } from "../state";
2
+ /**
3
+ * Hide compress tool calls whose blocks have all been consumed by a higher-tier
4
+ * distillation, and for batched calls where only some sibling blocks are
5
+ * consumed, rewrite the surviving tool part to carry only the still-live
6
+ * entries' summaries.
7
+ *
8
+ * Decided per-block, not per-callID: a single batched `compress` call (multiple
9
+ * `content[]` entries) creates multiple blocks sharing one `compressCallId`.
10
+ * Keying on the callId (1:N) lets one live sibling rescue consumed batch-mates,
11
+ * permanently leaking their summary text — unreclaimable because `compress` is
12
+ * in the default protected-tools list. See upstream issue #288.
13
+ */
14
+ export declare function hideConsumedCompressCalls(state: SessionState, messages: WithParts[]): number;
15
+ //# sourceMappingURL=hide-consumed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hide-consumed.d.ts","sourceRoot":"","sources":["../../../lib/compress/hide-consumed.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAoB,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAgDzE;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,MAAM,CA8F5F"}
@@ -0,0 +1,3 @@
1
+ import type { WithParts } from "../state";
2
+ export declare function hideFailedCompressCalls(messages: WithParts[]): number;
3
+ //# sourceMappingURL=hide-failed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hide-failed.d.ts","sourceRoot":"","sources":["../../../lib/compress/hide-failed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAUzC,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,MAAM,CA+CrE"}
@@ -0,0 +1,43 @@
1
+ import type { CompressImagesConfig } from "../config";
2
+ import type { Logger } from "../logger";
3
+ import type { SessionState, WithParts } from "../state/types";
4
+ import type { SelectionResolution } from "./types";
5
+ /**
6
+ * [Issue #478] Parse an inline data-URL image attachment. Returns undefined for
7
+ * non-data URLs (file paths, http(s) links) which v1 does not archive.
8
+ */
9
+ export declare function parseImageDataUrl(url: string): {
10
+ mediaType: string;
11
+ base64: string;
12
+ } | undefined;
13
+ export declare function extForMediaType(mediaType: string): string | undefined;
14
+ /**
15
+ * [Issue #478] Map a session ID to a safe archive directory name. The salt
16
+ * (sha8 of the raw ID) is appended whenever sanitization changed the string,
17
+ * so two distinct session IDs can never collide on one directory even after
18
+ * aggressive character replacement.
19
+ */
20
+ export declare function archiveDirName(sessionId: string): string;
21
+ /**
22
+ * [Issue #478] Spill inline image attachments of known messages to disk so that
23
+ * later compression folds keep a re-readable file pointer instead of silently
24
+ * losing the pixels. Metadata-only index in `state.imageArchive` (keyed by RAW
25
+ * message ID — stable across compaction ref re-issue); pixels never enter state.
26
+ * Never throws: any I/O failure downgrades to a warn log and skips the entry.
27
+ * Returns the number of newly archived images.
28
+ */
29
+ export declare function archiveSessionImages(state: SessionState, messages: WithParts[], images: CompressImagesConfig, logger: Logger): number;
30
+ /**
31
+ * [Issue #478] Best-effort TTL sweep of the session's archived image files,
32
+ * run at most once per process per session (transient `imagePruneDone` flag).
33
+ * Files older than `ttlDays` are deleted along with their index entries; the
34
+ * now-empty directory is removed too. Never throws.
35
+ */
36
+ export declare function pruneImageArchive(state: SessionState, images: CompressImagesConfig, logger: Logger): void;
37
+ /**
38
+ * [Issue #478] Append a pointer appendix to a folded block summary listing every
39
+ * archived image whose source message falls inside the compressed range, so the
40
+ * model can re-read the pixels with its own file tools after folding.
41
+ */
42
+ export declare function appendArchivedImagePointers(summary: string, selection: SelectionResolution, state: SessionState, enabled: boolean): string;
43
+ //# sourceMappingURL=image-archive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-archive.d.ts","sourceRoot":"","sources":["../../../lib/compress/image-archive.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAEvC,OAAO,KAAK,EAAsB,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAuBlD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GACvC;IACI,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;CACjB,GACD,SAAS,CAKd;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAErE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAMxD;AAMD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAChC,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,SAAS,EAAE,EACrB,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,MAAM,GACf,MAAM,CAgER;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC7B,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,MAAM,GACf,IAAI,CA6CN;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACvC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,mBAAmB,EAC9B,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,OAAO,GACjB,MAAM,CAkBR"}
@@ -0,0 +1,9 @@
1
+ export type { ToolContext } from "./types";
2
+ export { createCompressRangeTool } from "./range";
3
+ export { createDecompressTool } from "./decompress";
4
+ export { createSearchContextToolV2 } from "./search";
5
+ export { createAcpStatusToolV2 } from "./status";
6
+ export { createAcpContextRecapToolV2 } from "./recap";
7
+ export { hideConsumedCompressCalls } from "./hide-consumed";
8
+ export { hideFailedCompressCalls } from "./hide-failed";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/compress/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAA;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAA;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA"}
@@ -0,0 +1,11 @@
1
+ import type { WithParts } from "../state";
2
+ import type { SessionState } from "../state";
3
+ import type { PluginConfig } from "../config";
4
+ export interface KeepMarkerResult {
5
+ summary: string;
6
+ expandedCount: number;
7
+ refCount: number;
8
+ unresolvedRefs: string[];
9
+ }
10
+ export declare function resolveKeepMarkers(summary: string, messages: WithParts[], state: SessionState, config: PluginConfig): KeepMarkerResult;
11
+ //# sourceMappingURL=keep-markers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keep-markers.d.ts","sourceRoot":"","sources":["../../../lib/compress/keep-markers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAM7C,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,MAAM,EAAE,CAAA;CAC3B;AAED,wBAAgB,kBAAkB,CAC9B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,SAAS,EAAE,EACrB,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,YAAY,GACrB,gBAAgB,CAmClB"}
@@ -0,0 +1,4 @@
1
+ export declare function hasMeaningfulContent(parts: {
2
+ type: string;
3
+ }[]): boolean;
4
+ //# sourceMappingURL=parts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../../../lib/compress/parts.ts"],"names":[],"mappings":"AAEA,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,GAAG,OAAO,CAEvE"}
@@ -0,0 +1,141 @@
1
+ import type { PruneMessagesState, SessionState, SessionStats, WithParts } from "../state";
2
+ import type { ToolContext } from "./types";
3
+ import type { SearchContext } from "./types";
4
+ export interface CompressionSnapshot {
5
+ messages: PruneMessagesState;
6
+ stats: SessionStats;
7
+ }
8
+ export declare function snapshotCompressionState(state: SessionState): CompressionSnapshot;
9
+ export declare function restoreCompressionState(state: SessionState, snapshot: CompressionSnapshot): void;
10
+ interface RunContext {
11
+ sessionID: string;
12
+ }
13
+ export interface NotificationEntry {
14
+ blockId: number;
15
+ runId: number;
16
+ summary: string;
17
+ summaryTokens: number;
18
+ }
19
+ export interface PreparedSession {
20
+ rawMessages: WithParts[];
21
+ searchContext: SearchContext;
22
+ }
23
+ export declare function prepareSession(ctx: ToolContext, toolCtx: RunContext, title: string): Promise<PreparedSession>;
24
+ export declare function finalizeSession(ctx: ToolContext, toolCtx: RunContext, rawMessages: WithParts[], entries: NotificationEntry[], batchTopic: string | undefined): Promise<void>;
25
+ /**
26
+ * Find the last visible (non-synthetic, non-pruned) message ID.
27
+ * Returns null if no visible message exists.
28
+ */
29
+ export declare function getLastVisibleMessageId(rawMessages: WithParts[], state: SessionState): string | null;
30
+ /**
31
+ * Per-phantom diagnostics used in error / skip-notice messages (issue #290).
32
+ */
33
+ export interface PhantomPlanDetail {
34
+ /** 0-based index in the input plans array. */
35
+ index: number;
36
+ /** Sample of message IDs in the effective set that are already compressed. */
37
+ consumedMessageIds: string[];
38
+ /** Block IDs owning those messages (sorted ascending). */
39
+ owningBlockIds: number[];
40
+ }
41
+ export interface PhantomIdentification {
42
+ /** Indices of plans that are phantom (no new messages to compress). */
43
+ phantomIndices: number[];
44
+ /** Per-phantom diagnostics for error / skip-notice messages. */
45
+ details: PhantomPlanDetail[];
46
+ }
47
+ /**
48
+ * Identify which plans in a batch are phantom (would produce 0 new compressed
49
+ * messages). Stateless pre-check mirroring applyCompressionState's
50
+ * newlyCompressedMessageIds computation: a message is "new" iff it has no
51
+ * byMessageId entry OR its activeBlockIds is empty.
52
+ *
53
+ * Returns per-plan diagnostics so callers can implement partial-failure
54
+ * batches (issue #290 fix A): skip phantom entries, compress the valid ones,
55
+ * and report which entries / IDs / blocks conflicted (fix C).
56
+ *
57
+ * Multi-consumed single-tier carve-out: a higher-tier distillation that merges
58
+ * sibling blocks of the SAME tier is allowed even when every message is
59
+ * already active under those siblings (the merge itself is the value).
60
+ * Matches the historical exception in checkPhantomBlock.
61
+ *
62
+ * Fix for issue #93/#290: empty compression blocks waste context (summary
63
+ * overhead with no token savings) and cause compression loops.
64
+ */
65
+ export declare function identifyPhantomPlans(state: SessionState, plans: Array<{
66
+ messageIds: string[];
67
+ consumedBlockIds: number[];
68
+ }>): PhantomIdentification;
69
+ export declare function buildPhantomErrorMessage(details: PhantomPlanDetail[]): string;
70
+ /**
71
+ * Outcome of classifying a batch against its phantom identification (issue #290).
72
+ * - `clean`: no phantom entries — compress everything.
73
+ * - `all-phantom`: every entry is phantom — caller throws via {@link buildPhantomErrorMessage}.
74
+ * - `partial`: some entries are phantom — caller drops `dropIndices`, compresses the rest,
75
+ * and surfaces `notice` in the success return.
76
+ */
77
+ export type PhantomPartition = {
78
+ kind: "clean";
79
+ } | {
80
+ kind: "all-phantom";
81
+ details: PhantomPlanDetail[];
82
+ } | {
83
+ kind: "partial";
84
+ dropIndices: number[];
85
+ details: PhantomPlanDetail[];
86
+ notice: string;
87
+ };
88
+ /**
89
+ * Partition a batch of plans based on its phantom identification. Pure helper
90
+ * extracted so the all-vs-some-vs-clean decision and skip-notice construction
91
+ * are independently unit-testable (issue #290 review concern C1).
92
+ *
93
+ * @param identification Result of {@link identifyPhantomPlans}.
94
+ * @param totalPlans Count of plans in the batch (before any filtering).
95
+ */
96
+ export declare function partitionPhantomPlans(identification: PhantomIdentification, totalPlans: number): PhantomPartition;
97
+ /**
98
+ * Build the concise skip-notice shown when a partial batch drops phantom entries
99
+ * (issue #290 fix A — model-facing success return).
100
+ */
101
+ export declare function buildPhantomSkipNotice(identification: PhantomIdentification): string;
102
+ /**
103
+ * Stateless check: reject compression plans that would produce phantom blocks
104
+ * (0 new direct messages, 0 compressed tokens). A phantom block occurs when
105
+ * every message in the effective range is already active under an existing
106
+ * compression block. Returns an Error for the FIRST phantom plan, or null.
107
+ *
108
+ * Legacy single-error API — kept for backward compatibility. Batch-aware
109
+ * callers should use {@link identifyPhantomPlans} + {@link buildPhantomErrorMessage}
110
+ * to implement partial-failure batches (issue #290 fix A).
111
+ *
112
+ * Fix for issue #93: empty compression blocks waste context (summary overhead
113
+ * with no token savings) and cause compression loops — the model sees 0 tokens
114
+ * removed, retries the same range, creates another phantom, endlessly.
115
+ *
116
+ * A message is "new" (will be newly compressed) if it is NOT currently active
117
+ * under any block. Messages active under consumed blocks are still "already
118
+ * compressed" — re-labeling them under a new block does not newly hide them
119
+ * (matches applyCompressionState's newlyCompressedMessageIds computation).
120
+ */
121
+ export declare function checkPhantomBlock(state: SessionState, plans: Array<{
122
+ messageIds: string[];
123
+ consumedBlockIds: number[];
124
+ }>): Error | null;
125
+ /**
126
+ * Compute the set of protected message raw IDs based on recent-message and
127
+ * recent-token rules. These IDs cannot be included in a compression plan
128
+ * unless the caller passes `dangerous: true`.
129
+ *
130
+ * Note: preserveLastUserMessage is handled by soft filtering in the compress
131
+ * pipeline (filterLastUserMessage), not here.
132
+ */
133
+ export declare function computeProtectedRawIds(rawMessages: WithParts[], state: SessionState, compress: import("../config").CompressConfig): Set<string>;
134
+ /**
135
+ * Reject compression plans that cover protected messages (last N messages
136
+ * or last N tokens). The caller must pass `dangerous: true` to proceed.
137
+ * Returns an Error to throw if the caller did not opt in.
138
+ */
139
+ export declare function checkProtectedRange(ctx: ToolContext, allPlanMessageIds: string[][], rawMessages: WithParts[], dangerous: boolean): Error | null;
140
+ export {};
141
+ //# sourceMappingURL=pipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../lib/compress/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO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AAE,MAAM,EAAE,CAAC;IAAC,gBAAgB,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,GACnE,KAAK,GAAG,IAAI,CAUd;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAClC,WAAW,EAAE,SAAS,EAAE,EACxB,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,OAAO,WAAW,EAAE,cAAc,GAC7C,GAAG,CAAC,MAAM,CAAC,CAuCb;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAC/B,GAAG,EAAE,WAAW,EAChB,iBAAiB,EAAE,MAAM,EAAE,EAAE,EAC7B,WAAW,EAAE,SAAS,EAAE,EACxB,SAAS,EAAE,OAAO,GACnB,KAAK,GAAG,IAAI,CA6Bd"}
@@ -0,0 +1,12 @@
1
+ import type { SessionState, WithParts } from "../state";
2
+ import type { CompressConfig } from "../config";
3
+ import type { SearchContext, SelectionResolution } from "./types";
4
+ export declare function appendProtectedUserMessages(summary: string, selection: SelectionResolution, searchContext: SearchContext, state: SessionState, enabled: boolean): string;
5
+ export declare function appendProtectedPromptInfo(summary: string, selection: SelectionResolution, searchContext: SearchContext, state: SessionState, enabled: boolean): string;
6
+ export declare function extractProtectedPromptInfo(text: string): string[];
7
+ export declare function appendProtectedTools(client: any, state: SessionState, summary: string, selection: SelectionResolution, searchContext: SearchContext, protectedTools: string[], protectedFilePatterns?: string[]): Promise<string>;
8
+ export declare function messageContainsProtectedTool(message: WithParts, protectedTools: string[], protectedFilePatterns?: string[]): boolean;
9
+ export declare function filterProtectedToolMessages(selection: SelectionResolution, searchContext: SearchContext, protectedTools: string[], protectedFilePatterns?: string[]): SelectionResolution;
10
+ export declare function filterLastUserMessage(selection: SelectionResolution, searchContext: SearchContext, state: SessionState, compress: CompressConfig): SelectionResolution;
11
+ export declare function filterProtectedRecentMessages(selection: SelectionResolution, searchContext: SearchContext, state: SessionState, compress: CompressConfig): SelectionResolution;
12
+ //# sourceMappingURL=protected-content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protected-content.d.ts","sourceRoot":"","sources":["../../../lib/compress/protected-content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAQ/C,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAEjE,wBAAgB,2BAA2B,CACvC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,mBAAmB,EAC9B,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,OAAO,GACjB,MAAM,CAgCR;AAED,wBAAgB,yBAAyB,CACrC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,mBAAmB,EAC9B,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,OAAO,GACjB,MAAM,CAgCR;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAYjE;AAED,wBAAsB,oBAAoB,CACtC,MAAM,EAAE,GAAG,EACX,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,mBAAmB,EAC9B,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,MAAM,EAAE,EACxB,qBAAqB,GAAE,MAAM,EAAO,GACrC,OAAO,CAAC,MAAM,CAAC,CAiDjB;AAED,wBAAgB,4BAA4B,CACxC,OAAO,EAAE,SAAS,EAClB,cAAc,EAAE,MAAM,EAAE,EACxB,qBAAqB,GAAE,MAAM,EAAO,GACrC,OAAO,CAiBT;AAED,wBAAgB,2BAA2B,CACvC,SAAS,EAAE,mBAAmB,EAC9B,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,MAAM,EAAE,EACxB,qBAAqB,GAAE,MAAM,EAAO,GACrC,mBAAmB,CAyCrB;AAED,wBAAgB,qBAAqB,CACjC,SAAS,EAAE,mBAAmB,EAC9B,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,cAAc,GACzB,mBAAmB,CAoCrB;AAED,wBAAgB,6BAA6B,CACzC,SAAS,EAAE,mBAAmB,EAC9B,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,cAAc,GACzB,mBAAmB,CAyDrB"}
@@ -0,0 +1,3 @@
1
+ export declare function ensureBuiltinGatesRegistered(): void;
2
+ export { rougeRecallV1 } from "context-compress-algorithms/quality-gate";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../lib/compress/quality-gate/algorithms/index.ts"],"names":[],"mappings":"AAGA,wBAAgB,4BAA4B,IAAI,IAAI,CAEnD;AAED,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAA"}