@borgee/agents-host 0.2.74 → 0.2.94

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.
Files changed (82) hide show
  1. package/README.md +11 -24
  2. package/dist/agents-host.d.ts +6 -4
  3. package/dist/agents-host.js +127 -16
  4. package/dist/background-runs.d.ts +24 -0
  5. package/dist/background-runs.js +184 -0
  6. package/dist/chat/chat-control-plane.d.ts +7 -1
  7. package/dist/chat/sdk-chat-control-plane.d.ts +7 -2
  8. package/dist/chat/sdk-chat-control-plane.js +22 -0
  9. package/dist/context/claude-file-brief.js +3 -3
  10. package/dist/context/injection.d.ts +18 -12
  11. package/dist/context/injection.js +53 -53
  12. package/dist/context/prompt.js +10 -10
  13. package/dist/context/resolved-working-folder.d.ts +3 -0
  14. package/dist/context/resolved-working-folder.js +106 -0
  15. package/dist/context/turn-preparation.js +1 -1
  16. package/dist/managed-daemon.js +30 -30
  17. package/dist/plugin-sdk.js +315 -29
  18. package/dist/plugin-sdk.js.map +3 -3
  19. package/dist/policy/authorization-audit.d.ts +1 -1
  20. package/dist/policy/copilot-permission.d.ts +9 -0
  21. package/dist/policy/copilot-permission.js +120 -1
  22. package/dist/progress-to-activity.d.ts +1 -1
  23. package/dist/progress-to-activity.js +1 -0
  24. package/dist/providers/claude/adapter.d.ts +2 -1
  25. package/dist/providers/claude/adapter.js +36 -1
  26. package/dist/providers/claude/background-run-observer.d.ts +32 -0
  27. package/dist/providers/claude/background-run-observer.js +381 -0
  28. package/dist/providers/claude/cli-client.d.ts +12 -0
  29. package/dist/providers/claude/cli-client.js +453 -72
  30. package/dist/providers/claude/foreground-handoff.d.ts +4 -0
  31. package/dist/providers/claude/foreground-handoff.js +45 -0
  32. package/dist/providers/claude/task-cancellation-protocol.d.ts +14 -0
  33. package/dist/providers/claude/task-cancellation-protocol.js +21 -0
  34. package/dist/providers/codex/adapter.d.ts +1 -1
  35. package/dist/providers/codex/adapter.js +7 -0
  36. package/dist/providers/codex/cli-client.js +8 -7
  37. package/dist/providers/codex/project-doc.js +6 -6
  38. package/dist/providers/copilot/activity-metadata.d.ts +3 -0
  39. package/dist/providers/copilot/activity-metadata.js +19 -0
  40. package/dist/providers/copilot/adapter.d.ts +6 -2
  41. package/dist/providers/copilot/adapter.js +27 -1
  42. package/dist/providers/copilot/cli-client.d.ts +37 -10
  43. package/dist/providers/copilot/cli-client.js +756 -122
  44. package/dist/providers/copilot/sdk-session.d.ts +149 -0
  45. package/dist/providers/copilot/sdk-session.js +981 -0
  46. package/dist/providers/create-provider.js +33 -0
  47. package/dist/providers/provider-adapter.d.ts +24 -1
  48. package/dist/providers/provider-adapter.js +17 -0
  49. package/dist/types.d.ts +40 -11
  50. package/dist/vendor/claude-agent-acp/LICENSE +191 -0
  51. package/dist/vendor/claude-agent-acp/NOTICE +8 -0
  52. package/dist/vendor/claude-agent-acp/dist/acp-agent.d.ts +1017 -0
  53. package/dist/vendor/claude-agent-acp/dist/acp-agent.d.ts.map +1 -0
  54. package/dist/vendor/claude-agent-acp/dist/acp-agent.js +6305 -0
  55. package/dist/vendor/claude-agent-acp/dist/borgee-foreground-handoff-bridge.js +322 -0
  56. package/dist/vendor/claude-agent-acp/dist/borgee-task-cancellation-bridge.js +101 -0
  57. package/dist/vendor/claude-agent-acp/dist/borgee-task-lifecycle-bridge.js +58 -0
  58. package/dist/vendor/claude-agent-acp/dist/elicitation.d.ts +130 -0
  59. package/dist/vendor/claude-agent-acp/dist/elicitation.d.ts.map +1 -0
  60. package/dist/vendor/claude-agent-acp/dist/elicitation.js +304 -0
  61. package/dist/vendor/claude-agent-acp/dist/index.d.ts +3 -0
  62. package/dist/vendor/claude-agent-acp/dist/index.d.ts.map +1 -0
  63. package/dist/vendor/claude-agent-acp/dist/index.js +75 -0
  64. package/dist/vendor/claude-agent-acp/dist/lib.d.ts +6 -0
  65. package/dist/vendor/claude-agent-acp/dist/lib.d.ts.map +1 -0
  66. package/dist/vendor/claude-agent-acp/dist/lib.js +5 -0
  67. package/dist/vendor/claude-agent-acp/dist/settings.d.ts +68 -0
  68. package/dist/vendor/claude-agent-acp/dist/settings.d.ts.map +1 -0
  69. package/dist/vendor/claude-agent-acp/dist/settings.js +185 -0
  70. package/dist/vendor/claude-agent-acp/dist/tools.d.ts +102 -0
  71. package/dist/vendor/claude-agent-acp/dist/tools.d.ts.map +1 -0
  72. package/dist/vendor/claude-agent-acp/dist/tools.js +1000 -0
  73. package/dist/vendor/claude-agent-acp/dist/utils.d.ts +16 -0
  74. package/dist/vendor/claude-agent-acp/dist/utils.d.ts.map +1 -0
  75. package/dist/vendor/claude-agent-acp/dist/utils.js +81 -0
  76. package/dist/vendor/claude-agent-acp/package.json +85 -0
  77. package/package.json +15 -10
  78. package/skills/borgee-agent/references/task-properties.md +3 -3
  79. package/skills/borgee-agent/scripts/borgee-agent.mjs +1 -1
  80. package/skills/borgee-agent/scripts/borgee-agent.py +1 -1
  81. package/dist/context/resolved-workspace.d.ts +0 -3
  82. package/dist/context/resolved-workspace.js +0 -106
