@retaw106/mmc-oc 2.5.0 → 2.7.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 (121) hide show
  1. package/dist/{context-xx09sh1g.js → context-9q17e52a.js} +553 -214
  2. package/dist/features/magic-context/auto-search-diagnostics.d.ts +27 -0
  3. package/dist/features/magic-context/auto-search-diagnostics.d.ts.map +1 -0
  4. package/dist/features/magic-context/compaction-marker.d.ts +34 -6
  5. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
  6. package/dist/features/magic-context/message-index.d.ts +1 -24
  7. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  8. package/dist/features/magic-context/search.d.ts +4 -0
  9. package/dist/features/magic-context/search.d.ts.map +1 -1
  10. package/dist/features/magic-context/session-decision-calibration.d.ts.map +1 -1
  11. package/dist/features/magic-context/session-retention.fixture.d.ts +4 -0
  12. package/dist/features/magic-context/session-retention.fixture.d.ts.map +1 -0
  13. package/dist/features/magic-context/storage-meta-persisted.d.ts +21 -1
  14. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  15. package/dist/features/magic-context/storage-native-replay.d.ts +2 -0
  16. package/dist/features/magic-context/storage-native-replay.d.ts.map +1 -1
  17. package/dist/features/magic-context/storage-session-tables.d.ts +4 -11
  18. package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
  19. package/dist/features/magic-context/tool-definition-tokens.d.ts +113 -58
  20. package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -1
  21. package/dist/features/magic-context/work-metrics.d.ts +5 -3
  22. package/dist/features/magic-context/work-metrics.d.ts.map +1 -1
  23. package/dist/hooks/magic-context/apply-operations.d.ts +32 -0
  24. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  25. package/dist/hooks/magic-context/ask-answer-notice.d.ts +25 -0
  26. package/dist/hooks/magic-context/ask-answer-notice.d.ts.map +1 -0
  27. package/dist/hooks/magic-context/auto-search-observation.d.ts +13 -0
  28. package/dist/hooks/magic-context/auto-search-observation.d.ts.map +1 -0
  29. package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
  30. package/dist/hooks/magic-context/compaction-marker-manager.d.ts +5 -5
  31. package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
  32. package/dist/hooks/magic-context/compaction-marker-publication.d.ts +14 -0
  33. package/dist/hooks/magic-context/compaction-marker-publication.d.ts.map +1 -0
  34. package/dist/hooks/magic-context/compaction-off-transition.d.ts.map +1 -1
  35. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +11 -0
  36. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  37. package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
  38. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +11 -3
  39. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
  40. package/dist/hooks/magic-context/historian-history-wait.d.ts +16 -0
  41. package/dist/hooks/magic-context/historian-history-wait.d.ts.map +1 -0
  42. package/dist/hooks/magic-context/history-boundary-repair.d.ts +1 -1
  43. package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -1
  44. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  45. package/dist/hooks/magic-context/lkg-measured-request.d.ts.map +1 -1
  46. package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts +3 -1
  47. package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts.map +1 -1
  48. package/dist/hooks/magic-context/lkg-replay-fit.d.ts.map +1 -1
  49. package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
  50. package/dist/hooks/magic-context/lkg-slot.d.ts +2 -0
  51. package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
  52. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  53. package/dist/hooks/magic-context/read-session-db.d.ts +8 -2
  54. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  55. package/dist/hooks/magic-context/read-session-raw.d.ts +20 -0
  56. package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
  57. package/dist/hooks/magic-context/signed-thinking-fit-snapshot.d.ts +42 -0
  58. package/dist/hooks/magic-context/signed-thinking-fit-snapshot.d.ts.map +1 -0
  59. package/dist/hooks/magic-context/tag-messages.d.ts +2 -0
  60. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  61. package/dist/hooks/magic-context/todo-view.d.ts +2 -2
  62. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  63. package/dist/{index-bpjjcdy9.js → index-8rmt6s4f.js} +77 -31
  64. package/dist/{index-mjf0p7yq.js → index-cgjyhwdk.js} +1 -1
  65. package/dist/{index-k25thxq7.js → index-s3ebcy63.js} +1 -1
  66. package/dist/{index-1vxffj5j.js → index-t0zx3tgz.js} +408 -89
  67. package/dist/{index-0d40b4q8.js → index-xrxpbe74.js} +9355 -9215
  68. package/dist/index.js +14 -4
  69. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  70. package/dist/{read-session-chunk-eb3fy45y.js → read-session-chunk-2s8x6xps.js} +2 -2
  71. package/dist/{recomp-orchestrator-mmpy5cb7.js → recomp-orchestrator-gzd1at06.js} +5 -5
  72. package/dist/{send-session-notification-zpqs213d.js → send-session-notification-vdppp5x6.js} +2 -2
  73. package/dist/shared/search-text.d.ts +2 -0
  74. package/dist/shared/search-text.d.ts.map +1 -1
  75. package/dist/shared/tag-transcript.d.ts +2 -0
  76. package/dist/shared/tag-transcript.d.ts.map +1 -1
  77. package/dist/shared/transcript.d.ts +3 -1
  78. package/dist/shared/transcript.d.ts.map +1 -1
  79. package/dist/tools/ctx-expand/render.d.ts +5 -3
  80. package/dist/tools/ctx-expand/render.d.ts.map +1 -1
  81. package/dist/tools/ctx-expand/tools.d.ts +2 -0
  82. package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
  83. package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
  84. package/dist/tools/ctx-note/tools.d.ts.map +1 -1
  85. package/dist/tools/parameter-descriptions.d.ts +10 -10
  86. package/dist/tools/parameter-descriptions.d.ts.map +1 -1
  87. package/dist/tui.js +2144 -0
  88. package/dist/v2/hooks/context.d.ts +5 -1
  89. package/dist/v2/hooks/context.d.ts.map +1 -1
  90. package/dist/v2/hooks/store.d.ts.map +1 -1
  91. package/dist/v2/message-times.d.ts +17 -0
  92. package/dist/v2/message-times.d.ts.map +1 -0
  93. package/dist/v2/server.js +11211 -10345
  94. package/dist/v2/store-reader.d.ts +14 -4
  95. package/dist/v2/store-reader.d.ts.map +1 -1
  96. package/dist/v2/tui/client.d.ts +57 -0
  97. package/dist/v2/tui/client.d.ts.map +1 -0
  98. package/dist/v2/tui/context-rpc.d.ts +63 -0
  99. package/dist/v2/tui/context-rpc.d.ts.map +1 -0
  100. package/dist/v2/tui/entry.d.ts +8 -0
  101. package/dist/v2/tui/entry.d.ts.map +1 -0
  102. package/dist/v2/tui/notification-socket.d.ts +26 -0
  103. package/dist/v2/tui/notification-socket.d.ts.map +1 -0
  104. package/dist/v2/tui/session-directory.d.ts +22 -0
  105. package/dist/v2/tui/session-directory.d.ts.map +1 -0
  106. package/dist/v2/tui/types.d.ts +110 -0
  107. package/dist/v2/tui/types.d.ts.map +1 -0
  108. package/dist/web/main.js +85 -11
  109. package/dist/{wrapup-orchestrator-jq589pgr.js → wrapup-orchestrator-ghq4y406.js} +5 -5
  110. package/package.json +13 -3
  111. package/src/config/latch-permanence-guard.test.ts +0 -5
  112. package/src/shared/prompt-surface-a1-golden.md +8 -9
  113. package/src/shared/search-text.test.ts +36 -1
  114. package/src/shared/search-text.ts +48 -0
  115. package/src/shared/sqlite-transaction-mode-guard.test.ts +2 -0
  116. package/src/shared/tag-transcript.ts +47 -4
  117. package/src/shared/transcript.ts +1 -1
  118. package/src/shared/write-transaction-attribution.test.ts +1 -6
  119. package/tui.js +4 -0
  120. package/dist/features/magic-context/message-index-sweep.d.ts +0 -11
  121. package/dist/features/magic-context/message-index-sweep.d.ts.map +0 -1
