# Conflicts: # AGENTS.md # docs/config-catalog.md # docs/cordis-catalog/events.md # docs/cordis-catalog/services.md # docs/core-data-structures/core.md # docs/event-producer-consumer.md # docs/persistence-catalog.md # docs/rfc/implemented/architecture/2026-07-05-reconstructable-requests.md # docs/rfc/implemented/feature/2026-06-15-code-mode.md # docs/rfc/implemented/feature/2026-06-30-hook-bridges.md # docs/rfc/implemented/feature/2026-06-30-interception-seams.md # docs/rfc/implemented/feature/2026-07-08-repeat-tool-guard.md # docs/rfc/proposed/simplification/2026-07-04-prune-dead-core-spine-surface.md # examples/AGENTS.md # examples/acp-agent/cordis.yml # examples/acp-agent/tests/acp.snapshot.ts # examples/echo-agent/cordis.yml # examples/sandbox-acp-agent/cordis.yml # packages/cordis/tool-cordis/src/api-catalog.ts # packages/core/agent-core/README.md # packages/core/agent-core/src/index.ts # packages/core/agent-loop/README.md # packages/core/agent-loop/src/loop.ts # packages/core/agent-loop/tests/interception.spec.ts # packages/core/agent/src/types.ts # packages/core/tools/README.md # packages/core/tools/src/code-mode.ts # packages/core/tools/src/index.ts # packages/fs/fs-local/src/index.ts # packages/fs/fs/README.md # packages/fs/fs/src/index.ts # packages/guard/repeat-tool-guard/README.md # packages/guard/repeat-tool-guard/src/index.ts # packages/hooks/hooks-claude/src/index.ts # packages/hooks/hooks-codex/src/index.ts # packages/ui/acp-agent/src/index.ts
34 lines
1.4 KiB
TypeScript
34 lines
1.4 KiB
TypeScript
/**
|
|
* Derive the working directory a filesystem tool resolves relative paths against: the calling
|
|
* agent's per-session workspace (`exec.agent.session.header.cwd`), so each ACP session's
|
|
* `read`/`write`/`edit` act on ITS workspace, not the server's launch dir — mirroring how
|
|
* `dsh-tool-bash` defaults a bash `workdir` to the session cwd.
|
|
* Non-agent calls return `undefined`, leaving the fallback in the provider rather than reading
|
|
* `process.cwd()` at the tool seam.
|
|
* @module @deepseek-ai/dsh-tool-fs/session-cwd
|
|
*/
|
|
|
|
import type { ToolExecution } from '@deepseek-ai/dsh-tools'
|
|
|
|
/**
|
|
* The session workspace cwd for this call, or `undefined` when none applies.
|
|
* @param exec - the tool-execution context; only its optional `agent` is read.
|
|
* @returns the calling agent's session cwd, or undefined for a non-agent caller (the backend then applies its own default).
|
|
*/
|
|
export function sessionCwd(exec: ToolExecution): string | undefined {
|
|
return exec.agent?.session.header.cwd
|
|
}
|
|
|
|
/**
|
|
* Resolution options shared by all model-facing filesystem tools.
|
|
* @param exec - the tool-execution context supplying session cwd and cancellation.
|
|
* @returns provider resolution options for the current tool call.
|
|
*/
|
|
export function sessionResolveOptions(exec: ToolExecution): { cwd?: string; signal?: AbortSignal } {
|
|
const cwd = sessionCwd(exec)
|
|
return {
|
|
...cwd !== undefined ? { cwd } : {},
|
|
...exec.signal !== undefined ? { signal: exec.signal } : {},
|
|
}
|
|
}
|