@xeno-corporation/xeno-agent-sdk 0.6.3 → 0.6.5
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/agents/index.d.ts +15 -1
- package/dist/agents/index.js +6 -6
- package/dist/control-plane/index.js +4 -4
- package/dist/electron/index.d.ts +52 -0
- package/dist/electron/index.js +154 -146
- package/dist/hooks/index.d.ts +43 -1
- package/dist/hooks/index.js +4 -4
- package/dist/index.d.ts +350 -18
- package/dist/index.js +248 -222
- package/dist/mcp/index.d.ts +82 -7
- package/dist/mcp/index.js +19 -15
- package/dist/session/index.d.ts +9 -1
- package/dist/session/index.js +21 -17
- package/dist/ui/index.d.ts +52 -0
- package/package.json +114 -110
package/dist/agents/index.d.ts
CHANGED
|
@@ -20,13 +20,19 @@ interface AgentToolPolicy {
|
|
|
20
20
|
allow?: string[];
|
|
21
21
|
deny?: string[];
|
|
22
22
|
}
|
|
23
|
+
type AgentDefinitionIsolation = "none" | "worktree";
|
|
23
24
|
interface AgentDefinitionMetadata {
|
|
24
25
|
name: string;
|
|
25
26
|
scope: AgentDefinitionScope;
|
|
26
27
|
path: string;
|
|
27
28
|
description?: string;
|
|
28
29
|
model?: string;
|
|
30
|
+
color?: string;
|
|
31
|
+
memory?: string;
|
|
32
|
+
isolation?: AgentDefinitionIsolation;
|
|
29
33
|
tags: string[];
|
|
34
|
+
skills: string[];
|
|
35
|
+
hooks: string[];
|
|
30
36
|
active: boolean;
|
|
31
37
|
shadowedBy?: AgentDefinitionShadowRef;
|
|
32
38
|
toolPolicy?: AgentToolPolicy;
|
|
@@ -95,6 +101,14 @@ declare function createAgentDefinitionFile(input: {
|
|
|
95
101
|
cwd?: string;
|
|
96
102
|
agentHome?: string;
|
|
97
103
|
description?: string;
|
|
104
|
+
model?: string;
|
|
105
|
+
color?: string;
|
|
106
|
+
memory?: string;
|
|
107
|
+
isolation?: AgentDefinitionIsolation;
|
|
108
|
+
skills?: string[];
|
|
109
|
+
hooks?: string[];
|
|
110
|
+
toolPolicy?: AgentToolPolicy;
|
|
111
|
+
prompt?: string;
|
|
98
112
|
force?: boolean;
|
|
99
113
|
}): string;
|
|
100
|
-
export { type AgentDefinition, type AgentDefinitionIssue, AgentDefinitionLoader, type AgentDefinitionLoaderOptions, type AgentDefinitionMetadata, AgentDefinitionResolver, type AgentDefinitionScanResult, type AgentDefinitionScope, type AgentDefinitionShadowRef, type AgentToolPolicy, createAgentDefinitionFile, createAgentDefinitionPromptSection, getProjectAgentDefinitionDirs, getProjectAgentDefinitionsDir, getUserAgentDefinitionsDir, isValidAgentDefinitionName, renderAgentDefinition, renderAgentDefinitions, resolveAgentDefinition, resolveAgentToolPolicy, scanAgentDefinitions, toAgentDefinitionMetadata, validateAgentDefinition };
|
|
114
|
+
export { type AgentDefinition, type AgentDefinitionIsolation, type AgentDefinitionIssue, AgentDefinitionLoader, type AgentDefinitionLoaderOptions, type AgentDefinitionMetadata, AgentDefinitionResolver, type AgentDefinitionScanResult, type AgentDefinitionScope, type AgentDefinitionShadowRef, type AgentToolPolicy, createAgentDefinitionFile, createAgentDefinitionPromptSection, getProjectAgentDefinitionDirs, getProjectAgentDefinitionsDir, getUserAgentDefinitionsDir, isValidAgentDefinitionName, renderAgentDefinition, renderAgentDefinitions, resolveAgentDefinition, resolveAgentToolPolicy, scanAgentDefinitions, toAgentDefinitionMetadata, validateAgentDefinition };
|
package/dist/agents/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{existsSync as
|
|
2
|
-
`)),nextIndex:
|
|
3
|
-
`)}}}function
|
|
1
|
+
import{existsSync as k,mkdirSync as B,readFileSync as C,readdirSync as F,writeFileSync as J}from"fs";import{homedir as W}from"os";import{basename as Y,dirname as U,join as m,parse as _,resolve as z}from"path";function S(t){let n=L(t);return{frontmatter:n.frontmatter,content:n.content.trim()}}function L(t){let n=t.replace(/^\uFEFF/,"");if(!n.startsWith("---"))return{frontmatter:{},content:t};let e=n.search(/\r?\n/);if(e<0||n.slice(0,e).trim()!=="---")return{frontmatter:{},content:t};let o=n.slice(e+(n[e]==="\r"?2:1)),i=o.match(/(?:^|\r?\n)---[ \t]*(?:\r?\n|$)/);if(!i||i.index===void 0)throw new Error("YAML frontmatter is not closed.");let r=o.slice(0,i.index),s=i[0],a=i.index+s.length;return{frontmatter:b(r),content:o.slice(a)}}function b(t){let n={},e=t.split(/\r?\n/);for(let o=0;o<e.length;o+=1){let i=e[o];if(!i.trim()||i.trimStart().startsWith("#"))continue;if(/^\s/.test(i))throw new Error(`Unexpected indentation at line ${o+1}.`);let r=M(i,o+1);if(r.key==="<<")throw new Error("YAML merge keys are not supported.");if(r.value!==""){n[r.key]=j(r.value,o+1);continue}let s=R(e,o+1);n[r.key]=s.value,o=s.nextIndex-1}return n}function R(t,n){let e=[],o=n;for(;o<t.length;o+=1){let r=t[o];if(!r.trim()){e.push(r);continue}if(!/^\s/.test(r))break;e.push(r.replace(/^ {2}/,""))}let i=e.filter(r=>r.trim()&&!r.trimStart().startsWith("#"));return i.length===0?{value:{},nextIndex:o}:i.every(r=>r.trimStart().startsWith("- "))?{value:i.map((r,s)=>j(r.trimStart().slice(2),n+s+1)),nextIndex:o}:{value:b(e.join(`
|
|
2
|
+
`)),nextIndex:o}}function M(t,n){let e=t.indexOf(":");if(e<=0)throw new Error(`Invalid YAML line ${n}.`);let o=t.slice(0,e).trim(),i=t.slice(e+1).trim();if(!o)throw new Error(`Invalid YAML key at line ${n}.`);return{key:o,value:i}}function j(t,n){if(t==="")return"";if(t==="[]")return[];if(t==="{}")return{};if(t==="true")return!0;if(t==="false")return!1;if(t==="null"||t==="~")return null;if(/^-?\d+(?:\.\d+)?$/.test(t))return Number(t);if(t.startsWith('"'))return x(t,n);if(t.startsWith("'")){if(!t.endsWith("'"))throw new Error(`Unclosed quoted scalar at line ${n}.`);return t.slice(1,-1).replace(/''/g,"'")}if(t.startsWith("[")||t.startsWith("{"))return x(t,n);if(t.includes("[")||t.includes("]")||t.includes("{")||t.includes("}"))throw new Error(`Unsupported YAML scalar at line ${n}.`);return t}function x(t,n){try{return JSON.parse(t)}catch{throw new Error(`Invalid YAML scalar at line ${n}.`)}}var H=/^[a-z][a-z0-9_-]{0,63}$/;function v(){return process.env.XENO_AGENT_HOME?.trim()||m(W(),".xeno-agent")}function O(t=v()){return m(t,"agents")}function T(t){return z(t)}function q(t){let n=U(t);return n===t?t:n}function G(t=process.cwd()){let n=T(t),e=[],o=n;for(;;){let i=m(o,".xeno","agents");k(i)&&e.push(i);let r=q(o);if(r===o)break;o=r}return e.reverse()}function V(t=process.cwd()){return m(T(t),".xeno","agents")}function K(t){return k(t)?F(t,{withFileTypes:!0}).filter(n=>n.isFile()&&n.name.toLowerCase().endsWith(".md")).map(n=>m(t,n.name)).sort((n,e)=>n.localeCompare(e)):[]}function u(t){if(typeof t!="string")return;let n=t.trim();return n.length>0?n:void 0}function d(t){return Array.isArray(t)?t.map(n=>String(n).trim()).filter(Boolean):typeof t=="string"?t.split(",").map(n=>n.trim()).filter(Boolean):[]}function X(t){if(typeof t=="boolean")return t;if(typeof t!="string")return;let n=t.trim().toLowerCase();if(["1","true","yes","on"].includes(n))return!0;if(["0","false","no","off"].includes(n))return!1}function Q(t){return _(Y(t)).name.toLowerCase()}function E(t){return H.test(t)}function Z(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function tt(t){if(typeof t!="string")return;let n=t.trim().toLowerCase();if(n==="inherit")return"inherit";if(n==="none"||n==="off"||n==="disabled")return"none";if(n==="read"||n==="readonly"||n==="read-only")return"readOnly";if(n==="default"||n==="standard")return"default";if(n==="full"||n==="fullaccess"||n==="full-access")return"fullAccess"}function nt(t){if(t===void 0)return;if(typeof t=="string"||Array.isArray(t)){let r=d(t);return r.length>0?{allow:r}:void 0}if(!Z(t))return;let n=d(t.allow),e=d(t.deny),o=tt(t.mode),i={};return o&&(i.mode=o),n.length>0&&(i.allow=n),e.length>0&&(i.deny=e),Object.keys(i).length>0?i:void 0}function et(t){let n=X(t.worktree??t.defaultWorktreeIsolation);if(n===!0)return"worktree";if(n===!1)return"none";let e=u(t.isolation)?.toLowerCase();if(e==="worktree")return"worktree";if(e==="none"||e==="off"||e==="disabled")return"none"}function ot(t){let n=[];return E(t.name)||n.push(`Invalid agent name "${t.name}". Use 1-64 lowercase letters, digits, hyphens, or underscores, starting with a letter.`),t.prompt.trim().length===0&&n.push("Agent definition body is empty."),n}function rt(t,n,e){let o=C(t,"utf8"),i=S(o),r=i.frontmatter,s=Q(t),a=u(r.name)?.toLowerCase()??s,f=i.content.trim(),y=ot({name:a,prompt:f});if(y.length>0)throw new Error(y.join(" "));let p=u(r.description),c=u(r.model),l=u(r.color),h=u(r.memory??r.memoryScope),$=et(r),P=nt(r.tools);return{name:a,scope:n,path:t,...p?{description:p}:{},...c?{model:c}:{},...l?{color:l}:{},...h?{memory:h}:{},...$?{isolation:$}:{},tags:d(r.tags),skills:d(r.skills),hooks:d(r.hooks),prompt:f,active:!0,priority:e,...P?{toolPolicy:P}:{}}}function w(t,n,e,o,i){for(let r of K(t))try{o.push(rt(r,n,e))}catch(s){i.push({path:r,scope:n,message:s instanceof Error?s.message:String(s)})}}function it(t){let n=new Map;for(let e of t){let o=n.get(e.name);(!o||e.priority>o.priority)&&n.set(e.name,e)}return n}function st(t,n){let e=n.get(t.name),o=e?.path===t.path;return{name:t.name,scope:t.scope,path:t.path,...t.description?{description:t.description}:{},...t.model?{model:t.model}:{},...t.color?{color:t.color}:{},...t.memory?{memory:t.memory}:{},...t.isolation?{isolation:t.isolation}:{},tags:t.tags,skills:t.skills,hooks:t.hooks,prompt:t.prompt,active:o,...t.toolPolicy?{toolPolicy:t.toolPolicy}:{},...!o&&e?{shadowedBy:{name:e.name,scope:e.scope,path:e.path}}:{}}}function N(t=process.cwd(),n={}){let e=n.cwd??t,o=n.userDir??O(n.agentHome),i=n.projectDirs??G(e),r=n.pluginDirs??[],s=n.builtInDirs??[],a=[],f=[];n.includeUser!==!1&&w(o,"user",0,a,f),n.includeProject!==!1&&i.forEach((c,l)=>w(c,"project",100+l,a,f)),n.includePlugins&&r.forEach((c,l)=>w(c,"plugin",1e3+l,a,f)),n.includeBuiltIns&&s.forEach((c,l)=>w(c,"built-in",2e3+l,a,f));let y=it(a),p=a.map(c=>st(c,y));return p.sort((c,l)=>{if(c.active!==l.active)return c.active?-1:1;let h=c.name.localeCompare(l.name);return h!==0?h:c.path.localeCompare(l.path)}),{definitions:p,issues:f,searchPaths:{...n.includeUser!==!1?{user:o}:{},project:n.includeProject===!1?[]:i,plugin:n.includePlugins?r:[],builtIn:n.includeBuiltIns?s:[]}}}function mt(t,n=process.cwd(),e={}){let o=t.trim().toLowerCase(),i=N(n,e);return{definition:i.definitions.find(r=>r.active&&r.name===o)??null,scan:i}}var D=class{constructor(n={}){this.options=n}options;scan(n=this.options.cwd??process.cwd()){return N(n,this.options)}},I=class{constructor(n=new D){this.loader=n}loader;resolve(n,e=process.cwd()){let o=this.loader.scan(e),i=n.trim().toLowerCase();return{definition:o.definitions.find(r=>r.active&&r.name===i)??null,scan:o}}};function A(t){if(!t||t.length===0)return;let n=Array.from(new Set(t.map(e=>e.trim()).filter(Boolean)));return n.length>0?n:void 0}function ct(t,n){if(!t&&!n)return;if(!t)return A(n);if(!n)return A(t);let e=new Set(n);return A(t.filter(o=>e.has(o)))}function at(t,n){let e={none:0,readOnly:1,default:2,fullAccess:3,inherit:4},o=n??"inherit",i=t??"inherit";return e[o]<=e[i]?o:i}function pt(t,n={}){let e=t.toolPolicy??{},o={mode:at(e.mode,n.mode)},i=ct(n.allow,e.allow),r=A([...n.deny??[],...e.deny??[]]);return i&&(o.allow=i),r&&(o.deny=r),o}function ht(t){return{name:`custom-agent:${t.name}`,order:20,provide(){let n=["","","# Custom Agent",`Active agent: ${t.name}`,`Definition scope: ${t.scope}`,`Definition path: ${t.path}`];return t.description&&n.push(`Description: ${t.description}`),n.push("",t.prompt),n.join(`
|
|
3
|
+
`)}}}function yt(t){return{name:t.name,scope:t.scope,path:t.path,...t.description?{description:t.description}:{},...t.model?{model:t.model}:{},...t.color?{color:t.color}:{},...t.memory?{memory:t.memory}:{},...t.isolation?{isolation:t.isolation}:{},tags:t.tags,skills:t.skills,hooks:t.hooks,active:t.active,...t.toolPolicy?{toolPolicy:t.toolPolicy}:{},...t.shadowedBy?{shadowedBy:t.shadowedBy}:{}}}function g(t,n){return t.length>=n?t:t+" ".repeat(n-t.length)}function wt(t,n){let e=[];if(t.length===0)e.push("No custom agent definitions found.");else{e.push(`${g("name",22)} ${g("scope",8)} ${g("status",9)} description`),e.push(`${"-".repeat(22)} ${"-".repeat(8)} ${"-".repeat(9)} ${"-".repeat(32)}`);for(let o of t){let i=o.active?"active":"shadowed";e.push(`${g(o.name,22)} ${g(o.scope,8)} ${g(i,9)} ${o.description??""}`)}}if(n.length>0){e.push("","Invalid definitions:");for(let o of n)e.push(`- ${o.path}: ${o.message}`)}return e.join(`
|
|
4
4
|
`)+`
|
|
5
|
-
`}function
|
|
6
|
-
`)}function
|
|
7
|
-
`);return
|
|
5
|
+
`}function At(t){let n=[`Agent: ${t.name}`,`Scope: ${t.scope}`,`Path: ${t.path}`,`Status: ${t.active?"active":"shadowed"}`];return t.description&&n.push(`Description: ${t.description}`),t.model&&n.push(`Model: ${t.model}`),t.color&&n.push(`Color: ${t.color}`),t.memory&&n.push(`Memory: ${t.memory}`),t.isolation&&n.push(`Isolation: ${t.isolation}`),t.tags.length>0&&n.push(`Tags: ${t.tags.join(", ")}`),t.skills.length>0&&n.push(`Skills: ${t.skills.join(", ")}`),t.hooks.length>0&&n.push(`Hooks: ${t.hooks.join(", ")}`),t.toolPolicy&&n.push(`Tools: ${JSON.stringify(t.toolPolicy)}`),t.shadowedBy&&n.push(`Shadowed by: ${t.shadowedBy.scope} ${t.shadowedBy.path}`),n.push("",t.prompt,""),n.join(`
|
|
6
|
+
`)}function Dt(t){let n=t.name.trim().toLowerCase();if(!E(n))throw new Error(`Invalid agent name "${t.name}". Use 1-64 lowercase letters, digits, hyphens, or underscores, starting with a letter.`);let e=t.scope==="user"?O(t.agentHome):V(t.cwd??process.cwd());B(e,{recursive:!0});let o=m(e,`${n}.md`);if(k(o)&&!t.force)throw new Error(`Agent definition already exists: ${o}`);let i=t.description?.trim()||`${n} custom agent`,r=t.prompt?.trim()||`You are ${n}. Replace this paragraph with precise operating instructions, constraints, tools policy, verification expectations, and the kind of work this agent should own.`,a=[...["---",`name: ${n}`,`description: ${JSON.stringify(i)}`,...t.model?.trim()?[`model: ${JSON.stringify(t.model.trim())}`]:[],...t.color?.trim()?[`color: ${JSON.stringify(t.color.trim())}`]:[],...t.memory?.trim()?[`memory: ${JSON.stringify(t.memory.trim())}`]:[],...t.isolation?[`isolation: ${t.isolation}`]:[],"tags: []",...t.skills&&t.skills.length>0?[`skills: ${JSON.stringify(t.skills)}`]:[],...t.hooks&&t.hooks.length>0?[`hooks: ${JSON.stringify(t.hooks)}`]:[],...t.toolPolicy?["tools:",...t.toolPolicy.mode?[` mode: ${t.toolPolicy.mode}`]:[],...t.toolPolicy.allow&&t.toolPolicy.allow.length>0?[` allow: ${JSON.stringify(t.toolPolicy.allow)}`]:[],...t.toolPolicy.deny&&t.toolPolicy.deny.length>0?[` deny: ${JSON.stringify(t.toolPolicy.deny)}`]:[]]:[],"---"],"",r,""].join(`
|
|
7
|
+
`);return J(o,a,"utf8"),o}export{D as AgentDefinitionLoader,I as AgentDefinitionResolver,Dt as createAgentDefinitionFile,ht as createAgentDefinitionPromptSection,G as getProjectAgentDefinitionDirs,V as getProjectAgentDefinitionsDir,O as getUserAgentDefinitionsDir,E as isValidAgentDefinitionName,At as renderAgentDefinition,wt as renderAgentDefinitions,mt as resolveAgentDefinition,pt as resolveAgentToolPolicy,N as scanAgentDefinitions,yt as toAgentDefinitionMetadata,ot as validateAgentDefinition};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{randomUUID as J}from"crypto";import{appendFileSync as M,existsSync as y,mkdirSync as
|
|
2
|
-
`,{encoding:"utf8",flag:"wx"})}function $(
|
|
3
|
-
`,"utf8"),z(e
|
|
4
|
-
`,"utf8"),s&&this.update(t,c=>({...c,lastActivityAt:o.timestamp}))}readEvents(t){let
|
|
1
|
+
import{randomUUID as J}from"crypto";import{appendFileSync as M,existsSync as y,mkdirSync as l,readFileSync as L,readdirSync as U,renameSync as z,rmSync as j,writeFileSync as g}from"fs";import{homedir as q}from"os";import{basename as P,dirname as b,join as u,resolve as B}from"path";var m="0.6.4";import{mkdirSync as x,readFileSync as O,rmSync as v,writeFileSync as V}from"fs";import{hostname as k}from"os";import{dirname as _}from"path";function I(){return new Date().toISOString()}function N(){return new Date(Date.now()-Math.floor(process.uptime()*1e3)).toISOString()}function w(e){try{return JSON.parse(O(e,"utf8"))}catch{return null}}function T(e){if(!e||e<=0)return!1;try{return process.kill(e,0),!0}catch{return!1}}function F(e){return e.hostname!==k()?!0:T(e.pid)}function h(e,t){x(_(e),{recursive:!0}),V(e,JSON.stringify(t,null,2)+`
|
|
2
|
+
`,{encoding:"utf8",flag:"wx"})}function $(e,t){let r=w(e);r?.pid!==t.pid||r.hostname!==t.hostname||v(e,{force:!0})}function S(e,t,r){let n=I(),s={schemaVersion:1,name:t,pid:process.pid,hostname:k(),processStartedAt:N(),version:r,acquiredAt:n,updatedAt:n};try{h(e,s)}catch(a){if(a.code!=="EEXIST")throw a;let c=w(e);if(c&&F(c))throw new Error(`${t} is already locked by PID ${c.pid} on ${c.hostname}.`);v(e,{force:!0}),h(e,s)}return{record:s,release:()=>{$(e,s)}}}var D=1,H=u(q(),".xeno-agent"),W=u(process.env.XENO_AGENT_HOME??H,"daemon"),A=u(W,"runs");function i(){return new Date().toISOString()}function G(e=new Date){return e.toISOString().replace(/[^0-9]/g,"").slice(0,14)}function R(e){return e.replace(/[^A-Za-z0-9_.-]/g,"_").slice(0,80)}function p(e){return B(e)}function f(e){return p(e).toLowerCase()}function C(e,t){let r=f(e),n=f(t);return r===n||r.startsWith(`${n}\\`)||r.startsWith(`${n}/`)}function K(e,t){return!!(f(e.cwd)===f(t)||e.git?.root&&C(t,e.git.root)||e.git?.worktree&&C(t,e.git.worktree))}function X(e){return R(Buffer.from(p(e)).toString("base64url"))}function Z(){return{input:0,output:0,total:0}}function d(e){try{return JSON.parse(L(e,"utf8"))}catch{return null}}function Q(e){return e instanceof Error&&/\balready locked by PID\b/.test(e.message)}function Y(e,t){l(b(e),{recursive:!0});let r=`${e}.${process.pid}.${Date.now()}.tmp`;g(r,JSON.stringify(t,null,2)+`
|
|
3
|
+
`,"utf8"),z(r,e)}function tt(e){if(!e||e<=0)return!1;try{return process.kill(e,0),!0}catch{return!1}}function et(e){return e==="completed"||e==="failed"||e==="cancelled"||e==="interrupted"}function rt(e,t){return e.pinned!==t.pinned?e.pinned?-1:1:Date.parse(t.updatedAt)-Date.parse(e.updatedAt)}function Rt(){return A}function At(e){return u(A,e)}function nt(e=new Date){return`run_${G(e)}_${J().slice(0,8)}`}var E=class{constructor(t=A){this.runsDir=t;l(this.runsDir,{recursive:!0})}runsDir;create(t){let r=nt(),n=u(this.runsDir,r);l(n,{recursive:!0});let s=i(),a=u(n,"events.jsonl"),o={schemaVersion:D,runId:r,sessionId:r,rootRunId:r,cwd:p(t.cwd),workspaceId:X(t.cwd),prompt:t.prompt,...t.title?{title:t.title}:{},status:"starting",model:t.model,...t.effort?{effort:t.effort}:{},...t.agent?{agent:t.agent}:{},...t.git?{git:t.git}:{},permissionMode:t.permissionMode,...t.cliVersion?{createdByCliVersion:t.cliVersion}:{},createdBySdkVersion:t.sdkVersion??m,createdAt:s,updatedAt:s,lastActivityAt:s,pinned:!!t.pinned,attachedClients:0,...t.cliVersion?{cliVersion:t.cliVersion}:{},...t.sdkVersion?{sdkVersion:t.sdkVersion}:{},stdoutPath:u(n,"stdout.log"),stderrPath:u(n,"stderr.log"),eventsPath:a,usage:Z(),children:[],tags:[]};return g(o.stdoutPath,"","utf8"),g(o.stderrPath,"","utf8"),g(o.eventsPath,"","utf8"),this.write(o),this.appendEvent(r,"run_created",{cwd:o.cwd,model:o.model,...o.agent?{agent:o.agent}:{},...o.git?{git:o.git}:{},permissionMode:o.permissionMode,pinned:o.pinned}),o}get(t){let r=d(this.recordPath(t));return r?this.refreshRecordStatus(r):null}list(t={}){if(!y(this.runsDir))return[];let r=U(this.runsDir,{withFileTypes:!0}).filter(n=>n.isDirectory()).map(n=>{try{return this.get(n.name)}catch(s){if(Q(s))return d(this.recordPath(n.name));throw s}}).filter(n=>n!==null).filter(n=>t.all||!t.cwd||K(n,t.cwd)).filter(n=>!t.status||t.status.includes(n.status)).sort(rt);return typeof t.limit=="number"&&t.limit>0?r.slice(0,t.limit):r}markSpawned(t,r,n){return this.update(t,s=>({...s,status:"running",workerPid:r,...n?{workerVersion:n}:{},startedAt:s.startedAt??i(),lastActivityAt:i()}))}markStarted(t,r){return this.update(t,n=>({...n,status:"running",workerPid:r.pid,...r.workerVersion?{workerVersion:r.workerVersion}:{},...r.model?{model:r.model}:{},...r.effort?{effort:r.effort}:{},startedAt:n.startedAt??i(),lastActivityAt:i()}))}markCompleted(t,r){return this.update(t,n=>({...n,status:r.status,...r.statusReason?{statusReason:r.statusReason}:{},exitCode:r.exitCode??null,usage:r.usage??n.usage,endedAt:i(),lastActivityAt:i()}))}markCancelled(t,r){return this.update(t,n=>({...n,status:"cancelled",statusReason:r,endedAt:i(),lastActivityAt:i()}))}markPaused(t,r="Paused by user."){let n=this.update(t,s=>({...s,status:"paused",statusReason:r,lastActivityAt:i()}));return n&&this.appendEvent(t,"run_paused",{reason:r}),n}markResumed(t,r="Resumed by user."){let n=this.update(t,s=>{let a={...s,status:"running",statusReason:r,lastActivityAt:i()};return delete a.endedAt,delete a.exitCode,a});return n&&this.appendEvent(t,"run_resumed",{reason:r}),n}setPinned(t,r){let n=this.update(t,s=>({...s,pinned:r,lastActivityAt:i()}));return n&&this.appendEvent(t,r?"run_pinned":"run_unpinned",{pinned:r}),n}appendEvent(t,r,n={}){let s=d(this.recordPath(t)),a=s?.eventsPath??u(this.runsDir,t,"events.jsonl");l(b(a),{recursive:!0});let o={schemaVersion:D,runId:t,type:r,timestamp:i(),payload:n};M(a,JSON.stringify(o)+`
|
|
4
|
+
`,"utf8"),s&&this.update(t,c=>({...c,lastActivityAt:o.timestamp}))}readEvents(t){let r=this.get(t);return!r||!y(r.eventsPath)?[]:L(r.eventsPath,"utf8").split(/\r?\n/).map(n=>n.trim()).filter(Boolean).map(n=>{try{return JSON.parse(n)}catch{return null}}).filter(n=>n!==null)}delete(t){j(u(this.runsDir,t),{recursive:!0,force:!0})}refreshRecordStatus(t){if(et(t.status))return t;if(t.workerPid&&!tt(t.workerPid)){let r={...t,status:"failed",statusReason:"Worker process is no longer running and did not record a terminal status.",endedAt:t.endedAt??i(),updatedAt:i()};return this.write(r),r}return t}update(t,r){let n=d(this.recordPath(t));if(!n)return null;let s=r(n);return s.updatedAt=i(),this.write(s),s}write(t){let r=S(u(this.runDir(t.runId),"run.lock"),`run:${t.runId}`,m);try{Y(this.recordPath(t.runId),t)}finally{r.release()}}recordPath(t){return u(this.runsDir,R(P(t)),"run.json")}runDir(t){return u(this.runsDir,R(P(t)))}};export{E as AgentRunStore,S as acquireControlPlaneLock,nt as createAgentRunId,At as getAgentRunDir,Rt as getAgentRunStoreDir};
|
package/dist/electron/index.d.ts
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
|
+
type PermissionProfileName = "default" | "read-only" | "trusted-dev";
|
|
2
|
+
type PermissionProfileDecision = "allow" | "ask" | "deny";
|
|
3
|
+
type PermissionProfileMode = "default" | "acceptEdits" | "bypassPermissions" | "auto";
|
|
4
|
+
interface PermissionProfile {
|
|
5
|
+
schemaVersion: 1;
|
|
6
|
+
name: PermissionProfileName;
|
|
7
|
+
displayName: string;
|
|
8
|
+
description: string;
|
|
9
|
+
permissionMode: PermissionProfileMode;
|
|
10
|
+
filesystem: {
|
|
11
|
+
scope: "workspace" | "workspace-readonly" | "unrestricted";
|
|
12
|
+
read: PermissionProfileDecision;
|
|
13
|
+
write: PermissionProfileDecision;
|
|
14
|
+
allowedPaths: string[];
|
|
15
|
+
deniedPaths: string[];
|
|
16
|
+
};
|
|
17
|
+
shell: {
|
|
18
|
+
default: PermissionProfileDecision;
|
|
19
|
+
allowedCommands: string[];
|
|
20
|
+
deniedCommands: string[];
|
|
21
|
+
};
|
|
22
|
+
network: {
|
|
23
|
+
default: PermissionProfileDecision;
|
|
24
|
+
allowDomains: string[];
|
|
25
|
+
denyDomains: string[];
|
|
26
|
+
};
|
|
27
|
+
mcp: {
|
|
28
|
+
remoteServers: PermissionProfileDecision;
|
|
29
|
+
allowedServers: string[];
|
|
30
|
+
deniedServers: string[];
|
|
31
|
+
};
|
|
32
|
+
lsp: {
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
diagnostics: PermissionProfileDecision;
|
|
35
|
+
navigation: PermissionProfileDecision;
|
|
36
|
+
startProcesses: PermissionProfileDecision;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
1
39
|
interface ToolDefinition {
|
|
2
40
|
name: string;
|
|
3
41
|
description: string;
|
|
@@ -69,6 +107,7 @@ interface PermissionRule {
|
|
|
69
107
|
interface PermissionConfig {
|
|
70
108
|
mode: "default" | "acceptEdits" | "bypassPermissions" | "plan" | "auto";
|
|
71
109
|
rules: PermissionRule[];
|
|
110
|
+
profile?: PermissionProfile;
|
|
72
111
|
}
|
|
73
112
|
type PermissionPromptOperation = "generic" | "filesystem" | "write" | "edit" | "bash";
|
|
74
113
|
interface PermissionPromptPreviewLine {
|
|
@@ -418,6 +457,12 @@ interface AuditEvent {
|
|
|
418
457
|
timestamp: string;
|
|
419
458
|
trace_id: string;
|
|
420
459
|
session_id?: string;
|
|
460
|
+
run_id?: string;
|
|
461
|
+
agent_id?: string;
|
|
462
|
+
parent_agent_id?: string;
|
|
463
|
+
workspace?: string;
|
|
464
|
+
model?: string;
|
|
465
|
+
provider?: string;
|
|
421
466
|
event_type: string;
|
|
422
467
|
actor: "user" | "assistant" | "system";
|
|
423
468
|
risk_level: AuditRiskLevel;
|
|
@@ -430,10 +475,17 @@ interface AuditEvent {
|
|
|
430
475
|
interface AuditLoggerOptions {
|
|
431
476
|
filePath: string;
|
|
432
477
|
sessionId?: string;
|
|
478
|
+
runId?: string;
|
|
479
|
+
agentId?: string;
|
|
480
|
+
parentAgentId?: string;
|
|
481
|
+
workspace?: string;
|
|
482
|
+
model?: string;
|
|
483
|
+
provider?: string;
|
|
433
484
|
}
|
|
434
485
|
declare class AuditLogger {
|
|
435
486
|
private filePath;
|
|
436
487
|
private sessionId?;
|
|
488
|
+
private labels;
|
|
437
489
|
private sequence;
|
|
438
490
|
private writeQueue;
|
|
439
491
|
constructor(options: AuditLoggerOptions);
|