From 086189c6a636e8758ff483d46e358cc2238a4b58 Mon Sep 17 00:00:00 2001 From: Ovidiu Rusu Date: Mon, 28 Apr 2025 13:42:53 +0300 Subject: [PATCH] Added SEMA4AI_FILE_MANAGEMENT_URL environment variable on action run --- docs/changelog.md | 2 ++ sema4ai/vscode-client/src/activities.ts | 23 ++++++++++++++++++++--- sema4ai/vscode-client/src/debugger.ts | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 676a378c..8278ed05 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,7 @@ ## Unreleased +- Added `SEMA4AI_FILE_MANAGEMENT_URL` environment variable when running actions to `file:///devdata/chat-files`. + ## New in 2.11.0 (2025-03-11) - Pass datasource `name` and `engine` parameters to `sema4ai-data.database.add` call diff --git a/sema4ai/vscode-client/src/activities.ts b/sema4ai/vscode-client/src/activities.ts index 84bd969f..daa094ea 100644 --- a/sema4ai/vscode-client/src/activities.ts +++ b/sema4ai/vscode-client/src/activities.ts @@ -52,6 +52,8 @@ import { import { createActionPackage } from "./robo/actionPackage"; import { createAgentPackage } from "./robo/agentPackage"; import { langServer } from "./extension"; +import * as path from "path"; +import * as fs from "fs"; export interface ListRobotSelectionOpts { showTaskPackages: boolean; @@ -494,7 +496,7 @@ export async function uploadRobot(robot?: LocalPackageMetadataInfo) { let refresh = false; SELECT_OR_REFRESH: do { let workspaceSelection = await selectWorkspace( - "Please select a Workspace to upload ‘" + robot.name + "’ to.", + "Please select a Workspace to upload '" + robot.name + "' to.", refresh ); if (workspaceSelection === undefined) { @@ -605,7 +607,7 @@ export async function uploadRobot(robot?: LocalPackageMetadataInfo) { let selectedItem: QuickPickItemWithAction = await showSelectOneQuickPick( updateExistingCaptions, - "This will overwrite the robot ‘" + robotInfo.name + "’ on Control Room. Are you sure? " + "This will overwrite the robot '" + robotInfo.name + "' on Control Room. Are you sure? " ); // robot.language-server.python @@ -892,7 +894,8 @@ export async function createPackage() { * tasks will use `updateLaunchEnvironment`). */ export async function updateLaunchEnvironmentCommonTasksAndActions( - environment: Record + environment: Record, + targetYaml?: string ): Promise> { const newEnv = applyOutViewIntegrationEnvVars(environment); @@ -901,6 +904,20 @@ export async function updateLaunchEnvironmentCommonTasksAndActions( newEnv["SEMA4AI_CREDENTIAL_API"] = externalApiUrl; } + if (targetYaml) { + const packageDir = path.dirname(targetYaml); + const devdataPath = path.join(packageDir, "devdata", "chat-files"); + + try { + if (!fs.existsSync(devdataPath)) { + fs.mkdirSync(devdataPath, { recursive: true }); + } + newEnv["SEMA4AI_FILE_MANAGEMENT_URL"] = `file://${devdataPath}`; + } catch (error) { + logError("Error creating devdata/chat-files directory", error, "ERR_CREATE_DEVDATA_DIR"); + } + } + return newEnv; } diff --git a/sema4ai/vscode-client/src/debugger.ts b/sema4ai/vscode-client/src/debugger.ts index 70af5e4c..acf7e850 100644 --- a/sema4ai/vscode-client/src/debugger.ts +++ b/sema4ai/vscode-client/src/debugger.ts @@ -135,7 +135,7 @@ export class RobocorpCodeDebugConfigurationProvider implements DebugConfiguratio } if (isActionPackageLaunch) { - env = await updateLaunchEnvironmentCommonTasksAndActions(env); + env = await updateLaunchEnvironmentCommonTasksAndActions(env, debugConfiguration.package); // Vault/work-items features not available in action server at this point. } else { // Resolve environment (updates the environment to add vault