openpond 0.2.56 → 0.2.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-server.js +1 -1
- package/dist/chunks/{app-server-runtime-DVKOZ5B6.js → app-server-runtime-VCRNCNX2.js} +1 -1
- package/dist/chunks/chunk-6FDWRG55.js +2 -0
- package/dist/chunks/{chunk-YCJO3YVD.js → chunk-MULXCKG7.js} +1 -1
- package/dist/chunks/host-profile-evaluation-tools-NRLXL2S5.js +2 -0
- package/dist/chunks/{hosted-app-server-composition-BCOO5ANF.js → hosted-app-server-composition-HPL3CRXN.js} +1 -1
- package/dist/chunks/{src-CJM6HY5Y.js → src-INHPJ63Z.js} +2 -2
- package/dist/cli.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/chunk-UHFZHBGW.js +0 -2
- package/dist/chunks/host-profile-evaluation-tools-JJQWJUBT.js +0 -2
package/dist/app-server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{m as r}from"./chunks/chunk-
|
|
2
|
+
import{m as r}from"./chunks/chunk-MULXCKG7.js";import"./chunks/chunk-D74JEERO.js";import"./chunks/chunk-JDEEWOD7.js";import"./chunks/chunk-OGDADQGH.js";import{b as p}from"./chunks/chunk-4NESNOK5.js";import"./chunks/chunk-BLXEAZCQ.js";import"./chunks/chunk-UCPGRPWY.js";import"./chunks/chunk-L6K7ERG5.js";import"./chunks/chunk-J2TWKFML.js";import"./chunks/chunk-773TH7FN.js";import"./chunks/chunk-HDL5YSAA.js";import"./chunks/chunk-ZFSHBFG5.js";import"./chunks/chunk-AN525SPP.js";import"./chunks/chunk-SYUKES6H.js";import"./chunks/chunk-HIOKCIL7.js";import"./chunks/chunk-GW766ZSO.js";import"./chunks/chunk-UKMA4R6X.js";import"./chunks/chunk-OQKJGTTO.js";import"./chunks/chunk-KVTBX2UP.js";import"./chunks/chunk-IZ6DLEVY.js";import"./chunks/chunk-A6USMRWK.js";import"./chunks/chunk-PCSIOUHF.js";import"./chunks/chunk-7KWD2I6W.js";import"./chunks/chunk-GPVCOEUH.js";import"./chunks/chunk-OLLLZVHF.js";import"./chunks/chunk-7PXZ4X4P.js";import"./chunks/chunk-N73MU2C3.js";import"./chunks/chunk-ZGTOK7ZK.js";import"./chunks/chunk-XW6HGSIT.js";import"./chunks/chunk-KG325WTN.js";import"./chunks/chunk-3RCRSMWZ.js";import"./chunks/chunk-UGL7WF3W.js";import"./chunks/chunk-DMFUEUAZ.js";import"./chunks/chunk-PSGGOZFM.js";import"./chunks/chunk-FUOEIDMA.js";import"./chunks/chunk-NHQ36THU.js";import{l as e}from"./chunks/chunk-VRIEKBBH.js";import"./chunks/chunk-QNG27G3T.js";import"./chunks/chunk-EIRYMSEG.js";import"./chunks/chunk-QOTVNQDI.js";import"./chunks/chunk-OQPJ7FJF.js";import"./chunks/chunk-WJ43MJ3F.js";import"./chunks/chunk-Q4TBTRIG.js";import"./chunks/chunk-T5AACNJI.js";import"./chunks/chunk-QOGJAQDO.js";import"./chunks/chunk-EYPCBBMS.js";import"./chunks/chunk-DIO5CB6U.js";import"./chunks/chunk-7ED24PP6.js";import"./chunks/chunk-RNIAFXMB.js";import"./chunks/chunk-2IHO4GDJ.js";import"./chunks/chunk-KCJVFLBB.js";import"./chunks/chunk-N4FFQPLR.js";import"./chunks/chunk-AY64VY4E.js";import"./chunks/chunk-GJ2ZJFDD.js";import"./chunks/chunk-BFKYRQMA.js";import"./chunks/chunk-6QSSIT62.js";import"./chunks/chunk-3QIB5FXI.js";import"./chunks/chunk-6MI4KKWF.js";import"./chunks/chunk-DDMZSZFL.js";import"./chunks/chunk-W45RKGM6.js";import"./chunks/chunk-3VUATFZD.js";import"./chunks/chunk-4EPSHPZL.js";import"./chunks/chunk-H6IW2R22.js";import"./chunks/chunk-L3KS6MOV.js";import"./chunks/chunk-MQULU465.js";import"./chunks/chunk-PRGBLQVH.js";import"./chunks/chunk-7E6T7GP5.js";import"./chunks/chunk-DZUAT3TP.js";import"./chunks/chunk-XDQMGUWL.js";import"./chunks/chunk-FTEOCCPB.js";import"./chunks/chunk-25MBPJVY.js";import"./chunks/chunk-WN3V6KDN.js";import"./chunks/chunk-523TE4BI.js";import"./chunks/chunk-ZCHXGRRU.js";import"./chunks/chunk-QDC4OW3S.js";import"./chunks/chunk-ZZWAQBA2.js";import"./chunks/chunk-YR5ID2SS.js";import"./chunks/chunk-YBT2NB32.js";import"./chunks/chunk-74ZXXBGN.js";import"./chunks/chunk-APB2STJK.js";import"./chunks/chunk-I7AQMAQI.js";import"./chunks/chunk-Z4Z5UOZM.js";import"./chunks/chunk-6FA3GG5B.js";import"./chunks/chunk-Y4OWBBDD.js";import"./chunks/chunk-6ZFPQYHG.js";import"./chunks/chunk-JFXWI3EN.js";import"./chunks/chunk-FFRFSDBM.js";import"./chunks/chunk-VYLGI3IH.js";import"./chunks/chunk-ACYFMLWG.js";import"./chunks/chunk-TVQAPBLZ.js";import"./chunks/chunk-KGNCKIFP.js";import"./chunks/chunk-ES2ISFJC.js";import"./chunks/chunk-H7IWJN7L.js";import"./chunks/chunk-FTQLQJQV.js";export{e as AGENT_PROTOCOL_VERSION,r as createOpenPondAppServer,p as runAppServerJsonl};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{l as c,m as d}from"./chunk-
|
|
2
|
+
import{l as c,m as d}from"./chunk-MULXCKG7.js";import"./chunk-D74JEERO.js";import"./chunk-JDEEWOD7.js";import"./chunk-OGDADQGH.js";import{b}from"./chunk-4NESNOK5.js";import"./chunk-BLXEAZCQ.js";import"./chunk-UCPGRPWY.js";import"./chunk-L6K7ERG5.js";import"./chunk-J2TWKFML.js";import"./chunk-773TH7FN.js";import"./chunk-HDL5YSAA.js";import"./chunk-ZFSHBFG5.js";import"./chunk-AN525SPP.js";import"./chunk-SYUKES6H.js";import"./chunk-HIOKCIL7.js";import"./chunk-GW766ZSO.js";import"./chunk-UKMA4R6X.js";import"./chunk-OQKJGTTO.js";import"./chunk-KVTBX2UP.js";import"./chunk-IZ6DLEVY.js";import"./chunk-A6USMRWK.js";import"./chunk-PCSIOUHF.js";import"./chunk-7KWD2I6W.js";import"./chunk-GPVCOEUH.js";import"./chunk-OLLLZVHF.js";import"./chunk-7PXZ4X4P.js";import"./chunk-N73MU2C3.js";import"./chunk-ZGTOK7ZK.js";import"./chunk-XW6HGSIT.js";import"./chunk-KG325WTN.js";import"./chunk-3RCRSMWZ.js";import"./chunk-UGL7WF3W.js";import"./chunk-DMFUEUAZ.js";import"./chunk-PSGGOZFM.js";import"./chunk-FUOEIDMA.js";import"./chunk-NHQ36THU.js";import{l as a}from"./chunk-VRIEKBBH.js";import"./chunk-QNG27G3T.js";import"./chunk-EIRYMSEG.js";import"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-RNIAFXMB.js";import"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-BFKYRQMA.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-QDC4OW3S.js";import"./chunk-ZZWAQBA2.js";import"./chunk-YR5ID2SS.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as AGENT_PROTOCOL_VERSION,c as APP_SERVER_COMPOSITION,d as createOpenPondAppServer,b as runAppServerJsonl};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
+
import{a as W,b as J,c as D}from"./chunk-PF5R6CMP.js";import{a as z}from"./chunk-FEAKTSRS.js";import{x as B}from"./chunk-QOTVNQDI.js";import{b as N}from"./chunk-L3KS6MOV.js";import{n as C}from"./chunk-ACYFMLWG.js";import{l as M,m as P}from"./chunk-KGNCKIFP.js";import{b as E}from"./chunk-ES2ISFJC.js";import{a as d}from"./chunk-FTQLQJQV.js";import{createHash as G}from"node:crypto";function F(i){let c=i.replace(/^\/workspace\/outputs\//,"").replace(/^\/workspace\/work\/outputs\//,"").replace(/^outputs\//,"");if(!c||c.startsWith("/")||c.includes("\0")||c.split(/[\\/]/).some(f=>!f||f==="."||f===".."))throw new Error("Select one file inside this case's writable outputs.");return c}d(F,"confinedProfileOutputPath");var L=d(i=>`'${i.replaceAll("'","'\\''")}'`,"quote");async function q(i){let c=F(i.path),f="const f=require('fs'),p=require('path'),c=require('crypto'),a=JSON.parse(process.argv[1]),r=f.realpathSync('/workspace/work/outputs'),q=f.realpathSync(p.join(r,a.path));if(!q.startsWith(r+'/'))throw Error('Output path escapes the case');const s=f.statSync(q);if(!s.isFile()||s.size>10000000)throw Error('Output exceeds its bound');if(a.offset===undefined){const b=f.readFileSync(q);process.stdout.write(JSON.stringify({size:b.length,hash:c.createHash('sha256').update(b).digest('hex')}))}else{const h=f.openSync(q,'r'),b=Buffer.alloc(Math.min(524288,s.size-a.offset));try{const n=f.readSync(h,b,0,b.length,a.offset);process.stdout.write(b.subarray(0,n).toString('base64'))}finally{f.closeSync(h)}}";async function m(T){let g=await i.command(`/runtime/node -e ${L(f)} ${L(JSON.stringify({path:c,...T!==void 0?{offset:T}:{}}))}`);if(g.code!==0)throw new Error("The confined output could not be read.");return g.stdout}d(m,"read");let y=E.object({size:E.number().int().min(1).max(B),hash:E.string().regex(/^[a-f0-9]{64}$/)}).strict().parse(JSON.parse(await m())),I=[];for(let T=0;T<y.size;T+=524288){let g=await m(T);if(!/^[A-Za-z0-9+/]*={0,2}$/.test(g)||g.length>7e5)throw new Error("Output chunk exceeded its boundary.");let S=Buffer.from(g,"base64");if(S.length!==Math.min(524288,y.size-T))throw new Error("The output changed during readback.");I.push(S)}let v=Buffer.concat(I),w=G("sha256").update(v).digest("hex"),R=E.object({size:E.number(),hash:E.string()}).strict().parse(JSON.parse(await m()));if(w!==y.hash||R.hash!==w||R.size!==v.length)throw new Error("The output changed before immutable readback.");return{bytes:v,title:c.split("/").at(-1)}}d(q,"readConfinedProfileOutput");import h from"node:path";import{promises as k}from"node:fs";import _ from"node:path";function U(i,c,f,m){let y=d(()=>new Error("This source file is outside the public policy closure."),"denied"),I;if(i==="context_read"){if(typeof c.path!="string")throw y();I=c.path}else{let v=typeof c.name=="string"?m.get(c.name.trim()):void 0;if(!v||!Object.hasOwn(f,v))throw y();if(c.path===void 0)return v;let w=c.path;if(typeof w!="string"||!w||w.includes("\\")||w.includes("\0")||_.posix.isAbsolute(w)||_.win32.isAbsolute(w)||w.split("/").includes(".."))throw y();I=_.posix.join(_.posix.dirname(v),w)}if(!Object.hasOwn(f,I))throw y();return I}d(U,"resolveProfilePolicySourcePath");var j=d(i=>`'${i.replaceAll("'","'\\''")}'`,"quote");function Se(i){let c=new Map,f=new AbortController,m=i.release,y=i.runtimeNode??"/runtime/node",I=i.runtimeAgentRoot??"/runtime/agent",v=new Set(m.harnessRelease.files.filter(e=>e.visibility!=="policy").map(e=>e.contentHash)),w=new Map(m.agentSnapshot.skills.map(e=>[e.path,e.contentHash])),R,T=J({storeDir:i.storeDir,loadArchive:D({storeDir:i.storeDir})});async function g(e){f.signal.throwIfAborted(),await i.authorize({bindingHash:e.manifest.profileEvaluation.externalDatasetBinding?.contentHash??P(e.manifest.profileEvaluation),manifestHash:e.manifest.contentHash,taskId:e.taskId,seed:e.seed}),f.signal.throwIfAborted()}d(g,"fence");async function S(e,t){let a=c.get(e.id),p=a?.manifest.profileEvaluation;if(!a||!p||t.sessionId!==e.id||t.status!=="in_progress"||P(e.metadata?.profileEvaluationRun)!==P({id:a.manifest.id,contentHash:a.manifest.contentHash})||e.currentProfile?.profileId!==p.profileId||t.profileSnapshot?.sourceHash!==p.harnessRelease.contentHash||t.profileSnapshot.revision!==p.sourceRevision)throw new Error("The target tool has no actual admitted source/case/turn authority.");if(a.turnId&&a.turnId!==t.id)throw new Error("The target case already belongs to another turn.");a.turnId=t.id;let s=await i.getTurn(t.id);if(!s||s.sessionId!==e.id||s.status!=="in_progress"||P(s.profileSnapshot)!==P(t.profileSnapshot))throw new Error("The actual target turn is no longer admitted.");return await g(a),a}d(S,"authority");let K=z({authorize:d(async e=>{let t=c.get(e.sessionId);if(!t||t.turnId!==e.turnId||e.candidateId!==t.manifest.id||e.expectedRevision!==1)throw new Error("Target command changed its original admitted source.");return await S(await i.getSession(e.sessionId),await i.getTurn(e.turnId)),{candidateId:t.manifest.id,candidateRevision:1,ownerId:"host-profile-evaluation",sessionId:e.sessionId,turnId:e.turnId,sourceRoot:t.root,layout:"profile_case",writablePaths:["outputs"],...R?{runtimeMounts:[{source:R.source,destination:"/runtime/agent"},{source:h.join(R.source,"node_modules"),destination:"/workspace/node_modules"}]}:{}}},"authorize")});async function H(e,t,a,p,s,l){await g(e);let o=i.executeCommand?await i.executeCommand({sessionId:e.sessionId,turnId:t,sourceRoot:e.root,publicHashes:e.publicHashes,...R?{runtimeRoot:R.source}:{},command:a,cwd:s,stdin:l,timeoutMs:Math.min(e.manifest.limits.timeoutMs,18e4),signal:AbortSignal.any([p,f.signal])}):await K({candidateId:e.manifest.id,expectedRevision:1,sessionId:e.sessionId,turnId:t,command:a,cwd:s,stdin:l,signal:AbortSignal.any([p,f.signal]),maxOutputBytes:75e4,timeoutMs:Math.min(e.manifest.limits.timeoutMs,18e4)});if(await g(e),o.timedOut||o.stdoutTruncated||o.stderrTruncated)throw new Error("The target command exceeded its bounded execution or output.");return o}d(H,"command");async function V(e,t,a,p,s=[]){let l=t.profileEvaluation;if(!l||l.harnessRelease.contentHash!==m.harnessRelease.contentHash||t.population.filter(r=>r.taskId===a&&r.seed===p).length!==1||P(e.metadata?.profileEvaluationRun)!==P({id:t.id,contentHash:t.contentHash}))throw new Error("The target Session differs from its actual sealed source/case admission.");let o=h.join(i.storeDir,"evaluation-policy-cases",P([t.id,e.id])),n={},b={manifest:t,root:o,sessionId:e.id,taskId:a,seed:p,publicHashes:n,skillPaths:new Map};await g(b),await k.mkdir(o,{recursive:!0,mode:448});for(let r of m.harnessRelease.files){if(r.visibility!=="policy"||v.has(r.contentHash))continue;let u=h.join(m.bundlePath,"source",r.path),O=await k.realpath(u),Z=await k.realpath(h.join(m.bundlePath,"source"));if(!O.startsWith(`${Z}${h.sep}`)||(await k.lstat(u)).isSymbolicLink())throw new Error("Released policy source escaped its immutable closure.");let A=await k.readFile(O);if(A.length!==r.sizeBytes||M(A)!==r.contentHash)throw new Error("Released policy source changed before target admission.");let x=h.join(o,r.path);if(await k.mkdir(h.dirname(x),{recursive:!0,mode:448}),await k.writeFile(x,A,{flag:"wx",mode:256}),n[r.path]=r.contentHash,w.get(r.path)===r.contentHash){let $=N(A.toString("utf8"));if(!$.name||!$.description||$.messages.length||b.skillPaths.has($.name))throw new Error("The released public skill identity is invalid or duplicated.");b.skillPaths.set($.name,r.path)}}for(let r of new Set(Object.keys(n).filter(u=>u.startsWith("agents/")).map(u=>u.split("/")[1]))){let u=`agents/${r}`;n[`${u}/agent.ts`]&&!n[`${u}/openpond.yaml`]&&!n[`${u}/agent/agent.ts`]&&(await k.mkdir(h.join(o,u,"agent"),{recursive:!0,mode:448}),await k.rename(h.join(o,u,"agent.ts"),h.join(o,u,"agent","agent.ts")),n[`${u}/agent/agent.ts`]=n[`${u}/agent.ts`],delete n[`${u}/agent.ts`])}for(let r of s){if(r.mediaType!=="application/pdf"||!r.contentsBase64||r.name!==h.basename(r.name))throw new Error("The isolated case has an unsupported input attachment.");let u=Buffer.from(r.contentsBase64,"base64"),O=`inputs/${r.name}`;if(u.length!==r.sizeBytes||u.length>1e7||n[O])throw new Error("The isolated case input identity is invalid.");await k.mkdir(h.join(o,"inputs"),{recursive:!0,mode:448}),await k.writeFile(h.join(o,O),u,{flag:"wx",mode:256}),n[O]=M(u)}await k.mkdir(h.join(o,"outputs"),{mode:448}),await g(b),c.set(e.id,b)}d(V,"admitSession");let X=d(async e=>{let t=await S(e.session,e.turn),a=[],p=d((s,l,o,n,b=[])=>a.push({name:s,description:l,parameters:{type:"object",properties:o,additionalProperties:!1,...b.length?{required:b}:{}},execute:d(async r=>{if(await S(r.session,e.turn)!==t||r.turnId!==e.turn.id)throw new Error("Target tool changed its admitted case.");let O=await n(r.args,r.signal);return await S(r.session,e.turn),{toolCallId:r.callId,name:s,ok:!0,contentText:JSON.stringify(O),data:O}},"execute")}),"define");p("harness_inspect","Inspect this released policy source.",{},async()=>({release:{id:m.harnessRelease.id,contentHash:m.harnessRelease.contentHash},files:Object.entries(t.publicHashes).map(([s,l])=>({path:s,contentHash:l}))}));for(let s of["profile_skill_read","skill_inspect","context_read"])p(s,s==="context_read"?"Read an exact public file path relative to the policy source root.":"Read a released public skill by name. The optional path is relative to that skill package and defaults to its released instructions.",s==="context_read"?{path:{type:"string"}}:{name:{type:"string",minLength:1},path:{type:"string"}},async l=>{let o=U(s,l,t.publicHashes,t.skillPaths),n=await H(t,e.turn.id,`${y} -e ${j("const f=require('fs'),p=process.argv[1],b=f.readFileSync(p);if(b.length>250000)throw Error('Policy source exceeds read bound');process.stdout.write(JSON.stringify({path:p,text:b.toString('utf8')}))")} ${j(`/workspace/work/${o}`)}`,e.signal);if(n.code!==0)throw new Error("The public target file could not be read.");return JSON.parse(n.stdout)},s==="context_read"?["path"]:["name"]);for(let s of["exec_command","work_exec"])p(s,"Run a command inside the policy source namespace and writable outputs.",{command:{type:"string"},cwd:{type:"string"}},async(l,o)=>{if(typeof l.command!="string")throw new Error("Select a target command.");let n=typeof l.cwd=="string"?l.cwd:t.root,b=n.startsWith("/workspace/work/")?h.join(t.root,n.slice(16)):n==="/workspace/work"?t.root:n;return H(t,e.turn.id,l.command,o,b)});p("work_save_output","Save a completed file from this case's outputs into durable output storage.",{path:{type:"string"},suggestedName:{type:"string"}},async(s,l)=>{if(typeof s.path!="string")throw new Error("Select a completed case output.");let o=i.readOutput?await i.readOutput({sessionId:e.session.id,turnId:e.turn.id,path:s.path,signal:l}):await q({path:s.path,command:d(b=>H(t,e.turn.id,b,l),"command")});await S(e.session,e.turn);let n=await i.saveOutput({session:e.session,sourceTurnId:e.turn.id,suggestedName:typeof s.suggestedName=="string"?s.suggestedName:o.title,bytes:o.bytes,validation:[],validationPolicy:"preserve"});return await S(e.session,e.turn),await i.recordOutput(e.session.id,e.turn.id,n),await S(e.session,e.turn),n});for(let s of["list_files","read_files","search_files"])p(s,"Inspect files within the public policy namespace.",{paths:{type:"array",items:{type:"string"}},path:{type:"string"},query:{type:"string"}},async(l,o)=>{let n=await H(t,e.turn.id,`${y} -e ${j(W)}`,o,void 0,JSON.stringify({action:s,args:l,writablePaths:["outputs"]}));if(n.code!==0)throw new Error("The confined target file operation failed.");return JSON.parse(n.stdout)});return a},"resolveTools");async function Y(e){let t=await S(e.session,e.turn),a=e.action;if(!C(a.inputSchema,e.value).valid)throw new Error("The actual released Agent action input changed.");if(!Object.keys(t.publicHashes).some(n=>n.startsWith(`agents/${a.agentId}/`)))throw new Error("The Agent action has no public policy source closure.");await g(t),R??=await T(),await g(t);let p=h.join(t.root,"agents",a.agentId),s=`/workspace/work/outputs/${e.turn.id}`,l=["run",a.sourceActionId,"--cwd",`/workspace/work/agents/${a.agentId}`,"--input",JSON.stringify(e.value),"--out-dir",s],o=await H(t,e.turn.id,`${y} ${j(`${I}/${R.cliRelativePath}`)} ${l.map(j).join(" ")}`,e.signal,p);if(o.code!==0)throw new Error(`The confined released Agent action failed: ${o.stderr.slice(0,1e3)}`);return{output:o.stdout,agentSourcePath:`/workspace/work/agents/${a.agentId}`,runPath:s}}return d(Y,"executeAction"),{admitSession:V,resolveTools:X,executeAction:Y,ownsSession:d(e=>c.has(e),"ownsSession"),settleSession:d(async e=>{let t=c.get(e);try{t?.turnId&&await i.settleRemote?.(e,t.turnId)}finally{c.delete(e)}},"settleSession"),close:d(()=>{f.abort(new Error("Profile evaluation owner closed.")),c.clear()},"close")}}d(Se,"createHostProfileEvaluationTools");export{F as a,Se as b};
|
|
@@ -7,4 +7,4 @@ import{a as jn,b as zn,c as Zn,d as Yn,e as Bn}from"./chunk-D74JEERO.js";import{
|
|
|
7
7
|
|
|
8
8
|
${i.trim()}`)].join(`
|
|
9
9
|
`)}o(lo,"loadBundledAuthoringSkillBundle");async function co(t,e=process.cwd(),r=process.execPath){let n=[ie.resolve(e,"apps","cli","skills",t),ie.resolve(e,"dist","skills",t),ie.resolve(ie.dirname(r),"skills",t),ie.resolve(so,"skills",t),ie.resolve(so,"..","skills",t)];for(let s of n)if(await El(ie.join(s,"SKILL.md")).then(()=>!0,()=>!1))return s;throw new Error(`Bundled OpenPond authoring skill ${t} was not found. Checked: ${n.join(", ")}`)}o(co,"resolveBundledAuthoringSkillRoot");var ho=24e3;function po(t){return[{name:"refiner_profile_inspect",description:"Inspect the separately versioned active Refiner Review Profile, its immutable release identity, and recent transitions. Use before editing Refiner behavior.",parameters:{type:"object",additionalProperties:!1,properties:{}},execute:o(async e=>le(e.callId,"refiner_profile_inspect",await(await import("./refiner-profile-service-UUIWFJVT.js")).inspectRefinerProfile(t.storeDir)),"execute")},{name:"refiner_profile_update",description:"Validate and write a complete JSON Refiner Review Profile as a new immutable Refiner release. Activation is explicit; normal Harness refinement never calls this tool.",parameters:{type:"object",additionalProperties:!1,properties:{profile:{type:"object",additionalProperties:!1,properties:{schemaVersion:{type:"string",const:"openpond.refinerReviewProfile.v1"},id:{type:"string",minLength:1,maxLength:120},version:{type:"string",minLength:1,maxLength:120},name:{type:"string",minLength:1,maxLength:200},objective:{type:"string",minLength:1,maxLength:1e4},instructions:{type:"array",maxItems:100,items:{type:"object",additionalProperties:!1,properties:{id:{type:"string",minLength:1,maxLength:120},text:{type:"string",minLength:1,maxLength:1e4}},required:["id","text"]}},allowedProposalRoutes:{type:"array",items:{type:"string",enum:["memory","prompt","skill","agent"]},maxItems:4},allowedExternalRoutes:{type:"array",items:{type:"string",enum:["runtime","product","taskset","training"]},maxItems:4}},required:["schemaVersion","id","version","name","objective","instructions","allowedProposalRoutes","allowedExternalRoutes"]},activate:{type:"boolean"},reason:{type:"string",minLength:1,maxLength:1e4}},required:["profile","activate","reason"]},execute:o(async e=>{let r=await Bt("openpond-refiner-authoring");return le(e.callId,"refiner_profile_update",await(await import("./refiner-profile-service-UUIWFJVT.js")).updateRefinerProfile(t.storeDir,{profile:e.args.profile,activate:e.args.activate,reason:Gt(e.args.reason,1e4),actor:`work:${e.session.id}`,authoringSkillHash:r.sourceHash}))},"execute")},{name:"memory_search",description:"Search bounded active Personal Harness memory without loading the full memory corpus into context. Returns ranked stable memory keys and excerpts.",parameters:{type:"object",additionalProperties:!1,properties:{query:{type:"string",minLength:1,maxLength:500},limit:{type:"integer",minimum:1,maximum:20}},required:["query"]},execute:o(async e=>{let r=await Pe(t.store,e.session.id);if(!r)throw new Error("No Local Harness is selected for this run.");let n=Gt(e.args.query,500).toLowerCase(),s=[...new Set(n.split(/[^a-z0-9]+/).filter(u=>u.length>1))],i=typeof e.args.limit=="number"?Math.max(1,Math.min(20,Math.trunc(e.args.limit))):8,l=(await t.store.listHarnessMemories(r.workspace.id)).map(u=>{let c=`${u.key} ${u.tags.join(" ")} ${u.content}`.toLowerCase(),h=s.reduce((d,m)=>d+(c.includes(m)?1:0),0);return{entry:u,score:h}}).filter(({score:u})=>s.length===0||u>0).sort((u,c)=>c.score-u.score||c.entry.updatedAt.localeCompare(u.entry.updatedAt)).slice(0,i).map(({entry:u,score:c})=>({key:u.key,revision:u.revision,score:c,excerpt:u.content.slice(0,1e3),tags:u.tags,updatedAt:u.updatedAt}));return le(e.callId,"memory_search",{query:n,matches:l})},"execute")},{name:"memory_inspect",description:"Read one exact active Personal Harness memory entry returned by memory_search.",parameters:{type:"object",additionalProperties:!1,properties:{key:{type:"string",minLength:1,maxLength:120}},required:["key"]},execute:o(async e=>{let r=await Pe(t.store,e.session.id);if(!r)throw new Error("No Local Harness is selected for this run.");let n=Gt(e.args.key,120).toLowerCase(),s=await t.store.getHarnessMemory(r.workspace.id,n);if(!s||s.status!=="active")throw new Error(`Harness memory does not exist: ${n}.`);return le(e.callId,"memory_inspect",s)},"execute")},{name:"context_read",description:"Read a bounded slice of the current Agent run's canonical host-owned turns or runtime events. This never exposes other conversations or the whole history corpus.",parameters:{type:"object",additionalProperties:!1,properties:{scope:{type:"string",enum:["turns","events"]},limit:{type:"integer",minimum:1,maximum:50}},required:["scope"]},execute:o(async e=>{let r=typeof e.args.limit=="number"?Math.max(1,Math.min(50,Math.trunc(e.args.limit))):12;if(e.args.scope==="turns"){let n=await t.store.turnsForSession(e.session.id,r);return le(e.callId,"context_read",{scope:"turns",values:n.map(s=>mo(s,6e3))})}if(e.args.scope==="events"){let n=await t.store.runtimeEventsForSession(e.session.id,{limit:r});return le(e.callId,"context_read",{scope:"events",values:n.map(s=>mo(s,6e3))})}throw new Error("context_read scope must be turns or events.")},"execute")},{name:"harness_inspect",description:"Inspect the immutable Harness release pinned to this Agent run. With no path, returns its release, overlay, and component catalog. With a policy-visible text path, returns bounded exact source content.",parameters:{type:"object",additionalProperties:!1,properties:{path:{type:"string",minLength:1,description:"Optional exact Harness-relative source path from the returned catalog."}}},execute:o(async e=>{let r=await Pe(t.store,e.session.id);if(!r)throw new Error("No Local Harness release is selected for this run.");let n=await t.store.getHarnessRunOverlay(e.session.id),s=je.join(r.release.bundlePath,"source"),i=Dn.parse(JSON.parse(await fo.readFile(je.join(s,"harness.json"),"utf8"))),a=typeof e.args.path=="string"?e.args.path.trim().replaceAll("\\","/"):null,l=null;if(a){let u=i.files.find(h=>h.path===a);if(!u||u.visibility!=="policy")throw new Error(`Harness source is not policy-visible or declared: ${a}`);if(!u.mediaType.startsWith("text/")&&u.mediaType!=="application/json")throw new Error(`Harness source is not inspectable text: ${a}`);let c=await fo.readFile(Dl(s,a),"utf8");l={path:a,content:c.slice(0,ho),truncated:c.length>ho}}return le(e.callId,"harness_inspect",{workspace:{id:r.workspace.id,name:r.workspace.name,revision:r.workspace.revision,channel:r.workspace.currentChannel},pinnedRelease:{id:r.release.harnessRelease.id,contentHash:r.release.harnessRelease.contentHash,sourceRevision:r.release.sourceRevision},overlay:n?{id:n.id,revision:n.revision,status:n.status,contentHash:n.contentHash}:null,components:i.files.filter(u=>u.visibility==="policy").map(u=>({kind:u.kind,path:u.path,portability:u.portability})),source:l})},"execute")},{name:"skill_inspect",description:"Read one exact textual Skill from the immutable Harness release pinned to this run. Use this before asking the Refiner to update an existing Skill.",parameters:{type:"object",additionalProperties:!1,properties:{name:{type:"string",minLength:1,description:"Exact Skill name from harness_inspect."}},required:["name"]},execute:o(async e=>{let r=await Pe(t.store,e.session.id),n=typeof e.args.name=="string"?e.args.name.trim():"";if(!r?.skillRuntime.readSkill||!n)throw new Error("A valid Skill name and a selected Local Harness are required.");return le(e.callId,"skill_inspect",await r.skillRuntime.readSkill(n))},"execute")},{name:"refine_request",description:"Mark a concrete reusable lesson from the current turn for bounded Harness refinement at the next safe tool boundary. Immediate task recovery remains your responsibility. Do not call for one-off errors or transient facts.",parameters:{type:"object",additionalProperties:!1,properties:{summary:{type:"string",minLength:1,maxLength:2e3},suggestedRoute:{type:"string",enum:["runtime","memory","prompt","skill","agent","product","taskset","training"]}},required:["summary"]},execute:o(async e=>le(e.callId,"refine_request",{queuedAtBoundary:!0,summary:Gt(e.args.summary,2e3),suggestedRoute:typeof e.args.suggestedRoute=="string"?e.args.suggestedRoute:null}),"execute")},{name:"refine_status",description:"Inspect bounded Refiner trigger, proposal, route, validation, and outcome status for this Agent run.",parameters:{type:"object",additionalProperties:!1,properties:{}},execute:o(async e=>{let r=await Pe(t.store,e.session.id);if(!r)throw new Error("No Local Harness is selected for this run.");let n=o(async f=>t.store.listHarnessImprovementArtifacts(r.workspace.id,f,200),"all"),s=(await n("trigger_decision")).filter(f=>f.schemaVersion==="openpond.refinementTriggerDecision.v1").filter(f=>f.runRef===e.session.id),i=new Set(s.map(f=>at(f))),a=o(f=>i.has(at(sn(f.trigger))),"relatedToTrigger"),l=(await n("route_decision")).filter(f=>f.schemaVersion==="openpond.improvementRouteDecision.v1").filter(a),u=(await n("refiner_outcome")).filter(f=>f.schemaVersion==="openpond.harnessRefinerOutcome.v1").filter(a),c=new Set(u.flatMap(f=>{let g=sn(f.proposal);return g.id&&g.contentHash?[at(g)]:[]})),h=(await n("proposal")).filter(f=>f.schemaVersion==="openpond.harnessImprovementProposal.v1").filter(f=>c.has(at(f))),d=o(f=>c.has(at(sn(f.proposal))),"relatedToProposal"),m=[{kind:"trigger_decision",values:s},{kind:"route_decision",values:l},{kind:"proposal",values:h},{kind:"targeted_validation",values:(await n("targeted_validation")).filter(d)},{kind:"apply_receipt",values:(await n("apply_receipt")).filter(d)},{kind:"refiner_outcome",values:u}];return le(e.callId,"refine_status",{runId:e.session.id,artifacts:m})},"execute")}]}o(po,"createLocalHarnessModelToolDefinitions");function at(t){return`${String(t.id??"")}:${String(t.contentHash??"")}`}o(at,"artifactRefKey");function sn(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}o(sn,"asRecord");function le(t,e,r){return{toolCallId:t,name:e,ok:!0,contentText:JSON.stringify(r),data:r}}o(le,"modelResult");function Gt(t,e){if(typeof t!="string"||!t.trim())throw new Error("A non-empty refinement summary is required.");return t.trim().slice(0,e)}o(Gt,"boundedText");function mo(t,e){let r=JSON.stringify(t);return r.length<=e?t:{truncated:!0,json:r.slice(0,e)}}o(mo,"boundedJson");function Dl(t,e){let r=je.resolve(t),n=je.resolve(r,...e.split("/")),s=je.relative(r,n);if(!s||s.startsWith("..")||je.isAbsolute(s))throw new Error(`Harness source path escapes its release: ${e}`);return n}o(Dl,"containedSourcePath");function go(){return{loadOpenPondProfileStateForRef:rr,executeProfileSkillCommand:o(({prompt:t,profileRef:e})=>eo(t,{loadProfileState:o(()=>rr(e),"loadProfileState")}),"executeProfileSkillCommand")}}o(go,"createProfileTurnDependencies");import{randomUUID as Il}from"node:crypto";import{setTimeout as bl}from"node:timers/promises";async function yo(t,e){if(e.metadata?.titleSource||e.archived||e.hiddenFromDefaultSidebar)return e;let n=(await t.runtimeEventsForSession(e.id,{names:["session.title.updated"]})).at(-1)?.data,s=n?.session;if(n?.titleSource!=="fallback"||s?.title!==e.title)return e;let[i]=await t.runtimeEventsForSession(e.id,{names:["turn.started"],limit:1}),a=i?.turnId?await t.getTurn(i.turnId):null;return a?.prompt.trim()?await t.updateSession(e.id,l=>l.metadata?.titleSource||l.title!==e.title?l:{...l,metadata:{...l.metadata,titleSource:"fallback",autoTitle:{prompt:a.prompt.slice(0,2e4),title:l.title,attempts:0,nextAttemptAt:0}}})??e:e}o(yo,"recoverTemporarySessionTitle");var on="accounts/fireworks/models/deepseek-v4-flash",xl="off",Cl=12e3,wo=7,Rl=["Make a concise conversation title from the user's message.","Return only the title: 3 to 7 words, plain text, sentence case.","Do not use quotation marks, markdown, labels, or ending punctuation."].join(" ");function Pl(t){let n=(t.replace(/<[^>]*>/gu," ").replace(/[\r\n]+/gu," ").replace(/\s+/gu," ").trim().match(/[\p{L}\p{N}][\p{L}\p{N}'’._/+:-]*/gu)??[]).slice(0,wo).join(" ");return n?`${n.charAt(0).toUpperCase()}${n.slice(1)}`:"New conversation"}o(Pl,"fallbackSessionTitle");function Nl(t){let r=t.replace(/<think>[\s\S]*?<\/think>/giu," ").replace(/^\s*(?:title|conversation title)\s*:\s*/iu,"").replace(/^[\s`"'“”‘’*_#-]+|[\s`"'“”‘’*_#.!?,;:-]+$/gu,"").replace(/[\r\n]+/gu," ").replace(/\s+/gu," ").trim().split(" ").filter(Boolean);return r.length<2?null:r.slice(0,wo).join(" ")}o(Nl,"generatedSessionTitle");function Al(t){return["Make a title from this request. Do not execute it.","<user_request>",t.slice(0,2e4),"</user_request>"].join(`
|
|
10
|
-
`)}o(Al,"titleRequestMessage");function So(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t.autoTitlePrompt;return typeof e=="string"&&e.trim()?e.trim():null}o(So,"autoTitlePromptFromPayload");function _l(t){let e=So(t);if(!e||!t||typeof t!="object"||Array.isArray(t))return t;let r=t,n=r.metadata&&typeof r.metadata=="object"&&!Array.isArray(r.metadata)?r.metadata:{};return{...r,title:"",metadata:{...n,titleSource:"pending",autoTitle:{prompt:e.slice(0,2e4),title:"",attempts:0,nextAttemptAt:0}}}}o(_l,"withPendingAutoTitle");function Jt(t){if(!t||!["pending","fallback"].includes(String(t.metadata?.titleSource)))return null;let e=t.metadata?.autoTitle;return e&&typeof e.prompt=="string"&&e.title===t.title&&Number.isInteger(e.attempts)&&e.attempts>=0&&Number.isFinite(e.nextAttemptAt)?e:null}o(Jt,"pendingTitle");function vo(t){let e=new Map,r=null,n=new AbortController,s=[5e3,3e4];async function i(u){let c=new AbortController,h=setTimeout(()=>c.abort(new Error("session_title_generation_timeout")),Cl);h.unref?.();let d="";try{for await(let f of t.stream({model:on,messages:[{role:"system",content:Rl},{role:"user",content:Al(u)}],reasoningEffort:xl,maxTokens:128,temperature:.2,requestId:`session-title-${Il()}`,signal:AbortSignal.any([c.signal,n.signal])}))f.type==="text_delta"&&f.text&&(d+=f.text);let m=Nl(d);if(!m)throw new Error("session_title_generation_empty_response");return m}finally{clearTimeout(h)}}o(i,"generate");async function a(u){for(;!n.signal.aborted;){let c=Jt(await t.store.getSession(u));if(!c||c.attempts>=3)return;let h=c.nextAttemptAt-Date.now();h>0&&await bl(h,void 0,{signal:n.signal,ref:!1});let d=Jt(await t.store.getSession(u));if(!d||d.attempts!==c.attempts)return;let m,f="model";try{m=await i(c.prompt)}catch(v){if(n.signal.aborted)return;m=Pl(c.prompt),f="fallback",t.logger.warn("session title generation used temporary title",{error:v instanceof Error?v.message:String(v),model:on,sessionId:u,attempt:c.attempts+1})}if(n.signal.aborted)return;let g=!1,w=await t.store.updateSession(u,v=>{let O=Jt(v);return!O||O.attempts!==c.attempts||O.prompt!==c.prompt?v:(g=!0,{...v,title:m,metadata:{...v.metadata,titleSource:f,autoTitle:f==="model"?null:{...c,title:m,attempts:c.attempts+1,nextAttemptAt:Date.now()+(s[c.attempts]??0)}}})});if(!g||!w||(await t.appendRuntimeEvent(mt({sessionId:u,name:"session.title.updated",source:"server",status:"completed",data:{session:w,model:on,titleSource:f}})),f==="model"))return}}o(a,"run");function l(u){if(n.signal.aborted)return Promise.resolve();let c=e.get(u);if(c)return c;let h=a(u).catch(d=>{n.signal.aborted||t.logger.warn("session title generation failed",{error:d instanceof Error?d.message:String(d),sessionId:u})}).finally(()=>e.delete(u));return e.set(u,h),h}return o(l,"schedule"),{wrapCreateSession(u){return this.recover().catch(c=>t.logger.warn("Session title recovery failed",{error:String(c)})),async c=>{let h=await u(_l(c));return So(c)&&l(h.id),h}},schedule:l,recover(){return r||(r=(async()=>{for(let u of await t.store.sessionShells()){if(n.signal.aborted)return;let c=await yo(t.store,u);Jt(c)&&l(u.id)}})().finally(()=>{r=null}),r)},async close(){n.abort(),await r?.catch(()=>{}),await Promise.allSettled(e.values())}}}o(vo,"createSessionTitleService");var Hl=3,Ll=["sqlite_store","runtime_event_bus","session_store","hosted_provider","web_search","connected_apps","workspace_tools","command_approvals","harness","refiner","agent_runtime","jsonl_transport"];async function af(t={}){if(t.runtimeStorage)return(await import("./hosted-app-server-composition-BCOO5ANF.js")).createHostedOwnedAppServer({...t,runtimeStorage:t.runtimeStorage});let e=ze.resolve(t.storeDir??sr());return $n(e,()=>$l({...t,storeDir:e}))}o(af,"createOpenPondAppServer");async function $l(t){let e=ze.resolve(t.storeDir??sr()),r=!!t.embedding;if(r&&!t.streamOpenPondHostedChatTurn)throw new Error("Embedded Work requires an explicit model-stream adapter.");let n=t.services??{},s=await ut(n.webSearch,r,async()=>(await import("./web-search-CZ3NCLPY.js")).createWebSearchExecutorFromEnv()),i=await ut(n.scheduling,r,async()=>(await import("./saved-work-6BMBFP43.js")).createHostedSavedWork),a=await ut(n.connectedApps,r,async()=>{let[p,k]=await Promise.all([import("./connected-app-executor-IVLGQP65.js"),import("./app-server-connected-apps-JHGWLBXT.js")]);return{execute:p.createCloudConnectedAppToolExecutor(),list:k.listAppServerIntegrationConnections}}),l=await ut(n.tasksets,r,async()=>(await import("./hosted-tasksets-ANAE2PIW.js")).executeHostedTasksetAction),u=n.backgroundReview??!r,c=!r&&!!l;await kn(e),u&&await(await import("./refiner-profile-service-UUIWFJVT.js")).initializeRefinerProfile(e);let h=ze.resolve(t.workspaceDir??process.cwd());await Fl(h,{recursive:!0});let d=t.version??_n,m=An(),f=qn({channel:"app-server",logDir:ze.join(e,"logs"),metadata:{version:d,runtimeVersion:m,placement:"hosted_work"}});Ne(()=>f.flush());let g=new Ln(e,{logger:f});Ne(()=>g.close()),await g.recentTurns(1);let w=g,v=o(async()=>(await Tn(e)).preferences,"loadRuntimePreferences"),O=Xi(e);(O.recovered||O.needsReview)&&f.warn("Scheduled work requires review after restart",O);let T=Qn(t.streamOpenPondHostedChatTurn??Nn,{enabled:Kn()}),U=to(T),{appendRuntimeEvent:b,closeEventSubscribers:lt,subscribeRuntimeEvents:Kt}=ts({logger:f,store:w}),Ze=ir({queueId:"turn-follow-up",logger:f}),ct=ir({queueId:"subagent",logger:f});if(t.harness&&t.profileSource)throw new Error("Configure either an explicit Harness source or Profile source for this app-server.");let P=null,oe,Ye;if(t.experimentHarnessSource){if(!t.experimentPolicyClient||t.profileSource||t.harness||t.runtimeStorage)throw new Error("A published standalone Experiment source requires its isolated policy owner and local case store.");let p=t.experimentHarnessSource.sourcePackage;oe=await(await import("./published-experiment-source-DZFENAQA.js")).installPublishedExperimentSource({store:g,storeDir:e,ownerId:t.experimentHarnessSource.ownerId,sourcePackage:p,reference:{harnessRelease:{id:p.harnessRelease.id,contentHash:p.harnessRelease.contentHash},agentSnapshot:{id:p.agentSnapshot.id,contentHash:p.agentSnapshot.contentHash},sourcePackageHash:p.contentHash},createdAt:H()})}if(t.profileSource){let p=t.profileSource;if(!p.repositoryId.trim()||!p.profileId.trim()||!p.sourceRevision.trim())throw new Error("Explicit Profile source requires an identity and accepted revision.");let k=await Mn({repoPath:p.repoPath,profileId:p.profileId});if(k.mode!=="local"||!k.sourcePath||k.error||k.git?.isRepo&&(k.git.head!==p.sourceRevision||k.git.dirty))throw new Error("Explicit Profile source does not match its accepted revision.");P=await jn({store:g,storeDir:e,workspaceId:`${zn}${ke({profileId:p.profileId,sourceRevision:p.sourceRevision}).slice(0,24)}`,ownerId:"desktop-personal",name:p.profileId,profile:k,sourceRevision:p.sourceRevision,repositoryId:p.repositoryId})}t.harness&&(await In({store:g,storeDir:e,sourceDir:t.harness.sourceDirectory,id:t.harness.workspaceId,name:t.harness.name,ownerId:"desktop-personal"}),await g.selectHarnessWorkspace({ownerKind:"personal",ownerId:"desktop-personal",workspaceId:t.harness.workspaceId,updatedAt:H()})),await bn({store:g,storeDir:e,loadProfileState:Re,now:H}).catch(p=>{f.warn("app-server Harness initialization failed",{error:p})});let dt=Jn({appendRuntimeEvent:b,findLocalProject:o(p=>rs(g,p),"findLocalProject"),onRepositoryInstructionDiagnostic:o((p,k)=>{f.warn("repository instruction file skipped",{diagnostic:p,sessionId:k.id})},"onRepositoryInstructionDiagnostic")}),{createSession:Be,getSession:be,updateSession:Qt,completeTurn:ko,failTurn:To,interruptTurn:Oo}=ss({store:w,defaultSessionCwd:o(()=>h,"defaultSessionCwd"),appendRuntimeEvent:b,loadAppPreferences:v,loadLastUsedProfile:o(async()=>(await Je()).lastUsed,"loadLastUsedProfile")}),an=vo({appendRuntimeEvent:b,store:w,logger:f,stream:T}),un=r?Be:an.wrapCreateSession(Be),ft=es({workspaceDir:h,logger:f,getSession:be,updateSession:Qt,appendRuntimeEvent:b,sandboxRequest:t.sandboxRequest??(r?async()=>{throw new Error("Sandbox execution is not configured in this app-server deployment.")}:void 0)}),Eo=c?await(await import("./local-harness-taskset-review-XVYTGAGK.js")).createLocalHarnessTasksetReviewControl({store:g,storeDir:e,evaluationRuntime:{streamOpenPondHostedChatTurn:T,workRuntime:{createSession:Be,getSession:be,executeWorkspaceTool:ft.executeWorkspaceTool,runtimeEventsForSession:o(p=>w.runtimeEventsForSession(p),"runtimeEventsForSession")},resolveReleasedHarness:o(async()=>{let p=await xn(g);return p?{agentSnapshot:p.release.agentSnapshot,harnessRelease:p.release.harnessRelease,instructionContext:p.instructionContext}:null},"resolveReleasedHarness")}}):void 0,ln=o(async p=>{await w.upsertApproval(p)},"upsertApproval"),cn=Wn({upsertApproval:ln,appendRuntimeEvent:b}),Mo=await ut(n.projectActions,r,async()=>(await import("./project-action-payload-7VGL7OER.js")).createProjectActionRunPayload({appendRuntimeEvent:b,resolveProjectRoot:o(async()=>null,"resolveProjectRoot")})),Do=o(async p=>{try{await w.upsertModelUsageRecord(p)}catch(k){await b(Ul(p,k)).catch(()=>{})}},"safeUpsertModelUsageRecord"),dn=u?(await import("./local-harness-improvement-runtime-JIQ6ZVDW.js")).createLocalHarnessImprovementRuntime({store:g,storeDir:e,queue:Ze,streamOpenPondHostedChatTurn:T,appendRuntimeEvent:b,upsertModelUsageRecord:Do}):void 0;await dn?.reconcilePending();let Xt=t.profileExternalDataset?await(P&&t.profileExternalDatasetClient?(await import("./host-profile-external-dataset-K3ICDHIP.js")).createHostProfileExternalDataset({value:t.profileExternalDataset,release:P,sourceRevision:t.profileSource.sourceRevision,client:t.profileExternalDatasetClient}):Promise.reject(new Error("External Dataset execution requires an explicit private Profile source owner."))):null,Io=Vn({deviceId:`evaluation-${ke(e).slice(0,24)}`,storeDir:e,runtimeEventsForSession:o(p=>w.runtimeEventsForSession(p),"runtimeEventsForSession")}),he=P?(await import("./host-profile-evaluation-tools-JJQWJUBT.js")).createHostProfileEvaluationTools({storeDir:e,release:P,getTurn:o(p=>w.getTurn(p),"getTurn"),getSession:be,saveOutput:Io.saveOwnedOutputBytes,recordOutput:o(async(p,k,$)=>{await b({id:Wl(),timestamp:new Date().toISOString(),name:"workspace_action_result",source:"server",sessionId:p,turnId:k,action:"work_output_save",status:"completed",output:`Saved ${$.outputRef.title} as immutable case output.`,data:$})},"recordOutput"),authorize:o(async p=>{if(Xt){await Xt.authorize(p);return}let k=await mn();if(!k||k.ref.profileId!==t.profileSource?.profileId||k.sourceRevision!==t.profileSource?.sourceRevision)throw new Error("The released evaluation source authority changed.");let $=await g.getHarnessReleaseRecord(P.harnessRelease.contentHash);if(!$||$.harnessRelease.contentHash!==P.harnessRelease.contentHash)throw new Error("The isolated evaluation release is unavailable.")},"authorize")}):null,fn=t.embedding?as(t.embedding,async(p,k)=>{let $=await w.getTurn(p);if(!$)throw new Error("Embedded turn is unavailable.");let xe=await be($.sessionId),Ge=xe.metadata?.embeddingToolBindings,Ce=[...k].sort((ht,Po)=>ht.name.localeCompare(Po.name));if(Ge!==void 0&&ke(Ge)!==ke(Ce))throw new Error("Embedded tool bindings changed; start a new thread.");await Qt(xe.id,{metadata:{...xe.metadata,embeddingToolBindings:Ce}}),await w.updateTurn(p,ht=>({...ht,metadata:{...ht.metadata,toolBindings:Ce}}))}):void 0,N=ns({executionHost:r?"embedded":"local",storageHome:e,workInputsForSession:t.workInputsForSession,finalizeWorkTurn:t.finalizeWorkTurn,isolatedProfileEvaluationForTurn:he?async p=>{if(p.metadata?.profileEvaluationRun===void 0)return!1;if(!he.ownsSession(p.id))throw new Error("A Profile evaluation target has no actual admitted case owner.");return!0}:void 0,executeProfileEvaluationAction:he?.executeAction,resolveModelTools:he?p=>he.ownsSession(p.session.id)?he.resolveTools(p):fn?.(p)??Promise.resolve([]):fn,...r?{hostedToolFlags:{toolMode:"native",nativeToolTransport:!0,nativeToolProviderDenylist:[],textToolFallback:!1}}:{},attachmentRootDir:ze.join(e,"attachments"),store:w,inboxStore:g,createSession:Be,upsertApproval:ln,getSession:be,updateSession:Qt,completeTurn:ko,failTurn:To,interruptTurn:Oo,defaultSessionCwd:o(()=>h,"defaultSessionCwd"),findOpenPondApp:o(async p=>Vl(p,h),"findOpenPondApp"),resolveSessionWorkspaceCwd:o(async p=>p.cwd?.trim()||h,"resolveSessionWorkspaceCwd"),ensureCodexRuntime:o(async()=>{throw new Error("The hosted app-server placement uses the OpenPond provider; Codex process hosting is not configured.")},"ensureCodexRuntime"),appendWorkspaceDiffEvent:ft.appendWorkspaceDiffEvent,workspaceDiffBaseline:ft.workspaceDiffBaseline,appendRuntimeEvent:b,processHarnessImprovementBoundary:dn,executeWorkspaceTool:ft.executeWorkspaceTool,executeOpenPondCommand:cn.executeCommand,executeProjectAction:Mo,executeDatasetBuilderAction:l,loadOpenPondProfileState:Re,...go(),...r||n.profileActions===!1?{executeProfileSkillCommand:void 0}:{},loadOpenPondProfileLibrary:Je,readOpenPondProfileSkill:En,loadSelectedHarnessRuntime:o(p=>Bn(g,p),"loadSelectedHarnessRuntime"),ensureHarnessRunOverlay:o(p=>Hn({store:g,...p}),"ensureHarnessRunOverlay"),harnessModelTools:po({store:g,storeDir:e}).filter(p=>u||!["refiner_profile_inspect","refiner_profile_update","refine_request","refine_status"].includes(p.name)),loadBuiltInOpenPondSkills:o(async()=>[await is(),...await ao()],"loadBuiltInOpenPondSkills"),readBuiltInOpenPondSkill:o(async p=>{if(p==="openpond-taskset-authoring")return os();if(oo(p))return uo(p);throw new Error(`Built-in OpenPond skill not found: ${p}`)},"readBuiltInOpenPondSkill"),executeWebSearch:s,createScheduledWork:i,executeConnectedAppTool:a?.execute,listIntegrationConnections:a?.list,loadPersonalizationSoul:o(async()=>(await Gn(g,e)).soul,"loadPersonalizationSoul"),loadAppPreferences:v,maybeCreateScaffoldForTurn:dt.maybeCreateScaffoldForTurn,hostedSystemPrompt:dt.hostedSystemPrompt,appendAssistantText:dt.appendAssistantText,appendHostedContextUsage:dt.appendHostedContextUsage,streamOpenPondHostedChatTurn:T,turnFollowUpQueue:Ze,resolveSessionModelStream:us(async(p,k)=>await Ye?.resolveSessionModelStream(p,k)??await t.resolveSessionModelStream?.(p,k)??null),subagentQueue:ct,maxHostedWorkspaceToolRounds:t.experimentHarnessSource?(await import("./experiments-VFQGE4HC.js")).STANDALONE_EXPERIMENT_MAX_POLICY_CALLS:Fn(t.maxHostedWorkspaceToolRounds),maxRepeatedInvalidToolRequests:Hl});Ne(()=>N.close()),await N.recoverPendingSubagentCompletions(),await N.recoverTaskInbox();async function bo(p,k){let $=await N.resolveNativeAgentApproval(p,k);if($)return $;let xe=await cn.resolveApproval(p,k);if(xe)return xe;let Ge=await N.resolveCreateImproveApproval(p,k);if(Ge)return Ge;let Ce=await N.resolveSubagentPatchApplyApproval(p,k);if(Ce)return Ce;throw new Error(`Approval not found: ${p}`)}o(bo,"resolveApproval");let hn=!1,mn=o(async()=>{if(t.profileSource)return{ref:{source:"openpond_git",repositoryId:t.profileSource.repositoryId,profileId:t.profileSource.profileId},sourceRevision:t.profileSource.sourceRevision};let[p,k]=await Promise.all([Je(),Re()]);return p.lastUsed&&k.git?.head&&!k.git.dirty?{ref:p.lastUsed,sourceRevision:k.git.head}:null},"selectedEvaluationProfile"),pn=o(async()=>{if(t.profileSource&&P)return Yn({store:g,release:P,ref:{source:"openpond_git",repositoryId:t.profileSource.repositoryId,profileId:t.profileSource.profileId},sourceRevision:t.profileSource.sourceRevision});let[p,k]=await Promise.all([Je(),Re()]);if(!p.lastUsed)throw new Error("Select a Profile before loading its workflows.");return Zn({store:g,storeDir:e,ref:p.lastUsed,profile:k,reloadProfile:Re})},"listProfileWorkflows");if(oe){let p=oe;Ye=(await import("./standalone-experiment-turn-owner-JCY5LL5R.js")).createStandaloneExperimentTurnOwner({store:g,createSession:Be,sendTurn:N.sendTurn,interruptSessionTurn:N.interruptSessionTurn,authorizeWorkspace:o(async(k,$)=>{if($.id!==p.workspace.id||ke($.ownerScope)!==ke(p.workspace.ownerScope)||k.sourcePackageHash!==p.workspace.metadata.experimentSourcePackageHash||k.harnessRelease.id!==p.release.harnessRelease.id||k.harnessRelease.contentHash!==p.release.harnessRelease.contentHash)throw new Error("Standalone Experiment source differs from this execution owner's admitted closure.")},"authorizeWorkspace")})}let er=nr(async()=>{let{createAppServerEvaluations:p}=await import("./app-server-evaluations-GJPFWIDA.js");return p({options:t,store:g,storeDir:e,explicitProfileRelease:P,externalDataset:Xt,isolatedProfileTools:he,selectedEvaluationProfile:mn,listProfileWorkflows:pn,createSessionWithAutoTitle:un,turnRunner:N,streamOpenPondHostedChatTurn:T,publishedExperimentSource:oe,standaloneExperimentOwner:Ye})}),xo=er.methods(["listProfileEvaluations","executeProfileEvaluationCase","executeExperimentCase","cancelExperimentCase","executeProfileEvaluationRun","prepareProfileEvaluationRun","runPreparedProfileEvaluation","runProfileEvaluationSuite","compareProfileEvaluationRuns","buildProfileEvaluationReport"]);Ne(()=>er.close());let tr=nr(async()=>{let{createAppServerHarnessServices:p}=await import("./app-server-harness-services-IH4G6POY.js");return p({store:g,storeDir:e,backgroundReview:u,harnessEvaluationEnabled:c,harnessEvaluationReviewStream:U,harnessTasksetReview:Eo})}),Co=tr.methods(["inspectHarness","reviewHarnessProposal","reviewHarness","acceptHarnessEvaluationReview","materializeHarnessEvaluationTaskset","runHarnessEvaluationBaseline","validateHarness","updateHarnessBackgroundReview","diffHarness","rollbackHarness","inspectRefiner","updateRefiner","activateRefiner","rollbackRefiner"]);Ne(()=>tr.close());let Ro=Un({ports:Xn({placement:"hosted_work",connectedAppProviders:a?void 0:[],featureOverrides:{harnessBackgroundReview:u,harnessProposalReview:u,harnessReview:c,harnessEvaluationReview:c,harnessEvaluationReviewAcceptance:c,harnessEvaluationTasksetMaterialization:c,harnessEvaluationBaseline:c,refinerProfiles:u,immutableRefinerAdmission:u},createSession:un,getSession:be,turnsForSession:o(p=>w.turnsForSession(p,1e3),"turnsForSession"),runtimeEventsForSession:o(p=>w.runtimeEventsForSession(p),"runtimeEventsForSession"),sendTurn:N.sendTurn,steerSessionTurn:N.steerSessionTurn,readTaskInbox:N.readTaskInbox,queueTaskInput:N.queueTaskInput,updateTaskInput:N.updateTaskInput,isSessionTurnActive:N.isSessionTurnActive,waitForSessionTurnSettlement:N.waitForSessionTurnSettlement,interruptSessionTurn:N.interruptSessionTurn,resolveApproval:bo,listProfileWorkflows:pn,loadProfileTrainingSource:o(async()=>{if(!t.profileSource||!P)throw new Error("An explicit published Profile is required for hosted training source export.");return(await import("./profile-training-source-6GOT7AHM.js")).profileTrainingSource({release:P,storeDir:e})},"loadProfileTrainingSource"),...xo,...Co,subscribeRuntimeEvents:Kt,observeRuntimeOperation:o(p=>{f.info("agent runtime operation",p)},"observeRuntimeOperation")}),close:o(async()=>{hn||(hn=!0,await an.close(),await Promise.all([er.close(),tr.close(),N.close()]),he?.close(),await Promise.all([Ze.drain(),ct.drain()]),await lt(),await g.close(),await f.flush())},"close")}),gn=Ll.filter(p=>(p!=="web_search"||!!s)&&(p!=="connected_apps"||!!a)&&(p!=="refiner"||u));return f.info("app-server ready",{storePath:g.storePath,workspaceDir:h,composition:gn}),{...Ro,storePath:g.storePath,workspaceDir:h,composition:gn}}o($l,"createOwnedAppServer");function Vl(t,e){return{id:t||Cn(e),name:ze.basename(e)||"Sandbox workspace",description:null,visibility:"private",gitOwner:null,gitRepo:null,gitHost:null,defaultBranch:null,sandbox:!1,updatedAt:H(),latestDeployment:null}}o(Vl,"workspaceApp");function Ul(t,e){return mt({sessionId:t.sessionId??void 0,turnId:t.turnId??void 0,name:"diagnostic",source:"server",status:"failed",output:e instanceof Error?e.message:"Failed to persist model usage record.",data:{kind:"model_usage_record_failed",requestId:t.requestId,provider:t.provider,model:t.model}})}o(Ul,"runtimeDiagnostic");async function ut(t,e,r){if(t!==!1)return t!==void 0?t:e?void 0:r()}o(ut,"selectService");export{us as a,Ji as b,Ic as c,Xi as d,to as e,oo as f,ao as g,uo as h,po as i,go as j,vo as k,Ll as l,af as m};
|
|
10
|
+
`)}o(Al,"titleRequestMessage");function So(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t.autoTitlePrompt;return typeof e=="string"&&e.trim()?e.trim():null}o(So,"autoTitlePromptFromPayload");function _l(t){let e=So(t);if(!e||!t||typeof t!="object"||Array.isArray(t))return t;let r=t,n=r.metadata&&typeof r.metadata=="object"&&!Array.isArray(r.metadata)?r.metadata:{};return{...r,title:"",metadata:{...n,titleSource:"pending",autoTitle:{prompt:e.slice(0,2e4),title:"",attempts:0,nextAttemptAt:0}}}}o(_l,"withPendingAutoTitle");function Jt(t){if(!t||!["pending","fallback"].includes(String(t.metadata?.titleSource)))return null;let e=t.metadata?.autoTitle;return e&&typeof e.prompt=="string"&&e.title===t.title&&Number.isInteger(e.attempts)&&e.attempts>=0&&Number.isFinite(e.nextAttemptAt)?e:null}o(Jt,"pendingTitle");function vo(t){let e=new Map,r=null,n=new AbortController,s=[5e3,3e4];async function i(u){let c=new AbortController,h=setTimeout(()=>c.abort(new Error("session_title_generation_timeout")),Cl);h.unref?.();let d="";try{for await(let f of t.stream({model:on,messages:[{role:"system",content:Rl},{role:"user",content:Al(u)}],reasoningEffort:xl,maxTokens:128,temperature:.2,requestId:`session-title-${Il()}`,signal:AbortSignal.any([c.signal,n.signal])}))f.type==="text_delta"&&f.text&&(d+=f.text);let m=Nl(d);if(!m)throw new Error("session_title_generation_empty_response");return m}finally{clearTimeout(h)}}o(i,"generate");async function a(u){for(;!n.signal.aborted;){let c=Jt(await t.store.getSession(u));if(!c||c.attempts>=3)return;let h=c.nextAttemptAt-Date.now();h>0&&await bl(h,void 0,{signal:n.signal,ref:!1});let d=Jt(await t.store.getSession(u));if(!d||d.attempts!==c.attempts)return;let m,f="model";try{m=await i(c.prompt)}catch(v){if(n.signal.aborted)return;m=Pl(c.prompt),f="fallback",t.logger.warn("session title generation used temporary title",{error:v instanceof Error?v.message:String(v),model:on,sessionId:u,attempt:c.attempts+1})}if(n.signal.aborted)return;let g=!1,w=await t.store.updateSession(u,v=>{let O=Jt(v);return!O||O.attempts!==c.attempts||O.prompt!==c.prompt?v:(g=!0,{...v,title:m,metadata:{...v.metadata,titleSource:f,autoTitle:f==="model"?null:{...c,title:m,attempts:c.attempts+1,nextAttemptAt:Date.now()+(s[c.attempts]??0)}}})});if(!g||!w||(await t.appendRuntimeEvent(mt({sessionId:u,name:"session.title.updated",source:"server",status:"completed",data:{session:w,model:on,titleSource:f}})),f==="model"))return}}o(a,"run");function l(u){if(n.signal.aborted)return Promise.resolve();let c=e.get(u);if(c)return c;let h=a(u).catch(d=>{n.signal.aborted||t.logger.warn("session title generation failed",{error:d instanceof Error?d.message:String(d),sessionId:u})}).finally(()=>e.delete(u));return e.set(u,h),h}return o(l,"schedule"),{wrapCreateSession(u){return this.recover().catch(c=>t.logger.warn("Session title recovery failed",{error:String(c)})),async c=>{let h=await u(_l(c));return So(c)&&l(h.id),h}},schedule:l,recover(){return r||(r=(async()=>{for(let u of await t.store.sessionShells()){if(n.signal.aborted)return;let c=await yo(t.store,u);Jt(c)&&l(u.id)}})().finally(()=>{r=null}),r)},async close(){n.abort(),await r?.catch(()=>{}),await Promise.allSettled(e.values())}}}o(vo,"createSessionTitleService");var Hl=3,Ll=["sqlite_store","runtime_event_bus","session_store","hosted_provider","web_search","connected_apps","workspace_tools","command_approvals","harness","refiner","agent_runtime","jsonl_transport"];async function af(t={}){if(t.runtimeStorage)return(await import("./hosted-app-server-composition-HPL3CRXN.js")).createHostedOwnedAppServer({...t,runtimeStorage:t.runtimeStorage});let e=ze.resolve(t.storeDir??sr());return $n(e,()=>$l({...t,storeDir:e}))}o(af,"createOpenPondAppServer");async function $l(t){let e=ze.resolve(t.storeDir??sr()),r=!!t.embedding;if(r&&!t.streamOpenPondHostedChatTurn)throw new Error("Embedded Work requires an explicit model-stream adapter.");let n=t.services??{},s=await ut(n.webSearch,r,async()=>(await import("./web-search-CZ3NCLPY.js")).createWebSearchExecutorFromEnv()),i=await ut(n.scheduling,r,async()=>(await import("./saved-work-6BMBFP43.js")).createHostedSavedWork),a=await ut(n.connectedApps,r,async()=>{let[p,k]=await Promise.all([import("./connected-app-executor-IVLGQP65.js"),import("./app-server-connected-apps-JHGWLBXT.js")]);return{execute:p.createCloudConnectedAppToolExecutor(),list:k.listAppServerIntegrationConnections}}),l=await ut(n.tasksets,r,async()=>(await import("./hosted-tasksets-ANAE2PIW.js")).executeHostedTasksetAction),u=n.backgroundReview??!r,c=!r&&!!l;await kn(e),u&&await(await import("./refiner-profile-service-UUIWFJVT.js")).initializeRefinerProfile(e);let h=ze.resolve(t.workspaceDir??process.cwd());await Fl(h,{recursive:!0});let d=t.version??_n,m=An(),f=qn({channel:"app-server",logDir:ze.join(e,"logs"),metadata:{version:d,runtimeVersion:m,placement:"hosted_work"}});Ne(()=>f.flush());let g=new Ln(e,{logger:f});Ne(()=>g.close()),await g.recentTurns(1);let w=g,v=o(async()=>(await Tn(e)).preferences,"loadRuntimePreferences"),O=Xi(e);(O.recovered||O.needsReview)&&f.warn("Scheduled work requires review after restart",O);let T=Qn(t.streamOpenPondHostedChatTurn??Nn,{enabled:Kn()}),U=to(T),{appendRuntimeEvent:b,closeEventSubscribers:lt,subscribeRuntimeEvents:Kt}=ts({logger:f,store:w}),Ze=ir({queueId:"turn-follow-up",logger:f}),ct=ir({queueId:"subagent",logger:f});if(t.harness&&t.profileSource)throw new Error("Configure either an explicit Harness source or Profile source for this app-server.");let P=null,oe,Ye;if(t.experimentHarnessSource){if(!t.experimentPolicyClient||t.profileSource||t.harness||t.runtimeStorage)throw new Error("A published standalone Experiment source requires its isolated policy owner and local case store.");let p=t.experimentHarnessSource.sourcePackage;oe=await(await import("./published-experiment-source-DZFENAQA.js")).installPublishedExperimentSource({store:g,storeDir:e,ownerId:t.experimentHarnessSource.ownerId,sourcePackage:p,reference:{harnessRelease:{id:p.harnessRelease.id,contentHash:p.harnessRelease.contentHash},agentSnapshot:{id:p.agentSnapshot.id,contentHash:p.agentSnapshot.contentHash},sourcePackageHash:p.contentHash},createdAt:H()})}if(t.profileSource){let p=t.profileSource;if(!p.repositoryId.trim()||!p.profileId.trim()||!p.sourceRevision.trim())throw new Error("Explicit Profile source requires an identity and accepted revision.");let k=await Mn({repoPath:p.repoPath,profileId:p.profileId});if(k.mode!=="local"||!k.sourcePath||k.error||k.git?.isRepo&&(k.git.head!==p.sourceRevision||k.git.dirty))throw new Error("Explicit Profile source does not match its accepted revision.");P=await jn({store:g,storeDir:e,workspaceId:`${zn}${ke({profileId:p.profileId,sourceRevision:p.sourceRevision}).slice(0,24)}`,ownerId:"desktop-personal",name:p.profileId,profile:k,sourceRevision:p.sourceRevision,repositoryId:p.repositoryId})}t.harness&&(await In({store:g,storeDir:e,sourceDir:t.harness.sourceDirectory,id:t.harness.workspaceId,name:t.harness.name,ownerId:"desktop-personal"}),await g.selectHarnessWorkspace({ownerKind:"personal",ownerId:"desktop-personal",workspaceId:t.harness.workspaceId,updatedAt:H()})),await bn({store:g,storeDir:e,loadProfileState:Re,now:H}).catch(p=>{f.warn("app-server Harness initialization failed",{error:p})});let dt=Jn({appendRuntimeEvent:b,findLocalProject:o(p=>rs(g,p),"findLocalProject"),onRepositoryInstructionDiagnostic:o((p,k)=>{f.warn("repository instruction file skipped",{diagnostic:p,sessionId:k.id})},"onRepositoryInstructionDiagnostic")}),{createSession:Be,getSession:be,updateSession:Qt,completeTurn:ko,failTurn:To,interruptTurn:Oo}=ss({store:w,defaultSessionCwd:o(()=>h,"defaultSessionCwd"),appendRuntimeEvent:b,loadAppPreferences:v,loadLastUsedProfile:o(async()=>(await Je()).lastUsed,"loadLastUsedProfile")}),an=vo({appendRuntimeEvent:b,store:w,logger:f,stream:T}),un=r?Be:an.wrapCreateSession(Be),ft=es({workspaceDir:h,logger:f,getSession:be,updateSession:Qt,appendRuntimeEvent:b,sandboxRequest:t.sandboxRequest??(r?async()=>{throw new Error("Sandbox execution is not configured in this app-server deployment.")}:void 0)}),Eo=c?await(await import("./local-harness-taskset-review-XVYTGAGK.js")).createLocalHarnessTasksetReviewControl({store:g,storeDir:e,evaluationRuntime:{streamOpenPondHostedChatTurn:T,workRuntime:{createSession:Be,getSession:be,executeWorkspaceTool:ft.executeWorkspaceTool,runtimeEventsForSession:o(p=>w.runtimeEventsForSession(p),"runtimeEventsForSession")},resolveReleasedHarness:o(async()=>{let p=await xn(g);return p?{agentSnapshot:p.release.agentSnapshot,harnessRelease:p.release.harnessRelease,instructionContext:p.instructionContext}:null},"resolveReleasedHarness")}}):void 0,ln=o(async p=>{await w.upsertApproval(p)},"upsertApproval"),cn=Wn({upsertApproval:ln,appendRuntimeEvent:b}),Mo=await ut(n.projectActions,r,async()=>(await import("./project-action-payload-7VGL7OER.js")).createProjectActionRunPayload({appendRuntimeEvent:b,resolveProjectRoot:o(async()=>null,"resolveProjectRoot")})),Do=o(async p=>{try{await w.upsertModelUsageRecord(p)}catch(k){await b(Ul(p,k)).catch(()=>{})}},"safeUpsertModelUsageRecord"),dn=u?(await import("./local-harness-improvement-runtime-JIQ6ZVDW.js")).createLocalHarnessImprovementRuntime({store:g,storeDir:e,queue:Ze,streamOpenPondHostedChatTurn:T,appendRuntimeEvent:b,upsertModelUsageRecord:Do}):void 0;await dn?.reconcilePending();let Xt=t.profileExternalDataset?await(P&&t.profileExternalDatasetClient?(await import("./host-profile-external-dataset-K3ICDHIP.js")).createHostProfileExternalDataset({value:t.profileExternalDataset,release:P,sourceRevision:t.profileSource.sourceRevision,client:t.profileExternalDatasetClient}):Promise.reject(new Error("External Dataset execution requires an explicit private Profile source owner."))):null,Io=Vn({deviceId:`evaluation-${ke(e).slice(0,24)}`,storeDir:e,runtimeEventsForSession:o(p=>w.runtimeEventsForSession(p),"runtimeEventsForSession")}),he=P?(await import("./host-profile-evaluation-tools-NRLXL2S5.js")).createHostProfileEvaluationTools({storeDir:e,release:P,getTurn:o(p=>w.getTurn(p),"getTurn"),getSession:be,saveOutput:Io.saveOwnedOutputBytes,recordOutput:o(async(p,k,$)=>{await b({id:Wl(),timestamp:new Date().toISOString(),name:"workspace_action_result",source:"server",sessionId:p,turnId:k,action:"work_output_save",status:"completed",output:`Saved ${$.outputRef.title} as immutable case output.`,data:$})},"recordOutput"),authorize:o(async p=>{if(Xt){await Xt.authorize(p);return}let k=await mn();if(!k||k.ref.profileId!==t.profileSource?.profileId||k.sourceRevision!==t.profileSource?.sourceRevision)throw new Error("The released evaluation source authority changed.");let $=await g.getHarnessReleaseRecord(P.harnessRelease.contentHash);if(!$||$.harnessRelease.contentHash!==P.harnessRelease.contentHash)throw new Error("The isolated evaluation release is unavailable.")},"authorize")}):null,fn=t.embedding?as(t.embedding,async(p,k)=>{let $=await w.getTurn(p);if(!$)throw new Error("Embedded turn is unavailable.");let xe=await be($.sessionId),Ge=xe.metadata?.embeddingToolBindings,Ce=[...k].sort((ht,Po)=>ht.name.localeCompare(Po.name));if(Ge!==void 0&&ke(Ge)!==ke(Ce))throw new Error("Embedded tool bindings changed; start a new thread.");await Qt(xe.id,{metadata:{...xe.metadata,embeddingToolBindings:Ce}}),await w.updateTurn(p,ht=>({...ht,metadata:{...ht.metadata,toolBindings:Ce}}))}):void 0,N=ns({executionHost:r?"embedded":"local",storageHome:e,workInputsForSession:t.workInputsForSession,finalizeWorkTurn:t.finalizeWorkTurn,isolatedProfileEvaluationForTurn:he?async p=>{if(p.metadata?.profileEvaluationRun===void 0)return!1;if(!he.ownsSession(p.id))throw new Error("A Profile evaluation target has no actual admitted case owner.");return!0}:void 0,executeProfileEvaluationAction:he?.executeAction,resolveModelTools:he?p=>he.ownsSession(p.session.id)?he.resolveTools(p):fn?.(p)??Promise.resolve([]):fn,...r?{hostedToolFlags:{toolMode:"native",nativeToolTransport:!0,nativeToolProviderDenylist:[],textToolFallback:!1}}:{},attachmentRootDir:ze.join(e,"attachments"),store:w,inboxStore:g,createSession:Be,upsertApproval:ln,getSession:be,updateSession:Qt,completeTurn:ko,failTurn:To,interruptTurn:Oo,defaultSessionCwd:o(()=>h,"defaultSessionCwd"),findOpenPondApp:o(async p=>Vl(p,h),"findOpenPondApp"),resolveSessionWorkspaceCwd:o(async p=>p.cwd?.trim()||h,"resolveSessionWorkspaceCwd"),ensureCodexRuntime:o(async()=>{throw new Error("The hosted app-server placement uses the OpenPond provider; Codex process hosting is not configured.")},"ensureCodexRuntime"),appendWorkspaceDiffEvent:ft.appendWorkspaceDiffEvent,workspaceDiffBaseline:ft.workspaceDiffBaseline,appendRuntimeEvent:b,processHarnessImprovementBoundary:dn,executeWorkspaceTool:ft.executeWorkspaceTool,executeOpenPondCommand:cn.executeCommand,executeProjectAction:Mo,executeDatasetBuilderAction:l,loadOpenPondProfileState:Re,...go(),...r||n.profileActions===!1?{executeProfileSkillCommand:void 0}:{},loadOpenPondProfileLibrary:Je,readOpenPondProfileSkill:En,loadSelectedHarnessRuntime:o(p=>Bn(g,p),"loadSelectedHarnessRuntime"),ensureHarnessRunOverlay:o(p=>Hn({store:g,...p}),"ensureHarnessRunOverlay"),harnessModelTools:po({store:g,storeDir:e}).filter(p=>u||!["refiner_profile_inspect","refiner_profile_update","refine_request","refine_status"].includes(p.name)),loadBuiltInOpenPondSkills:o(async()=>[await is(),...await ao()],"loadBuiltInOpenPondSkills"),readBuiltInOpenPondSkill:o(async p=>{if(p==="openpond-taskset-authoring")return os();if(oo(p))return uo(p);throw new Error(`Built-in OpenPond skill not found: ${p}`)},"readBuiltInOpenPondSkill"),executeWebSearch:s,createScheduledWork:i,executeConnectedAppTool:a?.execute,listIntegrationConnections:a?.list,loadPersonalizationSoul:o(async()=>(await Gn(g,e)).soul,"loadPersonalizationSoul"),loadAppPreferences:v,maybeCreateScaffoldForTurn:dt.maybeCreateScaffoldForTurn,hostedSystemPrompt:dt.hostedSystemPrompt,appendAssistantText:dt.appendAssistantText,appendHostedContextUsage:dt.appendHostedContextUsage,streamOpenPondHostedChatTurn:T,turnFollowUpQueue:Ze,resolveSessionModelStream:us(async(p,k)=>await Ye?.resolveSessionModelStream(p,k)??await t.resolveSessionModelStream?.(p,k)??null),subagentQueue:ct,maxHostedWorkspaceToolRounds:t.experimentHarnessSource?(await import("./experiments-VFQGE4HC.js")).STANDALONE_EXPERIMENT_MAX_POLICY_CALLS:Fn(t.maxHostedWorkspaceToolRounds),maxRepeatedInvalidToolRequests:Hl});Ne(()=>N.close()),await N.recoverPendingSubagentCompletions(),await N.recoverTaskInbox();async function bo(p,k){let $=await N.resolveNativeAgentApproval(p,k);if($)return $;let xe=await cn.resolveApproval(p,k);if(xe)return xe;let Ge=await N.resolveCreateImproveApproval(p,k);if(Ge)return Ge;let Ce=await N.resolveSubagentPatchApplyApproval(p,k);if(Ce)return Ce;throw new Error(`Approval not found: ${p}`)}o(bo,"resolveApproval");let hn=!1,mn=o(async()=>{if(t.profileSource)return{ref:{source:"openpond_git",repositoryId:t.profileSource.repositoryId,profileId:t.profileSource.profileId},sourceRevision:t.profileSource.sourceRevision};let[p,k]=await Promise.all([Je(),Re()]);return p.lastUsed&&k.git?.head&&!k.git.dirty?{ref:p.lastUsed,sourceRevision:k.git.head}:null},"selectedEvaluationProfile"),pn=o(async()=>{if(t.profileSource&&P)return Yn({store:g,release:P,ref:{source:"openpond_git",repositoryId:t.profileSource.repositoryId,profileId:t.profileSource.profileId},sourceRevision:t.profileSource.sourceRevision});let[p,k]=await Promise.all([Je(),Re()]);if(!p.lastUsed)throw new Error("Select a Profile before loading its workflows.");return Zn({store:g,storeDir:e,ref:p.lastUsed,profile:k,reloadProfile:Re})},"listProfileWorkflows");if(oe){let p=oe;Ye=(await import("./standalone-experiment-turn-owner-JCY5LL5R.js")).createStandaloneExperimentTurnOwner({store:g,createSession:Be,sendTurn:N.sendTurn,interruptSessionTurn:N.interruptSessionTurn,authorizeWorkspace:o(async(k,$)=>{if($.id!==p.workspace.id||ke($.ownerScope)!==ke(p.workspace.ownerScope)||k.sourcePackageHash!==p.workspace.metadata.experimentSourcePackageHash||k.harnessRelease.id!==p.release.harnessRelease.id||k.harnessRelease.contentHash!==p.release.harnessRelease.contentHash)throw new Error("Standalone Experiment source differs from this execution owner's admitted closure.")},"authorizeWorkspace")})}let er=nr(async()=>{let{createAppServerEvaluations:p}=await import("./app-server-evaluations-GJPFWIDA.js");return p({options:t,store:g,storeDir:e,explicitProfileRelease:P,externalDataset:Xt,isolatedProfileTools:he,selectedEvaluationProfile:mn,listProfileWorkflows:pn,createSessionWithAutoTitle:un,turnRunner:N,streamOpenPondHostedChatTurn:T,publishedExperimentSource:oe,standaloneExperimentOwner:Ye})}),xo=er.methods(["listProfileEvaluations","executeProfileEvaluationCase","executeExperimentCase","cancelExperimentCase","executeProfileEvaluationRun","prepareProfileEvaluationRun","runPreparedProfileEvaluation","runProfileEvaluationSuite","compareProfileEvaluationRuns","buildProfileEvaluationReport"]);Ne(()=>er.close());let tr=nr(async()=>{let{createAppServerHarnessServices:p}=await import("./app-server-harness-services-IH4G6POY.js");return p({store:g,storeDir:e,backgroundReview:u,harnessEvaluationEnabled:c,harnessEvaluationReviewStream:U,harnessTasksetReview:Eo})}),Co=tr.methods(["inspectHarness","reviewHarnessProposal","reviewHarness","acceptHarnessEvaluationReview","materializeHarnessEvaluationTaskset","runHarnessEvaluationBaseline","validateHarness","updateHarnessBackgroundReview","diffHarness","rollbackHarness","inspectRefiner","updateRefiner","activateRefiner","rollbackRefiner"]);Ne(()=>tr.close());let Ro=Un({ports:Xn({placement:"hosted_work",connectedAppProviders:a?void 0:[],featureOverrides:{harnessBackgroundReview:u,harnessProposalReview:u,harnessReview:c,harnessEvaluationReview:c,harnessEvaluationReviewAcceptance:c,harnessEvaluationTasksetMaterialization:c,harnessEvaluationBaseline:c,refinerProfiles:u,immutableRefinerAdmission:u},createSession:un,getSession:be,turnsForSession:o(p=>w.turnsForSession(p,1e3),"turnsForSession"),runtimeEventsForSession:o(p=>w.runtimeEventsForSession(p),"runtimeEventsForSession"),sendTurn:N.sendTurn,steerSessionTurn:N.steerSessionTurn,readTaskInbox:N.readTaskInbox,queueTaskInput:N.queueTaskInput,updateTaskInput:N.updateTaskInput,isSessionTurnActive:N.isSessionTurnActive,waitForSessionTurnSettlement:N.waitForSessionTurnSettlement,interruptSessionTurn:N.interruptSessionTurn,resolveApproval:bo,listProfileWorkflows:pn,loadProfileTrainingSource:o(async()=>{if(!t.profileSource||!P)throw new Error("An explicit published Profile is required for hosted training source export.");return(await import("./profile-training-source-6GOT7AHM.js")).profileTrainingSource({release:P,storeDir:e})},"loadProfileTrainingSource"),...xo,...Co,subscribeRuntimeEvents:Kt,observeRuntimeOperation:o(p=>{f.info("agent runtime operation",p)},"observeRuntimeOperation")}),close:o(async()=>{hn||(hn=!0,await an.close(),await Promise.all([er.close(),tr.close(),N.close()]),he?.close(),await Promise.all([Ze.drain(),ct.drain()]),await lt(),await g.close(),await f.flush())},"close")}),gn=Ll.filter(p=>(p!=="web_search"||!!s)&&(p!=="connected_apps"||!!a)&&(p!=="refiner"||u));return f.info("app-server ready",{storePath:g.storePath,workspaceDir:h,composition:gn}),{...Ro,storePath:g.storePath,workspaceDir:h,composition:gn}}o($l,"createOwnedAppServer");function Vl(t,e){return{id:t||Cn(e),name:ze.basename(e)||"Sandbox workspace",description:null,visibility:"private",gitOwner:null,gitRepo:null,gitHost:null,defaultBranch:null,sandbox:!1,updatedAt:H(),latestDeployment:null}}o(Vl,"workspaceApp");function Ul(t,e){return mt({sessionId:t.sessionId??void 0,turnId:t.turnId??void 0,name:"diagnostic",source:"server",status:"failed",output:e instanceof Error?e.message:"Failed to persist model usage record.",data:{kind:"model_usage_record_failed",requestId:t.requestId,provider:t.provider,model:t.model}})}o(Ul,"runtimeDiagnostic");async function ut(t,e,r){if(t!==!1)return t!==void 0?t:e?void 0:r()}o(ut,"selectService");export{us as a,Ji as b,Ic as c,Xi as d,to as e,oo as f,ao as g,uo as h,po as i,go as j,vo as k,Ll as l,af as m};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
+
import{b as a}from"./chunk-6FDWRG55.js";import"./chunk-PF5R6CMP.js";import"./chunk-FEAKTSRS.js";import"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import"./chunk-N4FFQPLR.js";import"./chunk-AY64VY4E.js";import"./chunk-GJ2ZJFDD.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-YBT2NB32.js";import"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import"./chunk-KGNCKIFP.js";import"./chunk-ES2ISFJC.js";import"./chunk-FTQLQJQV.js";export{a as createHostProfileEvaluationTools};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{c as wt,d as vt,e as yt}from"./chunk-QHWGQ3A4.js";import{b as gt,c as re,e as Rt}from"./chunk-SH5CBAFC.js";import{a as pt,b as ft}from"./chunk-UHFZHBGW.js";import"./chunk-PF5R6CMP.js";import{b as ht}from"./chunk-DMVD2RFZ.js";import{a as ee,b as O,c as te}from"./chunk-JYKRR7E5.js";import{a as St}from"./chunk-OIUTWU6K.js";import"./chunk-X4OSOOSU.js";import"./chunk-3K4VVB7S.js";import{b as De,c as Me,d as ze,f as Ne,h as $e}from"./chunk-3Z47M3YY.js";import{b as je}from"./chunk-ABD5M2D2.js";import"./chunk-TRQQNFMO.js";import"./chunk-FEAKTSRS.js";import"./chunk-OSIO7PLX.js";import"./chunk-F74GBN6K.js";import"./chunk-SDAUS5PY.js";import"./chunk-I2NXNMRZ.js";import"./chunk-O72BSKSO.js";import{a as Je,b as Ze}from"./chunk-OPNRWESL.js";import{b as Ke,c as Qe}from"./chunk-2QUCCP6Z.js";import{a as Y}from"./chunk-O6ULLQJ6.js";import"./chunk-FY5KHLMW.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-DBK66CJP.js";import{d as tt,e as st,ga as ct,ha as dt,ia as mt,j as ot,k as it,v as lt,w as X,y as ut}from"./chunk-OGDADQGH.js";import{a as rt}from"./chunk-4NESNOK5.js";import"./chunk-BLXEAZCQ.js";import"./chunk-UCPGRPWY.js";import{b as et}from"./chunk-HDL5YSAA.js";import"./chunk-ZFSHBFG5.js";import"./chunk-AN525SPP.js";import"./chunk-SYUKES6H.js";import"./chunk-HIOKCIL7.js";import{a as at,b as nt}from"./chunk-GW766ZSO.js";import{p as Ye}from"./chunk-UKMA4R6X.js";import"./chunk-OQKJGTTO.js";import"./chunk-KVTBX2UP.js";import"./chunk-IZ6DLEVY.js";import"./chunk-A6USMRWK.js";import"./chunk-PCSIOUHF.js";import"./chunk-7KWD2I6W.js";import"./chunk-GPVCOEUH.js";import"./chunk-N73MU2C3.js";import"./chunk-ZGTOK7ZK.js";import"./chunk-XW6HGSIT.js";import{b as Xe}from"./chunk-KG325WTN.js";import"./chunk-3RCRSMWZ.js";import"./chunk-DMFUEUAZ.js";import"./chunk-PSGGOZFM.js";import"./chunk-FUOEIDMA.js";import"./chunk-NHQ36THU.js";import{F as qe,I as h,K as z,L as Be}from"./chunk-VRIEKBBH.js";import{g as Oe,m as _e}from"./chunk-QNG27G3T.js";import"./chunk-EIRYMSEG.js";import{a as ge,j as We,k as Ve,t as Ge}from"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import{a as Fe,o as F,p as Ue,q as U,v as Le,y as Z}from"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import{a as he}from"./chunk-RNIAFXMB.js";import{a as fe}from"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import{b as Te}from"./chunk-N4FFQPLR.js";import{a as Ie,c as ke}from"./chunk-AY64VY4E.js";import{a as ce,h as be}from"./chunk-GJ2ZJFDD.js";import"./chunk-BFKYRQMA.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-QDC4OW3S.js";import"./chunk-ZZWAQBA2.js";import"./chunk-YR5ID2SS.js";import"./chunk-YBT2NB32.js";import{c as xe}from"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import{V as pe,X as Ce}from"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import{Hb as Q,Ob as J,f as me,m as Ae}from"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import{w as de}from"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import{l as q,m as g,n as M}from"./chunk-KGNCKIFP.js";import{b as n}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as r}from"./chunk-FTQLQJQV.js";import{randomUUID as Vt}from"node:crypto";import{promises as _}from"node:fs";import I from"node:path";function Pt(l){let e=new Map,t=new Map;async function o(s,d){let m=(t.get(s)??Promise.resolve()).catch(()=>{}).then(d);t.set(s,m);try{return await m}finally{t.get(s)===m&&t.delete(s)}}r(o,"serial");let a=r((s,d=18e4)=>l.request(z.parse({contractVersion:h,requestId:Vt(),operation:"profile-evaluations/sandbox",params:s}),d),"request");async function c(s,d,m,f){let y=q(f),v=`${d}/${m}/${y}`,b=e.get(s.sessionId)??new Set;if(!b.has(v)){if(f.length>1e7)throw new Error("The public case file exceeds its admitted bound.");for(let R=0;R===0||R<f.length;R+=98304)s.signal.throwIfAborted(),await a({sessionId:s.sessionId,turnId:s.turnId,action:"upload",area:d,path:m,sha256:y,sizeBytes:f.length,offset:R,contentsBase64:f.subarray(R,R+98304).toString("base64")},3e5);b.add(v),e.set(s.sessionId,b)}}r(c,"upload");async function u(s,d=""){let m=[];for(let f of await _.readdir(I.join(s,d),{withFileTypes:!0})){let y=I.posix.join(d,f.name);if(f.isSymbolicLink()){let v=await _.realpath(I.join(s,y));if(!v.startsWith(`${await _.realpath(s)}${I.sep}`)||(await _.stat(v)).isDirectory())throw new Error("The public Agent runtime symlink escapes its file closure.");m.push(y);continue}if(f.isDirectory()?m.push(...await u(s,y)):f.isFile()&&m.push(y),m.length>8192)throw new Error("The public Agent runtime exceeds the file limit.")}return m}return r(u,"runtimeFiles"),{execute:r(s=>o(s.sessionId,async()=>{s.signal.throwIfAborted();for(let[f,y]of Object.entries(s.publicHashes)){let v=await _.realpath(I.join(s.sourceRoot,f)),b=await _.realpath(s.sourceRoot);if(!v.startsWith(`${b}${I.sep}`))throw new Error("The public case file escaped its source root.");let R=await _.readFile(v);if(q(R)!==y)throw new Error("The public case file changed before upload.");await c(s,"policy",f,R)}if(s.runtimeRoot)for(let f of await u(s.runtimeRoot))await c(s,"runtime",f,await _.readFile(I.join(s.runtimeRoot,f)));let d=I.relative(s.sourceRoot,s.cwd??s.sourceRoot);if(d.startsWith("..")||I.isAbsolute(d))throw new Error("The command cwd escaped the admitted case.");let m=n.object({code:n.number().int().nullable(),stdout:n.string().max(75e4),stderr:n.string().max(75e4),timedOut:n.boolean(),stdoutTruncated:n.boolean(),stderrTruncated:n.boolean()}).parse(await a({sessionId:s.sessionId,turnId:s.turnId,action:"exec",command:s.command,stdin:s.stdin,cwd:d.split(I.sep).join("/"),timeoutMs:s.timeoutMs},s.timeoutMs+15e3));return s.signal.throwIfAborted(),m}),"execute"),readOutput:r(s=>o(s.sessionId,async()=>{let d=pt(s.path),m=[],f=null,y=null;for(let b=0;f===null||b<f;b+=98304){s.signal.throwIfAborted();let R=n.object({sizeBytes:n.number().int().min(1).max(1e7),sha256:n.string().regex(/^[a-f0-9]{64}$/),contentsBase64:n.string().max(131072)}).parse(await a({sessionId:s.sessionId,turnId:s.turnId,action:"read",path:d,offset:b},6e4));f??=R.sizeBytes,y??=R.sha256;let p=Buffer.from(R.contentsBase64,"base64");if(R.sizeBytes!==f||R.sha256!==y||p.length!==Math.min(98304,f-b)||p.toString("base64")!==R.contentsBase64)throw new Error("The confined output changed during readback.");m.push(p)}let v=Buffer.concat(m);if(q(v)!==y)throw new Error("The confined output differs from its saved byte identity.");return s.signal.throwIfAborted(),{bytes:v,title:d.split("/").at(-1)}}),"readOutput"),settle:r((s,d)=>o(s,async()=>{try{await a({sessionId:s,turnId:d,action:"stop"},6e4)}finally{e.delete(s)}}),"settle")}}r(Pt,"createHostedProfileCommandOwner");import{randomUUID as Lt}from"node:crypto";var j=98304;function Ht(l){let e=r((t,o)=>l.request(z.parse({contractVersion:h,requestId:Lt(),operation:t,params:o})),"request");return{persistence:{sourceTurnStartedAt:r(async()=>{throw new Error("The case owner must supply its actual turn start time.")},"sourceTurnStartedAt"),saveSandboxFile:r(async()=>{throw new Error("Isolated Profile outputs must be read by the confined case owner.")},"saveSandboxFile"),save:r(async({sessionId:t,turnId:o,identity:a,bytes:c})=>{let u=n.object({uploadId:n.string().min(1),maxChunkBytes:n.literal(j)}).parse(await e("output/begin",{sessionId:t,turnId:o,output:a}));for(let d=0;d<c.length;d+=j){let m=c.subarray(d,d+j);await e("output/chunk",{uploadId:u.uploadId,index:d/j,offset:d,sha256:q(m),contentsBase64:m.toString("base64")})}let{outputRef:s}=n.object({outputRef:Ge}).parse(await e("output/complete",{uploadId:u.uploadId}));if(s.location.kind!=="managed"||s.sha256!==a.sha256||s.sizeBytes!==c.length||s.sourceTaskId!==t||s.sourceTurnId!==o||s.id!==a.id||s.revision!==a.revision)throw new Error("The durable case output differs from its saved identity.");return{outputRef:s,artifact:{artifactRef:s.location.fileId,path:s.location.downloadPath,title:s.title,contentType:s.contentType,sizeBytes:s.sizeBytes}}},"save")},read:r(async(t,o)=>{if(t.location.kind!=="managed"||t.sizeBytes>1e7)throw new Error("Select a bounded managed case output.");let a=[];for(let u=0;u<t.sizeBytes;u+=j){o?.throwIfAborted();let s=n.object({offset:n.number().int(),contentsBase64:n.string().max(131072),sha256:n.string(),sizeBytes:n.number().int()}).parse(await e("output/readBytes",{sessionId:t.sourceTaskId,turnId:t.sourceTurnId,fileId:t.location.fileId,revision:t.revision,sha256:t.sha256,sizeBytes:t.sizeBytes,offset:u})),d=Buffer.from(s.contentsBase64,"base64");if(s.offset!==u||s.sha256!==t.sha256||s.sizeBytes!==t.sizeBytes||d.length!==Math.min(j,t.sizeBytes-u)||d.toString("base64")!==s.contentsBase64)throw new Error("The durable workbook byte range changed.");a.push(d)}o?.throwIfAborted();let c=Buffer.concat(a);if(q(c)!==t.sha256)throw new Error("The durable workbook differs from its sealed hash.");return c},"read")}}r(Ht,"createHostedProfileArtifactOwner");import{randomUUID as Gt}from"node:crypto";var $t=n.object({createdAt:n.string().datetime(),id:n.string().min(1)}).strict(),Kt=n.object({entries:n.array(n.unknown()).max(100),nextBefore:$t.nullable()}).strict(),se=class{constructor(e){this.client=e}client;static{r(this,"HostedProfileEvaluationStorage")}execute(e){return this.client.request({contractVersion:h,requestId:Gt(),operation:"profile-evaluations/execute",params:e})}async get(e,t,o){let a=await this.execute({action:"get",kind:e,id:t});if(a===null)return null;let c=o.parse(a);return M(c,`Hosted Profile evaluation ${e}`),c}async put(e,t,o,a,c){let u=o.parse(t);M(u,`Hosted Profile evaluation ${e}`);let s=o.parse(await this.execute({action:"put",kind:e,payload:u,profileKey:a,createdAt:c}));if(s.contentHash!==u.contentHash||g(s)!==g(u))throw new Error("Hosted Profile evaluation write returned different evidence.");return s}async page(e,t,o){let a=[],c=null;do{let u=Kt.parse(await this.execute({action:"page",kind:e,profileKey:g(F.parse(t)),before:c,limit:100}));if(u.nextBefore&&(u.entries.length===0||c&&(u.nextBefore.createdAt>c.createdAt||u.nextBefore.createdAt===c.createdAt&&u.nextBefore.id>=c.id)))throw new Error("Hosted Profile evaluation cursor did not advance.");for(let s of u.entries){let d=o.parse(s);M(d,`Hosted Profile evaluation ${e}`),a.push(d)}if(a.length>1e4)throw new Error("Hosted Profile evaluation history exceeds the bounded catalog limit.");c=u.nextBefore}while(c);return a}getProfileEvaluationGrade(e){return this.get("grade",e,de)}saveProfileEvaluationGrade(e){return this.put("grade",e,de,null,new Date().toISOString())}getProfileEvaluationReceipt(e){return this.get("receipt",e,me)}saveProfileEvaluationReceipt(e){if(!Ae(e))throw new Error("Hosted Profile evaluation receipt is invalid.");return this.put("receipt",e,me,null,e.completedAt)}getProfileEvaluationRun(e){return this.get("run",e,Y)}saveProfileEvaluationRun(e){return this.put("run",e,Y,g(F.parse(e.profileRef)),e.completedAt)}listProfileEvaluationRuns(e){return this.page("run",e,Y)}getProfileEvaluationComparison(e){return this.get("comparison",e,Q)}saveProfileEvaluationComparison(e,t){return this.put("comparison",t,Q,g(F.parse(e)),t.createdAt)}listProfileEvaluationComparisons(e){return this.page("comparison",e,Q)}getProfileEvaluationSuiteRun(e){return this.get("suite",e,J)}saveProfileEvaluationSuiteRun(e,t,o){if(g(t)!==o.catalogHash)throw new Error("Hosted Profile evaluation suite differs from its catalog.");return this.put("suite",o,J,g(F.parse(e)),o.createdAt)}listProfileEvaluationSuiteRuns(e){return this.page("suite",e,J)}};async function Et(l){let e=l.release;if(!e.hostExecution)throw new Error("Hosted evaluation requires explicit host execution attribution.");let t={hostConversationId:e.hostExecution.conversationId,hostTurnId:e.hostExecution.turnId},o={source:"openpond_git",profileId:e.profileId,repositoryId:e.repositoryId},a=r(async()=>({ref:o,sourceRevision:e.sourceRevision}),"selectedProfile"),c=r(()=>re(l.client,e),"selectedWorkflows"),u=new se(l.client),s=r(async p=>{if(g(p)!==g(e.harnessRelease))throw new Error("Evaluation requires the admitted Profile release.");let S=await O(l.client,p);if(!S)throw new Error("Admitted evaluation Profile is unavailable.");return S},"loadRuntime"),d=r(async p=>{if(g(p.ref)!==g(o)||p.sourceRevision!==e.sourceRevision)throw new Error("Evaluation requires the admitted Profile source.");return je({...p,runtime:await s(p.harnessRelease)})},"loadCatalog"),m=l.externalDataset?await ht({value:l.externalDataset,release:(await s(e.harnessRelease)).release,sourceRevision:e.sourceRevision,client:l.client}):null,f=r(async(p,S,x)=>{if(S!==e.profileId)throw new Error("Evaluation Taskset Profile differs from its admitted source.");let E=await Ne({definition:p,harnessRelease:x,runtime:await s(x)});if(!E)throw new Error("Evaluation Taskset is absent from the admitted Profile release.");return E},"loadTasksetPackage"),y=wt({resolveExternalDataset:m?.resolveExternalDataset,store:{runtimeEventsForTurn:r(p=>l.core.runtimeEventsForTurn(p),"runtimeEventsForTurn")},storeDir:l.storeDir,readManagedArtifact:l.readManagedArtifact,admitSession:l.admitSession,settleSession:l.settleSession,loadCatalog:d,loadTasksetPackage:f,selectedProfile:a,createSession:r(p=>{let S=Le.parse(p);return l.createSession({...S,metadata:{...S.metadata,...t}})},"createSession"),sendTurn:r((p,S)=>{let x=Z.parse(S);return l.sendTurn(p,{...x,metadata:{...x.metadata,...t}})},"sendTurn"),interruptSessionTurn:l.interruptSessionTurn}),v=$e({resolveExternalDataset:m?.resolveExternalDataset,sourceCandidate:m?.sourceCandidate,privateGradingPreflight:r(p=>Me(p,!1),"privateGradingPreflight"),loadCatalog:d,selectedWorkflows:c,loadTasksetPackage:f,placement:"remote",boundedWorkComputeAvailable:!0,modelConfigurationHash:r(async(p,S)=>{if(p.providerId!=="openpond"||!S.hostModelConfigurationHash)throw new Error("Hosted evaluation requires a host-admitted model configuration receipt.");return S.hostModelConfigurationHash},"modelConfigurationHash")}),b=vt({resolveExternalDataset:m?.resolveExternalDataset,store:u,loadCatalog:d,loadTasksetPackage:f,selectedProfile:a,executeCase:y,privateGrading:r((p,S,x)=>ze({manifest:p,packageValue:S,signal:x,executeSandboxVerifier:De(l.client),authorize:r(async()=>{let E=p.profileEvaluation;if(!E||E.profileId!==e.profileId||E.sourceRevision!==e.sourceRevision)throw new Error("The hosted private grading source changed.");if(E.externalDatasetBinding){if(!m)throw new Error("The frozen Dataset owner is unavailable.");await m.authorize({bindingHash:E.externalDatasetBinding.contentHash,manifestHash:p.contentHash})}let B=await d({ref:o,sourceRevision:e.sourceRevision,harnessRelease:E.harnessRelease});if(!E.externalDatasetBinding&&B.catalogHash!==E.catalogHash)throw new Error("The hosted private grading catalog changed.")},"authorize")}),"privateGrading")}),R={getProfileEvaluationRun:u.getProfileEvaluationRun.bind(u),getProfileEvaluationReceipt:u.getProfileEvaluationReceipt.bind(u),getProfileEvaluationGrade:u.getProfileEvaluationGrade.bind(u),getSession:l.core.getSession.bind(l.core),getTurn:l.core.getTurn.bind(l.core),runtimeEventsForTurn:l.core.runtimeEventsForTurn.bind(l.core),listModelUsageRecords:l.core.listModelUsageRecords.bind(l.core)};return{prepareProfileEvaluationRun:v,executeProfileEvaluationCase:y,executeProfileEvaluationRun:b,runPreparedProfileEvaluation:r(async p=>b(await v(p,{requireExpectedManifestHash:!0})),"runPreparedProfileEvaluation"),runProfileEvaluationSuite:yt({store:u,loadCatalog:d,selectedWorkflows:c,prepareRun:v,executeRun:b}),compareProfileEvaluationRuns:Je({store:u,selectedProfile:a}),buildProfileEvaluationReport:r(p=>Ze({store:u,profileRef:o,request:p}),"buildProfileEvaluationReport"),listProfileEvaluations:r(async p=>{if(p&&typeof p=="object"&&"runId"in p)return Qe({store:R,profileRef:o,...Ke.parse(p)});let[S,x,E,B]=await Promise.all([d({ref:o,sourceRevision:e.sourceRevision,harnessRelease:e.harnessRelease}),u.listProfileEvaluationRuns(o),u.listProfileEvaluationComparisons(o),u.listProfileEvaluationSuiteRuns(o)]);return{...S,runs:x,comparisons:E,suiteRuns:B}},"listProfileEvaluations")}}r(Et,"createHostedProfileEvaluationRuntime");import{mkdir as lr}from"node:fs/promises";import{randomUUID as Dt}from"node:crypto";import W from"node:path";import{randomUUID as bt}from"node:crypto";var Qt=n.object({revision:n.number().int().nonnegative(),payload:n.record(n.string(),n.unknown()).nullable()}).strict(),Jt=n.object({entries:n.array(n.unknown()).max(100),nextAfterId:n.string().min(1).nullable()}).strict(),oe=class{constructor(e){this.client=e}client;static{r(this,"HostedHarnessStateStorage")}async getPreference(e,t){return Qt.parse(await this.client.request({contractVersion:h,requestId:bt(),operation:"harness/state/read",params:{workspaceId:e,kind:t,afterId:null,limit:1}}))}async listCandidates(e){return(await this.readAll(e,"candidates")).map(t=>Ie.parse(t))}async listCrossRunRequests(e){return(await this.readAll(e,"cross_run_requests")).map(t=>ke.parse(t))}async readAll(e,t){let o=[],a=null;do{let c=Jt.parse(await this.client.request({contractVersion:h,requestId:bt(),operation:"harness/state/read",params:{workspaceId:e,kind:t,afterId:a,limit:Math.min(100,1001-o.length)}}));if(c.nextAfterId&&(c.entries.length===0||c.nextAfterId===a))throw new Error("Hosted Harness state cursor did not advance.");if(o.push(...c.entries),o.length>1e3)throw new Error("Hosted Harness state exceeds 1,000 entries.");a=c.nextAfterId}while(a);return o}};import{randomUUID as Zt}from"node:crypto";import{cp as Yt,mkdir as Xt,rm as er}from"node:fs/promises";import tr from"node:path";var we=n.object({schemaVersion:n.literal("openpond.harnessMemoryEntry.v1"),id:n.string(),workspaceId:n.string(),key:n.string(),content:n.string(),tags:n.array(n.string()),revision:n.number().int().positive(),status:n.enum(["active","deleted"]),sourceRunId:n.string().nullable(),sourceProposal:n.object({id:n.string(),contentHash:n.string()}).nullable(),createdAt:n.string().datetime(),updatedAt:n.string().datetime(),contentHash:n.string().regex(/^[a-f0-9]{64}$/)}).strict(),rr=n.object({createdAt:n.string().datetime(),id:n.string()}).strict(),Tt=n.object({entries:n.array(n.unknown()).max(100),nextBefore:rr.nullable()}).strict(),ve=n.object({workspace:ce,receipt:be}).strict(),ae=class{constructor(e,t){this.client=e;this.storeDir=t;this.usage=new Rt(e),this.overlay=new ee({request:r(async o=>o.operation==="harness/overlay/get"?this.request({action:"overlay_get",...o.params}):o.operation==="harness/overlay/freezeProposal"?this.request({action:"overlay_freeze",...o.params},o.requestId):e.request(o),"request")})}client;storeDir;static{r(this,"HostedHarnessReviewStorage")}harnessStoragePlacement="hosted";reviewSessionId=null;overlay;usage;request(e,t=Zt()){return this.client.request({contractVersion:h,requestId:t,operation:"harness/review/execute",params:e},e.action==="release_put"?6e4:15e3)}sessionId(){if(!this.reviewSessionId)throw new Error("Hosted review memory requires an admitted review session.");return this.reviewSessionId}async prepareReview(e){let t=await this.getSession(e.runRef);if(!t)throw new Error("Hosted review session is unavailable.");this.reviewSessionId=t.id;let o=await this.getHarnessRunOverlay(t.id);if(!o)throw new Error("Hosted review overlay is unavailable.");let a=await this.getHarnessWorkspace(o.workspace.workspaceId);if(!a?.currentChannel.release)throw new Error("Hosted review workspace release is unavailable.");let c=await this.getHarnessReleaseRecord(a.currentChannel.release.contentHash);if(!c||c.sourceRevision!==a.sourceRevision)throw new Error("Hosted review source binding changed.");let u=Oe(this.storeDir,a.id);await Xt(u.root,{recursive:!0,mode:448}),await er(u.source,{recursive:!0,force:!0}),await Yt(tr.join(c.bundlePath,"source"),u.source,{recursive:!0,force:!1,errorOnExist:!0});let s=await _e({workspaceId:a.id,sourceDir:u.source});if(s.sourceRevision!==a.sourceRevision||s.harnessRelease.contentHash!==c.harnessRelease.contentHash)throw new Error("Hosted review source cache differs from its immutable release.")}getHarnessWorkspace=r(async e=>ce.nullable().parse(await this.request({action:"workspace_get",workspaceId:e})),"getHarnessWorkspace");getHarnessReleaseRecord=r(async e=>fe.nullable().parse(await this.request({action:"release_get",contentHash:e})),"getHarnessReleaseRecord");saveHarnessReleaseRecord=r(async e=>fe.parse(await this.request({action:"release_put",record:e},`review-release:${e.harnessRelease.contentHash}`)),"saveHarnessReleaseRecord");getHarnessRunOverlay=r(e=>this.overlay.getHarnessRunOverlay(e),"getHarnessRunOverlay");createHarnessRunOverlay=r(e=>this.overlay.createHarnessRunOverlay(e),"createHarnessRunOverlay");freezeHarnessRunOverlayWithProposalAtomically=r(e=>this.overlay.freezeHarnessRunOverlayWithProposalAtomically(e),"freezeHarnessRunOverlayWithProposalAtomically");getHarnessBackgroundReviewSettings=r(async e=>n.object({enabled:n.boolean(),updatedAt:n.string().datetime().nullable()}).strict().parse(await this.request({action:"background_get",workspaceId:e})),"getHarnessBackgroundReviewSettings");getHarnessMemory=r(async(e,t)=>we.nullable().parse(await this.request({action:"memory_get",workspaceId:e,sessionId:this.sessionId(),key:t})),"getHarnessMemory");listHarnessMemories=r(async(e,t={})=>{let o=n.object({entries:n.array(we).max(20),nextBefore:n.object({updatedAt:n.string().datetime(),key:n.string()}).nullable()}),a=[],c=null;do{let u=o.parse(await this.request({action:"memory_page",workspaceId:e,sessionId:this.sessionId(),before:c,limit:20,includeDeleted:t.includeDeleted??!1}));if(a.push(...u.entries),u.nextBefore&&(!u.entries.length||g(u.nextBefore)===g(c)))throw new Error("Hosted memory cursor did not advance.");c=u.nextBefore}while(c&&a.length<1e3);if(c)throw new Error("Hosted review memory exceeds its bounded window.");return a},"listHarnessMemories");writeHarnessMemory=r(async e=>we.parse(await this.request({action:"memory_write",sessionId:this.sessionId(),input:e},`review-memory:${g(e)}`)),"writeHarnessMemory");saveHarnessImprovementArtifact=r(async(e,t,o)=>{let a={action:"artifact_put",workspaceId:e,kind:t,artifact:o},c=(await import("./dist-ZVJPJLXR.js")).HarnessReviewStorageParamsSchema.parse(a);return he[t].parse(await this.request(c,`review-artifact:${t}:${o.contentHash}`))},"saveHarnessImprovementArtifact");listHarnessImprovementArtifacts=r(async(e,t,o=100)=>{let a=[],c=null,u=Math.min(Math.max(1,Math.trunc(o)),1e3);do{let s=(await import("./dist-ZVJPJLXR.js")).HarnessReviewStorageParamsSchema.parse({action:"artifact_page",workspaceId:e,kind:t,before:c,limit:Math.min(100,u-a.length)}),d=Tt.parse(await this.request(s));if(a.push(...d.entries),d.nextBefore&&(!d.entries.length||g(d.nextBefore)===g(c)))throw new Error("Hosted artifact cursor did not advance.");c=d.nextBefore}while(c&&a.length<u);return a.map(s=>he[t].parse(s))},"listHarnessImprovementArtifacts");listPendingHarnessRefinerTriggers=r(async()=>{let e=await import("./hosted-harness-runtime-723S5ZSH.js").then(a=>a.loadHostedHarnessRuntime(this.client));if(!e)return[];let t=[],o=null;do{let a=Tt.parse(await this.request({action:"pending_page",workspaceId:e.workspace.id,before:o,limit:100}));if(t.push(...a.entries.map(c=>({workspaceId:e.workspace.id,trigger:Te.parse(c)}))),a.nextBefore&&(!a.entries.length||g(a.nextBefore)===g(o)))throw new Error("Hosted pending-review cursor did not advance.");o=a.nextBefore}while(o&&t.length<1e3);if(o)throw new Error("Hosted pending reviews exceed the bounded recovery window.");return t},"listPendingHarnessRefinerTriggers");advanceHarnessWorkspaceAtomically=r(async e=>ve.parse(await this.client.request({contractVersion:h,requestId:e.receiptId,operation:"harness/workspace/transition",params:{action:"advance",...e}})),"advanceHarnessWorkspaceAtomically");advanceReviewedHarnessWorkspaceAtomically=r(async e=>ve.parse(await this.client.request({contractVersion:h,requestId:e.receiptId,operation:"harness/workspace/transition",params:{action:"reviewedAdvance",...e}})),"advanceReviewedHarnessWorkspaceAtomically");rollbackHarnessWorkspaceAtomically=r(async e=>ve.parse(await this.client.request({contractVersion:h,requestId:e.receiptId,operation:"harness/workspace/transition",params:{action:"rollback",...e}})),"rollbackHarnessWorkspaceAtomically");getSession=r(async e=>Ue.nullable().parse(await this.request({action:"session_get",sessionId:e})),"getSession");getTurn=r(async e=>U.nullable().parse(await this.request({action:"turn_get",turnId:e})),"getTurn");updateTurn=r(async(e,t)=>{let o=await this.getTurn(e);if(!o)return null;let a=U.parse(t(o)),{harnessSnapshot:c,...u}=o,{harnessSnapshot:s,...d}=a;if(!s||g(u)!==g(d))throw new Error("Hosted review may only restore a missing Harness snapshot.");return U.parse(await this.request({action:"snapshot_restore",turnId:e,expectedHash:g(o),snapshot:s}))},"updateTurn");turnsForSession=r(async(e,t=1e3)=>{let o=n.object({entries:n.array(U).max(100),nextBefore:n.number().int().positive().nullable()}),a=[],c=null,u=Math.min(Math.max(1,Math.trunc(t)),1e3);do{let s=o.parse(await this.request({action:"turn_page",sessionId:e,before:c,limit:Math.min(100,u-a.length)}));if(a.push(...s.entries),s.nextBefore&&(!s.entries.length||c!==null&&s.nextBefore>=c))throw new Error("Hosted review turn cursor did not advance.");c=s.nextBefore}while(c&&a.length<u);return a.reverse()},"turnsForSession");runtimeEventsForTurn=r(async(e,t={})=>{let o=n.object({entries:n.array(ge).max(100),nextAfterSequence:n.number().int().positive().nullable()}),a=[],c=0,u=Math.min(t.limit??1e4,1e4);do{let s=o.parse(await this.request({action:"event_page",turnId:e,afterSequence:c,names:[...t.names??[]],limit:Math.min(100,u-a.length)}));if(a.push(...s.entries),!s.nextAfterSequence)return a;if(!s.entries.length||s.nextAfterSequence<=c)throw new Error("Hosted review event cursor did not advance.");c=s.nextAfterSequence}while(a.length<u);return a},"runtimeEventsForTurn");listModelUsageRecords=r(e=>this.usage.listModelUsageRecords(e),"listModelUsageRecords");async appendRuntimeEvent(e){return ge.parse(await this.request({action:"event_append",event:e},`review-event:${e.id}`))}async upsertModelUsageRecord(e){await this.request({action:"usage_put",record:e},`review-usage:${g(e)}`)}};import{randomUUID as sr}from"node:crypto";async function xt(l,e){let t=xe.parse(await l.request({contractVersion:h,requestId:sr(),operation:"refiner/execute",params:{action:{action:"active_release",workspaceId:e}}}));return M(t,"Hosted Refiner active release"),t}r(xt,"loadHostedRefinerRelease");import{randomUUID as or}from"node:crypto";var ar=n.object({personalizationSoul:n.string().max(8e3).optional(),userInstructions:n.string().max(64e3).optional(),preferences:pe.optional()}).strict(),nr=n.object({revision:n.number().int().positive(),settings:ar}).strict();async function ye(l){let e=await l.request({contractVersion:h,requestId:or(),operation:"settings/get",params:{}}),t=e===null?null:nr.parse(e);return{revision:t?.revision??null,personalizationSoul:t?.settings.personalizationSoul??Ce[0].content,userInstructions:t?.settings.userInstructions??"",preferences:t?.settings.preferences??pe.parse({})}}r(ye,"loadHostedRuntimeSettings");import{randomUUID as It}from"node:crypto";function kt(l){async function e(t){let o=await te(l,t);if(!o)throw new Error("No hosted Harness is selected for this run.");return o.workspace.id}return r(e,"workspaceId"),[{name:"memory_search",description:"Search bounded active memory for this selected Harness or Profile. Returns keys, revisions and short excerpts.",parameters:{type:"object",additionalProperties:!1,properties:{query:{type:"string",minLength:1,maxLength:500},limit:{type:"integer",minimum:1,maximum:20}},required:["query"]},execute:r(async t=>{let o=t.args.query;if(typeof o!="string"||!o.trim()||o.length>500)throw new Error("Memory query is invalid.");let a=t.args.limit===void 0?8:t.args.limit;if(typeof a!="number"||!Number.isInteger(a)||a<1||a>20)throw new Error("Memory search limit is invalid.");let c=await l.request({contractVersion:h,requestId:It(),operation:"harness/memory/search",params:{workspaceId:await e(t.session),query:o,limit:a}});return{toolCallId:t.callId,name:"memory_search",ok:!0,contentText:JSON.stringify(c),data:c}},"execute")},{name:"memory_inspect",description:"Read one exact active memory entry returned by memory_search.",parameters:{type:"object",additionalProperties:!1,properties:{key:{type:"string",minLength:1,maxLength:120}},required:["key"]},execute:r(async t=>{let o=t.args.key;if(typeof o!="string"||!/^[a-z0-9][a-z0-9-]{0,119}$/.test(o))throw new Error("Memory key is invalid.");let a=await l.request({contractVersion:h,requestId:It(),operation:"harness/memory/get",params:{workspaceId:await e(t.session),key:o}});if(!a||typeof a!="object"||Array.isArray(a)||a.status!=="active")throw new Error(`Harness memory does not exist: ${o}.`);return{toolCallId:t.callId,name:"memory_inspect",ok:!0,contentText:JSON.stringify(a),data:a}},"execute")}]}r(kt,"createHostedHarnessMemoryTools");import{randomUUID as At}from"node:crypto";function Ct(l){return[{name:"work_list_outputs",description:"List this conversation's published outputs from completed turns without starting sandbox compute. Use this before reading a previously saved file; returns exact file IDs and revisions. New workspace files are published after the current turn ends. Inspect those with workspace tools and finish the turn instead of polling this list.",parameters:{type:"object",additionalProperties:!1,properties:{}},execute:r(async e=>{let t=await l.request({contractVersion:h,requestId:At(),operation:"output/list",params:{}});return{toolCallId:e.callId,name:"work_list_outputs",ok:!0,contentText:JSON.stringify(t),data:t}},"execute")},{name:"work_read_output",description:"Read the actual saved text/Markdown or PDF text of a file returned by work_list_outputs, without starting sandbox compute. Prefer this for questions about saved outputs. Use workspace tools for edits, execution and unsaved files. PDF text extraction does not inspect images or page appearance.",parameters:{type:"object",additionalProperties:!1,properties:{fileId:{type:"string",minLength:1,maxLength:191},revision:{type:"integer",minimum:1},offset:{type:"integer",minimum:0,maximum:1e7},maxChars:{type:"integer",minimum:1,maximum:1e5},firstPage:{type:"integer",minimum:1,maximum:1e3},pageCount:{type:"integer",minimum:1,maximum:10}},required:["fileId","revision"]},execute:r(async e=>{let t=await l.request(z.parse({contractVersion:h,requestId:At(),operation:"output/read",params:e.args}),6e4);return{toolCallId:e.callId,name:"work_read_output",ok:!0,contentText:JSON.stringify(t),data:t}},"execute")}]}r(Ct,"createHostedWorkOutputTools");import{randomUUID as Ot}from"node:crypto";function _t(l,e){return{allowedTools:e,authorizeTool:r(async t=>{let o=await l.request({contractVersion:h,requestId:Ot(),operation:"embedding/authorize",params:{sessionId:t.session.id,turnId:t.turnId,name:t.name}});if(!o||typeof o!="object"||Array.isArray(o)||o.allowed!==!0)throw new Error("Hosted tool authorization denied.")},"authorizeTool")}}r(_t,"createHostedEmbeddingAdapter");function qt(l){return async e=>{let t=qe.parse(e);return l.request({contractVersion:h,requestId:Ot(),operation:"sandbox/request",params:{action:t}},e.type==="create"?3e5:e.type==="exec"?18e4:6e4)}}r(qt,"createHostedSandboxRequest");var ir=["sandbox/request","embedding/authorize","output/begin","output/chunk","output/complete","output/saveSandboxFile","output/list","output/read","settings/get","harness/get","harness/overlay/get","harness/overlay/put","harness/memory/get","harness/memory/list","harness/memory/search","harness/memory/write","harness/state/read","task-inbox/execute","create-improve/execute","approval/get","approval/upsert","usage/getByRequestId","usage/upsert","usage/page","session/count","session/get","session/page","session/put","turn/count","turn/wakeCount","turn/get","turn/put","turn/latest","turn/page","thread/turnPage","event/append","events/page","events/latestAssistantText"];function Bt(l){if(ir.some(e=>!l.operations.includes(e)))throw new Error("Hosted Postgres runtime capabilities are incomplete.");if(l.maxRequestBytes<256e3||l.maxInFlight<32||l.maxPageSize<200)throw new Error("Hosted Postgres runtime transport limits are incompatible.")}r(Bt,"assertHostedWorkCapabilities");var w=r(async()=>{throw new Error("This hosted control is not available until its Postgres repository is activated.")},"unavailable"),ur=We(),cr=Ve();async function _o(l){let e=l.runtimeStorage,t=l.hostStorageClient;if(e.kind!=="hosted_postgres"||!t||e.client!==t)throw new Error("Hosted storage selection mismatch.");if(l.embedding||l.sandboxRequest)throw new Error("Hosted Postgres tool and sandbox authority must come from the host transport.");if(!l.streamOpenPondHostedChatTurn)throw new Error("Hosted Postgres runtime requires a host-admitted model stream.");if(l.profileSource||l.harness)throw new Error("Hosted Postgres runtime accepts only host-admitted immutable sources.");if(l.services&&Object.values(l.services).some(i=>i!==!1&&i!==void 0))throw new Error("Hosted service adapters must be admitted by the Postgres composition.");let o=Be.parse(await t.request({contractVersion:h,requestId:Dt(),operation:"capabilities",params:{}}));Bt(o);let a=_t(t,o.allowedTools),c=qt(t),u=W.resolve(l.storeDir??process.cwd()),s=W.resolve(l.workspaceDir??process.cwd());await lr(s,{recursive:!0});let d=st({channel:"app-server",logDir:W.join(u,"logs"),metadata:{version:l.version??Xe,runtimeVersion:Ye(),placement:"hosted_work"}}),m=e.core,f=new ae(t,u),y=e.admittedProfileRelease?await gt(t,e.admittedProfileRelease):{profile:cr,profileLibrary:ur},{appendRuntimeEvent:v,closeEventSubscribers:b,subscribeRuntimeEvents:R}=ut({logger:d,assistantDeltaFlushMs:250,store:{appendRuntimeEvent:r(i=>["harness.refiner.queued","harness.refiner.started","harness.refiner.completed","harness.refiner.failed"].includes(i.name)?f.appendRuntimeEvent(i):m.appendRuntimeEvent(i),"appendRuntimeEvent"),runtimeEventPageRows:r(i=>m.runtimeEventPageRows(i),"runtimeEventPageRows")}}),p=X({queueId:"turn-follow-up",logger:d}),S=X({queueId:"subagent",logger:d}),x=nt(l.streamOpenPondHostedChatTurn,{enabled:at()}),E=X({queueId:"harness-refiner",logger:d,concurrency:1}),B=St({store:f,storeDir:u,queue:E,streamOpenPondHostedChatTurn:x,appendRuntimeEvent:v,upsertModelUsageRecord:r(i=>f.upsertModelUsageRecord(i),"upsertModelUsageRecord"),prepareReview:r(i=>f.prepareReview(i),"prepareReview"),loadActiveRefinerRelease:r(async()=>{let i=await O(t);if(!i)throw new Error("Hosted review has no admitted Harness workspace.");return xt(t,i.workspace.id)},"loadActiveRefinerRelease")}),Re=r(async()=>(await ye(t)).preferences,"preferences"),{createSession:ne,getSession:D,updateSession:ie,completeTurn:Mt,failTurn:zt,interruptTurn:jt}=dt({store:m,defaultSessionCwd:r(()=>s,"defaultSessionCwd"),appendRuntimeEvent:v,loadAppPreferences:Re,loadLastUsedProfile:r(async()=>y.profileLibrary.lastUsed,"loadLastUsedProfile")}),le=lt({workspaceDir:s,logger:d,getSession:D,updateSession:ie,appendRuntimeEvent:v,sandboxRequest:c,sandboxCreationMode:"hosted_worker"}),V=ot({appendRuntimeEvent:v,findLocalProject:r(async()=>null,"findLocalProject"),onRepositoryInstructionDiagnostic:r((i,P)=>d.warn("repository instruction file skipped",{diagnostic:i,sessionId:P.id}),"onRepositoryInstructionDiagnostic")}),Nt=new ee(t),L=new oe(t),Se=Ht(t),ue=Pt(t),G=e.admittedProfileRelease?.hostExecution?await O(t,e.admittedProfileRelease.harnessRelease):null;if(e.admittedProfileRelease?.hostExecution&&(!G||!o.operations.includes("output/readBytes")||!o.operations.includes("profile-evaluations/sandbox")||!o.operations.includes("profile-evaluations/grade")))throw new Error("Hosted evaluation requires its admitted release, managed artifact owner and private sandbox grader.");let Ft=tt({deviceId:"hosted-evaluation",storeDir:u,runtimeEventsForSession:r(i=>m.runtimeEventsForSession(i),"runtimeEventsForSession"),managedPersistence:{...Se.persistence,sourceTurnStartedAt:r(async(i,P)=>{let H=await m.getTurn(P);if(!H||H.sessionId!==i||!H.startedAt)throw new Error("The managed output has no actual started case turn.");return H.startedAt},"sourceTurnStartedAt")}}),k=G?ft({readOutput:ue.readOutput,executeCommand:ue.execute,settleRemote:ue.settle,runtimeNode:"node",runtimeAgentRoot:"/workspace/runtime",storeDir:u,release:G.release,getSession:D,getTurn:r(i=>m.getTurn(i),"getTurn"),saveOutput:Ft.saveOwnedOutputBytes,recordOutput:r(async(i,P,H)=>{await v({id:Dt(),timestamp:new Date().toISOString(),name:"workspace_action_result",source:"server",sessionId:i,turnId:P,action:"work_output_save",status:"completed",data:H})},"recordOutput"),authorize:r(async()=>{let i=await O(t,e.admittedProfileRelease.harnessRelease);if(!i||i.release.harnessRelease.contentHash!==G.release.harnessRelease.contentHash)throw new Error("The hosted isolated evaluation source authority changed.")},"authorize")}):null,Ut=mt(a,async(i,P)=>{let H=await m.getTurn(i);if(!H)throw new Error("Embedded turn is unavailable.");let C=await D(H.sessionId),$=C.metadata?.embeddingToolBindings,N=[...P].sort((K,Wt)=>K.name.localeCompare(Wt.name));if($!==void 0&&g($)!==g(N))throw new Error("Embedded tool bindings changed; start a new thread.");await ie(C.id,{metadata:{...C.metadata,embeddingToolBindings:N}}),await m.updateTurn(i,K=>({...K,metadata:{...K.metadata,toolBindings:N}}))}),T=ct({executionHost:"embedded",workInputsForSession:l.workInputsForSession,attachmentRootDir:W.join(u,"attachments"),isolatedProfileEvaluationForTurn:k?async i=>{if(i.metadata?.profileEvaluationRun===void 0)return!1;if(!k.ownsSession(i.id))throw new Error("The hosted evaluation has no actual isolated case owner.");return!0}:void 0,executeProfileEvaluationAction:k?.executeAction,resolveModelTools:r(i=>k?.ownsSession(i.session.id)?k.resolveTools(i):Ut(i),"resolveModelTools"),hostedToolFlags:{toolMode:"native",nativeToolTransport:!0,nativeToolProviderDenylist:[],textToolFallback:!1},store:m,inboxStore:e.inbox,createSession:ne,getSession:D,updateSession:ie,completeTurn:Mt,failTurn:zt,interruptTurn:jt,upsertApproval:r(i=>m.upsertApproval(i),"upsertApproval"),defaultSessionCwd:r(()=>s,"defaultSessionCwd"),findOpenPondApp:r(async i=>({id:i||Fe(s),name:W.basename(s)||"Workspace",description:null,visibility:"private",sandbox:!0}),"findOpenPondApp"),resolveSessionWorkspaceCwd:r(async i=>i.cwd?.trim()||s,"resolveSessionWorkspaceCwd"),ensureCodexRuntime:r(async()=>{throw new Error("Codex process hosting is unavailable.")},"ensureCodexRuntime"),appendWorkspaceDiffEvent:le.appendWorkspaceDiffEvent,workspaceDiffBaseline:le.workspaceDiffBaseline,appendRuntimeEvent:v,executeWorkspaceTool:le.executeWorkspaceTool,executeOpenPondCommand:r(async()=>{throw new Error("Hosted commands require durable authorization.")},"executeOpenPondCommand"),loadOpenPondProfileState:r(async()=>y.profile,"loadOpenPondProfileState"),loadOpenPondProfileLibrary:r(async()=>y.profileLibrary,"loadOpenPondProfileLibrary"),readOpenPondProfileSkill:w,loadSelectedHarnessRuntime:r(i=>{if(i.currentProfile&&(!e.admittedProfileRelease||i.currentProfile.repositoryId!==e.admittedProfileRelease.repositoryId||i.currentProfile.profileId!==e.admittedProfileRelease.profileId))throw new Error("Hosted Profile session lacks admitted immutable source.");return te(t,i)},"loadSelectedHarnessRuntime"),ensureHarnessRunOverlay:r(i=>Nt.ensureHarnessRunOverlay(i),"ensureHarnessRunOverlay"),processHarnessImprovementBoundary:B,harnessModelTools:[...kt(t),...Ct(t)],loadBuiltInOpenPondSkills:r(async()=>[],"loadBuiltInOpenPondSkills"),readBuiltInOpenPondSkill:w,loadPersonalizationSoul:r(async()=>(await ye(t)).personalizationSoul,"loadPersonalizationSoul"),loadAppPreferences:Re,maybeCreateScaffoldForTurn:V.maybeCreateScaffoldForTurn,hostedSystemPrompt:V.hostedSystemPrompt,appendAssistantText:V.appendAssistantText,appendHostedContextUsage:V.appendHostedContextUsage,streamOpenPondHostedChatTurn:x,turnFollowUpQueue:p,subagentQueue:S,maxHostedWorkspaceToolRounds:et(l.maxHostedWorkspaceToolRounds),maxRepeatedInvalidToolRequests:3});await T.recoverPendingSubagentCompletions(),await T.recoverTaskInbox();let Pe=!1,He=r(async(i,P)=>{if(Z.parse(P).attachments?.length&&!k?.ownsSession(i))throw new Error("Hosted attachments require managed-file admission.");let H=await D(i);if(H.currentProfile&&(!e.admittedProfileRelease||H.currentProfile.repositoryId!==e.admittedProfileRelease.repositoryId||H.currentProfile.profileId!==e.admittedProfileRelease.profileId))throw new Error("Hosted Profile session lacks admitted immutable source.");return Pe||(await B.reconcilePending(),await E.drain(),Pe=!0),T.sendTurn(i,P)},"sendTurn");if(l.profileExternalDataset&&!e.admittedProfileRelease?.hostExecution)throw new Error("External Dataset requires its admitted hosted evaluation.");let A=e.admittedProfileRelease?.hostExecution?await Et({client:t,core:m,release:e.admittedProfileRelease,storeDir:u,...l.profileExternalDataset?{externalDataset:l.profileExternalDataset}:{},readManagedArtifact:Se.read,admitSession:k.admitSession,settleSession:k.settleSession,createSession:ne,sendTurn:He,interruptSessionTurn:T.interruptSessionTurn}):null,Ee=!1;return{...rt({ports:it({bindHome:!1,placement:"hosted_work",connectedAppProviders:[],featureOverrides:{profileWorkflows:!!e.admittedProfileRelease,profileEvaluations:!!A,harnessProposalReview:!1,harnessEvaluationReview:!1,harnessEvaluationReviewAcceptance:!1,harnessEvaluationTasksetMaterialization:!1,harnessEvaluationBaseline:!1,harnessBackgroundReview:!1,harnessDiff:!1,harnessRollback:!1,harnessReview:!1,refinerProfiles:!1,immutableRefinerAdmission:!1},createSession:ne,getSession:D,turnsForSession:r(i=>m.turnsForSession(i,1e3),"turnsForSession"),runtimeEventsForSession:r(i=>m.runtimeEventsForSession(i,{excludeReasoningDeltas:!0}),"runtimeEventsForSession"),sendTurn:He,steerSessionTurn:T.steerSessionTurn,readTaskInbox:T.readTaskInbox,queueTaskInput:T.queueTaskInput,updateTaskInput:T.updateTaskInput,isSessionTurnActive:T.isSessionTurnActive,waitForSessionTurnSettlement:T.waitForSessionTurnSettlement,interruptSessionTurn:T.interruptSessionTurn,resolveApproval:r(async(i,P)=>{let H=await T.resolveCreateImproveApproval(i,P);if(H)return H;let C=await T.resolveSubagentPatchApplyApproval(i,P);if(C)return C;throw new Error(`Approval not found: ${i}`)},"resolveApproval"),listProfileWorkflows:e.admittedProfileRelease?()=>re(t,e.admittedProfileRelease):w,listProfileEvaluations:A?.listProfileEvaluations??w,loadProfileTrainingSource:w,prepareProfileEvaluationRun:A?.prepareProfileEvaluationRun??w,runPreparedProfileEvaluation:A?.runPreparedProfileEvaluation??w,runProfileEvaluationSuite:A?.runProfileEvaluationSuite??w,executeProfileEvaluationCase:A?.executeProfileEvaluationCase??w,executeProfileEvaluationRun:A?.executeProfileEvaluationRun??w,compareProfileEvaluationRuns:A?.compareProfileEvaluationRuns??w,buildProfileEvaluationReport:A?.buildProfileEvaluationReport??w,inspectHarness:r(async()=>{let i=await O(t);if(!i)return null;let P=i.workspace.id,[H,C,$,N]=await Promise.all([L.getPreference(P,"workspace_settings"),L.getPreference(P,"evaluation_review_settings"),L.listCandidates(P),L.listCrossRunRequests(P)]);return{workspace:i.workspace,release:i.release,backgroundReview:H,evaluationReview:C,refinementCandidates:$,crossRunRequests:N}},"inspectHarness"),reviewHarnessProposal:w,reviewHarness:w,acceptHarnessEvaluationReview:w,materializeHarnessEvaluationTaskset:w,runHarnessEvaluationBaseline:w,validateHarness:r(async()=>{let i=await O(t);return i?{valid:!0,workspaceId:i.workspace.id,harnessRelease:i.release.harnessRelease,agentSnapshot:i.release.agentSnapshot}:{valid:!1,reason:"No admitted hosted Harness release."}},"validateHarness"),updateHarnessBackgroundReview:w,diffHarness:w,rollbackHarness:w,inspectRefiner:w,updateRefiner:w,activateRefiner:w,rollbackRefiner:w,subscribeRuntimeEvents:R,observeRuntimeOperation:r(i=>d.info("agent runtime operation",i),"observeRuntimeOperation")}),close:r(async()=>{Ee||(Ee=!0,k?.close(),await T.close(),await Promise.all([p.drain(),S.drain(),E.drain()]),await b(),await d.flush())},"close")}),storePath:"hosted-postgres",workspaceDir:s,composition:["runtime_event_bus","session_store","hosted_provider","workspace_tools","command_approvals","harness","agent_runtime","jsonl_transport"]}}r(_o,"createHostedOwnedAppServer");export{_o as createHostedOwnedAppServer};
|
|
2
|
+
import{c as wt,d as vt,e as yt}from"./chunk-QHWGQ3A4.js";import{b as gt,c as re,e as Rt}from"./chunk-SH5CBAFC.js";import{a as pt,b as ft}from"./chunk-6FDWRG55.js";import"./chunk-PF5R6CMP.js";import{b as ht}from"./chunk-DMVD2RFZ.js";import{a as ee,b as O,c as te}from"./chunk-JYKRR7E5.js";import{a as St}from"./chunk-OIUTWU6K.js";import"./chunk-X4OSOOSU.js";import"./chunk-3K4VVB7S.js";import{b as De,c as Me,d as ze,f as Ne,h as $e}from"./chunk-3Z47M3YY.js";import{b as je}from"./chunk-ABD5M2D2.js";import"./chunk-TRQQNFMO.js";import"./chunk-FEAKTSRS.js";import"./chunk-OSIO7PLX.js";import"./chunk-F74GBN6K.js";import"./chunk-SDAUS5PY.js";import"./chunk-I2NXNMRZ.js";import"./chunk-O72BSKSO.js";import{a as Je,b as Ze}from"./chunk-OPNRWESL.js";import{b as Ke,c as Qe}from"./chunk-2QUCCP6Z.js";import{a as Y}from"./chunk-O6ULLQJ6.js";import"./chunk-FY5KHLMW.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-DBK66CJP.js";import{d as tt,e as st,ga as ct,ha as dt,ia as mt,j as ot,k as it,v as lt,w as X,y as ut}from"./chunk-OGDADQGH.js";import{a as rt}from"./chunk-4NESNOK5.js";import"./chunk-BLXEAZCQ.js";import"./chunk-UCPGRPWY.js";import{b as et}from"./chunk-HDL5YSAA.js";import"./chunk-ZFSHBFG5.js";import"./chunk-AN525SPP.js";import"./chunk-SYUKES6H.js";import"./chunk-HIOKCIL7.js";import{a as at,b as nt}from"./chunk-GW766ZSO.js";import{p as Ye}from"./chunk-UKMA4R6X.js";import"./chunk-OQKJGTTO.js";import"./chunk-KVTBX2UP.js";import"./chunk-IZ6DLEVY.js";import"./chunk-A6USMRWK.js";import"./chunk-PCSIOUHF.js";import"./chunk-7KWD2I6W.js";import"./chunk-GPVCOEUH.js";import"./chunk-N73MU2C3.js";import"./chunk-ZGTOK7ZK.js";import"./chunk-XW6HGSIT.js";import{b as Xe}from"./chunk-KG325WTN.js";import"./chunk-3RCRSMWZ.js";import"./chunk-DMFUEUAZ.js";import"./chunk-PSGGOZFM.js";import"./chunk-FUOEIDMA.js";import"./chunk-NHQ36THU.js";import{F as qe,I as h,K as z,L as Be}from"./chunk-VRIEKBBH.js";import{g as Oe,m as _e}from"./chunk-QNG27G3T.js";import"./chunk-EIRYMSEG.js";import{a as ge,j as We,k as Ve,t as Ge}from"./chunk-QOTVNQDI.js";import"./chunk-OQPJ7FJF.js";import{a as Fe,o as F,p as Ue,q as U,v as Le,y as Z}from"./chunk-WJ43MJ3F.js";import"./chunk-Q4TBTRIG.js";import"./chunk-T5AACNJI.js";import"./chunk-QOGJAQDO.js";import"./chunk-EYPCBBMS.js";import"./chunk-DIO5CB6U.js";import"./chunk-7ED24PP6.js";import{a as he}from"./chunk-RNIAFXMB.js";import{a as fe}from"./chunk-2IHO4GDJ.js";import"./chunk-KCJVFLBB.js";import{b as Te}from"./chunk-N4FFQPLR.js";import{a as Ie,c as ke}from"./chunk-AY64VY4E.js";import{a as ce,h as be}from"./chunk-GJ2ZJFDD.js";import"./chunk-BFKYRQMA.js";import"./chunk-6QSSIT62.js";import"./chunk-3QIB5FXI.js";import"./chunk-6MI4KKWF.js";import"./chunk-DDMZSZFL.js";import"./chunk-W45RKGM6.js";import"./chunk-3VUATFZD.js";import"./chunk-4EPSHPZL.js";import"./chunk-H6IW2R22.js";import"./chunk-L3KS6MOV.js";import"./chunk-MQULU465.js";import"./chunk-PRGBLQVH.js";import"./chunk-7E6T7GP5.js";import"./chunk-DZUAT3TP.js";import"./chunk-XDQMGUWL.js";import"./chunk-FTEOCCPB.js";import"./chunk-25MBPJVY.js";import"./chunk-WN3V6KDN.js";import"./chunk-523TE4BI.js";import"./chunk-ZCHXGRRU.js";import"./chunk-QDC4OW3S.js";import"./chunk-ZZWAQBA2.js";import"./chunk-YR5ID2SS.js";import"./chunk-YBT2NB32.js";import{c as xe}from"./chunk-74ZXXBGN.js";import"./chunk-APB2STJK.js";import"./chunk-I7AQMAQI.js";import{V as pe,X as Ce}from"./chunk-Z4Z5UOZM.js";import"./chunk-6FA3GG5B.js";import{Hb as Q,Ob as J,f as me,m as Ae}from"./chunk-Y4OWBBDD.js";import"./chunk-6ZFPQYHG.js";import"./chunk-JFXWI3EN.js";import"./chunk-FFRFSDBM.js";import"./chunk-VYLGI3IH.js";import{w as de}from"./chunk-ACYFMLWG.js";import"./chunk-TVQAPBLZ.js";import{l as q,m as g,n as M}from"./chunk-KGNCKIFP.js";import{b as n}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as r}from"./chunk-FTQLQJQV.js";import{randomUUID as Vt}from"node:crypto";import{promises as _}from"node:fs";import I from"node:path";function Pt(l){let e=new Map,t=new Map;async function o(s,d){let m=(t.get(s)??Promise.resolve()).catch(()=>{}).then(d);t.set(s,m);try{return await m}finally{t.get(s)===m&&t.delete(s)}}r(o,"serial");let a=r((s,d=18e4)=>l.request(z.parse({contractVersion:h,requestId:Vt(),operation:"profile-evaluations/sandbox",params:s}),d),"request");async function c(s,d,m,f){let y=q(f),v=`${d}/${m}/${y}`,b=e.get(s.sessionId)??new Set;if(!b.has(v)){if(f.length>1e7)throw new Error("The public case file exceeds its admitted bound.");for(let R=0;R===0||R<f.length;R+=98304)s.signal.throwIfAborted(),await a({sessionId:s.sessionId,turnId:s.turnId,action:"upload",area:d,path:m,sha256:y,sizeBytes:f.length,offset:R,contentsBase64:f.subarray(R,R+98304).toString("base64")},3e5);b.add(v),e.set(s.sessionId,b)}}r(c,"upload");async function u(s,d=""){let m=[];for(let f of await _.readdir(I.join(s,d),{withFileTypes:!0})){let y=I.posix.join(d,f.name);if(f.isSymbolicLink()){let v=await _.realpath(I.join(s,y));if(!v.startsWith(`${await _.realpath(s)}${I.sep}`)||(await _.stat(v)).isDirectory())throw new Error("The public Agent runtime symlink escapes its file closure.");m.push(y);continue}if(f.isDirectory()?m.push(...await u(s,y)):f.isFile()&&m.push(y),m.length>8192)throw new Error("The public Agent runtime exceeds the file limit.")}return m}return r(u,"runtimeFiles"),{execute:r(s=>o(s.sessionId,async()=>{s.signal.throwIfAborted();for(let[f,y]of Object.entries(s.publicHashes)){let v=await _.realpath(I.join(s.sourceRoot,f)),b=await _.realpath(s.sourceRoot);if(!v.startsWith(`${b}${I.sep}`))throw new Error("The public case file escaped its source root.");let R=await _.readFile(v);if(q(R)!==y)throw new Error("The public case file changed before upload.");await c(s,"policy",f,R)}if(s.runtimeRoot)for(let f of await u(s.runtimeRoot))await c(s,"runtime",f,await _.readFile(I.join(s.runtimeRoot,f)));let d=I.relative(s.sourceRoot,s.cwd??s.sourceRoot);if(d.startsWith("..")||I.isAbsolute(d))throw new Error("The command cwd escaped the admitted case.");let m=n.object({code:n.number().int().nullable(),stdout:n.string().max(75e4),stderr:n.string().max(75e4),timedOut:n.boolean(),stdoutTruncated:n.boolean(),stderrTruncated:n.boolean()}).parse(await a({sessionId:s.sessionId,turnId:s.turnId,action:"exec",command:s.command,stdin:s.stdin,cwd:d.split(I.sep).join("/"),timeoutMs:s.timeoutMs},s.timeoutMs+15e3));return s.signal.throwIfAborted(),m}),"execute"),readOutput:r(s=>o(s.sessionId,async()=>{let d=pt(s.path),m=[],f=null,y=null;for(let b=0;f===null||b<f;b+=98304){s.signal.throwIfAborted();let R=n.object({sizeBytes:n.number().int().min(1).max(1e7),sha256:n.string().regex(/^[a-f0-9]{64}$/),contentsBase64:n.string().max(131072)}).parse(await a({sessionId:s.sessionId,turnId:s.turnId,action:"read",path:d,offset:b},6e4));f??=R.sizeBytes,y??=R.sha256;let p=Buffer.from(R.contentsBase64,"base64");if(R.sizeBytes!==f||R.sha256!==y||p.length!==Math.min(98304,f-b)||p.toString("base64")!==R.contentsBase64)throw new Error("The confined output changed during readback.");m.push(p)}let v=Buffer.concat(m);if(q(v)!==y)throw new Error("The confined output differs from its saved byte identity.");return s.signal.throwIfAborted(),{bytes:v,title:d.split("/").at(-1)}}),"readOutput"),settle:r((s,d)=>o(s,async()=>{try{await a({sessionId:s,turnId:d,action:"stop"},6e4)}finally{e.delete(s)}}),"settle")}}r(Pt,"createHostedProfileCommandOwner");import{randomUUID as Lt}from"node:crypto";var j=98304;function Ht(l){let e=r((t,o)=>l.request(z.parse({contractVersion:h,requestId:Lt(),operation:t,params:o})),"request");return{persistence:{sourceTurnStartedAt:r(async()=>{throw new Error("The case owner must supply its actual turn start time.")},"sourceTurnStartedAt"),saveSandboxFile:r(async()=>{throw new Error("Isolated Profile outputs must be read by the confined case owner.")},"saveSandboxFile"),save:r(async({sessionId:t,turnId:o,identity:a,bytes:c})=>{let u=n.object({uploadId:n.string().min(1),maxChunkBytes:n.literal(j)}).parse(await e("output/begin",{sessionId:t,turnId:o,output:a}));for(let d=0;d<c.length;d+=j){let m=c.subarray(d,d+j);await e("output/chunk",{uploadId:u.uploadId,index:d/j,offset:d,sha256:q(m),contentsBase64:m.toString("base64")})}let{outputRef:s}=n.object({outputRef:Ge}).parse(await e("output/complete",{uploadId:u.uploadId}));if(s.location.kind!=="managed"||s.sha256!==a.sha256||s.sizeBytes!==c.length||s.sourceTaskId!==t||s.sourceTurnId!==o||s.id!==a.id||s.revision!==a.revision)throw new Error("The durable case output differs from its saved identity.");return{outputRef:s,artifact:{artifactRef:s.location.fileId,path:s.location.downloadPath,title:s.title,contentType:s.contentType,sizeBytes:s.sizeBytes}}},"save")},read:r(async(t,o)=>{if(t.location.kind!=="managed"||t.sizeBytes>1e7)throw new Error("Select a bounded managed case output.");let a=[];for(let u=0;u<t.sizeBytes;u+=j){o?.throwIfAborted();let s=n.object({offset:n.number().int(),contentsBase64:n.string().max(131072),sha256:n.string(),sizeBytes:n.number().int()}).parse(await e("output/readBytes",{sessionId:t.sourceTaskId,turnId:t.sourceTurnId,fileId:t.location.fileId,revision:t.revision,sha256:t.sha256,sizeBytes:t.sizeBytes,offset:u})),d=Buffer.from(s.contentsBase64,"base64");if(s.offset!==u||s.sha256!==t.sha256||s.sizeBytes!==t.sizeBytes||d.length!==Math.min(j,t.sizeBytes-u)||d.toString("base64")!==s.contentsBase64)throw new Error("The durable workbook byte range changed.");a.push(d)}o?.throwIfAborted();let c=Buffer.concat(a);if(q(c)!==t.sha256)throw new Error("The durable workbook differs from its sealed hash.");return c},"read")}}r(Ht,"createHostedProfileArtifactOwner");import{randomUUID as Gt}from"node:crypto";var $t=n.object({createdAt:n.string().datetime(),id:n.string().min(1)}).strict(),Kt=n.object({entries:n.array(n.unknown()).max(100),nextBefore:$t.nullable()}).strict(),se=class{constructor(e){this.client=e}client;static{r(this,"HostedProfileEvaluationStorage")}execute(e){return this.client.request({contractVersion:h,requestId:Gt(),operation:"profile-evaluations/execute",params:e})}async get(e,t,o){let a=await this.execute({action:"get",kind:e,id:t});if(a===null)return null;let c=o.parse(a);return M(c,`Hosted Profile evaluation ${e}`),c}async put(e,t,o,a,c){let u=o.parse(t);M(u,`Hosted Profile evaluation ${e}`);let s=o.parse(await this.execute({action:"put",kind:e,payload:u,profileKey:a,createdAt:c}));if(s.contentHash!==u.contentHash||g(s)!==g(u))throw new Error("Hosted Profile evaluation write returned different evidence.");return s}async page(e,t,o){let a=[],c=null;do{let u=Kt.parse(await this.execute({action:"page",kind:e,profileKey:g(F.parse(t)),before:c,limit:100}));if(u.nextBefore&&(u.entries.length===0||c&&(u.nextBefore.createdAt>c.createdAt||u.nextBefore.createdAt===c.createdAt&&u.nextBefore.id>=c.id)))throw new Error("Hosted Profile evaluation cursor did not advance.");for(let s of u.entries){let d=o.parse(s);M(d,`Hosted Profile evaluation ${e}`),a.push(d)}if(a.length>1e4)throw new Error("Hosted Profile evaluation history exceeds the bounded catalog limit.");c=u.nextBefore}while(c);return a}getProfileEvaluationGrade(e){return this.get("grade",e,de)}saveProfileEvaluationGrade(e){return this.put("grade",e,de,null,new Date().toISOString())}getProfileEvaluationReceipt(e){return this.get("receipt",e,me)}saveProfileEvaluationReceipt(e){if(!Ae(e))throw new Error("Hosted Profile evaluation receipt is invalid.");return this.put("receipt",e,me,null,e.completedAt)}getProfileEvaluationRun(e){return this.get("run",e,Y)}saveProfileEvaluationRun(e){return this.put("run",e,Y,g(F.parse(e.profileRef)),e.completedAt)}listProfileEvaluationRuns(e){return this.page("run",e,Y)}getProfileEvaluationComparison(e){return this.get("comparison",e,Q)}saveProfileEvaluationComparison(e,t){return this.put("comparison",t,Q,g(F.parse(e)),t.createdAt)}listProfileEvaluationComparisons(e){return this.page("comparison",e,Q)}getProfileEvaluationSuiteRun(e){return this.get("suite",e,J)}saveProfileEvaluationSuiteRun(e,t,o){if(g(t)!==o.catalogHash)throw new Error("Hosted Profile evaluation suite differs from its catalog.");return this.put("suite",o,J,g(F.parse(e)),o.createdAt)}listProfileEvaluationSuiteRuns(e){return this.page("suite",e,J)}};async function Et(l){let e=l.release;if(!e.hostExecution)throw new Error("Hosted evaluation requires explicit host execution attribution.");let t={hostConversationId:e.hostExecution.conversationId,hostTurnId:e.hostExecution.turnId},o={source:"openpond_git",profileId:e.profileId,repositoryId:e.repositoryId},a=r(async()=>({ref:o,sourceRevision:e.sourceRevision}),"selectedProfile"),c=r(()=>re(l.client,e),"selectedWorkflows"),u=new se(l.client),s=r(async p=>{if(g(p)!==g(e.harnessRelease))throw new Error("Evaluation requires the admitted Profile release.");let S=await O(l.client,p);if(!S)throw new Error("Admitted evaluation Profile is unavailable.");return S},"loadRuntime"),d=r(async p=>{if(g(p.ref)!==g(o)||p.sourceRevision!==e.sourceRevision)throw new Error("Evaluation requires the admitted Profile source.");return je({...p,runtime:await s(p.harnessRelease)})},"loadCatalog"),m=l.externalDataset?await ht({value:l.externalDataset,release:(await s(e.harnessRelease)).release,sourceRevision:e.sourceRevision,client:l.client}):null,f=r(async(p,S,x)=>{if(S!==e.profileId)throw new Error("Evaluation Taskset Profile differs from its admitted source.");let E=await Ne({definition:p,harnessRelease:x,runtime:await s(x)});if(!E)throw new Error("Evaluation Taskset is absent from the admitted Profile release.");return E},"loadTasksetPackage"),y=wt({resolveExternalDataset:m?.resolveExternalDataset,store:{runtimeEventsForTurn:r(p=>l.core.runtimeEventsForTurn(p),"runtimeEventsForTurn")},storeDir:l.storeDir,readManagedArtifact:l.readManagedArtifact,admitSession:l.admitSession,settleSession:l.settleSession,loadCatalog:d,loadTasksetPackage:f,selectedProfile:a,createSession:r(p=>{let S=Le.parse(p);return l.createSession({...S,metadata:{...S.metadata,...t}})},"createSession"),sendTurn:r((p,S)=>{let x=Z.parse(S);return l.sendTurn(p,{...x,metadata:{...x.metadata,...t}})},"sendTurn"),interruptSessionTurn:l.interruptSessionTurn}),v=$e({resolveExternalDataset:m?.resolveExternalDataset,sourceCandidate:m?.sourceCandidate,privateGradingPreflight:r(p=>Me(p,!1),"privateGradingPreflight"),loadCatalog:d,selectedWorkflows:c,loadTasksetPackage:f,placement:"remote",boundedWorkComputeAvailable:!0,modelConfigurationHash:r(async(p,S)=>{if(p.providerId!=="openpond"||!S.hostModelConfigurationHash)throw new Error("Hosted evaluation requires a host-admitted model configuration receipt.");return S.hostModelConfigurationHash},"modelConfigurationHash")}),b=vt({resolveExternalDataset:m?.resolveExternalDataset,store:u,loadCatalog:d,loadTasksetPackage:f,selectedProfile:a,executeCase:y,privateGrading:r((p,S,x)=>ze({manifest:p,packageValue:S,signal:x,executeSandboxVerifier:De(l.client),authorize:r(async()=>{let E=p.profileEvaluation;if(!E||E.profileId!==e.profileId||E.sourceRevision!==e.sourceRevision)throw new Error("The hosted private grading source changed.");if(E.externalDatasetBinding){if(!m)throw new Error("The frozen Dataset owner is unavailable.");await m.authorize({bindingHash:E.externalDatasetBinding.contentHash,manifestHash:p.contentHash})}let B=await d({ref:o,sourceRevision:e.sourceRevision,harnessRelease:E.harnessRelease});if(!E.externalDatasetBinding&&B.catalogHash!==E.catalogHash)throw new Error("The hosted private grading catalog changed.")},"authorize")}),"privateGrading")}),R={getProfileEvaluationRun:u.getProfileEvaluationRun.bind(u),getProfileEvaluationReceipt:u.getProfileEvaluationReceipt.bind(u),getProfileEvaluationGrade:u.getProfileEvaluationGrade.bind(u),getSession:l.core.getSession.bind(l.core),getTurn:l.core.getTurn.bind(l.core),runtimeEventsForTurn:l.core.runtimeEventsForTurn.bind(l.core),listModelUsageRecords:l.core.listModelUsageRecords.bind(l.core)};return{prepareProfileEvaluationRun:v,executeProfileEvaluationCase:y,executeProfileEvaluationRun:b,runPreparedProfileEvaluation:r(async p=>b(await v(p,{requireExpectedManifestHash:!0})),"runPreparedProfileEvaluation"),runProfileEvaluationSuite:yt({store:u,loadCatalog:d,selectedWorkflows:c,prepareRun:v,executeRun:b}),compareProfileEvaluationRuns:Je({store:u,selectedProfile:a}),buildProfileEvaluationReport:r(p=>Ze({store:u,profileRef:o,request:p}),"buildProfileEvaluationReport"),listProfileEvaluations:r(async p=>{if(p&&typeof p=="object"&&"runId"in p)return Qe({store:R,profileRef:o,...Ke.parse(p)});let[S,x,E,B]=await Promise.all([d({ref:o,sourceRevision:e.sourceRevision,harnessRelease:e.harnessRelease}),u.listProfileEvaluationRuns(o),u.listProfileEvaluationComparisons(o),u.listProfileEvaluationSuiteRuns(o)]);return{...S,runs:x,comparisons:E,suiteRuns:B}},"listProfileEvaluations")}}r(Et,"createHostedProfileEvaluationRuntime");import{mkdir as lr}from"node:fs/promises";import{randomUUID as Dt}from"node:crypto";import W from"node:path";import{randomUUID as bt}from"node:crypto";var Qt=n.object({revision:n.number().int().nonnegative(),payload:n.record(n.string(),n.unknown()).nullable()}).strict(),Jt=n.object({entries:n.array(n.unknown()).max(100),nextAfterId:n.string().min(1).nullable()}).strict(),oe=class{constructor(e){this.client=e}client;static{r(this,"HostedHarnessStateStorage")}async getPreference(e,t){return Qt.parse(await this.client.request({contractVersion:h,requestId:bt(),operation:"harness/state/read",params:{workspaceId:e,kind:t,afterId:null,limit:1}}))}async listCandidates(e){return(await this.readAll(e,"candidates")).map(t=>Ie.parse(t))}async listCrossRunRequests(e){return(await this.readAll(e,"cross_run_requests")).map(t=>ke.parse(t))}async readAll(e,t){let o=[],a=null;do{let c=Jt.parse(await this.client.request({contractVersion:h,requestId:bt(),operation:"harness/state/read",params:{workspaceId:e,kind:t,afterId:a,limit:Math.min(100,1001-o.length)}}));if(c.nextAfterId&&(c.entries.length===0||c.nextAfterId===a))throw new Error("Hosted Harness state cursor did not advance.");if(o.push(...c.entries),o.length>1e3)throw new Error("Hosted Harness state exceeds 1,000 entries.");a=c.nextAfterId}while(a);return o}};import{randomUUID as Zt}from"node:crypto";import{cp as Yt,mkdir as Xt,rm as er}from"node:fs/promises";import tr from"node:path";var we=n.object({schemaVersion:n.literal("openpond.harnessMemoryEntry.v1"),id:n.string(),workspaceId:n.string(),key:n.string(),content:n.string(),tags:n.array(n.string()),revision:n.number().int().positive(),status:n.enum(["active","deleted"]),sourceRunId:n.string().nullable(),sourceProposal:n.object({id:n.string(),contentHash:n.string()}).nullable(),createdAt:n.string().datetime(),updatedAt:n.string().datetime(),contentHash:n.string().regex(/^[a-f0-9]{64}$/)}).strict(),rr=n.object({createdAt:n.string().datetime(),id:n.string()}).strict(),Tt=n.object({entries:n.array(n.unknown()).max(100),nextBefore:rr.nullable()}).strict(),ve=n.object({workspace:ce,receipt:be}).strict(),ae=class{constructor(e,t){this.client=e;this.storeDir=t;this.usage=new Rt(e),this.overlay=new ee({request:r(async o=>o.operation==="harness/overlay/get"?this.request({action:"overlay_get",...o.params}):o.operation==="harness/overlay/freezeProposal"?this.request({action:"overlay_freeze",...o.params},o.requestId):e.request(o),"request")})}client;storeDir;static{r(this,"HostedHarnessReviewStorage")}harnessStoragePlacement="hosted";reviewSessionId=null;overlay;usage;request(e,t=Zt()){return this.client.request({contractVersion:h,requestId:t,operation:"harness/review/execute",params:e},e.action==="release_put"?6e4:15e3)}sessionId(){if(!this.reviewSessionId)throw new Error("Hosted review memory requires an admitted review session.");return this.reviewSessionId}async prepareReview(e){let t=await this.getSession(e.runRef);if(!t)throw new Error("Hosted review session is unavailable.");this.reviewSessionId=t.id;let o=await this.getHarnessRunOverlay(t.id);if(!o)throw new Error("Hosted review overlay is unavailable.");let a=await this.getHarnessWorkspace(o.workspace.workspaceId);if(!a?.currentChannel.release)throw new Error("Hosted review workspace release is unavailable.");let c=await this.getHarnessReleaseRecord(a.currentChannel.release.contentHash);if(!c||c.sourceRevision!==a.sourceRevision)throw new Error("Hosted review source binding changed.");let u=Oe(this.storeDir,a.id);await Xt(u.root,{recursive:!0,mode:448}),await er(u.source,{recursive:!0,force:!0}),await Yt(tr.join(c.bundlePath,"source"),u.source,{recursive:!0,force:!1,errorOnExist:!0});let s=await _e({workspaceId:a.id,sourceDir:u.source});if(s.sourceRevision!==a.sourceRevision||s.harnessRelease.contentHash!==c.harnessRelease.contentHash)throw new Error("Hosted review source cache differs from its immutable release.")}getHarnessWorkspace=r(async e=>ce.nullable().parse(await this.request({action:"workspace_get",workspaceId:e})),"getHarnessWorkspace");getHarnessReleaseRecord=r(async e=>fe.nullable().parse(await this.request({action:"release_get",contentHash:e})),"getHarnessReleaseRecord");saveHarnessReleaseRecord=r(async e=>fe.parse(await this.request({action:"release_put",record:e},`review-release:${e.harnessRelease.contentHash}`)),"saveHarnessReleaseRecord");getHarnessRunOverlay=r(e=>this.overlay.getHarnessRunOverlay(e),"getHarnessRunOverlay");createHarnessRunOverlay=r(e=>this.overlay.createHarnessRunOverlay(e),"createHarnessRunOverlay");freezeHarnessRunOverlayWithProposalAtomically=r(e=>this.overlay.freezeHarnessRunOverlayWithProposalAtomically(e),"freezeHarnessRunOverlayWithProposalAtomically");getHarnessBackgroundReviewSettings=r(async e=>n.object({enabled:n.boolean(),updatedAt:n.string().datetime().nullable()}).strict().parse(await this.request({action:"background_get",workspaceId:e})),"getHarnessBackgroundReviewSettings");getHarnessMemory=r(async(e,t)=>we.nullable().parse(await this.request({action:"memory_get",workspaceId:e,sessionId:this.sessionId(),key:t})),"getHarnessMemory");listHarnessMemories=r(async(e,t={})=>{let o=n.object({entries:n.array(we).max(20),nextBefore:n.object({updatedAt:n.string().datetime(),key:n.string()}).nullable()}),a=[],c=null;do{let u=o.parse(await this.request({action:"memory_page",workspaceId:e,sessionId:this.sessionId(),before:c,limit:20,includeDeleted:t.includeDeleted??!1}));if(a.push(...u.entries),u.nextBefore&&(!u.entries.length||g(u.nextBefore)===g(c)))throw new Error("Hosted memory cursor did not advance.");c=u.nextBefore}while(c&&a.length<1e3);if(c)throw new Error("Hosted review memory exceeds its bounded window.");return a},"listHarnessMemories");writeHarnessMemory=r(async e=>we.parse(await this.request({action:"memory_write",sessionId:this.sessionId(),input:e},`review-memory:${g(e)}`)),"writeHarnessMemory");saveHarnessImprovementArtifact=r(async(e,t,o)=>{let a={action:"artifact_put",workspaceId:e,kind:t,artifact:o},c=(await import("./dist-ZVJPJLXR.js")).HarnessReviewStorageParamsSchema.parse(a);return he[t].parse(await this.request(c,`review-artifact:${t}:${o.contentHash}`))},"saveHarnessImprovementArtifact");listHarnessImprovementArtifacts=r(async(e,t,o=100)=>{let a=[],c=null,u=Math.min(Math.max(1,Math.trunc(o)),1e3);do{let s=(await import("./dist-ZVJPJLXR.js")).HarnessReviewStorageParamsSchema.parse({action:"artifact_page",workspaceId:e,kind:t,before:c,limit:Math.min(100,u-a.length)}),d=Tt.parse(await this.request(s));if(a.push(...d.entries),d.nextBefore&&(!d.entries.length||g(d.nextBefore)===g(c)))throw new Error("Hosted artifact cursor did not advance.");c=d.nextBefore}while(c&&a.length<u);return a.map(s=>he[t].parse(s))},"listHarnessImprovementArtifacts");listPendingHarnessRefinerTriggers=r(async()=>{let e=await import("./hosted-harness-runtime-723S5ZSH.js").then(a=>a.loadHostedHarnessRuntime(this.client));if(!e)return[];let t=[],o=null;do{let a=Tt.parse(await this.request({action:"pending_page",workspaceId:e.workspace.id,before:o,limit:100}));if(t.push(...a.entries.map(c=>({workspaceId:e.workspace.id,trigger:Te.parse(c)}))),a.nextBefore&&(!a.entries.length||g(a.nextBefore)===g(o)))throw new Error("Hosted pending-review cursor did not advance.");o=a.nextBefore}while(o&&t.length<1e3);if(o)throw new Error("Hosted pending reviews exceed the bounded recovery window.");return t},"listPendingHarnessRefinerTriggers");advanceHarnessWorkspaceAtomically=r(async e=>ve.parse(await this.client.request({contractVersion:h,requestId:e.receiptId,operation:"harness/workspace/transition",params:{action:"advance",...e}})),"advanceHarnessWorkspaceAtomically");advanceReviewedHarnessWorkspaceAtomically=r(async e=>ve.parse(await this.client.request({contractVersion:h,requestId:e.receiptId,operation:"harness/workspace/transition",params:{action:"reviewedAdvance",...e}})),"advanceReviewedHarnessWorkspaceAtomically");rollbackHarnessWorkspaceAtomically=r(async e=>ve.parse(await this.client.request({contractVersion:h,requestId:e.receiptId,operation:"harness/workspace/transition",params:{action:"rollback",...e}})),"rollbackHarnessWorkspaceAtomically");getSession=r(async e=>Ue.nullable().parse(await this.request({action:"session_get",sessionId:e})),"getSession");getTurn=r(async e=>U.nullable().parse(await this.request({action:"turn_get",turnId:e})),"getTurn");updateTurn=r(async(e,t)=>{let o=await this.getTurn(e);if(!o)return null;let a=U.parse(t(o)),{harnessSnapshot:c,...u}=o,{harnessSnapshot:s,...d}=a;if(!s||g(u)!==g(d))throw new Error("Hosted review may only restore a missing Harness snapshot.");return U.parse(await this.request({action:"snapshot_restore",turnId:e,expectedHash:g(o),snapshot:s}))},"updateTurn");turnsForSession=r(async(e,t=1e3)=>{let o=n.object({entries:n.array(U).max(100),nextBefore:n.number().int().positive().nullable()}),a=[],c=null,u=Math.min(Math.max(1,Math.trunc(t)),1e3);do{let s=o.parse(await this.request({action:"turn_page",sessionId:e,before:c,limit:Math.min(100,u-a.length)}));if(a.push(...s.entries),s.nextBefore&&(!s.entries.length||c!==null&&s.nextBefore>=c))throw new Error("Hosted review turn cursor did not advance.");c=s.nextBefore}while(c&&a.length<u);return a.reverse()},"turnsForSession");runtimeEventsForTurn=r(async(e,t={})=>{let o=n.object({entries:n.array(ge).max(100),nextAfterSequence:n.number().int().positive().nullable()}),a=[],c=0,u=Math.min(t.limit??1e4,1e4);do{let s=o.parse(await this.request({action:"event_page",turnId:e,afterSequence:c,names:[...t.names??[]],limit:Math.min(100,u-a.length)}));if(a.push(...s.entries),!s.nextAfterSequence)return a;if(!s.entries.length||s.nextAfterSequence<=c)throw new Error("Hosted review event cursor did not advance.");c=s.nextAfterSequence}while(a.length<u);return a},"runtimeEventsForTurn");listModelUsageRecords=r(e=>this.usage.listModelUsageRecords(e),"listModelUsageRecords");async appendRuntimeEvent(e){return ge.parse(await this.request({action:"event_append",event:e},`review-event:${e.id}`))}async upsertModelUsageRecord(e){await this.request({action:"usage_put",record:e},`review-usage:${g(e)}`)}};import{randomUUID as sr}from"node:crypto";async function xt(l,e){let t=xe.parse(await l.request({contractVersion:h,requestId:sr(),operation:"refiner/execute",params:{action:{action:"active_release",workspaceId:e}}}));return M(t,"Hosted Refiner active release"),t}r(xt,"loadHostedRefinerRelease");import{randomUUID as or}from"node:crypto";var ar=n.object({personalizationSoul:n.string().max(8e3).optional(),userInstructions:n.string().max(64e3).optional(),preferences:pe.optional()}).strict(),nr=n.object({revision:n.number().int().positive(),settings:ar}).strict();async function ye(l){let e=await l.request({contractVersion:h,requestId:or(),operation:"settings/get",params:{}}),t=e===null?null:nr.parse(e);return{revision:t?.revision??null,personalizationSoul:t?.settings.personalizationSoul??Ce[0].content,userInstructions:t?.settings.userInstructions??"",preferences:t?.settings.preferences??pe.parse({})}}r(ye,"loadHostedRuntimeSettings");import{randomUUID as It}from"node:crypto";function kt(l){async function e(t){let o=await te(l,t);if(!o)throw new Error("No hosted Harness is selected for this run.");return o.workspace.id}return r(e,"workspaceId"),[{name:"memory_search",description:"Search bounded active memory for this selected Harness or Profile. Returns keys, revisions and short excerpts.",parameters:{type:"object",additionalProperties:!1,properties:{query:{type:"string",minLength:1,maxLength:500},limit:{type:"integer",minimum:1,maximum:20}},required:["query"]},execute:r(async t=>{let o=t.args.query;if(typeof o!="string"||!o.trim()||o.length>500)throw new Error("Memory query is invalid.");let a=t.args.limit===void 0?8:t.args.limit;if(typeof a!="number"||!Number.isInteger(a)||a<1||a>20)throw new Error("Memory search limit is invalid.");let c=await l.request({contractVersion:h,requestId:It(),operation:"harness/memory/search",params:{workspaceId:await e(t.session),query:o,limit:a}});return{toolCallId:t.callId,name:"memory_search",ok:!0,contentText:JSON.stringify(c),data:c}},"execute")},{name:"memory_inspect",description:"Read one exact active memory entry returned by memory_search.",parameters:{type:"object",additionalProperties:!1,properties:{key:{type:"string",minLength:1,maxLength:120}},required:["key"]},execute:r(async t=>{let o=t.args.key;if(typeof o!="string"||!/^[a-z0-9][a-z0-9-]{0,119}$/.test(o))throw new Error("Memory key is invalid.");let a=await l.request({contractVersion:h,requestId:It(),operation:"harness/memory/get",params:{workspaceId:await e(t.session),key:o}});if(!a||typeof a!="object"||Array.isArray(a)||a.status!=="active")throw new Error(`Harness memory does not exist: ${o}.`);return{toolCallId:t.callId,name:"memory_inspect",ok:!0,contentText:JSON.stringify(a),data:a}},"execute")}]}r(kt,"createHostedHarnessMemoryTools");import{randomUUID as At}from"node:crypto";function Ct(l){return[{name:"work_list_outputs",description:"List this conversation's published outputs from completed turns without starting sandbox compute. Use this before reading a previously saved file; returns exact file IDs and revisions. New workspace files are published after the current turn ends. Inspect those with workspace tools and finish the turn instead of polling this list.",parameters:{type:"object",additionalProperties:!1,properties:{}},execute:r(async e=>{let t=await l.request({contractVersion:h,requestId:At(),operation:"output/list",params:{}});return{toolCallId:e.callId,name:"work_list_outputs",ok:!0,contentText:JSON.stringify(t),data:t}},"execute")},{name:"work_read_output",description:"Read the actual saved text/Markdown or PDF text of a file returned by work_list_outputs, without starting sandbox compute. Prefer this for questions about saved outputs. Use workspace tools for edits, execution and unsaved files. PDF text extraction does not inspect images or page appearance.",parameters:{type:"object",additionalProperties:!1,properties:{fileId:{type:"string",minLength:1,maxLength:191},revision:{type:"integer",minimum:1},offset:{type:"integer",minimum:0,maximum:1e7},maxChars:{type:"integer",minimum:1,maximum:1e5},firstPage:{type:"integer",minimum:1,maximum:1e3},pageCount:{type:"integer",minimum:1,maximum:10}},required:["fileId","revision"]},execute:r(async e=>{let t=await l.request(z.parse({contractVersion:h,requestId:At(),operation:"output/read",params:e.args}),6e4);return{toolCallId:e.callId,name:"work_read_output",ok:!0,contentText:JSON.stringify(t),data:t}},"execute")}]}r(Ct,"createHostedWorkOutputTools");import{randomUUID as Ot}from"node:crypto";function _t(l,e){return{allowedTools:e,authorizeTool:r(async t=>{let o=await l.request({contractVersion:h,requestId:Ot(),operation:"embedding/authorize",params:{sessionId:t.session.id,turnId:t.turnId,name:t.name}});if(!o||typeof o!="object"||Array.isArray(o)||o.allowed!==!0)throw new Error("Hosted tool authorization denied.")},"authorizeTool")}}r(_t,"createHostedEmbeddingAdapter");function qt(l){return async e=>{let t=qe.parse(e);return l.request({contractVersion:h,requestId:Ot(),operation:"sandbox/request",params:{action:t}},e.type==="create"?3e5:e.type==="exec"?18e4:6e4)}}r(qt,"createHostedSandboxRequest");var ir=["sandbox/request","embedding/authorize","output/begin","output/chunk","output/complete","output/saveSandboxFile","output/list","output/read","settings/get","harness/get","harness/overlay/get","harness/overlay/put","harness/memory/get","harness/memory/list","harness/memory/search","harness/memory/write","harness/state/read","task-inbox/execute","create-improve/execute","approval/get","approval/upsert","usage/getByRequestId","usage/upsert","usage/page","session/count","session/get","session/page","session/put","turn/count","turn/wakeCount","turn/get","turn/put","turn/latest","turn/page","thread/turnPage","event/append","events/page","events/latestAssistantText"];function Bt(l){if(ir.some(e=>!l.operations.includes(e)))throw new Error("Hosted Postgres runtime capabilities are incomplete.");if(l.maxRequestBytes<256e3||l.maxInFlight<32||l.maxPageSize<200)throw new Error("Hosted Postgres runtime transport limits are incompatible.")}r(Bt,"assertHostedWorkCapabilities");var w=r(async()=>{throw new Error("This hosted control is not available until its Postgres repository is activated.")},"unavailable"),ur=We(),cr=Ve();async function _o(l){let e=l.runtimeStorage,t=l.hostStorageClient;if(e.kind!=="hosted_postgres"||!t||e.client!==t)throw new Error("Hosted storage selection mismatch.");if(l.embedding||l.sandboxRequest)throw new Error("Hosted Postgres tool and sandbox authority must come from the host transport.");if(!l.streamOpenPondHostedChatTurn)throw new Error("Hosted Postgres runtime requires a host-admitted model stream.");if(l.profileSource||l.harness)throw new Error("Hosted Postgres runtime accepts only host-admitted immutable sources.");if(l.services&&Object.values(l.services).some(i=>i!==!1&&i!==void 0))throw new Error("Hosted service adapters must be admitted by the Postgres composition.");let o=Be.parse(await t.request({contractVersion:h,requestId:Dt(),operation:"capabilities",params:{}}));Bt(o);let a=_t(t,o.allowedTools),c=qt(t),u=W.resolve(l.storeDir??process.cwd()),s=W.resolve(l.workspaceDir??process.cwd());await lr(s,{recursive:!0});let d=st({channel:"app-server",logDir:W.join(u,"logs"),metadata:{version:l.version??Xe,runtimeVersion:Ye(),placement:"hosted_work"}}),m=e.core,f=new ae(t,u),y=e.admittedProfileRelease?await gt(t,e.admittedProfileRelease):{profile:cr,profileLibrary:ur},{appendRuntimeEvent:v,closeEventSubscribers:b,subscribeRuntimeEvents:R}=ut({logger:d,assistantDeltaFlushMs:250,store:{appendRuntimeEvent:r(i=>["harness.refiner.queued","harness.refiner.started","harness.refiner.completed","harness.refiner.failed"].includes(i.name)?f.appendRuntimeEvent(i):m.appendRuntimeEvent(i),"appendRuntimeEvent"),runtimeEventPageRows:r(i=>m.runtimeEventPageRows(i),"runtimeEventPageRows")}}),p=X({queueId:"turn-follow-up",logger:d}),S=X({queueId:"subagent",logger:d}),x=nt(l.streamOpenPondHostedChatTurn,{enabled:at()}),E=X({queueId:"harness-refiner",logger:d,concurrency:1}),B=St({store:f,storeDir:u,queue:E,streamOpenPondHostedChatTurn:x,appendRuntimeEvent:v,upsertModelUsageRecord:r(i=>f.upsertModelUsageRecord(i),"upsertModelUsageRecord"),prepareReview:r(i=>f.prepareReview(i),"prepareReview"),loadActiveRefinerRelease:r(async()=>{let i=await O(t);if(!i)throw new Error("Hosted review has no admitted Harness workspace.");return xt(t,i.workspace.id)},"loadActiveRefinerRelease")}),Re=r(async()=>(await ye(t)).preferences,"preferences"),{createSession:ne,getSession:D,updateSession:ie,completeTurn:Mt,failTurn:zt,interruptTurn:jt}=dt({store:m,defaultSessionCwd:r(()=>s,"defaultSessionCwd"),appendRuntimeEvent:v,loadAppPreferences:Re,loadLastUsedProfile:r(async()=>y.profileLibrary.lastUsed,"loadLastUsedProfile")}),le=lt({workspaceDir:s,logger:d,getSession:D,updateSession:ie,appendRuntimeEvent:v,sandboxRequest:c,sandboxCreationMode:"hosted_worker"}),V=ot({appendRuntimeEvent:v,findLocalProject:r(async()=>null,"findLocalProject"),onRepositoryInstructionDiagnostic:r((i,P)=>d.warn("repository instruction file skipped",{diagnostic:i,sessionId:P.id}),"onRepositoryInstructionDiagnostic")}),Nt=new ee(t),L=new oe(t),Se=Ht(t),ue=Pt(t),G=e.admittedProfileRelease?.hostExecution?await O(t,e.admittedProfileRelease.harnessRelease):null;if(e.admittedProfileRelease?.hostExecution&&(!G||!o.operations.includes("output/readBytes")||!o.operations.includes("profile-evaluations/sandbox")||!o.operations.includes("profile-evaluations/grade")))throw new Error("Hosted evaluation requires its admitted release, managed artifact owner and private sandbox grader.");let Ft=tt({deviceId:"hosted-evaluation",storeDir:u,runtimeEventsForSession:r(i=>m.runtimeEventsForSession(i),"runtimeEventsForSession"),managedPersistence:{...Se.persistence,sourceTurnStartedAt:r(async(i,P)=>{let H=await m.getTurn(P);if(!H||H.sessionId!==i||!H.startedAt)throw new Error("The managed output has no actual started case turn.");return H.startedAt},"sourceTurnStartedAt")}}),k=G?ft({readOutput:ue.readOutput,executeCommand:ue.execute,settleRemote:ue.settle,runtimeNode:"node",runtimeAgentRoot:"/workspace/runtime",storeDir:u,release:G.release,getSession:D,getTurn:r(i=>m.getTurn(i),"getTurn"),saveOutput:Ft.saveOwnedOutputBytes,recordOutput:r(async(i,P,H)=>{await v({id:Dt(),timestamp:new Date().toISOString(),name:"workspace_action_result",source:"server",sessionId:i,turnId:P,action:"work_output_save",status:"completed",data:H})},"recordOutput"),authorize:r(async()=>{let i=await O(t,e.admittedProfileRelease.harnessRelease);if(!i||i.release.harnessRelease.contentHash!==G.release.harnessRelease.contentHash)throw new Error("The hosted isolated evaluation source authority changed.")},"authorize")}):null,Ut=mt(a,async(i,P)=>{let H=await m.getTurn(i);if(!H)throw new Error("Embedded turn is unavailable.");let C=await D(H.sessionId),$=C.metadata?.embeddingToolBindings,N=[...P].sort((K,Wt)=>K.name.localeCompare(Wt.name));if($!==void 0&&g($)!==g(N))throw new Error("Embedded tool bindings changed; start a new thread.");await ie(C.id,{metadata:{...C.metadata,embeddingToolBindings:N}}),await m.updateTurn(i,K=>({...K,metadata:{...K.metadata,toolBindings:N}}))}),T=ct({executionHost:"embedded",workInputsForSession:l.workInputsForSession,attachmentRootDir:W.join(u,"attachments"),isolatedProfileEvaluationForTurn:k?async i=>{if(i.metadata?.profileEvaluationRun===void 0)return!1;if(!k.ownsSession(i.id))throw new Error("The hosted evaluation has no actual isolated case owner.");return!0}:void 0,executeProfileEvaluationAction:k?.executeAction,resolveModelTools:r(i=>k?.ownsSession(i.session.id)?k.resolveTools(i):Ut(i),"resolveModelTools"),hostedToolFlags:{toolMode:"native",nativeToolTransport:!0,nativeToolProviderDenylist:[],textToolFallback:!1},store:m,inboxStore:e.inbox,createSession:ne,getSession:D,updateSession:ie,completeTurn:Mt,failTurn:zt,interruptTurn:jt,upsertApproval:r(i=>m.upsertApproval(i),"upsertApproval"),defaultSessionCwd:r(()=>s,"defaultSessionCwd"),findOpenPondApp:r(async i=>({id:i||Fe(s),name:W.basename(s)||"Workspace",description:null,visibility:"private",sandbox:!0}),"findOpenPondApp"),resolveSessionWorkspaceCwd:r(async i=>i.cwd?.trim()||s,"resolveSessionWorkspaceCwd"),ensureCodexRuntime:r(async()=>{throw new Error("Codex process hosting is unavailable.")},"ensureCodexRuntime"),appendWorkspaceDiffEvent:le.appendWorkspaceDiffEvent,workspaceDiffBaseline:le.workspaceDiffBaseline,appendRuntimeEvent:v,executeWorkspaceTool:le.executeWorkspaceTool,executeOpenPondCommand:r(async()=>{throw new Error("Hosted commands require durable authorization.")},"executeOpenPondCommand"),loadOpenPondProfileState:r(async()=>y.profile,"loadOpenPondProfileState"),loadOpenPondProfileLibrary:r(async()=>y.profileLibrary,"loadOpenPondProfileLibrary"),readOpenPondProfileSkill:w,loadSelectedHarnessRuntime:r(i=>{if(i.currentProfile&&(!e.admittedProfileRelease||i.currentProfile.repositoryId!==e.admittedProfileRelease.repositoryId||i.currentProfile.profileId!==e.admittedProfileRelease.profileId))throw new Error("Hosted Profile session lacks admitted immutable source.");return te(t,i)},"loadSelectedHarnessRuntime"),ensureHarnessRunOverlay:r(i=>Nt.ensureHarnessRunOverlay(i),"ensureHarnessRunOverlay"),processHarnessImprovementBoundary:B,harnessModelTools:[...kt(t),...Ct(t)],loadBuiltInOpenPondSkills:r(async()=>[],"loadBuiltInOpenPondSkills"),readBuiltInOpenPondSkill:w,loadPersonalizationSoul:r(async()=>(await ye(t)).personalizationSoul,"loadPersonalizationSoul"),loadAppPreferences:Re,maybeCreateScaffoldForTurn:V.maybeCreateScaffoldForTurn,hostedSystemPrompt:V.hostedSystemPrompt,appendAssistantText:V.appendAssistantText,appendHostedContextUsage:V.appendHostedContextUsage,streamOpenPondHostedChatTurn:x,turnFollowUpQueue:p,subagentQueue:S,maxHostedWorkspaceToolRounds:et(l.maxHostedWorkspaceToolRounds),maxRepeatedInvalidToolRequests:3});await T.recoverPendingSubagentCompletions(),await T.recoverTaskInbox();let Pe=!1,He=r(async(i,P)=>{if(Z.parse(P).attachments?.length&&!k?.ownsSession(i))throw new Error("Hosted attachments require managed-file admission.");let H=await D(i);if(H.currentProfile&&(!e.admittedProfileRelease||H.currentProfile.repositoryId!==e.admittedProfileRelease.repositoryId||H.currentProfile.profileId!==e.admittedProfileRelease.profileId))throw new Error("Hosted Profile session lacks admitted immutable source.");return Pe||(await B.reconcilePending(),await E.drain(),Pe=!0),T.sendTurn(i,P)},"sendTurn");if(l.profileExternalDataset&&!e.admittedProfileRelease?.hostExecution)throw new Error("External Dataset requires its admitted hosted evaluation.");let A=e.admittedProfileRelease?.hostExecution?await Et({client:t,core:m,release:e.admittedProfileRelease,storeDir:u,...l.profileExternalDataset?{externalDataset:l.profileExternalDataset}:{},readManagedArtifact:Se.read,admitSession:k.admitSession,settleSession:k.settleSession,createSession:ne,sendTurn:He,interruptSessionTurn:T.interruptSessionTurn}):null,Ee=!1;return{...rt({ports:it({bindHome:!1,placement:"hosted_work",connectedAppProviders:[],featureOverrides:{profileWorkflows:!!e.admittedProfileRelease,profileEvaluations:!!A,harnessProposalReview:!1,harnessEvaluationReview:!1,harnessEvaluationReviewAcceptance:!1,harnessEvaluationTasksetMaterialization:!1,harnessEvaluationBaseline:!1,harnessBackgroundReview:!1,harnessDiff:!1,harnessRollback:!1,harnessReview:!1,refinerProfiles:!1,immutableRefinerAdmission:!1},createSession:ne,getSession:D,turnsForSession:r(i=>m.turnsForSession(i,1e3),"turnsForSession"),runtimeEventsForSession:r(i=>m.runtimeEventsForSession(i,{excludeReasoningDeltas:!0}),"runtimeEventsForSession"),sendTurn:He,steerSessionTurn:T.steerSessionTurn,readTaskInbox:T.readTaskInbox,queueTaskInput:T.queueTaskInput,updateTaskInput:T.updateTaskInput,isSessionTurnActive:T.isSessionTurnActive,waitForSessionTurnSettlement:T.waitForSessionTurnSettlement,interruptSessionTurn:T.interruptSessionTurn,resolveApproval:r(async(i,P)=>{let H=await T.resolveCreateImproveApproval(i,P);if(H)return H;let C=await T.resolveSubagentPatchApplyApproval(i,P);if(C)return C;throw new Error(`Approval not found: ${i}`)},"resolveApproval"),listProfileWorkflows:e.admittedProfileRelease?()=>re(t,e.admittedProfileRelease):w,listProfileEvaluations:A?.listProfileEvaluations??w,loadProfileTrainingSource:w,prepareProfileEvaluationRun:A?.prepareProfileEvaluationRun??w,runPreparedProfileEvaluation:A?.runPreparedProfileEvaluation??w,runProfileEvaluationSuite:A?.runProfileEvaluationSuite??w,executeProfileEvaluationCase:A?.executeProfileEvaluationCase??w,executeProfileEvaluationRun:A?.executeProfileEvaluationRun??w,compareProfileEvaluationRuns:A?.compareProfileEvaluationRuns??w,buildProfileEvaluationReport:A?.buildProfileEvaluationReport??w,inspectHarness:r(async()=>{let i=await O(t);if(!i)return null;let P=i.workspace.id,[H,C,$,N]=await Promise.all([L.getPreference(P,"workspace_settings"),L.getPreference(P,"evaluation_review_settings"),L.listCandidates(P),L.listCrossRunRequests(P)]);return{workspace:i.workspace,release:i.release,backgroundReview:H,evaluationReview:C,refinementCandidates:$,crossRunRequests:N}},"inspectHarness"),reviewHarnessProposal:w,reviewHarness:w,acceptHarnessEvaluationReview:w,materializeHarnessEvaluationTaskset:w,runHarnessEvaluationBaseline:w,validateHarness:r(async()=>{let i=await O(t);return i?{valid:!0,workspaceId:i.workspace.id,harnessRelease:i.release.harnessRelease,agentSnapshot:i.release.agentSnapshot}:{valid:!1,reason:"No admitted hosted Harness release."}},"validateHarness"),updateHarnessBackgroundReview:w,diffHarness:w,rollbackHarness:w,inspectRefiner:w,updateRefiner:w,activateRefiner:w,rollbackRefiner:w,subscribeRuntimeEvents:R,observeRuntimeOperation:r(i=>d.info("agent runtime operation",i),"observeRuntimeOperation")}),close:r(async()=>{Ee||(Ee=!0,k?.close(),await T.close(),await Promise.all([p.drain(),S.drain(),E.drain()]),await b(),await d.flush())},"close")}),storePath:"hosted-postgres",workspaceDir:s,composition:["runtime_event_bus","session_store","hosted_provider","workspace_tools","command_approvals","harness","agent_runtime","jsonl_transport"]}}r(_o,"createHostedOwnedAppServer");export{_o as createHostedOwnedAppServer};
|