@evolvingmachines/sdk 0.0.51 → 0.0.52-launch-round-1.20260803.37a56fe
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-5HFUY44N.js +6 -0
- package/dist/hosted/cli.cjs +19 -0
- package/dist/hosted/cli.d.cts +105 -0
- package/dist/hosted/cli.d.ts +105 -0
- package/dist/hosted/cli.js +14 -0
- package/dist/index.cjs +440 -82
- package/dist/index.d.cts +1207 -478
- package/dist/index.d.ts +1207 -478
- package/dist/index.js +429 -79
- package/dist/managed-modal-CRZFDIRG.js +4 -0
- package/dist/tar-PPIAXEGM.js +1 -0
- package/dist/types-B6iGD_du.d.cts +1582 -0
- package/dist/types-B6iGD_du.d.ts +1582 -0
- package/harness-capabilities.json +345 -0
- package/hosted-error-codes.json +57 -0
- package/package.json +35 -10
- package/spec/openapi.yaml +4031 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import {createWriteStream}from'fs';import {mkdir,rename,rm}from'fs/promises';import {join,basename}from'path';import {Readable}from'stream';import {pipeline}from'stream/promises';function lt(t=""){let e=process.env.EVOLVE_GATEWAY_URL||"https://swarmkit-gateway-692833842999.us-central1.run.app";if(!t)return e;let r=t.startsWith("/")?t:`/${t}`;return `${e}${r}`}function ct(t=""){let e=process.env.EVOLVE_DASHBOARD_URL||I;if(!t)return e;let r=t.startsWith("/")?t:`/${t}`;return `${e.replace(/\/$/,"")}${r}`}var Ft=["e2b","daytona","modal"];function W(t){return ct(`/api/managed/${t}`)}function qt(){return `${W("daytona")}/toolbox`}function Gt(){return W("e2b")}function Wt(t){return {"browser-use":{type:"http",url:lt("/browser_use/mcp"),headers:{"x-litellm-api-key":`Bearer ${t}`}}}}var U="EVOLVE_API_KEY",Kt="E2B_API_KEY",Yt="DAYTONA_API_KEY",zt="MODAL_TOKEN_ID",Xt="MODAL_TOKEN_SECRET",Qt="claude",Zt=36e5,te=4,ee=100,K="/home/user";function ne(t,e){return e?e.replace(/\/+$/,"")||"/":t?t==="root"?"/root":`/home/${t}`:K}var I=process.env.EVOLVE_DASHBOARD_URL||"https://dashboard.evolvingmachines.ai",se="x-litellm-customer-id",ae="x-litellm-tags",oe="run:",ie=".evolve-sdk/observability/sessions",ue=["tag","provider","agent","model","sandboxId","sandbox_id","timestamp","event","events"],le=100,ce=5e3,de=3,ge=1e3;var dt=["QUEUED","RUNNING","SCORING","SCORED","SCORING_ERROR","INFRASTRUCTURE_ERROR","INDETERMINATE","CANCELLED"],gt=["e2b","daytona","modal"],pt=["trace-parsed","verifier","trace-stdout","trace-stderr","trajectory","agent-home"],Y=["missing_authorization","invalid_api_key","credential_service_unavailable","rate_limited","insufficient_credits","invalid_json","invalid_input","invalid_limit","invalid_status","invalid_cursor","invalid_after","invalid_format","invalid_ids","invalid_multipart","idempotency_key_reused","dataset_not_found","dataset_version_not_found","dataset_name_taken","dataset_in_use","dataset_not_owned","upstream_not_watchable","no_active_version","version_not_ready","version_not_activatable","unknown_task_names","no_tasks","agent_not_found","agent_name_taken","agent_name_reserved","agent_invalid_name","agent_source_required","agent_source_conflict","agent_invalid_env","agent_too_large","agent_limit_reached","agent_version_not_found","job_too_large","provider_unsupported","job_not_found","job_not_terminal","no_failed_trials","trial_not_found","concurrent_update","regrade_source_ineligible","no_regradable_trials","import_not_found","import_too_large","invalid_archive","package_not_retained","package_corrupt","package_missing","internal_error"];function N(t){return typeof t=="string"&&Y.includes(t)}var T=class extends Error{status;code;param;details;retryAfterSec;requestId;constructor(e,r,a,s){super(a),this.name="EvolveApiError",this.status=e,this.code=r,s?.param!==void 0&&(this.param=s.param),s?.details!==void 0&&(this.details=s.details),s?.retryAfterSec!==void 0&&(this.retryAfterSec=s.retryAfterSec),s?.requestId!==void 0&&(this.requestId=s.requestId);}isKnownCode(){return N(this.code)}};function Z(t,e){try{let l=JSON.parse(t)?.error?.retryAfterSec;if(typeof l=="number"&&Number.isFinite(l))return l}catch{}let r=e.headers?.get?.("retry-after");if(typeof r!="string"||r.trim()==="")return;let a=Number(r);return Number.isFinite(a)?a:void 0}async function B(t){let e=await t.text().catch(()=>""),r=t.headers?.get?.("x-request-id")??void 0,a=Z(e,t);try{let s=JSON.parse(e);if(s?.error&&typeof s.error=="object"){let l=typeof s.error.code=="string"?s.error.code:"unknown_error",g=typeof s.error.message=="string"?s.error.message:t.statusText;throw new T(t.status,l,g,{param:typeof s.error.param=="string"?s.error.param:void 0,details:s.error.details&&typeof s.error.details=="object"?s.error.details:void 0,retryAfterSec:a,requestId:typeof s.error.requestId=="string"?s.error.requestId:r})}}catch(s){if(s instanceof T)throw s}throw new T(t.status,"unknown_error",e||t.statusText,{retryAfterSec:a,requestId:r})}var M=class extends Error{dataset;constructor(e){super(`Dataset "${e}" has no active version`),this.name="NoActiveVersionError",this.dataset=e;}},xt=1e3,Tt=3e4,St=new Set(["COMPLETED","CANCELLED","FAILED"]),Dt=new Set(["job.completed","job.cancelled","job.failed"]),ht=2e3,Et=new Set(["COMPLETED","FAILED"]);function h(t,e){let r=e?.apiKey||process.env[U];if(!r)throw new Error(`${t}() requires an API key. Set ${U} or pass { apiKey } in config.`);let a=(e?.baseUrl||process.env.EVOLVE_DASHBOARD_URL||I).replace(/\/$/,"");return {apiKey:r,baseUrl:a}}async function d(t,e,r){let a=await fetch(`${t.baseUrl}${e}`,{...r,headers:{Authorization:`Bearer ${t.apiKey}`,...r?.headers}});return a.ok||await B(a),a}function z(t){let e=t.indexOf("@");if(e===-1)return {name:t.trim()};let r=t.slice(0,e).trim(),a=t.slice(e+1).trim();if(!r||!a)throw new Error(`Invalid dataset ref "${t}": expected "name" or "name@version"`);return {name:r,version:a}}function tt(t){return {name:t.name,version:t.version}}function et(t){return {name:t.name,model_name:t.model_name,version:t.version??null,reasoning_effort:t.reasoning_effort??null}}function P(t){return {version:t.version,state:t.state,created_at:t.created_at,task_count:t.task_count??0}}function It(t){return {task_name:t.task_name,agent_timeout_sec:t.agent_timeout_sec,verifier_timeout_sec:t.verifier_timeout_sec,providers:t.providers}}function Pt(t){return {action:t.action,type:t.type,job_id:t.job_id}}function A(t){let e=t.trials??{};return {id:t.id,job_name:t.job_name,status:t.status,datasets:(t.datasets??[]).map(tt),agents:(t.agents??[]).map(et),n_attempts:t.n_attempts,n_concurrent_trials:t.n_concurrent_trials,max_trial_spend_usd:t.max_trial_spend_usd,worst_case_spend_usd:t.worst_case_spend_usd,sandbox_provider:t.sandbox_provider,counts:t.counts,n_total_trials:t.n_total_trials??0,trials:{total:e.total??0,byStatus:e.byStatus??{}},stats:t.stats??{},failure:t.failure??null,source_jobs:(t.source_jobs??[]).map(Pt),is_regrade:t.is_regrade===true,idempotent_replay:t.idempotent_replay===true,started_at:t.started_at,updated_at:t.updated_at,finished_at:t.finished_at??null}}function R(t,e){let r=t??{};return {items:Array.isArray(r.items)?r.items.map(e):[],nextCursor:r.nextCursor??null,hasMore:r.hasMore===true}}function x(t,e){let r=new URLSearchParams;t?.limit!==void 0&&r.set("limit",String(t.limit)),t?.cursor&&r.set("cursor",t.cursor);for(let[s,l]of Object.entries(e??{}))l!==void 0&&r.set(s,l);let a=r.toString();return a?`?${a}`:""}function w(t){if(!t||typeof t!="object")return null;let e=t;return {started_at:e.started_at??null,finished_at:e.finished_at??null}}function wt(t){let e=t.model_info??{};return {name:t.name,version:t.version??null,model_info:{name:e.name,provider:e.provider??null},reasoning_effort:t.reasoning_effort??null}}function V(t){return {id:t.id,job_id:t.job_id,task_name:t.task_name,source:t.source,agent_info:wt(t.agent_info||{}),attempt:t.attempt,status:t.status,reward:t.reward??null,verifier_result:t.verifier_result??null,exception_info:t.exception_info??null,agent_result:t.agent_result??null,environment_setup:w(t.environment_setup),agent_setup:w(t.agent_setup),agent_execution:w(t.agent_execution),verifier:w(t.verifier),step_results:t.step_results??null,spend_source:t.spend_source??null,live_spent_usd:t.live_spent_usd??null,live_spend_at:t.live_spend_at??null,max_trial_spend_usd:t.max_trial_spend_usd??null,sandbox_provider:t.sandbox_provider??null,sandbox_id:t.sandbox_id??null,verifier_sandbox_id:t.verifier_sandbox_id??null,verifier_environment_mode:t.verifier_environment_mode??null,attempt_phase:t.attempt_phase??null,session_ref:t.session_ref??null,started_at:t.started_at??null,finished_at:t.finished_at??null}}function k(t){return {name:t.name,source:t.source,run_command:t.run_command,env:t.env??{},created_at:t.created_at,updated_at:t.updated_at}}function C(t){let e={id:t.id,status:t.status,name:t.name,version:t.version,failure:t.failure??null,warnings:t.warnings??[]};return typeof t.task_count=="number"&&(e.task_count=t.task_count),typeof t.created_at=="string"&&(e.created_at=t.created_at),typeof t.updated_at=="string"&&(e.updated_at=t.updated_at),e}function nt(t){let e=t??{};return {scored:e.scored??0,total:e.total??0}}function kt(t){return {id:t.id,datasets:(t.datasets??[]).map(tt),status:t.status,mean_reward:t.mean_reward??null,coverage:nt(t.coverage),cost_usd:t.cost_usd??0,agents:(t.agents||[]).map(et),started_at:t.started_at}}function Ct(t){return {job_id:t.job_id,status:t.status,mean_reward:t.mean_reward??null,coverage:nt(t.coverage)}}function Ot(t){return {task_name:t.task_name,disagreement:t.disagreement===true,cells:(t.cells||[]).map(Ct)}}function Jt(t){return {seq:t.seq,type:t.type,data:t.data??{}}}function $(t){if(t?.aborted)throw t.reason instanceof Error?t.reason:new Error("Watch aborted")}function X(t,e){return e?.aborted?true:t?.name==="AbortError"}function D(t,e){return new Promise((r,a)=>{let s=setTimeout(()=>{e?.removeEventListener("abort",l),r();},t),l=()=>{clearTimeout(s),a(e?.reason instanceof Error?e.reason:new Error("Watch aborted"));};e?.addEventListener("abort",l,{once:true});})}function Lt(t){let e="",r=false;return {push(a){r&&(a="\r"+a,r=false),a.endsWith("\r")&&(a=a.slice(0,-1),r=true),e+=a.replace(/\r\n|\r/g,`
|
|
2
|
+
`);let s;for(;(s=e.indexOf(`
|
|
3
|
+
|
|
4
|
+
`))!==-1;){let l=e.slice(0,s);e=e.slice(s+2);let g,u,n=[];for(let o of l.split(`
|
|
5
|
+
`)){if(!o||o.startsWith(":"))continue;let i=o.indexOf(":"),p=i===-1?o:o.slice(0,i),c=i===-1?"":o.slice(i+1);c.startsWith(" ")&&(c=c.slice(1)),p==="id"?g=c:p==="event"?u=c:p==="data"&&n.push(c);}(g!==void 0||u!==void 0||n.length>0)&&t({id:g,event:u,data:n.join(`
|
|
6
|
+
`)});}}}}function S(t,e){let r,a=()=>r??=t({limit:e?.limit,cursor:e?.cursor});return {then(s,l){return a().then(s,l)},catch(s){return a().catch(s)},finally(s){return a().finally(s)},async*[Symbol.asyncIterator](){let s=e?.cursor;for(;;){let l=await t({limit:e?.limit,cursor:s});for(let g of l.items)yield g;if(!l.nextCursor)return;s=l.nextCursor;}}}}function O(t,e){let r=new FormData;for(let[a,s]of Object.entries(t))s!==void 0&&r.set(a,s);return e&&r.set("archive",new Blob([e.bytes],{type:"application/gzip"}),e.filename),r}function jt(t){let e,r=()=>(e||(e=(async()=>{let a=await t.next();for(;!a.done;)a=await t.next();return a.value})()),e);return {then(a,s){return r().then(a,s)},catch(a){return r().catch(a)},finally(a){return r().finally(a)},[Symbol.asyncIterator](){return t}}}var rt="x-package-sha256",J=class extends Error{constructor(r,a){super(`downloaded bytes do not match the digest the server stated (expected ${r}, got ${a})`);this.expected=r;this.actual=a;}name="EvolveDigestMismatchError"},L=class extends Error{constructor(r,a){super(`download ended early: the server declared ${r} bytes and ${a} arrived`);this.expectedBytes=r;this.receivedBytes=a;}name="EvolveIncompleteDownloadError"};function st(t,e){let r=t.headers.get("Content-Length");if(r===null)return;let a=Number(r);if(Number.isFinite(a)&&e!==a)throw new L(a,e)}async function at(t,e){let r=t.headers.get(rt);if(!r)return;let{createHash:a}=await import('crypto'),s=a("sha256").update(e).digest("hex");if(s!==r)throw new J(r,s)}function Ut(t,e){let a=(t.headers.get("Content-Disposition")||"").match(/filename="([^"]+)"/);if(!a)return e;let s=basename(a[1]);return s===""||s==="."||s===".."||/[/\\]/.test(s)||/[\u0000-\u001f]/.test(s)?e:s}async function ot(t,e,r){if(!t.body)throw new Error("Download response has no body");await mkdir(e,{recursive:true});let a=join(e,Ut(t,r)),{createHash:s,randomBytes:l}=await import('crypto'),g=`${a}.${l(8).toString("hex")}.part`,u=s("sha256"),n=0,o=Readable.fromWeb(t.body);o.on("data",i=>{u.update(i),n+=i.length;});try{await pipeline(o,createWriteStream(g));let i=t.headers.get("Content-Length");if(i!==null&&n!==Number(i))throw new L(Number(i),n);let p=t.headers.get(rt),c=u.digest("hex");if(p&&c!==p)throw new J(p,c);await rename(g,a);}catch(i){throw await rm(g,{force:true}).catch(()=>{}),i}return a}function Nt(t){let e=h("datasets",t);async function r(n){let o=await d(e,`/api/datasets/imports/${encodeURIComponent(n)}`);return C(await o.json())}function a(n){if(!n||typeof n!="object")return null;let o=n;return {ref:o.ref,current_commit:o.current_commit,latest_commit:o.latest_commit??null,moved:o.moved===true,behind_by:typeof o.behind_by=="number"?o.behind_by:null,checked_at:o.checked_at??null,error:o.error??null,auto_import:o.auto_import===true}}function s(n){return {name:n.name,title:n.title??null,description:n.description??null,active_version:n.active_version?P(n.active_version):null,versions:(n.versions||[]).map(P),selected_version:n.selected_version?P(n.selected_version):null,tasks:R(n.tasks,It),upstream:a(n.upstream),created_at:n.created_at,updated_at:n.updated_at}}async function l(n,o){let i=z(n),p=x(o,{version:i.version}),c=await d(e,`/api/datasets/${encodeURIComponent(i.name)}${p}`);return s(await c.json())}function g(n){return {name:n.name,title:n.title??null,description:n.description??null,active_version:n.active_version?P(n.active_version):null,upstream:a(n.upstream)}}async function u(n){let o=await d(e,`/api/datasets${x(n,{search:n?.search})}`);return R(await o.json(),g)}return {list(n){return S(o=>u({...o,search:n?.search}),n)},get:l,async getActive(n,o){let i=await l(n,o);if(i.active_version===null)throw new M(n);return {name:i.name,title:i.title,description:i.description,active_version:i.active_version,version:i.active_version.version,tasks:i.tasks??{items:[],nextCursor:null,hasMore:false},versions:i.versions??[],created_at:i.created_at,updated_at:i.updated_at}},async publish(n){let o=n.source;if(o?.directory){let{tarGzipDirectory:i}=await import('./tar-PPIAXEGM.js'),p=await i(o.directory),c=await d(e,"/api/datasets/publish",{method:"POST",body:O({name:n.name,version:n.version},{bytes:p,filename:"corpus.tar.gz"})});return C(await c.json())}if(o&&"git_url"in o&&o.git_url){let i=await d(e,"/api/datasets/publish",{method:"POST",body:O({name:n.name,version:n.version,git_url:o.git_url,git_ref:o.git_ref})});return C(await i.json())}throw new Error("datasets().publish() requires either a git source ({ source: { git_url, git_ref } }) or a local corpus directory ({ source: { directory } }), plus name and version")},getImport:r,async watchImport(n,o){let i=o?.pollIntervalMs??ht,p=null;for(;;){$(o?.signal);let c;try{c=await r(n);}catch(_){if(_ instanceof T&&(_.status===429||_.status===503)){await D(Math.max((_.retryAfterSec??0)*1e3,i),o?.signal);continue}throw _}if(c.status!==p&&(p=c.status,o?.onStatus?.(c)),Et.has(c.status))return c;await D(i,o?.signal);}},download:(async(n,o)=>{let i=z(n),p=i.version?`?version=${encodeURIComponent(i.version)}`:"",c=await d(e,`/api/datasets/${encodeURIComponent(i.name)}/download${p}`);if(o?.stream){if(!c.body)throw new Error("Package response has no body");return c.body}if(o?.to)return ot(c,o.to,`${i.name}-corpus.tar.gz`);let _=Buffer.from(await c.arrayBuffer());return st(c,_.length),await at(c,_),_}),listImports(n){return S(async o=>{let i=new URLSearchParams;o.limit!==void 0&&i.set("limit",String(o.limit)),o.cursor!==void 0&&i.set("cursor",o.cursor),n?.status!==void 0&&i.set("status",n.status),n?.dataset!==void 0&&i.set("dataset",n.dataset);let p=i.toString()?`?${i}`:"",c=await d(e,`/api/datasets/imports${p}`);return R(await c.json(),C)},n)},async activate(n,o){let i=await d(e,`/api/datasets/${encodeURIComponent(n)}/versions/${encodeURIComponent(o)}/activate`,{method:"POST"});return s(await i.json())},async update(n,o){let i=await d(e,`/api/datasets/${encodeURIComponent(n)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});return g(await i.json())},async delete(n){await d(e,`/api/datasets/${encodeURIComponent(n)}`,{method:"DELETE"});}}}function Mt(t){let e=h("agents",t);return {async create(r){let a=await Q("agents().create()",r),s=await d(e,"/api/agents",{method:"POST",body:a});return k(await s.json())},list(r){return S(async a=>{let s=await d(e,`/api/agents${x(a)}`);return R(await s.json(),k)},r)},async get(r){let a=await d(e,`/api/agents/${encodeURIComponent(r)}`);return k(await a.json())},async delete(r){await d(e,`/api/agents/${encodeURIComponent(r)}`,{method:"DELETE"});},async upsert(r,a){let s=await Q("agents().upsert()",{...a,name:r}),l=await d(e,`/api/agents/${encodeURIComponent(r)}`,{method:"PUT",body:s});return k(await l.json())}}}async function Q(t,e){let r=typeof e.install_script=="string",a=typeof e.directory=="string";if(r&&a)throw new Error(`${t} takes EITHER an install script ({ install_script }) or a local directory ({ directory }), not both`);if(!r&&!a)throw new Error(`${t} requires either an install script ({ install_script }) or a local directory ({ directory }), plus run_command`);let s={name:e.name,run_command:e.run_command,...e.env!==void 0?{env:JSON.stringify(e.env)}:{},...r?{install_script:e.install_script}:{}};if(a){let{tarGzipDirectory:l}=await import('./tar-PPIAXEGM.js'),g=await l(e.directory);return O(s,{bytes:g,filename:"source.tar.gz"})}return O(s)}function Vt(t){let e=h("jobs",t);async function r(u){let n=await d(e,`/api/jobs/${encodeURIComponent(u)}`);return A(await n.json())}async function a(u){let n=await d(e,`/api/jobs${x(u,{search:u?.search})}`);return R(await n.json(),A)}function s(u){let n=u.trials??{};return {task_name:u.task_name,source:u.source,trials:{total:n.total??0,byStatus:n.byStatus??{}},mean_reward:u.mean_reward??null,cost_usd:u.cost_usd??null}}async function l(u,n){let o=x(n,{status:n?.status?.length?n.status.join(","):void 0,dataset:n?.dataset}),i=await d(e,`/api/jobs/${encodeURIComponent(u)}/trials${o}`);return R(await i.json(),V)}async function*g(u,n){let{onEvent:o,signal:i}=n??{},p=n?.reconnectDelayMs??xt,c=n?.maxReconnectDelayMs??Tt,_=null,E=false,H=false,b=p;for(;!E;){$(i);let f;try{f=await fetch(`${e.baseUrl}/api/jobs/${encodeURIComponent(u)}/events`,{headers:{Authorization:`Bearer ${e.apiKey}`,Accept:"text/event-stream",..._!==null?{"Last-Event-ID":String(_)}:{}},signal:i});}catch(m){if(X(m,i))throw m;await D(b,i),b=Math.min(b*2,c);continue}if(!f.ok){if(f.status===429||f.status>=500){let m=await f.text().catch(()=>""),y=Z(m,f)??0,v=y>0?Math.max(y*1e3,b):b;await D(v,i),b=Math.min(b*2,c);continue}await B(f);}if(!f.body)throw new Error("Event stream response has no body");let F=false,j=[],it=Lt(m=>{let y=Number(m.id),v={seq:Number.isInteger(y)?y:-1,type:m.event||"message",data:m.data?Bt(m.data):{}};Number.isInteger(y)&&(_=y),F=true,Dt.has(v.type)&&(E=true),j.push(v);}),q=f.body.getReader(),ut=new TextDecoder;try{for(;!E;){let{done:m,value:y}=await q.read();if(m)break;it.push(ut.decode(y,{stream:!0}));for(let v of j)o?.(v),yield v;j.length=0;}}catch(m){if(X(m,i))throw m}finally{await q.cancel().catch(()=>{});}if(E)break;$(i);let G=await r(u);if(St.has(G.status)){if(H)return G;H=true;continue}F&&(b=p),await D(b,i),b=Math.min(b*2,c);}return r(u)}return {async start(u,n){let o=await d(e,"/api/jobs",{method:"POST",headers:{"Content-Type":"application/json",...n?.idempotencyKey?{"Idempotency-Key":n.idempotencyKey}:{}},body:JSON.stringify(u)});return A(await o.json())},get:r,list(u){return S(n=>a({...n,search:u?.search}),u)},trials(u,n){return S(o=>l(u,{...o,status:n?.status,dataset:n?.dataset}),n)},tasks(u,n){return S(async o=>{let i=await d(e,`/api/jobs/${encodeURIComponent(u)}/tasks${x(o)}`);return R(await i.json(),s)},n)},watch(u,n){return jt(g(u,n))},async cancel(u){let n=await d(e,`/api/jobs/${encodeURIComponent(u)}/cancel`,{method:"POST"});return A(await n.json())},async compare(u){let n=u.map(encodeURIComponent).join(","),i=await(await d(e,`/api/jobs/compare?ids=${n}`)).json();return {jobs:(i.jobs||[]).map(kt),taskMatrix:(i.taskMatrix||[]).map(Ot)}},async resume(u,n,o){let i=await d(e,`/api/jobs/${encodeURIComponent(u)}/resume`,{method:"POST",headers:{"Content-Type":"application/json",...o?.idempotencyKey?{"Idempotency-Key":o.idempotencyKey}:{}},body:JSON.stringify(n??{})});return A(await i.json())},async regrade(u,n){let o={};n?.statuses?.length&&(o.statuses=n.statuses),n?.task_name!==void 0&&(o.task_name=n.task_name);let i=await d(e,`/api/jobs/${encodeURIComponent(u)}/regrade`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});return A(await i.json())},download:(async(u,n)=>{let o=await d(e,`/api/jobs/${encodeURIComponent(u)}/download`);if(n?.stream){if(!o.body)throw new Error("Download response has no body");return o.body}if(n?.to)return ot(o,n.to,`job-${u}-results.tar.gz`);let i=Buffer.from(await o.arrayBuffer());return st(o,i.length),await at(o,i),i})}}function $t(t){let e=h("trials",t);async function r(s,l){let g=await d(e,`/api/trials/${encodeURIComponent(s)}/trace${x(l)}`);return R(await g.json(),Jt)}async function a(s,l){let u=await(await d(e,`/api/trials/${encodeURIComponent(s)}/trace?stream=${l}`)).json();return l==="agent-home"?u.files??null:u.log??null}return {async get(s){let l=await d(e,`/api/trials/${encodeURIComponent(s)}`);return V(await l.json())},trace:r,artifact:a,async*traceEvents(s,l){let g=l?.cursor;for(;;){let u=await r(s,{cursor:g,limit:l?.limit});for(let n of u.items)yield n;if(!u.nextCursor)return;g=u.nextCursor;}},async regrade(s){let l=await d(e,`/api/trials/${encodeURIComponent(s)}/regrade`,{method:"POST"});return A(await l.json())},async stop(s){let g=await(await d(e,"/api/trials/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({trial_ids:s})})).json();return {stopped:(g.stopped??[]).map(V),already_terminal:g.already_terminal??[],not_found:g.not_found??[]}}}}function xe(t){let e=h("auth",t);return {async status(){let a=await(await d(e,"/api/auth/status")).json(),s=a.key??{};return {user_id:a.user_id,email:a.email??null,key:{id:s.id,label:s.label??null,created_at:s.created_at,last_used_at:s.last_used_at??null}}}}}function Bt(t){try{let e=JSON.parse(t);return e&&typeof e=="object"?e:{value:e}}catch{return {raw:t}}}function Te(t){let e,r,a,s;return {get datasets(){return e??=Nt(t)},get agents(){return r??=Mt(t)},get jobs(){return a??=Vt(t)},get trials(){return s??=$t(t)},meta(){return Ht(t)}}}async function Ht(t){let e=(t?.baseUrl||process.env.EVOLVE_DASHBOARD_URL||I).replace(/\/$/,""),r=await fetch(`${e}/api/meta`);return r.ok||await B(r),await r.json()}export{de as A,ge as B,dt as C,gt as D,pt as E,Y as F,N as G,T as H,M as I,J,L as K,Nt as L,Mt as M,Vt as N,$t as O,xe as P,Te as Q,Ht as R,lt as a,ct as b,Ft as c,W as d,qt as e,Gt as f,Wt as g,U as h,Kt as i,Yt as j,zt as k,Xt as l,Qt as m,Zt as n,te as o,ee as p,K as q,ne as r,I as s,se as t,ae as u,oe as v,ie as w,ue as x,le as y,ce as z};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';var zlib=require('zlib'),fs$1=require('fs'),promises=require('fs/promises'),path=require('path'),promises$1=require('stream/promises'),tarStream=require('tar-stream'),url=require('url'),yaml=require('yaml'),stream=require('stream');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;var vt=Object.defineProperty;var wt=(e,t)=>()=>(e&&(t=e(e=0)),t);var St=(e,t)=>{for(var n in t)vt(e,n,{get:t[n],enumerable:true});};var me={};St(me,{tarGzipDirectory:()=>Ct});async function Pt(e){let t=[],n=async s=>{let r=s===""?e:path.join(e,s),a=await promises.readdir(r,{withFileTypes:true});a.sort((i,l)=>i.name<l.name?-1:i.name>l.name?1:0);for(let i of a){if(It.has(i.name))continue;let l=s===""?i.name:`${s}/${i.name}`,o=path.join(r,i.name),c=await promises.lstat(o);c.isSymbolicLink()||(c.isDirectory()?await n(l):c.isFile()&&t.push({rel:l,abs:o,mode:c.mode&73?493:420,size:c.size}));}};return await n(""),t.sort((s,r)=>s.rel<r.rel?-1:s.rel>r.rel?1:0)}async function Ct(e){let t=await Pt(e),n=tarStream.pack(),s=zlib.createGzip({level:9}),r=[],a=(async()=>{for await(let l of s)r.push(Buffer.from(l));})(),i=(async()=>{for(let{rel:l,abs:o,mode:c,size:u}of t){let p=n.entry({name:l,size:u,mode:c,mtime:new Date(0),uid:0,gid:0,uname:"",gname:"",type:"file"});await promises$1.pipeline(fs$1.createReadStream(o),p);}n.finalize();})();return await Promise.all([promises$1.pipeline(n,s),i,a]),Buffer.concat(r)}var It,pe=wt(()=>{It=new Set([".git",".DS_Store",".venv"]);});var ue="EVOLVE_API_KEY";var Ie=process.env.EVOLVE_DASHBOARD_URL||"https://dashboard.evolvingmachines.ai";var W=["QUEUED","RUNNING","SCORING","SCORED","SCORING_ERROR","INFRASTRUCTURE_ERROR","INDETERMINATE","CANCELLED"],Y=["e2b","daytona","modal"],ce=["trace-parsed","verifier","trace-stdout","trace-stderr","trajectory","agent-home"],Pe=["missing_authorization","invalid_api_key","credential_service_unavailable","rate_limited","insufficient_credits","invalid_json","invalid_input","invalid_limit","invalid_status","invalid_cursor","invalid_after","invalid_format","invalid_ids","invalid_multipart","idempotency_key_reused","dataset_not_found","dataset_version_not_found","dataset_name_taken","dataset_in_use","dataset_not_owned","upstream_not_watchable","no_active_version","version_not_ready","version_not_activatable","unknown_task_names","no_tasks","agent_not_found","agent_name_taken","agent_name_reserved","agent_invalid_name","agent_source_required","agent_source_conflict","agent_invalid_env","agent_too_large","agent_limit_reached","agent_version_not_found","job_too_large","provider_unsupported","job_not_found","job_not_terminal","no_failed_trials","trial_not_found","concurrent_update","regrade_source_ineligible","no_regradable_trials","import_not_found","import_too_large","invalid_archive","package_not_retained","package_corrupt","package_missing","internal_error"];function de(e){return typeof e=="string"&&Pe.includes(e)}var T=class extends Error{status;code;param;details;retryAfterSec;requestId;constructor(t,n,s,r){super(s),this.name="EvolveApiError",this.status=t,this.code=n,r?.param!==void 0&&(this.param=r.param),r?.details!==void 0&&(this.details=r.details),r?.retryAfterSec!==void 0&&(this.retryAfterSec=r.retryAfterSec),r?.requestId!==void 0&&(this.requestId=r.requestId);}isKnownCode(){return de(this.code)}};function Le(e,t){try{let a=JSON.parse(e)?.error?.retryAfterSec;if(typeof a=="number"&&Number.isFinite(a))return a}catch{}let n=t.headers?.get?.("retry-after");if(typeof n!="string"||n.trim()==="")return;let s=Number(n);return Number.isFinite(s)?s:void 0}async function Je(e){let t=await e.text().catch(()=>""),n=e.headers?.get?.("x-request-id")??void 0,s=Le(t,e);try{let r=JSON.parse(t);if(r?.error&&typeof r.error=="object"){let a=typeof r.error.code=="string"?r.error.code:"unknown_error",i=typeof r.error.message=="string"?r.error.message:e.statusText;throw new T(e.status,a,i,{param:typeof r.error.param=="string"?r.error.param:void 0,details:r.error.details&&typeof r.error.details=="object"?r.error.details:void 0,retryAfterSec:s,requestId:typeof r.error.requestId=="string"?r.error.requestId:n})}}catch(r){if(r instanceof T)throw r}throw new T(e.status,"unknown_error",t||e.statusText,{retryAfterSec:s,requestId:n})}var ge=class extends Error{dataset;constructor(t){super(`Dataset "${t}" has no active version`),this.name="NoActiveVersionError",this.dataset=t;}},Mt=1e3,Ft=3e4,Vt=new Set(["COMPLETED","CANCELLED","FAILED"]),qt=new Set(["job.completed","job.cancelled","job.failed"]),Bt=2e3,Gt=new Set(["COMPLETED","FAILED"]);function V(e,t){let n=t?.apiKey||process.env[ue];if(!n)throw new Error(`${e}() requires an API key. Set ${ue} or pass { apiKey } in config.`);let s=(t?.baseUrl||process.env.EVOLVE_DASHBOARD_URL||Ie).replace(/\/$/,"");return {apiKey:n,baseUrl:s}}async function b(e,t,n){let s=await fetch(`${e.baseUrl}${t}`,{...n,headers:{Authorization:`Bearer ${e.apiKey}`,...n?.headers}});return s.ok||await Je(s),s}function De(e){let t=e.indexOf("@");if(t===-1)return {name:e.trim()};let n=e.slice(0,t).trim(),s=e.slice(t+1).trim();if(!n||!s)throw new Error(`Invalid dataset ref "${e}": expected "name" or "name@version"`);return {name:n,version:s}}function Ne(e){return {name:e.name,version:e.version}}function Ue(e){return {name:e.name,model_name:e.model_name,version:e.version??null,reasoning_effort:e.reasoning_effort??null}}function z(e){return {version:e.version,state:e.state,created_at:e.created_at,task_count:e.task_count??0}}function Ht(e){return {task_name:e.task_name,agent_timeout_sec:e.agent_timeout_sec,verifier_timeout_sec:e.verifier_timeout_sec,providers:e.providers}}function Kt(e){return {action:e.action,type:e.type,job_id:e.job_id}}function C(e){let t=e.trials??{};return {id:e.id,job_name:e.job_name,status:e.status,datasets:(e.datasets??[]).map(Ne),agents:(e.agents??[]).map(Ue),n_attempts:e.n_attempts,n_concurrent_trials:e.n_concurrent_trials,max_trial_spend_usd:e.max_trial_spend_usd,worst_case_spend_usd:e.worst_case_spend_usd,sandbox_provider:e.sandbox_provider,counts:e.counts,n_total_trials:e.n_total_trials??0,trials:{total:t.total??0,byStatus:t.byStatus??{}},stats:e.stats??{},failure:e.failure??null,source_jobs:(e.source_jobs??[]).map(Kt),is_regrade:e.is_regrade===true,idempotent_replay:e.idempotent_replay===true,started_at:e.started_at,updated_at:e.updated_at,finished_at:e.finished_at??null}}function E(e,t){let n=e??{};return {items:Array.isArray(n.items)?n.items.map(t):[],nextCursor:n.nextCursor??null,hasMore:n.hasMore===true}}function O(e,t){let n=new URLSearchParams;e?.limit!==void 0&&n.set("limit",String(e.limit)),e?.cursor&&n.set("cursor",e.cursor);for(let[r,a]of Object.entries(t??{}))a!==void 0&&n.set(r,a);let s=n.toString();return s?`?${s}`:""}function X(e){if(!e||typeof e!="object")return null;let t=e;return {started_at:t.started_at??null,finished_at:t.finished_at??null}}function Wt(e){let t=e.model_info??{};return {name:e.name,version:e.version??null,model_info:{name:t.name,provider:t.provider??null},reasoning_effort:e.reasoning_effort??null}}function fe(e){return {id:e.id,job_id:e.job_id,task_name:e.task_name,source:e.source,agent_info:Wt(e.agent_info||{}),attempt:e.attempt,status:e.status,reward:e.reward??null,verifier_result:e.verifier_result??null,exception_info:e.exception_info??null,agent_result:e.agent_result??null,environment_setup:X(e.environment_setup),agent_setup:X(e.agent_setup),agent_execution:X(e.agent_execution),verifier:X(e.verifier),step_results:e.step_results??null,spend_source:e.spend_source??null,live_spent_usd:e.live_spent_usd??null,live_spend_at:e.live_spend_at??null,max_trial_spend_usd:e.max_trial_spend_usd??null,sandbox_provider:e.sandbox_provider??null,sandbox_id:e.sandbox_id??null,verifier_sandbox_id:e.verifier_sandbox_id??null,verifier_environment_mode:e.verifier_environment_mode??null,attempt_phase:e.attempt_phase??null,session_ref:e.session_ref??null,started_at:e.started_at??null,finished_at:e.finished_at??null}}function Q(e){return {name:e.name,source:e.source,run_command:e.run_command,env:e.env??{},created_at:e.created_at,updated_at:e.updated_at}}function Z(e){let t={id:e.id,status:e.status,name:e.name,version:e.version,failure:e.failure??null,warnings:e.warnings??[]};return typeof e.task_count=="number"&&(t.task_count=e.task_count),typeof e.created_at=="string"&&(t.created_at=e.created_at),typeof e.updated_at=="string"&&(t.updated_at=e.updated_at),t}function Me(e){let t=e??{};return {scored:t.scored??0,total:t.total??0}}function Yt(e){return {id:e.id,datasets:(e.datasets??[]).map(Ne),status:e.status,mean_reward:e.mean_reward??null,coverage:Me(e.coverage),cost_usd:e.cost_usd??0,agents:(e.agents||[]).map(Ue),started_at:e.started_at}}function zt(e){return {job_id:e.job_id,status:e.status,mean_reward:e.mean_reward??null,coverage:Me(e.coverage)}}function Xt(e){return {task_name:e.task_name,disagreement:e.disagreement===true,cells:(e.cells||[]).map(zt)}}function Qt(e){return {seq:e.seq,type:e.type,data:e.data??{}}}function be(e){if(e?.aborted)throw e.reason instanceof Error?e.reason:new Error("Watch aborted")}function $e(e,t){return t?.aborted?true:e?.name==="AbortError"}function F(e,t){return new Promise((n,s)=>{let r=setTimeout(()=>{t?.removeEventListener("abort",a),n();},e),a=()=>{clearTimeout(r),s(t?.reason instanceof Error?t.reason:new Error("Watch aborted"));};t?.addEventListener("abort",a,{once:true});})}function Zt(e){let t="",n=false;return {push(s){n&&(s="\r"+s,n=false),s.endsWith("\r")&&(s=s.slice(0,-1),n=true),t+=s.replace(/\r\n|\r/g,`
|
|
3
|
+
`);let r;for(;(r=t.indexOf(`
|
|
4
|
+
|
|
5
|
+
`))!==-1;){let a=t.slice(0,r);t=t.slice(r+2);let i,l,o=[];for(let c of a.split(`
|
|
6
|
+
`)){if(!c||c.startsWith(":"))continue;let u=c.indexOf(":"),p=u===-1?c:c.slice(0,u),d=u===-1?"":c.slice(u+1);d.startsWith(" ")&&(d=d.slice(1)),p==="id"?i=d:p==="event"?l=d:p==="data"&&o.push(d);}(i!==void 0||l!==void 0||o.length>0)&&e({id:i,event:l,data:o.join(`
|
|
7
|
+
`)});}}}}function L(e,t){let n,s=()=>n??=e({limit:t?.limit,cursor:t?.cursor});return {then(r,a){return s().then(r,a)},catch(r){return s().catch(r)},finally(r){return s().finally(r)},async*[Symbol.asyncIterator](){let r=t?.cursor;for(;;){let a=await e({limit:t?.limit,cursor:r});for(let i of a.items)yield i;if(!a.nextCursor)return;r=a.nextCursor;}}}}function ee(e,t){let n=new FormData;for(let[s,r]of Object.entries(e))r!==void 0&&n.set(s,r);return t&&n.set("archive",new Blob([t.bytes],{type:"application/gzip"}),t.filename),n}function en(e){let t,n=()=>(t||(t=(async()=>{let s=await e.next();for(;!s.done;)s=await e.next();return s.value})()),t);return {then(s,r){return n().then(s,r)},catch(s){return n().catch(s)},finally(s){return n().finally(s)},[Symbol.asyncIterator](){return e}}}var Fe="x-package-sha256",te=class extends Error{constructor(n,s){super(`downloaded bytes do not match the digest the server stated (expected ${n}, got ${s})`);this.expected=n;this.actual=s;}name="EvolveDigestMismatchError"},ne=class extends Error{constructor(n,s){super(`download ended early: the server declared ${n} bytes and ${s} arrived`);this.expectedBytes=n;this.receivedBytes=s;}name="EvolveIncompleteDownloadError"};function Ve(e,t){let n=e.headers.get("Content-Length");if(n===null)return;let s=Number(n);if(Number.isFinite(s)&&t!==s)throw new ne(s,t)}async function qe(e,t){let n=e.headers.get(Fe);if(!n)return;let{createHash:s}=await import('crypto'),r=s("sha256").update(t).digest("hex");if(r!==n)throw new te(n,r)}function tn(e,t){let s=(e.headers.get("Content-Disposition")||"").match(/filename="([^"]+)"/);if(!s)return t;let r=path.basename(s[1]);return r===""||r==="."||r===".."||/[/\\]/.test(r)||/[\u0000-\u001f]/.test(r)?t:r}async function Be(e,t,n){if(!e.body)throw new Error("Download response has no body");await promises.mkdir(t,{recursive:true});let s=path.join(t,tn(e,n)),{createHash:r,randomBytes:a}=await import('crypto'),i=`${s}.${a(8).toString("hex")}.part`,l=r("sha256"),o=0,c=stream.Readable.fromWeb(e.body);c.on("data",u=>{l.update(u),o+=u.length;});try{await promises$1.pipeline(c,fs$1.createWriteStream(i));let u=e.headers.get("Content-Length");if(u!==null&&o!==Number(u))throw new ne(Number(u),o);let p=e.headers.get(Fe),d=l.digest("hex");if(p&&d!==p)throw new te(p,d);await promises.rename(i,s);}catch(u){throw await promises.rm(i,{force:true}).catch(()=>{}),u}return s}function J(e){let t=V("datasets",e);async function n(o){let c=await b(t,`/api/datasets/imports/${encodeURIComponent(o)}`);return Z(await c.json())}function s(o){if(!o||typeof o!="object")return null;let c=o;return {ref:c.ref,current_commit:c.current_commit,latest_commit:c.latest_commit??null,moved:c.moved===true,behind_by:typeof c.behind_by=="number"?c.behind_by:null,checked_at:c.checked_at??null,error:c.error??null,auto_import:c.auto_import===true}}function r(o){return {name:o.name,title:o.title??null,description:o.description??null,active_version:o.active_version?z(o.active_version):null,versions:(o.versions||[]).map(z),selected_version:o.selected_version?z(o.selected_version):null,tasks:E(o.tasks,Ht),upstream:s(o.upstream),created_at:o.created_at,updated_at:o.updated_at}}async function a(o,c){let u=De(o),p=O(c,{version:u.version}),d=await b(t,`/api/datasets/${encodeURIComponent(u.name)}${p}`);return r(await d.json())}function i(o){return {name:o.name,title:o.title??null,description:o.description??null,active_version:o.active_version?z(o.active_version):null,upstream:s(o.upstream)}}async function l(o){let c=await b(t,`/api/datasets${O(o,{search:o?.search})}`);return E(await c.json(),i)}return {list(o){return L(c=>l({...c,search:o?.search}),o)},get:a,async getActive(o,c){let u=await a(o,c);if(u.active_version===null)throw new ge(o);return {name:u.name,title:u.title,description:u.description,active_version:u.active_version,version:u.active_version.version,tasks:u.tasks??{items:[],nextCursor:null,hasMore:false},versions:u.versions??[],created_at:u.created_at,updated_at:u.updated_at}},async publish(o){let c=o.source;if(c?.directory){let{tarGzipDirectory:u}=await Promise.resolve().then(()=>(pe(),me)),p=await u(c.directory),d=await b(t,"/api/datasets/publish",{method:"POST",body:ee({name:o.name,version:o.version},{bytes:p,filename:"corpus.tar.gz"})});return Z(await d.json())}if(c&&"git_url"in c&&c.git_url){let u=await b(t,"/api/datasets/publish",{method:"POST",body:ee({name:o.name,version:o.version,git_url:c.git_url,git_ref:c.git_ref})});return Z(await u.json())}throw new Error("datasets().publish() requires either a git source ({ source: { git_url, git_ref } }) or a local corpus directory ({ source: { directory } }), plus name and version")},getImport:n,async watchImport(o,c){let u=c?.pollIntervalMs??Bt,p=null;for(;;){be(c?.signal);let d;try{d=await n(o);}catch(m){if(m instanceof T&&(m.status===429||m.status===503)){await F(Math.max((m.retryAfterSec??0)*1e3,u),c?.signal);continue}throw m}if(d.status!==p&&(p=d.status,c?.onStatus?.(d)),Gt.has(d.status))return d;await F(u,c?.signal);}},download:(async(o,c)=>{let u=De(o),p=u.version?`?version=${encodeURIComponent(u.version)}`:"",d=await b(t,`/api/datasets/${encodeURIComponent(u.name)}/download${p}`);if(c?.stream){if(!d.body)throw new Error("Package response has no body");return d.body}if(c?.to)return Be(d,c.to,`${u.name}-corpus.tar.gz`);let m=Buffer.from(await d.arrayBuffer());return Ve(d,m.length),await qe(d,m),m}),listImports(o){return L(async c=>{let u=new URLSearchParams;c.limit!==void 0&&u.set("limit",String(c.limit)),c.cursor!==void 0&&u.set("cursor",c.cursor),o?.status!==void 0&&u.set("status",o.status),o?.dataset!==void 0&&u.set("dataset",o.dataset);let p=u.toString()?`?${u}`:"",d=await b(t,`/api/datasets/imports${p}`);return E(await d.json(),Z)},o)},async activate(o,c){let u=await b(t,`/api/datasets/${encodeURIComponent(o)}/versions/${encodeURIComponent(c)}/activate`,{method:"POST"});return r(await u.json())},async update(o,c){let u=await b(t,`/api/datasets/${encodeURIComponent(o)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});return i(await u.json())},async delete(o){await b(t,`/api/datasets/${encodeURIComponent(o)}`,{method:"DELETE"});}}}function q(e){let t=V("agents",e);return {async create(n){let s=await je("agents().create()",n),r=await b(t,"/api/agents",{method:"POST",body:s});return Q(await r.json())},list(n){return L(async s=>{let r=await b(t,`/api/agents${O(s)}`);return E(await r.json(),Q)},n)},async get(n){let s=await b(t,`/api/agents/${encodeURIComponent(n)}`);return Q(await s.json())},async delete(n){await b(t,`/api/agents/${encodeURIComponent(n)}`,{method:"DELETE"});},async upsert(n,s){let r=await je("agents().upsert()",{...s,name:n}),a=await b(t,`/api/agents/${encodeURIComponent(n)}`,{method:"PUT",body:r});return Q(await a.json())}}}async function je(e,t){let n=typeof t.install_script=="string",s=typeof t.directory=="string";if(n&&s)throw new Error(`${e} takes EITHER an install script ({ install_script }) or a local directory ({ directory }), not both`);if(!n&&!s)throw new Error(`${e} requires either an install script ({ install_script }) or a local directory ({ directory }), plus run_command`);let r={name:t.name,run_command:t.run_command,...t.env!==void 0?{env:JSON.stringify(t.env)}:{},...n?{install_script:t.install_script}:{}};if(s){let{tarGzipDirectory:a}=await Promise.resolve().then(()=>(pe(),me)),i=await a(t.directory);return ee(r,{bytes:i,filename:"source.tar.gz"})}return ee(r)}function S(e){let t=V("jobs",e);async function n(l){let o=await b(t,`/api/jobs/${encodeURIComponent(l)}`);return C(await o.json())}async function s(l){let o=await b(t,`/api/jobs${O(l,{search:l?.search})}`);return E(await o.json(),C)}function r(l){let o=l.trials??{};return {task_name:l.task_name,source:l.source,trials:{total:o.total??0,byStatus:o.byStatus??{}},mean_reward:l.mean_reward??null,cost_usd:l.cost_usd??null}}async function a(l,o){let c=O(o,{status:o?.status?.length?o.status.join(","):void 0,dataset:o?.dataset}),u=await b(t,`/api/jobs/${encodeURIComponent(l)}/trials${c}`);return E(await u.json(),fe)}async function*i(l,o){let{onEvent:c,signal:u}=o??{},p=o?.reconnectDelayMs??Mt,d=o?.maxReconnectDelayMs??Ft,m=null,f=false,y=false,h=p;for(;!f;){be(u);let v;try{v=await fetch(`${t.baseUrl}/api/jobs/${encodeURIComponent(l)}/events`,{headers:{Authorization:`Bearer ${t.apiKey}`,Accept:"text/event-stream",...m!==null?{"Last-Event-ID":String(m)}:{}},signal:u});}catch(w){if($e(w,u))throw w;await F(h,u),h=Math.min(h*2,d);continue}if(!v.ok){if(v.status===429||v.status>=500){let w=await v.text().catch(()=>""),A=Le(w,v)??0,P=A>0?Math.max(A*1e3,h):h;await F(P,u),h=Math.min(h*2,d);continue}await Je(v);}if(!v.body)throw new Error("Event stream response has no body");let M=false,le=[],ht=Zt(w=>{let A=Number(w.id),P={seq:Number.isInteger(A)?A:-1,type:w.event||"message",data:w.data?nn(w.data):{}};Number.isInteger(A)&&(m=A),M=true,qt.has(P.type)&&(f=true),le.push(P);}),Te=v.body.getReader(),yt=new TextDecoder;try{for(;!f;){let{done:w,value:A}=await Te.read();if(w)break;ht.push(yt.decode(A,{stream:!0}));for(let P of le)c?.(P),yield P;le.length=0;}}catch(w){if($e(w,u))throw w}finally{await Te.cancel().catch(()=>{});}if(f)break;be(u);let Ee=await n(l);if(Vt.has(Ee.status)){if(y)return Ee;y=true;continue}M&&(h=p),await F(h,u),h=Math.min(h*2,d);}return n(l)}return {async start(l,o){let c=await b(t,"/api/jobs",{method:"POST",headers:{"Content-Type":"application/json",...o?.idempotencyKey?{"Idempotency-Key":o.idempotencyKey}:{}},body:JSON.stringify(l)});return C(await c.json())},get:n,list(l){return L(o=>s({...o,search:l?.search}),l)},trials(l,o){return L(c=>a(l,{...c,status:o?.status,dataset:o?.dataset}),o)},tasks(l,o){return L(async c=>{let u=await b(t,`/api/jobs/${encodeURIComponent(l)}/tasks${O(c)}`);return E(await u.json(),r)},o)},watch(l,o){return en(i(l,o))},async cancel(l){let o=await b(t,`/api/jobs/${encodeURIComponent(l)}/cancel`,{method:"POST"});return C(await o.json())},async compare(l){let o=l.map(encodeURIComponent).join(","),u=await(await b(t,`/api/jobs/compare?ids=${o}`)).json();return {jobs:(u.jobs||[]).map(Yt),taskMatrix:(u.taskMatrix||[]).map(Xt)}},async resume(l,o,c){let u=await b(t,`/api/jobs/${encodeURIComponent(l)}/resume`,{method:"POST",headers:{"Content-Type":"application/json",...c?.idempotencyKey?{"Idempotency-Key":c.idempotencyKey}:{}},body:JSON.stringify(o??{})});return C(await u.json())},async regrade(l,o){let c={};o?.statuses?.length&&(c.statuses=o.statuses),o?.task_name!==void 0&&(c.task_name=o.task_name);let u=await b(t,`/api/jobs/${encodeURIComponent(l)}/regrade`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});return C(await u.json())},download:(async(l,o)=>{let c=await b(t,`/api/jobs/${encodeURIComponent(l)}/download`);if(o?.stream){if(!c.body)throw new Error("Download response has no body");return c.body}if(o?.to)return Be(c,o.to,`job-${l}-results.tar.gz`);let u=Buffer.from(await c.arrayBuffer());return Ve(c,u.length),await qe(c,u),u})}}function N(e){let t=V("trials",e);async function n(r,a){let i=await b(t,`/api/trials/${encodeURIComponent(r)}/trace${O(a)}`);return E(await i.json(),Qt)}async function s(r,a){let l=await(await b(t,`/api/trials/${encodeURIComponent(r)}/trace?stream=${a}`)).json();return a==="agent-home"?l.files??null:l.log??null}return {async get(r){let a=await b(t,`/api/trials/${encodeURIComponent(r)}`);return fe(await a.json())},trace:n,artifact:s,async*traceEvents(r,a){let i=a?.cursor;for(;;){let l=await n(r,{cursor:i,limit:a?.limit});for(let o of l.items)yield o;if(!l.nextCursor)return;i=l.nextCursor;}},async regrade(r){let a=await b(t,`/api/trials/${encodeURIComponent(r)}/regrade`,{method:"POST"});return C(await a.json())},async stop(r){let i=await(await b(t,"/api/trials/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({trial_ids:r})})).json();return {stopped:(i.stopped??[]).map(fe),already_terminal:i.already_terminal??[],not_found:i.not_found??[]}}}}function Ge(e){let t=V("auth",e);return {async status(){let s=await(await b(t,"/api/auth/status")).json(),r=s.key??{};return {user_id:s.user_id,email:s.email??null,key:{id:r.id,label:r.label??null,created_at:r.created_at,last_used_at:r.last_used_at??null}}}}}function nn(e){try{let t=JSON.parse(e);return t&&typeof t=="object"?t:{value:t}}catch{return {raw:e}}}var g=class extends Error{constructor(t){super(t),this.name="CliUsageError";}},Re={json:{kind:"boolean",help:"Machine-readable JSON output"},"api-key":{kind:"string",value:"<key>",help:"API key (default: $EVOLVE_API_KEY)"},"base-url":{kind:"string",value:"<url>",help:"API base URL (default: the Evolve dashboard API)"}},B={limit:{kind:"number",short:"l",value:"<n>",help:"Page size"},cursor:{kind:"string",value:"<c>",help:"Resume from a page cursor"},columns:{kind:"string",value:"<keys|all|help>",help:"Choose and order columns (comma-separated keys; 'help' lists them)"},quiet:{kind:"boolean",short:"q",help:"Print only ids, one per line (for piping)"},"no-trunc":{kind:"boolean",help:"Full cell content instead of one-line truncation"},"no-headers":{kind:"boolean",help:"Omit the header row in piped (TSV) output"}},un={config:{kind:"string",short:"c",value:"<path>",help:"Job config file (YAML or JSON, spec vocabulary); explicit flags override its fields"},"print-config":{kind:"boolean",help:"Print the resolved job body as JSON and exit without running"},"job-name":{kind:"string",value:"<name>",help:"User-facing label (server-generated when omitted)"},dataset:{kind:"repeat",short:"d",value:"<name[@version]>",help:"Dataset to run (repeatable; bare name = active version)"},"include-task-name":{kind:"repeat",short:"i",value:"<glob>",help:"Include filter over task names, applied to every dataset (repeatable)"},"exclude-task-name":{kind:"repeat",short:"x",value:"<glob>",help:"Exclude filter over task names, applied to every dataset (repeatable)"},"n-tasks":{kind:"number",short:"l",value:"<n>",help:"Cap the task count of EACH dataset after filters"},agent:{kind:"string",short:"a",value:"<name[@version]>",help:"Agent (built-in or registered)"},model:{kind:"repeat",short:"m",value:"<name>",help:"Model (repeatable; each model is one arm)"},effort:{kind:"string",value:"<value>",help:"Reasoning effort for EVERY arm (values: GET /api/meta). Applied verbatim \u2014 an agent that cannot honor it is refused by the server, never silently skipped"},"agent-env":{kind:"repeat",aliases:["ae"],value:"KEY=VALUE",help:"Env for every agent run (repeatable); a pass-through slot the server owns"},"verifier-env":{kind:"repeat",aliases:["ve"],value:"KEY=VALUE",help:"Env for every verifier run (repeatable); a pass-through slot the server owns"},"n-attempts":{kind:"number",short:"k",value:"<n>",help:"Attempts per task x arm (default 1)"},"n-concurrent":{kind:"number",short:"n",value:"<n>",help:"Parallel trials (default 4)"},"max-trial-spend":{kind:"number",value:"<usd>",help:"Model-spend cap for EACH trial (default: the server's, $200)"},env:{kind:"string",short:"e",value:"<provider>",help:"Sandbox provider: e2b | daytona | modal (default e2b)"},watch:{kind:"boolean",help:"Stream events until the job finishes"},quiet:{kind:"boolean",short:"q",help:"With --watch: suppress the event log, print the final block only"},yes:{kind:"boolean",short:"y",help:"Accepted for compatibility; hosted runs have no prompt to confirm"}},G={job:{summary:"Start, follow, and derive jobs",commands:{start:{summary:"Start a job (add --watch to follow it)",flags:un,minPositionals:0,maxPositionals:0,example:"evolve-evals job start -d deep-swe@1.1 -a codex -m gpt-5.5 -k 2 --watch"},list:{summary:"List your jobs (newest first)",flags:{...B,search:{kind:"string",value:"<text>",help:"Free-text filter over job name and dataset names"}},minPositionals:0,maxPositionals:0,example:"evolve-evals job list --limit 20 -q"},show:{summary:"Show one or more jobs in full",flags:{},minPositionals:1,maxPositionals:1/0,positionalUsage:"<id> [id...]",example:"evolve-evals job show cme12ab34"},trials:{summary:"List a job's trials",flags:{...B,status:{kind:"string",value:"<s1,s2,...>",help:"Filter by trial status (e.g. INFRASTRUCTURE_ERROR)"},dataset:{kind:"string",value:"<name>",help:"Filter to one dataset's trials"}},minPositionals:1,maxPositionals:1,positionalUsage:"<id>",example:"evolve-evals job trials cme12ab34 --status FAILED,SCORING_ERROR"},tasks:{summary:"Per-task rollup of a job",flags:{...B},minPositionals:1,maxPositionals:1,positionalUsage:"<id>",example:"evolve-evals job tasks cme12ab34"},compare:{summary:"Compare 2-10 jobs side by side",flags:{},minPositionals:2,maxPositionals:10,positionalUsage:"<id> <id> [...]",example:"evolve-evals job compare cme12ab34 cme56cd78"},cancel:{summary:"Request cancellation of a job",flags:{},minPositionals:1,maxPositionals:1,positionalUsage:"<id>",example:"evolve-evals job cancel cme12ab34"},stop:{summary:"Stop one dataset's live trials without cancelling the job",flags:{dataset:{kind:"string",value:"<name>",help:"The dataset whose live trials to stop (required)"}},minPositionals:1,maxPositionals:1,positionalUsage:"<id>",example:"evolve-evals job stop cme12ab34 --dataset deep-swe"},resume:{summary:"New linked job over a terminal job's failed or stopped trials",flags:{"filter-error-type":{kind:"repeat",short:"f",value:"<type>",help:"Failure types to resume, matched on exception_info.exception_type (repeatable; default: the standard failure set plus stopped trials)"}},minPositionals:1,maxPositionals:1,positionalUsage:"<id>",example:"evolve-evals job resume cme12ab34 -f InfrastructureError"},regrade:{summary:"Verifier-only re-run of a terminal job (the result IS a job)",flags:{status:{kind:"string",value:"<s1,s2,...>",help:"Only regrade source trials in these statuses"},task:{kind:"string",value:"<name>",help:"Only regrade source trials of this task"}},minPositionals:1,maxPositionals:1,positionalUsage:"<id>",example:"evolve-evals job regrade cme12ab34 --task tricky-task"},download:{summary:"Download the results archive (gzipped)",flags:{"output-dir":{kind:"string",short:"o",value:"<dir>",help:"Directory to save into (default: current dir)"}},minPositionals:1,maxPositionals:1,positionalUsage:"<id>",example:"evolve-evals job download cme12ab34 -o results/"}}},trial:{summary:"Inspect, download, and act on single trials",commands:{show:{summary:"Show one trial in full detail",flags:{},minPositionals:1,maxPositionals:1,positionalUsage:"<trial-id>",example:"evolve-evals trial show cmt90ef12"},download:{summary:"Save everything a trial recorded, or stream one artifact",flags:{"output-dir":{kind:"string",short:"o",value:"<dir>",help:"Directory to save under (default: trials/); files land in <dir>/<trial-id>/"},overwrite:{kind:"boolean",help:"Replace an existing <dir>/<trial-id>/"},stream:{kind:"string",value:"<artifact>",help:"Print ONE artifact to stdout instead of saving: trace-parsed | verifier | trace-stdout | trace-stderr | trajectory (not served yet) | agent-home"},cursor:{kind:"string",value:"<seq>",help:"With --stream trace-parsed: resume after this seq"},limit:{kind:"number",value:"<n>",help:"With --stream trace-parsed: max events per page"}},minPositionals:1,maxPositionals:1,positionalUsage:"<trial-id>",example:"evolve-evals trial download cmt90ef12 --stream trace-stdout"},regrade:{summary:"Verifier-only re-run of one trial (the result IS a job)",flags:{},minPositionals:1,maxPositionals:1,positionalUsage:"<trial-id>",example:"evolve-evals trial regrade cmt90ef12"},stop:{summary:"Stop in-flight trials without cancelling their job",flags:{},minPositionals:1,maxPositionals:1/0,positionalUsage:"<trial-id> [trial-id...]",example:"evolve-evals trial stop cmt90ef12 cmt34gh56"}}},dataset:{summary:"Browse and publish the dataset catalog",commands:{list:{summary:"List the dataset catalog",flags:{...B,search:{kind:"string",value:"<text>",help:"Free-text filter over name and description"}},minPositionals:0,maxPositionals:0,example:"evolve-evals dataset list -q"},show:{summary:"Show one dataset (versions + tasks + providers)",flags:{limit:{kind:"number",short:"l",value:"<n>",help:"Task-list page size"},cursor:{kind:"string",value:"<c>",help:"Resume the task list from a cursor"}},minPositionals:1,maxPositionals:1,positionalUsage:"<name[@version]>",example:"evolve-evals dataset show deep-swe@1.1"},publish:{summary:"Publish a dataset version from a git source or a local directory",flags:{git:{kind:"string",value:"<url>",help:"Git repository URL (with --ref)"},ref:{kind:"string",value:"<ref>",help:"Git ref: branch, tag, or commit (with --git)"},dir:{kind:"string",value:"<path>",help:"Local corpus directory (tarred + uploaded)"},name:{kind:"string",value:"<dataset>",help:"Catalog dataset name to create or extend (required)"},version:{kind:"string",value:"<v>",help:"Version label for the published version (required)"},watch:{kind:"boolean",help:"Poll until the publish is COMPLETED or FAILED"}},minPositionals:0,maxPositionals:0,example:"evolve-evals dataset publish --name my-swe --version 1.0 --dir ./corpus --watch"},download:{summary:"Download the original corpus package (owner only)",flags:{"output-dir":{kind:"string",short:"o",value:"<dir>",help:"Directory to save into (default: current dir)"}},minPositionals:1,maxPositionals:1,positionalUsage:"<name[@version]>",example:"evolve-evals dataset download my-swe@1.0 -o corpora/"},activate:{summary:"Make a READY version the dataset's active version",flags:{},minPositionals:2,maxPositionals:2,positionalUsage:"<name> <version>",example:"evolve-evals dataset activate my-swe 1.0"}}},agent:{summary:"Register and manage your own agents",commands:{list:{summary:"List your registered agents",flags:{...B},minPositionals:0,maxPositionals:0,example:"evolve-evals agent list"},show:{summary:"Show one registered agent",flags:{},minPositionals:1,maxPositionals:1,positionalUsage:"<name>",example:"evolve-evals agent show acme-cli"},add:{summary:"Register an agent (install script or local directory)",flags:{"install-script":{kind:"string",value:"<path>",help:"Install script file; its contents are uploaded"},dir:{kind:"string",value:"<path>",help:"Local agent directory (tarred + uploaded)"},run:{kind:"string",value:"<command>",help:"Run command, executed with sh -c (required)"},"agent-env":{kind:"repeat",aliases:["ae"],value:"KEY=VALUE",help:"Env injected at run time (repeatable)"}},minPositionals:1,maxPositionals:1,positionalUsage:"<name>",example:'evolve-evals agent add acme-cli --install-script ./install.sh --run "acme-cli --headless"'},remove:{summary:"Delete a registered agent (past jobs keep their record)",flags:{},minPositionals:1,maxPositionals:1,positionalUsage:"<name>",example:"evolve-evals agent remove acme-cli"}}},auth:{summary:"Identity and API keys",commands:{status:{summary:"Who am I: the caller and the API key in use",flags:{},minPositionals:0,maxPositionals:0,example:"evolve-evals auth status"}}}},it={jobs:"job",trials:"trial",datasets:"dataset",agents:"agent"},lt={ls:"list"};function cn(e,t){return `${[...t.short?[`-${t.short}`]:[],...(t.aliases??[]).map(s=>`--${s}`),`--${e}`].join(", ")}${t.value?` ${t.value}`:""}`}function he(e){let t=Object.entries(e);if(t.length===0)return [];let n=t.map(([r,a])=>cn(r,a)),s=Math.min(Math.max(...n.map(r=>r.length)),36);return t.map(([,r],a)=>{let i=n[a];return i.length>s?` ${i}
|
|
8
|
+
${"".padEnd(s)} ${r.help}`:` ${i.padEnd(s)} ${r.help}`})}function dn(e,t,n){let s=n.positionalUsage?` ${n.positionalUsage}`:"",r=Object.keys(n.flags).length>0?" [options]":"",a=[`Usage: evolve-evals ${e} ${t}${s}${r}`,"",n.summary];return Object.keys(n.flags).length>0&&a.push("","Options:",...he(n.flags)),a.push("","Global options:",...he(Re)),a.push("","Example:",` ${n.example}`),a.join(`
|
|
9
|
+
`)}function He(e){let t=G[e],n=[`Usage: evolve-evals ${e} <command> [options]`,"",t.summary,"","Commands:"],s=Math.max(...Object.keys(t.commands).map(r=>r.length));for(let[r,a]of Object.entries(t.commands))n.push(` ${r.padEnd(s)} ${a.summary}`);return n.push("",`Run "evolve-evals ${e} <command> --help" for flags and an example.`),n.join(`
|
|
10
|
+
`)}function ye(){let e=["evolve-evals \u2014 Evolve hosted jobs CLI","","Usage: evolve-evals <command> [options]","","Commands:"," run Start a job \u2014 alias for `job start`"];for(let[t,n]of Object.entries(G)){let s=Object.keys(n.commands).join(" | ");e.push(` ${t.padEnd(22)} ${n.summary}`),e.push(` ${"".padEnd(22)} ${s}`);}return e.push(" help [command] Show help (also -h/--help on any command)","","Global options:",...he(Re)," -v, --version Print the CLI version","","Example:"," evolve-evals run -d deep-swe@1.1 -a codex -m gpt-5.5 --watch"),e.join(`
|
|
11
|
+
`)}var Ys=ye();function mn(){try{return JSON.parse(fs$1.readFileSync(url.fileURLToPath(new URL("../../package.json",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)))),"utf-8")).version??"unknown"}catch{return "unknown"}}function ve(e,t){let n=[e.flags,Re];for(let s of n)for(let[r,a]of Object.entries(s))if(t.long!==void 0){if(r===t.long||(a.aliases??[]).includes(t.long))return {name:r,flag:a}}else if(t.short!==void 0&&a.short===t.short)return {name:r,flag:a}}function pn(e,t){if(t==="--help"||t==="-h")return true;if(t.startsWith("--")){let n=t.slice(2).split("=")[0];return ve(e,{long:n})!==void 0}if(t.startsWith("-")&&t.length>1){let n=t.slice(1).split("=")[0];return ve(e,{short:n})!==void 0}return false}function Ke(e,t,n){let s={},r=[];for(let a=0;a<n.length;a++){let i=n[a];if(i==="--help"||i==="-h")return {command:"help",positionals:e.split(" "),flags:{}};let l,o;if(i.startsWith("--")){let m=i.slice(2),f=m.indexOf("=");f!==-1&&(o=m.slice(f+1),m=m.slice(0,f)),l={long:m};}else if(i.startsWith("-")&&i.length>1){let m=i.slice(1),f=m.indexOf("=");f!==-1&&(o=m.slice(f+1),m=m.slice(0,f)),l={short:m};}else {r.push(i);continue}let c=ve(t,l);if(!c)throw new g(`Unknown option ${i.split("=")[0]} for "${e}"`);let{name:u,flag:p}=c;if(p.kind==="boolean"){if(o!==void 0)throw new g(`Option --${u} takes no value`);s[u]=true;continue}let d=o;if(d===void 0){let m=n[a+1];if(m===void 0||pn(t,m)){let f=m!==void 0?` (use --${u}=${m} if that is the value)`:"";throw new g(`Option --${u} requires a value${f}`)}d=m,a++;}if(p.kind==="number"){let m=Number(d);if(d.trim()===""||!Number.isFinite(m))throw new g(`Option --${u} expects a number, got "${d}"`);s[u]=m;}else if(p.kind==="repeat"){let m=s[u]??[];m.push(d),s[u]=m;}else s[u]=d;}if(r.length<t.minPositionals)throw new g(`"${e}" requires ${t.positionalUsage??`${t.minPositionals} argument(s)`}`);if(r.length>t.maxPositionals)throw new g(`"${e}" got unexpected argument "${r[t.maxPositionals]}"`);return {command:e,positionals:r,flags:s}}function gn(e){if(e.length===0)return {command:"help",positionals:[],flags:{}};let t=e[0];if(t==="--help"||t==="-h"||t==="help")return {command:"help",positionals:e.slice(1),flags:{}};if(t==="--version"||t==="-v")return {command:"version",positionals:[],flags:{}};if(t==="run")return Ke("job start",G.job.commands.start,e.slice(1));let n=it[t]??t,s=G[n];if(!s)throw new g(`Unknown command "${t}"`);let r=e[1];if(r===void 0||r==="--help"||r==="-h")return {command:"help",positionals:[n],flags:{}};if(r.startsWith("-"))throw new g(`"${n}" requires a command (run "evolve-evals ${n} --help")`);let a=lt[r]??r,i=s.commands[a];if(!i)throw new g(`Unknown command "${n} ${r}" (supported: ${Object.keys(s.commands).join(", ")})`);return Ke(`${n} ${a}`,i,e.slice(2))}function fn(e){return e.map(t=>typeof t=="object"&&t.tag==="tag:yaml.org,2002:bool"&&t.test?{...t,test:t.identify?.(true)?/^(?:[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/:/^(?:[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/}:t)}var bn=/^(?:[-+]?[0-9][0-9_]*\.[0-9_]*|\.[0-9][0-9_]*)$/,_n=/^(?:[-+]?[0-9][0-9_]*\.[0-9_]*|\.[0-9][0-9_]*)[eE][-+][0-9]+$/;function hn(e){return e.map(t=>typeof t!="object"||t.tag!=="tag:yaml.org,2002:float"||!t.test?t:t.test.test("1.5e+3")?{...t,test:_n}:t.test.test("1.5")?{...t,test:bn}:t)}var yn=/^[-+]?(?:0|[1-9][0-9_]*)$/,vn=/^[-+]?[1-9][0-9_]*(?::[0-5]?[0-9])+$/;function wn(e){return e.map(t=>typeof t!="object"||t.tag!=="tag:yaml.org,2002:int"||!t.test?t:t.test.test("1:00")?{...t,test:vn}:t.test.test("19")?{...t,test:yn}:t)}function zs(e,t){return ut(e,t).value}function ut(e,t){let n=new yaml.LineCounter,s=yaml.parseDocument(e,{version:"1.1",schema:"yaml-1.1",resolveKnownTags:false,lineCounter:n,customTags:l=>wn(hn(fn(l)))}),r=s.errors[0]??s.warnings[0];if(r){let l=r.linePos?.[0]?.line??1,o=r.code==="MULTIPLE_DOCS"?"multi-document YAML is not supported here \u2014 one config per file":r.message.replace(/ at line \d+, column \d+:[\s\S]*$/,"");throw new g(`${t}:${l}: ${o}`)}s.options.logLevel="silent";let a;try{a=s.toJS()??{};}catch(l){throw new g(`${t}: ${l.message}`)}return {value:a,locate:l=>{let c=s.getIn(l,true)?.range?.[0];return c===void 0?void 0:n.linePos(c).line}}}var Sn=["../../spec/openapi.yaml","../../../../spec/openapi.yaml"],se;function kn(){if(se)return se;let e=[];for(let t of Sn){let n=url.fileURLToPath(new URL(t,(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href))));if(e.push(n),!fs$1.existsSync(n))continue;let r=yaml.parse(fs$1.readFileSync(n,"utf-8"))?.components?.schemas,a=r?.JobCreate;if(!r||!a||typeof a!="object")throw new Error(`${n} carries no components.schemas.JobCreate \u2014 the contract this CLI validates -c against`);return se={root:a,components:r},se}throw new Error(`spec/openapi.yaml not found (tried: ${e.join(", ")}) \u2014 the package ships it; reinstall the SDK`)}function ct(e){let t=e.type;return typeof t=="string"?[t]:Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}function Ae(e,t,n){let s=e.$ref;if(typeof s!="string")return {schema:e,specName:n};let r=s.replace("#/components/schemas/",""),a=t[r];if(!a)throw new Error(`spec/openapi.yaml: unresolvable $ref "${s}"`);return Ae(a,t,r)}function Rn(e){return e.length===1&&typeof e[0]=="string"?`"${e[0]}"`:e.map((t,n)=>typeof t=="number"?`[${t}]`:n===0?t:`.${t}`).join("")}function dt(e,t){let n=t.locate?.(e),s=`${t.source}${n!==void 0?`:${n}`:""}`;return e.length===0?s:`${Rn(e)} in ${s}`}function k(e,t,n,s){throw new g(`--config: ${dt(e,t)} ${n} [spec: ${s}]`)}function An(e){for(let t=e.length-1;t>=0;t--)if(typeof e[t]=="string")return e[t];return "value"}function xn(e,t){if(!e)return "a list";let n=Ae(e,t.components,""),s=ct(n.schema);return s.includes("string")?"a list of strings":s.includes("object")?"a list of objects":"a list"}function re(e,t,n,s,r,a=false){let{schema:i,specName:l}=Ae(t,r.components,s),o=ct(i),c=u=>l?`${l}.${u}`:u;if(e===null){if(o.includes("null"))return;k(n,r,`must be a ${o[0]??"value"}, not null`,l);}if(o.includes("object")){let u=U(i.additionalProperties)?i.additionalProperties:void 0;if(!U(e)){let d=u&&!i.properties?`must be a map of KEY: "value" pairs, not ${D(e)}`:`must be an object like {${Tn(i)}: "..."}, not ${D(e)}`;k(n,r,d,l);}let p=U(i.properties)?i.properties:void 0;if(p){if(!a&&Array.isArray(i.required))for(let d of i.required)typeof d=="string"&&e[d]===void 0&&k(n,r,`is missing the required key "${d}"`,l);for(let d of Object.keys(e))if(p[d]===void 0&&!u)throw new g(`--config: unknown key "${d}" in ${dt([...n,d],r)} (allowed: ${Object.keys(p).join(", ")}) [spec: ${l}]`);for(let[d,m]of Object.entries(p)){let f=e[d];f!==void 0&&re(f,m,[...n,d],c(d),r);}}if(u)for(let[d,m]of Object.entries(e))p?.[d]===void 0&&re(m,u,[...n,d],l,r);return}if(o.includes("array")){let u=U(i.items)?i.items:void 0;Array.isArray(e)||k(n,r,`must be ${xn(u,r)}, not ${D(e)}`,l),typeof i.minItems=="number"&&e.length<i.minItems&&k(n,r,`needs at least ${i.minItems} ${i.minItems===1?"entry":"entries"}`,l),typeof i.maxItems=="number"&&e.length>i.maxItems&&k(n,r,`takes at most ${i.maxItems} entries`,l),u&&e.forEach((p,d)=>re(p,u,[...n,d],l,r));return}if(Array.isArray(i.enum)){i.enum.includes(e)||k(n,r,`must be one of: ${i.enum.join(", ")}`,l);return}if(o.includes("string")){typeof e!="string"&&k(n,r,`must be a string, not ${D(e)} \u2014 quote it (${An(n)}: "...")`,l),typeof i.maxLength=="number"&&e.length>i.maxLength&&k(n,r,`must be at most ${i.maxLength} characters (got ${e.length})`,l);return}if(o.includes("integer")||o.includes("number")){let u=o.includes("integer");(typeof e!="number"||u&&!Number.isInteger(e))&&k(n,r,`must be ${u?"an integer":"a number"}, not ${D(e)}`,l),typeof i.minimum=="number"&&e<i.minimum&&k(n,r,`must be at least ${i.minimum}`,l),typeof i.maximum=="number"&&e>i.maximum&&k(n,r,`must be at most ${i.maximum}`,l);return}o.includes("boolean")&&typeof e!="boolean"&&k(n,r,`must be a boolean, not ${D(e)}`,l);}function Tn(e){let t=Array.isArray(e.required)?e.required[0]:void 0;return typeof t=="string"?t:(U(e.properties)?Object.keys(e.properties):[])[0]??"name"}function En(e,t,n){let{root:s,components:r}=kn();re(e,s,[],"JobCreate",{source:t,locate:n,components:r},true);}function D(e){return e===null?"null":Array.isArray(e)?"a list":typeof e=="object"?`a ${e.constructor?.name??"object"}`:`a ${typeof e}`}function U(e){if(typeof e!="object"||e===null||Array.isArray(e))return false;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function we(e,t,n,s=new WeakSet){if(!(e===null||typeof e=="string"||typeof e=="boolean")){if(typeof e=="number"){if(Number.isFinite(e))return;throw new g(`--config: ${t} in ${n} is ${Number.isNaN(e)?".nan":"infinite"} \u2014 a JSON body carries finite numbers only`)}if(Array.isArray(e)||U(e)){if(s.has(e))throw new g(`--config: ${t} in ${n} is an alias of a value that contains it \u2014 a JSON body cannot carry a cycle`);if(s.add(e),Array.isArray(e))e.forEach((r,a)=>we(r,`${t}[${a}]`,n,s));else for(let[r,a]of Object.entries(e))we(a,`${t}.${r}`,n,s);s.delete(e);return}throw new g(`--config: ${t} in ${n} resolved to ${D(e)}, which a JSON body cannot carry \u2014 quote the value to keep it text`)}}function In(e,t){let n;try{n=t(e);}catch(i){throw new g(`--config: cannot read ${e}: ${i.message}`)}let s,r;if(e.endsWith(".json"))try{s=JSON.parse(n);}catch(i){throw new g(`--config: ${e} is not valid JSON: ${i.message}`)}else ({value:s,locate:r}=ut(n,e));if(!s||typeof s!="object"||Array.isArray(s))throw new g(`--config: ${e} must contain a JSON/YAML object`);let a=s;for(let[i,l]of Object.entries(a))we(l,i,e);return En(a,e,r),s}function We(e,t){let n=e.indexOf("@");if(n===-1)return {name:e};let s=e.slice(0,n),r=e.slice(n+1);if(!s||!r)throw new g(`Invalid ${t} "${e}": expected name or name@version`);return {name:s,version:r}}function Se(e,t){let n={};for(let s of e){let r=s.indexOf("=");if(r<=0)throw new g(`Invalid ${t} "${s}": expected KEY=VALUE`);n[s.slice(0,r)]=s.slice(r+1);}return n}function Pn(e,t=n=>fs$1.readFileSync(n,"utf-8")){let n=e.flags,s=typeof n.config=="string"?In(n.config,t):{},r;if(n.dataset!==void 0)r=n.dataset.map(f=>{let y=We(f,"--dataset");return {name:y.name,...y.version?{version:y.version}:{}}});else if(Array.isArray(s.datasets)&&s.datasets.length>0)r=s.datasets.map(f=>({...f}));else throw new g('"job start" requires -d/--dataset (or datasets in --config)');if(n["include-task-name"]!==void 0)for(let f of r)f.task_names=n["include-task-name"];if(n["exclude-task-name"]!==void 0)for(let f of r)f.exclude_task_names=n["exclude-task-name"];if(n["n-tasks"]!==void 0)for(let f of r)f.n_tasks=n["n-tasks"];let a;if(n.agent!==void 0||n.model!==void 0){if(n.agent===void 0)throw new g("-m/--model requires -a/--agent");if(n.model===void 0)throw new g("-a/--agent requires at least one -m/--model (the server applies no model default)");let f=We(String(n.agent),"--agent");a=n.model.map(y=>({name:f.name,model_name:y,...f.version?{version:f.version}:{}}));}else if(Array.isArray(s.agents)&&s.agents.length>0)a=s.agents.map(f=>({...f}));else throw new g('"job start" requires -a/--agent and -m/--model (or agents in --config)');n.effort!==void 0&&(a=a.map(f=>({...f,reasoning_effort:n.effort})));let l=n["agent-env"]!==void 0?Se(n["agent-env"],"--agent-env"):s.agent_env,o=n["verifier-env"]!==void 0?Se(n["verifier-env"],"--verifier-env"):s.verifier_env,c=n["job-name"]!==void 0?String(n["job-name"]):s.job_name,u=n["n-attempts"]!==void 0?n["n-attempts"]:s.n_attempts,p=n["n-concurrent"]!==void 0?n["n-concurrent"]:s.n_concurrent_trials,d=n["max-trial-spend"]!==void 0?n["max-trial-spend"]:s.max_trial_spend_usd;if(n.env!==void 0&&!Y.includes(String(n.env)))throw new g(`-e/--env must be one of: ${Y.join(", ")}`);let m=n.env!==void 0?n.env:s.sandbox_provider;return {...c!==void 0?{job_name:c}:{},datasets:r,agents:a,...u!==void 0?{n_attempts:u}:{},...p!==void 0?{n_concurrent_trials:p}:{},...d!==void 0?{max_trial_spend_usd:d}:{},...m!==void 0?{sandbox_provider:m}:{},...l!==void 0?{agent_env:l}:{},...o!==void 0?{verifier_env:o}:{}}}function Cn(e){let t=e.flags,n=typeof t.dir=="string",s=typeof t.git=="string"||typeof t.ref=="string";if(n&&s)throw new g('"dataset publish" takes EITHER --dir OR --git/--ref, not both');if(n){for(let r of ["name","version"])if(typeof t[r]!="string")throw new g(`"dataset publish" requires --${r}`);return {source:{directory:t.dir},name:t.name,version:t.version}}for(let r of ["git","ref","name","version"])if(typeof t[r]!="string"){let a=r==="git"||r==="ref"?" (or --dir for a local corpus directory)":"";throw new g(`"dataset publish" requires --${r}${a}`)}return {source:{git_url:t.git,git_ref:t.ref},name:t.name,version:t.version}}function On(e,t=n=>fs$1.readFileSync(n,"utf-8")){let n=e.flags,s=typeof n.dir=="string",r=typeof n["install-script"]=="string";if(s&&r)throw new g('"agent add" takes EITHER --dir OR --install-script, not both');if(!s&&!r)throw new g('"agent add" requires --install-script (or --dir for a local agent directory)');if(typeof n.run!="string")throw new g('"agent add" requires --run');let a=Se(n["agent-env"]??[],"--agent-env");return {name:e.positionals[0],...s?{directory:n.dir}:{install_script:t(n["install-script"])},run_command:n.run,...Object.keys(a).length>0?{env:a}:{}}}var Dn={out:e=>process.stdout.write(e+`
|
|
12
|
+
`),err:e=>process.stderr.write(e+`
|
|
13
|
+
`),tty:process.stdout.isTTY===true&&process.env.TERM!=="dumb"};function R(e){if(e.length===0)return [];let t=[];for(let n of e)n.forEach((s,r)=>{t[r]=Math.max(t[r]??0,s.length);});return e.map(n=>n.map((s,r)=>s.padEnd(t[r])).join(" ").trimEnd())}function I(e){return typeof e=="number"?`$${e.toFixed(2)}`:"-"}function xe(e){let t=`${e.name}:${e.model_name}`;return e.version?`${t}:${e.version}`:t}function oe(e){return e.map(t=>`${t.name}@${t.version}`).join(", ")||"-"}function ie(e,t){return e.length>t?e.slice(0,t-1)+"\u2026":e}function _e(e){return e.replace(/[\t\n\r]+/g," ")}function H(e,t,n,s,r,a){if(e.flags.quiet===true){for(let o of n)t.out(a(o));return}let i=$n(e,s,r);if(t.tty===true){let o=e.flags["no-trunc"]===true,c=[i.map(u=>u.header)];for(let u of n)c.push(i.map(p=>o?_e(p.cell(u)):ie(_e(p.cell(u)),60)));for(let u of R(c))t.out(u);}else {e.flags["no-headers"]!==true&&t.out(i.map(o=>o.header).join(" "));for(let o of n)t.out(i.map(c=>_e(c.cell(o))).join(" "));}}function $n(e,t,n){let s=e.flags.columns;if(s===void 0)return n.map(a=>t.find(i=>i.key===a));if(s==="all")return t;let r=s.split(",").map(a=>a.trim()).filter(Boolean);if(r.length===0)throw new g("--columns got an empty column list");return r.map(a=>{let i=t.find(l=>l.key===a);if(!i)throw new g(`Unknown column "${a}" (available: ${t.map(l=>l.key).join(", ")}, or "all")`);return i})}function K(e,t,n){if(e.flags.columns!=="help")return false;for(let s of n)t.out(s.key);return true}function $(e){let t=[["id",e.id],["status",e.status],["datasets",oe(e.datasets)]];t.push(["agents",e.agents.map(xe).join(", ")]),t.push(["size",`${e.counts.agents} agent(s) x ${e.counts.tasks} task(s) = ${e.n_total_trials} trial(s)`]),t.push(["attempts/task",String(e.n_attempts)]),t.push(["concurrency",String(e.n_concurrent_trials)]),t.push(["max spend/trial",I(e.max_trial_spend_usd)]),t.push(["worst case",I(e.worst_case_spend_usd)]),t.push(["provider",e.sandbox_provider]),t.push(["spent",I(e.stats.cost_usd)]);let n=Object.entries(e.trials.byStatus).filter(([,s])=>s>0).map(([s,r])=>`${s} ${r}`).join(" \xB7 ");n&&t.push(["trials",n]);for(let s of e.source_jobs)t.push([s.action==="regrade"?"regrade of":"resume of",s.job_id]);return e.idempotent_replay&&t.push(["note","idempotent replay of an existing job"]),e.failure&&t.push(["failure",`${e.failure.code}: ${e.failure.message}`]),t.push(["started",e.started_at]),t.push(["updated",e.updated_at]),R(t)}var Ye=[{key:"id",header:"ID",cell:e=>e.id},{key:"name",header:"NAME",cell:e=>e.job_name??"-"},{key:"status",header:"STATUS",cell:e=>e.status},{key:"datasets",header:"DATASETS",cell:e=>oe(e.datasets)},{key:"agents",header:"AGENTS",cell:e=>e.agents.map(xe).join(", ")},{key:"trials",header:"TRIALS",cell:e=>String(e.trials.total)},{key:"spent",header:"SPENT",cell:e=>I(e.stats.cost_usd)},{key:"started",header:"STARTED",cell:e=>e.started_at}],jn=["id","status","datasets","trials","spent","started"],ze=[{key:"task",header:"TASK",cell:e=>e.task_name},{key:"agent",header:"AGENT",cell:e=>xe({name:e.agent_info.name,model_name:e.agent_info.model_info.name,version:e.agent_info.version,reasoning_effort:e.agent_info.reasoning_effort??null})},{key:"attempt",header:"ATTEMPT",cell:e=>String(e.attempt)},{key:"status",header:"STATUS",cell:e=>e.status},{key:"reward",header:"REWARD",cell:e=>e.reward!==null?String(e.reward):"-"},{key:"spent",header:"SPENT",cell:e=>I(e.agent_result?.cost_usd)},{key:"id",header:"TRIAL ID",cell:e=>e.id}],Ln=["task","agent","attempt","status","reward","spent","id"],Xe=[{key:"task",header:"TASK",cell:e=>e.task_name},{key:"source",header:"DATASET",cell:e=>e.source},{key:"trials",header:"TRIALS",cell:e=>String(e.trials.total)},{key:"statuses",header:"STATUSES",cell:e=>Object.entries(e.trials.byStatus).filter(([,t])=>t>0).map(([t,n])=>`${t} ${n}`).join(" \xB7 ")||"-"},{key:"reward",header:"MEAN REWARD",cell:e=>ke(e.mean_reward)},{key:"spent",header:"SPENT",cell:e=>I(e.cost_usd)}],Jn=["task","source","trials","statuses","reward","spent"],Qe=[{key:"name",header:"NAME",cell:e=>e.name},{key:"active",header:"ACTIVE",cell:e=>e.active_version?.version??"-"},{key:"state",header:"STATE",cell:e=>e.active_version?.state??"-"},{key:"tasks",header:"TASKS",cell:e=>e.active_version?String(e.active_version.task_count):"-"},{key:"title",header:"TITLE",cell:e=>e.title??"-"}],Nn=["name","active","state","tasks","title"],Ze=[{key:"name",header:"NAME",cell:e=>e.name},{key:"source",header:"SOURCE",cell:e=>e.source},{key:"run",header:"RUN COMMAND",cell:e=>e.run_command},{key:"updated",header:"UPDATED",cell:e=>e.updated_at}],Un=["name","source","run","updated"];function Mn(e){let t=[["trial id",e.id],["job",e.job_id],["task",e.task_name],["dataset",e.source],["agent",`${e.agent_info.name}:${e.agent_info.model_info.name}`],["attempt",String(e.attempt)],["status",e.status],["reward",e.reward!==null?String(e.reward):"-"]],n=e.verifier_result?.rewards;if(n&&Object.keys(n).length>0&&t.push(["rewards",Object.entries(n).map(([s,r])=>`${s}=${r}`).join(" \xB7 ")]),t.push(["spent",I(e.agent_result?.cost_usd)]),(e.status==="RUNNING"||e.status==="SCORING")&&e.live_spent_usd!==null){let s=e.live_spend_at?` as of ${e.live_spend_at}`:"";t.push(["spent (live)",`at least $${e.live_spent_usd.toFixed(4)}${s}`]);}return e.attempt_phase&&t.push(["phase",e.attempt_phase]),e.sandbox_provider&&t.push(["provider",e.sandbox_provider]),e.sandbox_id&&t.push(["sandbox",e.sandbox_id]),e.verifier_environment_mode&&t.push(["verifier",e.verifier_environment_mode]),e.verifier_sandbox_id&&t.push(["verifier sandbox",e.verifier_sandbox_id]),e.agent_info.version&&t.push(["agent version",e.agent_info.version]),e.exception_info&&(t.push(["failure type",e.exception_info.exception_type]),t.push(["failure detail",e.exception_info.exception_message])),e.session_ref&&t.push(["session",e.session_ref]),e.started_at&&t.push(["started",e.started_at]),e.finished_at&&t.push(["finished",e.finished_at]),R(t)}function mt(e){let t=[["name",e.name],["source",e.source],["run command",e.run_command]],n=Object.keys(e.env??{});return n.length>0&&t.push(["env",n.sort().join(", ")]),t.push(["created",e.created_at]),t.push(["updated",e.updated_at]),R(t)}var pt=["e2b","daytona","modal"];function Fn(e){return pt.filter(t=>e?.[t]!==void 0).map(t=>`${t} ${e[t].ok?"ok":"NO"}`).join(" \xB7 ")}function ke(e){return e!==null?String(Math.round(e*1e3)/1e3):"-"}function Vn(e){let t=ie(JSON.stringify(e.data??{}),140);return `#${String(e.seq).padStart(4)} ${e.type.padEnd(26)} ${t}`.trimEnd()}function gt(e){let t=e.failures?.length?` (${e.failures.length} task failure${e.failures.length===1?"":"s"})`:"";return `${e.message}${t}`}function et(e){let t=[["id",e.id],["status",e.status]];e.name!==void 0&&t.push(["dataset",e.name]),e.version!==void 0&&t.push(["version",e.version]),e.task_count!==void 0&&t.push(["tasks",String(e.task_count)]);for(let n of e.warnings)t.push(["warning",n.message??n.code]);if(e.failure){t.push(["failure",gt(e.failure)]);for(let n of e.failure.failures??[])t.push([` ${n.task_name}`,n.error]);}return R(t)}function qn(e){let t=[];return e.task_count!==void 0&&t.push(`tasks=${e.task_count}`),e.failure&&t.push(ie(gt(e.failure),140)),`status ${e.status.padEnd(12)} ${t.join(" ")}`.trimEnd()}function Bn(e){let t={...e.data??{}},n=[];typeof t.trial_id=="string"&&n.push(t.trial_id),typeof t.task_name=="string"&&n.push(t.task_name),typeof t.status=="string"&&n.push(t.status),typeof t.reward=="number"&&n.push(`reward=${t.reward}`);let s=new Set(["trial_id","task_name","status","reward"]);for(let[a,i]of Object.entries(t))s.has(a)||n.push(`${a}=${typeof i=="object"?JSON.stringify(i):String(i)}`);let r=ie(n.join(" "),140);return `#${String(e.seq).padStart(4)} ${e.type.padEnd(26)} ${r}`.trimEnd()}function _(e){let t={};return typeof e.flags["api-key"]=="string"&&(t.apiKey=e.flags["api-key"]),typeof e.flags["base-url"]=="string"&&(t.baseUrl=e.flags["base-url"]),t}var Gn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Hn=/^[0-9a-f][0-9a-f-]{7,34}$/i,tt=8,nt=new WeakMap;function Kn(e){let t=nt.get(e);if(t)return t;let n=(async()=>{let s=S(_(e)),r=[],a;do{let i=await s.list({limit:100,...a?{cursor:a}:{}});for(let l of i.items)r.push(l.id);a=i.nextCursor??void 0;}while(a);return r})();return nt.set(e,n),n}async function x(e,t){if(t===void 0||Gn.test(t))return t;if(/^[0-9a-f][0-9a-f-]*$/i.test(t)&&t.length<tt)throw new g(`"${t}" is too short to name a job \u2014 id prefixes need at least ${tt} characters`);if(!Hn.test(t))return t;let n=t.toLowerCase(),s=new Set;for(let a of await Kn(e))a.startsWith(n)&&s.add(a);let r=[...s];if(r.length===1)return r[0];throw r.length===0?new g(`no job id starts with "${t}"`):new g(`"${t}" is ambiguous \u2014 it matches ${r.length} jobs: ${r.slice(0,5).join(", ")}${r.length>5?", \u2026":""}`)}function j(e){return {...e.flags.limit!==void 0?{limit:e.flags.limit}:{},...e.flags.cursor!==void 0?{cursor:String(e.flags.cursor)}:{}}}function ft(e){if(e.flags.status===void 0)return;let t=String(e.flags.status).split(",").map(s=>s.trim()).filter(Boolean);if(t.length===0)throw new g("--status got an empty status list");let n=t.filter(s=>!W.includes(s));if(n.length>0)throw new g(`--status must name trial statuses (${W.join(", ")}); got: ${n.join(", ")}`);return t}function Wn(e){return e.status==="COMPLETED"?0:e.status==="FAILED"||e.status==="CANCELLED"?1:0}async function Yn(e,t){let n=Pn(e);if(e.flags["print-config"]===true)return t.out(JSON.stringify(n,null,2)),0;let s=e.flags.json===true,r=e.flags.watch===true,a=e.flags.quiet===true,i=S(_(e)),l=await i.start(n);if(!r){if(s)t.out(JSON.stringify(l));else {for(let c of $(l))t.out(c);t.out(""),t.out(`Follow it with: evolve-evals job show ${l.id}`);}return 0}s?t.out(JSON.stringify({kind:"job.created",job:l})):t.out(`Job ${l.id} (${oe(l.datasets)}) ${l.status} \u2014 watching\u2026`);let o=await i.watch(l.id,{onEvent:c=>{a||t.out(s?JSON.stringify({kind:"event",...c}):Bn(c));}});if(s)t.out(JSON.stringify({kind:"job.final",job:o}));else {t.out("");for(let c of $(o))t.out(c);}return Wn(o)}async function zn(e,t){if(K(e,t,Ye))return 0;let s=await S(_(e)).list({...j(e),...e.flags.search!==void 0?{search:String(e.flags.search)}:{}});return e.flags.json===true?(t.out(JSON.stringify(s)),0):s.items.length===0?(e.flags.quiet!==true&&t.out("No jobs."),0):(H(e,t,s.items,Ye,jn,r=>r.id),s.nextCursor&&t.tty===true&&e.flags.quiet!==true&&t.out(`
|
|
14
|
+
More: evolve-evals job list --cursor ${s.nextCursor}`),0)}async function Xn(e,t){let n=S(_(e)),s=[];for(let r of e.positionals)s.push(await n.get(await x(e,r)));return e.flags.json===true?(t.out(JSON.stringify(s.length===1?s[0]:s)),0):(s.forEach((r,a)=>{a>0&&t.out("");for(let i of $(r))t.out(i);}),0)}async function Qn(e,t){if(K(e,t,ze))return 0;let n=S(_(e)),s=ft(e),r=e.flags.dataset,a=await n.trials(await x(e,e.positionals[0]),{...s!==void 0?{status:s}:{},...r!==void 0?{dataset:r}:{},...j(e)});return e.flags.json===true?(t.out(JSON.stringify(a)),0):a.items.length===0?(e.flags.quiet!==true&&t.out("No trials."),0):(H(e,t,a.items,ze,Ln,i=>i.id),t.tty===true&&e.flags.quiet!==true&&(t.out(`
|
|
15
|
+
${a.items.length} trial(s) shown`),a.nextCursor&&t.out(`More: evolve-evals job trials ${e.positionals[0]} --cursor ${a.nextCursor}`)),0)}async function Zn(e,t){if(K(e,t,Xe))return 0;let s=await S(_(e)).tasks(await x(e,e.positionals[0]),j(e));return e.flags.json===true?(t.out(JSON.stringify(s)),0):s.items.length===0?(e.flags.quiet!==true&&t.out("No tasks."),0):(H(e,t,s.items,Xe,Jn,r=>r.task_name),s.nextCursor&&t.tty===true&&e.flags.quiet!==true&&t.out(`
|
|
16
|
+
More: evolve-evals job tasks ${e.positionals[0]} --cursor ${s.nextCursor}`),0)}function es(e){let t=[],n=[["ID","DATASETS","STATUS","MEAN REWARD","COVERAGE","SPENT"]];for(let s of e.jobs)n.push([s.id,oe(s.datasets),s.status,ke(s.mean_reward),`${s.coverage.scored}/${s.coverage.total}`,I(s.cost_usd)]);if(t.push(...R(n)),e.taskMatrix.length>0){t.push("","Task matrix (disagreements first; columns in the order above):");let s=[["TASK","DIFF",...e.jobs.map((a,i)=>`JOB ${i+1}`)]],r=e.jobs.map(a=>a.id);for(let a of e.taskMatrix){let i=new Map(a.cells.map(l=>[l.job_id,l]));s.push([a.task_name,a.disagreement?"!":"",...r.map(l=>{let o=i.get(l);return o?o.mean_reward!==null?`${o.status} ${ke(o.mean_reward)}`:o.status:"-"})]);}t.push(...R(s));}return t}async function ts(e,t){let n=S(_(e)),s=[];for(let a of e.positionals)s.push(await x(e,a));let r=await n.compare(s);if(e.flags.json===true)t.out(JSON.stringify(r));else for(let a of es(r))t.out(a);return 0}async function ns(e,t){let s=await S(_(e)).cancel(await x(e,e.positionals[0]));if(e.flags.json===true)t.out(JSON.stringify(s));else for(let r of $(s))t.out(r);return 0}async function ss(e,t){let n=e.flags.dataset;if(!n)throw new g("job stop needs --dataset <name> (to stop the whole job, use: evolve-evals job cancel <id>)");let s=S(_(e)),r=await s.get(await x(e,e.positionals[0])),a=r.datasets.map(u=>u.name);if(!a.includes(n))throw new Error(`job ${r.id} does not run dataset ${n}; its datasets: ${a.join(", ")}`);let i=[];for await(let u of s.trials(r.id,{dataset:n}))i.push(u.id);if(i.length===0)return e.flags.json===true?t.out(JSON.stringify({stopped:[],already_terminal:[],not_found:[]})):t.out(`No trials in ${n}.`),0;let l=N(_(e)),o={stopped:[],already_terminal:[],not_found:[]},c=0;try{for(let u=0;u<i.length;u+=100){let p=i.slice(u,u+100),d=await l.stop(p);c+=p.length,o.stopped.push(...d.stopped),o.already_terminal.push(...d.already_terminal),o.not_found.push(...d.not_found);}}catch(u){throw st(o,n,i.length,c,e,t),u}return st(o,n,i.length,c,e,t),0}function st(e,t,n,s,r,a){let i=n-s;if(r.flags.json===true){a.out(JSON.stringify(i>0?{...e,partial:true,unreported:i}:e));return}for(let l of e.stopped)a.out(`stopped ${l.id} (${l.task_name}) ${l.status}`);for(let l of e.already_terminal)a.out(`already terminal ${l}`);for(let l of e.not_found)a.out(`not found ${l}`);a.out(`${e.stopped.length} stopped, ${e.already_terminal.length} already terminal, ${e.not_found.length} not found (${t})`),i>0&&a.out(`PARTIAL: ${i} of ${n} trials have no report \u2014 no answer came back for trials ${s+1}-${Math.min(s+100,n)}; rerun the same command to finish the rest.`);}async function rs(e,t){let n=S(_(e)),s=e.flags["filter-error-type"],r=await n.resume(await x(e,e.positionals[0]),s!==void 0?{filter_error_types:s}:void 0);if(e.flags.json===true)t.out(JSON.stringify(r));else {for(let a of $(r))t.out(a);t.out(""),t.out(`Follow it with: evolve-evals job show ${r.id}`);}return 0}async function as(e,t){let n=S(_(e)),s={},r=ft(e);r!==void 0&&(s.statuses=r),e.flags.task!==void 0&&(s.task_name=String(e.flags.task));let a=await n.regrade(await x(e,e.positionals[0]),s);if(e.flags.json===true)t.out(JSON.stringify(a));else {for(let i of $(a))t.out(i);t.out(""),t.out(`Follow it with: evolve-evals job show ${a.id}`);}return 0}async function os(e,t){let s=await S(_(e)).download(await x(e,e.positionals[0]),{to:e.flags["output-dir"]??process.cwd()});return e.flags.json===true?t.out(JSON.stringify({path:s})):t.out(`Saved ${s}`),0}async function is(e,t){let s=await N(_(e)).get(e.positionals[0]);if(e.flags.json===true)t.out(JSON.stringify(s));else for(let r of Mn(s))t.out(r);return 0}var rt=ce;async function ls(e,t){let n=N(_(e)),s=e.positionals[0],r=e.flags.json===true,a=e.flags.stream;if(a!==void 0&&(e.flags["output-dir"]!==void 0||e.flags.overwrite===true))throw new g('"trial download" takes EITHER --stream OR -o/--overwrite, not both');if((a===void 0||a!=="trace-parsed")&&(e.flags.cursor!==void 0||e.flags.limit!==void 0))throw new g("--cursor/--limit page the parsed events; they apply only to --stream trace-parsed");if(a!==void 0){if(!rt.includes(a))throw new g(`--stream must be one of: ${rt.join(", ")}`);if(a==="trace-parsed"){let h=0;for await(let v of n.traceEvents(s,j(e)))t.out(r?JSON.stringify(v):Vn(v)),h+=1;return !r&&h===0&&t.out("No trace events."),0}if(a==="agent-home"){let h=await n.artifact(s,a);if(h===null)return t.out(r?JSON.stringify({files:null}):`No ${a} content was stored for this trial.`),0;if(r)t.out(JSON.stringify({files:h}));else for(let[v,M]of Object.entries(h))t.out(`===== ${v} (${Buffer.byteLength(M,"utf8")} bytes) =====`),t.out(M);return 0}let y=await n.artifact(s,a);return y===null?(t.out(r?JSON.stringify({log:null}):`No ${a} log was stored for this trial.`),0):(t.out(r?JSON.stringify({log:y}):y),0)}let{mkdir:i,writeFile:l}=await import('fs/promises'),{join:o,dirname:c}=await import('path'),u=o(e.flags["output-dir"]??"trials",s);if(fs$1.existsSync(u)&&e.flags.overwrite!==true)throw new Error(`${u} already exists (pass --overwrite to replace it)`);await i(u,{recursive:true});let p=[],d=y=>{p.push(y),r||t.out(y);},m=[];for await(let y of n.traceEvents(s))m.push(JSON.stringify(y));await l(o(u,"trace-parsed.jsonl"),m.join(`
|
|
17
|
+
`)+(m.length?`
|
|
18
|
+
`:"")),d(`trace-parsed.jsonl (${m.length} events)`);for(let y of ["verifier","trace-stdout","trace-stderr"]){let h=await n.artifact(s,y);h!==null&&(await l(o(u,`${y}.log`),h),d(`${y}.log (${Buffer.byteLength(h,"utf8")} bytes)`));}let f=await n.artifact(s,"agent-home");if(f!==null){for(let[y,h]of Object.entries(f)){let v=o(u,"agent-home",...y.split("/").filter(Boolean));await i(c(v),{recursive:true}),await l(v,h);}d(`agent-home/ (${Object.keys(f).length} files)`);}return r?t.out(JSON.stringify({path:u,saved:p})):t.out(`Saved ${u}`),0}async function us(e,t){let n=await N(_(e)).regrade(e.positionals[0]);if(e.flags.json===true)t.out(JSON.stringify(n));else {for(let s of $(n))t.out(s);t.out(""),t.out(`Follow it with: evolve-evals job show ${n.id}`);}return 0}async function cs(e,t){let s=await N(_(e)).stop(e.positionals);if(e.flags.json===true)return t.out(JSON.stringify(s)),0;for(let r of s.stopped)t.out(`stopped ${r.id} (${r.task_name}) ${r.status}`);for(let r of s.already_terminal)t.out(`already terminal ${r}`);for(let r of s.not_found)t.out(`not found ${r}`);return 0}function bt(e){let t=R([["name",e.name],["title",e.title??"-"],["description",e.description??"-"],["active version",e.active_version?.version??"-"]]);if(e.versions&&e.versions.length>0){t.push("");let n=[["VERSION","STATE","TASKS","CREATED"]];for(let s of e.versions)n.push([s.version,s.state,String(s.task_count),s.created_at??"-"]);t.push(...R(n));}if(e.tasks&&e.tasks.items.length>0){t.push("",`Tasks (version ${e.selected_version?.version??"?"}):`);let n=[["TASK","AGENT TIMEOUT","VERIFIER TIMEOUT","PROVIDERS"]];for(let r of e.tasks.items)n.push([r.task_name,`${r.agent_timeout_sec}s`,`${r.verifier_timeout_sec}s`,Fn(r.providers)]);t.push(...R(n)),e.tasks.nextCursor&&t.push(`More tasks: evolve-evals dataset show ${e.name} --cursor ${e.tasks.nextCursor}`);let s=new Map;for(let r of e.tasks.items)for(let a of pt){let i=r.providers?.[a];i&&!i.ok&&!s.has(`${a}:${i.reason}`)&&s.set(`${a}:${i.reason}`,`${a}: ${i.reason}`);}if(s.size>0){t.push("","Provider limitations:");for(let r of s.values())t.push(` ${r}`);}}return t}function _t(e){let t=[];for(let n of e){if(!n.upstream?.moved)continue;let s=n.active_version?`@${n.active_version.version}`:"";t.push(`${n.name}${s} \xB7 upstream ${n.upstream.ref} moved \u2014 run: evolve-evals dataset publish --name ${n.name} --version <new-version> --git <url> --ref ${n.upstream.ref}`);}return t}async function ds(e,t){if(K(e,t,Qe))return 0;let s=await J(_(e)).list({...j(e),...e.flags.search!==void 0?{search:String(e.flags.search)}:{}});if(e.flags.json===true)return t.out(JSON.stringify(s)),0;if(s.items.length===0)return e.flags.quiet!==true&&t.out("No datasets."),0;if(H(e,t,s.items,Qe,Nn,r=>r.name),e.flags.quiet!==true)for(let r of _t(s.items))t.out(r);return 0}async function ms(e,t){let s=await J(_(e)).get(e.positionals[0],j(e));if(e.flags.json===true)t.out(JSON.stringify(s));else {for(let r of bt(s))t.out(r);for(let r of _t([s]))t.out(r);}return 0}async function ps(e,t){let n=e.flags.json===true,s=J(_(e)),r=Cn(e),a=await s.publish(r);if(e.flags.watch!==true){if(n)t.out(JSON.stringify(a));else {for(let l of et(a))t.out(l);t.out(""),t.out(`Follow it with: evolve-evals dataset show ${r.name}`);}return 0}n?t.out(JSON.stringify({kind:"import.created",datasetImport:a})):t.out(`Publish ${a.id} (${r.name}) ${a.status} \u2014 watching\u2026`);let i=await s.watchImport(a.id,{onStatus:l=>{t.out(n?JSON.stringify({kind:"import.status",datasetImport:l}):qn(l));}});if(n)t.out(JSON.stringify({kind:"import.final",datasetImport:i}));else {t.out("");for(let l of et(i))t.out(l);}return i.status==="FAILED"?1:0}async function gs(e,t){let s=await J(_(e)).download(e.positionals[0],{to:e.flags["output-dir"]??process.cwd()});return e.flags.json===true?t.out(JSON.stringify({path:s})):t.out(`Saved ${s}`),0}async function fs(e,t){let n=J(_(e)),[s,r]=e.positionals,a=await n.activate(s,r);if(e.flags.json===true)t.out(JSON.stringify(a));else for(let i of bt(a))t.out(i);return 0}async function bs(e,t){if(K(e,t,Ze))return 0;let s=await q(_(e)).list(j(e));return e.flags.json===true?(t.out(JSON.stringify(s)),0):s.items.length===0?(e.flags.quiet!==true&&t.out("No registered agents."),0):(H(e,t,s.items,Ze,Un,r=>r.name),0)}async function _s(e,t){let s=await q(_(e)).get(e.positionals[0]);if(e.flags.json===true)t.out(JSON.stringify(s));else for(let r of mt(s))t.out(r);return 0}async function hs(e,t){let s=await q(_(e)).create(On(e));if(e.flags.json===true)t.out(JSON.stringify(s));else {for(let r of mt(s))t.out(r);t.out(""),t.out(`Use it with: evolve-evals run -d <dataset> -a ${s.name} -m <model>`);}return 0}async function ys(e,t){let n=q(_(e)),s=e.positionals[0];return await n.delete(s),e.flags.json===true?t.out(JSON.stringify({name:s,deleted:true})):t.out(`Deleted agent ${s}`),0}function vs(e){let t=[["user",e.user_id],["email",e.email??"-"],["key",e.key.id]];return e.key.label&&t.push(["key label",e.key.label]),t.push(["key created",e.key.created_at]),e.key.last_used_at&&t.push(["key last used",e.key.last_used_at]),R(t)}async function ws(e,t){let n=await Ge(_(e)).status();if(e.flags.json===true)t.out(JSON.stringify(n));else for(let s of vs(n))t.out(s);return 0}function Ss(e){if(e.length===0)return {text:ye(),code:0};let t=it[e[0]]??e[0],n=G[t];if(!n)return {text:ye(),code:0};if(e.length===1)return {text:He(t),code:0};let s=lt[e[1]]??e[1],r=n.commands[s];return r?{text:dn(t,s,r),code:0}:{text:He(t),code:0}}var ks={"job start":Yn,"job list":zn,"job show":Xn,"job trials":Qn,"job tasks":Zn,"job compare":ts,"job cancel":ns,"job stop":ss,"job resume":rs,"job regrade":as,"job download":os,"trial show":is,"trial download":ls,"trial regrade":us,"trial stop":cs,"dataset list":ds,"dataset show":ms,"dataset publish":ps,"dataset download":gs,"dataset activate":fs,"agent list":bs,"agent show":_s,"agent add":hs,"agent remove":ys,"auth status":ws};async function Rs(e,t=Dn){let n;try{n=gn(e);}catch(s){if(s instanceof g)return t.err(`Error: ${s.message}`),t.err('Run "evolve-evals help" for usage.'),2;throw s}if(n.command==="help"){let{text:s,code:r}=Ss(n.positionals);return t.out(s),r}if(n.command==="version")return t.out(mn()),0;try{let s=ks[n.command];return s?await s(n,t):(t.err(`Error: unknown command "${n.command}"`),2)}catch(s){if(s instanceof g)return t.err(`Error: ${s.message}`),t.err(`Run "evolve-evals ${n.command} --help" for usage.`),2;if(s instanceof T&&s.status===429){let r=s.retryAfterSec!==void 0?`retry in ${s.retryAfterSec}s`:"retry shortly";return t.err(`Error: rate limited by the server \u2014 ${r}.`),1}return t.err(`Error: ${s.message}`),1}}var As=(()=>{let e=process.argv[1];if(!e)return false;let t=n=>{try{return (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href))===url.pathToFileURL(n).href}catch{return false}};if(t(e))return true;try{return t(fs$1.realpathSync(e))}catch{return false}})();As&&Rs(process.argv.slice(2)).then(e=>{process.exitCode=e;},e=>{process.stderr.write(`Error: ${e?.message??e}
|
|
19
|
+
`),process.exitCode=1;});exports.CliUsageError=g;exports.USAGE=Ys;exports.buildAgentInput=On;exports.buildJobInput=Pn;exports.buildPublishInput=Cn;exports.eventLine=Bn;exports.importStatusLine=qn;exports.parseArgs=gn;exports.parseEnvPairs=Se;exports.parseYamlConfig=zs;exports.parseYamlConfigLocated=ut;exports.runCli=Rs;exports.traceEventLine=Vn;exports.trialDetailLines=Mn;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { B as JobCreate, ak as PublishDatasetInput, aq as AgentInput, Q as Trial, a5 as TraceEvent, ai as DatasetImport, a7 as JobEvent } from '../types-B6iGD_du.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* evolve-evals — CLI for Evolve hosted datasets & jobs.
|
|
6
|
+
*
|
|
7
|
+
* Noun-verb grammar over the hosted client: `evolve-evals <noun> <verb>`,
|
|
8
|
+
* with `run` as the one top-level shortcut (alias of `job start`). Singular
|
|
9
|
+
* nouns are canonical; the plurals parse as hidden aliases. The CLI speaks
|
|
10
|
+
* ONLY through the SDK clients (datasets() / agents() / jobs() / trials() /
|
|
11
|
+
* auth()) — no raw HTTP lives here.
|
|
12
|
+
*
|
|
13
|
+
* Output: human tables on a TTY, tab-separated rows when piped, --json for
|
|
14
|
+
* the rendered machine shape (NDJSON for --watch event streams), -q for
|
|
15
|
+
* ids-only lists. Exit codes: 0 success (watch: job COMPLETED / publish
|
|
16
|
+
* COMPLETED), 1 runtime/API failure (watch: FAILED or CANCELLED), 2 usage
|
|
17
|
+
* error.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** Usage-level error: bad command line, not a runtime failure. Exit code 2. */
|
|
21
|
+
declare class CliUsageError extends Error {
|
|
22
|
+
constructor(message: string);
|
|
23
|
+
}
|
|
24
|
+
declare const USAGE: string;
|
|
25
|
+
interface Invocation {
|
|
26
|
+
/** Canonical "<group> <verb>", or "help" / "version". */
|
|
27
|
+
command: string;
|
|
28
|
+
positionals: string[];
|
|
29
|
+
flags: Record<string, string | number | boolean | string[]>;
|
|
30
|
+
}
|
|
31
|
+
declare function parseArgs(argv: string[]): Invocation;
|
|
32
|
+
/**
|
|
33
|
+
* -c reads real YAML through the standard `yaml` package — the hand-rolled
|
|
34
|
+
* subset reader is retired. PyYAML's reading is the contract, so the schema is
|
|
35
|
+
* YAML 1.1 (`yes`/`on` are booleans, `012` is octal, a flow mapping is a whole
|
|
36
|
+
* sequence item) with two carve-outs: the 1.1 spec's bare `y`/`n` booleans,
|
|
37
|
+
* which PyYAML never adopted — `n: 3` keeps its key — and the 1.1 spec's
|
|
38
|
+
* number shapes PyYAML never adopted either, where a float needs a dot and a
|
|
39
|
+
* signed exponent and an integer may not be zero-padded, so `e3`, `1e3`, `08`
|
|
40
|
+
* and `0:0` stay the strings a caller wrote. The schema is PINNED, not
|
|
41
|
+
* merely defaulted: PyYAML's resolver has no mode but 1.1 and reads a file the
|
|
42
|
+
* same way whatever its `%YAML` directive says, while this library lets an
|
|
43
|
+
* explicit `%YAML 1.2` swap in the 1.2 core schema. One file, one reading.
|
|
44
|
+
* Three refusals sit on top of the library: a second document, an unresolvable
|
|
45
|
+
* tag (both PyYAML refusals too), and a duplicate key — PyYAML silently keeps
|
|
46
|
+
* the last value, and that silence is exactly the corruption a config file
|
|
47
|
+
* cannot afford. Every refusal names its `source` and carries `:line` wherever
|
|
48
|
+
* the parser places the problem — the library's alias-bomb guard fires at
|
|
49
|
+
* resolution, after parsing, and has no position to give. An empty or
|
|
50
|
+
* comment-only file is an empty object.
|
|
51
|
+
*/
|
|
52
|
+
declare function parseYamlConfig(text: string, source: string): unknown;
|
|
53
|
+
/** A path into the parsed config: object keys and list indices, root first. */
|
|
54
|
+
type ConfigPath = (string | number)[];
|
|
55
|
+
/**
|
|
56
|
+
* `parseYamlConfig` plus a `locate` that answers "what line does this path
|
|
57
|
+
* start on", so a schema refusal can point at the file the way a parse
|
|
58
|
+
* refusal already does. JSON configs have no locator — JSON.parse keeps no
|
|
59
|
+
* positions — and every message treats the line as optional for that reason.
|
|
60
|
+
*/
|
|
61
|
+
declare function parseYamlConfigLocated(text: string, source: string): {
|
|
62
|
+
value: unknown;
|
|
63
|
+
locate: (path: ConfigPath) => number | undefined;
|
|
64
|
+
};
|
|
65
|
+
/** Parse repeatable KEY=VALUE pairs into an env map. */
|
|
66
|
+
declare function parseEnvPairs(pairs: string[], flag: string): Record<string, string>;
|
|
67
|
+
/**
|
|
68
|
+
* Build the POST /api/jobs body from a parsed `job start` invocation:
|
|
69
|
+
* -c loads a base config in the spec's own vocabulary, then every explicitly
|
|
70
|
+
* passed flag overrides the corresponding field. -i/-x/-l are stamped onto
|
|
71
|
+
* EVERY dataset selector — per-selector filters with one flag grammar, so a
|
|
72
|
+
* glob that matches nothing in one dataset simply filters nothing there.
|
|
73
|
+
*/
|
|
74
|
+
declare function buildJobInput(inv: Invocation, read?: (path: string) => string): JobCreate;
|
|
75
|
+
/** Build the datasets().publish() input from a parsed `dataset publish` invocation. */
|
|
76
|
+
declare function buildPublishInput(inv: Invocation): PublishDatasetInput;
|
|
77
|
+
/**
|
|
78
|
+
* Build the agents().create() input from a parsed `agent add` invocation.
|
|
79
|
+
* `--install-script` names a FILE; its contents are what the SDK uploads.
|
|
80
|
+
*/
|
|
81
|
+
declare function buildAgentInput(inv: Invocation, readScript?: (path: string) => string): AgentInput;
|
|
82
|
+
interface CliIO {
|
|
83
|
+
out(line: string): void;
|
|
84
|
+
err(line: string): void;
|
|
85
|
+
/**
|
|
86
|
+
* True when stdout is an interactive terminal. Drives the table-vs-TSV
|
|
87
|
+
* split on list commands; TERM=dumb counts as non-interactive. Defaults to
|
|
88
|
+
* false when absent so redirected output always gets machine-safe rows.
|
|
89
|
+
*/
|
|
90
|
+
tty?: boolean;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Full-detail rendering of one trial — evolve-evals trial show. Exported for
|
|
94
|
+
* tests, like the other line renderers.
|
|
95
|
+
*/
|
|
96
|
+
declare function trialDetailLines(run: Trial): string[];
|
|
97
|
+
/** One trace event line — evolve-evals trial download --stream trace-parsed. */
|
|
98
|
+
declare function traceEventLine(event: TraceEvent): string;
|
|
99
|
+
/** Compact one-line rendering of one publish status change for --watch. */
|
|
100
|
+
declare function importStatusLine(job: DatasetImport): string;
|
|
101
|
+
/** Compact one-line rendering of one SSE event for --watch. */
|
|
102
|
+
declare function eventLine(event: JobEvent): string;
|
|
103
|
+
declare function runCli(argv: string[], io?: CliIO): Promise<number>;
|
|
104
|
+
|
|
105
|
+
export { type CliIO, CliUsageError, type Invocation, USAGE, buildAgentInput, buildJobInput, buildPublishInput, eventLine, importStatusLine, parseArgs, parseEnvPairs, parseYamlConfig, parseYamlConfigLocated, runCli, traceEventLine, trialDetailLines };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { B as JobCreate, ak as PublishDatasetInput, aq as AgentInput, Q as Trial, a5 as TraceEvent, ai as DatasetImport, a7 as JobEvent } from '../types-B6iGD_du.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* evolve-evals — CLI for Evolve hosted datasets & jobs.
|
|
6
|
+
*
|
|
7
|
+
* Noun-verb grammar over the hosted client: `evolve-evals <noun> <verb>`,
|
|
8
|
+
* with `run` as the one top-level shortcut (alias of `job start`). Singular
|
|
9
|
+
* nouns are canonical; the plurals parse as hidden aliases. The CLI speaks
|
|
10
|
+
* ONLY through the SDK clients (datasets() / agents() / jobs() / trials() /
|
|
11
|
+
* auth()) — no raw HTTP lives here.
|
|
12
|
+
*
|
|
13
|
+
* Output: human tables on a TTY, tab-separated rows when piped, --json for
|
|
14
|
+
* the rendered machine shape (NDJSON for --watch event streams), -q for
|
|
15
|
+
* ids-only lists. Exit codes: 0 success (watch: job COMPLETED / publish
|
|
16
|
+
* COMPLETED), 1 runtime/API failure (watch: FAILED or CANCELLED), 2 usage
|
|
17
|
+
* error.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** Usage-level error: bad command line, not a runtime failure. Exit code 2. */
|
|
21
|
+
declare class CliUsageError extends Error {
|
|
22
|
+
constructor(message: string);
|
|
23
|
+
}
|
|
24
|
+
declare const USAGE: string;
|
|
25
|
+
interface Invocation {
|
|
26
|
+
/** Canonical "<group> <verb>", or "help" / "version". */
|
|
27
|
+
command: string;
|
|
28
|
+
positionals: string[];
|
|
29
|
+
flags: Record<string, string | number | boolean | string[]>;
|
|
30
|
+
}
|
|
31
|
+
declare function parseArgs(argv: string[]): Invocation;
|
|
32
|
+
/**
|
|
33
|
+
* -c reads real YAML through the standard `yaml` package — the hand-rolled
|
|
34
|
+
* subset reader is retired. PyYAML's reading is the contract, so the schema is
|
|
35
|
+
* YAML 1.1 (`yes`/`on` are booleans, `012` is octal, a flow mapping is a whole
|
|
36
|
+
* sequence item) with two carve-outs: the 1.1 spec's bare `y`/`n` booleans,
|
|
37
|
+
* which PyYAML never adopted — `n: 3` keeps its key — and the 1.1 spec's
|
|
38
|
+
* number shapes PyYAML never adopted either, where a float needs a dot and a
|
|
39
|
+
* signed exponent and an integer may not be zero-padded, so `e3`, `1e3`, `08`
|
|
40
|
+
* and `0:0` stay the strings a caller wrote. The schema is PINNED, not
|
|
41
|
+
* merely defaulted: PyYAML's resolver has no mode but 1.1 and reads a file the
|
|
42
|
+
* same way whatever its `%YAML` directive says, while this library lets an
|
|
43
|
+
* explicit `%YAML 1.2` swap in the 1.2 core schema. One file, one reading.
|
|
44
|
+
* Three refusals sit on top of the library: a second document, an unresolvable
|
|
45
|
+
* tag (both PyYAML refusals too), and a duplicate key — PyYAML silently keeps
|
|
46
|
+
* the last value, and that silence is exactly the corruption a config file
|
|
47
|
+
* cannot afford. Every refusal names its `source` and carries `:line` wherever
|
|
48
|
+
* the parser places the problem — the library's alias-bomb guard fires at
|
|
49
|
+
* resolution, after parsing, and has no position to give. An empty or
|
|
50
|
+
* comment-only file is an empty object.
|
|
51
|
+
*/
|
|
52
|
+
declare function parseYamlConfig(text: string, source: string): unknown;
|
|
53
|
+
/** A path into the parsed config: object keys and list indices, root first. */
|
|
54
|
+
type ConfigPath = (string | number)[];
|
|
55
|
+
/**
|
|
56
|
+
* `parseYamlConfig` plus a `locate` that answers "what line does this path
|
|
57
|
+
* start on", so a schema refusal can point at the file the way a parse
|
|
58
|
+
* refusal already does. JSON configs have no locator — JSON.parse keeps no
|
|
59
|
+
* positions — and every message treats the line as optional for that reason.
|
|
60
|
+
*/
|
|
61
|
+
declare function parseYamlConfigLocated(text: string, source: string): {
|
|
62
|
+
value: unknown;
|
|
63
|
+
locate: (path: ConfigPath) => number | undefined;
|
|
64
|
+
};
|
|
65
|
+
/** Parse repeatable KEY=VALUE pairs into an env map. */
|
|
66
|
+
declare function parseEnvPairs(pairs: string[], flag: string): Record<string, string>;
|
|
67
|
+
/**
|
|
68
|
+
* Build the POST /api/jobs body from a parsed `job start` invocation:
|
|
69
|
+
* -c loads a base config in the spec's own vocabulary, then every explicitly
|
|
70
|
+
* passed flag overrides the corresponding field. -i/-x/-l are stamped onto
|
|
71
|
+
* EVERY dataset selector — per-selector filters with one flag grammar, so a
|
|
72
|
+
* glob that matches nothing in one dataset simply filters nothing there.
|
|
73
|
+
*/
|
|
74
|
+
declare function buildJobInput(inv: Invocation, read?: (path: string) => string): JobCreate;
|
|
75
|
+
/** Build the datasets().publish() input from a parsed `dataset publish` invocation. */
|
|
76
|
+
declare function buildPublishInput(inv: Invocation): PublishDatasetInput;
|
|
77
|
+
/**
|
|
78
|
+
* Build the agents().create() input from a parsed `agent add` invocation.
|
|
79
|
+
* `--install-script` names a FILE; its contents are what the SDK uploads.
|
|
80
|
+
*/
|
|
81
|
+
declare function buildAgentInput(inv: Invocation, readScript?: (path: string) => string): AgentInput;
|
|
82
|
+
interface CliIO {
|
|
83
|
+
out(line: string): void;
|
|
84
|
+
err(line: string): void;
|
|
85
|
+
/**
|
|
86
|
+
* True when stdout is an interactive terminal. Drives the table-vs-TSV
|
|
87
|
+
* split on list commands; TERM=dumb counts as non-interactive. Defaults to
|
|
88
|
+
* false when absent so redirected output always gets machine-safe rows.
|
|
89
|
+
*/
|
|
90
|
+
tty?: boolean;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Full-detail rendering of one trial — evolve-evals trial show. Exported for
|
|
94
|
+
* tests, like the other line renderers.
|
|
95
|
+
*/
|
|
96
|
+
declare function trialDetailLines(run: Trial): string[];
|
|
97
|
+
/** One trace event line — evolve-evals trial download --stream trace-parsed. */
|
|
98
|
+
declare function traceEventLine(event: TraceEvent): string;
|
|
99
|
+
/** Compact one-line rendering of one publish status change for --watch. */
|
|
100
|
+
declare function importStatusLine(job: DatasetImport): string;
|
|
101
|
+
/** Compact one-line rendering of one SSE event for --watch. */
|
|
102
|
+
declare function eventLine(event: JobEvent): string;
|
|
103
|
+
declare function runCli(argv: string[], io?: CliIO): Promise<number>;
|
|
104
|
+
|
|
105
|
+
export { type CliIO, CliUsageError, type Invocation, USAGE, buildAgentInput, buildJobInput, buildPublishInput, eventLine, importStatusLine, parseArgs, parseEnvPairs, parseYamlConfig, parseYamlConfigLocated, runCli, traceEventLine, trialDetailLines };
|