@@ -1,90 +1,145 @@
1
1
  /**
2
2
  * Tool-definition token measurement store.
3
3
  *
4
- * OpenCode's `tool.definition` hook fires once per tool per
5
- * `ToolRegistry.tools()` call, with `{ toolID }` as input and
6
- * `{ description, parameters }` as output. Crucially the hook input does NOT
7
- * carry `sessionID` — the tool set is computed per
8
- * `{providerID, modelID, agent}` combination, independent of session.
4
+ * Every provider request carries the definitions of the tools offered on it,
5
+ * and those definitions take room in the context window. This store measures
6
+ * them so estimates of a request's size can include them. Each tool's
7
+ * description + JSON-schema parameters is tokenized with the same Claude
8
+ * tokenizer used everywhere else in the plugin and stored per tool under a
9
+ * `${providerID}/${modelID}/${agentName}` route key.
9
10
  *
10
- * We measure each tool's description + JSON-schema parameters, tokenize with
11
- * the same Claude tokenizer used everywhere else in the plugin, and store
12
- * per-tool totals keyed by `${providerID}/${modelID}/${agentName}`. Inner map
13
- * keys on `toolID` so every hook fire idempotently overwrites its own slot
14
- * (same tool set on each turn → same key → same measured total).
11
+ * What a total counts: the tools of the current request. A tool the host
12
+ * stopped offering, or a tool another session was offered, must not add to it
13
+ * for long, and a tool the request does carry must never be left out. The
14
+ * totals feed the 95% size refusal and the replay fits as a trusted figure, so
15
+ * counting too few tools is the dangerous direction; counting a few too many
16
+ * for a while is the safe one. How the current request's tools are known
17
+ * depends on the host:
15
18
  *
16
- * Consumers (RPC sidebar/status handlers) look up the active session's
17
- * measurement via `getMeasuredToolDefinitionTokens(providerID, modelID,
18
- * agentName)`. Returns `undefined` when the key has never been measured — the
19
- * caller is expected to fall back to residual math or show zero.
19
+ * - OpenCode 1 fires its `tool.definition` hook once per tool per
20
+ * `ToolRegistry.tools()` call (once per request, all tools at once, before
21
+ * the messages transform of that request), with `{ toolID }` as input and
22
+ * no session and no "last tool" signal. Calls on one route can run at the
23
+ * same time and their fires interleave, so fires cannot be grouped into
24
+ * requests. Instead a route's total counts every tool fired within
25
+ * `ACTIVITY_WINDOW_MS` of the route's latest fire, measured on the route's
26
+ * own activity clock (see `advanceClock`): idle time does not age a tool,
27
+ * so an idle route keeps its whole set, and a tool leaves only after the
28
+ * route has gone on firing for ten minutes without it.
29
+ * - OpenCode 2 has no such hook, but each request draft carries its whole tool
30
+ * set, so `recordToolDefinitionSet` replaces the route's set with exactly
31
+ * that set and remembers it for the draft's session. A read with that
32
+ * session id returns that session's own set, even when another session on
33
+ * the same route was offered different tools since.
20
34
  *
21
35
  * Persistence (v9+): measurements are also written to SQLite so that a
22
- * plugin restart can repopulate the in-memory map without waiting for the
23
- * next chat.message → tool.definition hook chain. The in-memory Map remains
24
- * the hot read path; SQLite is a write-through mirror that backs cold starts.
25
- * If `setDatabase()` hasn't been called yet (cold path before openDatabase
26
- * completes), `recordToolDefinition` still updates the in-memory map and
27
- * silently skips persistence — first measurement after init lands both.
36
+ * plugin restart can show a "Tool Defs" figure before the first request of
37
+ * the new process. A row is deleted when its tool leaves the route's count,
38
+ * so the table holds each route's recent set. Rows loaded at startup count as
39
+ * if fired at load time: until the route's first live fire, and on OpenCode 1
40
+ * until the route has gone on firing for `ACTIVITY_WINDOW_MS` without them.
41
+ * The exception is rows an older version of this store wrote: it never
42
+ * deleted a row, so its rows can hold every tool a route was ever offered
43
+ * (the overcount reported in GitHub issue 797). Those "legacy" rows count
44
+ * only until the route's first live fire. Which rows are legacy is told by a
45
+ * marker in `schema_migrations_meta` (see `WINDOWED_SINCE_KEY`). If
46
+ * `setDatabase()` hasn't been called yet (cold path before openDatabase
47
+ * completes), measurements still update the in-memory map and are written
48
+ * once a database is bound.
28
49
  *
29
50
  * Hot-path optimization: `tool.definition` fires once per tool per LLM
30
51
  * flight (~58 tools × 5–18ms SQLite write = ~1.4s of redundant work per
31
52
  * flight on large MC databases). Tool descriptions and parameters almost
32
- * never change between flights, so we keep a per-key content-fingerprint
33
- * Map and bail out at the top of `recordToolDefinition` when the new fire
34
- * carries the same fingerprint as the previous one. This collapses
35
- * steady-state hook overhead from ~1.4s to <1ms while still re-measuring
36
- * any tool whose description/schema actually changed (e.g. MCP server
37
- * restart, OpenCode upgrade). Cached prepared statement avoids repeated
38
- * `db.prepare()` compile cost on first-flight rebuilds.
53
+ * never change between flights, so each tool keeps the content fingerprint of
54
+ * its last measurement and an identical fire only refreshes its last-fire
55
+ * time, without tokenizing or writing. A tool that left the count keeps its
56
+ * fingerprint and token count in a small per-route cache, so when it comes
57
+ * back unchanged it is not tokenized again, and its row is written again only
58
+ * if it was actually deleted. Any tool whose description or schema actually
59
+ * changed (e.g. MCP server restart, OpenCode upgrade) is re-measured. Cached
60
+ * prepared statements avoid repeated `db.prepare()` compile cost.
39
61
  */
