openpond 0.2.24 → 0.2.25
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-AOSX4AH5.js → app-server-runtime-QIIJ3KQJ.js} +1 -1
- package/dist/chunks/{chunk-K5IJNSHP.js → chunk-3YSCXFE6.js} +3 -3
- package/dist/chunks/{chunk-4D3JNBSP.js → chunk-5WFXFKLA.js} +2 -2
- package/dist/chunks/{chunk-NVVETL4F.js → chunk-JTX6QZEP.js} +1 -1
- package/dist/chunks/{chunk-B3LJ777T.js → chunk-RBQZVQQM.js} +1 -1
- package/dist/chunks/{chunk-WTZYPCLS.js → chunk-UBHTZJEV.js} +1 -1
- package/dist/chunks/{cli-WZ5H6EPA.js → cli-GGYPZNZC.js} +1 -1
- package/dist/chunks/{src-DT7YDHH6.js → src-R3FALV6F.js} +101 -101
- package/dist/chunks/{workspaces-QCCYGHZG.js → workspaces-RAHQXYWB.js} +1 -1
- package/dist/cli.js +1 -1
- package/package.json +1 -1
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{fd as r}from"./chunks/chunk-
|
|
2
|
+
import{fd as r}from"./chunks/chunk-5WFXFKLA.js";import"./chunks/chunk-JTX6QZEP.js";import{j as e,t as p}from"./chunks/chunk-3YSCXFE6.js";import"./chunks/chunk-RBQZVQQM.js";import"./chunks/chunk-WK5HTGXV.js";import"./chunks/chunk-M4CJXPMH.js";import"./chunks/chunk-XEOEKFG6.js";import"./chunks/chunk-TR37PJIQ.js";import"./chunks/chunk-6MI4KKWF.js";import"./chunks/chunk-SDO4FC4Q.js";import"./chunks/chunk-IR3YJWPW.js";import"./chunks/chunk-4KDHMGKI.js";import"./chunks/chunk-J2S7BOZU.js";import"./chunks/chunk-D6BBQHZM.js";import"./chunks/chunk-6FA3GG5B.js";import"./chunks/chunk-F4WS5QIT.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{ed as c,fd as d}from"./chunk-
|
|
2
|
+
import{ed as c,fd as d}from"./chunk-5WFXFKLA.js";import"./chunk-JTX6QZEP.js";import{j as a,t as b}from"./chunk-3YSCXFE6.js";import"./chunk-RBQZVQQM.js";import"./chunk-WK5HTGXV.js";import"./chunk-M4CJXPMH.js";import"./chunk-XEOEKFG6.js";import"./chunk-TR37PJIQ.js";import"./chunk-6MI4KKWF.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-4KDHMGKI.js";import"./chunk-J2S7BOZU.js";import"./chunk-D6BBQHZM.js";import"./chunk-6FA3GG5B.js";import"./chunk-F4WS5QIT.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};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{Bb as O,c as j,e as E,f as z,g as H,i as N}from"./chunk-F4WS5QIT.js";import{b as i}from"./chunk-ES2ISFJC.js";import{a as k,c as I,f as A,h as d}from"./chunk-H7IWJN7L.js";import{a}from"./chunk-FTQLQJQV.js";import b from"node:path";import{AsyncLocalStorage as V}from"node:async_hooks";import{promises as M}from"node:fs";var B=new V;function pe(e,t=!1){let n=B.getStore();n&&(t&&(n.length=0),n.push(e))}a(pe,"onStartupFailure");async function fe(e,t){await O(e);let n;try{n=await H(b.join(d(e).runtime,"server-owner"),100)}catch(s){if(s instanceof I&&s.issue.code==="STORAGE_BUSY"){let o=await N(b.join(d(e).runtime,"endpoint.json"),()=>null);throw new I({code:"RUNTIME_ALREADY_RUNNING",path:e,message:"An OpenPond runtime already owns this home.",action:o?.url?`Connect to the existing runtime at ${o.url}, or stop it before starting another.`:"Stop the existing runtime before starting another with this home."})}throw s}let r=[];try{let s=await k(e,()=>B.run(r,t)),o=s.close.bind(s);r.length=0;let l;return{...s,close:a(()=>l??=(async()=>{try{await k(e,o)}finally{await M.rm(b.join(d(e).runtime,"endpoint.json"),{force:!0}),await n()}})(),"close")}}catch(s){try{for(let o of r.reverse())await Promise.resolve().then(()=>k(e,o)).catch(()=>{});await M.rm(b.join(d(e).runtime,"endpoint.json"),{force:!0})}finally{await n()}throw s}}a(fe,"ownHomeRuntime");async function me(e,t,n){await E(b.join(d(e).runtime,"endpoint.json"),JSON.stringify({schemaVersion:"openpond.runtimeEndpoint.v1",pid:process.pid,url:t,serverId:n}))}a(me,"publishRuntimeEndpoint");function ge(e){if(!e.maxContextTokens||!e.usableContextTokens)return{shouldCompact:!1,projectedTokens:e.projectedTokens,thresholdTokens:Number.MAX_SAFE_INTEGER,usableContextTokens:0,maxContextTokens:0,tokenSource:"heuristic"};let t=Math.max(.01,Math.min(1,(e.triggerPercent??85)/100)),n=Math.max(1,Math.floor(e.usableContextTokens*t));return{shouldCompact:e.projectedTokens>=n,projectedTokens:e.projectedTokens,thresholdTokens:n,usableContextTokens:e.usableContextTokens,maxContextTokens:e.maxContextTokens,tokenSource:"heuristic"}}a(ge,"agentCompactionDecision");async function be(e){await e.started();try{return await e.compact()}catch(t){throw await e.failed(t),t}}a(be,"runAgentCompaction");async function xe(e){let t=e.host.projectEvents(e.events),n=e.host.selectEvents(t,e.maxContextTokens),{summaryEvents:r,preservedEvents:s,preservedEventIds:o}=n;if(r.length===0)throw new Error("There is not enough prior context to compact.");let l=e.host.normalizeRecords(r),c=e.host.normalizeRecords(s),h=e.host.buildFileLedger(e.host.normalizeRecords(t)),u=e.host.serializeRecords(l,e.host.inputCharBudget(e.maxContextTokens));if(!u.text.trim())throw new Error("There is not enough prior context to compact.");let p=e.host.buildSummaryMessages({serializedHistory:u.text,fileLedger:h}),v=Date.now(),w=(await e.host.streamSummary({model:e.model,messages:p,signal:e.signal})).trim(),R=Date.now()-v;if(!w)throw new Error("Compaction summary was empty.");let P=e.host.estimateProjection({events:t,preservedEvents:s,summary:w}),_=e.host.createMetrics({sourceEvents:t.length,summarizedEvents:r.length,preservedEvents:s.length,sourceRecords:u.sourceRecordCount,includedRecords:u.includedRecordCount,omittedRecords:u.omittedRecordCount,preservedRecords:c.length,truncatedRecords:u.truncatedRecordCount,summaryInputTruncated:u.inputTruncated,sourceSelectionStrategy:u.selectionStrategy,summaryInputChars:u.inputChars,retainedTailTokens:n.retainedTailTokens,retainedTailBudgetTokens:n.retainedTailBudgetTokens,finalProviderContextTokens:P.inputTokensAfter,durationMs:R,fileLedgerEntries:h.length,splitTurnId:n.splitTurnId});return{summary:w,model:e.model,compactedThroughEventId:t[t.length-1]?.id??null,compactedThroughTurnId:e.host.lastTurnId(t),preservedFromEventId:s[0]?.id??null,preservedEventIds:o,preservedResourceRefs:e.host.durableResourceRefs(e.events),sourceEventCount:r.length,preservedEventCount:s.length,fileLedger:h,inputTokensBefore:P.inputTokensBefore,inputTokensAfter:P.inputTokensAfter,maxContextTokens:e.maxContextTokens,tokenSource:"heuristic",metrics:_}}a(xe,"runAgentCompactionProgram");var y="2026-09-20",ye=["initialize","initialized","runtime/capabilities","thread/start","thread/resume","thread/read","turn/start","turn/steer","task/inbox","task/queue","task/inputUpdate","turn/interrupt","approval/resolve","userInput/resolve","profile/workflows","profile/evaluations","profile/trainingSource","profile/evaluations/prepare","profile/evaluations/run","profile/evaluations/runSuite","profile/evaluations/executeCase","profile/evaluations/executeRun","profile/evaluations/compare","profile/evaluations/report","harness/inspect","harness/proposalReview","harness/review","harness/acceptEvaluationReview","harness/materializeEvaluationTaskset","harness/runEvaluationBaseline","harness/validate","harness/backgroundReview","harness/diff","harness/rollback","refiner/inspect","refiner/update","refiner/activate","refiner/rollback"],U=i.object({jsonrpc:i.literal("2.0"),id:i.union([i.string(),i.number()]),method:i.string().trim().min(1),params:i.unknown().optional()}).strict(),$=i.object({jsonrpc:i.literal("2.0"),method:i.string().trim().min(1),params:i.unknown().optional()}).strict(),G=i.object({jsonrpc:i.literal("2.0"),id:i.union([i.string(),i.number()]),result:i.unknown()}).strict(),W=i.object({jsonrpc:i.literal("2.0"),id:i.union([i.string(),i.number(),i.null()]),error:i.object({code:i.number().int(),message:i.string(),data:i.unknown().optional()}).strict()}).strict(),Se=i.union([U,$,G,W]),K=i.object({protocolVersion:i.string().trim().min(1),client:i.object({name:i.string().trim().min(1),version:i.string().trim().min(1)}).strict(),capabilities:i.record(i.string(),i.unknown()).default({})}).strict(),S=class{static{a(this,"AgentJsonRpcDispatcher")}#e;#r=null;#t=!1;constructor(t){this.#e=t}get initialized(){return this.#t}async handle(t){let n=$.safeParse(t);if(n.success&&!("id"in t)){if(n.data.method==="initialized"){if(!this.#r)throw new f(-32002,"initialize must be called first");this.#t=!0}return null}let r=U.safeParse(t);if(!r.success)return q(null,-32600,"Invalid Request",r.error.flatten());let s=r.data;try{let o=await this.#n(s.method,s.params);return{jsonrpc:"2.0",id:s.id,result:o}}catch(o){let l=o instanceof f?o:new f(-32603,o instanceof Error?o.message:String(o));return q(s.id,l.code,l.message,l.data)}}async#n(t,n){if(t==="initialize"){let r=K.parse(n);if(r.protocolVersion!==y)throw new f(-32001,"Incompatible agent protocol version",{requested:r.protocolVersion,supported:y});return this.#r=r,{protocolVersion:y,server:{name:"openpond-app-server",version:"1"},capabilities:await this.#e.capabilities()}}if(!this.#t)throw new f(-32002,"initialized notification is required");switch(t){case"runtime/capabilities":return this.#e.capabilities(n);case"thread/start":return this.#e.threadStart(n);case"thread/resume":return this.#e.threadResume(n);case"thread/read":return this.#e.threadRead(n);case"turn/start":return this.#e.turnStart(n);case"turn/steer":return this.#e.turnSteer(n);case"task/inbox":return this.#e.taskInbox(n);case"task/queue":return this.#e.taskQueue(n);case"task/inputUpdate":return this.#e.taskInputUpdate(n);case"turn/interrupt":return this.#e.turnInterrupt(n);case"approval/resolve":return this.#e.approvalResolve(n);case"userInput/resolve":return this.#e.userInputResolve(n);case"profile/workflows":return this.#e.profileWorkflows(n);case"profile/evaluations":return this.#e.profileEvaluations(n);case"profile/trainingSource":return this.#e.profileTrainingSource(n);case"profile/evaluations/prepare":return this.#e.profileEvaluationPrepare(n);case"profile/evaluations/run":return this.#e.profileEvaluationRun(n);case"profile/evaluations/runSuite":return this.#e.profileEvaluationRunSuite(n);case"profile/evaluations/executeCase":return this.#e.profileEvaluationExecuteCase(n);case"profile/evaluations/executeRun":return this.#e.profileEvaluationExecuteRun(n);case"profile/evaluations/compare":return this.#e.profileEvaluationCompare(n);case"profile/evaluations/report":return this.#e.profileEvaluationReport(n);case"harness/inspect":return this.#e.harnessInspect(n);case"harness/proposalReview":return this.#e.harnessProposalReview(n);case"harness/review":return this.#e.harnessReview(n);case"harness/acceptEvaluationReview":return this.#e.harnessAcceptEvaluationReview(n);case"harness/materializeEvaluationTaskset":return this.#e.harnessMaterializeEvaluationTaskset(n);case"harness/runEvaluationBaseline":return this.#e.harnessRunEvaluationBaseline(n);case"harness/validate":return this.#e.harnessValidate(n);case"harness/backgroundReview":return this.#e.harnessBackgroundReview(n);case"harness/diff":return this.#e.harnessDiff(n);case"harness/rollback":return this.#e.harnessRollback(n);case"refiner/inspect":return this.#e.refinerInspect(n);case"refiner/update":return this.#e.refinerUpdate(n);case"refiner/activate":return this.#e.refinerActivate(n);case"refiner/rollback":return this.#e.refinerRollback(n);default:throw new f(-32601,`Method not found: ${t}`)}}},f=class extends Error{static{a(this,"JsonRpcDispatchError")}code;data;constructor(t,n,r){super(n),this.code=t,this.data=r}};function q(e,t,n,r){return{jsonrpc:"2.0",id:e,error:{code:t,message:n,...r===void 0?{}:{data:r}}}}a(q,"jsonRpcError");import{createHash as Q}from"node:crypto";function C(e){if(e===null||typeof e=="boolean"||typeof e=="string")return e;if(typeof e=="number"){if(!Number.isFinite(e))throw new Error("Canonical JSON cannot encode a non-finite number.");return e}if(Array.isArray(e))return e.map(C);if(typeof e=="object"){let t={};for(let n of Object.keys(e).sort()){let r=e[n];r!==void 0&&(t[n]=C(r))}return t}throw new Error(`Canonical JSON cannot encode ${typeof e}.`)}a(C,"canonicalJson");function g(e){return Q("sha256").update(JSON.stringify(C(e)),"utf8").digest("hex")}a(g,"canonicalHash");var Y=i.enum(["thread.started","thread.resumed","turn.started","turn.steered","turn.interrupted","turn.completed","turn.failed","item.started","item.delta","item.completed","assistant.reasoning.delta","assistant.delta","tool.started","tool.completed","approval.requested","approval.resolved","user_input.requested","user_input.resolved","compaction.started","compaction.completed","harness.admitted","harness.refiner.queued","harness.refiner.started","harness.refiner.completed","harness.refiner.failed","diagnostic"]),X=i.object({sequence:i.number().int().nonnegative(),name:Y,source:i.enum(["runtime","provider","tool","host","refiner"]),status:i.string().trim().min(1).nullable().default(null),threadId:i.string().trim().min(1),turnId:i.string().trim().min(1).nullable().default(null),callId:i.string().trim().min(1).nullable().default(null),output:i.string().nullable().default(null),error:i.string().nullable().default(null),data:i.record(i.string(),i.unknown()).default({})}).strict();function He(e){return g(X.parse(e))}a(He,"canonicalEventHash");import{once as Z}from"node:events";import{createInterface as ee}from"node:readline";async function D(e){let t=new S(e.host),n=Promise.resolve(),r=[],s=a(u=>(n=n.then(async()=>{e.writable.write(`${JSON.stringify(u)}
|
|
3
|
-
`)||await Z(e.writable,"drain")}),n),"write"),o=a(()=>{if(!(!
|
|
2
|
+
import{Bb as O,c as j,e as E,f as z,g as H,i as N}from"./chunk-F4WS5QIT.js";import{b as i}from"./chunk-ES2ISFJC.js";import{a as k,c as I,f as A,h as d}from"./chunk-H7IWJN7L.js";import{a}from"./chunk-FTQLQJQV.js";import b from"node:path";import{AsyncLocalStorage as V}from"node:async_hooks";import{promises as M}from"node:fs";var B=new V;function pe(e,r=!1){let n=B.getStore();n&&(r&&(n.length=0),n.push(e))}a(pe,"onStartupFailure");async function fe(e,r){await O(e);let n;try{n=await H(b.join(d(e).runtime,"server-owner"),100)}catch(s){if(s instanceof I&&s.issue.code==="STORAGE_BUSY"){let o=await N(b.join(d(e).runtime,"endpoint.json"),()=>null);throw new I({code:"RUNTIME_ALREADY_RUNNING",path:e,message:"An OpenPond runtime already owns this home.",action:o?.url?`Connect to the existing runtime at ${o.url}, or stop it before starting another.`:"Stop the existing runtime before starting another with this home."})}throw s}let t=[];try{let s=await k(e,()=>B.run(t,r)),o=s.close.bind(s);t.length=0;let l;return{...s,close:a(()=>l??=(async()=>{try{await k(e,o)}finally{await M.rm(b.join(d(e).runtime,"endpoint.json"),{force:!0}),await n()}})(),"close")}}catch(s){try{for(let o of t.reverse())await Promise.resolve().then(()=>k(e,o)).catch(()=>{});await M.rm(b.join(d(e).runtime,"endpoint.json"),{force:!0})}finally{await n()}throw s}}a(fe,"ownHomeRuntime");async function me(e,r,n){await E(b.join(d(e).runtime,"endpoint.json"),JSON.stringify({schemaVersion:"openpond.runtimeEndpoint.v1",pid:process.pid,url:r,serverId:n}))}a(me,"publishRuntimeEndpoint");function ge(e){if(!e.maxContextTokens||!e.usableContextTokens)return{shouldCompact:!1,projectedTokens:e.projectedTokens,thresholdTokens:Number.MAX_SAFE_INTEGER,usableContextTokens:0,maxContextTokens:0,tokenSource:"heuristic"};let r=Math.max(.01,Math.min(1,(e.triggerPercent??85)/100)),n=Math.max(1,Math.floor(e.usableContextTokens*r));return{shouldCompact:e.projectedTokens>=n,projectedTokens:e.projectedTokens,thresholdTokens:n,usableContextTokens:e.usableContextTokens,maxContextTokens:e.maxContextTokens,tokenSource:"heuristic"}}a(ge,"agentCompactionDecision");async function be(e){await e.started();try{return await e.compact()}catch(r){throw await e.failed(r),r}}a(be,"runAgentCompaction");async function xe(e){let r=e.host.projectEvents(e.events),n=e.host.selectEvents(r,e.maxContextTokens),{summaryEvents:t,preservedEvents:s,preservedEventIds:o}=n;if(t.length===0)throw new Error("There is not enough prior context to compact.");let l=e.host.normalizeRecords(t),c=e.host.normalizeRecords(s),h=e.host.buildFileLedger(e.host.normalizeRecords(r)),u=e.host.serializeRecords(l,e.host.inputCharBudget(e.maxContextTokens));if(!u.text.trim())throw new Error("There is not enough prior context to compact.");let p=e.host.buildSummaryMessages({serializedHistory:u.text,fileLedger:h}),v=Date.now(),w=(await e.host.streamSummary({model:e.model,messages:p,signal:e.signal})).trim(),R=Date.now()-v;if(!w)throw new Error("Compaction summary was empty.");let P=e.host.estimateProjection({events:r,preservedEvents:s,summary:w}),_=e.host.createMetrics({sourceEvents:r.length,summarizedEvents:t.length,preservedEvents:s.length,sourceRecords:u.sourceRecordCount,includedRecords:u.includedRecordCount,omittedRecords:u.omittedRecordCount,preservedRecords:c.length,truncatedRecords:u.truncatedRecordCount,summaryInputTruncated:u.inputTruncated,sourceSelectionStrategy:u.selectionStrategy,summaryInputChars:u.inputChars,retainedTailTokens:n.retainedTailTokens,retainedTailBudgetTokens:n.retainedTailBudgetTokens,finalProviderContextTokens:P.inputTokensAfter,durationMs:R,fileLedgerEntries:h.length,splitTurnId:n.splitTurnId});return{summary:w,model:e.model,compactedThroughEventId:r[r.length-1]?.id??null,compactedThroughTurnId:e.host.lastTurnId(r),preservedFromEventId:s[0]?.id??null,preservedEventIds:o,preservedResourceRefs:e.host.durableResourceRefs(e.events),sourceEventCount:t.length,preservedEventCount:s.length,fileLedger:h,inputTokensBefore:P.inputTokensBefore,inputTokensAfter:P.inputTokensAfter,maxContextTokens:e.maxContextTokens,tokenSource:"heuristic",metrics:_}}a(xe,"runAgentCompactionProgram");var y="2026-09-20",ye=["initialize","initialized","runtime/capabilities","thread/start","thread/resume","thread/read","turn/start","turn/steer","task/inbox","task/queue","task/inputUpdate","turn/interrupt","approval/resolve","userInput/resolve","profile/workflows","profile/evaluations","profile/trainingSource","profile/evaluations/prepare","profile/evaluations/run","profile/evaluations/runSuite","profile/evaluations/executeCase","profile/evaluations/executeRun","profile/evaluations/compare","profile/evaluations/report","harness/inspect","harness/proposalReview","harness/review","harness/acceptEvaluationReview","harness/materializeEvaluationTaskset","harness/runEvaluationBaseline","harness/validate","harness/backgroundReview","harness/diff","harness/rollback","refiner/inspect","refiner/update","refiner/activate","refiner/rollback"],U=i.object({jsonrpc:i.literal("2.0"),id:i.union([i.string(),i.number()]),method:i.string().trim().min(1),params:i.unknown().optional()}).strict(),$=i.object({jsonrpc:i.literal("2.0"),method:i.string().trim().min(1),params:i.unknown().optional()}).strict(),G=i.object({jsonrpc:i.literal("2.0"),id:i.union([i.string(),i.number()]),result:i.unknown()}).strict(),W=i.object({jsonrpc:i.literal("2.0"),id:i.union([i.string(),i.number(),i.null()]),error:i.object({code:i.number().int(),message:i.string(),data:i.unknown().optional()}).strict()}).strict(),Se=i.union([U,$,G,W]),K=i.object({protocolVersion:i.string().trim().min(1),client:i.object({name:i.string().trim().min(1),version:i.string().trim().min(1)}).strict(),capabilities:i.record(i.string(),i.unknown()).default({})}).strict(),S=class{static{a(this,"AgentJsonRpcDispatcher")}#e;#r=null;#t=!1;constructor(r){this.#e=r}get initialized(){return this.#t}async handle(r){let n=$.safeParse(r);if(n.success&&!("id"in r)){if(n.data.method==="initialized"){if(!this.#r)throw new f(-32002,"initialize must be called first");this.#t=!0}return null}let t=U.safeParse(r);if(!t.success)return q(null,-32600,"Invalid Request",t.error.flatten());let s=t.data;try{let o=await this.#n(s.method,s.params);return{jsonrpc:"2.0",id:s.id,result:o}}catch(o){let l=o instanceof f?o:new f(-32603,o instanceof Error?o.message:String(o));return q(s.id,l.code,l.message,l.data)}}async#n(r,n){if(r==="initialize"){let t=K.parse(n);if(t.protocolVersion!==y)throw new f(-32001,"Incompatible agent protocol version",{requested:t.protocolVersion,supported:y});return this.#r=t,{protocolVersion:y,server:{name:"openpond-app-server",version:"1"},capabilities:await this.#e.capabilities()}}if(!this.#t)throw new f(-32002,"initialized notification is required");switch(r){case"runtime/capabilities":return this.#e.capabilities(n);case"thread/start":return this.#e.threadStart(n);case"thread/resume":return this.#e.threadResume(n);case"thread/read":return this.#e.threadRead(n);case"turn/start":return this.#e.turnStart(n);case"turn/steer":return this.#e.turnSteer(n);case"task/inbox":return this.#e.taskInbox(n);case"task/queue":return this.#e.taskQueue(n);case"task/inputUpdate":return this.#e.taskInputUpdate(n);case"turn/interrupt":return this.#e.turnInterrupt(n);case"approval/resolve":return this.#e.approvalResolve(n);case"userInput/resolve":return this.#e.userInputResolve(n);case"profile/workflows":return this.#e.profileWorkflows(n);case"profile/evaluations":return this.#e.profileEvaluations(n);case"profile/trainingSource":return this.#e.profileTrainingSource(n);case"profile/evaluations/prepare":return this.#e.profileEvaluationPrepare(n);case"profile/evaluations/run":return this.#e.profileEvaluationRun(n);case"profile/evaluations/runSuite":return this.#e.profileEvaluationRunSuite(n);case"profile/evaluations/executeCase":return this.#e.profileEvaluationExecuteCase(n);case"profile/evaluations/executeRun":return this.#e.profileEvaluationExecuteRun(n);case"profile/evaluations/compare":return this.#e.profileEvaluationCompare(n);case"profile/evaluations/report":return this.#e.profileEvaluationReport(n);case"harness/inspect":return this.#e.harnessInspect(n);case"harness/proposalReview":return this.#e.harnessProposalReview(n);case"harness/review":return this.#e.harnessReview(n);case"harness/acceptEvaluationReview":return this.#e.harnessAcceptEvaluationReview(n);case"harness/materializeEvaluationTaskset":return this.#e.harnessMaterializeEvaluationTaskset(n);case"harness/runEvaluationBaseline":return this.#e.harnessRunEvaluationBaseline(n);case"harness/validate":return this.#e.harnessValidate(n);case"harness/backgroundReview":return this.#e.harnessBackgroundReview(n);case"harness/diff":return this.#e.harnessDiff(n);case"harness/rollback":return this.#e.harnessRollback(n);case"refiner/inspect":return this.#e.refinerInspect(n);case"refiner/update":return this.#e.refinerUpdate(n);case"refiner/activate":return this.#e.refinerActivate(n);case"refiner/rollback":return this.#e.refinerRollback(n);default:throw new f(-32601,`Method not found: ${r}`)}}},f=class extends Error{static{a(this,"JsonRpcDispatchError")}code;data;constructor(r,n,t){super(n),this.code=r,this.data=t}};function q(e,r,n,t){return{jsonrpc:"2.0",id:e,error:{code:r,message:n,...t===void 0?{}:{data:t}}}}a(q,"jsonRpcError");import{createHash as Q}from"node:crypto";function C(e){if(e===null||typeof e=="boolean"||typeof e=="string")return e;if(typeof e=="number"){if(!Number.isFinite(e))throw new Error("Canonical JSON cannot encode a non-finite number.");return e}if(Array.isArray(e))return e.map(C);if(typeof e=="object"){let r={};for(let n of Object.keys(e).sort()){let t=e[n];t!==void 0&&(r[n]=C(t))}return r}throw new Error(`Canonical JSON cannot encode ${typeof e}.`)}a(C,"canonicalJson");function g(e){return Q("sha256").update(JSON.stringify(C(e)),"utf8").digest("hex")}a(g,"canonicalHash");var Y=i.enum(["thread.started","thread.resumed","turn.started","turn.steered","turn.interrupted","turn.completed","turn.failed","item.started","item.delta","item.completed","assistant.reasoning.delta","assistant.delta","tool.started","tool.completed","approval.requested","approval.resolved","user_input.requested","user_input.resolved","compaction.started","compaction.completed","harness.admitted","harness.refiner.queued","harness.refiner.started","harness.refiner.completed","harness.refiner.failed","diagnostic"]),X=i.object({sequence:i.number().int().nonnegative(),name:Y,source:i.enum(["runtime","provider","tool","host","refiner"]),status:i.string().trim().min(1).nullable().default(null),threadId:i.string().trim().min(1),turnId:i.string().trim().min(1).nullable().default(null),callId:i.string().trim().min(1).nullable().default(null),output:i.string().nullable().default(null),error:i.string().nullable().default(null),data:i.record(i.string(),i.unknown()).default({})}).strict();function He(e){return g(X.parse(e))}a(He,"canonicalEventHash");import{once as Z}from"node:events";import{createInterface as ee}from"node:readline";async function D(e){let r=new S(e.host),n=Promise.resolve(),t=[],s=a(u=>(n=n.then(async()=>{e.writable.write(`${JSON.stringify(u)}
|
|
3
|
+
`)||await Z(e.writable,"drain")}),n),"write"),o=a(()=>{if(!(!r.initialized||t.length===0))for(let u of t.splice(0))s(u)},"flushPendingNotifications"),l=e.host.subscribe?.(u=>{if(!r.initialized){t.push(u);return}s(u)}),c=new Set,h=ee({input:e.readable,crlfDelay:1/0});try{for await(let u of h){if(!u.trim())continue;let p;try{p=JSON.parse(u)}catch{await s({jsonrpc:"2.0",id:null,error:{code:-32700,message:"Parse error"}});continue}let v=(async()=>{let R=await r.handle(p);R&&await s(R),o()})(),w=p&&typeof p=="object"&&"method"in p?p.method:null;if(w==="initialize"||w==="initialized"){await v;continue}c.add(v),v.finally(()=>c.delete(v))}await Promise.all(c),await n}finally{l?.()}}a(D,"runAgentJsonlServer");var T=i.object({threadId:i.string().trim().min(1)}).passthrough(),te=i.object({session:i.unknown()}).strict(),x=T.extend({input:i.unknown()}),re=x.extend({idempotencyKey:i.string().trim().min(1).max(200)}),ne=x.extend({inputId:i.string().trim().min(1)}),ae=T.extend({reason:i.string().trim().min(1).optional()}),ie=i.object({approvalId:i.string().trim().min(1),input:i.unknown()}).strict();function L(e){let r=a(async(t,s,o)=>{let l=performance.now();e.telemetry?.({method:t,phase:"started",threadId:s,durationMs:null,errorClass:null});try{let c=await o();return e.telemetry?.({method:t,phase:"completed",threadId:s,durationMs:performance.now()-l,errorClass:null}),c}catch(c){throw e.telemetry?.({method:t,phase:"failed",threadId:s,durationMs:performance.now()-l,errorClass:c instanceof Error?c.name:"UnknownError"}),c}},"run"),n=a(async(t,s="thread/read")=>{let{threadId:o}=T.parse(t);return r(s,o,async()=>{let[l,c,h]=await Promise.all([e.readThread(o),e.listTurns(o),e.listEvents(o)]);return{thread:l,turns:c,events:h}})},"threadRead");return{capabilities:a(t=>r("runtime/capabilities",null,()=>e.capabilities(t)),"capabilities"),threadStart:a(async t=>r("thread/start",null,async()=>({thread:await e.createThread(te.parse(t).session)})),"threadStart"),threadResume:a(t=>n(t,"thread/resume"),"threadResume"),threadRead:n,turnStart:a(async t=>{let s=x.parse(t);return r("turn/start",s.threadId,async()=>({turn:await e.startTurn(s.threadId,s.input)}))},"turnStart"),turnSteer:a(async t=>{let s=x.parse(t);return r("turn/steer",s.threadId,async()=>({receipt:await e.steerTurn(s.threadId,s.input)}))},"turnSteer"),taskInbox:a(async t=>{let{threadId:s}=T.parse(t);return r("task/inbox",s,()=>e.readTaskInbox(s))},"taskInbox"),taskQueue:a(async t=>{let s=re.parse(t);return r("task/queue",s.threadId,()=>e.queueTaskInput(s.threadId,s.input,s.idempotencyKey))},"taskQueue"),taskInputUpdate:a(async t=>{let s=ne.parse(t);return r("task/inputUpdate",s.threadId,()=>e.updateTaskInput(s.threadId,s.inputId,s.input))},"taskInputUpdate"),turnInterrupt:a(async t=>{let s=ae.parse(t);return r("turn/interrupt",s.threadId,async()=>({turn:await e.interruptTurn(s.threadId,s.reason)}))},"turnInterrupt"),approvalResolve:a(async t=>{let s=ie.parse(t);return r("approval/resolve",null,async()=>({approval:await e.resolveApproval(s.approvalId,s.input)}))},"approvalResolve"),userInputResolve:a(async t=>{let s=x.parse(t);return r("userInput/resolve",s.threadId,async()=>(e.isTurnActive(s.threadId)&&await e.waitForTurnSettlement(s.threadId),{turn:await e.startTurn(s.threadId,s.input)}))},"userInputResolve"),profileWorkflows:a(()=>r("profile/workflows",null,()=>e.listProfileWorkflows()),"profileWorkflows"),profileEvaluations:a(t=>r("profile/evaluations",null,()=>e.listProfileEvaluations(t)),"profileEvaluations"),profileTrainingSource:a(()=>r("profile/trainingSource",null,()=>e.loadProfileTrainingSource()),"profileTrainingSource"),profileEvaluationPrepare:a(t=>r("profile/evaluations/prepare",null,()=>e.prepareProfileEvaluationRun(t)),"profileEvaluationPrepare"),profileEvaluationRun:a(t=>r("profile/evaluations/run",null,()=>e.runPreparedProfileEvaluation(t)),"profileEvaluationRun"),profileEvaluationRunSuite:a(t=>r("profile/evaluations/runSuite",null,()=>e.runProfileEvaluationSuite(t)),"profileEvaluationRunSuite"),profileEvaluationExecuteCase:a(t=>r("profile/evaluations/executeCase",null,()=>e.executeProfileEvaluationCase(t)),"profileEvaluationExecuteCase"),profileEvaluationExecuteRun:a(t=>r("profile/evaluations/executeRun",null,()=>e.executeProfileEvaluationRun(t)),"profileEvaluationExecuteRun"),profileEvaluationCompare:a(t=>r("profile/evaluations/compare",null,()=>e.compareProfileEvaluationRuns(t)),"profileEvaluationCompare"),profileEvaluationReport:a(t=>r("profile/evaluations/report",null,()=>e.buildProfileEvaluationReport(t)),"profileEvaluationReport"),harnessInspect:a(()=>r("harness/inspect",null,()=>e.inspectHarness()),"harnessInspect"),harnessProposalReview:a(t=>r("harness/proposalReview",null,()=>e.reviewHarnessProposal(t)),"harnessProposalReview"),harnessReview:a(t=>r("harness/review",null,()=>e.reviewHarness(t)),"harnessReview"),harnessAcceptEvaluationReview:a(t=>r("harness/acceptEvaluationReview",null,()=>e.acceptHarnessEvaluationReview(t)),"harnessAcceptEvaluationReview"),harnessMaterializeEvaluationTaskset:a(t=>r("harness/materializeEvaluationTaskset",null,()=>e.materializeHarnessEvaluationTaskset(t)),"harnessMaterializeEvaluationTaskset"),harnessRunEvaluationBaseline:a(t=>r("harness/runEvaluationBaseline",null,()=>e.runHarnessEvaluationBaseline(t)),"harnessRunEvaluationBaseline"),harnessValidate:a(()=>r("harness/validate",null,()=>e.validateHarness()),"harnessValidate"),harnessBackgroundReview:a(t=>r("harness/backgroundReview",null,()=>e.updateHarnessBackgroundReview(t)),"harnessBackgroundReview"),harnessDiff:a(t=>r("harness/diff",null,()=>e.diffHarness(t)),"harnessDiff"),harnessRollback:a(t=>r("harness/rollback",null,()=>e.rollbackHarness(t)),"harnessRollback"),refinerInspect:a(()=>r("refiner/inspect",null,()=>e.inspectRefiner()),"refinerInspect"),refinerUpdate:a(t=>r("refiner/update",null,()=>e.updateRefiner(t)),"refinerUpdate"),refinerActivate:a(t=>r("refiner/activate",null,()=>e.activateRefiner(t)),"refinerActivate"),refinerRollback:a(t=>r("refiner/rollback",null,()=>e.rollbackRefiner(t)),"refinerRollback"),subscribe:e.subscribeEvents&&e.eventNotification?t=>e.subscribeEvents(s=>t(e.eventNotification(s))):void 0}}a(L,"createAgentRuntimeService");var m=i.string().regex(/^[a-f0-9]{64}$/),et=i.object({harnessReleaseHash:m,instructionsHash:m,skillHashes:i.record(i.string(),m),agentAssetHashes:i.record(i.string(),m),toolCatalogHash:m,memoryRevision:i.number().int().nonnegative().nullable()}).strict(),se=i.object({protocolVersion:i.string().trim().min(1),threadId:i.string().trim().min(1),turnId:i.string().trim().min(1),harnessReleaseHash:m,toolCatalogHash:m,context:i.record(i.string(),i.unknown()),pendingInteraction:i.record(i.string(),i.unknown()).nullable(),usage:i.record(i.string(),i.unknown())}).strict();function tt(e){return g(se.parse(e))}a(tt,"checkpointHash");function rt(e){return[e.system,...e.harnessInstructions,...e.skillInstructions,...e.hostInstructions??[]].map(r=>r.trim()).filter(Boolean).join(`
|
|
4
4
|
|
|
5
|
-
`)}a(rt,"materializeAgentPrompt");function st(e){let
|
|
5
|
+
`)}a(rt,"materializeAgentPrompt");function st(e){let r=new Set,n=[...e].map(o=>{let l=o.name.trim();if(!l)throw new Error("Agent tool names cannot be empty.");if(r.has(l))throw new Error(`Duplicate agent tool: ${l}.`);if(r.add(l),!o.unavailableReason&&!o.executorAvailable)throw new Error(`Agent tool ${l} is declared as available without an executor.`);return{...o,name:l}}).sort((o,l)=>o.name.localeCompare(l.name)),t=n.filter(o=>!o.unavailableReason).map(o=>({name:o.name,description:o.description,inputSchema:o.inputSchema})),s=n.map(o=>({name:o.name,displayLabel:o.displayLabel??o.name,placement:o.placement,available:!o.unavailableReason,unavailableReason:o.unavailableReason??null}));return{byName:new Map(n.map(o=>[o.name,o])),tools:n,modelTools:t,capabilities:s,hash:g({modelTools:t,capabilities:s})}}a(st,"createAgentToolCatalogProjection");async function ot(e,r){let n=e.byName.get(r.name);if(!n)throw new Error(`Unknown agent tool: ${r.name}.`);if(n.unavailableReason)throw new Error(`Agent tool ${r.name} is unavailable: ${n.unavailableReason}`);if(!n.execute)throw new Error(`Agent tool ${r.name} has no executor.`);let t=n.validateArguments?n.validateArguments(r.arguments):r.arguments;return n.execute(t,r.context)}a(ot,"executeProjectedAgentTool");var F=class{static{a(this,"TaskSignals")}#e=new Map;notify(r){for(let n of[...this.#e.get(r)??[]])n()}subscribe(r,n){let t=this.#e.get(r);return t||this.#e.set(r,t=new Set),t.add(n),()=>{t.delete(n),t.size===0&&this.#e.delete(r)}}async wait(r){let n=a(()=>{},"wake"),t=0,s=a(()=>{t+=1,n()},"changed"),o=[...new Set(r.taskIds)].map(c=>this.subscribe(c,s)),l=setTimeout(s,Math.max(0,r.deadline-Date.now()));r.signal.addEventListener("abort",s);try{for(;;){r.signal.throwIfAborted();let c=t,h=await r.read();if(h!==null)return h;if(Date.now()>=r.deadline)return null;t===c&&await new Promise(u=>{n=u,(t!==c||r.signal.aborted)&&u()})}}finally{clearTimeout(l),r.signal.removeEventListener("abort",s);for(let c of o)c()}}},J=class{static{a(this,"TaskSerialExecutor")}#e=new Map;async run(r,n){let s=(this.#e.get(r)??Promise.resolve()).then(n),o=s.then(()=>{},()=>{});this.#e.set(r,o);try{return await s}finally{this.#e.get(r)===o&&this.#e.delete(r)}}};function St(e){return oe({runtime:L(e.ports),close:e.close})}a(St,"createAppServer");function oe(e){let r=!1;return{runtime:e.runtime,close:a(async()=>{r||(r=!0,await e.close?.())},"close")}}a(oe,"attachAppServer");async function Tt(e){try{await D({host:e.appServer.runtime,readable:e.readable,writable:e.writable})}finally{await e.appServer.close()}}a(Tt,"runAppServerJsonl");import{randomBytes as le}from"node:crypto";function jt(){return A()}a(jt,"appDataDir");function zt(e){return d(e).config}a(zt,"providersConfigPath");function Ht(e){return d(e).credentials}a(Ht,"providerSecretsConfigPath");function Nt(e){return d(e).key}a(Nt,"providerSecretsKeyPath");async function Ot(e){let r=d(e).token;return z(r,async()=>{let n=(await j(r))?.trim(),t=process.env.OPENPOND_APP_TOKEN||n||le(32).toString("base64url");return t!==n&&await E(r,t),{token:t,tokenFile:r}})}a(Ot,"ensureCapabilityToken");export{pe as a,fe as b,me as c,g as d,ge as e,be as f,xe as g,X as h,He as i,y as j,ye as k,se as l,tt as m,rt as n,st as o,ot as p,F as q,J as r,St as s,Tt as t,jt as u,zt as v,Ht as w,Nt as x,Ot as y};
|