@wolfx/opencode-magic-context 0.28.0 → 0.30.3

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 (108) hide show
  1. package/dist/agents/magic-context-prompt.d.ts +1 -1
  2. package/dist/agents/magic-context-prompt.d.ts.map +1 -1
  3. package/dist/config/schema/magic-context.d.ts +11 -0
  4. package/dist/config/schema/magic-context.d.ts.map +1 -1
  5. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  6. package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts +0 -1
  7. package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts.map +1 -1
  8. package/dist/features/magic-context/dreamer/storage-task-schedule.d.ts +10 -0
  9. package/dist/features/magic-context/dreamer/storage-task-schedule.d.ts.map +1 -1
  10. package/dist/features/magic-context/dreamer/task-executor.d.ts +0 -3
  11. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  12. package/dist/features/magic-context/dreamer/task-prompts.d.ts +1 -1
  13. package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
  14. package/dist/features/magic-context/dreamer/task-registry.d.ts +0 -1
  15. package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
  16. package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
  17. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  18. package/dist/features/magic-context/recursive-text-splitter.d.ts +36 -0
  19. package/dist/features/magic-context/recursive-text-splitter.d.ts.map +1 -0
  20. package/dist/features/magic-context/smart-notes/sandbox-runner.d.ts.map +1 -1
  21. package/dist/features/magic-context/storage-db.d.ts +2 -21
  22. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  23. package/dist/features/magic-context/storage-schema-helpers.d.ts +30 -0
  24. package/dist/features/magic-context/storage-schema-helpers.d.ts.map +1 -0
  25. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  26. package/dist/features/magic-context/types.d.ts +12 -1
  27. package/dist/features/magic-context/types.d.ts.map +1 -1
  28. package/dist/hooks/magic-context/apply-operations.d.ts +8 -1
  29. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  30. package/dist/hooks/magic-context/channel2-delivery.d.ts +9 -5
  31. package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -1
  32. package/dist/hooks/magic-context/edit-marker.d.ts +11 -0
  33. package/dist/hooks/magic-context/edit-marker.d.ts.map +1 -0
  34. package/dist/hooks/magic-context/event-handler.d.ts +1 -4
  35. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  36. package/dist/hooks/magic-context/hook.d.ts +1 -2
  37. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  38. package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
  39. package/dist/hooks/magic-context/supersession-reclaim.d.ts +34 -0
  40. package/dist/hooks/magic-context/supersession-reclaim.d.ts.map +1 -0
  41. package/dist/hooks/magic-context/system-prompt-hash.d.ts +5 -0
  42. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  43. package/dist/hooks/magic-context/tag-messages.d.ts +8 -0
  44. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  45. package/dist/hooks/magic-context/tool-drop-target.d.ts +2 -0
  46. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
  47. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +8 -0
  48. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  49. package/dist/hooks/magic-context/transform.d.ts +4 -0
  50. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +3587 -5086
  53. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  54. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  55. package/dist/plugin/tool-registry.d.ts.map +1 -1
  56. package/dist/shared/announcement.d.ts +1 -1
  57. package/dist/shared/announcement.d.ts.map +1 -1
  58. package/dist/shared/commit-detection.d.ts +29 -0
  59. package/dist/shared/commit-detection.d.ts.map +1 -0
  60. package/dist/shared/data-path.d.ts.map +1 -1
  61. package/dist/shared/exit-abort-registry.d.ts +25 -0
  62. package/dist/shared/exit-abort-registry.d.ts.map +1 -0
  63. package/dist/shared/harness-provider-map.d.ts +30 -0
  64. package/dist/shared/harness-provider-map.d.ts.map +1 -0
  65. package/dist/shared/rpc-client.d.ts +8 -0
  66. package/dist/shared/rpc-client.d.ts.map +1 -1
  67. package/dist/shared/rpc-notifications.d.ts +28 -10
  68. package/dist/shared/rpc-notifications.d.ts.map +1 -1
  69. package/dist/shared/rpc-server.d.ts +22 -3
  70. package/dist/shared/rpc-server.d.ts.map +1 -1
  71. package/dist/shared/tag-transcript.d.ts.map +1 -1
  72. package/dist/shared/transcript.d.ts +15 -0
  73. package/dist/shared/transcript.d.ts.map +1 -1
  74. package/dist/tools/ctx-note/tools.d.ts.map +1 -1
  75. package/dist/tui/badge-contrast.d.ts +37 -22
  76. package/dist/tui/badge-contrast.d.ts.map +1 -1
  77. package/dist/tui/data/context-db.d.ts +4 -14
  78. package/dist/tui/data/context-db.d.ts.map +1 -1
  79. package/dist/tui/data/notification-socket.d.ts +39 -0
  80. package/dist/tui/data/notification-socket.d.ts.map +1 -0
  81. package/package.json +78 -77
  82. package/src/shared/announcement.ts +2 -3
  83. package/src/shared/commit-detection.test.ts +63 -0
  84. package/src/shared/commit-detection.ts +53 -0
  85. package/src/shared/data-path.test.ts +28 -0
  86. package/src/shared/data-path.ts +5 -0
  87. package/src/shared/exit-abort-registry.test.ts +50 -0
  88. package/src/shared/exit-abort-registry.ts +46 -0
  89. package/src/shared/harness-provider-map.test.ts +63 -0
  90. package/src/shared/harness-provider-map.ts +56 -0
  91. package/src/shared/rpc-client.ts +14 -0
  92. package/src/shared/rpc-notifications.test.ts +68 -11
  93. package/src/shared/rpc-notifications.ts +75 -36
  94. package/src/shared/rpc-server.ts +249 -150
  95. package/src/shared/tag-transcript.ts +32 -0
  96. package/src/shared/transcript-opencode.ts +33 -0
  97. package/src/shared/transcript.ts +17 -0
  98. package/src/tui/badge-contrast.test.ts +39 -1
  99. package/src/tui/badge-contrast.ts +63 -25
  100. package/src/tui/data/context-db.ts +10 -64
  101. package/src/tui/data/notification-socket.ts +229 -0
  102. package/src/tui/index.tsx +68 -118
  103. package/src/tui/slots/sidebar-content.tsx +2 -2
  104. package/dist/hooks/is-anthropic-provider.d.ts +0 -2
  105. package/dist/hooks/is-anthropic-provider.d.ts.map +0 -1
  106. package/dist/shared/live-server-client.d.ts +0 -50
  107. package/dist/shared/live-server-client.d.ts.map +0 -1
  108. package/src/shared/live-server-client.ts +0 -152