40
62
  import type { Database } from "../../shared/sqlite";
41
- /**
42
- * Hash the observed names in the provider tool set for one model/agent route.
43
- *
44
- * Tool names alone identify the prefix change this marker explains. Schema
45
- * fingerprints remain necessary for measurement de-duplication, but including
46
- * them here would add cost without improving cache-bust attribution. An empty
47
- * string means the route has not reported any tool definitions, not an empty
48
- * provider `tools` array.
49
- */
50
- export declare function getCurrentToolSetHash(providerID: string, modelID: string, agentName: string | undefined): string;
51
- /** Stable signature over the measured tool set, including schema fingerprints;
52
- * undefined until every measured tool also has an observed fingerprint. */
53
- export declare function getToolDefinitionMeasurementSignature(providerID: string, modelID: string, agentName: string | undefined): string | undefined;
54
63
  /**
55
64
  * Register the database used to persist measurements. Called by
56
65
  * openDatabase() after runMigrations() has ensured the
57
- * `tool_definition_measurements` table exists. Subsequent
58
- * recordToolDefinition() calls will write through to SQLite.
66
+ * `tool_definition_measurements` table exists. Subsequent measurements will
67
+ * write through to SQLite.
59
68
  */
60
69
  export declare function setDatabase(db: Database): void;
61
70
  /**
62
- * Populate the in-memory measurements map from the
63
- * `tool_definition_measurements` table. Called once at startup after
64
- * setDatabase(), before the first sidebar snapshot or status query, so the
65
- * sidebar's "Tool Defs" segment shows the correct value immediately on
66
- * restart instead of 0.
71
+ * Populate the in-memory store from the `tool_definition_measurements` table.
72
+ * Called once at startup after setDatabase(), before the first sidebar
73
+ * snapshot or status query, so the sidebar's "Tool Defs" segment shows a
74
+ * figure immediately on restart instead of 0.
75
+ *
76
+ * Loaded rows count as if their tools fired at load time: they stand in for
77
+ * the route until its first live fire and then, on OpenCode 1, until the
78
+ * route has gone on firing for the activity window without them. A read in
79
+ * the middle of the first request after a restart therefore still counts the
80
+ * stored set. Legacy rows (written before `WINDOWED_SINCE_KEY`, or in a table
81
+ * without it) can hold every tool a route was ever offered, so they stop
82
+ * counting at the route's first live fire. Since this process never measured
83
+ * a loaded row's content, it carries no fingerprint.
67
84
  *
68
85
  * Idempotent: re-running over the same DB reapplies the same values; the
69
- * inner-map key (toolID) ensures duplicates overwrite rather than accumulate.
86
+ * per-route tool key ensures duplicates overwrite rather than accumulate.
87
+ * Routes already measured in this process are left alone.
70
88
  */
71
89
  export declare function loadToolDefinitionMeasurements(db: Database): void;
72
90
  /**
73
- * Tokenize a single tool's schema and store it under the given key. Called
74
- * from the `tool.definition` plugin hook once per tool per flight. Same
75
- * toolID on a later flight overwrites its slot — the total for the key stays
76
- * consistent even if descriptions or parameters drift between turns.
91
+ * OpenCode 1: measure one tool the host is offering on the current request.
92
+ * Called from the `tool.definition` plugin hook once per tool per flight.
93
+ * `sessionId` is the session the request is believed to belong to (the hook
94
+ * carries none); it only records which route that session last flew.
95
+ */
96
+ export declare function recordToolDefinition(providerID: string, modelID: string, agentName: string | undefined, toolID: string, description: string, parameters: unknown, sessionId?: string): void;
97
+ /**
98
+ * OpenCode 2: record the exact tool set one request carries. The route's set
99
+ * becomes exactly `tools` (tools no longer offered are forgotten and their
100
+ * stored rows deleted), and `sessionId`'s figure becomes this set until its
101
+ * next request. Unchanged tools are not tokenized or written again.
102
+ */
103
+ export declare function recordToolDefinitionSet(providerID: string, modelID: string, agentName: string | undefined, tools: Iterable<{
104
+ id: string;
105
+ description: string;
106
+ parameters: unknown;
107
+ }>, sessionId?: string): void;
108
+ /**
109
+ * Hash the tool names of the current tool set for one model/agent route.
110
+ *
111
+ * Tool names alone identify the prefix change this marker explains. Schema
112
+ * fingerprints remain necessary for measurement de-duplication, but including
113
+ * them here would add cost without improving cache-bust attribution. An empty
114
+ * string is returned both before any measurement and for a request that
115
+ * carried no tools; it does not tell those cases apart.
116
+ */
117
+ export declare function getCurrentToolSetHash(providerID: string, modelID: string, agentName: string | undefined, sessionId?: string): string;
118
+ /**
119
+ * Hash the current tool set's IDs and full schemas so provider usage is reused
120
+ * only for the same definitions. Undefined when a counted tool's content was
121
+ * not measured in this process.
122
+ */
123
+ export declare function getToolDefinitionMeasurementSignature(providerID: string, modelID: string, agentName: string | undefined, sessionId?: string): string | undefined;
124
+ /**
125
+ * Returns the measured tokens of the current tool set for a
126
+ * `{provider, model, agent}` route, or `undefined` when never measured (e.g.
127
+ * fresh session before first turn). With `sessionId`, an OpenCode 2 session
128
+ * whose last request flew this route gets that request's exact set.
77
129
  */
