@adhd/dispatch-core-optimizer 0.1.6 → 0.1.7
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/CHANGELOG.md +10 -0
- package/index.js +3 -3
- package/index.mjs +147 -129
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 0.1.7 (2026-10-07)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **agent-core-provider:** merge provider representations into one registry + shared PartialBinding (d3f1f787 D-G(1)) ([eabd654c](https://github.com/PseudoSky/adhd/commit/eabd654c))
|
|
6
|
+
|
|
7
|
+
### ❤️ Thank You
|
|
8
|
+
|
|
9
|
+
- pseudosky
|
|
10
|
+
|
|
1
11
|
## 0.1.6 (2026-10-06)
|
|
2
12
|
|
|
3
13
|
### 🩹 Fixes
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=new Set([`create`,`modify-signature`,`modify-body`,`add-export`,`remove-export`,`rename`]),t=new Set([`pending`,`pending-surfaced`,`in_progress`,`complete`,`failed`,`skipped`,`awaiting_input`]),
|
|
2
|
-
`)}`)}var c={prose:5.5,md:5.5,ts:6.3,tsx:6.3,py:6.3,default:4};function l(e,t){if(e<=0)return 0;let n=c[t?t.split(`.`).pop()?.toLowerCase()??``:``]??c.default??4;return Math.ceil(e/n)}function u(e,t){if(e.length===0||t.fileSizes===void 0)return new Map;try{return t.fileSizes(e)}catch{return new Map}}var d={low:600,medium:1e3,high:2e3},f=e;function p(e){let t=e.properties??{};return Object.keys(t).length||Object.keys(e).length}function m(e,t){if(e.type===`tool-call`)return 0;let n=e.shape;if(n?.kind==null)return 0;let r=n.kind;return r===`function`||r===`interface`||r===`type`||r===`class`||r===`enum`||r===`const`||r===`script`?(`ops`in n&&Array.isArray(n.ops)?n.ops:[]).length*200:r===`config`||r===`env`||r===`schema`||r===`manifest`?(`ops`in n&&Array.isArray(n.ops)?n.ops:[]).length*100:r===`doc`?d[t??`medium`]??1e3:r===`structured-output`?p(`schema`in n&&n.schema?n.schema:{})*50:0}function h(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]),r={};for(let i of n)r[i]=e[i]??t[i]??null;return r}function g(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]),r={};for(let i of n){let n=e[i]??t[i];if(n===void 0)throw TypeError(`Model tier "${i}" not found in dag or deps context_window_per_tier`);r[i]=n}return r}function _(e){let t=Object.keys(e),n=new Map,r=new Map;for(let e of t)n.has(e)||n.set(e,0),r.has(e)||r.set(e,[]);for(let i of t){let t=e[i]?.depends_on??[];for(let e of t){let t=r.get(e);t!==void 0&&t.push(i),n.set(i,(n.get(i)??0)+1)}}let i=new Map,a=[],o=t.filter(e=>(n.get(e)??0)===0).sort();for(let e of o)i.set(e,0);for(;o.length>0;){let e=[];for(let t of o){a.push(t);let o=(r.get(t)??[]).slice().sort();for(let r of o){let a=(n.get(r)??0)-1;n.set(r,a);let o=i.get(t)??0,s=i.get(r)??0;i.set(r,Math.max(s,o+1)),a===0&&e.push(r)}}o=e.sort()}if(a.length!==t.length){let e=new Set(a),n=t.filter(t=>!e.has(t));throw Error(`snapshot(): cycle detected in milestone depends_on graph. Nodes involved: [${n.join(`, `)}]`)}return{order:a,waves:i}}function v(e,t){if(t.length===0)return[];let n=new Set(t);return e.filter(e=>e.operations.some(e=>n.has(e)))}function y(e,t){return e.filter(e=>e.operations.includes(t))}function b(e,t,n,r,i){let a=`${e}.guard`,o=[...n,a],s=v(r,o);for(let e of s)for(let t of e.results)if(t.op_id===a&&t.guard_result===`pass`)return`complete`;for(let e of s)if(e.suspension)return`awaiting_input`;for(let e of s)for(let t of e.results)if(o.includes(t.op_id)&&t.status===`failed`)return`failed`;for(let e of s)for(let t of e.results)if(o.includes(t.op_id)&&t.status===`in_progress`)return`in_progress`;let c=i.length===0||i.every(e=>e===`complete`);return t.pending!==null&&c?`pending-surfaced`:`pending`}function x(e,t){let n=`${e}.guard`,r=null,i=null,a=null;for(let e of t)if(e.operations.includes(n))for(let t of e.results)t.op_id===n&&t.guard_result!==null&&(r=t.guard_result,i=t.guard_output,t.guard_result===`pass`&&(a=t.guard_ran_at));return r===null?{guard_result:`pending`,guard_output:null,completed_at:null}:{guard_result:r,guard_output:i,completed_at:a}}function S(e){let t=new Set;for(let n of e)n.action===`move`&&n.to_file?t.add(n.to_file):f.has(n.action)&&n.file&&t.add(n.file);return Array.from(t)}function C(e,t,n){let r=y(n,e.id),i=r.map(e=>e.id),a=null,o=null,s=null;for(let t of r)for(let n of t.results)n.op_id===e.id&&n.guard_result!==null&&(a=n.guard_result,o=n.guard_output,s=n.guard_ran_at);let c=e.ki_estimate!==null&&e.ki_estimate!==void 0?e.ki_estimate:m(e,t),l=w(e.shape);return{...e,ki_estimate:c,shape:l,dispatch_ids:i,attempt_count:0,guard_result:a,guard_output:o,guard_ran_at:s,blast_radius:[],conflict:{detected:!1,competing_op:null,op_key:null,resolution:null},tokens_actual:null}}function w(e){if(!e)return null;if(e.kind===null)return e;let t=e.kind;if(t===`function`||t===`interface`||t===`type`||t===`class`||t===`enum`||t===`const`||t===`script`||t===`config`||t===`env`||t===`schema`||t===`manifest`){let t=(`ops`in e&&Array.isArray(e.ops)?e.ops:[]).map(e=>({...e,from:null,breaking:null,severity:null}));return{...e,ops:t}}return e}function T(e,t,n,r){let i=`${e}.guard`,a=y(r,i),o=a.map(e=>e.id),s=null,c=null,l=null;for(let e of a)for(let t of e.results)t.op_id===i&&t.guard_result!==null&&(s=t.guard_result,c=t.guard_output,l=t.guard_ran_at);return{id:i,milestone:e,depends_on:n,type:`tool-call`,action:`guard`,file:null,symbol:null,provenance:null,confidence:null,audit_check:null,criteria:[],tool:null,args:null,guard:t.guard??null,to_file:null,to_symbol:null,ki_estimate:0,ki_source:null,authored_by:`synthesized`,status:`pending`,shape:null,dispatch_ids:o,attempt_count:0,guard_result:s,guard_output:c,guard_ran_at:l,blast_radius:[],conflict:{detected:!1,competing_op:null,op_key:null,resolution:null},tokens_actual:null}}function E(e,t){let n={},{write_multiplier:r,read_multiplier:i,hit_probability:a}=t;for(let[t,o]of Object.entries(e))n[t]=o===null?null:Math.round(o*((1-a)*r+a*i));return n}function D(e,t,n){let r=Array.from(e.keys()),i={};for(let a=0;a<r.length;a++)for(let o=a+1;o<r.length;o++){let s=r[a],c=r[o];if(s===void 0||c===void 0)continue;let[l,u]=s<c?[s,c]:[c,s],d=`${l}:${u}`,f=e.get(s)??[],p=e.get(c)??[],m=new Set(f.map(e=>e.file).filter(e=>e!==null)),h=new Set(p.map(e=>e.file).filter(e=>e!==null)),g=Array.from(m).filter(e=>h.has(e));if(g.length===0)continue;let _=t.get(s)??`pending`,v=t.get(c)??`pending`,y=_===`complete`&&v===`complete`,b=0;for(let e of g)b+=y?n(e):0;i[d]=b}return i}function O(e){return(Array.isArray(e)?e:Object.values(e)).map(e=>e.type===void 0?{...e,type:`generative`}:e)}function k(e,t){let n=new Date().toISOString(),r=t.dispatchLog??e.dispatch_log,i=e.optimization.sentinel_fanout,a=h(e.optimization.b_per_tier,t.bPerTier),o=g(e.optimization.context_window_per_tier,t.contextWindowPerTier),c=E(a,i),{waves:d}=_(e.milestones),f=O(e.operations),p=new Map;for(let e of f){let t=p.get(e.milestone)??[];t.push(e),p.set(e.milestone,t)}let m=new Set;for(let e of f)e.file&&m.add(e.file),e.action===`move`&&e.to_file&&m.add(e.to_file);let y=u(Array.from(m),t),w=e=>y.get(e)??0,k=new Map,j=Array.from(d.entries()).sort((e,t)=>e[1]-t[1]||e[0].localeCompare(t[0])).map(([e])=>e);for(let t of j){let n=e.milestones[t];if(n===void 0)continue;let i=b(t,n,(p.get(t)??[]).map(e=>e.id),r,n.depends_on.map(e=>k.get(e)??`pending`));k.set(t,i)}let M={},N=[];for(let t of j){let n=e.milestones[t];if(n===void 0)continue;let i=d.get(t)??0,a=p.get(t)??[],o=a.map(e=>e.id),s=k.get(t)??`pending`,u=n.depends_on.map(e=>k.get(e)??`pending`),f=n.depends_on.length===0||u.every(e=>e===`complete`),m=u.every(e=>e!==`failed`),h=n.pending===null&&f&&m&&s!==`complete`,g=v(r,[...o,`${t}.guard`]),_=g.length>0?g.map(e=>e.started_at).sort()[0]??null:null,y,b,E;if(n.guard){let e=x(t,r);y=e.guard_result,b=e.guard_output,E=e.completed_at}else y=null,b=null,E=null;let D=S(a),O=D.reduce((e,t)=>e+w(t),0),A=a.map(e=>C(e,n.effort,r)),j=null,P=0,F=!1;for(let e of A){if(e.ki_estimate===null){F=!0;break}P+=e.ki_estimate}F||(j=P);let I=null,L=n.model;if(L!==null&&j!==null){let e=c[L]??null;e!==null&&(I=e+l(O)+j)}let R=null,z=g.filter(e=>e.completed_at!==null&&e.results.length>0&&e.results.every(e=>e.status===`complete`||e.status===`skipped`));z.length>0&&(R=z.reduce((e,t)=>e+t.turns.reduce((e,t)=>e+t.input_tokens+t.output_tokens,0),0));let B=T(t,n,o,r);N.push(...A,B),M[t]={description:n.description,...n.rationale===void 0?{}:{rationale:n.rationale},authored_by:n.authored_by,pending:n.pending,triggered_by:n.triggered_by,phase:n.phase,depends_on:n.depends_on,agent:n.agent,model:n.model,effort:n.effort,two_stage:n.two_stage,read_only:n.read_only,guard:n.guard,context:`contexts/${t}.md`,wave:i,eligible:h,status:s,started_at:_,completed_at:E,guard_result:y,guard_output:b,artifacts:D,si_bytes:O,ki_estimate:j,tokens_estimated:I,tokens_actual:R}}let P=D(p,k,w),F=A(e,M),I={tokens_naive:(()=>{let e=0;for(let n of Object.values(M))if(n.eligible&&n.status===`pending`&&n.model!==null){let r=a[n.model]??t.bPerTier[n.model]??0;e+=r+(n.ki_estimate??0)}return e})(),sentinel_fanout:i,context_window_override:e.optimization.context_window_override,b_override:e.optimization.b_override,b_per_tier:a,b_eff_per_tier:c,context_window_per_tier:o},L={snapshot_at:n,snapshot_version:1,plan:``,schema_version:e.schema_version,plan_kind:e.plan_kind,description:e.description,problem:e.problem,approach:e.approach,executor:e.executor,...e.executor_model===void 0?{}:{executor_model:e.executor_model},...e.executor_effort===void 0?{}:{executor_effort:e.executor_effort},phases:[...e.phases],terminal:e.terminal,...e.assumed_baseline===void 0?{}:{assumed_baseline:e.assumed_baseline},optimization:I,milestones:M,operations:N,pairwise_overlap:P,open_questions:F};return s(L),L}function A(e,t){let n=[];for(let[r,i]of Object.entries(t)){let t=e.milestones[r];if(t?.pending==null)continue;let a=i.status===`pending-surfaced`;n.push({id:`q:${r}`,text:t.pending,blocking:r,surfaced:a,raised_at_dispatch:null,raised_at_turn:null,answered:!1,answer:null})}return n}var j=`You are a dispatch-orchestrator worker agent executing one or more milestones from a dependency-DAG build plan. Each task turn gives you the full compiled instructions for this dispatch: milestone description, the operations to perform, and the guard command that defines done. Execute the operations precisely and produce real output (code, docs, or config) — never a plan or a summary in place of the work.`;function M(e){return Object.keys(e.milestones).filter(t=>{let n=e.milestones[t];return n?.eligible===!0&&n.status===`pending`})}function N(e){if(e.length===0||e.every(e=>e.type===`tool-call`))return`tool-call`;for(let t of e){if(t.type!==`generative`||t.shape?.kind==null)continue;let e=t.shape.kind;if(e===`function`||e===`interface`||e===`type`||e===`class`||e===`enum`||e===`const`||e===`script`||e===`config`||e===`env`||e===`schema`||e===`manifest`)return`code-config`;if(e===`doc`)return`doc`;if(e===`structured-output`)return`structured`}return`code-config`}function P(e){if(!e)return``;let t=e.indexOf(`:`);return t>=0?e.slice(t+1):e}function F(e,t,n){let r=!0,i=[];for(let a of e){let e=t[a];if(e===void 0)continue;let o=n.filter(e=>e.milestone===a&&e.action!==`guard`);o.some(e=>e.type===`generative`)&&(r=!1),i.push(`## Milestone: ${a}`),i.push(e.description),e.rationale&&i.push(`\n*Rationale:* ${e.rationale}`),i.push(`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=new Set([`create`,`modify-signature`,`modify-body`,`add-export`,`remove-export`,`rename`]),t=Object.freeze({"file-ops":[[`Read`,`ViewFile`],[`Write`,`WriteFile`,`Edit`,`EditFile`]],research:[[`WebSearch`,`FetchURL`,`WebFetch`]],execution:[[`Bash`]],backlog:[[`mcp__backlog__*`]]});Object.freeze(Object.keys(t));var n=new Set([`pending`,`pending-surfaced`,`in_progress`,`complete`,`failed`,`skipped`,`awaiting_input`]),r=new Set([`pending`,`in_progress`,`complete`,`failed`,`skipped`]);function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){return typeof e==`string`}function o(e,t,n){return{path:e,message:t,value:n}}function s(e){let t=[];if(!i(e))return{valid:!1,errors:[o(``,`root must be an object`)]};for(let n of[`snapshot_at`,`description`])a(e[n])||t.push(o(n,`required string field missing`,e[n]));a(e.plan)||t.push(o(`plan`,`required string`,e.plan));let s=e.milestones;if(!i(s))t.push(o(`milestones`,`must be an object`,s));else{let c=Object.keys(s),l=new Set(c);for(let e of c){let r=s[e];if(!i(r)){t.push(o(`milestones.${e}`,`must be an object`,r));continue}let c=r.eligible,l=r.pending;c===!0&&l!=null&&t.push(o(`milestones.${e}`,`D-07 violation: eligible=true but pending not null`)),typeof c!=`boolean`&&t.push(o(`milestones.${e}.eligible`,`must be boolean`,c));let u=r.status;(!a(u)||!n.has(u))&&t.push(o(`milestones.${e}.status`,`invalid status`,u)),c===!0&&u===`complete`&&t.push(o(`milestones.${e}`,`D-07 violation: eligible=true but status is complete`));let d=r.wave;(typeof d!=`number`||!Number.isInteger(d)||d<0)&&t.push(o(`milestones.${e}.wave`,`must be non-negative integer`,d));let f=r.ki_estimate;f!=null&&typeof f!=`number`&&t.push(o(`milestones.${e}.ki_estimate`,`must be number|null`,f));for(let n of[`tokens_estimated`,`tokens_actual`]){let i=r[n];i!=null&&typeof i!=`number`&&t.push(o(`milestones.${e}.${n}`,`must be number|null`,i))}Array.isArray(r.artifacts)||t.push(o(`milestones.${e}.artifacts`,`must be an array`,r.artifacts)),typeof r.si_bytes!=`number`&&t.push(o(`milestones.${e}.si_bytes`,`must be a number`,r.si_bytes))}let u=e.operations;if(!Array.isArray(u))t.push(o(`operations`,`must be an array`,u));else for(let e of u){if(!i(e))continue;let n=a(e.id)?e.id:`?`,s=e.milestone;a(s)&&!l.has(s)&&t.push(o(`operations[${n}].milestone`,`unknown milestone "${s}"`));let c=e.status;(!a(c)||!r.has(c))&&t.push(o(`operations[${n}].status`,`invalid operation status`,c)),Array.isArray(e.dispatch_ids)||t.push(o(`operations[${n}].dispatch_ids`,`must be an array`,e.dispatch_ids)),typeof e.attempt_count!=`number`&&t.push(o(`operations[${n}].attempt_count`,`must be a number`,e.attempt_count)),Array.isArray(e.blast_radius)||t.push(o(`operations[${n}].blast_radius`,`must be an array`,e.blast_radius))}let d=e.open_questions;if(!Array.isArray(d))t.push(o(`open_questions`,`must be an array`,d));else for(let e of d){if(!i(e))continue;let n=e.blocking;(!a(n)||!l.has(n))&&t.push(o(`open_questions`,`unknown blocking milestone "${n}"`)),typeof e.surfaced!=`boolean`&&t.push(o(`open_questions[${e.id}]`,`surfaced must be boolean`,e.surfaced)),typeof e.answered!=`boolean`&&t.push(o(`open_questions[${e.id}]`,`answered must be boolean`,e.answered))}let f=e.dispatch_units;if(f!==void 0){if(!Array.isArray(f))t.push(o(`dispatch_units`,`must be an array if present`,f));else for(let e of f){if(!i(e))continue;let n=e.fits_context_window;typeof n!=`boolean`&&t.push(o(`dispatch_units[${e.id}]`,`fits_context_window must be boolean`,n));let r=e.milestones;if(Array.isArray(r))for(let n of r)a(n)&&!l.has(n)&&t.push(o(`dispatch_units[${e.id}].milestones`,`unknown milestone "${n}"`))}}i(e.pairwise_overlap)||t.push(o(`pairwise_overlap`,`must be an object`,e.pairwise_overlap))}return{valid:t.length===0,errors:t}}function c(e){let t=s(e);if(!t.valid)throw Error(`Snapshot validation failed:\n${t.errors.map(e=>` ${e.path}: ${e.message}`).join(`
|
|
2
|
+
`)}`)}var l={prose:5.5,md:5.5,ts:6.3,tsx:6.3,py:6.3,default:4};function u(e,t){if(e<=0)return 0;let n=l[t?t.split(`.`).pop()?.toLowerCase()??``:``]??l.default??4;return Math.ceil(e/n)}function d(e,t){if(e.length===0||t.fileSizes===void 0)return new Map;try{return t.fileSizes(e)}catch{return new Map}}var f={low:600,medium:1e3,high:2e3},p=e;function m(e){let t=e.properties??{};return Object.keys(t).length||Object.keys(e).length}function h(e,t){if(e.type===`tool-call`)return 0;let n=e.shape;if(n?.kind==null)return 0;let r=n.kind;return r===`function`||r===`interface`||r===`type`||r===`class`||r===`enum`||r===`const`||r===`script`?(`ops`in n&&Array.isArray(n.ops)?n.ops:[]).length*200:r===`config`||r===`env`||r===`schema`||r===`manifest`?(`ops`in n&&Array.isArray(n.ops)?n.ops:[]).length*100:r===`doc`?f[t??`medium`]??1e3:r===`structured-output`?m(`schema`in n&&n.schema?n.schema:{})*50:0}function g(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]),r={};for(let i of n)r[i]=e[i]??t[i]??null;return r}function _(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]),r={};for(let i of n){let n=e[i]??t[i];if(n===void 0)throw TypeError(`Model tier "${i}" not found in dag or deps context_window_per_tier`);r[i]=n}return r}function v(e){let t=Object.keys(e),n=new Map,r=new Map;for(let e of t)n.has(e)||n.set(e,0),r.has(e)||r.set(e,[]);for(let i of t){let t=e[i]?.depends_on??[];for(let e of t){let t=r.get(e);t!==void 0&&t.push(i),n.set(i,(n.get(i)??0)+1)}}let i=new Map,a=[],o=t.filter(e=>(n.get(e)??0)===0).sort();for(let e of o)i.set(e,0);for(;o.length>0;){let e=[];for(let t of o){a.push(t);let o=(r.get(t)??[]).slice().sort();for(let r of o){let a=(n.get(r)??0)-1;n.set(r,a);let o=i.get(t)??0,s=i.get(r)??0;i.set(r,Math.max(s,o+1)),a===0&&e.push(r)}}o=e.sort()}if(a.length!==t.length){let e=new Set(a),n=t.filter(t=>!e.has(t));throw Error(`snapshot(): cycle detected in milestone depends_on graph. Nodes involved: [${n.join(`, `)}]`)}return{order:a,waves:i}}function y(e,t){if(t.length===0)return[];let n=new Set(t);return e.filter(e=>e.operations.some(e=>n.has(e)))}function b(e,t){return e.filter(e=>e.operations.includes(t))}function x(e,t,n,r,i){let a=`${e}.guard`,o=[...n,a],s=y(r,o);for(let e of s)for(let t of e.results)if(t.op_id===a&&t.guard_result===`pass`)return`complete`;for(let e of s)if(e.suspension)return`awaiting_input`;for(let e of s)for(let t of e.results)if(o.includes(t.op_id)&&t.status===`failed`)return`failed`;for(let e of s)for(let t of e.results)if(o.includes(t.op_id)&&t.status===`in_progress`)return`in_progress`;let c=i.length===0||i.every(e=>e===`complete`);return t.pending!==null&&c?`pending-surfaced`:`pending`}function S(e,t){let n=`${e}.guard`,r=null,i=null,a=null;for(let e of t)if(e.operations.includes(n))for(let t of e.results)t.op_id===n&&t.guard_result!==null&&(r=t.guard_result,i=t.guard_output,t.guard_result===`pass`&&(a=t.guard_ran_at));return r===null?{guard_result:`pending`,guard_output:null,completed_at:null}:{guard_result:r,guard_output:i,completed_at:a}}function C(e){let t=new Set;for(let n of e)n.action===`move`&&n.to_file?t.add(n.to_file):p.has(n.action)&&n.file&&t.add(n.file);return Array.from(t)}function w(e,t,n){let r=b(n,e.id),i=r.map(e=>e.id),a=null,o=null,s=null;for(let t of r)for(let n of t.results)n.op_id===e.id&&n.guard_result!==null&&(a=n.guard_result,o=n.guard_output,s=n.guard_ran_at);let c=e.ki_estimate!==null&&e.ki_estimate!==void 0?e.ki_estimate:h(e,t),l=T(e.shape);return{...e,ki_estimate:c,shape:l,dispatch_ids:i,attempt_count:0,guard_result:a,guard_output:o,guard_ran_at:s,blast_radius:[],conflict:{detected:!1,competing_op:null,op_key:null,resolution:null},tokens_actual:null}}function T(e){if(!e)return null;if(e.kind===null)return e;let t=e.kind;if(t===`function`||t===`interface`||t===`type`||t===`class`||t===`enum`||t===`const`||t===`script`||t===`config`||t===`env`||t===`schema`||t===`manifest`){let t=(`ops`in e&&Array.isArray(e.ops)?e.ops:[]).map(e=>({...e,from:null,breaking:null,severity:null}));return{...e,ops:t}}return e}function E(e,t,n,r){let i=`${e}.guard`,a=b(r,i),o=a.map(e=>e.id),s=null,c=null,l=null;for(let e of a)for(let t of e.results)t.op_id===i&&t.guard_result!==null&&(s=t.guard_result,c=t.guard_output,l=t.guard_ran_at);return{id:i,milestone:e,depends_on:n,type:`tool-call`,action:`guard`,file:null,symbol:null,provenance:null,confidence:null,audit_check:null,criteria:[],tool:null,args:null,guard:t.guard??null,to_file:null,to_symbol:null,ki_estimate:0,ki_source:null,authored_by:`synthesized`,status:`pending`,shape:null,dispatch_ids:o,attempt_count:0,guard_result:s,guard_output:c,guard_ran_at:l,blast_radius:[],conflict:{detected:!1,competing_op:null,op_key:null,resolution:null},tokens_actual:null}}function D(e,t){let n={},{write_multiplier:r,read_multiplier:i,hit_probability:a}=t;for(let[t,o]of Object.entries(e))n[t]=o===null?null:Math.round(o*((1-a)*r+a*i));return n}function O(e,t,n){let r=Array.from(e.keys()),i={};for(let a=0;a<r.length;a++)for(let o=a+1;o<r.length;o++){let s=r[a],c=r[o];if(s===void 0||c===void 0)continue;let[l,u]=s<c?[s,c]:[c,s],d=`${l}:${u}`,f=e.get(s)??[],p=e.get(c)??[],m=new Set(f.map(e=>e.file).filter(e=>e!==null)),h=new Set(p.map(e=>e.file).filter(e=>e!==null)),g=Array.from(m).filter(e=>h.has(e));if(g.length===0)continue;let _=t.get(s)??`pending`,v=t.get(c)??`pending`,y=_===`complete`&&v===`complete`,b=0;for(let e of g)b+=y?n(e):0;i[d]=b}return i}function k(e){return(Array.isArray(e)?e:Object.values(e)).map(e=>e.type===void 0?{...e,type:`generative`}:e)}function A(e,t){let n=new Date().toISOString(),r=t.dispatchLog??e.dispatch_log,i=e.optimization.sentinel_fanout,a=g(e.optimization.b_per_tier,t.bPerTier),o=_(e.optimization.context_window_per_tier,t.contextWindowPerTier),s=D(a,i),{waves:l}=v(e.milestones),f=k(e.operations),p=new Map;for(let e of f){let t=p.get(e.milestone)??[];t.push(e),p.set(e.milestone,t)}let m=new Set;for(let e of f)e.file&&m.add(e.file),e.action===`move`&&e.to_file&&m.add(e.to_file);let h=d(Array.from(m),t),b=e=>h.get(e)??0,T=new Map,A=Array.from(l.entries()).sort((e,t)=>e[1]-t[1]||e[0].localeCompare(t[0])).map(([e])=>e);for(let t of A){let n=e.milestones[t];if(n===void 0)continue;let i=x(t,n,(p.get(t)??[]).map(e=>e.id),r,n.depends_on.map(e=>T.get(e)??`pending`));T.set(t,i)}let M={},N=[];for(let t of A){let n=e.milestones[t];if(n===void 0)continue;let i=l.get(t)??0,a=p.get(t)??[],o=a.map(e=>e.id),c=T.get(t)??`pending`,d=n.depends_on.map(e=>T.get(e)??`pending`),f=n.depends_on.length===0||d.every(e=>e===`complete`),m=d.every(e=>e!==`failed`),h=n.pending===null&&f&&m&&c!==`complete`,g=y(r,[...o,`${t}.guard`]),_=g.length>0?g.map(e=>e.started_at).sort()[0]??null:null,v,x,D;if(n.guard){let e=S(t,r);v=e.guard_result,x=e.guard_output,D=e.completed_at}else v=null,x=null,D=null;let O=C(a),k=O.reduce((e,t)=>e+b(t),0),A=a.map(e=>w(e,n.effort,r)),j=null,P=0,F=!1;for(let e of A){if(e.ki_estimate===null){F=!0;break}P+=e.ki_estimate}F||(j=P);let I=null,L=n.model;if(L!==null&&j!==null){let e=s[L]??null;e!==null&&(I=e+u(k)+j)}let R=null,z=g.filter(e=>e.completed_at!==null&&e.results.length>0&&e.results.every(e=>e.status===`complete`||e.status===`skipped`));z.length>0&&(R=z.reduce((e,t)=>e+t.turns.reduce((e,t)=>e+t.input_tokens+t.output_tokens,0),0));let B=E(t,n,o,r);N.push(...A,B),M[t]={description:n.description,...n.rationale===void 0?{}:{rationale:n.rationale},authored_by:n.authored_by,pending:n.pending,triggered_by:n.triggered_by,phase:n.phase,depends_on:n.depends_on,agent:n.agent,model:n.model,effort:n.effort,two_stage:n.two_stage,read_only:n.read_only,guard:n.guard,context:`contexts/${t}.md`,wave:i,eligible:h,status:c,started_at:_,completed_at:D,guard_result:v,guard_output:x,artifacts:O,si_bytes:k,ki_estimate:j,tokens_estimated:I,tokens_actual:R}}let P=O(p,T,b),F=j(e,M),I={tokens_naive:(()=>{let e=0;for(let n of Object.values(M))if(n.eligible&&n.status===`pending`&&n.model!==null){let r=a[n.model]??t.bPerTier[n.model]??0;e+=r+(n.ki_estimate??0)}return e})(),sentinel_fanout:i,context_window_override:e.optimization.context_window_override,b_override:e.optimization.b_override,b_per_tier:a,b_eff_per_tier:s,context_window_per_tier:o},L={snapshot_at:n,snapshot_version:1,plan:``,schema_version:e.schema_version,plan_kind:e.plan_kind,description:e.description,problem:e.problem,approach:e.approach,executor:e.executor,...e.executor_model===void 0?{}:{executor_model:e.executor_model},...e.executor_effort===void 0?{}:{executor_effort:e.executor_effort},phases:[...e.phases],terminal:e.terminal,...e.assumed_baseline===void 0?{}:{assumed_baseline:e.assumed_baseline},optimization:I,milestones:M,operations:N,pairwise_overlap:P,open_questions:F};return c(L),L}function j(e,t){let n=[];for(let[r,i]of Object.entries(t)){let t=e.milestones[r];if(t?.pending==null)continue;let a=i.status===`pending-surfaced`;n.push({id:`q:${r}`,text:t.pending,blocking:r,surfaced:a,raised_at_dispatch:null,raised_at_turn:null,answered:!1,answer:null})}return n}var M=`You are a dispatch-orchestrator worker agent executing one or more milestones from a dependency-DAG build plan. Each task turn gives you the full compiled instructions for this dispatch: milestone description, the operations to perform, and the guard command that defines done. Execute the operations precisely and produce real output (code, docs, or config) — never a plan or a summary in place of the work.`;function N(e){return Object.keys(e.milestones).filter(t=>{let n=e.milestones[t];return n?.eligible===!0&&n.status===`pending`})}function P(e){if(e.length===0||e.every(e=>e.type===`tool-call`))return`tool-call`;for(let t of e){if(t.type!==`generative`||t.shape?.kind==null)continue;let e=t.shape.kind;if(e===`function`||e===`interface`||e===`type`||e===`class`||e===`enum`||e===`const`||e===`script`||e===`config`||e===`env`||e===`schema`||e===`manifest`)return`code-config`;if(e===`doc`)return`doc`;if(e===`structured-output`)return`structured`}return`code-config`}function F(e){if(!e)return``;let t=e.indexOf(`:`);return t>=0?e.slice(t+1):e}function I(e,t,n){let r=!0,i=[];for(let a of e){let e=t[a];if(e===void 0)continue;let o=n.filter(e=>e.milestone===a&&e.action!==`guard`);o.some(e=>e.type===`generative`)&&(r=!1),i.push(`## Milestone: ${a}`),i.push(e.description),e.rationale&&i.push(`\n*Rationale:* ${e.rationale}`),i.push(`
|
|
3
3
|
### Operations:`);for(let e of o){let t=e.file?` ${e.file}`:``,n=e.symbol?` (${e.symbol})`:``;if(i.push(`- [${e.id}] ${e.action}${t}${n}`),e.shape&&e.shape.kind!==null){let t=e.shape;if(t.kind===`doc`)i.push(` Description: ${t.description}`),i.push(` Objective: ${t.objective}`),t.required_sections&&t.required_sections.length>0&&i.push(` Required sections: ${t.required_sections.join(`, `)}`);else if(t.kind===`structured-output`)i.push(` Schema:
|
|
4
4
|
`+JSON.stringify(t.schema,null,2).split(`
|
|
5
5
|
`).map(e=>` ${e}`).join(`
|
|
6
6
|
`));else if(`ops`in t&&Array.isArray(t.ops))for(let e of t.ops){let t=e.to===null?``:` → ${e.to}`,n=e.target===null?``:` "${e.target}"`;if(i.push(` - ${e.op}${n}${t}`),e.type_spec)for(let[t,n]of Object.entries(e.type_spec))i.push(` - ${t}: ${n}`)}}}let s=e.guard;i.push(`\n### Guard: ${s??`none`}`),i.push(``)}return r?null:i.join(`
|
|
7
|
-
`)}function
|
|
7
|
+
`)}function L(e,t,n){if(e===null)return null;let r=t.optimization.b_eff_per_tier[e];if(r!=null)return r;let i=t.optimization.b_per_tier[e];if(i!=null)return i;let a=n.bPerTier[e];return a===void 0?null:a}function R(e,t,n){if(e===null)return 1/0;let r=t.optimization.context_window_per_tier[e];if(r!==void 0)return r;let i=n.contextWindowPerTier[e];return i===void 0?1/0:i}function z(e,t){let n=new Set;for(let r of e){let e=t.snapshot.milestones[r];if(e!==void 0){n.add(e.context);for(let t of e.read_only)n.add(t);for(let e of t.opsByMilestone.get(r)??[])e.file&&n.add(e.file)}}return Array.from(n)}function B(e,t,n){let r=L(t,n.snapshot,n.deps);if(r===null)return null;let i=u(z(e,n).reduce((e,t)=>e+(n.sizeMap.get(t)??0),0)),a=e.reduce((e,t)=>e+(n.snapshot.milestones[t]?.ki_estimate??0),0);return r+i+a}function V(e,t,n){let r=R(t,n.snapshot,n.deps),i=[...e].sort((e,t)=>(n.snapshot.milestones[e]?.ki_estimate??0)-(n.snapshot.milestones[t]?.ki_estimate??0)||e.localeCompare(t)),a=[],o=[];for(let e of i){let i=[...o,e],s=B(i,t,n);s!==null&&s>r&&o.length>0?(a.push(o),o=[e]):o=i}return o.length>0&&a.push(o),a.filter(e=>{let i=B(e,t,n);return i===null||i<=r})}function H(e,t,n,r){let i=e[0]??``,a=r.snapshot.milestones[i],o=a?.effort??null,s=[];for(let t of e)for(let e of r.opsByMilestone.get(t)??[])s.push(e.id);let c=z(e,r),l=c.reduce((e,t)=>e+(r.sizeMap.get(t)??0),0),d=L(n,r.snapshot,r.deps),f=e.reduce((e,t)=>e+(r.snapshot.milestones[t]?.ki_estimate??0),0),p=d===null?null:d+u(l)+f,m=R(n,r.snapshot,r.deps),h=p===null||p<=m,g=F(a?.agent??null),_=I(e,r.snapshot.milestones,r.snapshot.operations),v=_===null?`guard-only`:`model-dispatch`,y=_===null?null:M;return{id:`${i}.dispatch.${t}`,milestones:e,operations:s,model:n,effort:o,two_stage:a?.two_stage??!1,provider:null,agent_name:g,execution_mode:v,mcp_servers:null,resolved_max_tokens:null,background:!0,systemPrompt:y,prompt:_,context_files:c,si_bytes:l,tokens_estimated:p,fits_context_window:h,sentinel_role:null,dispatch_log_id:null,remote_task_id:null,result:null,status:`pending`,started_at:null,completed_at:null,tokens_actual:null}}function U(e,t){let n=N(e);if(n.length===0)return[];let r=new Map;for(let t of e.operations){if(t.action===`guard`)continue;let e=r.get(t.milestone)??[];e.push(t),r.set(t.milestone,e)}let i=new Map;for(let t of n){let n=e.milestones[t];if(n===void 0)continue;let a=`${P(r.get(t)??[])}:${n.model??`_null`}`,o=i.get(a)??[];o.push(t),i.set(a,o)}let a=new Set;for(let t of n){let n=e.milestones[t];if(n!==void 0){a.add(n.context);for(let e of n.read_only)a.add(e);for(let e of r.get(t)??[])e.file&&a.add(e.file)}}let o={snapshot:e,deps:t,sizeMap:d(Array.from(a),t),opsByMilestone:r},s=[],c=0,l=Array.from(i.keys()).sort();for(let e of l){let t=i.get(e);if(t===void 0)continue;let n=e.slice(e.indexOf(`:`)+1),r=n===`_null`?null:n,a=V(t,r,o);for(let e of a)s.push(H(e,c++,r,o))}return s}function W(e,t){let n=0;for(let r of N(e)){let i=e.milestones[r];if(i===void 0)continue;let a=G(i.model,e,t)??0;n+=a+(i.ki_estimate??0)}return n}function G(e,t,n){if(e===null)return null;let r=t.optimization.b_per_tier[e];if(r!=null)return r;let i=n.bPerTier[e];return i===void 0?null:i}exports.computeTokensNaive=W,exports.optimize=U,exports.snapshot=A,exports.topoSortMilestones=v;
|
package/index.mjs
CHANGED
|
@@ -6,7 +6,25 @@ var e = /* @__PURE__ */ new Set([
|
|
|
6
6
|
"add-export",
|
|
7
7
|
"remove-export",
|
|
8
8
|
"rename"
|
|
9
|
-
]), t =
|
|
9
|
+
]), t = Object.freeze({
|
|
10
|
+
"file-ops": [["Read", "ViewFile"], [
|
|
11
|
+
"Write",
|
|
12
|
+
"WriteFile",
|
|
13
|
+
"Edit",
|
|
14
|
+
"EditFile"
|
|
15
|
+
]],
|
|
16
|
+
research: [[
|
|
17
|
+
"WebSearch",
|
|
18
|
+
"FetchURL",
|
|
19
|
+
"WebFetch"
|
|
20
|
+
]],
|
|
21
|
+
execution: [["Bash"]],
|
|
22
|
+
backlog: [["mcp__backlog__*"]]
|
|
23
|
+
});
|
|
24
|
+
Object.freeze(Object.keys(t));
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region ../dispatch-base-spec/src/lib/validate.ts
|
|
27
|
+
var n = /* @__PURE__ */ new Set([
|
|
10
28
|
"pending",
|
|
11
29
|
"pending-surfaced",
|
|
12
30
|
"in_progress",
|
|
@@ -14,99 +32,99 @@ var e = /* @__PURE__ */ new Set([
|
|
|
14
32
|
"failed",
|
|
15
33
|
"skipped",
|
|
16
34
|
"awaiting_input"
|
|
17
|
-
]),
|
|
35
|
+
]), r = /* @__PURE__ */ new Set([
|
|
18
36
|
"pending",
|
|
19
37
|
"in_progress",
|
|
20
38
|
"complete",
|
|
21
39
|
"failed",
|
|
22
40
|
"skipped"
|
|
23
41
|
]);
|
|
24
|
-
function
|
|
42
|
+
function i(e) {
|
|
25
43
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
26
44
|
}
|
|
27
|
-
function
|
|
45
|
+
function a(e) {
|
|
28
46
|
return typeof e == "string";
|
|
29
47
|
}
|
|
30
|
-
function
|
|
48
|
+
function o(e, t, n) {
|
|
31
49
|
return {
|
|
32
50
|
path: e,
|
|
33
51
|
message: t,
|
|
34
52
|
value: n
|
|
35
53
|
};
|
|
36
54
|
}
|
|
37
|
-
function
|
|
38
|
-
let
|
|
39
|
-
if (!
|
|
55
|
+
function s(e) {
|
|
56
|
+
let t = [];
|
|
57
|
+
if (!i(e)) return {
|
|
40
58
|
valid: !1,
|
|
41
|
-
errors: [
|
|
59
|
+
errors: [o("", "root must be an object")]
|
|
42
60
|
};
|
|
43
|
-
for (let
|
|
44
|
-
|
|
61
|
+
for (let n of ["snapshot_at", "description"]) a(e[n]) || t.push(o(n, "required string field missing", e[n]));
|
|
62
|
+
a(e.plan) || t.push(o("plan", "required string", e.plan));
|
|
45
63
|
let s = e.milestones;
|
|
46
|
-
if (!
|
|
64
|
+
if (!i(s)) t.push(o("milestones", "must be an object", s));
|
|
47
65
|
else {
|
|
48
66
|
let c = Object.keys(s), l = new Set(c);
|
|
49
67
|
for (let e of c) {
|
|
50
|
-
let
|
|
51
|
-
if (!r
|
|
52
|
-
|
|
68
|
+
let r = s[e];
|
|
69
|
+
if (!i(r)) {
|
|
70
|
+
t.push(o(`milestones.${e}`, "must be an object", r));
|
|
53
71
|
continue;
|
|
54
72
|
}
|
|
55
|
-
let c =
|
|
56
|
-
c === !0 && l != null &&
|
|
57
|
-
let u =
|
|
58
|
-
(!
|
|
59
|
-
let d =
|
|
60
|
-
(typeof d != "number" || !Number.isInteger(d) || d < 0) &&
|
|
61
|
-
let f =
|
|
62
|
-
f != null && typeof f != "number" &&
|
|
63
|
-
for (let
|
|
64
|
-
let
|
|
65
|
-
|
|
73
|
+
let c = r.eligible, l = r.pending;
|
|
74
|
+
c === !0 && l != null && t.push(o(`milestones.${e}`, "D-07 violation: eligible=true but pending not null")), typeof c != "boolean" && t.push(o(`milestones.${e}.eligible`, "must be boolean", c));
|
|
75
|
+
let u = r.status;
|
|
76
|
+
(!a(u) || !n.has(u)) && t.push(o(`milestones.${e}.status`, "invalid status", u)), c === !0 && u === "complete" && t.push(o(`milestones.${e}`, "D-07 violation: eligible=true but status is complete"));
|
|
77
|
+
let d = r.wave;
|
|
78
|
+
(typeof d != "number" || !Number.isInteger(d) || d < 0) && t.push(o(`milestones.${e}.wave`, "must be non-negative integer", d));
|
|
79
|
+
let f = r.ki_estimate;
|
|
80
|
+
f != null && typeof f != "number" && t.push(o(`milestones.${e}.ki_estimate`, "must be number|null", f));
|
|
81
|
+
for (let n of ["tokens_estimated", "tokens_actual"]) {
|
|
82
|
+
let i = r[n];
|
|
83
|
+
i != null && typeof i != "number" && t.push(o(`milestones.${e}.${n}`, "must be number|null", i));
|
|
66
84
|
}
|
|
67
|
-
Array.isArray(
|
|
85
|
+
Array.isArray(r.artifacts) || t.push(o(`milestones.${e}.artifacts`, "must be an array", r.artifacts)), typeof r.si_bytes != "number" && t.push(o(`milestones.${e}.si_bytes`, "must be a number", r.si_bytes));
|
|
68
86
|
}
|
|
69
87
|
let u = e.operations;
|
|
70
|
-
if (!Array.isArray(u))
|
|
88
|
+
if (!Array.isArray(u)) t.push(o("operations", "must be an array", u));
|
|
71
89
|
else for (let e of u) {
|
|
72
|
-
if (!
|
|
73
|
-
let
|
|
74
|
-
|
|
90
|
+
if (!i(e)) continue;
|
|
91
|
+
let n = a(e.id) ? e.id : "?", s = e.milestone;
|
|
92
|
+
a(s) && !l.has(s) && t.push(o(`operations[${n}].milestone`, `unknown milestone "${s}"`));
|
|
75
93
|
let c = e.status;
|
|
76
|
-
(!
|
|
94
|
+
(!a(c) || !r.has(c)) && t.push(o(`operations[${n}].status`, "invalid operation status", c)), Array.isArray(e.dispatch_ids) || t.push(o(`operations[${n}].dispatch_ids`, "must be an array", e.dispatch_ids)), typeof e.attempt_count != "number" && t.push(o(`operations[${n}].attempt_count`, "must be a number", e.attempt_count)), Array.isArray(e.blast_radius) || t.push(o(`operations[${n}].blast_radius`, "must be an array", e.blast_radius));
|
|
77
95
|
}
|
|
78
96
|
let d = e.open_questions;
|
|
79
|
-
if (!Array.isArray(d))
|
|
97
|
+
if (!Array.isArray(d)) t.push(o("open_questions", "must be an array", d));
|
|
80
98
|
else for (let e of d) {
|
|
81
|
-
if (!
|
|
82
|
-
let
|
|
83
|
-
(!
|
|
99
|
+
if (!i(e)) continue;
|
|
100
|
+
let n = e.blocking;
|
|
101
|
+
(!a(n) || !l.has(n)) && t.push(o("open_questions", `unknown blocking milestone "${n}"`)), typeof e.surfaced != "boolean" && t.push(o(`open_questions[${e.id}]`, "surfaced must be boolean", e.surfaced)), typeof e.answered != "boolean" && t.push(o(`open_questions[${e.id}]`, "answered must be boolean", e.answered));
|
|
84
102
|
}
|
|
85
103
|
let f = e.dispatch_units;
|
|
86
104
|
if (f !== void 0) {
|
|
87
|
-
if (!Array.isArray(f))
|
|
105
|
+
if (!Array.isArray(f)) t.push(o("dispatch_units", "must be an array if present", f));
|
|
88
106
|
else for (let e of f) {
|
|
89
|
-
if (!
|
|
90
|
-
let
|
|
91
|
-
typeof
|
|
92
|
-
let
|
|
93
|
-
if (Array.isArray(
|
|
107
|
+
if (!i(e)) continue;
|
|
108
|
+
let n = e.fits_context_window;
|
|
109
|
+
typeof n != "boolean" && t.push(o(`dispatch_units[${e.id}]`, "fits_context_window must be boolean", n));
|
|
110
|
+
let r = e.milestones;
|
|
111
|
+
if (Array.isArray(r)) for (let n of r) a(n) && !l.has(n) && t.push(o(`dispatch_units[${e.id}].milestones`, `unknown milestone "${n}"`));
|
|
94
112
|
}
|
|
95
113
|
}
|
|
96
|
-
|
|
114
|
+
i(e.pairwise_overlap) || t.push(o("pairwise_overlap", "must be an object", e.pairwise_overlap));
|
|
97
115
|
}
|
|
98
116
|
return {
|
|
99
|
-
valid:
|
|
100
|
-
errors:
|
|
117
|
+
valid: t.length === 0,
|
|
118
|
+
errors: t
|
|
101
119
|
};
|
|
102
120
|
}
|
|
103
|
-
function
|
|
104
|
-
let t =
|
|
121
|
+
function c(e) {
|
|
122
|
+
let t = s(e);
|
|
105
123
|
if (!t.valid) throw Error(`Snapshot validation failed:\n${t.errors.map((e) => ` ${e.path}: ${e.message}`).join("\n")}`);
|
|
106
124
|
}
|
|
107
125
|
//#endregion
|
|
108
126
|
//#region src/lib/size-tokens.ts
|
|
109
|
-
var
|
|
127
|
+
var l = {
|
|
110
128
|
prose: 5.5,
|
|
111
129
|
md: 5.5,
|
|
112
130
|
ts: 6.3,
|
|
@@ -114,12 +132,12 @@ var c = {
|
|
|
114
132
|
py: 6.3,
|
|
115
133
|
default: 4
|
|
116
134
|
};
|
|
117
|
-
function
|
|
135
|
+
function u(e, t) {
|
|
118
136
|
if (e <= 0) return 0;
|
|
119
|
-
let n =
|
|
137
|
+
let n = l[t ? t.split(".").pop()?.toLowerCase() ?? "" : ""] ?? l.default ?? 4;
|
|
120
138
|
return Math.ceil(e / n);
|
|
121
139
|
}
|
|
122
|
-
function
|
|
140
|
+
function d(e, t) {
|
|
123
141
|
if (e.length === 0 || t.fileSizes === void 0) return /* @__PURE__ */ new Map();
|
|
124
142
|
try {
|
|
125
143
|
return t.fileSizes(e);
|
|
@@ -129,28 +147,28 @@ function u(e, t) {
|
|
|
129
147
|
}
|
|
130
148
|
//#endregion
|
|
131
149
|
//#region src/lib/snapshot.ts
|
|
132
|
-
var
|
|
150
|
+
var f = {
|
|
133
151
|
low: 600,
|
|
134
152
|
medium: 1e3,
|
|
135
153
|
high: 2e3
|
|
136
|
-
},
|
|
137
|
-
function
|
|
154
|
+
}, p = e;
|
|
155
|
+
function m(e) {
|
|
138
156
|
let t = e.properties ?? {};
|
|
139
157
|
return Object.keys(t).length || Object.keys(e).length;
|
|
140
158
|
}
|
|
141
|
-
function
|
|
159
|
+
function h(e, t) {
|
|
142
160
|
if (e.type === "tool-call") return 0;
|
|
143
161
|
let n = e.shape;
|
|
144
162
|
if (n?.kind == null) return 0;
|
|
145
163
|
let r = n.kind;
|
|
146
|
-
return r === "function" || r === "interface" || r === "type" || r === "class" || r === "enum" || r === "const" || r === "script" ? ("ops" in n && Array.isArray(n.ops) ? n.ops : []).length * 200 : r === "config" || r === "env" || r === "schema" || r === "manifest" ? ("ops" in n && Array.isArray(n.ops) ? n.ops : []).length * 100 : r === "doc" ?
|
|
164
|
+
return r === "function" || r === "interface" || r === "type" || r === "class" || r === "enum" || r === "const" || r === "script" ? ("ops" in n && Array.isArray(n.ops) ? n.ops : []).length * 200 : r === "config" || r === "env" || r === "schema" || r === "manifest" ? ("ops" in n && Array.isArray(n.ops) ? n.ops : []).length * 100 : r === "doc" ? f[t ?? "medium"] ?? 1e3 : r === "structured-output" ? m("schema" in n && n.schema ? n.schema : {}) * 50 : 0;
|
|
147
165
|
}
|
|
148
|
-
function
|
|
166
|
+
function g(e, t) {
|
|
149
167
|
let n = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]), r = {};
|
|
150
168
|
for (let i of n) r[i] = e[i] ?? t[i] ?? null;
|
|
151
169
|
return r;
|
|
152
170
|
}
|
|
153
|
-
function
|
|
171
|
+
function _(e, t) {
|
|
154
172
|
let n = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]), r = {};
|
|
155
173
|
for (let i of n) {
|
|
156
174
|
let n = e[i] ?? t[i];
|
|
@@ -159,7 +177,7 @@ function g(e, t) {
|
|
|
159
177
|
}
|
|
160
178
|
return r;
|
|
161
179
|
}
|
|
162
|
-
function
|
|
180
|
+
function v(e) {
|
|
163
181
|
let t = Object.keys(e), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
164
182
|
for (let e of t) n.has(e) || n.set(e, 0), r.has(e) || r.set(e, []);
|
|
165
183
|
for (let i of t) {
|
|
@@ -194,16 +212,16 @@ function _(e) {
|
|
|
194
212
|
waves: i
|
|
195
213
|
};
|
|
196
214
|
}
|
|
197
|
-
function
|
|
215
|
+
function y(e, t) {
|
|
198
216
|
if (t.length === 0) return [];
|
|
199
217
|
let n = new Set(t);
|
|
200
218
|
return e.filter((e) => e.operations.some((e) => n.has(e)));
|
|
201
219
|
}
|
|
202
|
-
function
|
|
220
|
+
function b(e, t) {
|
|
203
221
|
return e.filter((e) => e.operations.includes(t));
|
|
204
222
|
}
|
|
205
|
-
function
|
|
206
|
-
let a = `${e}.guard`, o = [...n, a], s =
|
|
223
|
+
function x(e, t, n, r, i) {
|
|
224
|
+
let a = `${e}.guard`, o = [...n, a], s = y(r, o);
|
|
207
225
|
for (let e of s) for (let t of e.results) if (t.op_id === a && t.guard_result === "pass") return "complete";
|
|
208
226
|
for (let e of s) if (e.suspension) return "awaiting_input";
|
|
209
227
|
for (let e of s) for (let t of e.results) if (o.includes(t.op_id) && t.status === "failed") return "failed";
|
|
@@ -211,7 +229,7 @@ function b(e, t, n, r, i) {
|
|
|
211
229
|
let c = i.length === 0 || i.every((e) => e === "complete");
|
|
212
230
|
return t.pending !== null && c ? "pending-surfaced" : "pending";
|
|
213
231
|
}
|
|
214
|
-
function
|
|
232
|
+
function S(e, t) {
|
|
215
233
|
let n = `${e}.guard`, r = null, i = null, a = null;
|
|
216
234
|
for (let e of t) if (e.operations.includes(n)) for (let t of e.results) t.op_id === n && t.guard_result !== null && (r = t.guard_result, i = t.guard_output, t.guard_result === "pass" && (a = t.guard_ran_at));
|
|
217
235
|
return r === null ? {
|
|
@@ -224,15 +242,15 @@ function x(e, t) {
|
|
|
224
242
|
completed_at: a
|
|
225
243
|
};
|
|
226
244
|
}
|
|
227
|
-
function
|
|
245
|
+
function C(e) {
|
|
228
246
|
let t = /* @__PURE__ */ new Set();
|
|
229
|
-
for (let n of e) n.action === "move" && n.to_file ? t.add(n.to_file) :
|
|
247
|
+
for (let n of e) n.action === "move" && n.to_file ? t.add(n.to_file) : p.has(n.action) && n.file && t.add(n.file);
|
|
230
248
|
return Array.from(t);
|
|
231
249
|
}
|
|
232
|
-
function
|
|
233
|
-
let r =
|
|
250
|
+
function w(e, t, n) {
|
|
251
|
+
let r = b(n, e.id), i = r.map((e) => e.id), a = null, o = null, s = null;
|
|
234
252
|
for (let t of r) for (let n of t.results) n.op_id === e.id && n.guard_result !== null && (a = n.guard_result, o = n.guard_output, s = n.guard_ran_at);
|
|
235
|
-
let c = e.ki_estimate !== null && e.ki_estimate !== void 0 ? e.ki_estimate :
|
|
253
|
+
let c = e.ki_estimate !== null && e.ki_estimate !== void 0 ? e.ki_estimate : h(e, t), l = T(e.shape);
|
|
236
254
|
return {
|
|
237
255
|
...e,
|
|
238
256
|
ki_estimate: c,
|
|
@@ -252,7 +270,7 @@ function C(e, t, n) {
|
|
|
252
270
|
tokens_actual: null
|
|
253
271
|
};
|
|
254
272
|
}
|
|
255
|
-
function
|
|
273
|
+
function T(e) {
|
|
256
274
|
if (!e) return null;
|
|
257
275
|
if (e.kind === null) return e;
|
|
258
276
|
let t = e.kind;
|
|
@@ -270,8 +288,8 @@ function w(e) {
|
|
|
270
288
|
}
|
|
271
289
|
return e;
|
|
272
290
|
}
|
|
273
|
-
function
|
|
274
|
-
let i = `${e}.guard`, a =
|
|
291
|
+
function E(e, t, n, r) {
|
|
292
|
+
let i = `${e}.guard`, a = b(r, i), o = a.map((e) => e.id), s = null, c = null, l = null;
|
|
275
293
|
for (let e of a) for (let t of e.results) t.op_id === i && t.guard_result !== null && (s = t.guard_result, c = t.guard_output, l = t.guard_ran_at);
|
|
276
294
|
return {
|
|
277
295
|
id: i,
|
|
@@ -310,12 +328,12 @@ function T(e, t, n, r) {
|
|
|
310
328
|
tokens_actual: null
|
|
311
329
|
};
|
|
312
330
|
}
|
|
313
|
-
function
|
|
331
|
+
function D(e, t) {
|
|
314
332
|
let n = {}, { write_multiplier: r, read_multiplier: i, hit_probability: a } = t;
|
|
315
333
|
for (let [t, o] of Object.entries(e)) n[t] = o === null ? null : Math.round(o * ((1 - a) * r + a * i));
|
|
316
334
|
return n;
|
|
317
335
|
}
|
|
318
|
-
function
|
|
336
|
+
function O(e, t, n) {
|
|
319
337
|
let r = Array.from(e.keys()), i = {};
|
|
320
338
|
for (let a = 0; a < r.length; a++) for (let o = a + 1; o < r.length; o++) {
|
|
321
339
|
let s = r[a], c = r[o];
|
|
@@ -328,37 +346,37 @@ function D(e, t, n) {
|
|
|
328
346
|
}
|
|
329
347
|
return i;
|
|
330
348
|
}
|
|
331
|
-
function
|
|
349
|
+
function k(e) {
|
|
332
350
|
return (Array.isArray(e) ? e : Object.values(e)).map((e) => e.type === void 0 ? {
|
|
333
351
|
...e,
|
|
334
352
|
type: "generative"
|
|
335
353
|
} : e);
|
|
336
354
|
}
|
|
337
|
-
function
|
|
338
|
-
let n = (/* @__PURE__ */ new Date()).toISOString(), r = t.dispatchLog ?? e.dispatch_log, i = e.optimization.sentinel_fanout, a =
|
|
355
|
+
function A(e, t) {
|
|
356
|
+
let n = (/* @__PURE__ */ new Date()).toISOString(), r = t.dispatchLog ?? e.dispatch_log, i = e.optimization.sentinel_fanout, a = g(e.optimization.b_per_tier, t.bPerTier), o = _(e.optimization.context_window_per_tier, t.contextWindowPerTier), s = D(a, i), { waves: l } = v(e.milestones), f = k(e.operations), p = /* @__PURE__ */ new Map();
|
|
339
357
|
for (let e of f) {
|
|
340
358
|
let t = p.get(e.milestone) ?? [];
|
|
341
359
|
t.push(e), p.set(e.milestone, t);
|
|
342
360
|
}
|
|
343
361
|
let m = /* @__PURE__ */ new Set();
|
|
344
362
|
for (let e of f) e.file && m.add(e.file), e.action === "move" && e.to_file && m.add(e.to_file);
|
|
345
|
-
let
|
|
346
|
-
for (let t of
|
|
363
|
+
let h = d(Array.from(m), t), b = (e) => h.get(e) ?? 0, T = /* @__PURE__ */ new Map(), A = Array.from(l.entries()).sort((e, t) => e[1] - t[1] || e[0].localeCompare(t[0])).map(([e]) => e);
|
|
364
|
+
for (let t of A) {
|
|
347
365
|
let n = e.milestones[t];
|
|
348
366
|
if (n === void 0) continue;
|
|
349
|
-
let i =
|
|
350
|
-
|
|
367
|
+
let i = x(t, n, (p.get(t) ?? []).map((e) => e.id), r, n.depends_on.map((e) => T.get(e) ?? "pending"));
|
|
368
|
+
T.set(t, i);
|
|
351
369
|
}
|
|
352
370
|
let M = {}, N = [];
|
|
353
|
-
for (let t of
|
|
371
|
+
for (let t of A) {
|
|
354
372
|
let n = e.milestones[t];
|
|
355
373
|
if (n === void 0) continue;
|
|
356
|
-
let i =
|
|
374
|
+
let i = l.get(t) ?? 0, a = p.get(t) ?? [], o = a.map((e) => e.id), c = T.get(t) ?? "pending", d = n.depends_on.map((e) => T.get(e) ?? "pending"), f = n.depends_on.length === 0 || d.every((e) => e === "complete"), m = d.every((e) => e !== "failed"), h = n.pending === null && f && m && c !== "complete", g = y(r, [...o, `${t}.guard`]), _ = g.length > 0 ? g.map((e) => e.started_at).sort()[0] ?? null : null, v, x, D;
|
|
357
375
|
if (n.guard) {
|
|
358
|
-
let e =
|
|
359
|
-
|
|
360
|
-
} else
|
|
361
|
-
let
|
|
376
|
+
let e = S(t, r);
|
|
377
|
+
v = e.guard_result, x = e.guard_output, D = e.completed_at;
|
|
378
|
+
} else v = null, x = null, D = null;
|
|
379
|
+
let O = C(a), k = O.reduce((e, t) => e + b(t), 0), A = a.map((e) => w(e, n.effort, r)), j = null, P = 0, F = !1;
|
|
362
380
|
for (let e of A) {
|
|
363
381
|
if (e.ki_estimate === null) {
|
|
364
382
|
F = !0;
|
|
@@ -369,12 +387,12 @@ function k(e, t) {
|
|
|
369
387
|
F || (j = P);
|
|
370
388
|
let I = null, L = n.model;
|
|
371
389
|
if (L !== null && j !== null) {
|
|
372
|
-
let e =
|
|
373
|
-
e !== null && (I = e +
|
|
390
|
+
let e = s[L] ?? null;
|
|
391
|
+
e !== null && (I = e + u(k) + j);
|
|
374
392
|
}
|
|
375
393
|
let R = null, z = g.filter((e) => e.completed_at !== null && e.results.length > 0 && e.results.every((e) => e.status === "complete" || e.status === "skipped"));
|
|
376
394
|
z.length > 0 && (R = z.reduce((e, t) => e + t.turns.reduce((e, t) => e + t.input_tokens + t.output_tokens, 0), 0));
|
|
377
|
-
let B =
|
|
395
|
+
let B = E(t, n, o, r);
|
|
378
396
|
N.push(...A, B), M[t] = {
|
|
379
397
|
description: n.description,
|
|
380
398
|
...n.rationale === void 0 ? {} : { rationale: n.rationale },
|
|
@@ -392,19 +410,19 @@ function k(e, t) {
|
|
|
392
410
|
context: `contexts/${t}.md`,
|
|
393
411
|
wave: i,
|
|
394
412
|
eligible: h,
|
|
395
|
-
status:
|
|
413
|
+
status: c,
|
|
396
414
|
started_at: _,
|
|
397
|
-
completed_at:
|
|
398
|
-
guard_result:
|
|
399
|
-
guard_output:
|
|
400
|
-
artifacts:
|
|
401
|
-
si_bytes:
|
|
415
|
+
completed_at: D,
|
|
416
|
+
guard_result: v,
|
|
417
|
+
guard_output: x,
|
|
418
|
+
artifacts: O,
|
|
419
|
+
si_bytes: k,
|
|
402
420
|
ki_estimate: j,
|
|
403
421
|
tokens_estimated: I,
|
|
404
422
|
tokens_actual: R
|
|
405
423
|
};
|
|
406
424
|
}
|
|
407
|
-
let P =
|
|
425
|
+
let P = O(p, T, b), F = j(e, M), I = {
|
|
408
426
|
tokens_naive: (() => {
|
|
409
427
|
let e = 0;
|
|
410
428
|
for (let n of Object.values(M)) if (n.eligible && n.status === "pending" && n.model !== null) {
|
|
@@ -417,7 +435,7 @@ function k(e, t) {
|
|
|
417
435
|
context_window_override: e.optimization.context_window_override,
|
|
418
436
|
b_override: e.optimization.b_override,
|
|
419
437
|
b_per_tier: a,
|
|
420
|
-
b_eff_per_tier:
|
|
438
|
+
b_eff_per_tier: s,
|
|
421
439
|
context_window_per_tier: o
|
|
422
440
|
}, L = {
|
|
423
441
|
snapshot_at: n,
|
|
@@ -440,9 +458,9 @@ function k(e, t) {
|
|
|
440
458
|
pairwise_overlap: P,
|
|
441
459
|
open_questions: F
|
|
442
460
|
};
|
|
443
|
-
return
|
|
461
|
+
return c(L), L;
|
|
444
462
|
}
|
|
445
|
-
function
|
|
463
|
+
function j(e, t) {
|
|
446
464
|
let n = [];
|
|
447
465
|
for (let [r, i] of Object.entries(t)) {
|
|
448
466
|
let t = e.milestones[r];
|
|
@@ -463,14 +481,14 @@ function A(e, t) {
|
|
|
463
481
|
}
|
|
464
482
|
//#endregion
|
|
465
483
|
//#region src/lib/optimize.ts
|
|
466
|
-
var
|
|
467
|
-
function
|
|
484
|
+
var M = "You are a dispatch-orchestrator worker agent executing one or more milestones from a dependency-DAG build plan. Each task turn gives you the full compiled instructions for this dispatch: milestone description, the operations to perform, and the guard command that defines done. Execute the operations precisely and produce real output (code, docs, or config) — never a plan or a summary in place of the work.";
|
|
485
|
+
function N(e) {
|
|
468
486
|
return Object.keys(e.milestones).filter((t) => {
|
|
469
487
|
let n = e.milestones[t];
|
|
470
488
|
return n?.eligible === !0 && n.status === "pending";
|
|
471
489
|
});
|
|
472
490
|
}
|
|
473
|
-
function
|
|
491
|
+
function P(e) {
|
|
474
492
|
if (e.length === 0 || e.every((e) => e.type === "tool-call")) return "tool-call";
|
|
475
493
|
for (let t of e) {
|
|
476
494
|
if (t.type !== "generative" || t.shape?.kind == null) continue;
|
|
@@ -481,12 +499,12 @@ function N(e) {
|
|
|
481
499
|
}
|
|
482
500
|
return "code-config";
|
|
483
501
|
}
|
|
484
|
-
function
|
|
502
|
+
function F(e) {
|
|
485
503
|
if (!e) return "";
|
|
486
504
|
let t = e.indexOf(":");
|
|
487
505
|
return t >= 0 ? e.slice(t + 1) : e;
|
|
488
506
|
}
|
|
489
|
-
function
|
|
507
|
+
function I(e, t, n) {
|
|
490
508
|
let r = !0, i = [];
|
|
491
509
|
for (let a of e) {
|
|
492
510
|
let e = t[a];
|
|
@@ -510,7 +528,7 @@ function F(e, t, n) {
|
|
|
510
528
|
}
|
|
511
529
|
return r ? null : i.join("\n");
|
|
512
530
|
}
|
|
513
|
-
function
|
|
531
|
+
function L(e, t, n) {
|
|
514
532
|
if (e === null) return null;
|
|
515
533
|
let r = t.optimization.b_eff_per_tier[e];
|
|
516
534
|
if (r != null) return r;
|
|
@@ -519,14 +537,14 @@ function I(e, t, n) {
|
|
|
519
537
|
let a = n.bPerTier[e];
|
|
520
538
|
return a === void 0 ? null : a;
|
|
521
539
|
}
|
|
522
|
-
function
|
|
540
|
+
function R(e, t, n) {
|
|
523
541
|
if (e === null) return Infinity;
|
|
524
542
|
let r = t.optimization.context_window_per_tier[e];
|
|
525
543
|
if (r !== void 0) return r;
|
|
526
544
|
let i = n.contextWindowPerTier[e];
|
|
527
545
|
return i === void 0 ? Infinity : i;
|
|
528
546
|
}
|
|
529
|
-
function
|
|
547
|
+
function z(e, t) {
|
|
530
548
|
let n = /* @__PURE__ */ new Set();
|
|
531
549
|
for (let r of e) {
|
|
532
550
|
let e = t.snapshot.milestones[r];
|
|
@@ -538,27 +556,27 @@ function R(e, t) {
|
|
|
538
556
|
}
|
|
539
557
|
return Array.from(n);
|
|
540
558
|
}
|
|
541
|
-
function
|
|
542
|
-
let r =
|
|
559
|
+
function B(e, t, n) {
|
|
560
|
+
let r = L(t, n.snapshot, n.deps);
|
|
543
561
|
if (r === null) return null;
|
|
544
|
-
let i =
|
|
562
|
+
let i = u(z(e, n).reduce((e, t) => e + (n.sizeMap.get(t) ?? 0), 0)), a = e.reduce((e, t) => e + (n.snapshot.milestones[t]?.ki_estimate ?? 0), 0);
|
|
545
563
|
return r + i + a;
|
|
546
564
|
}
|
|
547
|
-
function
|
|
548
|
-
let r =
|
|
565
|
+
function V(e, t, n) {
|
|
566
|
+
let r = R(t, n.snapshot, n.deps), i = [...e].sort((e, t) => (n.snapshot.milestones[e]?.ki_estimate ?? 0) - (n.snapshot.milestones[t]?.ki_estimate ?? 0) || e.localeCompare(t)), a = [], o = [];
|
|
549
567
|
for (let e of i) {
|
|
550
|
-
let i = [...o, e], s =
|
|
568
|
+
let i = [...o, e], s = B(i, t, n);
|
|
551
569
|
s !== null && s > r && o.length > 0 ? (a.push(o), o = [e]) : o = i;
|
|
552
570
|
}
|
|
553
571
|
return o.length > 0 && a.push(o), a.filter((e) => {
|
|
554
|
-
let i =
|
|
572
|
+
let i = B(e, t, n);
|
|
555
573
|
return i === null || i <= r;
|
|
556
574
|
});
|
|
557
575
|
}
|
|
558
|
-
function
|
|
576
|
+
function H(e, t, n, r) {
|
|
559
577
|
let i = e[0] ?? "", a = r.snapshot.milestones[i], o = a?.effort ?? null, s = [];
|
|
560
578
|
for (let t of e) for (let e of r.opsByMilestone.get(t) ?? []) s.push(e.id);
|
|
561
|
-
let c =
|
|
579
|
+
let c = z(e, r), l = c.reduce((e, t) => e + (r.sizeMap.get(t) ?? 0), 0), d = L(n, r.snapshot, r.deps), f = e.reduce((e, t) => e + (r.snapshot.milestones[t]?.ki_estimate ?? 0), 0), p = d === null ? null : d + u(l) + f, m = R(n, r.snapshot, r.deps), h = p === null || p <= m, g = F(a?.agent ?? null), _ = I(e, r.snapshot.milestones, r.snapshot.operations), v = _ === null ? "guard-only" : "model-dispatch", y = _ === null ? null : M;
|
|
562
580
|
return {
|
|
563
581
|
id: `${i}.dispatch.${t}`,
|
|
564
582
|
milestones: e,
|
|
@@ -575,7 +593,7 @@ function V(e, t, n, r) {
|
|
|
575
593
|
systemPrompt: y,
|
|
576
594
|
prompt: _,
|
|
577
595
|
context_files: c,
|
|
578
|
-
si_bytes:
|
|
596
|
+
si_bytes: l,
|
|
579
597
|
tokens_estimated: p,
|
|
580
598
|
fits_context_window: h,
|
|
581
599
|
sentinel_role: null,
|
|
@@ -588,8 +606,8 @@ function V(e, t, n, r) {
|
|
|
588
606
|
tokens_actual: null
|
|
589
607
|
};
|
|
590
608
|
}
|
|
591
|
-
function
|
|
592
|
-
let n =
|
|
609
|
+
function U(e, t) {
|
|
610
|
+
let n = N(e);
|
|
593
611
|
if (n.length === 0) return [];
|
|
594
612
|
let r = /* @__PURE__ */ new Map();
|
|
595
613
|
for (let t of e.operations) {
|
|
@@ -601,7 +619,7 @@ function H(e, t) {
|
|
|
601
619
|
for (let t of n) {
|
|
602
620
|
let n = e.milestones[t];
|
|
603
621
|
if (n === void 0) continue;
|
|
604
|
-
let a = `${
|
|
622
|
+
let a = `${P(r.get(t) ?? [])}:${n.model ?? "_null"}`, o = i.get(a) ?? [];
|
|
605
623
|
o.push(t), i.set(a, o);
|
|
606
624
|
}
|
|
607
625
|
let a = /* @__PURE__ */ new Set();
|
|
@@ -616,28 +634,28 @@ function H(e, t) {
|
|
|
616
634
|
let o = {
|
|
617
635
|
snapshot: e,
|
|
618
636
|
deps: t,
|
|
619
|
-
sizeMap:
|
|
637
|
+
sizeMap: d(Array.from(a), t),
|
|
620
638
|
opsByMilestone: r
|
|
621
639
|
}, s = [], c = 0, l = Array.from(i.keys()).sort();
|
|
622
640
|
for (let e of l) {
|
|
623
641
|
let t = i.get(e);
|
|
624
642
|
if (t === void 0) continue;
|
|
625
|
-
let n = e.slice(e.indexOf(":") + 1), r = n === "_null" ? null : n, a =
|
|
626
|
-
for (let e of a) s.push(
|
|
643
|
+
let n = e.slice(e.indexOf(":") + 1), r = n === "_null" ? null : n, a = V(t, r, o);
|
|
644
|
+
for (let e of a) s.push(H(e, c++, r, o));
|
|
627
645
|
}
|
|
628
646
|
return s;
|
|
629
647
|
}
|
|
630
|
-
function
|
|
648
|
+
function W(e, t) {
|
|
631
649
|
let n = 0;
|
|
632
|
-
for (let r of
|
|
650
|
+
for (let r of N(e)) {
|
|
633
651
|
let i = e.milestones[r];
|
|
634
652
|
if (i === void 0) continue;
|
|
635
|
-
let a =
|
|
653
|
+
let a = G(i.model, e, t) ?? 0;
|
|
636
654
|
n += a + (i.ki_estimate ?? 0);
|
|
637
655
|
}
|
|
638
656
|
return n;
|
|
639
657
|
}
|
|
640
|
-
function
|
|
658
|
+
function G(e, t, n) {
|
|
641
659
|
if (e === null) return null;
|
|
642
660
|
let r = t.optimization.b_per_tier[e];
|
|
643
661
|
if (r != null) return r;
|
|
@@ -645,4 +663,4 @@ function W(e, t, n) {
|
|
|
645
663
|
return i === void 0 ? null : i;
|
|
646
664
|
}
|
|
647
665
|
//#endregion
|
|
648
|
-
export {
|
|
666
|
+
export { W as computeTokensNaive, U as optimize, A as snapshot, v as topoSortMilestones };
|
package/package.json
CHANGED