@cortexkit/pi-magic-context 0.30.0 → 0.30.2

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/index.js CHANGED
@@ -14945,12 +14945,30 @@ var require_src2 = __commonJS((exports, module) => {
14945
14945
  // ../plugin/src/shared/rpc-notifications.ts
14946
14946
  var exports_rpc_notifications = {};
14947
14947
  __export(exports_rpc_notifications, {
14948
+ registerNotificationSink: () => registerNotificationSink,
14948
14949
  pushNotification: () => pushNotification,
14949
14950
  isTuiConnected: () => isTuiConnected,
14950
14951
  drainNotifications: () => drainNotifications
14951
14952
  });
14953
+ function registerNotificationSink(sink) {
14954
+ sinks.add(sink);
14955
+ return () => {
14956
+ sinks.delete(sink);
14957
+ };
14958
+ }
14959
+ function notificationMatchesSink(notification, sink) {
14960
+ return notification.sessionId === undefined || sink.sessionId === undefined || notification.sessionId === sink.sessionId;
14961
+ }
14952
14962
  function pushNotification(type, payload, sessionId) {
14953
- queue.push({ id: nextNotificationId++, type, payload, sessionId });
14963
+ const notification = { id: nextNotificationId++, type, payload, sessionId };
14964
+ queue.push(notification);
14965
+ for (const sink of sinks) {
14966
+ if (!notificationMatchesSink(notification, sink))
14967
+ continue;
14968
+ try {
14969
+ sink.send(notification);
14970
+ } catch {}
14971
+ }
14954
14972
  if (queue.length > 100) {
14955
14973
  const newestPerSession = new Map;
14956
14974
  for (const n of queue) {
@@ -14970,10 +14988,6 @@ function pushNotification(type, payload, sessionId) {
14970
14988
  }
14971
14989
  }
14972
14990
  function drainNotifications(lastReceivedId = 0, sessionId) {
14973
- const now = Date.now();
14974
- lastDrainAtAny = now;
14975
- if (sessionId !== undefined)
14976
- lastDrainAtBySession.set(sessionId, now);
14977
14991
  const matchesClient = (notification) => sessionId === undefined || notification.sessionId === undefined || notification.sessionId === sessionId;
14978
14992
  if (lastReceivedId > 0) {
14979
14993
  queue = queue.filter((notification) => !(notification.id <= lastReceivedId && matchesClient(notification)));
@@ -14981,17 +14995,20 @@ function drainNotifications(lastReceivedId = 0, sessionId) {
14981
14995
  return queue.filter((notification) => notification.id > lastReceivedId && matchesClient(notification));
14982
14996
  }
14983
14997
  function isTuiConnected(sessionId) {
14984
- const now = Date.now();
14985
- if (sessionId !== undefined) {
14986
- const at = lastDrainAtBySession.get(sessionId) ?? 0;
14987
- return at > 0 && now - at < TUI_CONNECTED_WINDOW_MS;
14998
+ if (sinks.size === 0)
14999
+ return false;
15000
+ if (sessionId === undefined)
15001
+ return true;
15002
+ for (const sink of sinks) {
15003
+ if (sink.sessionId === undefined || sink.sessionId === sessionId)
15004
+ return true;
14988
15005
  }
14989
- return lastDrainAtAny > 0 && now - lastDrainAtAny < TUI_CONNECTED_WINDOW_MS;
15006
+ return false;
14990
15007
  }
14991
- var queue, nextNotificationId = 1, lastDrainAtBySession, lastDrainAtAny = 0, TUI_CONNECTED_WINDOW_MS = 3000;
15008
+ var queue, nextNotificationId = 1, sinks;
14992
15009
  var init_rpc_notifications = __esm(() => {
14993
15010
  queue = [];
14994
- lastDrainAtBySession = new Map;
15011
+ sinks = new Set;
14995
15012
  });
14996
15013
 
14997
15014
  // ../plugin/src/shared/safe-notification-target.ts
@@ -156467,11 +156484,9 @@ function compareSemverCore(a, b) {
156467
156484
 
156468
156485
  // ../plugin/src/shared/announcement.ts
156469
156486
  init_data_path();
156470
- var ANNOUNCEMENT_VERSION = "0.30.0";
156487
+ var ANNOUNCEMENT_VERSION = "0.30.2";
156471
156488
  var ANNOUNCEMENT_FEATURES = [
156472
- "Setup and doctor now recognize an OpenCode Desktop install that has no CLI on PATH, instead of reporting OpenCode as not installed (#196). Desktop-only users continue setup with manual model entry.",
156473
- "TUI sidebar badge color follows your theme again (#198): it uses the theme background like sibling badges, with a fallback so the label can't disappear on transparent themes.",
156474
- "doctor clears a stale plugin cache more reliably (#199): it compares against the plugin's latest published version and preserves the cache when offline."
156489
+ "Fixed high idle CPU from the TUI sidebar (#200): it now uses a single persistent connection to the plugin instead of polling, so an idle session no longer burns CPU."
156475
156490
  ];
156476
156491
  var ANNOUNCEMENT_FOOTER = "Join us on Discord: https://discord.gg/F2uWxjGnU";
156477
156492
  var STATE_FILENAME = "last_announced_version";
@@ -173220,8 +173235,8 @@ async function injectWasmOrtForElectron() {
173220
173235
  try {
173221
173236
  const { createRequire: createRequireFn } = await import("node:module");
173222
173237
  const requireFn = createRequireFn(import.meta.url);
173223
- const pkgPath = requireFn.resolve("onnxruntime-web/package.json");
173224
- const distDir = join10(dirname5(pkgPath), "dist");
173238
+ const mainEntry = requireFn.resolve("onnxruntime-web");
173239
+ const distDir = dirname5(mainEntry);
173225
173240
  const wasmPathsPrefix = `${pathToFileURL(distDir).href}/`;
173226
173241
  if (ortWeb.env?.wasm) {
173227
173242
  ortWeb.env.wasm.wasmPaths = wasmPathsPrefix;
@@ -173342,7 +173357,7 @@ class LocalEmbeddingProvider {
173342
173357
  if (this.disposing) {
173343
173358
  return;
173344
173359
  }
173345
- await injectWasmOrtForElectron();
173360
+ const injectedWasmOrt = await injectWasmOrtForElectron();
173346
173361
  const transformersSpec = "@huggingface/transformers";
173347
173362
  const transformersModule = await import(transformersSpec);
173348
173363
  const env = transformersModule.env;
@@ -173372,7 +173387,8 @@ class LocalEmbeddingProvider {
173372
173387
  for (let attempt = 1;attempt <= MAX_ATTEMPTS; attempt++) {
173373
173388
  try {
173374
173389
  const pipeline = await withQuietConsole(() => createPipeline("feature-extraction", this.model, {
173375
- dtype: "fp32"
173390
+ dtype: "fp32",
173391
+ ...injectedWasmOrt ? { device: "auto" } : {}
173376
173392
  }));
173377
173393
  if (this.disposing) {
173378
173394
  await pipeline.dispose?.();
@@ -199800,7 +199816,7 @@ function formatThresholdPercent(value) {
199800
199816
  // package.json
199801
199817
  var package_default = {
199802
199818
  name: "@cortexkit/pi-magic-context",
199803
- version: "0.30.0",
199819
+ version: "0.30.2",
199804
199820
  type: "module",
199805
199821
  description: "Pi coding agent extension for Magic Context — cross-session memory and context management",
199806
199822
  main: "dist/index.js",
@@ -160859,8 +160859,8 @@ async function injectWasmOrtForElectron() {
160859
160859
  try {
160860
160860
  const { createRequire: createRequireFn } = await import("node:module");
160861
160861
  const requireFn = createRequireFn(import.meta.url);
160862
- const pkgPath = requireFn.resolve("onnxruntime-web/package.json");
160863
- const distDir = join5(dirname5(pkgPath), "dist");
160862
+ const mainEntry = requireFn.resolve("onnxruntime-web");
160863
+ const distDir = dirname5(mainEntry);
160864
160864
  const wasmPathsPrefix = `${pathToFileURL(distDir).href}/`;
160865
160865
  if (ortWeb.env?.wasm) {
160866
160866
  ortWeb.env.wasm.wasmPaths = wasmPathsPrefix;
@@ -160981,7 +160981,7 @@ class LocalEmbeddingProvider {
160981
160981
  if (this.disposing) {
160982
160982
  return;
160983
160983
  }
160984
- await injectWasmOrtForElectron();
160984
+ const injectedWasmOrt = await injectWasmOrtForElectron();
160985
160985
  const transformersSpec = "@huggingface/transformers";
160986
160986
  const transformersModule = await import(transformersSpec);
160987
160987
  const env = transformersModule.env;
@@ -161011,7 +161011,8 @@ class LocalEmbeddingProvider {
161011
161011
  for (let attempt = 1;attempt <= MAX_ATTEMPTS; attempt++) {
161012
161012
  try {
161013
161013
  const pipeline = await withQuietConsole(() => createPipeline("feature-extraction", this.model, {
161014
- dtype: "fp32"
161014
+ dtype: "fp32",
161015
+ ...injectedWasmOrt ? { device: "auto" } : {}
161015
161016
  }));
161016
161017
  if (this.disposing) {
161017
161018
  await pipeline.dispose?.();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/pi-magic-context",
3
- "version": "0.30.0",
3
+ "version": "0.30.2",
4
4
  "type": "module",
5
5
  "description": "Pi coding agent extension for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",