@cortexkit/opencode-magic-context 0.22.5 → 0.23.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.
- package/dist/agents/magic-context-prompt.d.ts +1 -1
- package/dist/agents/magic-context-prompt.d.ts.map +1 -1
- package/dist/agents/permissions.d.ts +4 -4
- package/dist/agents/permissions.d.ts.map +1 -1
- package/dist/config/project-security.d.ts +5 -0
- package/dist/config/project-security.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +0 -13
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
- package/dist/features/magic-context/memory/constants.d.ts +7 -0
- package/dist/features/magic-context/memory/constants.d.ts.map +1 -1
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +1 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +83 -15
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-shared.d.ts +9 -2
- package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta.d.ts +1 -1
- package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
- package/dist/features/magic-context/storage-notes.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +118 -1
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/storage.d.ts +2 -2
- package/dist/features/magic-context/storage.d.ts.map +1 -1
- package/dist/features/magic-context/tagger.d.ts +12 -2
- package/dist/features/magic-context/tagger.d.ts.map +1 -1
- package/dist/features/magic-context/tool-definition-tokens.d.ts +0 -21
- package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -1
- package/dist/features/magic-context/tool-owner-backfill.d.ts +2 -1
- package/dist/features/magic-context/tool-owner-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/types.d.ts +8 -0
- package/dist/features/magic-context/types.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/channel2-delivery.d.ts +22 -0
- package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -0
- package/dist/hooks/magic-context/command-handler.d.ts +0 -1
- package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +5 -0
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts +47 -2
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/ctx-reduce-availability.d.ts +18 -0
- package/dist/hooks/magic-context/ctx-reduce-availability.d.ts.map +1 -0
- package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts +117 -0
- package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts.map +1 -0
- package/dist/hooks/magic-context/emergency-drop.d.ts +86 -0
- package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -0
- package/dist/hooks/magic-context/event-handler.d.ts +6 -4
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/execute-flush.d.ts.map +1 -1
- package/dist/hooks/magic-context/execute-status.d.ts +1 -1
- package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts +10 -3
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook-handlers.d.ts +3 -9
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +3 -5
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +0 -2
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/issue-135-wire-fixtures.d.ts +8 -0
- package/dist/hooks/magic-context/issue-135-wire-fixtures.d.ts.map +1 -0
- package/dist/hooks/magic-context/note-visibility.d.ts +1 -1
- package/dist/hooks/magic-context/openai-compat-adjacency.d.ts +38 -0
- package/dist/hooks/magic-context/openai-compat-adjacency.d.ts.map +1 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +132 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -0
- package/dist/hooks/magic-context/read-session-chunk.d.ts +55 -0
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts +91 -0
- package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts +70 -0
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -0
- package/dist/hooks/magic-context/send-session-notification.d.ts +2 -1
- package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts +0 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +3 -0
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/todo-view.d.ts +1 -1
- package/dist/hooks/magic-context/tool-drop-target.d.ts +9 -0
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +15 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +7 -10
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +14 -17
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/upgrade-reminder.d.ts +2 -1
- package/dist/hooks/magic-context/upgrade-reminder.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5215 -1140
- package/dist/plugin/conflict-warning-hook.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/plugin/tool-registry.d.ts.map +1 -1
- package/dist/shared/announcement.d.ts +4 -6
- package/dist/shared/announcement.d.ts.map +1 -1
- package/dist/shared/live-server-client.d.ts +50 -0
- package/dist/shared/live-server-client.d.ts.map +1 -0
- package/dist/shared/prompt-context.d.ts +31 -0
- package/dist/shared/prompt-context.d.ts.map +1 -0
- package/dist/shared/rpc-types.d.ts +0 -3
- package/dist/shared/rpc-types.d.ts.map +1 -1
- package/dist/shared/safe-notification-target.d.ts +23 -0
- package/dist/shared/safe-notification-target.d.ts.map +1 -0
- package/dist/shared/tag-transcript.d.ts.map +1 -1
- package/dist/shared/transcript-opencode.d.ts.map +1 -1
- package/dist/shared/transcript.d.ts +15 -1
- package/dist/shared/transcript.d.ts.map +1 -1
- package/dist/tools/ctx-expand/constants.d.ts +1 -1
- package/dist/tools/ctx-expand/constants.d.ts.map +1 -1
- package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
- package/dist/tools/ctx-memory/constants.d.ts +1 -1
- package/dist/tools/ctx-memory/constants.d.ts.map +1 -1
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-memory/types.d.ts +7 -3
- package/dist/tools/ctx-memory/types.d.ts.map +1 -1
- package/dist/tools/ctx-note/constants.d.ts +1 -1
- package/dist/tools/ctx-note/constants.d.ts.map +1 -1
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/dist/tools/ctx-note/types.d.ts +4 -0
- package/dist/tools/ctx-note/types.d.ts.map +1 -1
- package/dist/tools/ctx-search/constants.d.ts +1 -1
- package/dist/tools/ctx-search/constants.d.ts.map +1 -1
- package/dist/tui/data/context-db.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/shared/announcement.test.ts +18 -0
- package/src/shared/announcement.ts +35 -20
- package/src/shared/live-server-client.ts +152 -0
- package/src/shared/prompt-context.ts +135 -0
- package/src/shared/rpc-types.ts +0 -3
- package/src/shared/safe-notification-target.test.ts +97 -0
- package/src/shared/safe-notification-target.ts +102 -0
- package/src/shared/tag-transcript.test.ts +34 -8
- package/src/shared/tag-transcript.ts +110 -8
- package/src/shared/transcript-opencode.ts +15 -5
- package/src/shared/transcript.ts +20 -2
- package/src/tui/data/context-db.ts +0 -3
- package/src/tui/index.tsx +2 -5
- package/src/tui/slots/sidebar-content.tsx +1 -26
- package/dist/hooks/magic-context/apply-context-nudge.d.ts +0 -5
- package/dist/hooks/magic-context/apply-context-nudge.d.ts.map +0 -1
- package/dist/hooks/magic-context/nudge-bands.d.ts +0 -6
- package/dist/hooks/magic-context/nudge-bands.d.ts.map +0 -1
- package/dist/hooks/magic-context/nudge-injection.d.ts +0 -7
- package/dist/hooks/magic-context/nudge-injection.d.ts.map +0 -1
- package/dist/hooks/magic-context/nudge-placement-store.d.ts +0 -15
- package/dist/hooks/magic-context/nudge-placement-store.d.ts.map +0 -1
- package/dist/hooks/magic-context/nudger.d.ts +0 -21
- package/dist/hooks/magic-context/nudger.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-session-chunk.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/read-session-chunk.ts"],"names":[],"mappings":"AAOA,OAAO,EAWH,KAAK,gBAAgB,EACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACH,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"read-session-chunk.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/read-session-chunk.ts"],"names":[],"mappings":"AAOA,OAAO,EAWH,KAAK,gBAAgB,EACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACH,KAAK,UAAU,EAIlB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAUhF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,kBAAkB;IAC/B,YAAY,IAAI,UAAU,EAAE,CAAC;IAC7B,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,UAAU,GAAG,IAAI,CAAC;IAC3D,qEAAqE;IACrE,eAAe,CAAC,EAAE,MAAM,MAAM,CAAC;CAClC;AAID;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,GAAG,MAAM,IAAI,CAMjG;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EACpC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,kBAAkB,EAC5B,EAAE,EAAE,MAAM,CAAC,GACZ,CAAC,CAkBH;AAED,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,MAAM,WAAW,YAAY;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,gBAAgB,EAAE,CAAC;IA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jB,gBAAgB,EAAE,MAAM,GACzB,iBAAiB,CA2DnB;AAID,wBAAgB,kCAAkC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAS5E;AAED,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,wBAAgB,gBAAgB,CAC5B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,MAAU,EAClB,kBAAkB,CAAC,EAAE,MAAM,GAC5B,YAAY,CAqMd;AAED,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAK9F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-session-formatting.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/read-session-formatting.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB;;;;;OAKG;IACH,UAAU,EAAE,OAAO,CAAC;CACvB;AAMD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAiB/D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CAUvD;AAED;4EAC4E;AAC5E,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CA2BnE;AAoCD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"read-session-formatting.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/read-session-formatting.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB;;;;;OAKG;IACH,UAAU,EAAE,OAAO,CAAC;CACvB;AAMD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAiB/D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CAUvD;AAED;4EAC4E;AAC5E,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CA2BnE;AAoCD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAYnD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAQrD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAW1D;AAED,wBAAgB,qBAAqB,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACb;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAA;CAAE,CAmB1C;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAS9E"}
|
|
@@ -4,7 +4,98 @@ export interface RawMessage {
|
|
|
4
4
|
id: string;
|
|
5
5
|
role: string;
|
|
6
6
|
parts: unknown[];
|
|
7
|
+
version?: string | number | null;
|
|
7
8
|
}
|
|
8
9
|
export declare function readRawSessionMessagesFromDb(db: Database, sessionId: string): RawMessage[];
|
|
10
|
+
/**
|
|
11
|
+
* Read ONLY the eligible tail — messages at/after the last compartment boundary
|
|
12
|
+
* — assigning them their correct ABSOLUTE ordinals (continuing from
|
|
13
|
+
* `baseOrdinal`), and return the absolute session message count alongside.
|
|
14
|
+
*
|
|
15
|
+
* This is the O(tail) read: it never touches the ~63k pre-boundary rows that the
|
|
16
|
+
* full reader scans just to recover the tail's ordinal base — a number the
|
|
17
|
+
* compaction marker already stores (`end_message` ordinal + `end_message_id`
|
|
18
|
+
* anchor). On a months-long session the full read is O(session) and grows
|
|
19
|
+
* unbounded; this stays flat at the tail size.
|
|
20
|
+
*
|
|
21
|
+
* Anchor semantics: reads rows with `(time_created, id) >= anchor` (INCLUSIVE of
|
|
22
|
+
* the boundary message), in the same sort order as the full reader, filters
|
|
23
|
+
* compaction-summary rows identically, and numbers the kept messages
|
|
24
|
+
* `baseOrdinal, baseOrdinal+1, …`. Including the anchor keeps
|
|
25
|
+
* `messageIdAtOrdinal(baseOrdinal)` real (the full reader has it too) so
|
|
26
|
+
* boundary-edge message ids match.
|
|
27
|
+
*
|
|
28
|
+
* Returns null when the anchor message id isn't found (deleted / legacy
|
|
29
|
+
* compartment without `end_message_id`); the caller then falls back to the full
|
|
30
|
+
* read. `absoluteMessageCount` = `baseOrdinal + (keptTail - 1)` = the exact
|
|
31
|
+
* count the full reader would produce, so every absolute-ordinal consumer lines
|
|
32
|
+
* up.
|
|
33
|
+
*/
|
|
34
|
+
export declare function readRawSessionTailFromDb(db: Database, sessionId: string, baseOrdinal: number, anchorMessageId: string): {
|
|
35
|
+
messages: RawMessage[];
|
|
36
|
+
absoluteMessageCount: number;
|
|
37
|
+
} | null;
|
|
38
|
+
/**
|
|
39
|
+
* Minimal structural view of an in-memory transform message, extracted from
|
|
40
|
+
* OpenCode's `MessageLike` by the caller. Kept dependency-free so this module
|
|
41
|
+
* doesn't import the transform/tagging layer.
|
|
42
|
+
*/
|
|
43
|
+
export interface InMemoryMessageView {
|
|
44
|
+
id: string;
|
|
45
|
+
role: string;
|
|
46
|
+
parts: unknown[];
|
|
47
|
+
/** From the message `info` if present; used to mirror the DB summary filter. */
|
|
48
|
+
summary?: boolean;
|
|
49
|
+
finish?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface InMemoryTailResult {
|
|
52
|
+
messages: RawMessage[];
|
|
53
|
+
absoluteMessageCount: number;
|
|
54
|
+
/** True when the compaction anchor id was located within the array. */
|
|
55
|
+
anchorFound: boolean;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Extract the minimal structural view from OpenCode transform messages
|
|
59
|
+
* (`args.messages`, MessageLike-shaped: `{ info, parts }`). Tolerates missing
|
|
60
|
+
* fields — a message without a string id becomes an empty-id view, which
|
|
61
|
+
* `buildInMemoryTailRawMessages` treats as a malformed row (ordinal slot kept,
|
|
62
|
+
* no element), mirroring the DB reader.
|
|
63
|
+
*/
|
|
64
|
+
export declare function extractInMemoryMessageViews(messages: readonly {
|
|
65
|
+
info?: unknown;
|
|
66
|
+
parts?: unknown;
|
|
67
|
+
}[]): InMemoryMessageView[];
|
|
68
|
+
/**
|
|
69
|
+
* Build an absolute-ordinal `RawMessage[]` tail from the in-memory transform
|
|
70
|
+
* messages (`args.messages`), mirroring {@link readRawSessionTailFromDb} so the
|
|
71
|
+
* boundary resolver produces an identical result without any opencode.db read.
|
|
72
|
+
*
|
|
73
|
+
* OpenCode hands the transform the post-compaction-marker tail, i.e. the eligible
|
|
74
|
+
* window, already parsed. Ordinals are anchored at the last compartment boundary:
|
|
75
|
+
*
|
|
76
|
+
* - If `anchorMessageId` is found at index k, that message IS the boundary
|
|
77
|
+
* (ordinal `lastCompartmentEnd`); messages k, k+1, … get ordinals
|
|
78
|
+
* `lastCompartmentEnd, lastCompartmentEnd+1, …`. Messages before k (compaction
|
|
79
|
+
* marker lag — already compartmentalized) are dropped, matching the DB tail
|
|
80
|
+
* which starts AT the anchor.
|
|
81
|
+
* - If the anchor isn't present (it was a summary row OpenCode already filtered,
|
|
82
|
+
* or marker is ahead), the array is assumed to start at `lastCompartmentEnd+1`
|
|
83
|
+
* and ordinals run `lastCompartmentEnd+1, …`. `anchorFound=false` flags this so
|
|
84
|
+
* callers can choose the DB fallback if they don't trust the assumption.
|
|
85
|
+
* - No compartments yet (#132): pass `lastCompartmentEnd=0`,
|
|
86
|
+
* `anchorMessageId=null` → ordinals from 1 over the whole array.
|
|
87
|
+
*
|
|
88
|
+
* Mirrors the DB reader's contracts: compaction-summary rows
|
|
89
|
+
* (`summary===true && finish==='stop'`) are filtered BEFORE ordinal assignment;
|
|
90
|
+
* a malformed message (no string id) keeps its ordinal slot but yields no element;
|
|
91
|
+
* `absoluteMessageCount` equals what the DB reader would report for the same tail.
|
|
92
|
+
*
|
|
93
|
+
* Returns null when there are no usable messages.
|
|
94
|
+
*/
|
|
95
|
+
export declare function buildInMemoryTailRawMessages(args: {
|
|
96
|
+
messages: readonly InMemoryMessageView[];
|
|
97
|
+
lastCompartmentEnd: number;
|
|
98
|
+
anchorMessageId: string | null;
|
|
99
|
+
}): InMemoryTailResult | null;
|
|
9
100
|
export declare function readRawSessionMessageByIdFromDb(db: Database, sessionId: string, messageId: string): RawMessage | null;
|
|
10
101
|
//# sourceMappingURL=read-session-raw.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-session-raw.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/read-session-raw.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,WAAW,UAAU;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"read-session-raw.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/read-session-raw.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,WAAW,UAAU;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CACpC;AAmED,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,CA0C1F;AAgBD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,wBAAwB,CACpC,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,GACxB;IAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;IAAC,oBAAoB,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA6EjE;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,gFAAgF;IAChF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,uEAAuE;IACvE,WAAW,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACvC,QAAQ,EAAE,SAAS;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,EAAE,GACzD,mBAAmB,EAAE,CAWvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE;IAC/C,QAAQ,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACzC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,GAAG,kBAAkB,GAAG,IAAI,CA+C5B;AAED,wBAAgB,+BAA+B,CAC3C,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAClB,UAAU,GAAG,IAAI,CA8CnB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { RawMessage } from "./read-session-raw";
|
|
2
|
+
export interface TrueRawTokenBreakdown {
|
|
3
|
+
text: number;
|
|
4
|
+
reasoning: number;
|
|
5
|
+
toolInput: number;
|
|
6
|
+
toolOutput: number;
|
|
7
|
+
image: number;
|
|
8
|
+
other: number;
|
|
9
|
+
total: number;
|
|
10
|
+
}
|
|
11
|
+
export interface TrueRawEstimateOptions {
|
|
12
|
+
providerShapeVersion: "opencode-v1" | "pi-folded-v1";
|
|
13
|
+
imageTokenHeuristic?: (part: unknown) => number;
|
|
14
|
+
}
|
|
15
|
+
export interface TrueRawTokenIndex {
|
|
16
|
+
readonly sessionId: string;
|
|
17
|
+
readonly providerShapeVersion: string;
|
|
18
|
+
readonly rawMessageCount: number;
|
|
19
|
+
tokenForOrdinal(ordinal: number): number;
|
|
20
|
+
messageIdAtOrdinal(ordinal: number): string | null;
|
|
21
|
+
suffixTokensFromOrdinal(ordinal: number): number;
|
|
22
|
+
rangeTokens(startInclusive: number, endExclusive: number): number;
|
|
23
|
+
findSuffixStartForTokens(tokens: number): number;
|
|
24
|
+
findHeadEndForCap(startInclusive: number, endExclusive: number, capTokens: number): number;
|
|
25
|
+
}
|
|
26
|
+
export interface ToolArc {
|
|
27
|
+
callId: string;
|
|
28
|
+
invOrdinal: number;
|
|
29
|
+
resOrdinal: number | null;
|
|
30
|
+
}
|
|
31
|
+
export interface TrueRawTokenIndexBuildOptions extends TrueRawEstimateOptions {
|
|
32
|
+
cacheNamespace: string;
|
|
33
|
+
/**
|
|
34
|
+
* Durable per-message token source. When provided and it returns a non-null
|
|
35
|
+
* value for a message, that value is used as the message's total instead of
|
|
36
|
+
* live-tokenizing its parts — this is how the protected-tail boundary reads
|
|
37
|
+
* the precomputed `tags.token_count` store (restart-durable) rather than
|
|
38
|
+
* re-tokenizing the whole raw session every cold pass. Returning null falls
|
|
39
|
+
* back to live tokenization for that message (untagged / legacy-NULL rows),
|
|
40
|
+
* which converges to the stored path once the tagger backfills.
|
|
41
|
+
*/
|
|
42
|
+
storedTotalForMessage?: (message: RawMessage) => number | null;
|
|
43
|
+
/**
|
|
44
|
+
* Absolute total message count for the session, when `messages` is a
|
|
45
|
+
* TAIL-ONLY slice carrying absolute ordinals (e.g. only messages after the
|
|
46
|
+
* last compartment boundary). The prefix/suffix machinery is sized to this
|
|
47
|
+
* count and ordinals outside the supplied slice contribute zero tokens —
|
|
48
|
+
* which is exactly correct for every offset-forward query the protected-tail
|
|
49
|
+
* boundary makes (its candidate, suffix, range, and head-cap reads never
|
|
50
|
+
* cross below the eligible offset). Lets the boundary resolve from only the
|
|
51
|
+
* eligible tail instead of reading the whole session every pass.
|
|
52
|
+
*
|
|
53
|
+
* Omitted for whole-session callers: defaults to `messages.length`, and with
|
|
54
|
+
* contiguous 1..N ordinals the result is byte-identical to the prior
|
|
55
|
+
* index-positional fill.
|
|
56
|
+
*/
|
|
57
|
+
absoluteMessageCount?: number;
|
|
58
|
+
}
|
|
59
|
+
export declare function estimateTrueRawMessageTokens(message: RawMessage, options: TrueRawEstimateOptions): TrueRawTokenBreakdown;
|
|
60
|
+
export declare function buildToolArcs(messages: readonly RawMessage[]): ToolArc[];
|
|
61
|
+
export declare function fenceBoundaryForToolArcs(candidate: number, arcs: readonly ToolArc[], lastCompartmentEndOrdinal: number): number;
|
|
62
|
+
export declare function buildTrueRawTokenIndex(sessionId: string, messages: readonly RawMessage[], options: TrueRawTokenIndexBuildOptions): TrueRawTokenIndex;
|
|
63
|
+
export declare function computeRawRangeFingerprint(messages: readonly RawMessage[], startInclusive: number, endExclusive: number): string;
|
|
64
|
+
export declare function invalidateTrueRawTokenCache(args: {
|
|
65
|
+
sessionId?: string;
|
|
66
|
+
messageId?: string;
|
|
67
|
+
reason: "message.updated" | "message.removed" | "session.compacted" | "session.deleted" | "pi.branch.changed" | "pi.stable-id-scheme.changed" | "provider.unregistered" | "schema.migration";
|
|
68
|
+
}): void;
|
|
69
|
+
export declare function buildTrueRawTokenIndexFromTokenCountsForTest(sessionId: string, tokens: readonly number[]): TrueRawTokenIndex;
|
|
70
|
+
//# sourceMappingURL=read-session-true-raw-tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-session-true-raw-tokens.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/read-session-true-raw-tokens.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,WAAW,qBAAqB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACnC,oBAAoB,EAAE,aAAa,GAAG,cAAc,CAAC;IACrD,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,CAAC;CACnD;AAED,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AAE,MAAM,GAClC,MAAM,CAiBR;AAcD,wBAAgB,sBAAsB,CAClC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,SAAS,UAAU,EAAE,EAC/B,OAAO,EAAE,6BAA6B,GACvC,iBAAiB,CA+GnB;AA4BD,wBAAgB,0BAA0B,CACtC,QAAQ,EAAE,SAAS,UAAU,EAAE,EAC/B,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,GACrB,MAAM,CAQR;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EACA,iBAAiB,GACjB,iBAAiB,GACjB,mBAAmB,GACnB,iBAAiB,GACjB,mBAAmB,GACnB,6BAA6B,GAC7B,uBAAuB,GACvB,kBAAkB,CAAC;CAC5B,GAAG,IAAI,CAYP;AAED,wBAAgB,4CAA4C,CACxD,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,SAAS,MAAM,EAAE,GAC1B,iBAAiB,CA2DnB"}
|
|
@@ -4,7 +4,8 @@ export interface NotificationParams {
|
|
|
4
4
|
providerId?: string;
|
|
5
5
|
modelId?: string;
|
|
6
6
|
}
|
|
7
|
-
export
|
|
7
|
+
export type NotificationDeliveryDisposition = "sent" | "skipped" | "failed";
|
|
8
|
+
export declare function sendIgnoredMessage(client: unknown, sessionId: string, text: string, params: NotificationParams, forcePersist?: boolean): Promise<NotificationDeliveryDisposition>;
|
|
8
9
|
/**
|
|
9
10
|
* Send a real user prompt that will be processed by the model (not ignored).
|
|
10
11
|
* Used by /ctx-aug to inject the augmented prompt after sidekick completes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-session-notification.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/send-session-notification.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"send-session-notification.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/send-session-notification.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,+BAA+B,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;AAoD5E,wBAAsB,kBAAkB,CACpC,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,kBAAkB,EAK1B,YAAY,UAAQ,GACrB,OAAO,CAAC,+BAA+B,CAAC,CA0F1C;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAChC,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CA0Bf"}
|
|
@@ -24,7 +24,6 @@ export declare function createSystemPromptHashHandler(deps: {
|
|
|
24
24
|
db: ContextDatabase;
|
|
25
25
|
protectedTags: number;
|
|
26
26
|
ctxReduceEnabled: boolean;
|
|
27
|
-
dropToolStructure: boolean;
|
|
28
27
|
dreamerEnabled: boolean;
|
|
29
28
|
/** When true + dreamerEnabled, inject ARCHITECTURE.md and STRUCTURE.md into system prompt */
|
|
30
29
|
injectDocs: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt-hash.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/system-prompt-hash.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,eAAe,EAGvB,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"system-prompt-hash.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/system-prompt-hash.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,eAAe,EAGvB,MAAM,sCAAsC,CAAC;AAW9C;;;;;GAKG;AACH,wBAAgB,4BAA4B,CACxC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE;IACR,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;CACnD,GACF,IAAI,CAIN;AA+ED;;;;;;;;;;GAUG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IAChD,EAAE,EAAE,eAAe,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,OAAO,CAAC;IACxB,6FAA6F;IAC7F,UAAU,EAAE,OAAO,CAAC;IACpB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,2BAA2B,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzC;;;;;;OAMG;IACH,sBAAsB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,8BAA8B,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5C,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;OAMG;IACH,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;IACnC;;;;;;;OAOG;IACH,qBAAqB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,4EAA4E;IAC5E,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,mEAAmE;IACnE,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,mEAAmE;IACnE,kCAAkC,CAAC,EAAE,MAAM,CAAC;IAC5C,yFAAyF;IACzF,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC;qFACiF;IACjF,kCAAkC,CAAC,EAAE,OAAO,CAAC;CAChD,GAAG;IACA,OAAO,EAAE,CAAC,KAAK,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxF,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C,CA0RA"}
|
|
@@ -20,6 +20,9 @@ export type TagTarget = {
|
|
|
20
20
|
getContent?: () => string | null;
|
|
21
21
|
drop?: () => ToolDropResult;
|
|
22
22
|
truncate?: () => ToolDropResult;
|
|
23
|
+
/** Non-mutating: would drop()/truncate() actually reclaim bytes? Tool
|
|
24
|
+
* targets only; absent on message/file targets. */
|
|
25
|
+
canDrop?: () => boolean;
|
|
23
26
|
message?: MessageLike;
|
|
24
27
|
};
|
|
25
28
|
export interface TagMessagesResult {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag-messages.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/tag-messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAQ5E,OAAO,EAAwB,KAAK,MAAM,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"tag-messages.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/tag-messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAQ5E,OAAO,EAAwB,KAAK,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAexF,OAAO,EAGH,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,iBAAiB,EACp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WAAW,CACvB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,WAAW,EAAE,EACvB,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,eAAe,EACnB,OAAO,GAAE,kBAAuB,GACjC,iBAAiB,CAwZnB"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* only — no message mutation.
|
|
14
14
|
* - Injection happens in transform-postprocess-phase.ts AFTER tagging and
|
|
15
15
|
* AFTER applyPendingOperations, so the synthetic part never gets tagged
|
|
16
|
-
* and is invisible to ctx_reduce
|
|
16
|
+
* and is invisible to ctx_reduce and heuristic cleanup.
|
|
17
17
|
* - The synthetic callID is deterministic (sha256(stateJson)) so a stable
|
|
18
18
|
* snapshot produces a stable wire shape across passes; on defer passes we
|
|
19
19
|
* re-inject the same part at the same anchor, idempotent via callID match.
|
|
@@ -43,6 +43,15 @@ export declare function createToolDropTarget(compositeKey: string, thinkingParts
|
|
|
43
43
|
setContent: (content: string) => boolean;
|
|
44
44
|
drop: () => ToolDropResult;
|
|
45
45
|
truncate: () => ToolDropResult;
|
|
46
|
+
/**
|
|
47
|
+
* Non-mutating predicate: would drop()/truncate() actually remove bytes?
|
|
48
|
+
* False for an absent (compacted-away) or incomplete (invocation present,
|
|
49
|
+
* no result part) entry — both return early without reclaiming anything.
|
|
50
|
+
* The tiered emergency planner must filter on this, not on the mere
|
|
51
|
+
* presence of a drop() function: counting a no-reclaim tag as droppable
|
|
52
|
+
* makes the plan stop early and under-evict below the ceiling.
|
|
53
|
+
*/
|
|
54
|
+
canDrop: () => boolean;
|
|
46
55
|
};
|
|
47
56
|
export {};
|
|
48
57
|
//# sourceMappingURL=tool-drop-target.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-drop-target.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/tool-drop-target.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AA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AAc,CAAC;IAC3B,QAAQ,EAAE,MAAM,cAAc,CAAC;IAC/B;;;;;;;OAOG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC;CAC1B,CAuDA"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type ContextDatabase } from "../../features/magic-context/storage";
|
|
2
|
+
import type { ContextUsage } from "../../features/magic-context/types";
|
|
2
3
|
import type { PluginContext } from "../../plugin/types";
|
|
3
4
|
import { type PreparedCompartmentInjection } from "./inject-compartments";
|
|
5
|
+
import { type ProtectedTailBoundarySnapshot } from "./protected-tail-boundary";
|
|
4
6
|
import type { MessageLike } from "./transform-operations";
|
|
5
7
|
interface RunCompartmentPhaseArgs {
|
|
6
8
|
canRunCompartments: boolean;
|
|
@@ -13,6 +15,10 @@ interface RunCompartmentPhaseArgs {
|
|
|
13
15
|
contextUsage: {
|
|
14
16
|
percentage: number;
|
|
15
17
|
};
|
|
18
|
+
boundaryContextLimit: number;
|
|
19
|
+
boundaryExecuteThresholdPercentage: number;
|
|
20
|
+
boundaryUsage: ContextUsage;
|
|
21
|
+
boundaryUsageSource: "live" | "persisted" | "provisional-zero" | "manual-none";
|
|
16
22
|
client?: PluginContext["client"];
|
|
17
23
|
db: ContextDatabase;
|
|
18
24
|
sessionId: string;
|
|
@@ -46,6 +52,15 @@ interface RunCompartmentPhaseArgs {
|
|
|
46
52
|
autoPromote?: boolean;
|
|
47
53
|
/** Forwarded to compartment runner — see CompartmentRunnerDeps.onCompartmentStatePublished. */
|
|
48
54
|
onCompartmentStatePublished?: (sessionId: string) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Boundary snapshot already resolved by THIS pass's trigger decision
|
|
57
|
+
* (transform-located trigger). When present and runnable, the phase uses it
|
|
58
|
+
* instead of re-resolving — one boundary resolution per pass, and the
|
|
59
|
+
* historian starts from exactly the snapshot the fire decision saw. The
|
|
60
|
+
* ≥80% emergency re-scale fallback below still re-resolves when this
|
|
61
|
+
* snapshot has no runnable window.
|
|
62
|
+
*/
|
|
63
|
+
preResolvedBoundarySnapshot?: ProtectedTailBoundarySnapshot;
|
|
49
64
|
}
|
|
50
65
|
export declare function runCompartmentPhase(args: RunCompartmentPhaseArgs): Promise<{
|
|
51
66
|
pendingCompartmentInjection: PreparedCompartmentInjection | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-compartment-phase.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/transform-compartment-phase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transform-compartment-phase.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/transform-compartment-phase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAqB,MAAM,sCAAsC,CAAC;AAC/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQxD,OAAO,EACH,KAAK,4BAA4B,EAEpC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGH,KAAK,6BAA6B,EAErC,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,UAAU,uBAAuB;IAC7B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;IACzB,iFAAiF;IACjF,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE;QAAE,qBAAqB,EAAE,OAAO,CAAA;KAAE,CAAC;IAChD,YAAY,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IACrC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kCAAkC,EAAE,MAAM,CAAC;IAC3C,aAAa,EAAE,YAAY,CAAC;IAC5B,mBAAmB,EAAE,MAAM,GAAG,WAAW,GAAG,kBAAkB,GAAG,aAAa,CAAC;IAC/E,MAAM,CAAC,EAAE,aAAa,CAAC,QA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AE,6BAA6B,CAAC;CAC/D;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC;IAC9E,2BAA2B,EAAE,4BAA4B,GAAG,IAAI,CAAC;IACjE,qBAAqB,EAAE,OAAO,CAAC;IAC/B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,sBAAsB,EAAE,OAAO,CAAC;IAChC,sBAAsB,EAAE,OAAO,CAAC;CACnC,CAAC,CA8PD"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { type ContextDatabase
|
|
1
|
+
import { type ContextDatabase } from "../../features/magic-context/storage";
|
|
2
2
|
import type { SessionMeta, TagEntry } from "../../features/magic-context/types";
|
|
3
3
|
import { type M0HardSignals, type PreparedCompartmentInjection } from "./inject-compartments";
|
|
4
|
-
import type { NudgePlacementStore } from "./nudge-placement-store";
|
|
5
|
-
import type { ContextNudge } from "./nudger";
|
|
6
4
|
import { type MessageLike, type TagTarget } from "./transform-operations";
|
|
7
5
|
export declare function resetDegradedCacheCount(sessionId: string): void;
|
|
8
6
|
interface RunPostTransformPhaseArgs {
|
|
@@ -49,15 +47,14 @@ interface RunPostTransformPhaseArgs {
|
|
|
49
47
|
deferredHistoryRefreshSessions: Set<string>;
|
|
50
48
|
deferredMaterializationSessions: Set<string>;
|
|
51
49
|
lastHeuristicsTurnId: Map<string, string>;
|
|
52
|
-
autoDropToolAge: number;
|
|
53
|
-
dropToolStructure: boolean;
|
|
54
50
|
clearReasoningAge: number;
|
|
55
51
|
protectedTags: number;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Ceiling for the tiered emergency drop = contextLimit × executeThreshold%.
|
|
54
|
+
* Undefined when the context limit isn't resolved (cold start) — the
|
|
55
|
+
* emergency drop then skips (the 95% block stays the backstop).
|
|
56
|
+
*/
|
|
57
|
+
emergencyCeilingTokens?: number;
|
|
61
58
|
pendingCompartmentInjection: PreparedCompartmentInjection | null;
|
|
62
59
|
didMutateFromFlushedStatuses: boolean;
|
|
63
60
|
watermark: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-postprocess-phase.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/transform-postprocess-phase.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"transform-postprocess-phase.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/transform-postprocess-phase.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,eAAe,EAkBvB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAShF,OAAO,EAIH,KAAK,aAAa,EAElB,KAAK,4BAA4B,EAEpC,MAAM,uBAAuB,CAAC;AAkB/B,OAAO,EAEH,KAAK,WAAW,EAEhB,KAAK,SAAS,EAEjB,MAAM,wBAAwB,CAAC;AAQhC,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAE/D;AAED,UAAU,yBAAyB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,eAAe,CAAC;IACpB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAChC,kBAAkB,EAAE,GAAG,CAAC,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC,CAAC;IAC3F,iBAAiB,EAAE,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAC5C,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,IAAI,C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AAM,CAAC,CAAC;CACxC,GAAG,OAAO,CAaV"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import type { Scheduler } from "../../features/magic-context/scheduler";
|
|
2
|
-
import { type ContextDatabase
|
|
2
|
+
import { type ContextDatabase } from "../../features/magic-context/storage";
|
|
3
3
|
import type { Tagger } from "../../features/magic-context/tagger";
|
|
4
|
-
import type { ContextUsage
|
|
4
|
+
import type { ContextUsage } from "../../features/magic-context/types";
|
|
5
5
|
import type { PluginContext } from "../../plugin/types";
|
|
6
|
-
import type { NudgePlacementStore } from "./nudge-placement-store";
|
|
7
|
-
import type { ContextNudge } from "./nudger";
|
|
8
|
-
export { createNudgePlacementStore, type NudgePlacementStore } from "./nudge-placement-store";
|
|
9
6
|
import type { LiveModelBySession } from "./hook-handlers";
|
|
10
7
|
export declare function clearMessageTokensCache(sessionId: string, messageId?: string): void;
|
|
11
8
|
/**
|
|
@@ -25,9 +22,14 @@ export interface TransformDeps {
|
|
|
25
22
|
updatedAt: number;
|
|
26
23
|
lastResponseTime?: number;
|
|
27
24
|
}>;
|
|
28
|
-
nudger: (sessionId: string, contextUsage: ContextUsage, db: ContextDatabase, topNFn: typeof getTopNBySize, preloadedTags?: TagEntry[], messagesSinceLastUser?: number, preloadedSessionMeta?: import("../../features/magic-context/types").SessionMeta) => ContextNudge | null;
|
|
29
25
|
db: ContextDatabase;
|
|
30
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Channel 1 (ctx_reduce tool-output nudge) per-session metric baseline,
|
|
28
|
+
* refreshed at the end of each primary-session transform pass and read in
|
|
29
|
+
* tool.execute.after. Subagents never get a snapshot, which is how Channel 1
|
|
30
|
+
* stays primary-only.
|
|
31
|
+
*/
|
|
32
|
+
channel1StateBySession?: Map<string, import("./ctx-reduce-nudge").Channel1State>;
|
|
31
33
|
protectedTags: number;
|
|
32
34
|
/**
|
|
33
35
|
* Primary-session ctx_reduce setting. When false, tag prefix injection is
|
|
@@ -37,9 +39,12 @@ export interface TransformDeps {
|
|
|
37
39
|
* Defaults to true when omitted (preserves legacy behavior for tests).
|
|
38
40
|
*/
|
|
39
41
|
ctxReduceEnabled?: boolean;
|
|
40
|
-
autoDropToolAge: number;
|
|
41
|
-
dropToolStructure?: boolean;
|
|
42
42
|
clearReasoningAge: number;
|
|
43
|
+
/** Commit-cluster historian trigger config (`commit_cluster_trigger`). */
|
|
44
|
+
commitClusterTrigger?: {
|
|
45
|
+
enabled: boolean;
|
|
46
|
+
min_clusters: number;
|
|
47
|
+
};
|
|
43
48
|
/**
|
|
44
49
|
* One-shot signal that `<session-history>` injection cache is stale and
|
|
45
50
|
* `prepareCompartmentInjection` should rebuild on this pass. Drained
|
|
@@ -92,14 +97,6 @@ export interface TransformDeps {
|
|
|
92
97
|
getNotificationParams?: (sessionId: string) => import("./send-session-notification").NotificationParams;
|
|
93
98
|
getModelKey?: (sessionId: string) => string | undefined;
|
|
94
99
|
getFallbackModelId?: (sessionId: string) => string | undefined;
|
|
95
|
-
/**
|
|
96
|
-
* Combined fingerprint of the current tool set for this session's
|
|
97
|
-
* provider/model/agent, used as a HARD-bust marker (the provider `tools`
|
|
98
|
-
* block sits before `system` and a tool change is invisible to the system
|
|
99
|
-
* hash). Returns "" when unknown (no tool.definition fire yet) → treated as
|
|
100
|
-
* "no signal", never a spurious fold.
|
|
101
|
-
*/
|
|
102
|
-
getToolSetHash?: (sessionId: string) => string;
|
|
103
100
|
projectPath?: string;
|
|
104
101
|
experimentalUserMemories?: boolean;
|
|
105
102
|
experimentalPinKeyFiles?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/transform.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/transform.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAGxE,OAAO,EACH,KAA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AI,CAAC,CAwjDnB;AAED,wBAAgB,0BAA0B,CACtC,uBAAuB,EAAE,MAAM,GAAG,SAAS,EAC3C,YAAY,EAAE,YAAY,EAC1B,0BAA0B,EACpB,MAAM,GACN;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAC/C,SAAS,EACf,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,sBAAsB,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CAAE,EACrF,oBAAoB,CAAC,EAAE,MAAM,GAC9B,MAAM,GAAG,SAAS,CAqCpB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Database } from "../../shared/sqlite";
|
|
2
|
+
import type { NotificationDeliveryDisposition } from "./send-session-notification";
|
|
2
3
|
declare const UPGRADE_REMINDER_TEXT: string;
|
|
3
4
|
/** A compartment needs upgrading when it lacks usable v2 tiers — either a pre-v2
|
|
4
5
|
* `legacy=1` row, OR a malformed "pseudo-v2" row flagged `legacy=0` but with no
|
|
@@ -30,7 +31,7 @@ export interface UpgradeReminderDeps {
|
|
|
30
31
|
db: Database;
|
|
31
32
|
/** Delivers a model-invisible ignored message to the session (non-TUI path:
|
|
32
33
|
* Desktop/headless, where it persists in scrollback). */
|
|
33
|
-
sendIgnoredMessage: (client: unknown, sessionId: string, text: string, params: Record<string, unknown>) => Promise<
|
|
34
|
+
sendIgnoredMessage: (client: unknown, sessionId: string, text: string, params: Record<string, unknown>) => Promise<NotificationDeliveryDisposition>;
|
|
34
35
|
/** Live notification params (model/variant/agent) for the active session. */
|
|
35
36
|
getNotificationParams: (sessionId: string) => Record<string, unknown>;
|
|
36
37
|
/** True when a TUI client is actively polling FOR THIS SESSION (decides
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-reminder.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/upgrade-reminder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"upgrade-reminder.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/upgrade-reminder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AA2BnF,QAAA,MAAM,qBAAqB,QAYf,CAAC;AAEb;;;;;;kFAMkF;AAClF,eAAO,MAAM,iBAAiB,0CAA0C,CAAC;AAEzE;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAWvF;AAMD;;;+EAG+E;AAC/E,MAAM,WAAW,UAAU;IACvB,+CAA+C;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,aAAa,EAAE,MAAM,CAAC;CACzB;AA6BD,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,EAAE,EAAE,QAAQ,CAAC;IACb;8DAC0D;IAC1D,kBAAkB,EAAE,CAChB,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,OAAO,CAAC,+BAA+B,CAAC,CAAC;IAC9C,6EAA6E;IAC7E,qBAAqB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtE;;;;;yCAKqC;IACrC,cAAc,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IACjD;;;6CAGyC;IACzC,mBAAmB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACvE;;;;;;;;;;;8BAW0B;IAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC1C,IAAI,EAAE,mBAAmB,EACzB,SAAS,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CA0Hf;AAED,8CAA8C;AAC9C,wBAAgB,kCAAkC,IAAI,IAAI,CAEzD;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AA8ClD,QAAA,MAAM,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AA8ClD,QAAA,MAAM,MAAM,EAAE,MA6hBb,CAAC;AAEF,eAAe,MAAM,CAAC"}
|