@@ -1 +1 @@
1
- {"version":3,"file":"create-session-hooks.d.ts","sourceRoot":"","sources":["../../../src/plugin/hooks/create-session-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAO7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BjF;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACrC,GAAG,EAAE,aAAa,CAAC;IACnB,YAAY,EAAE,wBAAwB,CAAC;IACvC,gBAAgB,EAAE,gBAAgB,CAAC;CACtC;;;;;;qBA+By6J,CAAC;;;;;;;;;;;;qBAAvsD,CAAC;mBAAyB,CAAC;iBAAuB,CAAC;iBAAuB,CAAC;0BAAc,CAAC;uBAAiB,CAAC;;;;;;0BAA41mC,CAAC;;;;;;EAD5qtC"}
1
+ {"version":3,"file":"create-session-hooks.d.ts","sourceRoot":"","sources":["../../../src/plugin/hooks/create-session-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAO7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BjF;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACrC,GAAG,EAAE,aAAa,CAAC;IACnB,YAAY,EAAE,wBAAwB,CAAC;IACvC,gBAAgB,EAAE,gBAAgB,CAAC;CACtC;;;;;;qBA2B28K,CAAC;;;;;;;;;;;;qBAAjhE,CAAC;mBAAyB,CAAC;iBAAuB,CAAC;iBAAuB,CAAC;0BAAc,CAAC;uBAAiB,CAAC;;;;;;0BAAo9mC,CAAC;;;;;;EAD5/tC"}
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-handlers.d.ts","sourceRoot":"","sources":["../../src/plugin/rpc-handlers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EACH,KAAK,eAAe,IAAI,QAAQ,EAGnC,MAAM,mCAAmC,CAAC;AAc3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,YAAY,EAAE,wBAAwB,CAAC;CAC1C,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAiFjC"}
1
+ {"version":3,"file":"tool-registry.d.ts","sourceRoot":"","sources":["../../src/plugin/tool-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAiB1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACrC,GAAG,EAAE,aAAa,CAAC;IACnB,YAAY,EAAE,wBAAwB,CAAC;CAC1C,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAyFjC"}
@@ -18,7 +18,7 @@
18
18
  * Bump only when there are user-visible changes worth a startup dialog.
19
19
  * Does NOT need to match the published package version.
20
20
  */
21
- export declare const ANNOUNCEMENT_VERSION = "0.28.0";
21
+ export declare const ANNOUNCEMENT_VERSION = "0.30.2";
22
22
  /**
23
23
  * Short, user-facing bullet strings. Keep each line ~80 chars or shorter so the
24
24
  * TUI dialog renders cleanly without horizontal scroll on a typical terminal.
@@ -1 +1 @@
1
- {"version":3,"file":"announcement.d.ts","sourceRoot":"","sources":["../../src/shared/announcement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAoBH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC,MAAM,CAGvD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,qDAAqD,CAAC;AAyBtF;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAGjD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAS1D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CA0BhD"}
1
+ {"version":3,"file":"announcement.d.ts","sourceRoot":"","sources":["../../src/shared/announcement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAoBH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC,MAAM,CAEvD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,qDAAqD,CAAC;AAyBtF;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAGjD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAS1D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CA0BhD"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Boolean hash test. Non-global (stateless), so this single instance is safe to
3
+ * reuse with `.test()` across call sites — only `/g` regexes carry `lastIndex`.
4
+ */
5
+ export declare const COMMIT_HASH_TEST_PATTERN: RegExp;
6
+ /**
7
+ * Commit-ACTION verbs, with common inflections, each fully word-boundary-anchored
8
+ * (so they don't match e.g. "commitment"/"merger"). Non-global → safe to share.
9
+ *
10
+ * Scope decision: this is the commit-action set the OpenCode + Pi note-nudge
11
+ * detectors used and pin in tests ("commit/cherry-pick/merge/rebase"). It does
12
+ * NOT include the bare nouns "hash"/"sha" that the historian's old hint regex
13
+ * carried — a parity test asserts "hash <hex>" alone must NOT count as a commit,
14
+ * and those nouns only ever gated a cosmetic hash-strip in historian summaries
15
+ * (never a trigger), so unifying to the action set is behavior-preserving where
16
+ * it matters.
17
+ */
18
+ export declare const COMMIT_VERB_PATTERN: RegExp;
19
+ /** True when a text part mentions a commit hash in a commit context. Used by the
20
+ * OpenCode + Pi note-nudge detectors. */
21
+ export declare function textMentionsRecentCommit(text: string): boolean;
22
+ /**
23
+ * Fresh `/g` capturing, backtick-aware hash pattern for the historian's
24
+ * extract-and-strip path (matchAll + replace). Returned as a NEW instance per
25
+ * call: a `/g` regex carries `lastIndex`, so handing out a fresh one is
26
+ * bulletproof against accidental `.exec()` reuse across callers.
27
+ */
28
+ export declare function createCommitHashExtractPattern(): RegExp;
29
+ //# sourceMappingURL=commit-detection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commit-detection.d.ts","sourceRoot":"","sources":["../../src/shared/commit-detection.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,eAAO,MAAM,wBAAwB,QAAuC,CAAC;AAE7E;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,QACsE,CAAC;AAEvG;0CAC0C;AAC1C,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,IAAI,MAAM,CAEvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"data-path.d.ts","sourceRoot":"","sources":["../../src/shared/data-path.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAEvD,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,SAAwB,GAAG,MAAM,CAEhF;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,SAAwB,GAAG,MAAM,CAEhF;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,GAAE,SAAwB,GAAG,MAAM,CAErF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEnE;AAKD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gCAAgC,CAAC,SAAS,EAAE,MAA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ACH,wBAAgB,uCAAuC,IAAI,MAAM,CAEhE;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Process-global registry of AbortControllers to abort on process exit, backed
3
+ * by a SINGLE `process.once("exit")` listener no matter how many controllers
4
+ * register.
5
+ *
6
+ * Why this exists: the plugin factory runs once per plugin instance, and
7
+ * OpenCode Desktop loads many instances in one Node process (one per open
8
+ * project). Registering a `process.once("exit")` per instance added one listener
9
+ * each, so past Node's default 10-listener cap it logged a
10
+ * `MaxListenersExceededWarning` ("11 exit listeners added to [process]"). One
11
+ * module-global listener that fans out to every registered controller keeps the
12
+ * count at one.
13
+ */
14
+ /**
15
+ * Abort `controller` when the process exits. The underlying `process.once("exit")`
16
+ * listener is installed on the first call only; subsequent calls just add to the
17
+ * fan-out set.
18
+ */
19
+ export declare function registerExitAbort(controller: AbortController): void;
20
+ /**
21
+ * Stop tracking `controller` (e.g. when its plugin instance is disposed) so the
22
+ * set doesn't grow without bound as Desktop opens and closes projects.
23
+ */
24
+ export declare function unregisterExitAbort(controller: AbortController): void;
25
+ //# sourceMappingURL=exit-abort-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit-abort-registry.d.ts","sourceRoot":"","sources":["../../src/shared/exit-abort-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAeH;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI,CAKnE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI,CAErE"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Provider-id translation between the canonical (OpenCode) form stored in the
3
+ * shared magic-context config and Pi's harness-native provider ids.
4
+ *
5
+ * OpenCode and Pi now share ONE config, but a few auth-plugin providers were
6
+ * named differently on each side. The model id AFTER the slash is identical;
7
+ * only the provider prefix differs:
8
+ *
9
+ * canonical (OpenCode) Pi
10
+ * -------------------- -------------------
11
+ * openai/<model> openai-codex/<model>
12
+ * google/<model> google-antigravity/<model>
13
+ * anthropic/<model> anthropic/<model> (same; every other provider too)
14
+ *
15
+ * Canonical = OpenCode: the config always stores the OpenCode form. Pi
16
+ * translates at its edges:
17
+ * - read: canonical -> Pi when spawning a configured model (subagent-runner).
18
+ * - write: Pi -> canonical in the Pi setup wizard, so a config written from
19
+ * the Pi side stays readable by OpenCode.
20
+ *
21
+ * OpenCode needs no translation (canonical IS the OpenCode form).
22
+ */
23
+ /** Pi-native `provider/model` -> canonical (OpenCode). Identity when unmapped.
24
+ * Used by the Pi setup wizard so configs it writes stay OpenCode-readable. */
25
+ export declare function piModelRefToCanonical(ref: string): string;
26
+ /** Canonical (OpenCode) `provider/model` -> Pi-native, for spawning a model on
27
+ * Pi. Idempotent: normalizes any Pi-form prefix back to canonical first, so it
28
+ * is safe on a config that already holds Pi-form ids (hand-edited or pre-fix). */
29
+ export declare function resolveModelRefForPi(ref: string): string;
30
+ //# sourceMappingURL=harness-provider-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness-provider-map.d.ts","sourceRoot":"","sources":["../../src/shared/harness-provider-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAuBH;+EAC+E;AAC/E,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;mFAEmF;AACnF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAExD"}
@@ -9,6 +9,14 @@ export declare class MagicContextRpcClient {
9
9
  call<T = Record<string, unknown>>(method: string, params?: Record<string, unknown>): Promise<T>;
10
10
  /** Check if the RPC server is reachable. */
11
11
  isAvailable(): Promise<boolean>;
12
+ /** Resolve the live server's port + bearer token (for opening the WS push
13
+ * channel). Reuses the same health-checked port-file discovery as `call`,
14
+ * so the WS client and the HTTP client always agree on which server instance
15
+ * (and token) to use. Returns null when no live server is found. */
16
+ resolveEndpoint(): Promise<{
17
+ port: number;
18
+ token: string | null;
19
+ } | null>;
12
20
  private resolvePort;
13
21
  private readPortFile;
14
22
  private healthCheck;
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-client.d.ts","sourceRoot":"","sources":["../../src/shared/rpc-client.ts"],"names":[],"mappings":"AAiBA,qBAAa,qBAAqB;IAC9B,OAAO,CAAC,IAAI,CAAuB;IACnC,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,aAAa,CAAS;gBAElB,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAKjD,iFAAiF;IAC3E,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACrC,OAAO,CAAC,CAAC,CAAC;IAwDb,4CAA4C;IACtC,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;YASvB,WAAW;IAmCzB,OAAO,CAAC,YAAY;YA4BN,WAAW;YAWX,gBAAgB;IAU9B,KAAK,IAAI,IAAI;CAKhB"}
1
+ {"version":3,"file":"rpc-client.d.ts","sourceRoot":"","sources":["../../src/shared/rpc-client.ts"],"names":[],"mappings":"AAiBA,qBAAa,qBAAqB;IAC9B,OAAO,CAAC,IAAI,CAAuB;IACnC,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,aAAa,CAAS;gBAElB,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAKjD,iFAAiF;IAC3E,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACrC,OAAO,CAAC,CAAC,CAAC;IAwDb,4CAA4C;IACtC,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IASrC;;;yEAGqE;IAC/D,eAAe,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;YAUjE,WAAW;IAmCzB,OAAO,CAAC,YAAY;YA4BN,WAAW;YAWX,gBAAgB;IAU9B,KAAK,IAAI,IAAI;CAKhB"}
@@ -12,16 +12,33 @@ export interface RpcNotification {
12
12
  payload: Record<string, unknown>;
13
13
  sessionId?: string;
14
14
  }
15
- /** Push a notification for TUI to pick up via polling. */
15
+ /**
16
+ * A connected TUI notification sink — one per authenticated WebSocket. The RPC
17
+ * server registers a sink when a TUI socket authenticates (hello) and removes
18
+ * it on close. `send` is sink-agnostic (the server owns the actual WS socket)
19
+ * so this module stays free of Bun/WS types.
20
+ */
21
+ export interface NotificationSink {
22
+ /** The TUI's active session at connect time (its hello scope). */
23
+ sessionId?: string;
24
+ /** Deliver one notification over this sink's live socket. */
25
+ send: (notification: RpcNotification) => void;
26
+ }
27
+ /** Register a live TUI sink. Returns an unregister fn (call on socket close). */
28
+ export declare function registerNotificationSink(sink: NotificationSink): () => void;
29
+ /** Push a notification to the TUI. Fans out to any live WS sink immediately and
30
+ * also enqueues it so a TUI that is momentarily disconnected (reconnecting, or
31
+ * not yet connected) still receives it on its next hello via the backlog drain.
32
+ * At-least-once: a live push that the socket drops is re-delivered from the
33
+ * queue on reconnect (pruned only when the client acks via `lastReceivedId`). */
16
34
  export declare function pushNotification(type: string, payload: Record<string, unknown>, sessionId?: string): void;
17
35
  /** Return pending notifications after acking the client's last received id.
18
- * Updates lastDrainAt so isTuiConnected() reflects recent activity.
19
36
  *
20
37
  * Session scoping: when `sessionId` is provided, only notifications tagged for
21
38
  * that session (or session-less/global ones) are returned and pruned — a
22
39
  * notification tagged for a DIFFERENT session is never handed to this client
23
40
  * and is never pruned by this client's ack. This matters because the in-memory
24
- * queue is per-process but a TUI can end up draining a process that also serves
41
+ * queue is per-process but a TUI can end up bound to a process that also serves
25
42
  * OTHER sessions: e.g. opening OpenCode Desktop on the same project starts a
26
43
  * newer RPC server that the TUI's port discovery (newest-pid-wins) then selects,
27
44
  * so a Desktop-session upgrade-dialog action would otherwise surface in an
@@ -31,16 +48,17 @@ export declare function pushNotification(type: string, payload: Record<string, u
31
48
  *
32
49
  * Delivery is at-least-once (non-destructive return + prune-on-ack): a returned
33
50
  * notification stays queued until a later call acks it via a higher
34
- * `lastReceivedId`, so a lost poll response re-delivers on the next poll. */
51
+ * `lastReceivedId`, so a dropped WS socket re-delivers the backlog on reconnect
52
+ * (the client sends its `lastReceivedId` in the hello). */
35
53
  export declare function drainNotifications(lastReceivedId?: number, sessionId?: string): RpcNotification[];
36
- /** Whether a TUI client is actively polling for notifications.
37
- * Returns true only if a TUI has drained within the last 3 seconds.
54
+ /** Whether a TUI client is connected via a live notification socket.
55
+ * Now exact socket liveness (a registered WS sink), not a poll-drain timestamp.
38
56
  *
39
- * Pass `sessionId` (preferred) to ask whether a TUI is polling FOR THAT
57
+ * Pass `sessionId` (preferred) to ask whether a TUI is connected FOR THAT
40
58
  * SESSION — this is what producers (`/ctx-status`, `/ctx-recomp`, the upgrade
41
59
  * reminder) must use to decide dialog-vs-message, so a TUI on a different
42
- * session in the same process does not misroute their delivery. Omit it only
43
- * for legacy/global callers that genuinely have no session context; they fall
44
- * back to "any session recently drained" (the pre-per-session behavior). */
60
+ * session in the same process does not misroute their delivery. A session-less
61
+ * sink (legacy/global) counts for any session query. Omit `sessionId` only for
62
+ * callers with no session context; they get "any sink connected". */
45
63
  export declare function isTuiConnected(sessionId?: string): boolean;
46
64
  //# sourceMappingURL=rpc-notifications.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-notifications.d.ts","sourceRoot":"","sources":["../../src/shared/rpc-notifications.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAsBD,0DAA0D;AAC1D,wBAAgB,gBAAgB,CAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACnB,IAAI,CAwBN;AAED;;;;;;;;;;;;;;;;;8EAiB8E;AAC9E,wBAAgB,kBAAkB,CAAC,cAAc,SAAI,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,eAAe,EAAE,CAkB5F;AAED;;;;;;;;6EAQ6E;AAC7E,wBAAgB,cAAc,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAO1D"}
1
+ {"version":3,"file":"rpc-notifications.d.ts","sourceRoot":"","sources":["../../src/shared/rpc-notifications.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAKD;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC7B,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,IAAI,EAAE,CAAC,YAAY,EAAE,eAAe,KAAK,IAAI,CAAC;CACjD;AAYD,iFAAiF;AACjF,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,IAAI,CAK3E;AAcD;;;;kFAIkF;AAClF,wBAAgB,gBAAgB,CAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACnB,IAAI,CAoCN;AAED;;;;;;;;;;;;;;;;;4DAiB4D;AAC5D,wBAAgB,kBAAkB,CAAC,cAAc,SAAI,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,eAAe,EAAE,CAe5F;AAED;;;;;;;;sEAQsE;AACtE,wBAAgB,cAAc,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAO1D"}
@@ -1,4 +1,16 @@
1
1
  type RpcHandler = (params: Record<string, unknown>) => Promise<Record<string, unknown>>;
2
+ /**
3
+ * Plugin-private localhost RPC server for TUI ↔ server-plugin communication.
4
+ *
5
+ * Runs on Bun (the OpenCode server runner is a Bun Worker), so it uses
6
+ * `Bun.serve` to host BOTH:
7
+ * - HTTP request/reply routes (`/health`, `/rpc/<method>`) — the TUI's snapshot
8
+ * and dialog-result calls, which are event-driven, not idle; and
9
+ * - a WebSocket endpoint (`/ws`) — a single persistent connection per TUI over
10
+ * which the server PUSHES notifications (dialog/toast actions). This replaces
11
+ * the old 500ms HTTP poll, whose new-connection-per-tick cost was the source
12
+ * of idle TUI CPU (#200). Pi never imports this module, so `Bun.serve` is safe.
13
+ */
2
14
  export declare class MagicContextRpcServer {
3
15
  private server;
4
16
  private port;
@@ -6,16 +18,23 @@ export declare class MagicContextRpcServer {
6
18
  private portFilePath;
7
19
  private portDir;
8
20
  private startedAt;
21
+ /** Every authenticated WS socket, so dispose can close them all. */
22
+ private sockets;
9
23
  private readonly token;
10
24
  constructor(storageDir: string, directory: string);
11
25
  /** Register an RPC method handler. */
12
26
  handle(method: string, handler: RpcHandler): void;
13
27
  /** Start the server on a random port, write port to disk. */
14
28
  start(): Promise<number>;
15
- private warnIfOtherLiveInstance;
16
- /** Stop the server and clean up port file. */
29
+ /** Stop the server: close every socket, stop accepting, remove port file. */
17
30
  stop(): void;
18
- private dispatch;
31
+ private warnIfOtherLiveInstance;
32
+ /** HTTP route handler (Bun fetch). Returns a Response, or undefined when the
33
+ * request was upgraded to a WebSocket. */
34
+ private handleFetch;
35
+ /** WS message handler: hello (auth + sink registration + backlog drain) and
36
+ * ack (cursor advance → queue prune). All other messages are ignored. */
37
+ private handleWsMessage;
19
38
  }
20
39
  export {};
21
40
  //# sourceMappingURL=rpc-server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-server.d.ts","sourceRoot":"","sources":["../../src/shared/rpc-server.ts"],"names":[],"mappings":"AAgBA,KAAK,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAexF,qBAAa,qBAAqB;IAC9B,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,QAAQ,CAAiC;IACjD,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAc;IAK/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmC;gBAE7C,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAKjD,sCAAsC;IACtC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI;IAIjD,6DAA6D;IACvD,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAiF9B,OAAO,CAAC,uBAAuB;IAgB/B,8CAA8C;IAC9C,IAAI,IAAI,IAAI;IAYZ,OAAO,CAAC,QAAQ;CA6EnB"}
1
+ {"version":3,"file":"rpc-server.d.ts","sourceRoot":"","sources":["../../src/shared/rpc-server.ts"],"names":[],"mappings":"AAqBA,KAAK,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,CAA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OAAO,CAAC;IAC9B;;;;;;;OAOG;IACH,2BAA2B,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACnC;AA8DD,wBAAgB,aAAa,CACzB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,eAAe,EACnB,OAAO,GAAE,oBAAyB,GACnC,mBAAmB,CAiPrB"}
1
+ {"version":3,"file":"tag-transcript.d.ts","sourceRoot":"","sources":["../../src/shared/tag-transcript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAQzE,OAAO,EAAwB,KAAK,MAAM,EAAE,MAAM,kCAAkC,CAAC;AASrF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAC;AAE/D,MAAM,WAAW,oBAAoB;IACjC;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;;;OAOG;IACH,2BAA2B,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACnC;AA8DD,wBAAgB,aAAa,CACzB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,eAAe,EACnB,OAAO,GAAE,oBAAyB,GACnC,mBAAmB,CAiPrB"}
@@ -117,6 +117,21 @@ export interface TranscriptPart {
117
117
  inputByteSize: number;
118
118
  inputTokenCount: number;
119
119
  };
120
+ /**
121
+ * Non-mutating read of this tool invocation's input object, or null for
122
+ * non-tool parts / parts without an input. Used by smart-drops supersession
123
+ * selection (read `ctx_note`'s action, an edit's `filePath`) without
124
+ * touching the wire. Returns the live object reference; callers must NOT
125
+ * mutate it.
126
+ */
127
+ getToolInput?(): Record<string, unknown> | null;
128
+ /**
129
+ * Replace this tool invocation's input object with `input`. Used by the
130
+ * smart-drops edit_marker path to write back a filePath-preserving,
131
+ * region-hint-clamped copy of an edit's arguments. Returns true if the part
132
+ * carried a writable tool input. No-op (false) for non-tool parts.
133
+ */
134
+ setToolInput?(input: Record<string, unknown>): boolean;
120
135
  /**
121
136
  * Replace this part with a sentinel placeholder. Sentinels look like
122
137
  * `[dropped §N§]` or `[truncated §N§]` and survive cache-busting
@@ -1 +1 @@
1
- {"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../../src/shared/transcript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,2EAA2E;AAC3E,MAAM,MAAM,kBAAkB,GACxB,MAAM,GACN,UAAU,GACV,UAAU,GACV,aAAa,GACb,OAAO,GACP,MAAM,GACN,YAAY,GACZ,SAAS,CAAC;AAEhB;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,cAAc;IAC3B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAElC;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;IAEhC;;;;;;;OAOG;IACH,OAAO,IAAI,MAAM,GAAG,SAAS,CAAC;IAE9B;;;;;;;;OAQG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAElC;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAExC;;;;;;;;;;;OAWG;IACH,eAAe,IAAI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IACH,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IAEpC;;;;;;;;;;;;;OAaG;IACH,MAAM,IAAI,IAAI,CAAC;CAClB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,EAAE,kBAAiC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-note/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AAYhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAIpD,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,QAAQ,CAAC;IACb,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;CACtD;AAoTD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAIxF"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tools/ctx-note/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AAYhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAIpD,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,QAAQ,CAAC;IACb,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;CACtD;AAuTD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAIxF"}
@@ -1,31 +1,46 @@
1
1
  /**
2
- * Pick a readable text color (black or white) for text drawn ON TOP of a given
3
- * background color.
2
+ * Pick the text color for the sidebar header badge (a bold label drawn on a
3
+ * `theme.accent` background).
4
4
  *
5
- * The sidebar header badge previously drew its label with `fg={theme.background}`
6
- * on a `theme.accent` background. That breaks for themes that set
7
- * `background: "none"` (transparent) to respect terminal transparency: the
8
- * resolved background is `RGBA(0,0,0,0)`, so the badge text renders fully
9
- * transparent and disappears (issue #186). The badge background (`accent`) is
10
- * always opaque, so deriving the text color from it is transparency-proof.
5
+ * Primary rule (matches AFT's sidebar by construction): paint the theme's own
6
+ * `background` color as the label, the inverse-of-panel look. Because it is a
7
+ * fixed theme token rather than an accent-derived computation, MC's badge and
8
+ * AFT's badge agree on EVERY accent automatically, so the same theme can never
9
+ * make one badge black and the other white (issue #198).
11
10
  *
12
- * The pick is WHITE-BIASED off the accent's relative luminance: white for any
13
- * accent in the dark half (luminance < 0.5), black only for genuinely light
14
- * accents. A strict "higher-contrast-wins" pick (crossover at luminance 0.179)
15
- * flips ordinary mid-tone accents to black: a typical orange/amber sidebar
16
- * accent (luminance ~0.3) reads black ~5:1 vs white ~3.7:1, so contrast-wins
17
- * picks black even though white at ~3.7:1 is perfectly legible for a short bold
18
- * label. That looks heavy and clashes with the sibling status badges, so we
19
- * prefer white across the whole dark half and only fall to black once the accent
20
- * is actually light (pale/pastel/near-white), where white would be unreadable.
11
+ * Fallback rule (the reason a luminance pick exists at all): `theme.background`
12
+ * can be unusable as a label color in two degenerate cases, where it would
13
+ * render the label invisible on the accent:
14
+ * 1. Transparent background. Themes that respect terminal transparency set
15
+ * `background: "none"`, which resolves to `RGBA(0,0,0,0)`; drawing it as
16
+ * text renders fully transparent and the label disappears (issue #186).
17
+ * 2. Background ~= accent. If the theme's background and accent are nearly the
18
+ * same color, background-on-accent text has no contrast.
19
+ * In either case we fall back to a black/white pick that is guaranteed visible
20
+ * on the always-opaque accent.
21
21
  *
22
- * `RGBA` channels from @opentui/core are normalized 0..1 floats. We accept the
23
- * minimal `{ r, g, b }` shape so this stays a pure, trivially testable function
24
- * independent of the native color class.
22
+ * `RGBA` channels from @opentui/core are normalized 0..1 floats (alpha included).
23
+ * We accept the minimal `{ r, g, b, a? }` shape so this stays a pure, trivially
24
+ * testable function independent of the native color class, and we return the
25
+ * passed-in `background` object unchanged on the primary path so it stays the
26
+ * exact same theme token AFT uses.
25
27
  */
26
- export declare function readableTextColorOn(bg: {
28
+ type Color = {
27
29
  r: number;
28
30
  g: number;
29
31
  b: number;
30
- }): string;
32
+ a?: number;
33
+ };
34
+ /**
35
+ * Pure black/white pick by accent luminance. Used as the badge fallback and kept
36
+ * exported for callers that only have the accent.
37
+ */
38
+ export declare function readableTextColorOn(bg: Color): string;
39
+ /**
40
+ * Badge label color on the accent: the theme background (AFT parity) when it is
41
+ * usable, else a guaranteed-visible black/white fallback. Returns the passed-in
42
+ * `background` reference unchanged on the primary path.
43
+ */
44
+ export declare function badgeTextColor<T extends Color>(accent: T, background: T): T | string;
45
+ export {};
31
46
  //# sourceMappingURL=badge-contrast.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"badge-contrast.d.ts","sourceRoot":"","sources":["../../src/tui/badge-contrast.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAmBH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEnF"}
1
+ {"version":3,"file":"badge-contrast.d.ts","sourceRoot":"","sources":["../../src/tui/badge-contrast.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,KAAK,KAAK,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAoC7D;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,KAAK,GAAG,MAAM,CAErD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,CAMpF"}
@@ -1,8 +1,12 @@
1
+ import { MagicContextRpcClient } from "../../shared/rpc-client";
1
2
  import type { EmbedDetail, SidebarSnapshot, StatusDetail } from "../../shared/rpc-types";
2
3
  export type { EmbedDetail, SidebarSnapshot, StatusDetail };
3
4
  /** Initialize the RPC client. Call once on TUI startup. */
4
5
  export declare function initRpcClient(directory: string): void;
5
6
  export declare function getRpcGeneration(): number;
7
+ /** The live RPC client (for the WS notification socket's endpoint discovery).
8
+ * Null before init / after close. */
9
+ export declare function getRpcClient(): MagicContextRpcClient | null;
6
10
  /** Clean up the RPC client. */
7
11
  export declare function closeRpc(): void;
8
12
  /** Fetch sidebar snapshot from the server via RPC. */
@@ -24,12 +28,6 @@ export declare function requestUpgrade(sessionId: string): Promise<boolean>;
24
28
  export declare function dismissUpgradeReminder(sessionId: string): Promise<boolean>;
25
29
  /** Resolve global toast duration from server config via RPC. */
26
30
  export declare function loadToastDurationMs(): Promise<number>;
27
- export interface TuiMessage {
28
- id: number;
29
- type: string;
30
- payload: Record<string, unknown>;
31
- sessionId?: string;
32
- }
33
31
  /**
34
32
  * Fetch the current startup announcement from the server, if any.
35
33
  * Returns `{show: false}` when there's nothing to announce or when the
@@ -44,12 +42,4 @@ export interface AnnouncementResponse {
44
42
  export declare function getAnnouncement(): Promise<AnnouncementResponse>;
45
43
  /** Mark the current ANNOUNCEMENT_VERSION as dismissed on the server. */
46
44
  export declare function markAnnounced(): Promise<boolean>;
47
- /** Poll for pending server→TUI notifications via RPC. */
48
- export declare function consumeTuiMessages(sessionId: string): Promise<TuiMessage[]>;
49
- /**
50
- * Advance the delivered-message cursor for one active TUI session.
51
- * Callers must pass only the contiguous handled prefix of the drained batch;
52
- * this helper remains empty-safe and monotonic for that prefix.
53
- */
54
- export declare function markTuiMessagesHandled(sessionId: string, messages: TuiMessage[]): void;
55
45
  //# sourceMappingURL=context-db.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-db.d.ts","sourceRoot":"","sources":["../../../src/tui/data/context-db.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACR,WAAW,EAEX,eAAe,EACf,YAAY,EACf,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,CAAC;AAe3D,2DAA2D;AAC3D,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAOrD;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,+BAA+B;AAC/B,wBAAgB,QAAQ,IAAI,IAAI,CAO/B;AA4FD,sDAAsD;AACtD,wBAAsB,mBAAmB,CACrC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAClB,OAAO,CAAC,eAAe,CAAC,CA4B1B;AAED,wDAAwD;AACxD,wBAAsB,gBAAgB,CAClC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,YAAY,CAAC,CA0CvB;AAYD,gEAAgE;AAChE,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAchG;AAED,qCAAqC;AACrC,wBAAsB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ5E;AAED,6CAA6C;AAC7C,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQvE;AAED;mFACmF;AACnF,wBAAsB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQxE;AAED;;iDAEiD;AACjD,wBAAsB,s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AAC,oBAAoB,CAAC,CAkBrE;AAED,wEAAwE;AACxE,wBAAsB,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAQtD"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Persistent WebSocket to the server plugin's RPC server, replacing the old
3
+ * 500ms HTTP notification poll.
4
+ *
5
+ * Why this exists: the TUI plugin and the server plugin run in separate Bun
6
+ * runners in the same process, so they bridge over a localhost socket. The old
7
+ * bridge polled `pending-notifications` over HTTP every 500ms — and each poll
8
+ * opened a NEW loopback TCP connection (Bun's fetch isn't pooled to our server),
9
+ * which was the entire source of idle TUI CPU (#200). A single long-lived WS
10
+ * carries server→TUI pushes with zero per-event connection cost, and the server
11
+ * pushes notifications the instant they're queued (no polling latency).
12
+ *
13
+ * Session scope: the socket carries the TUI's active session in its `hello` so
14
+ * the server delivers only that session's (plus global) notifications and its
15
+ * `isTuiConnected(session)` routing stays correct. The active session is tracked
16
+ * with a cheap watcher that only reads `api.route.current` (a property access,
17
+ * no IPC) and re-scopes the socket ONLY when the session actually changes — so
18
+ * unlike the old poll it does no network work at idle.
19
+ */
20
+ export interface SocketNotification {
21
+ id: number;
22
+ type: string;
23
+ payload: Record<string, unknown>;
24
+ sessionId?: string;
25
+ }
26
+ interface NotificationSocketOptions {
27
+ /** Current active session id (re-read cheaply to follow session switches). */
28
+ getSessionId: () => string | null;
29
+ /** Handle one delivered notification. Returns true if it was consumed (so its
30
+ * id can advance the ack cursor). Async because dialog handlers await. */
31
+ onNotification: (notification: SocketNotification) => boolean | Promise<boolean>;
32
+ }
33
+ /** Open the persistent notification socket. Idempotent: a second call while open
34
+ * is a no-op. Reconnects on its own after any drop. */
35
+ export declare function startNotificationSocket(options: NotificationSocketOptions): void;
36
+ /** Close the socket and stop reconnecting. Call on TUI dispose. */
37
+ export declare function stopNotificationSocket(): void;
38
+ export {};
39
+ //# sourceMappingURL=notification-socket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-socket.d.ts","sourceRoot":"","sources":["../../../src/tui/data/notification-socket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,MAAM,WAAW,kBAAkB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,yBAAyB;IAC/B,8EAA8E;IAC9E,YAAY,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAClC;+EAC2E;IAC3E,cAAc,EAAE,CAAC,YAAY,EAAE,kBAAkB,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACpF;AAsBD;wDACwD;AACxD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,yBAAyB,GAAG,IAAI,CAQhF;AAED,mEAAmE;AACnE,wBAAgB,sBAAsB,IAAI,IAAI,CAkB7C"}