dexto 1.6.18 → 1.6.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,8 +23,8 @@ export type HonoInitializationResult = {
23
23
  ensureAgentAvailable: () => void;
24
24
  getActiveAgentId: () => string | undefined;
25
25
  };
26
- export declare function initializeHonoApi(agent: DextoAgent, agentCardOverride?: Partial<AgentCard>, listenPort?: number, agentId?: string, configFilePath?: string, webRoot?: string, webUIConfig?: WebUIRuntimeConfig): Promise<HonoInitializationResult>;
27
- export declare function startHonoApiServer(agent: DextoAgent, port?: number, agentCardOverride?: Partial<AgentCard>, agentId?: string, configFilePath?: string, webRoot?: string, webUIConfig?: WebUIRuntimeConfig): Promise<{
26
+ export declare function initializeHonoApi(agent: DextoAgent, agentCardOverride?: Partial<AgentCard>, listenPort?: number, agentId?: string, configFilePath?: string, workspaceRoot?: string, webRoot?: string, webUIConfig?: WebUIRuntimeConfig): Promise<HonoInitializationResult>;
27
+ export declare function startHonoApiServer(agent: DextoAgent, port?: number, agentCardOverride?: Partial<AgentCard>, agentId?: string, configFilePath?: string, workspaceRoot?: string, webRoot?: string, webUIConfig?: WebUIRuntimeConfig): Promise<{
28
28
  server: ReturnType<typeof createNodeServer>['server'];
29
29
  webhookSubscriber?: NonNullable<ReturnType<typeof createNodeServer>['webhookSubscriber']>;
30
30
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"server-hono.d.ts","sourceRoot":"","sources":["../../src/api/server-hono.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAuC,MAAM,aAAa,CAAC;AAY9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAC/E,OAAO,EACH,cAAc,EACd,gBAAgB,EAShB,KAAK,kBAAkB,EAC1B,MAAM,eAAe,CAAC;AA+FvB,MAAM,MAAM,wBAAwB,GAAG;IACnC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,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/E,gBAAgB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7E,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC,gBAAgB,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;CAC9C,CAAC;AAGF,wBAAsB,iBAAiB,CACnC,KAAK,EAAE,UAAU,EACjB,iBAAiB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,EACtC,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,MAAM,EAChB,cAAc,CAAC,EAAE,MAAM,EACvB,aAAa,CAAC,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,kBAAkB,GACjC,OAAO,CAAC,wBAAwB,CAAC,CA4XnC;AAED,wBAAsB,kBAAkB,CACpC,KAAK,EAAE,UAAU,EACjB,IAAI,SAAO,EACX,iBAAiB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,EACtC,OAAO,CAAC,EAAE,MAAM,EAChB,cAAc,CAAC,EAAE,MAAM,EACvB,aAAa,CAAC,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,kBAAkB,GACjC,OAAO,CAAC;IACP,MAAM,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,QAAQ,CAAC,CAAC;IACtD,iBAAiB,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC;CAC7F,CAAC,CAkCD"}
@@ -5,6 +5,7 @@ import { applyUserPreferences } from '../config/cli-overrides.js';
5
5
  import { createFileSessionLoggerFactory } from '../utils/session-logger-factory.js';
6
6
  import { createDextoApp, createNodeServer, createMcpTransport as createServerMcpTransport, createMcpHttpHandlers, initializeMcpServer as initializeServerMcpServer, createManualApprovalHandler, WebhookEventSubscriber, A2ASseEventSubscriber, ApprovalCoordinator, } from '@dexto/server';
7
7
  import { registerGracefulShutdown } from '../utils/graceful-shutdown.js';
8
+ import { applyWorkspaceToAgent } from '../utils/workspace.js';
8
9
  const DEFAULT_AGENT_VERSION = '1.0.0';
9
10
  const sessionLoggerFactory = createFileSessionLoggerFactory();
10
11
  /**
@@ -25,7 +26,7 @@ async function listAgents() {
25
26
  * Applies user preferences (preferences.yml) to ALL agents, not just the default.
26
27
  * See feature-plans/auto-update.md section 8.11 - Three-Layer LLM Resolution.
27
28
  */
28
- async function createAgentFromId(agentId) {
29
+ async function createAgentFromId(agentId, workspaceRoot) {
29
30
  try {
30
31
  // Use registry to resolve agent path (auto-installs if not present)
31
32
  const registry = getAgentRegistry();
@@ -53,7 +54,10 @@ async function createAgentFromId(agentId) {
53
54
  return await createDextoAgentFromConfig({
54
55
  config,
55
56
  configPath: agentPath,
56
- enrichOptions: { logLevel: 'info' },
57
+ enrichOptions: {
58
+ logLevel: 'info',
59
+ ...(workspaceRoot ? { workspaceRoot } : {}),
60
+ },
57
61
  overrides: { sessionLoggerFactory },
58
62
  });
59
63
  }
@@ -72,7 +76,7 @@ function resolveBaseUrl(port) {
72
76
  return process.env.DEXTO_BASE_URL ?? `http://localhost:${port}`;
73
77
  }
74
78
  //TODO (migration): consider moving this to the server package
75
- export async function initializeHonoApi(agent, agentCardOverride, listenPort, agentId, configFilePath, webRoot, webUIConfig) {
79
+ export async function initializeHonoApi(agent, agentCardOverride, listenPort, agentId, configFilePath, workspaceRoot, webRoot, webUIConfig) {
76
80
  // Declare before registering shutdown hook to avoid TDZ on signals
77
81
  let activeAgent = agent;
78
82
  let activeAgentId = agentId || 'coding-agent';
@@ -160,6 +164,9 @@ export async function initializeHonoApi(agent, agentCardOverride, listenPort, ag
160
164
  await wireServicesToAgent(newAgent);
161
165
  logger.info(`Starting new agent: ${agentId}`);
162
166
  await newAgent.start();
167
+ if (workspaceRoot) {
168
+ await applyWorkspaceToAgent(newAgent, workspaceRoot);
169
+ }
163
170
  // Update agent card for A2A and MCP routes
164
171
  agentCardData = createAgentCard({
165
172
  defaultName: agentId,
@@ -195,7 +202,7 @@ export async function initializeHonoApi(agent, agentCardOverride, listenPort, ag
195
202
  // 2. Create new agent from registry (will initialize fresh telemetry in createAgentServices)
196
203
  const registry = getAgentRegistry();
197
204
  newAgentConfigPath = await registry.resolveAgent(agentId, true);
198
- newAgent = await createAgentFromId(agentId);
205
+ newAgent = await createAgentFromId(agentId, workspaceRoot);
199
206
  // 3. Use common switch logic (register subscribers, start agent, stop previous)
200
207
  return await performAgentSwitch(newAgent, agentId, newAgentConfigPath, bridge);
201
208
  }
@@ -247,7 +254,10 @@ export async function initializeHonoApi(agent, agentCardOverride, listenPort, ag
247
254
  newAgent = await createDextoAgentFromConfig({
248
255
  config,
249
256
  configPath: filePath,
250
- enrichOptions: { logLevel: 'info' },
257
+ enrichOptions: {
258
+ logLevel: 'info',
259
+ ...(workspaceRoot ? { workspaceRoot } : {}),
260
+ },
251
261
  overrides: { sessionLoggerFactory },
252
262
  });
253
263
  // 4. Use enriched agentId (derived from config or filename during enrichment)
@@ -351,6 +361,9 @@ export async function initializeHonoApi(agent, agentCardOverride, listenPort, ag
351
361
  // Start the initial agent now that approval handler is set and subscribers are wired
352
362
  logger.info('Starting initial agent...');
353
363
  await activeAgent.start();
364
+ if (workspaceRoot) {
365
+ await applyWorkspaceToAgent(activeAgent, workspaceRoot);
366
+ }
354
367
  // Initialize MCP server after agent has started
355
368
  if (mcpTransport) {
356
369
  try {
@@ -376,8 +389,8 @@ export async function initializeHonoApi(agent, agentCardOverride, listenPort, ag
376
389
  getActiveAgentId: () => activeAgentId,
377
390
  };
378
391
  }
379
- export async function startHonoApiServer(agent, port = 3000, agentCardOverride, agentId, configFilePath, webRoot, webUIConfig) {
380
- const { server, webhookSubscriber } = await initializeHonoApi(agent, agentCardOverride, port, agentId, configFilePath, webRoot, webUIConfig);
392
+ export async function startHonoApiServer(agent, port = 3000, agentCardOverride, agentId, configFilePath, workspaceRoot, webRoot, webUIConfig) {
393
+ const { server, webhookSubscriber } = await initializeHonoApi(agent, agentCardOverride, port, agentId, configFilePath, workspaceRoot, webRoot, webUIConfig);
381
394
  server.listen(port, '0.0.0.0', () => {
382
395
  const networkInterfaces = os.networkInterfaces();
383
396
  let localIp = 'localhost';
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/cli/modes/cli.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAsBpD,wBAAsB,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAwKxE"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/cli/modes/cli.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAuBpD,wBAAsB,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAgLxE"}
@@ -1,6 +1,7 @@
1
1
  import chalk from 'chalk';
2
2
  import { logger } from '@dexto/core';
3
3
  import { safeExit, ExitSignal } from '../../analytics/wrapper.js';
4
+ import { applyWorkspaceToAgent } from '../../utils/workspace.js';
4
5
  async function getMostRecentSessionId(agent) {
5
6
  const sessionIds = await agent.listSessions();
6
7
  if (sessionIds.length === 0) {
@@ -18,7 +19,7 @@ async function getMostRecentSessionId(agent) {
18
19
  return mostRecentId;
19
20
  }
20
21
  export async function runCliMode(context) {
21
- const { agent, opts, validatedConfig, resolvedPath, initialPrompt, getVersionCheckResult } = context;
22
+ const { agent, opts, workspaceRoot, validatedConfig, resolvedPath, initialPrompt, getVersionCheckResult, } = context;
22
23
  const needsHandler = validatedConfig.permissions.mode === 'manual' || validatedConfig.elicitation.enabled;
23
24
  if (needsHandler) {
24
25
  const { createCLIApprovalHandler } = await import('../approval/index.js');
@@ -26,8 +27,9 @@ export async function runCliMode(context) {
26
27
  agent.setApprovalHandler(handler);
27
28
  logger.debug('CLI approval handler configured for Ink CLI');
28
29
  }
29
- await agent.start();
30
30
  try {
31
+ await agent.start();
32
+ await applyWorkspaceToAgent(agent, workspaceRoot);
31
33
  const llmConfig = agent.getCurrentLLMConfig();
32
34
  const { requiresApiKey } = await import('@dexto/core');
33
35
  if (requiresApiKey(llmConfig.provider) && !llmConfig.apiKey?.trim()) {
@@ -11,6 +11,7 @@ export interface MainModeOptions {
11
11
  export interface MainModeContext {
12
12
  agent: DextoAgent;
13
13
  opts: MainModeOptions;
14
+ workspaceRoot: string;
14
15
  validatedConfig: ValidatedAgentConfig;
15
16
  resolvedPath: string;
16
17
  derivedAgentId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/cli/modes/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,eAAe;IAC5B,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,EAAE,eAAe,CAAC;IACtB,eAAe,EAAE,oBAAoB,CAAC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,qBAAqB,EAAE,MAAM,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;CAC3D"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/cli/modes/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,eAAe;IAC5B,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,EAAE,eAAe,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,oBAAoB,CAAC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,qBAAqB,EAAE,MAAM,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;CAC3D"}
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/cli/modes/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,wBAAsB,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA0C3E"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/cli/modes/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,wBAAsB,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAkD3E"}
@@ -1,6 +1,6 @@
1
1
  import { getPort } from '../../utils/port-utils.js';
2
2
  export async function runServerMode(context) {
3
- const { agent, opts, derivedAgentId, resolvedPath, getVersionCheckResult } = context;
3
+ const { agent, opts, workspaceRoot, derivedAgentId, resolvedPath, getVersionCheckResult } = context;
4
4
  const { startHonoApiServer } = await import('../../api/server-hono.js');
5
5
  const agentCard = agent.config.agentCard ?? {};
6
6
  const defaultPort = (() => {
@@ -20,7 +20,7 @@ export async function runServerMode(context) {
20
20
  const apiPort = getPort(process.env.PORT, defaultPort, 'PORT');
21
21
  const apiUrl = process.env.DEXTO_URL ?? `http://localhost:${apiPort}`;
22
22
  console.log('🌐 Starting server (REST APIs + SSE)...');
23
- await startHonoApiServer(agent, apiPort, agentCard, derivedAgentId, resolvedPath);
23
+ await startHonoApiServer(agent, apiPort, agentCard, derivedAgentId, resolvedPath, workspaceRoot);
24
24
  console.log(`✅ Server running at ${apiUrl}`);
25
25
  console.log('Available endpoints:');
26
26
  console.log(' POST /api/message - Send async message');
@@ -1 +1 @@
1
- {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../../src/cli/modes/web.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,wBAAsB,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAmExE"}
1
+ {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../../src/cli/modes/web.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,wBAAsB,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAqExE"}
@@ -1,7 +1,7 @@
1
1
  import chalk from 'chalk';
2
2
  import { getPort } from '../../utils/port-utils.js';
3
3
  export async function runWebMode(context) {
4
- const { agent, opts, derivedAgentId, resolvedPath, getVersionCheckResult } = context;
4
+ const { agent, opts, workspaceRoot, derivedAgentId, resolvedPath, getVersionCheckResult } = context;
5
5
  const [{ resolveWebRoot }, { startHonoApiServer }, { getWebUIAnalyticsConfig }] = await Promise.all([
6
6
  import('../../web.js'),
7
7
  import('../../api/server-hono.js'),
@@ -30,7 +30,7 @@ export async function runWebMode(context) {
30
30
  console.info('For development: Run "pnpm dev" for hot reload');
31
31
  }
32
32
  const webUIConfig = webRoot ? { analytics: await getWebUIAnalyticsConfig() } : undefined;
33
- await startHonoApiServer(agent, port, agent.config.agentCard || {}, derivedAgentId, resolvedPath, webRoot, webUIConfig);
33
+ await startHonoApiServer(agent, port, agent.config.agentCard || {}, derivedAgentId, resolvedPath, workspaceRoot, webRoot, webUIConfig);
34
34
  console.log(chalk.green(`✅ Server running at ${serverUrl}`));
35
35
  const webUpdateInfo = await getVersionCheckResult();
36
36
  if (webUpdateInfo) {
@@ -356,6 +356,7 @@ async function bootstrapAgentFromGlobalOpts(options) {
356
356
  services,
357
357
  }));
358
358
  await agent.start();
359
+ await (await import('./utils/workspace.js')).applyWorkspaceToAgent(agent, workspaceRoot);
359
360
  // Register graceful shutdown
360
361
  const shutdown = async () => {
361
362
  try {
@@ -417,6 +418,7 @@ program
417
418
  logger.debug('WARNING: .env file not found; copy .env.example and set your API keys.');
418
419
  }
419
420
  const opts = program.opts();
421
+ const workspaceRoot = findDextoProjectRoot(process.cwd()) ?? process.cwd();
420
422
  // Set dev mode early to use local repo agents instead of ~/.dexto
421
423
  if (opts.dev) {
422
424
  process.env.DEXTO_DEV_MODE = 'true';
@@ -722,7 +724,6 @@ program
722
724
  // Enrichment adds filesystem paths to storage (schema has in-memory defaults)
723
725
  // Interactive CLI mode: only log to file (console would interfere with chat UI)
724
726
  const isInteractiveCli = opts.mode === 'cli';
725
- const workspaceRoot = findDextoProjectRoot(process.cwd()) ?? process.cwd();
726
727
  const enrichedConfig = enrichAgentConfig(configWithImageDefaults, resolvedPath, {
727
728
  isInteractiveCli,
728
729
  logLevel: 'info', // CLI uses info-level logging for visibility
@@ -826,6 +827,7 @@ program
826
827
  // - other modes: start immediately (no approval support)
827
828
  if (opts.mode !== 'web' && opts.mode !== 'server' && opts.mode !== 'cli') {
828
829
  await agent.start();
830
+ await (await import('./utils/workspace.js')).applyWorkspaceToAgent(agent, workspaceRoot);
829
831
  }
830
832
  // Derive a concise agent ID for display purposes (used by API/UI)
831
833
  // Prefer agentCard.name, otherwise extract from filename
@@ -851,6 +853,7 @@ program
851
853
  await dispatchMainMode({
852
854
  agent,
853
855
  opts: mainModeOpts,
856
+ workspaceRoot,
854
857
  validatedConfig,
855
858
  resolvedPath,
856
859
  derivedAgentId,
@@ -0,0 +1,9 @@
1
+ import type { DextoAgent } from '@dexto/core';
2
+ type WorkspaceAwareAgent = Pick<DextoAgent, 'getWorkspace' | 'setWorkspace'>;
3
+ /**
4
+ * Keep the runtime workspace in sync with the host-resolved project root so
5
+ * prompt contributors and downstream services don't fall back to process.cwd().
6
+ */
7
+ export declare function applyWorkspaceToAgent(agent: WorkspaceAwareAgent, workspaceRoot: string): Promise<void>;
8
+ export {};
9
+ //# sourceMappingURL=workspace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/utils/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,KAAK,mBAAmB,GAAG,IAAI,CAAC,UAAU,EAAE,cAAc,GAAG,cAAc,CAAC,CAAC;AAE7E;;;GAGG;AACH,wBAAsB,qBAAqB,CACvC,KAAK,EAAE,mBAAmB,EAC1B,aAAa,EAAE,MAAM,GACtB,OAAO,CAAC,IAAI,CAAC,CAcf"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Keep the runtime workspace in sync with the host-resolved project root so
3
+ * prompt contributors and downstream services don't fall back to process.cwd().
4
+ */
5
+ export async function applyWorkspaceToAgent(agent, workspaceRoot) {
6
+ const normalizedWorkspaceRoot = workspaceRoot.trim();
7
+ if (!normalizedWorkspaceRoot) {
8
+ return;
9
+ }
10
+ const currentWorkspace = await agent.getWorkspace();
11
+ if (currentWorkspace?.path === normalizedWorkspaceRoot) {
12
+ return;
13
+ }
14
+ await agent.setWorkspace({
15
+ path: normalizedWorkspaceRoot,
16
+ });
17
+ }