typebulb 0.51.1 → 0.51.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/render.js CHANGED
@@ -723,19 +723,17 @@ const something = require('module-name') // NOT SUPPORTED!
723
723
 
724
724
  // tb.infer() \u2014 the local inference layer (TB-Inference.md). The UI and network live in the
725
725
  // lazy-imported modal module (/__infer-ui.js \u2014 zero bytes here until the first call); the shim
726
- // stays the state machine and globals writer. The promise settles once: a modal retry after a
726
+ // stays the concurrency guard and globals writer. The promise settles once: a modal retry after a
727
727
  // rejected promise still updates runtime state on success, for tb.insight() readers.
728
- let inferState = 'idle';
729
- let dataOverrides = null;
728
+ let inferRunning = false;
730
729
  const infer = (opts = {}) => {
731
730
  if (isFramed) return Promise.reject(inlineErr('tb.infer()'));
732
- if (inferState === 'running') return Promise.reject(new Error('Inference already in progress'));
733
- inferState = 'running';
734
- // Data priority (matching the .com sandbox): explicit arg > setData overrides > undefined \u2014
735
- // the modal then seeds from the SOURCE chunks (/__infer-info), the local Data tab, exactly as
736
- // .com's IDE modal reseeds from the Data tab rather than post-run runtime state.
731
+ if (inferRunning) return Promise.reject(new Error('Inference already in progress'));
732
+ inferRunning = true;
733
+ // Data to preview: the explicit arg, else undefined \u2014 the modal then seeds from the SOURCE
734
+ // chunks (/__infer-info), the local Data tab, exactly as .com's IDE modal reseeds from the
735
+ // Data tab rather than post-run runtime state.
737
736
  let data = opts.data;
738
- if (data === undefined && dataOverrides) data = Object.values(dataOverrides);
739
737
  if (data !== undefined && !Array.isArray(data)) data = [data];
740
738
  return new Promise((resolve, reject) => {
741
739
  let settled = false;
@@ -751,19 +749,19 @@ const something = require('module-name') // NOT SUPPORTED!
751
749
  window.__TB_INSIGHT__ = final.insightJson;
752
750
  if (final.data && final.data.length) window.__TB_DATA__ = final.data;
753
751
  if (final.hash) history.replaceState(null, '', location.pathname + location.search + final.hash);
754
- inferState = 'complete';
752
+ inferRunning = false;
755
753
  settle(resolve, final.insight);
756
754
  },
757
755
  onError: (err) => {
758
- inferState = 'error';
756
+ inferRunning = false;
759
757
  const e = new Error(err.message); e.code = err.code; e.retryable = !!err.retryable;
760
758
  settle(reject, e);
761
759
  },
762
760
  onCancel: () => {
763
- if (!settled) { inferState = 'idle'; settle(resolve, undefined); }
761
+ if (!settled) { inferRunning = false; settle(resolve, undefined); }
764
762
  }
765
763
  });
766
- }).catch((e) => { inferState = 'error'; settle(reject, e); });
764
+ }).catch((e) => { inferRunning = false; settle(reject, e); });
767
765
  });
768
766
  };
769
767
 
@@ -812,9 +810,6 @@ const something = require('module-name') // NOT SUPPORTED!
812
810
 
813
811
  // Inference (TB-Inference.md) \u2014 modal-hosted one-shot LLM call over the bulb's own blocks
814
812
  infer,
815
- inferenceState: () => inferState,
816
- setData: (index, content) => { if (!dataOverrides) dataOverrides = {}; dataOverrides[index] = content; },
817
- resetInferenceState: () => { inferState = 'idle'; dataOverrides = null; },
818
813
 
819
814
  // AI - tb.ai() proxies to the provider via the local server; tb.ai.stream() streams AiChunks.
820
815
  ai,
package/dist/servers.js CHANGED
@@ -510,19 +510,17 @@ ${s}`}function Xd(t){let e=ur.filter(n=>t[n]).map(n=>f0(n,t[n]));return["---",`f
510
510
 
