@christianirack/brainllm-runtime 0.10.11 → 0.10.16

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/brain-budget.js CHANGED
@@ -5,7 +5,8 @@ const LIMITS = { steps: 1000000, depth: 128, ms: 200, rows: 100000, signals: 100
5
5
  const now = () => performance.now()
6
6
  const str = (v, n) => typeof v == 'string' ? v.slice(0, n) : null, pos = v => v > 0 ? v | 0 : null
7
7
  const metaOf = m => ({ file: str(m?.file, 256), component: str(m?.component, 80), line: pos(m?.line), column: pos(m?.column) })
8
- const limitsOf = options => Object.fromEntries(Object.entries(LIMITS).map(([k, max]) => [k, Math.min(max, options?.[k] >= 1 ? options[k] : max)]))
8
+ // An option replaces a default (`<meta budget="ms:N steps:N">` raises it), never above 100× the default.
9
+ const limitsOf = options => Object.fromEntries(Object.entries(LIMITS).map(([k, max]) => [k, Math.min(max * 100, options?.[k] >= 1 ? options[k] : max)]))
9
10
  const failure = (code, kind, limit, meta) => Object.assign(new Error(`${code}: ${kind} budget exceeded`), { code, kind: 'budget', budget: kind, limit, ...metaOf(meta), fix: code == 'B0910' ? 'Bound the work or use an owned worker.' : 'Bound it; dispose with its owner.' })
10
11
  const start = r => { r.running = true; r.started = now() }
11
12
  function charge(root) {
@@ -21,7 +22,7 @@ function enforce(frame, kind, value) {
21
22
  if (value > r.limits[kind]) {
22
23
  const e = failure('B0910', kind, r.limits[kind], frame.meta)
23
24
  if (kind != 'ms') throw (r.error = e)
24
- r.limits.ms = 1 / 0
25
+ r.limits.ms = 1 / 0, e.level = 'warning'
25
26
  console.warn(e.message += ` at ${e.file}:${e.line}: ${e.measured = value | 0} ms`), I.oops(e, null, 'budget')
26
27
  }
27
28
  }
package/brain-err.js CHANGED
@@ -285,7 +285,7 @@ function record(e, x, w) {
285
285
  else {
286
286
  const t = trace(e, c), chain = causes(e, c)
287
287
  r = {
288
- fp, code: clean(get(e, 'code') || '', 80) || null, type, msg: MSG[get(e, 'code')] || clean(get(e, 'message') || e), where: clean(w || '', 120) || null, comp: c, line,
288
+ fp, code: clean(get(e, 'code') || '', 80) || null, type, msg: MSG[get(e, 'code')] || clean(get(e, 'message') || e), level: get(e, 'level') == 'warning' ? 'warning' : null, where: clean(w || '', 120) || null, comp: c, line,
289
289
  stack: f.slice(0, LIMIT.frames).map(t => `${path(t.url).slice(-1024)}:${t.line}:${t.col}`), location: t.location, generatedLocation: t.generatedLocation, frames: t.frames, causes: chain.entries.map(({ rawFrames, ...item }) => item), truncated: { ...t.truncated, causes: chain.truncated, componentChain: !!(owner && owner.chain && owner.chain.length > 32), breadcrumbs: crumbs.length >= 30, locations: f.some(t => path(t.url).length > 1024), mapping: false }, mapping: { status: opts.maps ? 'pending' : 'disabled' }, crumbs: crumbs.map(c => ({ ...c })),
290
290
  build: clean(opts.build || '', 200) || null, ua: G.navigator ? clean(navigator.userAgent, 300) : null, at: Date.now(), last: Date.now(), n: 1,
291
291
  }
package/brain-guard.js CHANGED
@@ -136,7 +136,7 @@ function toast(msg) {
136
136
  // HTTP/API errors carry a message meant for people (ApiError, rpc); anything else gets a generic line
137
137
  const human = e => (e && (e.kind || e.status || e.code === 'rpc' || e.code === 'api') && e.message) || 'Something went wrong. Try again.'
138
138
 
139
- export function guard(C, fb, budget) {
139
+ export function guard(C, fb, budget, label) {
140
140
  const W = $p => {
141
141
  const own = I.owner(), end = G.document.createComment('')
142
142
  let nodes = [], dispose = null, fails = []
@@ -149,7 +149,7 @@ export function guard(C, fb, budget) {
149
149
  if (retry) {
150
150
  const b = G.document.createElement('button')
151
151
  b.setAttribute('type', 'button')
152
- b.textContent = 'Retry'
152
+ b.textContent = label || 'Retry'
153
153
  b.addEventListener('click', () => again())
154
154
  box.appendChild(G.document.createTextNode(' '))
155
155
  box.appendChild(b)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@christianirack/brainllm-runtime",
3
- "version": "0.10.11",
3
+ "version": "0.10.16",
4
4
  "description": "The BRAINLLM runtime for the Rust-built web compiler for LLMs: dependency-free ES modules (signals, DOM, router, data, forms, channels). The brain binary embeds this same version.",
5
5
  "type": "module",
6
6
  "exports": {