brass-runtime 1.13.2 → 1.13.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.
- package/dist/agent/cli/main.js +2021 -15
- package/dist/agent/cli/main.mjs +2022 -0
- package/dist/agent/index.js +153 -1
- package/dist/agent/index.mjs +153 -0
- package/dist/chunk-3IF374MG.js +407 -0
- package/dist/chunk-6ECUD4N3.mjs +2879 -0
- package/dist/chunk-HRVX2IYW.js +2879 -0
- package/dist/chunk-QRPYH5J7.mjs +407 -0
- package/dist/chunk-T5XJDGTQ.mjs +2556 -0
- package/dist/chunk-TGOMLZ65.js +2556 -0
- package/dist/http/index.js +453 -1
- package/dist/http/index.mjs +453 -0
- package/dist/index.js +855 -1
- package/dist/index.mjs +855 -0
- package/package.json +3 -5
- package/dist/agent/cli/main.cjs +0 -16
- package/dist/agent/index.cjs +0 -1
- package/dist/chunk-6OUI6UGZ.cjs +0 -25
- package/dist/chunk-JAQUSSUV.js +0 -1
- package/dist/chunk-K47BP5A2.cjs +0 -2
- package/dist/chunk-LTHJNW5A.js +0 -2
- package/dist/chunk-W6TVAMYC.js +0 -25
- package/dist/chunk-XPOARCND.cjs +0 -1
- package/dist/http/index.cjs +0 -1
- package/dist/index.cjs +0 -1
package/dist/chunk-LTHJNW5A.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {createRequire}from'module';var J={succeed:r=>({_tag:"Succeed",value:r}),fail:r=>({_tag:"Fail",error:r}),sync:r=>({_tag:"Sync",thunk:r}),async:r=>({_tag:"Async",register:r})};function F(r,e,n){return {_tag:"Fold",first:r,onFailure:e,onSuccess:n}}function Ye(r,e){return F(r,n=>e(n),n=>E(n))}function re(r,e){return F(r,n=>T(e(n)),n=>E(n))}var ie={_tag:"Succeed",value:void 0},Se={_tag:"Succeed",value:true},Ie={_tag:"Succeed",value:false},we={_tag:"Succeed",value:null},m=()=>ie,E=r=>r===void 0?ie:r===true?Se:r===false?Ie:r===null?we:{_tag:"Succeed",value:r},T=r=>({_tag:"Fail",error:r}),B=r=>({_tag:"Sync",thunk:r}),Xe=r=>B(()=>r()),h=r=>({_tag:"Async",register:r});function se(r,e){return y(r,n=>E(e(n)))}function y(r,e){return {_tag:"FlatMap",first:r,andThen:e}}function en(r,e,n){return y(r,t=>(n.addFinalizer(i=>e(t,i)),E(t)))}function nn(r){return h(r)}var tn=r=>e=>{let n=e;return n.toPromise||(n.toPromise=t=>r(e,t),n.unsafeRunPromise=()=>r(e,{})),n},rn=(r,e)=>y(r,n=>E(e(n))),sn=(r,e)=>y(r,n=>B(()=>e(n)));var oe={_tag:"None"},an=r=>({_tag:"Some",value:r});var c={fail:r=>({_tag:"Fail",error:r}),interrupt:()=>({_tag:"Interrupt"}),die:r=>({_tag:"Die",defect:r})},l={succeed:r=>({_tag:"Success",value:r}),failCause:r=>({_tag:"Failure",cause:r})},ln=r=>E(r),xe=r=>T(r),fn=r=>B(e=>r(e)),pn=(r,e)=>se(r,e),hn=(r,e)=>y(r,n=>e(n)),yn=(r,e)=>re(r,e),mn=(r,e)=>F(r,n=>e(n),n=>E(n));function gn(r,e){return F(r,n=>n._tag==="Some"?T(n):e(),n=>E(n))}var bn=()=>xe(oe);var _e=(t=>(t[t.Ok=0]="Ok",t[t.Grew=1]="Grew",t[t.Dropped=2]="Dropped",t))(_e||{}),I=class{buf;head=0;tail=0;size_=0;maxCap;constructor(e=1024,n=e){let t=Math.max(2,e);t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++;let i=Math.max(t,n);i--,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,i|=i>>>16,i++,this.buf=new Array(t),this.maxCap=i;}get length(){return this.size_}get capacity(){return this.buf.length}isEmpty(){return this.size_===0}push(e){return this.size_===this.buf.length?this.buf.length>=this.maxCap?2:(this.grow(),this.buf[this.tail]=e,this.tail=this.tail+1&this.buf.length-1,this.size_++,1):(this.buf[this.tail]=e,this.tail=this.tail+1&this.buf.length-1,this.size_++,0)}shift(){if(this.size_===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=this.head+1&this.buf.length-1,this.size_--,e}clear(){this.head=0,this.tail=0,this.size_=0;}grow(){let e=this.buf,n=Math.min(e.length*2,this.maxCap),t=new Array(n);for(let i=0;i<this.size_;i++)t[i]=e[this.head+i&e.length-1];this.buf=t,this.head=0,this.tail=this.size_;}};var $,ae=[];function R(r={}){if(!r.fresh&&r.modulePath==null&&$!==void 0)return $;let e=Be(),n=Te(r.modulePath),t=[];if(!e)return t.push("no CommonJS-compatible require/createRequire was available"),L(r,null,t);for(let i of n)try{return L(r,e(i),t)}catch(s){t.push(`${i}: ${De(s)}`);}return L(r,null,t)}function ue(){return ae.slice()}function Te(r){return r?[r]:["brass-runtime/wasm/pkg/brass_runtime_wasm_engine.js","../wasm/pkg/brass_runtime_wasm_engine.js","../../../wasm/pkg/brass_runtime_wasm_engine.js","../../../../../wasm/pkg/brass_runtime_wasm_engine.js",`${Me()}/wasm/pkg/brass_runtime_wasm_engine.js`]}function L(r,e,n){return !r.fresh&&r.modulePath==null&&($=e,ae=n),e}function Be(){return We()??Oe()??Ne()}function We(){try{return (0,eval)("typeof __non_webpack_require__ === 'function' ? __non_webpack_require__ : undefined")}catch{return}}function Oe(){try{return (0,eval)("typeof require === 'function' ? require : undefined")}catch{return}}function Ne(){try{return createRequire(import.meta.url)}catch{return}}function Me(){try{return (0,eval)("typeof process !== 'undefined' ? process.cwd() : ''")}catch{return ""}}function De(r){return r instanceof Error?r.message:String(r)}var W;function de(){return W!==void 0||(W=R()?.BrassWasmRingBuffer??null),W}var O=class{engine="wasm";fallbackUsed=false;inner;pushes=0;shifts=0;clears=0;dropped=0;constructor(e,n){let t=de();if(!t)throw new Error("brass-runtime wasm ring buffer is not available. Run npm run build:wasm first.");this.inner=new t(e,n);}get length(){return this.inner.len()}get capacity(){return this.inner.capacity()}isEmpty(){return this.inner.is_empty()}push(e){this.pushes++;let n=this.inner.push(e);return (n&2)!==0&&this.dropped++,n}shift(){let e=this.inner.shift();return e!==void 0&&this.shifts++,e===void 0?void 0:e}clear(){this.clears++,this.inner.clear();}stats(){return {engine:"wasm",fallbackUsed:false,data:{len:this.length,capacity:this.capacity,pushes:this.pushes,shifts:this.shifts,clears:this.clears,dropped:this.dropped}}}},N=class{constructor(e,n){this.inner=e;this.fallbackUsed=n;}inner;fallbackUsed;engine="js";pushes=0;shifts=0;clears=0;dropped=0;get length(){return this.inner.length}get capacity(){return this.inner.capacity}isEmpty(){return this.inner.isEmpty()}push(e){this.pushes++;let n=this.inner.push(e);return (n&2)!==0&&this.dropped++,n}shift(){let e=this.inner.shift();return e!==void 0&&this.shifts++,e}clear(){this.clears++,this.inner.clear();}stats(){return {engine:"js",fallbackUsed:this.fallbackUsed,data:{len:this.length,capacity:this.capacity,pushes:this.pushes,shifts:this.shifts,clears:this.clears,dropped:this.dropped}}}};function Z(r,e=r,n={}){let t=n.engine??"auto";return t==="js"?new N(new I(r,e),false):t==="wasm"?new O(r,e):de()?new O(r,e):new N(new I(r,e),true)}var ce=2048,le=4096,He=8192,Ue=(()=>{if(typeof globalThis.setImmediate=="function")return r=>globalThis.setImmediate(r);if(typeof globalThis.MessageChannel=="function"){let r=new globalThis.MessageChannel,e=null;return r.port1.onmessage=()=>{let n=e;e=null,n?.();},n=>{e=n,r.port2.postMessage(0);}}return r=>setTimeout(r,0)})();function fe(){return R()?.BrassWasmSchedulerStateMachine??null}var Q=class{tasks;tags;flushing=false;scheduled=false;scheduledFlushes=0;completedFlushes=0;enqueuedTasks=0;executedTasks=0;droppedTasks=0;yieldedByBudget=0;constructor(e){let n=e.initialCapacity??1024,t=e.maxCapacity??n;this.tasks=Z(n,t,{engine:e.engine}),this.tags=Z(n,t,{engine:e.engine});}},M=class{machine;nextRef=1;tasks=new Map;tags=new Map;constructor(e){let n=fe();if(!n)throw new Error("brass-runtime wasm scheduler is not available. Run npm run build:wasm first.");this.machine=new n(e.initialCapacity??1024,e.maxCapacity??He,e.flushBudget??ce,e.microThreshold??le);}enqueue(e,n){let t=this.nextRef++;this.tasks.set(t,e),this.tags.set(t,n);let i=this.machine.enqueue(t);return i===3&&(this.tasks.delete(t),this.tags.delete(t)),i}beginFlush(){return this.machine.begin_flush()}shift(){let e=this.machine.shift();if(e===0)return;let n=this.tasks.get(e),t=this.tags.get(e)??"anonymous";return this.tasks.delete(e),this.tags.delete(e),n?{task:n,tag:t}:void 0}endFlush(e){return this.machine.end_flush(e)}get length(){return this.machine.len()}stats(){return {engine:"wasm",fallbackUsed:false,data:JSON.parse(this.machine.stats_json())}}},G=class{engine;js;wasm;flushBudget;microThreshold;fallbackUsed;boundFlush=()=>this.flush();constructor(e={}){this.flushBudget=e.flushBudget??ce,this.microThreshold=e.microThreshold??le;let n=e.engine??"js";if(n==="wasm"){this.wasm=new M(e),this.engine="wasm",this.fallbackUsed=false;return}if(n==="auto"&&fe()){this.wasm=new M(e),this.engine="wasm",this.fallbackUsed=false;return}this.js=new Q({...e,engine:"js"}),this.engine="js",this.fallbackUsed=n==="auto";}schedule(e,n="anonymous"){if(typeof e=="function"){if(this.wasm)return this.scheduleWasm(e,n);this.scheduleJs(e,n);}}stats(){if(this.wasm)return this.wasm.stats();let e=this.js;return {engine:"js",fallbackUsed:this.fallbackUsed,data:{len:e.tasks.length,capacity:e.tasks.capacity,phase:e.flushing?"flushing":e.scheduled?"scheduled":"idle",scheduledFlushes:e.scheduledFlushes,completedFlushes:e.completedFlushes,enqueuedTasks:e.enqueuedTasks,executedTasks:e.executedTasks,droppedTasks:e.droppedTasks,yieldedByBudget:e.yieldedByBudget}}}scheduleWasm(e,n){let t=this.wasm.enqueue(e,n);t===0?this.requestFlush("micro"):t===1&&this.requestFlush("macro");}scheduleJs(e,n){let t=this.js,i=t.tasks.push(e),s=t.tags.push(n);if(t.enqueuedTasks++,((i&2)!==0||(s&2)!==0)&&t.droppedTasks++,!t.flushing&&!t.scheduled){t.scheduled=true,t.scheduledFlushes++;let o=t.tasks.length>this.microThreshold?"macro":"micro";this.requestFlush(o);}}requestFlush(e){e==="micro"?queueMicrotask(this.boundFlush):Ue(this.boundFlush);}flush(){if(this.wasm)return this.flushWasm();this.flushJs();}flushWasm(){let e=this.wasm,n=e.beginFlush();if(n<=0)return;let t=0;try{for(;t<n;){let i=e.shift();if(!i)break;t++;try{i.task();}catch(s){console.error(`[Scheduler] task threw (tag=${i.tag})`,s);}}}finally{let i=e.endFlush(t);i===0?this.requestFlush("micro"):i===1&&this.requestFlush("macro");}}flushJs(){let e=this.js;if(e.flushing)return;e.flushing=true,e.scheduled=false;let n=0;try{for(;n<this.flushBudget;){let t=e.tasks.shift();if(!t)break;let i=e.tags.shift();n++,e.executedTasks++;try{t();}catch(s){console.error(`[Scheduler] task threw (tag=${i})`,s);}}}finally{if(e.flushing=false,e.completedFlushes++,e.tasks.length>0&&!e.scheduled){e.scheduled=true,e.scheduledFlushes++;let t=n>=this.flushBudget||e.tasks.length>this.microThreshold?"macro":"micro";n>=this.flushBudget&&e.yieldedByBudget++,this.requestFlush(t);}}}},w=new G;var pe={parent:null,patch:Object.create(null)};function ye(r,e){let n=je(r);return {initChild(t,i,s){let o=i?.fiberContext,a=Pe(n,o?.trace??null);t.fiberContext={log:o?.log??pe,trace:a},t.parentFiberId=i?.id,t.name=n.childName(i?.name),s!==void 0&&(t.scopeId=s),e.emit({type:"fiber.start",fiberId:t.id,parentFiberId:i?.id,scopeId:t.scopeId,name:t.name},{fiberId:i?.id,traceId:o?.trace?.traceId,spanId:o?.trace?.spanId});}}}function je(r){let e={newTraceId:()=>he("trace"),newSpanId:()=>he("span")},n=r?.brass,t=n?.tracer??e,i=n?.traceSeed,s=n?.childName??(o=>o?`${o}/child`:void 0);return {tracer:t,seed:i,childName:s}}function he(r){let e=globalThis.crypto;return typeof e?.randomUUID=="function"?e.randomUUID():`${r}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function Pe(r,e){return e?{traceId:e.traceId,spanId:r.tracer.newSpanId(),parentSpanId:e.spanId,sampled:e.sampled}:r.seed?{...r.seed}:{traceId:r.tracer.newTraceId(),spanId:r.tracer.newSpanId(),sampled:true}}var me={async execute(r){return {kind:"error",actionId:r.actionId,error:new Error(`No HostExecutor configured for HostAction kind=${r.kind} target=${r.target}`)}}};var x=class{constructor(e){this.runtime=e;}runtime;kind="js";startedFibers=0;fork(e,n){this.startedFibers+=1;let t=new D(this.runtime,e);return n!==void 0&&(t.scopeId=n),t}stats(){return {engine:this.kind,startedFibers:this.startedFibers,runningFibers:0,suspendedFibers:0,queuedFibers:0,completedFibers:0,failedFibers:0,interruptedFibers:0,pendingHostEffects:0}}};var K=class{nextRef=1;refs=new Map;register(e){let n=this.nextRef++;return this.refs.set(n,e),n}get(e){if(!this.refs.has(e))throw new Error(`Missing host registry ref ${e}`);return this.refs.get(e)}set(e,n){this.refs.set(e,n);}delete(e){this.refs.delete(e);}clear(){this.refs.clear();}size(){return this.refs.size}},H=class{nodes=[];registry=new K;compile(e){return {program:{version:1,root:this.visit(e),nodes:this.nodes},registry:this.registry}}append(e){let n=this.nodes.length;return {root:this.visit(e),nodes:this.nodes.slice(n)}}add(e){let n=this.nodes.length;return this.nodes.push(e),n}visit(e){let n=e;switch(n._tag){case "Succeed":return this.add({tag:"Succeed",valueRef:this.registry.register(n.value)});case "Fail":return this.add({tag:"Fail",errorRef:this.registry.register(n.error)});case "Sync":return this.add({tag:"Sync",fnRef:this.registry.register(n.thunk)});case "Async":return this.add({tag:"Async",registerRef:this.registry.register(n.register)});case "FlatMap":return this.add({tag:"FlatMap",first:this.visit(n.first),fnRef:this.registry.register(n.andThen)});case "Fold":return this.add({tag:"Fold",first:this.visit(n.first),onFailureRef:this.registry.register(n.onFailure),onSuccessRef:this.registry.register(n.onSuccess)});case "Fork":{let t={tag:"Fork",effectRef:this.registry.register(n.effect)};return this.add(n.scopeId===void 0?t:{...t,scopeId:n.scopeId})}case "HostAction":{let t={tag:"HostAction",actionRef:this.registry.register(n.action)};return this.add(n.decode===void 0?t:{...t,decodeRef:this.registry.register(n.decode)})}default:return this.add({tag:"Fail",errorRef:this.registry.register(new Error(`Unknown Async opcode: ${n?._tag}`))})}}};var U=class{constructor(e,n,t,i,s,o){this.onScheduledStep=t;this.onInterrupt=i;this.onJoiner=s;this.onQueued=o;this.id=e,this.runtime=n;}onScheduledStep;onInterrupt;onJoiner;onQueued;id;runtime;fiberContext;name;scopeId;parentFiberId;result=null;joiners=[];finalizers=[];finalizersDrained=false;internalStatus="running";queued=false;status(){return this.result==null?"Running":this.result._tag==="Failure"&&this.result.cause._tag==="Interrupt"?"Interrupted":"Done"}engineStatus(){return this.internalStatus}setEngineStatus(e){this.internalStatus=e;}join(e){this.result!=null?e(this.result):(this.onJoiner?.(this.id),this.joiners.push(e));}interrupt(){this.result==null&&this.onInterrupt(this.id,c.interrupt());}addFinalizer(e){this.finalizers.push(e);}schedule(e="step"){this.result!=null||this.queued||(this.queued=true,this.internalStatus="queued",this.onQueued?.(this.id),this.runtime.scheduler.schedule(()=>{this.queued=false,this.result==null&&this.onScheduledStep(this.id);},`wasm-fiber#${this.id}.${e}`));}emit(e){this.runtime.hooks.emit(e,{fiberId:this.id,scopeId:this.scopeId,traceId:this.fiberContext?.trace?.traceId,spanId:this.fiberContext?.trace?.spanId});}succeed(e){this.complete(l.succeed(e));}fail(e){this.complete(l.failCause(c.fail(e)));}die(e){this.complete(l.failCause(c.die(e)));}interrupted(){this.complete(l.failCause(c.interrupt()));}complete(e){if(this.result!=null)return;this.runFinalizersOnce(e),this.result=e,this.internalStatus=e._tag==="Success"?"done":e.cause._tag==="Interrupt"?"interrupted":"failed";let n=e._tag==="Success"?"success":e.cause._tag==="Interrupt"?"interrupted":"failure";this.emit({type:"fiber.end",fiberId:this.id,status:n,error:e._tag==="Failure"?e.cause:void 0});for(let t of this.joiners)t(e);this.joiners.length=0;}runFinalizersOnce(e){if(!this.finalizersDrained)for(this.finalizersDrained=true;this.finalizers.length>0;){let n=this.finalizers.pop();try{let t=n(e);t&&typeof t=="object"&&"_tag"in t&&this.runtime.fork(t);}catch{}}}};var j=class{kind="wasm-reference";nextFiberId=1;fibers=new Map;started=0;completed=0;failed=0;interrupted=0;createFiber(e){let n=this.nextFiberId++;return this.started+=1,this.fibers.set(n,{id:n,program:qe(e),current:e.root,stack:[],status:"running",lastEvent:void 0}),n}poll(e){let n=this.mustFiber(e);return n.status==="suspended"&&n.lastEvent?n.lastEvent:this.step(n)}provideValue(e,n){let t=this.mustFiber(e);return t.status="running",t.lastEvent=void 0,this.success(t,n)}provideError(e,n){let t=this.mustFiber(e);return t.status="running",t.lastEvent=void 0,this.failure(t,n)}provideEffect(e,n,t){let i=this.mustFiber(e);return i.status="running",i.lastEvent=void 0,i.program.nodes.push(...t.map(s=>({...s}))),i.current=n,this.step(i)}interrupt(e,n){let t=this.mustFiber(e);t.status="interrupted",t.current=void 0,t.stack=[],this.interrupted+=1;let i={kind:"Interrupted",fiberId:e,reasonRef:n};return t.lastEvent=i,i}dropFiber(e){this.fibers.delete(e);}stats(){let e=0,n=0;for(let t of this.fibers.values())t.status==="running"&&(e+=1),t.status==="suspended"&&(n+=1);return {started:this.started,live:this.fibers.size,running:e,suspended:n,completed:this.completed,failed:this.failed,interrupted:this.interrupted}}mustFiber(e){let n=this.fibers.get(e);if(!n)throw new Error(`Fiber ${e} not found`);return n}step(e){for(;;){if(e.status==="interrupted"){let t=e.lastEvent??{kind:"Interrupted",fiberId:e.id,reasonRef:0};return e.lastEvent=t,t}if(e.current===void 0)return this.markFailed(e,0);let n=e.program.nodes[e.current];if(!n)return this.markFailed(e,0);switch(n.tag){case "Succeed":return e.current=void 0,this.success(e,n.valueRef);case "Fail":return e.current=void 0,this.failure(e,n.errorRef);case "Sync":return this.suspend(e,{kind:"InvokeSync",fiberId:e.id,fnRef:n.fnRef});case "Async":return this.suspend(e,{kind:"InvokeAsync",fiberId:e.id,registerRef:n.registerRef});case "FlatMap":e.stack.push({tag:"SuccessCont",fnRef:n.fnRef}),e.current=n.first;continue;case "Fold":e.stack.push({tag:"FoldCont",onFailureRef:n.onFailureRef,onSuccessRef:n.onSuccessRef}),e.current=n.first;continue;case "Fork":{let t=n.scopeId===void 0?{kind:"InvokeFork",fiberId:e.id,effectRef:n.effectRef}:{kind:"InvokeFork",fiberId:e.id,effectRef:n.effectRef,scopeId:n.scopeId};return this.suspend(e,t)}case "HostAction":{let t=n.decodeRef===void 0?{kind:"InvokeHostAction",fiberId:e.id,actionRef:n.actionRef}:{kind:"InvokeHostAction",fiberId:e.id,actionRef:n.actionRef,decodeRef:n.decodeRef};return this.suspend(e,t)}}}}success(e,n){let t=e.stack.pop();return t?t.tag==="SuccessCont"?this.suspend(e,{kind:"InvokeFlatMap",fiberId:e.id,fnRef:t.fnRef,valueRef:n}):this.suspend(e,{kind:"InvokeFoldSuccess",fiberId:e.id,fnRef:t.onSuccessRef,valueRef:n}):this.markDone(e,n)}failure(e,n){for(;e.stack.length>0;){let t=e.stack.pop();if(t.tag==="FoldCont")return this.suspend(e,{kind:"InvokeFoldFailure",fiberId:e.id,fnRef:t.onFailureRef,errorRef:n})}return this.markFailed(e,n)}suspend(e,n){return e.status="suspended",e.lastEvent=n,n}markDone(e,n){e.status="done",e.current=void 0,this.completed+=1;let t={kind:"Done",fiberId:e.id,valueRef:n};return e.lastEvent=t,t}markFailed(e,n){e.status="failed",e.current=void 0,this.failed+=1;let t={kind:"Failed",fiberId:e.id,errorRef:n};return e.lastEvent=t,t}};function qe(r){return {version:r.version,root:r.root,nodes:r.nodes.map(e=>({...e}))}}var P=class{kind="wasm";vm;constructor(e){let n=ze(e);this.vm=new n.BrassWasmVm;}createFiber(e){return this.vm.create_fiber(JSON.stringify(e))}poll(e){return JSON.parse(this.vm.poll(e))}provideValue(e,n){return JSON.parse(this.vm.provide_value(e,n))}provideError(e,n){return JSON.parse(this.vm.provide_error(e,n))}provideEffect(e,n,t){return JSON.parse(this.vm.provide_effect(e,n,JSON.stringify(t)))}interrupt(e,n){return JSON.parse(this.vm.interrupt(e,n))}dropFiber(e){this.vm.drop_fiber(e);}stats(){return JSON.parse(this.vm.stats_json())}};function ze(r){let e=R({modulePath:r});if(e)return e;let n=ue();throw new Error(["engine='wasm' could not load wasm/pkg/brass_runtime_wasm_engine.js.","Run `npm run build:wasm` first and make sure wasm/pkg is present in the package.","For Node 18 + webpack, keep brass-runtime's wasm/pkg files available at runtime or externalize brass-runtime.",...n.map(t=>`- ${t}`)].join(`
|
|
2
|
-
`))}var ge=0,be=1,Re=2,Ee=3,ve=4,Ae=5,q=class{registry;constructor(){let n=R()?.BrassWasmFiberRegistry;if(!n)throw new Error("brass-runtime wasm fiber registry is not available. Run npm run build:wasm first.");this.registry=new n;}registerFiber(e,n,t){this.registry.register_fiber(e,n??0,t??0,Date.now());}markQueued(e){this.registry.mark_queued(e,Date.now());}markRunning(e){this.registry.mark_running(e,Date.now());}markSuspended(e){this.registry.mark_suspended(e,Date.now());}markDone(e,n){return this.registry.mark_done(e,Ve(n),Date.now())}dropFiber(e){this.registry.drop_fiber(e);}addJoiner(e){this.registry.add_joiner(e);}wake(e){return this.registry.wake(e)}drainWakeup(){let e=this.registry.drain_wakeup();return e===0?void 0:e}drainWakeups(){let e=[];for(;;){let n=this.drainWakeup();if(n===void 0)return e;e.push(n);}}wakeQueueLength(){return this.registry.wake_queue_len()}stateOf(e){let n=this.registry.state_of(e);return n===4294967295?"missing":Je(n)}stats(){return JSON.parse(this.registry.stats_json())}};function Ve(r){switch(r){case "queued":return ge;case "running":return be;case "suspended":return Re;case "done":return Ee;case "failed":return ve;case "interrupted":return Ae}}function Je(r){switch(r){case ge:return "queued";case be:return "running";case Re:return "suspended";case Ee:return "done";case ve:return "failed";case Ae:return "interrupted";default:return "missing"}}var Le=4096,k=class{constructor(e,n={}){this.runtime=e;this.bridge=n.bridge??(n.reference?new j:new P(n.modulePath)),this.kind=this.bridge.kind,this.fiberRegistry=this.kind==="wasm"?new q:void 0;}runtime;kind;bridge;startedFibers=0;runningFibers=0;suspendedFibers=0;completedFibers=0;failedFibers=0;interruptedFibers=0;pendingHostEffects=0;states=new Map;fiberRegistry;fork(e,n){let t=new H,i=t.compile(e),s=this.bridge.createFiber(i.program),o=new AbortController,a=new U(s,this.runtime,d=>this.scheduleWakeup(d),(d,p)=>this.interruptById(d,p),d=>this.fiberRegistry?.addJoiner(d),d=>this.fiberRegistry?.markQueued(d));n!==void 0&&(a.scopeId=n);let u={fiberId:s,handle:a,builder:t,registry:i.registry,controller:o,startedAt:Date.now(),completed:false,status:"running",pendingCleanups:new Set};return this.states.set(s,u),this.fiberRegistry?.registerFiber(s,void 0,n),this.startedFibers+=1,this.runningFibers+=1,a}stats(){let e=0;for(let n of this.states.values())e+=n.registry.size();return {engine:this.kind,startedFibers:this.startedFibers,runningFibers:this.runningFibers,suspendedFibers:this.suspendedFibers,queuedFibers:0,completedFibers:this.completedFibers,failedFibers:this.failedFibers,interruptedFibers:this.interruptedFibers,pendingHostEffects:this.pendingHostEffects,hostRegistryRefs:e,wasm:this.bridge.stats(),fiberRegistry:this.fiberRegistry?.stats()}}async shutdown(){for(let e of Array.from(this.states.values()))this.interruptState(e,c.interrupt());}scheduleWakeup(e){let n=this.states.get(e);if(!(!n||n.completed)){if(!this.fiberRegistry){this.driveById(e);return}this.fiberRegistry.wake(e)&&this.drainWakeups();}}drainWakeups(){if(this.fiberRegistry)for(let e of this.fiberRegistry.drainWakeups())this.driveById(e);}driveById(e){let n=this.states.get(e);!n||n.completed||(this.fiberRegistry?.markRunning(e),_(n.handle,()=>this.drive(n)));}drive(e,n){if(e.completed)return;let t=Le,i=n??this.bridge.poll(e.fiberId);for(e.status="running",e.handle.setEngineStatus("running");!e.completed&&t-- >0;)try{switch(i.kind){case "Continue":i=this.bridge.poll(e.fiberId);continue;case "Done":{let s=e.registry.get(i.valueRef);this.completeSuccess(e,s);return}case "Failed":{let s=i.errorRef===0?new Error("WASM fiber failed"):e.registry.get(i.errorRef);this.completeFailure(e,s);return}case "Interrupted":{this.completeInterrupted(e);return}case "InvokeSync":{let s=e.registry.get(i.fnRef);try{let o=e.registry.register(s(this.runtime.env));i=this.bridge.provideValue(e.fiberId,o);}catch(o){i=this.bridge.provideError(e.fiberId,e.registry.register(o));}continue}case "InvokeFlatMap":{let s=e.registry.get(i.fnRef),o=e.registry.get(i.valueRef);try{let a=s(o),u=e.builder.append(a);i=this.bridge.provideEffect(e.fiberId,u.root,u.nodes);}catch(a){i=this.bridge.provideError(e.fiberId,e.registry.register(a));}continue}case "InvokeFoldFailure":{let s=e.registry.get(i.fnRef),o=e.registry.get(i.errorRef);try{let a=s(o),u=e.builder.append(a);i=this.bridge.provideEffect(e.fiberId,u.root,u.nodes);}catch(a){i=this.bridge.provideError(e.fiberId,e.registry.register(a));}continue}case "InvokeFoldSuccess":{let s=e.registry.get(i.fnRef),o=e.registry.get(i.valueRef);try{let a=s(o),u=e.builder.append(a);i=this.bridge.provideEffect(e.fiberId,u.root,u.nodes);}catch(a){i=this.bridge.provideError(e.fiberId,e.registry.register(a));}continue}case "InvokeFork":{let s=e.registry.get(i.effectRef);try{let o=this.runtime.fork(s,i.scopeId);i=this.bridge.provideValue(e.fiberId,e.registry.register(o));}catch(o){i=this.bridge.provideError(e.fiberId,e.registry.register(o));}continue}case "InvokeAsync":{this.scheduleAsync(e,i.registerRef);return}case "InvokeHostAction":{this.scheduleHostAction(e,i.actionRef,i.decodeRef);return}}}catch(s){i=this.bridge.provideError(e.fiberId,e.registry.register(s));}e.completed||e.handle.schedule("budget-yield");}scheduleAsync(e,n){this.markSuspended(e,"async"),this.pendingHostEffects+=1;let t=e.registry.get(n),i=false,s=false,o=null,a=()=>{i=true,e.pendingCleanups.delete(a);};e.pendingCleanups.add(a);let u=d=>{if(i)return;let p=d;if(!s){o=p;return}a(),this.pendingHostEffects=Math.max(0,this.pendingHostEffects-1),this.markRunning(e,"async"),this.resumeWithExit(e,p);};try{let d=t(this.runtime.env,u);if(s=!0,o){a(),this.pendingHostEffects=Math.max(0,this.pendingHostEffects-1),this.markRunning(e,"async-sync"),this.resumeWithExit(e,o);return}if(typeof d=="function"){let p=()=>{if(!i){i=!0;try{d();}catch{}e.pendingCleanups.delete(p);}};e.pendingCleanups.add(p),e.handle.addFinalizer(()=>p());}}catch(d){a(),this.pendingHostEffects=Math.max(0,this.pendingHostEffects-1),this.markRunning(e,"async-register-error"),this.resumeWithError(e,d);}}scheduleHostAction(e,n,t){this.markSuspended(e,"host-action"),this.pendingHostEffects+=1;let i=e.registry.get(n),o=()=>{e.pendingCleanups.delete(o);};e.pendingCleanups.add(o),this.runtime.hostExecutor.execute(i,{fiberId:e.fiberId,env:this.runtime.env,signal:e.controller.signal,deadlineAt:i.timeoutMs===void 0?void 0:Date.now()+i.timeoutMs}).then(a=>{if(o(),!e.completed){this.pendingHostEffects=Math.max(0,this.pendingHostEffects-1),this.markRunning(e,"host-action");try{if(t!==void 0){let u=e.registry.get(t);this.resumeWithValue(e,u(a));return}if(a.kind==="error"){this.resumeWithError(e,a.error);return}this.resumeWithValue(e,a.value);}catch(u){this.resumeWithError(e,u);}}}).catch(a=>{o(),!e.completed&&(this.pendingHostEffects=Math.max(0,this.pendingHostEffects-1),this.markRunning(e,"host-action-error"),this.resumeWithError(e,a));});}resumeWithExit(e,n){if(e.completed)return;if(n._tag==="Success"){this.resumeWithValue(e,n.value);return}let t=n.cause;if(t._tag==="Interrupt"){this.interruptState(e,t);return}if(t._tag==="Fail"){this.resumeWithError(e,t.error);return}this.completeDie(e,t.defect);}resumeWithValue(e,n){let t=this.bridge.provideValue(e.fiberId,e.registry.register(n));this.runtime.scheduler.schedule(()=>_(e.handle,()=>this.drive(e,t)),`wasm-fiber#${e.fiberId}.resume`);}resumeWithError(e,n){let t=this.bridge.provideError(e.fiberId,e.registry.register(n));this.runtime.scheduler.schedule(()=>_(e.handle,()=>this.drive(e,t)),`wasm-fiber#${e.fiberId}.resume-error`);}interruptById(e,n){let t=this.states.get(e);t&&this.interruptState(t,n);}interruptState(e,n){if(e.completed)return;e.controller.signal.aborted||e.controller.abort(n);for(let i of Array.from(e.pendingCleanups))i();let t=this.bridge.interrupt(e.fiberId,e.registry.register(n));this.drive(e,t);}markSuspended(e,n){e.status!=="suspended"&&(this.suspendedFibers+=1,e.status="suspended",this.fiberRegistry?.markSuspended(e.fiberId),e.handle.setEngineStatus("suspended"),e.handle.emit({type:"fiber.suspend",fiberId:e.fiberId,reason:n}));}markRunning(e,n){e.status==="suspended"&&(this.suspendedFibers=Math.max(0,this.suspendedFibers-1),e.status="running",this.fiberRegistry?.markRunning(e.fiberId),e.handle.setEngineStatus("running"),e.handle.emit({type:"fiber.resume",fiberId:e.fiberId}));}completeSuccess(e,n){e.completed||(e.completed=true,e.status="done",this.fiberRegistry?.markDone(e.fiberId,"done"),this.completedFibers+=1,this.cleanupState(e),e.handle.succeed(n));}completeFailure(e,n){e.completed||(e.completed=true,e.status="failed",this.fiberRegistry?.markDone(e.fiberId,"failed"),this.failedFibers+=1,this.cleanupState(e),e.handle.fail(n));}completeDie(e,n){e.completed||(e.completed=true,e.status="failed",this.fiberRegistry?.markDone(e.fiberId,"failed"),this.failedFibers+=1,this.cleanupState(e),e.handle.die(n));}completeInterrupted(e){e.completed||(e.completed=true,e.status="interrupted",this.fiberRegistry?.markDone(e.fiberId,"interrupted"),this.interruptedFibers+=1,this.cleanupState(e),e.handle.interrupted());}cleanupState(e){this.runningFibers=Math.max(0,this.runningFibers-1),e.status==="suspended"&&(this.suspendedFibers=Math.max(0,this.suspendedFibers-1));for(let n of Array.from(e.pendingCleanups))n();e.pendingCleanups.clear(),this.bridge.dropFiber(e.fiberId),this.fiberRegistry?.dropFiber(e.fiberId),e.registry.clear(),this.states.delete(e.fiberId);}};function Y(){let r=R();return {wasmAvailable:!!r,wasmFiberEngine:typeof r?.BrassWasmVm=="function",wasmRingBuffer:typeof r?.BrassWasmRingBuffer=="function",wasmScheduler:typeof r?.BrassWasmSchedulerStateMachine=="function",wasmFiberRegistry:typeof r?.BrassWasmFiberRegistry=="function",wasmStreamChunks:typeof r?.BrassWasmChunkBuffer=="function"}}var X={emit(){}},C=class r{env;scheduler;hooks;hostExecutor;engineMode;wasmOptions;fiberEngine;fallbackUsed;forkPolicy;registry;constructor(e){this.env=e.env,this.scheduler=e.scheduler??w,this.hooks=e.hooks??X,this.hostExecutor=e.hostExecutor??me,this.engineMode=e.engine??"auto",this.wasmOptions=e.wasm,this.forkPolicy=ye(this.env,this.hooks);let n=this.makeFiberEngine(this.engineMode,e.wasm);this.fiberEngine=n.engine,this.fallbackUsed=n.fallbackUsed;}makeFiberEngine(e,n){if(e==="js")return {engine:new x(this),fallbackUsed:false};if(e==="wasm-reference")return {engine:new k(this,{...n,reference:true}),fallbackUsed:false};if(e==="wasm")return {engine:new k(this,n),fallbackUsed:false};try{if(Y().wasmFiberEngine)return {engine:new k(this,n),fallbackUsed:!1}}catch{}return {engine:new x(this),fallbackUsed:true}}hasActiveHooks(){return this.hooks!==X}provide(e){return new r({env:Object.assign({},this.env,e),scheduler:this.scheduler,hooks:this.hooks,engine:this.engineMode,hostExecutor:this.hostExecutor,wasm:this.wasmOptions})}emit(e){if(this.hooks===X)return;let n=S(),t={fiberId:n?.id,scopeId:n?.scopeId,traceId:n?.fiberContext?.trace?.traceId,spanId:n?.fiberContext?.trace?.spanId};this.hooks.emit(e,t);}fork(e,n){let t=S(),i=this.fiberEngine.fork(e,n);return n!==void 0&&(i.scopeId=n),this.forkPolicy.initChild(i,t,n),i.schedule?.("initial-step"),i}stats(){let e=this.fiberEngine.stats();return {engine:this.fiberEngine.kind==="js"?"js":"wasm",fallbackUsed:this.fallbackUsed,data:e}}capabilities(){return Y()}shutdown(){return this.fiberEngine.shutdown?.()}unsafeRunAsync(e,n){this.fork(e).join(n);}toPromise(e){return new Promise((n,t)=>{this.fork(e).join(s=>{if(s._tag==="Success")n(s.value);else {let o=s.cause;o?._tag==="Fail"?t(o.error):t(new Error("Interrupted"));}});})}unsafeRun(e){this.unsafeRunAsync(e,()=>{});}delay(e,n){return h((t,i)=>{let s=setTimeout(()=>{this.unsafeRunAsync(n,i);},e);return ()=>clearTimeout(s)})}static make(e,n=w){return new r({env:e,scheduler:n})}static makeWithEngine(e,n,t={}){return new r({...t,env:e,engine:n})}log(e,n,t){this.emit({type:"log",level:e,message:n,fields:t});}};function pt(r,e){return C.make(e??{}).fork(r)}function ee(r,e,n){C.make(e??{}).unsafeRunAsync(r,n);}function ht(r,e){return C.make(e??{}).toPromise(r)}function yt(r,e){return {_tag:"Async",register:(n,t)=>{let i=new AbortController,s=false;return r(i.signal,n).then(o=>{s||(s=true,t(l.succeed(o)));}).catch(o=>{s||(s=true,t(l.failCause(c.fail(e(o)))));}),()=>{s||(s=true,i.abort(),t(l.failCause(c.interrupt())));}}}}function mt(r,e,n,t){ee(r,e,i=>{i._tag==="Failure"?n(i.cause):t(i.value);});}var z=null,g={CONTINUE:"Continue",SUSPEND:"Suspend",DONE:"Done"},v={QUEUED:"Queued",RUNNING:"Running",SUSPENDED:"Suspended",DONE:"Done"},$e=1,Fe=4096,ne;function kt(r){ne=r;}function St(){return ne}function Ze(r){let e=r;for(;e._tag==="FlatMap"&&e.first?._tag==="FlatMap";){let n=e.first,t=e.andThen;e={_tag:"FlatMap",first:n.first,andThen:i=>({_tag:"FlatMap",first:n.andThen(i),andThen:t})};}return e}var D=class{id;runtime;closing=null;finishing=false;runState=v.RUNNING;interrupted=false;result=null;joiners=[];current;stack=[];fiberFinalizers=[];finalizersDrained=false;fiberContext;name;scopeId;boundStep;constructor(e,n){this.id=$e++,this.runtime=e,this.current=n,this.boundStep=()=>{_(this,()=>{if(this.runState===v.DONE)return;switch(this.runState=v.RUNNING,this.step()){case g.CONTINUE:this.schedule("continue");return;case g.SUSPEND:this.runState=v.SUSPENDED,this.emit({type:"fiber.suspend",fiberId:this.id});return;case g.DONE:this.runState=v.DONE;return}});};}get env(){return this.runtime.env}get scheduler(){return this.runtime.scheduler??w}emit(e){this.runtime.hooks.emit(e,{fiberId:this.id,scopeId:this.scopeId,traceId:this.fiberContext?.trace?.traceId,spanId:this.fiberContext?.trace?.spanId});}addFinalizer(e){this.fiberFinalizers.push(e);}status(){return this.result==null?"Running":this.result._tag==="Failure"&&this.result.cause._tag==="Interrupt"?"Interrupted":"Done"}join(e){this.result!=null?e(this.result):this.joiners.push(e);}interrupt(){this.result==null&&(this.interrupted||(this.interrupted=true,this.schedule("interrupt-step")));}schedule(e="step"){this.runState===v.DONE||this.runState===v.QUEUED||(this.runState===v.SUSPENDED&&this.emit({type:"fiber.resume",fiberId:this.id}),this.runState=v.QUEUED,this.scheduler.schedule(this.boundStep,`fiber#${this.id}.${e}`));}runFinalizersOnce(e){if(!this.finalizersDrained)for(this.finalizersDrained=true;this.fiberFinalizers.length>0;){let n=this.fiberFinalizers.pop();try{let t=n(e);t&&typeof t=="object"&&"_tag"in t&&ee(t,this.env,()=>{});}catch{}}}notify(e){if(this.result!=null||this.closing!=null)return;this.finishing=true,this.closing=e,this.runFinalizersOnce(e),this.result=e;let n=e._tag==="Success"?"success":e.cause._tag==="Interrupt"?"interrupted":"failure";this.emit({type:"fiber.end",fiberId:this.id,status:n,error:e._tag==="Failure"?e.cause:void 0});for(let t of this.joiners)t(e);this.joiners.length=0;}onSuccess(e){let n=this.stack.pop();if(!n){this.notify(l.succeed(e));return}if(n._tag==="SuccessCont"){try{this.current=n.k(e);}catch(t){this.notify(l.failCause(c.die(t)));}return}try{this.current=n.onSuccess(e);}catch(t){this.notify(l.failCause(c.die(t)));}}onFailure(e){for(;this.stack.length>0;){let n=this.stack.pop();if(n._tag==="FoldCont")try{this.current=n.onFailure(e);return}catch(t){e=t;continue}}this.notify(l.failCause(c.fail(e)));}budget=Fe;step(){if(this.result!=null)return g.DONE;if(this.interrupted)return this.notify(l.failCause(c.interrupt())),g.DONE;for(this.budget=ne??Fe;this.budget-- >0;){this.current=Ze(this.current);let e=this.current;switch(e._tag){case "Succeed":{this.onSuccess(e.value);break}case "Fail":{this.onFailure(e.error);break}case "FlatMap":{this.stack.push({_tag:"SuccessCont",k:e.andThen}),this.current=e.first;break}case "Fold":{this.stack.push({_tag:"FoldCont",onFailure:e.onFailure,onSuccess:e.onSuccess}),this.current=e.first;break}case "Async":{if(this.finishing)return this.result!=null?g.DONE:g.CONTINUE;let n=false,t=false,i=false,s=null,o=u=>{if(n||(n=true,this.result!=null||this.closing!=null))return;if(!t){i=true,s=u;return}if(u._tag==="Success"){this.current=J.succeed(u.value),this.schedule("async-resume");return}let d=u.cause;if(d._tag==="Interrupt"){this.notify(l.failCause(c.interrupt()));return}if(d._tag==="Fail"){this.current=J.fail(d.error),this.schedule("async-resume");return}this.notify(l.failCause(c.die(d.defect)));},a=e.register(this.env,o);if(t=true,i&&s){let u=s;if(u._tag==="Success")this.onSuccess(u.value);else {let d=u.cause;d._tag==="Interrupt"?this.notify(l.failCause(c.interrupt())):d._tag==="Fail"?this.onFailure(d.error):this.notify(l.failCause(c.die(d.defect)));}break}return typeof a=="function"&&this.addFinalizer(()=>{n=true;try{a();}catch{}}),g.SUSPEND}case "Fork":{let n=this.runtime.fork(e.effect,e.scopeId);this.onSuccess(n);break}case "Sync":{try{let n=e.thunk(this.env);this.onSuccess(n);}catch(n){this.onFailure(n);}break}default:return this.onFailure(new Error(`Unknown opcode: ${e._tag}`)),g.CONTINUE}if(this.result!=null)return g.DONE}return g.CONTINUE}};function S(){return z}function It(){let r=S();if(!r?.runtime)throw new Error("unsafeGetCurrentRuntime: no current fiber/runtime");return r.runtime}function _(r,e){let n=z;z=r;try{return e()}finally{z=n;}}var Qe=1;function Ge(r){return h((e,n)=>{let t=r.length;if(t===0){n({_tag:"Success",value:void 0});return}for(let i of r)i.join(()=>{t-=1,t===0&&n({_tag:"Success",value:void 0});});})}var te=class r{constructor(e,n){this.runtime=e;this.parentScopeId=n;this.id=Qe++;let t=this.parentScopeId??S()?.scopeId;this.runtime.hasActiveHooks()&&this.runtime.emit({type:"scope.open",scopeId:this.id,parentScopeId:t});}runtime;parentScopeId;id;closed=false;children=new Set;subScopes=new Set;finalizers=[];addFinalizer(e){if(this.closed)throw new Error("Trying to add finalizer to closed scope");this.finalizers.push(e);}subScope(){if(this.closed)throw new Error("Scope closed");let e=new r(this.runtime,this.id);return this.subScopes.add(e),e}fork(e){if(this.closed)throw new Error("Scope closed");let n=this.runtime.fork(e,this.id);return this.children.add(n),n.join(()=>this.children.delete(n)),n}close(e={_tag:"Success",value:void 0}){this.runtime.fork(this.closeAsync(e));}emitCloseEvent(e){if(this.runtime.hasActiveHooks()){let n=e._tag==="Success"?"success":e.cause._tag==="Interrupt"?"interrupted":"failure";this.runtime.emit({type:"scope.close",scopeId:this.id,status:n,error:e._tag==="Failure"&&e.cause._tag==="Fail"?e.cause.error:void 0});}}buildFinalizerEffect(e){let n=this.finalizers;if(n.length===0)return m();let t=m();for(let i=n.length-1;i>=0;i--){let s=n[i];t=y(t,()=>{let o;try{o=s(e);}catch{return m()}return o._tag==="Succeed"?m():F(o,()=>m(),()=>m())});}return t}closeAsync(e={_tag:"Success",value:void 0},n={awaitChildren:true}){return y(m(),()=>h((t,i)=>{if(this.closed){i({_tag:"Success",value:void 0});return}this.closed=true;let s=Array.from(this.children),o=Array.from(this.subScopes);for(let V of s)V.interrupt();let a=o.reduceRight((V,ke)=>y(V,()=>ke.closeAsync(e,n)),m()),u=this.buildFinalizerEffect(e),d=n.awaitChildren&&s.length>0,p=d?Ge(s):m(),b=o.length>0,f=this.finalizers.length===0;if(!b&&!d&&f){this.emitCloseEvent(e),i({_tag:"Success",value:void 0});return}let A=y(a,()=>y(p,()=>u));this.runtime.fork(A).join(()=>{this.emitCloseEvent(e),i({_tag:"Success",value:void 0});});}))}};function Ke(r,e){return h((n,t)=>{let i=new te(r),s=false,o=u=>{r.fork(i.closeAsync(u)).join(()=>{s||(s=true,t(u));});},a=r.fork(e(i));return a.join(o),()=>{s||(a.interrupt(),r.fork(i.closeAsync(l.failCause(c.interrupt()))));}})}function Wt(r,e){return Ke(r,n=>{let t=e(n);return t&&typeof t=="object"&&"_tag"in t?t:m()})}function Dt(r,e,n){return h((t,i)=>{let s=n.subScope(),o=false,a=p=>{o||(o=true,s.close(p),i(p));},u=s.fork(r),d=s.fork(e);u.join(a),d.join(a);})}function Ht(r,e,n){return h((t,i)=>{let s=n.subScope(),o=null,a=null,u=false,d=()=>{if(!o||!a||u)return;if(u=true,o._tag==="Success"&&a._tag==="Success"){s.close({_tag:"Success",value:void 0}),i({_tag:"Success",value:[o.value,a.value]});return}let f;if(o._tag==="Failure")f=o.cause;else if(a._tag==="Failure")f=a.cause;else throw new Error("zipPar: unreachable state (no Failure exit)");let A={_tag:"Failure",cause:f};s.close(A),i(A);},p=s.fork(r),b=s.fork(e);p.join(f=>{o=f,d();}),b.join(f=>{a=f,d();});})}function Ut(r,e){return h((n,t)=>{let i=e.subScope(),s=new Array(r.length),o=0,a=false;r.forEach((u,d)=>{i.fork(u).join(b=>{if(!a){if(b._tag==="Failure"){a=true;let f={_tag:"Failure",cause:b.cause};i.close(f),t(f);return}if(s[d]=b.value,o++,o===r.length){a=true;let f={_tag:"Success",value:s};i.close({_tag:"Success",value:void 0}),t(f);}}});});})}function jt(r,e,n,t,i){return h((s,o)=>{let a=n.subScope(),u=false,d=a.fork(r),p=a.fork(e),b=f=>{a.fork(f).join(A=>{a.close(A),o(A);});};d.join(f=>{u||(u=true,b(t(f,p,a)));}),p.join(f=>{u||(u=true,b(i(f,d,a)));});})}export{C as $,yn as A,mn as B,gn as C,bn as D,_e as E,I as F,R as G,Z as H,G as I,w as J,kt as K,St as L,D as M,S as N,It as O,_ as P,me as Q,x as R,K as S,H as T,U,j as V,P as W,q as X,k as Y,Y as Z,X as _,J as a,pt as aa,F as b,ee as ba,Ye as c,ht as ca,re as d,yt as da,m as e,mt as ea,E as f,te as fa,T as g,Ke as ga,B as h,Wt as ha,Xe as i,Dt as ia,h as j,Ht as ja,se as k,Ut as ka,y as l,jt as la,en as m,nn as n,tn as o,rn as p,sn as q,oe as r,an as s,c as t,l as u,ln as v,xe as w,fn as x,pn as y,hn as z};
|
package/dist/chunk-W6TVAMYC.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {f,j,l,ia,g,ga,u as u$1,t,da as da$1,b as b$1,h as h$1,k}from'./chunk-LTHJNW5A.js';import {existsSync,statSync}from'fs';import {resolve,dirname,join}from'path';var Le=e=>({goal:e,phase:"boot",observations:[],errors:[],steps:0});var zt=(e,t)=>{switch(t.type){case "agent.done":return "done";case "agent.error":return e;case "fs.fileRead":case "fs.exists":case "fs.searchResult":return "discovering";case "shell.result":return "validating";case "llm.response":return "planning";case "patch.proposed":return "proposing";case "patch.applied":case "patch.rolledBack":return "validating"}},_e=(e,t)=>{let n=e.steps+1,r=n>=60?"failed":zt(e.phase,t);return {...e,phase:r,observations:[...e.observations,t],errors:t.type==="agent.error"?[...e.errors,t.error]:e.errors,steps:n}},Te=e=>e.phase==="done"||e.phase==="failed"||e.steps>=60;var Ut=["*.ts","*.tsx","*.js","*.jsx","*.mts","*.cts","*.mjs","*.cjs","*.json","*.md","*.yml","*.yaml"];var le=["tsx","jsx","mts","cts","mjs","cjs","json","yaml","html","scss","ts","js","md","yml","css"];[...le].sort((e,t)=>t.length-e.length).join("|");var Wt=new Set(["about","after","agent","because","before","brass","cannot","console","could","describe","error","expect","expected","exit","fail","failed","failing","failure","find","from","goal","have","into","name","node","only","package","please","process","repo","runtime","script","scripts","should","test","tests","that","this","throw","throws","undefined","using","with","previous","user","unrelated","validation","validacion","validaci\xF3n","discovered","remaining","rollback","rollbacks","strategy","proposed","request","relevant","context","summary","latest","patch","applied","configured","package","manager","commands","none","notes","usable","script","found","quality","loop","repairs","attempts","enabled","depth","workspace","inspect","inspection","diagnosis","diagnostic","diagn\xF3stico","plan","technology","stack","deployment","configuration","management","dependencies","observability","plugin","plugins","framework","serverless","commonjs","typescript","javascript","nodejs"]),ie=(e,t)=>e===void 0||!Number.isFinite(e)?t:Math.max(0,Math.floor(e)),H=e=>({enabled:e.goal.context?.enabled??true,maxSearchQueries:ie(e.goal.context?.maxSearchQueries,3),maxFiles:ie(e.goal.context?.maxFiles,4),maxSearchResults:ie(e.goal.context?.maxSearchResults,40),globs:e.goal.context?.globs??Ut,excludeGlobs:e.goal.context?.excludeGlobs??[]}),ce=e=>e.replace(/\\/g,"/"),De=e=>e.replace(/^(?:\.\/)+/,""),Qt=e=>e.replace(/(?:\d+){1,2}$/,""),Kt=new Set([" "," ",`
|
|
2
|
-
`,"\r","(","'",'"',"`","<","["]),Zt=new Set([" "," ",`
|
|
3
|
-
`,"\r",")","'",'"',">",",","]"]),Ht=e=>{let t=0,n=e.length;for(;t<n&&Kt.has(e[t]);)t+=1;for(;n>t&&Zt.has(e[n-1]);)n-=1;return e.slice(t,n)},Jt=new Set(["Node.js","CommonJS.js","TypeScript.ts","JavaScript.js"]),Xt=e=>Jt.has(e),Yt=e=>e.split("/").some(n=>n==="node_modules"||n===".git"||n==="dist"||n==="build"||n==="coverage"||n===".next"||n===".turbo"||n===".cache"),en=e=>le.some(t=>e.toLowerCase().endsWith(`.${t}`)),Ne=(e,t)=>{let n=ce(e).replace(/\/+$/,""),r=Qt(Ht(ce(t.trim())));if(r.startsWith("file://")&&(r=r.slice(7)),r.startsWith(`${n}/`)&&(r=r.slice(n.length+1)),r!==n&&(r=De(r),!(!r||r.startsWith("/")||/^[A-Za-z]:\//.test(r))&&!(r.includes("\0")||r.split("/").includes(".."))&&!Xt(r)&&!Yt(r)&&en(r)))return r},tn=e=>{let t=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"::DOUBLE_STAR::").replace(/\*/g,"[^/]*").replace(/::DOUBLE_STAR::/g,".*");return new RegExp(`^${t}$`)},Ie=(e,t)=>t.some(n=>tn(De(ce(n))).test(e)),nn=e=>[...e.globs,...e.excludeGlobs.map(t=>`!${t}`)],_=e=>{let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n},rn=e=>e.observations.filter(t=>t.type==="shell.result").map(t=>[t.command.join(" "),t.stdout.slice(-12e3),t.stderr.slice(-12e3)].join(`
|
|
4
|
-
`)).join(`
|
|
5
|
-
`),Ge=e=>[e.goal.text,rn(e)].filter(Boolean).join(`
|
|
6
|
-
`),qe=e=>{let t=H(e),n=Ge(e),r=new RegExp(`(?:file://)?(?:[A-Za-z]:)?[./\\\\]?(?:[A-Za-z0-9_@.-]+[/\\\\])*[A-Za-z0-9_@.-]+\\.(?:${le.join("|")})(?::\\d+){0,2}`,"g"),o=n.match(r)??[];return _(o.map(a=>Ne(e.goal.cwd,a)).filter(a=>!!a).filter(a=>!Ie(a,t.excludeGlobs)))},Be=e=>_(e.observations.filter(t=>t.type==="fs.searchResult").map(t=>t.query)),pe=e=>_(e.observations.filter(t=>t.type==="fs.fileRead").map(t=>t.path)),de=e=>e.observations.filter(t=>t.type==="fs.exists"),on=(e,t)=>pe(e).includes(t),an=(e,t)=>de(e).some(n=>n.path===t&&!n.exists),sn=(e,t)=>de(e).some(n=>n.path===t&&n.exists),cn=(e,t)=>de(e).some(n=>n.path===t),ln=(e,t)=>e.observations.filter(n=>n.type==="fs.searchResult").flatMap(n=>n.matches).slice(0,t),Ve=(e,t)=>{let n=H(e);return _(ln(e,t).map(r=>Ne(e.goal.cwd,r.path)).filter(r=>!!r).filter(r=>!Ie(r,n.excludeGlobs)))},Oe=e=>{let t=e.length;return /^[A-Z][A-Za-z0-9_]+$/.test(e)&&(t+=8),/[A-Z][a-z]+[A-Z]/.test(e)&&(t+=6),/^[a-z]+[A-Z]/.test(e)&&(t+=6),/Error$/.test(e)&&(t+=4),/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)&&(t+=2),t},pn=e=>{let t=[],n=/["'`]([^"'`\n]{4,80})["'`]/g,r;for(;r=n.exec(e);){let o=r[1]?.trim();o&&(/\s{3,}/.test(o)||/^[A-Za-z0-9_./:-]+$/.test(o)&&t.push(o));}return t},ze=e=>{let t=Ge(e),n=pn(t),r=t.match(/[A-Za-z_][A-Za-z0-9_]{3,}/g)??[];return [..._([...n,...r]).map(a=>a.trim()).filter(a=>a.length>=4&&a.length<=80).filter(a=>!a.includes("/")).filter(a=>!Wt.has(a.toLowerCase())).filter(a=>!/^\d+$/.test(a)).filter(a=>/^[A-Za-z0-9_]+$/.test(a))].sort((a,l)=>Oe(l)-Oe(a)).slice(0,8)},Ue=e=>pe(e).filter(t=>t!=="package.json").length,ue=e=>{let t=dn(e);if(!t.enabled)return "Context discovery: disabled.";let n=t.searchedQueries.join(", ")||"none",r=t.pendingQueries.slice(0,5).join(", ")||"none",o=t.discoveredPaths.slice(0,8).join(", ")||"none",a=t.readPaths.filter(l=>l!=="package.json").join(", ")||"none";return [`Context discovery: searched queries: ${n}.`,`Pending queries: ${r}.`,`Discovered paths: ${o}.`,`Read context files: ${a}.`,`Remaining file budget: ${t.remainingFileBudget}.`].join(" ")},dn=e=>{let t=H(e),n=Be(e),r=ze(e),o=qe(e),a=Ve(e,t.maxSearchResults),l=pe(e),s=Math.max(0,t.maxFiles-Ue(e));return {enabled:t.enabled,searchedQueries:n,pendingQueries:r.filter(p=>!n.includes(p)),discoveredPaths:_([...o,...a]),readPaths:l,remainingFileBudget:s}},We=e=>{let t=H(e);if(!t.enabled||e.goal.initialPatch?.trim())return;let n=Be(e),r=Math.max(0,t.maxFiles-Ue(e)),o=qe(e),a=Ve(e,t.maxSearchResults);if(r>0){let s=[...o,...a].find(p=>p!=="package.json"&&!on(e,p)&&!an(e,p));if(s){if(!cn(e,s))return {type:"fs.exists",path:s};if(sn(e,s))return {type:"fs.readFile",path:s}}}if(n.length>=t.maxSearchQueries)return;let l=ze(e).find(s=>!n.includes(s));if(l)return {type:"fs.searchText",query:l,globs:nn(t)}};var Qe=["Cargo.toml","Cargo.lock","src-tauri/tauri.conf.json","src-tauri/Cargo.toml","apps/desktop/package.json","apps/desktop/src-tauri/tauri.conf.json","apps/desktop/src-tauri/Cargo.toml","bridges/whatsmeow-bridge/Cargo.toml","bridges/whatsmeow-bridge/package.json","apps","packages","bridges","turbo.json","nx.json","pnpm-workspace.yaml"],me=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),un=e=>[...e.observations].reverse().find(t=>t.type==="fs.fileRead"&&t.path==="package.json"),gn=e=>{let t=un(e);if(t)try{let n=JSON.parse(t.content);return me(n)?n:void 0}catch{return}},mn=e=>{if(!e||!me(e.scripts))return {};let t={};for(let[n,r]of Object.entries(e.scripts))typeof r=="string"&&(t[n]=r);return t},u=(e,t)=>e.observations.some(n=>n.type==="fs.exists"&&n.path===t&&n.exists),fn=(e,t)=>[e?.dependencies,e?.devDependencies,e?.optionalDependencies].some(r=>me(r)&&typeof r[t]=="string"),yn=(e,t)=>t.some(n=>fn(e,n)),ge=e=>[...new Set(e)],hn=(e,t)=>{let n=[];for(let r of Object.keys(e))t.some(o=>o.test(r))&&n.push(r);return n},Ke=e=>Qe.find(t=>!e.observations.some(n=>n.type==="fs.exists"&&n.path===t)),fe=(e,t)=>{let n=gn(e),r=mn(n),o=Object.keys(r),a=Qe.filter(A=>u(e,A)),l=[],s=[];n&&l.push("node");let p=u(e,"Cargo.toml")||u(e,"Cargo.lock")||u(e,"src-tauri/Cargo.toml")||u(e,"apps/desktop/src-tauri/Cargo.toml")||u(e,"bridges/whatsmeow-bridge/Cargo.toml");p&&l.push("rust");let d=u(e,"src-tauri/tauri.conf.json")||u(e,"apps/desktop/src-tauri/tauri.conf.json")||yn(n,["@tauri-apps/api","@tauri-apps/cli"])||o.some(A=>A.includes("tauri"));d&&l.push("tauri"),(u(e,"apps/desktop/package.json")||o.some(A=>A.includes("desktop")))&&l.push("desktop");let f=u(e,"bridges")||u(e,"bridges/whatsmeow-bridge/Cargo.toml")||u(e,"bridges/whatsmeow-bridge/package.json")||o.some(A=>A.includes("bridge"));f&&l.push("bridge");let k=u(e,"pnpm-workspace.yaml")||u(e,"turbo.json")||u(e,"nx.json")||u(e,"apps")||u(e,"packages")||u(e,"bridges")||Array.isArray(n?.workspaces);k&&l.push("monorepo");let j=ge([...hn(r,[/^repo:check$/,/^check$/,/(^|:)check($|:)/,/(^|:)doctor($|:)/,/(^|:)health($|:)/,/(^|:)verify($|:)/,/(^|:)validate($|:)/,/(^|:)ci($|:)/])]),m=j.map(A=>t==="npm"&&A==="test"?"npm test":t==="pnpm"&&A==="test"?"pnpm test":t==="yarn"&&A==="test"?"yarn test":t==="bun"?`bun run ${A}`:`${t} run ${A}`);p&&u(e,"Cargo.toml")&&m.push("cargo check"),j.length>0&&s.push(`Likely health/check scripts: ${j.slice(0,5).join(", ")}.`),d&&s.push("Tauri markers detected; desktop validation may involve npm scripts plus Cargo checks."),f&&s.push("Bridge markers detected; bridge-specific doctor/check scripts may be relevant."),k&&s.push("Workspace/monorepo markers detected; prefer repo-level check scripts when available.");let se=d&&p&&n?"tauri":n&&p?"mixed":p?"rust":n?"node":"unknown",Vt=k&&n&&p?"mixed":k?"monorepo":n?"single-package":"unknown";return {kind:se,packageManager:t,stacks:ge(l),workspaceStyle:Vt,markers:a,scripts:o,candidateValidationScripts:j,candidateValidationCommands:ge(m),notes:s}},ye=e=>{let t=e.stacks.length>0?e.stacks.join(", "):"none detected",n=e.markers.length>0?e.markers.slice(0,8).join(", "):"none",r=e.candidateValidationCommands.length>0?e.candidateValidationCommands.slice(0,6).join("; "):"none",o=e.notes.length>0?` Notes: ${e.notes.join(" ")}`:"";return `Project profile: ${e.kind}; workspace: ${e.workspaceStyle}; stacks: ${t}; markers: ${n}; likely validation: ${r}.${o}`};var An=["pnpm-lock.yaml","yarn.lock","bun.lockb","bun.lock","package-lock.json","npm-shrinkwrap.json"],bn=["test","test:ci","test:unit"],kn=["typecheck","type-check","check-types","tsc","check"],xn=["lint","lint:ci"],Sn=[/^repo:check$/,/^check$/,/(^|:)check($|:)/,/(^|:)doctor($|:)/,/(^|:)health($|:)/,/(^|:)verify($|:)/,/(^|:)validate($|:)/,/(^|:)ci($|:)/],Je=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),vn=e=>[...e.observations].reverse().find(t=>t.type==="fs.fileRead"&&t.path==="package.json"),Xe=e=>{let t=vn(e);if(t)try{let n=JSON.parse(t.content);return Je(n)?n:void 0}catch{return}},En=e=>{if(!e||!Je(e.scripts))return {};let t={};for(let[n,r]of Object.entries(e.scripts))typeof r=="string"&&(t[n]=r);return t},wn=(e,t)=>e.observations.some(n=>n.type==="fs.exists"&&n.path===t),Ye=e=>{let t=e.goal.project;if(!t?.validationCommands&&(!t?.packageManager||t.packageManager==="auto")){for(let r of An)if(!wn(e,r))return {type:"fs.exists",path:r}}let n=Ke(e);return n?{type:"fs.exists",path:n}:void 0},Pn=e=>{let t=typeof e?.packageManager=="string"?e.packageManager:void 0;if(!t)return;let n=t.split("@")[0]?.trim();if(n==="npm"||n==="pnpm"||n==="yarn"||n==="bun")return n},T=(e,t)=>e.observations.some(n=>n.type==="fs.exists"&&n.path===t&&n.exists),Rn=e=>{if(T(e,"pnpm-lock.yaml"))return "pnpm";if(T(e,"yarn.lock"))return "yarn";if(T(e,"bun.lockb")||T(e,"bun.lock"))return "bun";if(T(e,"package-lock.json")||T(e,"npm-shrinkwrap.json"))return "npm"},Ze=e=>{let t=e.goal.project?.packageManager;return t&&t!=="auto"?t:Pn(Xe(e))??Rn(e)??"npm"},Cn=e=>/no test specified/i.test(e)&&/exit\s+1/.test(e),he=(e,t,n={})=>{for(let r of t){let o=e[r];if(o!==void 0&&!(n.skipPlaceholderTest&&r==="test"&&Cn(o)))return r}},jn=(e,t)=>{for(let n of Object.keys(e))if(t.some(r=>r.test(n)))return n},He=(e,t)=>{let n=e.toLowerCase();return t.some(r=>n.includes(r))},$n=e=>{let t=[],n="",r,o=false;for(let a of e.trim()){if(o){n+=a,o=false;continue}if(a==="\\"){o=true;continue}if(r){a===r?r=void 0:n+=a;continue}if(a==="'"||a==='"'){r=a;continue}if(/\s/.test(a)){n&&(t.push(n),n="");continue}n+=a;}return n&&t.push(n),t},et=e=>e.join(" "),Fn=e=>{let t=new Set,n=[];for(let r of e){let o=et(r);t.has(o)||(t.add(o),n.push(r));}return n},J=(e,t)=>{switch(e){case "npm":return t==="test"?["npm","test"]:["npm","run",t];case "pnpm":return t==="test"?["pnpm","test"]:["pnpm","run",t];case "yarn":return t==="test"?["yarn","test"]:["yarn","run",t];case "bun":return ["bun","run",t]}},Mn=e=>{if(e?.validationCommands)return e.validationCommands.map(t=>$n(t)).filter(t=>t.length>0)},P=e=>{let t=e.goal.project,n=Mn(t);if(n){let m=Ze(e),se=fe(e,m);return {packageManager:m,validationCommands:n,source:"config",notes:n.length>0?["Using validation commands from project config."]:["Project config explicitly disables validation commands."],profileSummary:ye(se)}}let r=Xe(e),o=En(r),a=Ze(e),l=fe(e,a),s=[],p=[],d=he(o,t?.testScriptNames??bn,{skipPlaceholderTest:true});if(d)s.push(J(a,d)),p.push(`Selected test script: ${d}.`);else {p.push("No usable test script found in package.json.");let m=jn(o,Sn);m&&(s.push(J(a,m)),p.push(`Selected project health script: ${m}.`));}if(t?.includeTypecheck===true||He(e.goal.text,["typecheck","type-check","type check","types","tsc"])||s.length===0){let m=he(o,kn);m&&(s.push(J(a,m)),p.push(`Selected typecheck script: ${m}.`));}if(t?.includeLint===true||He(e.goal.text,["lint","eslint"])||s.length===0){let m=he(o,xn);m&&(s.push(J(a,m)),p.push(`Selected lint script: ${m}.`));}s.length===0&&l.stacks.includes("rust")&&l.markers.includes("Cargo.toml")&&(s.push(["cargo","check"]),p.push("Selected Cargo check because a root Cargo.toml was detected."));let k=t?.maxValidationCommands??2,j=Fn(s).slice(0,Math.max(0,k));return {packageManager:a,validationCommands:j,source:j.length>0?"package-json":"fallback",notes:p,profileSummary:ye(l)}},Ln=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]),_n=(e,t)=>e.type==="shell.result"&&Ln(e.command,t),X=(e,t)=>e.find(n=>!t.some(r=>_n(r,n))),Ae=e=>{let t=e.validationCommands.map(et).join("; ")||"none",n=e.notes.length>0?` Notes: ${e.notes.join(" ")}`:"",r=e.profileSummary?` ${e.profileSummary}`:"";return `Package manager: ${e.packageManager}. Validation commands: ${t}.${n}${r}`};var Tn=(e,t)=>e===void 0||!Number.isFinite(e)?t:Math.max(0,Math.floor(e)),On=e=>e.observations.filter(t=>t.type==="llm.response"&&t.purpose==="patch").length,Y=e=>{let t=e.goal.patchQuality?.enabled??true,n=Tn(e.goal.patchQuality?.maxRepairAttempts,1),r=On(e);return {enabled:t,maxRepairAttempts:n,repairAttemptsUsed:r,repairsRemaining:Math.max(0,n-r),exactSuppliedPatch:!!e.goal.initialPatch?.trim()}},ee=e=>{let t=Y(e);return t.enabled&&!t.exactSuppliedPatch&&t.repairsRemaining>0},Dn=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]),Nn=(e,t)=>e.flatMap(n=>t.filter(r=>r.type==="shell.result"&&Dn(r.command,n)).slice(-1)),tt=(e,t)=>{if(e.length===0)return {type:"not-run"};let n=Nn(e,t);return n.length<e.length?{type:"pending",completed:n.length,total:e.length}:n.some(r=>r.exitCode!==0)?{type:"failed",results:n}:{type:"passed",results:n}},be=e=>{let t=Y(e);return t.enabled?t.exactSuppliedPatch?"Patch quality loop: disabled for supplied exact patches.":[`Patch quality loop: ${t.repairAttemptsUsed}/${t.maxRepairAttempts} repair attempts used.`,`Repairs remaining: ${t.repairsRemaining}.`].join(" "):"Patch quality loop: disabled."};var In=(e,t)=>e===void 0||!Number.isFinite(e)?t:Math.max(0,Math.floor(e)),Gn=e=>e==="last"?"last":"all",O=e=>{let t=e.goal.rollback,n=t?.enabled??true,r=In(t?.maxRollbackDepth,8),o=e.observations.filter(l=>l.type==="patch.rolledBack").length,a=nt(e).length;return {enabled:n,onFinalValidationFailure:t?.onFinalValidationFailure??true,strategy:Gn(t?.strategy),maxRollbackDepth:r,runValidationAfterRollback:t?.runValidationAfterRollback??true,allowForSuppliedPatches:t?.allowForSuppliedPatches??false,rollbackCount:o,appliedStackDepth:a,exactSuppliedPatch:!!e.goal.initialPatch?.trim()}},nt=e=>{let t=[];for(let[n,r]of e.observations.entries()){if(r.type==="patch.applied"&&r.patch?.trim()){t.push({index:n,patch:r.patch,changedFiles:r.changedFiles});continue}if(r.type==="patch.rolledBack"&&r.patch?.trim()){let o=[...t].reverse().findIndex(a=>a.patch.trim()===r.patch?.trim());o>=0&&t.splice(t.length-1-o,1);}}return t},rt=e=>nt(e).at(-1),ke=e=>{let t=O(e);return !t.enabled||t.rollbackCount>=t.maxRollbackDepth||t.exactSuppliedPatch&&!t.allowForSuppliedPatches?false:t.appliedStackDepth>0},ot=e=>{let t=O(e);return e.observations.at(-1)?.type==="patch.rolledBack"&&t.strategy==="all"&&ke(e)},qn=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]),Bn=(e,t)=>e.flatMap(n=>t.filter(r=>r.type==="shell.result"&&qn(r.command,n)).slice(-1)),at=(e,t)=>{if(e.length===0)return {type:"not-run"};let n=Bn(e,t);return n.length<e.length?{type:"pending",completed:n.length,total:e.length}:n.some(r=>r.exitCode!==0)?{type:"failed",results:n}:{type:"passed",results:n}},xe=e=>{let t=O(e);return t.enabled?t.exactSuppliedPatch&&!t.allowForSuppliedPatches?"Rollback safety: disabled for supplied exact patches.":[`Rollback safety: ${t.onFinalValidationFailure?"enabled":"not configured for final validation failure"}.`,`Strategy: ${t.strategy}.`,`Rollbacks used: ${t.rollbackCount}/${t.maxRollbackDepth}.`,`Applied patch stack depth: ${t.appliedStackDepth}.`].join(" "):"Rollback safety: disabled."};var Vn=/```(?:diff|patch)?\s*\n([\s\S]*?)```/g,zn=e=>e.replace(/^[ab]\//,""),B=e=>e.replace(/\r\n/g,`
|
|
7
|
-
`).trim(),st=e=>{let t=B(e);return t.includes("+++ ")&&t.includes("--- ")},Un=e=>{let t=B(e),n=t.indexOf("diff --git "),r=t.indexOf("--- "),o=[n,r].filter(l=>l>=0).sort((l,s)=>l-s)[0];if(o===void 0)return;let a=t.slice(o).trim();return st(a)?a:void 0},M=e=>{let t=B(e);if(!t)return;let n=t.matchAll(Vn);for(let r of n){let o=B(r[1]??"");if(st(o))return o}return Un(t)},Wn=e=>{let t=e.trim().split(/\s+/)[0];if(!(!t||t==="/dev/null"))return zn(t)},it=e=>{let t=B(e);if(!t)return [];let n=new Set,r=[];for(let o of t.split(`
|
|
8
|
-
`))if(o.startsWith("+++ ")||o.startsWith("--- ")){let a=Wn(o.slice(4));if(!a||n.has(a))continue;n.add(a),r.push(a);}return r};var Qn=[/\b(?:sk|pk|rk|ghp|gho|ghu|ghs|github_pat)_[A-Za-z0-9_\-]{16,}\b/g,/\bAIza[0-9A-Za-z_\-]{20,}\b/g,/\b(?:xoxb|xoxp|xoxa|xoxr)-[A-Za-z0-9\-]{20,}\b/g,/\b[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}\b/g,/((?:api[_-]?key|token|secret|password|passwd|authorization)\s*[:=]\s*)(["']?)[^\s"']{8,}\2/gi,/(Bearer\s+)[A-Za-z0-9._\-+/=]{12,}/gi],Kn=e=>{try{return new RegExp(e,"gi")}catch{return}},Zn=e=>(e?.additionalPatterns??[]).map(Kn).filter(t=>!!t),Hn=e=>e?.enabled??true,ct=(e,t)=>!Hn(t)||!e?e:[...Qn,...Zn(t)].reduce((n,r)=>n.replace(r,(o,a)=>typeof a=="string"&&a.length>0&&o.startsWith(a)?`${a}[REDACTED]`:"[REDACTED]"),e);var Jn={en:"English",es:"Spanish",pt:"Portuguese",fr:"French",de:"German",it:"Italian"},Xn=/[¿¡ñáéíóúü]|\b(aca|acá|ahora|arregl|ayuda|como|cómo|consulta|cual|cuál|cuando|cuándo|dale|decime|deberia|debería|donde|dónde|errores|explica|explicame|hacer|hagamos|mejorar|porque|porqué|por que|por qué|proyecto|quiero|seria|sería|tengo|usar|vayamos)\b/i,Yn=/[ãõç]|\b(como|corrigir|erro|falha|quero|projeto|porque|você|voce)\b/i,er=/[àâçéèêëîïôûùüÿœ]|\b(comment|pourquoi|corriger|erreur|projet|fichier)\b/i,tr=/[äöüß]|\b(warum|fehler|projekt|datei|bitte)\b/i,nr=/\b(come|perché|perche|errore|progetto|file|voglio)\b/i,lt=e=>{if(Xn.test(e))return "Spanish";if(Yn.test(e))return "Portuguese";if(er.test(e))return "French";if(tr.test(e))return "German";if(nr.test(e))return "Italian"},pt=e=>{let t=e?.response??"auto";if(t==="custom")return e?.custom?.trim()||void 0;if(!(t==="auto"||t==="match-user"))return Jn[t]},rr=e=>pt(e.language)??lt(e.text),Se=e=>{let t=pt(e.language),n=lt(e.text);return t?[`Language policy: respond in ${t}.`,"Keep code, identifiers, file paths, shell commands, logs, and unified diffs unchanged."].join(" "):n?[`Language policy: the user goal appears to be in ${n}; respond in ${n}.`,"Keep code, identifiers, file paths, shell commands, logs, and unified diffs unchanged."].join(" "):["Language policy: respond in the same natural language as the user's latest goal or follow-up.","If the user's goal is in Spanish, respond in Spanish.","Keep code, identifiers, file paths, shell commands, logs, and unified diffs unchanged."].join(" ")},te=e=>rr(e)==="Spanish";var ne=(e,t)=>e.observations.some(n=>n.type===t),D=(e,t)=>[...e.observations].reverse().find(n=>n.type===t),or=(e,t)=>e.observations.find(n=>n.type===t),ve=(e,t)=>[...e.observations].map(n=>n.type).lastIndexOf(t),ar=e=>{let t=e.observations.findIndex(n=>n.type==="llm.response"&&n.purpose==="plan");return t<0?e.observations:e.observations.slice(0,t)},Ee=e=>{let t=ve(e,"patch.applied");return t<0?[]:e.observations.slice(t+1)},ft=e=>Math.max(ve(e,"patch.applied"),ve(e,"patch.rolledBack")),we=e=>{let t=ft(e);return t<0?[]:e.observations.slice(t+1)},V=e=>{let t=ft(e),n=t<0?void 0:e.observations[t];return n?.type==="patch.applied"||n?.type==="patch.rolledBack"?n:void 0},sr=e=>{switch(e.type){case "fs.fileRead":{let t=e.path.toLowerCase(),r=t.endsWith("package-lock.json")||t.endsWith("npm-shrinkwrap.json")||t.endsWith("pnpm-lock.yaml")||t.endsWith("yarn.lock")||t.endsWith("cargo.lock")?1500:8e3;return {type:e.type,path:e.path,content:e.content.slice(0,r),omittedChars:Math.max(0,e.content.length-r)}}case "fs.exists":return {type:e.type,path:e.path,exists:e.exists};case "shell.result":return {type:e.type,command:e.command,exitCode:e.exitCode,stdout:e.stdout.slice(-8e3),stderr:e.stderr.slice(-8e3)};case "fs.searchResult":return {type:e.type,query:e.query,matches:e.matches.slice(0,20),omittedMatches:Math.max(0,e.matches.length-20)};case "patch.proposed":return {type:e.type,patch:e.patch.slice(0,8e3)};case "patch.applied":return {type:e.type,changedFiles:e.changedFiles};case "patch.rolledBack":return {type:e.type,changedFiles:e.changedFiles,...e.automatic!==void 0?{automatic:e.automatic}:{},...e.reason?{reason:e.reason}:{}};case "agent.done":case "agent.error":return e;case "llm.response":return {type:e.type,purpose:e.purpose,content:e.content.slice(-8e3)}}},z=(e,t)=>ct(t,e.goal.redaction),ir=e=>e.type==="fs.exists"&&!e.exists,yt=e=>z(e,e.observations.filter(t=>!ir(t)).map(t=>JSON.stringify(sr(t),null,2)).join(`
|
|
9
|
-
|
|
10
|
-
`)),cr=e=>{if(e instanceof Error)return e.message||String(e);if(typeof e=="string")return e;if(e&&typeof e=="object")try{let t=JSON.stringify(e);if(t&&t!=="{}")return t}catch{}return String(e)},R=(e,t)=>z(e,cr(t)).slice(0,2e3),lr=e=>{let t=P(e);return z(e,["You are a coding agent running on brass-runtime.","Return a concise diagnosis and proposed plan.","If you can infer a patch, include it as a unified diff inside a ```diff fenced block.","Do not claim that you edited files unless the runtime reports patch.applied.","Prefer a single focused patch over speculative broad changes.","Only propose a patch when the observations are strong enough.","Use the project command discovery summary as context, but do not invent commands that were not run.",Se(e.goal),"",`Goal: ${e.goal.text}`,`Workspace: ${e.goal.cwd}`,`Project commands: ${Ae(t)}`,ue(e),be(e),xe(e),"","Observations:",yt(e)||"No observations yet."].join(`
|
|
11
|
-
`))},dt=e=>Ee(e).filter(t=>t.type==="shell.result"&&t.exitCode!==0).map(t=>[`Command: ${t.command.join(" ")}`,`Exit code: ${t.exitCode}`,t.stdout?`stdout:
|
|
12
|
-
${t.stdout.slice(-8e3)}`:void 0,t.stderr?`stderr:
|
|
13
|
-
${t.stderr.slice(-8e3)}`:void 0].filter(Boolean).join(`
|
|
14
|
-
`)),pr=(e,t)=>{let n=P(e),r=Y(e),o=D(e,"agent.error")?.error,a=hr(e);return z(e,["You are repairing a generated patch for a coding agent running on brass-runtime.","The previous generated patch either failed to apply or failed validation.","Return a concise diagnosis and, if you can fix it, include a replacement incremental unified diff inside a ```diff fenced block.","The new diff should apply on top of the current workspace state, after any previous patch.applied observations.","Do not repeat the old patch unless it is still correct for the current workspace state.","Do not claim files were edited unless the runtime later reports patch.applied.",Se(e.goal),"",`Goal: ${e.goal.text}`,`Workspace: ${e.goal.cwd}`,`Repair reason: ${t}`,`Repair attempts used: ${r.repairAttemptsUsed}/${r.maxRepairAttempts}`,`Project commands: ${Ae(n)}`,ue(e),be(e),xe(e),"",a?`Latest materialized patch:
|
|
15
|
-
${a.slice(-8e3)}`:"Latest materialized patch: none.","",dt(e).length>0?`Failed validation after latest patch:
|
|
16
|
-
${dt(e).join(`
|
|
17
|
-
|
|
18
|
-
`)}`:"Failed validation after latest patch: none recorded.","",o?._tag==="PatchError"?`Latest patch error during ${o.operation}: ${String(o.cause)}`:"Latest patch error: none.","","Recent observations:",yt(e)||"No observations yet."].join(`
|
|
19
|
-
`))},N=e=>e==="write"||e==="autonomous",dr=e=>{let t=we(e).filter(a=>a.type==="shell.result");if(t.length===0)return;let n=V(e),r=te(e.goal),o=n?.type==="patch.rolledBack"?"rollback":r?"aplicar patch":"apply";return [r?`Validaci\xF3n despu\xE9s de ${o}:`:`Validation after latest ${o}:`,...t.map(a=>`- ${a.command.join(" ")} ${r?"termin\xF3 con c\xF3digo":"exited with"} ${a.exitCode}.`)].join(`
|
|
20
|
-
`)},ut=(e,t)=>{let n=or(e,"llm.response")?.content?.trim()??"No plan was generated.",r=D(e,"llm.response"),o=D(e,"patch.applied"),a=D(e,"patch.rolledBack"),l=D(e,"patch.proposed"),s=dr(e),p=te(e.goal),d=[n];return r?.purpose==="patch"&&r.content.trim()&&d.push("",p?"\xDAltima respuesta de reparaci\xF3n del patch:":"Latest patch repair response:",r.content.trim()),a?d.push("",p?`Patch revertido en: ${a.changedFiles.join(", ")||"(sin archivos reportados)"}`:`Patch rolled back for: ${a.changedFiles.join(", ")||"(no files reported)"}`):o?d.push("",p?`Patch aplicado en: ${o.changedFiles.join(", ")||"(sin archivos reportados)"}`:`Patch applied to: ${o.changedFiles.join(", ")||"(no files reported)"}`):l?d.push("",p?"Patch propuesto, pero no aplicado en este modo.":"Patch extracted and proposed, but not applied in this mode."):t&&d.push("",p?"Hab\xEDa un diff con forma de patch, pero no se materializ\xF3 como observaci\xF3n.":"A patch-shaped diff was present, but it was not materialized as an observation."),s&&d.push("",s),z(e,d.join(`
|
|
21
|
-
`).trim())},ur=e=>{let t=D(e,"agent.error")?.error,n=te(e.goal);if(!t)return n?"La ejecuci\xF3n del agente fall\xF3.":"Agent run failed.";switch(t._tag){case "FsError":return n?`El agente se detuvo por un error de filesystem durante ${t.operation}: ${R(e,t.cause)}`:`Agent stopped after a filesystem error during ${t.operation}: ${R(e,t.cause)}`;case "ShellError":return n?`El agente se detuvo por un error ejecutando ${t.command?.join(" ")??t.operation}: ${R(e,t.cause)}`:`Agent stopped after a shell error during ${t.command?.join(" ")??t.operation}: ${R(e,t.cause)}`;case "LLMError":return n?`El agente se detuvo porque fall\xF3 la llamada al modelo: ${R(e,t.cause)}`:`Agent stopped because the model call failed: ${R(e,t.cause)}`;case "PatchError":return n?`El agente se detuvo por un error de patch durante ${t.operation}: ${R(e,t.cause)}`:`Agent stopped after a patch error during ${t.operation}: ${R(e,t.cause)}`;case "PermissionDenied":return n?`El agente se detuvo porque una acci\xF3n fue denegada por policy: ${t.reason}`:`Agent stopped because an action was denied by policy: ${t.reason}`;case "ApprovalRejected":return n?`El agente se detuvo porque se rechaz\xF3 una aprobaci\xF3n: ${t.reason}`:`Agent stopped because an approval was rejected: ${t.reason}`;case "ToolTimeout":return n?`El agente se detuvo porque una tool tard\xF3 m\xE1s de ${t.timeoutMs}ms.`:`Agent stopped because a tool timed out after ${t.timeoutMs}ms.`;case "PathOutsideWorkspace":return n?`El agente bloque\xF3 un path fuera del workspace: ${t.path}`:`Agent blocked a path outside the workspace: ${t.path}`;case "AgentLoopError":return n?`El agente se detuvo por un error del loop: ${t.message}`:`Agent stopped after an agent loop error: ${t.message}`}},gr=e=>{if(e.goal.mode==="read-only")return;let t=P(e).validationCommands,n=X(t,ar(e));return n?{type:"shell.exec",command:n}:void 0},mr=e=>{let t=P(e).validationCommands,n=X(t,Ee(e));return n?{type:"shell.exec",command:n}:void 0},ht=e=>{let t=P(e).validationCommands,n=X(t,we(e));return n?{type:"shell.exec",command:n}:void 0},fr=e=>{for(let t=e.observations.length-1;t>=0;t-=1){let n=e.observations[t];if(!n||n.type!=="llm.response")continue;let r=M(n.content);if(!r)continue;return e.observations.slice(t+1).some(a=>a.type==="patch.applied"||a.type==="patch.proposed")?void 0:{index:t,patch:r}}},yr=e=>{for(let t=e.observations.length-1;t>=0;t-=1){let n=e.observations[t];if(n?.type!=="llm.response")continue;let r=M(n.content);if(r)return r}},hr=e=>{for(let t=e.observations.length-1;t>=0;t-=1){let n=e.observations[t];if(n?.type==="patch.proposed")return n.patch;if(n?.type==="patch.applied"){if(n.patch)return n.patch;let r=e.observations.slice(0,t).reverse().find(o=>o.type==="llm.response"&&!!M(o.content));return r?M(r.content):e.goal.initialPatch}}},Ar=e=>{if(!N(e.goal.mode)||V(e)?.type!=="patch.applied"||!ee(e))return false;let t=P(e).validationCommands;return tt(t,Ee(e)).type==="failed"},br=e=>{if(!N(e.goal.mode)||V(e)?.type!=="patch.applied"||ee(e)||!O(e).onFinalValidationFailure||!ke(e))return false;let n=P(e).validationCommands;return at(n,we(e)).type==="failed"},kr=e=>{if(!N(e.goal.mode)||!ee(e))return false;let t=e.observations.at(-1);return t?.type==="agent.error"&&t.error._tag==="PatchError"},gt=(e,t)=>({type:"llm.complete",purpose:"patch",prompt:pr(e,t)}),mt=(e,t)=>{let n=rt(e);if(n)return {type:"patch.rollback",patch:n.patch,automatic:true,reason:t}},xr=(e,t)=>{if(N(e.goal.mode))return e.goal.initialPatchMode==="rollback"?ne(e,"patch.rolledBack")?void 0:{type:"patch.rollback",patch:t}:ne(e,"patch.applied")?ht(e):{type:"patch.apply",patch:t};if(e.goal.mode==="propose"&&!ne(e,"patch.proposed"))return {type:"patch.propose",patch:t}},At=e=>{if(e.observations.at(-1)?.type==="agent.error")return kr(e)?f(gt(e,"previous patch failed to apply")):f({type:"agent.finish",summary:ur(e)});if(!ne(e,"fs.fileRead"))return f({type:"fs.readFile",path:"package.json"});let n=Ye(e);if(n)return f(n);let r=e.goal.initialPatch?.trim();if(r){let s=xr(e,r);return s?f(s):f({type:"agent.finish",summary:ut(e,r)})}let o=fr(e);if(o){if(N(e.goal.mode))return f({type:"patch.apply",patch:o.patch});if(e.goal.mode==="propose")return f({type:"patch.propose",patch:o.patch})}if(!e.observations.find(s=>s.type==="llm.response"&&s.purpose==="plan")){let s=gr(e);if(s)return f(s);let p=We(e);return p?f(p):f({type:"llm.complete",purpose:"plan",prompt:lr(e)})}if(N(e.goal.mode)){if(ot(e)){let s=mt(e,"continuing rollback of generated patch stack");if(s)return f(s)}if(V(e)?.type==="patch.rolledBack"&&O(e).runValidationAfterRollback){let p=ht(e);if(p)return f(p)}if(V(e)?.type==="patch.applied"){let s=mr(e);if(s)return f(s);if(Ar(e))return f(gt(e,"validation failed after applying the generated patch"));if(br(e)){let p=mt(e,"validation failed after generated patches and no repair attempts remain");if(p)return f(p)}}}let l=yr(e);return f({type:"agent.finish",summary:ut(e,l)})};var v=()=>j((e,t)=>{t({_tag:"Success",value:Date.now()});}),E=e=>j((t,n)=>{try{t.events?.emit(e);}catch{}n({_tag:"Success",value:void 0});}),Pe=e=>e.reduce((t,n)=>l(t,()=>E(n)),f(void 0)),_o=e=>{switch(e.type){case "fs.readFile":return `read ${e.path}`;case "fs.exists":return `check ${e.path}`;case "fs.searchText":return `search "${e.query}"`;case "shell.exec":return e.command.join(" ");case "llm.complete":return `llm.${e.purpose}`;case "patch.propose":return "propose patch";case "patch.apply":return "apply patch";case "patch.rollback":return "rollback patch";case "agent.finish":return "finish";case "agent.fail":return "fail"}},To=e=>{switch(e.type){case "fs.fileRead":return `read ${e.path}`;case "fs.exists":return `${e.exists?"found":"missing"} ${e.path}`;case "fs.searchResult":return `search "${e.query}" (${e.matches.length} matches)`;case "shell.result":return `${e.command.join(" ")} exited ${e.exitCode}`;case "llm.response":return `llm.${e.purpose} responded`;case "patch.proposed":return "patch proposed";case "patch.applied":return `patch applied (${e.changedFiles.join(", ")||"no files reported"})`;case "patch.rolledBack":return `patch rolled back (${e.changedFiles.join(", ")||"no files reported"})`;case "agent.done":return "done";case "agent.error":return `error ${e.error._tag}`}},Oo=e=>{switch(e.type){case "agent.error":return "fail";case "shell.result":return e.exitCode===0?"ok":"warn";default:return "ok"}},bt=(e,t,n,r)=>{switch(n._tag){case "ToolTimeout":return {type:"agent.tool.timeout",action:e,step:t.steps+1,phase:t.phase,timeoutMs:n.timeoutMs,at:r};case "PermissionDenied":return {type:"agent.permission.denied",action:e,step:t.steps+1,phase:t.phase,reason:n.reason,at:r};default:return}},kt=(e,t,n)=>{switch(t.type){case "patch.applied":return {type:"agent.patch.applied",step:e.steps,phase:e.phase,changedFiles:t.changedFiles,automaticRollbackEligible:!!t.patch,at:n};case "patch.rolledBack":return {type:"agent.patch.rolledBack",step:e.steps,phase:e.phase,changedFiles:t.changedFiles,...t.automatic!==void 0?{automatic:t.automatic}:{},...t.reason?{reason:t.reason}:{},at:n};default:return}},xt=e=>e==="done"?"done":"failed";var x=e=>h$1(t=>t[e]);var Sr=e=>e.startsWith("/")||/^[A-Za-z]:[\\/]/.test(e),vr=e=>{let t=e.length;for(;t>0;){let n=e.charCodeAt(t-1);if(n!==47&&n!==92)break;t-=1;}return t===e.length?e:e.slice(0,t)},Er=e=>e.replace(/^(?:\.[\\/])+/,""),wr=e=>{let t=e.trim();if(!(!t||t.includes("\0")||Sr(t)||t.split(/[\\/]+/).includes("..")))return Er(t)};var U=(e,t)=>{let n=wr(t);return n?f(`${vr(e)}/${n}`):g({_tag:"PathOutsideWorkspace",path:t,cwd:e})};var St=(e,t)=>{switch(e.type){case "fs.readFile":return l(U(t.goal.cwd,e.path),n=>l(x("fs"),r=>k(r.readFile(n),o=>({type:"fs.fileRead",path:e.path,content:o}))));case "fs.exists":return l(U(t.goal.cwd,e.path),n=>l(x("fs"),r=>k(r.exists(n),o=>({type:"fs.exists",path:e.path,exists:o}))));case "fs.searchText":return l(x("fs"),n=>k(n.searchText(t.goal.cwd,e.query,{globs:e.globs}),r=>({type:"fs.searchResult",query:e.query,matches:r})));case "shell.exec":return l(x("shell"),n=>k(n.exec(e.command,{cwd:e.cwd??t.goal.cwd}),r=>({type:"shell.result",command:e.command,exitCode:r.exitCode,stdout:r.stdout,stderr:r.stderr})));case "llm.complete":return l(x("llm"),n=>k(n.complete({purpose:e.purpose,prompt:e.prompt}),r=>({type:"llm.response",purpose:e.purpose,content:r.content})));case "patch.propose":return f({type:"patch.proposed",patch:e.patch});case "patch.apply":return l(x("patch"),n=>k(n.apply(t.goal.cwd,e.patch),r=>({type:"patch.applied",changedFiles:r.changedFiles,patch:e.patch})));case "patch.rollback":return l(x("patch"),n=>k(n.rollback(t.goal.cwd,e.patch),r=>({type:"patch.rolledBack",changedFiles:r.changedFiles,patch:e.patch,...e.automatic!==void 0?{automatic:e.automatic}:{},...e.reason?{reason:e.reason}:{}})));case "agent.finish":return f({type:"agent.done",summary:e.summary});case "agent.fail":return g({_tag:"AgentLoopError",message:e.reason})}};var vt=(e,t)=>{let n=r=>b$1(e(),o=>r>0&&t.while(o)?n(r-1):g(o),o=>f(o));return n(t.times)};var Pr=e=>j((t,n)=>{let r=setTimeout(()=>n({_tag:"Success",value:void 0}),e);return ()=>clearTimeout(r)}),Et=(e,t,n)=>ia(e,l(Pr(t),()=>g({_tag:"ToolTimeout",timeoutMs:t})),n);var wt=e=>e._tag==="LLMError"||e._tag==="ToolTimeout",Rr=e=>{switch(e.type){case "fs.readFile":case "fs.exists":case "fs.searchText":return {timeoutMs:5e3,retries:1,retryable:wt};case "llm.complete":return {timeoutMs:6e4,retries:2,retryable:wt};case "shell.exec":return {timeoutMs:12e4,retries:0,retryable:()=>false};case "patch.propose":case "agent.finish":case "agent.fail":return {timeoutMs:1e3,retries:0,retryable:()=>false};case "patch.apply":case "patch.rollback":return {timeoutMs:15e3,retries:0,retryable:()=>false}}},Cr=(e,t)=>{let n=Rr(e),r=t?.[e.type];return {...n,timeoutMs:r?.timeoutMs!==void 0?Math.max(1,Math.floor(r.timeoutMs)):n.timeoutMs,retries:r?.retries!==void 0?Math.max(0,Math.floor(r.retries)):n.retries}},Pt=(e,t,n)=>l(h$1(r=>r.toolPolicies),r=>{let o=Cr(e,r);return vt(()=>Et(St(e,t),o.timeoutMs,n),{times:o.retries,while:o.retryable})}),Rt=(e,t)=>({_tag:"ApprovalRejected",action:e,reason:t}),Re=(e,t,n,r)=>l(v(),o=>E({type:"agent.approval.resolved",action:e,step:t.steps+1,phase:t.phase,approved:n,...r?{reason:r}:{},at:o})),jr=(e,t,n)=>{let r=n.defaultAnswer??"reject";return l(v(),o=>l(E({type:"agent.approval.requested",action:e,step:t.steps+1,phase:t.phase,reason:n.reason,risk:n.risk,defaultAnswer:r,at:o}),()=>l(x("approvals"),a=>{if(!a){let l$1="No approval service configured.";return l(Re(e,t,false,l$1),()=>g(Rt(e,l$1)))}return l(a.request({action:e,state:t,reason:n.reason,risk:n.risk,defaultAnswer:r}),l$1=>{if(l$1.type==="approved")return l(Re(e,t,true,void 0),()=>f(void 0));let s=l$1.reason??"Approval rejected.";return l(Re(e,t,false,s),()=>g(Rt(e,s)))})})))},Ct=(e,t,n)=>l(x("permissions"),r=>l(r.check(e,t),o=>o.type==="deny"?g({_tag:"PermissionDenied",action:e,reason:o.reason}):o.type==="ask"?l(jr(e,t,o),()=>Pt(e,t,n)):Pt(e,t,n)));var $r=(e,t,n)=>l(v(),r=>l(E({type:"agent.action.started",action:e,step:t.steps+1,phase:t.phase,at:r}),()=>b$1(Ct(e,t,n),o=>l(v(),a=>{let l$1=bt(e,t,o,a),s=[...l$1?[l$1]:[],{type:"agent.action.failed",action:e,error:o,step:t.steps+1,phase:t.phase,durationMs:a-r,at:a}];return l(Pe(s),()=>f({type:"agent.error",error:o}))}),o=>l(v(),a=>l(E({type:"agent.action.completed",action:e,observation:o,step:t.steps+1,phase:t.phase,durationMs:a-r,at:a}),()=>f(o)))))),Fr=(e,t)=>l(v(),n=>{let r=kt(e,t,n),o=[{type:"agent.observation.recorded",observation:t,step:e.steps,phase:e.phase,at:n},...r?[r]:[]];return Pe(o)}),jt=(e,t,n)=>Te(e)?l(v(),r=>l(E({type:"agent.run.completed",goal:e.goal,status:xt(e.phase),phase:e.phase,steps:e.steps,durationMs:r-n,at:r}),()=>f(e))):l(At(e),r=>l($r(r,e,t),o=>{let a=_e(e,o);return l(Fr(a,o),()=>jt(a,t,n))})),da=(e,t)=>ga(e,n=>l(v(),r=>l(E({type:"agent.run.started",goal:t,at:r}),()=>jt(Le(t),n,r))));var Ce=e=>e==="read-only"||e==="propose"||e==="write"||e==="autonomous",$t=e=>e==="auto"||e==="interactive"||e==="approve"||e==="deny",Ft=e=>e==="fake"||e==="google"||e==="gemini"||e==="openai"||e==="openai-compatible",Mt=[".brass-agent.json","brass-agent.config.json"];var Lt=e=>e==="fix-tests"||e==="inspect"||e==="typecheck"||e==="lint",ma=e=>{switch(e){case "fix-tests":return "fix the failing tests";case "inspect":return "inspect this workspace and summarize the current project state";case "typecheck":return "run typecheck discovery and fix type errors if possible";case "lint":return "run lint discovery and fix lint errors if possible"}};var Mr=["npm test","npm run test*","npm run typecheck","npm run type-check","npm run check-types","npm run tsc","npm run check","npm run *check*","npm run *doctor*","npm run *health*","npm run *verify*","npm run *validate*","npm run repo:check","npm run lint*","pnpm test","pnpm run test*","pnpm run typecheck","pnpm run type-check","pnpm run check-types","pnpm run tsc","pnpm run check","pnpm run *check*","pnpm run *doctor*","pnpm run *health*","pnpm run *verify*","pnpm run *validate*","pnpm run repo:check","pnpm run lint*","yarn test","yarn run test*","yarn run typecheck","yarn run type-check","yarn run check-types","yarn run tsc","yarn run check","yarn run *check*","yarn run *doctor*","yarn run *health*","yarn run *verify*","yarn run *validate*","yarn run repo:check","yarn run lint*","bun run test*","bun run typecheck","bun run type-check","bun run check-types","bun run tsc","bun run check","bun run *check*","bun run *doctor*","bun run *health*","bun run *verify*","bun run *validate*","bun run repo:check","bun run lint*","cargo check","cargo test","cargo fmt --check","cargo clippy","cargo clippy *","git status","git diff","git log"],Ot=e=>e.trim().replace(/\s+/g," "),re=e=>Ot(e.join(" ")),Lr=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Dt=(e,t)=>{let n=re(e),r=Ot(t);return r.includes("*")?new RegExp(`^${r.split("*").map(Lr).join(".*")}$`).test(n):n===r},_t=(e,t)=>!!t?.some(n=>Dt(e,n)),I=()=>({type:"allow"}),G=e=>({type:"deny",reason:e}),W=(e,t,n="reject")=>({type:"ask",reason:e,risk:t,defaultAnswer:n}),_r=e=>e.type==="shell.exec"?e.command.join(" "):e.type,Tr=e=>typeof e=="string"?e:e.pattern,Or=(e,t)=>{let n=t?.find(r=>Dt(e,Tr(r)));if(n)return typeof n=="string"?W(`Run command: ${re(e)}`,"high","reject"):W(n.reason??`Run command: ${re(e)}`,n.risk??"high",n.defaultAnswer??"reject")},Dr=e=>[...e?.inheritDefaults===false?[]:Mr,...e?.allow??[]],je=(e,t)=>{if(_t(e,t?.deny))return G(`Command denied by policy: ${re(e)}`);let n=Or(e,t?.ask);if(n)return n;if(_t(e,Dr(t)))return I()},Nr=e=>e.type==="patch.rollback"?"Reverse-apply a patch to restore the workspace.":"Apply the proposed patch to the workspace.",Tt=(e,t)=>{let n=Nr(e);if(!t)return W(n,"high","reject");let r=typeof t=="string"?t:t.decision??"ask",o=typeof t=="string"?n:t.reason??n,a=typeof t=="string"?"high":t.risk??"high",l=typeof t=="string"?"reject":t.defaultAnswer??"reject";return r==="allow"?I():r==="deny"?G(o):W(o,a,l)},Ir=(e={})=>({check:(t,n)=>{switch(n.goal.mode){case "read-only":return t.type==="fs.readFile"||t.type==="fs.exists"||t.type==="fs.searchText"||t.type==="llm.complete"||t.type==="agent.finish"||t.type==="agent.fail"?f(I()):f(G(`Action ${t.type} is not allowed in read-only mode`));case "propose":{if(t.type==="shell.exec"){let r=je(t.command,e.shell);return f(r??G(`Command not whitelisted: ${t.command.join(" ")}`))}return t.type==="patch.apply"||t.type==="patch.rollback"?f(G(`${t.type} is not allowed in propose mode; use write mode or --apply.`)):f(I())}case "write":{if(t.type==="shell.exec"){let r=je(t.command,e.shell);return f(r??G(`Command not whitelisted: ${t.command.join(" ")}`))}return t.type==="patch.apply"||t.type==="patch.rollback"?f(Tt(t,e.patchApply)):f(I())}case "autonomous":{if(t.type==="patch.apply"||t.type==="patch.rollback")return f(Tt(t,e.patchApply));if(t.type==="shell.exec"){let r=je(t.command,e.shell);return f(r??W(`Run non-whitelisted command: ${_r(t)}`,"high","reject"))}return f(I())}}}}),ha=Ir();var ka={request:()=>f({type:"approved"})},xa=(e="Approval denied by non-interactive policy.")=>({request:()=>f({type:"rejected",reason:e})});var Gr=new Function("specifier","return import(specifier)"),Nt=e=>{let t=e?.toString;return typeof t=="function"?t.call(e,"utf8"):String(e)},wa={exec:(e,t$1)=>j((n,r)=>{let[o,...a]=e;if(!o){r(u$1.failCause(t.fail({_tag:"ShellError",operation:"exec",command:e,cause:new Error("Empty command")})));return}let l="",s="",p=false,d;return Gr("node:child_process").then(({spawn:C})=>{p||(d=C(o,a,{cwd:t$1.cwd,shell:false,stdio:["pipe","pipe","pipe"]}),d.stdout?.on("data",f=>{l+=Nt(f);}),d.stderr?.on("data",f=>{s+=Nt(f);}),d.on("error",f=>{p||(p=true,r(u$1.failCause(t.fail({_tag:"ShellError",operation:"exec",command:e,cause:f}))));}),d.on("close",f=>{p||(p=true,r(u$1.succeed({exitCode:f??1,stdout:l,stderr:s})));}),t$1.stdin!==void 0?d.stdin?.end(t$1.stdin):d.stdin?.end());}).catch(C=>{p||(p=true,r(u$1.failCause(t.fail({_tag:"ShellError",operation:"exec",command:e,cause:C}))));}),()=>{p||(p=true,d?.kill?.("SIGTERM"));}})};var It=new Function("specifier","return import(specifier)"),qr=e=>e.split(`
|
|
22
|
-
`).filter(Boolean).map(t=>{let[n="",r="0",...o]=t.split(":");return {path:n,line:Number(r),text:o.join(":")}}),ja=e=>({readFile:t=>da$1(async n=>{let{readFile:r}=await It("node:fs/promises");return r(t,{encoding:"utf8",signal:n})},n=>({_tag:"FsError",operation:"readFile",cause:n})),exists:t=>da$1(async n=>{if(n.aborted)return false;let{stat:r}=await It("node:fs/promises");if(n.aborted)return false;try{return await r(t),!0}catch{return false}},n=>({_tag:"FsError",operation:"exists",cause:n})),searchText:(t,n,r)=>l(e.exec(["rg","--fixed-strings","--line-number","--no-heading","--color","never","--max-count","5",...r?.globs?.flatMap(o=>["--glob",o])??[],"--",n,"."],{cwd:t}),o=>o.exitCode>1?g({_tag:"FsError",operation:"searchText",cause:o.stderr}):f(qr(o.stdout)))});var Br=(e,t)=>t.reduce((n,r)=>l(n,o=>l(U(e,r),()=>f([...o,r]))),f([])),$e=(e,t,n)=>({_tag:"PatchError",operation:e,cause:t,patch:n}),_a=e=>{let t=(n,r,o)=>{let a=M(r)??r.trim(),l$1=it(a),s=`${a.trim()}
|
|
23
|
-
`,p=o?"rollback":"apply";if(!a||!l$1.length)return g($e("extract","No unified diff with workspace-scoped paths was found.",r));let d=["git","apply",...o?["--reverse"]:[],"--recount","--whitespace=nowarn","-"],C=["git","apply",...o?["--reverse"]:[],"--check","--recount","--whitespace=nowarn","-"];return l(Br(n,l$1),()=>l(e.exec(C,{cwd:n,stdin:s}),f$1=>f$1.exitCode!==0?g($e(`${p}.check`,f$1.stderr||f$1.stdout||`git apply --check exited with ${f$1.exitCode}`,a)):l(e.exec(d,{cwd:n,stdin:s}),k=>k.exitCode!==0?g($e(p,k.stderr||k.stdout||`git apply exited with ${k.exitCode}`,a)):f({changedFiles:l$1}))))};return {apply:(n,r)=>t(n,r,false),rollback:(n,r)=>t(n,r,true)}};var oe=new Function("specifier","return import(specifier)"),y=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),L=(e,t)=>{if(e!==void 0&&(!Array.isArray(e)||e.some(n=>typeof n!="string")))throw new Error(`${t} must be an array of strings.`)},b=(e,t)=>{if(e!==void 0&&(typeof e!="number"||!Number.isFinite(e)))throw new Error(`${t} must be a finite number.`)},S=(e,t)=>{if(e!==void 0&&typeof e!="boolean")throw new Error(`${t} must be a boolean.`)},h=(e,t)=>{if(e!==void 0&&typeof e!="string")throw new Error(`${t} must be a string.`)},Vr=(e,t)=>{if(typeof e!="string"){if(!y(e))throw new Error(`${t} must be a string or object.`);if(h(e.goal,`${t}.goal`),h(e.cwd,`${t}.cwd`),h(e.patchFile,`${t}.patchFile`),h(e.saveRunDir,`${t}.saveRunDir`),e.preset!==void 0&&(typeof e.preset!="string"||!Lt(e.preset)))throw new Error(`${t}.preset must be one of: fix-tests, inspect, typecheck, lint.`);if(e.mode!==void 0&&(typeof e.mode!="string"||!Ce(e.mode)))throw new Error(`${t}.mode must be one of: read-only, propose, write, autonomous.`);if(e.patchFileMode!==void 0&&e.patchFileMode!=="apply"&&e.patchFileMode!=="rollback")throw new Error(`${t}.patchFileMode must be apply or rollback.`);if(e.goal===void 0&&e.preset===void 0&&e.patchFile===void 0)throw new Error(`${t} must include goal, preset, or patchFile.`)}},zr=(e,t)=>{if(!y(e))throw new Error(`Agent config at ${t} must be a JSON object.`);if(e.mode!==void 0&&(typeof e.mode!="string"||!Ce(e.mode)))throw new Error("config.mode must be one of: read-only, propose, write, autonomous.");if(e.approval!==void 0&&(typeof e.approval!="string"||!$t(e.approval)))throw new Error("config.approval must be one of: auto, interactive, approve, deny.");if(e.llm!==void 0){if(!y(e.llm))throw new Error("config.llm must be an object.");if(e.llm.provider!==void 0&&(typeof e.llm.provider!="string"||!Ft(e.llm.provider)))throw new Error("config.llm.provider must be one of: fake, google, gemini, openai, openai-compatible.");if("apiKey"in e.llm)throw new Error("config.llm.apiKey is not supported. Store secrets in environment variables and use config.llm.apiKeyEnv instead.");h(e.llm.model,"config.llm.model"),h(e.llm.endpoint,"config.llm.endpoint"),h(e.llm.baseUrl,"config.llm.baseUrl"),h(e.llm.apiVersion,"config.llm.apiVersion"),h(e.llm.apiKeyEnv,"config.llm.apiKeyEnv"),h(e.llm.systemInstruction,"config.llm.systemInstruction"),h(e.llm.fakeResponse,"config.llm.fakeResponse"),b(e.llm.temperature,"config.llm.temperature"),b(e.llm.topP,"config.llm.topP"),b(e.llm.topK,"config.llm.topK"),b(e.llm.maxOutputTokens,"config.llm.maxOutputTokens");}if(e.project!==void 0){if(!y(e.project))throw new Error("config.project must be an object.");if(e.project.packageManager!==void 0&&(typeof e.project.packageManager!="string"||!["auto","npm","pnpm","yarn","bun"].includes(e.project.packageManager)))throw new Error("config.project.packageManager must be one of: auto, npm, pnpm, yarn, bun.");L(e.project.validationCommands,"config.project.validationCommands"),L(e.project.testScriptNames,"config.project.testScriptNames"),S(e.project.includeTypecheck,"config.project.includeTypecheck"),S(e.project.includeLint,"config.project.includeLint"),b(e.project.maxValidationCommands,"config.project.maxValidationCommands");}if(e.context!==void 0){if(!y(e.context))throw new Error("config.context must be an object.");S(e.context.enabled,"config.context.enabled"),b(e.context.maxSearchQueries,"config.context.maxSearchQueries"),b(e.context.maxFiles,"config.context.maxFiles"),b(e.context.maxSearchResults,"config.context.maxSearchResults"),L(e.context.globs,"config.context.globs"),L(e.context.excludeGlobs,"config.context.excludeGlobs");}if(e.patchQuality!==void 0){if(!y(e.patchQuality))throw new Error("config.patchQuality must be an object.");if(S(e.patchQuality.enabled,"config.patchQuality.enabled"),b(e.patchQuality.maxRepairAttempts,"config.patchQuality.maxRepairAttempts"),typeof e.patchQuality.maxRepairAttempts=="number"&&e.patchQuality.maxRepairAttempts<0)throw new Error("config.patchQuality.maxRepairAttempts must be greater than or equal to 0.")}if(e.rollback!==void 0){if(!y(e.rollback))throw new Error("config.rollback must be an object.");if(S(e.rollback.enabled,"config.rollback.enabled"),S(e.rollback.onFinalValidationFailure,"config.rollback.onFinalValidationFailure"),S(e.rollback.runValidationAfterRollback,"config.rollback.runValidationAfterRollback"),S(e.rollback.allowForSuppliedPatches,"config.rollback.allowForSuppliedPatches"),b(e.rollback.maxRollbackDepth,"config.rollback.maxRollbackDepth"),typeof e.rollback.maxRollbackDepth=="number"&&e.rollback.maxRollbackDepth<0)throw new Error("config.rollback.maxRollbackDepth must be greater than or equal to 0.");if(e.rollback.strategy!==void 0&&e.rollback.strategy!=="last"&&e.rollback.strategy!=="all")throw new Error("config.rollback.strategy must be one of: last, all.")}if(e.redaction!==void 0){if(!y(e.redaction))throw new Error("config.redaction must be an object.");S(e.redaction.enabled,"config.redaction.enabled"),L(e.redaction.additionalPatterns,"config.redaction.additionalPatterns");}if(e.language!==void 0){if(!y(e.language))throw new Error("config.language must be an object.");if(e.language.response!==void 0&&(typeof e.language.response!="string"||!["auto","match-user","en","es","pt","fr","de","it","custom"].includes(e.language.response)))throw new Error("config.language.response must be one of: auto, match-user, en, es, pt, fr, de, it, custom.");h(e.language.custom,"config.language.custom");}if(e.permissions!==void 0){if(!y(e.permissions))throw new Error("config.permissions must be an object.");if(e.permissions.shell!==void 0){if(!y(e.permissions.shell))throw new Error("config.permissions.shell must be an object.");if(S(e.permissions.shell.inheritDefaults,"config.permissions.shell.inheritDefaults"),L(e.permissions.shell.allow,"config.permissions.shell.allow"),L(e.permissions.shell.deny,"config.permissions.shell.deny"),e.permissions.shell.ask!==void 0){if(!Array.isArray(e.permissions.shell.ask))throw new Error("config.permissions.shell.ask must be an array.");for(let[n,r]of e.permissions.shell.ask.entries())if(typeof r!="string"){if(!y(r))throw new Error(`config.permissions.shell.ask[${n}] must be a string or object.`);if(h(r.pattern,`config.permissions.shell.ask[${n}].pattern`),h(r.reason,`config.permissions.shell.ask[${n}].reason`),r.risk!==void 0&&r.risk!=="low"&&r.risk!=="medium"&&r.risk!=="high")throw new Error(`config.permissions.shell.ask[${n}].risk must be one of: low, medium, high.`);if(r.defaultAnswer!==void 0&&r.defaultAnswer!=="approve"&&r.defaultAnswer!=="reject")throw new Error(`config.permissions.shell.ask[${n}].defaultAnswer must be approve or reject.`)}}}if(e.permissions.patchApply!==void 0){let n=e.permissions.patchApply;if(typeof n=="string"){if(n!=="allow"&&n!=="ask"&&n!=="deny")throw new Error("config.permissions.patchApply must be allow, ask, deny, or an object.")}else if(y(n)){if(n.decision!==void 0&&n.decision!=="allow"&&n.decision!=="ask"&&n.decision!=="deny")throw new Error("config.permissions.patchApply.decision must be allow, ask, or deny.");if(h(n.reason,"config.permissions.patchApply.reason"),n.risk!==void 0&&n.risk!=="low"&&n.risk!=="medium"&&n.risk!=="high")throw new Error("config.permissions.patchApply.risk must be one of: low, medium, high.");if(n.defaultAnswer!==void 0&&n.defaultAnswer!=="approve"&&n.defaultAnswer!=="reject")throw new Error("config.permissions.patchApply.defaultAnswer must be approve or reject.")}else throw new Error("config.permissions.patchApply must be allow, ask, deny, or an object.")}}if(e.tools!==void 0){if(!y(e.tools))throw new Error("config.tools must be an object.");for(let[n,r]of Object.entries(e.tools)){if(!y(r))throw new Error(`config.tools.${n} must be an object.`);b(r.timeoutMs,`config.tools.${n}.timeoutMs`),b(r.retries,`config.tools.${n}.retries`);}}if(e.batch!==void 0){if(!y(e.batch))throw new Error("config.batch must be an object.");if(S(e.batch.stopOnFailure,"config.batch.stopOnFailure"),e.batch.goals!==void 0){if(!Array.isArray(e.batch.goals))throw new Error("config.batch.goals must be an array.");e.batch.goals.forEach((n,r)=>Vr(n,`config.batch.goals[${r}]`));}}return e},qt=async e=>{let{stat:t}=await oe("node:fs/promises");try{return (await t(e)).isFile()}catch{return false}},Ur=async e=>{let t=await oe("node:path"),n=t.resolve(e);for(;;){for(let o of Mt){let a=t.join(n,o);if(await qt(a))return a}let r=t.dirname(n);if(r===n)return;n=r;}},Gt=async e=>{let{readFile:t}=await oe("node:fs/promises"),n=String(await t(e,"utf8")).replace(/^\uFEFF/,"");try{return zr(JSON.parse(n),e)}catch(r){throw r instanceof SyntaxError?new Error(`Invalid JSON in agent config ${e}: ${r.message}`):r}},Na=async e=>{if(e.noConfig)return {config:{}};let t=await oe("node:path");if(e.configPath){let r=t.isAbsolute(e.configPath)?e.configPath:t.resolve(e.cwd,e.configPath);if(!await qt(r))throw new Error(`Agent config not found or not a file: ${r}`);return {path:r,config:await Gt(r)}}let n=await Ur(e.cwd);return n?{path:n,config:await Gt(n)}:{config:{}}};var Wr=e=>e?.choices?.[0]?.message?.content??e?.output_text??e?.content?.[0]?.text??JSON.stringify(e),qa=e=>({complete:t=>da$1(async n=>{let r=await fetch(e.endpoint,{method:"POST",signal:n,headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({model:e.model,messages:[{role:"user",content:t.prompt}]})});if(!r.ok)throw new Error(`LLM request failed with ${r.status}`);return {content:Wr(await r.json())}},n=>({_tag:"LLMError",cause:n}))});var Qr="gemini-2.5-flash",Kr="v1beta",Zr="https://generativelanguage.googleapis.com",Hr=e=>{let t=e.length;for(;t>0&&e.charCodeAt(t-1)===47;)t-=1;return t===e.length?e:e.slice(0,t)},Jr=e=>e.startsWith("models/")?e:`models/${e}`,Xr=e=>{if(e.endpoint)return e.endpoint;let t=Hr(e.baseUrl??Zr),n=e.apiVersion??Kr,r=Jr(e.model??Qr);return `${t}/${n}/${r}:generateContent`},ae=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,Bt=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0)),Yr=(e,t)=>{let n=Bt({temperature:ae(t.temperature),topP:ae(t.topP),topK:ae(t.topK),maxOutputTokens:ae(t.maxOutputTokens),stopSequences:t.stopSequences,responseMimeType:t.responseMimeType,...t.extraGenerationConfig??{}});return Bt({contents:[{role:"user",parts:[{text:e.prompt}]}],systemInstruction:t.systemInstruction?{parts:[{text:t.systemInstruction}]}:void 0,generationConfig:Object.keys(n).length>0?n:void 0})},eo=e=>{let t=e.candidates?.flatMap(o=>o.content?.parts??[]).map(o=>o.text??"").filter(Boolean).join(`
|
|
24
|
-
`).trim();if(t)return t;let n=e.promptFeedback?.blockReason;if(n){let o=e.promptFeedback?.blockReasonMessage;throw new Error(`Google Gemini blocked the prompt: ${n}${o?` - ${o}`:""}`)}let r=e.candidates?.[0]?.finishReason;if(r)throw new Error(`Google Gemini returned no text. finishReason=${r}`);if(e.error?.message)throw new Error(`Google Gemini error: ${e.error.message}`);return JSON.stringify(e)},to=async e=>{let t=await e.text();try{return JSON.parse(t).error?.message??t}catch{return t}},za=e=>({complete:t=>da$1(async n=>{let r=await fetch(Xr(e),{method:"POST",signal:n,headers:{"content-type":"application/json","x-goog-api-key":e.apiKey},body:JSON.stringify(Yr({prompt:t.prompt},e))});if(!r.ok){let a=await to(r);throw new Error(`Google Gemini request failed with ${r.status}: ${a}`)}let o=await r.json();return {content:eo(o)}},n=>({_tag:"LLMError",cause:n}))});var no=e=>["Fake LLM response.","",`Purpose: ${e.purpose}`,"Set BRASS_LLM_PROVIDER=google with GEMINI_API_KEY/GOOGLE_API_KEY, or set BRASS_LLM_ENDPOINT and BRASS_LLM_API_KEY for an OpenAI-compatible model.","You can also set BRASS_FAKE_LLM_RESPONSE to provide a deterministic offline response, including a fenced ```diff block."].join(`
|
|
25
|
-
`),Qa=(e={})=>({complete:t=>f({content:typeof e.content=="function"?e.content(t):e.content??no(t)})});var co=[{name:".brass-agent.json",kind:"file"},{name:"brass-agent.config.json",kind:"file"},{name:"package.json",kind:"file"},{name:"pnpm-workspace.yaml",kind:"file"},{name:"turbo.json",kind:"file"},{name:"nx.json",kind:"file"},{name:".git",kind:"directory"}],lo=(e,t)=>{try{let n=statSync(e);return t==="directory"?n.isDirectory():n.isFile()}catch{return false}},po=e=>{for(let t of co){let n=join(e,t.name);if(lo(n,t.kind))return {marker:t.name,markerPath:n}}},Ja=(e,t={})=>{let n=resolve(e);if(t.enabled===false)return {inputCwd:n,cwd:n,changed:false,disabled:true};if(!existsSync(n))return {inputCwd:n,cwd:n,changed:false};let r=n;for(;;){let o=po(r);if(o)return {inputCwd:n,cwd:r,marker:o.marker,markerPath:o.markerPath,changed:r!==n};let a=dirname(r);if(a===r)return {inputCwd:n,cwd:n,changed:false};r=a;}};export{Et as $,O as A,nt as B,rt as C,ke as D,ot as E,at as F,xe as G,M as H,it as I,Hn as J,ct as K,lt as L,rr as M,Se as N,te as O,At as P,v as Q,E as R,Pe as S,_o as T,To as U,Oo as V,bt as W,kt as X,xt as Y,vt as Z,Pr as _,Le as a,Ct as aa,_e as b,da as ba,Te as c,Ce as ca,qe as d,$t as da,ze as e,Ft as ea,ue as f,Mt as fa,dn as g,Lt as ga,We as h,ma as ha,Qe as i,Ir as ia,Ke as j,ha as ja,fe as k,ka,ye as l,xa as la,An as m,wa as ma,Xe as n,ja as na,Ye as o,_a as oa,Ze as p,Na as pa,$n as q,qa,J as r,za as ra,P as s,Qa as sa,X as t,Ja as ta,Ae as u,On as v,Y as w,ee as x,tt as y,be as z};
|
package/dist/chunk-XPOARCND.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkK47BP5A2_cjs=require('./chunk-K47BP5A2.cjs');var C=e=>e._tag==="None"?chunkK47BP5A2_cjs.r:chunkK47BP5A2_cjs.s(e.value),m=e=>({_tag:"FromPull",pull:e}),D=(e,a)=>({_tag:"Scoped",acquire:e,release:a}),K=e=>({_tag:"Managed",acquire:e}),Q=(e,a,r=true)=>({_tag:"Merge",left:e,right:a,flip:r}),G={_tag:"Empty"},P=()=>G,Y=e=>({_tag:"Emit",value:e}),w=(e,a)=>({_tag:"Concat",left:e,right:a}),N=e=>({_tag:"Flatten",stream:e});function T(e,a,r,n,t){return (o,E,R)=>{if(o._tag,o._tag,o._tag==="Success"){let[i,c]=o.value;E.interrupt();let d=m(e==="L"?B(c,r):B(a,c));return chunkK47BP5A2_cjs.f([i,d])}if(o.cause._tag==="Interrupt")return chunkK47BP5A2_cjs.j((i,c)=>{c(chunkK47BP5A2_cjs.u.failCause(chunkK47BP5A2_cjs.t.interrupt()));});let u=o.cause.error;return u._tag==="None"?s(e==="L"?r:a):chunkK47BP5A2_cjs.g(u)}}function B(e,a,r,n){let o=T("L",e,a),E=T("R",e,a);return chunkK47BP5A2_cjs.j((R,u)=>{let i=chunkK47BP5A2_cjs.O(),c=new chunkK47BP5A2_cjs.fa(i),d=chunkK47BP5A2_cjs.la(s(e),s(a),c,o,E);c.fork(d).join(A=>{c.close(A),u(A);});})}function Ae(e,a){return m(B(e,a))}function s(e){switch(e._tag){case "Empty":return chunkK47BP5A2_cjs.w(chunkK47BP5A2_cjs.r);case "Emit":return chunkK47BP5A2_cjs.y(chunkK47BP5A2_cjs.A(e.value,a=>chunkK47BP5A2_cjs.s(a)),a=>[a,G]);case "FromPull":return e.pull;case "Concat":return chunkK47BP5A2_cjs.C(chunkK47BP5A2_cjs.y(s(e.left),([a,r])=>[a,w(r,e.right)]),()=>s(e.right));case "Flatten":return chunkK47BP5A2_cjs.z(s(e.stream),([a,r])=>chunkK47BP5A2_cjs.C(chunkK47BP5A2_cjs.y(s(a),([n,t])=>[n,w(t,N(r))]),()=>s(N(r))));case "Merge":return B(e.left,e.right,e.flip);case "Scoped":return chunkK47BP5A2_cjs.j((a,r)=>{let n=chunkK47BP5A2_cjs.O(),t=new chunkK47BP5A2_cjs.fa(n);chunkK47BP5A2_cjs.N()?.addFinalizer(u=>{try{t.close(u);}catch{}});let E=u=>{if(u._tag==="Failure"){let i=u.cause.error;if(i&&typeof i=="object"&&i._tag==="None"){t.close({_tag:"Success",value:void 0});return}}t.close(u);},R=u=>m(chunkK47BP5A2_cjs.j((i,c)=>{let d=s(u);chunkK47BP5A2_cjs.ea(d,i,A=>{let l=chunkK47BP5A2_cjs.u.failCause(A);E(l),c(l);},([A,l])=>{c(chunkK47BP5A2_cjs.u.succeed([A,R(l)]));});}));t.fork(e.acquire).join(u=>{if(u._tag==="Failure"){E(u),r({_tag:"Failure",cause:{_tag:"Fail",error:chunkK47BP5A2_cjs.s(u.cause.error)}});return}t.addFinalizer(c=>e.release(c));let i=u.value;chunkK47BP5A2_cjs.O().fork(s(R(i))).join(r);});});case "Managed":return chunkK47BP5A2_cjs.j((a,r)=>{let n=chunkK47BP5A2_cjs.O(),t=new chunkK47BP5A2_cjs.fa(n);chunkK47BP5A2_cjs.N()?.addFinalizer(E=>{try{t.close(E);}catch{}});let o=E=>{if(E._tag==="Failure"){let R=E.cause.error;if(R&&typeof R=="object"&&R._tag==="None"){t.close({_tag:"Success",value:void 0});return}}t.close(E);};t.fork(e.acquire).join(E=>{if(E._tag==="Failure"){t.close(E),r({_tag:"Failure",cause:{_tag:"Fail",error:chunkK47BP5A2_cjs.s(E.cause.error)}});return}let{stream:R,release:u}=E.value;t.addFinalizer(c=>u(c));let i=c=>m(chunkK47BP5A2_cjs.j((d,A)=>{s(c)(d,l=>{if(l._tag==="Failure"){o(l),A(l);return}let[$,J]=l.value;A(chunkK47BP5A2_cjs.u.succeed([$,i(J)]));});}));chunkK47BP5A2_cjs.O().fork(s(i(R))).join(r);});})}}function X(e,a){throw new Error(a??`Unexpected value: ${String(e)}`)}function y(e,a){switch(e._tag){case "Empty":return P();case "Emit":return Y(chunkK47BP5A2_cjs.y(e.value,a));case "FromPull":return m(chunkK47BP5A2_cjs.y(e.pull,([r,n])=>[a(r),y(n,a)]));case "Concat":return w(y(e.left,a),y(e.right,a));case "Flatten":{let r=y(e.stream,n=>y(n,a));return N(r)}case "Merge":return Q(y(e.left,a),y(e.right,a),e.flip);case "Scoped":return D(chunkK47BP5A2_cjs.y(e.acquire,r=>y(r,a)),e.release);case "Managed":return K(chunkK47BP5A2_cjs.y(e.acquire,({stream:r,release:n})=>({stream:y(r,a),release:n})));default:return X(e)}}function le(e,a){let r=n=>m(n>a?chunkK47BP5A2_cjs.g(chunkK47BP5A2_cjs.r):chunkK47BP5A2_cjs.f([n,r(n+1)]));return r(e)}function ee(e,a){let r=chunkK47BP5A2_cjs.b(chunkK47BP5A2_cjs.d(s(e),n=>C(n)),n=>chunkK47BP5A2_cjs.g(n),([n,t])=>chunkK47BP5A2_cjs.b(chunkK47BP5A2_cjs.d(s(a),o=>C(o)),o=>chunkK47BP5A2_cjs.g(o),([o,E])=>chunkK47BP5A2_cjs.f([[n,o],ee(t,E)])));return m(r)}function ye(e,a){let r=n=>chunkK47BP5A2_cjs.b(chunkK47BP5A2_cjs.d(s(n),t=>C(t)),t=>t._tag==="None"?chunkK47BP5A2_cjs.f(void 0):chunkK47BP5A2_cjs.g(t),([t,o])=>chunkK47BP5A2_cjs.l(chunkK47BP5A2_cjs.d(a(t),E=>chunkK47BP5A2_cjs.s(E)),()=>r(o)));return chunkK47BP5A2_cjs.b(r(e),n=>n._tag==="None"?chunkK47BP5A2_cjs.f(void 0):chunkK47BP5A2_cjs.g(n.value),()=>chunkK47BP5A2_cjs.f(void 0))}function pe(e){let a=P();for(let r=e.length-1;r>=0;r--){let n=Y(chunkK47BP5A2_cjs.v(e[r]));a=w(n,a);}return a}function Se(e){let a=(r,n)=>chunkK47BP5A2_cjs.b(s(r),t=>t._tag==="None"?chunkK47BP5A2_cjs.v(n):chunkK47BP5A2_cjs.w(t),([t,o])=>a(o,[...n,t]));return chunkK47BP5A2_cjs.A(a(e,[]),r=>{if(r._tag==="Some")return r.value;throw new Error("unreachable: stream end handled as success")})}function ae(e,a){let r=chunkK47BP5A2_cjs.j((n,t)=>{e.read().then(({done:o,value:E})=>{if(o){t({_tag:"Failure",cause:{_tag:"Fail",error:chunkK47BP5A2_cjs.r}});return}t({_tag:"Success",value:[E,m(r)]});}).catch(o=>{t({_tag:"Failure",cause:{_tag:"Fail",error:chunkK47BP5A2_cjs.s(a(o))}});});});return m(r)}function de(e,a){if(!e)return P();let r;return D(chunkK47BP5A2_cjs.x(()=>(r=e.getReader(),ae(r,a))),()=>chunkK47BP5A2_cjs.h(()=>{try{r?.cancel();}catch{}}))}exports.a=C;exports.b=m;exports.c=D;exports.d=K;exports.e=Q;exports.f=P;exports.g=Y;exports.h=w;exports.i=N;exports.j=Ae;exports.k=s;exports.l=X;exports.m=y;exports.n=le;exports.o=ee;exports.p=ye;exports.q=pe;exports.r=Se;exports.s=de;
|
package/dist/http/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkXPOARCND_cjs=require('../chunk-XPOARCND.cjs'),chunkK47BP5A2_cjs=require('../chunk-K47BP5A2.cjs');var b={make(t,e){return {get:t,set:e}},over(t,e){return r=>t.set(e(t.get(r)))(r)},compose(t,e){return b.make(r=>t.get(e.get(r)),r=>n=>e.set(t.set(r)(e.get(n)))(n))}};var A={headers:b.make(t=>t.headers??{},t=>e=>({...e,headers:t}))};var I=t=>e=>b.over(A.headers,r=>({...r,...t}))(e),C=t=>e=>b.over(A.headers,r=>({...t,...r}))(e),g=(t,e)=>r=>b.over(A.headers,n=>n[t]?n:{...n,[t]:e})(r);var v=t=>typeof t=="object"&&t!==null&&"_tag"in t,J=t=>v(t)?t:typeof t=="object"&&t!==null&&t.name==="AbortError"?{_tag:"Abort"}:{_tag:"FetchError",message:String(t)},M=t=>chunkK47BP5A2_cjs.da(e=>new Promise((r,n)=>{if(e.aborted)return n({_tag:"Abort"});let u=setTimeout(r,t),p=()=>{clearTimeout(u),n({_tag:"Abort"});};e.addEventListener("abort",p,{once:true});}),J);var lt=t=>e=>T(t(e)),T=t=>Object.assign((e=>t(e)),{with:e=>T(e(t))}),O=t=>t instanceof DOMException&&t.name==="AbortError"?{_tag:"Abort"}:typeof t=="object"&&t&&"_tag"in t?t:{_tag:"FetchError",message:String(t)},k=t=>{if(t){if(typeof Headers<"u"&&t instanceof Headers){let e={};return t.forEach((r,n)=>e[n]=r),e}if(Array.isArray(t))return Object.fromEntries(t);if(typeof t=="object")return {...t}}},D=t=>e=>{let r=Object.keys(t).length?C(t)(e):e,n=k(e.init?.headers);return n&&Object.keys(n).length&&(r=C(n)(r)),r};function N(t={}){let e=t.baseUrl??"",r=t.headers??{},n=D(r);return u=>chunkK47BP5A2_cjs.da(async p=>{let y=n(u),i;try{i=new URL(y.url,e);}catch{throw {_tag:"BadUrl",message:`URL inv\xE1lida: ${y.url}`}}let a=performance.now(),s=await fetch(i,{...y.init??{},method:y.method,headers:A.headers.get(y),body:y.body,signal:p}),c={};s.headers.forEach((d,m)=>c[m]=d);let o=chunkXPOARCND_cjs.s(s.body,O);return {status:s.status,statusText:s.statusText,headers:c,body:o,ms:Math.round(performance.now()-a)}},O)}function _(t={}){let e=t.baseUrl??"",r=t.headers??{},n=D(r);return T(p=>chunkK47BP5A2_cjs.da(async y=>{let i=n(p),a;try{a=new URL(i.url,e);}catch{throw {_tag:"BadUrl",message:`URL inv\xE1lida: ${i.url}`}}let s=performance.now(),c=await fetch(a,{...i.init??{},method:i.method,headers:A.headers.get(i),body:i.body,signal:y}),o=await c.text(),d={};return c.headers.forEach((m,H)=>d[H]=m),{status:c.status,statusText:c.statusText,headers:d,bodyText:o,ms:Math.round(performance.now()-s)}},O))}var G=(t,e,r)=>Math.max(e,Math.min(r,t)),z=t=>t._tag==="FetchError",Z=t=>t===408||t===429||t===500||t===502||t===503||t===504,F=(t,e,r)=>{let n=e*Math.pow(2,t),u=G(n,0,r);return Math.floor(Math.random()*u)},$=t=>{let e=Object.keys(t).find(p=>p.toLowerCase()==="retry-after");if(!e)return;let r=t[e]?.trim();if(!r)return;let n=Number(r);if(Number.isFinite(n))return Math.max(0,Math.floor(n*1e3));let u=Date.parse(r);if(Number.isFinite(u))return Math.max(0,u-Date.now())},U=t=>e=>(r=>{let n=u=>chunkK47BP5A2_cjs.b(e(r),p=>{if(p._tag==="Abort"||p._tag==="BadUrl")return chunkK47BP5A2_cjs.g(p);if(!(u<t.maxRetries&&(t.retryOnError??z)(p)))return chunkK47BP5A2_cjs.g(p);let i=F(u,t.baseDelayMs,t.maxDelayMs);return chunkK47BP5A2_cjs.l(M(i),()=>n(u+1))},p=>{if(!(u<t.maxRetries&&(t.retryOnStatus??Z)(p.status)))return chunkK47BP5A2_cjs.f(p);let a=$(p.headers)??F(u,t.baseDelayMs,t.maxDelayMs);return chunkK47BP5A2_cjs.l(M(a),()=>n(u+1))});return n(0)});var K=["GET","HEAD","OPTIONS"],Q=t=>t===408||t===429||t===500||t===502||t===503||t===504,V=t=>t._tag==="FetchError";var X=(t,e,r)=>Math.max(e,Math.min(r,t)),L=(t,e,r)=>{let n=Math.max(0,e),u=Math.max(0,r),p=n*Math.pow(2,t),y=X(p,0,u);return Math.floor(Math.random()*y)},Y=(t,e)=>{let r=Object.keys(t).find(n=>n.toLowerCase()===e.toLowerCase());return r?t[r]:void 0},tt=t=>{let e=Y(t,"retry-after")?.trim();if(!e)return;let r=Number(e);if(Number.isFinite(r))return Math.max(0,Math.floor(r*1e3));let n=Date.parse(e);if(Number.isFinite(n))return Math.max(0,n-Date.now())},j=t=>e=>{let r=t.retryOnMethods??K,n=t.retryOnStatus??Q,u=t.retryOnError??V,p=i=>r.includes(i.method),y=(i,a)=>p(i)?chunkK47BP5A2_cjs.b(e(i),s=>{if(s._tag==="Abort"||s._tag==="BadUrl")return chunkK47BP5A2_cjs.g(s);if(!(a<t.maxRetries&&u(s)))return chunkK47BP5A2_cjs.g(s);let o=L(a,t.baseDelayMs,t.maxDelayMs);return chunkK47BP5A2_cjs.l(M(o),()=>y(i,a+1))},s=>{if(!(a<t.maxRetries&&n(s.status)))return chunkK47BP5A2_cjs.f(s);let d=tt(s.headers)??L(a,t.baseDelayMs,t.maxDelayMs);return chunkK47BP5A2_cjs.l(M(d),()=>y(i,a+1))}):e(i);return i=>y(i,0)};var et=(t,e)=>{try{return new URL(e,t??"").toString()}catch{return (t??"")+e}},B=(t={})=>{let e=_(t),r=a=>chunkK47BP5A2_cjs.o((s,c)=>chunkK47BP5A2_cjs.ca(s,c))(a),n=a=>e(a),u=a=>{let{headers:s,...c}=a??{};return {headers:k(s),init:c}},p=a=>s=>a?I(a)(s):s;return {cfg:t,wire:e,withPromise:r,requestRaw:n,splitInit:u,applyInitHeaders:p,buildReq:(a,s,c,o)=>{let d=u(c),m={method:a,url:s,...o&&o.length>0?{body:o}:{},init:d.init};return p(d.headers)(m)},toResponse:(a,s)=>({status:a.status,statusText:a.statusText,headers:a.headers,body:s})}};function _t(t={}){let e=B(t),r=n=>{let u=o=>n(o),p=o=>e.withPromise(u(o));return {request:p,get:(o,d)=>p(e.buildReq("GET",o,d)),post:(o,d,m)=>p(e.buildReq("POST",o,m,d)),getText:(o,d)=>{let m=e.buildReq("GET",o,d);return e.withPromise(chunkK47BP5A2_cjs.q(u(m),H=>e.toResponse(H,H.bodyText)))},getJson:(o,d)=>{let m=e.buildReq("GET",o,d),H=g("accept","application/json")(m);return e.withPromise(chunkK47BP5A2_cjs.q(u(H),l=>e.toResponse(l,JSON.parse(l.bodyText))))},postJson:(o,d,m)=>{let H=e.buildReq("POST",o,m,JSON.stringify(d??{})),l=g("content-type","application/json")(g("accept","application/json")(H));return e.withPromise(chunkK47BP5A2_cjs.q(u(l),P=>e.toResponse(P,JSON.parse(P.bodyText))))},with:o=>r(n.with(o)),withRetry:o=>r(n.with(j(o))),wire:n}};return r(e.wire)}function Ut(t={}){let e=B(t),r=(s,c,o)=>({request:s,urlFinal:et(e.cfg.baseUrl,s.url),startedAt:o,durationMs:c.ms}),n=s=>{let c=Date.now();return e.withPromise(chunkK47BP5A2_cjs.q(e.requestRaw(s),o=>({wire:o,meta:r(s,o,c)})))};return {request:n,get:(s,c)=>{let o=e.buildReq("GET",s,c);return n(o)},getText:(s,c)=>{let o=e.buildReq("GET",s,c),d=Date.now();return e.withPromise(chunkK47BP5A2_cjs.q(e.requestRaw(o),m=>({wire:m,response:e.toResponse(m,m.bodyText),meta:r(o,m,d)})))},getJson:(s,c)=>{let o=e.buildReq("GET",s,c),d=g("accept","application/json")(o),m=Date.now();return e.withPromise(chunkK47BP5A2_cjs.q(e.requestRaw(d),H=>({wire:H,response:e.toResponse(H,JSON.parse(H.bodyText)),meta:r(d,H,m)})))},post:(s,c,o)=>{let d=e.buildReq("POST",s,o,c);return n(d)},postJson:(s,c,o)=>{let d=e.buildReq("POST",s,o,JSON.stringify(c??{})),m=g("content-type","application/json")(g("accept","application/json")(d)),H=Date.now();return e.withPromise(chunkK47BP5A2_cjs.q(e.requestRaw(m),l=>({wire:l,response:e.toResponse(l,JSON.parse(l.bodyText)),meta:r(m,l,H)})))}}}function Lt(t={}){let e=N(t),r=n=>{let u=i=>chunkK47BP5A2_cjs.o((a,s)=>chunkK47BP5A2_cjs.ca(a,s))(i),p=i=>u(n(i)),y=(i,a)=>{let s={method:"GET",url:i,init:a},c=g("accept","*/*")(s);return p(c)};return {request:p,getStream:y,get:y,with:i=>r(i(n)),withRetry:i=>r(U(i)(n)),wire:n}};return r(e)}exports.decorate=T;exports.httpClient=_t;exports.httpClientStream=Lt;exports.httpClientWithMeta=Ut;exports.makeHttp=_;exports.makeHttpStream=N;exports.normalizeHeadersInit=k;exports.withMiddleware=lt;exports.withRetryStream=U;
|
package/dist/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkXPOARCND_cjs=require('./chunk-XPOARCND.cjs'),chunkK47BP5A2_cjs=require('./chunk-K47BP5A2.cjs');function En(){let n=false,e=new Set;return {isCancelled:()=>n,onCancel:r=>{if(n){try{r();}catch{}return ()=>{}}return e.add(r),()=>{e.delete(r);}},cancel:()=>{n||(n=true,e.forEach(r=>r()),e.clear());}}}function An(n,e){return n.onCancel(()=>e.abort())}var C=class{head=null;tail=null;len=0;get length(){return this.len}isEmpty(){return this.len===0}push(e){let t={value:e,next:null,prev:this.tail,removed:false};return this.tail?this.tail.next=t:this.head=t,this.tail=t,this.len++,t}shift(){let e=this.head;if(e)return this.unlink(e),e.value}remove(e){e.removed||this.unlink(e);}unlink(e){e.removed=true;let{prev:t,next:r}=e;t?t.next=r:this.head=r,r?r.prev=t:this.tail=t,e.next=null,e.prev=null,this.len--;}};function B(n,e="backpressure",t={}){return chunkK47BP5A2_cjs.h(()=>X(n,e,t))}function X(n,e,t){let r=chunkK47BP5A2_cjs.H(n,n,t),i=false,a={_tag:"QueueClosed"},o=new C,s=new C;return {size:()=>r.length,shutdown:()=>{if(!i){for(i=true;s.length>0;)s.shift()({_tag:"Failure",cause:{_tag:"Fail",error:a}});for(;o.length>0;)o.shift().cb(false);r.clear();}},offer:l=>chunkK47BP5A2_cjs.j((f,y)=>{if(i){y({_tag:"Success",value:false});return}if(s.length>0){s.shift()({_tag:"Success",value:l}),y({_tag:"Success",value:true});return}if(r.length<n){r.push(l),y({_tag:"Success",value:true});return}if(e==="dropping"){y({_tag:"Success",value:false});return}if(e==="sliding"){r.shift(),r.push(l),y({_tag:"Success",value:true});return}let R=o.push({a:l,cb:E=>y({_tag:"Success",value:E})});return ()=>{o.remove(R);}}),take:()=>chunkK47BP5A2_cjs.j((l,f)=>{if(r.length>0){let c=r.shift();if(f({_tag:"Success",value:c}),o.length>0&&r.length<n){let E=o.shift();r.push(E.a),E.cb(true);}return}if(o.length>0){let c=o.shift();c.cb(true),f({_tag:"Success",value:c.a});return}if(i){f({_tag:"Failure",cause:{_tag:"Fail",error:a}});return}let y=s.push(f);return ()=>{s.remove(y);}})}}var Y={_tag:"End"};function q(n,e,t="backpressure"){let r=false,i=null,a=null,o=n,s=c=>chunkK47BP5A2_cjs.f(c._tag==="None"?Y:{_tag:"Fail",error:c.value}),u=([c,E])=>chunkK47BP5A2_cjs.h(()=>(o=E,{_tag:"Elem",value:c})),l=()=>chunkK47BP5A2_cjs.b(chunkXPOARCND_cjs.k(o),s,u),f=c=>chunkK47BP5A2_cjs.l(B(e,t),E=>{i=E;let x,Z=()=>x._tag!=="Elem"?chunkK47BP5A2_cjs.f(void 0):Q(),v=z=>(x=z,chunkK47BP5A2_cjs.l(i.offer(z),Z)),Q=()=>chunkK47BP5A2_cjs.l(l(),v);return a=chunkK47BP5A2_cjs.aa(Q(),c),chunkK47BP5A2_cjs.f(void 0)}),y={_tag:"Async",register:(c,E)=>{(()=>{if(!r){r=true,chunkK47BP5A2_cjs.O().fork(f(c)).join(()=>{R(c,E);});return}R(c,E);})();}};function R(c,E){let x=i.take();chunkK47BP5A2_cjs.O().fork(x).join(Z=>{if(Z._tag!=="Success")return;let v=Z.value;switch(v._tag){case "Elem":E({_tag:"Success",value:[v.value,chunkXPOARCND_cjs.b(y)]});return;case "End":a?.interrupt?.(),E({_tag:"Failure",cause:{_tag:"Fail",error:chunkK47BP5A2_cjs.r}});return;case "Fail":a?.interrupt?.(),E({_tag:"Failure",cause:{_tag:"Fail",error:chunkK47BP5A2_cjs.s(v.error)}});return}});}return chunkXPOARCND_cjs.b(y)}var $=n=>n==="BackPressure"?"backpressure":n==="Dropping"?"dropping":"sliding";function ee(n,e="BackPressure"){let t=new Set,r=false,i=u=>{if(r)return chunkK47BP5A2_cjs.f(false);let l=t.size;if(l===0)return chunkK47BP5A2_cjs.f(true);if(l===1)return t.values().next().value.offer(u);let f=chunkK47BP5A2_cjs.f(true);for(let y of t)f=chunkK47BP5A2_cjs.l(f,R=>chunkK47BP5A2_cjs.l(y.offer(u),c=>chunkK47BP5A2_cjs.f(R&&c)));return f};return {publish:i,publishAll:u=>{let l=chunkK47BP5A2_cjs.f(true),f=u[Symbol.iterator]();for(;;){let y=f.next();if(y.done)break;let R=y.value;l=chunkK47BP5A2_cjs.l(l,c=>chunkK47BP5A2_cjs.l(i(R),E=>chunkK47BP5A2_cjs.f(c&&E)));}return l},subscribe:()=>r?chunkK47BP5A2_cjs.i(()=>{throw {_tag:"HubClosed"}}):chunkK47BP5A2_cjs.l(B(n,$(e)),u=>chunkK47BP5A2_cjs.h(()=>(t.add(u),{...u,unsubscribe:()=>{t.has(u)&&(t.delete(u),u.shutdown());}}))),shutdown:()=>chunkK47BP5A2_cjs.h(()=>{if(!r){r=true;for(let u of t)u.shutdown();t.clear();}})}}var $n=ee;function et(n,e){return chunkXPOARCND_cjs.p(n,t=>chunkK47BP5A2_cjs.l(e.publish(t),()=>chunkK47BP5A2_cjs.f(void 0)))}function nt(n){return chunkXPOARCND_cjs.d(chunkK47BP5A2_cjs.l(n.subscribe(),e=>{let t=chunkXPOARCND_cjs.b(chunkK47BP5A2_cjs.l(chunkK47BP5A2_cjs.d(e.take(),r=>chunkK47BP5A2_cjs.r),r=>chunkK47BP5A2_cjs.f([r,t])));return chunkK47BP5A2_cjs.f({stream:t,release:r=>chunkK47BP5A2_cjs.h(()=>e.unsubscribe())})}))}var _;function G(){return _!==void 0||(_=chunkK47BP5A2_cjs.G()?.BrassWasmChunkBuffer??null),_}var P=class{constructor(e,t=false){this.maxChunkSize=e;this.fallbackUsed=t;}maxChunkSize;fallbackUsed;engine="js";values=[];emittedChunks=0;emittedItems=0;flushes=0;get length(){return this.values.length}push(e){return this.values.length>=this.maxChunkSize?false:(this.values.push(e),true)}isFull(){return this.values.length>=this.maxChunkSize}isEmpty(){return this.values.length===0}takeChunk(){this.flushes+=1;let e=this.values;return this.values=[],e.length>0&&(this.emittedChunks+=1,this.emittedItems+=e.length),e}clear(){this.values=[];}stats(){return {engine:"js",fallbackUsed:this.fallbackUsed,data:{len:this.values.length,maxChunkSize:this.maxChunkSize,emittedChunks:this.emittedChunks,emittedItems:this.emittedItems,flushes:this.flushes}}}},T=class{engine="wasm";fallbackUsed=false;inner;constructor(e){let t=G();if(!t)throw new Error("brass-runtime wasm chunk buffer is not available. Run npm run build:wasm first.");this.inner=new t(e);}get length(){return this.inner.len()}get maxChunkSize(){return this.inner.max_chunk_size()}push(e){return this.inner.push(e)}isFull(){return this.inner.is_full()}isEmpty(){return this.inner.is_empty()}takeChunk(){return Array.from(this.inner.take_chunk())}clear(){this.inner.clear();}stats(){return {engine:"wasm",fallbackUsed:false,data:JSON.parse(this.inner.stats_json())}}};function ne(n,e={}){let t=Math.max(1,n|0),r=e.engine??"auto";return r==="js"?new P(t,false):r==="wasm"?new T(t):G()?new T(t):new P(t,true)}function F(n,e,t={}){let r=Math.max(1,e|0),i=o=>chunkXPOARCND_cjs.b(a(o,ne(r,t))),a=(o,s)=>chunkK47BP5A2_cjs.b(chunkXPOARCND_cjs.k(o),u=>u._tag==="None"&&!s.isEmpty()?chunkK47BP5A2_cjs.f([s.takeChunk(),chunkXPOARCND_cjs.b(chunkK47BP5A2_cjs.g(chunkK47BP5A2_cjs.r))]):chunkK47BP5A2_cjs.g(u),([u,l])=>(s.push(u),s.isFull()?chunkK47BP5A2_cjs.f([s.takeChunk(),i(l)]):a(l,s)));return i(n)}function pt(n,e,t,r={}){let i=(a,o)=>{if(a.length>0){let[s,...u]=a;return chunkXPOARCND_cjs.b(chunkK47BP5A2_cjs.f([s,i(u,o)]))}return chunkXPOARCND_cjs.b(chunkK47BP5A2_cjs.b(chunkXPOARCND_cjs.k(o),s=>chunkK47BP5A2_cjs.g(s),([s,u])=>{let l=t(s);return chunkXPOARCND_cjs.k(i(l,u))}))};return i([],F(n,e,r))}function L(n,e,t={}){return(r=>{let i=F(r,n,t),a=(o,s)=>{if(o.length>0){let[u,...l]=o;return chunkXPOARCND_cjs.b(chunkK47BP5A2_cjs.f([u,a(l,s)]))}return chunkXPOARCND_cjs.b(chunkK47BP5A2_cjs.b(chunkK47BP5A2_cjs.d(chunkXPOARCND_cjs.k(s),u=>chunkXPOARCND_cjs.a(u)),u=>chunkK47BP5A2_cjs.g(u),([u,l])=>chunkK47BP5A2_cjs.b(chunkK47BP5A2_cjs.d(e(u),f=>({_tag:"Some",value:f})),f=>chunkK47BP5A2_cjs.g(f),f=>chunkXPOARCND_cjs.k(a(f,l)))))};return a([],i)})}function kt(n,e){return e(n)}function te(n,e){return(t=>e(n(t)))}function bt(n,e){return te(e,n)}function xt(){return(n=>n)}function vt(n){return(e=>{let t=a=>chunkK47BP5A2_cjs.g(a),r=([a,o])=>chunkK47BP5A2_cjs.f([n(a),i(o)]),i=a=>chunkXPOARCND_cjs.b(chunkK47BP5A2_cjs.b(chunkXPOARCND_cjs.k(a),t,r));return i(e)})}function Ct(n){return(e=>{let t=o=>chunkK47BP5A2_cjs.g(o),r=([o,s])=>n(o)?chunkK47BP5A2_cjs.f([o,a(s)]):i(s),i=o=>chunkK47BP5A2_cjs.b(chunkXPOARCND_cjs.k(o),t,r),a=o=>chunkXPOARCND_cjs.b(i(o));return a(e)})}function Zt(n){return(e=>{let t=a=>chunkK47BP5A2_cjs.g(a),r=a=>chunkK47BP5A2_cjs.b(chunkXPOARCND_cjs.k(a),t,([o,s])=>{let u=n(o);return u._tag==="Some"?chunkK47BP5A2_cjs.f([u.value,i(s)]):r(s)}),i=a=>chunkXPOARCND_cjs.b(r(a));return i(e)})}function wt(n){let e=Math.max(0,n|0);return(t=>{let r=(i,a)=>a<=0?chunkXPOARCND_cjs.f():chunkXPOARCND_cjs.b(chunkK47BP5A2_cjs.b(chunkXPOARCND_cjs.k(i),o=>chunkK47BP5A2_cjs.g(o),([o,s])=>chunkK47BP5A2_cjs.f([o,r(s,a-1)])));return r(t,e)})}function Ot(n){let e=Math.max(0,n|0);return(t=>{let r=(i,a)=>a<=0?i:chunkXPOARCND_cjs.b(chunkK47BP5A2_cjs.b(chunkXPOARCND_cjs.k(i),o=>chunkK47BP5A2_cjs.g(o),([o,s])=>chunkXPOARCND_cjs.k(r(s,a-1))));return r(t,e)})}function re(n){return(e=>{let t=i=>chunkK47BP5A2_cjs.d(i,a=>chunkK47BP5A2_cjs.s(a)),r=i=>chunkXPOARCND_cjs.b(chunkK47BP5A2_cjs.b(chunkK47BP5A2_cjs.d(chunkXPOARCND_cjs.k(i),a=>chunkXPOARCND_cjs.a(a)),a=>chunkK47BP5A2_cjs.g(a),([a,o])=>chunkK47BP5A2_cjs.b(t(n(a)),s=>chunkK47BP5A2_cjs.g(s),s=>chunkK47BP5A2_cjs.f([s,r(o)]))));return r(e)})}function Bt(n){return re(e=>chunkK47BP5A2_cjs.l(n(e),()=>chunkK47BP5A2_cjs.f(e)))}function _t(n,e={}){return(t=>F(t,n,e))}function Pt(n,e,t={}){return L(n,e,t)}function Tt(n,e="backpressure"){return(t=>q(t,n,e))}function Ft(n){let e=Math.max(1,n|0);return(t=>{let r=(a,o,s)=>o<=0?chunkK47BP5A2_cjs.f({chunk:s,rest:a}):chunkK47BP5A2_cjs.b(chunkXPOARCND_cjs.k(a),u=>u._tag==="None"?chunkK47BP5A2_cjs.f({chunk:s,rest:chunkXPOARCND_cjs.f()}):chunkK47BP5A2_cjs.g(u),([u,l])=>r(l,o-1,[...s,u])),i=a=>chunkXPOARCND_cjs.b(chunkK47BP5A2_cjs.b(chunkXPOARCND_cjs.k(a),o=>chunkK47BP5A2_cjs.g(o),([o,s])=>chunkK47BP5A2_cjs.l(r(s,e-1,[o]),({chunk:u,rest:l})=>chunkK47BP5A2_cjs.f([u,i(l)]))));return i(t)})}function It(n,e,t=false){return {engine:n,data:e,fallbackUsed:t}}function Ht(n,e,t){return {requested:n,engine:e,data:t,fallbackUsed:n==="auto"&&e!=="wasm"}}Object.defineProperty(exports,"assertNever",{enumerable:true,get:function(){return chunkXPOARCND_cjs.l}});Object.defineProperty(exports,"collectStream",{enumerable:true,get:function(){return chunkXPOARCND_cjs.r}});Object.defineProperty(exports,"concatStream",{enumerable:true,get:function(){return chunkXPOARCND_cjs.h}});Object.defineProperty(exports,"emitStream",{enumerable:true,get:function(){return chunkXPOARCND_cjs.g}});Object.defineProperty(exports,"emptyStream",{enumerable:true,get:function(){return chunkXPOARCND_cjs.f}});Object.defineProperty(exports,"flattenStream",{enumerable:true,get:function(){return chunkXPOARCND_cjs.i}});Object.defineProperty(exports,"foreachStream",{enumerable:true,get:function(){return chunkXPOARCND_cjs.p}});Object.defineProperty(exports,"fromArray",{enumerable:true,get:function(){return chunkXPOARCND_cjs.q}});Object.defineProperty(exports,"fromPull",{enumerable:true,get:function(){return chunkXPOARCND_cjs.b}});Object.defineProperty(exports,"managedStream",{enumerable:true,get:function(){return chunkXPOARCND_cjs.d}});Object.defineProperty(exports,"mapStream",{enumerable:true,get:function(){return chunkXPOARCND_cjs.m}});Object.defineProperty(exports,"merge",{enumerable:true,get:function(){return chunkXPOARCND_cjs.j}});Object.defineProperty(exports,"mergeStream",{enumerable:true,get:function(){return chunkXPOARCND_cjs.e}});Object.defineProperty(exports,"rangeStream",{enumerable:true,get:function(){return chunkXPOARCND_cjs.n}});Object.defineProperty(exports,"streamFromReadableStream",{enumerable:true,get:function(){return chunkXPOARCND_cjs.s}});Object.defineProperty(exports,"uncons",{enumerable:true,get:function(){return chunkXPOARCND_cjs.k}});Object.defineProperty(exports,"unwrapScoped",{enumerable:true,get:function(){return chunkXPOARCND_cjs.c}});Object.defineProperty(exports,"widenOpt",{enumerable:true,get:function(){return chunkXPOARCND_cjs.a}});Object.defineProperty(exports,"zip",{enumerable:true,get:function(){return chunkXPOARCND_cjs.o}});Object.defineProperty(exports,"Async",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.a}});Object.defineProperty(exports,"Cause",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.t}});Object.defineProperty(exports,"DefaultHostExecutor",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.Q}});Object.defineProperty(exports,"EngineFiberHandle",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.U}});Object.defineProperty(exports,"Exit",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.u}});Object.defineProperty(exports,"HostRegistry",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.S}});Object.defineProperty(exports,"JsFiberEngine",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.R}});Object.defineProperty(exports,"NoopHooks",{enumerable:true,get:function(){return chunkK47BP5A2_cjs._}});Object.defineProperty(exports,"ProgramBuilder",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.T}});Object.defineProperty(exports,"PushStatus",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.E}});Object.defineProperty(exports,"ReferenceWasmBridge",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.V}});Object.defineProperty(exports,"RingBuffer",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.F}});Object.defineProperty(exports,"Runtime",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.$}});Object.defineProperty(exports,"RuntimeFiber",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.M}});Object.defineProperty(exports,"Scheduler",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.I}});Object.defineProperty(exports,"Scope",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.fa}});Object.defineProperty(exports,"WasmFiberEngine",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.Y}});Object.defineProperty(exports,"WasmFiberRegistryBridge",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.X}});Object.defineProperty(exports,"WasmPackFiberBridge",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.W}});Object.defineProperty(exports,"acquireRelease",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.m}});Object.defineProperty(exports,"async",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.j}});Object.defineProperty(exports,"asyncCatchAll",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.c}});Object.defineProperty(exports,"asyncFail",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.g}});Object.defineProperty(exports,"asyncFlatMap",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.l}});Object.defineProperty(exports,"asyncFold",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.b}});Object.defineProperty(exports,"asyncInterruptible",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.n}});Object.defineProperty(exports,"asyncMap",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.k}});Object.defineProperty(exports,"asyncMapError",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.d}});Object.defineProperty(exports,"asyncSucceed",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.f}});Object.defineProperty(exports,"asyncSync",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.h}});Object.defineProperty(exports,"asyncTotal",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.i}});Object.defineProperty(exports,"catchAll",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.B}});Object.defineProperty(exports,"collectAllPar",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.ka}});Object.defineProperty(exports,"end",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.D}});Object.defineProperty(exports,"fail",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.w}});Object.defineProperty(exports,"flatMap",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.z}});Object.defineProperty(exports,"fork",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.aa}});Object.defineProperty(exports,"fromPromiseAbortable",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.da}});Object.defineProperty(exports,"getBenchmarkBudget",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.L}});Object.defineProperty(exports,"getCurrentFiber",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.N}});Object.defineProperty(exports,"globalScheduler",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.J}});Object.defineProperty(exports,"makeBoundedRingBuffer",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.H}});Object.defineProperty(exports,"map",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.y}});Object.defineProperty(exports,"mapAsync",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.p}});Object.defineProperty(exports,"mapError",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.A}});Object.defineProperty(exports,"mapTryAsync",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.q}});Object.defineProperty(exports,"none",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.r}});Object.defineProperty(exports,"orElseOptional",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.C}});Object.defineProperty(exports,"race",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.ia}});Object.defineProperty(exports,"raceWith",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.la}});Object.defineProperty(exports,"runtimeCapabilities",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.Z}});Object.defineProperty(exports,"setBenchmarkBudget",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.K}});Object.defineProperty(exports,"some",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.s}});Object.defineProperty(exports,"succeed",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.v}});Object.defineProperty(exports,"sync",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.x}});Object.defineProperty(exports,"toPromise",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.ca}});Object.defineProperty(exports,"unit",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.e}});Object.defineProperty(exports,"unsafeGetCurrentRuntime",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.O}});Object.defineProperty(exports,"unsafeRunAsync",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.ba}});Object.defineProperty(exports,"unsafeRunFoldWithEnv",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.ea}});Object.defineProperty(exports,"withAsyncPromise",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.o}});Object.defineProperty(exports,"withCurrentFiber",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.P}});Object.defineProperty(exports,"withScope",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.ha}});Object.defineProperty(exports,"withScopeAsync",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.ga}});Object.defineProperty(exports,"zipPar",{enumerable:true,get:function(){return chunkK47BP5A2_cjs.ja}});exports.andThen=te;exports.bounded=B;exports.broadcast=$n;exports.broadcastToHub=et;exports.buffer=q;exports.bufferP=Tt;exports.chunks=F;exports.chunksP=_t;exports.compose=bt;exports.dropP=Ot;exports.engineStats=It;exports.filterMapP=Zt;exports.filterP=Ct;exports.fromHub=nt;exports.groupedP=Ft;exports.identity=xt;exports.linkAbortController=An;exports.makeCancelToken=En;exports.makeHub=ee;exports.makeStreamChunker=ne;exports.mapChunks=pt;exports.mapChunksEffect=L;exports.mapChunksEffectP=Pt;exports.mapEffectP=re;exports.mapP=vt;exports.selectedEngineStats=Ht;exports.takeP=wt;exports.tapEffectP=Bt;exports.via=kt;
|