78
- export declare function recordToolDefinition(providerID: string, modelID: string, agentName: string | undefined, toolID: string, description: string, parameters: unknown): void;
130
+ export declare function getMeasuredToolDefinitionTokens(providerID: string, modelID: string, agentName: string | undefined, sessionId?: string): number | undefined;
79
131
  /**
80
- * Returns the summed measured tokens for a `{provider, model, agent}` key,
81
- * or `undefined` when never measured (e.g. fresh session before first turn).
132
+ * The tool-definition total of the route `sessionId` last flew: on OpenCode 2
133
+ * the exact set of that session's last request, on OpenCode 1 the route's
134
+ * recent-activity total. For a session whose current route has no
135
+ * measurement yet (for example right after a model switch), this is the best
136
+ * evidence of the tools it is offered; undefined when the session never had
137
+ * its tools measured.
82
138
  */
83
- export declare function getLargestMeasuredToolDefinitionTokens(): number | undefined;
84
- export declare function getMeasuredToolDefinitionTokens(providerID: string, modelID: string, agentName: string | undefined): number | undefined;
139
+ export declare function getSessionToolDefinitionTokens(sessionId: string | undefined): number | undefined;
85
140
  /** Test helper: reset the store so suites don't leak measurements. */
86
141
  export declare function __resetToolDefinitionMeasurements(): void;