@@ -12,12 +12,12 @@ const TASK_ASSIGNMENT_STATE_FILENAME = 'context.json';
12
12
  const CHANNEL_GATEWAY_CREDENTIAL_FILENAME = '.borgee-agent-gateway.json';
13
13
  const CLAUDE_PROJECTED_BRIEF_FILENAME = 'CLAUDE.md';
14
14
  const DEFAULT_HOME_BORGEE_DIRNAME = '.borgee';
15
- const CHANNEL_WORKSPACE_COLLECTION_DIRNAME = 'channels';
16
- const CHANNEL_WORKSPACE_DIRNAME = 'workspace';
17
- const TASK_ISOLATED_WORKSPACE_COLLECTION_DIRNAME = 'tasks';
18
- const TASK_THREAD_SCRATCH_WORKSPACE_DIRNAME = 'scratch';
15
+ const CHANNEL_WORKING_FOLDER_COLLECTION_DIRNAME = 'channels';
16
+ const CHANNEL_WORKING_FOLDER_DIRNAME = 'workspace';
17
+ const TASK_ISOLATED_WORKING_FOLDER_COLLECTION_DIRNAME = 'tasks';
18
+ const TASK_THREAD_SCRATCH_WORKING_FOLDER_DIRNAME = 'scratch';
19
19
  const TASK_EXECUTION_LOCAL_DIRECTORY_PROPERTY_KEY = 'execution.local_directory';
