shuvcode 2.0.0-alpha-9 → 2.0.0-alpha-11
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/client/api.d.ts +1 -0
- package/client/generated/client.d.ts +14 -1
- package/client/generated/client.js +67 -7
- package/client/generated/types.d.ts +2079 -798
- package/client/generated/types.js +2 -2
- package/client/index.d.ts +1 -1
- package/client/index.js +3 -3
- package/client/service.d.ts +8 -1
- package/client/service.js +65 -21
- package/package.json +13 -13
|
@@ -2,15 +2,15 @@ export const isUnauthorizedError = (value) => typeof value === "object" && value
|
|
|
2
2
|
export const isInvalidRequestError = (value) => typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "InvalidRequestError";
|
|
3
3
|
export const isAgentNotFoundError = (value) => typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "AgentNotFoundError";
|
|
4
4
|
export const isInvalidCursorError = (value) => typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "InvalidCursorError";
|
|
5
|
+
export const isConflictError = (value) => typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "ConflictError";
|
|
5
6
|
export const isSessionNotFoundError = (value) => typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "SessionNotFoundError";
|
|
7
|
+
export const isUnknownError = (value) => typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "UnknownError";
|
|
6
8
|
export const isMessageNotFoundError = (value) => typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "MessageNotFoundError";
|
|
7
|
-
export const isConflictError = (value) => typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "ConflictError";
|
|
8
9
|
export const isCommandNotFoundError = (value) => typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "CommandNotFoundError";
|
|
9
10
|
export const isCommandEvaluationError = (value) => typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "CommandEvaluationError";
|
|
10
11
|
export const isSkillNotFoundError = (value) => typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "SkillNotFoundError";
|
|
11
12
|
export const isServiceUnavailableError = (value) => typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "ServiceUnavailableError";
|
|
12
13
|
export const isSessionBusyError = (value) => typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "SessionBusyError";
|
|
13
|
-
export const isUnknownError = (value) => typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "UnknownError";
|
|
14
14
|
export const isInstructionEntryValueTooLargeError = (value) => typeof value === "object" &&
|
|
15
15
|
value !== null &&
|
|
16
16
|
"_tag" in value &&
|
package/client/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from "./generated/index";
|
|
2
|
-
export type { AgentApi, CatalogApi, CommandApi, EventApi, IntegrationApi, ModelApi, PluginApi, ProviderApi, ReferenceApi, WebSearchApi, SessionApi, SkillApi, } from "./api.js";
|
|
2
|
+
export type { AgentApi, CatalogApi, CommandApi, ConfigApi, EventApi, IntegrationApi, ModelApi, PluginApi, ProviderApi, ReferenceApi, WebSearchApi, SessionApi, SkillApi, } from "./api.js";
|
|
3
3
|
export type { EventSubscribeOutput as OpenCodeEvent } from "./generated/types";
|
|
4
4
|
export type OpenCodeClient = ReturnType<typeof import("./generated/client").make>;
|
package/client/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var v=Object.defineProperty;var O=(
|
|
1
|
+
var v=Object.defineProperty;var O=(t)=>t;function q(t,s){this[t]=O.bind(null,s)}var k=(t,s)=>{for(var i in s)v(t,i,{get:s[i],enumerable:!0,configurable:!0,set:q.bind(s,i)})};class d extends Error{reason;name="ClientError";constructor(t,s){super(t,s);this.reason=t}}var R={};k(R,{make:()=>C});var A=16777216;function C(t){let s=t.fetch??globalThis.fetch,i=(e,n)=>{let o=new URL(e.path,t.baseUrl);for(let[y,a]of Object.entries(e.query??{}))f(o.searchParams,y,a);let l=new Headers(t.headers);for(let[y,a]of Object.entries(e.headers??{}))if(a!==void 0&&a!==null)l.set(y,String(a));for(let[y,a]of new Headers(n?.headers))l.set(y,a);if(e.body!==void 0&&!l.has("content-type"))l.set("content-type","application/json");return{url:o,init:{method:e.method,signal:n?.signal,headers:l,body:e.body===void 0?void 0:JSON.stringify(e.body)}}},u=async(e,n)=>{try{let o=i(e,n);return await s(o.url,o.init)}catch(o){throw new d("Transport",{cause:o})}},g=async(e,n)=>{if(n.declaredStatuses.includes(e.status))throw await h(e);try{await e.body?.cancel()}catch{}throw new d("UnexpectedStatus",{cause:{status:e.status}})},r=async(e,n)=>{let o=await u(e,n);if(o.status!==e.successStatus)return g(o,e);if(e.binary)return new Uint8Array(await o.arrayBuffer());if(e.empty){try{await o.body?.cancel()}catch{}return}return await h(o)},b=(e,n)=>({async*[Symbol.asyncIterator](){let o=await u(e,n);if(o.status!==e.successStatus)await g(o,e);if(!D(o,"text/event-stream")){try{await o.body?.cancel()}catch{}throw new d("UnsupportedContentType")}if(o.body===null)throw new d("MalformedResponse");let l=o.body.getReader(),y=new TextDecoder,a="";try{while(!0){let p;try{p=await l.read()}catch(I){throw new d("Transport",{cause:I})}if(a+=y.decode(p.value,{stream:!p.done}),a.length>A)throw new d("SseEventTooLarge");let S=!p.done&&a.endsWith("\r");if(S)a=a.slice(0,-1);if(a=a.replaceAll(`\r
|
|
2
2
|
`,`
|
|
3
3
|
`).replaceAll("\r",`
|
|
4
|
-
`),
|
|
4
|
+
`),S)a+="\r";if(p.done&&a!=="")a+=`
|
|
5
5
|
|
|
6
6
|
`;let c=a.indexOf(`
|
|
7
7
|
|
|
@@ -9,4 +9,4 @@ var v=Object.defineProperty;var O=(n)=>n;function q(n,s){this[n]=O.bind(null,s)}
|
|
|
9
9
|
`).flatMap((m)=>m.startsWith("data:")?[m.slice(5).trimStart()]:[]).join(`
|
|
10
10
|
`);if(x!=="")try{yield JSON.parse(x)}catch(m){throw new d("MalformedResponse",{cause:m})}c=a.indexOf(`
|
|
11
11
|
|
|
12
|
-
`)}if(p.done)return}}finally{try{await l.cancel()}catch{}l.releaseLock()}}});return{health:{get:(e)=>r({method:"GET",path:"/api/health",successStatus:200,declaredStatuses:[401,400],empty:!1},e),stop:(e,t)=>r({method:"POST",path:"/api/service/stop",body:{instanceID:e.instanceID},successStatus:200,declaredStatuses:[401,400],empty:!1},t)},server:{get:(e)=>r({method:"GET",path:"/api/server",successStatus:200,declaredStatuses:[401,400],empty:!1},e)},location:{get:(e,t)=>r({method:"GET",path:"/api/location",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t)},agent:{list:(e,t)=>r({method:"GET",path:"/api/agent",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t),get:(e,t)=>r({method:"GET",path:`/api/agent/${encodeURIComponent(e.agentID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[404,401,400],empty:!1},t)},plugin:{list:(e,t)=>r({method:"GET",path:"/api/plugin",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t)},session:{list:(e,t)=>r({method:"GET",path:"/api/session",query:{workspace:e?.workspace,limit:e?.limit,order:e?.order,search:e?.search,parentID:e?.parentID,directory:e?.directory,project:e?.project,subpath:e?.subpath,cursor:e?.cursor},successStatus:200,declaredStatuses:[400,401],empty:!1},t),create:(e,t)=>r({method:"POST",path:"/api/session",body:{id:e?.id,title:e?.title,agent:e?.agent,model:e?.model,location:e?.location,policy:e?.policy},successStatus:200,declaredStatuses:[401,400],empty:!1},t).then((o)=>o.data),active:(e)=>r({method:"GET",path:"/api/session/active",successStatus:200,declaredStatuses:[401,400],empty:!1},e).then((t)=>t.data),get:(e,t)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}`,successStatus:200,declaredStatuses:[404,400,401],empty:!1},t).then((o)=>o.data),remove:(e,t)=>r({method:"DELETE",path:`/api/session/${encodeURIComponent(e.sessionID)}`,successStatus:204,declaredStatuses:[404,400,401],empty:!0},t),fork:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/fork`,body:{boundary:e.boundary,policy:e.policy},successStatus:200,declaredStatuses:[404,400,401],empty:!1},t).then((o)=>o.data),switchAgent:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/agent`,body:{agent:e.agent},successStatus:204,declaredStatuses:[404,400,401],empty:!0},t),switchModel:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/model`,body:{model:e.model},successStatus:204,declaredStatuses:[404,400,401],empty:!0},t),rename:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/rename`,body:{title:e.title},successStatus:204,declaredStatuses:[404,400,401],empty:!0},t),move:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/move`,body:{directory:e.directory,workspaceID:e.workspaceID},successStatus:204,declaredStatuses:[404,400,401],empty:!0},t),prompt:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/prompt`,body:{id:e.id,text:e.text,files:e.files,agents:e.agents,output:e.output,metadata:e.metadata,delivery:e.delivery,resume:e.resume},successStatus:200,declaredStatuses:[409,400,404,401],empty:!1},t).then((o)=>o.data),command:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/command`,body:{id:e.id,command:e.command,arguments:e.arguments,agent:e.agent,model:e.model,files:e.files,agents:e.agents,delivery:e.delivery,resume:e.resume},successStatus:200,declaredStatuses:[409,400,404,500,401],empty:!1},t).then((o)=>o.data),skill:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/skill`,body:{id:e.id,skill:e.skill,resume:e.resume},successStatus:204,declaredStatuses:[404,400,401],empty:!0},t),synthetic:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/synthetic`,body:{id:e.id,text:e.text,description:e.description,metadata:e.metadata,delivery:e.delivery,resume:e.resume},successStatus:200,declaredStatuses:[409,404,400,401],empty:!1},t).then((o)=>o.data),shell:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/shell`,body:{id:e.id,command:e.command},successStatus:204,declaredStatuses:[404,400,401],empty:!0},t),compact:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/compact`,body:{id:e.id},successStatus:200,declaredStatuses:[409,404,400,401],empty:!1},t).then((o)=>o.data),wait:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/wait`,successStatus:204,declaredStatuses:[404,503,400,401],empty:!0},t),revert:{stage:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/revert/stage`,body:{messageID:e.messageID,files:e.files},successStatus:200,declaredStatuses:[404,409,500,400,401],empty:!1},t).then((o)=>o.data),clear:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/revert/clear`,successStatus:204,declaredStatuses:[404,409,500,400,401],empty:!0},t),commit:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/revert/commit`,successStatus:204,declaredStatuses:[404,409,400,401],empty:!0},t)},context:(e,t)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/context`,successStatus:200,declaredStatuses:[404,500,400,401],empty:!1},t).then((o)=>o.data),pending:{list:(e,t)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/pending`,successStatus:200,declaredStatuses:[404,400,401],empty:!1},t).then((o)=>o.data)},instructions:{entry:{list:(e,t)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/instructions/entries`,successStatus:200,declaredStatuses:[404,400,401],empty:!1},t).then((o)=>o.data),put:(e,t)=>r({method:"PUT",path:`/api/session/${encodeURIComponent(e.sessionID)}/instructions/entries/${encodeURIComponent(e.key)}`,body:{value:e.value},successStatus:204,declaredStatuses:[404,413,400,401],empty:!0},t),remove:(e,t)=>r({method:"DELETE",path:`/api/session/${encodeURIComponent(e.sessionID)}/instructions/entries/${encodeURIComponent(e.key)}`,successStatus:204,declaredStatuses:[404,400,401],empty:!0},t)}},generate:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/generate`,body:{prompt:e.prompt},successStatus:200,declaredStatuses:[404,503,400,401],empty:!1},t).then((o)=>o.data),log:(e,t)=>S({method:"GET",path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/log`,query:{after:e.after,follow:e.follow},successStatus:200,declaredStatuses:[404,400,401],empty:!1},t),interrupt:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/interrupt`,successStatus:204,declaredStatuses:[404,400,401],empty:!0},t),background:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/background`,successStatus:204,declaredStatuses:[404,400,401],empty:!0},t),message:(e,t)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/message/${encodeURIComponent(e.messageID)}`,successStatus:200,declaredStatuses:[404,400,401],empty:!1},t).then((o)=>o.data)},message:{list:(e,t)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/message`,query:{limit:e.limit,order:e.order,cursor:e.cursor},successStatus:200,declaredStatuses:[400,404,500,401],empty:!1},t)},model:{list:(e,t)=>r({method:"GET",path:"/api/model",query:{location:e?.location},successStatus:200,declaredStatuses:[503,401,400],empty:!1},t),default:(e,t)=>r({method:"GET",path:"/api/model/default",query:{location:e?.location},successStatus:200,declaredStatuses:[503,401,400],empty:!1},t)},generate:{text:(e,t)=>r({method:"POST",path:"/api/generate",query:{location:e.location},body:{prompt:e.prompt,model:e.model},successStatus:200,declaredStatuses:[400,503,401],empty:!1},t).then((o)=>o.data)},provider:{list:(e,t)=>r({method:"GET",path:"/api/provider",query:{location:e?.location},successStatus:200,declaredStatuses:[503,401,400],empty:!1},t),get:(e,t)=>r({method:"GET",path:`/api/provider/${encodeURIComponent(e.providerID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[404,503,401,400],empty:!1},t)},integration:{list:(e,t)=>r({method:"GET",path:"/api/integration",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t),get:(e,t)=>r({method:"GET",path:`/api/integration/${encodeURIComponent(e.integrationID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t),wellknown:{add:(e,t)=>r({method:"POST",path:"/api/experimental/integration/wellknown",query:{location:e.location},body:{url:e.url},successStatus:204,declaredStatuses:[400,401],empty:!0},t)},connect:{key:(e,t)=>r({method:"POST",path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/key`,query:{location:e.location},body:{key:e.key,label:e.label},successStatus:204,declaredStatuses:[400,401],empty:!0},t)},oauth:{connect:(e,t)=>r({method:"POST",path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth`,query:{location:e.location},body:{methodID:e.methodID,inputs:e.inputs,label:e.label},successStatus:200,declaredStatuses:[400,401],empty:!1},t),status:(e,t)=>r({method:"GET",path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t),complete:(e,t)=>r({method:"POST",path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}/complete`,query:{location:e.location},body:{code:e.code},successStatus:204,declaredStatuses:[400,401],empty:!0},t),cancel:(e,t)=>r({method:"DELETE",path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[401,400],empty:!0},t)},command:{connect:(e,t)=>r({method:"POST",path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command`,query:{location:e.location},body:{methodID:e.methodID,label:e.label},successStatus:200,declaredStatuses:[400,401],empty:!1},t),status:(e,t)=>r({method:"GET",path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t),cancel:(e,t)=>r({method:"DELETE",path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[401,400],empty:!0},t)}},auth:{status:(e,t)=>r({method:"GET",path:"/api/auth/status",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t)},mcp:{list:(e,t)=>r({method:"GET",path:"/api/mcp",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t),add:(e,t)=>r({method:"PUT",path:`/api/mcp/${encodeURIComponent(e.server)}`,query:{location:e.location},body:{config:e.config},successStatus:204,declaredStatuses:[401,400],empty:!0},t),remove:(e,t)=>r({method:"DELETE",path:`/api/mcp/${encodeURIComponent(e.server)}`,query:{location:e.location},successStatus:204,declaredStatuses:[404,401,400],empty:!0},t),connect:(e,t)=>r({method:"POST",path:`/api/mcp/${encodeURIComponent(e.server)}/connect`,query:{location:e.location},successStatus:204,declaredStatuses:[404,401,400],empty:!0},t),disconnect:(e,t)=>r({method:"POST",path:`/api/mcp/${encodeURIComponent(e.server)}/disconnect`,query:{location:e.location},successStatus:204,declaredStatuses:[404,401,400],empty:!0},t),resource:{catalog:(e,t)=>r({method:"GET",path:"/api/mcp/resource",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t)}},credential:{update:(e,t)=>r({method:"PATCH",path:`/api/credential/${encodeURIComponent(e.credentialID)}`,query:{location:e.location},body:{label:e.label},successStatus:204,declaredStatuses:[401,400],empty:!0},t),remove:(e,t)=>r({method:"DELETE",path:`/api/credential/${encodeURIComponent(e.credentialID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[401,400],empty:!0},t)},project:{list:(e)=>r({method:"GET",path:"/api/project",successStatus:200,declaredStatuses:[401,400],empty:!1},e),current:(e,t)=>r({method:"GET",path:"/api/project/current",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t),directories:(e,t)=>r({method:"GET",path:`/api/project/${encodeURIComponent(e.projectID)}/directories`,query:{location:e.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t)},form:{request:{list:(e,t)=>r({method:"GET",path:"/api/form/request",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t)},list:(e,t)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/form`,successStatus:200,declaredStatuses:[404,400,401],empty:!1},t).then((o)=>o.data),create:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/form`,body:{id:e.id,title:e.title,metadata:e.metadata,fields:e.fields},successStatus:200,declaredStatuses:[404,409,400,401],empty:!1},t).then((o)=>o.data),get:(e,t)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}`,successStatus:200,declaredStatuses:[404,400,401],empty:!1},t).then((o)=>o.data),state:(e,t)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}/state`,successStatus:200,declaredStatuses:[404,400,401],empty:!1},t).then((o)=>o.data),reply:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}/reply`,body:{answer:e.answer},successStatus:204,declaredStatuses:[404,409,400,401],empty:!0},t),cancel:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}/cancel`,successStatus:204,declaredStatuses:[404,409,400,401],empty:!0},t)},permission:{request:{list:(e,t)=>r({method:"GET",path:"/api/permission/request",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t)},saved:{list:(e,t)=>r({method:"GET",path:"/api/permission/saved",query:{projectID:e?.projectID},successStatus:200,declaredStatuses:[401,400],empty:!1},t).then((o)=>o.data),remove:(e,t)=>r({method:"DELETE",path:`/api/permission/saved/${encodeURIComponent(e.id)}`,successStatus:204,declaredStatuses:[401,400],empty:!0},t)},create:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/permission`,body:{id:e.id,action:e.action,resources:e.resources,save:e.save,metadata:e.metadata,source:e.source,agent:e.agent},successStatus:200,declaredStatuses:[404,400,401],empty:!1},t).then((o)=>o.data),list:(e,t)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/permission`,successStatus:200,declaredStatuses:[404,400,401],empty:!1},t).then((o)=>o.data),get:(e,t)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/permission/${encodeURIComponent(e.requestID)}`,successStatus:200,declaredStatuses:[404,400,401],empty:!1},t).then((o)=>o.data),reply:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/permission/${encodeURIComponent(e.requestID)}/reply`,body:{reply:e.reply,message:e.message},successStatus:204,declaredStatuses:[404,400,401],empty:!0},t)},file:{read:(e,t)=>r({method:"GET",path:`/api/fs/read/${A(e.path)}`,query:{location:e.location},successStatus:200,declaredStatuses:[401,400],empty:!1,binary:!0},t),list:(e,t)=>r({method:"GET",path:"/api/fs/list",query:{location:e?.location,path:e?.path},successStatus:200,declaredStatuses:[401,400],empty:!1},t),find:(e,t)=>r({method:"GET",path:"/api/fs/find",query:{location:e.location,query:e.query,type:e.type,limit:e.limit},successStatus:200,declaredStatuses:[401,400],empty:!1},t)},command:{list:(e,t)=>r({method:"GET",path:"/api/command",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t)},skill:{list:(e,t)=>r({method:"GET",path:"/api/skill",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t)},event:{subscribe:(e)=>S({method:"GET",path:"/api/event",successStatus:200,declaredStatuses:[401,400],empty:!1},e)},pty:{list:(e,t)=>r({method:"GET",path:"/api/pty",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t),create:(e,t)=>r({method:"POST",path:"/api/pty",query:{location:e?.location},body:{command:e?.command,args:e?.args,cwd:e?.cwd,title:e?.title,env:e?.env},successStatus:200,declaredStatuses:[401,400],empty:!1},t),get:(e,t)=>r({method:"GET",path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[404,401,400],empty:!1},t),update:(e,t)=>r({method:"PUT",path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},body:{title:e.title,size:e.size},successStatus:200,declaredStatuses:[404,401,400],empty:!1},t),remove:(e,t)=>r({method:"DELETE",path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[404,401,400],empty:!0},t)},shell:{list:(e,t)=>r({method:"GET",path:"/api/shell",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t),create:(e,t)=>r({method:"POST",path:"/api/shell",query:{location:e.location},body:{command:e.command,cwd:e.cwd,timeout:e.timeout,metadata:e.metadata},successStatus:200,declaredStatuses:[401,400],empty:!1},t),get:(e,t)=>r({method:"GET",path:`/api/shell/${encodeURIComponent(e.id)}`,query:{location:e.location},successStatus:200,declaredStatuses:[404,401,400],empty:!1},t),timeout:(e,t)=>r({method:"PATCH",path:`/api/shell/${encodeURIComponent(e.id)}/timeout`,query:{location:e.location},body:{timeout:e.timeout},successStatus:200,declaredStatuses:[404,401,400],empty:!1},t),output:(e,t)=>r({method:"GET",path:`/api/shell/${encodeURIComponent(e.id)}/output`,query:{location:e.location,cursor:e.cursor,limit:e.limit},successStatus:200,declaredStatuses:[404,401,400],empty:!1},t),remove:(e,t)=>r({method:"DELETE",path:`/api/shell/${encodeURIComponent(e.id)}`,query:{location:e.location},successStatus:204,declaredStatuses:[404,401,400],empty:!0},t)},question:{request:{list:(e,t)=>r({method:"GET",path:"/api/question/request",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t)},list:(e,t)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/question`,successStatus:200,declaredStatuses:[404,400,401],empty:!1},t).then((o)=>o.data),reply:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/question/${encodeURIComponent(e.requestID)}/reply`,body:{answers:e.answers},successStatus:204,declaredStatuses:[404,400,401],empty:!0},t),reject:(e,t)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/question/${encodeURIComponent(e.requestID)}/reject`,successStatus:204,declaredStatuses:[404,400,401],empty:!0},t)},reference:{list:(e,t)=>r({method:"GET",path:"/api/reference",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t)},projectCopy:{create:(e,t)=>r({method:"POST",path:`/experimental/project/${encodeURIComponent(e.projectID)}/copy`,query:{location:e.location},body:{strategy:e.strategy,directory:e.directory,name:e.name},successStatus:200,declaredStatuses:[400,401],empty:!1},t),remove:(e,t)=>r({method:"DELETE",path:`/experimental/project/${encodeURIComponent(e.projectID)}/copy`,query:{location:e.location},body:{directory:e.directory,force:e.force},successStatus:204,declaredStatuses:[400,401],empty:!0},t),refresh:(e,t)=>r({method:"POST",path:`/experimental/project/${encodeURIComponent(e.projectID)}/copy/refresh`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401],empty:!0},t)},vcs:{get:(e,t)=>r({method:"GET",path:"/api/vcs",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t),status:(e,t)=>r({method:"GET",path:"/api/vcs/status",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},t),diff:(e,t)=>r({method:"GET",path:"/api/vcs/diff",query:{location:e.location,mode:e.mode,context:e.context},successStatus:200,declaredStatuses:[401,400],empty:!1},t)},debug:{location:{list:(e)=>r({method:"GET",path:"/api/debug/location",successStatus:200,declaredStatuses:[401,400],empty:!1},e),evict:(e,t)=>r({method:"DELETE",path:"/api/debug/location",query:{location:e?.location},successStatus:204,declaredStatuses:[401,400],empty:!0},t)}},websearch:{providers:(e,t)=>r({method:"GET",path:"/api/websearch/provider",query:{location:e?.location},successStatus:200,declaredStatuses:[503,401,400],empty:!1},t),query:(e,t)=>r({method:"POST",path:"/api/websearch",query:{location:e.location},body:{query:e.query,providerID:e.providerID},successStatus:200,declaredStatuses:[400,503,401],empty:!1},t)}}}function A(n){return n.split("/").map(encodeURIComponent).join("/")}function f(n,s,i){if(i===void 0)return;if(i===null){n.append(s,"null");return}if(Array.isArray(i)){for(let u of i)f(n,s,u);return}if(typeof i==="object"){for(let[u,g]of Object.entries(i))f(n,`${s}[${u}]`,g);return}n.append(s,String(i))}async function h(n){if(!D(n,"application/json")&&!n.headers.get("content-type")?.includes("+json")){try{await n.body?.cancel()}catch{}throw new d("UnsupportedContentType")}let s;try{s=await n.text()}catch(i){throw new d("Transport",{cause:i})}if(s==="")throw new d("MalformedResponse");try{return JSON.parse(s)}catch(i){throw new d("MalformedResponse",{cause:i})}}function D(n,s){return n.headers.get("content-type")?.split(";",1)[0]?.trim().toLowerCase()===s}var L=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="UnauthorizedError",N=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="InvalidRequestError",M=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="AgentNotFoundError",T=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="InvalidCursorError",U=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="SessionNotFoundError",j=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="MessageNotFoundError",V=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="ConflictError",G=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="CommandNotFoundError",$=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="CommandEvaluationError",_=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="SkillNotFoundError",J=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="ServiceUnavailableError",Q=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="SessionBusyError",W=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="UnknownError",B=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="InstructionEntryValueTooLargeError",z=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="ProviderNotFoundError",H=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="McpServerNotFoundError",K=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="FormNotFoundError",X=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="FormAlreadySettledError",Y=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="FormInvalidAnswerError",Z=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="PermissionNotFoundError",ee=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="PtyNotFoundError",te=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="ShellNotFoundError",ne=(n)=>typeof n==="object"&&n!==null&&("_tag"in n)&&n._tag==="QuestionNotFoundError",re=(n)=>typeof n==="object"&&n!==null&&("name"in n)&&n.name==="ProjectCopyError";export{W as isUnknownError,L as isUnauthorizedError,_ as isSkillNotFoundError,te as isShellNotFoundError,U as isSessionNotFoundError,Q as isSessionBusyError,J as isServiceUnavailableError,ne as isQuestionNotFoundError,ee as isPtyNotFoundError,z as isProviderNotFoundError,re as isProjectCopyError,Z as isPermissionNotFoundError,j as isMessageNotFoundError,H as isMcpServerNotFoundError,N as isInvalidRequestError,T as isInvalidCursorError,B as isInstructionEntryValueTooLargeError,K as isFormNotFoundError,Y as isFormInvalidAnswerError,X as isFormAlreadySettledError,V as isConflictError,G as isCommandNotFoundError,$ as isCommandEvaluationError,M as isAgentNotFoundError,R as OpenCode,d as ClientError};
|
|
12
|
+
`)}if(p.done)return}}finally{try{await l.cancel()}catch{}l.releaseLock()}}});return{health:{get:(e)=>r({method:"GET",path:"/api/health",successStatus:200,declaredStatuses:[401,400],empty:!1},e),stop:(e,n)=>r({method:"POST",path:"/api/service/stop",body:{instanceID:e.instanceID},successStatus:200,declaredStatuses:[401,400],empty:!1},n)},server:{get:(e)=>r({method:"GET",path:"/api/server",successStatus:200,declaredStatuses:[401,400],empty:!1},e)},location:{get:(e,n)=>r({method:"GET",path:"/api/location",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n)},agent:{list:(e,n)=>r({method:"GET",path:"/api/agent",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n),get:(e,n)=>r({method:"GET",path:`/api/agent/${encodeURIComponent(e.agentID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[404,401,400],empty:!1},n)},plugin:{list:(e,n)=>r({method:"GET",path:"/api/plugin",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n)},session:{list:(e,n)=>r({method:"GET",path:"/api/session",query:{workspace:e?.workspace,limit:e?.limit,order:e?.order,search:e?.search,parentID:e?.parentID,directory:e?.directory,project:e?.project,subpath:e?.subpath,cursor:e?.cursor},successStatus:200,declaredStatuses:[400,401],empty:!1},n),create:(e,n)=>r({method:"POST",path:"/api/session",body:{id:e?.id,title:e?.title,agent:e?.agent,model:e?.model,location:e?.location,policy:e?.policy},successStatus:200,declaredStatuses:[401,400],empty:!1},n).then((o)=>o.data),import:(e,n)=>r({method:"POST",path:"/api/session/import",body:{info:e.info,messages:e.messages,location:e.location},successStatus:200,declaredStatuses:[409,401,400],empty:!1},n).then((o)=>o.data),export:(e,n)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/export`,query:{sanitize:e.sanitize},successStatus:200,declaredStatuses:[404,500,401,400],empty:!1},n).then((o)=>o.data),active:(e)=>r({method:"GET",path:"/api/session/active",successStatus:200,declaredStatuses:[401,400],empty:!1},e).then((n)=>n.data),get:(e,n)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}`,successStatus:200,declaredStatuses:[404,401,400],empty:!1},n).then((o)=>o.data),remove:(e,n)=>r({method:"DELETE",path:`/api/session/${encodeURIComponent(e.sessionID)}`,successStatus:204,declaredStatuses:[404,400,401],empty:!0},n),fork:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/fork`,body:{boundary:e.boundary,policy:e.policy},successStatus:200,declaredStatuses:[404,400,401],empty:!1},n).then((o)=>o.data),switchAgent:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/agent`,body:{agent:e.agent},successStatus:204,declaredStatuses:[404,400,401],empty:!0},n),switchModel:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/model`,body:{model:e.model},successStatus:204,declaredStatuses:[404,400,401],empty:!0},n),rename:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/rename`,body:{title:e.title},successStatus:204,declaredStatuses:[404,400,401],empty:!0},n),move:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/move`,body:{directory:e.directory,workspaceID:e.workspaceID},successStatus:204,declaredStatuses:[404,400,401],empty:!0},n),prompt:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/prompt`,body:{id:e.id,text:e.text,files:e.files,agents:e.agents,output:e.output,skills:e.skills,metadata:e.metadata,delivery:e.delivery,resume:e.resume},successStatus:200,declaredStatuses:[409,400,404,401],empty:!1},n).then((o)=>o.data),command:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/command`,body:{id:e.id,command:e.command,arguments:e.arguments,agent:e.agent,model:e.model,files:e.files,agents:e.agents,skills:e.skills,delivery:e.delivery,resume:e.resume},successStatus:200,declaredStatuses:[409,400,404,500,401],empty:!1},n).then((o)=>o.data),skill:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/skill`,body:{id:e.id,skill:e.skill,resume:e.resume},successStatus:204,declaredStatuses:[404,400,401],empty:!0},n),synthetic:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/synthetic`,body:{id:e.id,text:e.text,description:e.description,metadata:e.metadata,delivery:e.delivery,resume:e.resume},successStatus:200,declaredStatuses:[409,404,400,401],empty:!1},n).then((o)=>o.data),shell:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/shell`,body:{id:e.id,command:e.command},successStatus:204,declaredStatuses:[404,400,401],empty:!0},n),compact:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/compact`,body:{id:e.id},successStatus:200,declaredStatuses:[409,404,400,401],empty:!1},n).then((o)=>o.data),wait:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/wait`,successStatus:204,declaredStatuses:[404,503,400,401],empty:!0},n),revert:{stage:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/revert/stage`,body:{messageID:e.messageID,files:e.files},successStatus:200,declaredStatuses:[404,409,500,400,401],empty:!1},n).then((o)=>o.data),clear:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/revert/clear`,successStatus:204,declaredStatuses:[404,409,500,400,401],empty:!0},n),commit:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/revert/commit`,successStatus:204,declaredStatuses:[404,409,400,401],empty:!0},n)},context:(e,n)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/context`,successStatus:200,declaredStatuses:[404,500,401,400],empty:!1},n).then((o)=>o.data),pending:{list:(e,n)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/pending`,successStatus:200,declaredStatuses:[404,401,400],empty:!1},n).then((o)=>o.data),cancel:(e,n)=>r({method:"DELETE",path:`/api/session/${encodeURIComponent(e.sessionID)}/pending/${encodeURIComponent(e.inputID)}`,successStatus:204,declaredStatuses:[409,404,401,400],empty:!0},n),steer:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/pending/${encodeURIComponent(e.inputID)}/steer`,successStatus:204,declaredStatuses:[409,404,401,400],empty:!0},n),queue:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/pending/${encodeURIComponent(e.inputID)}/queue`,successStatus:204,declaredStatuses:[409,404,401,400],empty:!0},n)},instructions:{entry:{list:(e,n)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/instructions/entries`,successStatus:200,declaredStatuses:[404,400,401],empty:!1},n).then((o)=>o.data),put:(e,n)=>r({method:"PUT",path:`/api/session/${encodeURIComponent(e.sessionID)}/instructions/entries/${encodeURIComponent(e.key)}`,body:{value:e.value},successStatus:204,declaredStatuses:[404,413,400,401],empty:!0},n),remove:(e,n)=>r({method:"DELETE",path:`/api/session/${encodeURIComponent(e.sessionID)}/instructions/entries/${encodeURIComponent(e.key)}`,successStatus:204,declaredStatuses:[404,400,401],empty:!0},n)}},generate:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/generate`,body:{prompt:e.prompt},successStatus:200,declaredStatuses:[404,503,400,401],empty:!1},n).then((o)=>o.data),log:(e,n)=>b({method:"GET",path:`/api/experimental/session/${encodeURIComponent(e.sessionID)}/log`,query:{after:e.after,follow:e.follow},successStatus:200,declaredStatuses:[404,401,400],empty:!1},n),interrupt:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/interrupt`,successStatus:204,declaredStatuses:[404,400,401],empty:!0},n),background:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/background`,successStatus:204,declaredStatuses:[404,400,401],empty:!0},n),message:(e,n)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/message/${encodeURIComponent(e.messageID)}`,successStatus:200,declaredStatuses:[404,401,400],empty:!1},n).then((o)=>o.data)},message:{list:(e,n)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/message`,query:{limit:e.limit,order:e.order,cursor:e.cursor},successStatus:200,declaredStatuses:[400,404,500,401],empty:!1},n)},model:{list:(e,n)=>r({method:"GET",path:"/api/model",query:{location:e?.location},successStatus:200,declaredStatuses:[503,401,400],empty:!1},n),default:(e,n)=>r({method:"GET",path:"/api/model/default",query:{location:e?.location},successStatus:200,declaredStatuses:[503,401,400],empty:!1},n)},generate:{text:(e,n)=>r({method:"POST",path:"/api/generate",query:{location:e.location},body:{prompt:e.prompt,model:e.model},successStatus:200,declaredStatuses:[400,503,401],empty:!1},n).then((o)=>o.data)},provider:{list:(e,n)=>r({method:"GET",path:"/api/provider",query:{location:e?.location},successStatus:200,declaredStatuses:[503,401,400],empty:!1},n),get:(e,n)=>r({method:"GET",path:`/api/provider/${encodeURIComponent(e.providerID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[404,503,401,400],empty:!1},n)},integration:{list:(e,n)=>r({method:"GET",path:"/api/integration",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n),get:(e,n)=>r({method:"GET",path:`/api/integration/${encodeURIComponent(e.integrationID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n),wellknown:{add:(e,n)=>r({method:"POST",path:"/api/experimental/integration/wellknown",query:{location:e.location},body:{url:e.url},successStatus:204,declaredStatuses:[400,401],empty:!0},n)},connect:{key:(e,n)=>r({method:"POST",path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/key`,query:{location:e.location},body:{key:e.key,answer:e.answer,label:e.label},successStatus:204,declaredStatuses:[400,401],empty:!0},n)},oauth:{connect:(e,n)=>r({method:"POST",path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth`,query:{location:e.location},body:{methodID:e.methodID,answer:e.answer,label:e.label},successStatus:200,declaredStatuses:[400,401],empty:!1},n),status:(e,n)=>r({method:"GET",path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n),complete:(e,n)=>r({method:"POST",path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}/complete`,query:{location:e.location},body:{code:e.code},successStatus:204,declaredStatuses:[400,401],empty:!0},n),cancel:(e,n)=>r({method:"DELETE",path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/oauth/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[401,400],empty:!0},n)},command:{connect:(e,n)=>r({method:"POST",path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command`,query:{location:e.location},body:{methodID:e.methodID,label:e.label},successStatus:200,declaredStatuses:[400,401],empty:!1},n),status:(e,n)=>r({method:"GET",path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n),cancel:(e,n)=>r({method:"DELETE",path:`/api/integration/${encodeURIComponent(e.integrationID)}/connect/command/${encodeURIComponent(e.attemptID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[401,400],empty:!0},n)}},auth:{status:(e,n)=>r({method:"GET",path:"/api/auth/status",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n)},mcp:{list:(e,n)=>r({method:"GET",path:"/api/mcp",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n),add:(e,n)=>r({method:"PUT",path:`/api/mcp/${encodeURIComponent(e.server)}`,query:{location:e.location},body:{config:e.config},successStatus:204,declaredStatuses:[401,400],empty:!0},n),remove:(e,n)=>r({method:"DELETE",path:`/api/mcp/${encodeURIComponent(e.server)}`,query:{location:e.location},successStatus:204,declaredStatuses:[404,401,400],empty:!0},n),connect:(e,n)=>r({method:"POST",path:`/api/mcp/${encodeURIComponent(e.server)}/connect`,query:{location:e.location},successStatus:204,declaredStatuses:[404,401,400],empty:!0},n),disconnect:(e,n)=>r({method:"POST",path:`/api/mcp/${encodeURIComponent(e.server)}/disconnect`,query:{location:e.location},successStatus:204,declaredStatuses:[404,401,400],empty:!0},n),resource:{catalog:(e,n)=>r({method:"GET",path:"/api/mcp/resource",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n)}},credential:{update:(e,n)=>r({method:"PATCH",path:`/api/credential/${encodeURIComponent(e.credentialID)}`,query:{location:e.location},body:{label:e.label},successStatus:204,declaredStatuses:[401,400],empty:!0},n),remove:(e,n)=>r({method:"DELETE",path:`/api/credential/${encodeURIComponent(e.credentialID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[401,400],empty:!0},n)},project:{list:(e)=>r({method:"GET",path:"/api/project",successStatus:200,declaredStatuses:[401,400],empty:!1},e),current:(e,n)=>r({method:"GET",path:"/api/project/current",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n),directories:(e,n)=>r({method:"GET",path:`/api/project/${encodeURIComponent(e.projectID)}/directories`,query:{location:e.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n)},form:{request:{list:(e,n)=>r({method:"GET",path:"/api/form/request",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n)},list:(e,n)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/form`,successStatus:200,declaredStatuses:[404,400,401],empty:!1},n).then((o)=>o.data),create:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/form`,body:{id:e.id,title:e.title,metadata:e.metadata,fields:e.fields},successStatus:200,declaredStatuses:[404,409,400,401],empty:!1},n).then((o)=>o.data),get:(e,n)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}`,successStatus:200,declaredStatuses:[404,400,401],empty:!1},n).then((o)=>o.data),state:(e,n)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}/state`,successStatus:200,declaredStatuses:[404,400,401],empty:!1},n).then((o)=>o.data),reply:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}/reply`,body:{answer:e.answer},successStatus:204,declaredStatuses:[404,409,400,401],empty:!0},n),cancel:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/form/${encodeURIComponent(e.formID)}/cancel`,successStatus:204,declaredStatuses:[404,409,400,401],empty:!0},n)},permission:{request:{list:(e,n)=>r({method:"GET",path:"/api/permission/request",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n)},saved:{list:(e,n)=>r({method:"GET",path:"/api/permission/saved",query:{projectID:e?.projectID},successStatus:200,declaredStatuses:[401,400],empty:!1},n).then((o)=>o.data),remove:(e,n)=>r({method:"DELETE",path:`/api/permission/saved/${encodeURIComponent(e.id)}`,successStatus:204,declaredStatuses:[401,400],empty:!0},n)},create:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/permission`,body:{id:e.id,action:e.action,resources:e.resources,save:e.save,metadata:e.metadata,source:e.source,agent:e.agent},successStatus:200,declaredStatuses:[404,400,401],empty:!1},n).then((o)=>o.data),list:(e,n)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/permission`,successStatus:200,declaredStatuses:[404,400,401],empty:!1},n).then((o)=>o.data),get:(e,n)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/permission/${encodeURIComponent(e.requestID)}`,successStatus:200,declaredStatuses:[404,400,401],empty:!1},n).then((o)=>o.data),reply:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/permission/${encodeURIComponent(e.requestID)}/reply`,body:{reply:e.reply,message:e.message},successStatus:204,declaredStatuses:[404,400,401],empty:!0},n)},file:{read:(e,n)=>r({method:"GET",path:`/api/fs/read/${w(e.path)}`,query:{location:e.location},successStatus:200,declaredStatuses:[401,400],empty:!1,binary:!0},n),list:(e,n)=>r({method:"GET",path:"/api/fs/list",query:{location:e?.location,path:e?.path},successStatus:200,declaredStatuses:[401,400],empty:!1},n),find:(e,n)=>r({method:"GET",path:"/api/fs/find",query:{location:e.location,query:e.query,type:e.type,limit:e.limit},successStatus:200,declaredStatuses:[401,400],empty:!1},n)},command:{list:(e,n)=>r({method:"GET",path:"/api/command",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n)},skill:{list:(e,n)=>r({method:"GET",path:"/api/skill",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n)},event:{subscribe:(e)=>b({method:"GET",path:"/api/event",successStatus:200,declaredStatuses:[401,400],empty:!1},e)},pty:{list:(e,n)=>r({method:"GET",path:"/api/pty",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n),create:(e,n)=>r({method:"POST",path:"/api/pty",query:{location:e?.location},body:{command:e?.command,args:e?.args,cwd:e?.cwd,title:e?.title,env:e?.env},successStatus:200,declaredStatuses:[401,400],empty:!1},n),get:(e,n)=>r({method:"GET",path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},successStatus:200,declaredStatuses:[404,401,400],empty:!1},n),update:(e,n)=>r({method:"PUT",path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},body:{title:e.title,size:e.size},successStatus:200,declaredStatuses:[404,401,400],empty:!1},n),remove:(e,n)=>r({method:"DELETE",path:`/api/pty/${encodeURIComponent(e.ptyID)}`,query:{location:e.location},successStatus:204,declaredStatuses:[404,401,400],empty:!0},n)},shell:{list:(e,n)=>r({method:"GET",path:"/api/shell",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n),create:(e,n)=>r({method:"POST",path:"/api/shell",query:{location:e.location},body:{command:e.command,cwd:e.cwd,timeout:e.timeout,metadata:e.metadata},successStatus:200,declaredStatuses:[401,400],empty:!1},n),get:(e,n)=>r({method:"GET",path:`/api/shell/${encodeURIComponent(e.id)}`,query:{location:e.location},successStatus:200,declaredStatuses:[404,401,400],empty:!1},n),timeout:(e,n)=>r({method:"PATCH",path:`/api/shell/${encodeURIComponent(e.id)}/timeout`,query:{location:e.location},body:{timeout:e.timeout},successStatus:200,declaredStatuses:[404,401,400],empty:!1},n),output:(e,n)=>r({method:"GET",path:`/api/shell/${encodeURIComponent(e.id)}/output`,query:{location:e.location,cursor:e.cursor,limit:e.limit},successStatus:200,declaredStatuses:[404,401,400],empty:!1},n),remove:(e,n)=>r({method:"DELETE",path:`/api/shell/${encodeURIComponent(e.id)}`,query:{location:e.location},successStatus:204,declaredStatuses:[404,401,400],empty:!0},n)},question:{request:{list:(e,n)=>r({method:"GET",path:"/api/question/request",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n)},list:(e,n)=>r({method:"GET",path:`/api/session/${encodeURIComponent(e.sessionID)}/question`,successStatus:200,declaredStatuses:[404,400,401],empty:!1},n).then((o)=>o.data),reply:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/question/${encodeURIComponent(e.requestID)}/reply`,body:{answers:e.answers},successStatus:204,declaredStatuses:[404,400,401],empty:!0},n),reject:(e,n)=>r({method:"POST",path:`/api/session/${encodeURIComponent(e.sessionID)}/question/${encodeURIComponent(e.requestID)}/reject`,successStatus:204,declaredStatuses:[404,400,401],empty:!0},n)},reference:{list:(e,n)=>r({method:"GET",path:"/api/reference",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n)},projectCopy:{create:(e,n)=>r({method:"POST",path:`/experimental/project/${encodeURIComponent(e.projectID)}/copy`,query:{location:e.location},body:{strategy:e.strategy,directory:e.directory,name:e.name},successStatus:200,declaredStatuses:[400,401],empty:!1},n),remove:(e,n)=>r({method:"DELETE",path:`/experimental/project/${encodeURIComponent(e.projectID)}/copy`,query:{location:e.location},body:{directory:e.directory,force:e.force},successStatus:204,declaredStatuses:[400,401],empty:!0},n),refresh:(e,n)=>r({method:"POST",path:`/experimental/project/${encodeURIComponent(e.projectID)}/copy/refresh`,query:{location:e.location},successStatus:204,declaredStatuses:[400,401],empty:!0},n)},vcs:{get:(e,n)=>r({method:"GET",path:"/api/vcs",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n),status:(e,n)=>r({method:"GET",path:"/api/vcs/status",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n),diff:(e,n)=>r({method:"GET",path:"/api/vcs/diff",query:{location:e.location,mode:e.mode,context:e.context},successStatus:200,declaredStatuses:[401,400],empty:!1},n)},debug:{location:{list:(e)=>r({method:"GET",path:"/api/debug/location",successStatus:200,declaredStatuses:[401,400],empty:!1},e),evict:(e,n)=>r({method:"DELETE",path:"/api/debug/location",query:{location:e?.location},successStatus:204,declaredStatuses:[401,400],empty:!0},n)}},migration:{v1:{status:(e)=>r({method:"GET",path:"/api/experimental/migration/v1",successStatus:200,declaredStatuses:[401,400],empty:!1},e)}},websearch:{providers:(e,n)=>r({method:"GET",path:"/api/websearch/provider",query:{location:e?.location},successStatus:200,declaredStatuses:[503,401,400],empty:!1},n),query:(e,n)=>r({method:"POST",path:"/api/websearch",query:{location:e.location},body:{query:e.query,providerID:e.providerID},successStatus:200,declaredStatuses:[400,503,401],empty:!1},n)},config:{get:(e,n)=>r({method:"GET",path:"/api/config",query:{location:e?.location},successStatus:200,declaredStatuses:[401,400],empty:!1},n)}}}function w(t){return t.split("/").map(encodeURIComponent).join("/")}function f(t,s,i){if(i===void 0)return;if(i===null){t.append(s,"null");return}if(Array.isArray(i)){for(let u of i)f(t,s,u);return}if(typeof i==="object"){for(let[u,g]of Object.entries(i))f(t,`${s}[${u}]`,g);return}t.append(s,String(i))}async function h(t){if(!D(t,"application/json")&&!t.headers.get("content-type")?.includes("+json")){try{await t.body?.cancel()}catch{}throw new d("UnsupportedContentType")}let s;try{s=await t.text()}catch(i){throw new d("Transport",{cause:i})}if(s==="")throw new d("MalformedResponse");try{return JSON.parse(s)}catch(i){throw new d("MalformedResponse",{cause:i})}}function D(t,s){return t.headers.get("content-type")?.split(";",1)[0]?.trim().toLowerCase()===s}var F=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="UnauthorizedError",N=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="InvalidRequestError",M=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="AgentNotFoundError",T=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="InvalidCursorError",U=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="ConflictError",j=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="SessionNotFoundError",V=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="UnknownError",J=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="MessageNotFoundError",G=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="CommandNotFoundError",_=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="CommandEvaluationError",$=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="SkillNotFoundError",Q=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="ServiceUnavailableError",W=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="SessionBusyError",z=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="InstructionEntryValueTooLargeError",B=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="ProviderNotFoundError",H=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="McpServerNotFoundError",K=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="FormNotFoundError",X=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="FormAlreadySettledError",Y=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="FormInvalidAnswerError",Z=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="PermissionNotFoundError",ee=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="PtyNotFoundError",ne=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="ShellNotFoundError",te=(t)=>typeof t==="object"&&t!==null&&("_tag"in t)&&t._tag==="QuestionNotFoundError",re=(t)=>typeof t==="object"&&t!==null&&("name"in t)&&t.name==="ProjectCopyError";export{V as isUnknownError,F as isUnauthorizedError,$ as isSkillNotFoundError,ne as isShellNotFoundError,j as isSessionNotFoundError,W as isSessionBusyError,Q as isServiceUnavailableError,te as isQuestionNotFoundError,ee as isPtyNotFoundError,B as isProviderNotFoundError,re as isProjectCopyError,Z as isPermissionNotFoundError,J as isMessageNotFoundError,H as isMcpServerNotFoundError,N as isInvalidRequestError,T as isInvalidCursorError,z as isInstructionEntryValueTooLargeError,K as isFormNotFoundError,Y as isFormInvalidAnswerError,X as isFormAlreadySettledError,U as isConflictError,G as isCommandNotFoundError,_ as isCommandEvaluationError,M as isAgentNotFoundError,R as OpenCode,d as ClientError};
|
package/client/service.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import type { DiscoverOptions, Endpoint, EnsureOptions, StopOptions } from "../service.js";
|
|
2
2
|
export * from "../service.js";
|
|
3
3
|
/** Discover a healthy, compatible local service without starting one. */
|
|
4
|
-
export declare function discover(options?: DiscoverOptions): Promise<
|
|
4
|
+
export declare function discover(options?: DiscoverOptions): Promise<{
|
|
5
|
+
url: string;
|
|
6
|
+
auth: {
|
|
7
|
+
type: "basic";
|
|
8
|
+
username: string;
|
|
9
|
+
password: string;
|
|
10
|
+
} | undefined;
|
|
11
|
+
} | undefined>;
|
|
5
12
|
/** Ensure a healthy, compatible local service is running. */
|
|
6
13
|
export declare function ensure(options?: EnsureOptions): Promise<Endpoint>;
|
|
7
14
|
/** Stop the registered local service. */
|
package/client/service.js
CHANGED
|
@@ -19,10 +19,10 @@ async function discoverLocal(options) {
|
|
|
19
19
|
export async function ensure(options = {}) {
|
|
20
20
|
const deadline = Date.now() + 120_000;
|
|
21
21
|
const contenders = new Set();
|
|
22
|
+
let timeouts;
|
|
22
23
|
let announced = false;
|
|
23
24
|
let lastSpawn = 0;
|
|
24
25
|
let spawnDelay = 5_000;
|
|
25
|
-
let ownerHeld = false;
|
|
26
26
|
const announce = (reason, previousVersion) => {
|
|
27
27
|
if (announced)
|
|
28
28
|
return;
|
|
@@ -50,8 +50,21 @@ export async function ensure(options = {}) {
|
|
|
50
50
|
if (Date.now() >= deadline)
|
|
51
51
|
throw new Error("Timed out waiting for the background service to start");
|
|
52
52
|
const registration = await registered(options.file, true);
|
|
53
|
+
if (registration.timedOut && registration.info !== undefined) {
|
|
54
|
+
timeouts = {
|
|
55
|
+
info: registration.info,
|
|
56
|
+
count: timeouts !== undefined && same(timeouts.info, registration.info) ? timeouts.count + 1 : 1,
|
|
57
|
+
};
|
|
58
|
+
if (timeouts.count >= 3) {
|
|
59
|
+
announce("missing");
|
|
60
|
+
await evict(registration.info, options);
|
|
61
|
+
timeouts = undefined;
|
|
62
|
+
lastSpawn = Date.now() - spawnDelay;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else
|
|
66
|
+
timeouts = undefined;
|
|
53
67
|
if (registration.service !== undefined) {
|
|
54
|
-
ownerHeld = false;
|
|
55
68
|
spawnDelay = 5_000;
|
|
56
69
|
const service = registration.service;
|
|
57
70
|
const compatible = !service.legacy && (options.version === undefined || service.version === options.version);
|
|
@@ -68,15 +81,14 @@ export async function ensure(options = {}) {
|
|
|
68
81
|
else {
|
|
69
82
|
if (lastSpawn === 0 && registration.info !== undefined)
|
|
70
83
|
lastSpawn = Date.now();
|
|
71
|
-
const failure = [...contenders].map(contenderFailure).find((error) => error !== undefined);
|
|
72
|
-
if (failure !== undefined)
|
|
73
|
-
throw failure;
|
|
74
84
|
const finished = [...contenders].filter(contenderFinished);
|
|
85
|
+
const failure = finished.map(contenderFailure).find((error) => error !== undefined);
|
|
75
86
|
if (finished.some((item) => item.child.exitCode === 0)) {
|
|
76
|
-
ownerHeld = true;
|
|
77
87
|
spawnDelay = Math.min(spawnDelay * 2, 30_000);
|
|
78
88
|
}
|
|
79
89
|
finished.forEach((item) => contenders.delete(item));
|
|
90
|
+
if (failure !== undefined && contenders.size === 0)
|
|
91
|
+
throw failure;
|
|
80
92
|
// Keep one candidate plus one lock probe so a pre-lock stall cannot block recovery.
|
|
81
93
|
if (contenders.size < 2 && Date.now() - lastSpawn >= spawnDelay) {
|
|
82
94
|
announce("missing");
|
|
@@ -129,39 +141,57 @@ async function read(file) {
|
|
|
129
141
|
}
|
|
130
142
|
}
|
|
131
143
|
async function probe(info, allowLegacy = false) {
|
|
144
|
+
return (await probeResult(info, allowLegacy)).service;
|
|
145
|
+
}
|
|
146
|
+
async function probeResult(info, allowLegacy = false) {
|
|
132
147
|
const endpoint = {
|
|
133
148
|
url: info.url,
|
|
134
149
|
auth: info.password === undefined
|
|
135
150
|
? undefined
|
|
136
151
|
: { type: "basic", username: "opencode", password: info.password },
|
|
137
152
|
};
|
|
138
|
-
const
|
|
153
|
+
const signal = AbortSignal.timeout(2_000);
|
|
154
|
+
const result = await fetch(new URL("/api/health", info.url), {
|
|
139
155
|
headers: headers(endpoint),
|
|
140
|
-
signal
|
|
141
|
-
})
|
|
142
|
-
|
|
156
|
+
signal,
|
|
157
|
+
})
|
|
158
|
+
.then(async (response) => ({
|
|
159
|
+
response,
|
|
160
|
+
body: (await response.json()),
|
|
161
|
+
}))
|
|
162
|
+
.then((value) => ({ value }), (cause) => ({ cause }));
|
|
163
|
+
if ("cause" in result)
|
|
164
|
+
return { service: undefined, timedOut: signal.aborted };
|
|
165
|
+
const response = result.value.response;
|
|
166
|
+
const body = result.value.body;
|
|
143
167
|
if (body !== undefined && "version" in body && "pid" in body) {
|
|
144
168
|
if (body.pid !== info.pid)
|
|
145
|
-
return undefined;
|
|
169
|
+
return { service: undefined, timedOut: false };
|
|
146
170
|
if (info.version !== undefined && body.version !== info.version)
|
|
147
|
-
return undefined;
|
|
171
|
+
return { service: undefined, timedOut: false };
|
|
148
172
|
return {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
173
|
+
service: {
|
|
174
|
+
info,
|
|
175
|
+
endpoint,
|
|
176
|
+
version: body.version,
|
|
177
|
+
state: response.ok ? "ready" : response.status === 500 ? "failed" : "waiting",
|
|
178
|
+
legacy: false,
|
|
179
|
+
},
|
|
180
|
+
timedOut: false,
|
|
154
181
|
};
|
|
155
182
|
}
|
|
156
183
|
if (!allowLegacy || body?.healthy !== true)
|
|
157
|
-
return undefined;
|
|
158
|
-
return {
|
|
184
|
+
return { service: undefined, timedOut: false };
|
|
185
|
+
return {
|
|
186
|
+
service: { info, endpoint, state: "ready", legacy: true },
|
|
187
|
+
timedOut: false,
|
|
188
|
+
};
|
|
159
189
|
}
|
|
160
190
|
async function registered(file, allowLegacy = false) {
|
|
161
191
|
const info = await read(file);
|
|
162
192
|
if (info === undefined)
|
|
163
|
-
return { info: undefined, service: undefined };
|
|
164
|
-
return { info,
|
|
193
|
+
return { info: undefined, service: undefined, timedOut: false };
|
|
194
|
+
return { info, ...(await probeResult(info, allowLegacy)) };
|
|
165
195
|
}
|
|
166
196
|
async function find(options) {
|
|
167
197
|
return (await registered(options.file, true)).service;
|
|
@@ -193,6 +223,20 @@ async function waitUntilStopped(pid) {
|
|
|
193
223
|
function same(left, right) {
|
|
194
224
|
return left.id === right.id && left.version === right.version && left.url === right.url && left.pid === right.pid;
|
|
195
225
|
}
|
|
226
|
+
async function evict(info, options) {
|
|
227
|
+
const current = await read(options.file);
|
|
228
|
+
if (current === undefined || !same(current, info))
|
|
229
|
+
return;
|
|
230
|
+
signal(info.pid, "SIGTERM");
|
|
231
|
+
if (await waitUntilStopped(info.pid))
|
|
232
|
+
return;
|
|
233
|
+
const latest = await read(options.file);
|
|
234
|
+
if (latest === undefined || !same(latest, info))
|
|
235
|
+
return;
|
|
236
|
+
signal(info.pid, "SIGKILL");
|
|
237
|
+
if (!(await waitUntilStopped(info.pid)))
|
|
238
|
+
throw new Error(`Server process ${info.pid} is still running`);
|
|
239
|
+
}
|
|
196
240
|
async function kill(service, options) {
|
|
197
241
|
const requested = await requestStop(service);
|
|
198
242
|
if (requested === "rejected")
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"import": "./client/index.js"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
"version": "2.0.0-alpha-
|
|
17
|
+
"version": "2.0.0-alpha-11",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
@@ -30,17 +30,17 @@
|
|
|
30
30
|
"x64"
|
|
31
31
|
],
|
|
32
32
|
"optionalDependencies": {
|
|
33
|
-
"shuvcode-
|
|
34
|
-
"shuvcode-linux-x64-baseline": "2.0.0-alpha-
|
|
35
|
-
"shuvcode-
|
|
36
|
-
"shuvcode-
|
|
37
|
-
"shuvcode-
|
|
38
|
-
"shuvcode-linux-
|
|
39
|
-
"shuvcode-darwin-x64": "2.0.0-alpha-
|
|
40
|
-
"shuvcode-
|
|
41
|
-
"shuvcode-
|
|
42
|
-
"shuvcode-
|
|
43
|
-
"shuvcode-
|
|
44
|
-
"shuvcode-linux-x64": "2.0.0-alpha-
|
|
33
|
+
"shuvcode-linux-x64-baseline-musl": "2.0.0-alpha-11",
|
|
34
|
+
"shuvcode-linux-x64-baseline": "2.0.0-alpha-11",
|
|
35
|
+
"shuvcode-windows-x64": "2.0.0-alpha-11",
|
|
36
|
+
"shuvcode-darwin-x64-baseline": "2.0.0-alpha-11",
|
|
37
|
+
"shuvcode-linux-arm64": "2.0.0-alpha-11",
|
|
38
|
+
"shuvcode-linux-arm64-musl": "2.0.0-alpha-11",
|
|
39
|
+
"shuvcode-darwin-x64": "2.0.0-alpha-11",
|
|
40
|
+
"shuvcode-darwin-arm64": "2.0.0-alpha-11",
|
|
41
|
+
"shuvcode-windows-x64-baseline": "2.0.0-alpha-11",
|
|
42
|
+
"shuvcode-windows-arm64": "2.0.0-alpha-11",
|
|
43
|
+
"shuvcode-linux-x64": "2.0.0-alpha-11",
|
|
44
|
+
"shuvcode-linux-x64-musl": "2.0.0-alpha-11"
|
|
45
45
|
}
|
|
46
46
|
}
|