@adhd/dispatch-core-optimizer 0.1.5 → 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 +20 -0
- package/index.js +3 -3
- package/index.mjs +150 -130
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
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
|
+
|
|
11
|
+
## 0.1.6 (2026-10-06)
|
|
12
|
+
|
|
13
|
+
### 🩹 Fixes
|
|
14
|
+
|
|
15
|
+
- **dispatch-orchestrator,dispatch-cli:** make HITL reachable from dispatch ([57f53429](https://github.com/PseudoSky/adhd/commit/57f53429))
|
|
16
|
+
|
|
17
|
+
### ❤️ Thank You
|
|
18
|
+
|
|
19
|
+
- pseudosky
|
|
20
|
+
|
|
1
21
|
## 0.1.4 (2026-09-26)
|
|
2
22
|
|
|
3
23
|
### 🚀 Features
|
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`]),
|
|
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)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,106 +6,125 @@ 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",
|
|
13
31
|
"complete",
|
|
14
32
|
"failed",
|
|
15
|
-
"skipped"
|
|
16
|
-
|
|
33
|
+
"skipped",
|
|
34
|
+
"awaiting_input"
|
|
35
|
+
]), r = /* @__PURE__ */ new Set([
|
|
17
36
|
"pending",
|
|
18
37
|
"in_progress",
|
|
19
38
|
"complete",
|
|
20
39
|
"failed",
|
|
21
40
|
"skipped"
|
|
22
41
|
]);
|
|
23
|
-
function
|
|
42
|
+
function i(e) {
|
|
24
43
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
25
44
|
}
|
|
26
|
-
function
|
|
45
|
+
function a(e) {
|
|
27
46
|
return typeof e == "string";
|
|
28
47
|
}
|
|
29
|
-
function
|
|
48
|
+
function o(e, t, n) {
|
|
30
49
|
return {
|
|
31
50
|
path: e,
|
|
32
51
|
message: t,
|
|
33
52
|
value: n
|
|
34
53
|
};
|
|
35
54
|
}
|
|
36
|
-
function
|
|
37
|
-
let
|
|
38
|
-
if (!
|
|
55
|
+
function s(e) {
|
|
56
|
+
let t = [];
|
|
57
|
+
if (!i(e)) return {
|
|
39
58
|
valid: !1,
|
|
40
|
-
errors: [
|
|
59
|
+
errors: [o("", "root must be an object")]
|
|
41
60
|
};
|
|
42
|
-
for (let
|
|
43
|
-
|
|
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));
|
|
44
63
|
let s = e.milestones;
|
|
45
|
-
if (!
|
|
64
|
+
if (!i(s)) t.push(o("milestones", "must be an object", s));
|
|
46
65
|
else {
|
|
47
66
|
let c = Object.keys(s), l = new Set(c);
|
|
48
67
|
for (let e of c) {
|
|
49
|
-
let
|
|
50
|
-
if (!r
|
|
51
|
-
|
|
68
|
+
let r = s[e];
|
|
69
|
+
if (!i(r)) {
|
|
70
|
+
t.push(o(`milestones.${e}`, "must be an object", r));
|
|
52
71
|
continue;
|
|
53
72
|
}
|
|
54
|
-
let c =
|
|
55
|
-
c === !0 && l != null &&
|
|
56
|
-
let u =
|
|
57
|
-
(!
|
|
58
|
-
let d =
|
|
59
|
-
(typeof d != "number" || !Number.isInteger(d) || d < 0) &&
|
|
60
|
-
let f =
|
|
61
|
-
f != null && typeof f != "number" &&
|
|
62
|
-
for (let
|
|
63
|
-
let
|
|
64
|
-
|
|
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));
|
|
65
84
|
}
|
|
66
|
-
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));
|
|
67
86
|
}
|
|
68
87
|
let u = e.operations;
|
|
69
|
-
if (!Array.isArray(u))
|
|
88
|
+
if (!Array.isArray(u)) t.push(o("operations", "must be an array", u));
|
|
70
89
|
else for (let e of u) {
|
|
71
|
-
if (!
|
|
72
|
-
let
|
|
73
|
-
|
|
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}"`));
|
|
74
93
|
let c = e.status;
|
|
75
|
-
(!
|
|
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));
|
|
76
95
|
}
|
|
77
96
|
let d = e.open_questions;
|
|
78
|
-
if (!Array.isArray(d))
|
|
97
|
+
if (!Array.isArray(d)) t.push(o("open_questions", "must be an array", d));
|
|
79
98
|
else for (let e of d) {
|
|
80
|
-
if (!
|
|
81
|
-
let
|
|
82
|
-
(!
|
|
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));
|
|
83
102
|
}
|
|
84
103
|
let f = e.dispatch_units;
|
|
85
104
|
if (f !== void 0) {
|
|
86
|
-
if (!Array.isArray(f))
|
|
105
|
+
if (!Array.isArray(f)) t.push(o("dispatch_units", "must be an array if present", f));
|
|
87
106
|
else for (let e of f) {
|
|
88
|
-
if (!
|
|
89
|
-
let
|
|
90
|
-
typeof
|
|
91
|
-
let
|
|
92
|
-
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}"`));
|
|
93
112
|
}
|
|
94
113
|
}
|
|
95
|
-
|
|
114
|
+
i(e.pairwise_overlap) || t.push(o("pairwise_overlap", "must be an object", e.pairwise_overlap));
|
|
96
115
|
}
|
|
97
116
|
return {
|
|
98
|
-
valid:
|
|
99
|
-
errors:
|
|
117
|
+
valid: t.length === 0,
|
|
118
|
+
errors: t
|
|
100
119
|
};
|
|
101
120
|
}
|
|
102
|
-
function
|
|
103
|
-
let t =
|
|
121
|
+
function c(e) {
|
|
122
|
+
let t = s(e);
|
|
104
123
|
if (!t.valid) throw Error(`Snapshot validation failed:\n${t.errors.map((e) => ` ${e.path}: ${e.message}`).join("\n")}`);
|
|
105
124
|
}
|
|
106
125
|
//#endregion
|
|
107
126
|
//#region src/lib/size-tokens.ts
|
|
108
|
-
var
|
|
127
|
+
var l = {
|
|
109
128
|
prose: 5.5,
|
|
110
129
|
md: 5.5,
|
|
111
130
|
ts: 6.3,
|
|
@@ -113,12 +132,12 @@ var c = {
|
|
|
113
132
|
py: 6.3,
|
|
114
133
|
default: 4
|
|
115
134
|
};
|
|
116
|
-
function
|
|
135
|
+
function u(e, t) {
|
|
117
136
|
if (e <= 0) return 0;
|
|
118
|
-
let n =
|
|
137
|
+
let n = l[t ? t.split(".").pop()?.toLowerCase() ?? "" : ""] ?? l.default ?? 4;
|
|
119
138
|
return Math.ceil(e / n);
|
|
120
139
|
}
|
|
121
|
-
function
|
|
140
|
+
function d(e, t) {
|
|
122
141
|
if (e.length === 0 || t.fileSizes === void 0) return /* @__PURE__ */ new Map();
|
|
123
142
|
try {
|
|
124
143
|
return t.fileSizes(e);
|
|
@@ -128,28 +147,28 @@ function u(e, t) {
|
|
|
128
147
|
}
|
|
129
148
|
//#endregion
|
|
130
149
|
//#region src/lib/snapshot.ts
|
|
131
|
-
var
|
|
150
|
+
var f = {
|
|
132
151
|
low: 600,
|
|
133
152
|
medium: 1e3,
|
|
134
153
|
high: 2e3
|
|
135
|
-
},
|
|
136
|
-
function
|
|
154
|
+
}, p = e;
|
|
155
|
+
function m(e) {
|
|
137
156
|
let t = e.properties ?? {};
|
|
138
157
|
return Object.keys(t).length || Object.keys(e).length;
|
|
139
158
|
}
|
|
140
|
-
function
|
|
159
|
+
function h(e, t) {
|
|
141
160
|
if (e.type === "tool-call") return 0;
|
|
142
161
|
let n = e.shape;
|
|
143
162
|
if (n?.kind == null) return 0;
|
|
144
163
|
let r = n.kind;
|
|
145
|
-
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;
|
|
146
165
|
}
|
|
147
|
-
function
|
|
166
|
+
function g(e, t) {
|
|
148
167
|
let n = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]), r = {};
|
|
149
168
|
for (let i of n) r[i] = e[i] ?? t[i] ?? null;
|
|
150
169
|
return r;
|
|
151
170
|
}
|
|
152
|
-
function
|
|
171
|
+
function _(e, t) {
|
|
153
172
|
let n = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]), r = {};
|
|
154
173
|
for (let i of n) {
|
|
155
174
|
let n = e[i] ?? t[i];
|
|
@@ -158,7 +177,7 @@ function g(e, t) {
|
|
|
158
177
|
}
|
|
159
178
|
return r;
|
|
160
179
|
}
|
|
161
|
-
function
|
|
180
|
+
function v(e) {
|
|
162
181
|
let t = Object.keys(e), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
163
182
|
for (let e of t) n.has(e) || n.set(e, 0), r.has(e) || r.set(e, []);
|
|
164
183
|
for (let i of t) {
|
|
@@ -193,23 +212,24 @@ function _(e) {
|
|
|
193
212
|
waves: i
|
|
194
213
|
};
|
|
195
214
|
}
|
|
196
|
-
function
|
|
215
|
+
function y(e, t) {
|
|
197
216
|
if (t.length === 0) return [];
|
|
198
217
|
let n = new Set(t);
|
|
199
218
|
return e.filter((e) => e.operations.some((e) => n.has(e)));
|
|
200
219
|
}
|
|
201
|
-
function
|
|
220
|
+
function b(e, t) {
|
|
202
221
|
return e.filter((e) => e.operations.includes(t));
|
|
203
222
|
}
|
|
204
|
-
function
|
|
205
|
-
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);
|
|
206
225
|
for (let e of s) for (let t of e.results) if (t.op_id === a && t.guard_result === "pass") return "complete";
|
|
226
|
+
for (let e of s) if (e.suspension) return "awaiting_input";
|
|
207
227
|
for (let e of s) for (let t of e.results) if (o.includes(t.op_id) && t.status === "failed") return "failed";
|
|
208
228
|
for (let e of s) for (let t of e.results) if (o.includes(t.op_id) && t.status === "in_progress") return "in_progress";
|
|
209
229
|
let c = i.length === 0 || i.every((e) => e === "complete");
|
|
210
230
|
return t.pending !== null && c ? "pending-surfaced" : "pending";
|
|
211
231
|
}
|
|
212
|
-
function
|
|
232
|
+
function S(e, t) {
|
|
213
233
|
let n = `${e}.guard`, r = null, i = null, a = null;
|
|
214
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));
|
|
215
235
|
return r === null ? {
|
|
@@ -222,15 +242,15 @@ function x(e, t) {
|
|
|
222
242
|
completed_at: a
|
|
223
243
|
};
|
|
224
244
|
}
|
|
225
|
-
function
|
|
245
|
+
function C(e) {
|
|
226
246
|
let t = /* @__PURE__ */ new Set();
|
|
227
|
-
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);
|
|
228
248
|
return Array.from(t);
|
|
229
249
|
}
|
|
230
|
-
function
|
|
231
|
-
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;
|
|
232
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);
|
|
233
|
-
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);
|
|
234
254
|
return {
|
|
235
255
|
...e,
|
|
236
256
|
ki_estimate: c,
|
|
@@ -250,7 +270,7 @@ function C(e, t, n) {
|
|
|
250
270
|
tokens_actual: null
|
|
251
271
|
};
|
|
252
272
|
}
|
|
253
|
-
function
|
|
273
|
+
function T(e) {
|
|
254
274
|
if (!e) return null;
|
|
255
275
|
if (e.kind === null) return e;
|
|
256
276
|
let t = e.kind;
|
|
@@ -268,8 +288,8 @@ function w(e) {
|
|
|
268
288
|
}
|
|
269
289
|
return e;
|
|
270
290
|
}
|
|
271
|
-
function
|
|
272
|
-
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;
|
|
273
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);
|
|
274
294
|
return {
|
|
275
295
|
id: i,
|
|
@@ -308,12 +328,12 @@ function T(e, t, n, r) {
|
|
|
308
328
|
tokens_actual: null
|
|
309
329
|
};
|
|
310
330
|
}
|
|
311
|
-
function
|
|
331
|
+
function D(e, t) {
|
|
312
332
|
let n = {}, { write_multiplier: r, read_multiplier: i, hit_probability: a } = t;
|
|
313
333
|
for (let [t, o] of Object.entries(e)) n[t] = o === null ? null : Math.round(o * ((1 - a) * r + a * i));
|
|
314
334
|
return n;
|
|
315
335
|
}
|
|
316
|
-
function
|
|
336
|
+
function O(e, t, n) {
|
|
317
337
|
let r = Array.from(e.keys()), i = {};
|
|
318
338
|
for (let a = 0; a < r.length; a++) for (let o = a + 1; o < r.length; o++) {
|
|
319
339
|
let s = r[a], c = r[o];
|
|
@@ -326,37 +346,37 @@ function D(e, t, n) {
|
|
|
326
346
|
}
|
|
327
347
|
return i;
|
|
328
348
|
}
|
|
329
|
-
function
|
|
349
|
+
function k(e) {
|
|
330
350
|
return (Array.isArray(e) ? e : Object.values(e)).map((e) => e.type === void 0 ? {
|
|
331
351
|
...e,
|
|
332
352
|
type: "generative"
|
|
333
353
|
} : e);
|
|
334
354
|
}
|
|
335
|
-
function
|
|
336
|
-
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();
|
|
337
357
|
for (let e of f) {
|
|
338
358
|
let t = p.get(e.milestone) ?? [];
|
|
339
359
|
t.push(e), p.set(e.milestone, t);
|
|
340
360
|
}
|
|
341
361
|
let m = /* @__PURE__ */ new Set();
|
|
342
362
|
for (let e of f) e.file && m.add(e.file), e.action === "move" && e.to_file && m.add(e.to_file);
|
|
343
|
-
let
|
|
344
|
-
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) {
|
|
345
365
|
let n = e.milestones[t];
|
|
346
366
|
if (n === void 0) continue;
|
|
347
|
-
let i =
|
|
348
|
-
|
|
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);
|
|
349
369
|
}
|
|
350
370
|
let M = {}, N = [];
|
|
351
|
-
for (let t of
|
|
371
|
+
for (let t of A) {
|
|
352
372
|
let n = e.milestones[t];
|
|
353
373
|
if (n === void 0) continue;
|
|
354
|
-
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;
|
|
355
375
|
if (n.guard) {
|
|
356
|
-
let e =
|
|
357
|
-
|
|
358
|
-
} else
|
|
359
|
-
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;
|
|
360
380
|
for (let e of A) {
|
|
361
381
|
if (e.ki_estimate === null) {
|
|
362
382
|
F = !0;
|
|
@@ -367,12 +387,12 @@ function k(e, t) {
|
|
|
367
387
|
F || (j = P);
|
|
368
388
|
let I = null, L = n.model;
|
|
369
389
|
if (L !== null && j !== null) {
|
|
370
|
-
let e =
|
|
371
|
-
e !== null && (I = e +
|
|
390
|
+
let e = s[L] ?? null;
|
|
391
|
+
e !== null && (I = e + u(k) + j);
|
|
372
392
|
}
|
|
373
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"));
|
|
374
394
|
z.length > 0 && (R = z.reduce((e, t) => e + t.turns.reduce((e, t) => e + t.input_tokens + t.output_tokens, 0), 0));
|
|
375
|
-
let B =
|
|
395
|
+
let B = E(t, n, o, r);
|
|
376
396
|
N.push(...A, B), M[t] = {
|
|
377
397
|
description: n.description,
|
|
378
398
|
...n.rationale === void 0 ? {} : { rationale: n.rationale },
|
|
@@ -390,19 +410,19 @@ function k(e, t) {
|
|
|
390
410
|
context: `contexts/${t}.md`,
|
|
391
411
|
wave: i,
|
|
392
412
|
eligible: h,
|
|
393
|
-
status:
|
|
413
|
+
status: c,
|
|
394
414
|
started_at: _,
|
|
395
|
-
completed_at:
|
|
396
|
-
guard_result:
|
|
397
|
-
guard_output:
|
|
398
|
-
artifacts:
|
|
399
|
-
si_bytes:
|
|
415
|
+
completed_at: D,
|
|
416
|
+
guard_result: v,
|
|
417
|
+
guard_output: x,
|
|
418
|
+
artifacts: O,
|
|
419
|
+
si_bytes: k,
|
|
400
420
|
ki_estimate: j,
|
|
401
421
|
tokens_estimated: I,
|
|
402
422
|
tokens_actual: R
|
|
403
423
|
};
|
|
404
424
|
}
|
|
405
|
-
let P =
|
|
425
|
+
let P = O(p, T, b), F = j(e, M), I = {
|
|
406
426
|
tokens_naive: (() => {
|
|
407
427
|
let e = 0;
|
|
408
428
|
for (let n of Object.values(M)) if (n.eligible && n.status === "pending" && n.model !== null) {
|
|
@@ -415,7 +435,7 @@ function k(e, t) {
|
|
|
415
435
|
context_window_override: e.optimization.context_window_override,
|
|
416
436
|
b_override: e.optimization.b_override,
|
|
417
437
|
b_per_tier: a,
|
|
418
|
-
b_eff_per_tier:
|
|
438
|
+
b_eff_per_tier: s,
|
|
419
439
|
context_window_per_tier: o
|
|
420
440
|
}, L = {
|
|
421
441
|
snapshot_at: n,
|
|
@@ -438,9 +458,9 @@ function k(e, t) {
|
|
|
438
458
|
pairwise_overlap: P,
|
|
439
459
|
open_questions: F
|
|
440
460
|
};
|
|
441
|
-
return
|
|
461
|
+
return c(L), L;
|
|
442
462
|
}
|
|
443
|
-
function
|
|
463
|
+
function j(e, t) {
|
|
444
464
|
let n = [];
|
|
445
465
|
for (let [r, i] of Object.entries(t)) {
|
|
446
466
|
let t = e.milestones[r];
|
|
@@ -461,14 +481,14 @@ function A(e, t) {
|
|
|
461
481
|
}
|
|
462
482
|
//#endregion
|
|
463
483
|
//#region src/lib/optimize.ts
|
|
464
|
-
var
|
|
465
|
-
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) {
|
|
466
486
|
return Object.keys(e.milestones).filter((t) => {
|
|
467
487
|
let n = e.milestones[t];
|
|
468
488
|
return n?.eligible === !0 && n.status === "pending";
|
|
469
489
|
});
|
|
470
490
|
}
|
|
471
|
-
function
|
|
491
|
+
function P(e) {
|
|
472
492
|
if (e.length === 0 || e.every((e) => e.type === "tool-call")) return "tool-call";
|
|
473
493
|
for (let t of e) {
|
|
474
494
|
if (t.type !== "generative" || t.shape?.kind == null) continue;
|
|
@@ -479,12 +499,12 @@ function N(e) {
|
|
|
479
499
|
}
|
|
480
500
|
return "code-config";
|
|
481
501
|
}
|
|
482
|
-
function
|
|
502
|
+
function F(e) {
|
|
483
503
|
if (!e) return "";
|
|
484
504
|
let t = e.indexOf(":");
|
|
485
505
|
return t >= 0 ? e.slice(t + 1) : e;
|
|
486
506
|
}
|
|
487
|
-
function
|
|
507
|
+
function I(e, t, n) {
|
|
488
508
|
let r = !0, i = [];
|
|
489
509
|
for (let a of e) {
|
|
490
510
|
let e = t[a];
|
|
@@ -508,7 +528,7 @@ function F(e, t, n) {
|
|
|
508
528
|
}
|
|
509
529
|
return r ? null : i.join("\n");
|
|
510
530
|
}
|
|
511
|
-
function
|
|
531
|
+
function L(e, t, n) {
|
|
512
532
|
if (e === null) return null;
|
|
513
533
|
let r = t.optimization.b_eff_per_tier[e];
|
|
514
534
|
if (r != null) return r;
|
|
@@ -517,14 +537,14 @@ function I(e, t, n) {
|
|
|
517
537
|
let a = n.bPerTier[e];
|
|
518
538
|
return a === void 0 ? null : a;
|
|
519
539
|
}
|
|
520
|
-
function
|
|
540
|
+
function R(e, t, n) {
|
|
521
541
|
if (e === null) return Infinity;
|
|
522
542
|
let r = t.optimization.context_window_per_tier[e];
|
|
523
543
|
if (r !== void 0) return r;
|
|
524
544
|
let i = n.contextWindowPerTier[e];
|
|
525
545
|
return i === void 0 ? Infinity : i;
|
|
526
546
|
}
|
|
527
|
-
function
|
|
547
|
+
function z(e, t) {
|
|
528
548
|
let n = /* @__PURE__ */ new Set();
|
|
529
549
|
for (let r of e) {
|
|
530
550
|
let e = t.snapshot.milestones[r];
|
|
@@ -536,27 +556,27 @@ function R(e, t) {
|
|
|
536
556
|
}
|
|
537
557
|
return Array.from(n);
|
|
538
558
|
}
|
|
539
|
-
function
|
|
540
|
-
let r =
|
|
559
|
+
function B(e, t, n) {
|
|
560
|
+
let r = L(t, n.snapshot, n.deps);
|
|
541
561
|
if (r === null) return null;
|
|
542
|
-
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);
|
|
543
563
|
return r + i + a;
|
|
544
564
|
}
|
|
545
|
-
function
|
|
546
|
-
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 = [];
|
|
547
567
|
for (let e of i) {
|
|
548
|
-
let i = [...o, e], s =
|
|
568
|
+
let i = [...o, e], s = B(i, t, n);
|
|
549
569
|
s !== null && s > r && o.length > 0 ? (a.push(o), o = [e]) : o = i;
|
|
550
570
|
}
|
|
551
571
|
return o.length > 0 && a.push(o), a.filter((e) => {
|
|
552
|
-
let i =
|
|
572
|
+
let i = B(e, t, n);
|
|
553
573
|
return i === null || i <= r;
|
|
554
574
|
});
|
|
555
575
|
}
|
|
556
|
-
function
|
|
576
|
+
function H(e, t, n, r) {
|
|
557
577
|
let i = e[0] ?? "", a = r.snapshot.milestones[i], o = a?.effort ?? null, s = [];
|
|
558
578
|
for (let t of e) for (let e of r.opsByMilestone.get(t) ?? []) s.push(e.id);
|
|
559
|
-
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;
|
|
560
580
|
return {
|
|
561
581
|
id: `${i}.dispatch.${t}`,
|
|
562
582
|
milestones: e,
|
|
@@ -573,7 +593,7 @@ function V(e, t, n, r) {
|
|
|
573
593
|
systemPrompt: y,
|
|
574
594
|
prompt: _,
|
|
575
595
|
context_files: c,
|
|
576
|
-
si_bytes:
|
|
596
|
+
si_bytes: l,
|
|
577
597
|
tokens_estimated: p,
|
|
578
598
|
fits_context_window: h,
|
|
579
599
|
sentinel_role: null,
|
|
@@ -586,8 +606,8 @@ function V(e, t, n, r) {
|
|
|
586
606
|
tokens_actual: null
|
|
587
607
|
};
|
|
588
608
|
}
|
|
589
|
-
function
|
|
590
|
-
let n =
|
|
609
|
+
function U(e, t) {
|
|
610
|
+
let n = N(e);
|
|
591
611
|
if (n.length === 0) return [];
|
|
592
612
|
let r = /* @__PURE__ */ new Map();
|
|
593
613
|
for (let t of e.operations) {
|
|
@@ -599,7 +619,7 @@ function H(e, t) {
|
|
|
599
619
|
for (let t of n) {
|
|
600
620
|
let n = e.milestones[t];
|
|
601
621
|
if (n === void 0) continue;
|
|
602
|
-
let a = `${
|
|
622
|
+
let a = `${P(r.get(t) ?? [])}:${n.model ?? "_null"}`, o = i.get(a) ?? [];
|
|
603
623
|
o.push(t), i.set(a, o);
|
|
604
624
|
}
|
|
605
625
|
let a = /* @__PURE__ */ new Set();
|
|
@@ -614,28 +634,28 @@ function H(e, t) {
|
|
|
614
634
|
let o = {
|
|
615
635
|
snapshot: e,
|
|
616
636
|
deps: t,
|
|
617
|
-
sizeMap:
|
|
637
|
+
sizeMap: d(Array.from(a), t),
|
|
618
638
|
opsByMilestone: r
|
|
619
639
|
}, s = [], c = 0, l = Array.from(i.keys()).sort();
|
|
620
640
|
for (let e of l) {
|
|
621
641
|
let t = i.get(e);
|
|
622
642
|
if (t === void 0) continue;
|
|
623
|
-
let n = e.slice(e.indexOf(":") + 1), r = n === "_null" ? null : n, a =
|
|
624
|
-
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));
|
|
625
645
|
}
|
|
626
646
|
return s;
|
|
627
647
|
}
|
|
628
|
-
function
|
|
648
|
+
function W(e, t) {
|
|
629
649
|
let n = 0;
|
|
630
|
-
for (let r of
|
|
650
|
+
for (let r of N(e)) {
|
|
631
651
|
let i = e.milestones[r];
|
|
632
652
|
if (i === void 0) continue;
|
|
633
|
-
let a =
|
|
653
|
+
let a = G(i.model, e, t) ?? 0;
|
|
634
654
|
n += a + (i.ki_estimate ?? 0);
|
|
635
655
|
}
|
|
636
656
|
return n;
|
|
637
657
|
}
|
|
638
|
-
function
|
|
658
|
+
function G(e, t, n) {
|
|
639
659
|
if (e === null) return null;
|
|
640
660
|
let r = t.optimization.b_per_tier[e];
|
|
641
661
|
if (r != null) return r;
|
|
@@ -643,4 +663,4 @@ function W(e, t, n) {
|
|
|
643
663
|
return i === void 0 ? null : i;
|
|
644
664
|
}
|
|
645
665
|
//#endregion
|
|
646
|
-
export {
|
|
666
|
+
export { W as computeTokensNaive, U as optimize, A as snapshot, v as topoSortMilestones };
|
package/package.json
CHANGED