Function: ensureAgentCwd()
Makaio Framework / services-core / ensureAgentCwd
Function: ensureAgentCwd()
Section titled “Function: ensureAgentCwd()”ensureAgentCwd(
bus,agent,desiredCwd,options?):Promise<{swapped:false; } | {previousCwd:string;swapped:true; }>
Defined in: ../../../packages/services/core/src/session/utils/agent-recovery.ts:36
Ensure agent cwd matches desired cwd, swapping connector if needed. Must be called while agent is idle (before message routing).
Parameters
Section titled “Parameters”Bus instance
Agent to validate/swap
adapterId
Section titled “adapterId”string = ...
Adapter instance that owns this agent
adapterName
Section titled “adapterName”string = ...
Adapter type name (e.g., ‘claude-code’, ‘copilot’)
adapterSessionId?
Section titled “adapterSessionId?”string = ...
Provider’s session ID for native resume support
agentId
Section titled “agentId”string = ...
Unique agent execution unit ID (stable across connector swaps and restarts)
clientId?
Section titled “clientId?”string = ...
Client identifier for the client application this agent runs under (e.g., ‘claude-code’, ‘codex’). Omit for API-only adapters.
compressionMode?
Section titled “compressionMode?”"manual" | "auto" | "off" = ...
Compression mode for session context management.
createdAt
Section titled “createdAt”number = ...
Timestamp when agent was created (= when added to session)
string = ...
Current working directory
harnessId?
Section titled “harnessId?”string = ...
Resolved harness ID for this agent.
lastActivityAt
Section titled “lastActivityAt”number = ...
Timestamp of last activity (message sent/received)
model?
Section titled “model?”string = ...
Current model identifier
personaId?
Section titled “personaId?”string = ...
Persona used to configure this agent (if any).
profileId?
Section titled “profileId?”string = ...
Profile used to configure this agent (if any).
providerConfigId?
Section titled “providerConfigId?”string = ...
Provider config UUID for credential/endpoint resolution
"lead" | "member" = AgentRoleSchema
Agent’s role in the session
sessionId
Section titled “sessionId”string = ...
Makaio session this agent belongs to
status
Section titled “status”"active" | "idle" | "dead" | "disposed" = AgentStatusSchema
Agent lifecycle status
desiredCwd
Section titled “desiredCwd”string
Target working directory
options?
Section titled “options?”Optional request flags (e.g., skip interactive warnings)
skipWarning?
Section titled “skipWarning?”boolean
Returns
Section titled “Returns”Promise<{ swapped: false; } | { previousCwd: string; swapped: true; }>
Swap result with previous cwd when a swap occurred