openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
2 lines • 20.1 kB
JavaScript
import{nt as e}from"./openclaw-state-read-sqlite-readonly-worker-umlSCyCR.mjs";import{H as t,V as n}from"./openclaw-state-read-map-size-DJbMcZYM.mjs";import{a as r,d as i,f as a,g as o,r as s,t as c}from"./openclaw-state-read-home-dir-BQZX1pD2.mjs";import{a as l,c as u,s as d}from"./openclaw-state-read-tmp-openclaw-dir-C3Ynn93H.mjs";import"./openclaw-state-read-logger-Ix7jXPG1.mjs";import{x as f}from"./openclaw-state-read-read-open-flags-CtNL1rJs.mjs";import{ct as p}from"./openclaw-state-read-root-symlink-policy-AldRD6ik.mjs";import{i as m,r as h}from"./openclaw-state-read-path-existence-Bp_sxI9A.mjs";import{s as g}from"./openclaw-state-read-openclaw-state-db-async-lifecycle-B_Y330HB.mjs";import{a as _}from"./openclaw-state-read-record-coerce-D1s3ReAs.mjs";import{w as v}from"./openclaw-state-read-fs-safe-CpAHBauR.mjs";import{t as y}from"./openclaw-state-read-runtime-worker-url-ClM3d-g2.mjs";import{c as b}from"./openclaw-state-read-sqlite-worker-request-class-Coonj2Xz.mjs";import{n as x}from"./openclaw-state-read-agent-id-DmscQLD6.mjs";import"./openclaw-state-read-boundary-path-CCynIYBo.mjs";import{n as S,r as C}from"./openclaw-state-read-session-key-DaKMXMbu.mjs";import{a as w}from"./openclaw-state-read-openclaw-state-worker-context-Cvog3s4V.mjs";import T from"node:fs";import E from"node:path";import{isMainThread as D}from"node:worker_threads";import{spawn as O}from"node:child_process";import k from"node:fs/promises";import A from"node:os";import{EventEmitter as j}from"node:events";const M=/^(?:(?:pnpm|npm|bunx|npx)\s+)?openclaw(?=\s|$)/,N=/(?:^|\s)--container(?:\s|=|$)/,P=/(?:^|\s)--profile(?:\s|=|$)/,F=/(?:^|\s)--dev(?:\s|$)/,I=/^(?:\s+--(?:dev|no-color|(?:profile|log-level)[=\s]+\S+))*\s+update(?:\s|$)/,L=/^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,127}$/;function formatCliCommand(e,t=process.env){let n=t.OPENCLAW_CONTAINER_HINT?.trim(),r=n&&L.test(n)?n:void 0,i=d(t.OPENCLAW_PROFILE);if(!r&&!i||!M.test(e))return e;let a;return r&&!N.test(e)&&!I.test(e.replace(M,``))&&(a=`--container ${r}`),!r&&i&&!P.test(e)&&!F.test(e)&&(a=`--profile ${i}`),a?e.replace(M,e=>`${e} ${a}`):e}function hasExplicitModelPolicyAllow(e){return _(e)&&Object.hasOwn(e,`allow`)}const R={},z=[{id:`openclaw`,kind:`system`},{id:`crestodian`,kind:`system`}],B=new Set(z.map(e=>x(e.id)));function isReservedSystemAgentId(e){return B.has(x(e))}let V;const H=/* @__PURE__ */ new WeakMap;function readAgentRosterFacts(e){if(e===void 0)return V.facts;let t=R.current,n=t?.config===e?t.revision:void 0;if(n===void 0&&!w(e))return;let r=H.get(e);return r&&r.publication===n||(r={publication:n,facts:{}},H.set(e,r)),r.facts}function collectAgentEntries(e,t,n){let r=readAgentRosterProperty(e);if(r?.kind===`entries`&&_(r.value)){let e=[];for(let i in r.value){if(!Object.hasOwn(r.value,i))continue;let a=r.value[i];if(_(a)){let r={...a,id:i};if(e.push(t?{entry:r,source:{kind:`entries`,key:i}}:r),e.length===n)break}}return e}if(r?.kind!==`list`||!Array.isArray(r.value))return[];let i=[];return r.value.some((e,t)=>(typeof e==`object`&&e&&i.push({entry:e,source:{kind:`list`,index:t}}),i.length===n)),t?i:i.map(({entry:e})=>e)}function listAgentEntriesWithSource(e){return collectAgentEntries(e,!0)}function listAgentEntries(e){return collectAgentEntries(e,!1)}function readAgentRosterProperty(e){if(!_(e))return;let t=e.agents;if(_(t))for(let e of[`entries`,`list`]){let n=t[e];if(Object.hasOwn(t,e)&&n!==void 0)return{kind:e,value:n}}}function hasAgentRosterProperty(e){return readAgentRosterProperty(e)!==void 0}function listAgentIds(e){let t=readAgentRosterFacts(e);if(t?.agentIds)return t.agentIds;let n=listAgentEntries(e),r=n.length===0&&!hasAgentRosterProperty(e)?[S]:[...new Set(n.map(e=>x(e?.id)))];return t&&(Object.freeze(r),t.agentIds=r),r}function listGatewayOwnedAgentIds(e){return[.../* @__PURE__ */ new Set([...listAgentIds(e),...z.map(({id:e})=>e)])]}function tryResolveSoleAgentId(e){let t=collectAgentEntries(e,!1,2);return t.length===0?hasAgentRosterProperty(e)?void 0:S:t.length===1?x(t[0].id):void 0}function tryResolveRawLegacyDefaultAgentId(e){if(e.agents?.ownership===`explicit`)return;let t=collectAgentEntries(e,!1).filter(e=>e.default===!0);return t.length===1?x(t[0].id):void 0}function tryResolveDefaultAgentId(e){return tryResolveRawLegacyDefaultAgentId(e)??tryResolveSoleAgentId(e)}function tryResolveLegacyDataOwner(e){return tryResolveDefaultAgentId(e)}function resolveConcreteSessionStorePath(e){let t=e?.trim();if(t&&t!==`(multiple)`&&!t.includes(`{agentId}`))return t}function resolveUnsuffixedSqliteTargetFromSessionStorePath(e){let t=resolveConcreteSessionStorePath(e);if(!t)throw Error(`Session storage requires a concrete store path`);let n=E.resolve(t);if(n.endsWith(`.sqlite`)){let e=resolveAgentIdFromSqliteDatabasePath(n);return{path:n,...e?{agentId:e}:{shared:!0}}}let r=E.dirname(n);if(E.basename(n)!==`sessions.json`){let e=E.basename(n,E.extname(n))||`openclaw-agent`;return{path:E.join(r,`${e}.sqlite`)}}if(E.basename(r)!==`sessions`)return{path:E.join(r,`openclaw-agent.sqlite`)};let i=E.dirname(r);return E.basename(E.dirname(i))===`agents`?{agentId:x(E.basename(i)),path:E.join(i,`agent`,`openclaw-agent.sqlite`)}:{path:E.join(r,`openclaw-agent.sqlite`)}}function listSqliteTargetCandidatePathsForSessionStorePath(e,n){let r=resolveUnsuffixedSqliteTargetFromSessionStorePath(e);if(r.agentId||r.shared)return[r.path];let i=E.dirname(r.path),a=E.basename(r.path,`.sqlite`),o=n?`${a}.${x(n)}`:void 0,s=/* @__PURE__ */ new Set([E.basename(r.path)]);try{for(let e of T.readdirSync(i)){let t=e.replace(/-(?:wal|shm|journal)$/u,``);t.startsWith(`${a}.`)&&t.endsWith(`.sqlite`)&&(!o||parseSqliteTargetSuffixIndex(t,o)!==void 0)&&s.add(t)}}catch(e){t(e)}return[...s].map(e=>E.join(i,e))}function parseSqliteTargetSuffixIndex(e,t){if(e===`${t}.sqlite`)return 1;if(!e.startsWith(`${t}.`)||!e.endsWith(`.sqlite`))return;let n=e.slice(t.length+1,-7);if(!/^[1-9]\d*$/.test(n))return;let r=Number(n);return Number.isSafeInteger(r)&&r>=2&&String(r)===n?r:void 0}function resolveAgentIdFromSqliteDatabasePath(e){if(E.basename(e)!==`openclaw-agent.sqlite`)return;let t=E.dirname(e);if(E.basename(t)!==`agent`)return;let n=E.dirname(t);if(E.basename(E.dirname(n))===`agents`)return x(E.basename(n))}function resolveSessionTranscriptsDirForAgent(e,t=process.env,n=()=>s(t,A.homedir)){if(!e?.trim())throw Error(`Session storage path requires an explicit agent id.`);let r=l(t,n),i=x(e);return E.join(r,`agents`,i,`sessions`)}var SessionStoreAgentIdRequiredError=class extends Error{constructor(){super(`Session store path requires an explicit agent id.`),this.name=`SessionStoreAgentIdRequiredError`}};function resolveSessionStorePathCore(e,t){let n=t?.env??process.env,homedir=()=>s(n,A.homedir);if(!e){if(!t?.agentId?.trim())throw new SessionStoreAgentIdRequiredError;return`${resolveSessionTranscriptsDirForAgent(t.agentId,n,homedir)}${E.sep}sessions.json`}let r=e;if(r.includes(`{agentId}`)){if(!t?.agentId?.trim())throw new SessionStoreAgentIdRequiredError;let e=x(t.agentId);r=r.replaceAll(`{agentId}`,e)}return r.startsWith(`~`)&&(r=c(r,{home:s(n,homedir),env:n,homedir})),E.isAbsolute(r)?E.resolve(r):E.resolve(l(n,homedir),r)}function resolveAgentsDirFromSessionStorePath(e){let t=E.resolve(e);if(E.basename(t)!==`sessions.json`)return;let n=E.dirname(t);if(E.basename(n)!==`sessions`)return;let r=E.dirname(n),i=E.dirname(r);if(E.basename(i)===`agents`)return i}function resolveMissingStorePathIdentity(t){try{let n=e(E.resolve(t));return E.resolve(n.existingPath,...n.unresolvedSegments)}catch{return}}function isPerAgentSessionStoreConfig(e){return!e?.trim()||e.includes(`{agentId}`)}function isSameFixedSessionStoreConfig(e,t,n){if(isPerAgentSessionStoreConfig(e)||isPerAgentSessionStoreConfig(t))return!1;let r=E.resolve(resolveSessionStorePathCore(e,{env:n})),i=E.resolve(resolveSessionStorePathCore(t,{env:n}));if(r===i)return!0;try{return p(T.statSync(r,{bigint:!0}),T.statSync(i,{bigint:!0}))}catch(e){let t=e.code;if(t!==`ENOENT`&&t!==`ENOTDIR`)return!0}let a=resolveMissingStorePathIdentity(r),o=resolveMissingStorePathIdentity(i);if(!a||!o||a===o)return!0;if(a.toLowerCase()!==o.toLowerCase())return!1;let s=v(a),c=v(o);return s!==!1&&c!==!1}function resolvePersistedSessionStoreOwner(e){if(isPerAgentSessionStoreConfig(e.session?.store))return{kind:`none`};let t=e.agents?.defaults?.sessionStore?.agentId?.trim();if(!t)return{kind:`none`};let n=x(t);return listAgentIds(e).some(e=>x(e)===n)?{kind:`configured`,agentId:n}:{kind:`retired`,agentId:n}}function resolvePersistedSessionStoreOwnerForKey(e,t){return C(t)===`legacy_or_alias`?resolvePersistedSessionStoreOwner(e):{kind:`none`}}function resolvePersistedSessionStoreOwnerForTarget(e){let t=resolvePersistedSessionStoreOwnerForKey(e.config,e.sessionKey);return t.kind===`none`||!e.storePath||isSameFixedSessionStoreConfig(e.config.session?.store,e.storePath,e.env??process.env)?t:{kind:`none`}}let U,W=0;function startHost(){let e=O(process.execPath,[...y(b(`directoryWatchHost`)),String(process.pid)],{stdio:[`pipe`,`pipe`,`ignore`],detached:!0,env:{...process.env,NODE_OPTIONS:void 0}}),t={child:e,watches:/* @__PURE__ */ new Map,retired:0},n=``;e.stdout.setEncoding(`utf8`).on(`data`,e=>{let r=(n+e).split(`
`);n=r.pop()??``;for(let e of r){let n=JSON.parse(e),r=t.watches.get(n.id);r&&(n.event?r.emit(`change`,n.event,n.filename??void 0):(t.watches.delete(n.id),r.emit(`error`,/* @__PURE__ */ Error(`Directory watch host lost the watch`),!0)))}});let lost=()=>{U===t&&(U=void 0);let e=Array.from(t.watches.values());t.watches.clear();for(let t of e)t.emit(`error`,/* @__PURE__ */ Error(`Directory watch host exited`),!1)};e.on(`error`,lost).on(`exit`,lost),e.stdin.on(`error`,()=>{}),e.unref();for(let t of[e.stdin,e.stdout])t.unref?.();return t}function register(e,t,n){e.watches.set(t,n),e.child.stdin.write(`${JSON.stringify({id:t,path:n.path,recursive:n.recursive})}\n`)}function watchDirectory(e,t,n=!1){let r=W++,i=Object.assign(new j,{path:e,recursive:n});i.on(`change`,t);try{register(U??=startHost(),r,i)}catch(e){U?.watches.delete(r),queueMicrotask(()=>i.emit(`error`,e,!1))}return Object.assign(i,{close(){i.removeAllListeners(`change`);let e=U;if(e?.watches.delete(r)){if(e.watches.size&&(process.platform!==`darwin`||++e.retired<64))e.child.stdin.write(`${JSON.stringify({id:r})}\n`);else{if(U=void 0,e.watches.size){let t=U=startHost();for(let[n,r]of e.watches)register(t,n,r);e.watches.clear()}e.child.stdin.end()}}}})}const G=/* @__PURE__ */ new Map,K=/* @__PURE__ */ new Map;let q,J=1/0;const Y=3e4;function nextFallback(e=Y){let t=Date.now(),n=(Math.floor(t/e)+1)*e;return{atMs:n,elapsedAtMs:performance.now()+n-t}}function fallbackRemaining(e){return Math.min(e.nextFallback.atMs-Date.now(),e.nextFallback.elapsedAtMs-performance.now())}function retainEarlierFallback(e,t){e.nextFallback.atMs=Math.min(e.nextFallback.atMs,t.atMs),e.nextFallback.elapsedAtMs=Math.min(e.nextFallback.elapsedAtMs,t.elapsedAtMs)}function scheduleFallback(e){if(!G.size)return;let t=e?fallbackRemaining(e):Math.min(...Array.from(G.values(),fallbackRemaining)),r=performance.now()+Math.max(0,Math.ceil(t));q&&J<=r||(clearTimeout(q),J=r,q=n(()=>setTimeout(()=>{reconcile()},Math.max(0,Math.ceil(t))).unref()))}async function reconcile(){q=void 0;let e=Array.from(G.values()).filter(e=>fallbackRemaining(e)<=0),t=/* @__PURE__ */ new Map;for(let n of e){n.nextFallback=nextFallback(n.reconcileIntervalMs);let e=n.source;if((!e||!await k.access(e.path).then(()=>!0,()=>!1)||e.path!==n.path&&await k.access(n.path).then(()=>!0,()=>!1))&&n.source===e)for(let r of e?.directories??[n])t.set(r,e)}for(let[e,n]of t)(G.get(e.key)!==e||e.source!==n)&&t.delete(e);for(let e of t.keys())detach(e);for(let e of t.keys())attach(e);for(let t of e)G.get(t.key)===t&¬ify(t);scheduleFallback()}function detach(e){let t=e.source;e.source=void 0,t&&(t.directories=t.directories.filter(t=>t!==e),t.directories.length||(K.delete(t.key),t.watcher.close()))}function notify(e,t,n){for(let r of e.listeners)r(t,n)}function attach(e,t=e.watchRoot){let r=e.recursive&&t===e.watchRoot,i=JSON.stringify([t,r]),a=K.get(i);if(a){a.directories=[...a.directories,e],e.source=a;return}let o=E.basename(t),s=n(()=>watchDirectory(t,(e,n)=>{let r=K.get(i);if(!r||r.watcher!==s)return;r.admitted=!0;let a=r.directories,c=e===`rename`&&(!n||n===o),l;for(let r of a)(r.path===t||!n||c||f(r.path,l??=E.resolve(t,n))||f(l,r.path))&¬ify(r,r.path===t?n:void 0,e);if(e===`rename`){let e;for(let r of a)(c||r.watchRoot!==t&&n!==void 0&&f(l??=E.resolve(t,n),r.watchRoot))&&(e??=[]).push(r);if(!e)return;for(let t of e)detach(t);for(let t of e)G.get(t.key)===t&&(attach(t),retainEarlierFallback(t,nextFallback(t.reconcileIntervalMs)),scheduleFallback(t))}},r)),c={key:i,path:t,watcher:s,admitted:!1,directories:[e]};K.set(i,c),e.source=c,s.on(`error`,(e,n)=>{for(let e of c.directories){detach(e);let r=E.dirname(t);n&&!c.admitted&&r!==t?attach(e,r):(notify(e),retainEarlierFallback(e,nextFallback()),scheduleFallback(e))}})}function observeOwnedDirectory(e,t,n={}){let r=E.resolve(e),i=n.watchRoot?E.resolve(n.watchRoot):r,a=n.recursive??!1,o=n.reconcileIntervalMs??Y,s=JSON.stringify([r,i,a,o]),c=G.get(s);c||(c={key:s,path:r,watchRoot:i,recursive:a,reconcileIntervalMs:o,listeners:[],nextFallback:{atMs:1/0,elapsedAtMs:1/0}},G.set(s,c),attach(c));let listener=(e,n)=>t(e,n);return c.listeners=[...c.listeners,listener],retainEarlierFallback(c,nextFallback(o)),scheduleFallback(c),{isWatching:()=>c.listeners.includes(listener)&&c.source!==void 0,close(){c.listeners=c.listeners.filter(e=>e!==listener),!(c.listeners.length||G.get(s)!==c)&&(G.delete(s),detach(c),G.size||(clearTimeout(q),q=void 0))}}}const X=/* @__PURE__ */ new Map,Z=o(Symbol.for(`openclaw.agentDirPreparedPaths`),e=>{for(let t of e.values())t.close();e.clear()},`shared-state`);function registryPath(e,t,n=!1,i){let a=E.resolve(r(e,t)),o=g()?.ownsSchemaMaintenance===!0,s=o?void 0:Z.get(a);if(s)return s.key;let c=i??normalizeAgentDirRegistryPath(a,t);if(o||!D||!n&&!X.has(c))return c;let l=[],u={key:c,close:()=>l.forEach(e=>e.close())};Z.set(a,u);let d=!1;for(let e=a;E.dirname(e)!==e;e=E.dirname(e)){let t=E.basename(e);l.push(observeOwnedDirectory(E.dirname(e),e=>{d||e!==void 0&&e!==t||(d=!0,h(a).then(e=>{Z.get(a)===u&&e!==c&&(Z.delete(a),u.close())}).catch(()=>{}).finally(()=>{d=!1}))}))}let f=Math.max(256,X.size+1);for(let[e,t]of Z){if(Z.size<=f)break;Z.delete(e),t.close()}return c}function normalizeAgentDirRegistryPath(e,t=process.env){return m(r(e,t))}function registerResolvedAgentDir(e){let t=registryPath(e.agentDir,e.env,!0),n=X.get(t)??/* @__PURE__ */ new Set,r=x(e.agentId);return!n.has(r)&&(n.add(r),X.set(t,n),!0)}function resolveDefaultAgentWorkspaceDir(e=process.env,t=A.homedir){let n=e.OPENCLAW_WORKSPACE_DIR?.trim();if(n)return E.resolve(n);if(e.OPENCLAW_STATE_DIR?.trim())return E.join(l(e,t),`workspace`);let r=s(e,t),a=e.OPENCLAW_PROFILE?.trim();return a&&i(a)!=="default"?E.join(u(a,e,t),`workspace`):E.join(r,`.openclaw`,`workspace`)}resolveDefaultAgentWorkspaceDir();var AgentSelectionRequiredError=class extends Error{constructor(e,t){let n=t?.surface??`this operation`,r=t?.hint??`Select an agent explicitly; CLI callers can pass --agent <id>, channels can add a binding, and ambient services can set their agentId target.`;super(`Multiple agents are configured, but ${n} has no explicit owner. ${r}`),this.code=`AGENT_SELECTION_REQUIRED`,this.name=`AgentSelectionRequiredError`,this.agentIds=e,this.hint=r}};function resolveConfiguredAgentId(e,t){if(!listAgentIds(e).includes(t))throw Error(`Unknown agent id "${t}". Run ${formatCliCommand(`openclaw agents list`)} to see configured agents.`);return t}function resolveSoleAgentId(e,t){let n=tryResolveSoleAgentId(e);if(n)return n;let r=listAgentIds(e);throw r.length===0?Error("No agents configured. Run `openclaw onboard` or `openclaw agents add` first."):new AgentSelectionRequiredError(r,t)}function tryResolveLegacyDataOwnerAgentId(e){let t=readAgentRosterFacts(e);if(t?.legacyDataOwnerAgentId)return t.legacyDataOwnerAgentId.value;let n=tryResolveLegacyDataOwner(e);return t&&(t.legacyDataOwnerAgentId={value:n}),n}function tryResolveLegacyCompatibilityAgentId(e){let t=readAgentRosterFacts(e);if(t?.compatibilityAgentId)return t.compatibilityAgentId.value;let n;if(e.agents?.ownership===`explicit`){let t=a(e.agents.defaults?.systemAgent?.agentId),r=t?x(t):void 0;n=r&&listAgentIds(e).includes(r)?r:void 0}else n=tryResolveLegacyDataOwnerAgentId(e);return t&&(t.compatibilityAgentId={value:n}),n}function tryResolveAmbientOwnerAgentId(e,t){let n=a(t)??a(e.agents?.defaults?.systemAgent?.agentId);return n?x(n):tryResolveLegacyCompatibilityAgentId(e)??tryResolveSoleAgentId(e)}function resolveDefaultAgentId(e,t){return tryResolveRawLegacyDefaultAgentId(e)??resolveSoleAgentId(e,t)}function resolveAgentEntry(e,t){let n=x(t),r=readAgentRosterFacts(e);if(r){let t=(r.entryByNormalizedId??=buildAgentEntryIndex(e)).get(n);return t?t.clone?{...t.entry}:t.entry:void 0}let i=readAgentRosterProperty(e);if(i?.kind===`entries`&&_(i.value)){let e=i.value;for(let t in e){if(!Object.hasOwn(e,t))continue;let r=e[t];if(_(r)&&x(t)===n)return{...r,id:t}}}else if(i?.kind===`list`&&Array.isArray(i.value))return i.value.find(e=>typeof e==`object`&&!!e&&x(e.id)===n)}function buildAgentEntryIndex(e){let t=/* @__PURE__ */ new Map;for(let{entry:n,source:r}of listAgentEntriesWithSource(e)){let e=x(n?.id);t.has(e)||t.set(e,{clone:r.kind===`entries`,entry:n})}return t}function resolveAgentConfig(e,t){let n=x(t),r=resolveAgentEntry(e,n)??(!hasAgentRosterProperty(e)&&n===`main`?{id:n}:void 0);if(!r)return;let i=e.agents?.defaults;return{name:r.name,workspace:r.workspace,workspaceFileMode:r.workspaceFileMode??i?.workspaceFileMode,agentDir:r.agentDir,model:r.model,...r.models?{models:r.models}:{},...r.params?{params:r.params}:{},...r.runtime?{runtime:r.runtime}:{},...hasExplicitModelPolicyAllow(r.modelPolicy)?{modelPolicy:r.modelPolicy}:{},utilityModel:r.utilityModel,decisionModel:r.decisionModel,thinkingDefault:r.thinkingDefault,verboseDefault:r.verboseDefault??i?.verboseDefault,toolProgressDetail:r.toolProgressDetail??i?.toolProgressDetail,reasoningDefault:r.reasoningDefault,fastModeDefault:r.fastModeDefault??i?.fastModeDefault,newSessionPermissionMode:r.newSessionPermissionMode,contextInjection:r.contextInjection,bootstrapMaxChars:r.bootstrapMaxChars,bootstrapTotalMaxChars:r.bootstrapTotalMaxChars,experimental:r.experimental?{...i?.experimental,...r.experimental}:i?.experimental,skills:r.skills,memory:r.memory,humanDelay:r.humanDelay,typingMode:r.typingMode??i?.typingMode,tts:r.tts,...r.compaction?{compaction:r.compaction}:{},contextLimits:r.contextLimits?{...i?.contextLimits,...r.contextLimits}:i?.contextLimits,heartbeat:r.heartbeat,identity:r.identity,groupChat:r.groupChat,subagents:r.subagents,embeddedAgent:r.embeddedAgent,sandbox:r.sandbox,tools:r.tools}}function resolveEffectiveAgentDir(e,t,n){let i=x(t),a=resolveAgentConfig(e,i)?.agentDir?.trim(),o=n?.env??process.env;return a?r(a,o,n?.homedir):E.join(l(o,n?.homedir),`agents`,i,`agent`)}function resolveAgentDir(e,t,n=process.env){let r=resolveEffectiveAgentDir(e,t,{env:n});return registerResolvedAgentDir({agentId:t,agentDir:r,env:n}),r}export{listGatewayOwnedAgentIds as C,formatCliCommand as D,isReservedSystemAgentId as E,listAgentIds as S,tryResolveSoleAgentId as T,resolveSessionStorePathCore as _,resolveDefaultAgentId as a,resolveUnsuffixedSqliteTargetFromSessionStorePath as b,tryResolveLegacyCompatibilityAgentId as c,observeOwnedDirectory as d,resolvePersistedSessionStoreOwner as f,resolveAgentsDirFromSessionStorePath as g,isPerAgentSessionStoreConfig as h,resolveConfiguredAgentId as i,tryResolveLegacyDataOwnerAgentId as l,resolvePersistedSessionStoreOwnerForTarget as m,resolveAgentDir as n,resolveEffectiveAgentDir as o,resolvePersistedSessionStoreOwnerForKey as p,resolveAgentEntry as r,tryResolveAmbientOwnerAgentId as s,AgentSelectionRequiredError as t,normalizeAgentDirRegistryPath as u,listSqliteTargetCandidatePathsForSessionStorePath as v,readAgentRosterProperty as w,listAgentEntries as x,parseSqliteTargetSuffixIndex as y};