511
511
  // tb.infer() \u2014 the local inference layer (TB-Inference.md). The UI and network live in the
512
512
  // lazy-imported modal module (/__infer-ui.js \u2014 zero bytes here until the first call); the shim
513
- // stays the state machine and globals writer. The promise settles once: a modal retry after a
513
+ // stays the concurrency guard and globals writer. The promise settles once: a modal retry after a
514
514
  // rejected promise still updates runtime state on success, for tb.insight() readers.
515
- let inferState = 'idle';
516
- let dataOverrides = null;
515
+ let inferRunning = false;
517
516
  const infer = (opts = {}) => {
518
517
  if (isFramed) return Promise.reject(inlineErr('tb.infer()'));
519
- if (inferState === 'running') return Promise.reject(new Error('Inference already in progress'));
520
- inferState = 'running';
521
- // Data priority (matching the .com sandbox): explicit arg > setData overrides > undefined \u2014
522
- // the modal then seeds from the SOURCE chunks (/__infer-info), the local Data tab, exactly as
523
- // .com's IDE modal reseeds from the Data tab rather than post-run runtime state.
518
+ if (inferRunning) return Promise.reject(new Error('Inference already in progress'));
519
+ inferRunning = true;
520
+ // Data to preview: the explicit arg, else undefined \u2014 the modal then seeds from the SOURCE
521
+ // chunks (/__infer-info), the local Data tab, exactly as .com's IDE modal reseeds from the
522
+ // Data tab rather than post-run runtime state.
524
523
  let data = opts.data;
525
- if (data === undefined && dataOverrides) data = Object.values(dataOverrides);
526
524
  if (data !== undefined && !Array.isArray(data)) data = [data];
527
525
  return new Promise((resolve, reject) => {
528
526
  let settled = false;
@@ -538,19 +536,19 @@ ${s}`}function Xd(t){let e=ur.filter(n=>t[n]).map(n=>f0(n,t[n]));return["---",`f
538
536
  window.__TB_INSIGHT__ = final.insightJson;
539
537
  if (final.data && final.data.length) window.__TB_DATA__ = final.data;
540
538
  if (final.hash) history.replaceState(null, '', location.pathname + location.search + final.hash);
541
- inferState = 'complete';
539
+ inferRunning = false;
542
540
  settle(resolve, final.insight);
543
541
  },
544
542
  onError: (err) => {
545
- inferState = 'error';
543
+ inferRunning = false;
546
544
  const e = new Error(err.message); e.code = err.code; e.retryable = !!err.retryable;
547
545
  settle(reject, e);
548
546
  },
549
547
  onCancel: () => {
550
- if (!settled) { inferState = 'idle'; settle(resolve, undefined); }
548
+ if (!settled) { inferRunning = false; settle(resolve, undefined); }
551
549
  }
552
550
  });
553
- }).catch((e) => { inferState = 'error'; settle(reject, e); });
551
+ }).catch((e) => { inferRunning = false; settle(reject, e); });
554
552
  });
555
553
  };
556
554
 
@@ -599,9 +597,6 @@ ${s}`}function Xd(t){let e=ur.filter(n=>t[n]).map(n=>f0(n,t[n]));return["---",`f
599
597
 
600
598
  // Inference (TB-Inference.md) \u2014 modal-hosted one-shot LLM call over the bulb's own blocks
601
599
  infer,
602
- inferenceState: () => inferState,
603
- setData: (index, content) => { if (!dataOverrides) dataOverrides = {}; dataOverrides[index] = content; },
604
- resetInferenceState: () => { inferState = 'idle'; dataOverrides = null; },
605
600
 
606
601
  // AI - tb.ai() proxies to the provider via the local server; tb.ai.stream() streams AiChunks.
607
602
  ai,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typebulb",
3
- "version": "0.51.1",
3
+ "version": "0.51.2",
4
4
  "description": "Typebulb CLI to run single-file markdown apps called bulbs, either as standalone web apps or embedded in agent responses.",
5
5
  "keywords": [
6
6
  "bulb",