87
- /** Inspection helper: snapshot the current store (for debug logging/tests). */
142
+ /** Inspection helper: snapshot each route's current set (for debug logging/tests). */
88
143
  export declare function getToolDefinitionSnapshot(): Array<{
89
144
  key: string;
90
145
  totalTokens: number;
@@ -1 +1 @@
1
- {"version":3,"file":"tool-definition-tokens.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/tool-definition-tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,qBAAqB,CAAC;AA0C/D;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACjC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,GAC9B,MAAM,CAKR;AAED;2EAC2E;AAC3E,wBAAgB,qCAAqC,CACjD,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,GAC9B,MAAM,GAAG,SAAS,CAQpB;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAK9C;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAkCjE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAChC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,OAAO,GACpB,IAAI,CAwEN;AAED;;;GAGG;AACH,wBAAgB,sCAAsC,IAAI,MAAM,GAAG,SAAS,CAQ3E;AAED,wBAAgB,+BAA+B,CAC3C,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,GAC9B,MAAM,GAAG,SAAS,CAOpB;AAED,sEAAsE;AACtE,wBAAgB,iCAAiC,IAAI,IAAI,CAKxD;AAED,+EAA+E;AAC/E,wBAAgB,yBAAyB,IAAI,KAAK,CAAC;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC,CAMD"}
1
+ {"version":3,"file":"tool-definition-tokens.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/tool-definition-tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAKH,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,qBAAqB,CAAC;AAqd/D;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CA4B9C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,8BAA8B,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CA0CjE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAChC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,OAAO,EACnB,SAAS,CAAC,EAAE,MAAM,GACnB,IAAI,CAgCN;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACnC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,KAAK,EAAE,QAAQ,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC,EACzE,SAAS,CAAC,EAAE,MAAM,GACnB,IAAI,CAiCN;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACjC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,SAAS,CAAC,EAAE,MAAM,GACnB,MAAM,CAER;AAED;;;;GAIG;AACH,wBAAgB,qCAAqC,CACjD,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,SAAS,CAAC,EAAE,MAAM,GACnB,MAAM,GAAG,SAAS,CAEpB;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC3C,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,SAAS,CAAC,EAAE,MAAM,GACnB,MAAM,GAAG,SAAS,CAEpB;AAED;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAOhG;AAED,sEAAsE;AACtE,wBAAgB,iCAAiC,IAAI,IAAI,CAQxD;AAED,sFAAsF;AACtF,wBAAgB,yBAAyB,IAAI,KAAK,CAAC;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC,CASD"}
@@ -1,3 +1,4 @@
1
+ import type { OpenCodeHostGeneration } from "../../shared/opencode-db-path";
1
2
  import type { Database } from "../../shared/sqlite";
2
3
  export interface WorkMetrics {
3
4
  newWorkTokens: number;
@@ -13,6 +14,7 @@ export declare function computeOpenCodeWorkMetrics(openCodeDb: Database, session
13
14
  export interface AssistantUsageRow {
14
15
  /** json_extract(data,'$.agent'); null when absent (its own partition). */
15
16
  agent: string | null;
17
+ /** Ordering key: v1 time_created, or v2 seq (the store's append order). */
16
18
  timeCreated: number;
17
19
  id: string;
18
20
  /** input + cache.read + cache.write. */
@@ -36,7 +38,7 @@ export interface WorkMetricsCarry {
36
38
  perAgent: Map<string, AgentCarry>;
37
39
  /** Σ max(0, prompt - prevPrompt) across every folded row (metric A body). */
38
40
  newWorkSum: number;
39
- /** Watermark: last folded row's ordering key. */
41
+ /** Watermark: last folded row's ordering key (v1 time_created or v2 seq). */
40
42
  lastTimeCreated: number;
41
43
  lastId: string;
42
44
  }
@@ -56,7 +58,7 @@ export declare function foldWorkMetricsRows(rows: AssistantUsageRow[], carry: Wo
56
58
  /** Current metric value implied by the carry (cheap; no DB access). */
57
59
  export declare function metricsFromCarry(carry: WorkMetricsCarry): WorkMetrics;
58
60
  /** Read assistant usage rows strictly newer than the carry watermark. */
59
- export declare function readAssistantUsageRowsAfter(openCodeDb: Database, sessionId: string, afterTimeCreated: number, afterId: string): AssistantUsageRow[];
61
+ export declare function readAssistantUsageRowsAfter(openCodeDb: Database, sessionId: string, afterTimeCreated: number, afterId: string, generation?: OpenCodeHostGeneration): AssistantUsageRow[];
60
62
  /**
61
63
  * Extend `carry` with assistant rows newer than its watermark and return the
62
64
  * up-to-date metrics. On a fresh carry this folds the whole session once (cold
@@ -70,7 +72,7 @@ export declare function readAssistantUsageRowsAfter(openCodeDb: Database, sessio
70
72
  * throwaway clone for the returned value, so the result always matches a full
71
73
  * re-scan even while the latest turn is still streaming.
72
74
  */
73
- export declare function computeOpenCodeWorkMetricsIncremental(openCodeDb: Database, sessionId: string, carry: WorkMetricsCarry): {
75
+ export declare function computeOpenCodeWorkMetricsIncremental(openCodeDb: Database, sessionId: string, carry: WorkMetricsCarry, generation?: OpenCodeHostGeneration): {
74
76
  carry: WorkMetricsCarry;
75
77
  metrics: WorkMetrics;
76
78
  };
@@ -1 +1 @@
1
- {"version":3,"file":"work-metrics.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/work-metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,WAAW,WAAW;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;I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GAAG,OAAO,EAAE,GAAG,WAAW,CA8B9F"}
@@ -34,6 +34,8 @@ import type { ToolDropResult } from "./tool-drop-target";
34
34
  */
35
35
  export declare const RECENT_TOOL_SKELETON_WINDOW = 20;
36
36
  export declare function buildReplacementContent(tagId: number): string;
37
+ /** Reduce only the body; annotations already rendered on this part keep their exact bytes. */
38
+ export declare function renderDroppedText(tagId: number, renderedText?: string | null): string;
37
39
  export interface NewToolDropOutcome {
38
40
  result: ToolDropResult;
39
41
  /** The drop mode to persist so every later pass replays the same bytes. */
@@ -131,6 +133,10 @@ export declare function foldBustsServedPrefix(reason: string | null | undefined,
131
133
  */
132
134
  export declare function convertLegacyToolSkeletons(db: ContextDatabase, sessionId: string, targets: ReadonlyMap<number, TagTarget>, options?: {
133
135
  keepFullDrop?: (callId: string | null) => boolean;
136
+ prepareRemovals?: (rows: readonly {
137
+ tagNumber: number;
138
+ callId: string | null;
139
+ }[]) => void;
134
140
  }): Map<number, ConvertedToolDropMode>;
135
141
  /**
136
142
  * Precompute the legacy-marker conversions for the executing HARD fold without
@@ -142,6 +148,10 @@ export declare function convertLegacyToolSkeletons(db: ContextDatabase, sessionI
142
148
  */
143
149
  export declare function prepareLegacyToolSkeletonConversions(db: ContextDatabase, sessionId: string, targets: ReadonlyMap<number, TagTarget>, options?: {
144
150
  keepFullDrop?: (callId: string | null) => boolean;
151
+ prepareRemovals?: (rows: readonly {
152
+ tagNumber: number;
153
+ callId: string | null;
154
+ }[]) => void;
145
155
  }): {
146
156
  converted: Map<number, ConvertedToolDropMode>;
147
157
  isCurrent: (connection: ContextDatabase) => boolean;
@@ -149,12 +159,32 @@ export declare function prepareLegacyToolSkeletonConversions(db: ContextDatabase
149
159
  };
150
160
  /** Render conversions from convertLegacyToolSkeletons on this pass's wire. */
151
161
  export declare function renderConvertedToolSkeletons(targets: ReadonlyMap<number, TagTarget>, converted: ReadonlyMap<number, ConvertedToolDropMode>): boolean;
162
+ /**
163
+ * One rejected pending operation, attributed to the operation's own tag.
164
+ *
165
+ * `tagNumber` is bound at the reject site (including deferred mutation
166
+ * closures) rather than read from a shared cursor, so a rejection after the
167
+ * chunk walk still names the operation it belongs to.
168
+ */
169
+ export interface RejectedPendingOperation {
170
+ tagNumber: number;
171
+ reason: string;
172
+ /** True when the drop decision was already written before this rejection. */
173
+ persisted: boolean;
174
+ /** pending_ops row state at rejection; synthetic operations never have one. */
175
+ queueState: "retained" | "removed" | "none";
176
+ }
152
177
  export interface PendingOperationBatchDiagnostics {
153
178
  source: "pending" | "synthetic" | "mixed";
154
179
  total: number;
155
180
  mutated: number;
156
181
  persistedWithoutMutation: number;
157
182
  reasons: Record<string, number>;
183
+ /**
184
+ * Per-operation rejection detail, present only when something was rejected.
185
+ * Omitted for a clean batch so the historical shape stays unchanged.
186
+ */
187
+ rejected?: RejectedPendingOperation[];
158
188
  }
159
189
  export declare function applyPendingOperations(sessionId: string, db: ContextDatabase, targets: Map<number, TagTarget>,
160
190
  /**
@@ -179,4 +209,6 @@ onBatchComplete?: (diagnostics: PendingOperationBatchDiagnostics) => void,
179
209
  /** Supplies a read-only apply view for a later historian trigger. */
180
210
  onEligibilitySnapshot?: (eligible: ReadonlySet<number>) => void): boolean;
181
211
  export declare function applyFlushedStatuses(sessionId: string, db: ContextDatabase, targets: Map<number, TagTarget>, preloadedTags?: TagEntry[]): boolean;
212
+ /** Plan precisely the authorizations requested by full-drop replay, in replay order. */
213
+ export declare function prepareFlushedToolRemovals(targets: Map<number, TagTarget>, tags: readonly TagEntry[]): void;
182
214
  //# sourceMappingURL=apply-operations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"apply-operations.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/apply-operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAGH,aAAa,EAKhB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE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,CAAC,EACpC,aAAa,CAAC,EAAE,QAAQ,EAAE,EAC1B,mBAAmB,CAAC,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,EACtD,mBAAmB,GAAE,SAAS,EAAO;AACrC;;;;;GAKG;AACH,gBAAgB,GAAE,WAAW,CAAC,MAAM,CAAa;AACjD,4EAA4E;AAC5E,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,qBAAqB,KAAK,IAAI;AACzD,iFAAiF;AACjF,eAAe,CAAC,EAAE,CAAC,WAAW,EAAE,gCAAgC,KAAK,IAAI;AACzE,qEAAqE;AACrE,qBAAqB,CAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,KAAK,IAAI,GAChE,OAAO,CA8VT;AAED,wBAAgB,oBAAoB,CAChC,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,eAAe,EACnB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,EAC/B,aAAa,CAAC,EAAE,QAAQ,EAAE,GAC3B,OAAO,CAgDT;AAED,wFAAwF;AACxF,wBAAgB,0BAA0B,CACtC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,EAC/B,IAAI,EAAE,SAAS,QAAQ,EAAE,GAC1B,IAAI,CAMN"}
@@ -0,0 +1,25 @@
1
+ /** One answer the user gave to a parked ask, as rendered by Prefrontal. */
2
+ export interface AskAnswerNotice {
3
+ /** The question text as Prefrontal rendered it, on one line. */
4
+ question: string;
5
+ /** The user's answer, as Prefrontal rendered it, newlines and all. */
6
+ answer: string;
7
+ }
8
+ /**
9
+ * The one reminder the historian keeps verbatim: the user's own answer to a
10
+ * parked ask, rendered by Prefrontal. Returns one entry per answer notice in
11
+ * delivery order; an empty array for text with no answer notice.
12
+ */
13
+ export declare function extractAskAnswerNotices(text: string): AskAnswerNotice[];
14
+ /** `U (answered "<question>"): <answer>`, the line the historian reads. */
15
+ export declare function formatAskAnswerNotice(notice: AskAnswerNotice): string;
16
+ /**
17
+ * One `U (answered "<question>"): <answer>` line per answer notice in `text`, in
18
+ * delivery order. The chunk readers append these after the user's own words, so a
19
+ * decision the user made by answering an ask reaches the historian as the user's
20
+ * line instead of only as the agent's restatement. A text with no answer notice
21
+ * yields no lines, which leaves every other user message rendered exactly as it
22
+ * was before this existed.
23
+ */
24
+ export declare function askAnswerLines(text: string): string[];
25
+ //# sourceMappingURL=ask-answer-notice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ask-answer-notice.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/ask-answer-notice.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,MAAM,WAAW,eAAe;IAC5B,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;CAClB;AAiED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,EAAE,CAOvE;AAED,2EAA2E;AAC3E,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAErE;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAErD"}
@@ -0,0 +1,13 @@
1
+ import { type AutoSearchDiagnostics } from "../../features/magic-context/auto-search-diagnostics";
2
+ import type { AutoSearchHintNoHintReason } from "../../features/magic-context/storage-meta-persisted";
3
+ import type { Database } from "../../shared/sqlite";
4
+ export type AutoSearchDecisionOutcome = "attached" | "below-threshold" | "timeout" | "no-candidates" | "disabled" | "error";
5
+ type DecisionReason = AutoSearchHintNoHintReason | "unregistered" | "worker-busy" | "storage-busy" | "cas-exhausted";
6
+ /** Disabled turns have no persisted decision; deduplicate their diagnostics without writing one. */
7
+ export declare function logDisabledAutoSearch(db: Database, sessionId: string, messageId: string, threshold: number, startedAt: number): void;
8
+ export declare function observeAutoSearch(sessionId: string, threshold: number, startedAt: number): {
9
+ diagnostics: AutoSearchDiagnostics;
10
+ finish(outcome: AutoSearchDecisionOutcome, reason?: DecisionReason): void;
11
+ };
12
+ export {};
13
+ //# sourceMappingURL=auto-search-observation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-search-observation.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/auto-search-observation.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,qBAAqB,EAE7B,MAAM,sDAAsD,CAAC;AAC9D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qDAAqD,CAAC;AAEtG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,MAAM,yBAAyB,GAC/B,UAAU,GACV,iBAAiB,GACjB,SAAS,GACT,eAAe,GACf,UAAU,GACV,OAAO,CAAC;AAGd,KAAK,cAAc,GACb,0BAA0B,GAC1B,cAAc,GACd,aAAa,GACb,cAAc,GACd,eAAe,CAAC;AAEtB,oGAAoG;AACpG,wBAAgB,qBAAqB,CACjC,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAClB,IAAI,CAMN;AAED,wBAAgB,iBAAiB,CAC7B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAClB;IACC,WAAW,EAAE,qBAAqB,CAAC;IACnC,MAAM,CAAC,OAAO,EAAE,yBAAyB,EAAE,MAAM,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAC7E,CAqBA"}
@@ -1 +1 @@
1
- {"version":3,"file":"auto-search-runner.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/auto-search-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAsBH,OAAO,EAAE,KAAK,QAAQ,EAA0B,MAAM,qBAAqB,CAAC;AAS5E,OAAO,KAAK,E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,13 +113,13 @@ export interface OrphanMarkerReconcileResult {
113
113
  * Removal is idempotent (plain DELETEs) so concurrent processes racing on the
114
114
  * same orphan converge on the same end state; the only guarded invariant is
115
115
  * never deleting our own marker, re-checked against freshly-read persisted
116
- * state below.
116
+ * state under the host writer lock below. An unresolved publication intent
117
+ * protects its entire row set until publication verifies or retires it.
117
118
  *
118
- * Cost gate: callers invoke this only when degraded mode fires (never on every
119
- * pass), so steady state pays nothing. Any failure is swallowed and reported
120
- * via the result so the next degraded pass retries.
119
+ * Cost gate: callers invoke this only on rebuilding degraded passes, never on
120
+ * cached-request replay. Failures can retry on the next rebuilding degraded pass.
121
121
  */
122
- export declare function reconcileForkOrphanedCompactionMarkers(db: Database, sessionId: string): OrphanMarkerReconcileResult;
122
+ export declare function reconcileForkOrphanedCompactionMarkers(db: Database, sessionId: string, isCacheBusting: boolean): OrphanMarkerReconcileResult;
123
123
  /**
124
124
  * Close the writable OpenCode DB connection used for marker injection.
125
125
  */
@@ -1 +1 @@
1
- {"version":3,"file":"compaction-marker-manager.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compaction-marker-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAgBH,OAAO,EAEH,KAAK,uBAAuB,EAG/B,MAAM,qDAAqD,CAAC;AAY7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAKpD,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,iFAC6C,CAAC;AAwB9E;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GACzB;IACI,IAAI,EAAE,SAAS,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;CACzB,GACD;IAAE,IAAI,EAAE,iBAAiB,CAAA;CAAE,GAC3B;IACI,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,qBAAqB,GAAG,mBAAmB,CAAC;CACvD,GACD;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AA6IlD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,qCAAqC;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,6BAA6B,CACzC,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,uBAAuB,EAChC,SAAS,CAAC,EAAE,MAAM,EAClB,eAAe,CAAC,EAAE,qCAAqC,GACxD,mBAAmB,CAyHrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,sCAAsC,CAClD,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,MAAM,EAC1B,SAAS,CAAC,EAAE,MAAM,GACnB,OAAO,CAoFT;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAmBtF;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,2BAA2B;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,sCAAsC,CAClD,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,GAClB,2BAA2B,CAoF7B;AAED;;GAEG;AACH,wBAAgB,+BAA+B,IAAI,IAAI,CAEtD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,gCAAgC,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CA6EnE"}
1
+ {"version":3,"file":"compaction-marker-manager.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compaction-marker-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAeH,OAAO,EAGH,KAAK,uBAAuB,EAE/B,MAAM,qDAAqD,CAAC;AAQ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CAClD,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,OAAO,GACxB,2BAA2B,CA8G7B;AAED;;GAEG;AACH,wBAAgB,+BAA+B,IAAI,IAAI,CAEtD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,gCAAgC,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CA6EnE"}
@@ -0,0 +1,14 @@
1
+ import { type CompactionMarkerReplacementOutcome, type InjectCompactionMarkerArgs } from "../../features/magic-context/compaction-marker";
2
+ import type { Database } from "../../shared/sqlite";
3
+ /**
4
+ * Consumes deferred marker requests when a response is rebuilding its cached prefix.
5
+ * Also used by incremental publication with deferral disabled and explicit full
6
+ * or partial recompilation.
7
+ *
8
+ * Journals the deterministic intent in the existing marker JSON before touching
9
+ * host rows, then CAS-finalizes ownership after the host commit. Recovery adopts
10
+ * only an exact, uniquely verified pair; native, partial and ambiguous rows are
11
+ * left alone and reported as a retryable failure.
12
+ */
13
+ export declare function publishRecoverableCompactionMarker(db: Database, args: InjectCompactionMarkerArgs, targetIsCurrent: () => boolean): CompactionMarkerReplacementOutcome;
14
+ //# sourceMappingURL=compaction-marker-publication.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compaction-marker-publication.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compaction-marker-publication.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,kCAAkC,EAGvC,KAAK,0BAA0B,EAMlC,MAAM,gDAAgD,CAAC;AAcxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAWpD;;;;;;;;;GASG;AACH,wBAAgB,kCAAkC,CAC9C,EAAE,EAAE,QAAQ,EACZ,IAAI,EAAE,0BAA0B,EAChC,eAAe,EAAE,MAAM,OAAO,GAC/B,kCAAkC,CAkKpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"compaction-off-transition.d.ts","sourceRoot":"","sources":["../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,IAAI,CAEN"}
1
+ {"version":3,"file":"compaction-off-transition.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compaction-off-transition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAGH,OAAO,EAEH,KAAK,0BAA0B,EAElC,MAAM,gDAAgD,CAAC;AAMxD,OAAO,EACH,KAAK,oBAAoB,EAa5B,MAAM,qDAAqD,CAAC;AAM7D;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,QAM3B,CAAC;AAEb;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,QAIhC,CAAC;AAEb,MAAM,WAAW,8BAA8B;IAC3C;;;;;OAKG;IACH,aAAa,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC3C,uEAAuE;IACvE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB;;;;OAIG;IACH,qBAAqB,EAAE,OAAO,CAAC;IAC/B,mFAAmF;IACnF,wBAAwB,EAAE,OAAO,CAAC;IAClC,2EAA2E;IAC3E,4BAA4B,EAAE,OAAO,CAAC;IACtC,+EAA+E;IAC/E,gBAAgB,EAAE,OAAO,CAAC;IAC1B,wEAAwE;IACxE,aAAa,EAAE,0BAA0B,CAAC;CAC7C;AA2CD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAC1C,EAAE,EAAE,OAAO,qBAAqB,EAAE,QAAQ,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,aAAa,EAAE,OAAO,CAAC;IACvB,8EAA8E;IAC9E,iBAAiB,EAAE,OAAO,CAAC;IAC3B,8EAA8E;IAC9E,qBAAqB,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,0BAA0B,CAAC;CACtE,GAAG,8BAA8B,CAyLjC;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACtC,EAAE,EAAE,OAAO,qBAAqB,EAAE,QAAQ,EAC1C,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,oBAAoB,GAC7B,IAAI,CAEN"}
@@ -26,5 +26,16 @@ export declare function findDanglingPublicationBoundary(sessionId: string, compa
26
26
  }>, messageExists?: (sessionId: string, messageId: string) => boolean): DanglingPublicationBoundary | null;
27
27
  /** Clean up module-level session state on session deletion. */
28
28
  export declare function clearHistorianAlertState(sessionId: string): void;
29
+ /**
30
+ * Whether a stale-snapshot detail proves the serving thread's ordinal ranks
31
+ * disagree with the exact read on a check that never moves by itself: one of
32
+ * the `offset`, `protectedTailStart` or `eligibleEnd` boundary id checks found
33
+ * a different message id at its ordinal, or the session shrank (deleted rows
34
+ * shift every later ordinal). The `last` id moves every turn as the live tail
35
+ * grows, so a changed last id alone never proves drift. Other stale reasons —
36
+ * stored compartments moved, raw content changed, the model or limit changed
37
+ * — say nothing about the ranks.
38
+ */
39
+ export declare function isServingOrdinalDriftSignal(detail: string | undefined): boolean;
29
40
  export declare function runCompartmentAgent(deps: HiddenCompartmentRunnerDeps): Promise<void>;
30
41
  //# sourceMappingURL=compartment-runner-incremental.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compartment-runner-incremental.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-incremental.ts"],"names":[],"mappings":"AAgEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAoE9E,wBAAgB,6BAA6B,CACzC,EAAE,EAAE,2BAA2B,CAAC,IAAI,CAAC,EACrC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,aAAa,CAAC;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,GAC1E,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBvC;AAGD;;;;GAIG;AACH,eAAO,MAAM,qCAAqC,QAAiB,CAAC;AAwBpE,MAAM,WAAW,2BAA2B;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,GAAG,KAAK,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;+EAC+E;AAC/E,wBAAgB,+BAA+B,CAC3C,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,aAAa,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACxB,CAAC,EACF,aAAa,GAAE,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAkC,GAC5F,2BAA2B,GAAG,IAAI,CAkBpC;AAED,+DAA+D;AAC/D,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAEhE;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAukC1F"}
1
+ {"version":3,"file":"compartment-runner-incremental.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-incremental.ts"],"names":[],"mappings":"AAgEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AA6E9E,wBAAgB,6BAA6B,CACzC,EAAE,EAAE,2BAA2B,CAAC,IAAI,CAAC,EACrC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,aAAa,CAAC;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,GAC1E,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBvC;AAGD;;;;GAIG;AACH,eAAO,MAAM,qCAAqC,QAAiB,CAAC;AAwBpE,MAAM,WAAW,2BAA2B;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,GAAG,KAAK,CAAC;IACtB,SAAS,E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
29
29
  modelID: string | undefined;
30
30
  agentName: string | undefined;
31
+ /**
32
+ * The session the request belongs to. On OpenCode 2 it selects the exact
33
+ * tool set this session's request carries. For a route with no measurement
34
+ * it names the session whose last known tool figure may stand in: its
35
+ * exact set on OpenCode 2, or its last route's activity total on OpenCode 1.
36
+ */
37
+ sessionId?: string;
31
38
  systemPromptHash?: string;
32
39
  /** Bound tokenizer work for refusal checks; ordinary admission uses its
33
40
  * separate fit estimator. */
@@ -44,8 +51,8 @@ export interface FinalWireTokenEstimateInput {
44
51
  * No durable session aggregate or another route's usage can stand in for this.
45
52
  */
46
53
  export declare function createFinalWireUsageTracker(): {
47
- estimate(sessionId: string, input: FinalWireTokenEstimateInput, limit?: number): FinalWireTokenEstimate;
48
- capture(sessionId: string, input: FinalWireTokenEstimateInput): void;
54
+ estimate(sessionId: string, request: FinalWireTokenEstimateInput, limit?: number): FinalWireTokenEstimate;
55
+ capture(sessionId: string, request: FinalWireTokenEstimateInput): void;
49
56
  };
50
57
  export interface FinalWireTokenEstimate {
51
58
  tokens: number;
@@ -61,7 +68,8 @@ export interface FinalWireTokenEstimate {
61
68
  /**
62
69
  * True when the tool-definition figure is this route's own measurement. When
63
70
  * false, `toolDefinitionTokens` is either unknown or an upper envelope taken
64
- * from the largest tool set measured on any route.
71
+ * from this session's last known tool figure (its exact set on OpenCode 2,
72
+ * its last route's activity total on OpenCode 1).
65
73
  */
66
74
  toolDefinitionsMeasured?: boolean;
67
75
  /** Unscaled transform-array/system/tool measurement; provider framing is unmeasured. */
@@ -1 +1 @@
1
- {"version":3,"file":"final-wire-token-estimate.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/final-wire-token-estimate.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,MAAM,WAAW,oBAAoB;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAwBD,oFAAoF;AACpF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,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,YAAY,GAAG,iBAAiB,GAAG,YAAY,CAAC;IAC/D,aAAa,EAAE,oBAAoB,CAAC;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACjE,YAAY,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACtC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;;;GAIG;AACH;;8EAE8E;AAC9E,wBAAgB,8BAA8B,CAC1C,KAAK,EAAE,2BAA2B,EAClC,KAAK,CAAC,EAAE,MAAM,GACf,sBAAsB,CAqDxB;AAED,wBAAgB,4BAA4B,CACxC,KAAK,EAAE,2BAA2B,GACnC,sBAAsB,CAqGxB;AAaD,oFAAoF;AACpF,wBAAgB,0BAA0B,CACtC,KAAK,EAAE,IAAI,CAAC,2BAA2B,EAAE,UAAU,GAAG,YAAY,GAAG,SAAS,CAAC,GAChF,sBAAsB,CA0BxB"}
1
+ {"version":3,"file":"final-wire-token-estimate.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/final-wire-token-estimate.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,MAAM,WAAW,oBAAoB;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAwBD,oFAAoF;AACpF,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,SAAS,WAAW,EA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,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,YAAY,GAAG,iBAAiB,GAAG,YAAY,CAAC;IAC/D,aAAa,EAAE,oBAAoB,CAAC;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACjE,YAAY,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACtC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;;;GAIG;AACH;;8EAE8E;AAC9E,wBAAgB,8BAA8B,CAC1C,KAAK,EAAE,2BAA2B,EAClC,KAAK,CAAC,EAAE,MAAM,GACf,sBAAsB,CAsDxB;AAED,wBAAgB,4BAA4B,CACxC,KAAK,EAAE,2BAA2B,GACnC,sBAAsB,CA+GxB;AAaD,oFAAoF;AACpF,wBAAgB,0BAA0B,CACtC,KAAK,EAAE,IAAI,CAAC,2BAA2B,EAAE,UAAU,GAAG,YAAY,GAAG,SAAS,CAAC,GAChF,sBAAsB,CA0BxB"}
@@ -0,0 +1,16 @@
1
+ import type { ProtectedTailBoundarySnapshot } from "./protected-tail-boundary";
2
+ export declare function clearHistorianHistoryWait(sessionId: string): void;
3
+ export declare function recordHistorianNoProgress(snapshot: ProtectedTailBoundarySnapshot, emergency?: boolean): void;
4
+ /**
5
+ * Preview at the trigger; claim exceptions only when the runner is ready to send.
6
+ * Fork adaptation: upstream also spends one live-prompt-floor lift per failed
7
+ * history, but this fork never adopted the one-pass floor lift (declined
8
+ * protected admission exception, 2026-10-26), so only the force/emergency
9
+ * attempt is preserved here.
10
+ */
11
+ export declare function shouldWaitForNewHistorianHistory(snapshot: ProtectedTailBoundarySnapshot, options?: {
12
+ usagePercentage?: number;
13
+ emergency?: boolean;
14
+ claim?: boolean;
15
+ }): boolean;
16
+ //# sourceMappingURL=historian-history-wait.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"historian-history-wait.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/historian-history-wait.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAqC/E,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAEjE;AAED,wBAAgB,yBAAyB,CACrC,QAAQ,EAAE,6BAA6B,EACvC,SAAS,UAAQ,GAClB,IAAI,CAYN;AAED;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC5C,QAAQ,EAAE,6BAA6B,EACvC,OAAO,GAAE;IAAE,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GACjF,OAAO,CA4BT"}