Files
openclaw/scripts/e2e/parallels/agent-workspace.ts
2026-07-17 03:41:32 +01:00

58 lines
1.6 KiB
TypeScript

// Agent Workspace script supports OpenClaw repository automation.
interface AgentWorkspaceScriptOptions {
legacySetupState?: boolean;
}
export function posixAgentWorkspaceScript(
purpose: string,
options: AgentWorkspaceScriptOptions = {},
): string {
const legacySetupState =
options.legacySetupState === false
? ""
: `cat > "$workspace/.openclaw/workspace-state.json" <<'STATE_EOF'
{
"version": 1,
"setupCompletedAt": "2026-01-01T00:00:00.000Z"
}
STATE_EOF
`;
return `set -eu
workspace="\${OPENCLAW_WORKSPACE_DIR:-$HOME/.openclaw/workspace}"
mkdir -p "$workspace/.openclaw"
cat > "$workspace/IDENTITY.md" <<'IDENTITY_EOF'
# Identity
- Name: OpenClaw
- Purpose: ${purpose}
IDENTITY_EOF
${legacySetupState}rm -f "$workspace/BOOTSTRAP.md"`;
}
export function windowsAgentWorkspaceScript(
purpose: string,
options: AgentWorkspaceScriptOptions = {},
): string {
const legacySetupState =
options.legacySetupState === false
? ""
: `@'
{
"version": 1,
"setupCompletedAt": "2026-01-01T00:00:00.000Z"
}
'@ | Set-Content -Path (Join-Path $stateDir 'workspace-state.json') -Encoding UTF8
`;
return `$workspace = $env:OPENCLAW_WORKSPACE_DIR
if (-not $workspace) { $workspace = Join-Path $env:USERPROFILE '.openclaw\\workspace' }
$stateDir = Join-Path $workspace '.openclaw'
New-Item -ItemType Directory -Path $stateDir -Force | Out-Null
@'
# Identity
- Name: OpenClaw
- Purpose: ${purpose}
'@ | Set-Content -Path (Join-Path $workspace 'IDENTITY.md') -Encoding UTF8
${legacySetupState}Remove-Item (Join-Path $workspace 'BOOTSTRAP.md') -Force -ErrorAction SilentlyContinue`;
}