openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
521 lines (520 loc) • 24.1 kB
JavaScript
import { _ as resolvePrimaryStringValue, l as normalizeOptionalString, o as normalizeLowercaseStringOrEmpty } from "./string-coerce-CCIiB4H7.mjs";
import { r as resolveGlobalMap } from "./global-singleton-D7yf05nR.mjs";
import { c as resolveUserPath } from "./home-dir-EKmgmdPG.mjs";
import { l as isRecord } from "./record-coerce-CVPuDqcc.mjs";
import { n as resolveIdentityPathViaExistingAncestorSync, t as resolveIdentityPathViaExistingAncestor } from "./boundary-path-C2gXEiXe.mjs";
import { r as resolveStateDir } from "./state-dir-DiG0gXzD.mjs";
import { r as isPathInside } from "./path-guards-TIjxtj6H.mjs";
import "./utils-C8YECn2Q.mjs";
import "./paths-DAcAg5aV.mjs";
import { t as formatCliCommand } from "./command-format-CqdwUgPk.mjs";
import { n as hasExplicitModelPolicyAllow } from "./model-policy-allowlist-migration-Dd1EwQdo.mjs";
import { n as normalizeAgentId, r as normalizeAgentIdStrict } from "./agent-id-CQjtp2ft.mjs";
import { j as parseAgentSessionKey, n as LEGACY_IMPLICIT_AGENT_ID, o as classifySessionKeyShape } from "./session-key-CqAyZeVk.mjs";
import { d as tryResolveLegacyDataOwner, f as tryResolveRawLegacyDefaultAgentId, i as listAgentIds, o as readAgentRosterFacts, p as tryResolveSoleAgentId, r as listAgentEntriesWithSource, s as readAgentRosterProperty, t as hasAgentRosterProperty } from "./agent-roster-t1ooUdXp.mjs";
import { i as tryResolvePathCaseInsensitive } from "./path-case-B6O0zibk.mjs";
import { l as resolveSessionStorePathCore } from "./paths-DvQ5AJvD.mjs";
import { t as observeOwnedDirectory } from "./owned-directory-observation-2VESyPSQ.mjs";
import { a as getOpenClawDatabaseMaintenanceScope } from "./openclaw-state-maintenance-context-D6i7Zdhn.mjs";
import { t as resolveDefaultAgentWorkspaceDir } from "./workspace-default-path-CWX4WiCH.mjs";
import "./workspace-default-DvctYF3A.mjs";
import fs from "node:fs";
import path from "node:path";
import { isMainThread } from "node:worker_threads";
import { resolvePathPrefixSync, sameFileIdentity } from "@openclaw/fs-safe/advanced";
//#region src/config/sessions/session-store-config.ts
function resolveMissingStorePathIdentity(e) {
try {
const t = resolvePathPrefixSync(path.resolve(e));
return path.resolve(t.existingPath, ...t.unresolvedSegments);
} catch {
return;
}
}
function isPerAgentSessionStoreConfig(e) {
return !e?.trim() || e.includes("{agentId}");
}
function isSameAuthoredSessionStoreConfig(e, t) {
return !e?.trim() && !t?.trim() || e === t;
}
function isSameSessionStoreConfig(e, t, n) {
if (isPerAgentSessionStoreConfig(e) || isPerAgentSessionStoreConfig(t)) return isSameAuthoredSessionStoreConfig(e, t);
return isSameFixedSessionStoreConfig(e, t, n);
}
function isSameFixedSessionStoreConfig(e, t, n) {
if (isPerAgentSessionStoreConfig(e) || isPerAgentSessionStoreConfig(t)) return false;
const r = path.resolve(resolveSessionStorePathCore(e, { env: n }));
const i = path.resolve(resolveSessionStorePathCore(t, { env: n }));
if (r === i) return true;
try {
return sameFileIdentity(fs.statSync(r, { bigint: true }), fs.statSync(i, { bigint: true }));
} catch (e) {
const t = e.code;
if (t !== "ENOENT" && t !== "ENOTDIR") return true;
}
const a = resolveMissingStorePathIdentity(r);
const o = resolveMissingStorePathIdentity(i);
if (!a || !o) return true;
if (a === o) return true;
if (a.toLowerCase() !== o.toLowerCase()) return false;
const s = tryResolvePathCaseInsensitive(a);
const c = tryResolvePathCaseInsensitive(o);
return s !== false && c !== false;
}
//#endregion
//#region src/config/sessions/session-store-owner.ts
/** Preserves a retired fixed-store owner as an explicit unavailable state. */
function resolvePersistedSessionStoreOwner(e) {
if (isPerAgentSessionStoreConfig(e.session?.store)) return { kind: "none" };
const t = e.agents?.defaults?.sessionStore?.agentId?.trim();
if (!t) return { kind: "none" };
const n = normalizeAgentId(t);
return listAgentIds(e).some((e) => normalizeAgentId(e) === n) ? {
kind: "configured",
agentId: n
} : {
kind: "retired",
agentId: n
};
}
/** Applies fixed-store ownership only to keys without an agent-qualified namespace. */
function resolvePersistedSessionStoreOwnerForKey(e, t) {
return classifySessionKeyShape(t) === "legacy_or_alias" ? resolvePersistedSessionStoreOwner(e) : { kind: "none" };
}
/** Applies fixed-store ownership only when the concrete write target is that configured store. */
function resolvePersistedSessionStoreOwnerForTarget(e) {
const t = resolvePersistedSessionStoreOwnerForKey(e.config, e.sessionKey);
if (t.kind === "none" || !e.storePath) return t;
return isSameFixedSessionStoreConfig(e.config.session?.store, e.storePath, e.env ?? process.env) ? t : { kind: "none" };
}
//#endregion
//#region src/agents/agent-dir-registry.ts
/** Process-local reverse registry from prepared agent directories to agent ids. */
const agentIdsByDir = /* @__PURE__ */ new Map();
const preparedPaths = resolveGlobalMap(Symbol.for("openclaw.agentDirPreparedPaths"), (e) => {
for (const t of e.values()) t.close();
e.clear();
}, "shared-state");
function forgetPreparedPaths(e) {
for (const [t, n] of preparedPaths) if (n.key === e) {
preparedPaths.delete(t);
n.close();
}
}
function registryPath(e, t, n = false, r) {
const i = path.resolve(resolveUserPath(e, t));
const a = getOpenClawDatabaseMaintenanceScope()?.ownsSchemaMaintenance === true;
const o = a ? void 0 : preparedPaths.get(i);
if (o) return o.key;
const s = r ?? normalizeAgentDirRegistryPath(i, t);
if (a || !isMainThread || !n && !agentIdsByDir.has(s)) return s;
const c = [];
const l = {
key: s,
close: () => c.forEach((e) => e.close())
};
preparedPaths.set(i, l);
let u = false;
for (let e = i; path.dirname(e) !== e; e = path.dirname(e)) {
const t = path.basename(e);
c.push(observeOwnedDirectory(path.dirname(e), (e) => {
if (!u && (e === void 0 || e === t)) {
u = true;
queueMicrotask(() => {
u = false;
});
if (resolveIdentityPathViaExistingAncestorSync(i) === s) return;
preparedPaths.delete(i);
l.close();
}
}));
}
const d = Math.max(256, agentIdsByDir.size + 1);
for (const [e, t] of preparedPaths) {
if (preparedPaths.size <= d) break;
preparedPaths.delete(e);
t.close();
}
return s;
}
function normalizeAgentDirRegistryPath(e, t = process.env) {
return resolveIdentityPathViaExistingAncestorSync(resolveUserPath(e, t));
}
/** Register a resolved agent directory for later reverse lookup. */
function registerResolvedAgentDir(e) {
const t = registryPath(e.agentDir, e.env, true);
const n = agentIdsByDir.get(t) ?? /* @__PURE__ */ new Set();
const r = normalizeAgentId(e.agentId);
if (n.has(r)) return false;
n.add(r);
agentIdsByDir.set(t, n);
return true;
}
/** Remove a reverse lookup only while it still belongs to the expected agent. */
function unregisterResolvedAgentDir(e) {
const t = normalizeAgentDirRegistryPath(e.agentDir, e.env);
const n = agentIdsByDir.get(t);
if (!n?.delete(normalizeAgentId(e.agentId))) return false;
if (n.size === 0) {
agentIdsByDir.delete(t);
forgetPreparedPaths(t);
}
return true;
}
/** Resolve the agent id previously registered for an agent directory. */
function resolveRegisteredAgentIdForDir(e, t) {
const n = agentIdsByDir.get(registryPath(e, t));
return n?.size === 1 ? n.values().next().value : void 0;
}
async function resolveRegisteredAgentIdForDirAsync(e, t) {
const n = path.resolve(resolveUserPath(e, t));
const r = (getOpenClawDatabaseMaintenanceScope()?.ownsSchemaMaintenance === true ? void 0 : preparedPaths.get(n))?.key ?? await resolveIdentityPathViaExistingAncestor(n);
const i = agentIdsByDir.get(registryPath(n, t, false, r));
return i?.size === 1 ? i.values().next().value : void 0;
}
/** Whether a path overlaps a directory currently owned by another agent. */
function isPathOwnedByAnotherRegisteredAgent(e) {
const t = normalizeAgentDirRegistryPath(e.pathname, e.env);
const n = normalizeAgentId(e.agentId);
for (const [e, r] of agentIdsByDir) if ([...r].some((e) => e !== n) && (e === t || isPathInside(e, t) || isPathInside(t, e))) return true;
return false;
}
//#endregion
//#region src/agents/agent-scope-config.ts
/** Resolves configured agent ids, directories, workspaces, and merged agent defaults. */
var AgentSelectionRequiredError = class extends Error {
constructor(e, t) {
const n = t?.surface ?? "this operation";
const 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;
}
};
/** ACP primaries select the harness; explicit fallback lists still configure native calls. */
function resolveAgentModelConfigForRuntime(e, t = "native") {
const n = e?.model;
if (t === "acp" || e?.runtime?.type !== "acp") return n;
return n && typeof n === "object" && n.fallbacks ? { fallbacks: n.fallbacks } : void 0;
}
/** Native overrides exclude ACP harness primaries without changing authored configuration. */
function resolveAgentNativeModelPrimary(e, t) {
return resolvePrimaryStringValue(resolveAgentModelConfigForRuntime(resolveAgentConfig(e, t)));
}
/** Native requests inherit the raw default, including its configured auth-profile suffix. */
function resolveNativeModelPrimary(e, t) {
return resolveAgentNativeModelPrimary(e, t) ?? resolvePrimaryStringValue(e.agents?.defaults?.model);
}
/** Strip null bytes from paths to prevent ENOTDIR errors. */
function stripNullBytes(e) {
return e.replaceAll("\0", "");
}
/** Converts either supported roster representation into the canonical keyed shape. */
function toAgentEntriesRecord(e) {
return Object.fromEntries(e.map((e) => {
const { id: t, ...n } = e;
return [t, n];
}));
}
/** Returns a configured agent id or throws the canonical CLI selection error. */
function resolveConfiguredAgentId(e, t) {
if (!listAgentIds(e).includes(t)) throw new Error(`Unknown agent id "${t}". Run ${formatCliCommand("openclaw agents list")} to see configured agents.`);
return t;
}
function resolveSoleAgentId(e, t) {
const n = tryResolveSoleAgentId(e);
if (n) return n;
const r = listAgentIds(e);
if (r.length === 0) throw new Error("No agents configured. Run `openclaw onboard` or `openclaw agents add` first.");
throw new AgentSelectionRequiredError(r, t);
}
/** Preserves legacy data locators independently of the configured runtime owner. */
function tryResolveLegacyDataOwnerAgentId(e) {
const t = readAgentRosterFacts(e);
if (t?.legacyDataOwnerAgentId) return t.legacyDataOwnerAgentId.value;
const n = tryResolveLegacyDataOwner(e);
if (t) t.legacyDataOwnerAgentId = { value: n };
return n;
}
/** Resolves the recorded default after migration, or a sole/raw legacy owner. */
function tryResolveLegacyCompatibilityAgentId(e) {
const t = readAgentRosterFacts(e);
if (t?.compatibilityAgentId) return t.compatibilityAgentId.value;
let n;
if (e.agents?.ownership === "explicit") {
const t = normalizeOptionalString(e.agents.defaults?.systemAgent?.agentId);
const r = t ? normalizeAgentId(t) : void 0;
n = r && listAgentIds(e).includes(r) ? r : void 0;
} else n = tryResolveLegacyDataOwnerAgentId(e);
if (t) t.compatibilityAgentId = { value: n };
return n;
}
/** Resolves the owner for ambient system work and explicit requests. */
function tryResolveAmbientOwnerAgentId(e, t) {
const n = normalizeOptionalString(t) ?? normalizeOptionalString(e.agents?.defaults?.systemAgent?.agentId);
return n ? normalizeAgentId(n) : tryResolveLegacyCompatibilityAgentId(e) ?? tryResolveSoleAgentId(e);
}
/** Ambient owner for surfaces that must fail loudly rather than act on the wrong agent. */
function resolveAmbientOwnerAgentId(e, t, n) {
return tryResolveAmbientOwnerAgentId(e, t) ?? resolveSoleAgentId(e, n);
}
/** Returns an operation owner while preserving legacy defaults outside explicit fleets. */
function tryResolveAgentOperationAgentId(e, t) {
if (t !== void 0) return tryResolveAmbientOwnerAgentId(e, t);
return tryResolveLegacyCompatibilityAgentId(e) ?? tryResolveSoleAgentId(e);
}
/** Resolves a CLI operation owner, requiring selection when no owner is configured. */
function resolveAgentOperationAgentId(e, t, n) {
return tryResolveAgentOperationAgentId(e, t) ?? resolveSoleAgentId(e, n);
}
/**
* @deprecated Ambient system work uses resolveAmbientOwnerAgentId so the configured
* system agent is honored; explicit-selection surfaces use resolveSoleAgentId. This
* accepts raw shipped markers only for input compatibility.
*/
function resolveDefaultAgentId(e, t) {
return tryResolveRawLegacyDefaultAgentId(e) ?? resolveSoleAgentId(e, t);
}
const SESSION_AGENT_SELECTION_CONTEXT = {
surface: "session agent resolution",
hint: "Pass an agentId, an agent-scoped session key, or a prepared fallbackAgentId."
};
function resolveSelectedSessionAgentId(e) {
if (classifySessionKeyShape(e.sessionKey) === "malformed_agent") throw new Error("Malformed agent session key; refusing default-agent resolution.");
const t = e.agentId === void 0 ? null : normalizeAgentIdStrict(e.agentId);
if (t && !t.ok) throw new Error("Invalid explicit agent id; refusing default-agent resolution.");
const n = t?.value;
const r = normalizeLowercaseStringOrEmpty(e.fallbackAgentId);
const i = r ? normalizeAgentId(r) : null;
const a = e.sessionKey?.trim();
const o = parseAgentSessionKey(a);
const s = o?.agentId ? normalizeAgentId(o.agentId) : null;
const c = e.config ?? {};
const l = resolvePersistedSessionStoreOwnerForKey(c, a);
if (s && n && n !== s) throw new AgentSelectionRequiredError(listAgentIds(c), {
surface: "session agent resolution",
hint: `The agent-scoped session key belongs to "${s}", not "${n}".`
});
const u = n ?? i;
if (!s && l.kind === "retired") throw new AgentSelectionRequiredError(listAgentIds(c), {
surface: "session agent resolution",
hint: `The shared fixed-store row belongs to retired agent "${l.agentId}".`
});
if (!s && l.kind === "configured" && u && u !== l.agentId) throw new AgentSelectionRequiredError(listAgentIds(c), {
surface: "session agent resolution",
hint: `The shared fixed-store row belongs to "${l.agentId}", not "${u}".`
});
return s ?? (l.kind === "configured" ? l.agentId : void 0) ?? u ?? void 0;
}
/** Strict session selection uses explicit context and legacy data ownership. */
function resolveSessionAgentIdsStrict(e) {
const t = resolveSelectedSessionAgentId(e);
const n = e.config ?? {};
const r = tryResolveLegacyDataOwnerAgentId(n);
const i = t ?? r ?? resolveDefaultAgentId(n, SESSION_AGENT_SELECTION_CONTEXT);
return {
defaultAgentId: r ?? i,
sessionAgentId: i
};
}
const resolveSessionAgentIds = resolveSessionAgentIdsStrict;
function resolveSessionAgentIdStrict(e) {
const t = resolveSelectedSessionAgentId(e);
const n = e.config ?? {};
return t ?? tryResolveLegacyDataOwnerAgentId(n) ?? resolveDefaultAgentId(n, SESSION_AGENT_SELECTION_CONTEXT);
}
const resolveSessionAgentId = resolveSessionAgentIdStrict;
function resolveAgentEntry(e, t) {
const n = normalizeAgentId(t);
const r = readAgentRosterFacts(e);
if (r) {
const t = (r.entryByNormalizedId ??= buildAgentEntryIndex(e)).get(n);
return t ? t.clone ? { ...t.entry } : t.entry : void 0;
}
const i = readAgentRosterProperty(e);
if (i?.kind === "entries" && isRecord(i.value)) {
const e = i.value;
for (const t in e) {
if (!Object.hasOwn(e, t)) continue;
const r = e[t];
if (isRecord(r) && normalizeAgentId(t) === n) return {
...r,
id: t
};
}
return;
}
if (i?.kind === "list" && Array.isArray(i.value)) return i.value.find((e) => e !== null && typeof e === "object" && normalizeAgentId(e.id) === n);
}
/**
* First-match index over the projected roster for batch point lookups.
*
* Keyed entries must stay clone-on-read (callers may mutate the returned
* entry); list entries keep the original object, matching the direct
* traversal semantics of `resolveAgentEntry` outside a batch.
*/
function buildAgentEntryIndex(e) {
const t = /* @__PURE__ */ new Map();
for (const { entry: n, source: r } of listAgentEntriesWithSource(e)) {
const e = normalizeAgentId(n?.id);
if (!t.has(e)) t.set(e, {
clone: r.kind === "entries",
entry: n
});
}
return t;
}
/** Resolves the authored entry object for in-place canonical config mutations. */
function resolveMutableAgentEntry(e, t) {
const n = normalizeAgentId(t);
const r = readAgentRosterProperty(e);
if (r?.kind === "entries" && r.value && typeof r.value === "object") {
const e = r.value;
const t = Object.keys(e).find((e) => normalizeAgentId(e) === n);
return t ? e[t] : void 0;
}
if (r?.kind === "list" && Array.isArray(r.value)) return r.value.find((e) => normalizeAgentId(e?.id) === n);
}
/** Resolves merged config for one agent id. */
function resolveAgentConfig(e, t) {
const n = normalizeAgentId(t);
const r = resolveAgentEntry(e, n) ?? (!hasAgentRosterProperty(e) && n === "main" ? { id: n } : void 0);
if (!r) return;
const i = e.agents?.defaults;
return {
name: r.name,
workspace: r.workspace,
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,
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
};
}
/** The agent's verbose default; agents without an entry inherit the global default. */
function resolveAgentVerboseDefault(e, t) {
return resolveAgentConfig(e, t)?.verboseDefault ?? e.agents?.defaults?.verboseDefault;
}
function resolveAgentContextLimits(e, t) {
const n = e?.agents?.defaults?.contextLimits;
if (!e || !t) return n;
return resolveAgentConfig(e, t)?.contextLimits ?? n;
}
function resolveAgentWorkspaceDir(e, t, n = process.env) {
const r = normalizeAgentId(t);
const i = resolveAgentConfig(e, r)?.workspace?.trim();
if (i) return stripNullBytes(resolveUserPath(i, n));
const a = tryResolveLegacyDataOwnerAgentId(e);
const o = e.agents?.defaults?.workspace?.trim();
if (a && r === a) {
if (o) return stripNullBytes(resolveUserPath(o, n));
return stripNullBytes(resolveDefaultAgentWorkspaceDir(n));
}
if (o) return stripNullBytes(path.join(resolveUserPath(o, n), r));
const s = resolveStateDir(n);
return stripNullBytes(path.join(s, `workspace-${r}`));
}
/** Resolves the configured task directory without changing the agent workspace. */
function resolveAgentRunCwd(e, t) {
const n = normalizeOptionalString(resolveAgentEntry(e, t)?.cwd) ?? normalizeOptionalString(e.agents?.defaults?.cwd);
return n ? stripNullBytes(resolveUserPath(n)) : void 0;
}
/**
* Resolves whether an agent's workspace is runtime-managed and implicit.
*
* A workspace is runtime-managed-implicit only when all of the following hold:
* - the agent runs the ACP runtime (non-embedded),
* - the agent entry does not configure an explicit `workspace`,
* - the provisioned directory is the config-resolved implicit workspace, and
* - this invocation has a distinct authoritative cwd: the invocation cwd when
* known (session ACP meta or the configured binding that owns the session
* key), otherwise the agent-global runtime `acp.cwd` default. A cwd equal to
* the resolved workspace is not distinct.
*
* Such agents must not get a scaffolded default workspace with bootstrap
* files and `git init` (#92015). Every other shape — explicit workspaces,
* ACP agents that fall back to their workspace as cwd, and embedded agents —
* keeps standard provisioning.
*/
function resolveAgentWorkspaceProvisioning(e, t, n) {
const r = normalizeAgentId(t);
const i = resolveAgentConfig(e, r);
if (i?.runtime?.type !== "acp") return "standard";
if (i.workspace?.trim()) return "standard";
const a = resolveAgentWorkspaceDir(e, r);
const o = n?.workspaceDir?.trim() ? resolveUserPath(n.workspaceDir) : a;
if (o !== a) return "standard";
const s = normalizeOptionalString(n?.cwd)?.trim() ?? i.runtime.acp?.cwd?.trim();
if (!s) return "standard";
if (path.resolve(resolveUserPath(s)) === path.resolve(o)) return "standard";
return "runtime-managed-implicit";
}
/**
* Cheap candidate check for turn-level provisioning resolution: true only for
* ACP agents without an explicit workspace, so heavier invocation-cwd lookups
* (configured binding resolution) stay off embedded/default agent turns.
*/
function isImplicitAcpWorkspaceCandidate(e, t) {
const n = resolveAgentConfig(e, normalizeAgentId(t));
return n?.runtime?.type === "acp" && !n.workspace?.trim();
}
function tryResolveConfiguredAgentWorkspaceDir(e, t = process.env) {
const n = tryResolveLegacyDataOwnerAgentId(e);
if (n) return resolveAgentWorkspaceDir(e, n, t);
const r = e.agents?.defaults?.workspace?.trim();
return r ? stripNullBytes(resolveUserPath(r, t)) : void 0;
}
function resolveEffectiveAgentDir(e, t, n) {
const r = normalizeAgentId(t);
const i = resolveAgentConfig(e, r)?.agentDir?.trim();
const a = n?.env ?? process.env;
return i ? resolveUserPath(i, a, n?.homedir) : path.join(resolveStateDir(a, n?.homedir), "agents", r, "agent");
}
function resolveAgentDir(e, t, n = process.env) {
const r = resolveEffectiveAgentDir(e, t, { env: n });
registerResolvedAgentDir({
agentId: t,
agentDir: r,
env: n
});
return r;
}
function resolveDefaultAgentDir(e, t = process.env) {
return resolveAgentDir(e, resolveAmbientOwnerAgentId(e), t);
}
//#endregion
export { tryResolveLegacyCompatibilityAgentId as A, resolvePersistedSessionStoreOwnerForTarget as B, resolveSessionAgentIds as C, tryResolveAgentOperationAgentId as D, toAgentEntriesRecord as E, resolveRegisteredAgentIdForDir as F, isSameAuthoredSessionStoreConfig as H, resolveRegisteredAgentIdForDirAsync as I, unregisterResolvedAgentDir as L, isPathOwnedByAnotherRegisteredAgent as M, normalizeAgentDirRegistryPath as N, tryResolveAmbientOwnerAgentId as O, registerResolvedAgentDir as P, resolvePersistedSessionStoreOwner as R, resolveSessionAgentIdStrict as S, resolveSoleAgentId as T, isSameSessionStoreConfig as U, isPerAgentSessionStoreConfig as V, resolveDefaultAgentId as _, resolveAgentDir as a, resolveNativeModelPrimary as b, resolveAgentNativeModelPrimary as c, resolveAgentVerboseDefault as d, resolveAgentWorkspaceDir as f, resolveDefaultAgentDir as g, resolveConfiguredAgentId as h, resolveAgentContextLimits as i, tryResolveLegacyDataOwnerAgentId as j, tryResolveConfiguredAgentWorkspaceDir as k, resolveAgentOperationAgentId as l, resolveAmbientOwnerAgentId as m, isImplicitAcpWorkspaceCandidate as n, resolveAgentEntry as o, resolveAgentWorkspaceProvisioning as p, resolveAgentConfig as r, resolveAgentModelConfigForRuntime as s, AgentSelectionRequiredError as t, resolveAgentRunCwd as u, resolveEffectiveAgentDir as v, resolveSessionAgentIdsStrict as w, resolveSessionAgentId as x, resolveMutableAgentEntry as y, resolvePersistedSessionStoreOwnerForKey as z };