mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-25 15:01:15 +00:00
Adds an additive worktree flag to sessions.create so any new chat can run in an isolated managed worktree of the agent's git workspace, with the branch checked out and .worktreeinclude provisioning applied. The session's spawnedCwd points at the matching subdirectory inside the worktree so chat runs, CLI, and the file browser execute there. agents.list gains workspaceGit (workspace or an ancestor is a git checkout) to gate the affordance; web sidebar, iOS, and Android expose a New-Chat-in-worktree action. Uses the method's operator.write scope, but the .openclaw/worktree-setup.sh step runs only for operator.admin callers since it executes repo code. Deleting the session, or leaving via a plain New Chat, clears the cwd and lossless-removes the worktree; idle GC treats recent session activity as worktree activity so an active session's checkout is never swept. Live-verified end-to-end on a real gateway; follow-up to #100535 (issue #100534).
64 lines
1.5 KiB
TypeScript
64 lines
1.5 KiB
TypeScript
/** Agent identity fields returned by gateway session listing APIs. */
|
|
export type GatewayAgentIdentity = {
|
|
name?: string;
|
|
theme?: string;
|
|
emoji?: string;
|
|
avatar?: string;
|
|
avatarUrl?: string;
|
|
};
|
|
|
|
/** Model summary returned for an agent/session row. */
|
|
export type GatewayAgentModel = {
|
|
primary?: string;
|
|
fallbacks?: string[];
|
|
};
|
|
|
|
/** Runtime selection metadata for an agent row. */
|
|
export type GatewayAgentRuntime = {
|
|
id: string;
|
|
fallback?: "openclaw" | "none";
|
|
source: "env" | "agent" | "defaults" | "model" | "provider" | "implicit" | "session-key";
|
|
};
|
|
|
|
/** Thinking-level option exposed to UI clients. */
|
|
export type GatewayThinkingLevelOption = {
|
|
id: string;
|
|
label: string;
|
|
};
|
|
|
|
/** Common agent row shape used by session list responses. */
|
|
export type GatewayAgentRow = {
|
|
id: string;
|
|
name?: string;
|
|
identity?: GatewayAgentIdentity;
|
|
workspace?: string;
|
|
workspaceGit?: boolean;
|
|
model?: GatewayAgentModel;
|
|
agentRuntime?: GatewayAgentRuntime;
|
|
thinkingLevels?: GatewayThinkingLevelOption[];
|
|
thinkingOptions?: string[];
|
|
thinkingDefault?: string;
|
|
};
|
|
|
|
/** Generic base for paged session-list responses. */
|
|
export type SessionsListResultBase<TDefaults, TRow> = {
|
|
ts: number;
|
|
path: string;
|
|
count: number;
|
|
totalCount?: number;
|
|
limitApplied?: number;
|
|
offset?: number;
|
|
nextOffset?: number | null;
|
|
hasMore?: boolean;
|
|
defaults: TDefaults;
|
|
sessions: TRow[];
|
|
};
|
|
|
|
/** Generic base for successful session patch responses. */
|
|
export type SessionsPatchResultBase<TEntry> = {
|
|
ok: true;
|
|
path: string;
|
|
key: string;
|
|
entry: TEntry;
|
|
};
|