20
- const DEFAULT_TASK_WORKSPACE_RESOLUTION_TIMEOUT_MS = 1_500;
20
+ const DEFAULT_TASK_WORKING_FOLDER_RESOLUTION_TIMEOUT_MS = 1_500;
21
21
  export class ChannelContextPreparationError extends Error {
22
22
  partialContext;
23
23
  constructor(message, partialContext, options) {
@@ -113,7 +113,7 @@ function buildPromptContextForClaudeProjectedBrief(preparedContext) {
113
113
  skillRuntime: preparedContext.skillRuntime,
114
114
  localhostGateway: preparedContext.localhostGateway,
115
115
  taskAssignmentContext: preparedContext.payload.taskAssignmentContext,
116
- resolvedWorkspace: preparedContext.resolvedWorkspace,
116
+ resolvedWorkingFolder: preparedContext.resolvedWorkingFolder,
117
117
  runtimeSurface: preparedContext.payload.runtimeSurface,
118
118
  collaborationOutcome: preparedContext.payload.collaborationOutcome,
119
119
  attentionSnapshot: preparedContext.payload.attentionSnapshot,
@@ -246,17 +246,17 @@ async function readExistingTaskAssignmentContext(statePath, fileSystem) {
246
246
  return undefined;
247
247
  }
248
248
  }
249
- function buildChannelResolvedWorkspace(workspaceCollectionRootDir, channelId) {
249
+ function buildChannelResolvedWorkingFolder(workingFolderCollectionRootDir, channelId) {
250
250
  return {
251
251
  authority: 'channel',
252
252
  owningChannelId: channelId,
253
- rootPath: resolveChannelWorkspaceDirectory(workspaceCollectionRootDir, channelId),
253
+ rootPath: resolveChannelWorkingFolderDirectory(workingFolderCollectionRootDir, channelId),
254
254
  };
255
255
  }
256
- function buildTaskThreadScratchResolvedWorkspace(workspaceCollectionRootDir, channelId, reason = 'missing-or-invalid-execution-target') {
256
+ function buildTaskThreadScratchResolvedWorkingFolder(workingFolderCollectionRootDir, channelId, reason = 'missing-or-invalid-execution-target') {
257
257
  return {
258
258
  authority: 'task-thread-scratch',
259
- rootPath: resolveTaskThreadScratchWorkspaceDirectory(workspaceCollectionRootDir, channelId),
259
+ rootPath: resolveTaskThreadScratchWorkingFolderDirectory(workingFolderCollectionRootDir, channelId),
260
260
  reason,
261
261
  };
262
262
  }
@@ -312,23 +312,23 @@ async function isExistingDirectory(fileSystem, path) {
312
312
  return false;
313
313
  }
314
314
  }
315
- async function resolveTaskThreadWorkspaceContext(params) {
316
- const channelWorkspace = buildChannelResolvedWorkspace(params.workspaceCollectionRootDir, params.channelId);
317
- const discussionOnlyWorkspace = buildTaskThreadScratchResolvedWorkspace(params.workspaceCollectionRootDir, params.channelId);
315
+ async function resolveTaskThreadWorkingFolderContext(params) {
316
+ const channelWorkingFolder = buildChannelResolvedWorkingFolder(params.workingFolderCollectionRootDir, params.channelId);
317
+ const discussionOnlyWorkingFolder = buildTaskThreadScratchResolvedWorkingFolder(params.workingFolderCollectionRootDir, params.channelId);
318
318
  const taskAssignmentContext = params.taskAssignmentContext;
319
319
  const currentTaskId = taskAssignmentContext?.currentTaskId?.trim();
320
320
  if (taskAssignmentContext?.active !== true) {
321
- return { taskAssignmentContext, resolvedWorkspace: channelWorkspace };
321
+ return { taskAssignmentContext, resolvedWorkingFolder: channelWorkingFolder };
322
322
  }
323
323
  if (!currentTaskId || !params.taskReader) {
324
- return { taskAssignmentContext, resolvedWorkspace: discussionOnlyWorkspace };
324
+ return { taskAssignmentContext, resolvedWorkingFolder: discussionOnlyWorkingFolder };
325
325
  }
326
326
  try {
327
- const task = await withDeadline(findTaskForThread(params.taskReader, params.channelId, currentTaskId), params.taskResolutionTimeoutMs, `workspace resolution timed out for task ${currentTaskId}`);
327
+ const task = await withDeadline(findTaskForThread(params.taskReader, params.channelId, currentTaskId), params.taskResolutionTimeoutMs, `working folder resolution timed out for task ${currentTaskId}`);
328
328
  if (!task) {
329
329
  return {
330
330
  taskAssignmentContext,
331
- resolvedWorkspace: discussionOnlyWorkspace,
331
+ resolvedWorkingFolder: discussionOnlyWorkingFolder,
332
332
  };
333
333
  }
334
334
  const executionLocalDirectory = task.properties[TASK_EXECUTION_LOCAL_DIRECTORY_PROPERTY_KEY];
@@ -337,7 +337,7 @@ async function resolveTaskThreadWorkspaceContext(params) {
337
337
  || !(await isExistingDirectory(params.fileSystem, executionLocalDirectory))) {
338
338
  return {
339
339
  taskAssignmentContext,
340
- resolvedWorkspace: discussionOnlyWorkspace,
340
+ resolvedWorkingFolder: discussionOnlyWorkingFolder,
341
341
  };
342
342
  }
343
343
  if (!params.allowCrossAgentIndependentWorkspaceHandoff
@@ -348,12 +348,12 @@ async function resolveTaskThreadWorkspaceContext(params) {
348
348
  })) {
349
349
  return {
350
350
  taskAssignmentContext,
351
- resolvedWorkspace: buildTaskThreadScratchResolvedWorkspace(params.workspaceCollectionRootDir, params.channelId, 'cross-agent-independent-workspace-disabled'),
351
+ resolvedWorkingFolder: buildTaskThreadScratchResolvedWorkingFolder(params.workingFolderCollectionRootDir, params.channelId, 'cross-agent-independent-workspace-disabled'),
352
352
  };
353
353
  }
354
354
  return {
355
355
  taskAssignmentContext,
356
- resolvedWorkspace: {
356
+ resolvedWorkingFolder: {
357
357
  authority: 'task-execution-target',
358
358
  taskId: task.id,
359
359
  rootPath: executionLocalDirectory,
@@ -363,7 +363,7 @@ async function resolveTaskThreadWorkspaceContext(params) {
363
363
  catch (error) {
364
364
  return {
365
365
  taskAssignmentContext,
366
- resolvedWorkspace: discussionOnlyWorkspace,
366
+ resolvedWorkingFolder: discussionOnlyWorkingFolder,
367
367
  };
368
368
  }
369
369
  }
@@ -383,32 +383,32 @@ export function resolveTaskAssignmentStateDirectory(stateRootDir, channelId) {
383
383
  export function resolveTaskAssignmentStatePath(stateRootDir, channelId) {
384
384
  return join(resolveTaskAssignmentStateDirectory(stateRootDir, channelId), TASK_ASSIGNMENT_STATE_FILENAME);
385
385
  }
386
- export function resolveTaskWorkspaceRootDirectory(startupWorkspaceRootDir) {
387
- return join(resolve(startupWorkspaceRootDir), TASK_ISOLATED_WORKSPACE_COLLECTION_DIRNAME);
386
+ export function resolveTaskWorkingFolderRootDirectory(channelRootDir) {
387
+ return join(resolve(channelRootDir), TASK_ISOLATED_WORKING_FOLDER_COLLECTION_DIRNAME);
388
388
  }
389
- export function resolveManagedWorkspaceCollectionRoot(workspaceCollectionRootDir, env = process.env, resolvedHomeDir = homedir()) {
390
- const explicitRoot = workspaceCollectionRootDir?.trim();
389
+ export function resolveManagedWorkingFolderCollectionRoot(workingFolderCollectionRootDir, env = process.env, resolvedHomeDir = homedir()) {
390
+ const explicitRoot = workingFolderCollectionRootDir?.trim();
391
391
  if (explicitRoot) {
392
392
  return resolve(explicitRoot);
393
393
  }
394
394
  const home = env.HOME?.trim() || resolvedHomeDir.trim();
395
395
  if (!home) {
396
- throw new Error('Unable to resolve a user home directory for agents-host workspaces');
396
+ throw new Error('Unable to resolve a user home directory for agents-host working folders');
397
397
  }
398
- return join(resolve(home), DEFAULT_HOME_BORGEE_DIRNAME, CHANNEL_WORKSPACE_COLLECTION_DIRNAME);
398
+ return join(resolve(home), DEFAULT_HOME_BORGEE_DIRNAME, CHANNEL_WORKING_FOLDER_COLLECTION_DIRNAME);
399
399
  }
400
- export function resolveChannelWorkspaceRootDirectory(workspaceCollectionRootDir, channelId) {
401
- return join(resolve(workspaceCollectionRootDir), encodeChannelPathSegment(channelId));
400
+ export function resolveChannelWorkingFolderRootDirectory(workingFolderCollectionRootDir, channelId) {
401
+ return join(resolve(workingFolderCollectionRootDir), encodeChannelPathSegment(channelId));
402
402
  }
403
- export function resolveChannelWorkspaceDirectory(workspaceCollectionRootDir, channelId) {
404
- return join(resolveChannelWorkspaceRootDirectory(workspaceCollectionRootDir, channelId), CHANNEL_WORKSPACE_DIRNAME);
403
+ export function resolveChannelWorkingFolderDirectory(workingFolderCollectionRootDir, channelId) {
404
+ return join(resolveChannelWorkingFolderRootDirectory(workingFolderCollectionRootDir, channelId), CHANNEL_WORKING_FOLDER_DIRNAME);
405
405
  }
406
- export function resolveTaskIsolatedWorkspaceDirectory(workspaceCollectionRootDir, channelId, taskId) {
407
- return join(resolveTaskWorkspaceRootDirectory(resolveChannelWorkspaceRootDirectory(workspaceCollectionRootDir, channelId)), encodeChannelPathSegment(taskId), CHANNEL_WORKSPACE_DIRNAME);
406
+ export function resolveTaskIsolatedWorkingFolderDirectory(workingFolderCollectionRootDir, channelId, taskId) {
407
+ return join(resolveTaskWorkingFolderRootDirectory(resolveChannelWorkingFolderRootDirectory(workingFolderCollectionRootDir, channelId)), encodeChannelPathSegment(taskId), CHANNEL_WORKING_FOLDER_DIRNAME);
408
408
  }
409
- export const resolveTaskWorkspaceDirectory = resolveTaskIsolatedWorkspaceDirectory;
410
- export function resolveTaskThreadScratchWorkspaceDirectory(workspaceCollectionRootDir, channelId) {
411
- return join(resolveChannelWorkspaceRootDirectory(workspaceCollectionRootDir, channelId), TASK_THREAD_SCRATCH_WORKSPACE_DIRNAME, CHANNEL_WORKSPACE_DIRNAME);
409
+ export const resolveTaskWorkingFolderDirectory = resolveTaskIsolatedWorkingFolderDirectory;
410
+ export function resolveTaskThreadScratchWorkingFolderDirectory(workingFolderCollectionRootDir, channelId) {
411
+ return join(resolveChannelWorkingFolderRootDirectory(workingFolderCollectionRootDir, channelId), TASK_THREAD_SCRATCH_WORKING_FOLDER_DIRNAME, CHANNEL_WORKING_FOLDER_DIRNAME);
412
412
  }
413
413
  export function resolveChannelGatewayCredentialPath(stateRootDir, channelId) {
414
414
  return join(resolveChannelContextDirectory(stateRootDir, channelId), CHANNEL_GATEWAY_CREDENTIAL_FILENAME);
@@ -509,7 +509,7 @@ export class FileChannelContextStore {
509
509
  skillRuntimeEnabled;
510
510
  skillAssetResolver;
511
511
  localhostGateway;
512
- workspaceCollectionRootDir;
512
+ workingFolderCollectionRootDir;
513
513
  taskReader;
514
514
  taskResolutionTimeoutMs;
515
515
  allowCrossAgentIndependentWorkspaceHandoff;
@@ -520,9 +520,9 @@ export class FileChannelContextStore {
520
520
  this.skillRuntimeEnabled = options.skillRuntimeEnabled ?? false;
521
521
  this.skillAssetResolver = options.skillAssetResolver ?? new PackageSkillAssetResolver(import.meta.url, this.fileSystem);
522
522
  this.localhostGateway = options.localhostGateway;
523
- this.workspaceCollectionRootDir = resolveManagedWorkspaceCollectionRoot(options.workspaceCollectionRootDir, options.env, options.resolvedHomeDir);
523
+ this.workingFolderCollectionRootDir = resolveManagedWorkingFolderCollectionRoot(options.workingFolderCollectionRootDir, options.env, options.resolvedHomeDir);
524
524
  this.taskReader = options.taskReader;
525
- this.taskResolutionTimeoutMs = options.taskResolutionTimeoutMs ?? DEFAULT_TASK_WORKSPACE_RESOLUTION_TIMEOUT_MS;
525
+ this.taskResolutionTimeoutMs = options.taskResolutionTimeoutMs ?? DEFAULT_TASK_WORKING_FOLDER_RESOLUTION_TIMEOUT_MS;
526
526
  this.allowCrossAgentIndependentWorkspaceHandoff
527
527
  = options.allowCrossAgentIndependentWorkspaceHandoff ?? true;
528
528
  this.resolveStableAgentId = options.resolveStableAgentId;
@@ -571,9 +571,9 @@ export class FileChannelContextStore {
571
571
  incomingMessageType: input.incomingMessageType,
572
572
  incomingContent: input.incomingContent,
573
573
  }, existingTaskAssignmentContext);
574
- const workspaceResolution = await resolveTaskThreadWorkspaceContext({
574
+ const workingFolderResolution = await resolveTaskThreadWorkingFolderContext({
575
575
  channelId: input.channelId,
576
- workspaceCollectionRootDir: this.workspaceCollectionRootDir,
576
+ workingFolderCollectionRootDir: this.workingFolderCollectionRootDir,
577
577
  taskAssignmentContext,
578
578
  taskReader: this.taskReader,
579
579
  taskResolutionTimeoutMs: this.taskResolutionTimeoutMs,
@@ -581,8 +581,8 @@ export class FileChannelContextStore {
581
581
  resolveStableAgentId: this.resolveStableAgentId,
582
582
  fileSystem: this.fileSystem,
583
583
  });
584
- const resolvedWorkspace = workspaceResolution.resolvedWorkspace;
585
- const runtimeTaskAssignmentContext = workspaceResolution.taskAssignmentContext ?? taskAssignmentContext;
584
+ const resolvedWorkingFolder = workingFolderResolution.resolvedWorkingFolder;
585
+ const runtimeTaskAssignmentContext = workingFolderResolution.taskAssignmentContext ?? taskAssignmentContext;
586
586
  const persistedTaskAssignmentContext = input.taskAssignmentContextOverridePersistence === 'ephemeral'
587
587
  ? existingTaskAssignmentContext
588
588
  : runtimeTaskAssignmentContext;
@@ -591,12 +591,12 @@ export class FileChannelContextStore {
591
591
  collaboration: input.collaboration,
592
592
  taskAssignmentContext: runtimeTaskAssignmentContext,
593
593
  });
594
- const payload = buildChannelContextPayload(input.channelId, runtimeSurface, input.collaborationOutcome, input.attentionSnapshot, input.compactionSnapshot, input.taskThreadCollaborationContract, input.collaborationCapabilities, input.missedCollaborationDiagnostic, skillRuntime, localhostGateway, persistedTaskAssignmentContext || resolvedWorkspace
594
+ const payload = buildChannelContextPayload(input.channelId, runtimeSurface, input.collaborationOutcome, input.attentionSnapshot, input.compactionSnapshot, input.taskThreadCollaborationContract, input.collaborationCapabilities, input.missedCollaborationDiagnostic, skillRuntime, localhostGateway, persistedTaskAssignmentContext || resolvedWorkingFolder
595
595
  ? {
596
596
  ...(persistedTaskAssignmentContext
597
597
  ? { taskAssignmentContext: persistedTaskAssignmentContext }
598
598
  : {}),
599
- resolvedWorkspace,
599
+ resolvedWorkspace: resolvedWorkingFolder,
600
600
  }
601
601
  : undefined);
602
602
  const gatewayCredential = buildBorgeeAgentGatewayCredential(input.channelId, issuedLocalhostGateway);
@@ -610,7 +610,7 @@ export class FileChannelContextStore {
610
610
  gatewayCredentialPath: gatewayCredential ? gatewayCredentialPath : undefined,
611
611
  skillRuntime,
612
612
  localhostGateway,
613
- resolvedWorkspace,
613
+ resolvedWorkingFolder,
614
614
  };
615
615
  const shouldProjectClaudeBrief = input.provider === 'claude' && input.projectionStrategy === 'file-brief';
616
616
  const claudeProjectedBriefContent = shouldProjectClaudeBrief
@@ -626,8 +626,8 @@ export class FileChannelContextStore {
626
626
  try {
627
627
  await this.fileSystem.mkdir(directoryPath, { recursive: true, mode: 0o700 });
628
628
  await this.fileSystem.mkdir(resolveTaskAssignmentStateDirectory(this.stateRootDir, input.channelId), { recursive: true, mode: 0o700 });
629
- if (resolvedWorkspace.authority !== 'task-execution-target') {
630
- await this.fileSystem.mkdir(resolvedWorkspace.rootPath, { recursive: true, mode: 0o700 });
629
+ if (resolvedWorkingFolder.authority !== 'task-execution-target') {
630
+ await this.fileSystem.mkdir(resolvedWorkingFolder.rootPath, { recursive: true, mode: 0o700 });
631
631
  }
632
632
  await pruneGatewayCredentialSidecars(this.fileSystem, directoryPath, gatewayCredential ? CHANNEL_GATEWAY_CREDENTIAL_FILENAME : undefined);
633
633
  if (!claudeProjectedBriefContent) {
@@ -675,9 +675,9 @@ export class FileChannelContextStore {
675
675
  directoryPath,
676
676
  payload: {
677
677
  ...payload,
678
- ...(resolvedWorkspace.authority === 'task-execution-target' && runtimeTaskAssignmentContext?.active === true
678
+ ...(resolvedWorkingFolder.authority === 'task-execution-target' && runtimeTaskAssignmentContext?.active === true
679
679
  ? {
680
- resolvedWorkspace: buildTaskThreadScratchResolvedWorkspace(this.workspaceCollectionRootDir, input.channelId),
680
+ resolvedWorkspace: buildTaskThreadScratchResolvedWorkingFolder(this.workingFolderCollectionRootDir, input.channelId),
681
681
  }
682
682
  : {}),
683
683
  },
@@ -687,9 +687,9 @@ export class FileChannelContextStore {
687
687
  gatewayCredentialPath: gatewayCredentialWritten ? gatewayCredentialPath : undefined,
688
688
  skillRuntime: payloadWritten ? skillRuntime : undefined,
689
689
  localhostGateway: payloadWritten ? localhostGateway : undefined,
690
- resolvedWorkspace: resolvedWorkspace.authority === 'task-execution-target' && runtimeTaskAssignmentContext?.active === true
691
- ? buildTaskThreadScratchResolvedWorkspace(this.workspaceCollectionRootDir, input.channelId)
692
- : resolvedWorkspace,
690
+ resolvedWorkingFolder: resolvedWorkingFolder.authority === 'task-execution-target' && runtimeTaskAssignmentContext?.active === true
691
+ ? buildTaskThreadScratchResolvedWorkingFolder(this.workingFolderCollectionRootDir, input.channelId)
692
+ : resolvedWorkingFolder,
693
693
  };
694
694
  throw new ChannelContextPreparationError('failed to persist channel context payload', partialContext, { cause: error });
695
695
  }
@@ -4,7 +4,7 @@ import { buildAttentionSummaryLines } from './attention.js';
4
4
  import { buildCollaborationCapabilityDeclarationSummaryLines, buildMissedCollaborationDiagnosticSummaryLines, } from './collaboration-capabilities-diagnostics.js';
5
5
  import { buildCollaborationOutcomeSummaryLines } from './collaboration-outcome.js';
6
6
  import { MAIN_SESSION_DELEGATION_LINES } from './main-session-delegation.js';
7
- import { buildResolvedWorkspaceGuidanceLines } from './resolved-workspace.js';
7
+ import { buildResolvedWorkingFolderGuidanceLines } from './resolved-working-folder.js';
8
8
  import { buildSkillManualLines, buildSkillManualReadLine } from './skill-manual.js';
9
9
  import { PARENT_CHANNEL_TASK_BOUNDARY_LINES } from './task-channel-boundary.js';
10
10
  import { buildTaskThreadCollaborationSummaryLines } from './task-thread-collaboration.js';
@@ -101,8 +101,8 @@ function buildTaskAssignmentPromptLines(params) {
101
101
  'This thread is continuing an existing task assignment.',
102
102
  'Keep the main work in this thread.',
103
103
  ];
104
- if ((params.provider !== 'claude' || params.forceInlineForClaude === true) && params.promptContext?.resolvedWorkspace) {
105
- lines.push(...buildResolvedWorkspacePromptLines(params.provider, params.promptContext));
104
+ if ((params.provider !== 'claude' || params.forceInlineForClaude === true) && params.promptContext?.resolvedWorkingFolder) {
105
+ lines.push(...buildResolvedWorkingFolderPromptLines(params.provider, params.promptContext));
106
106
  }
107
107
  if ((params.provider !== 'claude' || params.forceInlineForClaude === true) && taskAssignmentContext?.currentTaskId) {
108
108
  lines.push(`Current assigned task id: ${taskAssignmentContext.currentTaskId}.`);
@@ -115,8 +115,8 @@ function buildTaskAssignmentPromptLines(params) {
115
115
  }
116
116
  return lines;
117
117
  }
118
- function buildResolvedWorkspacePromptLines(provider, context) {
119
- return buildResolvedWorkspaceGuidanceLines(context, provider);
118
+ function buildResolvedWorkingFolderPromptLines(provider, context) {
119
+ return buildResolvedWorkingFolderGuidanceLines(context, provider);
120
120
  }
121
121
  function buildClaudeOrdinaryGatewayTaskLines(context) {
122
122
  if (!context?.skillRuntime || !context.localhostGateway || !context.gatewayCredentialPath) {
@@ -250,18 +250,18 @@ function buildClaudeProjectedBriefTurnPrompt(params) {
250
250
  params.incomingContent,
251
251
  ].join('\n');
252
252
  }
253
- function buildOrdinaryCopilotWorkspacePromptLines(params) {
253
+ function buildOrdinaryCopilotWorkingFolderPromptLines(params) {
254
254
  if (params.provider !== 'copilot') {
255
255
  return [];
256
256
  }
257
- if (!params.promptContext?.resolvedWorkspace) {
257
+ if (!params.promptContext?.resolvedWorkingFolder) {
258
258
  return [];
259
259
  }
260
260
  if (params.incomingMessageType?.trim() === 'task_assignment'
261
261
  || params.promptContext.taskAssignmentContext?.active === true) {
262
262
  return [];
263
263
  }
264
- return buildResolvedWorkspacePromptLines(params.provider, params.promptContext);
264
+ return buildResolvedWorkingFolderPromptLines(params.provider, params.promptContext);
265
265
  }
266
266
  function buildInboundMetadataLines(params) {
267
267
  return [
@@ -272,7 +272,7 @@ function buildInboundMetadataLines(params) {
272
272
  return lines.length > 0 ? ['', ...lines] : [];
273
273
  })(),
274
274
  ...(() => {
275
- const lines = buildOrdinaryCopilotWorkspacePromptLines(params);
275
+ const lines = buildOrdinaryCopilotWorkingFolderPromptLines(params);
276
276
  return lines.length > 0 ? ['', ...lines] : [];
277
277
  })(),
278
278
  ...buildTaskAssignmentPromptLines({
@@ -601,7 +601,7 @@ function buildClaudeSessionEnvironmentLines(context) {
601
601
  if (context.localhostGateway && context.gatewayCredentialPath) {
602
602
  lines.push(`Gateway credential file for this session: ${context.gatewayCredentialPath}`);
603
603
  }
604
- lines.push(...buildResolvedWorkspaceGuidanceLines(context));
604
+ lines.push(...buildResolvedWorkingFolderGuidanceLines(context));
605
605
  if (context.taskAssignmentContext?.currentTaskId) {
606
606
  lines.push(`Current assigned task id: ${context.taskAssignmentContext.currentTaskId}.`);
607
607
  }
@@ -0,0 +1,3 @@
1
+ import type { PreparedPromptContext, ProviderKind } from '../types.js';
2
+ export declare function buildResolvedWorkingFolderGuidanceLines(context: PreparedPromptContext | undefined, provider?: ProviderKind): string[];
3
+ export declare function isDiscussionOnlyResolvedWorkingFolder(context: PreparedPromptContext | undefined): boolean;
@@ -0,0 +1,106 @@
1
+ function buildWorkingFolderRootLine(context) {
2
+ const resolvedWorkingFolder = context.resolvedWorkingFolder;
3
+ if (!resolvedWorkingFolder) {
4
+ return undefined;
5
+ }
6
+ if (resolvedWorkingFolder.authority === 'task-execution-target') {
7
+ return `Explicit execution local directory for this task thread: ${resolvedWorkingFolder.rootPath}.`;
8
+ }
9
+ if (resolvedWorkingFolder.authority === 'task-thread-scratch') {
10
+ return `Discussion-only scratch working folder for this task thread: ${resolvedWorkingFolder.rootPath}.`;
11
+ }
12
+ if (context.taskAssignmentContext?.active === true) {
13
+ return `Writable working folder inherited from this task thread's channel: ${resolvedWorkingFolder.rootPath}.`;
14
+ }
15
+ return `Writable working folder for this channel: ${resolvedWorkingFolder.rootPath}.`;
16
+ }
17
+ function buildWorkingFolderModeLine(context) {
18
+ if (context.taskAssignmentContext?.active !== true || !context.resolvedWorkingFolder) {
19
+ return undefined;
20
+ }
21
+ if (context.resolvedWorkingFolder.authority === 'task-execution-target') {
22
+ return 'This task thread has a valid explicit execution.local_directory target, so execution is bound to that exact existing local directory.';
23
+ }
24
+ if (context.resolvedWorkingFolder.authority === 'task-thread-scratch') {
25
+ return context.resolvedWorkingFolder.reason === 'cross-agent-independent-workspace-disabled'
26
+ ? 'This task thread has an explicit execution.local_directory target, but this agents-host currently disables cross-agent independent-working-folder handoff, so it is discussion-only.'
27
+ : 'This task thread has no valid explicit execution.local_directory target, so it is discussion-only.';
28
+ }
29
+ return 'This task thread inherits the channel working folder rather than using a task-isolated working folder.';
30
+ }
31
+ function buildWorkingFolderLocalityLine(context) {
32
+ if (!context.resolvedWorkingFolder) {
33
+ return undefined;
34
+ }
35
+ if (context.resolvedWorkingFolder.authority === 'task-execution-target') {
36
+ return 'This is a human-selected existing local directory. The host validates it before use and never creates it.';
37
+ }
38
+ if (context.resolvedWorkingFolder.authority === 'task-thread-scratch') {
39
+ return 'This scratch working folder is host-managed only for discussion turns. It is not a bound project directory and does not imply that any target repository is checked out there.';
40
+ }
41
+ if (context.taskAssignmentContext?.active === true) {
42
+ return 'This writable working folder is local to agents-host for this task thread because the task inherits its channel working folder. It does not imply that the target repository has already been checked out there.';
43
+ }
44
+ return 'This writable working folder is local to agents-host for this channel. It does not imply that the target repository has already been checked out there.';
45
+ }
46
+ function buildCopilotCwdLine(context) {
47
+ if (!context.resolvedWorkingFolder) {
48
+ return undefined;
49
+ }
50
+ if (context.resolvedWorkingFolder.authority === 'task-execution-target') {
51
+ return 'GitHub Copilot runs this turn with that exact local directory as its real cwd.';
52
+ }
53
+ if (context.resolvedWorkingFolder.authority === 'task-thread-scratch') {
54
+ return 'GitHub Copilot runs this turn with that host-managed scratch working folder as its real cwd.';
55
+ }
56
+ if (context.taskAssignmentContext?.active === true) {
57
+ return 'GitHub Copilot runs this turn with that inherited channel working folder as its real cwd.';
58
+ }
59
+ return 'GitHub Copilot runs this turn with that working folder as its real cwd.';
60
+ }
61
+ function buildDiscussionOnlyPermissionLine(context) {
62
+ if (context.resolvedWorkingFolder?.authority !== 'task-thread-scratch') {
63
+ return undefined;
64
+ }
65
+ return context.resolvedWorkingFolder.reason === 'cross-agent-independent-workspace-disabled'
66
+ ? 'Filesystem and shell tool permissions stay denied in this discussion-only task thread while this agents-host keeps cross-agent independent-working-folder handoff disabled.'
67
+ : 'Filesystem and shell tool permissions stay denied in this discussion-only task thread until a human sets a valid execution.local_directory target.';
68
+ }
69
+ function buildProjectEntryPrecheckLine(context) {
70
+ if (context.taskAssignmentContext?.active !== true) {
71
+ return undefined;
72
+ }
73
+ if (context.resolvedWorkingFolder?.authority === 'task-execution-target') {
74
+ return 'Precheck before switching this task thread into your own local project directory: the task\'s parent channel must have exactly one human user. Cross-agent independent-working-folder handoff is also governed by this agents-host\'s local policy switch.';
75
+ }
76
+ return 'Before a human switches this task thread into their own local project directory, verify that the task\'s parent channel has exactly one human user; otherwise keep the thread discussion-only. Cross-agent independent-working-folder handoff is also governed by this agents-host\'s local policy switch.';
77
+ }
78
+ export function buildResolvedWorkingFolderGuidanceLines(context, provider) {
79
+ if (!context?.resolvedWorkingFolder) {
80
+ return [];
81
+ }
82
+ const lines = [buildWorkingFolderRootLine(context), buildWorkingFolderModeLine(context)]
83
+ .filter((line) => line != null);
84
+ if (provider === 'copilot') {
85
+ const copilotCwdLine = buildCopilotCwdLine(context);
86
+ if (copilotCwdLine) {
87
+ lines.push(copilotCwdLine);
88
+ }
89
+ }
90
+ const localityLine = buildWorkingFolderLocalityLine(context);
91
+ if (localityLine) {
92
+ lines.push(localityLine);
93
+ }
94
+ const permissionLine = buildDiscussionOnlyPermissionLine(context);
95
+ if (permissionLine) {
96
+ lines.push(permissionLine);
97
+ }
98
+ const precheckLine = buildProjectEntryPrecheckLine(context);
99
+ if (precheckLine) {
100
+ lines.push(precheckLine);
101
+ }
102
+ return lines;
103
+ }
104
+ export function isDiscussionOnlyResolvedWorkingFolder(context) {
105
+ return context?.resolvedWorkingFolder?.authority === 'task-thread-scratch';
106
+ }
@@ -38,7 +38,7 @@ function toPromptContext(channelContext, input) {
38
38
  skillRuntime: channelContext.skillRuntime,
39
39
  localhostGateway: channelContext.localhostGateway,
40
40
  taskAssignmentContext: channelContext.payload.taskAssignmentContext,
41
- resolvedWorkspace: channelContext.resolvedWorkspace,
41
+ resolvedWorkingFolder: channelContext.resolvedWorkingFolder,
42
42
  }
43
43
  : {}),
44
44
  runtimeSurface,
@@ -6,7 +6,7 @@ import { dirname, isAbsolute, join, resolve } from 'node:path';
6
6
  import { fileURLToPath } from 'node:url';
7
7
  import { AgentsHostSupervisor } from './agents-host-supervisor.js';
8
8
  import { DEFAULT_PROJECTION_STRATEGY, normalizeProjectionStrategy, } from './projection-strategy-values.js';
9
- import { resolveChannelWorkspaceDirectory, resolveChannelWorkspaceRootDirectory, resolveManagedWorkspaceCollectionRoot, resolveTaskThreadScratchWorkspaceDirectory, } from './context/injection.js';
9
+ import { resolveChannelWorkingFolderDirectory, resolveChannelWorkingFolderRootDirectory, resolveManagedWorkingFolderCollectionRoot, resolveTaskThreadScratchWorkingFolderDirectory, } from './context/injection.js';
10
10
  import { CLAUDE_PROVIDER_V2_COMPATIBILITY_GATE, COMPATIBILITY_GATES_ENV, CURRENT_AGENTS_HOST_PACKAGE_VERSION, createManagedRuntimeSettingsFingerprint, INTERNAL_CLAUDE_PROMPT_STRATEGY_ENV, INTERNAL_DISABLED_COMPATIBILITY_GATES_ENV, INTERNAL_POLICY_MODE_ENV, INTERNAL_PROVIDER_IMPLEMENTATIONS_ENV, MANAGED_RUNTIME_CONVERGENCE_COMPATIBILITY_GATE, MANAGED_RUNTIME_SETTINGS_SCHEMA_VERSION, resolveDisabledDefaultCompatibilityGates, resolveManagedRuntimeSettingsSnapshot, serializeManagedRuntimeSettingsSnapshot, normalizeInternalProviderImplementationOverrides, } from './compatibility-gates.js';
11
11
  import { DEFAULT_PROVIDER_COMMAND_CONFIG, hasLegacyClaudeOneShotArgs, loadConfigFromEnv, } from './config.js';
12
12
  import { hasManagedLocalConfig, loadLocalConfigGenerateSpec, materializeLocalConfig, parseGenerateConfigSpec, resolveLocalConfigLayout, } from './local-config.js';
@@ -843,19 +843,19 @@ async function shutdownManagedDaemon(rootPath, sendRequest, waitForShutdown) {
843
843
  }
844
844
  await waitForShutdown(rootPath);
845
845
  }
846
- function resolveTrustedPersistedChannelWorkspaceRoot(workspaceCollectionRoot, owningChannelId, rootPath) {
846
+ function resolveTrustedPersistedChannelWorkingFolderRoot(workingFolderCollectionRoot, owningChannelId, rootPath) {
847
847
  if (!owningChannelId || !isAbsolute(rootPath)) {
848
848
  return null;
849
849
  }
850
- const expectedWorkspacePath = resolveChannelWorkspaceDirectory(workspaceCollectionRoot, owningChannelId);
851
- if (rootPath !== expectedWorkspacePath) {
850
+ const expectedWorkingFolderPath = resolveChannelWorkingFolderDirectory(workingFolderCollectionRoot, owningChannelId);
851
+ if (rootPath !== expectedWorkingFolderPath) {
852
852
  return null;
853
853
  }
854
- return resolveChannelWorkspaceRootDirectory(workspaceCollectionRoot, owningChannelId);
854
+ return resolveChannelWorkingFolderRootDirectory(workingFolderCollectionRoot, owningChannelId);
855
855
  }
856
- async function discoverManagedWorkspaceRootsForPurge(rootPath, processEnv) {
857
- const trustedWorkspaceCollectionRoots = new Set([
858
- resolveManagedWorkspaceCollectionRoot(undefined, processEnv),
856
+ async function discoverManagedWorkingFolderRootsForPurge(rootPath, processEnv) {
857
+ const trustedWorkingFolderCollectionRoots = new Set([
858
+ resolveManagedWorkingFolderCollectionRoot(undefined, processEnv),
859
859
  ]);
860
860
  const managedStateRoot = resolveManagedStateRoot(rootPath);
861
861
  const agentStateEntries = await fs.readdir(managedStateRoot, { withFileTypes: true }).catch((error) => {
@@ -864,7 +864,7 @@ async function discoverManagedWorkspaceRootsForPurge(rootPath, processEnv) {
864
864
  }
865
865
  throw error;
866
866
  });
867
- const workspaceRoots = new Set();
867
+ const workingFolderRoots = new Set();
868
868
  for (const agentStateEntry of agentStateEntries) {
869
869
  if (!agentStateEntry.isDirectory()) {
870
870
  continue;
@@ -900,43 +900,43 @@ async function discoverManagedWorkspaceRootsForPurge(rootPath, processEnv) {
900
900
  if (!isRecord(parsed) || typeof parsed.channelId !== 'string' || !isRecord(parsed.resolvedWorkspace)) {
901
901
  continue;
902
902
  }
903
- const resolvedWorkspace = parsed.resolvedWorkspace;
904
- if ((resolvedWorkspace.authority !== 'channel'
905
- && resolvedWorkspace.authority !== 'task-thread-scratch'
906
- && resolvedWorkspace.authority !== 'task-execution-target')
907
- || typeof resolvedWorkspace.rootPath !== 'string'
908
- || !isAbsolute(resolvedWorkspace.rootPath)) {
903
+ const resolvedWorkingFolder = parsed.resolvedWorkspace;
904
+ if ((resolvedWorkingFolder.authority !== 'channel'
905
+ && resolvedWorkingFolder.authority !== 'task-thread-scratch'
906
+ && resolvedWorkingFolder.authority !== 'task-execution-target')
907
+ || typeof resolvedWorkingFolder.rootPath !== 'string'
908
+ || !isAbsolute(resolvedWorkingFolder.rootPath)) {
909
909
  continue;
910
910
  }
911
- for (const workspaceCollectionRoot of trustedWorkspaceCollectionRoots) {
912
- if (resolvedWorkspace.authority === 'channel') {
913
- if (typeof resolvedWorkspace.owningChannelId !== 'string'
914
- || resolvedWorkspace.owningChannelId.length === 0) {
911
+ for (const workingFolderCollectionRoot of trustedWorkingFolderCollectionRoots) {
912
+ if (resolvedWorkingFolder.authority === 'channel') {
913
+ if (typeof resolvedWorkingFolder.owningChannelId !== 'string'
914
+ || resolvedWorkingFolder.owningChannelId.length === 0) {
915
915
  continue;
916
916
  }
917
- const trustedChannelWorkspaceRoot = resolveTrustedPersistedChannelWorkspaceRoot(workspaceCollectionRoot, resolvedWorkspace.owningChannelId, resolvedWorkspace.rootPath);
918
- if (!trustedChannelWorkspaceRoot) {
917
+ const trustedChannelWorkingFolderRoot = resolveTrustedPersistedChannelWorkingFolderRoot(workingFolderCollectionRoot, resolvedWorkingFolder.owningChannelId, resolvedWorkingFolder.rootPath);
918
+ if (!trustedChannelWorkingFolderRoot) {
919
919
  continue;
920
920
  }
921
- workspaceRoots.add(trustedChannelWorkspaceRoot);
921
+ workingFolderRoots.add(trustedChannelWorkingFolderRoot);
922
922
  break;
923
923
  }
924
- if (resolvedWorkspace.authority === 'task-thread-scratch') {
925
- const expectedWorkspacePath = resolveTaskThreadScratchWorkspaceDirectory(workspaceCollectionRoot, parsed.channelId);
926
- if (resolvedWorkspace.rootPath !== expectedWorkspacePath) {
924
+ if (resolvedWorkingFolder.authority === 'task-thread-scratch') {
925
+ const expectedWorkingFolderPath = resolveTaskThreadScratchWorkingFolderDirectory(workingFolderCollectionRoot, parsed.channelId);
926
+ if (resolvedWorkingFolder.rootPath !== expectedWorkingFolderPath) {
927
927
  continue;
928
928
  }
929
- workspaceRoots.add(resolveChannelWorkspaceRootDirectory(workspaceCollectionRoot, parsed.channelId));
929
+ workingFolderRoots.add(resolveChannelWorkingFolderRootDirectory(workingFolderCollectionRoot, parsed.channelId));
930
930
  break;
931
931
  }
932
- if (resolvedWorkspace.authority !== 'task-execution-target') {
932
+ if (resolvedWorkingFolder.authority !== 'task-execution-target') {
933
933
  continue;
934
934
  }
935
935
  continue;
936
936
  }
937
937
  }
938
938
  }
939
- return [...workspaceRoots].sort((left, right) => left.localeCompare(right));
939
+ return [...workingFolderRoots].sort((left, right) => left.localeCompare(right));
940
940
  }
941
941
  export async function cleanupManagedRuntime(options, deps = {}) {
942
942
  const sendRequest = deps.sendRequest ?? sendManagedDaemonRequest;
@@ -974,8 +974,8 @@ export async function cleanupManagedRuntime(options, deps = {}) {
974
974
  await waitForShutdown(resolved.rootPath);
975
975
  }
976
976
  if (options.purge === true) {
977
- for (const workspaceRoot of await discoverManagedWorkspaceRootsForPurge(resolved.rootPath, options.processEnv ?? process.env)) {
978
- await fs.rm(workspaceRoot, { recursive: true, force: true });
977
+ for (const workingFolderRoot of await discoverManagedWorkingFolderRootsForPurge(resolved.rootPath, options.processEnv ?? process.env)) {
978
+ await fs.rm(workingFolderRoot, { recursive: true, force: true });
979
979
  }
980
980
  await removeRuntimeRoot(resolved.rootPath);
981
981
  }