// src/server/constants.ts
var MASTRA_RESOURCE_ID_KEY = "mastra__resourceId";
var MASTRA_THREAD_ID_KEY = "mastra__threadId";
var WORKSPACE_TOOLS_PREFIX = "mastra_workspace";
var WORKSPACE_TOOLS = {
  FILESYSTEM: {
    READ_FILE: `${WORKSPACE_TOOLS_PREFIX}_read_file`,
    WRITE_FILE: `${WORKSPACE_TOOLS_PREFIX}_write_file`,
    EDIT_FILE: `${WORKSPACE_TOOLS_PREFIX}_edit_file`,
    LIST_FILES: `${WORKSPACE_TOOLS_PREFIX}_list_files`,
    DELETE: `${WORKSPACE_TOOLS_PREFIX}_delete`,
    FILE_STAT: `${WORKSPACE_TOOLS_PREFIX}_file_stat`,
    MKDIR: `${WORKSPACE_TOOLS_PREFIX}_mkdir`,
    GREP: `${WORKSPACE_TOOLS_PREFIX}_grep`
  },
  SANDBOX: {
    EXECUTE_COMMAND: `${WORKSPACE_TOOLS_PREFIX}_execute_command`
  },
  SEARCH: {
    SEARCH: `${WORKSPACE_TOOLS_PREFIX}_search`,
    INDEX: `${WORKSPACE_TOOLS_PREFIX}_index`
  }
};
async function resolveDynamicValue(value, context, safeDefault) {
  if (value === void 0) return safeDefault;
  if (typeof value === "boolean") return value;
  if (!context) return safeDefault;
  try {
    return await value(context);
  } catch (error) {
    console.warn("[Workspace Tools] Dynamic config function threw, using safe default:", error);
    return safeDefault;
  }
}
async function resolveToolConfig(toolsConfig, toolName, context) {
  let enabled = true;
  let requireApproval = false;
  let requireReadBeforeWrite;
  if (toolsConfig) {
    if (toolsConfig.enabled !== void 0) {
      enabled = toolsConfig.enabled;
    }
    if (toolsConfig.requireApproval !== void 0) {
      requireApproval = toolsConfig.requireApproval;
    }
    const perToolConfig = toolsConfig[toolName];
    if (perToolConfig) {
      if (perToolConfig.enabled !== void 0) {
        enabled = perToolConfig.enabled;
      }
      if (perToolConfig.requireApproval !== void 0) {
        requireApproval = perToolConfig.requireApproval;
      }
      if (perToolConfig.requireReadBeforeWrite !== void 0) {
        requireReadBeforeWrite = perToolConfig.requireReadBeforeWrite;
      }
    }
  }
  return {
    enabled: await resolveDynamicValue(enabled, context, false),
    requireApproval: await resolveDynamicValue(requireApproval, context, true),
    requireReadBeforeWrite: requireReadBeforeWrite !== void 0 ? await resolveDynamicValue(requireReadBeforeWrite, context, true) : void 0
  };
}

export { MASTRA_RESOURCE_ID_KEY, MASTRA_THREAD_ID_KEY, WORKSPACE_TOOLS, resolveToolConfig };
//# sourceMappingURL=chunk-JVQ5EXNJ.js.map
//# sourceMappingURL=chunk-JVQ5EXNJ.js.map