Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions apps/worker/src/commands/__tests__/setup.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions apps/worker/src/commands/resume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export async function resume(runId: number): Promise<boolean> {
repoPaths,
repoLocalSkills,
workspaceReadinessWarnings,
backgroundEnvironmentSetup,
callbacks: defaultCallbacks,
context,
logger,
Expand Down Expand Up @@ -96,6 +97,7 @@ export async function resume(runId: number): Promise<boolean> {
repoPaths,
repoLocalSkills,
workspaceReadinessWarnings,
backgroundEnvironmentSetup,
orgAgentInstructions: jobContext.orgAgentInstructions,
styleGuidance: jobContext.styleGuidance,
agentInstructions:
Expand Down
2 changes: 2 additions & 0 deletions apps/worker/src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export async function run({
repoPaths,
repoLocalSkills,
workspaceReadinessWarnings,
backgroundEnvironmentSetup,
cancelSignal,
callbacks,
context,
Expand All @@ -76,6 +77,7 @@ export async function run({
repoPaths,
repoLocalSkills,
workspaceReadinessWarnings,
backgroundEnvironmentSetup,
cancelSignal,
orgAgentInstructions: jobContext.orgAgentInstructions,
styleGuidance: jobContext.styleGuidance,
Expand Down
29 changes: 28 additions & 1 deletion apps/worker/src/commands/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
installOrganizationEnvironmentSkills,
executeOrganizationEnvironmentRepositoryCommands,
setupOrganizationEnvironment,
EnvironmentSetupStatusWriter,
} from './setup/index';

export type SetupMode = 'full' | 'directDispatch';
Expand Down Expand Up @@ -395,6 +396,17 @@ async function runSetup({
return;
}

// Publish the command plan to <workspace>/.roomote/setup-status.json
// before the agent can start, so the sandbox always has an observable
// answer to "has environment setup finished?". Created for every
// environment workspace — including Docker-only or command-less
// setups — because the sandbox instruction and the settle notification
// point the agent at this file and must be able to rely on it existing.
const setupStatusWriter = new EnvironmentSetupStatusWriter(
initializeRepositoriesResult.workspacePath,
);
setupStatusWriter.initialize(workspace.environmentConfig.repositories);

if (!backgroundEnvironmentSetup) {
const warnings =
(await setupOrganizationEnvironment(logger, {
Expand All @@ -403,6 +415,8 @@ async function runSetup({
userEnvVars: workspaceOptions.userEnvVars,
preparedWorkspace: initializeRepositoriesResult,
continueRepositoryCommandFailures: continueEnvironmentSetupFailures,
setupStatusWriter,
recordPhase,
})) ?? [];

environmentSetupWarnings.push(...warnings);
Expand All @@ -423,14 +437,27 @@ async function runSetup({
'setupOrganizationEnvironmentCommands (background)',
async () => {
try {
await backgroundDockerProjectsTask;
const dockerProjectWarnings =
(await backgroundDockerProjectsTask) ?? [];

// Reflect Docker project failures in the workspace status file
// so it never reports a clean `completed` when part of
// environment setup went wrong.
if (dockerProjectWarnings.length > 0) {
setupStatusWriter?.addWarnings(
dockerProjectWarnings.map((warning) => warning.message),
);
}

const warnings =
await executeOrganizationEnvironmentRepositoryCommands(logger, {
environment: workspace,
envVars: workspaceOptions.envVars,
userEnvVars: workspaceOptions.userEnvVars,
preparedWorkspace: initializeRepositoriesResult,
continueRepositoryCommandFailures: true,
setupStatusWriter,
recordPhase,
});

environmentSetupWarnings.push(...warnings);
Expand Down
6 changes: 6 additions & 0 deletions apps/worker/src/commands/setup/__tests__/workspace.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/worker/src/commands/setup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export {
installOrganizationEnvironmentSkills,
executeOrganizationEnvironmentRepositoryCommands,
setupOrganizationEnvironment,
EnvironmentSetupStatusWriter,
} from './workspace';
1 change: 1 addition & 0 deletions apps/worker/src/commands/setup/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export {
executeOrganizationEnvironmentRepositoryCommands,
setupOrganizationEnvironment,
} from './workspace/environment-commands';
export { EnvironmentSetupStatusWriter } from './workspace/setup-status';
export { initializeRepositories } from './workspace/repositories';
export { initializeDockerProjects } from './workspace/docker-projects';
export {
Expand Down
Loading
Loading