@evolvingmachines/sdk 0.0.50 → 0.0.52-berth-day-one.20260814.cc8d926
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/README.md +9 -1
- package/dist/chunk-ONFS4OPY.js +10 -0
- package/dist/cli/index.cjs +24 -0
- package/dist/cli/index.d.cts +146 -0
- package/dist/cli/index.d.ts +146 -0
- package/dist/cli/index.js +15 -0
- package/dist/index.cjs +443 -80
- package/dist/index.d.cts +1735 -465
- package/dist/index.d.ts +1735 -465
- package/dist/index.js +429 -78
- package/dist/managed-modal-CRZFDIRG.js +4 -0
- package/dist/tar-KTM2224F.js +1 -0
- package/dist/types-rqn7yZnX.d.cts +2512 -0
- package/dist/types-rqn7yZnX.d.ts +2512 -0
- package/harness-capabilities.json +365 -0
- package/hosted-error-codes.json +76 -0
- package/package.json +38 -10
- package/spec/atif/README.md +45 -0
- package/spec/atif/trajectory.schema.json +865 -0
- package/spec/openapi.yaml +7649 -0
package/README.md
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
<br><br>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/evolving-machines-lab/evolve/main/logo/evolving-machines-ink.png" alt="Evolving Machines" width="380">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<br><br>
|
|
8
|
+
|
|
9
|
+
# Evolving Machines — Evolve SDK (TypeScript)
|
|
2
10
|
|
|
3
11
|
Evolve SDK lets you run and orchestrate terminal-based AI agents in secure sandboxes with built-in observability.
|
|
4
12
|
|
|
@@ -0,0 +1,10 @@
|
|
|
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 fe(e=""){let t=process.env.EVOLVE_GATEWAY_URL||"https://swarmkit-gateway-692833842999.us-central1.run.app";if(!e)return t;let n=e.startsWith("/")?e:`/${e}`;return `${t}${n}`}function be(e=""){let t=process.env.EVOLVE_DASHBOARD_URL||E;if(!e)return t;let n=e.startsWith("/")?e:`/${e}`;return `${t.replace(/\/$/,"")}${n}`}var gt=["e2b","daytona","modal"];function X(e){return be(`/api/managed/${e}`)}function pt(){return `${X("daytona")}/toolbox`}function mt(){return X("e2b")}function _t(e){return {"browser-use":{type:"http",url:fe("/browser_use/mcp"),headers:{"x-litellm-api-key":`Bearer ${e}`}}}}var G="EVOLVE_API_KEY",ft="E2B_API_KEY",bt="DAYTONA_API_KEY",yt="MODAL_TOKEN_ID",Rt="MODAL_TOKEN_SECRET",vt="claude",kt=36e5,xt=4,At=100,Q="/home/user";function Tt(e,t){return t?t.replace(/\/+$/,"")||"/":e?e==="root"?"/root":`/home/${e}`:Q}var E=process.env.EVOLVE_DASHBOARD_URL||"https://dashboard.evolvingmachines.ai",ht="x-litellm-customer-id",Pt="x-litellm-tags",Dt="run:",Et=".evolve-sdk/observability/sessions",wt=["tag","provider","agent","model","sandboxId","sandbox_id","timestamp","event","events"],It=100,Ct=5e3,Ot=3,Jt=1e3;var ye=["QUEUED","RUNNING","SCORING","SCORED","SCORING_ERROR","INFRASTRUCTURE_ERROR","INDETERMINATE","CANCELLED"],Re=["e2b","daytona","modal"];function ve(e){let t=e.stats?.evals??{},n=[];for(let a of Object.keys(t).sort()){let s=t[a]?.pass_at_k??{},o=[];for(let c of Object.keys(s)){let u=Number(c),r=s[c];!Number.isFinite(u)||typeof r!="number"||!Number.isFinite(r)||o.push({k:u,value:r});}o.length!==0&&(o.sort((c,u)=>c.k-u.k),n.push({evals_key:a,points:o}));}return n}var ke=["trace-parsed","verifier","trace-stdout","trace-stderr","trace-atif","trajectory","agent-home"],Z=["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","skill_not_found","skill_name_not_found","skill_ref_invalid","skill_unresolvable","skill_invalid","skill_in_use","skill_too_large","skill_limit_reached","secret_not_found","secret_ambiguous","secret_brokered_unsupported","secret_exists","agent_version_not_found","agent_version_unresolvable","agent_kwarg_unsupported","agent_config_unsupported","agent_config_key_refused","agent_preset_unsupported","job_too_large","provider_unsupported","job_not_found","job_not_terminal","no_failed_trials","trial_not_found","trial_not_settled","concurrent_update","regrade_source_ineligible","no_regradable_trials","import_not_found","import_too_large","invalid_archive","unpinned_git_ref","package_not_retained","package_corrupt","package_missing","internal_error"];function $(e){return typeof e=="string"&&Z.includes(e)}var xe=["level","binary","none"];function ee(e){let t={};for(let[n,a]of Object.entries(e)){let s=n.replace(/^\/+/,""),o=s.split("/");o.length>1&&o[0]==="root"?o.shift():o.length>2&&o[0]==="home"&&o.splice(0,2),o[0].length>1&&o[0].startsWith(".")&&(o[0]=o[0].slice(1));let c=o.join("/");c in t?t[s]=a:t[c]=a;}return t}function w(e){return JSON.stringify(e,null,2)+`
|
|
2
|
+
`}function te(e,t,n){return {trial_id:e.id,job_id:e.job_id,user_id:n,provider:e.sandbox_provider,gateway:{cost_usd:e.agent_result?.cost_usd??null,n_input_tokens:e.agent_result?.n_input_tokens??null,n_cache_tokens:e.agent_result?.n_cache_tokens??null,n_output_tokens:e.agent_result?.n_output_tokens??null,spend_source:e.spend_source,max_trial_spend_usd:e.max_trial_spend_usd,judge:e.judge_result?{cost_usd:e.judge_result.cost_usd,n_input_tokens:e.judge_result.n_input_tokens,n_cache_tokens:e.judge_result.n_cache_tokens,n_output_tokens:e.judge_result.n_output_tokens,spend_source:e.judge_spend_source??null}:null},regrade_lineage:{is_regrade:t?.is_regrade??false,source_jobs:t?.source_jobs??[],n_retries:e.n_retries,retries:e.retries}}}function Ae(e,t){return {job_id:e.id,user_id:t,provider:e.sandbox_provider,gateway:{cost_usd:e.stats.cost_usd??null,judge_cost_usd:e.stats.judge_cost_usd??null,n_input_tokens:e.stats.n_input_tokens??null,n_cache_tokens:e.stats.n_cache_tokens??null,n_output_tokens:e.stats.n_output_tokens??null,max_trial_spend_usd:e.max_trial_spend_usd,worst_case_spend_usd:e.worst_case_spend_usd},regrade_lineage:{is_regrade:e.is_regrade,source_jobs:e.source_jobs}}}function Te(e){let{trial:t}=e,n={};if(n["config.json"]=w({trial_name:t.id,task:{name:t.task_name,source:t.source},agent:{name:t.agent_info.name,version:t.agent_info.version,model_name:t.agent_info.model_info.name,reasoning_effort:t.agent_info.reasoning_effort}}),n["result.json"]=w({trial_name:t.id,task_name:t.task_name,status:t.status,reward:t.reward,verifier_result:t.verifier_result,exception_info:t.exception_info,agent_result:t.agent_result,started_at:t.started_at,finished_at:t.finished_at,environment_setup:t.environment_setup,agent_setup:t.agent_setup,agent_execution:t.agent_execution,verifier:t.verifier}),e.atif!==null&&(n["agent/trajectory.json"]=e.atif),e.stdout!==null&&(n["agent/stdout.log"]=e.stdout),e.stderr!==null&&(n["agent/stderr.log"]=e.stderr),e.events.length>0&&(n["agent/trace-parsed.jsonl"]=e.events.map(a=>JSON.stringify(a)).join(`
|
|
3
|
+
`)+`
|
|
4
|
+
`),e.home!==null){let a=ee(e.home);for(let s of Object.keys(a))n[`agent/sessions/${s}`]=a[s];}return e.verifierLog!==null&&(n["verifier/test-stdout.txt"]=e.verifierLog),t.verifier_result?.rewards&&(n["verifier/reward.json"]=w(t.verifier_result.rewards)),t.exception_info&&(n["exception.txt"]=`${t.exception_info.exception_type}: ${t.exception_info.exception_message}
|
|
5
|
+
`),n["evolve.json"]=w(te(t,e.job,e.userId)),n}var S=class extends Error{status;code;param;details;retryAfterSec;requestId;constructor(t,n,a,s){super(a),this.name="EvolveApiError",this.status=t,this.code=n,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 $(this.code)}};function ae(e,t){try{let o=JSON.parse(e)?.error?.retryAfterSec;if(typeof o=="number"&&Number.isFinite(o))return o}catch{}let n=t.headers?.get?.("retry-after");if(typeof n!="string"||n.trim()==="")return;let a=Number(n);return Number.isFinite(a)?a:void 0}async function K(e){let t=await e.text().catch(()=>""),n=e.headers?.get?.("x-request-id")??void 0,a=ae(t,e);try{let s=JSON.parse(t);if(s?.error&&typeof s.error=="object"){let o=typeof s.error.code=="string"?s.error.code:"unknown_error",c=typeof s.error.message=="string"?s.error.message:e.statusText;throw new S(e.status,o,c,{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:n})}}catch(s){if(s instanceof S)throw s}throw new S(e.status,"unknown_error",t||e.statusText,{retryAfterSec:a,requestId:n})}var F=class extends Error{dataset;constructor(t){super(`Dataset "${t}" has no active version`),this.name="NoActiveVersionError",this.dataset=t;}},B=class extends Error{name="GateRunningError";code="gate_running";dataset;version;gate;constructor(t,n,a,s){super(a),this.dataset=t,this.version=n,this.gate=s;}};function Oe(e){let t=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return {status:typeof t.status=="string"?t.status:"PENDING",tasks:typeof t.tasks=="number"?t.tasks:0,unverified:typeof t.unverified=="number"?t.unverified:0,ineligible:typeof t.ineligible=="number"?t.ineligible:0}}var Je=1e3,Le=3e4,je=new Set(["COMPLETED","CANCELLED","FAILED"]),Ue=new Set(["job.completed","job.cancelled","job.failed"]),Ve=2e3,Ne=new Set(["COMPLETED","FAILED"]);function h(e,t){let n=t?.apiKey||process.env[G];if(!n)throw new Error(`${e}() requires an API key. Set ${G} or pass { apiKey } in config.`);let a=(t?.baseUrl||process.env.EVOLVE_DASHBOARD_URL||E).replace(/\/$/,"");return {apiKey:n,baseUrl:a}}async function d(e,t,n){let a=await fetch(`${e.baseUrl}${t}`,{...n,headers:{Authorization:`Bearer ${e.apiKey}`,...n?.headers}});return a.ok||await K(a),a}function ne(e){let t=e.indexOf("@");if(t===-1)return {name:e.trim()};let n=e.slice(0,t).trim(),a=e.slice(t+1).trim();if(!n||!a)throw new Error(`Invalid dataset ref "${e}": expected "name" or "name@version"`);return {name:n,version:a}}function ie(e){return {name:e.name,version:e.version}}function oe(e){let t=e.kwargs,n=Array.isArray(e.skills)?e.skills.filter(o=>typeof o=="string"):[],a=Array.isArray(e.skill_locks)?e.skill_locks:null,s=a?a.flatMap(o=>{if(!o||typeof o!="object")return [];let c=o;return typeof c.name!="string"||typeof c.digest!="string"?[]:[{name:c.name,source:typeof c.source=="string"?c.source:"",digest:c.digest,git_url:typeof c.git_url=="string"?c.git_url:null,git_commit_id:typeof c.git_commit_id=="string"?c.git_commit_id:null}]}):null;return {name:e.name,model_name:e.model_name,version:e.version??null,reasoning_effort:e.reasoning_effort??null,kwargs:t&&typeof t=="object"&&!Array.isArray(t)?t:null,preset:typeof e.preset=="string"?e.preset:null,skills:n,skill_locks:s}}function Ge(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(typeof t.status!="string")return null;let n=t.failure&&typeof t.failure=="object"&&!Array.isArray(t.failure)?t.failure:{},a=typeof t.code=="string"?t.code:n.code,s=typeof t.message=="string"?t.message:n.message,o=$e(Array.isArray(t.failed_tasks)?t.failed_tasks:n.failed_tasks),c=typeof t.failed_task_count=="number"?t.failed_task_count:n.failed_task_count;return {status:t.status,attempts:typeof t.attempts=="number"?t.attempts:0,code:typeof a=="string"?a:null,message:typeof s=="string"?s:null,failed_tasks:o,failed_task_count:typeof c=="number"?c:o.length}}function $e(e){if(!Array.isArray(e))return [];let t=[];for(let n of e){if(!n||typeof n!="object"||Array.isArray(n))continue;let a=n;typeof a.task_name=="string"&&t.push({task_name:a.task_name,outcome:typeof a.outcome=="string"?a.outcome:null,reasons:Array.isArray(a.reasons)?a.reasons.filter(s=>typeof s=="string"):[]});}return t}function Me(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(typeof t.name!="string")return null;let n=Array.isArray(t.authors)?t.authors.flatMap(a=>{if(!a||typeof a!="object"||Array.isArray(a))return [];let s=a;return typeof s.name!="string"?[]:[{name:s.name,email:typeof s.email=="string"?s.email:null}]}):[];return {name:t.name,version:typeof t.version=="string"?t.version:null,description:typeof t.description=="string"?t.description:"",authors:n,keywords:Array.isArray(t.keywords)?t.keywords.filter(a=>typeof a=="string"):[],task_count:typeof t.task_count=="number"?t.task_count:null}}function Fe(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;return typeof t.ref!="string"||typeof t.commit!="string"?null:{git_url:typeof t.git_url=="string"?t.git_url:null,ref:t.ref,commit:t.commit,path:typeof t.path=="string"?t.path:null}}function I(e){return {version:e.version,state:e.state,created_at:e.created_at,task_count:e.task_count??0,manifest:Me(e.manifest),source:Fe(e.source),gate:Ge(e.gate)}}function Be(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;return typeof t.outcome!="string"?null:{outcome:t.outcome,flaky:t.flaky===true,reasons:Array.isArray(t.reasons)?t.reasons.filter(n=>typeof n=="string"):[],ran_at:typeof t.ran_at=="string"?t.ran_at:null}}function He(e){return {task_name:e.task_name,agent_timeout_sec:e.agent_timeout_sec,verifier_timeout_sec:e.verifier_timeout_sec,gpus:typeof e.gpus=="number"&&e.gpus>0?e.gpus:0,gpu_types:Array.isArray(e.gpu_types)&&e.gpu_types.length>0?e.gpu_types.map(String):null,providers:e.providers,gate:Be(e.gate)}}function qe(e){return {action:e.action,type:e.type,job_id:e.job_id}}function Ke(e){let t=e&&typeof e=="object"?e:{};return {max_retries:typeof t.max_retries=="number"?t.max_retries:0,include_exceptions:Array.isArray(t.include_exceptions)?t.include_exceptions:null,exclude_exceptions:Array.isArray(t.exclude_exceptions)?t.exclude_exceptions:[],wait_multiplier:typeof t.wait_multiplier=="number"?t.wait_multiplier:1,min_wait_sec:typeof t.min_wait_sec=="number"?t.min_wait_sec:1,max_wait_sec:typeof t.max_wait_sec=="number"?t.max_wait_sec:60}}function We(e){return {attempt_number:e.attempt_number,exception_info:e.exception_info??{exception_type:"InfrastructureError",exception_message:""},cost_usd:e.cost_usd??null,started_at:e.started_at??null,settled_at:e.settled_at??null}}function C(e){return typeof e=="number"?e:null}function k(e){let t=e.trials??{};return {id:e.id,job_name:e.job_name,status:e.status,datasets:(e.datasets??[]).map(ie),agents:(e.agents??[]).map(oe),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,retry:Ke(e.retry),timeout_multiplier:typeof e.timeout_multiplier=="number"?e.timeout_multiplier:1,agent_timeout_multiplier:C(e.agent_timeout_multiplier),verifier_timeout_multiplier:C(e.verifier_timeout_multiplier),agent_setup_timeout_multiplier:C(e.agent_setup_timeout_multiplier),environment_build_timeout_multiplier:C(e.environment_build_timeout_multiplier),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(qe),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 b(e,t){let n=e??{};return {items:Array.isArray(n.items)?n.items.map(t):[],nextCursor:n.nextCursor??null,hasMore:n.hasMore===true}}function y(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[s,o]of Object.entries(t??{}))o!==void 0&&n.set(s,o);let a=n.toString();return a?`?${a}`:""}function O(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 ze(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 Ye(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let{from:t,to:n,reason:a}=e;return typeof t!="string"||typeof n!="string"||typeof a!="string"?null:{from:t,to:n,reason:a}}function H(e){return {id:e.id,job_id:e.job_id,task_name:e.task_name,source:e.source,agent_info:ze(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,judge_result:e.judge_result??null,environment_setup:O(e.environment_setup),agent_setup:O(e.agent_setup),agent_execution:O(e.agent_execution),verifier:O(e.verifier),step_results:e.step_results??null,spend_source:e.spend_source??null,judge_spend_source:e.judge_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_provider_degrade:Ye(e.sandbox_provider_degrade),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,n_retries:e.n_retries??0,retries:Array.isArray(e.retries)?e.retries.map(We):[],session_ref:e.session_ref??null,started_at:e.started_at??null,finished_at:e.finished_at??null}}function J(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 L(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 le(e){let t=e??{};return {scored:t.scored??0,total:t.total??0}}function Xe(e){return {id:e.id,datasets:(e.datasets??[]).map(ie),status:e.status,mean_reward:e.mean_reward??null,coverage:le(e.coverage),cost_usd:e.cost_usd??0,agents:(e.agents||[]).map(oe),started_at:e.started_at}}function Qe(e){return {job_id:e.job_id,status:e.status,mean_reward:e.mean_reward??null,coverage:le(e.coverage)}}function Ze(e){return {task_name:e.task_name,disagreement:e.disagreement===true,cells:(e.cells||[]).map(Qe)}}function ue(e){return {seq:e.seq,type:e.type,data:e.data??{}}}function et(e){return {trial_id:e.trial_id,task_name:e.task_name??null,match_count:e.match_count,events:(e.events||[]).map(ue)}}function tt(e){return e?e.suffix!==void 0?`bytes=-${e.suffix}`:e.start===void 0?null:`bytes=${e.start}-${e.end??""}`:null}function q(e){if(e?.aborted)throw e.reason instanceof Error?e.reason:new Error("Watch aborted")}function re(e,t){return t?.aborted?true:e?.name==="AbortError"}function P(e,t){return new Promise((n,a)=>{let s=setTimeout(()=>{t?.removeEventListener("abort",o),n();},e),o=()=>{clearTimeout(s),a(t?.reason instanceof Error?t.reason:new Error("Watch aborted"));};t?.addEventListener("abort",o,{once:true});})}function nt(e){let t="",n=false;return {push(a){n&&(a="\r"+a,n=false),a.endsWith("\r")&&(a=a.slice(0,-1),n=true),t+=a.replace(/\r\n|\r/g,`
|
|
6
|
+
`);let s;for(;(s=t.indexOf(`
|
|
7
|
+
|
|
8
|
+
`))!==-1;){let o=t.slice(0,s);t=t.slice(s+2);let c,u,r=[];for(let i of o.split(`
|
|
9
|
+
`)){if(!i||i.startsWith(":"))continue;let l=i.indexOf(":"),p=l===-1?i:i.slice(0,l),g=l===-1?"":i.slice(l+1);g.startsWith(" ")&&(g=g.slice(1)),p==="id"?c=g:p==="event"?u=g:p==="data"&&r.push(g);}(c!==void 0||u!==void 0||r.length>0)&&e({id:c,event:u,data:r.join(`
|
|
10
|
+
`)});}}}}function T(e,t){let n,a=()=>n??=e({limit:t?.limit,cursor:t?.cursor});return {then(s,o){return a().then(s,o)},catch(s){return a().catch(s)},finally(s){return a().finally(s)},async*[Symbol.asyncIterator](){let s=t?.cursor;for(;;){let o=await e({limit:t?.limit,cursor:s});for(let c of o.items)yield c;if(!o.nextCursor)return;s=o.nextCursor;}}}}function D(e,t){let n=new FormData;for(let[a,s]of Object.entries(e))s!==void 0&&n.set(a,s);return t&&n.set("archive",new Blob([t.bytes],{type:"application/gzip"}),t.filename),n}function rt(e){let t,n=()=>(t||(t=(async()=>{let a=await e.next();for(;!a.done;)a=await e.next();return a.value})()),t);return {then(a,s){return n().then(a,s)},catch(a){return n().catch(a)},finally(a){return n().finally(a)},[Symbol.asyncIterator](){return e}}}var ce="x-package-sha256",j=class extends Error{constructor(n,a){super(`downloaded bytes do not match the digest the server stated (expected ${n}, got ${a})`);this.expected=n;this.actual=a;}name="EvolveDigestMismatchError"},U=class extends Error{constructor(n,a){super(`download ended early: the server declared ${n} bytes and ${a} arrived`);this.expectedBytes=n;this.receivedBytes=a;}name="EvolveIncompleteDownloadError"};function de(e,t){let n=e.headers.get("Content-Length");if(n===null)return;let a=Number(n);if(Number.isFinite(a)&&t!==a)throw new U(a,t)}async function ge(e,t){let n=e.headers.get(ce);if(!n)return;let{createHash:a}=await import('crypto'),s=a("sha256").update(t).digest("hex");if(s!==n)throw new j(n,s)}function st(e,t){let a=(e.headers.get("Content-Disposition")||"").match(/filename="([^"]+)"/);if(!a)return t;let s=basename(a[1]);return s===""||s==="."||s===".."||/[/\\]/.test(s)||/[\u0000-\u001f]/.test(s)?t:s}async function pe(e,t,n){if(!e.body)throw new Error("Download response has no body");await mkdir(t,{recursive:true});let a=join(t,st(e,n)),{createHash:s,randomBytes:o}=await import('crypto'),c=`${a}.${o(8).toString("hex")}.part`,u=s("sha256"),r=0,i=Readable.fromWeb(e.body);i.on("data",l=>{u.update(l),r+=l.length;});try{await pipeline(i,createWriteStream(c));let l=e.headers.get("Content-Length");if(l!==null&&r!==Number(l))throw new U(Number(l),r);let p=e.headers.get(ce),g=u.digest("hex");if(p&&g!==p)throw new j(p,g);await rename(c,a);}catch(l){throw await rm(c,{force:true}).catch(()=>{}),l}return a}function at(e){let t=h("datasets",e);async function n(r){let i=await d(t,`/api/datasets/imports/${encodeURIComponent(r)}`);return L(await i.json())}function a(r){if(!r||typeof r!="object")return null;let i=r;return {git_url:i.git_url??null,ref:i.ref,current_commit:i.current_commit,path:i.path??null,latest_commit:i.latest_commit??null,acked_commit:i.acked_commit??null,moved:i.moved===true,behind_by:typeof i.behind_by=="number"?i.behind_by:null,checked_at:i.checked_at??null,error:i.error??null,auto_import:i.auto_import===true}}function s(r){return {name:r.name,title:r.title??null,description:r.description??null,active_version:r.active_version?I(r.active_version):null,versions:(r.versions||[]).map(I),selected_version:r.selected_version?I(r.selected_version):null,tasks:b(r.tasks,He),upstream:a(r.upstream),created_at:r.created_at,updated_at:r.updated_at}}async function o(r,i){let l=ne(r),p=y(i,{version:l.version}),g=await d(t,`/api/datasets/${encodeURIComponent(l.name)}${p}`);return s(await g.json())}function c(r){return {name:r.name,title:r.title??null,description:r.description??null,active_version:r.active_version?I(r.active_version):null,upstream:a(r.upstream)}}async function u(r){let i=await d(t,`/api/datasets${y(r,{search:r?.search})}`);return b(await i.json(),c)}return {list(r){return T(i=>u({...i,search:r?.search}),r)},get:o,async getActive(r,i){let l=await o(r,i);if(l.active_version===null)throw new F(r);return {name:l.name,title:l.title,description:l.description,active_version:l.active_version,version:l.active_version.version,tasks:l.tasks??{items:[],nextCursor:null,hasMore:false},versions:l.versions??[],created_at:l.created_at,updated_at:l.updated_at}},async publish(r){let i=r.source;if(i?.directory){if(r.name===void 0||r.version===void 0){let{existsSync:m}=await import('fs'),{join:x}=await import('path');if(!(m(x(i.directory,"dataset.toml"))||m(x(i.directory,"tasks","dataset.toml"))))throw new Error(`datasets().publish() needs ${r.name===void 0?"a name":"a version"} \u2014 pass it explicitly, or add a dataset.toml manifest to the corpus directory (the server then derives name and version from it)`)}let{tarGzipDirectory:l}=await import('./tar-KTM2224F.js'),p=await l(i.directory),g=await d(t,"/api/datasets/publish",{method:"POST",body:D({name:r.name,version:r.version},{bytes:p,filename:"corpus.tar.gz"})});return L(await g.json())}if(i&&"git_url"in i&&i.git_url){if(r.name===void 0||r.version===void 0)throw new Error("datasets().publish() requires name and version for a git source \u2014 a dataset.toml manifest can only supply them for a directory source, because a git repository is cloned server-side after the publish is accepted");let l=await d(t,"/api/datasets/publish",{method:"POST",body:D({name:r.name,version:r.version,git_url:i.git_url,git_ref:i.git_ref,...i.git_path!==void 0?{git_path:i.git_path}:{}})});return L(await l.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 (both optional for a directory whose corpus carries a dataset.toml manifest)")},getImport:n,async watchImport(r,i){let l=i?.pollIntervalMs??Ve,p=null;for(;;){q(i?.signal);let g;try{g=await n(r);}catch(m){if(m instanceof S&&(m.status===429||m.status===503)){await P(Math.max((m.retryAfterSec??0)*1e3,l),i?.signal);continue}throw m}if(g.status!==p&&(p=g.status,i?.onStatus?.(g)),Ne.has(g.status))return g;await P(l,i?.signal);}},download:(async(r,i)=>{let l=ne(r),p=l.version?`?version=${encodeURIComponent(l.version)}`:"",g=await d(t,`/api/datasets/${encodeURIComponent(l.name)}/download${p}`);if(i?.stream){if(!g.body)throw new Error("Package response has no body");return g.body}if(i?.to)return pe(g,i.to,`${l.name}-corpus.tar.gz`);let m=Buffer.from(await g.arrayBuffer());return de(g,m.length),await ge(g,m),m}),listImports(r){return T(async i=>{let l=new URLSearchParams;i.limit!==void 0&&l.set("limit",String(i.limit)),i.cursor!==void 0&&l.set("cursor",i.cursor),r?.status!==void 0&&l.set("status",r.status),r?.dataset!==void 0&&l.set("dataset",r.dataset);let p=l.toString()?`?${l}`:"",g=await d(t,`/api/datasets/imports${p}`);return b(await g.json(),L)},r)},async activate(r,i){let l=await d(t,`/api/datasets/${encodeURIComponent(r)}/versions/${encodeURIComponent(i)}/activate`,{method:"POST"});if(l.status===202){let p=await l.json();throw new B(r,i,typeof p.message=="string"?p.message:`Dataset "${r}" version "${i}" is still being proven by its activation gate`,Oe(p.gate))}return s(await l.json())},async update(r,i){let l=await d(t,`/api/datasets/${encodeURIComponent(r)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});return c(await l.json())},async delete(r){await d(t,`/api/datasets/${encodeURIComponent(r)}`,{method:"DELETE"});}}}function it(e){let t=h("agents",e);return {async create(n){let a=await se("agents().create()",n),s=await d(t,"/api/agents",{method:"POST",body:a});return J(await s.json())},list(n){return T(async a=>{let s=await d(t,`/api/agents${y(a)}`);return b(await s.json(),J)},n)},async get(n){let a=await d(t,`/api/agents/${encodeURIComponent(n)}`);return J(await a.json())},async delete(n){await d(t,`/api/agents/${encodeURIComponent(n)}`,{method:"DELETE"});},async upsert(n,a){let s=await se("agents().upsert()",{...a,name:n}),o=await d(t,`/api/agents/${encodeURIComponent(n)}`,{method:"PUT",body:s});return J(await o.json())}}}async function se(e,t){let n=typeof t.install_script=="string",a=typeof t.directory=="string";if(n&&a)throw new Error(`${e} takes EITHER an install script ({ install_script }) or a local directory ({ directory }), not both`);if(!n&&!a)throw new Error(`${e} requires either an install script ({ install_script }) or a local directory ({ directory }), plus run_command`);let s={name:t.name,run_command:t.run_command,...t.env!==void 0?{env:JSON.stringify(t.env)}:{},...n?{install_script:t.install_script}:{}};if(a){let{tarGzipDirectory:o}=await import('./tar-KTM2224F.js'),c=await o(t.directory);return D(s,{bytes:c,filename:"source.tar.gz"})}return D(s)}function M(e){return {id:e.id,name:e.name,digest:e.digest,size_bytes:e.size_bytes??0,description:e.description??null,ref:e.ref??`upload:${e.id}`,created_at:e.created_at}}function ot(e){let t=h("skills",e);return {async upload(n){if(typeof n!="string"||!n.trim())throw new Error("skills().upload() requires a local skill directory path");let{tarGzipDirectory:a}=await import('./tar-KTM2224F.js'),{basename:s,resolve:o}=await import('path'),c=s(o(n)),u=await a(n),i=await(await d(t,"/api/skills",{method:"POST",body:D({name:c||void 0},{bytes:u,filename:"skill.tar.gz"})})).json();return (Array.isArray(i.skills)?i.skills:[i]).map(M)},list(n){return T(async a=>{let s=await d(t,`/api/skills${y(a)}`);return b(await s.json(),M)},n)},async get(n){let s=await(await d(t,`/api/skills/${encodeURIComponent(n)}`)).json();return {...M(s),skill_md:s.skill_md??null}},async delete(n){await d(t,`/api/skills/${encodeURIComponent(n)}`,{method:"DELETE"});}}}function lt(e){let t=h("jobs",e);async function n(u){let r=await d(t,`/api/jobs/${encodeURIComponent(u)}`);return k(await r.json())}async function a(u){let r=await d(t,`/api/jobs${y(u,{search:u?.search})}`);return b(await r.json(),k)}function s(u){let r=u.trials??{};return {task_name:u.task_name,source:u.source,trials:{total:r.total??0,byStatus:r.byStatus??{}},mean_reward:u.mean_reward??null,cost_usd:u.cost_usd??null}}async function o(u,r){let i=y(r,{status:r?.status?.length?r.status.join(","):void 0,dataset:r?.dataset}),l=await d(t,`/api/jobs/${encodeURIComponent(u)}/trials${i}`);return b(await l.json(),H)}async function*c(u,r){let{onEvent:i,signal:l}=r??{},p=r?.reconnectDelayMs??Je,g=r?.maxReconnectDelayMs??Le,m=null,x=false,V=false,f=p;for(;!x;){q(l);let R;try{R=await fetch(`${t.baseUrl}/api/jobs/${encodeURIComponent(u)}/events`,{headers:{Authorization:`Bearer ${t.apiKey}`,Accept:"text/event-stream",...m!==null?{"Last-Event-ID":String(m)}:{}},signal:l});}catch(_){if(re(_,l))throw _;await P(f,l),f=Math.min(f*2,g);continue}if(!R.ok){if(R.status===429||R.status>=500){let _=await R.text().catch(()=>""),v=ae(_,R)??0,A=v>0?Math.max(v*1e3,f):f;await P(A,l),f=Math.min(f*2,g);continue}await K(R);}if(!R.body)throw new Error("Event stream response has no body");let W=false,N=[],me=nt(_=>{let v=Number(_.id),A={seq:Number.isInteger(v)?v:-1,type:_.event||"message",data:_.data?ct(_.data):{}};Number.isInteger(v)&&(m=v),W=true,Ue.has(A.type)&&(x=true),N.push(A);}),z=R.body.getReader(),_e=new TextDecoder;try{for(;!x;){let{done:_,value:v}=await z.read();if(_)break;me.push(_e.decode(v,{stream:!0}));for(let A of N)i?.(A),yield A;N.length=0;}}catch(_){if(re(_,l))throw _}finally{await z.cancel().catch(()=>{});}if(x)break;q(l);let Y=await n(u);if(je.has(Y.status)){if(V)return Y;V=true;continue}W&&(f=p),await P(f,l),f=Math.min(f*2,g);}return n(u)}return {async start(u,r){let i=await d(t,"/api/jobs",{method:"POST",headers:{"Content-Type":"application/json",...r?.idempotencyKey?{"Idempotency-Key":r.idempotencyKey}:{}},body:JSON.stringify(u)});return k(await i.json())},get:n,list(u){return T(r=>a({...r,search:u?.search}),u)},trials(u,r){return T(i=>o(u,{...i,status:r?.status,dataset:r?.dataset}),r)},tasks(u,r){return T(async i=>{let l=await d(t,`/api/jobs/${encodeURIComponent(u)}/tasks${y(i)}`);return b(await l.json(),s)},r)},watch(u,r){return rt(c(u,r))},async cancel(u){let r=await d(t,`/api/jobs/${encodeURIComponent(u)}/cancel`,{method:"POST"});return k(await r.json())},async compare(u){let r=u.map(encodeURIComponent).join(","),l=await(await d(t,`/api/jobs/compare?ids=${r}`)).json();return {jobs:(l.jobs||[]).map(Xe),taskMatrix:(l.taskMatrix||[]).map(Ze)}},async resume(u,r,i){let l=await d(t,`/api/jobs/${encodeURIComponent(u)}/resume`,{method:"POST",headers:{"Content-Type":"application/json",...i?.idempotencyKey?{"Idempotency-Key":i.idempotencyKey}:{}},body:JSON.stringify(r??{})});return k(await l.json())},async retry(u,r,i){let l=await d(t,`/api/jobs/${encodeURIComponent(u)}/retry`,{method:"POST",headers:{"Content-Type":"application/json",...i?.idempotencyKey?{"Idempotency-Key":i.idempotencyKey}:{}},body:JSON.stringify(r??{})});return k(await l.json())},async regrade(u,r){let i={};r?.statuses?.length&&(i.statuses=r.statuses),r?.task_name!==void 0&&(i.task_name=r.task_name);let l=await d(t,`/api/jobs/${encodeURIComponent(u)}/regrade`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});return k(await l.json())},download:(async(u,r)=>{let i=await d(t,`/api/jobs/${encodeURIComponent(u)}/download`);if(r?.stream){if(!i.body)throw new Error("Download response has no body");return i.body}if(r?.to)return pe(i,r.to,`job-${u}-results.tar.gz`);let l=Buffer.from(await i.arrayBuffer());return de(i,l.length),await ge(i,l),l}),async grep(u,r,i){let l=await d(t,`/api/jobs/${encodeURIComponent(u)}/grep${y(i,{q:r,type:i?.type})}`);return b(await l.json(),et)}}}function ut(e){let t=h("trials",e);async function n(s,o){let c=await d(t,`/api/trials/${encodeURIComponent(s)}/trace${y(o,{type:o?.type,grep:o?.grep,tail:o?.tail!==void 0?String(o.tail):void 0})}`);return b(await c.json(),ue)}async function a(s,o){let u=await(await d(t,`/api/trials/${encodeURIComponent(s)}/trace?stream=${o}`)).json();return o==="agent-home"?u.files??null:u.log??null}return {async get(s){let o=await d(t,`/api/trials/${encodeURIComponent(s)}`);return H(await o.json())},trace:n,artifact:a,async*traceEvents(s,o){let c=o?.cursor;for(;;){let u=await n(s,{...o,cursor:c});for(let r of u.items)yield r;if(!u.nextCursor)return;c=u.nextCursor;}},async regrade(s){let o=await d(t,`/api/trials/${encodeURIComponent(s)}/regrade`,{method:"POST"});return k(await o.json())},async retry(s,o){let c=await d(t,`/api/trials/${encodeURIComponent(s)}/retry`,{method:"POST",...o?.idempotencyKey?{headers:{"Idempotency-Key":o.idempotencyKey}}:{}});return k(await c.json())},async stop(s){let c=await(await d(t,"/api/trials/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({trial_ids:s})})).json();return {stopped:(c.stopped??[]).map(H),already_terminal:c.already_terminal??[],not_found:c.not_found??[]}},async files(s,o){let c=await d(t,`/api/trials/${encodeURIComponent(s)}/files${y(o)}`);return b(await c.json(),u=>({path:u.path,size_bytes:u.size_bytes}))},async file(s,o,c){let u=o.split("/").filter(Boolean).map(encodeURIComponent).join("/"),r=tt(c),i=await d(t,`/api/trials/${encodeURIComponent(s)}/files/${u}`,r?{headers:{Range:r}}:void 0);return Buffer.from(await i.arrayBuffer())}}}function Ht(e){let t=h("auth",e);return {async status(){let a=await(await d(t,"/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 ct(e){try{let t=JSON.parse(e);return t&&typeof t=="object"?t:{value:t}}catch{return {raw:e}}}function qt(e){let t,n,a,s,o;return {get datasets(){return t??=at(e)},get agents(){return n??=it(e)},get jobs(){return a??=lt(e)},get trials(){return s??=ut(e)},get skills(){return o??=ot(e)},meta(){return dt(e)}}}async function dt(e){let t=(e?.baseUrl||process.env.EVOLVE_DASHBOARD_URL||E).replace(/\/$/,""),n=await fetch(`${t}/api/meta`);return n.ok||await K(n),await n.json()}export{Ot as A,Jt as B,ye as C,Re as D,ve as E,ke as F,Z as G,$ as H,xe as I,te as J,Ae as K,Te as L,S as M,F as N,B as O,j as P,U as Q,at as R,it as S,ot as T,lt as U,ut as V,Ht as W,qt as X,dt as Y,fe as a,be as b,gt as c,X as d,pt as e,mt as f,_t as g,G as h,ft as i,bt as j,yt as k,Rt as l,vt as m,kt as n,xt as o,At as p,Q as q,Tt as r,E as s,ht as t,Pt as u,Dt as v,Et as w,wt as x,It as y,Ct as z};
|
|
@@ -0,0 +1,24 @@
|
|
|
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'),smolToml=require('smol-toml'),stream=require('stream');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;var qt=Object.defineProperty;var Bt=(e,t)=>()=>(e&&(t=e(e=0)),t);var Kt=(e,t)=>{for(var s in t)qt(e,s,{get:t[s],enumerable:true});};var z={};Kt(z,{extractTarGz:()=>an,tarGzipDirectory:()=>rn});async function sn(e){let t=[],s=async n=>{let r=n===""?e:path.join(e,n),a=await promises.readdir(r,{withFileTypes:true});a.sort((i,o)=>i.name<o.name?-1:i.name>o.name?1:0);for(let i of a){if(nn.has(i.name))continue;let o=n===""?i.name:`${n}/${i.name}`,l=path.join(r,i.name),u=await promises.lstat(l);u.isSymbolicLink()||(u.isDirectory()?await s(o):u.isFile()&&t.push({rel:o,abs:l,mode:u.mode&73?493:420,size:u.size}));}};return await s(""),t.sort((n,r)=>n.rel<r.rel?-1:n.rel>r.rel?1:0)}async function rn(e){let t=await sn(e),s=tarStream.pack(),n=zlib.createGzip({level:9}),r=[],a=(async()=>{for await(let o of n)r.push(Buffer.from(o));})(),i=(async()=>{for(let{rel:o,abs:l,mode:u,size:c}of t){let p=s.entry({name:o,size:c,mode:u,mtime:new Date(0),uid:0,gid:0,uname:"",gname:"",type:"file"});await promises$1.pipeline(fs$1.createReadStream(l),p);}s.finalize();})();return await Promise.all([promises$1.pipeline(s,n),i,a]),Buffer.concat(r)}async function an(e,t,s){let n=tarStream.extract(),r=[],a=(async()=>{for await(let i of n){let o=i.header.name,l=o.split("/").filter(c=>c!==""&&c!==".");if(o.startsWith("/")||o.includes("\\")||l.length===0||l.some(c=>c===".."))throw new Error(`refusing to extract "${o}": the path escapes the target directory`);if(l[0]!==s)throw new Error(`refusing to extract "${o}": entry outside ${s}/`);if(i.header.type==="directory"){await promises.mkdir(path.join(t,...l),{recursive:true}),i.resume();continue}if(i.header.type!=="file")throw new Error(`refusing to extract "${o}": unsupported entry type "${i.header.type}"`);let u=path.join(t,...l);await promises.mkdir(path.dirname(u),{recursive:true}),await promises$1.pipeline(i,fs$1.createWriteStream(u)),r.push(l.join("/"));}})();try{await Promise.all([promises$1.pipeline(fs$1.createReadStream(e),zlib.createGunzip(),n),a]);}catch(i){throw n.destroy(),i}return r}var nn,X=Bt(()=>{nn=new Set([".git",".DS_Store",".venv"]);});var Se="EVOLVE_API_KEY";var Ke=process.env.EVOLVE_DASHBOARD_URL||"https://dashboard.evolvingmachines.ai";var re=["QUEUED","RUNNING","SCORING","SCORED","SCORING_ERROR","INFRASTRUCTURE_ERROR","INDETERMINATE","CANCELLED"],ae=["e2b","daytona","modal"];function xe(e){let t=e.stats?.evals??{},s=[];for(let n of Object.keys(t).sort()){let r=t[n]?.pass_at_k??{},a=[];for(let i of Object.keys(r)){let o=Number(i),l=r[i];!Number.isFinite(o)||typeof l!="number"||!Number.isFinite(l)||a.push({k:o,value:l});}a.length!==0&&(a.sort((i,o)=>i.k-o.k),s.push({evals_key:n,points:a}));}return s}var Re=["trace-parsed","verifier","trace-stdout","trace-stderr","trace-atif","trajectory","agent-home"],He=["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","skill_not_found","skill_name_not_found","skill_ref_invalid","skill_unresolvable","skill_invalid","skill_in_use","skill_too_large","skill_limit_reached","secret_not_found","secret_ambiguous","secret_brokered_unsupported","secret_exists","agent_version_not_found","agent_version_unresolvable","agent_kwarg_unsupported","agent_config_unsupported","agent_config_key_refused","agent_preset_unsupported","job_too_large","provider_unsupported","job_not_found","job_not_terminal","no_failed_trials","trial_not_found","trial_not_settled","concurrent_update","regrade_source_ineligible","no_regradable_trials","import_not_found","import_too_large","invalid_archive","unpinned_git_ref","package_not_retained","package_corrupt","package_missing","internal_error"];function Ae(e){return typeof e=="string"&&He.includes(e)}function We(e){let t={};for(let[s,n]of Object.entries(e)){let r=s.replace(/^\/+/,""),a=r.split("/");a.length>1&&a[0]==="root"?a.shift():a.length>2&&a[0]==="home"&&a.splice(0,2),a[0].length>1&&a[0].startsWith(".")&&(a[0]=a[0].slice(1));let i=a.join("/");i in t?t[r]=n:t[i]=n;}return t}function ie(e){return JSON.stringify(e,null,2)+`
|
|
3
|
+
`}function oe(e,t,s){return {trial_id:e.id,job_id:e.job_id,user_id:s,provider:e.sandbox_provider,gateway:{cost_usd:e.agent_result?.cost_usd??null,n_input_tokens:e.agent_result?.n_input_tokens??null,n_cache_tokens:e.agent_result?.n_cache_tokens??null,n_output_tokens:e.agent_result?.n_output_tokens??null,spend_source:e.spend_source,max_trial_spend_usd:e.max_trial_spend_usd,judge:e.judge_result?{cost_usd:e.judge_result.cost_usd,n_input_tokens:e.judge_result.n_input_tokens,n_cache_tokens:e.judge_result.n_cache_tokens,n_output_tokens:e.judge_result.n_output_tokens,spend_source:e.judge_spend_source??null}:null},regrade_lineage:{is_regrade:t?.is_regrade??false,source_jobs:t?.source_jobs??[],n_retries:e.n_retries,retries:e.retries}}}function Ee(e,t){return {job_id:e.id,user_id:t,provider:e.sandbox_provider,gateway:{cost_usd:e.stats.cost_usd??null,judge_cost_usd:e.stats.judge_cost_usd??null,n_input_tokens:e.stats.n_input_tokens??null,n_cache_tokens:e.stats.n_cache_tokens??null,n_output_tokens:e.stats.n_output_tokens??null,max_trial_spend_usd:e.max_trial_spend_usd,worst_case_spend_usd:e.worst_case_spend_usd},regrade_lineage:{is_regrade:e.is_regrade,source_jobs:e.source_jobs}}}function Te(e){let{trial:t}=e,s={};if(s["config.json"]=ie({trial_name:t.id,task:{name:t.task_name,source:t.source},agent:{name:t.agent_info.name,version:t.agent_info.version,model_name:t.agent_info.model_info.name,reasoning_effort:t.agent_info.reasoning_effort}}),s["result.json"]=ie({trial_name:t.id,task_name:t.task_name,status:t.status,reward:t.reward,verifier_result:t.verifier_result,exception_info:t.exception_info,agent_result:t.agent_result,started_at:t.started_at,finished_at:t.finished_at,environment_setup:t.environment_setup,agent_setup:t.agent_setup,agent_execution:t.agent_execution,verifier:t.verifier}),e.atif!==null&&(s["agent/trajectory.json"]=e.atif),e.stdout!==null&&(s["agent/stdout.log"]=e.stdout),e.stderr!==null&&(s["agent/stderr.log"]=e.stderr),e.events.length>0&&(s["agent/trace-parsed.jsonl"]=e.events.map(n=>JSON.stringify(n)).join(`
|
|
4
|
+
`)+`
|
|
5
|
+
`),e.home!==null){let n=We(e.home);for(let r of Object.keys(n))s[`agent/sessions/${r}`]=n[r];}return e.verifierLog!==null&&(s["verifier/test-stdout.txt"]=e.verifierLog),t.verifier_result?.rewards&&(s["verifier/reward.json"]=ie(t.verifier_result.rewards)),t.exception_info&&(s["exception.txt"]=`${t.exception_info.exception_type}: ${t.exception_info.exception_message}
|
|
6
|
+
`),s["evolve.json"]=ie(oe(t,e.job,e.userId)),s}var j=class extends Error{status;code;param;details;retryAfterSec;requestId;constructor(t,s,n,r){super(n),this.name="EvolveApiError",this.status=t,this.code=s,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 Ae(this.code)}};function et(e,t){try{let a=JSON.parse(e)?.error?.retryAfterSec;if(typeof a=="number"&&Number.isFinite(a))return a}catch{}let s=t.headers?.get?.("retry-after");if(typeof s!="string"||s.trim()==="")return;let n=Number(s);return Number.isFinite(n)?n:void 0}async function tt(e){let t=await e.text().catch(()=>""),s=e.headers?.get?.("x-request-id")??void 0,n=et(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 j(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:n,requestId:typeof r.error.requestId=="string"?r.error.requestId:s})}}catch(r){if(r instanceof j)throw r}throw new j(e.status,"unknown_error",t||e.statusText,{retryAfterSec:n,requestId:s})}var Ie=class extends Error{dataset;constructor(t){super(`Dataset "${t}" has no active version`),this.name="NoActiveVersionError",this.dataset=t;}},Z=class extends Error{name="GateRunningError";code="gate_running";dataset;version;gate;constructor(t,s,n,r){super(n),this.dataset=t,this.version=s,this.gate=r;}};function fn(e){let t=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return {status:typeof t.status=="string"?t.status:"PENDING",tasks:typeof t.tasks=="number"?t.tasks:0,unverified:typeof t.unverified=="number"?t.unverified:0,ineligible:typeof t.ineligible=="number"?t.ineligible:0}}var _n=1e3,bn=3e4,hn=new Set(["COMPLETED","CANCELLED","FAILED"]),yn=new Set(["job.completed","job.cancelled","job.failed"]),vn=2e3,kn=new Set(["COMPLETED","FAILED"]);function F(e,t){let s=t?.apiKey||process.env[Se];if(!s)throw new Error(`${e}() requires an API key. Set ${Se} or pass { apiKey } in config.`);let n=(t?.baseUrl||process.env.EVOLVE_DASHBOARD_URL||Ke).replace(/\/$/,"");return {apiKey:s,baseUrl:n}}async function _(e,t,s){let n=await fetch(`${e.baseUrl}${t}`,{...s,headers:{Authorization:`Bearer ${e.apiKey}`,...s?.headers}});return n.ok||await tt(n),n}function Xe(e){let t=e.indexOf("@");if(t===-1)return {name:e.trim()};let s=e.slice(0,t).trim(),n=e.slice(t+1).trim();if(!s||!n)throw new Error(`Invalid dataset ref "${e}": expected "name" or "name@version"`);return {name:s,version:n}}function nt(e){return {name:e.name,version:e.version}}function st(e){let t=e.kwargs,s=Array.isArray(e.skills)?e.skills.filter(a=>typeof a=="string"):[],n=Array.isArray(e.skill_locks)?e.skill_locks:null,r=n?n.flatMap(a=>{if(!a||typeof a!="object")return [];let i=a;return typeof i.name!="string"||typeof i.digest!="string"?[]:[{name:i.name,source:typeof i.source=="string"?i.source:"",digest:i.digest,git_url:typeof i.git_url=="string"?i.git_url:null,git_commit_id:typeof i.git_commit_id=="string"?i.git_commit_id:null}]}):null;return {name:e.name,model_name:e.model_name,version:e.version??null,reasoning_effort:e.reasoning_effort??null,kwargs:t&&typeof t=="object"&&!Array.isArray(t)?t:null,preset:typeof e.preset=="string"?e.preset:null,skills:s,skill_locks:r}}function wn(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(typeof t.status!="string")return null;let s=t.failure&&typeof t.failure=="object"&&!Array.isArray(t.failure)?t.failure:{},n=typeof t.code=="string"?t.code:s.code,r=typeof t.message=="string"?t.message:s.message,a=Sn(Array.isArray(t.failed_tasks)?t.failed_tasks:s.failed_tasks),i=typeof t.failed_task_count=="number"?t.failed_task_count:s.failed_task_count;return {status:t.status,attempts:typeof t.attempts=="number"?t.attempts:0,code:typeof n=="string"?n:null,message:typeof r=="string"?r:null,failed_tasks:a,failed_task_count:typeof i=="number"?i:a.length}}function Sn(e){if(!Array.isArray(e))return [];let t=[];for(let s of e){if(!s||typeof s!="object"||Array.isArray(s))continue;let n=s;typeof n.task_name=="string"&&t.push({task_name:n.task_name,outcome:typeof n.outcome=="string"?n.outcome:null,reasons:Array.isArray(n.reasons)?n.reasons.filter(r=>typeof r=="string"):[]});}return t}function xn(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(typeof t.name!="string")return null;let s=Array.isArray(t.authors)?t.authors.flatMap(n=>{if(!n||typeof n!="object"||Array.isArray(n))return [];let r=n;return typeof r.name!="string"?[]:[{name:r.name,email:typeof r.email=="string"?r.email:null}]}):[];return {name:t.name,version:typeof t.version=="string"?t.version:null,description:typeof t.description=="string"?t.description:"",authors:s,keywords:Array.isArray(t.keywords)?t.keywords.filter(n=>typeof n=="string"):[],task_count:typeof t.task_count=="number"?t.task_count:null}}function Rn(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;return typeof t.ref!="string"||typeof t.commit!="string"?null:{git_url:typeof t.git_url=="string"?t.git_url:null,ref:t.ref,commit:t.commit,path:typeof t.path=="string"?t.path:null}}function ce(e){return {version:e.version,state:e.state,created_at:e.created_at,task_count:e.task_count??0,manifest:xn(e.manifest),source:Rn(e.source),gate:wn(e.gate)}}function An(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;return typeof t.outcome!="string"?null:{outcome:t.outcome,flaky:t.flaky===true,reasons:Array.isArray(t.reasons)?t.reasons.filter(s=>typeof s=="string"):[],ran_at:typeof t.ran_at=="string"?t.ran_at:null}}function En(e){return {task_name:e.task_name,agent_timeout_sec:e.agent_timeout_sec,verifier_timeout_sec:e.verifier_timeout_sec,gpus:typeof e.gpus=="number"&&e.gpus>0?e.gpus:0,gpu_types:Array.isArray(e.gpu_types)&&e.gpu_types.length>0?e.gpu_types.map(String):null,providers:e.providers,gate:An(e.gate)}}function Tn(e){return {action:e.action,type:e.type,job_id:e.job_id}}function Pn(e){let t=e&&typeof e=="object"?e:{};return {max_retries:typeof t.max_retries=="number"?t.max_retries:0,include_exceptions:Array.isArray(t.include_exceptions)?t.include_exceptions:null,exclude_exceptions:Array.isArray(t.exclude_exceptions)?t.exclude_exceptions:[],wait_multiplier:typeof t.wait_multiplier=="number"?t.wait_multiplier:1,min_wait_sec:typeof t.min_wait_sec=="number"?t.min_wait_sec:1,max_wait_sec:typeof t.max_wait_sec=="number"?t.max_wait_sec:60}}function In(e){return {attempt_number:e.attempt_number,exception_info:e.exception_info??{exception_type:"InfrastructureError",exception_message:""},cost_usd:e.cost_usd??null,started_at:e.started_at??null,settled_at:e.settled_at??null}}function de(e){return typeof e=="number"?e:null}function D(e){let t=e.trials??{};return {id:e.id,job_name:e.job_name,status:e.status,datasets:(e.datasets??[]).map(nt),agents:(e.agents??[]).map(st),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,retry:Pn(e.retry),timeout_multiplier:typeof e.timeout_multiplier=="number"?e.timeout_multiplier:1,agent_timeout_multiplier:de(e.agent_timeout_multiplier),verifier_timeout_multiplier:de(e.verifier_timeout_multiplier),agent_setup_timeout_multiplier:de(e.agent_setup_timeout_multiplier),environment_build_timeout_multiplier:de(e.environment_build_timeout_multiplier),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(Tn),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 T(e,t){let s=e??{};return {items:Array.isArray(s.items)?s.items.map(t):[],nextCursor:s.nextCursor??null,hasMore:s.hasMore===true}}function $(e,t){let s=new URLSearchParams;e?.limit!==void 0&&s.set("limit",String(e.limit)),e?.cursor&&s.set("cursor",e.cursor);for(let[r,a]of Object.entries(t??{}))a!==void 0&&s.set(r,a);let n=s.toString();return n?`?${n}`:""}function me(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 $n(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 On(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let{from:t,to:s,reason:n}=e;return typeof t!="string"||typeof s!="string"||typeof n!="string"?null:{from:t,to:s,reason:n}}function $e(e){return {id:e.id,job_id:e.job_id,task_name:e.task_name,source:e.source,agent_info:$n(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,judge_result:e.judge_result??null,environment_setup:me(e.environment_setup),agent_setup:me(e.agent_setup),agent_execution:me(e.agent_execution),verifier:me(e.verifier),step_results:e.step_results??null,spend_source:e.spend_source??null,judge_spend_source:e.judge_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_provider_degrade:On(e.sandbox_provider_degrade),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,n_retries:e.n_retries??0,retries:Array.isArray(e.retries)?e.retries.map(In):[],session_ref:e.session_ref??null,started_at:e.started_at??null,finished_at:e.finished_at??null}}function pe(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 ge(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 rt(e){let t=e??{};return {scored:t.scored??0,total:t.total??0}}function Cn(e){return {id:e.id,datasets:(e.datasets??[]).map(nt),status:e.status,mean_reward:e.mean_reward??null,coverage:rt(e.coverage),cost_usd:e.cost_usd??0,agents:(e.agents||[]).map(st),started_at:e.started_at}}function Dn(e){return {job_id:e.job_id,status:e.status,mean_reward:e.mean_reward??null,coverage:rt(e.coverage)}}function jn(e){return {task_name:e.task_name,disagreement:e.disagreement===true,cells:(e.cells||[]).map(Dn)}}function at(e){return {seq:e.seq,type:e.type,data:e.data??{}}}function Ln(e){return {trial_id:e.trial_id,task_name:e.task_name??null,match_count:e.match_count,events:(e.events||[]).map(at)}}function Jn(e){return e?e.suffix!==void 0?`bytes=-${e.suffix}`:e.start===void 0?null:`bytes=${e.start}-${e.end??""}`:null}function Oe(e){if(e?.aborted)throw e.reason instanceof Error?e.reason:new Error("Watch aborted")}function Qe(e,t){return t?.aborted?true:e?.name==="AbortError"}function Q(e,t){return new Promise((s,n)=>{let r=setTimeout(()=>{t?.removeEventListener("abort",a),s();},e),a=()=>{clearTimeout(r),n(t?.reason instanceof Error?t.reason:new Error("Watch aborted"));};t?.addEventListener("abort",a,{once:true});})}function Nn(e){let t="",s=false;return {push(n){s&&(n="\r"+n,s=false),n.endsWith("\r")&&(n=n.slice(0,-1),s=true),t+=n.replace(/\r\n|\r/g,`
|
|
7
|
+
`);let r;for(;(r=t.indexOf(`
|
|
8
|
+
|
|
9
|
+
`))!==-1;){let a=t.slice(0,r);t=t.slice(r+2);let i,o,l=[];for(let u of a.split(`
|
|
10
|
+
`)){if(!u||u.startsWith(":"))continue;let c=u.indexOf(":"),p=c===-1?u:u.slice(0,c),d=c===-1?"":u.slice(c+1);d.startsWith(" ")&&(d=d.slice(1)),p==="id"?i=d:p==="event"?o=d:p==="data"&&l.push(d);}(i!==void 0||o!==void 0||l.length>0)&&e({id:i,event:o,data:l.join(`
|
|
11
|
+
`)});}}}}function U(e,t){let s,n=()=>s??=e({limit:t?.limit,cursor:t?.cursor});return {then(r,a){return n().then(r,a)},catch(r){return n().catch(r)},finally(r){return n().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 s=new FormData;for(let[n,r]of Object.entries(e))r!==void 0&&s.set(n,r);return t&&s.set("archive",new Blob([t.bytes],{type:"application/gzip"}),t.filename),s}function Un(e){let t,s=()=>(t||(t=(async()=>{let n=await e.next();for(;!n.done;)n=await e.next();return n.value})()),t);return {then(n,r){return s().then(n,r)},catch(n){return s().catch(n)},finally(n){return s().finally(n)},[Symbol.asyncIterator](){return e}}}var it="x-package-sha256",fe=class extends Error{constructor(s,n){super(`downloaded bytes do not match the digest the server stated (expected ${s}, got ${n})`);this.expected=s;this.actual=n;}name="EvolveDigestMismatchError"},_e=class extends Error{constructor(s,n){super(`download ended early: the server declared ${s} bytes and ${n} arrived`);this.expectedBytes=s;this.receivedBytes=n;}name="EvolveIncompleteDownloadError"};function ot(e,t){let s=e.headers.get("Content-Length");if(s===null)return;let n=Number(s);if(Number.isFinite(n)&&t!==n)throw new _e(n,t)}async function lt(e,t){let s=e.headers.get(it);if(!s)return;let{createHash:n}=await import('crypto'),r=n("sha256").update(t).digest("hex");if(r!==s)throw new fe(s,r)}function Mn(e,t){let n=(e.headers.get("Content-Disposition")||"").match(/filename="([^"]+)"/);if(!n)return t;let r=path.basename(n[1]);return r===""||r==="."||r===".."||/[/\\]/.test(r)||/[\u0000-\u001f]/.test(r)?t:r}async function ut(e,t,s){if(!e.body)throw new Error("Download response has no body");await promises.mkdir(t,{recursive:true});let n=path.join(t,Mn(e,s)),{createHash:r,randomBytes:a}=await import('crypto'),i=`${n}.${a(8).toString("hex")}.part`,o=r("sha256"),l=0,u=stream.Readable.fromWeb(e.body);u.on("data",c=>{o.update(c),l+=c.length;});try{await promises$1.pipeline(u,fs$1.createWriteStream(i));let c=e.headers.get("Content-Length");if(c!==null&&l!==Number(c))throw new _e(Number(c),l);let p=e.headers.get(it),d=o.digest("hex");if(p&&d!==p)throw new fe(p,d);await promises.rename(i,n);}catch(c){throw await promises.rm(i,{force:true}).catch(()=>{}),c}return n}function V(e){let t=F("datasets",e);async function s(l){let u=await _(t,`/api/datasets/imports/${encodeURIComponent(l)}`);return ge(await u.json())}function n(l){if(!l||typeof l!="object")return null;let u=l;return {git_url:u.git_url??null,ref:u.ref,current_commit:u.current_commit,path:u.path??null,latest_commit:u.latest_commit??null,acked_commit:u.acked_commit??null,moved:u.moved===true,behind_by:typeof u.behind_by=="number"?u.behind_by:null,checked_at:u.checked_at??null,error:u.error??null,auto_import:u.auto_import===true}}function r(l){return {name:l.name,title:l.title??null,description:l.description??null,active_version:l.active_version?ce(l.active_version):null,versions:(l.versions||[]).map(ce),selected_version:l.selected_version?ce(l.selected_version):null,tasks:T(l.tasks,En),upstream:n(l.upstream),created_at:l.created_at,updated_at:l.updated_at}}async function a(l,u){let c=Xe(l),p=$(u,{version:c.version}),d=await _(t,`/api/datasets/${encodeURIComponent(c.name)}${p}`);return r(await d.json())}function i(l){return {name:l.name,title:l.title??null,description:l.description??null,active_version:l.active_version?ce(l.active_version):null,upstream:n(l.upstream)}}async function o(l){let u=await _(t,`/api/datasets${$(l,{search:l?.search})}`);return T(await u.json(),i)}return {list(l){return U(u=>o({...u,search:l?.search}),l)},get:a,async getActive(l,u){let c=await a(l,u);if(c.active_version===null)throw new Ie(l);return {name:c.name,title:c.title,description:c.description,active_version:c.active_version,version:c.active_version.version,tasks:c.tasks??{items:[],nextCursor:null,hasMore:false},versions:c.versions??[],created_at:c.created_at,updated_at:c.updated_at}},async publish(l){let u=l.source;if(u?.directory){if(l.name===void 0||l.version===void 0){let{existsSync:g}=await import('fs'),{join:h}=await import('path');if(!(g(h(u.directory,"dataset.toml"))||g(h(u.directory,"tasks","dataset.toml"))))throw new Error(`datasets().publish() needs ${l.name===void 0?"a name":"a version"} \u2014 pass it explicitly, or add a dataset.toml manifest to the corpus directory (the server then derives name and version from it)`)}let{tarGzipDirectory:c}=await Promise.resolve().then(()=>(X(),z)),p=await c(u.directory),d=await _(t,"/api/datasets/publish",{method:"POST",body:ee({name:l.name,version:l.version},{bytes:p,filename:"corpus.tar.gz"})});return ge(await d.json())}if(u&&"git_url"in u&&u.git_url){if(l.name===void 0||l.version===void 0)throw new Error("datasets().publish() requires name and version for a git source \u2014 a dataset.toml manifest can only supply them for a directory source, because a git repository is cloned server-side after the publish is accepted");let c=await _(t,"/api/datasets/publish",{method:"POST",body:ee({name:l.name,version:l.version,git_url:u.git_url,git_ref:u.git_ref,...u.git_path!==void 0?{git_path:u.git_path}:{}})});return ge(await c.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 (both optional for a directory whose corpus carries a dataset.toml manifest)")},getImport:s,async watchImport(l,u){let c=u?.pollIntervalMs??vn,p=null;for(;;){Oe(u?.signal);let d;try{d=await s(l);}catch(g){if(g instanceof j&&(g.status===429||g.status===503)){await Q(Math.max((g.retryAfterSec??0)*1e3,c),u?.signal);continue}throw g}if(d.status!==p&&(p=d.status,u?.onStatus?.(d)),kn.has(d.status))return d;await Q(c,u?.signal);}},download:(async(l,u)=>{let c=Xe(l),p=c.version?`?version=${encodeURIComponent(c.version)}`:"",d=await _(t,`/api/datasets/${encodeURIComponent(c.name)}/download${p}`);if(u?.stream){if(!d.body)throw new Error("Package response has no body");return d.body}if(u?.to)return ut(d,u.to,`${c.name}-corpus.tar.gz`);let g=Buffer.from(await d.arrayBuffer());return ot(d,g.length),await lt(d,g),g}),listImports(l){return U(async u=>{let c=new URLSearchParams;u.limit!==void 0&&c.set("limit",String(u.limit)),u.cursor!==void 0&&c.set("cursor",u.cursor),l?.status!==void 0&&c.set("status",l.status),l?.dataset!==void 0&&c.set("dataset",l.dataset);let p=c.toString()?`?${c}`:"",d=await _(t,`/api/datasets/imports${p}`);return T(await d.json(),ge)},l)},async activate(l,u){let c=await _(t,`/api/datasets/${encodeURIComponent(l)}/versions/${encodeURIComponent(u)}/activate`,{method:"POST"});if(c.status===202){let p=await c.json();throw new Z(l,u,typeof p.message=="string"?p.message:`Dataset "${l}" version "${u}" is still being proven by its activation gate`,fn(p.gate))}return r(await c.json())},async update(l,u){let c=await _(t,`/api/datasets/${encodeURIComponent(l)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});return i(await c.json())},async delete(l){await _(t,`/api/datasets/${encodeURIComponent(l)}`,{method:"DELETE"});}}}function te(e){let t=F("agents",e);return {async create(s){let n=await Ze("agents().create()",s),r=await _(t,"/api/agents",{method:"POST",body:n});return pe(await r.json())},list(s){return U(async n=>{let r=await _(t,`/api/agents${$(n)}`);return T(await r.json(),pe)},s)},async get(s){let n=await _(t,`/api/agents/${encodeURIComponent(s)}`);return pe(await n.json())},async delete(s){await _(t,`/api/agents/${encodeURIComponent(s)}`,{method:"DELETE"});},async upsert(s,n){let r=await Ze("agents().upsert()",{...n,name:s}),a=await _(t,`/api/agents/${encodeURIComponent(s)}`,{method:"PUT",body:r});return pe(await a.json())}}}async function Ze(e,t){let s=typeof t.install_script=="string",n=typeof t.directory=="string";if(s&&n)throw new Error(`${e} takes EITHER an install script ({ install_script }) or a local directory ({ directory }), not both`);if(!s&&!n)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)}:{},...s?{install_script:t.install_script}:{}};if(n){let{tarGzipDirectory:a}=await Promise.resolve().then(()=>(X(),z)),i=await a(t.directory);return ee(r,{bytes:i,filename:"source.tar.gz"})}return ee(r)}function Pe(e){return {id:e.id,name:e.name,digest:e.digest,size_bytes:e.size_bytes??0,description:e.description??null,ref:e.ref??`upload:${e.id}`,created_at:e.created_at}}function G(e){let t=F("skills",e);return {async upload(s){if(typeof s!="string"||!s.trim())throw new Error("skills().upload() requires a local skill directory path");let{tarGzipDirectory:n}=await Promise.resolve().then(()=>(X(),z)),{basename:r,resolve:a}=await import('path'),i=r(a(s)),o=await n(s),u=await(await _(t,"/api/skills",{method:"POST",body:ee({name:i||void 0},{bytes:o,filename:"skill.tar.gz"})})).json();return (Array.isArray(u.skills)?u.skills:[u]).map(Pe)},list(s){return U(async n=>{let r=await _(t,`/api/skills${$(n)}`);return T(await r.json(),Pe)},s)},async get(s){let r=await(await _(t,`/api/skills/${encodeURIComponent(s)}`)).json();return {...Pe(r),skill_md:r.skill_md??null}},async delete(s){await _(t,`/api/skills/${encodeURIComponent(s)}`,{method:"DELETE"});}}}function k(e){let t=F("jobs",e);async function s(o){let l=await _(t,`/api/jobs/${encodeURIComponent(o)}`);return D(await l.json())}async function n(o){let l=await _(t,`/api/jobs${$(o,{search:o?.search})}`);return T(await l.json(),D)}function r(o){let l=o.trials??{};return {task_name:o.task_name,source:o.source,trials:{total:l.total??0,byStatus:l.byStatus??{}},mean_reward:o.mean_reward??null,cost_usd:o.cost_usd??null}}async function a(o,l){let u=$(l,{status:l?.status?.length?l.status.join(","):void 0,dataset:l?.dataset}),c=await _(t,`/api/jobs/${encodeURIComponent(o)}/trials${u}`);return T(await c.json(),$e)}async function*i(o,l){let{onEvent:u,signal:c}=l??{},p=l?.reconnectDelayMs??_n,d=l?.maxReconnectDelayMs??bn,g=null,h=false,S=false,y=p;for(;!h;){Oe(c);let f;try{f=await fetch(`${t.baseUrl}/api/jobs/${encodeURIComponent(o)}/events`,{headers:{Authorization:`Bearer ${t.apiKey}`,Accept:"text/event-stream",...g!==null?{"Last-Event-ID":String(g)}:{}},signal:c});}catch(w){if(Qe(w,c))throw w;await Q(y,c),y=Math.min(y*2,d);continue}if(!f.ok){if(f.status===429||f.status>=500){let w=await f.text().catch(()=>""),C=et(w,f)??0,N=C>0?Math.max(C*1e3,y):y;await Q(N,c),y=Math.min(y*2,d);continue}await tt(f);}if(!f.body)throw new Error("Event stream response has no body");let v=false,A=[],se=Nn(w=>{let C=Number(w.id),N={seq:Number.isInteger(C)?C:-1,type:w.event||"message",data:w.data?Fn(w.data):{}};Number.isInteger(C)&&(g=C),v=true,yn.has(N.type)&&(h=true),A.push(N);}),E=f.body.getReader(),W=new TextDecoder;try{for(;!h;){let{done:w,value:C}=await E.read();if(w)break;se.push(W.decode(C,{stream:!0}));for(let N of A)u?.(N),yield N;A.length=0;}}catch(w){if(Qe(w,c))throw w}finally{await E.cancel().catch(()=>{});}if(h)break;Oe(c);let Y=await s(o);if(hn.has(Y.status)){if(S)return Y;S=true;continue}v&&(y=p),await Q(y,c),y=Math.min(y*2,d);}return s(o)}return {async start(o,l){let u=await _(t,"/api/jobs",{method:"POST",headers:{"Content-Type":"application/json",...l?.idempotencyKey?{"Idempotency-Key":l.idempotencyKey}:{}},body:JSON.stringify(o)});return D(await u.json())},get:s,list(o){return U(l=>n({...l,search:o?.search}),o)},trials(o,l){return U(u=>a(o,{...u,status:l?.status,dataset:l?.dataset}),l)},tasks(o,l){return U(async u=>{let c=await _(t,`/api/jobs/${encodeURIComponent(o)}/tasks${$(u)}`);return T(await c.json(),r)},l)},watch(o,l){return Un(i(o,l))},async cancel(o){let l=await _(t,`/api/jobs/${encodeURIComponent(o)}/cancel`,{method:"POST"});return D(await l.json())},async compare(o){let l=o.map(encodeURIComponent).join(","),c=await(await _(t,`/api/jobs/compare?ids=${l}`)).json();return {jobs:(c.jobs||[]).map(Cn),taskMatrix:(c.taskMatrix||[]).map(jn)}},async resume(o,l,u){let c=await _(t,`/api/jobs/${encodeURIComponent(o)}/resume`,{method:"POST",headers:{"Content-Type":"application/json",...u?.idempotencyKey?{"Idempotency-Key":u.idempotencyKey}:{}},body:JSON.stringify(l??{})});return D(await c.json())},async retry(o,l,u){let c=await _(t,`/api/jobs/${encodeURIComponent(o)}/retry`,{method:"POST",headers:{"Content-Type":"application/json",...u?.idempotencyKey?{"Idempotency-Key":u.idempotencyKey}:{}},body:JSON.stringify(l??{})});return D(await c.json())},async regrade(o,l){let u={};l?.statuses?.length&&(u.statuses=l.statuses),l?.task_name!==void 0&&(u.task_name=l.task_name);let c=await _(t,`/api/jobs/${encodeURIComponent(o)}/regrade`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});return D(await c.json())},download:(async(o,l)=>{let u=await _(t,`/api/jobs/${encodeURIComponent(o)}/download`);if(l?.stream){if(!u.body)throw new Error("Download response has no body");return u.body}if(l?.to)return ut(u,l.to,`job-${o}-results.tar.gz`);let c=Buffer.from(await u.arrayBuffer());return ot(u,c.length),await lt(u,c),c}),async grep(o,l,u){let c=await _(t,`/api/jobs/${encodeURIComponent(o)}/grep${$(u,{q:l,type:u?.type})}`);return T(await c.json(),Ln)}}}function J(e){let t=F("trials",e);async function s(r,a){let i=await _(t,`/api/trials/${encodeURIComponent(r)}/trace${$(a,{type:a?.type,grep:a?.grep,tail:a?.tail!==void 0?String(a.tail):void 0})}`);return T(await i.json(),at)}async function n(r,a){let o=await(await _(t,`/api/trials/${encodeURIComponent(r)}/trace?stream=${a}`)).json();return a==="agent-home"?o.files??null:o.log??null}return {async get(r){let a=await _(t,`/api/trials/${encodeURIComponent(r)}`);return $e(await a.json())},trace:s,artifact:n,async*traceEvents(r,a){let i=a?.cursor;for(;;){let o=await s(r,{...a,cursor:i});for(let l of o.items)yield l;if(!o.nextCursor)return;i=o.nextCursor;}},async regrade(r){let a=await _(t,`/api/trials/${encodeURIComponent(r)}/regrade`,{method:"POST"});return D(await a.json())},async retry(r,a){let i=await _(t,`/api/trials/${encodeURIComponent(r)}/retry`,{method:"POST",...a?.idempotencyKey?{headers:{"Idempotency-Key":a.idempotencyKey}}:{}});return D(await i.json())},async stop(r){let i=await(await _(t,"/api/trials/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({trial_ids:r})})).json();return {stopped:(i.stopped??[]).map($e),already_terminal:i.already_terminal??[],not_found:i.not_found??[]}},async files(r,a){let i=await _(t,`/api/trials/${encodeURIComponent(r)}/files${$(a)}`);return T(await i.json(),o=>({path:o.path,size_bytes:o.size_bytes}))},async file(r,a,i){let o=a.split("/").filter(Boolean).map(encodeURIComponent).join("/"),l=Jn(i),u=await _(t,`/api/trials/${encodeURIComponent(r)}/files/${o}`,l?{headers:{Range:l}}:void 0);return Buffer.from(await u.arrayBuffer())}}}function Ce(e){let t=F("auth",e);return {async status(){let n=await(await _(t,"/api/auth/status")).json(),r=n.key??{};return {user_id:n.user_id,email:n.email??null,key:{id:r.id,label:r.label??null,created_at:r.created_at,last_used_at:r.last_used_at??null}}}}}function Fn(e){try{let t=JSON.parse(e);return t&&typeof t=="object"?t:{value:t}}catch{return {raw:e}}}var m=class extends Error{constructor(t){super(t),this.name="CliUsageError";}},Ve={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)"}},q={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"}},Tt={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"},preset:{kind:"string",value:"<name>",help:"Named settings preset for EVERY arm: no-internet (vendor server-side web tools off) or pinned-context (fixed context window). Applied verbatim \u2014 an agent that cannot guarantee it is refused by the server, never silently skipped"},ak:{kind:"repeat",aliases:["agent-kwarg"],value:"key=value",help:"Agent kwarg for EVERY arm (repeatable, Harbor grammar). The delivered key is 'config': --ak 'config=<path|inline JSON>' becomes the harness's native settings file (user config is the base, platform routing on top); the server refuses unsupported kwargs and config keys touching billing/base-URL/routing/env"},skill:{kind:"repeat",aliases:["skills"],value:"<ref|path>",help:"Skill for EVERY agent arm (repeatable): skills.sh/<owner>/<repo>[/<skill>], org/repo[@ref], an https git URL, upload:<id>, name:<skill-name> (your moving name pointer, resolved server-side), or a local folder (uploaded to the platform first, then referenced)"},"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); the server honors exactly REWARDKIT_JUDGE and REWARDKIT_MODEL (rewardkit's judge override) and refuses any other key"},secret:{kind:"repeat",value:"NAME[@LABEL][=ENVNAME]",help:"Attach one of your stored env secrets to every agent run (repeatable). NAME is the stored secret's name; @LABEL picks a labeled row (omitted = the 'default' row, or the only row \u2014 several labels with no 'default' is refused as ambiguous); =ENVNAME renames the env var inside the sandbox. References only \u2014 the value never rides the command line or the wire"},"secret-inline":{kind:"repeat",value:"NAME[@LABEL]:DELIVERY=VALUE",help:"Save VALUE into your vault as an env secret and attach it to this job in one step (repeatable). DELIVERY is 'brokered' or 'direct' and sits before '=' so everything after the first '=' is the value, passed through byte-for-byte ('=', ':' and '@' need no escaping). @LABEL defaults to 'default'; if that (NAME, LABEL) secret already exists the job is refused \u2014 attach it with --secret or pick a label. The job stores only the reference, never the value"},"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)"},"max-retries":{kind:"number",short:"r",value:"<n>",help:"Max automatic retries per trial on infrastructure errors (default: the server's fleet default; 0 = off). Each attempt carries the full trial cap"},"retry-include":{kind:"repeat",value:"<exception>",help:"Exception types to retry on (repeatable; default: everything --retry-exclude admits)"},"retry-exclude":{kind:"repeat",value:"<exception>",help:"Exception types to NOT retry on (repeatable; wins over --retry-include; default: Harbor's non-retryable set)"},"timeout-multiplier":{kind:"number",value:"<x>",help:"Multiplier for task timeouts (default 1.0; > 0, server ceiling on GET /api/meta). Multiplies each task's DECLARED timeouts for this job only \u2014 the task is never rewritten"},"agent-timeout-multiplier":{kind:"number",value:"<x>",help:"Multiplier for agent execution timeout (overrides --timeout-multiplier)"},"verifier-timeout-multiplier":{kind:"number",value:"<x>",help:"Multiplier for verifier timeout (overrides --timeout-multiplier)"},"agent-setup-timeout-multiplier":{kind:"number",value:"<x>",help:"Multiplier for agent setup timeout (overrides --timeout-multiplier)"},"environment-build-timeout-multiplier":{kind:"number",value:"<x>",help:"Multiplier for environment build timeout (overrides --timeout-multiplier)"},env:{kind:"string",short:"e",value:"<provider>",help:"Sandbox provider: e2b | daytona | modal (default daytona)"},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"}},ve={job:{summary:"Start, follow, and derive jobs",commands:{start:{summary:"Start a job (add --watch to follow it)",flags:Tt,minPositionals:0,maxPositionals:0,example:"evolve job start -d deep-swe@1.1 -a codex -m gpt-5.5 -k 2 --watch"},list:{summary:"List your jobs (newest first)",flags:{...q,search:{kind:"string",value:"<text>",help:"Free-text filter over job name and dataset names"}},minPositionals:0,maxPositionals:0,example:"evolve job list --limit 20 -q"},show:{summary:"Show one or more jobs in full (incl. pass@k, once attempts settle)",flags:{},minPositionals:1,maxPositionals:1/0,positionalUsage:"<id> [id...]",example:"evolve job show cme12ab34"},trials:{summary:"List a job's trials",flags:{...q,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 job trials cme12ab34 --status FAILED,SCORING_ERROR"},tasks:{summary:"Per-task rollup of a job",flags:{...q},minPositionals:1,maxPositionals:1,positionalUsage:"<id>",example:"evolve job tasks cme12ab34"},compare:{summary:"Compare 2-10 jobs side by side",flags:{},minPositionals:2,maxPositionals:10,positionalUsage:"<id> <id> [...]",example:"evolve job compare cme12ab34 cme56cd78"},cancel:{summary:"Request cancellation of a job",flags:{},minPositionals:1,maxPositionals:1,positionalUsage:"<id>",example:"evolve 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 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 job resume cme12ab34 -f InfrastructureError"},retry:{summary:"New linked job re-running selected trials (all, failed-only, or named ids)",flags:{"failed-only":{kind:"boolean",help:"Only retry failed trials (SCORING_ERROR, INFRASTRUCTURE_ERROR, INDETERMINATE); stopped and scored trials are not failures"},trial:{kind:"repeat",short:"t",value:"<trial-id>",help:"Retry exactly this trial (repeatable, all-or-nothing; each must be settled, the job may still be running). Not combinable with --failed-only"}},minPositionals:1,maxPositionals:1,positionalUsage:"<id>",example:"evolve job retry cme12ab34 --failed-only"},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 job regrade cme12ab34 --task tricky-task"},download:{summary:"Download the job's results, unpacked as the standard job-directory tree (plus evolve.json records)",flags:{"output-dir":{kind:"string",short:"o",value:"<dir>",help:"Directory to unpack into (default: current dir); the tree lands in <dir>/job-<id>/"},overwrite:{kind:"boolean",help:"Replace an existing <dir>/job-<id>/"}},minPositionals:1,maxPositionals:1,positionalUsage:"<id>",example:"evolve job download cme12ab34 -o results/"},grep:{summary:"Search every trial's parsed trace in one server-side pass",flags:{type:{kind:"string",value:"<event-type>",help:"Only search events of exactly this type"},limit:{kind:"number",short:"l",value:"<n>",help:"Per-trial match groups per page (default 50, max 200)"},cursor:{kind:"string",value:"<c>",help:"Resume after this trial id (the previous page's nextCursor)"}},minPositionals:2,maxPositionals:2,positionalUsage:"<id> <pattern>",example:"evolve job grep cme12ab34 'permission denied'"}}},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 trial show cmt90ef12"},trace:{summary:"Print a trial's parsed trace, filtered server-side",flags:{type:{kind:"string",value:"<event-type>",help:"Only events of exactly this type"},grep:{kind:"string",value:"<pattern>",help:"Only events matching this case-insensitive regex over type + content (a plain string is a plain substring \u2014 grep's own grammar)"},tail:{kind:"number",value:"<n>",help:"Only the last N matching events"},cursor:{kind:"string",value:"<seq>",help:"Resume after this seq"},limit:{kind:"number",short:"l",value:"<n>",help:"Events per page fetch (default 200, max 1000)"}},minPositionals:1,maxPositionals:1,positionalUsage:"<trial-id>",example:"evolve trial trace cmt90ef12 --grep 'permission denied' --tail 50"},download:{summary:"Save a trial as Harbor's trial tree (plus evolve.json), 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 | trace-atif (the ATIF trajectory) | trajectory (reserved: the harness-native session file) | 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 trial download cmt90ef12 --stream trace-stdout"},retry:{summary:"Run one settled trial again (the result IS a job)",flags:{},minPositionals:1,maxPositionals:1,positionalUsage:"<trial-id>",example:"evolve trial retry cmt90ef12"},regrade:{summary:"Verifier-only re-run of one trial (the result IS a job)",flags:{},minPositionals:1,maxPositionals:1,positionalUsage:"<trial-id>",example:"evolve 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 trial stop cmt90ef12 cmt34gh56"}}},dataset:{summary:"Browse and publish the dataset catalog",commands:{list:{summary:"List the dataset catalog",flags:{...q,search:{kind:"string",value:"<text>",help:"Free-text filter over name and description"}},minPositionals:0,maxPositionals:0,example:"evolve 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 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:"Pinned git ref: a full 40-hex commit sha, or a tag (resolved to its commit at publish and verified at import). Branch names are refused \u2014 unpinned_git_ref (with --git)"},path:{kind:"string",value:"<subfolder>",help:"Repository subfolder holding the corpus (with --git; sparse checkout \u2014 only that folder is imported)"},dir:{kind:"string",value:"<path>",help:"Local corpus directory (tarred + uploaded)"},name:{kind:"string",value:"<dataset>",help:"Catalog dataset name to create or extend (optional with --dir when the corpus carries a dataset.toml manifest; required with --git)"},version:{kind:"string",value:"<v>",help:"Version label for the published version (optional with --dir when dataset.toml declares one; required with --git)"},watch:{kind:"boolean",help:"Poll until the publish is COMPLETED or FAILED"}},minPositionals:0,maxPositionals:0,example:"evolve 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 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 dataset activate my-swe 1.0"}}},skill:{summary:"Upload and manage platform-stored skills",commands:{list:{summary:"List your uploaded skills (newest first)",flags:{...q},minPositionals:0,maxPositionals:0,example:"evolve skill list"},upload:{summary:"Upload a skill folder (its name becomes your moving name pointer)",flags:{},minPositionals:1,maxPositionals:1,positionalUsage:"<dir>",example:"evolve skill upload ./my-skill"},show:{summary:"Show one uploaded skill (metadata + SKILL.md)",flags:{},minPositionals:1,maxPositionals:1,positionalUsage:"<id | name:<skill-name>>",example:"evolve skill show name:my-skill"},delete:{summary:"Delete an uploaded skill record (past jobs keep their locks); refused (skill_in_use, 409) while a running job references it",flags:{},minPositionals:1,maxPositionals:1,positionalUsage:"<id>",example:"evolve skill delete 6f6f1f36-1c60-4f8e-9e2b-2a54cbb0f2aa"}}},agent:{summary:"Register and manage your own agents",commands:{list:{summary:"List your registered agents",flags:{...q},minPositionals:0,maxPositionals:0,example:"evolve agent list"},show:{summary:"Show one registered agent",flags:{},minPositionals:1,maxPositionals:1,positionalUsage:"<name>",example:"evolve 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 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 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 auth status"}}}},Ge={run:{summary:"Start a job (add --watch to follow it) \u2014 the short form of `job start`",flags:Tt,minPositionals:0,maxPositionals:0,example:"evolve run -d deep-swe@1.1 -a codex -m gpt-5.5 -k 2 --watch"}},Pt={jobs:"job",trials:"trial",datasets:"dataset",skills:"skill"},It={agents:'"agents" is reserved for the managed-agents CLI (not released yet) \u2014 for eval agent arms use "evolve agent"'},$t={ls:"list"};function Hn(e,t){return `${[...t.short?[`-${t.short}`]:[],...(t.aliases??[]).map(n=>`--${n}`),`--${e}`].join(", ")}${t.value?` ${t.value}`:""}`}function je(e){let t=Object.entries(e);if(t.length===0)return [];let s=t.map(([r,a])=>Hn(r,a)),n=Math.min(Math.max(...s.map(r=>r.length)),36);return t.map(([,r],a)=>{let i=s[a];return i.length>n?` ${i}
|
|
12
|
+
${"".padEnd(n)} ${r.help}`:` ${i.padEnd(n)} ${r.help}`})}function dt(e,t){let s=t.positionalUsage?` ${t.positionalUsage}`:"",n=Object.keys(t.flags).length>0?" [options]":"",r=[`Usage: evolve ${e}${s}${n}`,"",t.summary];return Object.keys(t.flags).length>0&&r.push("","Options:",...je(t.flags)),r.push("","Global options:",...je(Ve)),r.push("","Example:",` ${t.example}`),r.join(`
|
|
13
|
+
`)}function mt(e){let t=ve[e],s=[`Usage: evolve ${e} <command> [options]`,"",t.summary,"","Commands:"],n=Math.max(...Object.keys(t.commands).map(r=>r.length));for(let[r,a]of Object.entries(t.commands))s.push(` ${r.padEnd(n)} ${a.summary}`);return s.push("",`Run "evolve ${e} <command> --help" for flags and an example.`),s.join(`
|
|
14
|
+
`)}function Le(){let e=["evolve \u2014 Evolve hosted jobs CLI","","Usage: evolve <command> [options]","","Commands:"];for(let[t,s]of Object.entries(Ge))e.push(` ${t.padEnd(22)} ${s.summary}`);for(let[t,s]of Object.entries(ve)){let n=Object.keys(s.commands).join(" | ");e.push(` ${t.padEnd(22)} ${s.summary}`),e.push(` ${"".padEnd(22)} ${n}`);}return e.push(" help [command] Show help (also -h/--help on any command)","","Global options:",...je(Ve)," -v, --version Print the CLI version","","Example:"," evolve run -d deep-swe@1.1 -a codex -m gpt-5.5 --watch"),e.join(`
|
|
15
|
+
`)}var Zr=Le();function Wn(){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('index.cjs', document.baseURI).href)))),"utf-8")).version??"unknown"}catch{return "unknown"}}function Je(e,t){let s=[e.flags,Ve];for(let n of s)for(let[r,a]of Object.entries(n))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 Yn(e,t){if(t==="--help"||t==="-h")return true;if(t.startsWith("--")){let s=t.slice(2).split("=")[0];return Je(e,{long:s})!==void 0}if(t.startsWith("-")&&t.length>1){let s=t.slice(1).split("=")[0];return Je(e,{short:s})!==void 0}return false}function pt(e,t,s){let n={},r=[];for(let a=0;a<s.length;a++){let i=s[a];if(i==="--help"||i==="-h")return {command:"help",positionals:e.split(" "),flags:{}};let o,l;if(i.startsWith("--")){let g=i.slice(2),h=g.indexOf("=");h!==-1&&(l=g.slice(h+1),g=g.slice(0,h)),o={long:g};}else if(i.startsWith("-")&&i.length>1){let g=i.slice(1),h=g.indexOf("=");h!==-1&&(l=g.slice(h+1),g=g.slice(0,h)),o={short:g};}else {r.push(i);continue}let u=Je(t,o);if(!u)throw new m(`Unknown option ${i.split("=")[0]} for "${e}"`);let{name:c,flag:p}=u;if(p.kind==="boolean"){if(l!==void 0)throw new m(`Option --${c} takes no value`);n[c]=true;continue}let d=l;if(d===void 0){let g=s[a+1];if(g===void 0||Yn(t,g)){let h=g!==void 0?` (use --${c}=${g} if that is the value)`:"";throw new m(`Option --${c} requires a value${h}`)}d=g,a++;}if(p.kind==="number"){let g=Number(d);if(d.trim()===""||!Number.isFinite(g))throw new m(`Option --${c} expects a number, got "${d}"`);n[c]=g;}else if(p.kind==="repeat"){let g=n[c]??[];g.push(d),n[c]=g;}else n[c]=d;}if(r.length<t.minPositionals)throw new m(`"${e}" requires ${t.positionalUsage??`${t.minPositionals} argument(s)`}`);if(r.length>t.maxPositionals)throw new m(`"${e}" got unexpected argument "${r[t.maxPositionals]}"`);return {command:e,positionals:r,flags:n}}function zn(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:{}};let s=Ge[t];if(s)return pt(t,s,e.slice(1));let n=It[t];if(n)throw new m(n);let r=Pt[t]??t,a=ve[r];if(!a)throw new m(`Unknown command "${t}"`);let i=e[1];if(i===void 0||i==="--help"||i==="-h")return {command:"help",positionals:[r],flags:{}};if(i.startsWith("-"))throw new m(`"${r}" requires a command (run "evolve ${r} --help")`);let o=$t[i]??i,l=a.commands[o];if(!l)throw new m(`Unknown command "${r} ${i}" (supported: ${Object.keys(a.commands).join(", ")})`);return pt(`${r} ${o}`,l,e.slice(2))}function Xn(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 Qn=/^(?:[-+]?[0-9][0-9_]*\.[0-9_]*|\.[0-9][0-9_]*)$/,Zn=/^(?:[-+]?[0-9][0-9_]*\.[0-9_]*|\.[0-9][0-9_]*)[eE][-+][0-9]+$/;function es(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:Zn}:t.test.test("1.5")?{...t,test:Qn}:t)}var ts=/^[-+]?(?:0|[1-9][0-9_]*)$/,ns=/^[-+]?[1-9][0-9_]*(?::[0-5]?[0-9])+$/;function ss(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:ns}:t.test.test("19")?{...t,test:ts}:t)}function ea(e,t){return Ot(e,t).value}function Ot(e,t){let s=new yaml.LineCounter,n=yaml.parseDocument(e,{version:"1.1",schema:"yaml-1.1",resolveKnownTags:false,lineCounter:s,customTags:o=>ss(es(Xn(o)))}),r=n.errors[0]??n.warnings[0];if(r){let o=r.linePos?.[0]?.line??1,l=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 m(`${t}:${o}: ${l}`)}n.options.logLevel="silent";let a;try{a=n.toJS()??{};}catch(o){throw new m(`${t}: ${o.message}`)}return {value:a,locate:o=>{let u=n.getIn(o,true)?.range?.[0];return u===void 0?void 0:s.linePos(u).line}}}var rs=["../../spec/openapi.yaml","../../../../spec/openapi.yaml"],be;function as(){if(be)return be;let e=[],t=rs.map(n=>url.fileURLToPath(new URL(n,(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))))),s=process.env.EVOLVE_OPENAPI_SPEC_PATH;s&&t.unshift(s);for(let n of t){if(e.push(n),!fs$1.existsSync(n))continue;let a=yaml.parse(fs$1.readFileSync(n,"utf-8"))?.components?.schemas,i=a?.JobCreate;if(!a||!i||typeof i!="object")throw new Error(`${n} carries no components.schemas.JobCreate \u2014 the contract this CLI validates -c against`);return be={root:i,components:a},be}throw new Error(`spec/openapi.yaml not found (tried: ${e.join(", ")}) \u2014 the package ships it; reinstall the SDK, or point EVOLVE_OPENAPI_SPEC_PATH at a contract checkout`)}function Ct(e){let t=e.type;return typeof t=="string"?[t]:Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function qe(e,t,s){let n=e.$ref;if(typeof n!="string")return {schema:e,specName:s};let r=n.replace("#/components/schemas/",""),a=t[r];if(!a)throw new Error(`spec/openapi.yaml: unresolvable $ref "${n}"`);return qe(a,t,r)}function is(e){return e.length===1&&typeof e[0]=="string"?`"${e[0]}"`:e.map((t,s)=>typeof t=="number"?`[${t}]`:s===0?t:`.${t}`).join("")}function Dt(e,t){let s=t.locate?.(e),n=`${t.source}${s!==void 0?`:${s}`:""}`;return e.length===0?n:`${is(e)} in ${n}`}function x(e,t,s,n){throw new m(`--config: ${Dt(e,t)} ${s} [spec: ${n}]`)}function os(e){for(let t=e.length-1;t>=0;t--)if(typeof e[t]=="string")return e[t];return "value"}function ls(e,t){if(!e)return "a list";let s=qe(e,t.components,""),n=Ct(s.schema);return n.includes("string")?"a list of strings":n.includes("object")?"a list of objects":"a list"}function he(e,t,s,n,r,a=false){let{schema:i,specName:o}=qe(t,r.components,n),l=Ct(i),u=c=>o?`${o}.${c}`:c;if(e===null){if(l.includes("null"))return;x(s,r,`must be a ${l[0]??"value"}, not null`,o);}if(l.includes("object")){let c=B(i.additionalProperties)?i.additionalProperties:void 0;if(!B(e)){let d=c&&!i.properties?`must be a map of KEY: "value" pairs, not ${M(e)}`:`must be an object like {${us(i)}: "..."}, not ${M(e)}`;x(s,r,d,o);}let p=B(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&&x(s,r,`is missing the required key "${d}"`,o);for(let d of Object.keys(e))if(p[d]===void 0&&!c)throw new m(`--config: unknown key "${d}" in ${Dt([...s,d],r)} (allowed: ${Object.keys(p).join(", ")}) [spec: ${o}]`);for(let[d,g]of Object.entries(p)){let h=e[d];h!==void 0&&he(h,g,[...s,d],u(d),r);}}if(c)for(let[d,g]of Object.entries(e))p?.[d]===void 0&&he(g,c,[...s,d],o,r);return}if(l.includes("array")){let c=B(i.items)?i.items:void 0;Array.isArray(e)||x(s,r,`must be ${ls(c,r)}, not ${M(e)}`,o),typeof i.minItems=="number"&&e.length<i.minItems&&x(s,r,`needs at least ${i.minItems} ${i.minItems===1?"entry":"entries"}`,o),typeof i.maxItems=="number"&&e.length>i.maxItems&&x(s,r,`takes at most ${i.maxItems} entries`,o),c&&e.forEach((p,d)=>he(p,c,[...s,d],o,r));return}if(Array.isArray(i.enum)){i.enum.includes(e)||x(s,r,`must be one of: ${i.enum.join(", ")}`,o);return}if(l.includes("string")){typeof e!="string"&&x(s,r,`must be a string, not ${M(e)} \u2014 quote it (${os(s)}: "...")`,o),typeof i.maxLength=="number"&&e.length>i.maxLength&&x(s,r,`must be at most ${i.maxLength} characters (got ${e.length})`,o);return}if(l.includes("integer")||l.includes("number")){let c=l.includes("integer");(typeof e!="number"||c&&!Number.isInteger(e))&&x(s,r,`must be ${c?"an integer":"a number"}, not ${M(e)}`,o),typeof i.minimum=="number"&&e<i.minimum&&x(s,r,`must be at least ${i.minimum}`,o),typeof i.maximum=="number"&&e>i.maximum&&x(s,r,`must be at most ${i.maximum}`,o);return}l.includes("boolean")&&typeof e!="boolean"&&x(s,r,`must be a boolean, not ${M(e)}`,o);}function us(e){let t=Array.isArray(e.required)?e.required[0]:void 0;return typeof t=="string"?t:(B(e.properties)?Object.keys(e.properties):[])[0]??"name"}function cs(e,t,s){let{root:n,components:r}=as();he(e,n,[],"JobCreate",{source:t,locate:s,components:r},true);}function M(e){return e===null?"null":Array.isArray(e)?"a list":typeof e=="object"?`a ${e.constructor?.name??"object"}`:`a ${typeof e}`}function B(e){if(typeof e!="object"||e===null||Array.isArray(e))return false;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Ne(e,t,s,n=new WeakSet){if(!(e===null||typeof e=="string"||typeof e=="boolean")){if(typeof e=="number"){if(Number.isFinite(e))return;throw new m(`--config: ${t} in ${s} is ${Number.isNaN(e)?".nan":"infinite"} \u2014 a JSON body carries finite numbers only`)}if(Array.isArray(e)||B(e)){if(n.has(e))throw new m(`--config: ${t} in ${s} is an alias of a value that contains it \u2014 a JSON body cannot carry a cycle`);if(n.add(e),Array.isArray(e))e.forEach((r,a)=>Ne(r,`${t}[${a}]`,s,n));else for(let[r,a]of Object.entries(e))Ne(a,`${t}.${r}`,s,n);n.delete(e);return}throw new m(`--config: ${t} in ${s} resolved to ${M(e)}, which a JSON body cannot carry \u2014 quote the value to keep it text`)}}function ds(e,t){let s;try{s=t(e);}catch(i){throw new m(`--config: cannot read ${e}: ${i.message}`)}let n,r;if(e.endsWith(".json"))try{n=JSON.parse(s);}catch(i){throw new m(`--config: ${e} is not valid JSON: ${i.message}`)}else ({value:n,locate:r}=Ot(s,e));if(!n||typeof n!="object"||Array.isArray(n))throw new m(`--config: ${e} must contain a JSON/YAML object`);let a=n;for(let[i,o]of Object.entries(a))Ne(o,i,e);return cs(a,e,r),n}function gt(e,t){let s=e.indexOf("@");if(s===-1)return {name:e};let n=e.slice(0,s),r=e.slice(s+1);if(!n||!r)throw new m(`Invalid ${t} "${e}": expected name or name@version`);return {name:n,version:r}}function ms(e){let t=e.trim();try{return JSON.parse(t)}catch{return t==="True"?true:t==="False"?false:t==="None"?null:t}}function ps(e,t=s=>fs$1.readFileSync(s,"utf-8")){let s={};for(let n of e){let r=n.indexOf("=");if(r<=0)throw new m(`Invalid --ak "${n}": expected key=value`);let a=n.slice(0,r).trim(),i=ms(n.slice(r+1));a==="config"&&typeof i=="string"&&(i=gs(i,t)),s[a]=i;}return s}function gs(e,t){let s;try{s=t(e);}catch(r){throw new m(`--ak config: cannot read ${e}: ${r.message}`)}let n;if(e.endsWith(".toml"))try{n=smolToml.parse(s);}catch(r){throw new m(`--ak config: ${e} is not valid TOML: ${r.message}`)}else if(e.endsWith(".json"))try{n=JSON.parse(s);}catch(r){throw new m(`--ak config: ${e} is not valid JSON: ${r.message}`)}else try{n=JSON.parse(s);}catch{try{n=smolToml.parse(s);}catch{throw new m(`--ak config: ${e} parses as neither JSON nor TOML; use a .json or .toml settings file`)}}if(!n||typeof n!="object"||Array.isArray(n))throw new m(`--ak config: ${e} must contain a settings object`);return n}function fs(e){return e.map(t=>{let s=t.indexOf("="),n=s===-1?t:t.slice(0,s),r=s===-1?void 0:t.slice(s+1);if(s!==-1&&!r)throw new m(`Invalid --secret "${t}": expected NAME[@LABEL][=ENVNAME]`);let a=n.indexOf("@"),i=a===-1?n:n.slice(0,a),o=a===-1?void 0:n.slice(a+1);if(!i||a!==-1&&!o)throw new m(`Invalid --secret "${t}": expected NAME[@LABEL][=ENVNAME]`);return {name:i,...o!==void 0?{label:o}:{},...r!==void 0?{as:r}:{}}})}function _s(e){let t="NAME[@LABEL]:brokered|direct=VALUE";return e.map(s=>{let n=s.indexOf("=");if(n===-1)throw new m(`Invalid --secret-inline "${s}": expected ${t}`);let r=s.slice(0,n),a=s.slice(n+1);if(!a)throw new m(`Invalid --secret-inline "${s}": the value must not be empty`);let i=r.lastIndexOf(":");if(i===-1)throw new m(`Invalid --secret-inline "${r}=...": a delivery mode is required \u2014 ${t}`);let o=r.slice(0,i),l=r.slice(i+1);if(l!=="brokered"&&l!=="direct")throw new m(`Invalid --secret-inline delivery "${l}": expected brokered or direct`);let u=o.indexOf("@"),c=u===-1?o:o.slice(0,u),p=u===-1?void 0:o.slice(u+1);if(!c||u!==-1&&!p)throw new m(`Invalid --secret-inline "${r}=...": expected ${t}`);return {name:c,value:a,delivery:l,...p!==void 0?{label:p}:{}}})}function Ue(e,t){let s={};for(let n of e){let r=n.indexOf("=");if(r<=0)throw new m(`Invalid ${t} "${n}": expected KEY=VALUE`);s[n.slice(0,r)]=n.slice(r+1);}return s}function bs(e,t=s=>fs$1.readFileSync(s,"utf-8")){let s=e.flags,n=typeof s.config=="string"?ds(s.config,t):{},r;if(s.dataset!==void 0)r=s.dataset.map(f=>{let v=gt(f,"--dataset");return {name:v.name,...v.version?{version:v.version}:{}}});else if(Array.isArray(n.datasets)&&n.datasets.length>0)r=n.datasets.map(f=>({...f}));else throw new m(`"${e.command}" requires -d/--dataset (or datasets in --config)`);if(s["include-task-name"]!==void 0)for(let f of r)f.task_names=s["include-task-name"];if(s["exclude-task-name"]!==void 0)for(let f of r)f.exclude_task_names=s["exclude-task-name"];if(s["n-tasks"]!==void 0)for(let f of r)f.n_tasks=s["n-tasks"];let a;if(s.agent!==void 0||s.model!==void 0){if(s.agent===void 0)throw new m("-m/--model requires -a/--agent");if(s.model===void 0)throw new m("-a/--agent requires at least one -m/--model (the server applies no model default)");let f=gt(String(s.agent),"--agent");a=s.model.map(v=>({name:f.name,model_name:v,...f.version?{version:f.version}:{}}));}else if(Array.isArray(n.agents)&&n.agents.length>0)a=n.agents.map(f=>({...f}));else throw new m(`"${e.command}" requires -a/--agent and -m/--model (or agents in --config)`);if(s.effort!==void 0&&(a=a.map(f=>({...f,reasoning_effort:s.effort}))),s.ak!==void 0){let f=ps(s.ak,t);a=a.map(v=>({...v,kwargs:{...v.kwargs??{},...f}}));}s.preset!==void 0&&(a=a.map(f=>({...f,preset:s.preset}))),s.skill!==void 0&&(a=a.map(f=>({...f,skills:[...s.skill]})));let o=s["agent-env"]!==void 0?Ue(s["agent-env"],"--agent-env"):n.agent_env,l=s["verifier-env"]!==void 0?Ue(s["verifier-env"],"--verifier-env"):n.verifier_env,u=s.secret!==void 0||s["secret-inline"]!==void 0?[...s.secret!==void 0?fs(s.secret):[],...s["secret-inline"]!==void 0?_s(s["secret-inline"]):[]]:n.secrets,c=s["job-name"]!==void 0?String(s["job-name"]):n.job_name,p=s["n-attempts"]!==void 0?s["n-attempts"]:n.n_attempts,d=s["n-concurrent"]!==void 0?s["n-concurrent"]:n.n_concurrent_trials,g=s["max-trial-spend"]!==void 0?s["max-trial-spend"]:n.max_trial_spend_usd;if(s.env!==void 0&&!ae.includes(String(s.env)))throw new m(`-e/--env must be one of: ${ae.join(", ")}`);let h=s.env!==void 0?s.env:n.sandbox_provider,S={...n.retry??{}};s["max-retries"]!==void 0&&(S.max_retries=s["max-retries"]),s["retry-include"]!==void 0&&(S.include_exceptions=s["retry-include"]),s["retry-exclude"]!==void 0&&(S.exclude_exceptions=s["retry-exclude"]);let y={};for(let[f,v]of [["timeout-multiplier","timeout_multiplier"],["agent-timeout-multiplier","agent_timeout_multiplier"],["verifier-timeout-multiplier","verifier_timeout_multiplier"],["agent-setup-timeout-multiplier","agent_setup_timeout_multiplier"],["environment-build-timeout-multiplier","environment_build_timeout_multiplier"]]){let A=s[f]!==void 0?s[f]:n[v];A!==void 0&&(y[v]=A);}return {...c!==void 0?{job_name:c}:{},datasets:r,agents:a,...p!==void 0?{n_attempts:p}:{},...d!==void 0?{n_concurrent_trials:d}:{},...g!==void 0?{max_trial_spend_usd:g}:{},...h!==void 0?{sandbox_provider:h}:{},...Object.keys(S).length>0?{retry:S}:{},...y,...o!==void 0?{agent_env:o}:{},...l!==void 0?{verifier_env:l}:{},...u!==void 0?{secrets:u}:{}}}function hs(e){let t=e.flags,s=typeof t.dir=="string",n=typeof t.git=="string"||typeof t.ref=="string"||typeof t.path=="string";if(s&&n)throw new m('"dataset publish" takes EITHER --dir OR --git/--ref/--path, not both');if(s)return {source:{directory:t.dir},...typeof t.name=="string"?{name:t.name}:{},...typeof t.version=="string"?{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)":" (a git source cannot take it from dataset.toml \u2014 the repository is only cloned after the publish is accepted)";throw new m(`"dataset publish" requires --${r}${a}`)}return {source:{git_url:t.git,git_ref:t.ref,...typeof t.path=="string"?{git_path:t.path}:{}},name:t.name,version:t.version}}function ys(e,t=s=>fs$1.readFileSync(s,"utf-8")){let s=e.flags,n=typeof s.dir=="string",r=typeof s["install-script"]=="string";if(n&&r)throw new m('"agent add" takes EITHER --dir OR --install-script, not both');if(!n&&!r)throw new m('"agent add" requires --install-script (or --dir for a local agent directory)');if(typeof s.run!="string")throw new m('"agent add" requires --run');let a=Ue(s["agent-env"]??[],"--agent-env");return {name:e.positionals[0],...n?{directory:s.dir}:{install_script:t(s["install-script"])},run_command:s.run,...Object.keys(a).length>0?{env:a}:{}}}var vs={out:e=>process.stdout.write(e+`
|
|
16
|
+
`),err:e=>process.stderr.write(e+`
|
|
17
|
+
`),tty:process.stdout.isTTY===true&&process.env.TERM!=="dumb"};function R(e){if(e.length===0)return [];let t=[];for(let s of e)s.forEach((n,r)=>{t[r]=Math.max(t[r]??0,n.length);});return e.map(s=>s.map((n,r)=>n.padEnd(t[r])).join(" ").trimEnd())}function P(e){return typeof e=="number"?`$${e.toFixed(2)}`:"-"}function ye(e){let t=`${e.name}:${e.model_name}`;return e.version?`${t}:${e.version}`:t}function ke(e){return e.map(t=>`${t.name}@${t.version}`).join(", ")||"-"}function we(e,t){return e.length>t?e.slice(0,t-1)+"\u2026":e}function De(e){return e.replace(/[\t\n\r]+/g," ")}function K(e,t,s,n,r,a){if(e.flags.quiet===true){for(let l of s)t.out(a(l));return}let i=ks(e,n,r);if(t.tty===true){let l=e.flags["no-trunc"]===true,u=[i.map(c=>c.header)];for(let c of s)u.push(i.map(p=>l?De(p.cell(c)):we(De(p.cell(c)),60)));for(let c of R(u))t.out(c);}else {e.flags["no-headers"]!==true&&t.out(i.map(l=>l.header).join(" "));for(let l of s)t.out(i.map(u=>De(u.cell(l))).join(" "));}}function ks(e,t,s){let n=e.flags.columns;if(n===void 0)return s.map(a=>t.find(i=>i.key===a));if(n==="all")return t;let r=n.split(",").map(a=>a.trim()).filter(Boolean);if(r.length===0)throw new m("--columns got an empty column list");return r.map(a=>{let i=t.find(o=>o.key===a);if(!i)throw new m(`Unknown column "${a}" (available: ${t.map(o=>o.key).join(", ")}, or "all")`);return i})}function H(e,t,s){if(e.flags.columns!=="help")return false;for(let n of s)t.out(n.key);return true}function L(e){let t=[["id",e.id],["status",e.status],["datasets",ke(e.datasets)]];t.push(["agents",e.agents.map(ye).join(", ")]);for(let n of e.agents){n.skills.length>0&&t.push(["skills",`${ye(n)}: ${n.skills.join(", ")}`]);for(let r of n.skill_locks??[])t.push(["skill lock",`${r.name} @ ${r.git_commit_id?r.git_commit_id.slice(0,12):r.digest.slice(0,19)}`]);}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",P(e.max_trial_spend_usd)]),t.push(["worst case",P(e.worst_case_spend_usd)]),t.push(["retries",`${e.retry.max_retries}/trial on infrastructure errors`+((e.stats.n_retries??0)>0?` (${e.stats.n_retries} used)`:"")]);{let r=[["agent",e.agent_timeout_multiplier],["verifier",e.verifier_timeout_multiplier],["agent setup",e.agent_setup_timeout_multiplier],["environment build",e.environment_build_timeout_multiplier]].filter(([,a])=>a!=null);(e.timeout_multiplier!==1||r.length>0)&&t.push(["timeouts",`x${e.timeout_multiplier}`+(r.length>0?` (${r.map(([a,i])=>`${a} x${i}`).join(", ")})`:"")]);}t.push(["provider",e.sandbox_provider]),t.push(["spent",P(e.stats.cost_usd)]),e.stats.gpu_cost_usd!=null&&t.push(["gpu compute (est.)",`$${e.stats.gpu_cost_usd.toFixed(4)}`]),e.stats.judge_cost_usd!=null&&e.stats.judge_cost_usd>0&&t.push(["spent (judge)",P(e.stats.judge_cost_usd)]);let s=Object.entries(e.trials.byStatus).filter(([,n])=>n>0).map(([n,r])=>`${n} ${r}`).join(" \xB7 ");s&&t.push(["trials",s]);for(let n of e.source_jobs)t.push([n.action==="regrade"?"regrade of":n.action==="retry"?"retry of":"resume of",n.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),...ws(e)]}function ws(e){let t=xe(e);if(t.length===0)return [];let s=t.map(n=>[` ${n.evals_key}`,n.points.map(r=>`pass@${r.k} ${r.value.toFixed(3)}`).join(" ")]);return ["","pass@k",...R(s)]}var ft=[{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=>ke(e.datasets)},{key:"agents",header:"AGENTS",cell:e=>e.agents.map(ye).join(", ")},{key:"trials",header:"TRIALS",cell:e=>String(e.trials.total)},{key:"spent",header:"SPENT",cell:e=>P(e.stats.cost_usd)},{key:"started",header:"STARTED",cell:e=>e.started_at}],Ss=["id","status","datasets","trials","spent","started"],_t=[{key:"task",header:"TASK",cell:e=>e.task_name},{key:"agent",header:"AGENT",cell:e=>ye({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=>P(e.agent_result?.cost_usd)},{key:"gpu",header:"GPU (EST)",cell:e=>e.gpu_cost?.estimate_usd!=null?`$${e.gpu_cost.estimate_usd.toFixed(4)}`:"-"},{key:"id",header:"TRIAL ID",cell:e=>e.id}],xs=["task","agent","attempt","status","reward","spent","id"],bt=[{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,s])=>`${t} ${s}`).join(" \xB7 ")||"-"},{key:"reward",header:"MEAN REWARD",cell:e=>Me(e.mean_reward)},{key:"spent",header:"SPENT",cell:e=>P(e.cost_usd)}],Rs=["task","source","trials","statuses","reward","spent"],ht=[{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??"-"}],As=["name","active","state","tasks","title"];function Es(e){return e.length>19?`${e.slice(0,19)}\u2026`:e}function jt(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}var yt=[{key:"name",header:"NAME",cell:e=>e.name},{key:"id",header:"ID",cell:e=>e.id},{key:"digest",header:"DIGEST",cell:e=>Es(e.digest)},{key:"size",header:"SIZE",cell:e=>jt(e.size_bytes)},{key:"created",header:"CREATED",cell:e=>e.created_at},{key:"description",header:"DESCRIPTION",cell:e=>e.description??"-"},{key:"ref",header:"REF",cell:e=>e.ref}],Ts=["name","id","digest","size","created"],vt=[{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}],Ps=["name","source","run","updated"];function Is(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):"-"]],s=e.verifier_result?.rewards;if(s&&Object.keys(s).length>0&&t.push(["rewards",Object.entries(s).map(([n,r])=>`${n}=${r}`).join(" \xB7 ")]),t.push(["spent",P(e.agent_result?.cost_usd)]),e.judge_result&&t.push(["spent (judge)",P(e.judge_result.cost_usd)]),(e.status==="RUNNING"||e.status==="SCORING")&&e.live_spent_usd!==null){let n=e.live_spend_at?` as of ${e.live_spend_at}`:"";t.push(["spent (live)",`at least $${e.live_spent_usd.toFixed(4)}${n}`]);}if(e.attempt_phase&&t.push(["phase",e.attempt_phase]),e.sandbox_provider&&t.push(["provider",e.sandbox_provider]),e.sandbox_provider_degrade){let n=e.sandbox_provider_degrade;t.push(["provider degrade",`${n.from} \u2192 ${n.to}: ${n.reason}`]);}if(e.gpu_cost){let n=e.gpu_cost;if(n.estimate_usd!=null){let r=n.gpu_type??n.declared_gpu_type,a=n.duration_sec!=null?`${Math.round(n.duration_sec)}s`:"unmeasured",i=`rate card v${n.rate_card.version}${n.rate_card.source?`, ${n.rate_card.source} ${n.rate_card.source_date??""}`.trimEnd():""}`;t.push(["gpu compute (est.)",`$${n.estimate_usd.toFixed(4)} \u2014 ${r} x${n.gpu_count}, ${a} on ${n.provider} (${i})`]);}else t.push(["gpu compute (est.)",`not priced \u2014 ${n.unpriced_reason??"no reason recorded"}`]);}if(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.n_retries>0){t.push(["auto-retries",String(e.n_retries)]);for(let n of e.retries)t.push([`attempt ${n.attempt_number}`,`${n.exception_info.exception_type} \xB7 spent ${P(n.cost_usd)}`+(n.settled_at?` \xB7 settled ${n.settled_at}`:"")]);}return 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 Lt(e){let t=[["name",e.name],["source",e.source],["run command",e.run_command]],s=Object.keys(e.env??{});return s.length>0&&t.push(["env",s.sort().join(", ")]),t.push(["created",e.created_at]),t.push(["updated",e.updated_at]),R(t)}var Jt=["e2b","daytona","modal"];function $s(e){return Jt.filter(t=>e?.[t]!==void 0).map(t=>{let s=e[t];return s.ok?s.degrades_to?`${t} \u2192${s.degrades_to}`:`${t} ok`:`${t} NO`}).join(" \xB7 ")}function Os(e){let t=e.gpus??0;if(t<=0)return null;let s=e.gpu_types&&e.gpu_types.length>0?e.gpu_types.join("|"):"any GPU";return `${t}x ${s}`}function Me(e){return e!==null?String(Math.round(e*1e3)/1e3):"-"}function Be(e){let t=we(JSON.stringify(e.data??{}),140);return `#${String(e.seq).padStart(4)} ${e.type.padEnd(26)} ${t}`.trimEnd()}function Nt(e){let t=e.failures?.length?` (${e.failures.length} task failure${e.failures.length===1?"":"s"})`:"";return `${e.message}${t}`}function kt(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 s of e.warnings)t.push(["warning",s.message??s.code]);if(e.failure){t.push(["failure",Nt(e.failure)]);for(let s of e.failure.failures??[])t.push([` ${s.task_name}`,s.error]);}return R(t)}function Cs(e){let t=[];return e.task_count!==void 0&&t.push(`tasks=${e.task_count}`),e.failure&&t.push(we(Nt(e.failure),140)),`status ${e.status.padEnd(12)} ${t.join(" ")}`.trimEnd()}function Ds(e){let t={...e.data??{}},s=[];typeof t.trial_id=="string"&&s.push(t.trial_id),typeof t.task_name=="string"&&s.push(t.task_name),typeof t.status=="string"&&s.push(t.status),typeof t.reward=="number"&&s.push(`reward=${t.reward}`);let n=new Set(["trial_id","task_name","status","reward"]);for(let[a,i]of Object.entries(t))n.has(a)||s.push(`${a}=${typeof i=="object"?JSON.stringify(i):String(i)}`);let r=we(s.join(" "),140);return `#${String(e.seq).padStart(4)} ${e.type.padEnd(26)} ${r}`.trimEnd()}function b(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 js=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Ls=/^[0-9a-f][0-9a-f-]{7,34}$/i,wt=8,St=new WeakMap;function Js(e){let t=St.get(e);if(t)return t;let s=(async()=>{let n=k(b(e)),r=[],a;do{let i=await n.list({limit:100,...a?{cursor:a}:{}});for(let o of i.items)r.push(o.id);a=i.nextCursor??void 0;}while(a);return r})();return St.set(e,s),s}async function I(e,t){if(t===void 0||js.test(t))return t;if(/^[0-9a-f][0-9a-f-]*$/i.test(t)&&t.length<wt)throw new m(`"${t}" is too short to name a job \u2014 id prefixes need at least ${wt} characters`);if(!Ls.test(t))return t;let s=t.toLowerCase(),n=new Set;for(let a of await Js(e))a.startsWith(s)&&n.add(a);let r=[...n];if(r.length===1)return r[0];throw r.length===0?new m(`no job id starts with "${t}"`):new m(`"${t}" is ambiguous \u2014 it matches ${r.length} jobs: ${r.slice(0,5).join(", ")}${r.length>5?", \u2026":""}`)}function O(e){return {...e.flags.limit!==void 0?{limit:e.flags.limit}:{},...e.flags.cursor!==void 0?{cursor:String(e.flags.cursor)}:{}}}function Ut(e){if(e.flags.status===void 0)return;let t=String(e.flags.status).split(",").map(n=>n.trim()).filter(Boolean);if(t.length===0)throw new m("--status got an empty status list");let s=t.filter(n=>!re.includes(n));if(s.length>0)throw new m(`--status must name trial statuses (${re.join(", ")}); got: ${s.join(", ")}`);return t}function Ns(e){return e.status==="COMPLETED"?0:e.status==="FAILED"||e.status==="CANCELLED"?1:0}function Us(e){return e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||e.startsWith("~")}async function Ms(e,t,s){let n=new Set;for(let i of e.agents)for(let o of i.skills??[])Us(o)&&n.add(o);if(n.size===0)return e;let r=G(b(t)),a=new Map;for(let i of n){let o=await r.upload(i);if(a.set(i,o.map(l=>l.ref)),t.flags.json!==true)for(let l of o)s.err(`Uploaded skill ${l.name} (${l.ref}, ${l.digest.slice(0,19)}\u2026)`);}return {...e,agents:e.agents.map(i=>({...i,...i.skills!==void 0&&i.skills!==null?{skills:i.skills.flatMap(o=>a.get(o)??[o])}:{}}))}}async function xt(e,t){let s=bs(e);if(e.flags["print-config"]===true)return t.out(JSON.stringify(s,null,2)),0;let n=e.flags.json===true,r=e.flags.watch===true,a=e.flags.quiet===true,i=k(b(e)),o=await i.start(await Ms(s,e,t));if(!r){if(n)t.out(JSON.stringify(o));else {for(let u of L(o))t.out(u);t.out(""),t.out(`Follow it with: evolve job show ${o.id}`);}return 0}n?t.out(JSON.stringify({kind:"job.created",job:o})):t.out(`Job ${o.id} (${ke(o.datasets)}) ${o.status} \u2014 watching\u2026`);let l=await i.watch(o.id,{onEvent:u=>{a||t.out(n?JSON.stringify({kind:"event",...u}):Ds(u));}});if(n)t.out(JSON.stringify({kind:"job.final",job:l}));else {t.out("");for(let u of L(l))t.out(u);}return Ns(l)}async function Fs(e,t){if(H(e,t,ft))return 0;let n=await k(b(e)).list({...O(e),...e.flags.search!==void 0?{search:String(e.flags.search)}:{}});return e.flags.json===true?(t.out(JSON.stringify(n)),0):n.items.length===0?(e.flags.quiet!==true&&t.out("No jobs."),0):(K(e,t,n.items,ft,Ss,r=>r.id),n.nextCursor&&t.tty===true&&e.flags.quiet!==true&&t.out(`
|
|
18
|
+
More: evolve job list --cursor ${n.nextCursor}`),0)}async function Vs(e,t){let s=k(b(e)),n=[];for(let r of e.positionals)n.push(await s.get(await I(e,r)));return e.flags.json===true?(t.out(JSON.stringify(n.length===1?n[0]:n)),0):(n.forEach((r,a)=>{a>0&&t.out("");for(let i of L(r))t.out(i);}),0)}async function Gs(e,t){if(H(e,t,_t))return 0;let s=k(b(e)),n=Ut(e),r=e.flags.dataset,a=await s.trials(await I(e,e.positionals[0]),{...n!==void 0?{status:n}:{},...r!==void 0?{dataset:r}:{},...O(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):(K(e,t,a.items,_t,xs,i=>i.id),t.tty===true&&e.flags.quiet!==true&&(t.out(`
|
|
19
|
+
${a.items.length} trial(s) shown`),a.nextCursor&&t.out(`More: evolve job trials ${e.positionals[0]} --cursor ${a.nextCursor}`)),0)}async function qs(e,t){if(H(e,t,bt))return 0;let n=await k(b(e)).tasks(await I(e,e.positionals[0]),O(e));return e.flags.json===true?(t.out(JSON.stringify(n)),0):n.items.length===0?(e.flags.quiet!==true&&t.out("No tasks."),0):(K(e,t,n.items,bt,Rs,r=>r.task_name),n.nextCursor&&t.tty===true&&e.flags.quiet!==true&&t.out(`
|
|
20
|
+
More: evolve job tasks ${e.positionals[0]} --cursor ${n.nextCursor}`),0)}function Bs(e){let t=[],s=[["ID","DATASETS","STATUS","MEAN REWARD","COVERAGE","SPENT"]];for(let n of e.jobs)s.push([n.id,ke(n.datasets),n.status,Me(n.mean_reward),`${n.coverage.scored}/${n.coverage.total}`,P(n.cost_usd)]);if(t.push(...R(s)),e.taskMatrix.length>0){t.push("","Task matrix (disagreements first; columns in the order above):");let n=[["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(o=>[o.job_id,o]));n.push([a.task_name,a.disagreement?"!":"",...r.map(o=>{let l=i.get(o);return l?l.mean_reward!==null?`${l.status} ${Me(l.mean_reward)}`:l.status:"-"})]);}t.push(...R(n));}return t}async function Ks(e,t){let s=k(b(e)),n=[];for(let a of e.positionals)n.push(await I(e,a));let r=await s.compare(n);if(e.flags.json===true)t.out(JSON.stringify(r));else for(let a of Bs(r))t.out(a);return 0}async function Hs(e,t){let n=await k(b(e)).cancel(await I(e,e.positionals[0]));if(e.flags.json===true)t.out(JSON.stringify(n));else for(let r of L(n))t.out(r);return 0}async function Ws(e,t){let s=e.flags.dataset;if(!s)throw new m("job stop needs --dataset <name> (to stop the whole job, use: evolve job cancel <id>)");let n=k(b(e)),r=await n.get(await I(e,e.positionals[0])),a=r.datasets.map(c=>c.name);if(!a.includes(s))throw new Error(`job ${r.id} does not run dataset ${s}; its datasets: ${a.join(", ")}`);let i=[];for await(let c of n.trials(r.id,{dataset:s}))i.push(c.id);if(i.length===0)return e.flags.json===true?t.out(JSON.stringify({stopped:[],already_terminal:[],not_found:[]})):t.out(`No trials in ${s}.`),0;let o=J(b(e)),l={stopped:[],already_terminal:[],not_found:[]},u=0;try{for(let c=0;c<i.length;c+=100){let p=i.slice(c,c+100),d=await o.stop(p);u+=p.length,l.stopped.push(...d.stopped),l.already_terminal.push(...d.already_terminal),l.not_found.push(...d.not_found);}}catch(c){throw Rt(l,s,i.length,u,e,t),c}return Rt(l,s,i.length,u,e,t),0}function Rt(e,t,s,n,r,a){let i=s-n;if(r.flags.json===true){a.out(JSON.stringify(i>0?{...e,partial:true,unreported:i}:e));return}for(let o of e.stopped)a.out(`stopped ${o.id} (${o.task_name}) ${o.status}`);for(let o of e.already_terminal)a.out(`already terminal ${o}`);for(let o of e.not_found)a.out(`not found ${o}`);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 ${s} trials have no report \u2014 no answer came back for trials ${n+1}-${Math.min(n+100,s)}; rerun the same command to finish the rest.`);}async function Ys(e,t){let s=k(b(e)),n=e.flags["filter-error-type"],r=await s.resume(await I(e,e.positionals[0]),n!==void 0?{filter_error_types:n}:void 0);if(e.flags.json===true)t.out(JSON.stringify(r));else {for(let a of L(r))t.out(a);t.out(""),t.out(`Follow it with: evolve job show ${r.id}`);}return 0}async function zs(e,t){let s=e.flags.trial,n=e.flags["failed-only"]===true;if(s!==void 0&&n)throw new m('"job retry" takes EITHER -t/--trial OR --failed-only, not both \u2014 explicit ids are already a selection');let r={};s!==void 0&&(r.trial_ids=s),n&&(r.failed_only=true);let a=await k(b(e)).retry(await I(e,e.positionals[0]),r);if(e.flags.json===true)t.out(JSON.stringify(a));else {for(let i of L(a))t.out(i);t.out(""),t.out(`Follow it with: evolve job show ${a.id}`);}return 0}async function Xs(e,t){let s=k(b(e)),n={},r=Ut(e);r!==void 0&&(n.statuses=r),e.flags.task!==void 0&&(n.task_name=String(e.flags.task));let a=await s.regrade(await I(e,e.positionals[0]),n);if(e.flags.json===true)t.out(JSON.stringify(a));else {for(let i of L(a))t.out(i);t.out(""),t.out(`Follow it with: evolve job show ${a.id}`);}return 0}async function Qs(e,t){let s=k(b(e)),n=await I(e,e.positionals[0]),{join:r}=await import('path'),a=e.flags["output-dir"]??process.cwd(),i=`job-${n}`,o=r(a,i);if(fs$1.existsSync(o)&&e.flags.overwrite!==true)throw new Error(`${o} already exists (pass --overwrite to replace it)`);let{mkdtemp:l,rm:u}=await import('fs/promises'),{tmpdir:c}=await import('os'),{extractTarGz:p}=await Promise.resolve().then(()=>(X(),z)),d=await l(r(c(),"evolve-job-download-"));try{let g=await s.download(n,{to:d});e.flags.overwrite===!0&&await u(o,{recursive:!0,force:!0});let h;try{h=await p(g,a,i);}catch(E){throw await u(o,{recursive:!0,force:!0}).catch(()=>{}),E}let{readdir:S,readFile:y,writeFile:f}=await import('fs/promises'),v=await s.get(n),A=await Mt(e),se=new Map;for await(let E of s.trials(n))se.set(E.id,E);await f(r(o,"evolve.json"),JSON.stringify(Ee(v,A),null,2)+`
|
|
21
|
+
`),h.push("evolve.json");for(let E of await S(o,{withFileTypes:!0})){if(!E.isDirectory())continue;let W;try{W=JSON.parse(await y(r(o,E.name,"result.json"),"utf8")).x_evolve?.trialId;}catch{continue}let Y=W!==void 0?se.get(W):void 0;Y&&(await f(r(o,E.name,"evolve.json"),JSON.stringify(oe(Y,v,A),null,2)+`
|
|
22
|
+
`),h.push(`${E.name}/evolve.json`));}return e.flags.json===!0?t.out(JSON.stringify({path:o,files:h.length})):t.out(`Saved ${o} (${h.length} files)`),0}finally{await u(d,{recursive:true,force:true}).catch(()=>{});}}async function Zs(e,t){let n=await J(b(e)).get(e.positionals[0]);if(e.flags.json===true)t.out(JSON.stringify(n));else for(let r of Is(n))t.out(r);return 0}var At=Re;async function er(e,t){let s=J(b(e)),n=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 m('"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 m("--cursor/--limit page the parsed events; they apply only to --stream trace-parsed");if(a!==void 0){if(!At.includes(a))throw new m(`--stream must be one of: ${At.join(", ")}`);if(a==="trace-parsed"){let f=0;for await(let v of s.traceEvents(n,O(e)))t.out(r?JSON.stringify(v):Be(v)),f+=1;return !r&&f===0&&t.out("No trace events."),0}if(a==="agent-home"){let f=await s.artifact(n,a);if(f===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:f}));else for(let[v,A]of Object.entries(f))t.out(`===== ${v} (${Buffer.byteLength(A,"utf8")} bytes) =====`),t.out(A);return 0}let y=await s.artifact(n,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:o}=await import('fs/promises'),{join:l,dirname:u}=await import('path'),c=l(e.flags["output-dir"]??"trials",n);if(fs$1.existsSync(c)&&e.flags.overwrite!==true)throw new Error(`${c} already exists (pass --overwrite to replace it)`);let p=await s.get(n),d=null;try{d=await k(b(e)).get(p.job_id);}catch{d=null;}let g=[];for await(let y of s.traceEvents(n))g.push(y);let h=Te({trial:p,job:d,events:g,atif:await s.artifact(n,"trace-atif"),verifierLog:await s.artifact(n,"verifier"),stdout:await s.artifact(n,"trace-stdout"),stderr:await s.artifact(n,"trace-stderr"),home:await s.artifact(n,"agent-home"),userId:await Mt(e)});await i(c,{recursive:true});let S=[];for(let y of Object.keys(h).sort()){let f=l(c,...y.split("/"));await i(u(f),{recursive:true}),await o(f,h[y]),S.push(y),r||t.out(y);}return r?t.out(JSON.stringify({path:c,saved:S})):t.out(`Saved ${c}`),0}async function Mt(e){try{return (await Ce(b(e)).status()).user_id}catch{return null}}async function tr(e,t){let s=J(b(e)),n=e.flags.json===true,r=O(e);e.flags.type!==void 0&&(r.type=String(e.flags.type)),e.flags.grep!==void 0&&(r.grep=String(e.flags.grep)),e.flags.tail!==void 0&&(r.tail=e.flags.tail);let a=0;for await(let i of s.traceEvents(e.positionals[0],r))t.out(n?JSON.stringify(i):Be(i)),a+=1;return !n&&a===0&&t.out("No trace events."),0}async function nr(e,t){let s=k(b(e)),n=await I(e,e.positionals[0]),r=O(e);e.flags.type!==void 0&&(r.type=String(e.flags.type));let a=await s.grep(n,e.positionals[1],r);if(e.flags.json===true)return t.out(JSON.stringify(a)),0;if(a.items.length===0)return t.out("No matches."),0;for(let i of a.items){let o=i.match_count===1?"match":"matches";t.out(`${i.trial_id} ${i.task_name??"-"} ${i.match_count} ${o}`);for(let l of i.events)t.out(` ${Be(l)}`);}return a.hasMore&&a.nextCursor&&(t.out(""),t.out(`More trials match \u2014 resume with --cursor ${a.nextCursor}`)),0}async function sr(e,t){let s=await J(b(e)).retry(e.positionals[0]);if(e.flags.json===true)t.out(JSON.stringify(s));else {for(let n of L(s))t.out(n);t.out(""),t.out(`Follow it with: evolve job show ${s.id}`);}return 0}async function rr(e,t){let s=await J(b(e)).regrade(e.positionals[0]);if(e.flags.json===true)t.out(JSON.stringify(s));else {for(let n of L(s))t.out(n);t.out(""),t.out(`Follow it with: evolve job show ${s.id}`);}return 0}async function ar(e,t){let n=await J(b(e)).stop(e.positionals);if(e.flags.json===true)return t.out(JSON.stringify(n)),0;for(let r of n.stopped)t.out(`stopped ${r.id} (${r.task_name}) ${r.status}`);for(let r of n.already_terminal)t.out(`already terminal ${r}`);for(let r of n.not_found)t.out(`not found ${r}`);return 0}function Ft(e){let t=R([["name",e.name],["title",e.title??"-"],["description",e.description??"-"],["active version",e.active_version?.version??"-"]]),s=e.selected_version?.source??e.active_version?.source??null;if(s){let r=s.ref===s.commit?"":` @ ${s.ref}`;t.push(`source: ${s.git_url??"?"}${r} (commit ${s.commit.slice(0,12)})`),s.path&&t.push(` subfolder: ${s.path}`);}else if(e.upstream){let r=e.upstream,a=r.ref===r.current_commit?"":` @ ${r.ref}`;t.push(`source: ${r.git_url??"?"}${a} (commit ${r.current_commit.slice(0,12)})`),r.path&&t.push(` subfolder: ${r.path}`);}let n=e.active_version?.manifest;if(n&&(t.push(`manifest: ${n.name}${n.version?`@${n.version}`:""}`+(n.task_count!==null?` (${n.task_count} tasks pinned)`:"")),n.authors.length>0&&t.push(` authors: ${n.authors.map(r=>r.email?`${r.name} <${r.email}>`:r.name).join(", ")}`),n.keywords.length>0&&t.push(` keywords: ${n.keywords.join(", ")}`)),e.versions&&e.versions.length>0){t.push("");let r=e.versions.some(o=>o.gate!=null),a=e.versions.some(o=>o.source!=null),i=[["VERSION","STATE","TASKS","CREATED",...a?["COMMIT"]:[],...r?["GATE"]:[]]];for(let o of e.versions)i.push([o.version,o.state,String(o.task_count),o.created_at??"-",...a?[o.source?o.source.commit.slice(0,12):"-"]:[],...r?[o.gate?.status??"-"]:[]]);t.push(...R(i));for(let o of e.versions)if(o.gate?.status==="FAILED"){let l=o.gate.message??o.gate.code??"no reason reported";t.push(`version ${o.version} activation gate FAILED: ${l}`);for(let u of o.gate.failed_tasks){let c=u.reasons.length>0?u.reasons.join("; "):u.outcome??"no reason reported";t.push(` ${u.task_name}: ${c}`);}o.gate.failed_task_count>o.gate.failed_tasks.length&&t.push(` \u2026 and ${o.gate.failed_task_count-o.gate.failed_tasks.length} more (${o.gate.failed_task_count} ineligible tasks in total)`);}}if(e.tasks&&e.tasks.items.length>0){t.push("",`Tasks (version ${e.selected_version?.version??"?"}):`);let r=e.tasks.items.some(o=>(o.gpus??0)>0),a=[["TASK","AGENT TIMEOUT","VERIFIER TIMEOUT",...r?["GPU"]:[],"PROVIDERS"]];for(let o of e.tasks.items)a.push([o.task_name,`${o.agent_timeout_sec}s`,`${o.verifier_timeout_sec}s`,...r?[Os(o)??"-"]:[],$s(o.providers)]);t.push(...R(a)),e.tasks.nextCursor&&t.push(`More tasks: evolve dataset show ${e.name} --cursor ${e.tasks.nextCursor}`);let i=new Map;for(let o of e.tasks.items)for(let l of Jt){let u=o.providers?.[l];if(u){if(!u.ok)i.has(`${l}:${u.reason}`)||i.set(`${l}:${u.reason}`,`${l}: ${u.reason}`);else if(u.degrades_to&&u.reason){let c=`${l}:degrade:${u.reason}`;i.has(c)||i.set(c,`${l}: runs on ${u.degrades_to} \u2014 ${u.reason}`);}}}if(i.size>0){t.push("","Provider limitations:");for(let o of i.values())t.push(` ${o}`);}}return t}function Vt(e){let t=[];for(let s of e){if(!s.upstream?.moved)continue;let n=s.active_version?`@${s.active_version.version}`:"",r=s.upstream.latest_commit??s.upstream.ref,a=s.upstream.git_url??"<url>",i=s.upstream.path?` --path ${s.upstream.path}`:"";t.push(`${s.name}${n} \xB7 upstream ${s.upstream.ref} moved \u2014 run: evolve dataset publish --name ${s.name} --version <new-version> --git ${a} --ref ${r}${i}`);}return t}async function ir(e,t){if(H(e,t,ht))return 0;let n=await V(b(e)).list({...O(e),...e.flags.search!==void 0?{search:String(e.flags.search)}:{}});if(e.flags.json===true)return t.out(JSON.stringify(n)),0;if(n.items.length===0)return e.flags.quiet!==true&&t.out("No datasets."),0;if(K(e,t,n.items,ht,As,r=>r.name),e.flags.quiet!==true)for(let r of Vt(n.items))t.out(r);return 0}async function or(e,t){let n=await V(b(e)).get(e.positionals[0],O(e));if(e.flags.json===true)t.out(JSON.stringify(n));else {for(let r of Ft(n))t.out(r);for(let r of Vt([n]))t.out(r);}return 0}async function lr(e,t){let s=e.flags.json===true,n=V(b(e)),r=hs(e),a=await n.publish(r);if(e.flags.watch!==true){if(s)t.out(JSON.stringify(a));else {for(let o of kt(a))t.out(o);t.out(""),t.out(`Follow it with: evolve dataset show ${a.name}`);}return 0}s?t.out(JSON.stringify({kind:"import.created",datasetImport:a})):t.out(`Publish ${a.id} (${a.name}) ${a.status} \u2014 watching\u2026`);let i=await n.watchImport(a.id,{onStatus:o=>{t.out(s?JSON.stringify({kind:"import.status",datasetImport:o}):Cs(o));}});if(s)t.out(JSON.stringify({kind:"import.final",datasetImport:i}));else {t.out("");for(let o of kt(i))t.out(o);}return i.status==="FAILED"?1:0}async function ur(e,t){let n=await V(b(e)).download(e.positionals[0],{to:e.flags["output-dir"]??process.cwd()});return e.flags.json===true?t.out(JSON.stringify({path:n})):t.out(`Saved ${n}`),0}async function cr(e,t){let s=V(b(e)),[n,r]=e.positionals,a;try{a=await s.activate(n,r);}catch(i){if(i instanceof Z)return e.flags.json===true?t.out(JSON.stringify({kind:"gate.running",code:i.code,message:i.message,dataset:i.dataset,version:i.version,gate:i.gate})):(t.out(`Not yet: ${i.message}`),t.out(`Gate ${i.gate.status}: ${i.gate.tasks} task(s), ${i.gate.unverified} unverified, ${i.gate.ineligible} ineligible so far.`),t.out(`Follow it with: evolve dataset show ${n} \u2014 a gate that passes activates the version itself.`)),1;throw i}if(e.flags.json===true)t.out(JSON.stringify(a));else for(let i of Ft(a))t.out(i);return 0}function Gt(e){let t=[["name",e.name],["id",e.id],["ref",e.ref],["digest",e.digest],["size",jt(e.size_bytes)]];return e.description&&t.push(["description",e.description]),t.push(["created",e.created_at]),R(t)}async function dr(e,t){if(H(e,t,yt))return 0;let n=await G(b(e)).list(O(e));return e.flags.json===true?(t.out(JSON.stringify(n)),0):n.items.length===0?(e.flags.quiet!==true&&t.out("No uploaded skills."),0):(K(e,t,n.items,yt,Ts,r=>r.id),n.nextCursor&&t.tty===true&&e.flags.quiet!==true&&t.out(`
|
|
23
|
+
More: evolve skill list --cursor ${n.nextCursor}`),0)}async function mr(e,t){let n=await G(b(e)).upload(e.positionals[0]);return e.flags.json===true?(t.out(JSON.stringify(n.length===1?n[0]:n)),0):(n.forEach((r,a)=>{a>0&&t.out("");for(let i of Gt(r))t.out(i);}),t.out(""),t.out(`Use it with: evolve run --skill name:${n[0].name} (moving pointer) or --skill ${n[0].ref} (this exact content)`),0)}async function pr(e,t){let s=await G(b(e)).get(e.positionals[0]);if(e.flags.json===true)return t.out(JSON.stringify(s)),0;for(let n of Gt(s))t.out(n);return s.skill_md&&(t.out(""),t.out(s.skill_md)),0}async function gr(e,t){let s=e.positionals[0];return await G(b(e)).delete(s),e.flags.json===true?t.out(JSON.stringify({id:s,deleted:true})):t.out(`Deleted skill ${s}`),0}async function fr(e,t){if(H(e,t,vt))return 0;let n=await te(b(e)).list(O(e));return e.flags.json===true?(t.out(JSON.stringify(n)),0):n.items.length===0?(e.flags.quiet!==true&&t.out("No registered agents."),0):(K(e,t,n.items,vt,Ps,r=>r.name),0)}async function _r(e,t){let n=await te(b(e)).get(e.positionals[0]);if(e.flags.json===true)t.out(JSON.stringify(n));else for(let r of Lt(n))t.out(r);return 0}async function br(e,t){let n=await te(b(e)).create(ys(e));if(e.flags.json===true)t.out(JSON.stringify(n));else {for(let r of Lt(n))t.out(r);t.out(""),t.out(`Use it with: evolve run -d <dataset> -a ${n.name} -m <model>`);}return 0}async function hr(e,t){let s=te(b(e)),n=e.positionals[0];return await s.delete(n),e.flags.json===true?t.out(JSON.stringify({name:n,deleted:true})):t.out(`Deleted agent ${n}`),0}function yr(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 vr(e,t){let s=await Ce(b(e)).status();if(e.flags.json===true)t.out(JSON.stringify(s));else for(let n of yr(s))t.out(n);return 0}function kr(e){if(e.length===0)return {text:Le(),code:0};let t=Ge[e[0]];if(t)return {text:dt(e[0],t),code:0};let s=It[e[0]];if(s)return {text:s,code:0};let n=Pt[e[0]]??e[0],r=ve[n];if(!r)return {text:Le(),code:0};if(e.length===1)return {text:mt(n),code:0};let a=$t[e[1]]??e[1],i=r.commands[a];return i?{text:dt(`${n} ${a}`,i),code:0}:{text:mt(n),code:0}}var wr={run:xt,"job start":xt,"job list":Fs,"job show":Vs,"job trials":Gs,"job tasks":qs,"job compare":Ks,"job cancel":Hs,"job stop":Ws,"job resume":Ys,"job retry":zs,"job regrade":Xs,"job download":Qs,"job grep":nr,"trial show":Zs,"trial trace":tr,"trial download":er,"trial retry":sr,"trial regrade":rr,"trial stop":ar,"dataset list":ir,"dataset show":or,"dataset publish":lr,"dataset download":ur,"dataset activate":cr,"skill list":dr,"skill upload":mr,"skill show":pr,"skill delete":gr,"agent list":fr,"agent show":_r,"agent add":br,"agent remove":hr,"auth status":vr};function Sr(e){return e instanceof j?{code:e.code,message:e.message,...e.param!==void 0?{param:e.param}:{},...e.details!==void 0?{details:e.details}:{},...e.retryAfterSec!==void 0?{retryAfterSec:e.retryAfterSec}:{},...e.requestId!==void 0?{request_id:e.requestId}:{}}:{message:e instanceof Error?e.message:String(e)}}async function xr(e,t=vs){let s;try{s=zn(e);}catch(n){if(n instanceof m)return t.err(`Error: ${n.message}`),t.err('Run "evolve help" for usage.'),2;throw n}if(s.command==="help"){let{text:n,code:r}=kr(s.positionals);return t.out(n),r}if(s.command==="version")return t.out(Wn()),0;try{let n=wr[s.command];return n?await n(s,t):(t.err(`Error: unknown command "${s.command}"`),2)}catch(n){if(n instanceof m)return t.err(`Error: ${n.message}`),t.err(`Run "evolve ${s.command} --help" for usage.`),2;if(s.flags.json===true&&t.out(JSON.stringify({error:Sr(n)})),n instanceof j&&n.status===429){let r=n.retryAfterSec!==void 0?`retry in ${n.retryAfterSec}s`:"retry shortly";return t.err(`Error: rate limited by the server \u2014 ${r}.`),1}return t.err(`Error: ${n.message}`),1}}var Rr=(()=>{let e=process.argv[1];if(!e)return false;let t=s=>{try{return (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))===url.pathToFileURL(s).href}catch{return false}};if(t(e))return true;try{return t(fs$1.realpathSync(e))}catch{return false}})();Rr&&xr(process.argv.slice(2)).then(e=>{process.exitCode=e;},e=>{process.stderr.write(`Error: ${e?.message??e}
|
|
24
|
+
`),process.exitCode=1;});exports.CliUsageError=m;exports.USAGE=Zr;exports.buildAgentInput=ys;exports.buildJobInput=bs;exports.buildPublishInput=hs;exports.eventLine=Ds;exports.importStatusLine=Cs;exports.parseAgentKwargs=ps;exports.parseArgs=zn;exports.parseEnvPairs=Ue;exports.parseInlineSecrets=_s;exports.parseSecretRefs=fs;exports.parseYamlConfig=ea;exports.parseYamlConfigLocated=Ot;exports.runCli=xr;exports.traceEventLine=Be;exports.trialDetailLines=Is;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { bc as JobSecretRef, bd as JobSecretInline, a0 as JobCreate, aB as PublishDatasetInput, aH as AgentInput, T as Trial, a as TraceEvent, az as DatasetImport, an as JobEvent } from '../types-rqn7yZnX.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* evolve — the CLI for Evolve hosted datasets & jobs.
|
|
6
|
+
*
|
|
7
|
+
* Noun-verb grammar over the hosted client: `evolve <noun> <verb>`, plus
|
|
8
|
+
* first-class top-level commands that need no noun — today that is `run`,
|
|
9
|
+
* which takes `job start`'s flags and is spelled, helped and dispatched as a
|
|
10
|
+
* command in its own right (Harbor registers their `run` the same way, as the
|
|
11
|
+
* `job start` function bound at the top level: cli/main.py:164). Singular
|
|
12
|
+
* nouns are canonical; `job`/`trial`/`dataset`/`skill` also answer to their
|
|
13
|
+
* plurals as hidden aliases, but `agents` does NOT — that word is reserved for
|
|
14
|
+
* the managed-agents CLI and refuses with the reason. The CLI speaks ONLY
|
|
15
|
+
* through the SDK clients (datasets() / agents() / jobs() / trials() /
|
|
16
|
+
* skills() / auth()) — no raw HTTP lives here.
|
|
17
|
+
*
|
|
18
|
+
* Output: human tables on a TTY, tab-separated rows when piped, --json for
|
|
19
|
+
* the rendered machine shape (NDJSON for --watch event streams), -q for
|
|
20
|
+
* ids-only lists. Exit codes: 0 success (watch: job COMPLETED / publish
|
|
21
|
+
* COMPLETED), 1 runtime/API failure (watch: FAILED or CANCELLED), 2 usage
|
|
22
|
+
* error.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/** Usage-level error: bad command line, not a runtime failure. Exit code 2. */
|
|
26
|
+
declare class CliUsageError extends Error {
|
|
27
|
+
constructor(message: string);
|
|
28
|
+
}
|
|
29
|
+
declare const USAGE: string;
|
|
30
|
+
interface Invocation {
|
|
31
|
+
/** Canonical "<group> <verb>", or "help" / "version". */
|
|
32
|
+
command: string;
|
|
33
|
+
positionals: string[];
|
|
34
|
+
flags: Record<string, string | number | boolean | string[]>;
|
|
35
|
+
}
|
|
36
|
+
declare function parseArgs(argv: string[]): Invocation;
|
|
37
|
+
/**
|
|
38
|
+
* -c reads real YAML through the standard `yaml` package — the hand-rolled
|
|
39
|
+
* subset reader is retired. PyYAML's reading is the contract, so the schema is
|
|
40
|
+
* YAML 1.1 (`yes`/`on` are booleans, `012` is octal, a flow mapping is a whole
|
|
41
|
+
* sequence item) with two carve-outs: the 1.1 spec's bare `y`/`n` booleans,
|
|
42
|
+
* which PyYAML never adopted — `n: 3` keeps its key — and the 1.1 spec's
|
|
43
|
+
* number shapes PyYAML never adopted either, where a float needs a dot and a
|
|
44
|
+
* signed exponent and an integer may not be zero-padded, so `e3`, `1e3`, `08`
|
|
45
|
+
* and `0:0` stay the strings a caller wrote. The schema is PINNED, not
|
|
46
|
+
* merely defaulted: PyYAML's resolver has no mode but 1.1 and reads a file the
|
|
47
|
+
* same way whatever its `%YAML` directive says, while this library lets an
|
|
48
|
+
* explicit `%YAML 1.2` swap in the 1.2 core schema. One file, one reading.
|
|
49
|
+
* Three refusals sit on top of the library: a second document, an unresolvable
|
|
50
|
+
* tag (both PyYAML refusals too), and a duplicate key — PyYAML silently keeps
|
|
51
|
+
* the last value, and that silence is exactly the corruption a config file
|
|
52
|
+
* cannot afford. Every refusal names its `source` and carries `:line` wherever
|
|
53
|
+
* the parser places the problem — the library's alias-bomb guard fires at
|
|
54
|
+
* resolution, after parsing, and has no position to give. An empty or
|
|
55
|
+
* comment-only file is an empty object.
|
|
56
|
+
*/
|
|
57
|
+
declare function parseYamlConfig(text: string, source: string): unknown;
|
|
58
|
+
/** A path into the parsed config: object keys and list indices, root first. */
|
|
59
|
+
type ConfigPath = (string | number)[];
|
|
60
|
+
/**
|
|
61
|
+
* `parseYamlConfig` plus a `locate` that answers "what line does this path
|
|
62
|
+
* start on", so a schema refusal can point at the file the way a parse
|
|
63
|
+
* refusal already does. JSON configs have no locator — JSON.parse keeps no
|
|
64
|
+
* positions — and every message treats the line as optional for that reason.
|
|
65
|
+
*/
|
|
66
|
+
declare function parseYamlConfigLocated(text: string, source: string): {
|
|
67
|
+
value: unknown;
|
|
68
|
+
locate: (path: ConfigPath) => number | undefined;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Parse repeatable --ak key=value pairs into the wire's agents[].kwargs
|
|
72
|
+
* object. The `config` key gets the channel's one client-side mechanic: a
|
|
73
|
+
* string value is a LOCAL settings file (the server never reads a client
|
|
74
|
+
* path), resolved here to its parsed content — JSON or TOML by extension,
|
|
75
|
+
* with a both-ways attempt for anything else. Every other key rides verbatim;
|
|
76
|
+
* acceptance is the server's.
|
|
77
|
+
*/
|
|
78
|
+
declare function parseAgentKwargs(pairs: string[], read?: (path: string) => string): Record<string, unknown>;
|
|
79
|
+
/**
|
|
80
|
+
* Parse repeatable --secret NAME[@LABEL][=ENVNAME] references into the wire's
|
|
81
|
+
* secrets[] objects. The grammar splits on the FIRST '=' (everything after it
|
|
82
|
+
* is the in-sandbox env name) and then the FIRST '@' (everything after it is
|
|
83
|
+
* the label), so neither delimiter is legal inside the parts — which matches
|
|
84
|
+
* the server's vocabularies (env-var-shaped names, [A-Za-z0-9._-] labels).
|
|
85
|
+
* Only the shape is ruled here; name/label semantics (reserved names, the
|
|
86
|
+
* 'default' fallback, the ambiguity refusal) are the server's.
|
|
87
|
+
*/
|
|
88
|
+
declare function parseSecretRefs(values: string[]): JobSecretRef[];
|
|
89
|
+
/**
|
|
90
|
+
* Parse repeatable --secret-inline NAME[@LABEL]:DELIVERY=VALUE entries into
|
|
91
|
+
* the wire's inline secrets[] objects. DELIVERY sits BEFORE the '=' so the
|
|
92
|
+
* value — everything after the FIRST '=' — is passed through byte-for-byte
|
|
93
|
+
* and may contain '=', ':' and '@' unescaped. The head splits on its FIRST
|
|
94
|
+
* '@' (label) and LAST ':' (delivery), matching the label grammar
|
|
95
|
+
* ([A-Za-z0-9._-], no ':' possible). Only the shape is ruled here;
|
|
96
|
+
* name/label semantics and the collision refusal are the server's.
|
|
97
|
+
*/
|
|
98
|
+
declare function parseInlineSecrets(values: string[]): JobSecretInline[];
|
|
99
|
+
/** Parse repeatable KEY=VALUE pairs into an env map. */
|
|
100
|
+
declare function parseEnvPairs(pairs: string[], flag: string): Record<string, string>;
|
|
101
|
+
/**
|
|
102
|
+
* Build the POST /api/jobs body from a parsed `job start` / `run` invocation:
|
|
103
|
+
* -c loads a base config in the spec's own vocabulary, then every explicitly
|
|
104
|
+
* passed flag overrides the corresponding field. -i/-x/-l are stamped onto
|
|
105
|
+
* EVERY dataset selector — per-selector filters with one flag grammar, so a
|
|
106
|
+
* glob that matches nothing in one dataset simply filters nothing there.
|
|
107
|
+
*/
|
|
108
|
+
declare function buildJobInput(inv: Invocation, read?: (path: string) => string): JobCreate;
|
|
109
|
+
/**
|
|
110
|
+
* Build the datasets().publish() input from a parsed `dataset publish`
|
|
111
|
+
* invocation. `--name`/`--version` are optional with `--dir`: a corpus
|
|
112
|
+
* carrying a dataset.toml manifest supplies them server-side (Harbor's
|
|
113
|
+
* dataset layout), and the SDK refuses before uploading when neither the
|
|
114
|
+
* flags nor a manifest exist. A git source always requires both — its
|
|
115
|
+
* manifest is only readable after the server clones it.
|
|
116
|
+
*/
|
|
117
|
+
declare function buildPublishInput(inv: Invocation): PublishDatasetInput;
|
|
118
|
+
/**
|
|
119
|
+
* Build the agents().create() input from a parsed `agent add` invocation.
|
|
120
|
+
* `--install-script` names a FILE; its contents are what the SDK uploads.
|
|
121
|
+
*/
|
|
122
|
+
declare function buildAgentInput(inv: Invocation, readScript?: (path: string) => string): AgentInput;
|
|
123
|
+
interface CliIO {
|
|
124
|
+
out(line: string): void;
|
|
125
|
+
err(line: string): void;
|
|
126
|
+
/**
|
|
127
|
+
* True when stdout is an interactive terminal. Drives the table-vs-TSV
|
|
128
|
+
* split on list commands; TERM=dumb counts as non-interactive. Defaults to
|
|
129
|
+
* false when absent so redirected output always gets machine-safe rows.
|
|
130
|
+
*/
|
|
131
|
+
tty?: boolean;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Full-detail rendering of one trial — evolve trial show. Exported for
|
|
135
|
+
* tests, like the other line renderers.
|
|
136
|
+
*/
|
|
137
|
+
declare function trialDetailLines(run: Trial): string[];
|
|
138
|
+
/** One trace event line — evolve trial download --stream trace-parsed. */
|
|
139
|
+
declare function traceEventLine(event: TraceEvent): string;
|
|
140
|
+
/** Compact one-line rendering of one publish status change for --watch. */
|
|
141
|
+
declare function importStatusLine(job: DatasetImport): string;
|
|
142
|
+
/** Compact one-line rendering of one SSE event for --watch. */
|
|
143
|
+
declare function eventLine(event: JobEvent): string;
|
|
144
|
+
declare function runCli(argv: string[], io?: CliIO): Promise<number>;
|
|
145
|
+
|
|
146
|
+
export { type CliIO, CliUsageError, type Invocation, USAGE, buildAgentInput, buildJobInput, buildPublishInput, eventLine, importStatusLine, parseAgentKwargs, parseArgs, parseEnvPairs, parseInlineSecrets, parseSecretRefs, parseYamlConfig, parseYamlConfigLocated, runCli, traceEventLine, trialDetailLines };
|